public void On_CMSG_GUILD_LEAVE(PacketClass packet, ClientClass client) { // packet.GetInt16() _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GUILD_LEAVE", client.IP, client.Port); // DONE: Checks if (!client.Character.IsInGuild) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD); return; } if (client.Character.IsGuildLeader) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_QUIT_S, GuildError.GUILD_LEADER_LEAVE); return; } _clusterServiceLocator.WcGuild.RemoveCharacterFromGuild(client.Character); _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_QUIT_S, GuildError.GUILD_PLAYER_NO_MORE_IN_GUILD, client.Character.Name); var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT); response.AddInt8((byte)GuildEvent.LEFT); response.AddInt8(1); response.AddString(client.Character.Name); var argnotTo = 0UL; _clusterServiceLocator.WcGuild.BroadcastToGuild(response, client.Character.Guild, notTo: argnotTo); response.Dispose(); }
public void SendIgnoreList(ClientClass client, WcHandlerCharacter.CharacterObject character) { // DONE: Query DB var q = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM character_social WHERE guid = {0} AND (flags & {1}) > 0;", character.Guid, Conversions.ToInteger(SocialFlag.SOCIAL_FLAG_IGNORED)), ref q); // DONE: Make the packet var smsgIgnoreList = new PacketClass(Opcodes.SMSG_IGNORE_LIST); if (q.Rows.Count > 0) { smsgIgnoreList.AddInt8((byte)q.Rows.Count); foreach (DataRow row in q.Rows) { smsgIgnoreList.AddUInt64(row.As <ulong>("friend")); // Player GUID } } else { smsgIgnoreList.AddInt8(0); } client.Send(smsgIgnoreList); smsgIgnoreList.Dispose(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_IGNORE_LIST", client.IP, client.Port); }
public void On_CMSG_ADD_IGNORE(PacketClass packet, ClientClass client) { if (packet.Data.Length - 1 < 6) { return; } packet.GetInt16(); var response = new PacketClass(Opcodes.SMSG_FRIEND_STATUS); var name = packet.GetString(); var guid = 0UL; _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_ADD_IGNORE [{2}]", client.IP, client.Port, name); // DONE: Get GUID from DB var q = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT char_guid FROM characters WHERE char_name = \"{0}\";", name), ref q); if (q.Rows.Count > 0) { guid = (ulong)q.Rows[0].As <long>("char_guid"); q.Clear(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT flags FROM character_social WHERE flags = {0}", Conversions.ToByte(SocialFlag.SOCIAL_FLAG_IGNORED)), ref q); var numberOfFriends = q.Rows.Count; q.Clear(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM character_social WHERE guid = {0} AND friend = {1} AND flags = {2};", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_IGNORED)), ref q); if (guid == client.Character.Guid) { response.AddInt8((byte)FriendResult.FRIEND_IGNORE_SELF); response.AddUInt64(guid); } else if (q.Rows.Count > 0) { response.AddInt8((byte)FriendResult.FRIEND_IGNORE_ALREADY); response.AddUInt64(guid); } else if (numberOfFriends >= (int)SocialList.MAX_IGNORES_ON_LIST) { response.AddInt8((byte)FriendResult.FRIEND_IGNORE_ALREADY); response.AddUInt64(guid); } else { response.AddInt8((byte)FriendResult.FRIEND_IGNORE_ADDED); response.AddUInt64(guid); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("INSERT INTO character_social (guid, friend, flags) VALUES ({0}, {1}, {2});", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_IGNORED))); client.Character.IgnoreList.Add(guid); } } else { response.AddInt8((byte)FriendResult.FRIEND_IGNORE_NOT_FOUND); response.AddUInt64(guid); } client.Send(response); response.Dispose(); q.Dispose(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_FRIEND_STATUS", client.IP, client.Port); }
public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref ItemObject updateObject) { checked { packet.AddInt8((byte)updateType); packet.AddPackGUID(updateObject.GUID); if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT) { if (WorldServiceLocator._WorldServer.ITEMDatabase[updateObject.ItemEntry].ContainerSlots > 0) { packet.AddInt8(2); } else { packet.AddInt8(1); } packet.AddInt8(24); packet.AddUInt64(updateObject.GUID); } if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_VALUES) { var updateCount = 0; var num = UpdateMask.Count - 1; for (var j = 0; j <= num; j++) { if (UpdateMask.Get(j)) { updateCount = j; } } packet.AddInt8((byte)(checked (updateCount + 32) / 32)); packet.AddBitArray(UpdateMask, checked ((byte)(checked (updateCount + 32) / 32)) * 4); var num2 = UpdateMask.Count - 1; for (var i = 0; i <= num2; i++) { if (UpdateMask.Get(i)) { if (UpdateData[i] is uint) { packet.AddUInt32(Conversions.ToUInteger(UpdateData[i])); } else if (UpdateData[i] is float) { packet.AddSingle(Conversions.ToSingle(UpdateData[i])); } else { packet.AddInt32(Conversions.ToInteger(UpdateData[i])); } } } UpdateMask.SetAll(value: false); } if (packet is UpdatePacketClass @class) { @class.UpdatesCount++; } } }
public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref WS_Corpses.CorpseObject updateObject) { checked { packet.AddInt8((byte)updateType); packet.AddPackGUID(updateObject.GUID); if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT) { packet.AddInt8(7); packet.AddInt8(88); packet.AddSingle(updateObject.positionX); packet.AddSingle(updateObject.positionY); packet.AddSingle(updateObject.positionZ); packet.AddSingle(updateObject.orientation); packet.AddUInt64(updateObject.GUID); } if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT || updateType == ObjectUpdateType.UPDATETYPE_VALUES) { int updateCount = 0; int num = UpdateMask.Count - 1; for (int j = 0; j <= num; j++) { if (UpdateMask.Get(j)) { updateCount = j; } } packet.AddInt8((byte)(checked (updateCount + 32) / 32)); packet.AddBitArray(UpdateMask, checked ((byte)(checked (updateCount + 32) / 32)) * 4); int num2 = UpdateMask.Count - 1; for (int i = 0; i <= num2; i++) { if (UpdateMask.Get(i)) { if (UpdateData[i] is uint) { packet.AddUInt32(Conversions.ToUInteger(UpdateData[i])); } else if (UpdateData[i] is float) { packet.AddSingle(Conversions.ToSingle(UpdateData[i])); } else { packet.AddInt32(Conversions.ToInteger(UpdateData[i])); } } } UpdateMask.SetAll(value: false); } if (packet is UpdatePacketClass @class) { @class.UpdatesCount++; } } }
public void On_MSG_RAID_ICON_TARGET(PacketClass packet, ClientClass client) { if (packet.Data.Length < 7) { return; // Too short packet } if (client.Character.Group is null) { return; } packet.GetInt16(); var icon = packet.GetInt8(); if (icon == 255) { // DONE: Send icon target list var response = new PacketClass(Opcodes.MSG_RAID_ICON_TARGET); response.AddInt8(1); // Target list for (byte i = 0; i <= 7; i++) { if (client.Character.Group.TargetIcons[i] == 0m) { continue; } response.AddInt8(i); response.AddUInt64(client.Character.Group.TargetIcons[i]); } client.Send(response); response.Dispose(); } else { if (icon > 7) { return; // Not a valid icon } if (packet.Data.Length < 15) { return; // Too short packet } var guid = packet.GetUInt64(); // DONE: Set the raid icon target client.Character.Group.TargetIcons[icon] = guid; var response = new PacketClass(Opcodes.MSG_RAID_ICON_TARGET); response.AddInt8(0); // Set target response.AddInt8(icon); response.AddUInt64(guid); client.Character.Group.Broadcast(response); response.Dispose(); } }
public void SendLoginOk(ClientClass client) { _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_AUTH_SESSION [{2}]", client.IP, client.Port, client.Account); Thread.Sleep(500); var response = new PacketClass(Opcodes.SMSG_AUTH_RESPONSE); response.AddInt8((byte)LoginResponse.LOGIN_OK); response.AddInt32(0); response.AddInt8(2); // BillingPlanFlags response.AddUInt32(0U); // BillingTimeRested client.Send(response); }
// Members Options public void SendGuildMotd(WcHandlerCharacter.CharacterObject objCharacter) { if (objCharacter.IsInGuild) { if (!string.IsNullOrEmpty(objCharacter.Guild.Motd)) { var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT); response.AddInt8((byte)GuildEvent.MOTD); response.AddInt8(1); response.AddString(objCharacter.Guild.Motd); objCharacter.Client.Send(response); response.Dispose(); } } }
public void On_CMSG_GUILD_DISBAND(PacketClass packet, ClientClass client) { // packet.GetInt16() _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GUILD_DISBAND", client.IP, client.Port); if (!client.Character.IsInGuild) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD); return; } if (!client.Character.IsGuildLeader) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PERMISSIONS); return; } // DONE: Clear all members var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT); response.AddInt8((byte)GuildEvent.DISBANDED); response.AddInt8(0); var guildId = (int)client.Character.Guild.Id; var tmpArray = client.Character.Guild.Members.ToArray(); foreach (var member in tmpArray) { if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(member)) { var tmp = _clusterServiceLocator.WorldCluster.CharacteRs; var argobjCharacter = tmp[member]; _clusterServiceLocator.WcGuild.RemoveCharacterFromGuild(argobjCharacter); tmp[member] = argobjCharacter; _clusterServiceLocator.WorldCluster.CharacteRs[member].Client.SendMultiplyPackets(response); } else { _clusterServiceLocator.WcGuild.RemoveCharacterFromGuild(member); } } _clusterServiceLocator.WcGuild.GuilDs[(uint)guildId].Dispose(); response.Dispose(); // DONE: Delete guild information _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update("DELETE FROM guilds WHERE guild_id = " + guildId + ";"); }
public void NotifyGuildStatus(WcHandlerCharacter.CharacterObject objCharacter, GuildEvent status) { if (objCharacter.Guild is null) { return; } var statuspacket = new PacketClass(Opcodes.SMSG_GUILD_EVENT); statuspacket.AddInt8((byte)status); statuspacket.AddInt8(1); statuspacket.AddString(objCharacter.Name); statuspacket.AddInt8(0); statuspacket.AddInt8(0); statuspacket.AddInt8(0); BroadcastToGuild(statuspacket, objCharacter.Guild, objCharacter.Guid); statuspacket.Dispose(); }
public void On_CMSG_DEL_IGNORE(PacketClass packet, ClientClass client) { _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_DEL_IGNORE", client.IP, client.Port); if (packet.Data.Length - 1 < 13) { return; } packet.GetInt16(); var response = new PacketClass(Opcodes.SMSG_FRIEND_STATUS); var guid = packet.GetUInt64(); try { var q = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT flags FROM character_social WHERE guid = {0} AND friend = {1};", client.Character.Guid, guid), ref q); if (q.Rows.Count > 0) { var flags = q.Rows[0].As <int>("flags"); var newFlags = (SocialFlag)flags ^ SocialFlag.SOCIAL_FLAG_IGNORED; if ((newFlags & (SocialFlag.SOCIAL_FLAG_FRIEND | SocialFlag.SOCIAL_FLAG_IGNORED)) == 0) { _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("DELETE FROM character_social WHERE friend = {1} AND guid = {0};", client.Character.Guid, guid)); } else { _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE character_social SET flags = {2} WHERE friend = {1} AND guid = {0};", client.Character.Guid, guid, newFlags)); } response.AddInt8((byte)FriendResult.FRIEND_IGNORE_REMOVED); } else { response.AddInt8((byte)FriendResult.FRIEND_IGNORE_NOT_FOUND); } } catch { response.AddInt8((byte)FriendResult.FRIEND_DB_ERROR); } response.AddUInt64(guid); client.Send(response); response.Dispose(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_FRIEND_STATUS", client.IP, client.Port); }
public void On_CMSG_GUILD_ACCEPT(PacketClass packet, ClientClass client) { if (client.Character.GuildInvited == 0L) { throw new ApplicationException("Character accepting guild invitation whihtout being invited."); } _clusterServiceLocator.WcGuild.AddCharacterToGuild(client.Character, (int)client.Character.GuildInvited); client.Character.GuildInvited = 0U; var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT); response.AddInt8((byte)GuildEvent.JOINED); response.AddInt8(1); response.AddString(client.Character.Name); var argnotTo = 0UL; _clusterServiceLocator.WcGuild.BroadcastToGuild(response, client.Character.Guild, notTo: argnotTo); response.Dispose(); _clusterServiceLocator.WcGuild.SendGuildRoster(client.Character); _clusterServiceLocator.WcGuild.SendGuildMotd(client.Character); }
public void On_MSG_SAVE_GUILD_EMBLEM(PacketClass packet, ClientClass client) { if (packet.Data.Length < 34) { return; } packet.GetInt16(); var unk0 = packet.GetInt32(); var unk1 = packet.GetInt32(); var tEmblemStyle = packet.GetInt32(); var tEmblemColor = packet.GetInt32(); var tBorderStyle = packet.GetInt32(); var tBorderColor = packet.GetInt32(); var tBackgroundColor = packet.GetInt32(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_SAVE_GUILD_EMBLEM [{2},{3}] [{4}:{5}:{6}:{7}:{8}]", client.IP, client.Port, unk0, unk1, tEmblemStyle, tEmblemColor, tBorderStyle, tBorderColor, tBackgroundColor); if (!client.Character.IsInGuild) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD); return; } if (!client.Character.IsGuildLeader) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PERMISSIONS); return; // TODO: Check if you have enough money // ElseIf client.Character.Copper < 100000 Then // SendInventoryChangeFailure(Client.Character, InventoryChangeFailure.EQUIP_ERR_NOT_ENOUGH_MONEY, 0, 0) // Exit Sub } client.Character.Guild.EmblemStyle = (byte)tEmblemStyle; client.Character.Guild.EmblemColor = (byte)tEmblemColor; client.Character.Guild.BorderStyle = (byte)tBorderStyle; client.Character.Guild.BorderColor = (byte)tBorderColor; client.Character.Guild.BackgroundColor = (byte)tBackgroundColor; _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE guilds SET guild_tEmblemStyle = {1}, guild_tEmblemColor = {2}, guild_tBorderStyle = {3}, guild_tBorderColor = {4}, guild_tBackgroundColor = {5} WHERE guild_id = {0};", client.Character.Guild.Id, tEmblemStyle, tEmblemColor, tBorderStyle, tBorderColor, tBackgroundColor)); _clusterServiceLocator.WcGuild.SendGuildQuery(client, client.Character.Guild.Id); var packetEvent = new PacketClass(Opcodes.SMSG_GUILD_EVENT); packetEvent.AddInt8((byte)GuildEvent.TABARDCHANGE); packetEvent.AddInt32((int)client.Character.Guild.Id); var argnotTo = 0UL; _clusterServiceLocator.WcGuild.BroadcastToGuild(packetEvent, client.Character.Guild, notTo: argnotTo); packetEvent.Dispose(); // TODO: This tabard design costs 10g! // Client.Character.Copper -= 100000 // Client.Character.SetUpdateFlag(EPlayerFields.PLAYER_FIELD_COINAGE, client.Character.Copper) // Client.Character.SendCharacterUpdate(False) }
public void On_CMSG_GUILD_MOTD(PacketClass packet, ClientClass client) { // Isn't the client even sending a null terminator for the motd if it's empty? if (packet.Data.Length - 1 < 6) { return; } packet.GetInt16(); var motd = ""; if (packet.Length != 4) { motd = packet.GetString().Replace("\"", "_").Replace("'", "_"); } _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GUILD_MOTD", client.IP, client.Port); if (!client.Character.IsInGuild) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD); return; } if (!client.Character.IsGuildRightSet(GuildRankRights.GR_RIGHT_SETMOTD)) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PERMISSIONS); return; } client.Character.Guild.Motd = motd; _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE guilds SET guild_MOTD = '{1}' WHERE guild_id = '{0}';", client.Character.Guild.Id, motd)); var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT); response.AddInt8((byte)GuildEvent.MOTD); response.AddInt8(1); response.AddString(motd); // DONE: Send message to everyone in the guild var argnotTo = 0UL; _clusterServiceLocator.WcGuild.BroadcastToGuild(response, client.Character.Guild, notTo: argnotTo); response.Dispose(); }
public void SendGroupList() { var groupCount = GetMembersCount(); for (byte i = 0, loopTo = (byte)(Members.Length - 1); i <= loopTo; i++) { if (Members[i] is object) { var packet = new PacketClass(Opcodes.SMSG_GROUP_LIST); packet.AddInt8((byte)Type); // GroupType 0:Party 1:Raid var memberFlags = (byte)(i / _clusterServiceLocator.GlobalConstants.GROUP_SUBGROUPSIZE); // If Members(i).GroupAssistant Then MemberFlags = MemberFlags Or &H1 packet.AddInt8(memberFlags); packet.AddInt32(groupCount - 1); for (byte j = 0, loopTo1 = (byte)(Members.Length - 1); j <= loopTo1; j++) { if (Members[j] is object && !ReferenceEquals(Members[j], Members[i])) { packet.AddString(Members[j].Name); packet.AddUInt64(Members[j].Guid); if (Members[j].IsInWorld) { packet.AddInt8(1); // CharOnline? } else { packet.AddInt8(0); } // CharOnline? memberFlags = (byte)(j / _clusterServiceLocator.GlobalConstants.GROUP_SUBGROUPSIZE); // If Members(j).GroupAssistant Then MemberFlags = MemberFlags Or &H1 packet.AddInt8(memberFlags); } } packet.AddUInt64(Members[Leader].Guid); packet.AddInt8((byte)LootMethod); if (_lootMaster != 255) { packet.AddUInt64(Members[_lootMaster].Guid); } else { packet.AddUInt64(0UL); } packet.AddInt8((byte)LootThreshold); packet.AddInt16(0); if (Members[i].Client is object) { Members[i].Client.Send(packet); } packet.Dispose(); } } }
public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref WS_GameObjects.GameObject updateObject) { checked { packet.AddInt8((byte)updateType); packet.AddPackGUID(updateObject.GUID); switch (updateObject.Type) { case GameObjectType.GAMEOBJECT_TYPE_TRAP: case GameObjectType.GAMEOBJECT_TYPE_DUEL_ARBITER: case GameObjectType.GAMEOBJECT_TYPE_FLAGSTAND: case GameObjectType.GAMEOBJECT_TYPE_FLAGDROP: updateType = ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF; break; } if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF) { packet.AddInt8(5); if (updateObject.Type is GameObjectType.GAMEOBJECT_TYPE_TRANSPORT or GameObjectType.GAMEOBJECT_TYPE_MO_TRANSPORT) { packet.AddInt8(82); }
public void SendFriendList(ClientClass client, WcHandlerCharacter.CharacterObject character) { // DONE: Query DB var q = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM character_social WHERE guid = {0} AND (flags & {1}) > 0;", character.Guid, Conversions.ToInteger(SocialFlag.SOCIAL_FLAG_FRIEND)), ref q); // DONE: Make the packet var smsgFriendList = new PacketClass(Opcodes.SMSG_FRIEND_LIST); if (q.Rows.Count > 0) { smsgFriendList.AddInt8((byte)q.Rows.Count); foreach (DataRow row in q.Rows) { var guid = row.As <ulong>("friend"); smsgFriendList.AddUInt64(guid); // Player GUID if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid) && _clusterServiceLocator.WorldCluster.CharacteRs[guid].IsInWorld) { if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].Dnd) { smsgFriendList.AddInt8((byte)FriendStatus.FRIEND_STATUS_DND); } else if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].Afk) { smsgFriendList.AddInt8((byte)FriendStatus.FRIEND_STATUS_AFK); } else { smsgFriendList.AddInt8((byte)FriendStatus.FRIEND_STATUS_ONLINE); } smsgFriendList.AddInt32((int)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Zone); // Area smsgFriendList.AddInt32(_clusterServiceLocator.WorldCluster.CharacteRs[guid].Level); // Level smsgFriendList.AddInt32((int)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Classe); // Class } else { smsgFriendList.AddInt8((byte)FriendStatus.FRIEND_STATUS_OFFLINE); } } } else { smsgFriendList.AddInt8(0); } client.Send(smsgFriendList); smsgFriendList.Dispose(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_FRIEND_LIST", client.IP, client.Port); }
public void NotifyFriendStatus(WcHandlerCharacter.CharacterObject objCharacter, FriendStatus s) { var q = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT guid FROM character_social WHERE friend = {0} AND (flags & {1}) > 0;", objCharacter.Guid, Conversions.ToInteger(SocialFlag.SOCIAL_FLAG_FRIEND)), ref q); // DONE: Send "Friend offline/online" var friendpacket = new PacketClass(Opcodes.SMSG_FRIEND_STATUS); friendpacket.AddInt8((byte)s); friendpacket.AddUInt64(objCharacter.Guid); foreach (DataRow row in q.Rows) { var guid = row.As <ulong>("guid"); if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid) && _clusterServiceLocator.WorldCluster.CharacteRs[guid].Client is object) { _clusterServiceLocator.WorldCluster.CharacteRs[guid].Client.SendMultiplyPackets(friendpacket); } } friendpacket.Dispose(); }
public void On_CMSG_NAME_QUERY(PacketClass packet, ClientClass client) { if (packet.Data.Length - 1 < 13) { return; } packet.GetInt16(); var guid = packet.GetUInt64(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_NAME_QUERY [GUID={2:X}]", client.IP, client.Port, guid); if (_clusterServiceLocator.CommonGlobalFunctions.GuidIsPlayer(guid) && _clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid)) { var smsgNameQueryResponse = new PacketClass(Opcodes.SMSG_NAME_QUERY_RESPONSE); smsgNameQueryResponse.AddUInt64(guid); smsgNameQueryResponse.AddString(_clusterServiceLocator.WorldCluster.CharacteRs[guid].Name); smsgNameQueryResponse.AddInt32((byte)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Race); smsgNameQueryResponse.AddInt32(_clusterServiceLocator.WorldCluster.CharacteRs[guid].Gender); smsgNameQueryResponse.AddInt32((byte)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Classe); smsgNameQueryResponse.AddInt8(0); client.Send(smsgNameQueryResponse); smsgNameQueryResponse.Dispose(); } else { // DONE: Send it to the world server if it wasn't found in the cluster try { client.Character.GetWorld.ClientPacket(client.Index, packet.Data); } catch { _clusterServiceLocator.WcNetwork.WorldServer.Disconnect("NULL", new List <uint> { client.Character.Map }); } } }
public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref WS_GameObjects.GameObjectObject updateObject) { checked { packet.AddInt8((byte)updateType); packet.AddPackGUID(updateObject.GUID); switch (updateObject.Type) { case GameObjectType.GAMEOBJECT_TYPE_TRAP: case GameObjectType.GAMEOBJECT_TYPE_DUEL_ARBITER: case GameObjectType.GAMEOBJECT_TYPE_FLAGSTAND: case GameObjectType.GAMEOBJECT_TYPE_FLAGDROP: updateType = ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF; break; } if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT || updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF) { packet.AddInt8(5); if (updateObject.Type == GameObjectType.GAMEOBJECT_TYPE_TRANSPORT || updateObject.Type == GameObjectType.GAMEOBJECT_TYPE_MO_TRANSPORT) { packet.AddInt8(82); } else { packet.AddInt8(80); } if (updateObject.Type == GameObjectType.GAMEOBJECT_TYPE_MO_TRANSPORT) { packet.AddSingle(0f); packet.AddSingle(0f); packet.AddSingle(0f); packet.AddSingle(updateObject.orientation); } else { packet.AddSingle(updateObject.positionX); packet.AddSingle(updateObject.positionY); packet.AddSingle(updateObject.positionZ); packet.AddSingle(updateObject.orientation); } packet.AddUInt32(WorldServiceLocator._CommonGlobalFunctions.GuidHigh(updateObject.GUID)); if (updateObject.Type == GameObjectType.GAMEOBJECT_TYPE_TRANSPORT || updateObject.Type == GameObjectType.GAMEOBJECT_TYPE_MO_TRANSPORT) { packet.AddInt32(WorldServiceLocator._WS_Network.MsTime()); } } if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT || updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF || updateType == ObjectUpdateType.UPDATETYPE_VALUES) { int updateCount = 0; int num = UpdateMask.Count - 1; for (int i = 0; i <= num; i++) { if (UpdateMask.Get(i)) { updateCount = i; } } packet.AddInt8((byte)(checked (updateCount + 32) / 32)); packet.AddBitArray(UpdateMask, checked ((byte)(checked (updateCount + 32) / 32)) * 4); int num2 = UpdateMask.Count - 1; for (int j = 0; j <= num2; j++) { if (UpdateMask.Get(j)) { if (UpdateData[j] is uint) { packet.AddUInt32(Conversions.ToUInteger(UpdateData[j])); } else if (UpdateData[j] is float) { packet.AddSingle(Conversions.ToSingle(UpdateData[j])); } else { packet.AddInt32(Conversions.ToInteger(UpdateData[j])); } } } UpdateMask.SetAll(value: false); } if (packet is UpdatePacketClass @class) { @class.UpdatesCount++; } } }
public void SendGuildRoster(WcHandlerCharacter.CharacterObject objCharacter) { if (!objCharacter.IsInGuild) { return; } // DONE: Count the ranks byte guildRanksCount = 0; for (var i = 0; i <= 9; i++) { if (!string.IsNullOrEmpty(objCharacter.Guild.Ranks[i])) { guildRanksCount = (byte)(guildRanksCount + 1); } } // DONE: Count the members var members = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query("SELECT char_online, char_guid, char_name, char_class, char_level, char_zone_id, char_logouttime, char_guildRank, char_guildPNote, char_guildOffNote FROM characters WHERE char_guildId = " + objCharacter.Guild.Id + ";", ref members); var response = new PacketClass(Opcodes.SMSG_GUILD_ROSTER); response.AddInt32(members.Rows.Count); response.AddString(objCharacter.Guild.Motd); response.AddString(objCharacter.Guild.Info); response.AddInt32(guildRanksCount); for (var i = 0; i <= 9; i++) { if (!string.IsNullOrEmpty(objCharacter.Guild.Ranks[i])) { response.AddUInt32(objCharacter.Guild.RankRights[i]); } } var officer = objCharacter.IsGuildRightSet(GuildRankRights.GR_RIGHT_VIEWOFFNOTE); for (int i = 0, loopTo = members.Rows.Count - 1; i <= loopTo; i++) { if (members.Rows[i].As <byte>("char_online") == 1) { response.AddUInt64(members.Rows[i].As <ulong>("char_guid")); response.AddInt8(1); // OnlineFlag response.AddString(members.Rows[i].As <string>("char_name")); response.AddInt32(members.Rows[i].As <int>("char_guildRank")); response.AddInt8(members.Rows[i].As <byte>("char_level")); response.AddInt8(members.Rows[i].As <byte>("char_class")); response.AddInt32(members.Rows[i].As <int>("char_zone_id")); response.AddString(members.Rows[i].As <string>("char_guildPNote")); if (officer) { response.AddString(members.Rows[i].As <string>("char_guildOffNote")); } else { response.AddInt8(0); } } else { response.AddUInt64(members.Rows[i].As <ulong>("char_guid")); response.AddInt8(0); // OfflineFlag response.AddString(members.Rows[i].As <string>("char_name")); response.AddInt32(members.Rows[i].As <int>("char_guildRank")); response.AddInt8(members.Rows[i].As <byte>("char_level")); response.AddInt8(members.Rows[i].As <byte>("char_class")); response.AddInt32(members.Rows[i].As <int>("char_zone_id")); // 0 = < 1 hour / 0.1 = 2.4 hours / 1 = 24 hours (1 day) // (Time logged out / 86400) = Days offline var daysOffline = (float)((_clusterServiceLocator.Functions.GetTimestamp(DateAndTime.Now) - members.Rows[i].As <uint>("char_logouttime")) / (double)DateInterval.Day); response.AddSingle(daysOffline); // Days offline response.AddString(members.Rows[i].As <string>("char_guildPNote")); if (officer) { response.AddString(members.Rows[i].As <string>("char_guildOffNote")); } else { response.AddInt8(0); } } } objCharacter.Client.Send(response); response.Dispose(); }
public void On_CMSG_AUTH_SESSION(PacketClass packet, ClientClass client) { // _WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}] [{1}:{2}] CMSG_AUTH_SESSION", Format(TimeOfDay, "hh:mm:ss"), client.IP, client.Port) packet.GetInt16(); var clientVersion = packet.GetInt32(); var clientSessionId = packet.GetInt32(); var clientAccount = packet.GetString(); var clientSeed = packet.GetInt32(); var clientHash = new byte[20]; for (var i = 0; i <= 19; i++) { clientHash[i] = packet.GetInt8(); } var clientAddOnsSize = packet.GetInt32(); // DONE: Set client.Account var tmp = clientAccount; // DONE: Kick if existing foreach (var tmpClientEntry in _clusterServiceLocator.WorldCluster.ClienTs) { if (tmpClientEntry.Value is object) { if (tmpClientEntry.Value.Account == tmp) { if (tmpClientEntry.Value.Character is object) { tmpClientEntry.Value.Character.Dispose(); tmpClientEntry.Value.Character = null; } tmpClientEntry.Value.Dispose(); } } } client.Account = tmp; // DONE: Set client.SS_Hash var result = new DataTable(); string query; query = "SELECT sessionkey, gmlevel FROM account WHERE username = '******';"; _clusterServiceLocator.WorldCluster.GetAccountDatabase().Query(query, ref result); if (result.Rows.Count > 0) { tmp = result.Rows[0].As <string>("sessionkey"); client.Access = (AccessLevel)result.Rows[0]["gmlevel"]; } else { _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.USER, "[{0}:{1}] AUTH_UNKNOWN_ACCOUNT: Account not in DB!", client.IP, client.Port); var responseUnkAcc = new PacketClass(Opcodes.SMSG_AUTH_RESPONSE); responseUnkAcc.AddInt8((byte)AuthResult.WOW_FAIL_UNKNOWN_ACCOUNT); client.Send(responseUnkAcc); return; } client.Client.PacketEncryption.Hash = new byte[40]; for (int i = 0, loopTo = Strings.Len(tmp) - 1; i <= loopTo; i += 2) { client.Client.PacketEncryption.Hash[i / 2] = (byte)Conversion.Val("&H" + Strings.Mid(tmp, i + 1, 2)); } client.Client.PacketEncryption.IsEncryptionEnabled = true; // DONE: Disconnect clients trying to enter with an invalid build if (clientVersion < REQUIRED_BUILD_LOW || clientVersion > REQUIRED_BUILD_HIGH) { var invalidVersion = new PacketClass(Opcodes.SMSG_AUTH_RESPONSE); invalidVersion.AddInt8((byte)AuthResult.WOW_FAIL_VERSION_INVALID); client.Send(invalidVersion); return; } // TODO: Make sure the correct client connected // Dim temp() As Byte = System.Text.Encoding.ASCII.GetBytes(clientAccount) // temp = Concat(temp, BitConverter.GetBytes(0)) // temp = Concat(temp, BitConverter.GetBytes(clientSeed)) // temp = Concat(temp, BitConverter.GetBytes(client.Index)) // temp = Concat(temp, client.SS_Hash) // Dim ShaDigest() As Byte = New System.Security.Cryptography.SHA1Managed().ComputeHash(temp) // _WorldCluster.Log.WriteLine(LogType.DEBUG, "Client Hash: {0}", BitConverter.ToString(clientHash).Replace("-", "")) // _WorldCluster.Log.WriteLine(LogType.DEBUG, "Server Hash: {0}", BitConverter.ToString(ShaDigest).Replace("-", "")) // For i As Integer = 0 To 19 // If clientHash(i) <> ShaDigest(i) Then // Dim responseFail As New PacketClass(OPCODES.SMSG_AUTH_RESPONSE) // responseFail.AddInt8(AuthResponseCodes.AUTH_FAILED) // client.Send(responseFail) // Exit Sub // End If // Next // DONE: If server full then queue, If GM/Admin let in if (_clusterServiceLocator.WorldCluster.ClienTs.Count > configurationProvider.GetConfiguration().ServerPlayerLimit & client.Access <= AccessLevel.Player) { ThreadPool.QueueUserWorkItem(client.EnQueue); } else { SendLoginOk(client); } // DONE: Addons info reading var decompressBuffer = new byte[packet.Data.Length - packet.Offset + 1]; Array.Copy(packet.Data, packet.Offset, decompressBuffer, 0, packet.Data.Length - packet.Offset); packet.Data = _clusterServiceLocator.GlobalZip.DeCompress(decompressBuffer); packet.Offset = 0; // DumpPacket(packet.Data) var addOnsNames = new List <string>(); var addOnsHashes = new List <uint>(); // Dim AddOnsConsoleWrite As String = String.Format("[{0}:{1}] Client addons loaded:", client.IP, client.Port) while (packet.Offset < clientAddOnsSize) { addOnsNames.Add(packet.GetString()); addOnsHashes.Add(packet.GetUInt32()); packet.GetInt32(); // Unk7 packet.GetInt8(); // Unk6 // AddOnsConsoleWrite &= String.Format("{0}{1} AddOnName: [{2,-30}], AddOnHash: [{3:X}]", vbCrLf, vbTab, AddOnsNames(AddOnsNames.Count - 1), AddOnsHashes(AddOnsHashes.Count - 1)) } // _WorldCluster.Log.WriteLine(LogType.DEBUG, AddOnsConsoleWrite) // DONE: Build mysql addons query // Not needed already - in 1.11 addons list is removed. // DONE: Send packet var addOnsEnable = new PacketClass(Opcodes.SMSG_ADDON_INFO); for (int i = 0, loopTo1 = addOnsNames.Count - 1; i <= loopTo1; i++) { if (File.Exists(string.Format(@"interface\{0}.pub", addOnsNames[i])) && addOnsHashes[i] != 0x1C776D01U) { // We have hash data addOnsEnable.AddInt8(2); // AddOn Type [1-enabled, 0-banned, 2-blizzard] addOnsEnable.AddInt8(1); // Unk var fs = new FileStream(string.Format(@"interface\{0}.pub", addOnsNames[i]), FileMode.Open, FileAccess.Read, FileShare.Read, 258, FileOptions.SequentialScan); var fb = new byte[257]; fs.Read(fb, 0, 257); // NOTE: Read from file addOnsEnable.AddByteArray(fb); addOnsEnable.AddInt32(0); addOnsEnable.AddInt8(0); } else { // We don't have hash data or already sent to client addOnsEnable.AddInt8(2); // AddOn Type [1-enabled, 0-banned, 2-blizzard] addOnsEnable.AddInt8(1); // Unk addOnsEnable.AddInt32(0); addOnsEnable.AddInt16(0); } } client.Send(addOnsEnable); addOnsEnable.Dispose(); }
/// <summary> /// Sends the battleground status. /// </summary> /// <param name="objCharacter">The obj char.</param> /// <param name="slot">The slot.</param> /// <returns></returns> private void SendBattlegroundStatus(WcHandlerCharacter.CharacterObject objCharacter, byte slot) { var status = BattlegroundStatus.STATUS_CLEAR; if (_queueTeam1.Contains(objCharacter) | _queueTeam2.Contains(objCharacter)) { status = BattlegroundStatus.STATUS_WAIT_QUEUE; } else if (_invitedTeam1.Contains(objCharacter) | _invitedTeam2.Contains(objCharacter)) { status = BattlegroundStatus.STATUS_WAIT_JOIN; } else if (_membersTeam1.Contains(objCharacter) | _membersTeam2.Contains(objCharacter)) { status = BattlegroundStatus.STATUS_IN_PROGRESS; } var p = new PacketClass(Opcodes.SMSG_BATTLEFIELD_STATUS); try { p.AddUInt32(slot); // Slot (0, 1 or 2) // p.AddInt8(0) 'ArenaType p.AddUInt32((uint)MapType); // MapType // p.AddInt8(&HD) 'Unk1 (0xD?) // p.AddInt8(0) 'Unk2 // p.AddInt16() 'Unk3 (String?) p.AddUInt32((uint)Id); // ID // p.AddInt32(0) 'Unk5 p.AddInt8(0); // alliance/horde for BG and skirmish/rated for Arenas p.AddUInt32((uint)status); switch (status) { case var @case when @case == BattlegroundStatus.STATUS_WAIT_QUEUE: { p.AddUInt32(120000U); // average wait time, milliseconds p.AddUInt32(1U); // time in queue, updated every minute? break; } case var case1 when case1 == BattlegroundStatus.STATUS_WAIT_JOIN: { p.AddUInt32(_map); // map id p.AddUInt32(60000U); // time to remove from queue, milliseconds break; } case var case2 when case2 == BattlegroundStatus.STATUS_IN_PROGRESS: { p.AddUInt32(_map); // map id p.AddUInt32(0U); // 0 at bg start, 120000 after bg end, time to bg auto leave, milliseconds p.AddUInt32(1U); // time from bg start, milliseconds p.AddInt8(1); // unk sometimes 0x0! break; } case var case3 when case3 == BattlegroundStatus.STATUS_CLEAR: { break; } // Do nothing } objCharacter.Client.Send(p); } finally { p.Dispose(); } }
public void On_CMSG_CHAR_ENUM(PacketClass packet, ClientClass client) { _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_CHAR_ENUM", client.IP, client.Port); // DONE: Query _WorldCluster.CHARACTERs DB var response = new PacketClass(Opcodes.SMSG_CHAR_ENUM); var mySqlQuery = new DataTable(); int accountId; try { _clusterServiceLocator.WorldCluster.GetAccountDatabase().Query(string.Format("SELECT id FROM account WHERE username = '******';", client.Account), ref mySqlQuery); accountId = mySqlQuery.Rows[0].As <int>("id"); mySqlQuery.Clear(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM characters WHERE account_id = '{0}' ORDER BY char_guid;", accountId), ref mySqlQuery); // DONE: Make The Packet response.AddInt8((byte)mySqlQuery.Rows.Count); for (int i = 0, loopTo = mySqlQuery.Rows.Count - 1; i <= loopTo; i++) { var dead = false; var deadMySqlQuery = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT COUNT(*) FROM corpse WHERE player = {0};", mySqlQuery.Rows[i]["char_guid"]), ref deadMySqlQuery); if (deadMySqlQuery.Rows[0].As <int>(0) > 0) { dead = true; } var petQuery = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT modelid, level, entry FROM character_pet WHERE owner = '{0}';", mySqlQuery.Rows[i]["char_guid"]), ref petQuery); response.AddInt64(mySqlQuery.Rows[i].As <long>("char_guid")); response.AddString(mySqlQuery.Rows[i].As <string>("char_name")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_race")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_class")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_gender")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_skin")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_face")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_hairStyle")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_hairColor")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_facialHair")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_level")); response.AddInt32(mySqlQuery.Rows[i].As <int>("char_zone_id")); response.AddInt32(mySqlQuery.Rows[i].As <int>("char_map_id")); response.AddSingle(mySqlQuery.Rows[i].As <float>("char_positionX")); response.AddSingle(mySqlQuery.Rows[i].As <float>("char_positionY")); response.AddSingle(mySqlQuery.Rows[i].As <float>("char_positionZ")); response.AddInt32(mySqlQuery.Rows[i].As <int>("char_guildId")); var playerState = (uint)CharacterFlagState.CHARACTER_FLAG_NONE; var forceRestrictions = mySqlQuery.Rows[i].As <uint>("force_restrictions"); if ((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_TRANSFER) != 0) { playerState += (uint)CharacterFlagState.CHARACTER_FLAG_LOCKED_FOR_TRANSFER; } if ((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_BILLING) != 0) { playerState += (uint)CharacterFlagState.CHARACTER_FLAG_LOCKED_BY_BILLING; } if ((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_RENAME) != 0) { playerState += (uint)CharacterFlagState.CHARACTER_FLAG_RENAME; } if (dead) { playerState += (uint)CharacterFlagState.CHARACTER_FLAG_GHOST; } response.AddUInt32(playerState); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_restState")); var petModel = 0; var petLevel = 0; var petFamily = 0; if (petQuery.Rows.Count > 0) { petModel = petQuery.Rows[0].As <int>("modelid"); petLevel = petQuery.Rows[0].As <int>("level"); var petFamilyQuery = new DataTable(); _clusterServiceLocator.WorldCluster.GetWorldDatabase().Query(string.Format("SELECT family FROM creature_template WHERE entry = '{0}'", petQuery.Rows[0]["entry"]), ref petFamilyQuery); petFamily = petFamilyQuery.Rows[0].As <int>("family"); } response.AddInt32(petModel); response.AddInt32(petLevel); response.AddInt32(petFamily); // DONE: Get items var guid = mySqlQuery.Rows[i].As <long>("char_guid"); var itemsMySqlQuery = new DataTable(); var characterDb = _clusterServiceLocator.WorldCluster.GetCharacterDatabase().SQLDBName; var worldDb = _clusterServiceLocator.WorldCluster.GetWorldDatabase().SQLDBName; _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT item_slot, displayid, inventorytype FROM " + characterDb + ".characters_inventory, " + worldDb + ".item_template WHERE item_bag = {0} AND item_slot <> 255 AND entry = item_id ORDER BY item_slot;", guid), ref itemsMySqlQuery); var e = itemsMySqlQuery.Rows.GetEnumerator(); e.Reset(); e.MoveNext(); var row = (DataRow)e.Current; // DONE: Add model info for (byte slot = 0, loopTo1 = (byte)EquipmentSlots.EQUIPMENT_SLOT_END; slot <= loopTo1; slot++) // - 1 { if (row is null || row.As <int>("item_slot") != slot) { // No equiped item in this slot response.AddInt32(0); // Item Model response.AddInt8(0); // Item Slot } else { // DONE: Do not show helmet or cloak if (((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_HIDECLOAK) != 0) && (EquipmentSlots)row.As <byte>("item_slot") == EquipmentSlots.EQUIPMENT_SLOT_BACK || ((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_HIDEHELM) != 0) && (EquipmentSlots)row.As <byte>("item_slot") == EquipmentSlots.EQUIPMENT_SLOT_HEAD) { response.AddInt32(0); // Item Model response.AddInt8(0); // Item Slot } else { response.AddInt32(row.As <int>("displayid")); // Item Model response.AddInt8(row.As <byte>("inventorytype")); } // Item Slot e.MoveNext(); row = (DataRow)e.Current; } }
public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref WS_Creatures.CreatureObject updateObject) { checked { packet.AddInt8((byte)updateType); packet.AddPackGUID(updateObject.GUID); if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT) { packet.AddInt8(3); } if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_MOVEMENT) { packet.AddInt8(112); packet.AddInt32(8388608); packet.AddInt32(WorldServiceLocator._WS_Network.MsTime()); packet.AddSingle(updateObject.positionX); packet.AddSingle(updateObject.positionY); packet.AddSingle(updateObject.positionZ); packet.AddSingle(updateObject.orientation); packet.AddSingle(0f); packet.AddSingle(WorldServiceLocator._WorldServer.CREATURESDatabase[updateObject.ID].WalkSpeed); packet.AddSingle(WorldServiceLocator._WorldServer.CREATURESDatabase[updateObject.ID].RunSpeed); packet.AddSingle(WorldServiceLocator._Global_Constants.UNIT_NORMAL_SWIM_BACK_SPEED); packet.AddSingle(WorldServiceLocator._Global_Constants.UNIT_NORMAL_SWIM_SPEED); packet.AddSingle(WorldServiceLocator._Global_Constants.UNIT_NORMAL_WALK_BACK_SPEED); packet.AddSingle(WorldServiceLocator._Global_Constants.UNIT_NORMAL_TURN_RATE); packet.AddUInt32(1u); } if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_VALUES) { var updateCount = 0; var num = UpdateMask.Count - 1; for (var i = 0; i <= num; i++) { if (UpdateMask.Get(i)) { updateCount = i; } } packet.AddInt8((byte)(checked (updateCount + 32) / 32)); packet.AddBitArray(UpdateMask, checked ((byte)(checked (updateCount + 32) / 32)) * 4); var num2 = UpdateMask.Count - 1; for (var j = 0; j <= num2; j++) { if (UpdateMask.Get(j)) { if (UpdateData[j] is uint) { packet.AddUInt32(Conversions.ToUInteger(UpdateData[j])); } else if (UpdateData[j] is float) { packet.AddSingle(Conversions.ToSingle(UpdateData[j])); } else { packet.AddInt32(Conversions.ToInteger(UpdateData[j])); } } } UpdateMask.SetAll(value: false); } if (packet is UpdatePacketClass @class) { @class.UpdatesCount++; } } }
public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref WS_PlayerData.CharacterObject updateObject) { packet.AddInt8(checked ((byte)updateType)); packet.AddPackGUID(updateObject.GUID); if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF) { packet.AddInt8(4); } if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF or ObjectUpdateType.UPDATETYPE_MOVEMENT) { var flags2 = updateObject.charMovementFlags & 0xFF; if (updateObject.OnTransport != null) { flags2 |= 0x2000000; } packet.AddInt8(112); packet.AddInt32(flags2); packet.AddInt32(WorldServiceLocator._WS_Network.MsTime()); packet.AddSingle(updateObject.positionX); packet.AddSingle(updateObject.positionY); packet.AddSingle(updateObject.positionZ); packet.AddSingle(updateObject.orientation); if (((uint)flags2 & 0x2000000u) != 0) { packet.AddUInt64(updateObject.OnTransport.GUID); packet.AddSingle(updateObject.transportX); packet.AddSingle(updateObject.transportY); packet.AddSingle(updateObject.transportZ); packet.AddSingle(updateObject.orientation); } packet.AddInt32(0); packet.AddSingle(updateObject.WalkSpeed); packet.AddSingle(updateObject.RunSpeed); packet.AddSingle(updateObject.RunBackSpeed); packet.AddSingle(updateObject.SwimSpeed); packet.AddSingle(updateObject.SwimBackSpeed); packet.AddSingle(updateObject.TurnRate); packet.AddUInt32(WorldServiceLocator._CommonGlobalFunctions.GuidLow(updateObject.GUID)); } checked { if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_VALUES or ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF) { var updateCount = 0; var num = UpdateMask.Count - 1; for (var i = 0; i <= num; i++) { if (UpdateMask.Get(i)) { updateCount = i; } } packet.AddInt8((byte)(checked (updateCount + 32) / 32)); packet.AddBitArray(UpdateMask, checked ((byte)(checked (updateCount + 32) / 32)) * 4); var num2 = UpdateMask.Count - 1; for (var j = 0; j <= num2; j++) { if (UpdateMask.Get(j)) { if (UpdateData[j] is uint) { packet.AddUInt32(Conversions.ToUInteger(UpdateData[j])); } else if (UpdateData[j] is float) { packet.AddSingle(Conversions.ToSingle(UpdateData[j])); } else { packet.AddInt32(Conversions.ToInteger(UpdateData[j])); } } } UpdateMask.SetAll(value: false); } if (packet is UpdatePacketClass @class) { @class.UpdatesCount++; } } }
public void On_CMSG_GUILD_LEADER(PacketClass packet, ClientClass client) { if (packet.Data.Length - 1 < 6) { return; } packet.GetInt16(); var playerName = packet.GetString(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GUILD_LEADER [{2}]", client.IP, client.Port, playerName); if (playerName.Length < 2) { return; } playerName = _clusterServiceLocator.Functions.CapitalizeName(playerName); if (!client.Character.IsInGuild) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD); return; } if (!client.Character.IsGuildLeader) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PERMISSIONS); return; } // DONE: Find new leader's GUID var mySqlQuery = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query("SELECT char_guid, char_guildId, char_guildrank FROM characters WHERE char_name = '" + playerName + "';", ref mySqlQuery); if (mySqlQuery.Rows.Count == 0) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_PLAYER_NOT_FOUND, playerName); return; } if (mySqlQuery.Rows[0].As <uint>("char_guildId") != client.Character.Guild.Id) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD_S, playerName); return; } var playerGuid = mySqlQuery.Rows[0].As <ulong>("char_guid"); client.Character.GuildRank = 1; // Officer client.Character.SendGuildUpdate(); if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(playerGuid)) { _clusterServiceLocator.WorldCluster.CharacteRs[playerGuid].GuildRank = 0; _clusterServiceLocator.WorldCluster.CharacteRs[playerGuid].SendGuildUpdate(); } client.Character.Guild.Leader = playerGuid; _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE guilds SET guild_leader = \"{1}\" WHERE guild_id = {0};", client.Character.Guild.Id, playerGuid)); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE characters SET char_guildRank = {0} WHERE char_guid = {1};", 0, playerGuid)); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE characters SET char_guildRank = {0} WHERE char_guid = {1};", client.Character.GuildRank, client.Character.Guid)); // DONE: Send notify message var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT); response.AddInt8((byte)GuildEvent.LEADER_CHANGED); response.AddInt8(2); response.AddString(client.Character.Name); response.AddString(playerName); var argnotTo = 0UL; _clusterServiceLocator.WcGuild.BroadcastToGuild(response, client.Character.Guild, notTo: argnotTo); response.Dispose(); }
public void On_CMSG_GUILD_REMOVE(PacketClass packet, ClientClass client) { if (packet.Data.Length - 1 < 6) { return; } packet.GetInt16(); var playerName = packet.GetString().Replace("'", "_").Replace("\"", "_"); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GUILD_REMOVE [{2}]", client.IP, client.Port, playerName); if (playerName.Length < 2) { return; } playerName = _clusterServiceLocator.Functions.CapitalizeName(playerName); // DONE: Player1 checks if (!client.Character.IsInGuild) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD); return; } if (!client.Character.IsGuildRightSet(GuildRankRights.GR_RIGHT_REMOVE)) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PERMISSIONS); return; } // DONE: Find player2's guid var q = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query("SELECT char_guid FROM characters WHERE char_name = '" + playerName + "';", ref q); // DONE: Removed checks if (q.Rows.Count == 0) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_PLAYER_NOT_FOUND, playerName); return; } if (!_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(q.Rows[0].As <ulong>("char_guid"))) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_PLAYER_NOT_FOUND, playerName); return; } var objCharacter = _clusterServiceLocator.WorldCluster.CharacteRs[q.Rows[0].As <ulong>("char_guid")]; if (objCharacter.IsGuildLeader) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_QUIT_S, GuildError.GUILD_LEADER_LEAVE); return; } // DONE: Send guild event var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT); response.AddInt8((byte)GuildEvent.REMOVED); response.AddInt8(2); response.AddString(playerName); response.AddString(objCharacter.Name); var argnotTo = 0UL; _clusterServiceLocator.WcGuild.BroadcastToGuild(response, client.Character.Guild, notTo: argnotTo); response.Dispose(); _clusterServiceLocator.WcGuild.RemoveCharacterFromGuild(objCharacter); }
public void On_CMSG_ADD_FRIEND(PacketClass packet, ClientClass client) { if (packet.Data.Length - 1 < 6) { return; } packet.GetInt16(); var response = new PacketClass(Opcodes.SMSG_FRIEND_STATUS); var name = packet.GetString(); var guid = 0UL; _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_ADD_FRIEND [{2}]", client.IP, client.Port, name); // DONE: Get GUID from DB var q = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT char_guid, char_race FROM characters WHERE char_name = \"{0}\";", name), ref q); if (q.Rows.Count > 0) { guid = (ulong)q.Rows[0].As <long>("char_guid"); var friendSide = _clusterServiceLocator.Functions.GetCharacterSide(q.Rows[0].As <byte>("char_race")); q.Clear(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT flags FROM character_social WHERE flags = {0}", Conversions.ToByte(SocialFlag.SOCIAL_FLAG_FRIEND)), ref q); var numberOfFriends = q.Rows.Count; q.Clear(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT flags FROM character_social WHERE guid = {0} AND friend = {1} AND flags = {2};", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_FRIEND)), ref q); if (guid == client.Character.Guid) { response.AddInt8((byte)FriendResult.FRIEND_SELF); response.AddUInt64(guid); } else if (q.Rows.Count > 0) { response.AddInt8((byte)FriendResult.FRIEND_ALREADY); response.AddUInt64(guid); } else if (numberOfFriends >= (int)SocialList.MAX_FRIENDS_ON_LIST) { response.AddInt8((byte)FriendResult.FRIEND_LIST_FULL); response.AddUInt64(guid); } else if (_clusterServiceLocator.Functions.GetCharacterSide((byte)client.Character.Race) != friendSide) { response.AddInt8((byte)FriendResult.FRIEND_ENEMY); response.AddUInt64(guid); } else if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid)) { response.AddInt8((byte)FriendResult.FRIEND_ADDED_ONLINE); response.AddUInt64(guid); response.AddString(name); if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].Dnd) { response.AddInt8((byte)FriendStatus.FRIEND_STATUS_DND); } else if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].Afk) { response.AddInt8((byte)FriendStatus.FRIEND_STATUS_AFK); } else { response.AddInt8((byte)FriendStatus.FRIEND_STATUS_ONLINE); } response.AddInt32((int)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Zone); response.AddInt32(_clusterServiceLocator.WorldCluster.CharacteRs[guid].Level); response.AddInt32((int)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Classe); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("INSERT INTO character_social (guid, friend, flags) VALUES ({0}, {1}, {2});", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_FRIEND))); } else { response.AddInt8((byte)FriendResult.FRIEND_ADDED_OFFLINE); response.AddUInt64(guid); response.AddString(name); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("INSERT INTO character_social (guid, friend, flags) VALUES ({0}, {1}, {2});", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_FRIEND))); } } else { response.AddInt8((byte)FriendResult.FRIEND_NOT_FOUND); response.AddUInt64(guid); } client.Send(response); response.Dispose(); q.Dispose(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_FRIEND_STATUS", client.IP, client.Port); }
public void On_CMSG_GUILD_DEMOTE(PacketClass packet, ClientClass client) { if (packet.Data.Length - 1 < 6) { return; } packet.GetInt16(); var playerName = _clusterServiceLocator.Functions.CapitalizeName(packet.GetString()); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GUILD_DEMOTE [{2}]", client.IP, client.Port, playerName); if (!client.Character.IsInGuild) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD); return; } if (!client.Character.IsGuildRightSet(GuildRankRights.GR_RIGHT_PROMOTE)) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PERMISSIONS); return; } // DONE: Find demoted player's guid var q = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query("SELECT char_guid FROM characters WHERE char_name = '" + playerName.Replace("'", "_") + "';", ref q); // DONE: Demoted checks if (q.Rows.Count == 0) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_NAME_INVALID); return; } if (!_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(q.Rows[0].As <ulong>("char_guid"))) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_PLAYER_NOT_FOUND, playerName); return; } var objCharacter = _clusterServiceLocator.WorldCluster.CharacteRs[q.Rows[0].As <ulong>("char_guid")]; if (objCharacter.Guild.Id != client.Character.Guild.Id) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD_S, playerName); return; } if (objCharacter.GuildRank <= client.Character.GuildRank) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_PERMISSIONS); return; } if (objCharacter.GuildRank == _clusterServiceLocator.GlobalConstants.GUILD_RANK_MAX) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_INTERNAL); return; } // DONE: Max defined rank check if (string.IsNullOrEmpty(Strings.Trim(client.Character.Guild.Ranks[objCharacter.GuildRank + 1]))) { _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_INVITE_S, GuildError.GUILD_INTERNAL); return; } // DONE: Do the real update objCharacter.GuildRank = (byte)(objCharacter.GuildRank + 1); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE characters SET char_guildRank = {0} WHERE char_guid = {1};", objCharacter.GuildRank, objCharacter.Guid)); objCharacter.SendGuildUpdate(); // DONE: Send event to guild var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT); response.AddInt8((byte)GuildEvent.DEMOTION); response.AddInt8(3); response.AddString(objCharacter.Name); response.AddString(playerName); response.AddString(client.Character.Guild.Ranks[objCharacter.GuildRank]); var argnotTo = 0UL; _clusterServiceLocator.WcGuild.BroadcastToGuild(response, client.Character.Guild, notTo: argnotTo); response.Dispose(); }