mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-07-24 19:38:26 +02:00
Finished fixing bugs in the bazaar code.
This commit is contained in:
parent
e8c9904e1d
commit
b2e273d7cf
7 changed files with 175 additions and 83 deletions
|
@ -10,7 +10,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
class Character:Actor
|
||||
class Character : Actor
|
||||
{
|
||||
public const int SIZE = 0;
|
||||
public const int COLORINFO = 1;
|
||||
|
@ -63,8 +63,9 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
protected Dictionary<ushort, Inventory> itemPackages = new Dictionary<ushort, Inventory>();
|
||||
protected Equipment equipment;
|
||||
|
||||
public Character(uint actorID) : base(actorID)
|
||||
{
|
||||
public Character(uint actorID)
|
||||
: base(actorID)
|
||||
{
|
||||
//Init timer array to "notimer"
|
||||
for (int i = 0; i < charaWork.statusShownTime.Length; i++)
|
||||
charaWork.statusShownTime[i] = 0xFFFFFFFF;
|
||||
|
@ -78,7 +79,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
public SubPacket CreateInitStatusPacket()
|
||||
{
|
||||
return (SetActorStatusAllPacket.BuildPacket(actorId, charaWork.status));
|
||||
return (SetActorStatusAllPacket.BuildPacket(actorId, charaWork.status));
|
||||
}
|
||||
|
||||
public SubPacket CreateSetActorIconPacket()
|
||||
|
@ -106,13 +107,13 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
currentContentGroup = group;
|
||||
|
||||
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charaWork/currentContentGroup", this);
|
||||
propPacketUtil.AddProperty("charaWork.currentContentGroup");
|
||||
propPacketUtil.AddProperty("charaWork.currentContentGroup");
|
||||
zone.BroadcastPacketsAroundActor(this, propPacketUtil.Done());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void PlayAnimation(uint animId, bool onlySelf = false)
|
||||
{
|
||||
{
|
||||
if (onlySelf)
|
||||
{
|
||||
if (this is Player)
|
||||
|
@ -121,7 +122,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
else
|
||||
zone.BroadcastPacketAroundActor(this, PlayAnimationOnActorPacket.BuildPacket(actorId, animId));
|
||||
}
|
||||
|
||||
|
||||
#region Inventory
|
||||
|
||||
public void AddItem(uint catalogID)
|
||||
|
@ -148,7 +149,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
{
|
||||
ushort itemPackage = GetPackageForItem(item.GetItemData().catalogID);
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
{
|
||||
itemPackages[itemPackage].AddItem(item);
|
||||
}
|
||||
}
|
||||
|
@ -169,9 +170,9 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
return;
|
||||
|
||||
itemPackages[sourcePackage].RemoveItem(item);
|
||||
itemPackages[destinationPackage].AddItem(item);
|
||||
itemPackages[destinationPackage].AddItem(item);
|
||||
}
|
||||
|
||||
|
||||
public void RemoveItem(uint catalogID)
|
||||
{
|
||||
RemoveItem(catalogID, 1);
|
||||
|
@ -187,7 +188,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
ushort itemPackage = GetPackageForItem(catalogID);
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
itemPackages[itemPackage].RemoveItem(catalogID, quantity, quantity);
|
||||
itemPackages[itemPackage].RemoveItem(catalogID, quantity, quality);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +270,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
if (data == null)
|
||||
return Inventory.NORMAL;
|
||||
else
|
||||
{
|
||||
{
|
||||
if (data.IsMoney())
|
||||
return Inventory.CURRENCY_CRYSTALS;
|
||||
else if (data.IsImportant())
|
||||
|
|
|
@ -56,7 +56,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
{
|
||||
int i = 0;
|
||||
foreach (InventoryItem item in itemsFromDB)
|
||||
{
|
||||
item.RefreshPositioning(itemPackageCode, (ushort) i);
|
||||
list[i++] = item;
|
||||
}
|
||||
endOfListIndex = i;
|
||||
}
|
||||
|
||||
|
@ -107,7 +110,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
}
|
||||
|
||||
public INV_ERROR AddItem(InventoryItem itemRef)
|
||||
{
|
||||
{
|
||||
//If it isn't a single item (ie: armor) just add like normal (not valid for BAZAAR)
|
||||
if (itemPackageCode != BAZAAR && itemRef.GetItemData().maxStack > 1)
|
||||
return AddItem(itemRef.itemId, itemRef.quantity, itemRef.quality);
|
||||
|
||||
if (!IsSpaceForAdd(itemRef.itemId, itemRef.quantity, itemRef.quality))
|
||||
return INV_ERROR.INVENTORY_FULL;
|
||||
|
||||
|
@ -133,10 +140,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
public INV_ERROR AddItem(uint itemId, int quantity, byte quality)
|
||||
{
|
||||
if (!IsSpaceForAdd(itemId, quantity, quality))
|
||||
return INV_ERROR.INVENTORY_FULL;
|
||||
return INV_ERROR.INVENTORY_FULL;
|
||||
|
||||
ItemData gItem = Server.GetItemGamedata(itemId);
|
||||
|
||||
//If it's unique, abort
|
||||
if (HasItem(itemId) && gItem.isExclusive)
|
||||
return INV_ERROR.ALREADY_HAS_UNIQUE;
|
||||
|
||||
ItemData gItem = Server.GetItemGamedata(itemId);
|
||||
|
||||
if (gItem == null)
|
||||
{
|
||||
Program.Log.Error("Inventory.AddItem: unable to find item %u", itemId);
|
||||
|
@ -164,10 +175,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//If it's unique, abort
|
||||
if (quantityCount > 0 && gItem.isExclusive)
|
||||
return INV_ERROR.ALREADY_HAS_UNIQUE;
|
||||
|
||||
//New item that spilled over
|
||||
while (quantityCount > 0)
|
||||
|
@ -180,9 +187,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
}
|
||||
|
||||
InventoryItem addedItem = Database.CreateItem(itemId, Math.Min(quantityCount, gItem.maxStack), quality, modifiers);
|
||||
addedItem.slot = (ushort)endOfListIndex;
|
||||
addedItem.RefreshPositioning(itemPackageCode, (ushort)endOfListIndex);
|
||||
isDirty[endOfListIndex] = true;
|
||||
list[endOfListIndex++] = addedItem;
|
||||
list[endOfListIndex++] = addedItem;
|
||||
quantityCount -= gItem.maxStack;
|
||||
|
||||
DoDatabaseAdd(addedItem);
|
||||
|
@ -197,6 +204,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
{
|
||||
list[slot] = item;
|
||||
SendUpdatePackets();
|
||||
item.RefreshPositioning(itemPackageCode, slot);
|
||||
}
|
||||
|
||||
public void RemoveItem(uint itemId)
|
||||
|
@ -260,7 +268,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
|
||||
public void RemoveItem(InventoryItem item)
|
||||
{
|
||||
RemoveItemByUniqueId(item.uniqueId, 1);
|
||||
RemoveItemByUniqueId(item.uniqueId, item.quantity);
|
||||
}
|
||||
|
||||
public void RemoveItem(InventoryItem item, int quantity)
|
||||
|
@ -272,18 +280,18 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
{
|
||||
ushort slot = 0;
|
||||
InventoryItem toDelete = null;
|
||||
for (int i = endOfListIndex - 1; i >= 0; i--)
|
||||
for (int i = 0; i < endOfListIndex; i++)
|
||||
{
|
||||
InventoryItem item = list[i];
|
||||
|
||||
Debug.Assert(item != null, "Item slot was null!!!");
|
||||
|
||||
if (item.uniqueId == itemDBId)
|
||||
{
|
||||
toDelete = item;
|
||||
break;
|
||||
}
|
||||
slot++;
|
||||
Debug.Assert(item != null, "Item slot was null!!!");
|
||||
|
||||
if (item.uniqueId == itemDBId)
|
||||
{
|
||||
toDelete = item;
|
||||
break;
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
|
||||
if (toDelete == null)
|
||||
|
@ -292,6 +300,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
if (quantity >= toDelete.quantity)
|
||||
{
|
||||
DoDatabaseRemove(toDelete.uniqueId);
|
||||
list[slot].RefreshPositioning(0xFFFF, 0xFFFF);
|
||||
list[slot] = null;
|
||||
}
|
||||
else
|
||||
|
@ -313,6 +322,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
|
||||
DoDatabaseRemove(list[slot].uniqueId);
|
||||
|
||||
list[slot].RefreshPositioning(0xFFFF, 0xFFFF);
|
||||
list[slot] = null;
|
||||
isDirty[slot] = true;
|
||||
|
||||
|
@ -333,6 +343,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
{
|
||||
DoDatabaseRemove(list[slot].uniqueId);
|
||||
|
||||
list[slot].RefreshPositioning(0xFFFF, 0xFFFF);
|
||||
list[slot] = null;
|
||||
DoRealign();
|
||||
}
|
||||
|
@ -348,6 +359,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
{
|
||||
for (int i = 0; i < endOfListIndex; i++)
|
||||
{
|
||||
list[i].RefreshPositioning(0xFFFF, 0xFFFF);
|
||||
list[i] = null;
|
||||
isDirty[i] = true;
|
||||
}
|
||||
|
@ -504,6 +516,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
if (isTemporary)
|
||||
return;
|
||||
|
||||
if (itemPackageCode == BAZAAR)
|
||||
return;
|
||||
|
||||
if (owner is Player)
|
||||
Database.AddItem((Player)owner, addedItem, itemPackageCode);
|
||||
else if (owner is Retainer)
|
||||
|
@ -515,6 +530,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
if (isTemporary)
|
||||
return;
|
||||
|
||||
|
||||
if (itemPackageCode == BAZAAR)
|
||||
return;
|
||||
|
||||
if (owner is Player)
|
||||
Database.SetQuantity((Player)owner, itemDBId, itemPackageCode);
|
||||
else if (owner is Retainer)
|
||||
|
@ -526,6 +545,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
if (isTemporary)
|
||||
return;
|
||||
|
||||
if (itemPackageCode == BAZAAR)
|
||||
return;
|
||||
|
||||
if (owner is Player)
|
||||
Database.RemoveItem((Player)owner, itemDBId);
|
||||
else if (owner is Retainer)
|
||||
|
@ -534,7 +556,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
|
||||
private void SendUpdatePackets()
|
||||
{
|
||||
if (owner is Player)
|
||||
if (owner is Player && !holdingUpdates)
|
||||
{
|
||||
SendUpdatePackets((Player)owner);
|
||||
}
|
||||
|
@ -560,7 +582,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
}
|
||||
|
||||
if (!holdingUpdates)
|
||||
DoneSendUpdate();
|
||||
Array.Clear(isDirty, 0, isDirty.Length);
|
||||
|
||||
player.QueuePacket(InventoryBeginChangePacket.BuildPacket(owner.actorId));
|
||||
player.QueuePacket(InventorySetBeginPacket.BuildPacket(owner.actorId, itemPackageCapacity, itemPackageCode));
|
||||
|
@ -580,6 +602,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
public void DoneSendUpdate()
|
||||
{
|
||||
holdingUpdates = false;
|
||||
SendUpdatePackets();
|
||||
Array.Clear(isDirty, 0, isDirty.Length);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue