mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-22 20:57:47 +00:00
Added broadcast packet list to Player. Fixed bazaar flags not working. Added the seeking item trade code.
This commit is contained in:
parent
a9d4e621e3
commit
c0312079ef
2 changed files with 73 additions and 16 deletions
|
@ -1049,7 +1049,7 @@ namespace FFXIVClassic_Map_Server
|
|||
return Database.CreateItem(itemId, amount, quality, modifiers);
|
||||
}
|
||||
|
||||
public bool BazaarPurchaseOperation(Player bazaar, Player buyer, InventoryItem itemToBuy, int quantity, int cost)
|
||||
public bool BazaarBuyOperation(Player bazaar, Player buyer, InventoryItem itemToBuy, int quantity, int cost)
|
||||
{
|
||||
if (bazaar == null || buyer == null || itemToBuy == null)
|
||||
return false;
|
||||
|
@ -1075,6 +1075,30 @@ namespace FFXIVClassic_Map_Server
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool BazaarSellOperation(Player bazaar, Player buyer, InventoryItem reward, int rewardQuantity, InventoryItem seek, int seekQuantity)
|
||||
{
|
||||
if (bazaar == null || buyer == null || reward == null || seek == null)
|
||||
return false;
|
||||
|
||||
if (rewardQuantity <= 0 || seekQuantity <= 0)
|
||||
return false;
|
||||
|
||||
if (reward.GetBazaarMode() == InventoryItem.TYPE_SEEK_ITEM)
|
||||
{
|
||||
bazaar.RemoveItem(reward, rewardQuantity);
|
||||
buyer.RemoveItem(seek, seekQuantity);
|
||||
|
||||
bazaar.AddItem(seek);
|
||||
bazaar.AddItem(reward);
|
||||
}
|
||||
|
||||
Database.ClearBazaarEntry(bazaar, reward);
|
||||
|
||||
bazaar.CheckBazaarFlags();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddToBazaar(Player player, InventoryItem reward, InventoryItem seek, int rewardAmount, int seekAmount, byte bazaarMode)
|
||||
{
|
||||
bool succ = false;
|
||||
|
|
|
@ -653,6 +653,33 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
}
|
||||
}
|
||||
|
||||
public void BroadcastPackets(List<SubPacket> packets, bool sendToSelf)
|
||||
{
|
||||
foreach (SubPacket packet in packets)
|
||||
{
|
||||
if (sendToSelf)
|
||||
{
|
||||
|
||||
SubPacket clonedPacket = new SubPacket(packet, actorId);
|
||||
QueuePacket(clonedPacket);
|
||||
}
|
||||
|
||||
foreach (Actor a in playerSession.actorInstanceList)
|
||||
{
|
||||
if (a is Player)
|
||||
{
|
||||
Player p = (Player)a;
|
||||
|
||||
if (p.Equals(this))
|
||||
continue;
|
||||
|
||||
SubPacket clonedPacket = new SubPacket(packet, a.actorId);
|
||||
p.QueuePacket(clonedPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BroadcastPacket(SubPacket packet, bool sendToSelf)
|
||||
{
|
||||
if (sendToSelf)
|
||||
|
@ -1086,24 +1113,30 @@ 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;
|
||||
|
||||
if (noUpdate)
|
||||
return;
|
||||
|
||||
if (doUpdate)
|
||||
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charaWork/bazaar", this);
|
||||
if (charaWork.eventTemp.bazaarRetail != isDealing)
|
||||
{
|
||||
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charaWork/bazaar", this);
|
||||
charaWork.eventTemp.bazaarRetail = isDealing;
|
||||
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRetail");
|
||||
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRepair");
|
||||
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarMateria");
|
||||
QueuePackets(propPacketUtil.Done());
|
||||
doUpdate = true;
|
||||
}
|
||||
|
||||
if (charaWork.eventTemp.bazaarRepair != isRepairing)
|
||||
{
|
||||
charaWork.eventTemp.bazaarRepair = isRepairing;
|
||||
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRepair");
|
||||
doUpdate = true;
|
||||
}
|
||||
|
||||
if (charaWork.eventTemp.bazaarMateria != (GetItemPackage(Inventory.MELDREQUEST).GetCount() != 0))
|
||||
{
|
||||
charaWork.eventTemp.bazaarMateria = GetItemPackage(Inventory.MELDREQUEST).GetCount() != 0;
|
||||
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarMateria");
|
||||
doUpdate = true;
|
||||
}
|
||||
|
||||
if (!noUpdate && doUpdate)
|
||||
BroadcastPackets(propPacketUtil.Done(), true);
|
||||
}
|
||||
|
||||
public int GetCurrentGil()
|
||||
|
|
Loading…
Add table
Reference in a new issue