Example #1
0
 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();
     }
 }
Example #2
0
 public void On_CMSG_STANDSTATECHANGE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 6)
     {
         packet.GetInt16();
         byte StandState = packet.GetInt8();
         if (StandState == 0)
         {
             client.Character.RemoveAurasByInterruptFlag(262144);
         }
         client.Character.StandState = StandState;
         client.Character.SetUpdateFlag(138, client.Character.cBytes1);
         client.Character.SendCharacterUpdate();
         Packets.PacketClass packetACK = new Packets.PacketClass(Opcodes.SMSG_STANDSTATE_CHANGE_ACK);
         try
         {
             packetACK.AddInt8(StandState);
             client.Send(ref packetACK);
         }
         finally
         {
             packetACK.Dispose();
         }
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_STANDSTATECHANGE [{2}]", client.IP, client.Port, client.Character.StandState);
     }
 }
Example #3
0
        private void SendTaxiStatus(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));

            Packets.PacketClass SMSG_TAXINODE_STATUS = new Packets.PacketClass(Opcodes.SMSG_TAXINODE_STATUS);
            try
            {
                SMSG_TAXINODE_STATUS.AddUInt64(cGuid);
                if (!objCharacter.TaxiZones[currentTaxi])
                {
                    SMSG_TAXINODE_STATUS.AddInt8(0);
                }
                else
                {
                    SMSG_TAXINODE_STATUS.AddInt8(1);
                }
                objCharacter.client.Send(ref SMSG_TAXINODE_STATUS);
            }
            finally
            {
                SMSG_TAXINODE_STATUS.Dispose();
            }
        }
Example #4
0
 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();
     }
 }
Example #5
0
 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();
 }
Example #6
0
 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();
     }
 }
Example #7
0
 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();
     }
 }
Example #8
0
 public void On_CMSG_AUTOSTORE_LOOT_ITEM(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) < 6)
     {
         return;
     }
     try
     {
         packet.GetInt16();
         byte slot = packet.GetInt8();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_AUTOSTORE_LOOT_ITEM [slot={2}]", client.IP, client.Port, slot);
         if (LootTable.ContainsKey(client.Character.lootGUID))
         {
             LootTable[client.Character.lootGUID].GetLoot(ref client, slot);
             return;
         }
         Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
         response.AddInt8(49);
         response.AddUInt64(0uL);
         response.AddUInt64(0uL);
         response.AddInt8(0);
         client.Send(ref response);
         response.Dispose();
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         Exception e = ex;
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "Error looting item.{0}", Environment.NewLine + e);
         ProjectData.ClearProjectError();
     }
 }
Example #9
0
        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();
            }
        }
Example #10
0
 public void SendRelease(ref WS_Network.ClientClass client)
 {
     Packets.PacketClass responseRelease = new Packets.PacketClass(Opcodes.SMSG_LOOT_RELEASE_RESPONSE);
     responseRelease.AddUInt64(GUID);
     responseRelease.AddInt8(1);
     client.Send(ref responseRelease);
     responseRelease.Dispose();
 }
Example #11
0
 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();
     }
 }
Example #12
0
 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();
     }
 }
Example #13
0
 public void SendTutorialFlags(ref WS_Network.ClientClass client, ref WS_PlayerData.CharacterObject Character)
 {
     Packets.PacketClass SMSG_TUTORIAL_FLAGS = new Packets.PacketClass(Opcodes.SMSG_TUTORIAL_FLAGS);
     try
     {
         SMSG_TUTORIAL_FLAGS.AddByteArray(Character.TutorialFlags);
         client.Send(ref SMSG_TUTORIAL_FLAGS);
     }
     finally
     {
         SMSG_TUTORIAL_FLAGS.Dispose();
     }
 }
Example #14
0
 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();
     }
 }
Example #15
0
 public void On_CMSG_MOUNTSPECIAL_ANIM(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MOUNTSPECIAL_ANIM", client.IP, client.Port);
     Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_MOUNTSPECIAL_ANIM);
     try
     {
         response.AddPackGUID(client.Character.GUID);
         client.Character.SendToNearPlayers(ref response);
     }
     finally
     {
         response.Dispose();
     }
 }
Example #16
0
 public void Destroy()
 {
     Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_DESTROY_OBJECT);
     try
     {
         packet.AddUInt64(GUID);
         SendToNearPlayers(ref packet);
     }
     finally
     {
         packet.Dispose();
     }
     Dispose();
 }
Example #17
0
        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();
                }
            }
        }
Example #18
0
 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 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();
 }
Example #20
0
 public void MaievSendCheck(ref WS_PlayerData.CharacterObject objCharacter)
 {
     if (!objCharacter.WardenData.Ready)
     {
         throw new ApplicationException("Maiev.mod not ready!");
     }
     objCharacter.WardenData.Scan.Do_TIMING_CHECK();
     Packets.PacketClass packet = objCharacter.WardenData.Scan.GetPacket();
     try
     {
         WorldServiceLocator._WS_Warden.SendWardenPacket(ref objCharacter, ref packet);
     }
     finally
     {
         packet.Dispose();
     }
 }
Example #21
0
 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();
     }
 }
Example #22
0
 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();
     }
 }
Example #23
0
            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();
                    }
                }
            }
Example #24
0
        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();
            }
        }
Example #25
0
 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();
         }
     }
 }
Example #26
0
 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();
         }
     }
 }
Example #27
0
        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();
            }
        }
Example #28
0
        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();
        }
Example #29
0
 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();
         }
     }
 }
Example #30
0
        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();
            }
        }