mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-08-05 17:18:07 +02:00
Implemented mode trade methods. Figured out the modifiers portion of the item packet and rewrote how they are stored.
This commit is contained in:
parent
94491903f7
commit
59e3b2379a
6 changed files with 300 additions and 116 deletions
|
@ -37,6 +37,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
private bool isTemporary;
|
||||
private InventoryItem[] list;
|
||||
private bool[] isDirty;
|
||||
private bool holdingUpdates = false;
|
||||
|
||||
private int endOfListIndex = 0;
|
||||
|
||||
|
@ -135,7 +136,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
if (item.itemId == itemId && item.quality == quality && item.quantity < gItem.maxStack)
|
||||
{
|
||||
int oldQuantity = item.quantity;
|
||||
item.quantity = Math.Min(item.quantity + quantityCount, gItem.maxStack);
|
||||
item.quantity = Math.Min(item.quantity + quantityCount, gItem.maxStack);
|
||||
isDirty[i] = true;
|
||||
quantityCount -= (gItem.maxStack - oldQuantity);
|
||||
|
||||
|
@ -165,6 +166,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
SendUpdatePackets();
|
||||
|
||||
return INV_ERROR.SUCCESS;
|
||||
}
|
||||
|
||||
public void AddItemSpecial(ushort slot, InventoryItem item)
|
||||
{
|
||||
list[slot] = item;
|
||||
SendUpdatePackets();
|
||||
}
|
||||
|
||||
public void RemoveItem(uint itemId)
|
||||
|
@ -306,6 +313,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
SendUpdatePackets();
|
||||
}
|
||||
|
||||
public InventoryItem[] GetRawList()
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
public void ChangeDurability(uint slot, uint durabilityChange)
|
||||
{
|
||||
isDirty[slot] = true;
|
||||
|
@ -481,11 +493,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
{
|
||||
if (owner is Player)
|
||||
{
|
||||
SendUpdatePackets((Player)owner, true);
|
||||
SendUpdatePackets((Player)owner);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendUpdatePackets(Player player, bool doneImmediate = false)
|
||||
public void SendUpdatePackets(Player player)
|
||||
{
|
||||
List<InventoryItem> items = new List<InventoryItem>();
|
||||
List<ushort> slotsToRemove = new List<ushort>();
|
||||
|
@ -504,7 +516,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
slotsToRemove.Add((ushort)i);
|
||||
}
|
||||
|
||||
if (doneImmediate)
|
||||
if (!holdingUpdates)
|
||||
DoneSendUpdate();
|
||||
|
||||
player.QueuePacket(InventoryBeginChangePacket.BuildPacket(owner.actorId));
|
||||
|
@ -517,8 +529,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
player.QueuePacket(InventoryEndChangePacket.BuildPacket(owner.actorId));
|
||||
}
|
||||
|
||||
public void StartSendUpdate()
|
||||
{
|
||||
holdingUpdates = true;
|
||||
}
|
||||
|
||||
public void DoneSendUpdate()
|
||||
{
|
||||
holdingUpdates = false;
|
||||
Array.Clear(isDirty, 0, isDirty.Length);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,8 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
//Trading
|
||||
private Player otherTrader = null;
|
||||
private Inventory myOfferings;
|
||||
private bool isTradeAccepted = false;
|
||||
private bool isTradeLocked = false;
|
||||
|
||||
//GC Related
|
||||
public byte gcCurrent;
|
||||
|
@ -1600,7 +1602,18 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
return;
|
||||
|
||||
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
||||
SubPacket spacket = KickEventPacket.BuildPacket(actorId, actor.actorId, conditionName, lParams);
|
||||
SubPacket spacket = KickEventPacket.BuildPacket(actorId, actor.actorId, 0x75dc1, conditionName, lParams);
|
||||
spacket.DebugPrintSubPacket();
|
||||
QueuePacket(spacket);
|
||||
}
|
||||
|
||||
public void KickEventSpecial(Actor actor, uint unknown, string conditionName, params object[] parameters)
|
||||
{
|
||||
if (actor == null)
|
||||
return;
|
||||
|
||||
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
||||
SubPacket spacket = KickEventPacket.BuildPacket(actorId, actor.actorId, unknown, conditionName, lParams);
|
||||
spacket.DebugPrintSubPacket();
|
||||
QueuePacket(spacket);
|
||||
}
|
||||
|
@ -1786,19 +1799,98 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
myOfferings = new Inventory(this, 4, Inventory.TRADE, true);
|
||||
Inventory otherPlayerOfferings = new Inventory(otherPlayer, 4, Inventory.TRADE, true);
|
||||
|
||||
QueuePacket(InventoryBeginChangePacket.BuildPacket(actorId));
|
||||
QueuePacket(InventorySetBeginPacket.BuildPacket(actorId, 4, Inventory.TRADE));
|
||||
|
||||
QueuePacket(EquipmentListX01Packet.BuildPacket(actorId, 1, 1));
|
||||
|
||||
QueuePacket(InventorySetEndPacket.BuildPacket(actorId));
|
||||
QueuePacket(InventoryEndChangePacket.BuildPacket(actorId));
|
||||
|
||||
myOfferings.SendFullInventory(this);
|
||||
myOfferings.StartSendUpdate();
|
||||
myOfferings.SendUpdatePackets(this);
|
||||
myOfferings.SendUpdatePackets(otherPlayer);
|
||||
myOfferings.DoneSendUpdate();
|
||||
|
||||
otherTrader = otherPlayer;
|
||||
isTradeAccepted = false;
|
||||
}
|
||||
|
||||
public Player GetOtherTrader()
|
||||
{
|
||||
return otherTrader;
|
||||
}
|
||||
|
||||
public Inventory GetTradeOfferings()
|
||||
{
|
||||
return myOfferings;
|
||||
}
|
||||
|
||||
public bool IsTrading()
|
||||
{
|
||||
return otherTrader != null;
|
||||
}
|
||||
|
||||
public bool IsTradeAccepted()
|
||||
{
|
||||
return isTradeAccepted;
|
||||
}
|
||||
|
||||
public void AddTradeItem(ushort slot, ushort linkedSlot, int subquantity)
|
||||
{
|
||||
if (!IsTrading())
|
||||
return;
|
||||
|
||||
InventoryItem mine = inventories[Inventory.NORMAL].GetItemAtSlot(linkedSlot);
|
||||
|
||||
InventoryItem tradeItem = new InventoryItem(mine, slot);
|
||||
|
||||
myOfferings.StartSendUpdate();
|
||||
myOfferings.AddItem(mine.itemId, mine.quantity, mine.quality);
|
||||
myOfferings.SendUpdatePackets(otherTrader);
|
||||
myOfferings.DoneSendUpdate();
|
||||
}
|
||||
|
||||
public void AddTradeGil(int quantity)
|
||||
{
|
||||
if (!IsTrading())
|
||||
return;
|
||||
|
||||
myOfferings.StartSendUpdate();
|
||||
myOfferings.AddItem(1000001, quantity, 1);
|
||||
myOfferings.SendUpdatePackets(otherTrader);
|
||||
myOfferings.DoneSendUpdate();
|
||||
}
|
||||
|
||||
public void RemoveTradeItem(ushort slot)
|
||||
{
|
||||
if (!IsTrading())
|
||||
return;
|
||||
|
||||
myOfferings.StartSendUpdate();
|
||||
myOfferings.RemoveItemAtSlot(slot);
|
||||
myOfferings.SendUpdatePackets(otherTrader);
|
||||
myOfferings.DoneSendUpdate();
|
||||
}
|
||||
|
||||
public void ClearTradeItems(ushort slot)
|
||||
{
|
||||
if (!IsTrading())
|
||||
return;
|
||||
|
||||
myOfferings.StartSendUpdate();
|
||||
myOfferings.Clear();
|
||||
myOfferings.SendUpdatePackets(otherTrader);
|
||||
myOfferings.DoneSendUpdate();
|
||||
}
|
||||
|
||||
public void AcceptTrade(bool accepted)
|
||||
{
|
||||
if (!IsTrading())
|
||||
return;
|
||||
isTradeAccepted = accepted;
|
||||
}
|
||||
|
||||
public void FinishTradeTransaction()
|
||||
{
|
||||
isTradeAccepted = false;
|
||||
myOfferings = null;
|
||||
otherTrader = null;
|
||||
}
|
||||
|
||||
|
||||
public void Test()
|
||||
{
|
||||
QueuePacket(InventoryBeginChangePacket.BuildPacket(actorId));
|
||||
|
@ -1820,22 +1912,5 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
QueuePacket(InventoryEndChangePacket.BuildPacket(actorId));
|
||||
}
|
||||
|
||||
|
||||
public Inventory GetTradeOfferings()
|
||||
{
|
||||
return myOfferings;
|
||||
}
|
||||
|
||||
public void FinishTradeTransaction()
|
||||
{
|
||||
myOfferings = null;
|
||||
otherTrader = null;
|
||||
}
|
||||
|
||||
public void CancelTradeTransaction()
|
||||
{
|
||||
myOfferings = null;
|
||||
otherTrader = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue