public void SendFactions(ref WS_Network.ClientClass client, ref WS_PlayerData.CharacterObject Character) { Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_INITIALIZE_FACTIONS); try { packet.AddInt32(64); byte i = 0; do { checked { if (Character.Reputation != null) { packet.AddInt8((byte)Character.Reputation[i].Flags); } packet.AddInt32(Character.Reputation[i].Value); i = (byte)unchecked ((uint)(i + 1)); } }while (i <= 63u); client.Send(ref packet); } finally { packet.Dispose(); } }
public void SendWeather(int ZoneID, ref WS_Network.ClientClass client) { if (WeatherZones.ContainsKey(ZoneID)) { WeatherZone Weather = WeatherZones[ZoneID]; Packets.PacketClass SMSG_WEATHER = new Packets.PacketClass(Opcodes.SMSG_WEATHER); SMSG_WEATHER.AddInt32((int)Weather.CurrentWeather); SMSG_WEATHER.AddSingle(Weather.Intensity); SMSG_WEATHER.AddInt32(Weather.GetSound()); client.Send(ref SMSG_WEATHER); SMSG_WEATHER.Dispose(); } }
public void SendTaxiMenu(ref WS_PlayerData.CharacterObject objCharacter, ulong cGuid) { if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(cGuid)) { return; } int currentTaxi = WorldServiceLocator._WS_DBCDatabase.GetNearestTaxi(WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].positionX, WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].positionY, checked ((int)WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].MapID)); if (!objCharacter.TaxiZones[currentTaxi]) { objCharacter.TaxiZones.Set(currentTaxi, value: true); Packets.PacketClass SMSG_NEW_TAXI_PATH = new Packets.PacketClass(Opcodes.SMSG_NEW_TAXI_PATH); try { objCharacter.client.Send(ref SMSG_NEW_TAXI_PATH); } finally { SMSG_NEW_TAXI_PATH.Dispose(); } Packets.PacketClass SMSG_TAXINODE_STATUS = new Packets.PacketClass(Opcodes.SMSG_TAXINODE_STATUS); try { SMSG_TAXINODE_STATUS.AddUInt64(cGuid); SMSG_TAXINODE_STATUS.AddInt8(1); objCharacter.client.Send(ref SMSG_TAXINODE_STATUS); } finally { SMSG_TAXINODE_STATUS.Dispose(); } } else { Packets.PacketClass SMSG_SHOWTAXINODES = new Packets.PacketClass(Opcodes.SMSG_SHOWTAXINODES); try { SMSG_SHOWTAXINODES.AddInt32(1); SMSG_SHOWTAXINODES.AddUInt64(cGuid); SMSG_SHOWTAXINODES.AddInt32(currentTaxi); SMSG_SHOWTAXINODES.AddBitArray(objCharacter.TaxiZones, 32); objCharacter.client.Send(ref SMSG_SHOWTAXINODES); } finally { SMSG_SHOWTAXINODES.Dispose(); } } }
public void On_CMSG_LOOT_MONEY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_LOOT_MONEY", client.IP, client.Port); if (!LootTable.ContainsKey(client.Character.lootGUID)) { return; } checked { if (client.Character.IsInGroup) { List <WS_Base.BaseUnit> members = WorldServiceLocator._WS_Spells.GetPartyMembersAroundMe(ref client.Character, 100f); int copper2 = LootTable[client.Character.lootGUID].Money / members.Count + 1; LootTable[client.Character.lootGUID].Money = 0; Packets.PacketClass sharePcket = new Packets.PacketClass(Opcodes.SMSG_LOOT_MONEY_NOTIFY); sharePcket.AddInt32(copper2); foreach (WS_PlayerData.CharacterObject character in members) { character.client.SendMultiplyPackets(ref sharePcket); ref uint copper3 = ref character.Copper; copper3 = (uint)(copper3 + copper2); character.SetUpdateFlag(1176, character.Copper); character.SaveCharacter(); } client.SendMultiplyPackets(ref sharePcket); ref uint copper4 = ref client.Character.Copper; copper4 = (uint)(copper4 + copper2); sharePcket.Dispose(); }
public void SendActionButtons(ref WS_Network.ClientClass client, ref WS_PlayerData.CharacterObject Character) { Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_ACTION_BUTTONS); try { byte i = 0; do { checked { if (Character.ActionButtons.ContainsKey(i)) { packet.AddUInt16((ushort)Character.ActionButtons[i].Action); packet.AddInt8(Character.ActionButtons[i].ActionType); packet.AddInt8(Character.ActionButtons[i].ActionMisc); } else { packet.AddInt32(0); } i = (byte)unchecked ((uint)(i + 1)); } }while (i <= 119u); client.Send(ref packet); } finally { packet.Dispose(); } }
public void On_CMSG_CANCEL_TRADE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { if (client == null || client.Character == null) { return; } WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_CANCEL_TRADE", client.IP, client.Port); if (client.Character.tradeInfo == null) { return; } Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response.AddInt32(3); if (client.Character.tradeInfo.Target != null) { client.Character.tradeInfo.Target.client.SendMultiplyPackets(ref response); } if (client.Character.tradeInfo.Trader != null) { client.Character.tradeInfo.Trader.client.SendMultiplyPackets(ref response); } } finally { response.Dispose(); } client.Character.tradeInfo.Dispose(); }
public void DoTrade(ref WS_PlayerData.CharacterObject Who) { Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response.AddInt32(4); if (Trader == Who) { Target.client.SendMultiplyPackets(ref response); TraderAccept = true; } else { Trader.client.SendMultiplyPackets(ref response); TargetAccept = true; } } finally { response.Dispose(); } if (TargetAccept && TraderAccept) { DoTrade(); } }
public void SendUpdate() { Packets.PacketClass SMSG_WEATHER = new Packets.PacketClass(Opcodes.SMSG_WEATHER); SMSG_WEATHER.AddInt32((int)CurrentWeather); SMSG_WEATHER.AddSingle(Intensity); SMSG_WEATHER.AddInt32(GetSound()); try { WorldServiceLocator._WorldServer.CHARACTERs_Lock.AcquireReaderLock(WorldServiceLocator._Global_Constants.DEFAULT_LOCK_TIMEOUT); try { foreach (KeyValuePair <ulong, WS_PlayerData.CharacterObject> Character in WorldServiceLocator._WorldServer.CHARACTERs) { if (Character.Value.client != null && Character.Value.ZoneID == ZoneID) { Character.Value.client.SendMultiplyPackets(ref SMSG_WEATHER); } } } catch (Exception ex4) { ProjectData.SetProjectError(ex4); Exception ex3 = ex4; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "Error updating Weather.{0}{1}", Environment.NewLine, ex3.ToString()); ProjectData.ClearProjectError(); } finally { WorldServiceLocator._WorldServer.CHARACTERs_Lock.ReleaseReaderLock(); } } catch (ApplicationException ex5) { ProjectData.SetProjectError(ex5); ApplicationException ex2 = ex5; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.WARNING, "Update: Weather Manager timed out"); ProjectData.ClearProjectError(); } catch (Exception ex6) { ProjectData.SetProjectError(ex6); Exception ex = ex6; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "Error updating Weather.{0}{1}", Environment.NewLine, ex.ToString()); ProjectData.ClearProjectError(); } SMSG_WEATHER.Dispose(); }
public void On_CMSG_LOGOUT_CANCEL(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { try { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_LOGOUT_CANCEL", client.IP, client.Port); if (client != null && client.Character != null && client.Character.LogoutTimer != null) { client.Character.LogoutTimer?.Dispose(); client.Character.LogoutTimer = null; Packets.UpdateClass UpdateData = new Packets.UpdateClass(WorldServiceLocator._Global_Constants.FIELD_MASK_SIZE_PLAYER); Packets.PacketClass SMSG_UPDATE_OBJECT = new Packets.PacketClass(Opcodes.SMSG_UPDATE_OBJECT); try { SMSG_UPDATE_OBJECT.AddInt32(1); SMSG_UPDATE_OBJECT.AddInt8(0); client.Character.cUnitFlags &= -262145; UpdateData.SetUpdateFlag(46, client.Character.cUnitFlags); client.Character.StandState = 0; UpdateData.SetUpdateFlag(138, client.Character.cBytes1); WS_PlayerData.CharacterObject updateObject = client.Character; UpdateData.AddToPacket(ref SMSG_UPDATE_OBJECT, ObjectUpdateType.UPDATETYPE_VALUES, ref updateObject); client.Send(ref SMSG_UPDATE_OBJECT); } finally { SMSG_UPDATE_OBJECT.Dispose(); } Packets.PacketClass packetACK = new Packets.PacketClass(Opcodes.SMSG_STANDSTATE_CHANGE_ACK); try { packetACK.AddInt8(0); client.Send(ref packetACK); } finally { packetACK.Dispose(); } Packets.PacketClass SMSG_LOGOUT_CANCEL_ACK = new Packets.PacketClass(Opcodes.SMSG_LOGOUT_CANCEL_ACK); try { client.Send(ref SMSG_LOGOUT_CANCEL_ACK); } finally { SMSG_LOGOUT_CANCEL_ACK.Dispose(); } WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_LOGOUT_CANCEL_ACK", client.IP, client.Port); client.Character.SetMoveUnroot(); } } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception e = ex; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "Error while trying to cancel logout.{0}", Environment.NewLine + e); ProjectData.ClearProjectError(); } }
public void SendBindPointUpdate(ref WS_Network.ClientClass client, ref WS_PlayerData.CharacterObject Character) { Packets.PacketClass SMSG_BINDPOINTUPDATE = new Packets.PacketClass(Opcodes.SMSG_BINDPOINTUPDATE); try { SMSG_BINDPOINTUPDATE.AddSingle(Character.bindpoint_positionX); SMSG_BINDPOINTUPDATE.AddSingle(Character.bindpoint_positionY); SMSG_BINDPOINTUPDATE.AddSingle(Character.bindpoint_positionZ); SMSG_BINDPOINTUPDATE.AddInt32(Character.bindpoint_map_id); SMSG_BINDPOINTUPDATE.AddInt32(Character.bindpoint_zone_id); client.Send(ref SMSG_BINDPOINTUPDATE); } finally { SMSG_BINDPOINTUPDATE.Dispose(); } }
public void On_CMSG_MAIL_DELETE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { if (checked (packet.Data.Length - 1) >= 17) { packet.GetInt16(); ulong GameObjectGUID = packet.GetUInt64(); int MailID = packet.GetInt32(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MAIL_DELETE [MailID={2}]", client.IP, client.Port, MailID); WorldServiceLocator._WorldServer.CharacterDatabase.Update($"DELETE FROM characters_mail WHERE mail_id = {MailID};"); Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_SEND_MAIL_RESULT); response.AddInt32(MailID); response.AddInt32(4); response.AddInt32(0); client.Send(ref response); response.Dispose(); } }
public void On_CMSG_BATTLEMASTER_HELLO(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { if (checked (packet.Data.Length - 1) < 13) { return; } packet.GetInt16(); ulong GUID = packet.GetUInt64(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_BATTLEMASTER_HELLO [{2:X}]", client.IP, client.Port, GUID); if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID) || (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].CreatureInfo.cNpcFlags & 0x800) == 0 || !WorldServiceLocator._WS_DBCDatabase.Battlemasters.ContainsKey(WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].ID)) { return; } byte BGType = WorldServiceLocator._WS_DBCDatabase.Battlemasters[WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].ID]; if (!WorldServiceLocator._WS_DBCDatabase.Battlegrounds.ContainsKey(BGType)) { return; } if (WorldServiceLocator._WS_DBCDatabase.Battlegrounds[BGType].MinLevel > (uint)client.Character.Level || WorldServiceLocator._WS_DBCDatabase.Battlegrounds[BGType].MaxLevel < (uint)client.Character.Level) { WorldServiceLocator._Functions.SendMessageNotification(ref client, "You don't meet Battleground level requirements"); return; } Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_BATTLEFIELD_LIST); try { response.AddUInt64(client.Character.GUID); response.AddInt32(BGType); List <int> Battlegrounds = WorldServiceLocator._WorldServer.ClsWorldServer.Cluster.BattlefieldList(BGType); response.AddInt8(0); response.AddInt32(Battlegrounds.Count); foreach (int Instance in Battlegrounds) { response.AddInt32(Instance); } client.Send(ref response); } finally { response.Dispose(); } }
public void On_CMSG_MAIL_RETURN_TO_SENDER(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { checked { if (packet.Data.Length - 1 >= 17) { packet.GetInt16(); ulong GameObjectGUID = packet.GetUInt64(); int MailID = packet.GetInt32(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MAIL_RETURN_TO_SENDER [MailID={2}]", client.IP, client.Port, MailID); int MailTime = (int)(WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now) + 2592000L); WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("UPDATE characters_mail SET mail_time = {1}, mail_read = 0, mail_receiver = (mail_receiver + mail_sender), mail_sender = (mail_receiver - mail_sender), mail_receiver = (mail_receiver - mail_sender) WHERE mail_id = {0};", MailID, MailTime)); Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_SEND_MAIL_RESULT); response.AddInt32(MailID); response.AddInt32(3); response.AddInt32(0); client.Send(ref response); response.Dispose(); } } }
public void SendPetitionActivate(ref WS_PlayerData.CharacterObject objCharacter, ulong cGUID) { if (WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(cGUID)) { byte Count = 3; if (((uint)WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGUID].CreatureInfo.cNpcFlags & 4u) != 0) { Count = 1; } Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_PETITION_SHOWLIST); packet.AddUInt64(cGUID); packet.AddInt8(1); if (Count == 1) { packet.AddInt32(1); packet.AddInt32(WorldServiceLocator._Global_Constants.PETITION_GUILD); packet.AddInt32(16161); packet.AddInt32(WorldServiceLocator._Global_Constants.PETITION_GUILD_PRICE); packet.AddInt32(0); packet.AddInt32(9); } objCharacter.client.Send(ref packet); packet.Dispose(); } }
public void Send_SMSG_SET_REST_START(ref WS_Network.ClientClass client, ref WS_PlayerData.CharacterObject Character) { Packets.PacketClass SMSG_SET_REST_START = new Packets.PacketClass(Opcodes.SMSG_SET_REST_START); try { SMSG_SET_REST_START.AddInt32(WorldServiceLocator._WS_Network.MsTime()); client.Send(ref SMSG_SET_REST_START); } finally { SMSG_SET_REST_START.Dispose(); } }
private void SendActivateTaxiReply(ref WS_Network.ClientClass client, ActivateTaxiReplies reply) { Packets.PacketClass taxiFailed = new Packets.PacketClass(Opcodes.SMSG_ACTIVATETAXIREPLY); try { taxiFailed.AddInt32((int)reply); client.Send(ref taxiFailed); } finally { taxiFailed.Dispose(); } }
public void EndRoll(object state) { foreach (WS_PlayerData.CharacterObject objCharacter in Rolls) { if (!Looters.ContainsKey(objCharacter)) { Looters[objCharacter] = 0; Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_LOOT_ROLL); response.AddUInt64(LootObject.GUID); response.AddInt32(LootSlot); response.AddUInt64(objCharacter.GUID); response.AddInt32(Item.ItemID); response.AddInt32(0); response.AddInt32(0); response.AddInt8(249); response.AddInt8(0); Broadcast(ref response); } } RollTimeoutTimer.Dispose(); RollTimeoutTimer = null; Check(); }
public void SendTransferAborted(ref WS_Network.ClientClass client, int Map, TransferAbortReason Reason) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_TRANSFER_ABORTED [{2}:{3}]", client.IP, client.Port, Map, Reason); Packets.PacketClass p = new Packets.PacketClass(Opcodes.SMSG_TRANSFER_ABORTED); try { p.AddInt32(Map); p.AddInt16((short)Reason); client.Send(ref p); } finally { p.Dispose(); } }
public void Initialize(ref WS_PlayerData.CharacterObject objCharacter) { if (ObjectivesDeliver > 0) { ItemObject tmpItem = new ItemObject(ObjectivesDeliver, objCharacter.GUID); if (!objCharacter.ItemADD(ref tmpItem)) { tmpItem.Delete(); Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_QUESTGIVER_QUEST_FAILED); response.AddInt32(ID); response.AddInt32(4); objCharacter.client.Send(ref response); response.Dispose(); return; } objCharacter.LogLootItem(tmpItem, 1, Recieved: true, Created: false); } byte i = 0; do { checked { if (ObjectivesItem[i] != 0) { ProgressItem[i] = (byte)objCharacter.ItemCOUNT(ObjectivesItem[i]); } i = (byte)unchecked ((uint)(i + 1)); } }while (i <= 3u); if (((uint)ObjectiveFlags & 2u) != 0) { Explored = false; } IsCompleted(); }
public void ConvertToBones() { WorldServiceLocator._WorldServer.CharacterDatabase.Update($"DELETE FROM corpse WHERE player = \"{Owner}\";"); Flags = 5; Owner = 0uL; int j = 0; checked { do { Items[j] = 0; j++; }while (j <= 18); Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_UPDATE_OBJECT); try { packet.AddInt32(1); packet.AddInt8(0); Packets.UpdateClass tmpUpdate = new Packets.UpdateClass(WorldServiceLocator._Global_Constants.FIELD_MASK_SIZE_CORPSE); try { tmpUpdate.SetUpdateFlag(6, 0); tmpUpdate.SetUpdateFlag(35, 5); int i = 0; do { tmpUpdate.SetUpdateFlag(13 + i, 0); i++; }while (i <= 18); CorpseObject updateObject = this; tmpUpdate.AddToPacket(ref packet, ObjectUpdateType.UPDATETYPE_VALUES, ref updateObject); SendToNearPlayers(ref packet); } finally { tmpUpdate.Dispose(); } } finally { packet.Dispose(); } } }
public void On_CMSG_EMOTE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { if (checked (packet.Data.Length - 1) >= 9) { packet.GetInt16(); int emoteID = packet.GetInt32(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_EMOTE [{2}]", client.IP, client.Port, emoteID); Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_EMOTE); try { response.AddInt32(emoteID); response.AddUInt64(client.Character.GUID); client.Character.SendToNearPlayers(ref response); } finally { response.Dispose(); } } }
public void On_MSG_QUERY_NEXT_MAIL_TIME(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_QUERY_NEXT_MAIL_TIME", client.IP, client.Port); DataTable MySQLQuery = new DataTable(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT COUNT(*) FROM characters_mail WHERE mail_read = 0 AND mail_receiver = {client.Character.GUID} AND mail_time > {WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)};", ref MySQLQuery); if (Operators.ConditionalCompareObjectGreater(MySQLQuery.Rows[0][0], 0, TextCompare: false)) { Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.MSG_QUERY_NEXT_MAIL_TIME); response2.AddInt32(0); client.Send(ref response2); response2.Dispose(); } else { Packets.PacketClass response = new Packets.PacketClass(Opcodes.MSG_QUERY_NEXT_MAIL_TIME); response.AddInt8(0); response.AddInt8(192); response.AddInt8(168); response.AddInt8(199); client.Send(ref response); response.Dispose(); } }
public void SendInitialSpells(ref WS_Network.ClientClass client, ref WS_PlayerData.CharacterObject Character) { Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_INITIAL_SPELLS); checked { try { packet.AddInt8(0); int countPos = packet.Data.Length; packet.AddInt16(0); int spellCount = 0; Dictionary <int, KeyValuePair <uint, int> > spellCooldowns = new Dictionary <int, KeyValuePair <uint, int> >(); foreach (KeyValuePair <int, WS_Spells.CharacterSpell> Spell in Character.Spells) { if (Spell.Value.Active == 1) { packet.AddUInt16((ushort)Spell.Key); packet.AddInt16(0); spellCount++; if (Spell.Value.Cooldown != 0) { spellCooldowns.Add(Spell.Key, new KeyValuePair <uint, int>(Spell.Value.Cooldown, 0)); } } } packet.AddInt16((short)spellCount, countPos); spellCount = 0; countPos = packet.Data.Length; packet.AddInt16(0); foreach (KeyValuePair <int, KeyValuePair <uint, int> > Cooldown in spellCooldowns) { if (WorldServiceLocator._WS_Spells.SPELLs.ContainsKey(Cooldown.Key)) { packet.AddUInt16((ushort)Cooldown.Key); int timeLeft = 0; if (Cooldown.Value.Key > WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)) { timeLeft = (int)(checked (Cooldown.Value.Key - WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)) * 1000L); } packet.AddUInt16((ushort)Cooldown.Value.Value); packet.AddUInt16((ushort)WorldServiceLocator._WS_Spells.SPELLs[Cooldown.Key].Category); if (WorldServiceLocator._WS_Spells.SPELLs[Cooldown.Key].CategoryCooldown > 0) { packet.AddInt32(0); packet.AddInt32(timeLeft); } else { packet.AddInt32(timeLeft); packet.AddInt32(0); } spellCount++; } } packet.AddInt16((short)spellCount, countPos); client.Send(ref packet); } finally { packet.Dispose(); } } }
public void SendInitWorldStates(ref WS_Network.ClientClass client, ref WS_PlayerData.CharacterObject Character) { Character.ZoneCheck(); ushort NumberOfFields; switch (Character.ZoneID) { case 0: case 1: case 4: case 8: case 10: case 11: case 12: case 36: case 38: case 40: case 41: case 51: case 267: case 1519: case 1537: case 2257: case 2918: NumberOfFields = 6; break; case 2597: NumberOfFields = 81; break; case 3277: NumberOfFields = 14; break; case 3358: case 3820: NumberOfFields = 38; break; case 3483: NumberOfFields = 22; break; case 3519: NumberOfFields = 36; break; case 3521: NumberOfFields = 35; break; case 3698: case 3702: case 3968: NumberOfFields = 9; break; case 3703: NumberOfFields = 9; break; default: NumberOfFields = 10; break; } Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_INIT_WORLD_STATES); try { packet.AddUInt32(Character.MapID); packet.AddInt32(Character.ZoneID); packet.AddInt32(Character.AreaID); packet.AddUInt16(NumberOfFields); packet.AddUInt32(2264u); packet.AddUInt32(0u); packet.AddUInt32(2263u); packet.AddUInt32(0u); packet.AddUInt32(2262u); packet.AddUInt32(0u); packet.AddUInt32(2261u); packet.AddUInt32(0u); packet.AddUInt32(2260u); packet.AddUInt32(0u); packet.AddUInt32(2259u); packet.AddUInt32(0u); switch (Character.ZoneID) { case 3968: packet.AddUInt32(3000u); packet.AddUInt32(0u); packet.AddUInt32(3001u); packet.AddUInt32(0u); packet.AddUInt32(3002u); packet.AddUInt32(0u); break; default: packet.AddUInt32(2324u); packet.AddUInt32(0u); packet.AddUInt32(2323u); packet.AddUInt32(0u); packet.AddUInt32(2322u); packet.AddUInt32(0u); packet.AddUInt32(2325u); packet.AddUInt32(0u); break; case 1: case 11: case 12: case 38: case 40: case 51: case 1519: case 1537: case 2257: case 2597: case 3277: case 3358: case 3820: break; } client.Send(ref packet); } finally { packet.Dispose(); } }
public void On_CMSG_GET_MAIL_LIST(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { checked { if (packet.Data.Length - 1 < 13) { return; } packet.GetInt16(); var GameObjectGUID = packet.GetUInt64(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GET_MAIL_LIST [GUID={2:X}]", client.IP, client.Port, GameObjectGUID); try { DataTable MySQLQuery = new(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT mail_id FROM characters_mail WHERE mail_time < {WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)};", ref MySQLQuery); if (MySQLQuery.Rows.Count > 0) { var b = (byte)(MySQLQuery.Rows.Count - 1); byte j = 0; while (j <= (uint)b) { WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("DELETE FROM characters_mail WHERE mail_id = {0};", RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[j]["mail_id"]))); j = (byte)unchecked ((uint)(j + 1)); } } WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT * FROM characters_mail WHERE mail_receiver = {client.Character.GUID};", ref MySQLQuery); Packets.PacketClass response = new(Opcodes.SMSG_MAIL_LIST_RESULT); response.AddInt8((byte)MySQLQuery.Rows.Count); if (MySQLQuery.Rows.Count > 0) { var b2 = (byte)(MySQLQuery.Rows.Count - 1); byte i = 0; while (i <= (uint)b2) { response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_id")); response.AddInt8(MySQLQuery.Rows[i].As <byte>("mail_type")); var left = MySQLQuery.Rows[i]["mail_type"]; if (Operators.ConditionalCompareObjectEqual(left, MailTypeInfo.NORMAL, TextCompare: false)) { response.AddUInt64(MySQLQuery.Rows[i].As <ulong>("mail_sender")); } else if (Operators.ConditionalCompareObjectEqual(left, MailTypeInfo.AUCTION, TextCompare: false)) { response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_sender")); } response.AddString(MySQLQuery.Rows[i].As <string>("mail_subject")); if (Operators.ConditionalCompareObjectNotEqual(MySQLQuery.Rows[i]["mail_body"], "", TextCompare: false)) { response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_id")); } else { response.AddInt32(0); } response.AddInt32(0); response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_stationary")); if (decimal.Compare(new decimal(MySQLQuery.Rows[i].As <ulong>("item_guid")), 0m) > 0) { var tmpItem = WorldServiceLocator._WS_Items.LoadItemByGUID(MySQLQuery.Rows[i].As <ulong>("item_guid")); response.AddInt32(tmpItem.ItemEntry); if (tmpItem.Enchantments.ContainsKey(0)) { packet.AddInt32(tmpItem.Enchantments[0].ID); } else { packet.AddInt32(0); } response.AddInt32(tmpItem.RandomProperties); response.AddInt32(0); response.AddInt8((byte)tmpItem.StackCount); response.AddInt32(tmpItem.ChargesLeft); response.AddInt32(tmpItem.ItemInfo.Durability); response.AddInt32(tmpItem.Durability); } else { response.AddInt32(0); response.AddInt32(0); response.AddInt32(0); response.AddInt32(0); response.AddInt8(0); response.AddInt32(0); response.AddInt32(0); response.AddInt32(0); } response.AddUInt32(MySQLQuery.Rows[i].As <uint>("mail_money")); response.AddUInt32(MySQLQuery.Rows[i].As <uint>("mail_COD")); response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_read")); response.AddSingle((float)((MySQLQuery.Rows[i].As <uint>("mail_time") - WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)) / 86400.0)); response.AddInt32(0); i = (byte)unchecked ((uint)(i + 1)); } } client.Send(ref response); response.Dispose(); } catch (Exception ex) { ProjectData.SetProjectError(ex); var e = ex; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "Error getting mail list: {0}{1}", Environment.NewLine, e.ToString()); ProjectData.ClearProjectError(); } } }
public void AddToWorld() { WorldServiceLocator._WS_Maps.GetMapTile(positionX, positionY, ref CellX, ref CellY); if (WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[CellX, CellY] == null) { WorldServiceLocator._WS_CharMovement.MAP_Load(CellX, CellY, MapID); } WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[CellX, CellY].CorpseObjectsHere.Add(GUID); Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_UPDATE_OBJECT); checked { try { Packets.UpdateClass tmpUpdate = new Packets.UpdateClass(WorldServiceLocator._Global_Constants.FIELD_MASK_SIZE_CORPSE); try { packet.AddInt32(1); packet.AddInt8(0); FillAllUpdateFlags(ref tmpUpdate); Packets.UpdateClass updateClass = tmpUpdate; CorpseObject updateObject = this; updateClass.AddToPacket(ref packet, ObjectUpdateType.UPDATETYPE_CREATE_OBJECT, ref updateObject); } finally { tmpUpdate.Dispose(); } short i = -1; do { short j = -1; do { if ((short)unchecked (CellX + i) >= 0 && (short)unchecked (CellX + i) <= 63 && (short)unchecked (CellY + j) >= 0 && (short)unchecked (CellY + j) <= 63 && WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[(short)unchecked (CellX + i), (short)unchecked (CellY + j)] != null && WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[(short)unchecked (CellX + i), (short)unchecked (CellY + j)].PlayersHere.Count > 0) { WS_Maps.TMapTile tMapTile = WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[(short)unchecked (CellX + i), (short)unchecked (CellY + j)]; ulong[] list = tMapTile.PlayersHere.ToArray(); ulong[] array = list; foreach (ulong plGUID in array) { int num; if (WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(plGUID)) { WS_PlayerData.CharacterObject characterObject = WorldServiceLocator._WorldServer.CHARACTERs[plGUID]; WS_Base.BaseObject objCharacter = this; num = (characterObject.CanSee(ref objCharacter) ? 1 : 0); } else { num = 0; } if (num != 0) { WorldServiceLocator._WorldServer.CHARACTERs[plGUID].client.SendMultiplyPackets(ref packet); WorldServiceLocator._WorldServer.CHARACTERs[plGUID].corpseObjectsNear.Add(GUID); SeenBy.Add(plGUID); } } } j = (short)unchecked (j + 1); }while (j <= 1); i = (short)unchecked (i + 1); }while (i <= 1); } finally { packet.Dispose(); } } }
public void SendTradeUpdateToTarget() { if (Target == null) { return; } Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS_EXTENDED); checked { try { packet.AddInt8(1); packet.AddInt32(7); packet.AddInt32(7); packet.AddUInt32(TraderGold); packet.AddInt32(0); int i = 0; do { packet.AddInt8((byte)i); if (TraderSlots[i] > 0) { byte mySlot = (byte)(TraderSlots[i] & 0xFF); byte myBag = (byte)(TraderSlots[i] >> 8); ItemObject myItem = null; myItem = ((myBag != 0) ? Trader.Items[myBag].Items[mySlot] : Trader.Items[mySlot]); packet.AddInt32(myItem.ItemEntry); packet.AddInt32(myItem.ItemInfo.Model); packet.AddInt32(myItem.StackCount); packet.AddInt32(0); packet.AddUInt64(myItem.GiftCreatorGUID); if (myItem.Enchantments.ContainsKey(0)) { packet.AddInt32(myItem.Enchantments[0].ID); } else { packet.AddInt32(0); } packet.AddUInt64(myItem.CreatorGUID); packet.AddInt32(myItem.ChargesLeft); packet.AddInt32(0); packet.AddInt32(myItem.RandomProperties); packet.AddInt32(myItem.ItemInfo.Flags); packet.AddInt32(myItem.ItemInfo.Durability); packet.AddInt32(myItem.Durability); } else { int j = 0; do { packet.AddInt32(0); j++; }while (j <= 14); } i++; }while (i <= 6); Target.client.Send(ref packet); } finally { packet.Dispose(); } } }
public void AddToWorld() { WorldServiceLocator._WS_Maps.GetMapTile(positionX, positionY, ref CellX, ref CellY); if (WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[CellX, CellY] == null) { WorldServiceLocator._WS_CharMovement.MAP_Load(CellX, CellY, MapID); } try { WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[CellX, CellY].DynamicObjectsHere.Add(GUID); } catch (Exception projectError) { ProjectData.SetProjectError(projectError); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.WARNING, "AddToWorld failed MapId: {0} Tile XY: {1} {2} GUID: {3}", MapID, CellX, CellY, GUID); ProjectData.ClearProjectError(); return; } Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_UPDATE_OBJECT); packet.AddInt32(1); packet.AddInt8(0); Packets.UpdateClass tmpUpdate = new Packets.UpdateClass(WorldServiceLocator._Global_Constants.FIELD_MASK_SIZE_DYNAMICOBJECT); FillAllUpdateFlags(ref tmpUpdate); Packets.UpdateClass updateClass = tmpUpdate; DynamicObjectObject updateObject = this; updateClass.AddToPacket(ref packet, ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF, ref updateObject); tmpUpdate.Dispose(); short i = -1; checked { do { short j = -1; do { if ((short)unchecked (CellX + i) >= 0 && (short)unchecked (CellX + i) <= 63 && (short)unchecked (CellY + j) >= 0 && (short)unchecked (CellY + j) <= 63 && WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[(short)unchecked (CellX + i), (short)unchecked (CellY + j)] != null && WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[(short)unchecked (CellX + i), (short)unchecked (CellY + j)].PlayersHere.Count > 0) { WS_Maps.TMapTile tMapTile = WorldServiceLocator._WS_Maps.Maps[MapID].Tiles[(short)unchecked (CellX + i), (short)unchecked (CellY + j)]; ulong[] list = tMapTile.PlayersHere.ToArray(); ulong[] array = list; foreach (ulong plGUID in array) { int num; if (WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(plGUID)) { WS_PlayerData.CharacterObject characterObject = WorldServiceLocator._WorldServer.CHARACTERs[plGUID]; WS_Base.BaseObject objCharacter = this; num = (characterObject.CanSee(ref objCharacter) ? 1 : 0); } else { num = 0; } if (num != 0) { WorldServiceLocator._WorldServer.CHARACTERs[plGUID].client.SendMultiplyPackets(ref packet); WorldServiceLocator._WorldServer.CHARACTERs[plGUID].dynamicObjectsNear.Add(GUID); SeenBy.Add(plGUID); } } } j = (short)unchecked (j + 1); }while (j <= 1); i = (short)unchecked (i + 1); }while (i <= 1); packet.Dispose(); } }
public void On_CMSG_INITIATE_TRADE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { packet.GetInt16(); ulong targetGUID = packet.GetUInt64(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_INITIATE_TRADE [Trader={2} Target={3}]", client.IP, client.Port, client.Character.GUID, targetGUID); if (client.Character.DEAD) { Packets.PacketClass response6 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response6.AddInt32(17); client.Send(ref response6); } finally { response6.Dispose(); } return; } if (client.Character.LogoutTimer != null) { Packets.PacketClass response8 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response8.AddInt32(19); client.Send(ref response8); } finally { response8.Dispose(); } return; } if (((uint)client.Character.cUnitFlags & 0x40000u) != 0) { Packets.PacketClass response10 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response10.AddInt32(15); client.Send(ref response10); } finally { response10.Dispose(); } return; } if (!WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(targetGUID)) { Packets.PacketClass response12 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response12.AddInt32(6); client.Send(ref response12); } finally { response12.Dispose(); } return; } if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].DEAD) { Packets.PacketClass response13 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response13.AddInt32(18); client.Send(ref response13); } finally { response13.Dispose(); } return; } if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].LogoutTimer != null) { Packets.PacketClass response11 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response11.AddInt32(20); client.Send(ref response11); } finally { response11.Dispose(); } return; } if (((uint)WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].cUnitFlags & 0x40000u) != 0) { Packets.PacketClass response9 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response9.AddInt32(15); client.Send(ref response9); } finally { response9.Dispose(); } return; } if (client.Character.tradeInfo != null) { Packets.PacketClass response7 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response7.AddInt32(0); client.Send(ref response7); } finally { response7.Dispose(); } return; } if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].tradeInfo != null) { Packets.PacketClass response5 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response5.AddInt32(5); client.Send(ref response5); } finally { response5.Dispose(); } return; } if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].IsHorde != client.Character.IsHorde) { Packets.PacketClass response4 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response4.AddInt32(11); client.Send(ref response4); } finally { response4.Dispose(); } return; } if (WorldServiceLocator._WS_Combat.GetDistance(client.Character, WorldServiceLocator._WorldServer.CHARACTERs[targetGUID]) > 30f) { Packets.PacketClass response3 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response3.AddInt32(10); client.Send(ref response3); } finally { response3.Dispose(); } return; } if (client.Character.Access == AccessLevel.Trial) { Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response2.AddInt32(21); client.Send(ref response2); } finally { response2.Dispose(); } return; } if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].Access == AccessLevel.Trial) { Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response.AddInt32(21); client.Send(ref response); } finally { response.Dispose(); } return; } ref WS_PlayerData.CharacterObject character = ref client.Character;
private void DoTrade() { byte TargetReqItems = 0; byte TraderReqItems = 0; byte i = 0; do { checked { if (TraderSlots[i] > 0) { TargetReqItems = (byte)(TargetReqItems + 1); } if (TargetSlots[i] > 0) { TraderReqItems = (byte)(TraderReqItems + 1); } i = (byte)unchecked ((uint)(i + 1)); } }while (i <= 5u); try { if (Target.ItemFREESLOTS() < TargetReqItems) { Packets.PacketClass responseUnAccept2 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { responseUnAccept2.AddInt32(7); Target.client.SendMultiplyPackets(ref responseUnAccept2); TraderAccept = false; Trader.client.SendMultiplyPackets(ref responseUnAccept2); TraderAccept = false; } finally { responseUnAccept2.Dispose(); } Packets.PacketClass responseNoSlot2 = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE); try { responseNoSlot2.AddInt8(50); responseNoSlot2.AddUInt64(0uL); responseNoSlot2.AddUInt64(0uL); responseNoSlot2.AddInt8(0); Target.client.Send(ref responseNoSlot2); } finally { responseNoSlot2.Dispose(); } return; } if (Trader.ItemFREESLOTS() < TraderReqItems) { Packets.PacketClass responseUnAccept = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { responseUnAccept.AddInt32(7); Target.client.SendMultiplyPackets(ref responseUnAccept); TraderAccept = false; Trader.client.SendMultiplyPackets(ref responseUnAccept); TargetAccept = false; } finally { responseUnAccept.Dispose(); } Packets.PacketClass responseNoSlot = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE); try { responseNoSlot.AddInt8(50); responseNoSlot.AddUInt64(0uL); responseNoSlot.AddUInt64(0uL); responseNoSlot.AddInt8(0); Trader.client.Send(ref responseNoSlot); } finally { responseNoSlot.Dispose(); } return; } if ((TargetGold > 0L) | (TraderGold > 0L)) { checked { Trader.Copper = Trader.Copper - TraderGold + TargetGold; Target.Copper = Target.Copper + TraderGold - TargetGold; Trader.SetUpdateFlag(1176, Trader.Copper); Target.SetUpdateFlag(1176, Target.Copper); } } if (TargetReqItems > 0 || TraderReqItems > 0) { byte j = 0; do { checked { if (TraderSlots[j] > 0) { byte mySlot2 = (byte)(TraderSlots[j] & 0xFF); byte myBag2 = (byte)(TraderSlots[j] >> 8); ItemObject myItem2 = null; myItem2 = ((myBag2 != 0) ? Trader.Items[myBag2].Items[mySlot2] : Trader.Items[mySlot2]); if (myItem2.ItemInfo.ObjectClass != ITEM_CLASS.ITEM_CLASS_QUEST) { myItem2.OwnerGUID = Target.GUID; if (Target.ItemADD(ref myItem2)) { Trader.ItemREMOVE(myBag2, mySlot2, Destroy: false, Update: false); } } } if (TargetSlots[j] > 0) { byte mySlot = (byte)(TargetSlots[j] & 0xFF); byte myBag = (byte)(TargetSlots[j] >> 8); ItemObject myItem = null; myItem = ((myBag != 0) ? Target.Items[myBag].Items[mySlot] : Target.Items[mySlot]); if (myItem.ItemInfo.ObjectClass != ITEM_CLASS.ITEM_CLASS_QUEST) { myItem.OwnerGUID = Trader.GUID; if (Trader.ItemADD(ref myItem)) { Target.ItemREMOVE(myBag, mySlot, Destroy: false, Update: false); } } } j = (byte)unchecked ((uint)(j + 1)); } }while (j <= 5u); } Trader.SendCharacterUpdate(); Target.SendCharacterUpdate(); Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS); try { response.AddInt32(8); Target.client.SendMultiplyPackets(ref response); Trader.client.SendMultiplyPackets(ref response); } finally { response.Dispose(); Dispose(); } } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception e = ex; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "Error doing trade: {0}{1}", Environment.NewLine, e.ToString()); ProjectData.ClearProjectError(); } }