Implement DB updates for player. Cleaned up DB calls. No longer track slot, it's ordered by index id (no concept of slots anyway in client).

This commit is contained in:
Filip Maj
2017-09-09 11:25:58 -04:00
parent 76f073d85f
commit bc95c139de
2 changed files with 70 additions and 91 deletions

View File

@@ -123,7 +123,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
int oldQuantity = item.quantity;
item.quantity = Math.Min(item.quantity + quantityCount, gItem.maxStack);
isDirty[i] = true;
quantityCount -= (gItem.maxStack - oldQuantity);
quantityCount -= (gItem.maxStack - oldQuantity);
if (owner is Player)
{
Database.SetQuantity((Player)owner, item.uniqueId, item.quantity);
}
if (quantityCount <= 0)
break;
}
@@ -145,10 +151,17 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
isDirty[endOfListIndex] = true;
list[endOfListIndex++] = addedItem;
quantityCount -= gItem.maxStack;
if (owner is Player)
{
Database.AddItem((Player)owner, addedItem, inventoryCode);
}
}
if (owner is Player)
SendUpdatePackets((Player)owner);
{
SendUpdatePackets((Player)owner);
}
return true;
}
@@ -176,12 +189,20 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
if (item.itemId == itemId)
{
int oldQuantity = item.quantity;
//Stack nomnomed
if (item.quantity - quantityCount <= 0)
list[i] = null;
//Stack reduced
else
//Stack nomnomed
if (item.quantity - quantityCount <= 0)
{
if (owner is Player)
Database.RemoveItem((Player)owner, list[i].uniqueId);
list[i] = null;
}
//Stack reduced
else
{
item.quantity -= quantityCount;
if (owner is Player)
Database.SetQuantity((Player)owner, list[i].uniqueId, list[i].quantity);
}
isDirty[i] = true;
@@ -213,7 +234,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
}
if (toDelete == null)
return;
return;
if (owner is Player)
Database.RemoveItem((Player)owner, toDelete.uniqueId);
list[slot] = null;
isDirty[slot] = true;
@@ -223,7 +247,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
public void RemoveItemAtSlot(ushort slot)
{
if (slot >= endOfListIndex)
return;
return;
if (owner is Player)
Database.RemoveItem((Player)owner, list[slot].uniqueId);
list[slot] = null;
isDirty[slot] = true;
@@ -243,9 +270,17 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
if (list[slot].quantity <= 0)
{
if (owner is Player)
Database.RemoveItem((Player)owner, list[slot].uniqueId);
list[slot] = null;
doRealign();
}
else
{
if (owner is Player)
Database.SetQuantity((Player)owner, list[slot].uniqueId, list[slot].quantity);
}
isDirty[slot] = true;
if (owner is Player)