mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Finished writing the query and editing the inventory methods to use the gamedata.
This commit is contained in:
		| @@ -108,10 +108,14 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|  |  | ||||||
|                     string query = @" |                     string query = @" | ||||||
|                                 SELECT |                                 SELECT | ||||||
|                                 equipSlot, |                                 *                                 | ||||||
|                                 itemSlot |                                 FROM gamedata_items | ||||||
|                                 FROM characters_inventory_equipment                                     |                                 LEFT JOIN gamedata_items_equipment  ON gamedata_items.catalogID = gamedata_items_equipment.catalogID | ||||||
|                                 WHERE characterId = @charId ORDER BY equipSlot"; |                                 LEFT JOIN gamedata_items_accessory  ON gamedata_items.catalogID = gamedata_items_accessory.catalogID | ||||||
|  |                                 LEFT JOIN gamedata_items_armor      ON gamedata_items.catalogID = gamedata_items_armor.catalogID | ||||||
|  |                                 LEFT JOIN gamedata_items_weapon     ON gamedata_items.catalogID = gamedata_items_weapon.catalogID | ||||||
|  |                                 LEFT JOIN gamedata_items_graphics   ON gamedata_items.catalogID = gamedata_items_graphics.catalogID | ||||||
|  |                                 "; | ||||||
|  |  | ||||||
|                     MySqlCommand cmd = new MySqlCommand(query, conn); |                     MySqlCommand cmd = new MySqlCommand(query, conn); | ||||||
|  |  | ||||||
| @@ -670,7 +674,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                             int quantity = reader.GetInt32(2); |                             int quantity = reader.GetInt32(2); | ||||||
|                             ushort slot = reader.GetUInt16(3); |                             ushort slot = reader.GetUInt16(3); | ||||||
|  |  | ||||||
|                             bool isUntradeable = reader.GetBoolean(4); |                             byte itemType = reader.GetByte(4); | ||||||
|                             byte qualityNumber = reader.GetByte(5); |                             byte qualityNumber = reader.GetByte(5); | ||||||
|  |  | ||||||
|                             uint durability = reader.GetUInt32(6); |                             uint durability = reader.GetUInt32(6); | ||||||
| @@ -682,7 +686,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                             byte materia4 = reader.GetByte(11); |                             byte materia4 = reader.GetByte(11); | ||||||
|                             byte materia5 = reader.GetByte(12); |                             byte materia5 = reader.GetByte(12); | ||||||
|  |  | ||||||
|                             items.Add(new InventoryItem(uniqueId, itemId, quantity, slot, isUntradeable, qualityNumber, durability, spiritBind, materia1, materia2, materia3, materia4, materia5)); |                             items.Add(new InventoryItem(uniqueId, itemId, quantity, slot, itemType, qualityNumber, durability, spiritBind, materia1, materia2, materia3, materia4, materia5)); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @@ -697,7 +701,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             return items; |             return items; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static InventoryItem addItem(Player player, uint itemId, int quantity, byte quality, bool isUntradeable, uint durability, ushort type) |         public static InventoryItem addItem(Player player, uint itemId, int quantity, byte quality, byte itemType, uint durability, ushort type) | ||||||
|         { |         { | ||||||
|             InventoryItem insertedItem = null; |             InventoryItem insertedItem = null; | ||||||
|  |  | ||||||
| @@ -728,7 +732,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                      |                      | ||||||
|                     cmd.Parameters.AddWithValue("@itemId", itemId); |                     cmd.Parameters.AddWithValue("@itemId", itemId); | ||||||
|                     cmd.Parameters.AddWithValue("@quality", quality); |                     cmd.Parameters.AddWithValue("@quality", quality); | ||||||
|                     cmd.Parameters.AddWithValue("@isUntradeable", isUntradeable); |                     cmd.Parameters.AddWithValue("@itemType", itemType); | ||||||
|                     cmd.Parameters.AddWithValue("@durability", durability); |                     cmd.Parameters.AddWithValue("@durability", durability); | ||||||
|  |  | ||||||
|                     cmd2.Parameters.AddWithValue("@charId", player.actorId); |                     cmd2.Parameters.AddWithValue("@charId", player.actorId); | ||||||
| @@ -738,7 +742,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|                     cmd.ExecuteNonQuery(); |                     cmd.ExecuteNonQuery(); | ||||||
|                     cmd2.ExecuteNonQuery(); |                     cmd2.ExecuteNonQuery(); | ||||||
|  |  | ||||||
|                     insertedItem = new InventoryItem((uint)cmd.LastInsertedId, itemId, quantity, (ushort)player.getInventory(type).getNextEmptySlot(), isUntradeable, quality, durability, 0, 0, 0, 0, 0, 0); |                     insertedItem = new InventoryItem((uint)cmd.LastInsertedId, itemId, quantity, (ushort)player.getInventory(type).getNextEmptySlot(), itemType, quality, durability, 0, 0, 0, 0, 0, 0); | ||||||
|                 } |                 } | ||||||
|                 catch (MySqlException e) |                 catch (MySqlException e) | ||||||
|                 { Console.WriteLine(e); } |                 { Console.WriteLine(e); } | ||||||
|   | |||||||
| @@ -36,6 +36,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|         private LuaEngine mLuaEngine = new LuaEngine(); |         private LuaEngine mLuaEngine = new LuaEngine(); | ||||||
|  |  | ||||||
|         private WorldManager mWorldManager; |         private WorldManager mWorldManager; | ||||||
|  |         private static Dictionary<uint, Item> gamedataItems; | ||||||
|         private static StaticActors mStaticActors; |         private static StaticActors mStaticActors; | ||||||
|  |  | ||||||
|         private PacketProcessor mProcessor; |         private PacketProcessor mProcessor; | ||||||
| @@ -50,11 +51,13 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             return mSelf; |             return mSelf; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         #region Socket Handling |  | ||||||
|         public bool startServer() |         public bool startServer() | ||||||
|         { |         { | ||||||
|             mStaticActors = new StaticActors(STATIC_ACTORS_PATH); |             mStaticActors = new StaticActors(STATIC_ACTORS_PATH); | ||||||
|              |              | ||||||
|  |             gamedataItems = Database.getItemGamedata(); | ||||||
|  |             Log.info(String.Format("Loaded {0} items.",gamedataItems.Count)); | ||||||
|  |  | ||||||
|             mWorldManager = new WorldManager(this); |             mWorldManager = new WorldManager(this); | ||||||
|             mWorldManager.LoadZoneList(); |             mWorldManager.LoadZoneList(); | ||||||
|             mWorldManager.LoadZoneEntranceList(); |             mWorldManager.LoadZoneEntranceList(); | ||||||
| @@ -99,6 +102,7 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         #region Socket Handling | ||||||
|         private void acceptCallback(IAsyncResult result) |         private void acceptCallback(IAsyncResult result) | ||||||
|         { |         { | ||||||
|             ClientConnection conn = null; |             ClientConnection conn = null; | ||||||
| @@ -157,6 +161,14 @@ namespace FFXIVClassic_Lobby_Server | |||||||
|             return mStaticActors.findStaticActor(name); |             return mStaticActors.findStaticActor(name); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         public static Item getItemGamedata(uint id) | ||||||
|  |         { | ||||||
|  |             if (gamedataItems.ContainsKey(id)) | ||||||
|  |                 return gamedataItems[id]; | ||||||
|  |             else | ||||||
|  |                 return null; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Receive Callback. Reads in incoming data, converting them to base packets. Base packets are sent to be parsed. If not enough data at the end to build a basepacket, move to the beginning and prepend. |         /// Receive Callback. Reads in incoming data, converting them to base packets. Base packets are sent to be parsed. If not enough data at the end to build a basepacket, move to the beginning and prepend. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|   | |||||||
| @@ -75,6 +75,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | |||||||
|             if (!isSpaceForAdd(itemId, quantity)) |             if (!isSpaceForAdd(itemId, quantity)) | ||||||
|                 return; |                 return; | ||||||
|  |  | ||||||
|  |             Item gItem = Server.getItemGamedata(itemId); | ||||||
|             List<ushort> slotsToUpdate = new List<ushort>(); |             List<ushort> slotsToUpdate = new List<ushort>(); | ||||||
|             List<SubPacket> addItemPackets = new List<SubPacket>(); |             List<SubPacket> addItemPackets = new List<SubPacket>(); | ||||||
|  |  | ||||||
| @@ -83,12 +84,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | |||||||
|             for (int i = 0; i < list.Count; i++) |             for (int i = 0; i < list.Count; i++) | ||||||
|             {                 |             {                 | ||||||
|                 InventoryItem item = list[i]; |                 InventoryItem item = list[i]; | ||||||
|                 if (item.itemId == itemId && item.quantity < item.maxStack) |                 if (item.itemId == itemId && item.quantity < gItem.maxStack) | ||||||
|                 { |                 { | ||||||
|                     slotsToUpdate.Add(item.slot); |                     slotsToUpdate.Add(item.slot); | ||||||
|                     int oldQuantity = item.quantity; |                     int oldQuantity = item.quantity; | ||||||
|                     item.quantity = Math.Min(item.quantity + quantityCount, item.maxStack); |                     item.quantity = Math.Min(item.quantity + quantityCount, gItem.maxStack); | ||||||
|                     quantityCount -= (item.maxStack - oldQuantity); |                     quantityCount -= (gItem.maxStack - oldQuantity); | ||||||
|                     if (quantityCount <= 0) |                     if (quantityCount <= 0) | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
| @@ -118,13 +119,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | |||||||
|             //New item that spilled over |             //New item that spilled over | ||||||
|             while (quantityCount > 0) |             while (quantityCount > 0) | ||||||
|             { |             { | ||||||
|                 InventoryItem addedItem = Database.addItem(owner, itemId, Math.Min(quantityCount, 5), quality, false, 100, inventoryCode); |                 InventoryItem addedItem = Database.addItem(owner, itemId, Math.Min(quantityCount, 5), quality, gItem.isExclusive ? (byte)0x3 : (byte)0x0, 100, inventoryCode); | ||||||
|  |  | ||||||
|  |                  | ||||||
|                 list.Add(addedItem); |                 list.Add(addedItem); | ||||||
|  |  | ||||||
|                 if (inventoryCode != CURRANCY && inventoryCode != KEYITEMS) |                 if (inventoryCode != CURRANCY && inventoryCode != KEYITEMS) | ||||||
|                     sendInventoryPackets(addedItem); |                     sendInventoryPackets(addedItem); | ||||||
|  |  | ||||||
|                 quantityCount -= addedItem.maxStack; |                 quantityCount -= gItem.maxStack; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (inventoryCode == CURRANCY || inventoryCode == KEYITEMS) |             if (inventoryCode == CURRANCY || inventoryCode == KEYITEMS) | ||||||
| @@ -405,9 +408,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | |||||||
|             for (int i = 0; i < list.Count; i++) |             for (int i = 0; i < list.Count; i++) | ||||||
|             { |             { | ||||||
|                 InventoryItem item = list[i]; |                 InventoryItem item = list[i]; | ||||||
|                 if (item.itemId == itemId && item.quantity < item.maxStack) |                 Item gItem = Server.getItemGamedata(item.itemId); | ||||||
|  |                 if (item.itemId == itemId && item.quantity < gItem.maxStack) | ||||||
|                 { |                 { | ||||||
|                     quantityCount -= (item.maxStack - item.quantity); |                     quantityCount -= (gItem.maxStack - item.quantity); | ||||||
|                     if (quantityCount <= 0) |                     if (quantityCount <= 0) | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| using System; | using FFXIVClassic_Lobby_Server; | ||||||
|  | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.IO; | using System.IO; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| @@ -14,9 +15,7 @@ namespace FFXIVClassic_Map_Server.dataobjects | |||||||
|         public int quantity = 1; |         public int quantity = 1; | ||||||
|         public ushort slot; |         public ushort slot; | ||||||
|  |  | ||||||
|         public int maxStack = 99999; |         public byte itemType; | ||||||
|  |  | ||||||
|         public bool isUntradeable = false; |  | ||||||
|         public byte quality = 1; |         public byte quality = 1; | ||||||
|  |  | ||||||
|         public uint durability = 0; |         public uint durability = 0; | ||||||
| @@ -35,15 +34,18 @@ namespace FFXIVClassic_Map_Server.dataobjects | |||||||
|             this.itemId = itemId; |             this.itemId = itemId; | ||||||
|             this.quantity = quantity; |             this.quantity = quantity; | ||||||
|             this.slot = slot; |             this.slot = slot; | ||||||
|  |  | ||||||
|  |             Item gItem = Server.getItemGamedata(id); | ||||||
|  |             itemType = gItem.isExclusive ? (byte)0x3 : (byte)0x0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public InventoryItem(uint uniqueId, uint itemId, int quantity, ushort slot, bool isUntradeable, byte qualityNumber, uint durability, ushort spiritbind, byte materia1, byte materia2, byte materia3, byte materia4, byte materia5) |         public InventoryItem(uint uniqueId, uint itemId, int quantity, ushort slot, byte itemType, byte qualityNumber, uint durability, ushort spiritbind, byte materia1, byte materia2, byte materia3, byte materia4, byte materia5) | ||||||
|         { |         { | ||||||
|             this.uniqueId = uniqueId; |             this.uniqueId = uniqueId; | ||||||
|             this.itemId = itemId; |             this.itemId = itemId; | ||||||
|             this.quantity = quantity; |             this.quantity = quantity; | ||||||
|             this.slot = slot; |             this.slot = slot; | ||||||
|             this.isUntradeable = isUntradeable; |             this.itemType = itemType; | ||||||
|             this.quality = qualityNumber; |             this.quality = qualityNumber; | ||||||
|             this.durability = durability; |             this.durability = durability; | ||||||
|             this.spiritbind = spiritbind; |             this.spiritbind = spiritbind; | ||||||
| @@ -73,7 +75,7 @@ namespace FFXIVClassic_Map_Server.dataobjects | |||||||
|                     binWriter.Write((UInt32)0x00000000); |                     binWriter.Write((UInt32)0x00000000); | ||||||
|                     binWriter.Write((UInt32)0x00000000); |                     binWriter.Write((UInt32)0x00000000); | ||||||
|  |  | ||||||
|                     binWriter.Write(isUntradeable ? (UInt32)0x3 : (UInt32)0x0); |                     binWriter.Write((UInt32)itemType); | ||||||
|  |  | ||||||
|                     binWriter.Write((UInt32)0x00000000); |                     binWriter.Write((UInt32)0x00000000); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -426,15 +426,18 @@ namespace FFXIVClassic_Map_Server.dataobjects | |||||||
|  |  | ||||||
|         public readonly short additionalEffect; |         public readonly short additionalEffect; | ||||||
|         public readonly bool materialBindPermission; |         public readonly bool materialBindPermission; | ||||||
|         public readonly short materiaTable; |         public readonly short materializeTable; | ||||||
|  |  | ||||||
|         public EquipmentItem(MySqlDataReader reader)  |         public EquipmentItem(MySqlDataReader reader)  | ||||||
|             : base (reader) |             : base (reader) | ||||||
|         { |         { | ||||||
|             graphicsWeaponId = reader.GetUInt32("weaponId"); |             if (!reader.IsDBNull(reader.GetOrdinal("weaponId")) && !reader.IsDBNull(reader.GetOrdinal("equipmentId")) && !reader.IsDBNull(reader.GetOrdinal("variantId")) && !reader.IsDBNull(reader.GetOrdinal("colorId"))) | ||||||
|             graphicsEquipmentId = reader.GetUInt32("equipmentId"); |             { | ||||||
|             graphicsVariantId = reader.GetUInt32("variantId"); |                 graphicsWeaponId = reader.GetUInt32("weaponId"); | ||||||
|             graphicsColorId = reader.GetUInt32("colorId"); |                 graphicsEquipmentId = reader.GetUInt32("equipmentId"); | ||||||
|  |                 graphicsVariantId = reader.GetUInt32("variantId"); | ||||||
|  |                 graphicsColorId = reader.GetUInt32("colorId"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             equipPoint = reader.GetInt32("equipPoint"); |             equipPoint = reader.GetInt32("equipPoint"); | ||||||
|             equipTribe = reader.GetInt16("equipTribe"); |             equipTribe = reader.GetInt16("equipTribe"); | ||||||
| @@ -461,8 +464,8 @@ namespace FFXIVClassic_Map_Server.dataobjects | |||||||
|             paramBonusValue10 = reader.GetInt16("paramBonusValue10"); |             paramBonusValue10 = reader.GetInt16("paramBonusValue10"); | ||||||
|  |  | ||||||
|             additionalEffect = reader.GetInt16("additionalEffect"); |             additionalEffect = reader.GetInt16("additionalEffect"); | ||||||
|             materialBindPermission = reader.GetBoolean("materialBindPermission"); |             materialBindPermission = reader.GetBoolean("materiaBindPermission"); | ||||||
|             materiaTable = reader.GetInt16("materiaTable"); |             materializeTable = reader.GetInt16("materializeTable"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -529,8 +532,8 @@ namespace FFXIVClassic_Map_Server.dataobjects | |||||||
|     class ArmorItem : EquipmentItem |     class ArmorItem : EquipmentItem | ||||||
|     { |     { | ||||||
|         //armor sheet |         //armor sheet | ||||||
|         public readonly short defence;    |         public readonly short defense; | ||||||
|         public readonly short magicDefence; |         public readonly short magicDefense; | ||||||
|         public readonly short criticalDefense; |         public readonly short criticalDefense; | ||||||
|         public readonly short evasion; |         public readonly short evasion; | ||||||
|         public readonly short magicResistance; |         public readonly short magicResistance; | ||||||
| @@ -547,8 +550,8 @@ namespace FFXIVClassic_Map_Server.dataobjects | |||||||
|         public ArmorItem(MySqlDataReader reader) |         public ArmorItem(MySqlDataReader reader) | ||||||
|             : base(reader) |             : base(reader) | ||||||
|         { |         { | ||||||
|             defence = reader.GetInt16("defence"); |             defense = reader.GetInt16("defense"); | ||||||
|             magicDefence = reader.GetInt16("magicDefence"); |             magicDefense = reader.GetInt16("magicDefense"); | ||||||
|             criticalDefense = reader.GetInt16("criticalDefense"); |             criticalDefense = reader.GetInt16("criticalDefense"); | ||||||
|             evasion = reader.GetInt16("evasion"); |             evasion = reader.GetInt16("evasion"); | ||||||
|             magicResistance = reader.GetInt16("magicResistance"); |             magicResistance = reader.GetInt16("magicResistance"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user