Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinglykrab committed Nov 22, 2024
1 parent 95687b5 commit cd158aa
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 36 deletions.
8 changes: 4 additions & 4 deletions common/inventory_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,13 +1095,13 @@ int16 EQ::InventoryProfile::CalcSlotId(int16 bagslot_id, uint8 bagidx)
if (bagslot_id == invslot::slotCursor) {
slot_id = invbag::CURSOR_BAG_BEGIN + bagidx;
} else if (EQ::ValueWithin(bagslot_id, invslot::GENERAL_BEGIN, invslot::GENERAL_END)) {
slot_id = invbag::GENERAL_BAGS_BEGIN + (bagslot_id - invbag::GENERAL_BAGS_BEGIN) * invbag::SLOT_COUNT + bagidx;
slot_id = invbag::GENERAL_BAGS_BEGIN + (bagslot_id - invslot::GENERAL_BEGIN) * invbag::SLOT_COUNT + bagidx;
} else if (EQ::ValueWithin(bagslot_id, invslot::BANK_BEGIN, invslot::BANK_END)) {
slot_id = invbag::BANK_BAGS_BEGIN + (bagslot_id - invbag::BANK_BAGS_BEGIN) * invbag::SLOT_COUNT + bagidx;
slot_id = invbag::BANK_BAGS_BEGIN + (bagslot_id - invslot::BANK_BEGIN) * invbag::SLOT_COUNT + bagidx;
} else if (EQ::ValueWithin(bagslot_id, invslot::SHARED_BANK_BEGIN, invslot::SHARED_BANK_END)) {
slot_id = invbag::SHARED_BANK_BAGS_BEGIN + (bagslot_id - invbag::SHARED_BANK_BAGS_BEGIN) * invbag::SLOT_COUNT + bagidx;
slot_id = invbag::SHARED_BANK_BAGS_BEGIN + (bagslot_id - invslot::SHARED_BANK_BEGIN) * invbag::SLOT_COUNT + bagidx;
} else if (EQ::ValueWithin(bagslot_id, invslot::TRADE_BEGIN, invslot::TRADE_END)) {
slot_id = invbag::TRADE_BAGS_BEGIN + (bagslot_id - invbag::TRADE_BAGS_BEGIN) * invbag::SLOT_COUNT + bagidx;
slot_id = invbag::TRADE_BAGS_BEGIN + (bagslot_id - invslot::TRADE_BEGIN) * invbag::SLOT_COUNT + bagidx;
}

return slot_id;
Expand Down
2 changes: 1 addition & 1 deletion common/shareddb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQ::InventoryProfile* inv)
}

int16 put_slot_id;
if (EQ::ValueWithin(slot_id, EQ::invbag::CURSOR_BAG_BEGIN, EQ::invbag::CURSOR_BAG_END) || slot_id == EQ::invslot::slotCursor) {
if (EQ::ValueWithin(slot_id, EQ::invbag::CURSOR_BAG_BEGIN, EQ::invbag::CURSOR_BAG_END)) {
put_slot_id = inv->PushCursor(*inst);
} else {
put_slot_id = inv->PutItem(slot_id, *inst);
Expand Down
77 changes: 50 additions & 27 deletions zone/client_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,47 +779,70 @@ void Client::BulkSendInventoryItems()

inst->Serialize(ob, slot_id);

if (ob.tellp() == last_pos)
if (ob.tellp() == last_pos) {
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
}

last_pos = ob.tellp();
}

// General items
for (int16 slot_id = EQ::invslot::GENERAL_BEGIN; slot_id <= EQ::invslot::GENERAL_END; slot_id++) {
const EQ::ItemInstance* inst = m_inv[slot_id];
if (!inst) {
continue;
}

inst->Serialize(ob, slot_id);

if (ob.tellp() == last_pos) {
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
}

last_pos = ob.tellp();
}

if (!RuleB(Inventory, LazyLoadBank)) {
// Bank items
for (int16 slot_id = EQ::invslot::BANK_BEGIN; slot_id <= EQ::invslot::BANK_END; slot_id++) {
const EQ::ItemInstance* inst = m_inv[slot_id];
if (!inst)
continue;
// Bank items
for (int16 slot_id = EQ::invslot::BANK_BEGIN; slot_id <= EQ::invslot::BANK_END; slot_id++) {
const EQ::ItemInstance* inst = m_inv[slot_id];
if (!inst) {
continue;
}

inst->Serialize(ob, slot_id);
inst->Serialize(ob, slot_id);

if (ob.tellp() == last_pos)
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
if (ob.tellp() == last_pos) {
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
}

last_pos = ob.tellp();
}
last_pos = ob.tellp();
}

// SharedBank items
for (int16 slot_id = EQ::invslot::SHARED_BANK_BEGIN; slot_id <= EQ::invslot::SHARED_BANK_END; slot_id++) {
const EQ::ItemInstance* inst = m_inv[slot_id];
if (!inst)
continue;
// SharedBank items
for (int16 slot_id = EQ::invslot::SHARED_BANK_BEGIN; slot_id <= EQ::invslot::SHARED_BANK_END; slot_id++) {
const EQ::ItemInstance* inst = m_inv[slot_id];
if (!inst) {
continue;
}

inst->Serialize(ob, slot_id);
inst->Serialize(ob, slot_id);

if (ob.tellp() == last_pos)
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
if (ob.tellp() == last_pos) {
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
}

last_pos = ob.tellp();
}
}

auto outapp = new EQApplicationPacket(OP_CharInventory);

last_pos = ob.tellp();
}
}
outapp->size = ob.size();
outapp->pBuffer = ob.detach();

auto outapp = new EQApplicationPacket(OP_CharInventory);
outapp->size = ob.size();
outapp->pBuffer = ob.detach();
QueuePacket(outapp);
safe_delete(outapp);
QueuePacket(outapp);
safe_delete(outapp);
}

void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
Expand Down
8 changes: 4 additions & 4 deletions zone/gm_commands/show/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void ShowInventory(Client *c, const Seperator *sep)
Chat::White,
fmt::format(
"Slot {} | {} ({}){}",
(EQ::invbag::CURSOR_BAG_BEGIN + limboIndex),
(14000 + limboIndex),
item_data->ID,
linker.GenerateLink(),
(
Expand Down Expand Up @@ -339,7 +339,7 @@ void ShowInventory(Client *c, const Seperator *sep)
Chat::White,
fmt::format(
"Slot {} (Augment Slot {}) | {} ({}){}",
(EQ::invbag::CURSOR_BAG_BEGIN + limboIndex),
(14000 + limboIndex),
augment_index,
linker.GenerateLink(),
item_data->ID,
Expand Down Expand Up @@ -375,7 +375,7 @@ void ShowInventory(Client *c, const Seperator *sep)
Chat::White,
fmt::format(
"Slot {} Bag Slot {} | {} ({}){}",
(EQ::invbag::CURSOR_BAG_BEGIN + limboIndex),
(14000 + limboIndex),
sub_index,
linker.GenerateLink(),
item_data->ID,
Expand Down Expand Up @@ -407,7 +407,7 @@ void ShowInventory(Client *c, const Seperator *sep)
Chat::White,
fmt::format(
"Slot {} Bag Slot {} (Augment Slot {}) | {} ({}){}",
(EQ::invbag::CURSOR_BAG_BEGIN + limboIndex),
(14000 + limboIndex),
sub_index,
augment_index,
linker.GenerateLink(),
Expand Down

0 comments on commit cd158aa

Please sign in to comment.