Finished the structure of the database item loader. Added the graphics portion of the reader.

This commit is contained in:
Filip Maj 2016-02-21 16:34:29 -05:00
parent 2f3f677ec4
commit e72f1d3dcf
2 changed files with 60 additions and 18 deletions

View File

@ -96,6 +96,56 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
public static Dictionary<uint, Item> getItemGamedata()
{
using (var conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
Dictionary<uint, Item> gamedataItems = new Dictionary<uint, Item>();
try
{
conn.Open();
string query = @"
SELECT
equipSlot,
itemSlot
FROM characters_inventory_equipment
WHERE characterId = @charId ORDER BY equipSlot";
MySqlCommand cmd = new MySqlCommand(query, conn);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
uint id = reader.GetUInt32("catalogID");
Item item = null;
if (Item.IsWeapon(id))
item = new WeaponItem(reader);
else if (Item.IsArmor(id))
item = new ArmorItem(reader);
else if (Item.IsAccessory(id))
item = new AccessoryItem(reader);
else
item = new Item(reader);
gamedataItems.Add(item.catalogID, item);
}
}
}
catch (MySqlException e)
{ Console.WriteLine(e); }
finally
{
conn.Dispose();
}
return gamedataItems;
}
}
public static void loadPlayerCharacter(Player player) public static void loadPlayerCharacter(Player player)
{ {
string query; string query;

View File

@ -77,19 +77,6 @@ namespace FFXIVClassic_Map_Server.dataobjects
repairItemNum = reader.GetInt32("repairItemNum"); repairItemNum = reader.GetInt32("repairItemNum");
repairLevel = reader.GetInt32("repairLevel"); repairLevel = reader.GetInt32("repairLevel");
repairLicense = reader.GetInt32("repairLicense"); repairLicense = reader.GetInt32("repairLicense");
if (IsWeapon())
{
}
else if (IsArmor())
{
}
else if (IsAccessory())
{
}
} }
#region Utility Functions #region Utility Functions
@ -410,10 +397,10 @@ namespace FFXIVClassic_Map_Server.dataobjects
class EquipmentItem : Item class EquipmentItem : Item
{ {
//graphics //graphics
public readonly int graphicsCategoryId; public readonly uint graphicsWeaponId;
public readonly int graphicsEquipId; public readonly uint graphicsEquipmentId;
public readonly int graphicsVariantId; public readonly uint graphicsVariantId;
public readonly int graphicsColorId; public readonly uint graphicsColorId;
//equipment sheet //equipment sheet
public readonly int equipPoint; public readonly int equipPoint;
@ -444,6 +431,11 @@ namespace FFXIVClassic_Map_Server.dataobjects
public EquipmentItem(MySqlDataReader reader) public EquipmentItem(MySqlDataReader reader)
: base (reader) : base (reader)
{ {
graphicsWeaponId = reader.GetUInt32("weaponId");
graphicsEquipmentId = reader.GetUInt32("equipmentId");
graphicsVariantId = reader.GetUInt32("variantId");
graphicsColorId = reader.GetUInt32("colorId");
equipPoint = reader.GetInt32("equipPoint"); equipPoint = reader.GetInt32("equipPoint");
equipTribe1 = reader.GetInt16("equipTribe1"); equipTribe1 = reader.GetInt16("equipTribe1");
unknown1 = reader.GetUInt16("unknown1"); unknown1 = reader.GetUInt16("unknown1");