Example #1
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 #2
0
        public static void AddIgnoreRequest(RealmClient client, RealmPacketIn packet)
        {
            string relCharacterName = packet.ReadString();

            RelationMgr.Instance.AddRelation(client.ActiveCharacter, relCharacterName, 
                                             CharacterRelationType.Ignored);
        }
Example #3
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 #4
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 #5
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);
			}
		}