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

View File

@ -1,5 +1,26 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 08/13/2018 ==
Uleat: Activation of RoF+ clients' two additional general slots and integration of SoF+ clients' PowerSource slot
- Inventory 'Possessions' main slots are now contiguous and implemented to RoF2 standards
-- 'slotGeneral9'(31) and 'slotGeneral10'(32) are now active
-- Possessions slot enumerations are now defined as between 'slotCharm'(0) and 'slotCursor'(33)
-- 'slotPowerSource'(21) is no longer a special case slot(9999)
- Special code has been added to exclude 'slotPowerSource,' 'slotGeneral9' and 'slotGeneral10' from server
actions in clients that do not support them.
- The lua api has been updated to use the new slot enumeration as well as having some slot range definitions added
- The perl api now has a look-up function to provide token-to-value translations .. definitions are similar to lua
- In both lua and perl, it is HIGHLY recommended that any custom scripts using hard-coded inventory slot values be
updated to use the constants/lookup methods as any old values are no longer guaranteed to be accurate
- Database will have existing inventory slot values modified to the new standard and table `items` entries will
also be updated to the 'correct' equipable slot bitmask
- Script (quest) updates are required with this change
Note: The proper way to reference inventory slots is to use either instrinsic lookups (c/c++ & perl) or to use valid
const ref declarations (c/c++ & lua). Any other method is not guaranteed to be accurate and may result in item loss
and/or unexpected/undefined behavior.
== 07/10/2018 ==
Akkadius: Adjusted DataBuckets to use other acceptable time formats
Example: quest::set_data('key', 'value', '1d');

View File

@ -78,28 +78,26 @@ namespace EQEmu
} // namespace invtype
namespace invslot {
using namespace Titanium::invslot::enum_;
const int16 SLOT_POWER_SOURCE = 9999;
using namespace RoF2::invslot::enum_;
using RoF2::invslot::SLOT_INVALID;
using RoF2::invslot::SLOT_BEGIN;
using Titanium::invslot::POSSESSIONS_BEGIN;
using Titanium::invslot::POSSESSIONS_END;
using SoF::invslot::POSSESSIONS_COUNT;
using RoF2::invslot::POSSESSIONS_BEGIN;
using RoF2::invslot::POSSESSIONS_END;
using RoF2::invslot::POSSESSIONS_COUNT;
using Titanium::invslot::EQUIPMENT_BEGIN;
using Titanium::invslot::EQUIPMENT_END;
using Titanium::invslot::EQUIPMENT_COUNT;
using RoF2::invslot::EQUIPMENT_BEGIN;
using RoF2::invslot::EQUIPMENT_END;
using RoF2::invslot::EQUIPMENT_COUNT;
using Titanium::invslot::GENERAL_BEGIN;
using Titanium::invslot::GENERAL_END;
using Titanium::invslot::GENERAL_COUNT;
using RoF2::invslot::GENERAL_BEGIN;
using RoF2::invslot::GENERAL_END;
using RoF2::invslot::GENERAL_COUNT;
using Titanium::invslot::BONUS_BEGIN;
using Titanium::invslot::BONUS_STAT_END;
using Titanium::invslot::BONUS_SKILL_END;
using RoF2::invslot::BONUS_BEGIN;
using RoF2::invslot::BONUS_STAT_END;
using RoF2::invslot::BONUS_SKILL_END;
using Titanium::invslot::BANK_BEGIN;
using SoF::invslot::BANK_END;
@ -145,7 +143,7 @@ namespace EQEmu
const int16 GENERAL_BAGS_8_COUNT = 8 * SLOT_COUNT;
const int16 GENERAL_BAGS_8_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_8_COUNT) - 1;
const int16 CURSOR_BAG_BEGIN = 331;
const int16 CURSOR_BAG_BEGIN = 351;
const int16 CURSOR_BAG_COUNT = SLOT_COUNT;
const int16 CURSOR_BAG_END = (CURSOR_BAG_BEGIN + CURSOR_BAG_COUNT) - 1;

View File

@ -177,7 +177,7 @@ EQEmu::ItemInstance* EQEmu::InventoryProfile::GetItem(int16 slot_id) const
result = _GetItem(m_inv, slot_id);
}
else if ((slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) ||
(slot_id >= invslot::TRIBUTE_BEGIN && slot_id <= invslot::TRIBUTE_END) || (slot_id == invslot::SLOT_POWER_SOURCE)) {
(slot_id >= invslot::TRIBUTE_BEGIN && slot_id <= invslot::TRIBUTE_END)) {
// Equippable slots (on body)
result = _GetItem(m_worn, slot_id);
}
@ -231,6 +231,25 @@ EQEmu::ItemInstance* EQEmu::InventoryProfile::GetItem(int16 slot_id, uint8 bagid
// Put an item snto specified slot
int16 EQEmu::InventoryProfile::PutItem(int16 slot_id, const ItemInstance& inst)
{
if (slot_id <= EQEmu::invslot::POSSESSIONS_END && slot_id >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << slot_id) & m_lookup->PossessionsBitmask) == 0)
return EQEmu::invslot::SLOT_INVALID;
}
else if (slot_id <= EQEmu::invbag::GENERAL_BAGS_END && slot_id >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_id - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << temp_slot) & m_lookup->PossessionsBitmask) == 0)
return EQEmu::invslot::SLOT_INVALID;
}
else if (slot_id <= EQEmu::invslot::BANK_END && slot_id >= EQEmu::invslot::BANK_BEGIN) {
if ((slot_id - EQEmu::invslot::BANK_BEGIN) >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank])
return EQEmu::invslot::SLOT_INVALID;
}
else if (slot_id <= EQEmu::invbag::BANK_BAGS_END && slot_id >= EQEmu::invbag::BANK_BAGS_BEGIN) {
auto temp_slot = (slot_id - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
if (temp_slot >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank])
return EQEmu::invslot::SLOT_INVALID;
}
// Clean up item already in slot (if exists)
DeleteItem(slot_id);
@ -260,6 +279,60 @@ bool EQEmu::InventoryProfile::SwapItem(int16 slot_a, int16 slot_b, SwapItemFailS
{
fail_state = swapInvalid;
if (slot_a <= EQEmu::invslot::POSSESSIONS_END && slot_a >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << slot_a) & m_lookup->PossessionsBitmask) == 0) {
fail_state = swapNotAllowed;
return false;
}
}
else if (slot_a <= EQEmu::invbag::GENERAL_BAGS_END && slot_a >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_a - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << temp_slot) & m_lookup->PossessionsBitmask) == 0) {
fail_state = swapNotAllowed;
return false;
}
}
else if (slot_a <= EQEmu::invslot::BANK_END && slot_a >= EQEmu::invslot::BANK_BEGIN) {
if ((slot_a - EQEmu::invslot::BANK_BEGIN) >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank]) {
fail_state = swapNotAllowed;
return false;
}
}
else if (slot_a <= EQEmu::invbag::BANK_BAGS_END && slot_a >= EQEmu::invbag::BANK_BAGS_BEGIN) {
auto temp_slot = (slot_a - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
if (temp_slot >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank]) {
fail_state = swapNotAllowed;
return false;
}
}
if (slot_b <= EQEmu::invslot::POSSESSIONS_END && slot_b >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << slot_b) & m_lookup->PossessionsBitmask) == 0) {
fail_state = swapNotAllowed;
return false;
}
}
else if (slot_b <= EQEmu::invbag::GENERAL_BAGS_END && slot_b >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_b - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << temp_slot) & m_lookup->PossessionsBitmask) == 0) {
fail_state = swapNotAllowed;
return false;
}
}
else if (slot_b <= EQEmu::invslot::BANK_END && slot_b >= EQEmu::invslot::BANK_BEGIN) {
if ((slot_b - EQEmu::invslot::BANK_BEGIN) >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank]) {
fail_state = swapNotAllowed;
return false;
}
}
else if (slot_b <= EQEmu::invbag::BANK_BAGS_END && slot_b >= EQEmu::invbag::BANK_BAGS_BEGIN) {
auto temp_slot = (slot_b - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
if (temp_slot >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank]) {
fail_state = swapNotAllowed;
return false;
}
}
// Temp holding areas for a and b
ItemInstance* inst_a = GetItem(slot_a);
ItemInstance* inst_b = GetItem(slot_b);
@ -269,7 +342,7 @@ bool EQEmu::InventoryProfile::SwapItem(int16 slot_a, int16 slot_b, SwapItemFailS
fail_state = swapNotAllowed;
return false;
}
if ((slot_b >= invslot::EQUIPMENT_BEGIN && slot_b <= invslot::EQUIPMENT_END) || slot_b == invslot::SLOT_POWER_SOURCE) {
if ((slot_b >= invslot::EQUIPMENT_BEGIN && slot_b <= invslot::EQUIPMENT_END)) {
auto item_a = inst_a->GetItem();
if (!item_a) {
fail_state = swapNullData;
@ -295,7 +368,7 @@ bool EQEmu::InventoryProfile::SwapItem(int16 slot_a, int16 slot_b, SwapItemFailS
fail_state = swapNotAllowed;
return false;
}
if ((slot_a >= invslot::EQUIPMENT_BEGIN && slot_a <= invslot::EQUIPMENT_END) || slot_a == invslot::SLOT_POWER_SOURCE) {
if ((slot_a >= invslot::EQUIPMENT_BEGIN && slot_a <= invslot::EQUIPMENT_END)) {
auto item_b = inst_b->GetItem();
if (!item_b) {
fail_state = swapNullData;
@ -379,11 +452,11 @@ EQEmu::ItemInstance* EQEmu::InventoryProfile::PopItem(int16 slot_id)
if (slot_id == invslot::slotCursor) {
p = m_cursor.pop();
}
else if ((slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) || (slot_id == invslot::SLOT_POWER_SOURCE)) {
else if (slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) {
p = m_worn[slot_id];
m_worn.erase(slot_id);
}
else if ((slot_id >= invslot::GENERAL_BEGIN && slot_id <= invslot::GENERAL_END)) {
else if (slot_id >= invslot::GENERAL_BEGIN && slot_id <= invslot::GENERAL_END) {
p = m_inv[slot_id];
m_inv.erase(slot_id);
}
@ -420,6 +493,8 @@ bool EQEmu::InventoryProfile::HasSpaceForItem(const ItemData *ItemToTry, int16 Q
if (ItemToTry->Stackable) {
for (int16 i = invslot::GENERAL_BEGIN; i <= invslot::GENERAL_END; i++) {
if ((((uint64)1 << i) & m_lookup->PossessionsBitmask) == 0)
continue;
ItemInstance* InvItem = GetItem(i);
@ -457,6 +532,8 @@ bool EQEmu::InventoryProfile::HasSpaceForItem(const ItemData *ItemToTry, int16 Q
}
for (int16 i = invslot::GENERAL_BEGIN; i <= invslot::GENERAL_END; i++) {
if ((((uint64)1 << i) & m_lookup->PossessionsBitmask) == 0)
continue;
ItemInstance* InvItem = GetItem(i);
@ -483,7 +560,7 @@ bool EQEmu::InventoryProfile::HasSpaceForItem(const ItemData *ItemToTry, int16 Q
uint8 BagSize = InvItem->GetItem()->BagSlots;
for (uint8 BagSlot = invbag::SLOT_BEGIN; BagSlot<BagSize; BagSlot++) {
for (uint8 BagSlot = invbag::SLOT_BEGIN; BagSlot < BagSize; BagSlot++) {
InvItem = GetItem(BaseSlotID + BagSlot);
@ -663,6 +740,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlot(bool for_bag, bool try_cursor, uint8
{
// Check basic inventory
for (int16 i = invslot::GENERAL_BEGIN; i <= invslot::GENERAL_END; i++) {
if ((((uint64)1 << i) & m_lookup->PossessionsBitmask) == 0)
continue;
if (!GetItem(i))
// Found available slot in personal inventory
return i;
@ -670,6 +750,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlot(bool for_bag, bool try_cursor, uint8
if (!for_bag) {
for (int16 i = invslot::GENERAL_BEGIN; i <= invslot::GENERAL_END; i++) {
if ((((uint64)1 << i) & m_lookup->PossessionsBitmask) == 0)
continue;
const ItemInstance* inst = GetItem(i);
if (inst && inst->IsClassBag() && inst->GetItem()->BagSize >= min_size)
{
@ -720,6 +803,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlotForTradeItem(const ItemInstance* inst
// step 1: find room for bags (caller should really ask for slots for bags first to avoid sending them to cursor..and bag item loss)
if (inst->IsClassBag()) {
for (int16 free_slot = general_start; free_slot <= invslot::GENERAL_END; ++free_slot) {
if ((((uint64)1 << free_slot) & m_lookup->PossessionsBitmask) == 0)
continue;
if (!m_inv[free_slot])
return free_slot;
}
@ -730,6 +816,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlotForTradeItem(const ItemInstance* inst
// step 2: find partial room for stackables
if (inst->IsStackable()) {
for (int16 free_slot = general_start; free_slot <= invslot::GENERAL_END; ++free_slot) {
if ((((uint64)1 << free_slot) & m_lookup->PossessionsBitmask) == 0)
continue;
const ItemInstance* main_inst = m_inv[free_slot];
if (!main_inst)
@ -740,6 +829,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlotForTradeItem(const ItemInstance* inst
}
for (int16 free_slot = general_start; free_slot <= invslot::GENERAL_END; ++free_slot) {
if ((((uint64)1 << free_slot) & m_lookup->PossessionsBitmask) == 0)
continue;
const ItemInstance* main_inst = m_inv[free_slot];
if (!main_inst)
@ -763,6 +855,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlotForTradeItem(const ItemInstance* inst
// step 3a: find room for container-specific items (ItemClassArrow)
if (inst->GetItem()->ItemType == item::ItemTypeArrow) {
for (int16 free_slot = general_start; free_slot <= invslot::GENERAL_END; ++free_slot) {
if ((((uint64)1 << free_slot) & m_lookup->PossessionsBitmask) == 0)
continue;
const ItemInstance* main_inst = m_inv[free_slot];
if (!main_inst || (main_inst->GetItem()->BagType != item::BagTypeQuiver) || !main_inst->IsClassBag())
@ -779,6 +874,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlotForTradeItem(const ItemInstance* inst
// step 3b: find room for container-specific items (ItemClassSmallThrowing)
if (inst->GetItem()->ItemType == item::ItemTypeSmallThrowing) {
for (int16 free_slot = general_start; free_slot <= invslot::GENERAL_END; ++free_slot) {
if ((((uint64)1 << free_slot) & m_lookup->PossessionsBitmask) == 0)
continue;
const ItemInstance* main_inst = m_inv[free_slot];
if (!main_inst || (main_inst->GetItem()->BagType != item::BagTypeBandolier) || !main_inst->IsClassBag())
@ -794,6 +892,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlotForTradeItem(const ItemInstance* inst
// step 4: just find an empty slot
for (int16 free_slot = general_start; free_slot <= invslot::GENERAL_END; ++free_slot) {
if ((((uint64)1 << free_slot) & m_lookup->PossessionsBitmask) == 0)
continue;
const ItemInstance* main_inst = m_inv[free_slot];
if (!main_inst)
@ -801,6 +902,9 @@ int16 EQEmu::InventoryProfile::FindFreeSlotForTradeItem(const ItemInstance* inst
}
for (int16 free_slot = general_start; free_slot <= invslot::GENERAL_END; ++free_slot) {
if ((((uint64)1 << free_slot) & m_lookup->PossessionsBitmask) == 0)
continue;
const ItemInstance* main_inst = m_inv[free_slot];
if (main_inst && main_inst->IsClassBag()) {
@ -977,12 +1081,13 @@ bool EQEmu::InventoryProfile::CanItemFitInContainer(const ItemData *ItemToTry, c
bool EQEmu::InventoryProfile::SupportsClickCasting(int16 slot_id)
{
// there are a few non-potion items that identify as ItemTypePotion..so, we still need to ubiquitously include the equipment range
if ((uint16)slot_id <= invslot::GENERAL_END || slot_id == invslot::SLOT_POWER_SOURCE)
{
if (slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) {
return true;
}
else if (slot_id >= invbag::GENERAL_BAGS_BEGIN && slot_id <= invbag::GENERAL_BAGS_END)
{
else if (slot_id >= invslot::GENERAL_BEGIN && slot_id <= invslot::GENERAL_END) {
return true;
}
else if (slot_id >= invbag::GENERAL_BAGS_BEGIN && slot_id <= invbag::GENERAL_BAGS_END) {
if (inventory::Lookup(m_mob_version)->AllowClickCastFromBag)
return true;
}
@ -992,8 +1097,16 @@ bool EQEmu::InventoryProfile::SupportsClickCasting(int16 slot_id)
bool EQEmu::InventoryProfile::SupportsPotionBeltCasting(int16 slot_id)
{
if ((uint16)slot_id <= invslot::GENERAL_END || slot_id == invslot::SLOT_POWER_SOURCE || (slot_id >= invbag::GENERAL_BAGS_BEGIN && slot_id <= invbag::GENERAL_BAGS_END))
// does this have the same criteria as 'SupportsClickCasting' above? (bag clicking per client)
if (slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) {
return true;
}
else if (slot_id >= invslot::GENERAL_BEGIN && slot_id <= invslot::GENERAL_END) {
return true;
}
else if (slot_id >= invbag::GENERAL_BAGS_BEGIN && slot_id <= invbag::GENERAL_BAGS_END) {
return true;
}
return false;
}
@ -1006,7 +1119,7 @@ bool EQEmu::InventoryProfile::SupportsContainers(int16 slot_id)
(slot_id >= invslot::BANK_BEGIN && slot_id <= invslot::BANK_END) ||
(slot_id >= invslot::SHARED_BANK_BEGIN && slot_id <= invslot::SHARED_BANK_END) ||
(slot_id >= invslot::TRADE_BEGIN && slot_id <= invslot::TRADE_END)
) {
) {
return true;
}
@ -1054,13 +1167,19 @@ uint8 EQEmu::InventoryProfile::FindBrightestLightType()
uint8 brightest_light_type = 0;
for (auto iter = m_worn.begin(); iter != m_worn.end(); ++iter) {
if ((iter->first < invslot::EQUIPMENT_BEGIN || iter->first > invslot::EQUIPMENT_END) && iter->first != invslot::SLOT_POWER_SOURCE) { continue; }
if (iter->first == invslot::slotAmmo) { continue; }
if ((iter->first < invslot::EQUIPMENT_BEGIN || iter->first > invslot::EQUIPMENT_END))
continue;
if (iter->first == invslot::slotAmmo)
continue;
auto inst = iter->second;
if (inst == nullptr) { continue; }
if (inst == nullptr)
continue;
auto item = inst->GetItem();
if (item == nullptr) { continue; }
if (item == nullptr)
continue;
if (lightsource::IsLevelGreater(item->Light, brightest_light_type))
brightest_light_type = item->Light;
@ -1068,15 +1187,21 @@ uint8 EQEmu::InventoryProfile::FindBrightestLightType()
uint8 general_light_type = 0;
for (auto iter = m_inv.begin(); iter != m_inv.end(); ++iter) {
if (iter->first < invslot::GENERAL_BEGIN || iter->first > invslot::GENERAL_END) { continue; }
if (iter->first < invslot::GENERAL_BEGIN || iter->first > invslot::GENERAL_END)
continue;
auto inst = iter->second;
if (inst == nullptr) { continue; }
auto item = inst->GetItem();
if (item == nullptr) { continue; }
if (inst == nullptr)
continue;
if (!item->IsClassCommon()) { continue; }
if (item->Light < 9 || item->Light > 13) { continue; }
auto item = inst->GetItem();
if (item == nullptr)
continue;
if (!item->IsClassCommon())
continue;
if (item->Light < 9 || item->Light > 13)
continue;
if (lightsource::TypeToLevel(item->Light))
general_light_type = item->Light;
@ -1136,7 +1261,7 @@ int EQEmu::InventoryProfile::GetSlotByItemInstCollection(const std::map<int16, I
}
}
return -1;
return EQEmu::invslot::SLOT_INVALID;
}
void EQEmu::InventoryProfile::dumpItemCollection(const std::map<int16, ItemInstance*> &collection)
@ -1174,6 +1299,15 @@ void EQEmu::InventoryProfile::dumpBagContents(ItemInstance *inst, std::map<int16
// Internal Method: Retrieves item within an inventory bucket
EQEmu::ItemInstance* EQEmu::InventoryProfile::_GetItem(const std::map<int16, ItemInstance*>& bucket, int16 slot_id) const
{
if (slot_id <= EQEmu::invslot::POSSESSIONS_END && slot_id >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << slot_id) & m_lookup->PossessionsBitmask) == 0)
return nullptr;
}
else if (slot_id <= EQEmu::invslot::BANK_END && slot_id >= EQEmu::invslot::BANK_BEGIN) {
if (slot_id - EQEmu::invslot::BANK_BEGIN >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank])
return nullptr;
}
auto it = bucket.find(slot_id);
if (it != bucket.end()) {
return it->second;
@ -1205,21 +1339,27 @@ int16 EQEmu::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst)
m_cursor.push_front(inst);
result = slot_id;
}
else if ((slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) || (slot_id == invslot::SLOT_POWER_SOURCE)) {
m_worn[slot_id] = inst;
result = slot_id;
else if (slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) {
if ((((uint64)1 << slot_id) & m_lookup->PossessionsBitmask) != 0) {
m_worn[slot_id] = inst;
result = slot_id;
}
}
else if ((slot_id >= invslot::GENERAL_BEGIN && slot_id <= invslot::GENERAL_END)) {
m_inv[slot_id] = inst;
result = slot_id;
if ((((uint64)1 << slot_id) & m_lookup->PossessionsBitmask) != 0) {
m_inv[slot_id] = inst;
result = slot_id;
}
}
else if (slot_id >= invslot::TRIBUTE_BEGIN && slot_id <= invslot::TRIBUTE_END) {
m_worn[slot_id] = inst;
result = slot_id;
}
else if (slot_id >= invslot::BANK_BEGIN && slot_id <= invslot::BANK_END) {
m_bank[slot_id] = inst;
result = slot_id;
if (slot_id - EQEmu::invslot::BANK_BEGIN < m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank]) {
m_bank[slot_id] = inst;
result = slot_id;
}
}
else if (slot_id >= invslot::SHARED_BANK_BEGIN && slot_id <= invslot::SHARED_BANK_END) {
m_shbank[slot_id] = inst;
@ -1254,6 +1394,15 @@ int16 EQEmu::InventoryProfile::_HasItem(std::map<int16, ItemInstance*>& bucket,
uint32 quantity_found = 0;
for (auto iter = bucket.begin(); iter != bucket.end(); ++iter) {
if (iter->first <= EQEmu::invslot::POSSESSIONS_END && iter->first >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << iter->first) & m_lookup->PossessionsBitmask) == 0)
continue;
}
else if (iter->first <= EQEmu::invslot::BANK_END && iter->first >= EQEmu::invslot::BANK_BEGIN) {
if (iter->first - EQEmu::invslot::BANK_BEGIN >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank])
continue;
}
auto inst = iter->second;
if (inst == nullptr) { continue; }
@ -1347,6 +1496,15 @@ int16 EQEmu::InventoryProfile::_HasItemByUse(std::map<int16, ItemInstance*>& buc
uint32 quantity_found = 0;
for (auto iter = bucket.begin(); iter != bucket.end(); ++iter) {
if (iter->first <= EQEmu::invslot::POSSESSIONS_END && iter->first >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << iter->first) & m_lookup->PossessionsBitmask) == 0)
continue;
}
else if (iter->first <= EQEmu::invslot::BANK_END && iter->first >= EQEmu::invslot::BANK_BEGIN) {
if (iter->first - EQEmu::invslot::BANK_BEGIN >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank])
continue;
}
auto inst = iter->second;
if (inst == nullptr) { continue; }
@ -1411,6 +1569,15 @@ int16 EQEmu::InventoryProfile::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, u
int16 EQEmu::InventoryProfile::_HasItemByLoreGroup(std::map<int16, ItemInstance*>& bucket, uint32 loregroup)
{
for (auto iter = bucket.begin(); iter != bucket.end(); ++iter) {
if (iter->first <= EQEmu::invslot::POSSESSIONS_END && iter->first >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << iter->first) & m_lookup->PossessionsBitmask) == 0)
continue;
}
else if (iter->first <= EQEmu::invslot::BANK_END && iter->first >= EQEmu::invslot::BANK_BEGIN) {
if (iter->first - EQEmu::invslot::BANK_BEGIN >= m_lookup->InventoryTypeSize[EQEmu::invtype::typeBank])
continue;
}
auto inst = iter->second;
if (inst == nullptr) { continue; }
@ -1444,7 +1611,7 @@ int16 EQEmu::InventoryProfile::_HasItemByLoreGroup(std::map<int16, ItemInstance*
}
}
return INVALID_INDEX;
return EQEmu::invslot::SLOT_INVALID;
}
// Internal Method: Checks an inventory queue type bucket for a particular item
@ -1487,5 +1654,5 @@ int16 EQEmu::InventoryProfile::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32
break;
}
return INVALID_INDEX;
return EQEmu::invslot::SLOT_INVALID;
}

View File

@ -110,9 +110,7 @@ bool EQEmu::InventorySlot::IsDeleteSlot() const
bool EQEmu::InventorySlot::IsEquipmentIndex(int16 slot_index)
{
/*if (slot_index < inventory::EquipmentBegin || slot_index > inventory::EquipmentEnd)
return false;*/
if ((slot_index < invslot::EQUIPMENT_BEGIN || slot_index > invslot::EQUIPMENT_END) && slot_index != invslot::SLOT_POWER_SOURCE)
if (slot_index < invslot::EQUIPMENT_BEGIN || slot_index > invslot::EQUIPMENT_END)
return false;
return true;
@ -120,8 +118,6 @@ bool EQEmu::InventorySlot::IsEquipmentIndex(int16 slot_index)
bool EQEmu::InventorySlot::IsGeneralIndex(int16 slot_index)
{
/*if (slot_index < inventory::GeneralBegin || slot_index > inventory::GeneralEnd)
return false;*/
if (slot_index < invslot::GENERAL_BEGIN || slot_index > invslot::GENERAL_END)
return false;
@ -130,22 +126,18 @@ bool EQEmu::InventorySlot::IsGeneralIndex(int16 slot_index)
bool EQEmu::InventorySlot::IsCursorIndex(int16 slot_index)
{
/*if (slot_index != inventory::slotCursor)
return false;*/
if (slot_index != invslot::slotCursor)
return false;
if (slot_index == invslot::slotCursor)
return true;
return true;
return false;
}
bool EQEmu::InventorySlot::IsWeaponIndex(int16 slot_index)
{
/*if ((slot_index != inventory::slotRange) && (slot_index != inventory::slotPrimary) && (slot_index != inventory::slotSecondary))
return false;*/
if ((slot_index != invslot::slotRange) && (slot_index != invslot::slotPrimary) && (slot_index != invslot::slotSecondary))
return false;
return true;
if (slot_index == invslot::slotPrimary || slot_index == invslot::slotSecondary || slot_index == invslot::slotRange)
return true;
return false;
}
bool EQEmu::InventorySlot::IsTextureIndex(int16 slot_index)

View File

@ -271,17 +271,10 @@ bool EQEmu::ItemInstance::IsEquipable(int16 slot_id) const
if (!m_item)
return false;
// another "shouldn't do" fix..will be fixed in future updates (requires code and database work)
int16 use_slot = INVALID_INDEX;
if (slot_id == invslot::SLOT_POWER_SOURCE) { use_slot = invslot::slotGeneral1; }
if ((uint16)slot_id <= invslot::EQUIPMENT_END) { use_slot = slot_id; }
if (slot_id < EQEmu::invslot::EQUIPMENT_BEGIN || slot_id > EQEmu::invslot::EQUIPMENT_END)
return false;
if (use_slot != INVALID_INDEX) {
if (m_item->Slots & (1 << use_slot))
return true;
}
return false;
return ((m_item->Slots & (1 << slot_id)) != 0);
}
bool EQEmu::ItemInstance::IsAugmentable() const
@ -298,20 +291,18 @@ bool EQEmu::ItemInstance::IsAugmentable() const
}
bool EQEmu::ItemInstance::AvailableWearSlot(uint32 aug_wear_slots) const {
// TODO: check to see if incoming 'aug_wear_slots' "switches" bit assignments like above...
// (if wrong, would only affect MainAmmo and MainPowerSource augments)
if (!m_item || !m_item->IsClassCommon())
return false;
int index = invslot::EQUIPMENT_BEGIN;
for (; index <= invslot::slotGeneral1; ++index) { // MainGeneral1 should be legacy::EQUIPMENT_END
for (; index <= invslot::EQUIPMENT_END; ++index) {
if (m_item->Slots & (1 << index)) {
if (aug_wear_slots & (1 << index))
break;
}
}
return (index < 23) ? true : false;
return (index <= EQEmu::invslot::EQUIPMENT_END);
}
int8 EQEmu::ItemInstance::AvailableAugmentSlot(int32 augtype) const
@ -810,12 +801,10 @@ EQEmu::ItemInstance* EQEmu::ItemInstance::Clone() const
}
bool EQEmu::ItemInstance::IsSlotAllowed(int16 slot_id) const {
// 'SupportsContainers' and 'slot_id > 21' previously saw the reassigned PowerSource slot (9999 to 22) as valid
if (!m_item) { return false; }
else if (InventoryProfile::SupportsContainers(slot_id)) { return true; }
else if (m_item->Slots & (1 << slot_id)) { return true; }
else if (slot_id == invslot::SLOT_POWER_SOURCE && (m_item->Slots & (1 << 22))) { return true; } // got lazy... <watch>
else if (slot_id != invslot::SLOT_POWER_SOURCE && slot_id > invslot::EQUIPMENT_END) { return true; }
else if (slot_id > invslot::EQUIPMENT_END) { return true; } // why do we call 'InventoryProfile::SupportsContainers' with this here?
else { return false; }
}

View File

@ -45,18 +45,20 @@ namespace RoF
static OpcodeManager *opcodes = nullptr;
static Strategy struct_strategy;
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id, uint8 depth);
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id, uint8 depth, ItemPacketType packet_type);
// server to client inventory location converters
static inline structs::InventorySlot_Struct ServerToRoFSlot(uint32 serverSlot);
static inline structs::TypelessInventorySlot_Struct ServerToRoFTypelessSlot(uint32 serverSlot);
static inline uint32 ServerToRoFCorpseSlot(uint32 serverCorpseSlot);
static inline structs::InventorySlot_Struct ServerToRoFCorpseSlot(uint32 serverCorpseSlot);
static inline uint32 ServerToRoFCorpseMainSlot(uint32 serverCorpseSlot);
static inline structs::TypelessInventorySlot_Struct ServerToRoFTypelessSlot(uint32 serverSlot, int16 serverType);
// client to server inventory location converters
static inline uint32 RoFToServerSlot(structs::InventorySlot_Struct rofSlot);
static inline uint32 RoFToServerTypelessSlot(structs::TypelessInventorySlot_Struct rofSlot);
static inline uint32 RoFToServerCorpseSlot(uint32 rofCorpseSlot);
static inline uint32 RoFToServerCorpseSlot(structs::InventorySlot_Struct rofCorpseSlot);
static inline uint32 RoFToServerCorpseMainSlot(uint32 rofCorpseSlot);
static inline uint32 RoFToServerTypelessSlot(structs::TypelessInventorySlot_Struct rofSlot, int16 rofType);
// server to client say link converter
static inline void ServerToRoFSayLink(std::string& rofSayLink, const std::string& serverSayLink);
@ -191,7 +193,7 @@ namespace RoF
eq->unknown000 = 1;
OUT(npcid);
eq->inventory_slot = ServerToRoFTypelessSlot(emu->slot);
eq->inventory_slot = ServerToRoFTypelessSlot(emu->slot, EQEmu::invtype::typePossessions);
OUT(charges);
OUT(sell_price);
@ -244,7 +246,7 @@ namespace RoF
SETUP_DIRECT_ENCODE(AltCurrencySellItem_Struct, structs::AltCurrencySellItem_Struct);
OUT(merchant_entity_id);
eq->inventory_slot = ServerToRoFTypelessSlot(emu->slot_id);
eq->inventory_slot = ServerToRoFTypelessSlot(emu->slot_id, EQEmu::invtype::typePossessions);
OUT(charges);
OUT(cost);
@ -268,7 +270,7 @@ namespace RoF
ENCODE_LENGTH_EXACT(ApplyPoison_Struct);
SETUP_DIRECT_ENCODE(ApplyPoison_Struct, structs::ApplyPoison_Struct);
eq->inventory_slot = ServerToRoFTypelessSlot(emu->inventorySlot);
eq->inventory_slot = ServerToRoFTypelessSlot(emu->inventorySlot, EQEmu::invtype::typePossessions);
OUT(success);
FINISH_ENCODE();
@ -585,9 +587,9 @@ namespace RoF
ob.write((const char*)&item_count, sizeof(uint32));
for (int index = 0; index < item_count; ++index, ++eq) {
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0);
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory);
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, "RoF::ENCODE(OP_CharInventory) Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
last_pos = ob.tellp();
}
@ -667,7 +669,12 @@ namespace RoF
FINISH_ENCODE();
}
ENCODE(OP_DeleteCharge) { ENCODE_FORWARD(OP_MoveItem); }
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "RoF::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
ENCODE(OP_DeleteItem)
{
@ -1504,6 +1511,7 @@ namespace RoF
//store away the emu struct
uchar* __emu_buffer = in->pBuffer;
ItemPacket_Struct* old_item_pkt = (ItemPacket_Struct*)__emu_buffer;
EQEmu::InternalSerializedItem_Struct* int_struct = (EQEmu::InternalSerializedItem_Struct*)(&__emu_buffer[4]);
EQEmu::OutBuffer ob;
@ -1511,9 +1519,9 @@ namespace RoF
ob.write((const char*)__emu_buffer, 4);
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0);
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType);
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, "RoF::ENCODE(OP_ItemPacket) Serialization failed on item slot %d.", int_struct->slot_id);
delete in;
return;
}
@ -1586,9 +1594,11 @@ namespace RoF
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
eq->slot_id = ServerToRoFCorpseSlot(emu->slot_id);
eq->slot_id = ServerToRoFCorpseMainSlot(emu->slot_id);
OUT(auto_loot);
FINISH_ENCODE();
@ -1756,6 +1766,8 @@ namespace RoF
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToRoFSlot(emu->from_slot);
eq->to_slot = ServerToRoFSlot(emu->to_slot);
OUT(number_in_stack);
@ -2226,7 +2238,7 @@ namespace RoF
outapp->WriteUInt32(profile::BANDOLIERS_SIZE);
// Copy bandoliers where server and client indexes converge
// Copy bandoliers where server and client indices converge
for (uint32 r = 0; r < EQEmu::profile::BANDOLIERS_SIZE && r < profile::BANDOLIERS_SIZE; ++r) {
outapp->WriteString(emu->bandoliers[r].Name);
for (uint32 j = 0; j < profile::BANDOLIER_ITEM_COUNT; ++j) { // Will need adjusting if 'server != client' is ever true
@ -2241,7 +2253,7 @@ namespace RoF
}
}
}
// 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 (uint32 r = EQEmu::profile::BANDOLIERS_SIZE; r < profile::BANDOLIERS_SIZE; ++r) {
outapp->WriteString("");
for (uint32 j = 0; j < profile::BANDOLIER_ITEM_COUNT; ++j) { // Will need adjusting if 'server != client' is ever true
@ -2253,7 +2265,7 @@ namespace RoF
outapp->WriteUInt32(profile::POTION_BELT_SIZE);
// Copy potion belt where server and client indexes converge
// Copy potion belt where server and client indices converge
for (uint32 r = 0; r < EQEmu::profile::POTION_BELT_SIZE && r < profile::POTION_BELT_SIZE; ++r) {
outapp->WriteString(emu->potionbelt.Items[r].Name);
outapp->WriteUInt32(emu->potionbelt.Items[r].ID);
@ -2265,7 +2277,7 @@ namespace RoF
outapp->WriteSInt32(-1);
}
}
// 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 (uint32 r = EQEmu::profile::POTION_BELT_SIZE; r < profile::POTION_BELT_SIZE; ++r) {
outapp->WriteString("");
outapp->WriteUInt32(0);
@ -3041,7 +3053,7 @@ namespace RoF
SETUP_DIRECT_ENCODE(Merchant_Purchase_Struct, structs::Merchant_Purchase_Struct);
OUT(npcid);
eq->inventory_slot = ServerToRoFTypelessSlot(emu->itemslot);
eq->inventory_slot = ServerToRoFTypelessSlot(emu->itemslot, EQEmu::invtype::typePossessions);
//OUT(itemslot);
OUT(quantity);
OUT(price);
@ -4057,7 +4069,7 @@ namespace RoF
SETUP_DIRECT_DECODE(Adventure_Sell_Struct, structs::Adventure_Sell_Struct);
IN(npcid);
emu->slot = RoFToServerTypelessSlot(eq->inventory_slot);
emu->slot = RoFToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
IN(charges);
IN(sell_price);
@ -4070,7 +4082,7 @@ namespace RoF
SETUP_DIRECT_DECODE(AltCurrencySellItem_Struct, structs::AltCurrencySellItem_Struct);
IN(merchant_entity_id);
emu->slot_id = RoFToServerTypelessSlot(eq->inventory_slot);
emu->slot_id = RoFToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
IN(charges);
IN(cost);
@ -4083,7 +4095,7 @@ namespace RoF
SETUP_DIRECT_DECODE(AltCurrencySelectItem_Struct, structs::AltCurrencySelectItem_Struct);
IN(merchant_entity_id);
emu->slot_id = RoFToServerTypelessSlot(eq->inventory_slot);
emu->slot_id = RoFToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
FINISH_DIRECT_DECODE();
}
@ -4105,7 +4117,7 @@ namespace RoF
DECODE_LENGTH_EXACT(structs::ApplyPoison_Struct);
SETUP_DIRECT_DECODE(ApplyPoison_Struct, structs::ApplyPoison_Struct);
emu->inventorySlot = RoFToServerTypelessSlot(eq->inventory_slot);
emu->inventorySlot = RoFToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
IN(success);
FINISH_DIRECT_DECODE();
@ -4741,9 +4753,11 @@ namespace RoF
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
emu->slot_id = RoFToServerCorpseSlot(eq->slot_id);
emu->slot_id = RoFToServerCorpseMainSlot(eq->slot_id);
IN(auto_loot);
FINISH_DIRECT_DECODE();
@ -4754,8 +4768,8 @@ namespace RoF
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Moved item from %u to %u", eq->from_slot.MainSlot, eq->to_slot.MainSlot);
Log(Logs::General, Logs::Netcode, "[RoF] MoveItem SlotType from %i to %i, MainSlot from %i to %i, SubSlot from %i to %i, AugSlot from %i to %i, Unknown01 from %i to %i, Number %u", eq->from_slot.Type, eq->to_slot.Type, eq->from_slot.Slot, eq->to_slot.Slot, eq->from_slot.SubIndex, eq->to_slot.SubIndex, eq->from_slot.AugIndex, eq->to_slot.AugIndex, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack);
Log(Logs::Moderate, Logs::Netcode, "RoF::DECODE(OP_MoveItem)");
emu->from_slot = RoFToServerSlot(eq->from_slot);
emu->to_slot = RoFToServerSlot(eq->to_slot);
IN(number_in_stack);
@ -4904,7 +4918,7 @@ namespace RoF
SETUP_DIRECT_DECODE(Merchant_Purchase_Struct, structs::Merchant_Purchase_Struct);
IN(npcid);
emu->itemslot = RoFToServerTypelessSlot(eq->inventory_slot);
emu->itemslot = RoFToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
//IN(itemslot);
IN(quantity);
IN(price);
@ -5079,7 +5093,7 @@ namespace RoF
return NextItemInstSerialNumber;
}
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth)
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id_in, uint8 depth, ItemPacketType packet_type)
{
const EQEmu::ItemData *item = inst->GetUnscaledItem();
@ -5092,8 +5106,16 @@ namespace RoF
hdr.stacksize = (inst->IsStackable() ? ((inst->GetCharges() > 1000) ? 0xFFFFFFFF : inst->GetCharges()) : 1);
hdr.unknown004 = 0;
structs::InventorySlot_Struct slot_id = ServerToRoFSlot(slot_id_in);
structs::InventorySlot_Struct slot_id;
switch (packet_type) {
case ItemPacketLoot:
slot_id = ServerToRoFCorpseSlot(slot_id_in);
break;
default:
slot_id = ServerToRoFSlot(slot_id_in);
break;
}
hdr.slot_type = (inst->GetMerchantSlot() ? invtype::typeMerchant : slot_id.Type);
hdr.main_slot = (inst->GetMerchantSlot() ? inst->GetMerchantSlot() : slot_id.Slot);
hdr.sub_slot = (inst->GetMerchantSlot() ? 0xffff : slot_id.SubIndex);
@ -5188,7 +5210,7 @@ namespace RoF
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;
@ -5492,318 +5514,450 @@ namespace RoF
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::GENERAL_END && 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::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), packet_type);
++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 structs::InventorySlot_Struct ServerToRoFSlot(uint32 serverSlot)
{
structs::InventorySlot_Struct RoFSlot;
RoFSlot.Type = INVALID_INDEX;
RoFSlot.Unknown02 = 0;
RoFSlot.Slot = INVALID_INDEX;
RoFSlot.SubIndex = INVALID_INDEX;
RoFSlot.AugIndex = INVALID_INDEX;
RoFSlot.Unknown01 = 0;
RoFSlot.Type = invtype::TYPE_INVALID;
RoFSlot.Unknown02 = INULL;
RoFSlot.Slot = invslot::SLOT_INVALID;
RoFSlot.SubIndex = invbag::SLOT_INVALID;
RoFSlot.AugIndex = invaug::SOCKET_INVALID;
RoFSlot.Unknown01 = INULL;
uint32 TempSlot = 0;
uint32 TempSlot = EQEmu::invslot::SLOT_INVALID;
if (serverSlot < 56 || serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE) { // Main Inventory and Cursor
if (serverSlot < EQEmu::invtype::POSSESSIONS_SIZE) {
RoFSlot.Type = invtype::typePossessions;
RoFSlot.Slot = serverSlot;
if (serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE)
RoFSlot.Slot = invslot::slotPowerSource;
else if (serverSlot >= EQEmu::invslot::slotCursor) // Cursor and Extended Corpse Inventory
RoFSlot.Slot += 3;
else if (serverSlot >= EQEmu::invslot::slotAmmo) // (> 20)
RoFSlot.Slot += 1;
}
/*else if (ServerSlot < 51) { // Cursor Buffer
RoFSlot.SlotType = maps::MapLimbo;
RoFSlot.MainSlot = ServerSlot - 31;
}*/
else if (serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::invbag::CURSOR_BAG_END) { // (> 250 && < 341)
else if (serverSlot <= EQEmu::invbag::CURSOR_BAG_END && serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::GENERAL_BAGS_BEGIN;
RoFSlot.Type = invtype::typePossessions;
TempSlot = serverSlot - 1;
RoFSlot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 2;
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 2) * EQEmu::invbag::SLOT_COUNT);
if (RoFSlot.Slot >= invslot::slotGeneral9) // (> 30)
RoFSlot.Slot = invslot::slotCursor;
RoFSlot.Slot = invslot::GENERAL_BEGIN + (TempSlot / EQEmu::invbag::SLOT_COUNT);
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot - invslot::GENERAL_BEGIN) * EQEmu::invbag::SLOT_COUNT);
}
else if (serverSlot >= EQEmu::invslot::TRIBUTE_BEGIN && serverSlot <= EQEmu::invslot::TRIBUTE_END) { // Tribute
else if (serverSlot <= EQEmu::invslot::TRIBUTE_END && serverSlot >= EQEmu::invslot::TRIBUTE_BEGIN) {
RoFSlot.Type = invtype::typeTribute;
RoFSlot.Slot = serverSlot - EQEmu::invslot::TRIBUTE_BEGIN;
}
else if (serverSlot >= EQEmu::invslot::BANK_BEGIN && serverSlot <= EQEmu::invbag::BANK_BAGS_END) {
else if (serverSlot <= EQEmu::invslot::GUILD_TRIBUTE_END && serverSlot >= EQEmu::invslot::GUILD_TRIBUTE_BEGIN) {
RoFSlot.Type = invtype::typeGuildTribute;
RoFSlot.Slot = serverSlot - EQEmu::invslot::GUILD_TRIBUTE_BEGIN;
}
else if (serverSlot <= EQEmu::invslot::BANK_END && serverSlot >= EQEmu::invslot::BANK_BEGIN) {
RoFSlot.Type = invtype::typeBank;
TempSlot = serverSlot - EQEmu::invslot::BANK_BEGIN;
RoFSlot.Slot = TempSlot;
if (TempSlot > 30) { // (> 30)
RoFSlot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 3;
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::invbag::SLOT_COUNT);
}
RoFSlot.Slot = serverSlot - EQEmu::invslot::BANK_BEGIN;
}
else if (serverSlot >= EQEmu::invslot::SHARED_BANK_BEGIN && serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END) {
else if (serverSlot <= EQEmu::invbag::BANK_BAGS_END && serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::BANK_BAGS_BEGIN;
RoFSlot.Type = invtype::typeBank;
RoFSlot.Slot = TempSlot / EQEmu::invbag::SLOT_COUNT;
RoFSlot.SubIndex = TempSlot - (RoFSlot.Slot * EQEmu::invbag::SLOT_COUNT);
}
else if (serverSlot <= EQEmu::invslot::SHARED_BANK_END && serverSlot >= EQEmu::invslot::SHARED_BANK_BEGIN) {
RoFSlot.Type = invtype::typeSharedBank;
TempSlot = serverSlot - EQEmu::invslot::SHARED_BANK_BEGIN;
RoFSlot.Slot = TempSlot;
if (TempSlot > 30) { // (> 30)
RoFSlot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 3;
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::invbag::SLOT_COUNT);
}
RoFSlot.Slot = serverSlot - EQEmu::invslot::SHARED_BANK_BEGIN;
}
else if (serverSlot >= EQEmu::invslot::TRADE_BEGIN && serverSlot <= EQEmu::invbag::TRADE_BAGS_END) {
else if (serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END && serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::SHARED_BANK_BAGS_BEGIN;
RoFSlot.Type = invtype::typeSharedBank;
RoFSlot.Slot = TempSlot / EQEmu::invbag::SLOT_COUNT;
RoFSlot.SubIndex = TempSlot - (RoFSlot.Slot * EQEmu::invbag::SLOT_COUNT);
}
else if (serverSlot <= EQEmu::invslot::TRADE_END && serverSlot >= EQEmu::invslot::TRADE_BEGIN) {
RoFSlot.Type = invtype::typeTrade;
TempSlot = serverSlot - EQEmu::invslot::TRADE_BEGIN;
RoFSlot.Slot = TempSlot;
if (TempSlot > 30) {
RoFSlot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 3;
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 3) * EQEmu::invbag::SLOT_COUNT);
}
/*
// OLD CODE:
if (TempSlot > 99) {
if (TempSlot > 100)
RoFSlot.MainSlot = int((TempSlot - 100) / 10);
else
RoFSlot.MainSlot = 0;
RoFSlot.SubSlot = TempSlot - (100 + RoFSlot.MainSlot);
}
*/
RoFSlot.Slot = serverSlot - EQEmu::invslot::TRADE_BEGIN;
}
else if (serverSlot >= EQEmu::invslot::WORLD_BEGIN && serverSlot <= EQEmu::invslot::WORLD_END) {
else if (serverSlot <= EQEmu::invbag::TRADE_BAGS_END && serverSlot >= EQEmu::invbag::TRADE_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::TRADE_BAGS_BEGIN;
RoFSlot.Type = invtype::typeTrade;
RoFSlot.Slot = TempSlot / EQEmu::invbag::SLOT_COUNT;
RoFSlot.SubIndex = TempSlot - (RoFSlot.Slot * EQEmu::invbag::SLOT_COUNT);
}
else if (serverSlot <= EQEmu::invslot::WORLD_END && serverSlot >= EQEmu::invslot::WORLD_BEGIN) {
RoFSlot.Type = invtype::typeWorld;
TempSlot = serverSlot - EQEmu::invslot::WORLD_BEGIN;
RoFSlot.Slot = TempSlot;
RoFSlot.Slot = serverSlot - EQEmu::invslot::WORLD_BEGIN;
}
Log(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoFSlot.Type, RoFSlot.Unknown02, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown01);
Log(Logs::Detail, Logs::Netcode, "Convert Server Slot %i to RoF Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i)",
serverSlot, RoFSlot.Type, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown02, RoFSlot.Unknown01);
return RoFSlot;
}
static inline structs::TypelessInventorySlot_Struct ServerToRoFTypelessSlot(uint32 serverSlot)
static inline structs::InventorySlot_Struct ServerToRoFCorpseSlot(uint32 serverCorpseSlot)
{
structs::InventorySlot_Struct RoFSlot;
RoFSlot.Type = invtype::TYPE_INVALID;
RoFSlot.Unknown02 = INULL;
RoFSlot.Slot = ServerToRoFCorpseMainSlot(serverCorpseSlot);
RoFSlot.SubIndex = invbag::SLOT_INVALID;
RoFSlot.AugIndex = invaug::SOCKET_INVALID;
RoFSlot.Unknown01 = INULL;
if (RoFSlot.Slot != invslot::SLOT_INVALID)
RoFSlot.Type = invtype::typeCorpse;
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to RoF Corpse Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i)",
serverCorpseSlot, RoFSlot.Type, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown02, RoFSlot.Unknown01);
return RoFSlot;
}
static inline uint32 ServerToRoFCorpseMainSlot(uint32 serverCorpseSlot)
{
uint32 RoFSlot = invslot::SLOT_INVALID;
if (serverCorpseSlot <= EQEmu::invslot::CORPSE_END && serverCorpseSlot >= EQEmu::invslot::CORPSE_BEGIN) {
RoFSlot = serverCorpseSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to RoF Corpse Main Slot %i", serverCorpseSlot, RoFSlot);
return RoFSlot;
}
static inline structs::TypelessInventorySlot_Struct ServerToRoFTypelessSlot(uint32 serverSlot, int16 serverType)
{
structs::TypelessInventorySlot_Struct RoFSlot;
RoFSlot.Slot = INVALID_INDEX;
RoFSlot.SubIndex = INVALID_INDEX;
RoFSlot.AugIndex = INVALID_INDEX;
RoFSlot.Unknown01 = 0;
RoFSlot.Slot = invslot::SLOT_INVALID;
RoFSlot.SubIndex = invbag::SLOT_INVALID;
RoFSlot.AugIndex = invaug::SOCKET_INVALID;
RoFSlot.Unknown01 = INULL;
uint32 TempSlot = 0;
uint32 TempSlot = EQEmu::invslot::SLOT_INVALID;
if (serverSlot < 56 || serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE) { // (< 52)
RoFSlot.Slot = serverSlot;
if (serverType == EQEmu::invtype::typePossessions) {
if (serverSlot < EQEmu::invtype::POSSESSIONS_SIZE) {
RoFSlot.Slot = serverSlot;
}
if (serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE)
RoFSlot.Slot = invslot::slotPowerSource;
else if (serverSlot <= EQEmu::invbag::CURSOR_BAG_END && serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::GENERAL_BAGS_BEGIN;
else if (serverSlot >= EQEmu::invslot::slotCursor) // Cursor and Extended Corpse Inventory
RoFSlot.Slot += 3;
else if (serverSlot >= EQEmu::invslot::slotAmmo) // Ammo and Personl Inventory
RoFSlot.Slot += 1;
/*else if (ServerSlot >= MainCursor) { // Cursor
RoFSlot.MainSlot = slots::MainCursor;
if (ServerSlot > 30)
RoFSlot.SubSlot = (ServerSlot + 3) - 33;
}*/
RoFSlot.Slot = invslot::GENERAL_BEGIN + (TempSlot / EQEmu::invbag::SLOT_COUNT);
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot - invslot::GENERAL_BEGIN) * EQEmu::invbag::SLOT_COUNT);
}
}
else if (serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::invbag::CURSOR_BAG_END) {
TempSlot = serverSlot - 1;
RoFSlot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 2;
RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 2) * EQEmu::invbag::SLOT_COUNT);
}
Log(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown01);
Log(Logs::Detail, Logs::Netcode, "Convert Server Slot %i to RoF Typeless Slot [%i, %i, %i] (implied type: %i, unk1: %i)",
serverSlot, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, serverType, RoFSlot.Unknown01);
return RoFSlot;
}
static inline uint32 ServerToRoFCorpseSlot(uint32 serverCorpseSlot)
{
return (serverCorpseSlot + 1);
}
static inline uint32 RoFToServerSlot(structs::InventorySlot_Struct rofSlot)
{
uint32 ServerSlot = INVALID_INDEX;
uint32 TempSlot = 0;
if (rofSlot.AugIndex < invaug::SOCKET_INVALID || rofSlot.AugIndex >= invaug::SOCKET_COUNT) {
Log(Logs::Detail, Logs::Netcode, "Convert RoF Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i) to Server Slot %i",
rofSlot.Type, rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofSlot.Unknown02, rofSlot.Unknown01, EQEmu::invslot::SLOT_INVALID);
if (rofSlot.Type == invtype::typePossessions && rofSlot.Slot < 57) { // Worn/Personal Inventory and Cursor (< 51)
if (rofSlot.Slot == invslot::slotPowerSource)
TempSlot = EQEmu::invslot::SLOT_POWER_SOURCE;
else if (rofSlot.Slot >= invslot::slotCursor) // Cursor and Extended Corpse Inventory
TempSlot = rofSlot.Slot - 3;
/*else if (RoFSlot.MainSlot == slots::MainGeneral9 || RoFSlot.MainSlot == slots::MainGeneral10) { // 9th and 10th RoF inventory/corpse slots
// Need to figure out what to do when we get these
// The slot range of 0 - client_max is cross-utilized between player inventory and corpse inventory.
// In the case of RoF, player inventory is addressed as 0 - 33 and corpse inventory is addressed as 23 - 56.
// We 'could' assign the two new inventory slots as 9997 and 9998, and then work around their bag
// slot assignments, but doing so may disrupt our ability to utilize the corpse looting range properly.
// For now, it's probably best to leave as-is and let this work itself out in the inventory rework.
}*/
else if (rofSlot.Slot >= invslot::slotAmmo) // Ammo and Main Inventory
TempSlot = rofSlot.Slot - 1;
else // Worn Slots
TempSlot = rofSlot.Slot;
if (rofSlot.SubIndex >= EQEmu::invbag::SLOT_BEGIN) // Bag Slots
TempSlot = ((TempSlot + 3) * EQEmu::invbag::SLOT_COUNT) + rofSlot.SubIndex + 1;
ServerSlot = TempSlot;
return EQEmu::invslot::SLOT_INVALID;
}
else if (rofSlot.Type == invtype::typeBank) {
TempSlot = EQEmu::invslot::BANK_BEGIN;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
uint32 TempSlot = invslot::SLOT_INVALID;
if (rofSlot.SubIndex >= EQEmu::invbag::SLOT_BEGIN)
TempSlot += ((rofSlot.Slot + 3) * EQEmu::invbag::SLOT_COUNT) + rofSlot.SubIndex + 1;
switch (rofSlot.Type) {
case invtype::typePossessions: {
if (rofSlot.Slot >= invslot::POSSESSIONS_BEGIN && rofSlot.Slot <= invslot::POSSESSIONS_END) {
if (rofSlot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = rofSlot.Slot;
}
else
TempSlot += rofSlot.Slot;
else if (rofSlot.SubIndex >= invbag::SLOT_BEGIN && rofSlot.SubIndex <= invbag::SLOT_END) {
if (rofSlot.Slot < invslot::GENERAL_BEGIN)
return EQEmu::invslot::SLOT_INVALID;
ServerSlot = TempSlot;
TempSlot = (rofSlot.Slot - invslot::GENERAL_BEGIN) * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::GENERAL_BAGS_BEGIN + TempSlot + rofSlot.SubIndex;
}
}
break;
}
case invtype::typeBank: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::BANK_SIZE) {
if (rofSlot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::BANK_BEGIN + rofSlot.Slot;
}
else if (rofSlot.SubIndex >= invbag::SLOT_BEGIN && rofSlot.SubIndex <= invbag::SLOT_END) {
TempSlot = rofSlot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::BANK_BAGS_BEGIN + TempSlot + rofSlot.SubIndex;
}
}
break;
}
case invtype::typeSharedBank: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::SHARED_BANK_SIZE) {
if (rofSlot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::SHARED_BANK_BEGIN + rofSlot.Slot;
}
else if (rofSlot.SubIndex >= invbag::SLOT_BEGIN && rofSlot.SubIndex <= invbag::SLOT_END) {
TempSlot = rofSlot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::SHARED_BANK_BAGS_BEGIN + TempSlot + rofSlot.SubIndex;
}
}
break;
}
case invtype::typeTrade: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::TRADE_SIZE) {
if (rofSlot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::TRADE_BEGIN + rofSlot.Slot;
}
else if (rofSlot.SubIndex >= invbag::SLOT_BEGIN && rofSlot.SubIndex <= invbag::SLOT_END) {
TempSlot = rofSlot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::TRADE_BAGS_BEGIN + TempSlot + rofSlot.SubIndex;
}
}
break;
}
case invtype::typeWorld: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::WORLD_SIZE) {
ServerSlot = EQEmu::invslot::SHARED_BANK_BEGIN + rofSlot.Slot;
}
break;
}
case invtype::typeLimbo: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::LIMBO_SIZE) {
ServerSlot = EQEmu::invslot::slotCursor;
}
break;
}
case invtype::typeTribute: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::TRIBUTE_SIZE) {
ServerSlot = EQEmu::invslot::TRIBUTE_BEGIN + rofSlot.Slot;
}
break;
}
case invtype::typeGuildTribute: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::GUILD_TRIBUTE_SIZE) {
ServerSlot = EQEmu::invslot::GUILD_TRIBUTE_BEGIN + rofSlot.Slot;
}
break;
}
case invtype::typeCorpse: {
if (rofSlot.Slot >= invslot::CORPSE_BEGIN && rofSlot.Slot <= invslot::CORPSE_END) {
ServerSlot = rofSlot.Slot;
}
break;
}
default: {
break;
}
}
else if (rofSlot.Type == invtype::typeSharedBank) {
TempSlot = EQEmu::invslot::SHARED_BANK_BEGIN;
if (rofSlot.SubIndex >= EQEmu::invbag::SLOT_BEGIN)
TempSlot += ((rofSlot.Slot + 3) * EQEmu::invbag::SLOT_COUNT) + rofSlot.SubIndex + 1;
else
TempSlot += rofSlot.Slot;
ServerSlot = TempSlot;
}
else if (rofSlot.Type == invtype::typeTrade) {
TempSlot = EQEmu::invslot::TRADE_BEGIN;
if (rofSlot.SubIndex >= EQEmu::invbag::SLOT_BEGIN)
TempSlot += ((rofSlot.Slot + 3) * EQEmu::invbag::SLOT_COUNT) + rofSlot.SubIndex + 1;
// OLD CODE:
//TempSlot += 100 + (RoFSlot.MainSlot * EQEmu::inventory::ContainerCount) + RoFSlot.SubSlot;
else
TempSlot += rofSlot.Slot;
ServerSlot = TempSlot;
}
else if (rofSlot.Type == invtype::typeWorld) {
TempSlot = EQEmu::invslot::WORLD_BEGIN;
if (rofSlot.Slot >= EQEmu::invbag::SLOT_BEGIN)
TempSlot += rofSlot.Slot;
ServerSlot = TempSlot;
}
/*else if (RoFSlot.SlotType == maps::MapLimbo) { // Cursor Buffer
TempSlot = 31;
if (RoFSlot.MainSlot >= 0)
TempSlot += RoFSlot.MainSlot;
ServerSlot = TempSlot;
}*/
else if (rofSlot.Type == invtype::typeGuildTribute) {
ServerSlot = INVALID_INDEX;
}
Log(Logs::General, Logs::Netcode, "[ERROR] Convert RoF Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rofSlot.Type, rofSlot.Unknown02, rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofSlot.Unknown01, ServerSlot);
Log(Logs::Detail, Logs::Netcode, "Convert RoF Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i) to Server Slot %i",
rofSlot.Type, rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofSlot.Unknown02, rofSlot.Unknown01, ServerSlot);
return ServerSlot;
}
static inline uint32 RoFToServerTypelessSlot(structs::TypelessInventorySlot_Struct rofSlot)
static inline uint32 RoFToServerCorpseSlot(structs::InventorySlot_Struct rofCorpseSlot)
{
uint32 ServerSlot = INVALID_INDEX;
uint32 TempSlot = 0;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (rofSlot.Slot < 57) { // Worn/Personal Inventory and Cursor (< 33)
if (rofSlot.Slot == invslot::slotPowerSource)
TempSlot = EQEmu::invslot::SLOT_POWER_SOURCE;
else if (rofSlot.Slot >= invslot::slotCursor) // Cursor and Extended Corpse Inventory
TempSlot = rofSlot.Slot - 3;
/*else if (RoFSlot.MainSlot == slots::MainGeneral9 || RoFSlot.MainSlot == slots::MainGeneral10) { // 9th and 10th RoF inventory slots
// Need to figure out what to do when we get these
// Same as above
}*/
else if (rofSlot.Slot >= invslot::slotAmmo) // Main Inventory and Ammo Slots
TempSlot = rofSlot.Slot - 1;
else
TempSlot = rofSlot.Slot;
if (rofSlot.SubIndex >= EQEmu::invbag::SLOT_BEGIN) // Bag Slots
TempSlot = ((TempSlot + 3) * EQEmu::invbag::SLOT_COUNT) + rofSlot.SubIndex + 1;
ServerSlot = TempSlot;
if (rofCorpseSlot.Type != invtype::typeCorpse || rofCorpseSlot.SubIndex != invbag::SLOT_INVALID || rofCorpseSlot.AugIndex != invaug::SOCKET_INVALID) {
ServerSlot = EQEmu::invslot::SLOT_INVALID;
}
Log(Logs::General, Logs::Netcode, "[ERROR] Convert RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofSlot.Unknown01, ServerSlot);
else {
ServerSlot = RoFToServerCorpseMainSlot(rofCorpseSlot.Slot);
}
Log(Logs::Detail, Logs::Netcode, "Convert RoF Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i) to Server Slot %i",
rofCorpseSlot.Type, rofCorpseSlot.Slot, rofCorpseSlot.SubIndex, rofCorpseSlot.AugIndex, rofCorpseSlot.Unknown02, rofCorpseSlot.Unknown01, ServerSlot);
return ServerSlot;
}
static inline uint32 RoFToServerCorpseSlot(uint32 rofCorpseSlot)
static inline uint32 RoFToServerCorpseMainSlot(uint32 rofCorpseSlot)
{
return (rofCorpseSlot - 1);
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (rofCorpseSlot <= invslot::CORPSE_END && rofCorpseSlot >= invslot::CORPSE_BEGIN) {
ServerSlot = rofCorpseSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert RoF Corpse Main Slot %i to Server Corpse Slot %i", rofCorpseSlot, ServerSlot);
return ServerSlot;
}
static inline uint32 RoFToServerTypelessSlot(structs::TypelessInventorySlot_Struct rofSlot, int16 rofType)
{
if (rofSlot.AugIndex < invaug::SOCKET_INVALID || rofSlot.AugIndex >= invaug::SOCKET_COUNT) {
Log(Logs::Detail, Logs::Netcode, "Convert RoF Typeless Slot [%i, %i, %i] (implied type: %i, unk1: %i) to Server Slot %i",
rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofType, rofSlot.Unknown01, EQEmu::invslot::SLOT_INVALID);
return EQEmu::invslot::SLOT_INVALID;
}
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
uint32 TempSlot = invslot::SLOT_INVALID;
switch (rofType) {
case invtype::typePossessions: {
if (rofSlot.Slot >= invslot::POSSESSIONS_BEGIN && rofSlot.Slot <= invslot::POSSESSIONS_END) {
if (rofSlot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = rofSlot.Slot;
}
else if (rofSlot.SubIndex >= invbag::SLOT_BEGIN && rofSlot.SubIndex <= invbag::SLOT_END) {
if (rofSlot.Slot < invslot::GENERAL_BEGIN)
return EQEmu::invslot::SLOT_INVALID;
TempSlot = (rofSlot.Slot - invslot::GENERAL_BEGIN) * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::GENERAL_BAGS_BEGIN + TempSlot + rofSlot.SubIndex;
}
}
break;
}
case invtype::typeBank: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::BANK_SIZE) {
if (rofSlot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::BANK_BEGIN + rofSlot.Slot;
}
else if (rofSlot.SubIndex >= invbag::SLOT_BEGIN && rofSlot.SubIndex <= invbag::SLOT_END) {
TempSlot = rofSlot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::BANK_BAGS_BEGIN + TempSlot + rofSlot.SubIndex;
}
}
break;
}
case invtype::typeSharedBank: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::SHARED_BANK_SIZE) {
if (rofSlot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::SHARED_BANK_BEGIN + rofSlot.Slot;
}
else if (rofSlot.SubIndex >= invbag::SLOT_BEGIN && rofSlot.SubIndex <= invbag::SLOT_END) {
TempSlot = rofSlot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::SHARED_BANK_BAGS_BEGIN + TempSlot + rofSlot.SubIndex;
}
}
break;
}
case invtype::typeTrade: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::TRADE_SIZE) {
if (rofSlot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::TRADE_BEGIN + rofSlot.Slot;
}
else if (rofSlot.SubIndex >= invbag::SLOT_BEGIN && rofSlot.SubIndex <= invbag::SLOT_END) {
TempSlot = rofSlot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::TRADE_BAGS_BEGIN + TempSlot + rofSlot.SubIndex;
}
}
break;
}
case invtype::typeWorld: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::WORLD_SIZE) {
ServerSlot = EQEmu::invslot::SHARED_BANK_BEGIN + rofSlot.Slot;
}
break;
}
case invtype::typeLimbo: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::LIMBO_SIZE) {
ServerSlot = EQEmu::invslot::slotCursor;
}
break;
}
case invtype::typeTribute: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::TRIBUTE_SIZE) {
ServerSlot = EQEmu::invslot::TRIBUTE_BEGIN + rofSlot.Slot;
}
break;
}
case invtype::typeGuildTribute: {
if (rofSlot.Slot >= invslot::SLOT_BEGIN && rofSlot.Slot < invtype::GUILD_TRIBUTE_SIZE) {
ServerSlot = EQEmu::invslot::GUILD_TRIBUTE_BEGIN + rofSlot.Slot;
}
break;
}
case invtype::typeCorpse: {
if (rofSlot.Slot >= invslot::CORPSE_BEGIN && rofSlot.Slot <= invslot::CORPSE_END) {
ServerSlot = rofSlot.Slot;
}
break;
}
default: {
break;
}
}
Log(Logs::Detail, Logs::Netcode, "Convert RoF Typeless Slot [%i, %i, %i] (implied type: %i, unk1: %i) to Server Slot %i",
rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofType, rofSlot.Unknown01, ServerSlot);
return ServerSlot;
}
static inline void ServerToRoFSayLink(std::string& rofSayLink, const std::string& serverSayLink)

View File

@ -48,15 +48,17 @@ namespace RoF2
void SerializeItem(EQEmu::OutBuffer& ob, const EQEmu::ItemInstance *inst, int16 slot_id, uint8 depth, ItemPacketType packet_type);
// server to client inventory location converters
static inline structs::InventorySlot_Struct ServerToRoF2Slot(uint32 serverSlot, ItemPacketType PacketType = ItemPacketInvalid);
static inline structs::TypelessInventorySlot_Struct ServerToRoF2TypelessSlot(uint32 serverSlot);
static inline uint32 ServerToRoF2CorpseSlot(uint32 serverCorpseSlot);
static inline structs::InventorySlot_Struct ServerToRoF2Slot(uint32 serverSlot);
static inline structs::InventorySlot_Struct ServerToRoF2CorpseSlot(uint32 serverCorpseSlot);
static inline uint32 ServerToRoF2CorpseMainSlot(uint32 serverCorpseSlot);
static inline structs::TypelessInventorySlot_Struct ServerToRoF2TypelessSlot(uint32 serverSlot, int16 serverType);
// client to server inventory location converters
static inline uint32 RoF2ToServerSlot(structs::InventorySlot_Struct rof2Slot, ItemPacketType PacketType = ItemPacketInvalid);
static inline uint32 RoF2ToServerTypelessSlot(structs::TypelessInventorySlot_Struct rof2Slot);
static inline uint32 RoF2ToServerCorpseSlot(uint32 rof2CorpseSlot);
static inline uint32 RoF2ToServerSlot(structs::InventorySlot_Struct rof2Slot);
static inline uint32 RoF2ToServerCorpseSlot(structs::InventorySlot_Struct rof2CorpseSlot);
static inline uint32 RoF2ToServerCorpseMainSlot(uint32 rof2CorpseSlot);
static inline uint32 RoF2ToServerTypelessSlot(structs::TypelessInventorySlot_Struct rof2Slot, int16 rof2Type);
// server to client say link converter
static inline void ServerToRoF2SayLink(std::string& rof2SayLink, const std::string& serverSayLink);
@ -260,7 +262,7 @@ namespace RoF2
eq->unknown000 = 1;
OUT(npcid);
eq->inventory_slot = ServerToRoF2TypelessSlot(emu->slot);
eq->inventory_slot = ServerToRoF2TypelessSlot(emu->slot, EQEmu::invtype::typePossessions);
OUT(charges);
OUT(sell_price);
@ -313,7 +315,7 @@ namespace RoF2
SETUP_DIRECT_ENCODE(AltCurrencySellItem_Struct, structs::AltCurrencySellItem_Struct);
OUT(merchant_entity_id);
eq->inventory_slot = ServerToRoF2TypelessSlot(emu->slot_id);
eq->inventory_slot = ServerToRoF2TypelessSlot(emu->slot_id, EQEmu::invtype::typePossessions);
OUT(charges);
OUT(cost);
@ -337,7 +339,7 @@ namespace RoF2
ENCODE_LENGTH_EXACT(ApplyPoison_Struct);
SETUP_DIRECT_ENCODE(ApplyPoison_Struct, structs::ApplyPoison_Struct);
eq->inventorySlot = ServerToRoF2TypelessSlot(emu->inventorySlot);
eq->inventorySlot = ServerToRoF2TypelessSlot(emu->inventorySlot, EQEmu::invtype::typePossessions);
OUT(success);
FINISH_ENCODE();
@ -655,7 +657,7 @@ namespace RoF2
for (int index = 0; index < item_count; ++index, ++eq) {
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory);
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, "RoF2::ENCODE(OP_CharInventory) Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
last_pos = ob.tellp();
}
@ -735,7 +737,12 @@ namespace RoF2
FINISH_ENCODE();
}
ENCODE(OP_DeleteCharge) { ENCODE_FORWARD(OP_MoveItem); }
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "RoF2::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
ENCODE(OP_DeleteItem)
{
@ -1582,7 +1589,7 @@ namespace RoF2
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType);
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, "RoF2::ENCODE(OP_ItemPacket) Serialization failed on item slot %d.", int_struct->slot_id);
delete in;
return;
}
@ -1655,9 +1662,11 @@ namespace RoF2
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF2::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
eq->slot_id = ServerToRoF2CorpseSlot(emu->slot_id);
eq->slot_id = ServerToRoF2CorpseMainSlot(emu->slot_id);
OUT(auto_loot);
FINISH_ENCODE();
@ -1825,6 +1834,8 @@ namespace RoF2
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF2::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToRoF2Slot(emu->from_slot);
eq->to_slot = ServerToRoF2Slot(emu->to_slot);
OUT(number_in_stack);
@ -2303,7 +2314,7 @@ namespace RoF2
outapp->WriteUInt32(profile::BANDOLIERS_SIZE);
// Copy bandoliers where server and client indexes converge
// Copy bandoliers where server and client indices converge
for (uint32 r = 0; r < EQEmu::profile::BANDOLIERS_SIZE && r < profile::BANDOLIERS_SIZE; ++r) {
outapp->WriteString(emu->bandoliers[r].Name);
for (uint32 j = 0; j < profile::BANDOLIER_ITEM_COUNT; ++j) { // Will need adjusting if 'server != client' is ever true
@ -2318,7 +2329,7 @@ namespace RoF2
}
}
}
// 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 (uint32 r = EQEmu::profile::BANDOLIERS_SIZE; r < profile::BANDOLIERS_SIZE; ++r) {
outapp->WriteString("");
for (uint32 j = 0; j < profile::BANDOLIER_ITEM_COUNT; ++j) { // Will need adjusting if 'server != client' is ever true
@ -2330,7 +2341,7 @@ namespace RoF2
outapp->WriteUInt32(profile::POTION_BELT_SIZE);
// Copy potion belt where server and client indexes converge
// Copy potion belt where server and client indices converge
for (uint32 r = 0; r < EQEmu::profile::POTION_BELT_SIZE && r < profile::POTION_BELT_SIZE; ++r) {
outapp->WriteString(emu->potionbelt.Items[r].Name);
outapp->WriteUInt32(emu->potionbelt.Items[r].ID);
@ -2342,7 +2353,7 @@ namespace RoF2
outapp->WriteSInt32(-1);
}
}
// 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 (uint32 r = EQEmu::profile::POTION_BELT_SIZE; r < profile::POTION_BELT_SIZE; ++r) {
outapp->WriteString("");
outapp->WriteUInt32(0);
@ -3110,7 +3121,7 @@ namespace RoF2
SETUP_DIRECT_ENCODE(Merchant_Purchase_Struct, structs::Merchant_Purchase_Struct);
OUT(npcid);
eq->inventory_slot = ServerToRoF2TypelessSlot(emu->itemslot);
eq->inventory_slot = ServerToRoF2TypelessSlot(emu->itemslot, EQEmu::invtype::typePossessions);
//OUT(itemslot);
OUT(quantity);
OUT(price);
@ -4299,7 +4310,7 @@ namespace RoF2
SETUP_DIRECT_DECODE(Adventure_Sell_Struct, structs::Adventure_Sell_Struct);
IN(npcid);
emu->slot = RoF2ToServerTypelessSlot(eq->inventory_slot);
emu->slot = RoF2ToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
IN(charges);
IN(sell_price);
@ -4312,7 +4323,7 @@ namespace RoF2
SETUP_DIRECT_DECODE(AltCurrencySellItem_Struct, structs::AltCurrencySellItem_Struct);
IN(merchant_entity_id);
emu->slot_id = RoF2ToServerTypelessSlot(eq->inventory_slot);
emu->slot_id = RoF2ToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
IN(charges);
IN(cost);
@ -4325,7 +4336,7 @@ namespace RoF2
SETUP_DIRECT_DECODE(AltCurrencySelectItem_Struct, structs::AltCurrencySelectItem_Struct);
IN(merchant_entity_id);
emu->slot_id = RoF2ToServerTypelessSlot(eq->inventory_slot);
emu->slot_id = RoF2ToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
FINISH_DIRECT_DECODE();
}
@ -4347,7 +4358,7 @@ namespace RoF2
DECODE_LENGTH_EXACT(structs::ApplyPoison_Struct);
SETUP_DIRECT_DECODE(ApplyPoison_Struct, structs::ApplyPoison_Struct);
emu->inventorySlot = RoF2ToServerTypelessSlot(eq->inventorySlot);
emu->inventorySlot = RoF2ToServerTypelessSlot(eq->inventorySlot, invtype::typePossessions);
IN(success);
FINISH_DIRECT_DECODE();
@ -4981,9 +4992,11 @@ namespace RoF2
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF2::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
emu->slot_id = RoF2ToServerCorpseSlot(eq->slot_id);
emu->slot_id = RoF2ToServerCorpseMainSlot(eq->slot_id);
IN(auto_loot);
FINISH_DIRECT_DECODE();
@ -4994,10 +5007,13 @@ namespace RoF2
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::General, Logs::Netcode, "[RoF2] MoveItem SlotType from %i to %i, MainSlot from %i to %i, SubSlot from %i to %i, AugSlot from %i to %i, Unknown01 from %i to %i, Number %u", eq->from_slot.Type, eq->to_slot.Type, eq->from_slot.Slot, eq->to_slot.Slot, eq->from_slot.SubIndex, eq->to_slot.SubIndex, eq->from_slot.AugIndex, eq->to_slot.AugIndex, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack);
Log(Logs::Moderate, Logs::Netcode, "RoF2::DECODE(OP_MoveItem)");
emu->from_slot = RoF2ToServerSlot(eq->from_slot);
emu->to_slot = RoF2ToServerSlot(eq->to_slot);
IN(number_in_stack);
//Log(Logs::General, Logs::Netcode, "[RoF2] MoveItem Slot from %u to %u, Number %u", emu->from_slot, emu->to_slot, emu->number_in_stack);
FINISH_DIRECT_DECODE();
}
@ -5144,7 +5160,7 @@ namespace RoF2
SETUP_DIRECT_DECODE(Merchant_Purchase_Struct, structs::Merchant_Purchase_Struct);
IN(npcid);
emu->itemslot = RoF2ToServerTypelessSlot(eq->inventory_slot);
emu->itemslot = RoF2ToServerTypelessSlot(eq->inventory_slot, invtype::typePossessions);
//IN(itemslot);
IN(quantity);
IN(price);
@ -5387,8 +5403,16 @@ namespace RoF2
hdr.stacksize = (inst->IsStackable() ? ((inst->GetCharges() > 1000) ? 0xFFFFFFFF : inst->GetCharges()) : 1);
hdr.unknown004 = 0;
structs::InventorySlot_Struct slot_id = ServerToRoF2Slot(slot_id_in, packet_type);
structs::InventorySlot_Struct slot_id;
switch (packet_type) {
case ItemPacketLoot:
slot_id = ServerToRoF2CorpseSlot(slot_id_in);
break;
default:
slot_id = ServerToRoF2Slot(slot_id_in);
break;
}
hdr.slot_type = (inst->GetMerchantSlot() ? invtype::typeMerchant : slot_id.Type);
hdr.main_slot = (inst->GetMerchantSlot() ? inst->GetMerchantSlot() : slot_id.Slot);
hdr.sub_slot = (inst->GetMerchantSlot() ? 0xffff : slot_id.SubIndex);
@ -5483,7 +5507,7 @@ namespace RoF2
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;
@ -5797,330 +5821,450 @@ namespace RoF2
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::GENERAL_END && 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::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), packet_type);
++subitem_count;
ob.write((const char*)&index, sizeof(uint32));
SerializeItem(ob, sub, SubSlotNumber, (depth + 1), packet_type);
++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 structs::InventorySlot_Struct ServerToRoF2Slot(uint32 serverSlot, ItemPacketType PacketType)
static inline structs::InventorySlot_Struct ServerToRoF2Slot(uint32 serverSlot)
{
structs::InventorySlot_Struct RoF2Slot;
RoF2Slot.Type = INVALID_INDEX;
RoF2Slot.Unknown02 = 0;
RoF2Slot.Slot = INVALID_INDEX;
RoF2Slot.SubIndex = INVALID_INDEX;
RoF2Slot.AugIndex = INVALID_INDEX;
RoF2Slot.Unknown01 = 0;
RoF2Slot.Type = invtype::TYPE_INVALID;
RoF2Slot.Unknown02 = INULL;
RoF2Slot.Slot = invslot::SLOT_INVALID;
RoF2Slot.SubIndex = invbag::SLOT_INVALID;
RoF2Slot.AugIndex = invaug::SOCKET_INVALID;
RoF2Slot.Unknown01 = INULL;
uint32 TempSlot = 0;
uint32 TempSlot = EQEmu::invslot::SLOT_INVALID;
if (serverSlot < 56 || serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE) { // Main Inventory and Cursor
if (PacketType == ItemPacketLoot)
{
RoF2Slot.Type = invtype::typeCorpse;
RoF2Slot.Slot = serverSlot - EQEmu::invslot::CORPSE_BEGIN;
}
else
{
RoF2Slot.Type = invtype::typePossessions;
RoF2Slot.Slot = serverSlot;
}
if (serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE)
RoF2Slot.Slot = invslot::slotPowerSource;
else if (serverSlot >= EQEmu::invslot::slotCursor && PacketType != ItemPacketLoot) // Cursor and Extended Corpse Inventory
RoF2Slot.Slot += 3;
else if (serverSlot >= EQEmu::invslot::slotAmmo) // (> 20)
RoF2Slot.Slot += 1;
}
/*else if (ServerSlot < 51) { // Cursor Buffer
RoF2Slot.SlotType = maps::MapLimbo;
RoF2Slot.MainSlot = ServerSlot - 31;
}*/
else if (serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::invbag::CURSOR_BAG_END) { // (> 250 && < 341)
if (serverSlot < EQEmu::invtype::POSSESSIONS_SIZE) {
RoF2Slot.Type = invtype::typePossessions;
TempSlot = serverSlot - 1;
RoF2Slot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 2;
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 2) * EQEmu::invbag::SLOT_COUNT);
if (RoF2Slot.Slot >= invslot::slotGeneral9) // (> 30)
RoF2Slot.Slot = invslot::slotCursor;
RoF2Slot.Slot = serverSlot;
}
else if (serverSlot >= EQEmu::invslot::TRIBUTE_BEGIN && serverSlot <= EQEmu::invslot::TRIBUTE_END) { // Tribute
else if (serverSlot <= EQEmu::invbag::CURSOR_BAG_END && serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::GENERAL_BAGS_BEGIN;
RoF2Slot.Type = invtype::typePossessions;
RoF2Slot.Slot = invslot::GENERAL_BEGIN + (TempSlot / EQEmu::invbag::SLOT_COUNT);
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot - invslot::GENERAL_BEGIN) * EQEmu::invbag::SLOT_COUNT);
}
else if (serverSlot <= EQEmu::invslot::TRIBUTE_END && serverSlot >= EQEmu::invslot::TRIBUTE_BEGIN) {
RoF2Slot.Type = invtype::typeTribute;
RoF2Slot.Slot = serverSlot - EQEmu::invslot::TRIBUTE_BEGIN;
}
else if (serverSlot >= EQEmu::invslot::BANK_BEGIN && serverSlot <= EQEmu::invbag::BANK_BAGS_END) {
else if (serverSlot <= EQEmu::invslot::GUILD_TRIBUTE_END && serverSlot >= EQEmu::invslot::GUILD_TRIBUTE_BEGIN) {
RoF2Slot.Type = invtype::typeGuildTribute;
RoF2Slot.Slot = serverSlot - EQEmu::invslot::GUILD_TRIBUTE_BEGIN;
}
else if (serverSlot <= EQEmu::invslot::BANK_END && serverSlot >= EQEmu::invslot::BANK_BEGIN) {
RoF2Slot.Type = invtype::typeBank;
TempSlot = serverSlot - EQEmu::invslot::BANK_BEGIN;
RoF2Slot.Slot = TempSlot;
if (TempSlot > 30) { // (> 30)
RoF2Slot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 3;
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::invbag::SLOT_COUNT);
}
RoF2Slot.Slot = serverSlot - EQEmu::invslot::BANK_BEGIN;
}
else if (serverSlot >= EQEmu::invslot::SHARED_BANK_BEGIN && serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END) {
else if (serverSlot <= EQEmu::invbag::BANK_BAGS_END && serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::BANK_BAGS_BEGIN;
RoF2Slot.Type = invtype::typeBank;
RoF2Slot.Slot = TempSlot / EQEmu::invbag::SLOT_COUNT;
RoF2Slot.SubIndex = TempSlot - (RoF2Slot.Slot * EQEmu::invbag::SLOT_COUNT);
}
else if (serverSlot <= EQEmu::invslot::SHARED_BANK_END && serverSlot >= EQEmu::invslot::SHARED_BANK_BEGIN) {
RoF2Slot.Type = invtype::typeSharedBank;
TempSlot = serverSlot - EQEmu::invslot::SHARED_BANK_BEGIN;
RoF2Slot.Slot = TempSlot;
if (TempSlot > 30) { // (> 30)
RoF2Slot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 3;
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::invbag::SLOT_COUNT);
}
RoF2Slot.Slot = serverSlot - EQEmu::invslot::SHARED_BANK_BEGIN;
}
else if (serverSlot >= EQEmu::invslot::TRADE_BEGIN && serverSlot <= EQEmu::invbag::TRADE_BAGS_END) {
else if (serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END && serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::SHARED_BANK_BAGS_BEGIN;
RoF2Slot.Type = invtype::typeSharedBank;
RoF2Slot.Slot = TempSlot / EQEmu::invbag::SLOT_COUNT;
RoF2Slot.SubIndex = TempSlot - (RoF2Slot.Slot * EQEmu::invbag::SLOT_COUNT);
}
else if (serverSlot <= EQEmu::invslot::TRADE_END && serverSlot >= EQEmu::invslot::TRADE_BEGIN) {
RoF2Slot.Type = invtype::typeTrade;
TempSlot = serverSlot - EQEmu::invslot::TRADE_BEGIN;
RoF2Slot.Slot = TempSlot;
if (TempSlot > 30) {
RoF2Slot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 3;
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 3) * EQEmu::invbag::SLOT_COUNT);
}
/*
// OLD CODE:
if (TempSlot > 99) {
if (TempSlot > 100)
RoF2Slot.MainSlot = int((TempSlot - 100) / 10);
else
RoF2Slot.MainSlot = 0;
RoF2Slot.SubSlot = TempSlot - (100 + RoF2Slot.MainSlot);
}
*/
RoF2Slot.Slot = serverSlot - EQEmu::invslot::TRADE_BEGIN;
}
else if (serverSlot >= EQEmu::invslot::WORLD_BEGIN && serverSlot <= EQEmu::invslot::WORLD_END) {
else if (serverSlot <= EQEmu::invbag::TRADE_BAGS_END && serverSlot >= EQEmu::invbag::TRADE_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::TRADE_BAGS_BEGIN;
RoF2Slot.Type = invtype::typeTrade;
RoF2Slot.Slot = TempSlot / EQEmu::invbag::SLOT_COUNT;
RoF2Slot.SubIndex = TempSlot - (RoF2Slot.Slot * EQEmu::invbag::SLOT_COUNT);
}
else if (serverSlot <= EQEmu::invslot::WORLD_END && serverSlot >= EQEmu::invslot::WORLD_BEGIN) {
RoF2Slot.Type = invtype::typeWorld;
TempSlot = serverSlot - EQEmu::invslot::WORLD_BEGIN;
RoF2Slot.Slot = TempSlot;
RoF2Slot.Slot = serverSlot - EQEmu::invslot::WORLD_BEGIN;
}
Log(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF2 Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoF2Slot.Type, RoF2Slot.Unknown02, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown01);
Log(Logs::Detail, Logs::Netcode, "Convert Server Slot %i to RoF2 Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i)",
serverSlot, RoF2Slot.Type, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown02, RoF2Slot.Unknown01);
return RoF2Slot;
}
static inline structs::TypelessInventorySlot_Struct ServerToRoF2TypelessSlot(uint32 serverSlot)
static inline structs::InventorySlot_Struct ServerToRoF2CorpseSlot(uint32 serverCorpseSlot)
{
structs::InventorySlot_Struct RoF2Slot;
RoF2Slot.Type = invtype::TYPE_INVALID;
RoF2Slot.Unknown02 = INULL;
RoF2Slot.Slot = ServerToRoF2CorpseMainSlot(serverCorpseSlot);
RoF2Slot.SubIndex = invbag::SLOT_INVALID;
RoF2Slot.AugIndex = invaug::SOCKET_INVALID;
RoF2Slot.Unknown01 = INULL;
if (RoF2Slot.Slot != invslot::SLOT_INVALID)
RoF2Slot.Type = invtype::typeCorpse;
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to RoF2 Corpse Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i)",
serverCorpseSlot, RoF2Slot.Type, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown02, RoF2Slot.Unknown01);
return RoF2Slot;
}
static inline uint32 ServerToRoF2CorpseMainSlot(uint32 serverCorpseSlot)
{
uint32 RoF2Slot = invslot::SLOT_INVALID;
if (serverCorpseSlot <= EQEmu::invslot::CORPSE_END && serverCorpseSlot >= EQEmu::invslot::CORPSE_BEGIN) {
RoF2Slot = serverCorpseSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to RoF2 Corpse Main Slot %i", serverCorpseSlot, RoF2Slot);
return RoF2Slot;
}
static inline structs::TypelessInventorySlot_Struct ServerToRoF2TypelessSlot(uint32 serverSlot, int16 serverType)
{
structs::TypelessInventorySlot_Struct RoF2Slot;
RoF2Slot.Slot = INVALID_INDEX;
RoF2Slot.SubIndex = INVALID_INDEX;
RoF2Slot.AugIndex = INVALID_INDEX;
RoF2Slot.Unknown01 = 0;
RoF2Slot.Slot = invslot::SLOT_INVALID;
RoF2Slot.SubIndex = invbag::SLOT_INVALID;
RoF2Slot.AugIndex = invaug::SOCKET_INVALID;
RoF2Slot.Unknown01 = INULL;
uint32 TempSlot = 0;
uint32 TempSlot = EQEmu::invslot::SLOT_INVALID;
if (serverSlot < 56 || serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE) { // (< 52)
RoF2Slot.Slot = serverSlot;
if (serverType == EQEmu::invtype::typePossessions) {
if (serverSlot < EQEmu::invtype::POSSESSIONS_SIZE) {
RoF2Slot.Slot = serverSlot;
}
if (serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE)
RoF2Slot.Slot = invslot::slotPowerSource;
else if (serverSlot <= EQEmu::invbag::CURSOR_BAG_END && serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
TempSlot = serverSlot - EQEmu::invbag::GENERAL_BAGS_BEGIN;
else if (serverSlot >= EQEmu::invslot::slotCursor) // Cursor and Extended Corpse Inventory
RoF2Slot.Slot += 3;
else if (serverSlot >= EQEmu::invslot::slotAmmo) // Ammo and Personl Inventory
RoF2Slot.Slot += 1;
/*else if (ServerSlot >= MainCursor) { // Cursor
RoF2Slot.MainSlot = slots::MainCursor;
if (ServerSlot > 30)
RoF2Slot.SubSlot = (ServerSlot + 3) - 33;
}*/
RoF2Slot.Slot = invslot::GENERAL_BEGIN + (TempSlot / EQEmu::invbag::SLOT_COUNT);
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot - invslot::GENERAL_BEGIN) * EQEmu::invbag::SLOT_COUNT);
}
}
else if (serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::invbag::CURSOR_BAG_END) {
TempSlot = serverSlot - 1;
RoF2Slot.Slot = int(TempSlot / EQEmu::invbag::SLOT_COUNT) - 2;
RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 2) * EQEmu::invbag::SLOT_COUNT);
}
Log(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown01);
Log(Logs::Detail, Logs::Netcode, "Convert Server Slot %i to RoF2 Typeless Slot [%i, %i, %i] (implied type: %i, unk1: %i)",
serverSlot, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, serverType, RoF2Slot.Unknown01);
return RoF2Slot;
}
static inline uint32 ServerToRoF2CorpseSlot(uint32 serverCorpseSlot)
static inline uint32 RoF2ToServerSlot(structs::InventorySlot_Struct rof2Slot)
{
return (serverCorpseSlot - EQEmu::invslot::CORPSE_BEGIN + 1);
}
if (rof2Slot.AugIndex < invaug::SOCKET_INVALID || rof2Slot.AugIndex >= invaug::SOCKET_COUNT) {
Log(Logs::Detail, Logs::Netcode, "Convert RoF2 Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i) to Server Slot %i",
rof2Slot.Type, rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Slot.Unknown02, rof2Slot.Unknown01, EQEmu::invslot::SLOT_INVALID);
static inline uint32 RoF2ToServerSlot(structs::InventorySlot_Struct rof2Slot, ItemPacketType PacketType)
{
uint32 ServerSlot = INVALID_INDEX;
uint32 TempSlot = 0;
if (rof2Slot.Type == invtype::typePossessions && rof2Slot.Slot < 57) { // Worn/Personal Inventory and Cursor (< 51)
if (rof2Slot.Slot == invslot::slotPowerSource)
TempSlot = EQEmu::invslot::SLOT_POWER_SOURCE;
else if (rof2Slot.Slot >= invslot::slotCursor) // Cursor and Extended Corpse Inventory
TempSlot = rof2Slot.Slot - 3;
/*else if (RoF2Slot.MainSlot == slots::MainGeneral9 || RoF2Slot.MainSlot == slots::MainGeneral10) { // 9th and 10th RoF2 inventory/corpse slots
// Need to figure out what to do when we get these
// The slot range of 0 - client_max is cross-utilized between player inventory and corpse inventory.
// In the case of RoF2, player inventory is addressed as 0 - 33 and corpse inventory is addressed as 23 - 56.
// We 'could' assign the two new inventory slots as 9997 and 9998, and then work around their bag
// slot assignments, but doing so may disrupt our ability to utilize the corpse looting range properly.
// For now, it's probably best to leave as-is and let this work itself out in the inventory rework.
}*/
else if (rof2Slot.Slot >= invslot::slotAmmo) // Ammo and Main Inventory
TempSlot = rof2Slot.Slot - 1;
else // Worn Slots
TempSlot = rof2Slot.Slot;
if (rof2Slot.SubIndex >= EQEmu::invbag::SLOT_BEGIN) // Bag Slots
TempSlot = ((TempSlot + 3) * EQEmu::invbag::SLOT_COUNT) + rof2Slot.SubIndex + 1;
ServerSlot = TempSlot;
return EQEmu::invslot::SLOT_INVALID;
}
else if (rof2Slot.Type == invtype::typeBank) {
TempSlot = EQEmu::invslot::BANK_BEGIN;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
uint32 TempSlot = invslot::SLOT_INVALID;
switch (rof2Slot.Type) {
case invtype::typePossessions: {
if (rof2Slot.Slot >= invslot::POSSESSIONS_BEGIN && rof2Slot.Slot <= invslot::POSSESSIONS_END) {
if (rof2Slot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = rof2Slot.Slot;
}
if (rof2Slot.SubIndex >= EQEmu::invbag::SLOT_BEGIN)
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::invbag::SLOT_COUNT) + rof2Slot.SubIndex + 1;
else if (rof2Slot.SubIndex >= invbag::SLOT_BEGIN && rof2Slot.SubIndex <= invbag::SLOT_END) {
if (rof2Slot.Slot < invslot::GENERAL_BEGIN)
return EQEmu::invslot::SLOT_INVALID;
else
TempSlot += rof2Slot.Slot;
TempSlot = (rof2Slot.Slot - invslot::GENERAL_BEGIN) * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::GENERAL_BAGS_BEGIN + TempSlot + rof2Slot.SubIndex;
}
}
ServerSlot = TempSlot;
break;
}
case invtype::typeBank: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::BANK_SIZE) {
if (rof2Slot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::BANK_BEGIN + rof2Slot.Slot;
}
else if (rof2Slot.SubIndex >= invbag::SLOT_BEGIN && rof2Slot.SubIndex <= invbag::SLOT_END) {
TempSlot = rof2Slot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::BANK_BAGS_BEGIN + TempSlot + rof2Slot.SubIndex;
}
}
break;
}
case invtype::typeSharedBank: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::SHARED_BANK_SIZE) {
if (rof2Slot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::SHARED_BANK_BEGIN + rof2Slot.Slot;
}
else if (rof2Slot.SubIndex >= invbag::SLOT_BEGIN && rof2Slot.SubIndex <= invbag::SLOT_END) {
TempSlot = rof2Slot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::SHARED_BANK_BAGS_BEGIN + TempSlot + rof2Slot.SubIndex;
}
}
break;
}
case invtype::typeTrade: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::TRADE_SIZE) {
if (rof2Slot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::TRADE_BEGIN + rof2Slot.Slot;
}
else if (rof2Slot.SubIndex >= invbag::SLOT_BEGIN && rof2Slot.SubIndex <= invbag::SLOT_END) {
TempSlot = rof2Slot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::TRADE_BAGS_BEGIN + TempSlot + rof2Slot.SubIndex;
}
}
break;
}
case invtype::typeWorld: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::WORLD_SIZE) {
ServerSlot = EQEmu::invslot::SHARED_BANK_BEGIN + rof2Slot.Slot;
}
break;
}
case invtype::typeLimbo: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::LIMBO_SIZE) {
ServerSlot = EQEmu::invslot::slotCursor;
}
break;
}
case invtype::typeTribute: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::TRIBUTE_SIZE) {
ServerSlot = EQEmu::invslot::TRIBUTE_BEGIN + rof2Slot.Slot;
}
break;
}
case invtype::typeGuildTribute: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::GUILD_TRIBUTE_SIZE) {
ServerSlot = EQEmu::invslot::GUILD_TRIBUTE_BEGIN + rof2Slot.Slot;
}
break;
}
case invtype::typeCorpse: {
if (rof2Slot.Slot >= invslot::CORPSE_BEGIN && rof2Slot.Slot <= invslot::CORPSE_END) {
ServerSlot = rof2Slot.Slot;
}
break;
}
default: {
break;
}
}
else if (rof2Slot.Type == invtype::typeSharedBank) {
TempSlot = EQEmu::invslot::SHARED_BANK_BEGIN;
if (rof2Slot.SubIndex >= EQEmu::invbag::SLOT_BEGIN)
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::invbag::SLOT_COUNT) + rof2Slot.SubIndex + 1;
else
TempSlot += rof2Slot.Slot;
ServerSlot = TempSlot;
}
else if (rof2Slot.Type == invtype::typeTrade) {
TempSlot = EQEmu::invslot::TRADE_BEGIN;
if (rof2Slot.SubIndex >= EQEmu::invbag::SLOT_BEGIN)
TempSlot += ((rof2Slot.Slot + 3) * EQEmu::invbag::SLOT_COUNT) + rof2Slot.SubIndex + 1;
// OLD CODE:
//TempSlot += 100 + (RoF2Slot.MainSlot * EmuConstants::ITEM_CONTAINER_SIZE) + RoF2Slot.SubSlot;
else
TempSlot += rof2Slot.Slot;
ServerSlot = TempSlot;
}
else if (rof2Slot.Type == invtype::typeWorld) {
TempSlot = EQEmu::invslot::WORLD_BEGIN;
if (rof2Slot.Slot >= EQEmu::invbag::SLOT_BEGIN)
TempSlot += rof2Slot.Slot;
ServerSlot = TempSlot;
}
/*else if (RoF2Slot.SlotType == maps::MapLimbo) { // Cursor Buffer
TempSlot = 31;
if (RoF2Slot.MainSlot >= 0)
TempSlot += RoF2Slot.MainSlot;
ServerSlot = TempSlot;
}*/
else if (rof2Slot.Type == invtype::typeGuildTribute) {
ServerSlot = INVALID_INDEX;
}
else if (rof2Slot.Type == invtype::typeCorpse) {
ServerSlot = rof2Slot.Slot + EQEmu::invslot::CORPSE_BEGIN;
}
Log(Logs::General, Logs::Netcode, "[ERROR] Convert RoF2 Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rof2Slot.Type, rof2Slot.Unknown02, rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Slot.Unknown01, ServerSlot);
Log(Logs::Detail, Logs::Netcode, "Convert RoF2 Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i) to Server Slot %i",
rof2Slot.Type, rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Slot.Unknown02, rof2Slot.Unknown01, ServerSlot);
return ServerSlot;
}
static inline uint32 RoF2ToServerTypelessSlot(structs::TypelessInventorySlot_Struct rof2Slot)
static inline uint32 RoF2ToServerCorpseSlot(structs::InventorySlot_Struct rof2CorpseSlot)
{
uint32 ServerSlot = INVALID_INDEX;
uint32 TempSlot = 0;
if (rof2Slot.Slot < 57) { // Worn/Personal Inventory and Cursor (< 33)
if (rof2Slot.Slot == invslot::slotPowerSource)
TempSlot = EQEmu::invslot::SLOT_POWER_SOURCE;
else if (rof2Slot.Slot >= invslot::slotCursor) // Cursor and Extended Corpse Inventory
TempSlot = rof2Slot.Slot - 3;
/*else if (RoF2Slot.MainSlot == slots::MainGeneral9 || RoF2Slot.MainSlot == slots::MainGeneral10) { // 9th and 10th RoF2 inventory slots
// Need to figure out what to do when we get these
// Same as above
}*/
else if (rof2Slot.Slot >= invslot::slotAmmo) // Main Inventory and Ammo Slots
TempSlot = rof2Slot.Slot - 1;
else
TempSlot = rof2Slot.Slot;
if (rof2Slot.SubIndex >= EQEmu::invbag::SLOT_BEGIN) // Bag Slots
TempSlot = ((TempSlot + 3) * EQEmu::invbag::SLOT_COUNT) + rof2Slot.SubIndex + 1;
ServerSlot = TempSlot;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (rof2CorpseSlot.Type != invtype::typeCorpse || rof2CorpseSlot.SubIndex != invbag::SLOT_INVALID || rof2CorpseSlot.AugIndex != invaug::SOCKET_INVALID) {
ServerSlot = EQEmu::invslot::SLOT_INVALID;
}
else {
ServerSlot = RoF2ToServerCorpseMainSlot(rof2CorpseSlot.Slot);
}
Log(Logs::General, Logs::Netcode, "[ERROR] Convert RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Slot.Unknown01, ServerSlot);
Log(Logs::Detail, Logs::Netcode, "Convert RoF2 Slot [%i, %i, %i, %i] (unk2: %i, unk1: %i) to Server Slot %i",
rof2CorpseSlot.Type, rof2CorpseSlot.Slot, rof2CorpseSlot.SubIndex, rof2CorpseSlot.AugIndex, rof2CorpseSlot.Unknown02, rof2CorpseSlot.Unknown01, ServerSlot);
return ServerSlot;
}
static inline uint32 RoF2ToServerCorpseSlot(uint32 rof2CorpseSlot)
static inline uint32 RoF2ToServerCorpseMainSlot(uint32 rof2CorpseSlot)
{
return (rof2CorpseSlot + EQEmu::invslot::CORPSE_BEGIN - 1);
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (rof2CorpseSlot <= invslot::CORPSE_END && rof2CorpseSlot >= invslot::CORPSE_BEGIN) {
ServerSlot = rof2CorpseSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert RoF2 Corpse Main Slot %i to Server Corpse Slot %i", rof2CorpseSlot, ServerSlot);
return ServerSlot;
}
static inline uint32 RoF2ToServerTypelessSlot(structs::TypelessInventorySlot_Struct rof2Slot, int16 rof2Type)
{
if (rof2Slot.AugIndex < invaug::SOCKET_INVALID || rof2Slot.AugIndex >= invaug::SOCKET_COUNT) {
Log(Logs::Detail, Logs::Netcode, "Convert RoF2 Typeless Slot [%i, %i, %i] (implied type: %i, unk1: %i) to Server Slot %i",
rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Type, rof2Slot.Unknown01, EQEmu::invslot::SLOT_INVALID);
return EQEmu::invslot::SLOT_INVALID;
}
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
uint32 TempSlot = invslot::SLOT_INVALID;
switch (rof2Type) {
case invtype::typePossessions: {
if (rof2Slot.Slot >= invslot::POSSESSIONS_BEGIN && rof2Slot.Slot <= invslot::POSSESSIONS_END) {
if (rof2Slot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = rof2Slot.Slot;
}
else if (rof2Slot.SubIndex >= invbag::SLOT_BEGIN && rof2Slot.SubIndex <= invbag::SLOT_END) {
if (rof2Slot.Slot < invslot::GENERAL_BEGIN)
return EQEmu::invslot::SLOT_INVALID;
TempSlot = (rof2Slot.Slot - invslot::GENERAL_BEGIN) * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::GENERAL_BAGS_BEGIN + TempSlot + rof2Slot.SubIndex;
}
}
break;
}
case invtype::typeBank: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::BANK_SIZE) {
if (rof2Slot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::BANK_BEGIN + rof2Slot.Slot;
}
else if (rof2Slot.SubIndex >= invbag::SLOT_BEGIN && rof2Slot.SubIndex <= invbag::SLOT_END) {
TempSlot = rof2Slot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::BANK_BAGS_BEGIN + TempSlot + rof2Slot.SubIndex;
}
}
break;
}
case invtype::typeSharedBank: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::SHARED_BANK_SIZE) {
if (rof2Slot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::SHARED_BANK_BEGIN + rof2Slot.Slot;
}
else if (rof2Slot.SubIndex >= invbag::SLOT_BEGIN && rof2Slot.SubIndex <= invbag::SLOT_END) {
TempSlot = rof2Slot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::SHARED_BANK_BAGS_BEGIN + TempSlot + rof2Slot.SubIndex;
}
}
break;
}
case invtype::typeTrade: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::TRADE_SIZE) {
if (rof2Slot.SubIndex == invbag::SLOT_INVALID) {
ServerSlot = EQEmu::invslot::TRADE_BEGIN + rof2Slot.Slot;
}
else if (rof2Slot.SubIndex >= invbag::SLOT_BEGIN && rof2Slot.SubIndex <= invbag::SLOT_END) {
TempSlot = rof2Slot.Slot * invbag::SLOT_COUNT;
ServerSlot = EQEmu::invbag::TRADE_BAGS_BEGIN + TempSlot + rof2Slot.SubIndex;
}
}
break;
}
case invtype::typeWorld: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::WORLD_SIZE) {
ServerSlot = EQEmu::invslot::SHARED_BANK_BEGIN + rof2Slot.Slot;
}
break;
}
case invtype::typeLimbo: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::LIMBO_SIZE) {
ServerSlot = EQEmu::invslot::slotCursor;
}
break;
}
case invtype::typeTribute: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::TRIBUTE_SIZE) {
ServerSlot = EQEmu::invslot::TRIBUTE_BEGIN + rof2Slot.Slot;
}
break;
}
case invtype::typeGuildTribute: {
if (rof2Slot.Slot >= invslot::SLOT_BEGIN && rof2Slot.Slot < invtype::GUILD_TRIBUTE_SIZE) {
ServerSlot = EQEmu::invslot::GUILD_TRIBUTE_BEGIN + rof2Slot.Slot;
}
break;
}
case invtype::typeCorpse: {
if (rof2Slot.Slot >= invslot::CORPSE_BEGIN && rof2Slot.Slot <= invslot::CORPSE_END) {
ServerSlot = rof2Slot.Slot;
}
break;
}
default: {
break;
}
}
Log(Logs::Detail, Logs::Netcode, "Convert RoF2 Typeless Slot [%i, %i, %i] (implied type: %i, unk1: %i) to Server Slot %i",
rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Type, rof2Slot.Unknown01, ServerSlot);
return ServerSlot;
}
static inline void ServerToRoF2SayLink(std::string& rof2SayLink, const std::string& serverSayLink)

View File

@ -400,7 +400,7 @@ namespace SoD
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, "SoD::ENCODE(OP_CharInventory) Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
last_pos = ob.tellp();
}
@ -464,7 +464,12 @@ namespace SoD
FINISH_ENCODE();
}
ENCODE(OP_DeleteCharge) { ENCODE_FORWARD(OP_MoveItem); }
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "SoD::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
ENCODE(OP_DeleteItem)
{
@ -1064,7 +1069,7 @@ namespace SoD
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, "SoD::ENCODE(OP_ItemPacket) Serialization failed on item slot %d.", int_struct->slot_id);
delete in;
return;
}
@ -1125,6 +1130,8 @@ namespace SoD
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoD::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
eq->slot_id = ServerToSoDCorpseSlot(emu->slot_id);
@ -1286,6 +1293,8 @@ namespace SoD
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoD::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToSoDSlot(emu->from_slot);
eq->to_slot = ServerToSoDSlot(emu->to_slot);
OUT(number_in_stack);
@ -1523,7 +1532,7 @@ namespace SoD
// 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
@ -1532,7 +1541,7 @@ namespace SoD
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
@ -1544,13 +1553,13 @@ namespace SoD
// 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;
@ -3139,6 +3148,8 @@ namespace SoD
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoD::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
emu->slot_id = SoDToServerCorpseSlot(eq->slot_id);
@ -3152,7 +3163,7 @@ namespace SoD
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::General, Logs::Netcode, "[SoD] Moved item from %u to %u", eq->from_slot, eq->to_slot);
Log(Logs::Moderate, Logs::Netcode, "SoD::DECODE(OP_MoveItem)");
emu->from_slot = SoDToServerSlot(eq->from_slot);
emu->to_slot = SoDToServerSlot(eq->to_slot);
@ -3473,7 +3484,7 @@ namespace SoD
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;
@ -3736,79 +3747,193 @@ namespace SoD
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 ServerToSoDSlot(uint32 serverSlot)
{
uint32 SoDSlot = 0;
uint32 SoDSlot = invslot::SLOT_INVALID;
if (serverSlot >= EQEmu::invslot::slotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
SoDSlot = serverSlot + 1;
else if (serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::invbag::CURSOR_BAG_END)
SoDSlot = serverSlot + 11;
else if (serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN && serverSlot <= EQEmu::invbag::BANK_BAGS_END)
SoDSlot = serverSlot + 1;
else if (serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN && serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END)
SoDSlot = serverSlot + 1;
else if (serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE)
SoDSlot = invslot::slotPowerSource;
else
if (serverSlot <= EQEmu::invslot::slotGeneral8) {
SoDSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::CORPSE_END && serverSlot >= EQEmu::invslot::slotCursor) {
SoDSlot = serverSlot - 2;
}
else if (serverSlot <= EQEmu::invbag::GENERAL_BAGS_8_END && serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
SoDSlot = serverSlot + 11;
}
else if (serverSlot <= EQEmu::invbag::CURSOR_BAG_END && serverSlot >= EQEmu::invbag::CURSOR_BAG_BEGIN) {
SoDSlot = serverSlot - 9;
}
else if (serverSlot <= EQEmu::invslot::TRIBUTE_END && serverSlot >= EQEmu::invslot::TRIBUTE_BEGIN) {
SoDSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::GUILD_TRIBUTE_END && serverSlot >= EQEmu::invslot::GUILD_TRIBUTE_BEGIN) {
SoDSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::BANK_END && serverSlot >= EQEmu::invslot::BANK_BEGIN) {
SoDSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::BANK_BAGS_END && serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN) {
SoDSlot = serverSlot + 1;
}
else if (serverSlot <= EQEmu::invslot::SHARED_BANK_END && serverSlot >= EQEmu::invslot::SHARED_BANK_BEGIN) {
SoDSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END && serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN) {
SoDSlot = serverSlot + 1;
}
else if (serverSlot <= EQEmu::invslot::TRADE_END && serverSlot >= EQEmu::invslot::TRADE_BEGIN) {
SoDSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::TRADE_BAGS_END && serverSlot >= EQEmu::invbag::TRADE_BAGS_BEGIN) {
SoDSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::WORLD_END && serverSlot >= EQEmu::invslot::WORLD_BEGIN) {
SoDSlot = serverSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Slot %i to SoD Slot %i", serverSlot, SoDSlot);
return SoDSlot;
}
static inline uint32 ServerToSoDCorpseSlot(uint32 serverCorpseSlot)
{
//uint32 SoDCorpse;
return (serverCorpseSlot + 1);
uint32 SoDSlot = invslot::SLOT_INVALID;
if (serverCorpseSlot <= EQEmu::invslot::slotGeneral8 && serverCorpseSlot >= EQEmu::invslot::slotGeneral1) {
SoDSlot = serverCorpseSlot;
}
else if (serverCorpseSlot <= EQEmu::invslot::CORPSE_END && serverCorpseSlot >= EQEmu::invslot::slotCursor) {
SoDSlot = serverCorpseSlot - 2;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to SoD Corpse Slot %i", serverCorpseSlot, SoDSlot);
return SoDSlot;
}
static inline uint32 SoDToServerSlot(uint32 sodSlot)
{
uint32 ServerSlot = 0;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (sodSlot >= invslot::slotAmmo && sodSlot <= invslot::CORPSE_END) // Cursor/Ammo/Power Source and Normal Inventory Slots
ServerSlot = sodSlot - 1;
else if (sodSlot >= invbag::GENERAL_BAGS_BEGIN && sodSlot <= invbag::CURSOR_BAG_END)
ServerSlot = sodSlot - 11;
else if (sodSlot >= invbag::BANK_BAGS_BEGIN && sodSlot <= invbag::BANK_BAGS_END)
ServerSlot = sodSlot - 1;
else if (sodSlot >= invbag::SHARED_BANK_BAGS_BEGIN && sodSlot <= invbag::SHARED_BANK_BAGS_END)
ServerSlot = sodSlot - 1;
else if (sodSlot == invslot::slotPowerSource)
ServerSlot = EQEmu::invslot::SLOT_POWER_SOURCE;
else
if (sodSlot <= invslot::slotGeneral8) {
ServerSlot = sodSlot;
}
else if (sodSlot <= invslot::CORPSE_END && sodSlot >= invslot::slotCursor) {
ServerSlot = sodSlot + 2;
}
else if (sodSlot <= invbag::GENERAL_BAGS_END && sodSlot >= invbag::GENERAL_BAGS_BEGIN) {
ServerSlot = sodSlot - 11;
}
else if (sodSlot <= invbag::CURSOR_BAG_END && sodSlot >= invbag::CURSOR_BAG_BEGIN) {
ServerSlot = sodSlot + 9;
}
else if (sodSlot <= invslot::TRIBUTE_END && sodSlot >= invslot::TRIBUTE_BEGIN) {
ServerSlot = sodSlot;
}
else if (sodSlot <= invslot::GUILD_TRIBUTE_END && sodSlot >= invslot::GUILD_TRIBUTE_BEGIN) {
ServerSlot = sodSlot;
}
else if (sodSlot <= invslot::BANK_END && sodSlot >= invslot::BANK_BEGIN) {
ServerSlot = sodSlot;
}
else if (sodSlot <= invbag::BANK_BAGS_END && sodSlot >= invbag::BANK_BAGS_BEGIN) {
ServerSlot = sodSlot - 1;
}
else if (sodSlot <= invslot::SHARED_BANK_END && sodSlot >= invslot::SHARED_BANK_BEGIN) {
ServerSlot = sodSlot;
}
else if (sodSlot <= invbag::SHARED_BANK_BAGS_END && sodSlot >= invbag::SHARED_BANK_BAGS_BEGIN) {
ServerSlot = sodSlot - 1;
}
else if (sodSlot <= invslot::TRADE_END && sodSlot >= invslot::TRADE_BEGIN) {
ServerSlot = sodSlot;
}
else if (sodSlot <= invbag::TRADE_BAGS_END && sodSlot >= invbag::TRADE_BAGS_BEGIN) {
ServerSlot = sodSlot;
}
else if (sodSlot <= invslot::WORLD_END && sodSlot >= invslot::WORLD_BEGIN) {
ServerSlot = sodSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert SoD Slot %i to Server Slot %i", sodSlot, ServerSlot);
return ServerSlot;
}
static inline uint32 SoDToServerCorpseSlot(uint32 sodCorpseSlot)
{
//uint32 ServerCorpse;
return (sodCorpseSlot - 1);
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (sodCorpseSlot <= invslot::slotGeneral8 && sodCorpseSlot >= invslot::slotGeneral1) {
ServerSlot = sodCorpseSlot;
}
else if (sodCorpseSlot <= invslot::CORPSE_END && sodCorpseSlot >= invslot::slotCursor) {
ServerSlot = sodCorpseSlot + 2;
}
Log(Logs::Detail, Logs::Netcode, "Convert SoD Corpse Slot %i to Server Corpse Slot %i", sodCorpseSlot, ServerSlot);
return ServerSlot;
}
static inline void ServerToSoDSayLink(std::string& sodSayLink, const std::string& serverSayLink)

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)

View File

@ -335,9 +335,9 @@ namespace Titanium
EQEmu::OutBuffer::pos_type last_pos = ob.tellp();
for (int r = 0; r < itemcount; r++, eq++) {
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0);
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, ServerToTitaniumSlot(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, "Titanium::ENCODE(OP_CharInventory) Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
last_pos = ob.tellp();
}
@ -367,7 +367,12 @@ namespace Titanium
FINISH_ENCODE();
}
ENCODE(OP_DeleteCharge) { ENCODE_FORWARD(OP_MoveItem); }
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "Titanium::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
ENCODE(OP_DeleteItem)
{
@ -772,21 +777,15 @@ namespace Titanium
OUT(TargetID);
OUT(playerid);
int r;
for (r = 0; r <= 20; r++) {
strn0cpy(eq->itemnames[r], emu->itemnames[r], sizeof(eq->itemnames[r]));
for (int i = EQEmu::invslot::slotCharm; i <= EQEmu::invslot::slotWaist; ++i) {
strn0cpy(eq->itemnames[i], emu->itemnames[i], sizeof(eq->itemnames[i]));
OUT(itemicons[i]);
}
// move arrow item down to last element in titanium array
strn0cpy(eq->itemnames[21], emu->itemnames[22], sizeof(eq->itemnames[21]));
// move ammo down to last element in titanium array
strn0cpy(eq->itemnames[invslot::slotAmmo], emu->itemnames[EQEmu::invslot::slotAmmo], sizeof(eq->itemnames[invslot::slotAmmo]));
eq->itemicons[invslot::slotAmmo] = emu->itemicons[EQEmu::invslot::slotAmmo];
int k;
for (k = 0; k <= 20; k++) {
OUT(itemicons[k]);
}
// move arrow icon down to last element in titanium array
eq->itemicons[21] = emu->itemicons[22];
strn0cpy(eq->text, emu->text, sizeof(eq->text));
FINISH_ENCODE();
@ -821,9 +820,9 @@ namespace Titanium
ob.write((const char*)__emu_buffer, 4);
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0);
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, ServerToTitaniumSlot(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, "Titanium::ENCODE(OP_ItemPacket) Serialization failed on item slot %d.", int_struct->slot_id);
delete in;
return;
}
@ -874,6 +873,8 @@ namespace Titanium
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "Titanium::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
eq->slot_id = ServerToTitaniumCorpseSlot(emu->slot_id);
@ -903,6 +904,8 @@ namespace Titanium
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "Titanium::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToTitaniumSlot(emu->from_slot);
eq->to_slot = ServerToTitaniumSlot(emu->to_slot);
OUT(number_in_stack);
@ -1050,7 +1053,7 @@ namespace Titanium
// 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
@ -1059,7 +1062,7 @@ namespace Titanium
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
@ -1071,13 +1074,13 @@ namespace Titanium
// 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;
@ -1936,23 +1939,18 @@ namespace Titanium
IN(TargetID);
IN(playerid);
int r;
for (r = 0; r <= 20; r++) {
strn0cpy(emu->itemnames[r], eq->itemnames[r], sizeof(emu->itemnames[r]));
for (int i = invslot::slotCharm; i <= invslot::slotWaist; ++i) {
strn0cpy(emu->itemnames[i], eq->itemnames[i], sizeof(emu->itemnames[i]));
IN(itemicons[i]);
}
// move arrow item up to last element in server array
strn0cpy(emu->itemnames[21], "", sizeof(emu->itemnames[21]));
strn0cpy(emu->itemnames[22], eq->itemnames[21], sizeof(emu->itemnames[22]));
// move ammo up to last element in server array
strn0cpy(emu->itemnames[EQEmu::invslot::slotAmmo], eq->itemnames[invslot::slotAmmo], sizeof(emu->itemnames[EQEmu::invslot::slotAmmo]));
emu->itemicons[EQEmu::invslot::slotAmmo] = eq->itemicons[invslot::slotAmmo];
int k;
for (k = 0; k <= 20; k++) {
IN(itemicons[k]);
}
// move arrow icon up to last element in server array
emu->itemicons[21] = 0xFFFFFFFF;
emu->itemicons[22] = eq->itemicons[21];
// nullify power source element in server array
strn0cpy(emu->itemnames[EQEmu::invslot::slotPowerSource], "", sizeof(emu->itemnames[EQEmu::invslot::slotPowerSource]));
emu->itemicons[EQEmu::invslot::slotPowerSource] = 0xFFFFFFFF;
strn0cpy(emu->text, eq->text, sizeof(emu->text));
@ -2020,6 +2018,8 @@ namespace Titanium
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "Titanium::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
emu->slot_id = TitaniumToServerCorpseSlot(eq->slot_id);
@ -2033,7 +2033,7 @@ namespace Titanium
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::General, Logs::Netcode, "[Titanium] Moved item from %u to %u", eq->from_slot, eq->to_slot);
Log(Logs::Moderate, Logs::Netcode, "Titanium::DECODE(OP_MoveItem)");
emu->from_slot = TitaniumToServerSlot(eq->from_slot);
emu->to_slot = TitaniumToServerSlot(eq->to_slot);
@ -2259,7 +2259,7 @@ namespace Titanium
ob << '|' << itoa(item->NoRent);
ob << '|' << itoa(item->NoDrop);
ob << '|' << itoa(item->Size);
ob << '|' << itoa(item->Slots);
ob << '|' << itoa(Catch22(SwapBits21And22(item->Slots)));
ob << '|' << itoa(item->Price);
ob << '|' << itoa(item->Icon);
ob << '|' << "0";
@ -2464,32 +2464,190 @@ namespace Titanium
static inline int16 ServerToTitaniumSlot(uint32 serverSlot)
{
//int16 TitaniumSlot;
if (serverSlot == INVALID_INDEX)
return INVALID_INDEX;
int16 TitaniumSlot = invslot::SLOT_INVALID;
return serverSlot; // deprecated
if (serverSlot <= EQEmu::invslot::slotWaist) {
TitaniumSlot = serverSlot;
}
else if (serverSlot == EQEmu::invslot::slotAmmo) {
TitaniumSlot = serverSlot - 1;
}
else if (serverSlot <= EQEmu::invslot::slotGeneral8 && serverSlot >= EQEmu::invslot::slotGeneral1) {
TitaniumSlot = serverSlot - 1;
}
else if (serverSlot <= (EQEmu::invslot::POSSESSIONS_COUNT + EQEmu::invslot::slotWaist) && serverSlot >= EQEmu::invslot::slotCursor) {
TitaniumSlot = serverSlot - 3;
}
else if (serverSlot == (EQEmu::invslot::POSSESSIONS_COUNT + EQEmu::invslot::slotAmmo)) {
TitaniumSlot = serverSlot - 4;
}
else if (serverSlot <= EQEmu::invbag::GENERAL_BAGS_8_END && serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::CURSOR_BAG_END && serverSlot >= EQEmu::invbag::CURSOR_BAG_BEGIN) {
TitaniumSlot = serverSlot - 20;
}
else if (serverSlot <= EQEmu::invslot::TRIBUTE_END && serverSlot >= EQEmu::invslot::TRIBUTE_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::GUILD_TRIBUTE_END && serverSlot >= EQEmu::invslot::GUILD_TRIBUTE_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::BANK_END && serverSlot >= EQEmu::invslot::BANK_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::BANK_BAGS_16_END && serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::SHARED_BANK_END && serverSlot >= EQEmu::invslot::SHARED_BANK_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END && serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::TRADE_END && serverSlot >= EQEmu::invslot::TRADE_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::TRADE_BAGS_END && serverSlot >= EQEmu::invbag::TRADE_BAGS_BEGIN) {
TitaniumSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::WORLD_END && serverSlot >= EQEmu::invslot::WORLD_BEGIN) {
TitaniumSlot = serverSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Slot %i to Titanium Slot %i", serverSlot, TitaniumSlot);
return TitaniumSlot;
}
static inline int16 ServerToTitaniumCorpseSlot(uint32 serverCorpseSlot)
{
//int16 TitaniumCorpse;
return serverCorpseSlot;
int16 TitaniumSlot = invslot::SLOT_INVALID;
if (serverCorpseSlot <= EQEmu::invslot::slotGeneral8 && serverCorpseSlot >= EQEmu::invslot::slotGeneral1) {
TitaniumSlot = serverCorpseSlot - 1;
}
else if (serverCorpseSlot <= (EQEmu::invslot::POSSESSIONS_COUNT + EQEmu::invslot::slotWaist) && serverCorpseSlot >= EQEmu::invslot::slotCursor) {
TitaniumSlot = serverCorpseSlot - 3;
}
else if (serverCorpseSlot == (EQEmu::invslot::POSSESSIONS_COUNT + EQEmu::invslot::slotAmmo)) {
TitaniumSlot = serverCorpseSlot - 4;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to Titanium Corpse Slot %i", serverCorpseSlot, TitaniumSlot);
return TitaniumSlot;
}
static inline uint32 TitaniumToServerSlot(int16 titaniumSlot)
{
//uint32 ServerSlot;
if (titaniumSlot == INVALID_INDEX)
return INVALID_INDEX;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
return titaniumSlot; // deprecated
if (titaniumSlot <= invslot::slotWaist) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot == invslot::slotAmmo) {
ServerSlot = titaniumSlot + 1;
}
else if (titaniumSlot <= invslot::slotGeneral8 && titaniumSlot >= invslot::slotGeneral1) {
ServerSlot = titaniumSlot + 1;
}
else if (titaniumSlot <= (invslot::POSSESSIONS_COUNT + invslot::slotWaist) && titaniumSlot >= invslot::slotCursor) {
ServerSlot = titaniumSlot + 3;
}
else if (titaniumSlot == (invslot::POSSESSIONS_COUNT + invslot::slotAmmo)) {
ServerSlot = titaniumSlot + 4;
}
else if (titaniumSlot <= invbag::GENERAL_BAGS_END && titaniumSlot >= invbag::GENERAL_BAGS_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invbag::CURSOR_BAG_END && titaniumSlot >= invbag::CURSOR_BAG_BEGIN) {
ServerSlot = titaniumSlot + 20;
}
else if (titaniumSlot <= invslot::TRIBUTE_END && titaniumSlot >= invslot::TRIBUTE_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invslot::GUILD_TRIBUTE_END && titaniumSlot >= invslot::GUILD_TRIBUTE_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invslot::BANK_END && titaniumSlot >= invslot::BANK_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invbag::BANK_BAGS_END && titaniumSlot >= invbag::BANK_BAGS_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invslot::SHARED_BANK_END && titaniumSlot >= invslot::SHARED_BANK_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invbag::SHARED_BANK_BAGS_END && titaniumSlot >= invbag::SHARED_BANK_BAGS_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invslot::TRADE_END && titaniumSlot >= invslot::TRADE_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invbag::TRADE_BAGS_END && titaniumSlot >= invbag::TRADE_BAGS_BEGIN) {
ServerSlot = titaniumSlot;
}
else if (titaniumSlot <= invslot::WORLD_END && titaniumSlot >= invslot::WORLD_BEGIN) {
ServerSlot = titaniumSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert Titanium Slot %i to Server Slot %i", titaniumSlot, ServerSlot);
return ServerSlot;
}
static inline uint32 TitaniumToServerCorpseSlot(int16 titaniumCorpseSlot)
{
//uint32 ServerCorpse;
return titaniumCorpseSlot;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (titaniumCorpseSlot <= invslot::slotGeneral8 && titaniumCorpseSlot >= invslot::slotGeneral1) {
ServerSlot = titaniumCorpseSlot + 1;
}
else if (titaniumCorpseSlot <= (invslot::POSSESSIONS_COUNT + invslot::slotWaist) && titaniumCorpseSlot >= invslot::slotCursor) {
ServerSlot = titaniumCorpseSlot + 3;
}
else if (titaniumCorpseSlot == (invslot::POSSESSIONS_COUNT + invslot::slotAmmo)) {
ServerSlot = titaniumCorpseSlot + 4;
}
Log(Logs::Detail, Logs::Netcode, "Convert Titanium Corpse Slot %i to Server Corpse Slot %i", titaniumCorpseSlot, ServerSlot);
return ServerSlot;
}
static inline void ServerToTitaniumSayLink(std::string& titaniumSayLink, const std::string& serverSayLink)

View File

@ -520,7 +520,7 @@ namespace UF
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, "UF::ENCODE(OP_CharInventory) Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
last_pos = ob.tellp();
}
@ -584,7 +584,12 @@ namespace UF
FINISH_ENCODE();
}
ENCODE(OP_DeleteCharge) { ENCODE_FORWARD(OP_MoveItem); }
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "UF::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
ENCODE(OP_DeleteItem)
{
@ -1272,7 +1277,7 @@ namespace UF
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, "UF::ENCODE(OP_ItemPacket) Serialization failed on item slot %d.", int_struct->slot_id);
delete in;
return;
}
@ -1345,6 +1350,8 @@ namespace UF
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "UF::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
eq->slot_id = ServerToUFCorpseSlot(emu->slot_id);
@ -1510,6 +1517,8 @@ namespace UF
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "UF::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToUFSlot(emu->from_slot);
eq->to_slot = ServerToUFSlot(emu->to_slot);
OUT(number_in_stack);
@ -1769,7 +1778,7 @@ namespace UF
// 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
@ -1778,7 +1787,7 @@ namespace UF
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
@ -1790,13 +1799,13 @@ namespace UF
// 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;
@ -3496,6 +3505,8 @@ namespace UF
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "UF::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
emu->slot_id = UFToServerCorpseSlot(eq->slot_id);
@ -3509,7 +3520,7 @@ namespace UF
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::General, Logs::Netcode, "[UF] Moved item from %u to %u", eq->from_slot, eq->to_slot);
Log(Logs::Moderate, Logs::Netcode, "UF::DECODE(OP_MoveItem)");
emu->from_slot = UFToServerSlot(eq->from_slot);
emu->to_slot = UFToServerSlot(eq->to_slot);
@ -3810,7 +3821,7 @@ namespace UF
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;
@ -4096,81 +4107,193 @@ namespace UF
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 ServerToUFSlot(uint32 serverSlot)
{
uint32 UnderfootSlot = 0;
uint32 UFSlot = invslot::SLOT_INVALID;
if (serverSlot >= EQEmu::invslot::slotAmmo && serverSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
UnderfootSlot = serverSlot + 1;
else if (serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN && serverSlot <= EQEmu::invbag::CURSOR_BAG_END)
UnderfootSlot = serverSlot + 11;
else if (serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN && serverSlot <= EQEmu::invbag::BANK_BAGS_END)
UnderfootSlot = serverSlot + 1;
else if (serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN && serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END)
UnderfootSlot = serverSlot + 1;
else if (serverSlot == EQEmu::invslot::SLOT_POWER_SOURCE)
UnderfootSlot = invslot::slotPowerSource;
else
UnderfootSlot = serverSlot;
if (serverSlot <= EQEmu::invslot::slotGeneral8) {
UFSlot = serverSlot;
}
return UnderfootSlot;
else if (serverSlot <= EQEmu::invslot::CORPSE_END && serverSlot >= EQEmu::invslot::slotCursor) {
UFSlot = serverSlot - 2;
}
else if (serverSlot <= EQEmu::invbag::GENERAL_BAGS_8_END && serverSlot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
UFSlot = serverSlot + 11;
}
else if (serverSlot <= EQEmu::invbag::CURSOR_BAG_END && serverSlot >= EQEmu::invbag::CURSOR_BAG_BEGIN) {
UFSlot = serverSlot - 9;
}
else if (serverSlot <= EQEmu::invslot::TRIBUTE_END && serverSlot >= EQEmu::invslot::TRIBUTE_BEGIN) {
UFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::GUILD_TRIBUTE_END && serverSlot >= EQEmu::invslot::GUILD_TRIBUTE_BEGIN) {
UFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::BANK_END && serverSlot >= EQEmu::invslot::BANK_BEGIN) {
UFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::BANK_BAGS_END && serverSlot >= EQEmu::invbag::BANK_BAGS_BEGIN) {
UFSlot = serverSlot + 1;
}
else if (serverSlot <= EQEmu::invslot::SHARED_BANK_END && serverSlot >= EQEmu::invslot::SHARED_BANK_BEGIN) {
UFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::SHARED_BANK_BAGS_END && serverSlot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN) {
UFSlot = serverSlot + 1;
}
else if (serverSlot <= EQEmu::invslot::TRADE_END && serverSlot >= EQEmu::invslot::TRADE_BEGIN) {
UFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invbag::TRADE_BAGS_END && serverSlot >= EQEmu::invbag::TRADE_BAGS_BEGIN) {
UFSlot = serverSlot;
}
else if (serverSlot <= EQEmu::invslot::WORLD_END && serverSlot >= EQEmu::invslot::WORLD_BEGIN) {
UFSlot = serverSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Slot %i to UF Slot %i", serverSlot, UFSlot);
return UFSlot;
}
static inline uint32 ServerToUFCorpseSlot(uint32 serverCorpseSlot)
{
//uint32 UnderfootCorpse;
return (serverCorpseSlot + 1);
uint32 UFSlot = invslot::SLOT_INVALID;
if (serverCorpseSlot <= EQEmu::invslot::slotGeneral8 && serverCorpseSlot >= EQEmu::invslot::slotGeneral1) {
UFSlot = serverCorpseSlot;
}
else if (serverCorpseSlot <= EQEmu::invslot::CORPSE_END && serverCorpseSlot >= EQEmu::invslot::slotCursor) {
UFSlot = serverCorpseSlot - 2;
}
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to UF Corpse Slot %i", serverCorpseSlot, UFSlot);
return UFSlot;
}
static inline uint32 UFToServerSlot(uint32 ufSlot)
{
uint32 ServerSlot = 0;
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (ufSlot >= invslot::slotAmmo && ufSlot <= invslot::CORPSE_END) // Cursor/Ammo/Power Source and Normal Inventory Slots
ServerSlot = ufSlot - 1;
else if (ufSlot >= invbag::GENERAL_BAGS_BEGIN && ufSlot <= invbag::CURSOR_BAG_END)
ServerSlot = ufSlot - 11;
else if (ufSlot >= invbag::BANK_BAGS_BEGIN && ufSlot <= invbag::BANK_BAGS_END)
ServerSlot = ufSlot - 1;
else if (ufSlot >= invbag::SHARED_BANK_BAGS_BEGIN && ufSlot <= invbag::SHARED_BANK_BAGS_END)
ServerSlot = ufSlot - 1;
else if (ufSlot == invslot::slotPowerSource)
ServerSlot = EQEmu::invslot::SLOT_POWER_SOURCE;
else
if (ufSlot <= invslot::slotGeneral8) {
ServerSlot = ufSlot;
}
else if (ufSlot <= invslot::CORPSE_END && ufSlot >= invslot::slotCursor) {
ServerSlot = ufSlot + 2;
}
else if (ufSlot <= invbag::GENERAL_BAGS_END && ufSlot >= invbag::GENERAL_BAGS_BEGIN) {
ServerSlot = ufSlot - 11;
}
else if (ufSlot <= invbag::CURSOR_BAG_END && ufSlot >= invbag::CURSOR_BAG_BEGIN) {
ServerSlot = ufSlot + 9;
}
else if (ufSlot <= invslot::TRIBUTE_END && ufSlot >= invslot::TRIBUTE_BEGIN) {
ServerSlot = ufSlot;
}
else if (ufSlot <= invslot::GUILD_TRIBUTE_END && ufSlot >= invslot::GUILD_TRIBUTE_BEGIN) {
ServerSlot = ufSlot;
}
else if (ufSlot <= invslot::BANK_END && ufSlot >= invslot::BANK_BEGIN) {
ServerSlot = ufSlot;
}
else if (ufSlot <= invbag::BANK_BAGS_END && ufSlot >= invbag::BANK_BAGS_BEGIN) {
ServerSlot = ufSlot - 1;
}
else if (ufSlot <= invslot::SHARED_BANK_END && ufSlot >= invslot::SHARED_BANK_BEGIN) {
ServerSlot = ufSlot;
}
else if (ufSlot <= invbag::SHARED_BANK_BAGS_END && ufSlot >= invbag::SHARED_BANK_BAGS_BEGIN) {
ServerSlot = ufSlot - 1;
}
else if (ufSlot <= invslot::TRADE_END && ufSlot >= invslot::TRADE_BEGIN) {
ServerSlot = ufSlot;
}
else if (ufSlot <= invbag::TRADE_BAGS_END && ufSlot >= invbag::TRADE_BAGS_BEGIN) {
ServerSlot = ufSlot;
}
else if (ufSlot <= invslot::WORLD_END && ufSlot >= invslot::WORLD_BEGIN) {
ServerSlot = ufSlot;
}
Log(Logs::Detail, Logs::Netcode, "Convert UF Slot %i to Server Slot %i", ufSlot, ServerSlot);
return ServerSlot;
}
static inline uint32 UFToServerCorpseSlot(uint32 ufCorpseSlot)
{
//uint32 ServerCorpse;
return (ufCorpseSlot - 1);
uint32 ServerSlot = EQEmu::invslot::SLOT_INVALID;
if (ufCorpseSlot <= invslot::slotGeneral8 && ufCorpseSlot >= invslot::slotGeneral1) {
ServerSlot = ufCorpseSlot;
}
else if (ufCorpseSlot <= invslot::CORPSE_END && ufCorpseSlot >= invslot::slotCursor) {
ServerSlot = ufCorpseSlot + 2;
}
Log(Logs::Detail, Logs::Netcode, "Convert UF Corpse Slot %i to Server Corpse Slot %i", ufCorpseSlot, ServerSlot);
return ServerSlot;
}
static inline void ServerToUFSayLink(std::string& ufSayLink, const std::string& serverSayLink)

View File

@ -547,9 +547,12 @@ bool SharedDatabase::GetSharedBank(uint32 id, EQEmu::InventoryProfile *inv, bool
return true;
}
// Overloaded: Retrieve character inventory based on character id
// Overloaded: Retrieve character inventory based on character id (zone entry)
bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv)
{
if (!char_id || !inv)
return false;
// Retrieve character inventory
std::string query =
StringFormat("SELECT slotid, itemid, charges, color, augslot1, augslot2, augslot3, augslot4, augslot5, "
@ -566,8 +569,40 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv)
auto timestamps = GetItemRecastTimestamps(char_id);
auto cv_conflict = false;
auto pmask = inv->GetLookup()->PossessionsBitmask;
auto bank_size = inv->GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank];
for (auto row = results.begin(); row != results.end(); ++row) {
int16 slot_id = atoi(row[0]);
if (slot_id <= EQEmu::invslot::POSSESSIONS_END && slot_id >= EQEmu::invslot::POSSESSIONS_BEGIN) { // Titanium thru UF check
if ((((uint64)1 << slot_id) & pmask) == 0) {
cv_conflict = true;
continue;
}
}
else if (slot_id <= EQEmu::invbag::GENERAL_BAGS_END && slot_id >= EQEmu::invbag::GENERAL_BAGS_BEGIN) { // Titanium thru UF check
auto parent_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_id - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << parent_slot) & pmask) == 0) {
cv_conflict = true;
continue;
}
}
else if (slot_id <= EQEmu::invslot::BANK_END && slot_id >= EQEmu::invslot::BANK_BEGIN) { // Titanium check
if ((slot_id - EQEmu::invslot::BANK_BEGIN) >= bank_size) {
cv_conflict = true;
continue;
}
}
else if (slot_id <= EQEmu::invbag::BANK_BAGS_END && slot_id >= EQEmu::invbag::BANK_BAGS_BEGIN) { // Titanium check
auto parent_index = ((slot_id - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if (parent_index < EQEmu::invslot::SLOT_BEGIN || parent_index >= bank_size) {
cv_conflict = true;
continue;
}
}
uint32 item_id = atoi(row[1]);
uint16 charges = atoi(row[2]);
uint32 color = atoul(row[3]);
@ -633,10 +668,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv)
inst->SetOrnamentationIDFile(ornament_idfile);
inst->SetOrnamentHeroModel(item->HerosForgeModel);
if (instnodrop ||
(((slot_id >= EQEmu::invslot::EQUIPMENT_BEGIN && slot_id <= EQEmu::invslot::EQUIPMENT_END) ||
slot_id == EQEmu::invslot::SLOT_POWER_SOURCE) &&
inst->GetItem()->Attuneable))
if (instnodrop || (inst->GetItem()->Attuneable && slot_id >= EQEmu::invslot::EQUIPMENT_BEGIN && slot_id <= EQEmu::invslot::EQUIPMENT_END))
inst->SetAttuned(true);
if (color > 0)
@ -684,13 +716,22 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv)
char_id, item_id, slot_id);
}
}
if (cv_conflict) {
char char_name[64] = "";
GetCharName(char_id, char_name);
Log(Logs::General, Logs::Client_Login,
"ClientVersion conflict during inventory load at zone entry for '%s' (charid: %u, inver: %s)",
char_name, char_id, EQEmu::versions::MobVersionName(inv->InventoryVersion())
); // this can be changed to moderate after live testing
}
// Retrieve shared inventory
return GetSharedBank(char_id, inv, true);
}
// Overloaded: Retrieve character inventory based on account_id and character name
bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQEmu::InventoryProfile *inv)
// Overloaded: Retrieve character inventory based on account_id and character name (char select)
bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQEmu::InventoryProfile *inv) // deprecated
{
// Retrieve character inventory
std::string query =

View File

@ -89,7 +89,7 @@ class SharedDatabase : public Database
int32 GetSharedPlatinum(uint32 account_id);
bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add);
bool GetInventory(uint32 char_id, EQEmu::InventoryProfile* inv);
bool GetInventory(uint32 account_id, char* name, EQEmu::InventoryProfile* inv);
bool GetInventory(uint32 account_id, char* name, EQEmu::InventoryProfile* inv); // deprecated
std::map<uint32, uint32> GetItemRecastTimestamps(uint32 char_id);
uint32 GetItemRecastTimestamp(uint32 char_id, uint32 recast_type);
void ClearOldRecastTimestamps(uint32 char_id);

View File

@ -30,9 +30,9 @@
Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/
#define CURRENT_BINARY_DATABASE_VERSION 9125
#define CURRENT_BINARY_DATABASE_VERSION 9127
#ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9019
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9020
#else
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 0 // must be 0
#endif

View File

@ -1,4 +1,5 @@
command_settings
inventory_version
launcher
rule_sets
rule_values

View File

@ -379,6 +379,8 @@
9123|2018_07_07_data_buckets.sql|SHOW TABLES LIKE 'data_buckets'|empty|
9124|2018_07_09_tasks.sql|SHOW COLUMNS FROM `tasks` LIKE 'type'|empty|
9125|2018_07_20_task_emote.sql|SHOW COLUMNS FROM `tasks` LIKE 'completion_emote'|empty|
9126|2018_08_13_inventory_version_update.sql|SHOW COLUMNS FROM `inventory_version` LIKE 'bot_step'|empty|
9127|2018_08_13_inventory_update.sql|SELECT * FROM `inventory_version` WHERE `version` = 2 and `step` = 0|not_empty|
# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not

View File

@ -18,6 +18,7 @@
9017|2017_03_26_bots_spells_id_fix_for_saved_shadowknight_bots.sql|SELECT * FROM `bot_data` WHERE `class` = '5' AND `spells_id` = '3004'|not_empty|
9018|2018_02_02_Bot_Spells_Min_Max_HP.sql|SHOW COLUMNS FROM `bot_spells_entries` LIKE 'min_hp'|empty|
9019|2018_04_12_bots_stop_melee_level.sql|SHOW COLUMNS FROM `bot_data` LIKE 'stop_melee_level'|empty|
9020|2018_08_13_bots_inventory_update.sql|SELECT * FROM `inventory_version` WHERE `version` = 2 and `bot_step` = 0|not_empty|
# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not

View File

@ -0,0 +1,5 @@
-- update `bot_inventories` slots
UPDATE `bot_inventories` SET `slot_id` = 22 WHERE `slot_id` = 21; -- adjust ammo slot
UPDATE `bot_inventories` SET `slot_id` = 21 WHERE `slot_id` = 9999; -- adjust powersource slot
UPDATE `inventory_version` SET `bot_step` = 1 WHERE `version` = 2;

View File

@ -0,0 +1,45 @@
-- update equipable slots in `items` table
SELECT 'pre-transform count..',
(SELECT COUNT(id) FROM `items` WHERE `slots` & (3 << 21)) total,
(SELECT COUNT(id) FROM `items` WHERE `slots` & (1 << 21)) bit21,
(SELECT COUNT(id) FROM `items` WHERE `slots` & (1 << 22)) bit22;
UPDATE `items` SET `slots` = (`slots` ^ (3 << 21)) WHERE (`slots` & (3 << 21)) IN ((1 << 21), (1 << 22)); -- transform
SELECT 'post-transform count..',
(SELECT COUNT(id) FROM `items` WHERE `slots` & (3 << 21)) total,
(SELECT COUNT(id) FROM `items` WHERE `slots` & (1 << 21)) bit21,
(SELECT COUNT(id) FROM `items` WHERE `slots` & (1 << 22)) bit22;
-- update `inventory` slots
UPDATE `inventory` SET `slotid` = 33 WHERE `slotid` = 30; -- adjust cursor
UPDATE `inventory` SET `slotid` = (`slotid` + 20) WHERE `slotid` >= 331 AND `slotid` <= 340; -- adjust cursor bags
UPDATE `inventory` SET `slotid` = (`slotid` + 1) WHERE `slotid` >= 22 AND `slotid` <= 29; -- adjust general slots
-- current general bags remain the same
UPDATE `inventory` SET `slotid` = 22 WHERE `slotid` = 21; -- adjust ammo slot
UPDATE `inventory` SET `slotid` = 21 WHERE `slotid` = 9999; -- adjust powersource slot
-- update `inventory_snapshots` slots
UPDATE `inventory_snapshots` SET `slotid` = 33 WHERE `slotid` = 30; -- adjust cursor
UPDATE `inventory_snapshots` SET `slotid` = (`slotid` + 20) WHERE `slotid` >= 331 AND `slotid` <= 340; -- adjust cursor bags
UPDATE `inventory_snapshots` SET `slotid` = (`slotid` + 1) WHERE `slotid` >= 22 AND `slotid` <= 29; -- adjust general slots
-- current general bags remain the same
UPDATE `inventory_snapshots` SET `slotid` = 22 WHERE `slotid` = 21; -- adjust ammo slot
UPDATE `inventory_snapshots` SET `slotid` = 21 WHERE `slotid` = 9999; -- adjust powersource slot
-- update `character_corpse_items` slots
UPDATE `character_corpse_items` SET `equip_slot` = 33 WHERE `equip_slot` = 30; -- adjust cursor
UPDATE `character_corpse_items` SET `equip_slot` = (`equip_slot` + 20) WHERE `equip_slot` >= 331 AND `equip_slot` <= 340; -- adjust cursor bags
UPDATE `character_corpse_items` SET `equip_slot` = (`equip_slot` + 1) WHERE `equip_slot` >= 22 AND `equip_slot` <= 29; -- adjust general slots
-- current general bags remain the same
UPDATE `character_corpse_items` SET `equip_slot` = 22 WHERE `equip_slot` = 21; -- adjust ammo slot
UPDATE `character_corpse_items` SET `equip_slot` = 21 WHERE `equip_slot` = 9999; -- adjust powersource slot
-- update `character_pet_inventory` slots
UPDATE `character_pet_inventory` SET `slot` = 22 WHERE `slot` = 21; -- adjust ammo slot
UPDATE `inventory_version` SET `step` = 1 WHERE `version` = 2;

View File

@ -0,0 +1 @@
ALTER TABLE `inventory_version` ADD COLUMN `bot_step` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `step`;

View File

@ -252,7 +252,7 @@ void Client::SendMembership() {
mc->entries[1] = 0xffffffff; // Max Level Restriction
mc->entries[2] = 0xffffffff; // Max Char Slots per Account (not used by client?)
mc->entries[3] = 0xffffffff; // 1 for Silver
mc->entries[4] = 8; // Main Inventory Size (0xffffffff on Live for Gold, but limiting to 8 until 10 is supported)
mc->entries[4] = 0xffffffff; // Main Inventory Size (0xffffffff on Live for Gold, but limiting to 8 until 10 is supported)
mc->entries[5] = 0xffffffff; // Max Platinum per level
mc->entries[6] = 1; // 0 for Silver
mc->entries[7] = 1; // 0 for Silver
@ -1442,6 +1442,7 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
PlayerProfile_Struct pp;
ExtendedProfile_Struct ext;
EQEmu::InventoryProfile inv;
inv.SetInventoryVersion(EQEmu::versions::ConvertClientVersionBitToClientVersion(m_ClientVersionBit));
time_t bday = time(nullptr);
char startzone[50]={0};
uint32 i;

View File

@ -97,6 +97,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 accountID, EQApplicationPacket **ou
CharacterSelectEntry_Struct *cse = (CharacterSelectEntry_Struct *)buff_ptr;
PlayerProfile_Struct pp;
EQEmu::InventoryProfile inv;
inv.SetInventoryVersion(client_version);
uint32 character_id = (uint32)atoi(row[0]);
uint8 has_home = 0;
uint8 has_bind = 0;
@ -243,7 +244,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 accountID, EQApplicationPacket **ou
/* Load Inventory */
// If we ensure that the material data is updated appropriately, we can do away with inventory loads
if (GetInventory(accountID, cse->Name, &inv)) {
if (GetCharSelInventory(accountID, cse->Name, &inv)) {
const EQEmu::ItemData* item = nullptr;
const EQEmu::ItemInstance* inst = nullptr;
int16 invslot = 0;
@ -590,3 +591,143 @@ bool WorldDatabase::LoadCharacterCreateCombos()
return true;
}
// this is a slightly modified version of SharedDatabase::GetInventory(...) for character select use-only
bool WorldDatabase::GetCharSelInventory(uint32 account_id, char *name, EQEmu::InventoryProfile *inv)
{
if (!account_id || !name || !inv)
return false;
std::string query = StringFormat(
"SELECT"
" slotid,"
" itemid,"
" charges,"
" color,"
" augslot1,"
" augslot2,"
" augslot3,"
" augslot4,"
" augslot5,"
" augslot6,"
" instnodrop,"
" custom_data,"
" ornamenticon,"
" ornamentidfile,"
" ornament_hero_model "
"FROM"
" inventory "
"INNER JOIN"
" character_data ch "
"ON"
" ch.id = charid "
"WHERE"
" ch.name = '%s' "
"AND"
" ch.account_id = %i "
"AND"
" slotid >= %i "
"AND"
" slotid <= %i",
name,
account_id,
EQEmu::invslot::slotHead,
EQEmu::invslot::slotFeet
);
auto results = QueryDatabase(query);
if (!results.Success())
return false;
for (auto row = results.begin(); row != results.end(); ++row) {
int16 slot_id = atoi(row[0]);
switch (slot_id) {
case EQEmu::invslot::slotFace:
case EQEmu::invslot::slotEar2:
case EQEmu::invslot::slotNeck:
case EQEmu::invslot::slotShoulders:
case EQEmu::invslot::slotBack:
case EQEmu::invslot::slotFinger1:
case EQEmu::invslot::slotFinger2:
continue;
default:
break;
}
uint32 item_id = atoi(row[1]);
int8 charges = atoi(row[2]);
uint32 color = atoul(row[3]);
uint32 aug[EQEmu::invaug::SOCKET_COUNT];
aug[0] = (uint32)atoi(row[4]);
aug[1] = (uint32)atoi(row[5]);
aug[2] = (uint32)atoi(row[6]);
aug[3] = (uint32)atoi(row[7]);
aug[4] = (uint32)atoi(row[8]);
aug[5] = (uint32)atoi(row[9]);
bool instnodrop = ((row[10] && (uint16)atoi(row[10])) ? true : false);
uint32 ornament_icon = (uint32)atoul(row[12]);
uint32 ornament_idfile = (uint32)atoul(row[13]);
uint32 ornament_hero_model = (uint32)atoul(row[14]);
const EQEmu::ItemData *item = GetItem(item_id);
if (!item)
continue;
EQEmu::ItemInstance *inst = CreateBaseItem(item, charges);
if (inst == nullptr)
continue;
inst->SetAttuned(instnodrop);
if (row[11]) {
std::string data_str(row[11]);
std::string idAsString;
std::string value;
bool use_id = true;
for (int i = 0; i < data_str.length(); ++i) {
if (data_str[i] == '^') {
if (!use_id) {
inst->SetCustomData(idAsString, value);
idAsString.clear();
value.clear();
}
use_id = !use_id;
continue;
}
char v = data_str[i];
if (use_id)
idAsString.push_back(v);
else
value.push_back(v);
}
}
inst->SetOrnamentIcon(ornament_icon);
inst->SetOrnamentationIDFile(ornament_idfile);
inst->SetOrnamentHeroModel(item->HerosForgeModel);
if (color > 0)
inst->SetColor(color);
inst->SetCharges(charges);
if (item->IsClassCommon()) {
for (int i = EQEmu::invaug::SOCKET_BEGIN; i <= EQEmu::invaug::SOCKET_END; i++) {
if (aug[i])
inst->PutAugment(this, i, aug[i]);
}
}
inv->PutItem(slot_id, *inst);
safe_delete(inst);
}
return true;
}

View File

@ -41,6 +41,8 @@ public:
private:
void SetTitaniumDefaultStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc);
void SetSoFDefaultStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc);
bool GetCharSelInventory(uint32 account_id, char* name, EQEmu::InventoryProfile* inv);
};
extern WorldDatabase database;

View File

@ -179,14 +179,6 @@ void Client::CalcItemBonuses(StatBonuses* newbon) {
SetTwoHanderEquipped(true);
}
//Power Source Slot
if (ClientVersion() >= EQEmu::versions::ClientVersion::SoF)
{
const EQEmu::ItemInstance* inst = m_inv[EQEmu::invslot::SLOT_POWER_SOURCE];
if(inst)
AddItemBonuses(inst, newbon);
}
//tribute items
for (i = EQEmu::invslot::TRIBUTE_BEGIN; i <= EQEmu::invslot::TRIBUTE_END; i++) {
const EQEmu::ItemInstance* inst = m_inv[i];
@ -3261,7 +3253,7 @@ void NPC::CalcItemBonuses(StatBonuses *newbon)
{
if(newbon){
for (int i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= EQEmu::invslot::EQUIPMENT_END; i++){
for (int i = EQEmu::invslot::BONUS_BEGIN; i <= EQEmu::invslot::BONUS_STAT_END; i++){
const EQEmu::ItemData *cur = database.GetItem(equipment[i]);
if(cur){
//basic stats
@ -3353,13 +3345,6 @@ void Client::CalcItemScale() {
if (CalcItemScale(EQEmu::invslot::TRIBUTE_BEGIN, EQEmu::invslot::TRIBUTE_END)) // (< 405)
changed = true;
//Power Source Slot
if (ClientVersion() >= EQEmu::versions::ClientVersion::SoF)
{
if (CalcItemScale(EQEmu::invslot::SLOT_POWER_SOURCE, EQEmu::invslot::SLOT_POWER_SOURCE))
changed = true;
}
if(changed)
{
CalcBonuses();
@ -3447,13 +3432,6 @@ void Client::DoItemEnterZone() {
if (DoItemEnterZone(EQEmu::invslot::TRIBUTE_BEGIN, EQEmu::invslot::TRIBUTE_END)) // (< 405)
changed = true;
//Power Source Slot
if (ClientVersion() >= EQEmu::versions::ClientVersion::SoF)
{
if (DoItemEnterZone(EQEmu::invslot::SLOT_POWER_SOURCE, EQEmu::invslot::SLOT_POWER_SOURCE))
changed = true;
}
if(changed)
{
CalcBonuses();
@ -3486,7 +3464,7 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) {
uint16 oldexp = inst->GetExp();
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, inst, nullptr, "", 0);
if (i <= EQEmu::invslot::slotAmmo || i == EQEmu::invslot::SLOT_POWER_SOURCE) {
if (i <= EQEmu::invslot::EQUIPMENT_END) {
parse->EventItem(EVENT_EQUIP_ITEM, this, inst, nullptr, "", i);
}
@ -3496,7 +3474,7 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) {
update_slot = true;
}
} else {
if (i <= EQEmu::invslot::slotAmmo || i == EQEmu::invslot::SLOT_POWER_SOURCE) {
if (i <= EQEmu::invslot::EQUIPMENT_END) {
parse->EventItem(EVENT_EQUIP_ITEM, this, inst, nullptr, "", i);
}

View File

@ -38,6 +38,8 @@ Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, nullptr, glm
this->_botOwnerCharacterID = 0;
}
m_inv.SetInventoryVersion(EQEmu::versions::MobVersion::Bot);
_guildRank = 0;
_guildId = 0;
_lastTotalPlayTime = 0;
@ -109,6 +111,8 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
auto bot_owner = GetBotOwner();
m_inv.SetInventoryVersion(EQEmu::versions::MobVersion::Bot);
_guildRank = 0;
_guildId = 0;
_lastTotalPlayTime = totalPlayTime;
@ -3658,15 +3662,13 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli
ClientReturn(const ItemInstance* item, int16 from, const char* name = "") : returnItemInstance(item), fromBotSlot(from), toClientSlot(invslot::SLOT_INVALID), adjustStackSize(0), failedItemName(name) { }
};
static const int16 proxyPowerSource = 22;
static const int16 bot_equip_order[(invslot::CORPSE_BEGIN + 1)] = {
static const int16 bot_equip_order[invslot::EQUIPMENT_COUNT] = {
invslot::slotCharm, invslot::slotEar1, invslot::slotHead, invslot::slotFace,
invslot::slotEar2, invslot::slotNeck, invslot::slotShoulders, invslot::slotArms,
invslot::slotBack, invslot::slotWrist1, invslot::slotWrist2, invslot::slotRange,
invslot::slotHands, invslot::slotPrimary, invslot::slotSecondary, invslot::slotFinger1,
invslot::slotFinger2, invslot::slotChest, invslot::slotLegs, invslot::slotFeet,
invslot::slotWaist, invslot::slotAmmo, proxyPowerSource // invslot::SLOT_POWER_SOURCE
invslot::slotWaist, invslot::slotPowerSource, invslot::slotAmmo
};
enum { stageStackable = 0, stageEmpty, stageReplaceable };
@ -3802,9 +3804,7 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli
//}
if (stage_loop != stageReplaceable) {
if ((index == proxyPowerSource) && m_inv[invslot::SLOT_POWER_SOURCE])
continue;
else if (m_inv[index])
if (m_inv[index])
continue;
}
@ -3853,18 +3853,10 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli
}
}
if (index == proxyPowerSource) {
trade_iterator.toBotSlot = invslot::SLOT_POWER_SOURCE;
trade_iterator.toBotSlot = index;
if (m_inv[invslot::SLOT_POWER_SOURCE])
client_return.push_back(ClientReturn(m_inv[invslot::SLOT_POWER_SOURCE], invslot::SLOT_POWER_SOURCE));
}
else {
trade_iterator.toBotSlot = index;
if (m_inv[index])
client_return.push_back(ClientReturn(m_inv[index], index));
}
if (m_inv[index])
client_return.push_back(ClientReturn(m_inv[index], index));
break;
}
@ -4649,6 +4641,7 @@ int32 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) {
int32 focus_max = 0;
int32 focus_max_real = 0;
//item focus
// are focus effects the same as bonus? (slotAmmo-excluded)
for (int x = EQEmu::invslot::EQUIPMENT_BEGIN; x <= EQEmu::invslot::EQUIPMENT_END; x++) {
TempItem = nullptr;
EQEmu::ItemInstance* ins = GetBotItem(x);
@ -7604,10 +7597,7 @@ void Bot::ProcessBotInspectionRequest(Bot* inspectedBot, Client* client) {
const EQEmu::ItemData* item = nullptr;
const EQEmu::ItemInstance* inst = nullptr;
// Modded to display power source items (will only show up on SoF+ client inspect windows though.)
// I don't think bots are currently coded to use them..but, you'll have to use '#bot inventory list'
// to see them on a Titanium client when/if they are activated.
for (int16 L = EQEmu::invslot::EQUIPMENT_BEGIN; L <= EQEmu::invslot::slotWaist; L++) {
for (int16 L = EQEmu::invslot::EQUIPMENT_BEGIN; L <= EQEmu::invslot::EQUIPMENT_END; L++) {
inst = inspectedBot->GetBotItem(L);
if(inst) {
@ -7616,33 +7606,15 @@ void Bot::ProcessBotInspectionRequest(Bot* inspectedBot, Client* client) {
strcpy(insr->itemnames[L], item->Name);
insr->itemicons[L] = item->Icon;
}
else
else {
insr->itemnames[L][0] = '\0';
insr->itemicons[L] = 0xFFFFFFFF;
}
}
}
inst = inspectedBot->GetBotItem(EQEmu::invslot::SLOT_POWER_SOURCE);
if(inst) {
item = inst->GetItem();
if(item) {
strcpy(insr->itemnames[SoF::invslot::slotPowerSource], item->Name);
insr->itemicons[SoF::invslot::slotPowerSource] = item->Icon;
else {
insr->itemnames[L][0] = '\0';
insr->itemicons[L] = 0xFFFFFFFF;
}
else
insr->itemicons[SoF::invslot::slotPowerSource] = 0xFFFFFFFF;
}
inst = inspectedBot->GetBotItem(EQEmu::invslot::slotAmmo);
if(inst) {
item = inst->GetItem();
if(item) {
strcpy(insr->itemnames[SoF::invslot::slotAmmo], item->Name);
insr->itemicons[SoF::invslot::slotAmmo] = item->Icon;
}
else
insr->itemicons[SoF::invslot::slotAmmo] = 0xFFFFFFFF;
}
strcpy(insr->text, inspectedBot->GetInspectMessage().text);
@ -7655,8 +7627,8 @@ void Bot::CalcItemBonuses(StatBonuses* newbon)
{
const EQEmu::ItemData* itemtmp = nullptr;
for (int i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= (EQEmu::invslot::EQUIPMENT_END + 1); ++i) {
const EQEmu::ItemInstance* item = GetBotItem((i == 22 ? 9999 : i));
for (int i = EQEmu::invslot::BONUS_BEGIN; i <= EQEmu::invslot::BONUS_STAT_END; ++i) {
const EQEmu::ItemInstance* item = GetBotItem(i);
if(item) {
AddItemBonuses(item, newbon);
}

View File

@ -80,33 +80,33 @@ static const std::string bot_stance_name[BOT_STANCE_COUNT] = {
static const char* GetBotStanceName(int stance_id) { return bot_stance_name[VALIDBOTSTANCE(stance_id)].c_str(); }
#define VALIDBOTEQUIPSLOT(x) ((x >= EQEmu::invslot::EQUIPMENT_BEGIN && x <= EQEmu::invslot::EQUIPMENT_END) ? (x) : ((x == EQEmu::invslot::SLOT_POWER_SOURCE) ? (22) : (23)))
#define VALIDBOTEQUIPSLOT(x) ((x >= EQEmu::invslot::EQUIPMENT_BEGIN && x <= EQEmu::invslot::EQUIPMENT_END) ? (x) : (EQEmu::invslot::EQUIPMENT_COUNT))
static std::string bot_equip_slot_name[EQEmu::invslot::EQUIPMENT_COUNT + 2] =
static const std::string bot_equip_slot_name[EQEmu::invslot::EQUIPMENT_COUNT + 1] =
{
"Charm", // MainCharm
"Left Ear", // MainEar1
"Head", // MainHead
"Face", // MainFace
"Right Ear", // MainEar2
"Neck", // MainNeck
"Shoulders", // MainShoulders
"Arms", // MainArms
"Back", // MainBack
"Left Wrist", // MainWrist1
"Right Wrist", // MainWrist2
"Range", // MainRange
"Hands", // MainHands
"Primary Hand", // MainPrimary
"Secondary Hand", // MainSecondary
"Left Finger", // MainFinger1
"Right Finger", // MainFinger2
"Chest", // MainChest
"Legs", // MainLegs
"Feet", // MainFeet
"Waist", // MainWaist
"Ammo", // MainAmmo
"Power Source", // 22 (MainPowerSource = 9999)
"Charm", // slotCharm
"Ear 1", // slotEar1
"Head", // slotHead
"Face", // slotFace
"Ear 2", // slotEar2
"Neck", // slotNeck
"Shoulders", // slotShoulders
"Arms", // slotArms
"Back", // slotBack
"Wrist 1", // slotWrist1
"Wrist 2", // slotWrist2
"Range", // slotRange
"Hands", // slotHands
"Primary", // slotPrimary
"Secondary", // slotSecondary
"Finger 1", // slotFinger1
"Finger 2", // slotFinger2
"Chest", // slotChest
"Legs", // slotLegs
"Feet", // slotFeet
"Waist", // slotWaist
"Power Source", // slotPowerSource
"Ammo", // slotAmmo
"Unknown"
};

View File

@ -7194,13 +7194,13 @@ void bot_subcommand_inventory_list(Client *c, const Seperator *sep)
linker.SetLinkType(EQEmu::saylink::SayLinkItemInst);
uint32 inventory_count = 0;
for (int i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= (EQEmu::invslot::EQUIPMENT_END + 1); ++i) {
for (int i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= EQEmu::invslot::EQUIPMENT_END; ++i) {
if ((i == EQEmu::invslot::slotSecondary) && is2Hweapon)
continue;
inst = my_bot->CastToBot()->GetBotItem(i == 22 ? EQEmu::invslot::SLOT_POWER_SOURCE : i);
inst = my_bot->CastToBot()->GetBotItem(i);
if (!inst || !inst->GetItem()) {
c->Message(m_message, "I need something for my %s (slot %i)", GetBotEquipSlotName(i), (i == 22 ? EQEmu::invslot::SLOT_POWER_SOURCE : i));
c->Message(m_message, "I need something for my %s (slot %i)", GetBotEquipSlotName(i), i);
continue;
}
@ -7210,7 +7210,7 @@ void bot_subcommand_inventory_list(Client *c, const Seperator *sep)
}
linker.SetItemInst(inst);
c->Message(m_message, "Using %s in my %s (slot %i)", linker.GenerateLink().c_str(), GetBotEquipSlotName(i), (i == 22 ? EQEmu::invslot::SLOT_POWER_SOURCE : i));
c->Message(m_message, "Using %s in my %s (slot %i)", linker.GenerateLink().c_str(), GetBotEquipSlotName(i), i);
++inventory_count;
}
@ -7249,8 +7249,8 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
}
int slotId = atoi(sep->arg[1]);
if (!sep->IsNumber(1) || ((slotId > EQEmu::invslot::EQUIPMENT_END || slotId < EQEmu::invslot::EQUIPMENT_BEGIN) && slotId != EQEmu::invslot::SLOT_POWER_SOURCE)) {
c->Message(m_fail, "Valid slots are 0-21 or 9999");
if (!sep->IsNumber(1) || (slotId > EQEmu::invslot::EQUIPMENT_END || slotId < EQEmu::invslot::EQUIPMENT_BEGIN)) {
c->Message(m_fail, "Valid slots are 0-22");
return;
}
@ -7311,7 +7311,7 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
case EQEmu::invslot::slotFinger2:
case EQEmu::invslot::slotChest:
case EQEmu::invslot::slotWaist:
case EQEmu::invslot::SLOT_POWER_SOURCE:
case EQEmu::invslot::slotPowerSource:
case EQEmu::invslot::slotAmmo:
c->Message(m_message, "My %s is %s unequipped", GetBotEquipSlotName(slotId), ((itm) ? ("now") : ("already")));
break;
@ -7356,14 +7356,14 @@ void bot_subcommand_inventory_window(Client *c, const Seperator *sep)
//EQEmu::SayLinkEngine linker;
//linker.SetLinkType(EQEmu::saylink::SayLinkItemInst);
for (int i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= (EQEmu::invslot::EQUIPMENT_END + 1); ++i) {
for (int i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= EQEmu::invslot::EQUIPMENT_END; ++i) {
const EQEmu::ItemData* item = nullptr;
const EQEmu::ItemInstance* inst = my_bot->CastToBot()->GetBotItem(i == 22 ? EQEmu::invslot::SLOT_POWER_SOURCE : i);
const EQEmu::ItemInstance* inst = my_bot->CastToBot()->GetBotItem(i);
if (inst)
item = inst->GetItem();
window_text.append("<c \"#FFFFFF\">");
window_text.append(GetBotEquipSlotName(i == 22 ? EQEmu::invslot::SLOT_POWER_SOURCE : i));
window_text.append(GetBotEquipSlotName(i));
window_text.append(": ");
if (item) {
//window_text.append("</c>");

View File

@ -1138,7 +1138,7 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQEmu::InventoryProfile& invent
for (auto row = results.begin(); row != results.end(); ++row) {
int16 slot_id = atoi(row[0]);
if ((slot_id < EQEmu::invslot::EQUIPMENT_BEGIN || slot_id > EQEmu::invslot::EQUIPMENT_END) && slot_id != EQEmu::invslot::SLOT_POWER_SOURCE)
if (slot_id < EQEmu::invslot::EQUIPMENT_BEGIN || slot_id > EQEmu::invslot::EQUIPMENT_END)
continue;
uint32 item_id = atoi(row[1]);
@ -1173,7 +1173,7 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQEmu::InventoryProfile& invent
if (item_inst->GetItem()->Attuneable) {
if (atoi(row[4]))
item_inst->SetAttuned(true);
else if (((slot_id >= EQEmu::invslot::EQUIPMENT_BEGIN) && (slot_id <= EQEmu::invslot::EQUIPMENT_END) || slot_id == EQEmu::invslot::SLOT_POWER_SOURCE))
else if (slot_id >= EQEmu::invslot::EQUIPMENT_BEGIN && slot_id <= EQEmu::invslot::EQUIPMENT_END)
item_inst->SetAttuned(true);
}
@ -1241,7 +1241,7 @@ bool BotDatabase::LoadItemBySlot(Bot* bot_inst)
bool BotDatabase::LoadItemBySlot(const uint32 bot_id, const uint32 slot_id, uint32& item_id)
{
if (!bot_id || (slot_id > EQEmu::invslot::EQUIPMENT_END && slot_id != EQEmu::invslot::SLOT_POWER_SOURCE))
if (!bot_id || slot_id > EQEmu::invslot::EQUIPMENT_END)
return false;
query = StringFormat("SELECT `item_id` FROM `bot_inventories` WHERE `bot_id` = '%i' AND `slot_id` = '%i' LIMIT 1", bot_id, slot_id);
@ -1259,7 +1259,7 @@ bool BotDatabase::LoadItemBySlot(const uint32 bot_id, const uint32 slot_id, uint
bool BotDatabase::SaveItemBySlot(Bot* bot_inst, const uint32 slot_id, const EQEmu::ItemInstance* item_inst)
{
if (!bot_inst || !bot_inst->GetBotID() || (slot_id > EQEmu::invslot::EQUIPMENT_END && slot_id != EQEmu::invslot::SLOT_POWER_SOURCE))
if (!bot_inst || !bot_inst->GetBotID() || slot_id > EQEmu::invslot::EQUIPMENT_END)
return false;
if (!DeleteItemBySlot(bot_inst->GetBotID(), slot_id))
@ -1343,7 +1343,7 @@ bool BotDatabase::SaveItemBySlot(Bot* bot_inst, const uint32 slot_id, const EQEm
bool BotDatabase::DeleteItemBySlot(const uint32 bot_id, const uint32 slot_id)
{
if (!bot_id || (slot_id > EQEmu::invslot::EQUIPMENT_END && slot_id != EQEmu::invslot::SLOT_POWER_SOURCE))
if (!bot_id || slot_id > EQEmu::invslot::EQUIPMENT_END)
return false;
query = StringFormat("DELETE FROM `bot_inventories` WHERE `bot_id` = '%u' AND `slot_id` = '%u'", bot_id, slot_id);
@ -1382,7 +1382,7 @@ bool BotDatabase::SaveEquipmentColor(const uint32 bot_id, const int16 slot_id, c
return false;
bool all_flag = (slot_id == -2);
if ((slot_id < EQEmu::invslot::EQUIPMENT_BEGIN || slot_id > EQEmu::invslot::EQUIPMENT_END) && slot_id != EQEmu::invslot::SLOT_POWER_SOURCE && !all_flag)
if ((slot_id < EQEmu::invslot::EQUIPMENT_BEGIN || slot_id > EQEmu::invslot::EQUIPMENT_END) && !all_flag)
return false;
std::string where_clause;
@ -1659,7 +1659,7 @@ bool BotDatabase::LoadPetItems(const uint32 bot_id, uint32* pet_items)
return true;
int item_index = EQEmu::invslot::EQUIPMENT_BEGIN;
for (auto row = results.begin(); row != results.end() && item_index <= EQEmu::invslot::EQUIPMENT_END; ++row) {
for (auto row = results.begin(); row != results.end() && (item_index >= EQEmu::invslot::EQUIPMENT_BEGIN && item_index <= EQEmu::invslot::EQUIPMENT_END); ++row) {
pet_items[item_index] = atoi(row[0]);
++item_index;
}
@ -1683,7 +1683,7 @@ bool BotDatabase::SavePetItems(const uint32 bot_id, const uint32* pet_items, boo
if (!saved_pet_index)
return true;
for (int item_index = EQEmu::invslot::SLOT_BEGIN; item_index <= EQEmu::invslot::EQUIPMENT_END; ++item_index) {
for (int item_index = EQEmu::invslot::EQUIPMENT_BEGIN; item_index <= EQEmu::invslot::EQUIPMENT_END; ++item_index) {
if (!pet_items[item_index])
continue;

View File

@ -1905,7 +1905,7 @@ void Client::CheckManaEndUpdate() {
else if (group) {
group->SendEndurancePacketFrom(this);
}
auto endurance_packet = new EQApplicationPacket(OP_EnduranceUpdate, sizeof(EnduranceUpdate_Struct));
EnduranceUpdate_Struct* endurance_update = (EnduranceUpdate_Struct*)endurance_packet->pBuffer;
endurance_update->cur_end = GetEndurance();
@ -6004,56 +6004,34 @@ void Client::ProcessInspectRequest(Client* requestee, Client* requester) {
const EQEmu::ItemData* item = nullptr;
const EQEmu::ItemInstance* inst = nullptr;
int ornamentationAugtype = RuleI(Character, OrnamentationAugmentType);
for(int16 L = 0; L <= 20; L++) {
for(int16 L = EQEmu::invslot::EQUIPMENT_BEGIN; L <= EQEmu::invslot::EQUIPMENT_END; L++) {
inst = requestee->GetInv().GetItem(L);
if(inst) {
item = inst->GetItem();
if(item) {
strcpy(insr->itemnames[L], item->Name);
if (inst && inst->GetOrnamentationAug(ornamentationAugtype))
{
const EQEmu::ItemData *aug_item = inst->GetOrnamentationAug(ornamentationAugtype)->GetItem();
const EQEmu::ItemData *aug_item = nullptr;
if (inst->GetOrnamentationAug(ornamentationAugtype))
inst->GetOrnamentationAug(ornamentationAugtype)->GetItem();
if (aug_item)
insr->itemicons[L] = aug_item->Icon;
}
else if (inst && inst->GetOrnamentationIcon())
{
else if (inst->GetOrnamentationIcon())
insr->itemicons[L] = inst->GetOrnamentationIcon();
}
else
{
insr->itemicons[L] = item->Icon;
}
}
else
else {
insr->itemnames[L][0] = '\0';
insr->itemicons[L] = 0xFFFFFFFF;
}
}
}
inst = requestee->GetInv().GetItem(EQEmu::invslot::SLOT_POWER_SOURCE);
if(inst) {
item = inst->GetItem();
if(item) {
// we shouldn't do this..but, that's the way it's coded atm...
// (this type of action should be handled exclusively in the client translator)
strcpy(insr->itemnames[SoF::invslot::slotPowerSource], item->Name);
insr->itemicons[SoF::invslot::slotPowerSource] = item->Icon;
else {
insr->itemnames[L][0] = '\0';
insr->itemicons[L] = 0xFFFFFFFF;
}
else
insr->itemicons[SoF::invslot::slotPowerSource] = 0xFFFFFFFF;
}
inst = requestee->GetInv().GetItem(EQEmu::invslot::slotAmmo);
if(inst) {
item = inst->GetItem();
if(item) {
strcpy(insr->itemnames[SoF::invslot::slotAmmo], item->Name);
insr->itemicons[SoF::invslot::slotAmmo] = item->Icon;
}
else
insr->itemicons[SoF::invslot::slotAmmo] = 0xFFFFFFFF;
}
strcpy(insr->text, requestee->GetInspectMessage().text);
@ -8406,13 +8384,8 @@ void Client::TickItemCheck()
if(zone->tick_items.empty()) { return; }
//Scan equip slots for items
for (i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= EQEmu::invslot::EQUIPMENT_END; i++)
{
TryItemTick(i);
}
//Scan main inventory + cursor
for (i = EQEmu::invslot::GENERAL_BEGIN; i <= EQEmu::invslot::slotCursor; i++)
//Scan equip, general, cursor slots for items
for (i = EQEmu::invslot::POSSESSIONS_BEGIN; i <= EQEmu::invslot::POSSESSIONS_END; i++)
{
TryItemTick(i);
}
@ -8464,16 +8437,10 @@ void Client::TryItemTick(int slot)
void Client::ItemTimerCheck()
{
int i;
for (i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= EQEmu::invslot::EQUIPMENT_END; i++)
for (i = EQEmu::invslot::POSSESSIONS_BEGIN; i <= EQEmu::invslot::POSSESSIONS_END; i++)
{
TryItemTimer(i);
}
for (i = EQEmu::invslot::GENERAL_BEGIN; i <= EQEmu::invslot::slotCursor; i++)
{
TryItemTimer(i);
}
for (i = EQEmu::invbag::GENERAL_BAGS_BEGIN; i <= EQEmu::invbag::CURSOR_BAG_END; i++)
{
TryItemTimer(i);

View File

@ -3002,8 +3002,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
bool deleteItems = false;
if (ClientVersion() >= EQEmu::versions::ClientVersion::RoF)
{
if ((in_augment->container_slot < 0 || in_augment->container_slot >= EQEmu::invslot::slotCursor) &&
in_augment->container_slot != EQEmu::invslot::SLOT_POWER_SOURCE &&
if ((in_augment->container_slot < EQEmu::invslot::EQUIPMENT_BEGIN || in_augment->container_slot > EQEmu::invslot::GENERAL_END) &&
(in_augment->container_slot < EQEmu::invbag::GENERAL_BAGS_BEGIN || in_augment->container_slot > EQEmu::invbag::GENERAL_BAGS_END))
{
Message(13, "The server does not allow augmentation actions from this slot.");
@ -8239,7 +8238,7 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app)
const EQEmu::ItemData* item = nullptr;
int ornamentationAugtype = RuleI(Character, OrnamentationAugmentType);
for (int16 L = EQEmu::invslot::EQUIPMENT_BEGIN; L <= EQEmu::invslot::slotWaist; L++) {
for (int16 L = EQEmu::invslot::EQUIPMENT_BEGIN; L <= EQEmu::invslot::EQUIPMENT_END; L++) {
const EQEmu::ItemInstance* inst = GetInv().GetItem(L);
item = inst ? inst->GetItem() : nullptr;
@ -8259,16 +8258,6 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app)
else { insr->itemicons[L] = 0xFFFFFFFF; }
}
const EQEmu::ItemInstance* inst = GetInv().GetItem(EQEmu::invslot::slotAmmo);
item = inst ? inst->GetItem() : nullptr;
if (item) {
// another one..I did these, didn't I!!?
strcpy(insr->itemnames[SoF::invslot::slotAmmo], item->Name);
insr->itemicons[SoF::invslot::slotAmmo] = item->Icon;
}
else { insr->itemicons[SoF::invslot::slotAmmo] = 0xFFFFFFFF; }
InspectMessage_Struct* newmessage = (InspectMessage_Struct*)insr->text;
InspectMessage_Struct& playermessage = this->GetInspectMessage();
memcpy(&playermessage, newmessage, sizeof(InspectMessage_Struct));

View File

@ -815,19 +815,6 @@ void Client::BulkSendInventoryItems()
last_pos = ob.tellp();
}
// PowerSource item
if (ClientVersion() >= EQEmu::versions::ClientVersion::SoF) {
const EQEmu::ItemInstance* inst = m_inv[EQEmu::invslot::SLOT_POWER_SOURCE];
if (inst) {
inst->Serialize(ob, EQEmu::invslot::SLOT_POWER_SOURCE);
if (ob.tellp() == last_pos)
Log(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", EQEmu::invslot::SLOT_POWER_SOURCE);
last_pos = ob.tellp();
}
}
// Bank items
for (int16 slot_id = EQEmu::invslot::BANK_BEGIN; slot_id <= EQEmu::invslot::BANK_END; slot_id++) {
const EQEmu::ItemInstance* inst = m_inv[slot_id];

View File

@ -2768,52 +2768,6 @@ void command_peekinv(Client *c, const Seperator *sep)
}
}
if ((scopeBit & peekEquip) && (targetClient->ClientVersion() >= EQEmu::versions::ClientVersion::SoF)) {
inst_main = targetClient->GetInv().GetItem(EQEmu::invslot::SLOT_POWER_SOURCE);
if (inst_main) {
itemsFound = true;
item_data = inst_main->GetItem();
}
else {
item_data = nullptr;
}
linker.SetItemInst(inst_main);
c->Message(
(item_data == nullptr),
"%sSlot: %i, Item: %i (%s), Charges: %i",
scope_prefix[scopeIndex],
EQEmu::invslot::SLOT_POWER_SOURCE,
((item_data == nullptr) ? 0 : item_data->ID),
linker.GenerateLink().c_str(),
((inst_main == nullptr) ? 0 : inst_main->GetCharges())
);
if (inst_main && inst_main->IsClassCommon()) {
for (uint8 indexAug = EQEmu::invaug::SOCKET_BEGIN; indexAug <= EQEmu::invaug::SOCKET_END; ++indexAug) {
inst_aug = inst_main->GetItem(indexAug);
if (!inst_aug) // extant only
continue;
item_data = inst_aug->GetItem();
linker.SetItemInst(inst_aug);
c->Message(
(item_data == nullptr),
".%sAugSlot: %i (Slot #%i, Aug idx #%i), Item: %i (%s), Charges: %i",
scope_prefix[scopeIndex],
INVALID_INDEX,
EQEmu::invslot::SLOT_POWER_SOURCE,
indexAug,
((item_data == nullptr) ? 0 : item_data->ID),
linker.GenerateLink().c_str(),
((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())
);
}
}
}
if (scopeBit & peekLimbo) {
int limboIndex = 0;
for (auto it = targetClient->GetInv().cursor_cbegin(); (it != targetClient->GetInv().cursor_cend()); ++it, ++limboIndex) {
@ -3324,7 +3278,7 @@ void command_listpetition(Client *c, const Seperator *sep)
void command_equipitem(Client *c, const Seperator *sep)
{
uint32 slot_id = atoi(sep->arg[1]);
if (sep->IsNumber(1) && ((slot_id >= EQEmu::invslot::EQUIPMENT_BEGIN) && (slot_id <= EQEmu::invslot::EQUIPMENT_END) || (slot_id == EQEmu::invslot::SLOT_POWER_SOURCE))) {
if (sep->IsNumber(1) && (slot_id >= EQEmu::invslot::EQUIPMENT_BEGIN && slot_id <= EQEmu::invslot::EQUIPMENT_END)) {
const EQEmu::ItemInstance* from_inst = c->GetInv().GetItem(EQEmu::invslot::slotCursor);
const EQEmu::ItemInstance* to_inst = c->GetInv().GetItem(slot_id); // added (desync issue when forcing stack to stack)
bool partialmove = false;

View File

@ -263,6 +263,17 @@ enum class LootResponse : uint8 {
LootAll = 6 // SoD+
};
enum class LootRequestType : uint8 {
Forbidden = 0,
GMPeek,
GMAllowed,
Self,
AllowedPVE,
AllowedPVPAll,
AllowedPVPSingle, // can make this 'AllowedPVPVariable' and allow values between 1 and EQEmu::invtype::POSSESSIONS_SIZE
AllowedPVPDefined,
};
//this is our internal representation of the BUFF struct, can put whatever we want in it
struct Buffs_Struct {
uint16 spellid;

View File

@ -202,6 +202,8 @@ Corpse::Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NP
UpdateEquipmentLight();
UpdateActiveLight();
loot_request_type = LootRequestType::Forbidden;
}
Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
@ -322,15 +324,11 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
// to go into the regular slots on the player, out of bags
std::list<uint32> removed_list;
// ideally, we would start at invslot::slotGeneral1 and progress to invslot::slotCursor..
// ..then regress and process invslot::EQUIPMENT_BEGIN through invslot::EQUIPMENT_END...
// without additional work to database loading of player corpses, this order is not
// currently preserved and a re-work of this processing loop is not warranted.
for (i = EQEmu::invslot::POSSESSIONS_BEGIN; i <= EQEmu::invslot::POSSESSIONS_END; ++i) {
if (i == EQEmu::invslot::slotAmmo && client->ClientVersion() >= EQEmu::versions::ClientVersion::SoF) {
item = client->GetInv().GetItem(EQEmu::invslot::SLOT_POWER_SOURCE);
if (item != nullptr) {
if (!client->IsBecomeNPC() || (client->IsBecomeNPC() && !item->GetItem()->NoRent))
MoveItemToCorpse(client, item, EQEmu::invslot::SLOT_POWER_SOURCE, removed_list);
}
}
item = client->GetInv().GetItem(i);
if (item == nullptr) { continue; }
@ -340,25 +338,25 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
database.TransactionBegin();
// I have an untested process that avoids this snarl up when all possessions inventory is removed..but this isn't broke
// this should not be modified to include the entire range of invtype::TYPE_POSSESSIONS slots by default..
// ..due to the possibility of 'hidden' items from client version bias..or, possibly, soul-bound items (WoW?)
if (!removed_list.empty()) {
std::stringstream ss("");
ss << "DELETE FROM inventory WHERE charid=" << client->CharacterID();
ss << " AND (";
std::list<uint32>::const_iterator iter = removed_list.begin();
bool first = true;
while (iter != removed_list.end()) {
if (first) {
first = false;
}
else {
ss << " OR ";
}
ss << "slotid=" << (*iter);
if (iter != removed_list.end()) {
std::stringstream ss("");
ss << "DELETE FROM `inventory` WHERE `charid` = " << client->CharacterID();
ss << " AND `slotid` IN (" << (*iter);
++iter;
while (iter != removed_list.end()) {
ss << ", " << (*iter);
++iter;
}
ss << ")";
database.QueryDatabase(ss.str().c_str());
}
ss << ")";
database.QueryDatabase(ss.str().c_str());
}
auto start = client->GetInv().cursor_cbegin();
@ -382,6 +380,8 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
UpdateEquipmentLight();
UpdateActiveLight();
loot_request_type = LootRequestType::Forbidden;
IsRezzed(false);
Save();
}
@ -524,6 +524,8 @@ EQEmu::TintProfile(),
UpdateEquipmentLight();
UpdateActiveLight();
loot_request_type = LootRequestType::Forbidden;
}
Corpse::~Corpse() {
@ -873,13 +875,16 @@ void Corpse::AllowPlayerLoot(Mob *them, uint8 slot) {
}
void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* app) {
if (!client)
return;
// Added 12/08. Started compressing loot struct on live.
if(player_corpse_depop) {
SendLootReqErrorPacket(client, LootResponse::SomeoneElse);
return;
}
if(IsPlayerCorpse() && corpse_db_id == 0) {
if(IsPlayerCorpse() && !corpse_db_id) { // really should try to resave in this case
// SendLootReqErrorPacket(client, 0);
client->Message(13, "Warning: Corpse's dbid = 0! Corpse will not survive zone shutdown!");
std::cout << "Error: PlayerCorpse::MakeLootRequestPackets: dbid = 0!" << std::endl;
@ -892,165 +897,195 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a
return;
}
if(being_looted_by == 0)
if(!being_looted_by || (being_looted_by != 0xFFFFFFFF && !entity_list.GetID(being_looted_by)))
being_looted_by = 0xFFFFFFFF;
if(this->being_looted_by != 0xFFFFFFFF) {
// lets double check....
Entity* looter = entity_list.GetID(this->being_looted_by);
if(looter == nullptr)
this->being_looted_by = 0xFFFFFFFF;
}
uint8 Loot_Request_Type = 1;
bool loot_coin = false;
std::string tmp;
if(database.GetVariable("LootCoin", tmp))
loot_coin = tmp[0] == 1 && tmp[1] == '\0';
if (DistanceSquaredNoZ(client->GetPosition(), m_Position) > 625) {
SendLootReqErrorPacket(client, LootResponse::TooFar);
// not sure if we need to send the packet back in this case? Didn't before!
// Will just return for now
return;
}
else if (this->being_looted_by != 0xFFFFFFFF && this->being_looted_by != client->GetID()) {
if (being_looted_by != 0xFFFFFFFF && being_looted_by != client->GetID()) {
SendLootReqErrorPacket(client, LootResponse::SomeoneElse);
Loot_Request_Type = 0;
}
else if (IsPlayerCorpse() && char_id == client->CharacterID()) {
Loot_Request_Type = 2;
}
else if ((IsNPCCorpse() || become_npc) && CanPlayerLoot(client->CharacterID())) {
Loot_Request_Type = 2;
}
else if (GetPlayerKillItem() == -1 && CanPlayerLoot(client->CharacterID())) { /* PVP loot all items, variable cash */
Loot_Request_Type = 3;
}
else if (GetPlayerKillItem() == 1 && CanPlayerLoot(client->CharacterID())) { /* PVP loot 1 item, variable cash */
Loot_Request_Type = 4;
}
else if (GetPlayerKillItem() > 1 && CanPlayerLoot(client->CharacterID())) { /* PVP loot 1 set item, variable cash */
Loot_Request_Type = 5;
return;
}
if (Loot_Request_Type == 1) {
if (client->Admin() < 100 || !client->GetGM()) {
SendLootReqErrorPacket(client, LootResponse::NotAtThisTime);
// all loot session disqualifiers should occur before this point as not to interfere with any current looter
loot_request_type = LootRequestType::Forbidden;
// loot_request_type is scoped to class Corpse and reset on a per-loot session basis
if (client->GetGM()) {
if (client->Admin() >= 100)
loot_request_type = LootRequestType::GMAllowed;
else
loot_request_type = LootRequestType::GMPeek;
}
else {
if (IsPlayerCorpse()) {
if (char_id == client->CharacterID()) {
loot_request_type = LootRequestType::Self;
}
else if (CanPlayerLoot(client->CharacterID())) {
if (GetPlayerKillItem() == -1)
loot_request_type = LootRequestType::AllowedPVPAll;
else if (GetPlayerKillItem() == 1)
loot_request_type = LootRequestType::AllowedPVPSingle;
else if (GetPlayerKillItem() > 1)
loot_request_type = LootRequestType::AllowedPVPDefined;
}
}
else if ((IsNPCCorpse() || become_npc) && CanPlayerLoot(client->CharacterID())) {
loot_request_type = LootRequestType::AllowedPVE;
}
}
if(Loot_Request_Type >= 2 || (Loot_Request_Type == 1 && client->Admin() >= 100 && client->GetGM())) {
client->CommonBreakInvisible(); // we should be "all good" so lets break invis now instead of earlier before all error checking is done
this->being_looted_by = client->GetID();
Log(Logs::Moderate, Logs::Inventory, "MakeLootRequestPackets() LootRequestType %u for %s", loot_request_type, client->GetName());
if (loot_request_type == LootRequestType::Forbidden) {
SendLootReqErrorPacket(client, LootResponse::NotAtThisTime);
return;
}
being_looted_by = client->GetID();
client->CommonBreakInvisible(); // we should be "all good" so lets break invis now instead of earlier before all error checking is done
// process coin
bool loot_coin = false;
std::string tmp;
if (database.GetVariable("LootCoin", tmp))
loot_coin = (tmp[0] == 1 && tmp[1] == '\0');
if (loot_request_type == LootRequestType::GMPeek || loot_request_type == LootRequestType::GMAllowed) {
client->Message(15, "This corpse contains %u platinum, %u gold, %u silver and %u copper.",
GetPlatinum(), GetGold(), GetSilver(), GetCopper());
auto outapp = new EQApplicationPacket(OP_MoneyOnCorpse, sizeof(moneyOnCorpseStruct));
moneyOnCorpseStruct* d = (moneyOnCorpseStruct*) outapp->pBuffer;
moneyOnCorpseStruct* d = (moneyOnCorpseStruct*)outapp->pBuffer;
d->response = static_cast<uint8>(LootResponse::Normal);
d->unknown1 = 0x42;
d->unknown2 = 0xef;
d->response = static_cast<uint8>(LootResponse::Normal);
d->unknown1 = 0x42;
d->unknown2 = 0xef;
/* Dont take the coin off if it's a gm peeking at the corpse */
if(Loot_Request_Type == 2 || (Loot_Request_Type >= 3 && loot_coin)) {
if(!IsPlayerCorpse() && client->IsGrouped() && client->AutoSplitEnabled() && client->GetGroup()) {
d->copper = 0;
d->silver = 0;
d->gold = 0;
d->platinum = 0;
Group *cgroup = client->GetGroup();
cgroup->SplitMoney(GetCopper(), GetSilver(), GetGold(), GetPlatinum(), client);
}
else {
d->copper = this->GetCopper();
d->silver = this->GetSilver();
d->gold = this->GetGold();
d->platinum = this->GetPlatinum();
client->AddMoneyToPP(GetCopper(), GetSilver(), GetGold(), GetPlatinum(), false);
}
d->copper = 0;
d->silver = 0;
d->gold = 0;
d->platinum = 0;
RemoveCash();
Save();
}
auto timestamps = database.GetItemRecastTimestamps(client->CharacterID());
outapp->priority = 6;
client->QueuePacket(outapp);
safe_delete(outapp);
if(Loot_Request_Type == 5) {
int pkitem = GetPlayerKillItem();
const EQEmu::ItemData* item = database.GetItem(pkitem);
EQEmu::ItemInstance* inst = database.CreateItem(item, item->MaxCharges);
if(inst) {
if (item->RecastDelay)
inst->SetRecastTimestamp(timestamps.count(item->RecastType) ? timestamps.at(item->RecastType) : 0);
client->SendItemPacket(EQEmu::invslot::CORPSE_BEGIN, inst, ItemPacketLoot);
safe_delete(inst);
}
else { client->Message(13, "Could not find item number %i to send!!", GetPlayerKillItem()); }
}
else {
auto outapp = new EQApplicationPacket(OP_MoneyOnCorpse, sizeof(moneyOnCorpseStruct));
moneyOnCorpseStruct* d = (moneyOnCorpseStruct*)outapp->pBuffer;
client->QueuePacket(app);
return;
d->response = static_cast<uint8>(LootResponse::Normal);
d->unknown1 = 0x42;
d->unknown2 = 0xef;
Group* cgroup = client->GetGroup();
// this can be reworked into a switch and/or massaged to include specialized pve loot rules based on 'LootRequestType'
if (!IsPlayerCorpse() && client->IsGrouped() && client->AutoSplitEnabled() && cgroup) {
d->copper = 0;
d->silver = 0;
d->gold = 0;
d->platinum = 0;
cgroup->SplitMoney(GetCopper(), GetSilver(), GetGold(), GetPlatinum(), client);
}
else {
d->copper = GetCopper();
d->silver = GetSilver();
d->gold = GetGold();
d->platinum = GetPlatinum();
client->AddMoneyToPP(GetCopper(), GetSilver(), GetGold(), GetPlatinum(), false);
}
int i = 0;
const EQEmu::ItemData* item = nullptr;
ItemList::iterator cur,end;
cur = itemlist.begin();
end = itemlist.end();
RemoveCash();
Save();
int corpselootlimit = EQEmu::inventory::Lookup(EQEmu::versions::ConvertClientVersionToMobVersion(client->ClientVersion()))->InventoryTypeSize[EQEmu::invtype::typeCorpse];
outapp->priority = 6;
client->QueuePacket(outapp);
for(; cur != end; ++cur) {
ServerLootItem_Struct* item_data = *cur;
item_data->lootslot = 0xFFFF;
safe_delete(outapp);
}
// Dont display the item if it's in a bag
// process items
auto timestamps = database.GetItemRecastTimestamps(client->CharacterID());
// Added cursor queue slots to corpse item visibility list. Nothing else should be making it to corpse.
if (!IsPlayerCorpse() || item_data->equip_slot <= EQEmu::invslot::slotCursor || item_data->equip_slot == EQEmu::invslot::SLOT_POWER_SOURCE || Loot_Request_Type >= 3 ||
(item_data->equip_slot >= 8000 && item_data->equip_slot <= 8999)) {
if(i < corpselootlimit) {
item = database.GetItem(item_data->item_id);
if(client && item) {
EQEmu::ItemInstance* inst = database.CreateItem(item, item_data->charges, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5, item_data->aug_6, item_data->attuned);
if(inst) {
if (item->RecastDelay)
inst->SetRecastTimestamp(timestamps.count(item->RecastType) ? timestamps.at(item->RecastType) : 0);
// SlotGeneral1 is the corpse inventory start offset for Ti(EMu) - CORPSE_END = SlotGeneral1 + SlotCursor
client->SendItemPacket(i + EQEmu::invslot::CORPSE_BEGIN, inst, ItemPacketLoot);
safe_delete(inst);
}
if (loot_request_type == LootRequestType::AllowedPVPDefined) {
auto pkitemid = GetPlayerKillItem();
auto pkitem = database.GetItem(pkitemid);
auto pkinst = database.CreateItem(pkitem, pkitem->MaxCharges);
item_data->lootslot = i;
}
}
if (pkinst) {
if (pkitem->RecastDelay)
pkinst->SetRecastTimestamp(timestamps.count(pkitem->RecastType) ? timestamps.at(pkitem->RecastType) : 0);
i++;
}
Log(Logs::Detail, Logs::Inventory, "MakeLootRequestPackets() Slot %u, Item '%s'", EQEmu::invslot::CORPSE_BEGIN, pkitem->Name);
client->SendItemPacket(EQEmu::invslot::CORPSE_BEGIN, pkinst, ItemPacketLoot);
safe_delete(pkinst);
}
else {
Log(Logs::General, Logs::Inventory, "MakeLootRequestPackets() PlayerKillItem %i not found", pkitemid);
client->Message(CC_Red, "PlayerKillItem (id: %i) could not be found!", pkitemid);
}
if(IsPlayerCorpse() && (char_id == client->CharacterID() || client->GetGM())) {
if(i > corpselootlimit) {
client->Message(15, "*** This corpse contains more items than can be displayed! ***");
client->Message(0, "Remove items and re-loot corpse to access remaining inventory.");
client->Message(0, "(%s contains %i additional %s.)", GetName(), (i - corpselootlimit), (i - corpselootlimit) == 1 ? "item" : "items");
}
client->QueuePacket(app);
return;
}
if(IsPlayerCorpse() && i == 0 && itemlist.size() > 0) { // somehow, player corpse contains items, but client doesn't see them...
client->Message(13, "This corpse contains items that are inaccessable!");
client->Message(15, "Contact a GM for item replacement, if necessary.");
client->Message(15, "BUGGED CORPSE [DBID: %i, Name: %s, Item Count: %i]", GetCorpseDBID(), GetName(), itemlist.size());
auto loot_slot = EQEmu::invslot::CORPSE_BEGIN;
auto corpse_mask = client->GetInv().GetLookup()->CorpseBitmask;
for (auto item_data : itemlist) {
// every loot session must either set all items' lootslots to 'invslot::SLOT_INVALID'
// or to a valid enumerated client-versioned corpse slot (lootslot is not equip_slot)
item_data->lootslot = 0xFFFF;
// align server and client corpse slot mappings so translators can function properly
while (loot_slot <= EQEmu::invslot::CORPSE_END && (((uint64)1 << loot_slot) & corpse_mask) == 0)
++loot_slot;
if (loot_slot > EQEmu::invslot::CORPSE_END)
continue;
cur = itemlist.begin();
end = itemlist.end();
for(; cur != end; ++cur) {
ServerLootItem_Struct* item_data = *cur;
item = database.GetItem(item_data->item_id);
Log(Logs::General, Logs::None, "Corpse Looting: %s was not sent to client loot window (corpse_dbid: %i, charname: %s(%s))", item->Name, GetCorpseDBID(), client->GetName(), client->GetGM() ? "GM" : "Owner");
client->Message(0, "Inaccessable Corpse Item: %s", item->Name);
}
}
if (IsPlayerCorpse()) {
if (loot_request_type == LootRequestType::AllowedPVPSingle && loot_slot != EQEmu::invslot::CORPSE_BEGIN)
continue;
if (item_data->equip_slot < EQEmu::invslot::POSSESSIONS_BEGIN || item_data->equip_slot > EQEmu::invslot::POSSESSIONS_END)
continue;
}
const auto *item = database.GetItem(item_data->item_id);
auto inst = database.CreateItem(
item,
item_data->charges,
item_data->aug_1,
item_data->aug_2,
item_data->aug_3,
item_data->aug_4,
item_data->aug_5,
item_data->aug_6,
item_data->attuned
);
if (!inst)
continue;
if (item->RecastDelay)
inst->SetRecastTimestamp(timestamps.count(item->RecastType) ? timestamps.at(item->RecastType) : 0);
Log(Logs::Moderate, Logs::Inventory, "MakeLootRequestPackets() Slot %i, Item '%s'", loot_slot, item->Name);
client->SendItemPacket(loot_slot, inst, ItemPacketLoot);
safe_delete(inst);
item_data->lootslot = loot_slot++;
}
// Disgrace: Client seems to require that we send the packet back...
@ -1064,8 +1099,22 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a
void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
{
if (!client)
return;
auto lootitem = (LootingItem_Struct *)app->pBuffer;
Log(Logs::Moderate, Logs::Inventory, "LootItem() LootRequestType %u, Slot %u for %s", loot_request_type, lootitem->slot_id, client->GetName());
if (loot_request_type == LootRequestType::Forbidden) {
client->QueuePacket(app);
SendEndLootErrorPacket(client);
// unlock corpse for others
if (IsBeingLootedBy(client))
ResetLooter();
return;
}
if (!loot_cooldown_timer.Check()) {
client->QueuePacket(app);
SendEndLootErrorPacket(client);
@ -1093,7 +1142,7 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
}
if (IsPlayerCorpse() && !CanPlayerLoot(client->CharacterID()) && !become_npc &&
(char_id != client->CharacterID() && client->Admin() < 150)) {
(char_id != client->CharacterID() && client->Admin() < 150)) {
client->Message(13, "Error: This is a player corpse and you dont own it.");
client->QueuePacket(app);
SendEndLootErrorPacket(client);
@ -1108,7 +1157,7 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
}
if (IsPlayerCorpse() && (char_id != client->CharacterID()) && CanPlayerLoot(client->CharacterID()) &&
GetPlayerKillItem() == 0) {
GetPlayerKillItem() == 0) {
client->Message(13, "Error: You cannot loot any more items from this corpse.");
client->QueuePacket(app);
SendEndLootErrorPacket(client);
@ -1123,12 +1172,13 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
memset(bag_item_data, 0, sizeof(bag_item_data));
if (GetPlayerKillItem() > 1) {
item = database.GetItem(GetPlayerKillItem());
} else if (GetPlayerKillItem() == -1 || GetPlayerKillItem() == 1) {
}
else if (GetPlayerKillItem() == -1 || GetPlayerKillItem() == 1) {
item_data =
GetItem(lootitem->slot_id -
EQEmu::invslot::CORPSE_BEGIN); // dont allow them to loot entire bags of items as pvp reward
} else {
item_data = GetItem(lootitem->slot_id - EQEmu::invslot::CORPSE_BEGIN, bag_item_data);
GetItem(lootitem->slot_id); // dont allow them to loot entire bags of items as pvp reward
}
else {
item_data = GetItem(lootitem->slot_id, bag_item_data);
}
if (GetPlayerKillItem() <= 1 && item_data != 0) {
@ -1138,9 +1188,10 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
if (item != 0) {
if (item_data) {
inst = database.CreateItem(item, item_data ? item_data->charges : 0, item_data->aug_1,
item_data->aug_2, item_data->aug_3, item_data->aug_4,
item_data->aug_5, item_data->aug_6, item_data->attuned);
} else {
item_data->aug_2, item_data->aug_3, item_data->aug_4,
item_data->aug_5, item_data->aug_6, item_data->attuned);
}
else {
inst = database.CreateItem(item);
}
}
@ -1175,7 +1226,7 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
char q_corpse_name[64];
strcpy(q_corpse_name, corpse_name);
snprintf(buf, 87, "%d %d %s", inst->GetItem()->ID, inst->GetCharges(),
EntityList::RemoveNumbers(q_corpse_name));
EntityList::RemoveNumbers(q_corpse_name));
buf[87] = '\0';
std::vector<EQEmu::Any> args;
args.push_back(inst);
@ -1187,6 +1238,8 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
delete inst;
return;
}
// do we want this to have a fail option too?
parse->EventItem(EVENT_LOOT, client, inst, this, buf, 0);
@ -1211,7 +1264,8 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
if (lootitem->auto_loot > 0) {
if (!client->AutoPutLootInInventory(*inst, true, true, bag_item_data))
client->PutLootInInventory(EQEmu::invslot::slotCursor, *inst, bag_item_data);
} else {
}
else {
client->PutLootInInventory(EQEmu::invslot::slotCursor, *inst, bag_item_data);
}
@ -1222,9 +1276,9 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
/* Remove it from Corpse */
if (item_data) {
/* Delete needs to be before RemoveItem because its deletes the pointer for
* item_data/bag_item_data */
* item_data/bag_item_data */
database.DeleteItemOffCharacterCorpse(this->corpse_db_id, item_data->equip_slot,
item_data->item_id);
item_data->item_id);
/* Delete Item Instance */
RemoveItem(item_data->lootslot);
}
@ -1234,10 +1288,10 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
for (int i = EQEmu::invbag::SLOT_BEGIN; i <= EQEmu::invbag::SLOT_END; i++) {
if (bag_item_data[i]) {
/* Delete needs to be before RemoveItem because its deletes the pointer for
* item_data/bag_item_data */
* item_data/bag_item_data */
database.DeleteItemOffCharacterCorpse(this->corpse_db_id,
bag_item_data[i]->equip_slot,
bag_item_data[i]->item_id);
bag_item_data[i]->equip_slot,
bag_item_data[i]->item_id);
/* Delete Item Instance */
RemoveItem(bag_item_data[i]);
}
@ -1261,16 +1315,18 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
Group *g = client->GetGroup();
if (g != nullptr) {
g->GroupMessage_StringID(client, MT_LootMessages, OTHER_LOOTED_MESSAGE,
client->GetName(), linker.Link().c_str());
} else {
client->GetName(), linker.Link().c_str());
}
else {
Raid *r = client->GetRaid();
if (r != nullptr) {
r->RaidMessage_StringID(client, MT_LootMessages, OTHER_LOOTED_MESSAGE,
client->GetName(), linker.Link().c_str());
client->GetName(), linker.Link().c_str());
}
}
}
} else {
}
else {
SendEndLootErrorPacket(client);
safe_delete(inst);
return;
@ -1278,7 +1334,8 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
if (IsPlayerCorpse()) {
client->SendItemLink(inst);
} else {
}
else {
client->SendItemLink(inst, true);
}
@ -1457,7 +1514,7 @@ void Corpse::UpdateEquipmentLight()
m_Light.Level[EQEmu::lightsource::LightEquipment] = 0;
for (auto iter = itemlist.begin(); iter != itemlist.end(); ++iter) {
if (((*iter)->equip_slot < EQEmu::invslot::EQUIPMENT_BEGIN || (*iter)->equip_slot > EQEmu::invslot::EQUIPMENT_END) && (*iter)->equip_slot != EQEmu::invslot::SLOT_POWER_SOURCE) { continue; }
if ((*iter)->equip_slot < EQEmu::invslot::EQUIPMENT_BEGIN || (*iter)->equip_slot > EQEmu::invslot::EQUIPMENT_END) { continue; }
if ((*iter)->equip_slot == EQEmu::invslot::slotAmmo) { continue; }
auto item = database.GetItem((*iter)->item_id);

View File

@ -116,7 +116,7 @@ class Corpse : public Mob {
inline void Lock() { is_locked = true; }
inline void UnLock() { is_locked = false; }
inline bool IsLocked() { return is_locked; }
inline void ResetLooter() { being_looted_by = 0xFFFFFFFF; }
inline void ResetLooter() { being_looted_by = 0xFFFFFFFF; loot_request_type = LootRequestType::Forbidden; }
inline bool IsBeingLooted() { return (being_looted_by != 0xFFFFFFFF); }
inline bool IsBeingLootedBy(Client *c) { return being_looted_by == c->GetID(); }
@ -161,6 +161,7 @@ private:
Timer loot_cooldown_timer; /* Delay between loot actions on the corpse entity */
EQEmu::TintProfile item_tint;
LootRequestType loot_request_type;
};
#endif

View File

@ -1128,9 +1128,9 @@ void PerlembParser::ExportItemVariables(std::string &package_name, Mob *mob) {
std::string hashname = package_name + std::string("::oncursor");
perl->eval(std::string("%").append(hashname).append(" = ();").c_str());
char *hi_decl = nullptr;
int itemid = mob->CastToClient()->GetItemIDAt(30);
int itemid = mob->CastToClient()->GetItemIDAt(EQEmu::invslot::slotCursor);
if(!HASITEM_ISNULLITEM(itemid)) {
MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);",hashname.c_str(), itemid, 30);
MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);",hashname.c_str(), itemid, EQEmu::invslot::slotCursor);
perl->eval(hi_decl);
safe_delete_array(hi_decl);
}

View File

@ -33,6 +33,8 @@
#include "zone.h"
#include "data_bucket.h"
#include <cctype>
extern Zone *zone;
extern QueryServ *QServ;
@ -348,6 +350,83 @@ XS(XS__incstat) {
XSRETURN_EMPTY;
}
XS(XS__inventory);
XS(XS__inventory) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::inventory(string identifier)");
int16 RETVAL;
dXSTARG;
std::string identifier = (Const_char *)SvPV_nolen(ST(0));
for (std::string::size_type i = 0; i < identifier.length(); ++i)
identifier[i] = std::tolower(identifier[i]);
if (identifier == "invalid") RETVAL = EQEmu::invslot::SLOT_INVALID;
else if (identifier == "cursor") RETVAL = EQEmu::invslot::slotCursor;
else if (identifier == "possessions_begin") RETVAL = EQEmu::invslot::POSSESSIONS_BEGIN;
else if (identifier == "possessions_end") RETVAL = EQEmu::invslot::POSSESSIONS_END;
else if (identifier == "bank_begin") RETVAL = EQEmu::invslot::BANK_BEGIN;
else if (identifier == "bank_end") RETVAL = EQEmu::invslot::BANK_END;
else if (identifier == "sharedbank_begin") RETVAL = EQEmu::invslot::SHARED_BANK_BEGIN;
else if (identifier == "sharedbank_end") RETVAL = EQEmu::invslot::SHARED_BANK_END;
else if (identifier == "generalbags_begin") RETVAL = EQEmu::invbag::GENERAL_BAGS_BEGIN;
else if (identifier == "generalbags_end") RETVAL = EQEmu::invbag::GENERAL_BAGS_END;
else if (identifier == "cursorbag_begin") RETVAL = EQEmu::invbag::CURSOR_BAG_BEGIN;
else if (identifier == "cursorbag_end") RETVAL = EQEmu::invbag::CURSOR_BAG_END;
else if (identifier == "bankbags_begin") RETVAL = EQEmu::invbag::BANK_BAGS_BEGIN;
else if (identifier == "bankbags_end") RETVAL = EQEmu::invbag::BANK_BAGS_END;
else if (identifier == "sharedbankbags_begin") RETVAL = EQEmu::invbag::SHARED_BANK_BAGS_BEGIN;
else if (identifier == "sharedbankbags_end") RETVAL = EQEmu::invbag::SHARED_BANK_BAGS_END;
else if (identifier == "bagslot_begin") RETVAL = EQEmu::invbag::SLOT_BEGIN;
else if (identifier == "bagslot_end") RETVAL = EQEmu::invbag::SLOT_END;
else if (identifier == "augsocket_begin") RETVAL = EQEmu::invaug::SOCKET_BEGIN;
else if (identifier == "augsocket_end") RETVAL = EQEmu::invaug::SOCKET_END;
else if (identifier == "equipment_begin") RETVAL = EQEmu::invslot::EQUIPMENT_BEGIN;
else if (identifier == "equipment_end") RETVAL = EQEmu::invslot::EQUIPMENT_END;
else if (identifier == "general_begin") RETVAL = EQEmu::invslot::GENERAL_BEGIN;
else if (identifier == "general_end") RETVAL = EQEmu::invslot::GENERAL_END;
else if (identifier == "charm") RETVAL = EQEmu::invslot::slotCharm;
else if (identifier == "ear1") RETVAL = EQEmu::invslot::slotEar1;
else if (identifier == "head") RETVAL = EQEmu::invslot::slotHead;
else if (identifier == "face") RETVAL = EQEmu::invslot::slotFace;
else if (identifier == "ear2") RETVAL = EQEmu::invslot::slotEar2;
else if (identifier == "neck") RETVAL = EQEmu::invslot::slotNeck;
else if (identifier == "shoulders") RETVAL = EQEmu::invslot::slotShoulders;
else if (identifier == "arms") RETVAL = EQEmu::invslot::slotArms;
else if (identifier == "back") RETVAL = EQEmu::invslot::slotBack;
else if (identifier == "wrist1") RETVAL = EQEmu::invslot::slotWrist1;
else if (identifier == "wrist2") RETVAL = EQEmu::invslot::slotWrist2;
else if (identifier == "range") RETVAL = EQEmu::invslot::slotRange;
else if (identifier == "hands") RETVAL = EQEmu::invslot::slotHands;
else if (identifier == "primary") RETVAL = EQEmu::invslot::slotPrimary;
else if (identifier == "secondary") RETVAL = EQEmu::invslot::slotSecondary;
else if (identifier == "finger1") RETVAL = EQEmu::invslot::slotFinger1;
else if (identifier == "finger2") RETVAL = EQEmu::invslot::slotFinger2;
else if (identifier == "chest") RETVAL = EQEmu::invslot::slotChest;
else if (identifier == "legs") RETVAL = EQEmu::invslot::slotLegs;
else if (identifier == "feet") RETVAL = EQEmu::invslot::slotFeet;
else if (identifier == "waist") RETVAL = EQEmu::invslot::slotWaist;
else if (identifier == "powersource") RETVAL = EQEmu::invslot::slotPowerSource;
else if (identifier == "ammo") RETVAL = EQEmu::invslot::slotAmmo;
else if (identifier == "general1") RETVAL = EQEmu::invslot::slotGeneral1;
else if (identifier == "general2") RETVAL = EQEmu::invslot::slotGeneral2;
else if (identifier == "general3") RETVAL = EQEmu::invslot::slotGeneral3;
else if (identifier == "general4") RETVAL = EQEmu::invslot::slotGeneral4;
else if (identifier == "general5") RETVAL = EQEmu::invslot::slotGeneral5;
else if (identifier == "general6") RETVAL = EQEmu::invslot::slotGeneral6;
else if (identifier == "general7") RETVAL = EQEmu::invslot::slotGeneral7;
else if (identifier == "general8") RETVAL = EQEmu::invslot::slotGeneral8;
else if (identifier == "general9") RETVAL = EQEmu::invslot::slotGeneral9;
else if (identifier == "general10") RETVAL = EQEmu::invslot::slotGeneral10;
else RETVAL = EQEmu::invslot::SLOT_INVALID;
XSprePUSH; PUSHu((IV)RETVAL);
XSRETURN(1);
}
XS(XS__castspell);
XS(XS__castspell) {
dXSARGS;
@ -3683,6 +3762,7 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "gmsay"), XS__gmsay, file);
newXS(strcpy(buf, "has_zone_flag"), XS__has_zone_flag, file);
newXS(strcpy(buf, "incstat"), XS__incstat, file);
newXS(strcpy(buf, "inventory"), XS__inventory, file);
newXS(strcpy(buf, "isdisctome"), XS__isdisctome, file);
newXS(strcpy(buf, "isdooropen"), XS__isdooropen, file);
newXS(strcpy(buf, "istaskactive"), XS__istaskactive, file);

View File

@ -44,23 +44,9 @@ uint32 Client::NukeItem(uint32 itemnum, uint8 where_to_check) {
x++;
}
DeleteItemInInventory(i, 0, true);
DeleteItemInInventory(i, 0, ((((uint64)1 << i) & GetInv().GetLookup()->PossessionsBitmask) != 0));
}
}
if (GetItemIDAt(EQEmu::invslot::SLOT_POWER_SOURCE) == itemnum || (itemnum == 0xFFFE && GetItemIDAt(EQEmu::invslot::SLOT_POWER_SOURCE) != INVALID_ID)) {
cur = m_inv.GetItem(EQEmu::invslot::SLOT_POWER_SOURCE);
if(cur && cur->GetItem()->Stackable) {
x += cur->GetCharges();
} else {
x++;
}
if (ClientVersion() >= EQEmu::versions::ClientVersion::SoF)
DeleteItemInInventory(EQEmu::invslot::SLOT_POWER_SOURCE, 0, true);
else
DeleteItemInInventory(EQEmu::invslot::SLOT_POWER_SOURCE, 0, false); // Prevents Titanium crash
}
}
if(where_to_check & invWhereCursor) {
@ -99,7 +85,7 @@ uint32 Client::NukeItem(uint32 itemnum, uint8 where_to_check) {
x++;
}
DeleteItemInInventory(i, 0, true);
DeleteItemInInventory(i, 0, ((((uint64)1 << i) & GetInv().GetLookup()->PossessionsBitmask) != 0));
}
}
@ -112,7 +98,7 @@ uint32 Client::NukeItem(uint32 itemnum, uint8 where_to_check) {
x++;
}
DeleteItemInInventory(i, 0, true);
DeleteItemInInventory(i, 0, ((((uint64)1 << (EQEmu::invslot::GENERAL_BEGIN + ((i - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT))) & GetInv().GetLookup()->PossessionsBitmask) == 0));
}
}
}
@ -127,7 +113,7 @@ uint32 Client::NukeItem(uint32 itemnum, uint8 where_to_check) {
x++;
}
DeleteItemInInventory(i, 0, true);
DeleteItemInInventory(i, 0, ((i - EQEmu::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank]));
}
}
@ -140,7 +126,7 @@ uint32 Client::NukeItem(uint32 itemnum, uint8 where_to_check) {
x++;
}
DeleteItemInInventory(i, 0, true);
DeleteItemInInventory(i, 0, (((i - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT) >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank]));
}
}
}
@ -554,8 +540,8 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2,
inst->SetOrnamentHeroModel(ornament_hero_model);
// check to see if item is usable in requested slot
if (enforceusable && (((to_slot >= EQEmu::invslot::slotCharm) && (to_slot <= EQEmu::invslot::slotAmmo)) || (to_slot == EQEmu::invslot::SLOT_POWER_SOURCE))) {
uint32 slottest = (to_slot == EQEmu::invslot::SLOT_POWER_SOURCE) ? 22 : to_slot; // can't change '22' just yet...
if (enforceusable && (to_slot >= EQEmu::invslot::EQUIPMENT_BEGIN && to_slot <= EQEmu::invslot::EQUIPMENT_END)) {
uint32 slottest = to_slot;
if(!(slots & ((uint32)1 << slottest))) {
Message(0, "This item is not equipable at slot %u - moving to cursor.", to_slot);
@ -716,6 +702,25 @@ void Client::DropInst(const EQEmu::ItemInstance* inst)
// Returns a slot's item ID (returns INVALID_ID if not found)
int32 Client::GetItemIDAt(int16 slot_id) {
if (slot_id <= EQEmu::invslot::POSSESSIONS_END && slot_id >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask) == 0)
return INVALID_ID;
}
else if (slot_id <= EQEmu::invbag::GENERAL_BAGS_END && slot_id >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_id - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) == 0)
return INVALID_ID;
}
else if (slot_id <= EQEmu::invslot::BANK_END && slot_id >= EQEmu::invslot::BANK_BEGIN) {
if ((slot_id - EQEmu::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
return INVALID_ID;
}
else if (slot_id <= EQEmu::invbag::BANK_BAGS_END && slot_id >= EQEmu::invbag::BANK_BAGS_BEGIN) {
auto temp_slot = (slot_id - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
if (temp_slot >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
return INVALID_ID;
}
const EQEmu::ItemInstance* inst = m_inv[slot_id];
if (inst)
return inst->GetItem()->ID;
@ -727,6 +732,25 @@ int32 Client::GetItemIDAt(int16 slot_id) {
// Returns an augment's ID that's in an item (returns INVALID_ID if not found)
// Pass in the slot ID of the item and which augslot you want to check (0-5)
int32 Client::GetAugmentIDAt(int16 slot_id, uint8 augslot) {
if (slot_id <= EQEmu::invslot::POSSESSIONS_END && slot_id >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask) == 0)
return INVALID_ID;
}
else if (slot_id <= EQEmu::invbag::GENERAL_BAGS_END && slot_id >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_id - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) == 0)
return INVALID_ID;
}
else if (slot_id <= EQEmu::invslot::BANK_END && slot_id >= EQEmu::invslot::BANK_BEGIN) {
if ((slot_id - EQEmu::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
return INVALID_ID;
}
else if (slot_id <= EQEmu::invbag::BANK_BAGS_END && slot_id >= EQEmu::invbag::BANK_BAGS_BEGIN) {
auto temp_slot = (slot_id - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
if (temp_slot >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
return INVALID_ID;
}
const EQEmu::ItemInstance* inst = m_inv[slot_id];
if (inst && inst->GetAugmentItemID(augslot)) {
return inst->GetAugmentItemID(augslot);
@ -963,7 +987,7 @@ void Client::PutLootInInventory(int16 slot_id, const EQEmu::ItemInstance &inst,
}
if (bag_item_data) {
for (int index = 0; index < EQEmu::invbag::SLOT_COUNT; ++index) {
for (int index = EQEmu::invbag::SLOT_BEGIN; index <= EQEmu::invbag::SLOT_END; ++index) {
if (bag_item_data[index] == nullptr)
continue;
@ -1003,12 +1027,15 @@ void Client::PutLootInInventory(int16 slot_id, const EQEmu::ItemInstance &inst,
CalcBonuses();
}
bool Client::TryStacking(EQEmu::ItemInstance* item, uint8 type, bool try_worn, bool try_cursor){
bool Client::TryStacking(EQEmu::ItemInstance* item, uint8 type, bool try_worn, bool try_cursor) {
if(!item || !item->IsStackable() || item->GetCharges()>=item->GetItem()->StackSize)
return false;
int16 i;
uint32 item_id = item->GetItem()->ID;
for (i = EQEmu::invslot::GENERAL_BEGIN; i <= EQEmu::invslot::GENERAL_END; i++) {
if (((uint64)1 << i) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
EQEmu::ItemInstance* tmp_inst = m_inv.GetItem(i);
if(tmp_inst && tmp_inst->GetItem()->ID == item_id && tmp_inst->GetCharges() < tmp_inst->GetItem()->StackSize){
MoveItemCharges(*item, i, type);
@ -1020,6 +1047,9 @@ bool Client::TryStacking(EQEmu::ItemInstance* item, uint8 type, bool try_worn, b
}
}
for (i = EQEmu::invslot::GENERAL_BEGIN; i <= EQEmu::invslot::GENERAL_END; i++) {
if (((uint64)1 << i) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
for (uint8 j = EQEmu::invbag::SLOT_BEGIN; j <= EQEmu::invbag::SLOT_END; j++) {
uint16 slotid = EQEmu::InventoryProfile::CalcSlotId(i, j);
EQEmu::ItemInstance* tmp_inst = m_inv.GetItem(slotid);
@ -1044,15 +1074,9 @@ bool Client::AutoPutLootInInventory(EQEmu::ItemInstance& inst, bool try_worn, bo
{
// #1: Try to auto equip
if (try_worn && inst.IsEquipable(GetBaseRace(), GetClass()) && inst.GetItem()->ReqLevel <= level && (!inst.GetItem()->Attuneable || inst.IsAttuned()) && inst.GetItem()->ItemType != EQEmu::item::ItemTypeAugmentation) {
// too messy as-is... <watch>
for (int16 i = EQEmu::invslot::EQUIPMENT_BEGIN; i < EQEmu::invslot::SLOT_POWER_SOURCE; i++) { // originally (i < 22)
if (i == EQEmu::invslot::GENERAL_BEGIN) {
// added power source check for SoF+ clients
if (this->ClientVersion() >= EQEmu::versions::ClientVersion::SoF)
i = EQEmu::invslot::SLOT_POWER_SOURCE;
else
break;
}
for (int16 i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= EQEmu::invslot::EQUIPMENT_END; i++) {
if (((uint64)1 << i) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
if (!m_inv[i]) {
if (i == EQEmu::invslot::slotPrimary && inst.IsWeapon()) { // If item is primary slot weapon
@ -1373,23 +1397,34 @@ void Client::SendLootItemInPacket(const EQEmu::ItemInstance* inst, int16 slot_id
}
bool Client::IsValidSlot(uint32 slot) {
if ((slot == (uint32)INVALID_INDEX) ||
(slot >= EQEmu::invslot::POSSESSIONS_BEGIN && slot <= EQEmu::invslot::POSSESSIONS_END) ||
(slot >= EQEmu::invbag::GENERAL_BAGS_BEGIN && slot <= EQEmu::invbag::CURSOR_BAG_END) ||
(slot >= EQEmu::invslot::TRIBUTE_BEGIN && slot <= EQEmu::invslot::TRIBUTE_END) ||
(slot >= EQEmu::invslot::BANK_BEGIN && slot <= EQEmu::invslot::BANK_END) ||
(slot >= EQEmu::invbag::BANK_BAGS_BEGIN && slot <= EQEmu::invbag::BANK_BAGS_END) ||
(slot >= EQEmu::invslot::SHARED_BANK_BEGIN && slot <= EQEmu::invslot::SHARED_BANK_END) ||
(slot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN && slot <= EQEmu::invbag::SHARED_BANK_BAGS_END) ||
(slot >= EQEmu::invslot::TRADE_BEGIN && slot <= EQEmu::invslot::TRADE_END) ||
(slot >= EQEmu::invslot::WORLD_BEGIN && slot <= EQEmu::invslot::WORLD_END) ||
(slot == EQEmu::invslot::SLOT_POWER_SOURCE)
) {
if (slot <= EQEmu::invslot::POSSESSIONS_END && slot >= EQEmu::invslot::POSSESSIONS_BEGIN) {
return ((((uint64)1 << slot) & GetInv().GetLookup()->PossessionsBitmask) != 0);
}
else if (slot <= EQEmu::invbag::GENERAL_BAGS_END && slot >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
return ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) != 0);
}
else if (slot <= EQEmu::invslot::BANK_END && slot >= EQEmu::invslot::BANK_BEGIN) {
return ((slot - EQEmu::invslot::BANK_BEGIN) < GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank]);
}
else if (slot <= EQEmu::invbag::BANK_BAGS_END && slot >= EQEmu::invbag::BANK_BAGS_BEGIN) {
auto temp_slot = (slot - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
return (temp_slot < GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank]);
}
else if (
(slot == (uint32)INVALID_INDEX) ||
(slot == (uint32)EQEmu::invslot::slotCursor) ||
(slot <= EQEmu::invbag::CURSOR_BAG_END && slot >= EQEmu::invbag::CURSOR_BAG_BEGIN) ||
(slot <= EQEmu::invslot::TRIBUTE_END && slot >= EQEmu::invslot::TRIBUTE_BEGIN) ||
(slot <= EQEmu::invslot::SHARED_BANK_END && slot >= EQEmu::invslot::SHARED_BANK_BEGIN) ||
(slot <= EQEmu::invbag::SHARED_BANK_BAGS_END && slot >= EQEmu::invbag::SHARED_BANK_BAGS_BEGIN) ||
(slot <= EQEmu::invslot::TRADE_END && slot >= EQEmu::invslot::TRADE_BEGIN) ||
(slot <= EQEmu::invslot::WORLD_END && slot >= EQEmu::invslot::WORLD_BEGIN)
) {
return true;
}
else {
return false;
}
return false;
}
bool Client::IsBankSlot(uint32 slot)
@ -1481,10 +1516,14 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
return true; // Item deletion
}
}
if (auto_attack && (move_in->from_slot == EQEmu::invslot::slotPrimary || move_in->from_slot == EQEmu::invslot::slotSecondary || move_in->from_slot == EQEmu::invslot::slotRange))
SetAttackTimer();
else if (auto_attack && (move_in->to_slot == EQEmu::invslot::slotPrimary || move_in->to_slot == EQEmu::invslot::slotSecondary || move_in->to_slot == EQEmu::invslot::slotRange))
SetAttackTimer();
if (auto_attack) {
if (move_in->from_slot == EQEmu::invslot::slotPrimary || move_in->from_slot == EQEmu::invslot::slotSecondary || move_in->from_slot == EQEmu::invslot::slotRange)
SetAttackTimer();
else if (move_in->to_slot == EQEmu::invslot::slotPrimary || move_in->to_slot == EQEmu::invslot::slotSecondary || move_in->to_slot == EQEmu::invslot::slotRange)
SetAttackTimer();
}
// Step 1: Variables
int16 src_slot_id = (int16)move_in->from_slot;
int16 dst_slot_id = (int16)move_in->to_slot;
@ -1530,13 +1569,11 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
uint32 srcbagid =0;
uint32 dstbagid = 0;
//if (src_slot_id >= 250 && src_slot_id < 330) {
if (src_slot_id >= EQEmu::invbag::GENERAL_BAGS_BEGIN && src_slot_id <= EQEmu::invbag::GENERAL_BAGS_END) {
srcbag = m_inv.GetItem(((int)(src_slot_id / 10)) - 3);
if (srcbag)
srcbagid = srcbag->GetItem()->ID;
}
//if (dst_slot_id >= 250 && dst_slot_id < 330) {
if (dst_slot_id >= EQEmu::invbag::GENERAL_BAGS_BEGIN && dst_slot_id <= EQEmu::invbag::GENERAL_BAGS_END) {
dstbag = m_inv.GetItem(((int)(dst_slot_id / 10)) - 3);
if (dstbag)
@ -1808,7 +1845,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
else {
// Not dealing with charges - just do direct swap
if (src_inst && (dst_slot_id <= EQEmu::invslot::EQUIPMENT_END || dst_slot_id == EQEmu::invslot::SLOT_POWER_SOURCE) && dst_slot_id >= EQEmu::invslot::EQUIPMENT_BEGIN) {
if (src_inst && (dst_slot_id <= EQEmu::invslot::EQUIPMENT_END) && dst_slot_id >= EQEmu::invslot::EQUIPMENT_BEGIN) {
if (src_inst->GetItem()->Attuneable) {
src_inst->SetAttuned(true);
}
@ -1840,7 +1877,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
Log(Logs::Detail, Logs::Inventory, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id);
if (src_slot_id <= EQEmu::invslot::EQUIPMENT_END || src_slot_id == EQEmu::invslot::SLOT_POWER_SOURCE) {
if (src_slot_id <= EQEmu::invslot::EQUIPMENT_END) {
if(src_inst) {
parse->EventItem(EVENT_UNEQUIP_ITEM, this, src_inst, nullptr, "", src_slot_id);
}
@ -1850,7 +1887,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
}
if (dst_slot_id <= EQEmu::invslot::EQUIPMENT_END || dst_slot_id == EQEmu::invslot::SLOT_POWER_SOURCE) {
if (dst_slot_id <= EQEmu::invslot::EQUIPMENT_END) {
if(dst_inst) {
parse->EventItem(EVENT_UNEQUIP_ITEM, this, dst_inst, nullptr, "", dst_slot_id);
}
@ -1904,7 +1941,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) {
Log(Logs::Detail, Logs::Inventory, "Inventory desyncronization. (charname: %s, source: %i, destination: %i)", GetName(), move_slots->from_slot, move_slots->to_slot);
Message(15, "Inventory Desyncronization detected: Resending slot data...");
if ((move_slots->from_slot >= EQEmu::invslot::EQUIPMENT_BEGIN && move_slots->from_slot <= EQEmu::invbag::CURSOR_BAG_END) || move_slots->from_slot == EQEmu::invslot::SLOT_POWER_SOURCE) {
if (move_slots->from_slot >= EQEmu::invslot::EQUIPMENT_BEGIN && move_slots->from_slot <= EQEmu::invbag::CURSOR_BAG_END) {
int16 resync_slot = (EQEmu::InventoryProfile::CalcSlotId(move_slots->from_slot) == INVALID_INDEX) ? move_slots->from_slot : EQEmu::InventoryProfile::CalcSlotId(move_slots->from_slot);
if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) {
// This prevents the client from crashing when closing any 'phantom' bags
@ -1947,7 +1984,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) {
else { Message(13, "Could not resyncronize source slot %i.", move_slots->from_slot); }
}
if ((move_slots->to_slot >= EQEmu::invslot::EQUIPMENT_BEGIN && move_slots->to_slot <= EQEmu::invbag::CURSOR_BAG_END) || move_slots->to_slot == EQEmu::invslot::SLOT_POWER_SOURCE) {
if (move_slots->to_slot >= EQEmu::invslot::EQUIPMENT_BEGIN && move_slots->to_slot <= EQEmu::invbag::CURSOR_BAG_END) {
int16 resync_slot = (EQEmu::InventoryProfile::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : EQEmu::InventoryProfile::CalcSlotId(move_slots->to_slot);
if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) {
const EQEmu::ItemData* token_struct = database.GetItem(22292); // 'Copper Coin'
@ -2182,47 +2219,118 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
EQEmu::ItemInstance* ins = nullptr;
int x;
int num = 0;
for(x = EQEmu::invslot::EQUIPMENT_BEGIN; x <= EQEmu::invbag::GENERAL_BAGS_END; x++)
{
if (x == EQEmu::invslot::slotCursor + 1)
x = EQEmu::invbag::GENERAL_BAGS_BEGIN;
for (x = EQEmu::invslot::POSSESSIONS_BEGIN; x <= EQEmu::invslot::POSSESSIONS_END; ++x) {
if (num >= amt)
break;
if (((uint64)1 << x) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
TempItem = nullptr;
ins = GetInv().GetItem(x);
if (ins)
TempItem = ins->GetItem();
if (TempItem && TempItem->ID == type)
{
num += ins->GetCharges();
if (num >= amt)
break;
}
}
for (x = EQEmu::invbag::GENERAL_BAGS_BEGIN; x <= EQEmu::invbag::GENERAL_BAGS_END; ++x) {
if (num >= amt)
break;
if ((((uint64)1 << (EQEmu::invslot::GENERAL_BEGIN + ((x - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT))) & GetInv().GetLookup()->PossessionsBitmask) == 0)
continue;
TempItem = nullptr;
ins = GetInv().GetItem(x);
if (ins)
TempItem = ins->GetItem();
if (TempItem && TempItem->ID == type)
num += ins->GetCharges();
}
for (x = EQEmu::invbag::CURSOR_BAG_BEGIN; x <= EQEmu::invbag::CURSOR_BAG_END; ++x) {
if (num >= amt)
break;
TempItem = nullptr;
ins = GetInv().GetItem(x);
if (ins)
TempItem = ins->GetItem();
if (TempItem && TempItem->ID == type)
num += ins->GetCharges();
}
if (num < amt)
return false;
for(x = EQEmu::invslot::EQUIPMENT_BEGIN; x <= EQEmu::invbag::GENERAL_BAGS_END; x++) // should this be CURSOR_BAG_END?
{
if (x == EQEmu::invslot::slotCursor + 1)
x = EQEmu::invbag::GENERAL_BAGS_BEGIN;
for (x = EQEmu::invslot::POSSESSIONS_BEGIN; x <= EQEmu::invslot::POSSESSIONS_END; ++x) {
if (amt < 1)
break;
if (((uint64)1 << x) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
TempItem = nullptr;
ins = GetInv().GetItem(x);
if (ins)
TempItem = ins->GetItem();
if (TempItem && TempItem->ID == type)
{
if (ins->GetCharges() < amt)
{
amt -= ins->GetCharges();
DeleteItemInInventory(x,amt,true);
}
else
{
DeleteItemInInventory(x,amt,true);
amt = 0;
}
if (amt < 1)
break;
if (TempItem && TempItem->ID != type)
continue;
if (ins->GetCharges() < amt) {
amt -= ins->GetCharges();
DeleteItemInInventory(x, amt, true);
}
else {
DeleteItemInInventory(x, amt, true);
amt = 0;
}
}
for (x = EQEmu::invbag::GENERAL_BAGS_BEGIN; x <= EQEmu::invbag::GENERAL_BAGS_END; ++x) {
if (amt < 1)
break;
if ((((uint64)1 << (EQEmu::invslot::GENERAL_BEGIN + ((x - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT))) & GetInv().GetLookup()->PossessionsBitmask) == 0)
continue;
TempItem = nullptr;
ins = GetInv().GetItem(x);
if (ins)
TempItem = ins->GetItem();
if (TempItem && TempItem->ID != type)
continue;
if (ins->GetCharges() < amt) {
amt -= ins->GetCharges();
DeleteItemInInventory(x, amt, true);
}
else {
DeleteItemInInventory(x, amt, true);
amt = 0;
}
}
for (x = EQEmu::invbag::CURSOR_BAG_BEGIN; x <= EQEmu::invbag::CURSOR_BAG_END; ++x) {
if (amt < 1)
break;
TempItem = nullptr;
ins = GetInv().GetItem(x);
if (ins)
TempItem = ins->GetItem();
if (TempItem && TempItem->ID != type)
continue;
if (ins->GetCharges() < amt) {
amt -= ins->GetCharges();
DeleteItemInInventory(x, amt, true);
}
else {
DeleteItemInInventory(x, amt, true);
amt = 0;
}
}
return true;
}
@ -2299,6 +2407,9 @@ static bool CopyBagContents(EQEmu::ItemInstance* new_bag, const EQEmu::ItemInsta
void Client::DisenchantSummonedBags(bool client_update)
{
for (auto slot_id = EQEmu::invslot::GENERAL_BEGIN; slot_id <= EQEmu::invslot::GENERAL_END; ++slot_id) {
if (((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue; // not useable this session - will be disenchanted once player logs in on client that doesn't exclude affected slots
auto inst = m_inv[slot_id];
if (!inst) { continue; }
if (!IsSummonedBagID(inst->GetItem()->ID)) { continue; }
@ -2320,6 +2431,9 @@ void Client::DisenchantSummonedBags(bool client_update)
}
for (auto slot_id = EQEmu::invslot::BANK_BEGIN; slot_id <= EQEmu::invslot::BANK_END; ++slot_id) {
if ((slot_id - EQEmu::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
continue;
auto inst = m_inv[slot_id];
if (!inst) { continue; }
if (!IsSummonedBagID(inst->GetItem()->ID)) { continue; }
@ -2410,6 +2524,9 @@ void Client::DisenchantSummonedBags(bool client_update)
void Client::RemoveNoRent(bool client_update)
{
for (auto slot_id = EQEmu::invslot::EQUIPMENT_BEGIN; slot_id <= EQEmu::invslot::EQUIPMENT_END; ++slot_id) {
if (((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
auto inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) {
Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id);
@ -2418,6 +2535,9 @@ void Client::RemoveNoRent(bool client_update)
}
for (auto slot_id = EQEmu::invslot::GENERAL_BEGIN; slot_id <= EQEmu::invslot::GENERAL_END; ++slot_id) {
if (((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
auto inst = m_inv[slot_id];
if (inst && !inst->GetItem()->NoRent) {
Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id);
@ -2425,15 +2545,11 @@ void Client::RemoveNoRent(bool client_update)
}
}
if (m_inv[EQEmu::invslot::SLOT_POWER_SOURCE]) {
auto inst = m_inv[EQEmu::invslot::SLOT_POWER_SOURCE];
if (inst && !inst->GetItem()->NoRent) {
Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, EQEmu::invslot::SLOT_POWER_SOURCE);
DeleteItemInInventory(EQEmu::invslot::SLOT_POWER_SOURCE, 0, (ClientVersion() >= EQEmu::versions::ClientVersion::SoF) ? client_update : false); // Ti slot non-existent
}
}
for (auto slot_id = EQEmu::invbag::GENERAL_BAGS_BEGIN; slot_id <= EQEmu::invbag::CURSOR_BAG_END; ++slot_id) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_id - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) == 0)
continue;
auto inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) {
Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id);
@ -2442,6 +2558,9 @@ void Client::RemoveNoRent(bool client_update)
}
for (auto slot_id = EQEmu::invslot::BANK_BEGIN; slot_id <= EQEmu::invslot::BANK_END; ++slot_id) {
if ((slot_id - EQEmu::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
continue;
auto inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) {
Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id);
@ -2450,6 +2569,10 @@ void Client::RemoveNoRent(bool client_update)
}
for (auto slot_id = EQEmu::invbag::BANK_BAGS_BEGIN; slot_id <= EQEmu::invbag::BANK_BAGS_END; ++slot_id) {
auto temp_slot = (slot_id - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
if (temp_slot >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
continue;
auto inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) {
Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id);
@ -2504,6 +2627,9 @@ void Client::RemoveNoRent(bool client_update)
void Client::RemoveDuplicateLore(bool client_update)
{
for (auto slot_id = EQEmu::invslot::EQUIPMENT_BEGIN; slot_id <= EQEmu::invslot::EQUIPMENT_END; ++slot_id) {
if (((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
auto inst = m_inv.PopItem(slot_id);
if (inst == nullptr) { continue; }
if(CheckLoreConflict(inst->GetItem())) {
@ -2517,6 +2643,9 @@ void Client::RemoveDuplicateLore(bool client_update)
}
for (auto slot_id = EQEmu::invslot::GENERAL_BEGIN; slot_id <= EQEmu::invslot::GENERAL_END; ++slot_id) {
if (((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
auto inst = m_inv.PopItem(slot_id);
if (inst == nullptr) { continue; }
if (CheckLoreConflict(inst->GetItem())) {
@ -2529,21 +2658,11 @@ void Client::RemoveDuplicateLore(bool client_update)
safe_delete(inst);
}
if (m_inv[EQEmu::invslot::SLOT_POWER_SOURCE]) {
auto inst = m_inv.PopItem(EQEmu::invslot::SLOT_POWER_SOURCE);
if (inst) {
if (CheckLoreConflict(inst->GetItem())) {
Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, EQEmu::invslot::SLOT_POWER_SOURCE);
database.SaveInventory(character_id, nullptr, EQEmu::invslot::SLOT_POWER_SOURCE);
}
else {
m_inv.PutItem(EQEmu::invslot::SLOT_POWER_SOURCE, *inst);
}
safe_delete(inst);
}
}
for (auto slot_id = EQEmu::invbag::GENERAL_BAGS_BEGIN; slot_id <= EQEmu::invbag::CURSOR_BAG_END; ++slot_id) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_id - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) == 0)
continue;
auto inst = m_inv.PopItem(slot_id);
if (inst == nullptr) { continue; }
if(CheckLoreConflict(inst->GetItem())) {
@ -2557,6 +2676,9 @@ void Client::RemoveDuplicateLore(bool client_update)
}
for (auto slot_id = EQEmu::invslot::BANK_BEGIN; slot_id <= EQEmu::invslot::BANK_END; ++slot_id) {
if ((slot_id - EQEmu::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
continue;
auto inst = m_inv.PopItem(slot_id);
if (inst == nullptr) { continue; }
if(CheckLoreConflict(inst->GetItem())) {
@ -2570,6 +2692,10 @@ void Client::RemoveDuplicateLore(bool client_update)
}
for (auto slot_id = EQEmu::invbag::BANK_BAGS_BEGIN; slot_id <= EQEmu::invbag::BANK_BAGS_END; ++slot_id) {
auto temp_slot = (slot_id - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
if (temp_slot >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
continue;
auto inst = m_inv.PopItem(slot_id);
if (inst == nullptr) { continue; }
if(CheckLoreConflict(inst->GetItem())) {
@ -2642,15 +2768,21 @@ void Client::MoveSlotNotAllowed(bool client_update)
}
}
if (m_inv[EQEmu::invslot::SLOT_POWER_SOURCE] && !m_inv[EQEmu::invslot::SLOT_POWER_SOURCE]->IsSlotAllowed(EQEmu::invslot::SLOT_POWER_SOURCE)) {
auto inst = m_inv.PopItem(EQEmu::invslot::SLOT_POWER_SOURCE);
bool is_arrow = (inst->GetItem()->ItemType == EQEmu::item::ItemTypeArrow) ? true : false;
int16 free_slot_id = m_inv.FindFreeSlot(inst->IsClassBag(), true, inst->GetItem()->Size, is_arrow);
Log(Logs::Detail, Logs::Inventory, "Slot Assignment Error: Moving %s from slot %i to %i", inst->GetItem()->Name, EQEmu::invslot::SLOT_POWER_SOURCE, free_slot_id);
PutItemInInventory(free_slot_id, *inst, (ClientVersion() >= EQEmu::versions::ClientVersion::SoF) ? client_update : false);
database.SaveInventory(character_id, nullptr, EQEmu::invslot::SLOT_POWER_SOURCE);
safe_delete(inst);
}
// added this check to move any client-based excluded slots
//for (auto slot_id = EQEmu::invslot::POSSESSIONS_BEGIN; slot_id <= EQEmu::invslot::POSSESSIONS_END; ++slot_id) {
// if (((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask != 0)
// continue;
// if (m_inv[slot_id]) { // this is currently dangerous for bag-based movements since limbo does not save bag slots
// auto inst = m_inv.PopItem(slot_id);
// bool is_arrow = (inst->GetItem()->ItemType == EQEmu::item::ItemTypeArrow) ? true : false;
// int16 free_slot_id = m_inv.FindFreeSlot(inst->IsClassBag(), true, inst->GetItem()->Size, is_arrow);
// Log(Logs::Detail, Logs::Inventory, "Slot Assignment Error: Moving %s from slot %i to %i", inst->GetItem()->Name, slot_id, free_slot_id);
// PutItemInInventory(free_slot_id, *inst, client_update);
// database.SaveInventory(character_id, nullptr, slot_id);
// safe_delete(inst);
// }
//}
// No need to check inventory, cursor, bank or shared bank since they allow max item size and containers
// Code can be added to check item size vs. container size, but it is left to attrition for now.
@ -2716,7 +2848,26 @@ void Client::SendItemPacket(int16 slot_id, const EQEmu::ItemInstance* inst, Item
if (!inst)
return;
// Serialize item into |-delimited string
if (slot_id <= EQEmu::invslot::POSSESSIONS_END && slot_id >= EQEmu::invslot::POSSESSIONS_BEGIN) {
if ((((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask) == 0)
return;
}
else if (slot_id <= EQEmu::invbag::GENERAL_BAGS_END && slot_id >= EQEmu::invbag::GENERAL_BAGS_BEGIN) {
auto temp_slot = EQEmu::invslot::GENERAL_BEGIN + ((slot_id - EQEmu::invbag::GENERAL_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT);
if ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) == 0)
return;
}
else if (slot_id <= EQEmu::invslot::BANK_END && slot_id >= EQEmu::invslot::BANK_BEGIN) {
if ((slot_id - EQEmu::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
return;
}
else if (slot_id <= EQEmu::invbag::BANK_BAGS_END && slot_id >= EQEmu::invbag::BANK_BAGS_BEGIN) {
auto temp_slot = (slot_id - EQEmu::invbag::BANK_BAGS_BEGIN) / EQEmu::invbag::SLOT_COUNT;
if (temp_slot >= GetInv().GetLookup()->InventoryTypeSize[EQEmu::invtype::typeBank])
return;
}
// Serialize item into |-delimited string (Titanium- uses '|' delimiter .. newer clients use pure data serialization)
std::string packet = inst->Serialize(slot_id);
EmuOpcode opcode = OP_Unknown;
@ -3000,6 +3151,8 @@ bool Client::MoveItemToInventory(EQEmu::ItemInstance *ItemToReturn, bool UpdateC
if(ItemToReturn->IsStackable()) {
for (int16 i = EQEmu::invslot::GENERAL_BEGIN; i <= EQEmu::invslot::slotCursor; i++) { // changed slot max to 30 from 29. client will stack into slot 30 (bags too) before moving.
if (((uint64)1 << i) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
EQEmu::ItemInstance* InvItem = m_inv.GetItem(i);
@ -3059,6 +3212,8 @@ bool Client::MoveItemToInventory(EQEmu::ItemInstance *ItemToReturn, bool UpdateC
// We have tried stacking items, now just try and find an empty slot.
for (int16 i = EQEmu::invslot::GENERAL_BEGIN; i <= EQEmu::invslot::slotCursor; i++) { // changed slot max to 30 from 29. client will move into slot 30 (bags too) before pushing onto cursor.
if (((uint64)1 << i) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue;
EQEmu::ItemInstance* InvItem = m_inv.GetItem(i);
@ -3119,7 +3274,7 @@ bool Client::InterrogateInventory(Client* requester, bool log, bool silent, bool
std::map<int16, const EQEmu::ItemInstance*> instmap;
// build reference map
for (int16 index = EQEmu::invslot::EQUIPMENT_BEGIN; index <= EQEmu::invslot::POSSESSIONS_END; ++index) {
for (int16 index = EQEmu::invslot::POSSESSIONS_BEGIN; index <= EQEmu::invslot::POSSESSIONS_END; ++index) {
auto inst = m_inv[index];
if (inst == nullptr) { continue; }
instmap[index] = inst;
@ -3163,9 +3318,6 @@ bool Client::InterrogateInventory(Client* requester, bool log, bool silent, bool
instmap[8000 + limbo] = *cursor_itr;
}
if (m_inv[EQEmu::invslot::SLOT_POWER_SOURCE])
instmap[EQEmu::invslot::SLOT_POWER_SOURCE] = m_inv[EQEmu::invslot::SLOT_POWER_SOURCE];
// call InterrogateInventory_ for error check
for (auto instmap_itr = instmap.begin(); (instmap_itr != instmap.end()) && (!error); ++instmap_itr) {
InterrogateInventory_(true, requester, instmap_itr->first, INVALID_INDEX, instmap_itr->second, nullptr, log, silent, error, 0);
@ -3270,8 +3422,7 @@ bool Client::InterrogateInventory_error(int16 head, int16 index, const EQEmu::It
(head >= EQEmu::invslot::EQUIPMENT_BEGIN && head <= EQEmu::invslot::EQUIPMENT_END) ||
(head >= EQEmu::invslot::TRIBUTE_BEGIN && head <= EQEmu::invslot::TRIBUTE_END) ||
(head >= EQEmu::invslot::WORLD_BEGIN && head <= EQEmu::invslot::WORLD_END) ||
(head >= 8000 && head <= 8101) ||
(head == EQEmu::invslot::SLOT_POWER_SOURCE)) {
(head >= 8000 && head <= 8101)) {
switch (depth)
{
case 0: // requirement: inst is extant

View File

@ -323,7 +323,7 @@ void NPC::AddLootDrop(const EQEmu::ItemData *item2, ItemList* itemlist, int16 ch
// @merth: IDFile size has been increased, this needs to change
uint16 emat;
if(item2->Material <= 0
|| item2->Slots & (1 << EQEmu::invslot::slotPrimary | 1 << EQEmu::invslot::slotSecondary)) {
|| (item2->Slots & ((1 << EQEmu::invslot::slotPrimary) | (1 << EQEmu::invslot::slotSecondary)))) {
memset(newid, 0, sizeof(newid));
for(int i=0;i<7;i++){
if (!isalpha(item2->IDFile[i])){

View File

@ -1870,27 +1870,22 @@ luabind::scope lua_register_slot() {
luabind::value("Face", static_cast<int>(EQEmu::invslot::slotFace)),
luabind::value("Ear2", static_cast<int>(EQEmu::invslot::slotEar2)),
luabind::value("Neck", static_cast<int>(EQEmu::invslot::slotNeck)),
luabind::value("Shoulder", static_cast<int>(EQEmu::invslot::slotShoulders)), // deprecated
luabind::value("Shoulders", static_cast<int>(EQEmu::invslot::slotShoulders)),
luabind::value("Arms", static_cast<int>(EQEmu::invslot::slotArms)),
luabind::value("Back", static_cast<int>(EQEmu::invslot::slotBack)),
luabind::value("Bracer1", static_cast<int>(EQEmu::invslot::slotWrist1)), // deprecated
luabind::value("Wrist1", static_cast<int>(EQEmu::invslot::slotWrist1)),
luabind::value("Bracer2", static_cast<int>(EQEmu::invslot::slotWrist2)), // deprecated
luabind::value("Wrist2", static_cast<int>(EQEmu::invslot::slotWrist2)),
luabind::value("Range", static_cast<int>(EQEmu::invslot::slotRange)),
luabind::value("Hands", static_cast<int>(EQEmu::invslot::slotHands)),
luabind::value("Primary", static_cast<int>(EQEmu::invslot::slotPrimary)),
luabind::value("Secondary", static_cast<int>(EQEmu::invslot::slotSecondary)),
luabind::value("Ring1", static_cast<int>(EQEmu::invslot::slotFinger1)), // deprecated
luabind::value("Finger1", static_cast<int>(EQEmu::invslot::slotFinger1)),
luabind::value("Ring2", static_cast<int>(EQEmu::invslot::slotFinger2)), // deprecated
luabind::value("Finger2", static_cast<int>(EQEmu::invslot::slotFinger2)),
luabind::value("Chest", static_cast<int>(EQEmu::invslot::slotChest)),
luabind::value("Legs", static_cast<int>(EQEmu::invslot::slotLegs)),
luabind::value("Feet", static_cast<int>(EQEmu::invslot::slotFeet)),
luabind::value("Waist", static_cast<int>(EQEmu::invslot::slotWaist)),
luabind::value("PowerSource", static_cast<int>(EQEmu::invslot::SLOT_POWER_SOURCE)),
luabind::value("PowerSource", static_cast<int>(EQEmu::invslot::slotPowerSource)),
luabind::value("Ammo", static_cast<int>(EQEmu::invslot::slotAmmo)),
luabind::value("General1", static_cast<int>(EQEmu::invslot::slotGeneral1)),
luabind::value("General2", static_cast<int>(EQEmu::invslot::slotGeneral2)),
@ -1900,15 +1895,43 @@ luabind::scope lua_register_slot() {
luabind::value("General6", static_cast<int>(EQEmu::invslot::slotGeneral6)),
luabind::value("General7", static_cast<int>(EQEmu::invslot::slotGeneral7)),
luabind::value("General8", static_cast<int>(EQEmu::invslot::slotGeneral8)),
luabind::value("General9", static_cast<int>(EQEmu::invslot::slotGeneral9)),
luabind::value("General10", static_cast<int>(EQEmu::invslot::slotGeneral10)),
luabind::value("Cursor", static_cast<int>(EQEmu::invslot::slotCursor)),
luabind::value("PersonalBegin", static_cast<int>(EQEmu::invslot::GENERAL_BEGIN)), // deprecated
luabind::value("PossessionsBegin", static_cast<int>(EQEmu::invslot::POSSESSIONS_BEGIN)),
luabind::value("PossessionsEnd", static_cast<int>(EQEmu::invslot::POSSESSIONS_END)),
luabind::value("EquipmentBegin", static_cast<int>(EQEmu::invslot::EQUIPMENT_BEGIN)),
luabind::value("EquipmentEnd", static_cast<int>(EQEmu::invslot::EQUIPMENT_END)),
luabind::value("GeneralBegin", static_cast<int>(EQEmu::invslot::GENERAL_BEGIN)),
luabind::value("PersonalEnd", static_cast<int>(EQEmu::invslot::GENERAL_END)), // deprecated
luabind::value("GeneralEnd", static_cast<int>(EQEmu::invslot::GENERAL_END)),
luabind::value("GeneralBagsBegin", static_cast<int>(EQEmu::invbag::GENERAL_BAGS_BEGIN)),
luabind::value("GeneralBagsEnd", static_cast<int>(EQEmu::invbag::GENERAL_BAGS_END)),
luabind::value("CursorBagBegin", static_cast<int>(EQEmu::invbag::CURSOR_BAG_BEGIN)),
luabind::value("CursorBagEnd", static_cast<int>(EQEmu::invbag::CURSOR_BAG_END)),
luabind::value("BankBegin", static_cast<int>(EQEmu::invslot::BANK_BEGIN)),
luabind::value("BankEnd", static_cast<int>(EQEmu::invslot::BANK_END)),
luabind::value("BankBagsBegin", static_cast<int>(EQEmu::invbag::BANK_BAGS_BEGIN)),
luabind::value("BankBagsEnd", static_cast<int>(EQEmu::invbag::BANK_BAGS_END)),
luabind::value("SharedBankBegin", static_cast<int>(EQEmu::invslot::SHARED_BANK_BEGIN)),
luabind::value("SharedBankEnd", static_cast<int>(EQEmu::invslot::SHARED_BANK_END)),
luabind::value("SharedBankBagsBegin", static_cast<int>(EQEmu::invbag::SHARED_BANK_BAGS_BEGIN)),
luabind::value("SharedBankBagsEnd", static_cast<int>(EQEmu::invbag::SHARED_BANK_BAGS_END)),
luabind::value("BagSlotBegin", static_cast<int>(EQEmu::invbag::SLOT_BEGIN)),
luabind::value("BagSlotEnd", static_cast<int>(EQEmu::invbag::SLOT_END)),
luabind::value("AugSocketBegin", static_cast<int>(EQEmu::invaug::SOCKET_BEGIN)),
luabind::value("AugSocketEnd", static_cast<int>(EQEmu::invaug::SOCKET_END)),
luabind::value("Invalid", static_cast<int>(EQEmu::invslot::SLOT_INVALID)),
luabind::value("Shoulder", static_cast<int>(EQEmu::invslot::slotShoulders)), // deprecated
luabind::value("Bracer1", static_cast<int>(EQEmu::invslot::slotWrist1)), // deprecated
luabind::value("Bracer2", static_cast<int>(EQEmu::invslot::slotWrist2)), // deprecated
luabind::value("Ring1", static_cast<int>(EQEmu::invslot::slotFinger1)), // deprecated
luabind::value("Ring2", static_cast<int>(EQEmu::invslot::slotFinger2)), // deprecated
luabind::value("PersonalBegin", static_cast<int>(EQEmu::invslot::GENERAL_BEGIN)), // deprecated
luabind::value("PersonalEnd", static_cast<int>(EQEmu::invslot::GENERAL_END)), // deprecated
luabind::value("CursorEnd", 0xFFFE), // deprecated
luabind::value("Tradeskill", static_cast<int>(EQEmu::legacy::SLOT_TRADESKILL)), // deprecated
luabind::value("Augment", static_cast<int>(EQEmu::legacy::SLOT_AUGMENT)), // deprecated
luabind::value("Invalid", INVALID_INDEX)
luabind::value("Augment", static_cast<int>(EQEmu::legacy::SLOT_AUGMENT)) // deprecated
];
}
@ -1919,16 +1942,17 @@ luabind::scope lua_register_material() {
luabind::value("Head", static_cast<int>(EQEmu::textures::armorHead)),
luabind::value("Chest", static_cast<int>(EQEmu::textures::armorChest)),
luabind::value("Arms", static_cast<int>(EQEmu::textures::armorArms)),
luabind::value("Bracer", static_cast<int>(EQEmu::textures::armorWrist)), // deprecated
luabind::value("Wrist", static_cast<int>(EQEmu::textures::armorWrist)),
luabind::value("Hands", static_cast<int>(EQEmu::textures::armorHands)),
luabind::value("Legs", static_cast<int>(EQEmu::textures::armorLegs)),
luabind::value("Feet", static_cast<int>(EQEmu::textures::armorFeet)),
luabind::value("Primary", static_cast<int>(EQEmu::textures::weaponPrimary)),
luabind::value("Secondary", static_cast<int>(EQEmu::textures::weaponSecondary)),
luabind::value("Max", static_cast<int>(EQEmu::textures::materialCount)), // deprecated
luabind::value("Count", static_cast<int>(EQEmu::textures::materialCount)),
luabind::value("Invalid", static_cast<int>(EQEmu::textures::materialInvalid))
luabind::value("Invalid", static_cast<int>(EQEmu::textures::materialInvalid)),
luabind::value("Bracer", static_cast<int>(EQEmu::textures::armorWrist)), // deprecated
luabind::value("Max", static_cast<int>(EQEmu::textures::materialCount)) // deprecated
];
}

View File

@ -217,22 +217,16 @@ void Merc::CalcItemBonuses(StatBonuses* newbon) {
unsigned int i;
//should not include 21 (SLOT_AMMO)
for (i = 0; i < EQEmu::invslot::slotAmmo; i++) {
if(equipment[i] == 0)
for (i = EQEmu::invslot::BONUS_BEGIN; i <= EQEmu::invslot::BONUS_STAT_END; i++) {
if (i == EQEmu::invslot::slotAmmo)
continue;
if (equipment[i] == 0)
continue;
const EQEmu::ItemData * itm = database.GetItem(equipment[i]);
if(itm)
if (itm)
AddItemBonuses(itm, newbon);
}
//Power Source Slot
/*if (GetClientVersion() >= EQClientSoF)
{
const EQEmu::ItemInstance* inst = m_inv[MainPowerSource];
if(inst)
AddItemBonuses(inst, newbon);
}*/
// Caps
if(newbon->HPRegen > CalcHPRegenCap())
newbon->HPRegen = CalcHPRegenCap();

View File

@ -3026,7 +3026,7 @@ XS(XS_Client_SummonItem) {
dXSARGS;
if (items < 2 || items > 10)
Perl_croak(aTHX_
"Usage: Client::SummonItem(THIS, uint32 item_id, [int16 charges = -1], [bool attune = false], [uint32 aug1 = 0], [uint32 aug2 = 0], [uint32 aug3 = 0], [uint32 aug4 = 0], [uint32 aug5 = 0], [uint16 slot_id = 30])");
"Usage: Client::SummonItem(THIS, uint32 item_id, [int16 charges = -1], [bool attune = false], [uint32 aug1 = 0], [uint32 aug2 = 0], [uint32 aug3 = 0], [uint32 aug4 = 0], [uint32 aug5 = 0], [uint16 slot_id = cursor])");
{
Client *THIS;
uint32 item_id = (uint32) SvUV(ST(1));
@ -3037,7 +3037,7 @@ XS(XS_Client_SummonItem) {
uint32 aug3 = 0;
uint32 aug4 = 0;
uint32 aug5 = 0;
uint16 slot_id = 30;
uint16 slot_id = EQEmu::invslot::slotCursor;
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));

View File

@ -527,7 +527,7 @@ void NPC::GetPetState(SpellBuff_Struct *pet_buffs, uint32 *items, char *name) {
memcpy(items, equipment, sizeof(uint32) * EQEmu::invslot::EQUIPMENT_COUNT);
//save their buffs.
for (int i=0; i < GetPetMaxTotalSlots(); i++) {
for (int i=EQEmu::invslot::EQUIPMENT_BEGIN; i < GetPetMaxTotalSlots(); i++) {
if (buffs[i].spellid != SPELL_UNKNOWN) {
pet_buffs[i].spellid = buffs[i].spellid;
pet_buffs[i].effect_type = i+1;

View File

@ -281,7 +281,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
return(false);
}
}
if (itm && (itm->GetItem()->Click.Type == EQEmu::item::ItemEffectEquipClick) && !(item_slot <= EQEmu::invslot::slotAmmo || item_slot == EQEmu::invslot::SLOT_POWER_SOURCE)){
if (itm && (itm->GetItem()->Click.Type == EQEmu::item::ItemEffectEquipClick) && item_slot > EQEmu::invslot::EQUIPMENT_END){
if (CastToClient()->ClientVersion() < EQEmu::versions::ClientVersion::SoF) {
// They are attempting to cast a must equip clicky without having it equipped
Log(Logs::General, Logs::Error, "HACKER: %s (account: %s) attempted to click an equip-only effect on item %s (id: %d) without equiping it!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID);

View File

@ -1202,7 +1202,7 @@ void Client::SendSingleTraderItem(uint32 CharID, int SerialNumber) {
EQEmu::ItemInstance* inst= database.LoadSingleTraderItem(CharID, SerialNumber);
if(inst) {
SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor?
SendItemPacket(EQEmu::invslot::slotCursor, inst, ItemPacketMerchant); // MainCursor?
safe_delete(inst);
}
@ -1233,7 +1233,7 @@ void Client::BulkSendTraderInventory(uint32 char_id) {
}
inst->SetPrice(TraderItems->ItemCost[i]);
SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor?
SendItemPacket(EQEmu::invslot::slotCursor, inst, ItemPacketMerchant); // MainCursor?
safe_delete(inst);
}
else
@ -2072,7 +2072,7 @@ static void UpdateTraderCustomerItemsAdded(uint32 CustomerID, TraderCharges_Stru
Log(Logs::Detail, Logs::Trading, "Sending price update for %s, Serial No. %i with %i charges",
item->Name, gis->SerialNumber[i], gis->Charges[i]);
Customer->SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor?
Customer->SendItemPacket(EQEmu::invslot::slotCursor, inst, ItemPacketMerchant); // MainCursor?
}
}
@ -2156,7 +2156,7 @@ static void UpdateTraderCustomerPriceChanged(uint32 CustomerID, TraderCharges_St
Log(Logs::Detail, Logs::Trading, "Sending price update for %s, Serial No. %i with %i charges",
item->Name, gis->SerialNumber[i], gis->Charges[i]);
Customer->SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor??
Customer->SendItemPacket(EQEmu::invslot::slotCursor, inst, ItemPacketMerchant); // MainCursor??
}
safe_delete(inst);
}