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 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 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 On_MSG_MINIMAP_PING(PacketClass packet, ClientClass client) { packet.GetInt16(); var x = packet.GetFloat(); var y = packet.GetFloat(); _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_MINIMAP_PING [{2}:{3}]", client.IP, client.Port, x, y); if (client.Character.IsInGroup) { var response = new PacketClass(Opcodes.MSG_MINIMAP_PING); response.AddUInt64(client.Character.Guid); response.AddSingle(x); response.AddSingle(y); client.Character.Group.Broadcast(response); response.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++; } } }
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++; } } }