mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-02 19:42:05 -04:00
More inventory item refactoring.
This commit is contained in:
parent
59e3b2379a
commit
95b003cc2b
@ -1225,7 +1225,7 @@ namespace FFXIVClassic_Map_Server
|
||||
SELECT
|
||||
serverItemId,
|
||||
itemId,
|
||||
modifierId,
|
||||
server_items_modifiers.id AS modifierId,
|
||||
quantity,
|
||||
quality,
|
||||
|
||||
@ -1246,7 +1246,7 @@ namespace FFXIVClassic_Map_Server
|
||||
|
||||
FROM characters_inventory
|
||||
INNER JOIN server_items ON serverItemId = server_items.id
|
||||
LEFT JOIN server_items_modifiers ON server_items.modifierId = server_items_modifiers.id
|
||||
LEFT JOIN server_items_modifiers ON server_items.id = server_items_modifiers.id
|
||||
WHERE characterId = @charId AND inventoryType = @type";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
@ -1304,7 +1304,7 @@ namespace FFXIVClassic_Map_Server
|
||||
SELECT
|
||||
serverItemId,
|
||||
itemId,
|
||||
modifierId,
|
||||
server_items_modifiers.id AS modifierId,
|
||||
quantity,
|
||||
quality,
|
||||
|
||||
@ -1325,7 +1325,7 @@ namespace FFXIVClassic_Map_Server
|
||||
|
||||
FROM retainers_inventory
|
||||
INNER JOIN server_items ON serverItemId = server_items.id
|
||||
LEFT JOIN server_items_modifiers ON server_items.modifierId = server_items_modifiers.id
|
||||
LEFT JOIN server_items_modifiers ON server_items.id = server_items_modifiers.id
|
||||
WHERE characterId = @charId AND inventoryType = @type";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
@ -1370,7 +1370,7 @@ namespace FFXIVClassic_Map_Server
|
||||
return items;
|
||||
}
|
||||
|
||||
public static InventoryItem CreateItem(uint itemId, int quantity, byte quality, byte itemType, int durability)
|
||||
public static InventoryItem CreateItem(uint itemId, int quantity, byte[] tags, byte[] values, byte quality, InventoryItem.ItemModifier modifiers)
|
||||
{
|
||||
InventoryItem insertedItem = null;
|
||||
|
||||
@ -1384,21 +1384,32 @@ namespace FFXIVClassic_Map_Server
|
||||
|
||||
string query = @"
|
||||
INSERT INTO server_items
|
||||
(itemId, quality, itemType, durability)
|
||||
(itemId, quality)
|
||||
VALUES
|
||||
(@itemId, @quality, @itemType, @durability);
|
||||
(@itemId, @quality);
|
||||
";
|
||||
|
||||
string query2 = @"
|
||||
INSERT INTO server_items_modifiers
|
||||
(id, durability)
|
||||
VALUES
|
||||
(@id, @durability);
|
||||
";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
|
||||
cmd.Parameters.AddWithValue("@itemId", itemId);
|
||||
cmd.Parameters.AddWithValue("@quality", quality);
|
||||
cmd.Parameters.AddWithValue("@itemType", itemType);
|
||||
cmd.Parameters.AddWithValue("@durability", durability);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
insertedItem = new InventoryItem((uint)cmd.LastInsertedId, itemId, quantity, new byte[4], new byte[4], quality, new InventoryItem.ItemModifier());
|
||||
insertedItem = new InventoryItem((uint)cmd.LastInsertedId, itemId, quantity, tags, values, quality, modifiers);
|
||||
|
||||
if (modifiers != null)
|
||||
{
|
||||
MySqlCommand cmd2 = new MySqlCommand(query2, conn);
|
||||
cmd2.Parameters.AddWithValue("@id", insertedItem.uniqueId);
|
||||
cmd2.Parameters.AddWithValue("@durability", modifiers.durability);
|
||||
cmd2.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
|
@ -153,8 +153,21 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
|
||||
//New item that spilled over
|
||||
while (quantityCount > 0)
|
||||
{
|
||||
InventoryItem addedItem = Database.CreateItem(itemId, Math.Min(quantityCount, gItem.maxStack), quality, gItem.isExclusive ? (byte)0x3 : (byte)0x0, gItem.durability);
|
||||
{
|
||||
byte[] tags = new byte[4];
|
||||
byte[] values = new byte[4];
|
||||
|
||||
if (gItem.isExclusive)
|
||||
tags[1] = 3;
|
||||
|
||||
InventoryItem.ItemModifier modifiers = null;
|
||||
if (gItem.durability != 0)
|
||||
{
|
||||
modifiers = new InventoryItem.ItemModifier();
|
||||
modifiers.durability = (uint)gItem.durability;
|
||||
}
|
||||
|
||||
InventoryItem addedItem = Database.CreateItem(itemId, Math.Min(quantityCount, gItem.maxStack), tags, values, quality, modifiers);
|
||||
addedItem.slot = (ushort)endOfListIndex;
|
||||
isDirty[endOfListIndex] = true;
|
||||
list[endOfListIndex++] = addedItem;
|
||||
|
@ -5,11 +5,17 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||
{
|
||||
class InventoryItem
|
||||
{
|
||||
public const byte DEALINGMODE_NONE = 0;
|
||||
public const byte DEALINGMODE_ATTACHED = 1;
|
||||
public const byte DEALINGMODE_PRICE = 2;
|
||||
|
||||
public ulong uniqueId;
|
||||
public uint itemId;
|
||||
public int quantity = 1;
|
||||
public ushort slot;
|
||||
|
||||
public byte dealingVal = 0;
|
||||
public byte dealingMode = DEALINGMODE_NONE;
|
||||
public uint dealingAttached1 = 0;
|
||||
public uint dealingAttached2 = 0;
|
||||
public uint dealingAttached3 = 0;
|
||||
@ -154,8 +160,8 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||
binWriter.Write((UInt32)itemId);
|
||||
binWriter.Write((UInt16)slot);
|
||||
|
||||
binWriter.Write((Byte)0x01);
|
||||
binWriter.Write((Byte)0x00);
|
||||
binWriter.Write((Byte)dealingVal);
|
||||
binWriter.Write((Byte)dealingMode);
|
||||
|
||||
binWriter.Write((UInt32)dealingAttached1);
|
||||
binWriter.Write((UInt32)dealingAttached2);
|
||||
|
Loading…
Reference in New Issue
Block a user