コード例 #1
0
        public static void RemoveFriendRequest(RealmClient client, RealmPacketIn packet)
        {
            EntityId relCharId = packet.ReadEntityId();

            RelationMgr.Instance.RemoveRelation(client.ActiveCharacter.EntityId, relCharId, 
                                                CharacterRelationType.Friend);
        }
コード例 #2
0
ファイル: WorldMgr.Handlers.cs プロジェクト: KroneckerX/WCell
		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);
				}
			}
		}
コード例 #3
0
ファイル: WorldMgr.Handlers.cs プロジェクト: KroneckerX/WCell
		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);
			}
		}
コード例 #4
0
ファイル: WorldMgr.Handlers.cs プロジェクト: KroneckerX/WCell
		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);
			}
		}
コード例 #5
0
ファイル: WorldMgr.Handlers.cs プロジェクト: KroneckerX/WCell
		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);
		}
コード例 #6
0
ファイル: WorldMgr.Handlers.cs プロジェクト: KroneckerX/WCell
		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);
			}
		}