Beispiel #1
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();
            }
        }
Beispiel #2
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();
     }
 }
Beispiel #3
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();
     }
 }
Beispiel #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();
     }
 }
Beispiel #5
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);
     }
 }
 public void MaievSendSeed(ref WS_PlayerData.CharacterObject objCharacter)
 {
     Packets.PacketClass r = new Packets.PacketClass(Opcodes.SMSG_WARDEN_DATA);
     r.AddInt8(5);
     r.AddByteArray(objCharacter.WardenData.Seed);
     WorldServiceLocator._WS_Warden.SendWardenPacket(ref objCharacter, ref r);
 }
Beispiel #7
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();
     }
 }
Beispiel #8
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();
            }
        }
Beispiel #9
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();
 }
            public Packets.PacketClass GetPacket()
            {
                Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_WARDEN_DATA);
                packet.AddInt8(2);
                foreach (string tmpStr in UsedStrings)
                {
                    packet.AddString2(tmpStr);
                }
                packet.AddInt8(0);
                byte i = 0;

                foreach (CheatCheck Check in Checks)
                {
                    byte   xorCheck  = (byte)(WorldServiceLocator._WS_Warden.Maiev.CheckIDs[(uint)Check.Type] ^ Character.WardenData.xorByte);
                    byte[] checkData = Check.ToData(xorCheck, ref i);
                    packet.AddByteArray(checkData);
                }
                packet.AddInt8(Character.WardenData.xorByte);
                return(packet);
            }
Beispiel #11
0
        public void MaievSendTransfer(ref WS_PlayerData.CharacterObject objCharacter)
        {
            if (!objCharacter.WardenData.Ready)
            {
                throw new ApplicationException("Maiev.mod not ready!");
            }
            FileStream file = new FileStream($"warden\\{WorldServiceLocator._WS_Warden.Maiev.ModuleName}.bin", FileMode.Open, FileAccess.Read);

            checked
            {
                int size;
                for (size = (int)file.Length; size > 500; size -= 500)
                {
                    Packets.PacketClass r = new Packets.PacketClass(Opcodes.SMSG_WARDEN_DATA);
                    r.AddInt8(1);
                    r.AddInt16(500);
                    int i = 1;
                    do
                    {
                        r.AddInt8((byte)file.ReadByte());
                        i++;
                    }while (i <= 500);
                    WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_WARDEN_DATA [data]", objCharacter.client.IP, objCharacter.client.Port);
                    WorldServiceLocator._WS_Warden.SendWardenPacket(ref objCharacter, ref r);
                }
                if (size > 0)
                {
                    Packets.PacketClass r2 = new Packets.PacketClass(Opcodes.SMSG_WARDEN_DATA);
                    r2.AddInt8(1);
                    r2.AddUInt16((ushort)size);
                    int num = size;
                    for (int j = 1; j <= num; j++)
                    {
                        r2.AddInt8((byte)file.ReadByte());
                    }
                    WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_WARDEN_DATA [done]", objCharacter.client.IP, objCharacter.client.Port);
                    WorldServiceLocator._WS_Warden.SendWardenPacket(ref objCharacter, ref r2);
                }
            }
        }
Beispiel #12
0
 public void MaievSendModule(ref WS_PlayerData.CharacterObject objCharacter)
 {
     if (!objCharacter.WardenData.Ready)
     {
         throw new ApplicationException("Maiev.mod not ready!");
     }
     WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_WARDEN_DATA [{2}]", objCharacter.client.IP, objCharacter.client.Port, WorldServiceLocator._WS_Warden.Maiev.ModuleName);
     Packets.PacketClass r = new Packets.PacketClass(Opcodes.SMSG_WARDEN_DATA);
     r.AddInt8(0);
     r.AddByteArray(WorldServiceLocator._WS_Warden.Maiev.WardenModule);
     r.AddByteArray(WorldServiceLocator._WS_Warden.Maiev.ModuleKey);
     r.AddUInt32(checked ((uint)WorldServiceLocator._WS_Warden.Maiev.ModuleSize));
     WorldServiceLocator._WS_Warden.SendWardenPacket(ref objCharacter, ref r);
 }
 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();
 }
Beispiel #14
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();
                }
            }
        }
Beispiel #15
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();
            }
        }
Beispiel #16
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();
                    }
                }
            }
Beispiel #17
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();
            }
        }
Beispiel #18
0
 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();
         }
     }
 }
Beispiel #19
0
            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();
                }
            }
Beispiel #20
0
            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();
                }
            }
Beispiel #21
0
 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();
         }
     }
 }
Beispiel #22
0
            public void SendLoot(ref WS_Network.ClientClass client)
            {
                if (Items.Count == 0)
                {
                    WorldServiceLocator._WS_Loot.SendEmptyLoot(GUID, LootType, ref client);
                    return;
                }
                if (decimal.Compare(new decimal(LootOwner), 0m) != 0 && client.Character.GUID != LootOwner)
                {
                    Packets.PacketClass notMy = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
                    notMy.AddInt8(58);
                    notMy.AddUInt64(0uL);
                    notMy.AddUInt64(0uL);
                    notMy.AddInt8(0);
                    client.Send(ref notMy);
                    notMy.Dispose();
                    return;
                }
                Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_LOOT_RESPONSE);
                response.AddUInt64(GUID);
                response.AddInt8((byte)LootType);
                response.AddInt32(Money);
                byte b2;
                byte i;

                checked
                {
                    response.AddInt8((byte)Items.Count);
                    byte b = (byte)(Items.Count - 1);
                    byte j = 0;
                    while (j <= (uint)b)
                    {
                        if (Items[j] == null)
                        {
                            response.AddInt8(j);
                            response.AddInt32(0);
                            response.AddInt32(0);
                            response.AddInt32(0);
                            response.AddUInt64(0uL);
                            response.AddInt8(0);
                        }
                        else
                        {
                            response.AddInt8(j);
                            response.AddInt32(Items[j].ItemID);
                            response.AddInt32(Items[j].ItemCount);
                            response.AddInt32(Items[j].ItemModel);
                            response.AddUInt64(0uL);
                            if (client.Character.IsInGroup && client.Character.Group.LootMethod == GroupLootMethod.LOOT_MASTER && client.Character.Group.LocalLootMaster != null && client.Character.Group.LocalLootMaster != client.Character)
                            {
                                response.AddInt8(2);
                            }
                            else
                            {
                                response.AddInt8(0);
                            }
                        }
                        j = (byte)unchecked ((uint)(j + 1));
                    }
                    client.Send(ref response);
                    response.Dispose();
                    client.Character.lootGUID = GUID;
                    if (!client.Character.IsInGroup || !((client.Character.Group.LootMethod == GroupLootMethod.LOOT_NEED_BEFORE_GREED) | (client.Character.Group.LootMethod == GroupLootMethod.LOOT_GROUP)))
                    {
                        return;
                    }
                    b2 = (byte)(Items.Count - 1);
                    i  = 0;
                }
                while (i <= (uint)b2)
                {
                    if (Items[i] != null && WorldServiceLocator._WorldServer.ITEMDatabase[Items[i].ItemID].Quality >= (int)client.Character.Group.LootThreshold)
                    {
                        GroupLootInfo[i] = new GroupLootInfo
                        {
                            LootObject = this,
                            LootSlot   = i,
                            Item       = Items[i]
                        };
                        WorldServiceLocator._WS_Loot.StartRoll(GUID, i, ref client.Character);
                        break;
                    }
                    checked
                    {
                        i = (byte)unchecked ((uint)(i + 1));
                    }
                }
            }
Beispiel #23
0
 public void MaievSendUnk(ref WS_PlayerData.CharacterObject objCharacter)
 {
     Packets.PacketClass unk = new Packets.PacketClass(Opcodes.SMSG_WARDEN_DATA);
     try
     {
         unk.AddInt8(3);
         unk.AddByteArray(new byte[56]
         {
             20,
             0,
             96,
             208,
             254,
             44,
             1,
             0,
             2,
             0,
             32,
             26,
             54,
             0,
             192,
             227,
             53,
             0,
             80,
             241,
             53,
             0,
             192,
             245,
             53,
             0,
             3,
             8,
             0,
             119,
             108,
             147,
             169,
             4,
             0,
             0,
             96,
             168,
             64,
             0,
             1,
             3,
             8,
             0,
             54,
             133,
             234,
             240,
             1,
             1,
             0,
             144,
             244,
             69,
             0,
             1
         });
         WorldServiceLocator._WS_Warden.SendWardenPacket(ref objCharacter, ref unk);
     }
     finally
     {
         unk.Dispose();
     }
 }
            public void Check()
            {
                if (Looters.Count != Rolls.Count)
                {
                    return;
                }
                byte maxRollType = 0;

                foreach (KeyValuePair <WS_PlayerData.CharacterObject, int> looter2 in Looters)
                {
                    if (looter2.Value == 1)
                    {
                        maxRollType = 1;
                    }
                    if (looter2.Value == 2 && maxRollType != 1)
                    {
                        maxRollType = 2;
                    }
                }
                if (maxRollType == 0)
                {
                    LootObject.GroupLootInfo.Remove(LootSlot);
                    Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.SMSG_LOOT_ALL_PASSED);
                    response2.AddUInt64(LootObject.GUID);
                    response2.AddInt32(LootSlot);
                    response2.AddInt32(Item.ItemID);
                    response2.AddInt32(0);
                    response2.AddInt32(0);
                    Broadcast(ref response2);
                    response2.Dispose();
                    return;
                }
                int maxRoll = -1;

                WS_PlayerData.CharacterObject looterCharacter = null;
                checked
                {
                    foreach (KeyValuePair <WS_PlayerData.CharacterObject, int> looter in Looters)
                    {
                        if (looter.Value == maxRollType)
                        {
                            byte rollValue = (byte)WorldServiceLocator._WorldServer.Rnd.Next(0, 100);
                            if (rollValue > maxRoll)
                            {
                                maxRoll         = rollValue;
                                looterCharacter = looter.Key;
                            }
                            Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_LOOT_ROLL);
                            response.AddUInt64(LootObject.GUID);
                            response.AddInt32(LootSlot);
                            response.AddUInt64(looter.Key.GUID);
                            response.AddInt32(Item.ItemID);
                            response.AddInt32(0);
                            response.AddInt32(0);
                            response.AddInt8(rollValue);
                            response.AddInt8((byte)looter.Value);
                            Broadcast(ref response);
                            response.Dispose();
                        }
                    }
                    ItemObject itemObject = new ItemObject(Item.ItemID, looterCharacter.GUID)
                    {
                        StackCount = Item.ItemCount
                    };
                    ItemObject          tmpItem = itemObject;
                    Packets.PacketClass wonItem = new Packets.PacketClass(Opcodes.SMSG_LOOT_ROLL_WON);
                    wonItem.AddUInt64(LootObject.GUID);
                    wonItem.AddInt32(LootSlot);
                    wonItem.AddInt32(Item.ItemID);
                    wonItem.AddInt32(0);
                    wonItem.AddInt32(0);
                    wonItem.AddUInt64(looterCharacter.GUID);
                    wonItem.AddInt8((byte)maxRoll);
                    wonItem.AddInt8(maxRollType);
                    Broadcast(ref wonItem);
                    if (looterCharacter.ItemADD(ref tmpItem))
                    {
                        looterCharacter.LogLootItem(tmpItem, Item.ItemCount, Recieved: false, Created: false);
                        LootObject.GroupLootInfo.Remove(LootSlot);
                        LootObject.Items[LootSlot] = null;
                    }
                    else
                    {
                        tmpItem.Delete();
                        LootObject.GroupLootInfo.Remove(LootSlot);
                    }
                }
            }
Beispiel #25
0
 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();
         ulong 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 DataTable();
             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)
             {
                 byte 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 Packets.PacketClass(Opcodes.SMSG_MAIL_LIST_RESULT);
             response.AddInt8((byte)MySQLQuery.Rows.Count);
             if (MySQLQuery.Rows.Count > 0)
             {
                 byte 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"));
                     object 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)
                     {
                         ItemObject 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);
             Exception e = ex;
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "Error getting mail list: {0}{1}", Environment.NewLine, e.ToString());
             ProjectData.ClearProjectError();
         }
     }
 }
Beispiel #26
0
        public Packets.PacketClass BuildPartyMemberStats(ref WS_PlayerData.CharacterObject objCharacter, uint flag)
        {
            Opcodes opCode = Opcodes.SMSG_PARTY_MEMBER_STATS;

            if (flag == 1015 || flag == 524279)
            {
                opCode = Opcodes.SMSG_PARTY_MEMBER_STATS_FULL;
                if (objCharacter.ManaType != 0)
                {
                    flag |= 8u;
                }
            }
            Packets.PacketClass packet = new Packets.PacketClass(opCode);
            packet.AddPackGUID(objCharacter.GUID);
            packet.AddUInt32(flag);
            if ((flag & (true ? 1u : 0u)) != 0)
            {
                byte memberFlags = 1;
                if (objCharacter.isPvP)
                {
                    memberFlags = (byte)(memberFlags | 2);
                }
                if (objCharacter.DEAD)
                {
                    memberFlags = (byte)(memberFlags | 0x10);
                }
                packet.AddInt8(memberFlags);
            }
            checked
            {
                if ((flag & 2u) != 0)
                {
                    packet.AddUInt16((ushort)objCharacter.Life.Current);
                }
                if ((flag & 4u) != 0)
                {
                    packet.AddUInt16((ushort)objCharacter.Life.Maximum);
                }
                if ((flag & 8u) != 0)
                {
                    packet.AddInt8((byte)objCharacter.ManaType);
                }
                if ((flag & 0x10u) != 0)
                {
                    if (objCharacter.ManaType == ManaTypes.TYPE_RAGE)
                    {
                        packet.AddUInt16((ushort)objCharacter.Rage.Current);
                    }
                    else if (objCharacter.ManaType == ManaTypes.TYPE_ENERGY)
                    {
                        packet.AddUInt16((ushort)objCharacter.Energy.Current);
                    }
                    else
                    {
                        packet.AddUInt16((ushort)objCharacter.Mana.Current);
                    }
                }
                if ((flag & 0x20u) != 0)
                {
                    if (objCharacter.ManaType == ManaTypes.TYPE_RAGE)
                    {
                        packet.AddUInt16((ushort)objCharacter.Rage.Maximum);
                    }
                    else if (objCharacter.ManaType == ManaTypes.TYPE_ENERGY)
                    {
                        packet.AddUInt16((ushort)objCharacter.Energy.Maximum);
                    }
                    else
                    {
                        packet.AddUInt16((ushort)objCharacter.Mana.Maximum);
                    }
                }
                if ((flag & 0x40u) != 0)
                {
                    packet.AddUInt16(objCharacter.Level);
                }
                if ((flag & 0x80u) != 0)
                {
                    packet.AddUInt16((ushort)objCharacter.ZoneID);
                }
                if ((flag & 0x100u) != 0)
                {
                    packet.AddInt16((short)objCharacter.positionX);
                    packet.AddInt16((short)objCharacter.positionY);
                }
                if ((flag & 0x200u) != 0)
                {
                    ulong auraMask2 = 0uL;
                    int   auraPos2  = packet.Data.Length;
                    packet.AddUInt64(0uL);
                    int num = WorldServiceLocator._Global_Constants.MAX_AURA_EFFECTs_VISIBLE - 1;
                    for (int j = 0; j <= num; j++)
                    {
                        if (objCharacter.ActiveSpells[j] != null)
                        {
                            unchecked
                            {
                                auraMask2 |= (ulong)(1L << checked ((int)(ulong)j));
                            }
                            packet.AddUInt16((ushort)objCharacter.ActiveSpells[j].SpellID);
                            packet.AddInt8(1);
                        }
                    }
                    packet.AddUInt64(auraMask2, auraPos2);
                }
                if ((flag & 0x400u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt64(objCharacter.Pet.GUID);
                    }
                    else
                    {
                        packet.AddInt64(0L);
                    }
                }
                if ((flag & 0x800u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddString(objCharacter.Pet.PetName);
                    }
                    else
                    {
                        packet.AddString("");
                    }
                }
                if ((flag & 0x1000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Model);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x2000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Life.Current);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x4000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Life.Maximum);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x8000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddInt8(2);
                    }
                    else
                    {
                        packet.AddInt8(0);
                    }
                }
                if ((flag & 0x10000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Mana.Current);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x20000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Mana.Maximum);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x40000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        ulong auraMask = 0uL;
                        int   auraPos  = packet.Data.Length;
                        packet.AddUInt64(0uL);
                        int num2 = WorldServiceLocator._Global_Constants.MAX_AURA_EFFECTs_VISIBLE - 1;
                        for (int i = 0; i <= num2; i++)
                        {
                            if (objCharacter.Pet.ActiveSpells[i] != null)
                            {
                                unchecked
                                {
                                    auraMask |= (ulong)(1L << checked ((int)(ulong)i));
                                }
                                packet.AddUInt16((ushort)objCharacter.Pet.ActiveSpells[i].SpellID);
                                packet.AddInt8(1);
                            }
                        }
                        packet.AddUInt64(auraMask, auraPos);
                    }
                    else
                    {
                        packet.AddInt64(0L);
                    }
                }
                return(packet);
            }
        }
Beispiel #27
0
 public void On_CMSG_LOGOUT_REQUEST(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_LOGOUT_REQUEST", client.IP, client.Port);
     client.Character.Save();
     if (client.Character.IsInCombat)
     {
         Packets.PacketClass LOGOUT_RESPONSE_DENIED = new Packets.PacketClass(Opcodes.SMSG_LOGOUT_RESPONSE);
         try
         {
             LOGOUT_RESPONSE_DENIED.AddInt32(0);
             LOGOUT_RESPONSE_DENIED.AddInt8(12);
             client.Send(ref LOGOUT_RESPONSE_DENIED);
         }
         finally
         {
             LOGOUT_RESPONSE_DENIED.Dispose();
         }
         return;
     }
     if (!(client.Character.positionZ > WorldServiceLocator._WS_Maps.GetZCoord(client.Character.positionX, client.Character.positionY, client.Character.positionZ, client.Character.MapID) + 10f))
     {
         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 |= 0x40000;
             UpdateData.SetUpdateFlag(46, client.Character.cUnitFlags);
             client.Character.StandState = 1;
             UpdateData.SetUpdateFlag(138, client.Character.cBytes1);
             WS_PlayerData.CharacterObject updateObject = client.Character;
             UpdateData.AddToPacket(ref SMSG_UPDATE_OBJECT, ObjectUpdateType.UPDATETYPE_VALUES, ref updateObject);
             client.Character.SendToNearPlayers(ref SMSG_UPDATE_OBJECT);
         }
         finally
         {
             SMSG_UPDATE_OBJECT.Dispose();
         }
         Packets.PacketClass packetACK = new Packets.PacketClass(Opcodes.SMSG_STANDSTATE_CHANGE_ACK);
         try
         {
             packetACK.AddInt8(1);
             client.Send(ref packetACK);
         }
         finally
         {
             packetACK.Dispose();
         }
     }
     Packets.PacketClass SMSG_LOGOUT_RESPONSE = new Packets.PacketClass(Opcodes.SMSG_LOGOUT_RESPONSE);
     try
     {
         SMSG_LOGOUT_RESPONSE.AddInt32(0);
         SMSG_LOGOUT_RESPONSE.AddInt8(0);
         client.Send(ref SMSG_LOGOUT_RESPONSE);
     }
     finally
     {
         SMSG_LOGOUT_RESPONSE.Dispose();
     }
     WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_LOGOUT_RESPONSE", client.IP, client.Port);
     client.Character.SetMoveRoot();
     client.Character.ZoneCheck();
     if (client.Character.isResting)
     {
         client.Character.Logout();
     }
     else
     {
         client.Character.LogoutTimer = new Timer(client.Character.Logout, null, 20000, -1);
     }
 }
Beispiel #28
0
 public void On_CMSG_PETITION_BUY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 < 26)
         {
             return;
         }
         packet.GetInt16();
         ulong GUID = packet.GetUInt64();
         packet.GetInt64();
         packet.GetInt32();
         string Name = packet.GetString();
         if (packet.Data.Length - 1 < 26 + Name.Length + 40 + 2 + 1 + 4 + 4)
         {
             return;
         }
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt16();
         packet.GetInt8();
         int Index = packet.GetInt32();
         packet.GetInt32();
         if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID) || (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].CreatureInfo.cNpcFlags & 0x200) == 0)
         {
             return;
         }
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_PETITION_BUY [GuildName={2}]", client.IP, client.Port, Name);
         if ((ulong)client.Character.GuildID != 0)
         {
             return;
         }
         int       CharterID    = WorldServiceLocator._Global_Constants.PETITION_GUILD;
         int       CharterPrice = WorldServiceLocator._Global_Constants.PETITION_GUILD_PRICE;
         DataTable q            = new DataTable();
         WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT guild_id FROM guilds WHERE guild_name = '{Name}'", ref q);
         if (q.Rows.Count > 0)
         {
             SendGuildResult(ref client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_NAME_EXISTS, Name);
         }
         q.Clear();
         if (!WorldServiceLocator._Functions.ValidateGuildName(Name))
         {
             SendGuildResult(ref client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_NAME_INVALID, Name);
         }
         if (!WorldServiceLocator._WorldServer.ITEMDatabase.ContainsKey(CharterID))
         {
             Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.SMSG_BUY_FAILED);
             response2.AddUInt64(GUID);
             response2.AddInt32(CharterID);
             response2.AddInt8(0);
             client.Send(ref response2);
             response2.Dispose();
             return;
         }
         if (client.Character.Copper < CharterPrice)
         {
             Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_BUY_FAILED);
             response.AddUInt64(GUID);
             response.AddInt32(CharterID);
             response.AddInt8(2);
             client.Send(ref response);
             response.Dispose();
             return;
         }
         ref uint copper = ref client.Character.Copper;
         copper = (uint)(copper - CharterPrice);
         client.Character.SetUpdateFlag(1176, client.Character.Copper);
         client.Character.SendCharacterUpdate(toNear: false);
         ItemObject tmpItem = new ItemObject(CharterID, client.Character.GUID)
         {
             StackCount = 1
         };
         tmpItem.AddEnchantment((int)(tmpItem.GUID - WorldServiceLocator._Global_Constants.GUID_ITEM), 0);
         if (client.Character.ItemADD(ref tmpItem))
         {
             WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("INSERT INTO petitions (petition_id, petition_itemGuid, petition_owner, petition_name, petition_type, petition_signedMembers) VALUES ({0}, {0}, {1}, '{2}', {3}, 0);", tmpItem.GUID - WorldServiceLocator._Global_Constants.GUID_ITEM, client.Character.GUID - WorldServiceLocator._Global_Constants.GUID_PLAYER, Name, 9));
         }
         else
         {
             tmpItem.Delete();
         }
     }
Beispiel #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();
         }
     }
 }
Beispiel #30
0
 public void GetLoot(ref WS_Network.ClientClass client, byte Slot)
 {
     try
     {
         if (Items[Slot] == null)
         {
             Packets.PacketClass response4 = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
             response4.AddInt8(49);
             response4.AddUInt64(0uL);
             response4.AddUInt64(0uL);
             response4.AddInt8(0);
             client.Send(ref response4);
             response4.Dispose();
             return;
         }
         if (GroupLootInfo.ContainsKey(Slot))
         {
             Packets.PacketClass response3 = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
             response3.AddInt8(58);
             response3.AddUInt64(0uL);
             response3.AddUInt64(0uL);
             response3.AddInt8(0);
             client.Send(ref response3);
             response3.Dispose();
             return;
         }
         ItemObject itemObject = new ItemObject(Items[Slot].ItemID, client.Character.GUID)
         {
             StackCount = Items[Slot].ItemCount
         };
         ItemObject tmpItem = itemObject;
         if (client.Character.ItemADD(ref tmpItem))
         {
             if (tmpItem.ItemInfo.Bonding == 1)
             {
                 ItemObject             itemObject2 = tmpItem;
                 WS_Network.ClientClass client2     = null;
                 itemObject2.SoulbindItem(client2);
             }
             Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.SMSG_LOOT_REMOVED);
             response2.AddInt8(Slot);
             client.Send(ref response2);
             response2.Dispose();
             client.Character.LogLootItem(tmpItem, Items[Slot].ItemCount, Recieved: false, Created: false);
             Items[Slot].Dispose();
             Items[Slot] = null;
             if (LootType == LootType.LOOTTYPE_FISHING && IsEmpty)
             {
                 SendRelease(ref client);
                 Dispose();
             }
         }
         else
         {
             tmpItem.Delete();
             Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
             response.AddInt8(50);
             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 getting loot.{0}", Environment.NewLine + e);
         ProjectData.ClearProjectError();
     }
 }