예제 #1
0
 public Player(ClientConnection connection, CharacterData characterData) : base(ObjectFamily.Player)
 {
     Connection = connection;
     DatabaseCharacterData = characterData;
     Position = new Position(new Vector3(characterData.PositionX, characterData.PositionY, characterData.PositionZ));
     Ai = new PlayerAI(this, CfgCore.Default.VisibleRangeDistance);
 }
예제 #2
0
        public void EndLoad(ClientConnection connection)
        {
            lock (_lOnline)
            {
                if (connection.ActivePlayer != null)
                {
                    var player = connection.ActivePlayer;
                    if(!_onlineCharacters.ContainsKey(player.GameSessionId))
                        _onlineCharacters.Add(player.GameSessionId, player);

                    connection.ActivePlayer.PlayerActions += (action, parameters) =>
                    {
                        switch (action)
                        {
                           case Player.PlayerAction.Logout:
                                if (_onlineCharacters.ContainsKey(player.GameSessionId))
                                {
                                    _onlineCharacters.Remove(player.GameSessionId);
                                    Log.Debug($"Player:{player.DatabaseCharacterData.CharacterName} has left the world");
                                }
                                break;

                            case Player.PlayerAction.Chat:
                                ChatProcessor.HandleChatMessage(connection, parameters);
                                break;
                        }
                    };
                }
            }
        }
예제 #3
0
        public void Process(ClientConnection connection, string[] message)
        {
            Core.Act(s =>
            {
                var playersList = s.CharacterProcessor.OnlineList;

                if (message.Length > 1)
                {
                    foreach (var selectedName in message)
                    {
                        var result = playersList.FirstOrDefault(
                                p => p.DatabaseCharacterData.CharacterName == selectedName);

                        if (result == null)
                            new SpChat($"[Admin processor] cannot found {selectedName} player", connection.ActivePlayer.GameSessionId,
                                connection.ActivePlayer.DatabaseCharacterData.CharacterName, ChatType.Notice)
                                .Send(connection);
                        else
                            result.Connection.CloseConnection();
                    }
                }
                if (message.Length == 1)
                {
                    var select =
                        playersList.FirstOrDefault(p => p.DatabaseCharacterData.CharacterName == message[0]);
                    if (select != null)
                        select.Connection.CloseConnection();
                    else
                        new SpChat($"[Admin processor] cannot found {message[0]} player",
                            connection.ActivePlayer.GameSessionId, connection.ActivePlayer.DatabaseCharacterData.CharacterName, ChatType.Notice).Send(connection);
                }
            });
        }
예제 #4
0
 public void Dispose()
 {
     Release(); //release factories
     Action(PlayerAction.Logout); //handle logout action for processors
     CancelTokenSource = null;
     Connection = null;
     DatabaseCharacterData = null;
 }
예제 #5
0
        public void Process(ClientConnection connection, string[] message)
        {
            Core.Act(s =>
            {
                var onlineCount = s.CharacterProcessor.OnlineList.Count;


                new SpChat($"Players online:{onlineCount}", connection.ActivePlayer.GameSessionId, connection.ActivePlayer.DatabaseCharacterData.CharacterName, ChatType.Public).Send(connection);
            });
        }
예제 #6
0
        public void Process(ClientConnection connection, string[] message)
        {
            var player = new Player(connection, connection.ActivePlayer.DatabaseCharacterData)
            {
                GameSessionId = 1135620,
                Position =
                    new Position(new Vector3(connection.ActivePlayer.Position.Point.X,
                        connection.ActivePlayer.Position.Point.Y, connection.ActivePlayer.Position.Point.Z))
            };

            new SBpPlayerSpawn.SpSpawnPlayer(player).Send(connection);
            new SBpPlayerSpawn.SpSetPlayerName(player).Send(connection);
            new SBpPlayerSpawn.SpSetPlayerFamilyName(player, connection.Account).Send(connection);
            new SBpPlayerSpawn.SpSetPlayerEquipment(player).Send(connection);
            new SpCharacterCustimozationData(player).Send(connection);
            new SpCharacterCustomizationResponse(player).Send(connection);            
        }
예제 #7
0
        public void EndLoad(ClientConnection connection)
        {
            var player = connection.ActivePlayer;
            lock (_worldLock)
            {
                var area = _world[1][0];

                area.PlaceToArea(player);
                player.Area = area;

                player.PlayerActions += (action, parameters) =>
                {
                    switch (action)
                    {
                       case Player.PlayerAction.Logout:
                            player.Area.RemoveFromArea(player);
                            player.Area = null;
                            break;
                    }
                };
            }
        }
예제 #8
0
        public void AuthProcess(ClientConnection client, string token)
        {
            using (var db = _lsDbFactory.OpenSession())
            {
                var model = db.QueryOver<AccountData>().Where(p => p.GameHash == token).Take(1).SingleOrDefault(); //get account data by token
                if (model == null)
                {
                    client.CloseConnection();
                    return;
                }
                if (model.ExpireTime < DateTime.Now)
                {
                    client.CloseConnection();
                    return;
                }

                client.Account = model;

                new SpUnk().Send(client, false);
                new SpUnk2().Send(client, false);

                Core.Act(s => s.LobbyProcessor.GetCharacterList(client));
            }
        }
예제 #9
0
        //8BD7D1ED85BE3F01 uid
        //07EC0901 sess id

        public void EnterOnWorldProcess(ClientConnection connection, int gameSession)
        {
            var sessionId = BitConverter.GetBytes(connection.ActivePlayer.GameSessionId).ToHex();
            var uid = BitConverter.GetBytes(connection.ActivePlayer.Uid).ToHex();

            new SpUpdateLevel(connection.ActivePlayer).Send(connection);

            new SpRaw(sessionId +
                      "60E316000000000000007A440000000000000000000000000000400D0300400D0300400D0300400D0300", 0x0f73).SendRaw(connection);
            new SpRaw("01" +
                      sessionId +
                      "00004040000080400000803F0000803F00004040000000000000000060E3160000000000010000000000C040000000000000000040420F00000000000000000000000000", 0x0f76).SendRaw(connection);
            new SpRaw("000000000000000000000000", 0x0f78).SendRaw(connection);
            new SpRaw("00000000000000000000", 0x0f7b).SendRaw(connection);
            new SpRaw("0000000000000000", 0x0f7f).SendRaw(connection);
            new SpRaw("02E8030000C8000000E8030000", 0x0eb7).SendRaw(connection);
            new SpRaw(sessionId +
                      "0500000005000000050000000A0000000A0000000A0000000000000005000000000000000500000000000000050000000000000005000000", 0x0f75).SendRaw(connection);
            new SpRaw(uid +
                      "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 0x0d27).SendRaw(connection);
            new SpRaw("00000000000000000000000000000000000000000000000000", 0x0e81).SendRaw(connection);
            new SpRaw("00000000000000000000", 0x0e84).SendRaw(connection);
            new SpRaw(sessionId +
                      "0000000000000000", 0x0d3f).SendRaw(connection);
            new SpRaw("01000000070006003300000000000000", 0x0e94).SendRaw(connection);
            new SpRaw("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 0x0e57).SendRaw(connection);
            new SpRaw("07007F020000B2020000C8020000D2020000050000001C000000F0020000", 0x10c1).SendRaw(connection);
            new SpRaw("00000000" +
                      sessionId, 0x0cdf).SendRaw(connection);
            new SpRaw("1900AA7501000000679C010000004F9C0100000029A001000000699C01000000519C010000005DC3010000005D9C01000000649C01000000669C01000000689C010000006C9C01000000839C01000000C19C010000009B9E01000000129F01000000149F0100000031A00100000037A0010000003BA0010000004CA0010000004DA0010000004EA00100000078A00100000057C301000000", 0x0ebb).SendRaw(connection);
            new SpRaw("00001B00290000000000000000000000000001000000010000000000000000004200000000000000000000000000020000000000000000000000000004000000000000000000000000000600000000000000000000000000170000000000000000000000000018000000000000000000000000002B000000000000000000000000003D00000001000000000000000000660000000100000000000000000067000000010000000000000000008B000000000000000000000000008E0000000000000000000000000090000000000000000000000000009B00000000000000000000000000A400000000000000000000000000C9000000000000000000000000002D010000010000000000000000002F0100000000000000000000000035010000000000000000000000004301000000000000000000000000910100000100000000000000000092010000010000000000000000009A01000000000000000000000000B701000000000000000000000000B801000000000000000000000000", 0x0e96).SendRaw(connection);
            new SpRaw("0000", 0x0e99).SendRaw(connection);
            new SpRaw("0000", 0x0ec0).SendRaw(connection);
            new SpRaw("0400660000000200000000170000000000DE5A895600000000670000000200000000170000000000DE5A895600000000910100000200000000170000000000DE5A895600000000920100000200000000170000000000DE5A895600000000", 0x0ec0).SendRaw(connection);
            new SpRaw("0000", 0x0ec0).SendRaw(connection);
            new SpRaw("000000000300000000000000", 0x0d2c).SendRaw(connection);
            new SpRaw("01003F0802000000010000006675615600000000", 0x0e87).SendRaw(connection);
            new SpRaw("0000", 0x0e88).SendRaw(connection);
            new SpRaw("4A00A80F00000100000028000000020000001000000001000000D20B000001000000D20F0000020000001200000001000000A70F00000100000027000000020000001F000000010000002600000003000000B90B000001000000B90F0000010000003900000001000000B10F0000010000003100000003000000A917000003000000A90F0000020000002900000002000000C40F000001000000440000000100000088000000010000004800000001000000A50F000001000000A51700000100000065000000030000006D000000010000007300000001000000B70F000002000000B700000001000000770000000100000089000000010000008A000000010000009C110000010000009C00000001000000B40F000004000000B4000000010000008701000002000000FC0B000001000000BC0B000002000000C00B0000010000008217000001000000C20B000001000000CB17000001000000CB0B000002000000CF0B0000040000001710000001000000D70B000002000000D80B000001000000DD0B000003000000B20F000002000000F20B000001000000F50B000002000000FB0B000001000000A10F000001000000A20F000002000000A30F000001000000A40F000002000000AA0F000002000000AC0F000001000000AE0F000001000000B00F000001000000BA0F000003000000C60F000001000000D40F000001000000D60F00000100000019100000010000007F17000004000000E017000002000000EC1700000100000070190000010000007119000002000000791900000200000090190000020000004E1E000001000000", 0x0c6f).SendRaw(connection);
            new SpRaw("00001E00", 0x0c6e).SendRaw(connection);
            new SpRaw("0000", 0x0fdf).SendRaw(connection);
            new SpRaw("01350027000000000000000000000000002F000000000000000000000000002E000000000000000000000000002D000000000000000000000000002C000000000000000000000000002B000000000000000000000000002A00000000000000000000000000290000000000000000000000000028000000000000000000000000002600000000000000000000000000250000000000000000000000000024000000000000000000000000002300000000000000000000000000220000000000000000000000000021000000000000000000000000002000000000000000000000000000370000000000000000000000000036000000000000000000000000003500000000000000000000000000340000000000000000000000000033000000000000000000000000003200000000000000000000000000310000000000000000000000000030000000000000000000000000000F000000000000000000000000000E000000000000000000000000000D000000000000000000000000000C000000000000000000000000000B000000000000000000000000000A0000000000000000000000000009001300000000000000000000000800130000000000000000000000070013000000000000000000000006001300000000000000000000000500130000000000000000000000040013000000000000000000000003001300000000000000000000001F000000000000000000000000009F000000000000000000000000001E000000000000000000000000001D000000000000000000000000001C000000000000000000000000001B000000000000000000000000001A00000000000000000000000000190000000000000000000000000018000000000000000000000000001700000000000000000000000000160000000000000000000000000015000000000000000000000000001400000000000000000000000000110000000000000000000000000010000000000000000000000000000100000000000000000000000000", 0x10c3).SendRaw(connection);
            new SpRaw("010E00A10000000000000000000100F0E5875600000000A2000000000000000000020000000000000000007A000000000000000000A30000000000000000007B0000000000000000007C000000000000000000A0000000000000000000A4000000000000000000A500000000000000000012000000000000000000A600000000000000000013000000000000000000", 0x10c4).SendRaw(connection);
            new SpRaw("010E00A10001000000010013000000A200010000000200010000007A0001000000A300010000007B00010000007C0001000000A00001000000A40001000000A50001000000120001000000A60001000000130001000000", 0x10c5).SendRaw(connection);
            new SpRaw("01000000", 0x0c2a).SendRaw(connection);
            new SpRaw("00340B0500FCFFFF601589C8CD2E92460046D5C7601589C8CD2E92460046D5C70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000799E615DCDCCCC3D2E2EC0C7000000000000000000000000000000000000000000007FD6FEBE0000000077095EBF7FD6FEBE0000000077095EBF", 0x0bcd).SendRaw(connection);
            new SpRaw("00BC4F1200000000000000000000000000000000000000000000000000000000000000000000000000000000000001004D0B00000000E0E1A65F1800000029E2", 0x0d32).SendRaw(connection);
            new SpRaw("001C590C00FCFFFFC7F6A4C80078FFC5A6DB6B48D42DA6C80078FFC56E3D69480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E104000000000A30C925CDCCCC3D2E2EC0C700000000000000000000000000030000000000000000BB8ADD3D000000006D7F7E3FBE7FDD3D00000000957F7E3F", 0x0bcd).SendRaw(connection);
            new SpRaw("00C44F1200000000000000000000000000000000000000000000000000000000000000000000000000000000000001004D0B00000000E0E1A65F18000000FEFF", 0x0d32).SendRaw(connection);
            new SpRaw("007C580C00FCFFFF3CFD27C80078FFC5B001AD48042B28C80078FFC51F38AD4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001007000000000A30C925CDCCCC3D2E2EC0C7000000000000000000000000000300000000000000002279C63E00000000B7FB6BBF68597ABF000000009BF655BE", 0x0bcd).SendRaw(connection);
            new SpRaw("00745A1200000000000000000000000000000000000000000000000000000000000000000000000000000000000001006C0B00000000E0E1A65F18000000FEFF", 0x0d32).SendRaw(connection);
            new SpRaw("00FC541200000000000000000000000000000000000000000000000000000000000000000000000000000000000001005C0B00000000E0E1A65F18000000FEFF", 0x0d32).SendRaw(connection);
            new SpRaw("00844F1200000000000000000000000000000000000000000000000000000000000000000000000000000000000001004C0B00000000E0E1A65F18000000FEFF", 0x0d32).SendRaw(connection);
            new SpRaw("00EC5F1200000000000000000000000000000000000000000000000000000000000000000000000000000000000001007B0B00000000E0E1A65F18000000FEFF", 0x0d32).SendRaw(connection);
            new SpRaw("010000000100" +
                      sessionId +
                      "C0100EC80080094580A6D847046788BE0000000080BF763F190000000000164300001643C2DEFFFFFFFFFFFFC2DEFFFFFFFFFFFF0A946DE49500000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000088590D0000000000000000000000000000000000000000000000000000000000FFA6190000000000000000000000000000000000000000000000000000000000FFA6190000000000000000000000000000000000000000000000000000000000FFA6190000000000000000000000000000000000000000000000000000000000000000FE00000000000000006F0917000000000001000000" +
                      uid +
                      "010000000100000000000000010100000000000000000000000000000000000005FCFFFF250000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFFFF00010000000000000003000000000000000000000000000000000000000000000037CA00000000000000000000000000000000000000F8FFFF00000000000000000000000000F8FFFF0000000000000000000000000200000000000000000000000000", 0x0bb9).SendRaw(connection);
            new SpRaw("010000010100" +
                      sessionId +
                      "C0100EC80080094580A6D847046788BE0000000080BF763F190000000000164300001643C2DEFFFFFFFFFFFFC2DEFFFFFFFFFFFF38946DE495000000000000000000000000000000000300000000000000000000000010302F0000000000000000000000000000000000000000000000000000000000000000000C4B3500000000000000000000000000000000000000000000000000000000000A442D00000000000000000000000000000000000000000000000000000000000C352200000000000000000000000000000000000000000000000000000000000D2A190000000000000000000000000000000000000000000000000000000000074129000000000000000000000000000000000000000000000000000000000008432C0000000000000000000000000000000000000000000000000000000000144E3900000000000000000000000000000000000000000000000000000000000D462D00000000000000000000000000000000000000000000000000000000000D372200000000000000000000000000000000000000000000000000000000000B412A00000000000000000000000000000000000000000000000000000000000C29180000000000000000000000000000000000000000000000000000000000072B190000000000000000000000000000000000000000000000000000000000105E44000000000000000000000000000000000000000000000000000000000009301C0000000000000000000000000000000000000000000000000000000000051F530000000000000000000000000000000000000000000000000000000000043F2800000000000000000000000000000000000000000000000000000000000A3E2700000000000000000000000000000000000000000000000000000000000E382500000000000000000000000000000000000000000000000000000000000C2C1A00000000000000000000000000000000000000000000000000000000000C4C340000000000000000000000000000000000000000000000000000000000063C2500000000000000000000000000000000000000000000000000000000000959400000000000000000000000000000000000000000000000000000000000083F6D0000000000000000000000000000000000000000000000000000000000083E27000000000000000000000000000000000000000000000000000000000009331EFF00000000000000006F0917000000000001000000" +
                      uid +
                      "010000000100000000000000010100000000000000000000000000000000000005FCFFFF250000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFFFF00010000000000000003000000000000000000000000000000000000000000000037CA000000000000000000000000000000000000FFFEFFFF000000000000000000000000FFFFFFFF0000000000000000000000000200000000000000000000000000", 0x0bb9).SendRaw(connection);
            new SpRaw("00000000000000000000000000000000000000000000000000000000000000000000000000000000", 0x0c0a).SendRaw(connection);
            new SpRaw(sessionId +
                      "6F09170000000000" +
                      uid +
                      "DE5A89560000000000000000000000002100070054006F006F0048006F007400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000C2DEFFFFFFFFFFFF49006E004300750062006500460054005700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028001900", 0x0d41).SendRaw(connection);

            new SpCharacterCustimozationData(connection.ActivePlayer).Send(connection);

            Core.Act(s =>
            {
                s.CharacterProcessor.EndLoad(connection);
                s.WorldProcessor.EndLoad(connection);
            });
        }
예제 #10
0
        public void PrepareForEnterOnWorld(ClientConnection connection, long characterId)
        {
            var player = new Player(connection, connection.Characters.First(s => s.CharacterId == characterId))
            {
                GameSessionId = _gameSessionFactory.Next(),
            };

            using (var db = _gsDbFactory.OpenSession())
            {
                var daoItems = db.QueryOver<CharacterItem>().Where(i => i.CharacterId == characterId).List();
                var items = new List<CharacterItem>();
                var equipItems = new List<CharacterItem>();

                foreach (var it in daoItems)
                {
                    if (it.StorageType == (int) StorageType.Equipment)
                        equipItems.Add(it);
                    if (it.StorageType == (int) StorageType.Inventory)
                        items.Add(it);
                }
                
                player.Inventory = new InventoryStorage(items.ToDictionary<CharacterItem, short, AStorageItem>(e => (short)(e.Slot + 1), e => new InventoryItem(e.ItemId, e.Count) {StorageType = (StorageType) e.StorageType}), 48);
                player.Equipment = new EquipmentStorage(equipItems.ToDictionary<CharacterItem, short, AStorageItem>(e => (short)(e.Slot + 1), e => new InventoryItem(e.ItemId, e.Count) {StorageType = (StorageType) e.StorageType}), 48);
            }

            connection.ActivePlayer = player;
            connection.ActivePlayer.PlayerActions += (action, parameters) =>
            {
                switch (action)
                {
                    case Player.PlayerAction.Logout:
                        if (connection.ActivePlayer != null)
                        {
                            UpdateCharacter(connection);
                            _gameSessionFactory.ReleaseUniqueInt(connection.ActivePlayer.GameSessionId);
                        }
                        break;                       
                }
            };

            var sessionId = BitConverter.GetBytes(connection.ActivePlayer.GameSessionId).ToHex();

            new SpRaw("000000000000000000000000", 0x0cf1).SendRaw(connection);
            new SpRaw("3401620010FC266F38020100000000000000630010FC266F38020100000000000000680010FC266F380201000000000000006E0010FC266F38020100000000000000720010FC266F38020100000000000000850010FC266F38020100000001000000960010FC266F380201000000000000009E0010FC266F38020100000000000000AD0010FC266F38020100000000000000AE0010FC266F38020100000000000000AF0010FC266F38020100000000000000B00010FC266F38020100000000000000B20010FC266F38020100000000000000B30010FC266F38020400000001000000BA0010FC266F38020100000000000000C30010FC266F38020100000000000000C80010FC266F38020100000000000000CA0010FC266F38020100000000000000CF0010FC266F38020100000000000000D70010FC266F38020100000000000000DB0010FC266F38020100000001000000DD0010FC266F38020100000001000000E20010FC266F38020100000000000000E30010FC266F38020100000001000000E50010FC266F38020100000000000000E70010FC266F38020100000000000000E80010FC266F38020100000000000000EA0010FC266F38020100000000000000EC0010FC266F38020100000000000000EE0010FC266F38020100000000000000F80010FC266F38020100000001000000FB0010FC266F38020100000000000000100110FC266F38020100000000000000160110FC266F38020100000000000000180110FC266F38020100000001000000190110FC266F380201000000000000001A0110FC266F380201000000000000001E0110FC266F38020100000000000000250110FC266F38020100000001000000280110FC266F380201000000000000002D0110FC266F38020100000000000000330110FC266F38020100000000000000340110FC266F38020100000000000000350110FC266F38020100000000000000370110FC266F38020100000000000000390110FC266F380201000000000000003B0110FC266F380201000000000000003D0110FC266F38020100000000000000440110FC266F380201000000000000004F0110FC266F38020100000000000000560110FC266F380201000000000000005B0110FC266F380201000000010000005C0110FC266F380201000000000000005E0110FC266F38020100000001000000600110FC266F38020100000001000000640110FC266F38020100000000000000650110FC266F38020100000000000000680110FC266F380201000000000000006B0110FC266F380201000000000000006C0110FC266F38020100000001000000710110FC266F38020100000000000000730110FC266F38020100000000000000740110FC266F38020100000000000000770110FC266F38020100000000000000790110FC266F38020100000000000000800110FC266F38020200000001000000840110FC266F38020100000000000000900110FC266F38020100000000000000950110FC266F38020100000000000000960110FC266F380201000000000000009D0110FC266F38020100000001000000A00110FC266F38020100000000000000AC0110FC266F38020100000000000000AE0110FC266F38020100000000000000AF0110FC266F38020100000000000000C00110FC266F38020100000000000000C30110FC266F38020100000000000000C40110FC266F38020100000000000000C70110FC266F38020E00000001000000C90110FC266F38022600000004000000CD0110FC266F38020300000000000000D00110FC266F38020100000000000000D10110FC266F38020100000000000000DA0110FC266F38020100000000000000E60110FC266F38020100000001000000F00110FC266F38020100000000000000F60110FC266F38020100000000000000FC0110FC266F38020100000000000000FD0110FC266F38020100000000000000010210FC266F380201000000000000000D0210FC266F38020100000000000000140210FC266F38020600000000000000190210FC266F380201000000000000001A0210FC266F380201000000000000001B0210FC266F380201000000000000001C0210FC266F380201000000000000001E0210FC266F38020100000000000000200210FC266F38020100000000000000230210FC266F38020100000000000000250210FC266F38021A00000015000000260210FC266F380205000000000000002C0210FC266F38020100000001000000350210FC266F38020100000000000000470210FC266F3802D704000006000000490210FC266F380201000000000000004A0210FC266F380201000000000000004B0210FC266F380201000000000000004D0210FC266F38020100000000000000520210FC266F38020100000000000000580210FC266F38020100000001000000590210FC266F380201000000000000005D0210FC266F38020100000001000000620210FC266F38020100000000000000640210FC266F38020100000000000000650210FC266F38020100000000000000670210FC266F38020100000001000000680210FC266F380201000000000000006A0210FC266F380201000000000000006F0210FC266F38020100000000000000770210FC266F38020D000000010000007B0210FC266F380201000000000000007E0210FC266F38020200000001000000820210FC266F38020100000001000000870210FC266F38020100000000000000880210FC266F38020100000000000000960210FC266F38021B00000002000000970210FC266F38020100000000000000A20210FC266F38020100000000000000A30210FC266F38020100000000000000AA0210FC266F38020100000000000000B60210FC266F38020100000000000000BD0210FC266F38020100000000000000BE0210FC266F38020100000000000000C40210FC266F38020100000000000000C50210FC266F38020100000001000000C70210FC266F38020100000000000000D00210FC266F38020100000001000000D40210FC266F38020100000001000000D60210FC266F38020100000000000000DA0210FC266F38020100000000000000ED0210FC266F38020100000000000000EF0210FC266F38020100000001000000F00210FC266F38020100000000000000F30210FC266F38020100000000000000000310FC266F38020100000000000000010310FC266F38020100000000000000020310FC266F38020100000000000000060310FC266F38020100000000000000080310FC266F380201000000000000000B0310FC266F380211000000010000000C0310FC266F380235000000010000000D0310FC266F380201000000000000000E0310FC266F380201000000010000001C0310FC266F38020100000001000000200310FC266F38020100000000000000250310FC266F38020100000000000000260310FC266F380201000000000000002D0310FC266F38020100000000000000310310FC266F38020100000000000000390310FC266F380201000000000000003B0310FC266F38020100000000000000420310FC266F38020500000001000000430310FC266F38020100000000000000460310FC266F38020100000000000000470310FC266F38020100000000000000490310FC266F380201000000000000004B0310FC266F38020100000000000000520310FC266F38020600000000000000530310FC266F38020100000000000000560310FC266F380201000000000000005D0310FC266F38020100000000000000600310FC266F38020100000000000000630310FC266F38020100000000000000660310FC266F38020100000000000000670310FC266F380201000000000000006B0310FC266F380201000000000000006D0310FC266F380201000000010000006E0310FC266F380201000000000000006F0310FC266F38020100000000000000720310FC266F38020100000000000000730310FC266F38020100000000000000740310FC266F38020100000000000000770310FC266F38020100000000000000780310FC266F38020200000001000000790310FC266F380201000000000000007A0310FC266F38020300000000000000810310FC266F38020100000000000000840310FC266F380201000000000000008A0310FC266F380201000000000000008E0310FC266F38020100000000000000A20310FC266F38020100000000000000A70310FC266F38020200000000000000AE0310FC266F38020200000001000000AF0310FC266F38020100000000000000B00310FC266F38020100000000000000B20310FC266F38020100000001000000BC0310FC266F38020100000000000000C10310FC266F38020100000000000000C30310FC266F38020100000000000000C70310FC266F38020100000000000000C90310FC266F38020100000000000000D00310FC266F38020100000000000000D10310FC266F38020200000001000000D50310FC266F38020100000000000000D90310FC266F38020100000000000000E10310FC266F38020100000000000000E40310FC266F38020100000000000000E60310FC266F38020100000000000000EC0310FC266F38020100000000000000EE0310FC266F38020100000000000000F20310FC266F38020100000000000000F30310FC266F38020100000000000000F40310FC266F38020100000000000000F60310FC266F38020100000000000000F80310FC266F38020100000000000000010410FC266F380201000000000000000E0410FC266F38020100000001000000130410FC266F38020100000001000000150410FC266F38020100000000000000180410FC266F380224000000040000001D0410FC266F380201000000000000001F0410FC266F38020100000000000000210410FC266F38020100000000000000280410FC266F38020100000000000000320410FC266F38020100000000000000350410FC266F38020100000000000000380410FC266F38028C000000050000003D0410FC266F380201000000000000003E0410FC266F38020100000000000000400410FC266F38020100000000000000981BC9ED85BE3F0101000000000000009A1BC9ED85BE3F0108000000030000009B1BC9ED85BE3F010100000000000000A21BC9ED85BE3F010100000000000000AC1BC9ED85BE3F010100000000000000AD1BC9ED85BE3F010400000000000000AE1BC9ED85BE3F010100000000000000B11BC9ED85BE3F010100000000000000B61BC9ED85BE3F010100000000000000BA1BC9ED85BE3F010700000000000000C51BC9ED85BE3F010100000000000000C61BC9ED85BE3F010100000003000000C71BC9ED85BE3F010100000000000000C81BC9ED85BE3F010100000000000000CA1BC9ED85BE3F010200000000000000D81BC9ED85BE3F010100000000000000DB1BC9ED85BE3F010100000000000000E21BC9ED85BE3F011200000000000000E71BC9ED85BE3F010300000000000000ED1BC9ED85BE3F010400000000000000EE1BC9ED85BE3F010100000000000000F01BC9ED85BE3F010100000000000000F31BC9ED85BE3F010100000000000000F41BC9ED85BE3F010400000000000000F91BC9ED85BE3F010300000000000000051CC9ED85BE3F010200000000000000081CC9ED85BE3F010100000000000000091CC9ED85BE3F010C000000000000000D1CC9ED85BE3F0101000000000000000E1CC9ED85BE3F010400000000000000121CC9ED85BE3F0103000000000000001B1CC9ED85BE3F0102000000000000001C1CC9ED85BE3F0101000000000000001D1CC9ED85BE3F0102000000000000001E1CC9ED85BE3F010100000000000000261CC9ED85BE3F010100000000000000291CC9ED85BE3F010100000000000000331CC9ED85BE3F010200000000000000361CC9ED85BE3F010200000000000000381CC9ED85BE3F0102000000000000003A1CC9ED85BE3F0102000000000000003B1CC9ED85BE3F0105000000000000003C1CC9ED85BE3F010200000000000000411CC9ED85BE3F010100000000000000451CC9ED85BE3F0101000000000000004A1CC9ED85BE3F0102000000000000004B1CC9ED85BE3F0104000000000000004F1CC9ED85BE3F010100000000000000521CC9ED85BE3F010100000000000000531CC9ED85BE3F010100000000000000551CC9ED85BE3F010200000000000000561CC9ED85BE3F010100000000000000581CC9ED85BE3F0101000000000000005B1CC9ED85BE3F0101000000000000005C1CC9ED85BE3F0101000000000000005F1CC9ED85BE3F010100000000000000601CC9ED85BE3F010100000000000000651CC9ED85BE3F010100000000000000681CC9ED85BE3F013E000000000000006A1CC9ED85BE3F0104000000000000006C1CC9ED85BE3F010100000000000000751CC9ED85BE3F010100000000000000761CC9ED85BE3F0101000000000000007C1CC9ED85BE3F0101000000000000007E1CC9ED85BE3F010300000000000000801CC9ED85BE3F010200000000000000811CC9ED85BE3F010200000000000000831CC9ED85BE3F010500000000000000851CC9ED85BE3F010100000000000000891CC9ED85BE3F0101000000000000008A1CC9ED85BE3F0105000000000000008C1CC9ED85BE3F0101000000000000008D1CC9ED85BE3F0101000000000000008F1CC9ED85BE3F010100000000000000911CC9ED85BE3F010100000000000000951CC9ED85BE3F010100000000000000981CC9ED85BE3F0101000000000000009A1CC9ED85BE3F010100000000000000", 0x10ab).SendRaw(connection);
            new SpRaw("DE5A89560000000000000000E02DC0C700000000000000000000000000", 0x0d4e).SendRaw(connection);

            new SpSpawnCharacter(connection.ActivePlayer).Send(connection);

            new SpRaw("", 0x0cfb).SendRaw(connection);
            new SpRaw("010000", 0x115a).SendRaw(connection);
            new SpRaw("011825000100D905000100890600010008030001008806000100BA050001008A020001008A0600010087060001007E02000100BE04000100C4050001008C02000100CC05000100B1020001000D030001008D02000100CF000001008F02000100CE020001008E02000100CB000001008B020001008602000100810200010080020001009002000100D3020001009302000100EB02000100E002000100D7020001007F02000100DD000001005C00000100DC00000100DE00000100580000", 0x0d12).SendRaw(connection);
            new SpRaw("0000", 0x1134).SendRaw(connection);
            new SpRaw("12", 0x0c46).SendRaw(connection);

            new SpInventory(connection.ActivePlayer).Send(connection);

            new SpRaw("0101" +
                      sessionId + //game session
                      "0000000000000000000000000000", 0x0bf1).SendRaw(connection);

            new SpCharacterEquipment(connection.ActivePlayer).Send(connection);

            new SpRaw("00010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("01010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("02010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("03010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("04010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("05010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("06010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("07010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("08010000000000000000000000", 0x1082).SendRaw(connection);
            new SpRaw("01DE5A8956000000000E169110DA01000000FA91E2EF01000000BFF1B3AF000000005EFCB343020000009A8ECBC1010000005721E3C301000000B9B43E6E000000007795A06D00000000E580AAC100000000696C543F00000000A97850BF0100000026309223000000001DE008A200000000BF0248CE00000000A132F53000000000614D6B6601000000B89CABD1000000002CF9D01D01000000ECE8F4CE00000000898179FF00000000", 0x0cdc).SendRaw(connection);
            new SpRaw("00000000010000000000000000000000010000000100000000000000000000000200000001000000000000000000000000000000000000000000000000000000", 0x1084).SendRaw(connection);
        }
예제 #11
0
        public void UpdateCharacter(ClientConnection connection)
        {
            using (var db = _gsDbFactory.OpenSession())
            {
                using (var transaction = db.BeginTransaction())
                {
                    try
                    {
                        var equipment = db.QueryOver<CharacterItem>().Where(i => i.CharacterId == connection.ActivePlayer.DatabaseCharacterData.CharacterId).List();
                        for (int i = 0; i < equipment.Count; i++)
                            db.Delete(equipment[i]);

                        /*Update inventory items*/
                        foreach (var daoItem in connection.ActivePlayer.Inventory.Items.Select(item => new CharacterItem
                        {
                            CharacterId = connection.ActivePlayer.DatabaseCharacterData.CharacterId,
                            ItemId = item.Value.ItemId,
                            ItemUid = _itemsUidsFactory.Next(),
                            Slot = item.Key - 1,
                            Count = item.Value.Count,
                            StorageType = (int)((InventoryItem)item.Value).StorageType
                        })) db.Save(daoItem);

                        /*Update equipment items*/
                        foreach (var daoItem in connection.ActivePlayer.Equipment.Items.Select(item => new CharacterItem
                        {
                            CharacterId = connection.ActivePlayer.DatabaseCharacterData.CharacterId,
                            ItemId = item.Value.ItemId,
                            ItemUid = _itemsUidsFactory.Next(),
                            Slot = item.Key - 1,
                            Count = item.Value.Count,
                            StorageType = (int)((InventoryItem)item.Value).StorageType
                        }))db.Save(daoItem);

                        db.Update(connection.ActivePlayer.DatabaseCharacterData);

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"Cannot update player id:{connection.ActivePlayer.DatabaseCharacterData.CharacterId} exception:\n{ex}");

                        transaction.Rollback();
                    }
                }
            }
        }
예제 #12
0
        public void DeleteCharacterProcess(ClientConnection connection, long characterId)
        {
            using (var db = _gsDbFactory.OpenSession())
            {
                using (var transaction = db.BeginTransaction())
                {
                    try
                    {
                        var deletionTime = (int)(DateTime.Now.UnixMilliseconds() / 1000);
                        var deleted = connection.Characters.First(s => s.CharacterId == characterId);

                        var equipment = db.QueryOver<CharacterItem>().Where(i => i.CharacterId == deleted.CharacterId).List();
                        for (int i = 0; i < equipment.Count; i++)
                            db.Delete(equipment[i]);
                        
                        db.Delete(deleted);

                        //TODO - Delayed removed task
                        new SpDeleteCharacter(characterId, 1, deletionTime).Send(connection);

                        transaction.Commit();
                    }
                    catch(Exception ex)
                    {
                        transaction.Rollback();
                        Log.Error(ex);
                    }
                }
            }
        }
예제 #13
0
        public void CreateCharacterProcess(ClientConnection connection, CharacterData info)
        {
            var characterData = info;

            using (var db = _gsDbFactory.OpenSession())
            {
                if (db.QueryOver<CharacterData>().Where(s => s.CharacterName == info.CharacterName).Take(1).SingleOrDefault() != null)
                {
                    new SpCreateCharacterError().Send(connection);

                    return;
                }
                   
                using (var transaction = db.BeginTransaction())
                {
                    try
                    {
                        characterData.CharacterId = _characterUidsFactory.Next();
                        characterData.Surname = connection.Account.FamilyName;
                        characterData.Level = 1;
                        characterData.CreationDate = DateTime.Now;
                        characterData.CreatedId = 0;//for nhibernate driver
                        characterData.PositionX = -96297;
                        characterData.PositionY = -3872;
                        characterData.PositionZ = 77811;

                        var inventory = InventoryStorage.GetDefault(characterData.ClassType);
                        foreach (var daoItem in inventory.Items.Select(item => new CharacterItem
                        {
                            CharacterId = characterData.CharacterId,
                            ItemId = item.Value.ItemId,
                            ItemUid = _itemsUidsFactory.Next(),
                            Slot = item.Key - 1,
                            Count = item.Value.Count,
                            StorageType = (int) ((InventoryItem)item.Value).StorageType
                        }))                       
                            db.Save(daoItem);
                        
                        db.Save(characterData);

                        connection.Characters.Add(characterData);

                        new SpCreateCharacter(characterData).Send(connection, false);

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        Log.Error($"Cannot create character\n{ex}");
                    }                   
                }
            }          
        }
예제 #14
0
        public void GetCharacterList(ClientConnection connection)
        {
            using (var db = _gsDbFactory.OpenSession())
            {
                var list = db.QueryOver<CharacterData>().Where(p => p.AccountId == connection.Account.Id).List();
                
                if(list != null)
                    connection.Characters = (List<CharacterData>) list;
                else
                    connection.Characters = new List<CharacterData>();

                foreach (var characterData in connection.Characters)               
                    characterData.EquipmentData = new EquipmentStorage(db.QueryOver<CharacterItem>().Where(i => 
                    i.CharacterId == characterData.CharacterId && i.StorageType == (int)StorageType.Equipment).List().ToDictionary<CharacterItem, short, AStorageItem>(e => 
                    (short)(e.Slot + 1), e => new InventoryItem(e.ItemId, e.Count) {StorageType = (StorageType) e.StorageType}), 48);           
                

                new SpCharacterList(connection.Account, connection.Characters).Send(connection);

                new SpRaw("FEFFFFFFFFFFFFFF00", 0x0c77).SendRaw(connection);
            }
        }
예제 #15
0
            private bool ProcessCommand(ClientConnection client, string text, int accessLevel)
            {
                if (text.StartsWith("`") && accessLevel < CfgCore.Default.AccesForAdminCommand)
                    return false; //dont have access for admin commands

                if (!text.StartsWith("`") && !text.StartsWith("!"))
                    return false; //not command

                var commandName = text.Split(' ')[0].Replace("!", "").Replace("`", "");

                var command = Commands.Values.FirstOrDefault(s => s.ContainsKey(commandName));
                if (command != null)
                {
                    var selected = Commands.FirstOrDefault(s => s.Value == command);
                    if (accessLevel < selected.Key) //if user dont have access for that command
                        return false;                
                    try
                    {
                        ((ICommandScript)Activator.CreateInstance(command[commandName])).Process(client, text.Split(' ').Skip(1).ToArray());
                        return true; //command processed
                    }
                    catch (Exception e)
                    {
                        Log.Error($"Something wrong happened, while try to process command {command.GetType().Name}, \nEx:{e}");
                    }                   
                }
                else
                    return false; //command not found
                  
                return false;
            }
예제 #16
0
            public void HandleChatMessage(ClientConnection client, object[] parameters)
            {
                if (ProcessCommand(client, (string)parameters[1], client.Account.AccessLevel))
                    return; // Since we are parsing the command, there is no need to reply to client

                switch ((ChatType)parameters[0])
                {
                    case ChatType.Public:
                        client.ActivePlayer.VisibleAi.NotifyObjectsThatSeeMe<Player>(s => new SpChat((string)parameters[1], client.ActivePlayer.GameSessionId, client.ActivePlayer.DatabaseCharacterData.CharacterName, (ChatType)parameters[0]).Send(s.Connection));
                        new SpChat((string)parameters[1], client.ActivePlayer.GameSessionId, client.ActivePlayer.DatabaseCharacterData.CharacterName, ChatType.Public).Send(client);
                        break;

                    case ChatType.World:
                        foreach (var receiver in _onlinePlayers.Values)
                            new SpChat((string)parameters[1], client.ActivePlayer.GameSessionId, client.ActivePlayer.DatabaseCharacterData.CharacterName, (ChatType)parameters[0]).Send(receiver.Connection);
                        break;
                }

                Log.Debug("Received message: {0}", (string)parameters[1]);
            }
예제 #17
0
 public void CancelCloseClientRequest(ClientConnection connection)
 {
     var player = connection.ActivePlayer;
     if(!player.CancelTokenSource.IsCancellationRequested)
         player.CancelTokenSource.Cancel();
 }
예제 #18
0
 public void CloseClientRequest(ClientConnection connection)
 {
     Core.Act(s =>
     {
         connection.CloseConnection();
     }, CfgCore.Default.LogoutSeconds * 1000, connection.ActivePlayer.CancelTokenSource);
 }
예제 #19
0
 public void Disconnect(ClientConnection connection)
 {
     try
     {
         connection.Socket.BeginDisconnect(false, EndDisconect, connection);
     }
     catch (Exception e)
     {
         Log.Info($"Exception occured on begin disconnect, {e}");
     }
 }