public static void RemoveIgnoreRequest(RealmClient client, RealmPacketIn packet)
        {
            EntityId relCharId = packet.ReadEntityId();

            RelationMgr.Instance.RemoveRelation(client.ActiveCharacter.EntityId, relCharId,
                                                CharacterRelationType.Ignored);
        }
Example #2
0
        public static void WhoListRequest(RealmClient client, RealmPacketIn packet)
        {
            WhoSearch search = new WhoSearch();

            search.MaxResultCount = MAX_RESULT_COUNT;
            search.Faction = client.ActiveCharacter.Faction.Group;
            search.MinLevel = (byte)packet.ReadUInt32();
            search.MaxLevel = (byte)packet.ReadUInt32();
            search.Name = packet.ReadString();

            byte unkown1 = packet.ReadByte();
            uint unkown2 = packet.ReadUInt32();
            uint unkown3 = packet.ReadUInt32();

            uint zoneCount = packet.ReadUInt32();
            if (zoneCount > 0 && zoneCount <= 10)
            {
                for (int i = 0; i < zoneCount; i++)
                    search.Zones.Add((ZoneId)packet.ReadUInt32());
            }

            uint nameCount = packet.ReadUInt32();
            if (nameCount > 0 && nameCount <= 10)
            {
                for (int i = 0; i < nameCount; i++)
                    search.Names.Add(packet.ReadString().ToLower());
            }

            uint totalMatches;
            //Performs the search and retrieves matching characters
            List<Character> characters = search.RetrieveMatchedCharacters(out totalMatches);

            //Send the character list to the client
            SendWhoList(client, characters, totalMatches);
        }
Example #3
0
        public static void SendInventoryError(RealmClient client, Item item1, Item item2, InventoryError error)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_INVENTORY_CHANGE_FAILURE,
                                                              error == InventoryError.YOU_MUST_REACH_LEVEL_N ? 22 : 18))
            {
                packet.WriteByte((byte)error);

                if (error == InventoryError.YOU_MUST_REACH_LEVEL_N)
                {
                    packet.WriteUInt(item1.Template.RequiredLevel);
                }

                if (item1 != null)
                {
                    packet.Write(item1.EntityId.Full);
                }
                else
                {
                    packet.WriteULong(0);
                }

                if (item2 != null)
                {
                    packet.Write(item2.EntityId.Full);
                }
                else
                {
                    packet.WriteULong(0);
                }

                packet.WriteByte(0);

                client.Send(packet);
            }
        }
Example #4
0
        public static void RemoveFriendRequest(RealmClient client, RealmPacketIn packet)
        {
            EntityId relCharId = packet.ReadEntityId();

            RelationMgr.Instance.RemoveRelation(client.ActiveCharacter.EntityId, relCharId, 
                                                CharacterRelationType.Friend);
        }
Example #5
0
        public static void AddIgnoreRequest(RealmClient client, RealmPacketIn packet)
        {
            string relCharacterName = packet.ReadString();

            RelationMgr.Instance.AddRelation(client.ActiveCharacter, relCharacterName, 
                                             CharacterRelationType.Ignored);
        }
Example #6
0
 /// <summary>Creates new realm client.</summary>
 /// <returns>RealmClient.</returns>
 public RealmClient NewRealmClient()
 {
     var client = new RealmClient(new TestProtocol());
     client.EntityStateChanged += OnEntityStateChanged;
     client.ConnectionStateChanged += OnConnectionStateChanged;
     return client;
 }
        public static void AddIgnoreRequest(RealmClient client, RealmPacketIn packet)
        {
            string relCharacterName = packet.ReadString();

            RelationMgr.Instance.AddRelation(client.ActiveCharacter, relCharacterName,
                                             CharacterRelationType.Ignored);
        }
Example #8
0
        static void Main(string[] args)
        {
            // Socket connection
            RealmClient client = new RealmClient("NECROALBERT", "N3YL9RL5WOW");
            client.Connect("www.avalonserver.org", 3724);

            Console.ReadKey();
        }
Example #9
0
        public static void HandleAutoEquip(RealmClient client, RealmPacketIn packet)
        {
            var contSlot = (InventorySlot)packet.ReadByte();
            var slot     = packet.ReadByte();

            client.ActiveCharacter.SendSystemMsg("Trying to equip Item in {0}/{1}", contSlot, slot);
            client.ActiveCharacter.Inventory.TryEquip(contSlot, slot);
        }
Example #10
0
 public static void SendCharacterRenameError(RealmClient client, AccountCharacterErrorCodes error)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 1))
     {
         packet.WriteByte((byte)error);
         client.Send(packet);
     }
 }
Example #11
0
        public static void HandleSwapItem(RealmClient client, RealmPacketIn packet)
        {
            var destBagSlot = (InventorySlot)packet.ReadByte();
            var destSlot    = packet.ReadByte();
            var srcBagSlot  = (InventorySlot)packet.ReadByte();
            var srcSlot     = packet.ReadByte();

            client.ActiveCharacter.Inventory.TrySwap(srcBagSlot, srcSlot, destBagSlot, destSlot);
        }
Example #12
0
        public static void CharEnumRequest(RealmClient client, RealmPacketIn packet)
        {
            if (client.Account == null)
            {
                return;
            }

            SendCharEnum(client);
        }
Example #13
0
        static void Main(string[] args)
        {
            // Socket connection
            RealmClient client = new RealmClient("NECROALBERT", "N3YL9RL5WOW");

            client.Connect("www.avalonserver.org", 3724);

            Console.ReadKey();
        }
Example #14
0
 public static void SendCharacterRenameSuccess(RealmClient client, EntityId guid, string newName)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 10 + newName.Length))
     {
         packet.WriteByte((byte)AccountCharacterErrorCodes.ACCNT_MANIP_OK);
         packet.Write(guid.Full);
         packet.WriteCString(newName);
         client.Send(packet);
     }
 }
Example #15
0
        public static void SendItemNameQueryResponse(RealmClient client, ItemTemplate item)
        {
            using (RealmPacketOut outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.Name.Length))
            {
                outPacket.WriteInt(item.Id);
                outPacket.WriteCString(item.Name);

                client.Send(outPacket);
            }
        }
Example #16
0
		public static void HandleAttackSwing(RealmClient client, RealmPacketIn packet)
		{
			if (client.ActiveCharacter.CanDoHarm) {
				EntityId targetId = packet.ReadEntityId();
				Unit target = WorldMgr.GetUnit(targetId);
				if (target != null && target.CanDoHarm && client.ActiveCharacter.IsHostileWith(target)) {
					client.ActiveCharacter.SetCombatState(true, false);
				}
			}
		}
Example #17
0
        public static void HandleSwapInvItem(RealmClient client, RealmPacketIn packet)
        {
            var srcSlot  = packet.ReadByte();
            var destSlot = packet.ReadByte();

            //SendInventoryError(client, null, null, InventoryError.NO_EQUIPMENT_SLOT_AVAILABLE3);
            var inv = client.ActiveCharacter.Inventory;

            inv.TrySwap(inv, srcSlot, inv, destSlot);
        }
Example #18
0
        /// <summary>
        /// Handles a command message, parsing it and executing the neccessary command script.
        /// </summary>
        /// <param name="commandMessage">the command message</param>
        public void HandleCommand(RealmClient client, string commandMessage)
        {
            List <string> commandArgs = ParseCommand(commandMessage);

            Command cmd = PrivilegeMgr.Instance.GetCommand(GetCommandName(commandArgs[0]));

            if (cmd != null)
            {
                m_scriptEnv.ExecuteFunction(cmd.ModuleName, cmd.FunctionName, client, commandArgs.ToArray());
            }
        }
Example #19
0
 public static void HandleAttackSwing(RealmClient client, RealmPacketIn packet)
 {
     if (client.ActiveCharacter.CanDoHarm)
     {
         EntityId targetId = packet.ReadEntityId();
         Unit     target   = WorldMgr.GetUnit(targetId);
         if (target != null && target.CanDoHarm && client.ActiveCharacter.IsHostileWith(target))
         {
             client.ActiveCharacter.SetCombatState(true, false);
         }
     }
 }
Example #20
0
 public PlayerManager(RealmClient rClient)
 {
     RClient = rClient;
     Server  = new PlayerServer();
     Server.ClientDisconnected  += Server_ClientDisconnected;
     Server.NewClientConntected += Server_NewClientConntected;
     Server.NewDataReceived     += Server_NewDataReceived;
     Server.NewDataSended       += Server_NewDataSended;
     Server.Started             += Server_Started;
     Server.Stoped       += Server_Stoped;
     Server.NewException += Server_NewException;
 }
Example #21
0
        public static void HandleItemSingleQuery(RealmClient client, RealmPacketIn packet)
        {
            uint itemId = packet.ReadUInt32();

            ItemTemplate item = ItemMgr.GetTemplate(itemId);
            if (item == null)
            {
                return;
            }

            SendItemQueryResponse(client, item);            
        }
Example #22
0
        public static void PlayerImediateLogoutRequest(RealmClient client, RealmPacketIn packet)
        {
            SendPlayerImmediateLogoutReply(client);

            Character chr = client.ActiveCharacter;

            chr.FlagForLogout(false);

            bool noDelay = chr.IsGameMaster || chr.CurrentZone.IsCity;

            chr.PrepareToLogout(noDelay);
        }
Example #23
0
        public static void CharDeleteRequest(RealmClient client, RealmPacketIn packet)
        {
            if (client.Account == null)
            {
                return;
            }

            CharacterErrorCodes returnCode = CharacterErrorCodes.DeleteSucceeded;
            EntityId            eid        = packet.ReadEntityId();
            CharacterRecord     record     = null;

            try
            {
                if (client.Account.Characters.ContainsKey(eid) && client.Account.Characters[eid] != null)
                {
                    record = client.Account.Characters[eid];
                }
                else
                {
                    // log error
                    returnCode = CharacterErrorCodes.DeleteFailed;
                    return;
                }

                EntityIdStorage.RecycleLowerEntityId(eid.Low, EntityIdType.Player);

                client.Account.Characters.Remove(eid);

#warning TODO (tobz): check/update/remove guild if player is last player in guild/guild leader
#warning TODO (tobz): return any unclaimed COD mails to their sender as server identity

                RelationMgr.Instance.RemoveForPlayer(eid.Low);

                record.DeleteAndFlush();
                record = null;
            }
            catch (Exception ex)
            {
                if (!client.Account.Characters.ContainsKey(eid) && record != null)
                {
                    client.Account.Characters.Add(eid, record);
                }

                s_log.Error("Failed to delete character!", ex);

                returnCode = CharacterErrorCodes.DeleteFailed;
            }
            finally
            {
                SendCharDeleteReply(client, returnCode);
            }
        }
Example #24
0
 public GameCore()
 {
     Log     = new MessageLog();
     Db      = new DataAccessObject();
     Setting = SettingModel.Load <GameSetting>();
     Db.Setup(Setting);
     RClient = new RealmClient(this);
     RClient.NewException += RClient_NewException;
     RClient.Connected    += RClient_Connected;
     RClient.Disconnected += RClient_Disconnected;
     RClient.DataReceived += RClient_DataReceived;
     RClient.DataSended   += RClient_DataSended;
 }
Example #25
0
        public static void HandleItemSingleQuery(RealmClient client, RealmPacketIn packet)
        {
            uint itemId = packet.ReadUInt32();

            ItemTemplate item = ItemMgr.GetTemplate(itemId);

            if (item == null)
            {
                return;
            }

            SendItemQueryResponse(client, item);
        }
Example #26
0
        public static void HandleZoneUpdate(RealmClient client, RealmPacketIn packet)
        {
            ZoneId newZoneId = (ZoneId)packet.ReadUInt32();
            ZoneId oldZoneId = client.ActiveCharacter.CurrentZone.ID;

            if (oldZoneId != newZoneId)
            {
                Zone newZone = WorldMgr.GetZone(newZoneId);

                if (newZone != null)
                {
                    client.ActiveCharacter.CurrentZone = newZone;

                    Channel.UpdatePlayerChannels(client.ActiveCharacter, oldZoneId);
                }
            }
        }
Example #27
0
        public static void PlayerLogoutRequest(RealmClient client, RealmPacketIn packet)
        {
            Character chr = client.ActiveCharacter;

            chr.FlagForLogout(false);

            bool noDelay = chr.IsGameMaster || chr.CurrentZone.IsCity;

            if (noDelay)
            {
                SendPlayerImmediateLogoutReply(client);
                chr.PrepareToLogout(noDelay);
            }
            else
            {
                SendLogoutReply(client, LogoutResponseCodes.LOGOUT_RESPONSE_ACCEPTED);
                chr.PrepareToLogout(noDelay);
            }
        }
Example #28
0
        public static void HandleDestroyItem(RealmClient client, RealmPacketIn packet)
        {
            var contSlot = (InventorySlot)packet.ReadByte();
            var slot     = packet.ReadByte();

            var inv  = client.ActiveCharacter.Inventory;
            var cont = inv.GetContainer(contSlot, inv.IsBankOpen);

            if (cont != null)
            {
                if (!cont.Destroy(slot))
                {
                    SendInventoryError(client, null, null, InventoryError.CANT_DROP_SOULBOUND);
                }
            }
            else
            {
                SendInventoryError(client, null, null, InventoryError.ITEM_NOT_FOUND);
            }
        }
Example #29
0
        public static void WhoListRequest(RealmClient client, RealmPacketIn packet)
        {
            WhoSearch search = new WhoSearch();

            search.MaxResultCount = MAX_RESULT_COUNT;
            search.Faction        = client.ActiveCharacter.Faction.Group;
            search.MinLevel       = (byte)packet.ReadUInt32();
            search.MaxLevel       = (byte)packet.ReadUInt32();
            search.Name           = packet.ReadString();

            byte unkown1 = packet.ReadByte();
            uint unkown2 = packet.ReadUInt32();
            uint unkown3 = packet.ReadUInt32();

            uint zoneCount = packet.ReadUInt32();

            if (zoneCount > 0 && zoneCount <= 10)
            {
                for (int i = 0; i < zoneCount; i++)
                {
                    search.Zones.Add((ZoneId)packet.ReadUInt32());
                }
            }

            uint nameCount = packet.ReadUInt32();

            if (nameCount > 0 && nameCount <= 10)
            {
                for (int i = 0; i < nameCount; i++)
                {
                    search.Names.Add(packet.ReadString().ToLower());
                }
            }

            uint totalMatches;
            //Performs the search and retrieves matching characters
            List <Character> characters = search.RetrieveMatchedCharacters(out totalMatches);

            //Send the character list to the client
            SendWhoList(client, characters, totalMatches);
        }
Example #30
0
        public static void NameQueryRequest(RealmClient client, RealmPacketIn packet)
        {
            CharacterRecord characterRecord = null;

            EntityId  id  = packet.ReadEntityId();
            Character chr = GetCharacter(id);

            if (chr != null)
            {
                characterRecord = chr.DBObject;
            }
            else
            {
                characterRecord = CharacterRecord.GetRecordByGUID(id);
            }

            if (characterRecord != null)
            {
                SendNameQueryReply(client, characterRecord);
            }
        }
Example #31
0
        public static void CreatureNameQueryRequest(RealmClient client, RealmPacketIn packet)
        {
            uint     creatureEntry    = packet.ReadUInt32();
            EntityId creatureEntityId = packet.ReadEntityId();

            var npc = WorldMgr.GetObject(creatureEntityId) as NPC;

            if (npc != null)
            {
                var entry = npc.Entry;
                var name  = entry.Name;
                var title = entry.Title;
                var info  = entry.Info;
                using (RealmPacketOut pkt = new RealmPacketOut(RealmServerOpCode.SMSG_CREATURE_QUERY_RESPONSE,
                                                               5 + 4 + 1 + 36 + 2 + name.Length + title.Length))
                {
                    pkt.WriteUInt(creatureEntry);
                    pkt.Write(name);
                    pkt.WriteByte(0);                                                                           // Name2
                    pkt.WriteByte(0);                                                                           // Name3
                    pkt.WriteByte(0);                                                                           // Name4
                    pkt.WriteCString(title);
                    //pkt.WriteCString(info);
                    pkt.WriteUInt(entry.Flags);
                    pkt.Write((uint)entry.Type);
                    pkt.WriteUInt(entry.Family);
                    pkt.Write((uint)entry.Rank);
                    pkt.WriteUInt(entry.UInt1);
                    pkt.WriteUInt(entry.SpellDataId);
                    pkt.WriteUInt(npc.DisplayId);
                    pkt.Write(entry.Float1);
                    pkt.Write(entry.Float2);
                    pkt.WriteByte(0);
                    pkt.WriteByte(entry.IsLeader);


                    client.Send(pkt);
                }
            }
        }
Example #32
0
 void RealmProxy_OnCharacterLogonRequest(RealmClient.CharacterLogonRequest packet, ref PacketFlag flag)
 {
     CharacterName = packet.Name;
 }
 public static void FriendListRequest(RealmClient client, RealmPacketIn packet)
 {
     RelationMgr.Instance.SendRelationList(client.ActiveCharacter, CharacterRelationType.Friend);
     RelationMgr.Instance.SendIgnoreList(client.ActiveCharacter);
 }
Example #34
0
 public static void PlayerLogoutCancel(RealmClient client, RealmPacketIn packet)
 {
     SendLogoutCancelReply(client);
 }
Example #35
0
        public static void AuthSessionRequest(RealmClient client, RealmPacketIn packet)
        {
            packet.SkipBytes(8);
            string                   accName      = packet.ReadString();
            uint                     clientSeed   = packet.ReadUInt32();
            BigInteger               clientDigest = packet.ReadBigInteger(20);
            AuthenticationInfo       authInfo;
            SecureRemotePassword     srp;
            AuthenticationErrorCodes errorCode = AuthenticationErrorCodes.AuthFailed;

            client.Account = new Account(client, accName);

            if (!client.Account.Initialize())
            {
                errorCode = AuthenticationErrorCodes.UnknownAccount;

                goto sendErrorReply;
            }

            if (client.Server.RequestAuthenticationInfo(accName, out authInfo))
            {
                srp = new SecureRemotePassword(accName, authInfo.Verifier, new BigInteger(authInfo.Salt, 32));

                client.Account.SessionKey = authInfo.SessionKey;
                client.SystemInfo         = SystemInformation.Deserialize(authInfo.SystemInformation);
            }
            else
            {
                goto sendErrorReply;
            }

            BigInteger clientVerifier = srp.Hash(srp.Username, new byte[4], clientSeed, client.Server.AuthSeed,
                                                 client.Account.SessionKey);

            client.IsEncrypted = true;             // all packets from here on are encrypted, including the AuthSessionReplys

            if (clientVerifier == clientDigest)
            {
                AddonHandler.ReadAddOns(client, packet);

                client.Server.LoginAccount(client.Account.Username);

                if (AuthQueue.QueuedClients > 0 ||
                    client.Server.NumberOfClients > client.Server.Config.ServerCapacity)
                {
                    AuthQueue.EnqueueClient(client);

                    return;
                }

                SendAuthSessionSuccess(client);

                return;
            }
            else
            {
                goto sendErrorReply;
            }

sendErrorReply:
            SendAuthSessionErrorReply(client, errorCode);

            client.Disconnect();
        }
Example #36
0
 public static void QueryTimeRequest(RealmClient client, RealmPacketIn packet)
 {
     SendQueryTimeReply(client);
 }
Example #37
0
        public static void PingRequest(RealmClient client, RealmPacketIn packet)
        {
            SendPingReply(client, packet.ReadUInt32());

            client.Latency = packet.ReadUInt32();
        }
Example #38
0
		public static void CreatureNameQueryRequest(RealmClient client, RealmPacketIn packet)
		{
			uint creatureEntry = packet.ReadUInt32();
			EntityId creatureEntityId = packet.ReadEntityId();

			var npc = WorldMgr.GetObject(creatureEntityId) as NPC;
			if (npc != null)
			{
				var entry = npc.Entry;
				var name = entry.Name;
				var title = entry.Title;
				var info = entry.Info;
				using (RealmPacketOut pkt = new RealmPacketOut(RealmServerOpCode.SMSG_CREATURE_QUERY_RESPONSE, 
					5 + 4 + 1 + 36 + 2 + name.Length + title.Length))
				{
					pkt.WriteUInt(creatureEntry);
					pkt.Write(name);
					pkt.WriteByte(0);							// Name2
					pkt.WriteByte(0);							// Name3
					pkt.WriteByte(0);							// Name4
					pkt.WriteCString(title);
					//pkt.WriteCString(info);
					pkt.WriteUInt(entry.Flags);
					pkt.Write((uint)entry.Type);
					pkt.WriteUInt(entry.Family);
					pkt.Write((uint)entry.Rank);
					pkt.WriteUInt(entry.UInt1);
					pkt.WriteUInt(entry.SpellDataId);
					pkt.WriteUInt(npc.DisplayId);
					pkt.Write(entry.Float1);
					pkt.Write(entry.Float2);
					pkt.WriteByte(0);
					pkt.WriteByte(entry.IsLeader);


					client.Send(pkt);
				}
			}
		}
Example #39
0
		public static void NameQueryRequest(RealmClient client, RealmPacketIn packet)
		{
			CharacterRecord characterRecord = null;

			EntityId id = packet.ReadEntityId();
			Character chr = GetCharacter(id);

			if (chr != null)
			{
				characterRecord = chr.DBObject;
			}
			else
			{
				characterRecord = CharacterRecord.GetRecordByGUID(id);
			}

			if (characterRecord != null)
			{
				SendNameQueryReply(client, characterRecord);
			}
		}
Example #40
0
		public static void QueryTimeRequest(RealmClient client, RealmPacketIn packet)
		{
			SendQueryTimeReply(client);
		}
Example #41
0
		public static void HandleZoneUpdate(RealmClient client, RealmPacketIn packet)
		{
			ZoneId newZoneId = (ZoneId)packet.ReadUInt32();
			ZoneId oldZoneId = client.ActiveCharacter.CurrentZone.ID;

			if (oldZoneId != newZoneId)
			{
				Zone newZone = WorldMgr.GetZone(newZoneId);

				if (newZone != null)
				{
					client.ActiveCharacter.CurrentZone = newZone;

					Channel.UpdatePlayerChannels(client.ActiveCharacter, oldZoneId);
				}
			}
		}
Example #42
0
		public static void PingRequest(RealmClient client, RealmPacketIn packet)
		{
			SendPingReply(client, packet.ReadUInt32());

			client.Latency = packet.ReadUInt32();
		}
Example #43
0
		public static void PlayerLoginRequest(RealmClient client, RealmPacketIn packet)
		{
			if (client.Account == null)
			{
				return;
			}

			try
			{
				EntityId charGUID = packet.ReadEntityId();

				if (charGUID != EntityId.Zero)
				{
					if (s_characters.ContainsKey(charGUID) && !s_characters[charGUID].IsLoggingOut)
					{
						s_log.Error(string.Format(Resources.CharacterAlreadyConnected, charGUID, client.Account.Username));

						Character.SendCharacterLoginFail(client, LoginErrorCodes.CHAR_LOGIN_DUPLICATE_CHARACTER);
					}
					else
					{
						if (!client.Account.Characters.ContainsKey(charGUID))
						{
							s_log.Error(string.Format(Resources.CharacterNotFound, charGUID, client.Account.Username));

							Character.SendCharacterLoginFail(client, LoginErrorCodes.CHAR_LOGIN_NO_CHARACTER);

							client.Server.DisconnectClient(client);
						}
						else
						{
							Character existingChar = null;

							// this handles character reconnection cases, which relinks a character
							// in the process of being logged out.
							if (s_characters.TryGetValue(charGUID, out existingChar))
							{
								existingChar.ReconnectCharacter(client);
							}
							else
							{
								// Set and register the current character.
								client.ActiveCharacter = new Character(client.Account, client.Account.Characters[charGUID], client);
								RegisterCharacter(client.ActiveCharacter);

								// Start character login process
								client.ActiveCharacter.FirstLogin();
							}

							// Give them our version. (as if they care :p)
							Version ver = Assembly.GetCallingAssembly().GetName().Version;
							string message = string.Format("Welcome to WCell {0}.{1}.{2}.{3}",
								ver.Major, ver.Minor, ver.Revision, ver.Build);

							ChatMgr.SendSystemMessage(client, message);
						}
					}
				}
			}
			catch (Exception e)
			{
				s_log.Error(e);
				Character.SendCharacterLoginFail(client, LoginErrorCodes.CHAR_LOGIN_FAILED);
			}
		}
Example #44
0
		public static void CharacterRenameRequest(RealmClient client, RealmPacketIn packet)
		{
			if (client.Account == null)
			{
				return;
			}

			CharacterRecord cr = null;

			EntityId guid = packet.ReadEntityId();
			string newName = packet.ReadString();

			if (!client.Account.Characters.ContainsKey(guid))
			{
				s_log.Error(Resources.IllegalRenameAttempt, guid.ToString(), RealmClient.GetInfo(client));
				return;
			}
			else
			{
				cr = client.Account.Characters[guid];

				if (((CharEnumFlags)cr.CharacterFlags & CharEnumFlags.NeedsRename) != CharEnumFlags.NeedsRename)
				{
					// their character isn't flagged to be renamed, what do they think they're doing? ;)
					client.Disconnect();
					return;
				}
			}

			if (newName.Length == 0)
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_INVALID);
				return;
			}

			if (Character.Exists(newName))
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_USED);
				return;
			}

			if (newName.Length < 3)
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_MIN_3);
				return;
			}

			if (newName.Length > 12)
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_MAX_12);
				return;
			}

			if (Character.DoesNameViolate(newName))
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_PROFANITY);
				return;
			}

			s_log.Debug(Resources.RenamingCharacter, cr.Name, newName);

			cr.Name = newName.ToCapitalizedString();
			cr.UpdateAndFlush();

			client.Account.ReloadCharacters();

			SendCharacterRenameSuccess(client, guid, newName);
		}
Example #45
0
 public static void FriendListRequest(RealmClient client, RealmPacketIn packet)
 {
     RelationMgr.Instance.SendRelationList(client.ActiveCharacter, CharacterRelationType.Friend);
     RelationMgr.Instance.SendIgnoreList(client.ActiveCharacter);
 }
Example #46
0
		public static void PlayerImediateLogoutRequest(RealmClient client, RealmPacketIn packet)
		{
			SendPlayerImmediateLogoutReply(client);

			Character chr = client.ActiveCharacter;

			chr.FlagForLogout(false);

			bool noDelay = chr.IsGameMaster || chr.CurrentZone.IsCity;
			chr.PrepareToLogout(noDelay);
		}
Example #47
0
		public static void HandleAttackStop(RealmClient client, RealmPacketIn packet)
		{
			client.ActiveCharacter.SetCombatState(false, false);
		}
Example #48
0
		public static void AuthSessionRequest(RealmClient client, RealmPacketIn packet)
		{
			packet.SkipBytes(8);
			string accName = packet.ReadString();
			uint clientSeed = packet.ReadUInt32();
			BigInteger clientDigest = packet.ReadBigInteger(20);
			AuthenticationInfo authInfo;
			SecureRemotePassword srp;
			AuthenticationErrorCodes errorCode = AuthenticationErrorCodes.AuthFailed;

			client.Account = new Account(client, accName);

			if (!client.Account.Initialize())
			{
				errorCode = AuthenticationErrorCodes.UnknownAccount;

				goto sendErrorReply;
			}

			if (client.Server.RequestAuthenticationInfo(accName, out authInfo))
			{
				srp = new SecureRemotePassword(accName, authInfo.Verifier, new BigInteger(authInfo.Salt, 32));

				client.Account.SessionKey = authInfo.SessionKey;
				client.SystemInfo = SystemInformation.Deserialize(authInfo.SystemInformation);
			}
			else
			{
				goto sendErrorReply;
			}

			BigInteger clientVerifier = srp.Hash(srp.Username, new byte[4], clientSeed, client.Server.AuthSeed,
													client.Account.SessionKey);

			client.IsEncrypted = true; // all packets from here on are encrypted, including the AuthSessionReplys

			if (clientVerifier == clientDigest)
			{
                AddonHandler.ReadAddOns(client, packet);

				client.Server.LoginAccount(client.Account.Username);

				if (AuthQueue.QueuedClients > 0 ||
					client.Server.NumberOfClients > client.Server.Config.ServerCapacity)
				{
					AuthQueue.EnqueueClient(client);

					return;
				}

				SendAuthSessionSuccess(client);

				return;
			}
			else
			{
				goto sendErrorReply;
			}

		sendErrorReply:
			SendAuthSessionErrorReply(client, errorCode);

			client.Disconnect();
		}
Example #49
0
		public static void PlayerLogoutRequest(RealmClient client, RealmPacketIn packet)
		{
			Character chr = client.ActiveCharacter;

			chr.FlagForLogout(false);

			bool noDelay = chr.IsGameMaster || chr.CurrentZone.IsCity;

			if (noDelay)
			{
				SendPlayerImmediateLogoutReply(client);
				chr.PrepareToLogout(noDelay);
			}
			else
			{
				SendLogoutReply(client, LogoutResponseCodes.LOGOUT_RESPONSE_ACCEPTED);
				chr.PrepareToLogout(noDelay);
			}
		}
Example #50
0
		public static void PlayerLogoutCancel(RealmClient client, RealmPacketIn packet)
		{
			SendLogoutCancelReply(client);
		}
Example #51
0
		public static void HandleSheathedStateChanged(RealmClient client, RealmPacketIn packet)
		{
			client.ActiveCharacter.SheathType = (SheathType)packet.ReadByte();
		}
Example #52
0
		public static void PlayerChangeStandState(RealmClient client, RealmPacketIn packet)
		{
			byte standState = packet.ReadByte();

			client.ActiveCharacter.StandState = (StandState)standState;
		}
Example #53
0
 void RealmProxy_OnJoinGameRequest(RealmClient.JoinGameRequest packet, ref PacketFlag flag)
 {
     ProxyServer.RealmProxyJoiningGame = this;
 }
Example #54
0
		public static void CharDeleteRequest(RealmClient client, RealmPacketIn packet)
		{
			if (client.Account == null)
			{
				return;
			}

			CharacterErrorCodes returnCode = CharacterErrorCodes.DeleteSucceeded;
			EntityId eid = packet.ReadEntityId();
			CharacterRecord record = null;

			try
			{
				if (client.Account.Characters.ContainsKey(eid) && client.Account.Characters[eid] != null)
				{
					record = client.Account.Characters[eid];
				}
				else
				{
					// log error
					returnCode = CharacterErrorCodes.DeleteFailed;
					return;
				}

				EntityIdStorage.RecycleLowerEntityId(eid.Low, EntityIdType.Player);

				client.Account.Characters.Remove(eid);

#warning TODO (tobz): check/update/remove guild if player is last player in guild/guild leader
#warning TODO (tobz): return any unclaimed COD mails to their sender as server identity

				RelationMgr.Instance.RemoveForPlayer(eid.Low);

				record.DeleteAndFlush();
				record = null;
			}
			catch (Exception ex)
			{
				if (!client.Account.Characters.ContainsKey(eid) && record != null)
				{
					client.Account.Characters.Add(eid, record);
				}

				s_log.Error("Failed to delete character!", ex);

				returnCode = CharacterErrorCodes.DeleteFailed;
			}
			finally
			{
				SendCharDeleteReply(client, returnCode);
			}
		}
Example #55
0
        public static void PlayerChangeStandState(RealmClient client, RealmPacketIn packet)
        {
            byte standState = packet.ReadByte();

            client.ActiveCharacter.StandState = (StandState)standState;
        }
Example #56
0
		public static void CharCreateRequest(RealmClient client, RealmPacketIn packet)
		{
			if (client.Account == null)
			{
				return;
			}

			try
			{
				string characterName = packet.ReadString();

				if (Character.Exists(characterName))
				{
					SendCharCreateReply(client, CharacterErrorCodes.CreateNameInUse);
					return;
				}

				if (characterName.Length < 3)
				{
					SendCharCreateReply(client, CharacterErrorCodes.NameTooShort);
					return;
				}

				if (characterName.Length > 12)
				{
					SendCharCreateReply(client, CharacterErrorCodes.NameTooLong);
					return;
				}

				if (Character.DoesNameViolate(characterName))
				{
					SendCharCreateReply(client, CharacterErrorCodes.NameProfanity);
					return;
				}

				RaceType chrRace = (RaceType)packet.ReadByte();
				ClassType chrClass = (ClassType)packet.ReadByte();

				CharacterErrorCodes createError;
				if (!RealmServer.Instance.ServerRules.CanCreateCharacter(client, chrRace, chrClass, out createError))
				{
					SendCharCreateReply(client, createError);
					return;
				}

				CharacterRecord ch = CharacterRecord.CreateNewCharacterRecord(client.Account, characterName);

				if (ch == null)
				{
					s_log.Error("Unable to create character record!");
					SendCharCreateReply(client, CharacterErrorCodes.CreateError);

					return;
				}

				ch.Race = chrRace;
				ch.Class = chrClass;
				ch.Gender = (GenderType)packet.ReadByte();
				ch.Skin = packet.ReadByte();
				ch.Face = packet.ReadByte();
				ch.HairStyle = packet.ReadByte();
				ch.HairColor = packet.ReadByte();
				ch.FacialHair = packet.ReadByte();
				ch.Outfit = packet.ReadByte();

#warning // TODO - Ogre: This should be handled elsewhere, when we have world events and stuff
				BaseRace race = GetRace(ch.Race);

				ch.Level = 1;
				ch.PositionX = race.StartPosition.X;
				ch.PositionY = race.StartPosition.Y;
				ch.PositionZ = race.StartPosition.Z;
				ch.Orientation = race.StartPosition.W;
				ch.CurrentMap = race.StartMap;
				ch.CurrentZone = race.StartZone;
				ch.TotalPlayTime = 0;
				ch.LevelPlayTime = 0;
				ch.PrivilegeLevel = "Guest";
				ch.TutorialFlags = new byte[32];
				ch.SerializedFields = new byte[0];

				if (race.Type == RaceType.BloodElf)
				{
					ch.DisplayId = race.ModelOffset - (uint)ch.Gender;
				}
				else
				{
					ch.DisplayId = race.ModelOffset + (uint)ch.Gender;
				}

				if (DBSetup.IsActive)
				{
					ch.CreateAndFlush();

					// Is it necessary to reload all?
					client.Account.ReloadCharacters();
				}
				else
					client.Account.Characters.Add(EntityId.GetPlayerId(ch.EntityId), ch);
				
				SendCharCreateReply(client, CharacterErrorCodes.CreateSucceeded);
			}
			catch (Exception e)
			{
				s_log.Error(e);
				SendCharCreateReply(client, CharacterErrorCodes.CreateError);
			}
		}
Example #57
0
 void RealmProxy_OnRealmStartupRequest(RealmClient.RealmStartupRequest packet, ref PacketFlag flag)
 {
     bnetProxy = ProxyServer.FindBnetProxyForRealm(packet.Username);
     if (bnetProxy != null)
     {
         bnetProxy.Proxy.RealmProxy = this;
         this.Proxy = bnetProxy.Proxy;
     }
 }
Example #58
0
		public static void CharEnumRequest(RealmClient client, RealmPacketIn packet)
		{
			if (client.Account == null)
			{
				return;
			}

			SendCharEnum(client);
		}
Example #59
0
		public static void SendCharacterRenameSuccess(RealmClient client, EntityId guid, string newName)
		{
			using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 10 + newName.Length))
			{
				packet.WriteByte((byte)AccountCharacterErrorCodes.ACCNT_MANIP_OK);
				packet.Write(guid.Full);
				packet.WriteCString(newName);
				client.Send(packet);
			}
		}
Example #60
0
		public static void SendCharacterRenameError(RealmClient client, AccountCharacterErrorCodes error)
		{
			using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 1))
			{
				packet.WriteByte((byte)error);
				client.Send(packet);
			}
		}