Exemple #1
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();
     }
 }
Exemple #2
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();
     }
 }
 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();
 }
Exemple #4
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();
         }
     }
 }