public void On_CMSG_REQUEST_RAID_INFO(PacketClass packet, ClientClass client) { _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_REQUEST_RAID_INFO", client.IP, client.Port); var q = new DataTable(); if (client.Character is object) { _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM characters_instances WHERE char_guid = {0};", client.Character.Guid), ref q); } var response = new PacketClass(Opcodes.SMSG_RAID_INSTANCE_INFO); response.AddInt32(q.Rows.Count); // Instances Counts var i = 0; foreach (DataRow r in q.Rows) { response.AddUInt32(Conversions.ToUInteger(r["map"])); // MapID response.AddUInt32((uint)(Conversions.ToInteger(r["expire"]) - _clusterServiceLocator.Functions.GetTimestamp(DateAndTime.Now))); // TimeLeft response.AddUInt32(Conversions.ToUInteger(r["instance"])); // InstanceID response.AddUInt32((uint)i); // Counter i += 1; } client.Send(response); response.Dispose(); }
public void On_MSG_BATTLEGROUND_PLAYER_POSITIONS(PacketClass packet, ClientClass client) { var p = new PacketClass(Opcodes.MSG_BATTLEGROUND_PLAYER_POSITIONS); try { p.AddUInt32(0U); p.AddUInt32(0U); // flagCarrierCount } finally { p.Dispose(); } }
public void SendGuildQuery(ClientClass client, uint guildId) { if (guildId == 0L) { return; } // WARNING: This opcode is used also in character enum, so there must not be used any references to CharacterObject, only ClientClass // DONE: Load the guild if it doesn't exist in the memory if (GuilDs.ContainsKey(guildId) == false) { var tmpGuild = new Guild(guildId); GuilDs.Add(guildId, tmpGuild); } var response = new PacketClass(Opcodes.SMSG_GUILD_QUERY_RESPONSE); response.AddUInt32(guildId); response.AddString(GuilDs[guildId].Name); for (var i = 0; i <= 9; i++) { response.AddString(GuilDs[guildId].Ranks[i]); } response.AddInt32(GuilDs[guildId].EmblemStyle); response.AddInt32(GuilDs[guildId].EmblemColor); response.AddInt32(GuilDs[guildId].BorderStyle); response.AddInt32(GuilDs[guildId].BorderColor); response.AddInt32(GuilDs[guildId].BackgroundColor); response.AddInt32(0); client.Send(response); response.Dispose(); }
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 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); }
public void ClientTransfer(uint id, float posX, float posY, float posZ, float ori, uint map) { _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.INFORMATION, "[{0:000000}] Client has transferred from map {1:000} to map {2:000}", id, _clusterServiceLocator.WorldCluster.ClienTs[id].Character.Map, map); var p = new PacketClass(Opcodes.SMSG_NEW_WORLD); p.AddUInt32(map); p.AddSingle(posX); p.AddSingle(posY); p.AddSingle(posZ); p.AddSingle(ori); _clusterServiceLocator.WorldCluster.ClienTs[id].Send(p); _clusterServiceLocator.WorldCluster.ClienTs[id].Character.Map = map; }
public void On_CMSG_REQUEST_ACCOUNT_DATA(PacketClass packet, ClientClass client) { if (packet.Data.Length - 1 < 9) { return; } packet.GetInt16(); var dataId = packet.GetUInt32(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_REQUEST_ACCOUNT_DATA [ID={2}]", client.IP, client.Port, dataId); if (dataId > 7L) { return; } // Dim AccData As New DataTable // _WorldCluster.AccountDatabase.Query(String.Format("SELECT account_id FROM accounts WHERE username = ""{0}"";", client.Account), AccData) // If AccData.Rows.Count > 0 Then // Dim AccID As Integer = CType(AccData.Rows(0).Item("account_id"), Integer) // // AccData.Clear() // _WorldCluster.AccountDatabase.Query(String.Format("SELECT `account_data{1}` FROM account_data WHERE account_id = {0}", AccID, DataID), AccData) // If AccData.Rows.Count > 0 Then FoundData = True // End If var response = new PacketClass(Opcodes.SMSG_UPDATE_ACCOUNT_DATA); response.AddUInt32(dataId); // If FoundData = False Then response.AddInt32(0); // Uncompressed buffer length // Else // Dim AccountData() As Byte = AccData.Rows(0).Item("account_data" & DataID) // If AccountData.Length > 0 Then // response.AddInt32(AccountData.Length) 'Uncompressed buffer length // DONE: Compress buffer if it's longer than 200 bytes // If AccountData.Length > 200 Then // Dim CompressedBuffer() As Byte = Compress(AccountData, 0, AccountData.Length) // response.AddByteArray(CompressedBuffer) // Else // response.AddByteArray(AccountData) // End If // Else // response.AddInt32(0) 'Uncompressed buffer length // End If // End If client.Send(response); response.Dispose(); }
/// <summary> /// Sends the battleground group joined. /// </summary> /// <param name="objCharacter">The objCharacter.</param> /// <returns></returns> public void SendBattlegroundGroupJoined(WcHandlerCharacter.CharacterObject objCharacter) { // 0 - Your group has joined a battleground queue, but you are not eligible // 1 - Your group has joined the queue for AV // 2 - Your group has joined the queue for WS // 3 - Your group has joined the queue for AB var p = new PacketClass(Opcodes.SMSG_GROUP_JOINED_BATTLEGROUND); try { p.AddUInt32(0xFFFFFFFEU); objCharacter.Client.Send(p); } finally { p.Dispose(); } }
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_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++; } } }
/// <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 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++; } } }