Added seek nameplate code. Added bazaar transaction stuff to WorldManager and DB. Added Item Gamedata to InventoryItem class.

This commit is contained in:
Filip Maj 2017-11-11 10:56:15 -05:00
parent b191da416b
commit 3850860440
5 changed files with 512 additions and 47 deletions

View File

@ -1078,7 +1078,7 @@ namespace FFXIVClassic_Map_Server
player.GetInventory(Inventory.NORMAL).InitList(GetInventory(player, 0, Inventory.NORMAL)); player.GetInventory(Inventory.NORMAL).InitList(GetInventory(player, 0, Inventory.NORMAL));
player.GetInventory(Inventory.KEYITEMS).InitList(GetInventory(player, 0, Inventory.KEYITEMS)); player.GetInventory(Inventory.KEYITEMS).InitList(GetInventory(player, 0, Inventory.KEYITEMS));
player.GetInventory(Inventory.CURRENCY_CRYSTALS).InitList(GetInventory(player, 0, Inventory.CURRENCY_CRYSTALS)); player.GetInventory(Inventory.CURRENCY_CRYSTALS).InitList(GetInventory(player, 0, Inventory.CURRENCY_CRYSTALS));
player.GetInventory(Inventory.BAZAAR).InitList(GetInventory(player, 0, Inventory.BAZAAR)); player.GetInventory(Inventory.BAZAAR).InitList(GetBazaar(player));
player.GetInventory(Inventory.MELDREQUEST).InitList(GetInventory(player, 0, Inventory.MELDREQUEST)); player.GetInventory(Inventory.MELDREQUEST).InitList(GetInventory(player, 0, Inventory.MELDREQUEST));
player.GetInventory(Inventory.LOOT).InitList(GetInventory(player, 0, Inventory.LOOT)); player.GetInventory(Inventory.LOOT).InitList(GetInventory(player, 0, Inventory.LOOT));
@ -1227,6 +1227,7 @@ namespace FFXIVClassic_Map_Server
itemId, itemId,
server_items_modifiers.id AS modifierId, server_items_modifiers.id AS modifierId,
quantity, quantity,
isExclusive,
quality, quality,
durability, durability,
@ -1247,7 +1248,7 @@ namespace FFXIVClassic_Map_Server
FROM characters_inventory FROM characters_inventory
INNER JOIN server_items ON serverItemId = server_items.id INNER JOIN server_items ON serverItemId = server_items.id
LEFT JOIN server_items_modifiers ON server_items.id = server_items_modifiers.id LEFT JOIN server_items_modifiers ON server_items.id = server_items_modifiers.id
WHERE characterId = @charId AND inventoryType = @type"; WHERE characterId = @charId AND itemPackage = @type";
MySqlCommand cmd = new MySqlCommand(query, conn); MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@charId", player.actorId); cmd.Parameters.AddWithValue("@charId", player.actorId);
@ -1270,7 +1271,7 @@ namespace FFXIVClassic_Map_Server
if (hasModifier) if (hasModifier)
modifier = new InventoryItem.ItemModifier(reader); modifier = new InventoryItem.ItemModifier(reader);
InventoryItem item = new InventoryItem(uniqueId, itemId, quantity, new byte[4], new byte[4], qualityNumber, modifier); InventoryItem item = new InventoryItem(uniqueId, Server.GetItemGamedata(itemId), quantity, qualityNumber, modifier);
item.slot = slot; item.slot = slot;
slot++; slot++;
items.Add(item); items.Add(item);
@ -1290,6 +1291,249 @@ namespace FFXIVClassic_Map_Server
return items; return items;
} }
public static bool CreateBazaarEntry(Player owner, InventoryItem reward, InventoryItem seek, int rewardAmount, int seekAmount, byte bazaarMode, int sellPrice = 0)
{
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
{
conn.Open();
string query = @"
INSERT INTO characters_inventory_bazaar
(characterId, rewardId, seekId, rewardAmount, seekAmount, bazaarMode, sellPrice)
VALUES
(@characterId, @rewardId, @seekId, @rewardAmount, @seekAmount, @bazaarMode, @sellPrice);
";
MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@characterId", owner.actorId);
cmd.Parameters.AddWithValue("@rewardId", reward.uniqueId);
cmd.Parameters.AddWithValue("@seekId", seek.uniqueId);
cmd.Parameters.AddWithValue("@rewardAmount", rewardAmount);
cmd.Parameters.AddWithValue("@seekAmount", seekAmount);
cmd.Parameters.AddWithValue("@bazaarMode", bazaarMode);
cmd.Parameters.AddWithValue("@sellPrice", sellPrice);
cmd.ExecuteNonQuery();
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
return false;
}
finally
{
conn.Dispose();
}
}
return true;
}
public static void ClearBazaarEntry(Player owner, InventoryItem reward)
{
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}; Allow User Variables=True", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
{
conn.Open();
string query = @"
DELETE FROM characters_inventory_bazaar
WHERE characterId = @charId and rewardId = @rewardId;
";
MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@charId", owner.actorId);
cmd.Parameters.AddWithValue("@rewardId", reward.uniqueId);
cmd.ExecuteNonQuery();
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
}
public static List<InventoryItem> GetBazaar(Player player)
{
List<InventoryItem> rewardItems = new List<InventoryItem>();
Dictionary<ulong, InventoryItem> seekItems = new Dictionary<ulong, InventoryItem>();
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
{
conn.Open();
string query = @"
SELECT
rewardId,
seekId,
rewardAmount,
bazaarMode,
sellPrice,
itemId,
server_items_modifiers.id AS modifierId,
quantity,
isExclusive,
quality,
durability,
mainQuality,
subQuality1,
subQuality2,
subQuality3,
param1,
param2,
param3,
spiritbind,
materia1,
materia2,
materia3,
materia4,
materia5
FROM characters_inventory_bazaar
INNER JOIN server_items ON rewardId = server_items.id
LEFT JOIN server_items_modifiers ON server_items.id = server_items_modifiers.id
WHERE characterId = @charaId";
MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@charaId", player.actorId);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
uint uniqueId = reader.GetUInt32("rewardId");
uint itemId = reader.GetUInt32("itemId");
int quantity = reader.GetInt32("quantity");
byte qualityNumber = reader.GetByte("quality");
bool hasModifier = !reader.IsDBNull(reader.GetOrdinal("modifierId"));
InventoryItem.ItemModifier modifier = null;
if (hasModifier)
modifier = new InventoryItem.ItemModifier(reader);
InventoryItem item = new InventoryItem(uniqueId, Server.GetItemGamedata(itemId), quantity, qualityNumber, modifier);
byte bazaarMode = reader.GetByte("bazaarMode");
if (bazaarMode == InventoryItem.TYPE_SINGLE || bazaarMode == InventoryItem.TYPE_STACK)
{
uint price = (uint) reader.GetInt32("sellPrice");
item.SetDealing(bazaarMode, price);
}
else
{
uint seekId = reader.GetUInt32("seekId");
item.SetDealingAttached(bazaarMode, seekId);
}
rewardItems.Add(item);
}
}
string query2 = @"
SELECT
seekId,
seekAmount,
sellPrice,
itemId,
server_items_modifiers.id AS modifierId,
quantity,
isExclusive,
quality,
durability,
mainQuality,
subQuality1,
subQuality2,
subQuality3,
param1,
param2,
param3,
spiritbind,
materia1,
materia2,
materia3,
materia4,
materia5
FROM characters_inventory_bazaar
INNER JOIN server_items ON seekId = server_items.id
LEFT JOIN server_items_modifiers ON server_items.id = server_items_modifiers.id
WHERE characterId = @charaId";
MySqlCommand cmd2 = new MySqlCommand(query2, conn);
cmd2.Parameters.AddWithValue("@charaId", player.actorId);
using (MySqlDataReader reader = cmd2.ExecuteReader())
{
while (reader.Read())
{
uint uniqueId = reader.GetUInt32("seekId");
uint itemId = reader.GetUInt32("itemId");
int quantity = reader.GetInt32("quantity");
byte qualityNumber = reader.GetByte("quality");
bool hasModifier = !reader.IsDBNull(reader.GetOrdinal("modifierId"));
InventoryItem.ItemModifier modifier = null;
if (hasModifier)
modifier = new InventoryItem.ItemModifier(reader);
InventoryItem item = new InventoryItem(uniqueId, Server.GetItemGamedata(itemId), quantity, qualityNumber, modifier);
item.SetHasAttached(true);
seekItems.Add(uniqueId, item);
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
List<InventoryItem> items = new List<InventoryItem>();
ushort slot = 0;
foreach (InventoryItem reward in rewardItems)
{
if (reward.dealingMode == InventoryItem.DEALINGMODE_PRICED)
{
reward.slot = slot++;
items.Add(reward);
}
else
{
if (seekItems.ContainsKey(reward.GetAttached()))
{
reward.slot = slot++;
items.Add(reward);
InventoryItem seek = seekItems[reward.GetAttached()];
seek.slot = slot++;
items.Add(seek);
reward.SetAttachedIndex(7, seek.slot);
}
}
}
return items;
}
public static List<InventoryItem> GetInventory(Retainer retainer, uint type) public static List<InventoryItem> GetInventory(Retainer retainer, uint type)
{ {
List<InventoryItem> items = new List<InventoryItem>(); List<InventoryItem> items = new List<InventoryItem>();
@ -1326,7 +1570,7 @@ namespace FFXIVClassic_Map_Server
FROM retainers_inventory FROM retainers_inventory
INNER JOIN server_items ON serverItemId = server_items.id INNER JOIN server_items ON serverItemId = server_items.id
LEFT JOIN server_items_modifiers ON server_items.id = server_items_modifiers.id LEFT JOIN server_items_modifiers ON server_items.id = server_items_modifiers.id
WHERE characterId = @charId AND inventoryType = @type"; WHERE characterId = @charId AND itemPackage = @type";
MySqlCommand cmd = new MySqlCommand(query, conn); MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@retainerId", retainer.getRetainerId()); cmd.Parameters.AddWithValue("@retainerId", retainer.getRetainerId());
@ -1350,7 +1594,7 @@ namespace FFXIVClassic_Map_Server
if (hasModifier) if (hasModifier)
modifier = new InventoryItem.ItemModifier(reader); modifier = new InventoryItem.ItemModifier(reader);
InventoryItem item = new InventoryItem(uniqueId, itemId, quantity, new byte[4], new byte[4], qualityNumber, modifier); InventoryItem item = new InventoryItem(uniqueId, Server.GetItemGamedata(itemId), quantity, qualityNumber, modifier);
item.slot = slot; item.slot = slot;
slot++; slot++;
items.Add(item); items.Add(item);
@ -1370,7 +1614,7 @@ namespace FFXIVClassic_Map_Server
return items; return items;
} }
public static InventoryItem CreateItem(uint itemId, int quantity, byte[] tags, byte[] values, byte quality, InventoryItem.ItemModifier modifiers) public static InventoryItem CreateItem(uint itemId, int quantity, byte quality, InventoryItem.ItemModifier modifiers = null)
{ {
InventoryItem insertedItem = null; InventoryItem insertedItem = null;
@ -1401,7 +1645,7 @@ namespace FFXIVClassic_Map_Server
cmd.Parameters.AddWithValue("@quality", quality); cmd.Parameters.AddWithValue("@quality", quality);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
insertedItem = new InventoryItem((uint)cmd.LastInsertedId, itemId, quantity, tags, values, quality, modifiers); insertedItem = new InventoryItem((uint)cmd.LastInsertedId, Server.GetItemGamedata(itemId), quantity, quality, modifiers);
if (modifiers != null) if (modifiers != null)
{ {
@ -1434,16 +1678,16 @@ namespace FFXIVClassic_Map_Server
string query = @" string query = @"
INSERT INTO characters_inventory INSERT INTO characters_inventory
(characterId, inventoryType, serverItemId, quantity) (characterId, itemPackage, serverItemId, quantity)
VALUES VALUES
(@charId, @inventoryType, @serverItemId, @quantity) (@charId, @itemPackage, @serverItemId, @quantity)
"; ";
MySqlCommand cmd = new MySqlCommand(query, conn); MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@serverItemId", addedItem.uniqueId); cmd.Parameters.AddWithValue("@serverItemId", addedItem.uniqueId);
cmd.Parameters.AddWithValue("@charId", player.actorId); cmd.Parameters.AddWithValue("@charId", player.actorId);
cmd.Parameters.AddWithValue("@inventoryType", type); cmd.Parameters.AddWithValue("@itemPackage", type);
cmd.Parameters.AddWithValue("@quantity", addedItem.quantity); cmd.Parameters.AddWithValue("@quantity", addedItem.quantity);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
@ -1520,7 +1764,6 @@ namespace FFXIVClassic_Map_Server
conn.Dispose(); conn.Dispose();
} }
} }
} }
public static void AddItem(Retainer retainer, InventoryItem addedItem, uint type) public static void AddItem(Retainer retainer, InventoryItem addedItem, uint type)
@ -1533,16 +1776,16 @@ namespace FFXIVClassic_Map_Server
string query = @" string query = @"
INSERT INTO retainers_inventory INSERT INTO retainers_inventory
(retainerId, inventoryType, serverItemId, quantity) (retainerId, itemPackage, serverItemId, quantity)
VALUES VALUES
(@retainerId, @inventoryType, @serverItemId, @quantity) (@retainerId, @itemPackage, @serverItemId, @quantity)
"; ";
MySqlCommand cmd = new MySqlCommand(query, conn); MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@serverItemId", addedItem.uniqueId); cmd.Parameters.AddWithValue("@serverItemId", addedItem.uniqueId);
cmd.Parameters.AddWithValue("@retainerId", retainer.getRetainerId()); cmd.Parameters.AddWithValue("@retainerId", retainer.getRetainerId());
cmd.Parameters.AddWithValue("@inventoryType", type); cmd.Parameters.AddWithValue("@itemPackage", type);
cmd.Parameters.AddWithValue("@quantity", addedItem.quantity); cmd.Parameters.AddWithValue("@quantity", addedItem.quantity);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();

View File

@ -23,6 +23,7 @@ using FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group;
using System.Threading; using System.Threading;
using System.Diagnostics; using System.Diagnostics;
using FFXIVClassic_Map_Server.actors.director; using FFXIVClassic_Map_Server.actors.director;
using FFXIVClassic_Map_Server.actors.chara.player;
namespace FFXIVClassic_Map_Server namespace FFXIVClassic_Map_Server
{ {
@ -1043,6 +1044,117 @@ namespace FFXIVClassic_Map_Server
} }
} }
public InventoryItem CreateItem(uint itemId, int amount, byte quality = 1)
{
return Database.CreateItem(itemId, amount, quality);
}
public void AddToBazaarRewardGil(Player player, InventoryItem seek, int seekAmount, int gilAmount, byte bazaarMode)
{
bool succ = Database.CreateBazaarEntry(player, gilReward, seek, gilAmount, seekAmount, bazaarMode);
if (succ)
{
player.GetInventory(Inventory.CURRENCY_CRYSTALS).RemoveItem(1000001, gilAmount);
player.GetInventory(Inventory.BAZAAR).StartSendUpdate();
player.GetInventory(Inventory.BAZAAR).AddItem(gilReward);
player.GetInventory(Inventory.BAZAAR).AddItem(seek);
player.GetInventory(Inventory.BAZAAR).DoneSendUpdate();
}
}
public void AddToBazaarSeekGil(Player player, InventoryItem reward, int rewardAmount, int gilAmount, byte bazaarMode)
{
InventoryItem gilSeek = Database.CreateItem(1000001, gilAmount, 1);
bool succ = false;
if (bazaarMode == InventoryItem.TYPE_SINGLE || bazaarMode == InventoryItem.TYPE_STACK)
succ = Database.CreateBazaarEntry(player, reward, gilSeek, rewardAmount, 0, bazaarMode, gilAmount);
else
succ = Database.CreateBazaarEntry(player, reward, gilSeek, rewardAmount, gilAmount, bazaarMode);
if (succ)
{
player.GetInventory(Inventory.NORMAL).RemoveItem(reward);
player.GetInventory(Inventory.BAZAAR).StartSendUpdate();
player.GetInventory(Inventory.BAZAAR).AddItem(reward);
player.GetInventory(Inventory.BAZAAR).AddItem(gilSeek);
player.GetInventory(Inventory.BAZAAR).DoneSendUpdate();
}
}
public void AddToBazaar(Player player, InventoryItem reward, InventoryItem seek, int rewardAmount, int seekAmount, byte bazaarMode)
{
bool succ = Database.CreateBazaarEntry(player, reward, seek, rewardAmount, seekAmount, bazaarMode);
if (succ)
{
if (reward.GetItemData().IsMoney())
player.GetInventory(Inventory.NORMAL).RemoveItem(reward);
player.GetInventory(Inventory.NORMAL).RemoveItem(seek);
player.GetInventory(Inventory.BAZAAR).StartSendUpdate();
player.GetInventory(Inventory.BAZAAR).AddItem(reward);
player.GetInventory(Inventory.BAZAAR).AddItem(seek);
player.GetInventory(Inventory.BAZAAR).DoneSendUpdate();
}
}
/*
public void RemoveFromBazaar(Player player, ushort position)
{
InventoryItem reward = player.GetInventory(Inventory.BAZAAR).GetItemAtSlot(position);
InventoryItem seek = null;
seek = player.GetInventory(Inventory.BAZAAR).
Database.ClearBazaarEntry(player, reward);
player.GetInventory(Inventory.BAZAAR).RemoveItem(reward);
player.GetInventory(Inventory.BAZAAR).RemoveItem(seek);
player.GetInventory(Inventory.NORMAL).StartSendUpdate();
player.GetInventory(Inventory.CURRENCY_CRYSTALS).StartSendUpdate();
if (reward.itemId == 1000001)
player.GetInventory(Inventory.CURRENCY_CRYSTALS).AddItem(reward.itemId, reward.quantity);
else
player.GetInventory(Inventory.NORMAL).AddItem(reward);
if (reward.itemId == 1000001)
player.GetInventory(Inventory.CURRENCY_CRYSTALS).AddItem(seek.itemId, seek.quantity);
else
player.GetInventory(Inventory.NORMAL).AddItem(seek);
player.GetInventory(Inventory.NORMAL).DoneSendUpdate();
player.GetInventory(Inventory.CURRENCY_CRYSTALS).DoneSendUpdate();
}
public void TransactionBazaar(Player owner, Player other, InventoryItem reward, InventoryItem seek, int rewardAmount, int seekAmount)
{
Database.ClearBazaarEntry(owner, reward, seek);
//Remove Bazaar Items from owner
owner.GetInventory(Inventory.BAZAAR).RemoveItem(reward);
owner.GetInventory(Inventory.BAZAAR).RemoveItem(seek);
//Remove Seek item from other
if (seek.GetItemData().IsMoney())
other.GetInventory(Inventory.CURRENCY_CRYSTALS).RemoveItem(seek.itemId, seekAmount);
else
other.GetInventory(Inventory.NORMAL).RemoveItem(seek.itemId, seekAmount);
//Add reward to other, seek to owner
if (reward.GetItemData().IsMoney())
other.GetInventory(Inventory.CURRENCY_CRYSTALS).AddItem(reward.itemId, rewardAmount);
else
other.GetInventory(Inventory.NORMAL).AddItem(reward);
if (seek.GetItemData().IsMoney())
owner.GetInventory(Inventory.CURRENCY_CRYSTALS).AddItem(seek.itemId, seekAmount);
else
other.GetInventory(Inventory.NORMAL).AddItem(seek);
}*/
public bool SendGroupInit(Session session, ulong groupId) public bool SendGroupInit(Session session, ulong groupId)
{ {
if (mContentGroups.ContainsKey(groupId)) if (mContentGroups.ContainsKey(groupId))

View File

@ -110,6 +110,29 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
public INV_ERROR AddItem(uint itemId, int quantity) public INV_ERROR AddItem(uint itemId, int quantity)
{ {
return AddItem(itemId, quantity, 1); return AddItem(itemId, quantity, 1);
}
public INV_ERROR AddItem(InventoryItem itemRef)
{
if (!IsSpaceForAdd(itemRef.itemId, itemRef.quantity, itemRef.quality))
return INV_ERROR.INVENTORY_FULL;
ItemData gItem = Server.GetItemGamedata(itemRef.itemId);
if (gItem == null)
{
Program.Log.Error("Inventory.AddItem: unable to find item %u", itemRef.itemId);
return INV_ERROR.SYSTEM_ERROR;
}
isDirty[endOfListIndex] = true;
list[endOfListIndex++] = itemRef;
DoDatabaseAdd(itemRef);
SendUpdatePackets();
return INV_ERROR.SUCCESS;
} }
public INV_ERROR AddItem(uint itemId, int quantity, byte quality) public INV_ERROR AddItem(uint itemId, int quantity, byte quality)
@ -154,12 +177,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
//New item that spilled over //New item that spilled over
while (quantityCount > 0) while (quantityCount > 0)
{ {
byte[] tags = new byte[4];
byte[] values = new byte[4];
if (gItem.isExclusive)
tags[1] = 3;
InventoryItem.ItemModifier modifiers = null; InventoryItem.ItemModifier modifiers = null;
if (gItem.durability != 0) if (gItem.durability != 0)
{ {
@ -167,7 +184,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
modifiers.durability = (uint)gItem.durability; modifiers.durability = (uint)gItem.durability;
} }
InventoryItem addedItem = Database.CreateItem(itemId, Math.Min(quantityCount, gItem.maxStack), tags, values, quality, modifiers); InventoryItem addedItem = Database.CreateItem(itemId, Math.Min(quantityCount, gItem.maxStack), quality, modifiers);
addedItem.slot = (ushort)endOfListIndex; addedItem.slot = (ushort)endOfListIndex;
isDirty[endOfListIndex] = true; isDirty[endOfListIndex] = true;
list[endOfListIndex++] = addedItem; list[endOfListIndex++] = addedItem;
@ -244,6 +261,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
DoRealign(); DoRealign();
SendUpdatePackets(); SendUpdatePackets();
}
public void RemoveItem(InventoryItem item)
{
RemoveItemByUniqueId(item.uniqueId);
} }
public void RemoveItemByUniqueId(ulong itemDBId) public void RemoveItemByUniqueId(ulong itemDBId)
@ -641,7 +663,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
endOfListIndex = lastNullSlot; endOfListIndex = lastNullSlot;
} }
#endregion #endregion
public int GetCount()
{
return endOfListIndex;
}
} }
} }

View File

@ -141,6 +141,13 @@ namespace FFXIVClassic_Map_Server.Actors
public uint homepoint = 0; public uint homepoint = 0;
public byte homepointInn = 0; public byte homepointInn = 0;
//Nameplate Stuff
public uint currentLSPlate = 0;
public bool isBazaarRetail = false;
public bool isBazaarRepair = false;
public bool isMateriaRequest = false;
public byte repairType = 0;
//Retainer //Retainer
RetainerMeetingRelationGroup retainerMeetingGroup = null; RetainerMeetingRelationGroup retainerMeetingGroup = null;
public Retainer currentSpawnedRetainer = null; public Retainer currentSpawnedRetainer = null;
@ -501,7 +508,17 @@ namespace FFXIVClassic_Map_Server.Actors
propPacketUtil.AddProperty(String.Format("work.guildleveChecked[{0}]", i)); propPacketUtil.AddProperty(String.Format("work.guildleveChecked[{0}]", i));
} }
//NPC Linkshell //Bazaar
if (charaWork.eventSave.repairType != 0)
propPacketUtil.AddProperty("charaWork.eventSave.repairType");
if (charaWork.eventTemp.bazaarRetail)
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRetail");
if (charaWork.eventTemp.bazaarRepair)
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarRepair");
if (charaWork.eventTemp.bazaarMateria)
propPacketUtil.AddProperty("charaWork.eventTemp.bazaarMateria");
//NPC Linkshell
for (int i = 0; i < playerWork.npcLinkshellChatCalling.Length; i++) for (int i = 0; i < playerWork.npcLinkshellChatCalling.Length; i++)
{ {
if (playerWork.npcLinkshellChatCalling[i] != false) if (playerWork.npcLinkshellChatCalling[i] != false)
@ -1046,6 +1063,47 @@ namespace FFXIVClassic_Map_Server.Actors
BroadcastPacket(CreateAppearancePacket(), true); BroadcastPacket(CreateAppearancePacket(), true);
} }
public void SetRepairRequest(byte type)
{
charaWork.eventSave.repairType = type;
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charaWork/bazaar", this);
propPacketUtil.AddProperty("charaWork.eventSave.repairType");
QueuePackets(propPacketUtil.Done());
}
public void CheckBazaarFlags()
{
bool isDealing = false, isRepairing = false, seekingItem = false;
lock (GetInventory(Inventory.BAZAAR))
{
foreach (InventoryItem item in GetInventory(Inventory.BAZAAR).GetRawList())
{
if (item == null)
break;
if (item.GetBazaarMode() == InventoryItem.TYPE_SINGLE || item.GetBazaarMode() == InventoryItem.TYPE_STACK)
isDealing = true;
if (item.GetBazaarMode() == InventoryItem.TYPE_SEEK_REPAIR)
isRepairing = true;
if (item.GetBazaarMode() == InventoryItem.TYPE_SEEK_ITEM)
seekingItem = true;
if (isDealing && isRepairing && seekingItem)
break;
}
}
charaWork.eventTemp.bazaarRetail = isDealing;
charaWork.eventTemp.bazaarRepair = isRepairing;
charaWork.eventTemp.bazaarMateria = GetInventory(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());
}
public Inventory GetInventory(ushort type) public Inventory GetInventory(ushort type)
{ {
if (inventories.ContainsKey(type)) if (inventories.ContainsKey(type))

View File

@ -34,8 +34,12 @@ namespace FFXIVClassic_Map_Server.dataobjects
public byte quality = 1; public byte quality = 1;
private ulong attachedTo = 0;
public ItemModifier modifiers; public ItemModifier modifiers;
public readonly ItemData itemData;
public class ItemModifier public class ItemModifier
{ {
public uint durability = 0; public uint durability = 0;
@ -115,10 +119,11 @@ namespace FFXIVClassic_Map_Server.dataobjects
} }
//Bare Minimum //Bare Minimum
public InventoryItem(uint id, uint itemId) public InventoryItem(uint id, ItemData data)
{ {
this.uniqueId = id; this.uniqueId = id;
this.itemId = itemId; this.itemId = data.catalogID;
this.itemData = data;
this.quantity = 1; this.quantity = 1;
ItemData gItem = Server.GetItemGamedata(itemId); ItemData gItem = Server.GetItemGamedata(itemId);
@ -129,6 +134,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
public InventoryItem(InventoryItem item, ushort equipSlot) public InventoryItem(InventoryItem item, ushort equipSlot)
{ {
this.uniqueId = item.uniqueId; this.uniqueId = item.uniqueId;
this.itemData = item.itemData;
this.itemId = item.itemId; this.itemId = item.itemId;
this.quantity = item.quantity; this.quantity = item.quantity;
this.slot = equipSlot; this.slot = equipSlot;
@ -141,17 +147,12 @@ namespace FFXIVClassic_Map_Server.dataobjects
this.modifiers = item.modifiers; this.modifiers = item.modifiers;
} }
public InventoryItem(uint uniqueId, uint itemId, int quantity, byte[] tags, byte[] tagValues, byte qualityNumber, ItemModifier modifiers = null) public InventoryItem(uint uniqueId, ItemData itemData, int quantity, byte qualityNumber, ItemModifier modifiers = null)
{ {
this.uniqueId = uniqueId; this.uniqueId = uniqueId;
this.itemId = itemId; this.itemId = itemData.catalogID;
this.itemData = itemData;
this.quantity = quantity; this.quantity = quantity;
if (tags != null)
this.tags = tags;
if (tagValues != null)
this.tagValues = tagValues;
this.quality = qualityNumber; this.quality = qualityNumber;
this.modifiers = modifiers; this.modifiers = modifiers;
} }
@ -196,7 +197,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
public void SetExclusive(bool isExclusive) public void SetExclusive(bool isExclusive)
{ {
tags[0] = isExclusive ? TAG_EXCLUSIVE : (byte)0; tags[1] = isExclusive ? TAG_EXCLUSIVE : (byte)0;
} }
public void SetHasAttached(bool isAttached) public void SetHasAttached(bool isAttached)
@ -205,31 +206,55 @@ namespace FFXIVClassic_Map_Server.dataobjects
} }
public void SetDealing(byte mode, uint price) public void SetDealing(byte mode, uint price)
{ {
if (tags[0] == TAG_EXCLUSIVE)
return;
tags[0] = TAG_DEALING; tags[0] = TAG_DEALING;
tagValues[0] = mode; tagValues[0] = mode;
if (dealingMode != DEALINGMODE_REFERENCED) if (mode == TYPE_SINGLE || mode == TYPE_STACK)
{ {
dealingVal = 1; dealingVal = 1;
dealingMode = DEALINGMODE_PRICED; dealingMode = DEALINGMODE_PRICED;
dealingAttached1 = 1; dealingAttached1 = 1;
dealingAttached2 = itemId; dealingAttached2 = 1000001;
dealingAttached3 = price; dealingAttached3 = price;
} }
} }
public void SetAttachedToSlot(ushort package, ushort slot) public void SetDealingAttached(byte mode, ulong attached)
{
tags[0] = TAG_DEALING;
tagValues[0] = mode;
attachedTo = attached;
}
public ulong GetAttached()
{
return attachedTo;
}
public void SetAttachedIndex(ushort package, ushort index)
{ {
dealingVal = 1; dealingVal = 1;
dealingMode = DEALINGMODE_REFERENCED; dealingMode = DEALINGMODE_REFERENCED;
dealingAttached1 = (uint)((ushort)package << 16) | slot; dealingAttached1 = (uint)((package << 16) | index);
dealingAttached2 = 0; dealingAttached2 = 0;
dealingAttached3 = 0; dealingAttached3 = 0;
} }
public ItemData GetItemData()
{
return itemData;
}
public byte GetBazaarMode()
{
for (int i = 0; i < tags.Length; i++)
{
if (tags[i] == 0xC9)
return tagValues[i];
}
return 0;
}
} }
} }