Added the UpdateItemPackage packet used to signal the server to send bazaar item info. Added a transaction method in WorldManager. Fixed some inventory bugs. InvItems now track what player, itempackage, and itemslot they are in... and may have their quantity set from there. Fixed DB SetQuantity bug.

This commit is contained in:
Filip Maj 2017-12-10 13:38:53 -05:00
parent b2e273d7cf
commit f5ea82f735
8 changed files with 156 additions and 51 deletions

View file

@ -145,6 +145,16 @@ namespace FFXIVClassic_Map_Server.Actors
}
}
public void AddItemStack(uint catalogID, int quantity, byte quality)
{
ItemData itemData = Server.GetItemGamedata(catalogID);
if (itemData != null)
{
int totalQuantity = itemData.maxStack * quantity;
AddItem(catalogID, totalQuantity, quality);
}
}
public void AddItem(InventoryItem item)
{
ushort itemPackage = GetPackageForItem(item.GetItemData().catalogID);
@ -228,7 +238,7 @@ namespace FFXIVClassic_Map_Server.Actors
ushort itemPackage = GetPackageForItem(catalogID);
if (itemPackages.ContainsKey(itemPackage))
{
itemPackages[itemPackage].HasItem(catalogID, minQuantity, quality);
return itemPackages[itemPackage].HasItem(catalogID, minQuantity, quality);
}
return false;
}

View file

@ -139,9 +139,6 @@ namespace FFXIVClassic_Map_Server.Actors
//Nameplate Stuff
public uint currentLSPlate = 0;
public bool isBazaarRetail = false;
public bool isBazaarRepair = false;
public bool isMateriaRequest = false;
public byte repairType = 0;
//Retainer
@ -505,6 +502,7 @@ namespace FFXIVClassic_Map_Server.Actors
}
//Bazaar
CheckBazaarFlags(true);
if (charaWork.eventSave.repairType != 0)
propPacketUtil.AddProperty("charaWork.eventSave.repairType");
if (charaWork.eventTemp.bazaarRetail)
@ -1067,7 +1065,7 @@ namespace FFXIVClassic_Map_Server.Actors
QueuePackets(propPacketUtil.Done());
}
public void CheckBazaarFlags()
public void CheckBazaarFlags(bool noUpdate = false)
{
bool isDealing = false, isRepairing = false, seekingItem = false;
lock (GetItemPackage(Inventory.BAZAAR))
@ -1089,15 +1087,26 @@ namespace FFXIVClassic_Map_Server.Actors
}
}
bool doUpdate = false;
if (charaWork.eventTemp.bazaarRetail != isDealing || charaWork.eventTemp.bazaarRepair != isRepairing || charaWork.eventTemp.bazaarMateria != (GetItemPackage(Inventory.MELDREQUEST).GetCount() != 0))
doUpdate = true;
charaWork.eventTemp.bazaarRetail = isDealing;
charaWork.eventTemp.bazaarRepair = isRepairing;
charaWork.eventTemp.bazaarMateria = GetItemPackage(Inventory.MELDREQUEST).GetCount() == 0;
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charaWork/bazaar", this);
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRetail");
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRepair");
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarMateria");
QueuePackets(propPacketUtil.Done());
if (noUpdate)
return;
if (doUpdate)
{
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charaWork/bazaar", this);
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRetail");
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRepair");
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarMateria");
QueuePackets(propPacketUtil.Done());
}
}
public int GetCurrentGil()
@ -1808,6 +1817,16 @@ namespace FFXIVClassic_Map_Server.Actors
chocoboAppearance = appearanceId;
}
public void SendItemPackage(Player player, uint id)
{
if (!itemPackages.ContainsKey((ushort)id))
return;
player.QueuePacket(InventoryBeginChangePacket.BuildPacket(actorId));
itemPackages[(ushort)id].SendFullInventory(player);
player.QueuePacket(InventoryEndChangePacket.BuildPacket(actorId));
}
public Retainer SpawnMyRetainer(Npc bell, int retainerIndex)
{
Retainer retainer = Database.LoadRetainer(this, retainerIndex);