Пример #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);
        }
Пример #2
0
		public static void PlayerChangeStandState(RealmClient client, RealmPacketIn packet)
		{
			byte standState = packet.ReadByte();

			client.ActiveCharacter.StandState = (StandState)standState;
		}
Пример #3
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);
			}
		}