Inventory possessions beta testing

This commit is contained in:
Uleat
2018-08-13 22:32:36 -04:00
parent 54abeba1ce
commit 509a2b30a5
45 changed files with 2842 additions and 1443 deletions
+179 -56
View File
@@ -382,7 +382,7 @@ namespace SoF
for (int index = 0; index < item_count; ++index, ++eq) {
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0);
if (ob.tellp() == last_pos)
Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
Log(Logs::General, Logs::Netcode, "SoF::ENCODE(OP_CharInventory) Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
last_pos = ob.tellp();
}
@@ -445,7 +445,12 @@ namespace SoF
FINISH_ENCODE();
}
ENCODE(OP_DeleteCharge) { ENCODE_FORWARD(OP_MoveItem); }
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "SoF::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
ENCODE(OP_DeleteItem)
{
@@ -861,7 +866,7 @@ namespace SoF
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0);
if (ob.tellp() == last_pos) {
Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
Log(Logs::General, Logs::Netcode, "SoF::ENCODE(OP_ItemPacket) Serialization failed on item slot %d.", int_struct->slot_id);
delete in;
return;
}
@@ -922,6 +927,8 @@ namespace SoF
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoF::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
eq->slot_id = ServerToSoFCorpseSlot(emu->slot_id);
@@ -965,6 +972,8 @@ namespace SoF
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoF::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToSoFSlot(emu->from_slot);
eq->to_slot = ServerToSoFSlot(emu->to_slot);
OUT(number_in_stack);
@@ -1190,7 +1199,7 @@ namespace SoF
// OUT(unknown06160[4]);
// Copy bandoliers where server and client indexes converge
// Copy bandoliers where server and client indices converge
for (r = 0; r < EQEmu::profile::BANDOLIERS_SIZE && r < profile::BANDOLIERS_SIZE; ++r) {
OUT_str(bandoliers[r].Name);
for (uint32 k = 0; k < profile::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true
@@ -1199,7 +1208,7 @@ namespace SoF
OUT_str(bandoliers[r].Items[k].Name);
}
}
// Nullify bandoliers where server and client indexes diverge, with a client bias
// Nullify bandoliers where server and client indices diverge, with a client bias
for (r = EQEmu::profile::BANDOLIERS_SIZE; r < profile::BANDOLIERS_SIZE; ++r) {
eq->bandoliers[r].Name[0] = '\0';
for (uint32 k = 0; k < profile::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true
@@ -1211,13 +1220,13 @@ namespace SoF
// OUT(unknown07444[5120]);
// Copy potion belt where server and client indexes converge
// Copy potion belt where server and client indices converge
for (r = 0; r < EQEmu::profile::POTION_BELT_SIZE && r < profile::POTION_BELT_SIZE; ++r) {
OUT(potionbelt.Items[r].ID);
OUT(potionbelt.Items[r].Icon);
OUT_str(potionbelt.Items[r].Name);
}
// Nullify potion belt where server and client indexes diverge, with a client bias
// Nullify potion belt where server and client indices diverge, with a client bias
for (r = EQEmu::profile::POTION_BELT_SIZE; r < profile::POTION_BELT_SIZE; ++r) {
eq->potionbelt.Items[r].ID = 0;
eq->potionbelt.Items[r].Icon = 0;
@@ -2548,6 +2557,8 @@ namespace SoF
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoF::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
emu->slot_id = SoFToServerCorpseSlot(eq->slot_id);
@@ -2561,7 +2572,7 @@ namespace SoF
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::General, Logs::Netcode, "[SoF] Moved item from %u to %u", eq->from_slot, eq->to_slot);
Log(Logs::Moderate, Logs::Netcode, "SoF::DECODE(OP_MoveItem)");
emu->from_slot = SoFToServerSlot(eq->from_slot);
emu->to_slot = SoFToServerSlot(eq->to_slot);
@@ -2867,7 +2878,7 @@ namespace SoF
ibs.nodrop = item->NoDrop;
ibs.attune = item->Attuneable;
ibs.size = item->Size;
ibs.slots = SwapBits21And22(item->Slots);
ibs.slots = item->Slots;
ibs.price = item->Price;
ibs.icon = item->Icon;
ibs.unknown1 = 1;
@@ -3129,81 +3140,193 @@ namespace SoF
ob.write((const char*)&subitem_count, sizeof(uint32));
for (uint32 index = EQEmu::invbag::SLOT_BEGIN; index <= EQEmu::invbag::SLOT_END; ++index) {
EQEmu::ItemInstance* sub = inst->GetItem(index);
if (!sub)
continue;
// moved outside of loop since it is not modified within that scope
int16 SubSlotNumber = EQEmu::invbag::SLOT_INVALID;
int SubSlotNumber = INVALID_INDEX;
if (slot_id_in >= EQEmu::invslot::GENERAL_BEGIN && slot_id_in <= EQEmu::invslot::GENERAL_END)
SubSlotNumber = (((slot_id_in + 3) * EQEmu::invbag::SLOT_COUNT) + index + 1);
else if (slot_id_in >= EQEmu::invslot::BANK_BEGIN && slot_id_in <= EQEmu::invslot::BANK_END)
SubSlotNumber = (((slot_id_in - EQEmu::invslot::BANK_BEGIN) * EQEmu::invbag::SLOT_COUNT) + EQEmu::invbag::BANK_BAGS_BEGIN + index);
else if (slot_id_in >= EQEmu::invslot::SHARED_BANK_BEGIN && slot_id_in <= EQEmu::invslot::SHARED_BANK_END)
SubSlotNumber = (((slot_id_in - EQEmu::invslot::SHARED_BANK_BEGIN) * EQEmu::invbag::SLOT_COUNT) + EQEmu::invbag::SHARED_BANK_BAGS_BEGIN + index);
else
SubSlotNumber = slot_id_in;
if (slot_id_in <= EQEmu::invslot::slotGeneral8 && slot_id_in >= EQEmu::invslot::GENERAL_BEGIN)
SubSlotNumber = EQEmu::invbag::GENERAL_BAGS_BEGIN + ((slot_id_in - EQEmu::invslot::GENERAL_BEGIN) * EQEmu::invbag::SLOT_COUNT);
else if (slot_id_in <= EQEmu::invslot::GENERAL_END && slot_id_in >= EQEmu::invslot::slotGeneral9)
SubSlotNumber = EQEmu::invbag::SLOT_INVALID;
else if (slot_id_in == EQEmu::invslot::slotCursor)
SubSlotNumber = EQEmu::invbag::CURSOR_BAG_BEGIN;
else if (slot_id_in <= EQEmu::invslot::BANK_END && slot_id_in >= EQEmu::invslot::BANK_BEGIN)
SubSlotNumber = EQEmu::invbag::BANK_BAGS_BEGIN + ((slot_id_in - EQEmu::invslot::BANK_BEGIN) * EQEmu::invbag::SLOT_COUNT);
else if (slot_id_in <= EQEmu::invslot::SHARED_BANK_END && slot_id_in >= EQEmu::invslot::SHARED_BANK_BEGIN)
SubSlotNumber = EQEmu::invbag::SHARED_BANK_BAGS_BEGIN + ((slot_id_in - EQEmu::invslot::SHARED_BANK_BEGIN) * EQEmu::invbag::SLOT_COUNT);
else
SubSlotNumber = slot_id_in; // not sure if this is the best way to handle this..leaving for now
ob.write((const char*)&index, sizeof(uint32));
if (SubSlotNumber != EQEmu::invbag::SLOT_INVALID) {
for (uint32 index = EQEmu::invbag::SLOT_BEGIN; index <= EQEmu::invbag::SLOT_END; ++index) {
EQEmu::ItemInstance* sub = inst->GetItem(index);
if (!sub)
continue;
SerializeItem(ob, sub, SubSlotNumber, (depth + 1));
++subitem_count;
ob.write((const char*)&index, sizeof(uint32));
SerializeItem(ob, sub, SubSlotNumber, (depth + 1));
++subitem_count;
}
if (subitem_count)
ob.overwrite(count_pos, (const char*)&subitem_count, sizeof(uint32));
}
if (subitem_count)
ob.overwrite(count_pos, (const char*)&subitem_count, sizeof(uint32));
}
static inline uint32 ServerToSoFSlot(uint32 serverSlot)
{
uint32 SoFSlot = 0;
uint32 SoFSlot = invslot::SLOT_INVALID;
if (serverSlot >= EQEmu::invslot::slotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
SoFSlot = serverSlot + 1;
else if (serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::invbag::CURSOR_BAG_END)
SoFSlot = serverSlot + 11;
else if (serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN && serverSlot <= EQEmu::invbag::BANK_BAGS_END)
SoFSlot = serverSlot + 1;
else if (serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN && serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END)
SoFSlot = serverSlot + 1;
else if (serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE)
SoFSlot = invslot::slotPowerSource;
else
if (serverSlot <= EQEmu::invslot::slotGeneral8) {
SoFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::CORPSE_END && serverSlot >= EQEmu::invslot::slotCursor) {
SoFSlot = serverSlot - 2;
}
else if (serverSlot <= EQEmu::invbag::GENERAL_BAGS_8_END && serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
SoFSlot = serverSlot + 11;
}
else if (serverSlot <= EQEmu::invbag::CURSOR_BAG_END && serverSlot >= EQEmu::invbag::CURSOR_BAG_BEGIN) {
SoFSlot = serverSlot - 9;
}
else if (serverSlot <= EQEmu::invslot::TRIBUTE_END && serverSlot >= EQEmu::invslot::TRIBUTE_BEGIN) {
SoFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::GUILD_TRIBUTE_END && serverSlot >= EQEmu::invslot::GUILD_TRIBUTE_BEGIN) {
SoFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::BANK_END && serverSlot >= EQEmu::invslot::BANK_BEGIN) {
SoFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::BANK_BAGS_END && serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN) {
SoFSlot = serverSlot + 1;
}
else if (serverSlot <= EQEmu::invslot::SHARED_BANK_END && serverSlot >= EQEmu::invslot::SHARED_BANK_BEGIN) {
SoFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END && serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN) {
SoFSlot = serverSlot + 1;
}
else if (serverSlot <= EQEmu::invslot::TRADE_END && serverSlot >= EQEmu::invslot::TRADE_BEGIN) {
SoFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::TRADE_BAGS_END && serverSlot >= EQEmu::invbag::TRADE_BAGS_BEGIN) {
SoFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::WORLD_END && serverSlot >= EQEmu::invslot::WORLD_BEGIN) {
SoFSlot = serverSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Slot %i to SoF Slot %i", serverSlot, SoFSlot);
return SoFSlot;
}
static inline uint32 ServerToSoFCorpseSlot(uint32 serverCorpseSlot)
{
//uint32 SoFCorpse;
return (serverCorpseSlot + 1);
uint32 SoFSlot = invslot::SLOT_INVALID;
if (serverCorpseSlot <= EQEmu::invslot::slotGeneral8 && serverCorpseSlot >= EQEmu::invslot::slotGeneral1) {
SoFSlot = serverCorpseSlot;
}
else if (serverCorpseSlot <= EQEmu::invslot::CORPSE_END && serverCorpseSlot >= EQEmu::invslot::slotCursor) {
SoFSlot = serverCorpseSlot - 2;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to SoF Corpse Slot %i", serverCorpseSlot, SoFSlot);
return SoFSlot;
}
static inline uint32 SoFToServerSlot(uint32 sofSlot)
{
uint32 ServerSlot = 0;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (sofSlot >= invslot::slotAmmo && sofSlot <= invslot::CORPSE_END) // Cursor/Ammo/Power Source and Normal Inventory Slots
ServerSlot = sofSlot - 1;
else if (sofSlot >= invbag::GENERAL_BAGS_BEGIN && sofSlot <= invbag::CURSOR_BAG_END)
ServerSlot = sofSlot - 11;
else if (sofSlot >= invbag::BANK_BAGS_BEGIN && sofSlot <= invbag::BANK_BAGS_END)
ServerSlot = sofSlot - 1;
else if (sofSlot >= invbag::SHARED_BANK_BAGS_BEGIN && sofSlot <= invbag::SHARED_BANK_BAGS_END)
ServerSlot = sofSlot - 1;
else if (sofSlot == invslot::slotPowerSource)
ServerSlot = EQEmu::invslot::SLOT_POWER_SOURCE;
else
if (sofSlot <= invslot::slotGeneral8) {
ServerSlot = sofSlot;
}
else if (sofSlot <= invslot::CORPSE_END && sofSlot >= invslot::slotCursor) {
ServerSlot = sofSlot + 2;
}
else if (sofSlot <= invbag::GENERAL_BAGS_END && sofSlot >= invbag::GENERAL_BAGS_BEGIN) {
ServerSlot = sofSlot - 11;
}
else if (sofSlot <= invbag::CURSOR_BAG_END && sofSlot >= invbag::CURSOR_BAG_BEGIN) {
ServerSlot = sofSlot + 9;
}
else if (sofSlot <= invslot::TRIBUTE_END && sofSlot >= invslot::TRIBUTE_BEGIN) {
ServerSlot = sofSlot;
}
else if (sofSlot <= invslot::GUILD_TRIBUTE_END && sofSlot >= invslot::GUILD_TRIBUTE_BEGIN) {
ServerSlot = sofSlot;
}
else if (sofSlot <= invslot::BANK_END && sofSlot >= invslot::BANK_BEGIN) {
ServerSlot = sofSlot;
}
else if (sofSlot <= invbag::BANK_BAGS_END && sofSlot >= invbag::BANK_BAGS_BEGIN) {
ServerSlot = sofSlot - 1;
}
else if (sofSlot <= invslot::SHARED_BANK_END && sofSlot >= invslot::SHARED_BANK_BEGIN) {
ServerSlot = sofSlot;
}
else if (sofSlot <= invbag::SHARED_BANK_BAGS_END && sofSlot >= invbag::SHARED_BANK_BAGS_BEGIN) {
ServerSlot = sofSlot - 1;
}
else if (sofSlot <= invslot::TRADE_END && sofSlot >= invslot::TRADE_BEGIN) {
ServerSlot = sofSlot;
}
else if (sofSlot <= invbag::TRADE_BAGS_END && sofSlot >= invbag::TRADE_BAGS_BEGIN) {
ServerSlot = sofSlot;
}
else if (sofSlot <= invslot::WORLD_END && sofSlot >= invslot::WORLD_BEGIN) {
ServerSlot = sofSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert SoF Slot %i to Server Slot %i", sofSlot, ServerSlot);
return ServerSlot;
}
static inline uint32 SoFToServerCorpseSlot(uint32 sofCorpseSlot)
{
//uint32 ServerCorpse;
return (sofCorpseSlot - 1);
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (sofCorpseSlot <= invslot::slotGeneral8 && sofCorpseSlot >= invslot::slotGeneral1) {
ServerSlot = sofCorpseSlot;
}
else if (sofCorpseSlot <= invslot::CORPSE_END && sofCorpseSlot >= invslot::slotCursor) {
ServerSlot = sofCorpseSlot + 2;
}
Log(Logs::Detail, Logs::Netcode, "Convert SoF Corpse Slot %i to Server Corpse Slot %i", sofCorpseSlot, ServerSlot);
return ServerSlot;
}
static inline void ServerToSoFSayLink(std::string& sofSayLink, const std::string& serverSayLink)