From d7c2d6108fe436f8c440bef5a925799eb7633eb9 Mon Sep 17 00:00:00 2001 From: Uleat Date: Wed, 16 Jul 2014 21:23:16 -0400 Subject: [PATCH] Added the initial references for two new dictionaries - EmuConstants and EQLimits..more to come. --- changelog.txt | 4 + common/CMakeLists.txt | 2 + common/Item.cpp | 154 ++++++++-------- common/clientversions.h | 56 ++++-- common/eq_constants.h | 241 +++++++++++++++++------- common/eq_dictionary.cpp | 363 +++++++++++++++++++++++++++++++++++++ common/eq_dictionary.h | 118 ++++++++++++ common/eq_packet_structs.h | 3 +- common/item_struct.h | 12 +- common/shareddb.cpp | 12 +- common/skills.h | 5 +- zone/MobAI.cpp | 2 +- zone/Object.cpp | 8 +- zone/attack.cpp | 52 +++--- zone/bonuses.cpp | 18 +- zone/bot.cpp | 251 ++++++++++++------------- zone/client.cpp | 111 +++++++----- zone/client.h | 2 +- zone/client_mods.cpp | 4 +- zone/client_packet.cpp | 32 ++-- zone/client_process.cpp | 12 +- zone/command.cpp | 24 +-- zone/corpse.cpp | 10 +- zone/doors.cpp | 6 +- zone/forage.cpp | 14 +- zone/inventory.cpp | 165 ++++++++--------- zone/loottables.cpp | 22 +-- zone/lua_general.cpp | 79 +++++--- zone/merc.cpp | 22 +-- zone/merc.h | 12 +- zone/mob.cpp | 18 +- zone/npc.cpp | 2 +- zone/npc.h | 10 +- zone/pets.cpp | 10 +- zone/special_attacks.cpp | 75 ++++---- zone/spell_effects.cpp | 12 +- zone/spells.cpp | 4 +- zone/titles.cpp | 2 +- zone/tradeskills.cpp | 4 +- zone/trading.cpp | 20 +- zone/zonedb.cpp | 10 +- zone/zonedb.h | 2 +- 42 files changed, 1323 insertions(+), 662 deletions(-) create mode 100644 common/eq_dictionary.cpp create mode 100644 common/eq_dictionary.h diff --git a/changelog.txt b/changelog.txt index 88a629067..3532d6e1d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,9 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 07/16/2014 == +Uleat: Initial commit of new client/server 'dictionaries' - work in-progress... Changed equipment slot references to reflect new naming +conventions. Lua enumerations maintain both the old and new names as to not break existing scripts..but, the old names are deprecated. + == 07/14/2014 == KLS: Changes to CMake build -Lua builds by default now diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index bcd054098..31dfcc978 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -14,6 +14,7 @@ SET(common_sources emu_opcodes.cpp EmuTCPConnection.cpp EmuTCPServer.cpp + eq_dictionary.cpp EQDB.cpp EQDBRes.cpp eqemu_exception.cpp @@ -111,6 +112,7 @@ SET(common_headers EmuTCPConnection.h EmuTCPServer.h eq_constants.h + eq_dictionary.h eq_packet_structs.h EQDB.h EQDBRes.h diff --git a/common/Item.cpp b/common/Item.cpp index 975275c41..b046635c6 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -166,7 +166,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const ItemInst* result = nullptr; // Cursor - if (slot_id == SLOT_CURSOR) { + if (slot_id == MainCursor) { // Cursor slot result = m_cursor.peek_front(); } @@ -258,7 +258,7 @@ int16 Inventory::PutItem(int16 slot_id, const ItemInst& inst) int16 Inventory::PushCursor(const ItemInst& inst) { m_cursor.push(inst.Clone()); - return SLOT_CURSOR; + return MainCursor; } // Swap items in inventory @@ -332,7 +332,7 @@ ItemInst* Inventory::PopItem(int16 slot_id) { ItemInst* p = nullptr; - if (slot_id == SLOT_CURSOR) { // Cursor + if (slot_id == MainCursor) { // Cursor p = m_cursor.pop(); } else if ((slot_id >= 0 && slot_id <= 21) || (slot_id >= 400 && slot_id <= 404) || (slot_id == 9999)) { // Worn slots @@ -469,7 +469,7 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) { //when quantity is greater than 1 and not all of quantity can be found in 1 stack. int16 Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where) { - int16 slot_id = SLOT_INVALID; + int16 slot_id = INVALID_INDEX; //Altered by Father Nitwit to support a specification of //where to search, with a default value to maintain compatibility @@ -477,38 +477,38 @@ int16 Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where) // Check each inventory bucket if (where & invWhereWorn) { slot_id = _HasItem(m_worn, item_id, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWherePersonal) { slot_id = _HasItem(m_inv, item_id, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereBank) { slot_id = _HasItem(m_bank, item_id, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereSharedBank) { slot_id = _HasItem(m_shbank, item_id, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereTrading) { slot_id = _HasItem(m_trade, item_id, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereCursor) { // Check cursor queue slot_id = _HasItem(m_cursor, item_id, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } @@ -518,43 +518,43 @@ int16 Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where) //this function has the same quantity flaw mentioned above in HasItem() int16 Inventory::HasItemByUse(uint8 use, uint8 quantity, uint8 where) { - int16 slot_id = SLOT_INVALID; + int16 slot_id = INVALID_INDEX; // Check each inventory bucket if (where & invWhereWorn) { slot_id = _HasItemByUse(m_worn, use, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWherePersonal) { slot_id = _HasItemByUse(m_inv, use, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereBank) { slot_id = _HasItemByUse(m_bank, use, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereSharedBank) { slot_id = _HasItemByUse(m_shbank, use, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereTrading) { slot_id = _HasItemByUse(m_trade, use, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereCursor) { // Check cursor queue slot_id = _HasItemByUse(m_cursor, use, quantity); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } @@ -563,43 +563,43 @@ int16 Inventory::HasItemByUse(uint8 use, uint8 quantity, uint8 where) int16 Inventory::HasItemByLoreGroup(uint32 loregroup, uint8 where) { - int16 slot_id = SLOT_INVALID; + int16 slot_id = INVALID_INDEX; // Check each inventory bucket if (where & invWhereWorn) { slot_id = _HasItemByLoreGroup(m_worn, loregroup); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWherePersonal) { slot_id = _HasItemByLoreGroup(m_inv, loregroup); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereBank) { slot_id = _HasItemByLoreGroup(m_bank, loregroup); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereSharedBank) { slot_id = _HasItemByLoreGroup(m_shbank, loregroup); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereTrading) { slot_id = _HasItemByLoreGroup(m_trade, loregroup); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } if (where & invWhereCursor) { // Check cursor queue slot_id = _HasItemByLoreGroup(m_cursor, loregroup); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) return slot_id; } @@ -644,21 +644,21 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo if (try_cursor) // Always room on cursor (it's a queue) // (we may wish to cap this in the future) - return SLOT_CURSOR; + return MainCursor; // No available slots - return SLOT_INVALID; + return INVALID_INDEX; } // Opposite of below: Get parent bag slot_id from a slot inside of bag int16 Inventory::CalcSlotId(int16 slot_id) { - int16 parent_slot_id = SLOT_INVALID; + int16 parent_slot_id = INVALID_INDEX; if (slot_id >= 251 && slot_id <= 330) parent_slot_id = IDX_INV + (slot_id - 251) / MAX_ITEMS_PER_BAG; else if (slot_id >= 331 && slot_id <= 340) - parent_slot_id = SLOT_CURSOR; + parent_slot_id = MainCursor; else if (slot_id >= 2000 && slot_id <= 2023) parent_slot_id = IDX_BANK + (slot_id - 2000) / MAX_ITEMS_PER_BAG; else if (slot_id >= 2031 && slot_id <= 2270) @@ -675,12 +675,12 @@ int16 Inventory::CalcSlotId(int16 slot_id) int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx) { if (!Inventory::SupportsContainers(bagslot_id)) { - return SLOT_INVALID; + return INVALID_INDEX; } - int16 slot_id = SLOT_INVALID; + int16 slot_id = INVALID_INDEX; - if (bagslot_id == SLOT_CURSOR || bagslot_id == 8000) // Cursor + if (bagslot_id == MainCursor || bagslot_id == 8000) // Cursor slot_id = IDX_CURSOR_BAG + bagidx; else if (bagslot_id >= 22 && bagslot_id <= 29) // Inventory slots slot_id = IDX_INV_BAG + (bagslot_id - 22)*MAX_ITEMS_PER_BAG + bagidx; @@ -721,25 +721,25 @@ int16 Inventory::CalcSlotFromMaterial(uint8 material) switch (material) { case MaterialHead: - return SLOT_HEAD; + return MainHead; case MaterialChest: - return SLOT_CHEST; + return MainChest; case MaterialArms: - return SLOT_ARMS; + return MainArms; case MaterialWrist: - return SLOT_BRACER01; // there's 2 bracers, only one bracer material + return MainWrist1; // there's 2 bracers, only one bracer material case MaterialHands: - return SLOT_HANDS; + return MainHands; case MaterialLegs: - return SLOT_LEGS; + return MainLegs; case MaterialFeet: - return SLOT_FEET; + return MainFeet; case MaterialPrimary: - return SLOT_PRIMARY; + return MainPrimary; case MaterialSecondary: - return SLOT_SECONDARY; + return MainSecondary; default: - return SLOT_INVALID; + return INVALID_INDEX; } } @@ -747,24 +747,24 @@ uint8 Inventory::CalcMaterialFromSlot(int16 equipslot) { switch (equipslot) { - case SLOT_HEAD: + case MainHead: return MaterialHead; - case SLOT_CHEST: + case MainChest: return MaterialChest; - case SLOT_ARMS: + case MainArms: return MaterialArms; - case SLOT_BRACER01: - case SLOT_BRACER02: + case MainWrist1: + //case SLOT_BRACER02: // non-live behavior return MaterialWrist; - case SLOT_HANDS: + case MainHands: return MaterialHands; - case SLOT_LEGS: + case MainLegs: return MaterialLegs; - case SLOT_FEET: + case MainFeet: return MaterialFeet; - case SLOT_PRIMARY: + case MainPrimary: return MaterialPrimary; - case SLOT_SECONDARY: + case MainSecondary: return MaterialSecondary; default: return _MaterialInvalid; @@ -790,7 +790,7 @@ bool Inventory::SupportsContainers(int16 slot_id) if ((slot_id >= 22 && slot_id <= 30) || // Personal inventory slots (slot_id >= 2000 && slot_id <= 2023) || // Bank slots (slot_id >= 2500 && slot_id <= 2501) || // Shared bank slots - (slot_id == SLOT_CURSOR) || // Cursor + (slot_id == MainCursor) || // Cursor (slot_id >= 3000 && slot_id <= 3007)) // Trade window return true; return false; @@ -826,7 +826,7 @@ int Inventory::GetSlotByItemInst(ItemInst *inst) { } if (m_cursor.peek_front() == inst) { - return SLOT_CURSOR; + return MainCursor; } return -1; @@ -944,9 +944,9 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst) return slot_id; } - int16 result = SLOT_INVALID; + int16 result = INVALID_INDEX; - if (slot_id == SLOT_CURSOR) { // Cursor + if (slot_id == MainCursor) { // Cursor // Replace current item on cursor, if exists m_cursor.pop(); // no memory delete, clients of this function know what they are doing m_cursor.push_front(inst); @@ -981,7 +981,7 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst) } } - if (result == SLOT_INVALID) { + if (result == INVALID_INDEX) { LogFile->write(EQEMuLog::Error, "Inventory::_PutItem: Invalid slot_id specified (%i)", slot_id); Inventory::MarkDirty(inst); // Slot not found, clean up } @@ -1007,7 +1007,7 @@ int16 Inventory::_HasItem(std::map& bucket, uint32 item_id, ui return it->first; } - for (int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { if (inst->GetAugmentItemID(i) == item_id && quantity <= 1) return SLOT_AUGMENT; // Only one augment per slot. } @@ -1022,7 +1022,7 @@ int16 Inventory::_HasItem(std::map& bucket, uint32 item_id, ui if (quantity_found >= quantity) return Inventory::CalcSlotId(it->first, itb->first); } - for (int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1) return SLOT_AUGMENT; // Only one augment per slot. } @@ -1031,7 +1031,7 @@ int16 Inventory::_HasItem(std::map& bucket, uint32 item_id, ui } // Not found - return SLOT_INVALID; + return INVALID_INDEX; } // Internal Method: Checks an inventory queue type bucket for a particular item @@ -1049,9 +1049,9 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) if (inst->GetID() == item_id) { quantity_found += (inst->GetCharges() <= 0) ? 1 : inst->GetCharges(); if (quantity_found >= quantity) - return SLOT_CURSOR; + return MainCursor; } - for (int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { if (inst->GetAugmentItemID(i) == item_id && quantity <= 1) return SLOT_AUGMENT; // Only one augment per slot. } @@ -1064,9 +1064,9 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) if (baginst->GetID() == item_id) { quantity_found += (baginst->GetCharges() <= 0) ? 1 : baginst->GetCharges(); if (quantity_found >= quantity) - return Inventory::CalcSlotId(SLOT_CURSOR, itb->first); + return Inventory::CalcSlotId(MainCursor, itb->first); } - for (int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1) return SLOT_AUGMENT; // Only one augment per slot. } @@ -1076,7 +1076,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) } // Not found - return SLOT_INVALID; + return INVALID_INDEX; } // Internal Method: Checks an inventory bucket for a particular item @@ -1111,7 +1111,7 @@ int16 Inventory::_HasItemByUse(std::map& bucket, uint8 use, ui } // Not found - return SLOT_INVALID; + return INVALID_INDEX; } // Internal Method: Checks an inventory queue type bucket for a particular item @@ -1127,7 +1127,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) if (inst && inst->IsType(ItemClassCommon) && inst->GetItem()->ItemType == use) { quantity_found += (inst->GetCharges() <= 0) ? 1 : inst->GetCharges(); if (quantity_found >= quantity) - return SLOT_CURSOR; + return MainCursor; } // Go through bag, if bag @@ -1138,14 +1138,14 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->ItemType == use) { quantity_found += (baginst->GetCharges() <= 0) ? 1 : baginst->GetCharges(); if (quantity_found >= quantity) - return Inventory::CalcSlotId(SLOT_CURSOR, itb->first); + return Inventory::CalcSlotId(MainCursor, itb->first); } } } } // Not found - return SLOT_INVALID; + return INVALID_INDEX; } int16 Inventory::_HasItemByLoreGroup(std::map& bucket, uint32 loregroup) @@ -1162,7 +1162,7 @@ int16 Inventory::_HasItemByLoreGroup(std::map& bucket, uint32 return it->first; ItemInst* Aug; - for (int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { Aug = inst->GetAugment(i); if (Aug && Aug->GetItem()->LoreGroup == loregroup) return SLOT_AUGMENT; // Only one augment per slot. @@ -1177,7 +1177,7 @@ int16 Inventory::_HasItemByLoreGroup(std::map& bucket, uint32 return Inventory::CalcSlotId(it->first, itb->first); ItemInst* Aug2; - for (int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { Aug2 = baginst->GetAugment(i); if (Aug2 && Aug2->GetItem()->LoreGroup == loregroup) return SLOT_AUGMENT; // Only one augment per slot. @@ -1187,7 +1187,7 @@ int16 Inventory::_HasItemByLoreGroup(std::map& bucket, uint32 } // Not found - return SLOT_INVALID; + return INVALID_INDEX; } // Internal Method: Checks an inventory queue type bucket for a particular item @@ -1202,10 +1202,10 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup) if (inst) { if (inst->GetItem()->LoreGroup == loregroup) - return SLOT_CURSOR; + return MainCursor; ItemInst* Aug; - for (int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { Aug = inst->GetAugment(i); if (Aug && Aug->GetItem()->LoreGroup == loregroup) return SLOT_AUGMENT; // Only one augment per slot. @@ -1217,11 +1217,11 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup) for (itb = inst->_begin(); itb != inst->_end(); ++itb) { ItemInst* baginst = itb->second; if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->LoreGroup == loregroup) - return Inventory::CalcSlotId(SLOT_CURSOR, itb->first); + return Inventory::CalcSlotId(MainCursor, itb->first); ItemInst* Aug2; - for (int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { Aug2 = baginst->GetAugment(i); if (Aug2 && Aug2->GetItem()->LoreGroup == loregroup) return SLOT_AUGMENT; // Only one augment per slot. @@ -1232,7 +1232,7 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup) } // Not found - return SLOT_INVALID; + return INVALID_INDEX; } @@ -1656,7 +1656,7 @@ ItemInst* ItemInst::RemoveAugment(uint8 index) bool ItemInst::IsAugmented() { - for (int i = 0; i < MAX_AUGMENT_SLOTS; ++i) + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; ++i) if (GetAugmentItemID(i)) return true; diff --git a/common/clientversions.h b/common/clientversions.h index 583648148..5e4e601a0 100644 --- a/common/clientversions.h +++ b/common/clientversions.h @@ -1,27 +1,47 @@ #ifndef CLIENTVERSIONS_H #define CLIENTVERSIONS_H -static const uint32 BIT_Client62 = 1; -static const uint32 BIT_Titanium = 2; -static const uint32 BIT_SoF = 4; -static const uint32 BIT_SoD = 8; -static const uint32 BIT_Underfoot = 16; -static const uint32 BIT_RoF = 32; -static const uint32 BIT_TitaniumAndEarlier = 3; -static const uint32 BIT_SoFAndLater = 0xFFFFFFFC; -static const uint32 BIT_SoDAndLater = 0xFFFFFFF8; -static const uint32 BIT_UnderfootAndLater = 0xFFFFFFF0; -static const uint32 BIT_RoFAndLater = 0xFFFFFFE0; -static const uint32 BIT_AllClients = 0xFFFFFFFF; +static const uint32 BIT_Client62 = 1; +static const uint32 BIT_Titanium = 2; +static const uint32 BIT_SoF = 4; +static const uint32 BIT_SoD = 8; +static const uint32 BIT_Underfoot = 16; +static const uint32 BIT_RoF = 32; +static const uint32 BIT_RoF2 = 64; + +static const uint32 BIT_TitaniumAndEarlier = 0x00000003; +static const uint32 BIT_SoFAndLater = 0xFFFFFFFC; +static const uint32 BIT_SoDAndLater = 0xFFFFFFF8; +static const uint32 BIT_UnderfootAndLater = 0xFFFFFFF0; +static const uint32 BIT_RoFAndLater = 0xFFFFFFE0; +static const uint32 BIT_RoF2AndLater = 0xFFFFFFC0; +static const uint32 BIT_AllClients = 0xFFFFFFFF; typedef enum { EQClientUnknown = 0, - EQClient62, - EQClientTitanium, - EQClientSoF, - EQClientSoD, - EQClientUnderfoot, - EQClientRoF + EQClient62, // Build: 'Aug 4 2005 15:40:59' + EQClientTitanium, // Build: 'Oct 31 2005 10:33:37' + EQClientSoF, // Build: 'Sep 7 2007 09:11:49' + EQClientSoD, // Build: 'Dec 19 2008 15:22:49' + EQClientUnderfoot, // Build: 'Jun 8 2010 16:44:32' + EQClientRoF, // Build: 'Dec 10 2012 17:35:44' + EQClientRoF2, // Build: 'May 10 2013 23:30:08' + + _EQClientCount, // place new clients before this point (preferably, in release/attribute order) + + // Values below are not implemented, as yet... + + // - RoF2 is added for convenience of implementor..creation client will need to be changed once that client is actually added + // - Code will be added to 'relieve' characters of any illegal inventory items based on their client version. This will + // oversee cheats and mis-placement of starting items whenever a client is loaded. + _EQCreationClient = EQClientRoF, // bump to latest client as new ones are added (make sure that db is updated accordingly) + + EmuNPC = _EQClientCount, + EmuMerc, + EmuBot, + EmuPet, + + _EmuClientCount // array size for EQLimits } EQClientVersion; #endif /* CLIENTVERSIONS_H */ diff --git a/common/eq_constants.h b/common/eq_constants.h index 8b4db6fc3..fabe85ae9 100644 --- a/common/eq_constants.h +++ b/common/eq_constants.h @@ -138,45 +138,86 @@ enum ItemUseTypes : uint8 }; /* -** Augmentation use types (in-work) +** Augmentation use type bitmasks (1-based) ** ** (ref: dbstr_us.txt) ** */ -enum AugmentationUseTypes : uint32 { - AugTypeNone = 0, // not 100% sure on this... - AugTypeGeneralSingleStat, /*1^16^1 (General: Single Stat)^0*/ - AugTypeGeneralMultipleStat, /*2^16^2 (General: Multiple Stat)^0*/ - AugTypeGeneralSpellEffect, /*3^16^3 (General: Spell Effect)^0*/ - AugTypeWeaponGeneral, /*4^16^4 (Weapon: General)^0*/ - AugTypeWeaponElemDamage, /*5^16^5 (Weapon: Elem Damage)^0*/ - AugTypeWeaponBaseDamage, /*6^16^6 (Weapon: Base Damage)^0*/ - AugTypeGeneralGroup, /*7^16^7 (General: Group)^0*/ - AugTypeGeneralRaid, /*8^16^8 (General: Raid)^0*/ - AugTypeGeneralDragonsPoints, /*9^16^9 (General: Dragons Points)^0*/ - AugTypeCraftedCommon, /*10^16^10 (Crafted: Common)^0*/ - AugTypeCraftedGroup1, /*11^16^11 (Crafted: Group)^0*/ - AugTypeCraftedRaid1, /*12^16^12 (Crafted: Raid)^0*/ - AugTypeEnergeiacGroup, /*13^16^13 (Energeiac: Group)^0*/ - AugTypeEnergeiacRaid, /*14^16^14 (Energeiac: Raid)^0*/ - AugTypeEmblem, /*15^16^15 (Emblem)^0*/ - AugTypeCraftedGroup2, /*16^16^16 (Crafted: Group)^0*/ - AugTypeCraftedRaid2, /*17^16^17 (Crafted: Raid)^0*/ - AugTypeUnknown1, /*18^16^18^0*/ - AugTypeUnknown2, /*19^16^19^0*/ - AugTypeOrnamentation, /*20^16^20 (Ornamentation)^0*/ - AugTypeSpecialOrnamentation, /*21^16^21 (Special Ornamentation)^0*/ - AugTypeUnknown3, /*22^16^22^0*/ - AugTypeUnknown4, /*23^16^23^0*/ - AugTypeUnknown5, /*24^16^24^0*/ - AugTypeUnknown6, /*25^16^25^0*/ - AugTypeUnknown7, /*26^16^26^0*/ - AugTypeUnknown8, /*27^16^27^0*/ - AugTypeUnknown9, /*28^16^28^0*/ - AugTypeUnknown10, /*29^16^29^0*/ - AugTypeEpic25, /*30^16^30^0*/ - AugTypeTest, /*31^16^Test^0*/ // listed as 31^16^31^0 in 5-10 client - _AugTypeCount +enum AugmentationUseTypeBitmasks : uint32 { + AugUseNone = 0x00000000, + AugUseGeneralSingleStat = 0x00000001, /*1^16^1 (General: Single Stat)^0*/ + AugUseGeneralMultipleStat = 0x00000002, /*2^16^2 (General: Multiple Stat)^0*/ + AugUseGeneralSpellEffect = 0x00000004, /*3^16^3 (General: Spell Effect)^0*/ + AugUseWeaponGeneral = 0x00000008, /*4^16^4 (Weapon: General)^0*/ + AugUseWeaponElemDamage = 0x00000010, /*5^16^5 (Weapon: Elem Damage)^0*/ + AugUseWeaponBaseDamage = 0x00000020, /*6^16^6 (Weapon: Base Damage)^0*/ + AugUseGeneralGroup = 0x00000040, /*7^16^7 (General: Group)^0*/ + AugUseGeneralRaid = 0x00000080, /*8^16^8 (General: Raid)^0*/ + AugUseGeneralDragonsPoints = 0x00000100, /*9^16^9 (General: Dragons Points)^0*/ + AugUseCraftedCommon = 0x00000200, /*10^16^10 (Crafted: Common)^0*/ + AugUseCraftedGroup1 = 0x00000400, /*11^16^11 (Crafted: Group)^0*/ + AugUseCraftedRaid1 = 0x00000800, /*12^16^12 (Crafted: Raid)^0*/ + AugUseEnergeiacGroup = 0x00001000, /*13^16^13 (Energeiac: Group)^0*/ + AugUseEnergeiacRaid = 0x00002000, /*14^16^14 (Energeiac: Raid)^0*/ + AugUseEmblem = 0x00004000, /*15^16^15 (Emblem)^0*/ + AugUseCraftedGroup2 = 0x00008000, /*16^16^16 (Crafted: Group)^0*/ + AugUseCraftedRaid2 = 0x00010000, /*17^16^17 (Crafted: Raid)^0*/ + AugUseUnknown1 = 0x00020000, /*18^16^18^0*/ + AugUseUnknown2 = 0x00040000, /*19^16^19^0*/ + AugUseOrnamentation = 0x00080000, /*20^16^20 (Ornamentation)^0*/ + AugUseSpecialOrnamentation = 0x00100000, /*21^16^21 (Special Ornamentation)^0*/ + AugUseUnknown3 = 0x00200000, /*22^16^22^0*/ + AugUseUnknown4 = 0x00400000, /*23^16^23^0*/ + AugUseUnknown5 = 0x00800000, /*24^16^24^0*/ + AugUseUnknown6 = 0x01000000, /*25^16^25^0*/ + AugUseUnknown7 = 0x02000000, /*26^16^26^0*/ + AugUseUnknown8 = 0x04000000, /*27^16^27^0*/ + AugUseUnknown9 = 0x08000000, /*28^16^28^0*/ + AugUseUnknown10 = 0x10000000, /*29^16^29^0*/ + AugUseEpic25 = 0x20000000, /*30^16^30^0*/ + AugUseTest = 0x40000000, /*31^16^Test^0*/ // listed as 31^16^31^0 in 5-10 client + AugUseAll = 0xFFFFFFFF +}; + +/* +** Augmentation use types (enumerated) +** +*/ +enum AugmentationUseTypes : uint8 { + AugTypeNone = 0, + AugTypeGeneralSingleStat, + AugTypeGeneralMultipleStat, + AugTypeGeneralSpellEffect, + AugTypeWeaponGeneral, + AugTypeWeaponElemDamage, + AugTypeWeaponBaseDamage, + AugTypeGeneralGroup, + AugTypeGeneralRaid, + AugTypeGeneralDragonsPoints, + AugTypeCraftedCommon, + AugTypeCraftedGroup1, + AugTypeCraftedRaid1, + AugTypeEnergeiacGroup, + AugTypeEnergeiacRaid, + AugTypeEmblem, + AugTypeCraftedGroup2, + AugTypeCraftedRaid2, + AugTypeUnknown1, + AugTypeUnknown2, + AugTypeOrnamentation, + AugTypeSpecialOrnamentation, + AugTypeUnknown3, + AugTypeUnknown4, + AugTypeUnknown5, + AugTypeUnknown6, + AugTypeUnknown7, + AugTypeUnknown8, + AugTypeUnknown9, + AugTypeUnknown10, + AugTypeEpic25, + AugTypeTest, + _AugTypeCount, + AugTypeAll = 255 }; /* @@ -735,10 +776,11 @@ enum MaterialUseSlots : uint8 _MaterialInvalid = 255 }; +/* // Used for worn NPC inventory tracking. NPCs don't use // augments, so only the basic slots need to be kept track of. #define MAX_WORN_INVENTORY 22 - +*/ /* ** Inventory Slot Equipment Enum @@ -768,42 +810,109 @@ enum MaterialUseSlots : uint8 ** */ +enum InventoryMapTypes : int16 { + MapPossessions = 0, + MapBank, + MapSharedBank, + MapTrade, + MapWorld, + MapLimbo, + MapTribute, + MapTrophyTribute, + MapGuildTribute, + MapMerchant, + MapDeleted, + MapCorpse, + MapBazaar, + MapInspect, + MapRealEstate, + MapViewMODPC, + MapViewMODBank, + MapViewMODSharedBank, + MapViewMODLimbo, + MapAltStorage, + MapArchived, + MapMail, + MapGuildTrophyTribute, + MapKrono, + MapOther, + _MapCount +}; + +enum InventoryMainTypes : int16 { + MainCharm = 0, + MainEar1, + MainHead, + MainFace, + MainEar2, + MainNeck, + MainShoulders, + MainArms, + MainBack, + MainWrist1, + MainWrist2, + MainRange, + MainHands, + MainPrimary, + MainSecondary, + MainFinger1, + MainFinger2, + MainChest, + MainLegs, + MainFeet, + MainWaist, + MainPowerSource = 9999, // temp + MainAmmo = 21, // temp + MainGeneral1, + MainGeneral2, + MainGeneral3, + MainGeneral4, + MainGeneral5, + MainGeneral6, + MainGeneral7, + MainGeneral8, + //MainGeneral9, + //MainGeneral10, + MainCursor //, + //_MainCount, +}; + enum InventorySlot { //////////////////////// // Equip slots //////////////////////// - SLOT_CHARM = 0, - SLOT_EAR01 = 1, - SLOT_HEAD = 2, - SLOT_FACE = 3, - SLOT_EAR02 = 4, - SLOT_NECK = 5, - SLOT_SHOULDER = 6, - SLOT_ARMS = 7, - SLOT_BACK = 8, - SLOT_BRACER01 = 9, - SLOT_BRACER02 = 10, - SLOT_RANGE = 11, - SLOT_HANDS = 12, - SLOT_PRIMARY = 13, - SLOT_SECONDARY = 14, - SLOT_RING01 = 15, - SLOT_RING02 = 16, - SLOT_CHEST = 17, - SLOT_LEGS = 18, - SLOT_FEET = 19, - SLOT_WAIST = 20, - SLOT_AMMO = 21, + //SLOT_CHARM = 0, + //SLOT_EAR01 = 1, + //SLOT_HEAD = 2, + //SLOT_FACE = 3, + //SLOT_EAR02 = 4, + //SLOT_NECK = 5, + //SLOT_SHOULDER = 6, + //SLOT_ARMS = 7, + //SLOT_BACK = 8, + //SLOT_BRACER01 = 9, + //SLOT_BRACER02 = 10, + //SLOT_RANGE = 11, + //SLOT_HANDS = 12, + //SLOT_PRIMARY = 13, + //SLOT_SECONDARY = 14, + //SLOT_RING01 = 15, + //SLOT_RING02 = 16, + //SLOT_CHEST = 17, + //SLOT_LEGS = 18, + //SLOT_FEET = 19, + //SLOT_WAIST = 20, + //SLOT_AMMO = 21, //////////////////////// // All other slots //////////////////////// - SLOT_PERSONAL_BEGIN = 22, - SLOT_PERSONAL_END = 29, + //SLOT_PERSONAL_BEGIN = 22, + //SLOT_PERSONAL_END = 29, - SLOT_CURSOR = 30, + //SLOT_CURSOR = 30, SLOT_CURSOR_END = (int16)0xFFFE, // Last item on cursor queue // Cursor bag slots are 331->340 (10 slots) @@ -830,11 +939,15 @@ enum InventorySlot // Slot used in OP_TradeSkillCombine for world tradeskill containers SLOT_TRADESKILL = 1000, - SLOT_AUGMENT = 1001, - SLOT_POWER_SOURCE = 9999, + SLOT_AUGMENT = 1001//, + //SLOT_POWER_SOURCE = 9999//, // Value recognized by client for destroying an item - SLOT_INVALID = (int16)0xFFFF + //SLOT_INVALID = (int16)0xFFFF }; +#define INVALID_INDEX -1 +#define NOT_USED 0 +#define NO_ITEM 0 + #endif diff --git a/common/eq_dictionary.cpp b/common/eq_dictionary.cpp new file mode 100644 index 000000000..4d2b995e6 --- /dev/null +++ b/common/eq_dictionary.cpp @@ -0,0 +1,363 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "eq_dictionary.h" + +// +// class ServerConstants +// +uint16 EmuConstants::InventoryMapSize(int16 map) { + switch (map) { + case MapPossessions: + return MAP_POSSESSIONS_SIZE; + case MapBank: + return MAP_BANK_SIZE; + case MapSharedBank: + return MAP_SHAREDBANK_SIZE; + case MapTrade: + return MAP_TRADE_SIZE; + case MapWorld: + return MAP_WORLD_SIZE; + case MapLimbo: + return MAP_LIMBO_SIZE; + case MapTribute: + return MAP_TRIBUTE_SIZE; + case MapTrophyTribute: + return MAP_TROPHYTRIBUTE_SIZE; + case MapGuildTribute: + return MAP_GUILDTRIBUTE_SIZE; + case MapMerchant: + return MAP_MERCHANT_SIZE; + case MapDeleted: + return MAP_DELETED_SIZE; + case MapCorpse: + return MAP_CORPSE_SIZE; + case MapBazaar: + return MAP_BAZAAR_SIZE; + case MapInspect: + return MAP_INSPECT_SIZE; + case MapRealEstate: + return MAP_REALESTATE_SIZE; + case MapViewMODPC: + return MAP_VIEWMODPC_SIZE; + case MapViewMODBank: + return MAP_VIEWMODBANK_SIZE; + case MapViewMODSharedBank: + return MAP_VIEWMODSHAREDBANK_SIZE; + case MapViewMODLimbo: + return MAP_VIEWMODLIMBO_SIZE; + case MapAltStorage: + return MAP_ALTSTORAGE_SIZE; + case MapArchived: + return MAP_ARCHIVED_SIZE; + case MapMail: + return MAP_MAIL_SIZE; + case MapGuildTrophyTribute: + return MAP_GUILDTROPHYTRIBUTE_SIZE; + case MapKrono: + return MAP_KRONO_SIZE; + case MapOther: + return MAP_OTHER_SIZE; + default: + return NOT_USED; + } +} + +// +// class ClientLimits +// +// client validation +bool EQLimits::IsValidClientVersion(uint32 version) { + if (version < _EQClientCount) + return true; + + return false; +} + +uint32 EQLimits::ValidateClientVersion(uint32 version) { + if (version < _EQClientCount) + return version; + + return EQClientUnknown; +} + +EQClientVersion EQLimits::ValidateClientVersion(EQClientVersion version) { + if (version >= EQClientUnknown) + if (version < _EQClientCount) + return version; + + return EQClientUnknown; +} + +// npc validation +bool EQLimits::IsValidNPCVersion(uint32 version) { + if (version >= _EQClientCount) + if (version < _EmuClientCount) + return true; + + return false; +} + +uint32 EQLimits::ValidateNPCVersion(uint32 version) { + if (version >= _EQClientCount) + if (version < _EmuClientCount) + return version; + + return EQClientUnknown; +} + +EQClientVersion EQLimits::ValidateNPCVersion(EQClientVersion version) { + if (version >= _EQClientCount) + if (version < _EmuClientCount) + return version; + + return EQClientUnknown; +} + +// mob validation +bool EQLimits::IsValidMobVersion(uint32 version) { + if (version < _EmuClientCount) + return true; + + return false; +} + +uint32 EQLimits::ValidateMobVersion(uint32 version) { + if (version < _EmuClientCount) + return version; + + return EQClientUnknown; +} + +EQClientVersion EQLimits::ValidateMobVersion(EQClientVersion version) { + if (version >= EQClientUnknown) + if (version < _EmuClientCount) + return version; + + return EQClientUnknown; +} + +// inventory +uint16 EQLimits::InventoryMapSize(int16 map, uint32 version) { + // not all maps will have an instantiated container..some are references for queue generators (i.e., bazaar, mail, etc...) + // a zero '0' indicates a needed value..otherwise, change to '_NOTUSED' for a null value so indices requiring research can be identified + // ALL of these values need to be verified before pushing to live + // + // make sure that you transcribe the actual value from 'defaults' to here before updating or client crashes will ensue..and/or... + // insert older clients inside of the progression of client order + + static const uint16 local[_MapCount][_EmuClientCount] = { + /* { Unknown, 62, Titanium, SoF, SoD, Underfoot, RoF, RoF2, NPC, Merc, Bot, Pet }*/ + { NOT_USED, 34, 34, 34, 34, 34, EmuConstants::MAP_POSSESSIONS_SIZE, 0, 0, 0, 0, 0 }, // (requires bitmask use...) + { NOT_USED, 16, 16, 24, 24, 24, EmuConstants::MAP_BANK_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 2, 2, 2, 2, 2, EmuConstants::MAP_SHAREDBANK_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 8, 8, 8, 8, 8, EmuConstants::MAP_TRADE_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 10, 10, 10, 10, 10, EmuConstants::MAP_WORLD_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 36, 36, 36, 36, 36, EmuConstants::MAP_LIMBO_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_TRIBUTE_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_TROPHYTRIBUTE_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_GUILDTRIBUTE_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_MERCHANT_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_DELETED_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 34, EmuConstants::MAP_CORPSE_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 80, EmuConstants::MAP_BAZAAR_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_INSPECT_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_REALESTATE_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_VIEWMODPC_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_VIEWMODBANK_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_VIEWMODSHAREDBANK_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_VIEWMODLIMBO_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_ALTSTORAGE_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_ARCHIVED_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_MAIL_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_GUILDTROPHYTRIBUTE_SIZE, 0, 0, 0, 0, 0 }, + { NOT_USED, NOT_USED, NOT_USED, NOT_USED, NOT_USED, NOT_USED, EmuConstants::MAP_KRONO_SIZE, 0, 0, 0, 0, 0 }, // (will be implemented in RoF2) + { NOT_USED, 0, 0, 0, 0, 0, EmuConstants::MAP_OTHER_SIZE, 0, 0, 0, 0, 0 } + }; + + if ((uint16)map < _MapCount) + return local[map][ValidateMobVersion(version)]; + + return NOT_USED; +} + +uint64 EQLimits::PossessionsBitmask(uint32 version) { + // these are for the new inventory system..not the current one... + // 0x0000000000200000 is SlotPowerSource (SoF+) + // 0x0000000100000000 is SlotGeneral9 (RoF+) + // 0x0000000200000000 is SlotGeneral10 (RoF+) + + static const uint64 local[_EmuClientCount] = { +/*Unknown*/ NOT_USED, +/*62*/ 0x000000027FDFFFFF, +/*Titanium*/ 0x000000027FDFFFFF, +/*SoF*/ 0x000000027FFFFFFF, +/*SoD*/ 0x000000027FFFFFFF, +/*Underfoot*/ 0x000000027FFFFFFF, +/*RoF*/ 0x00000003FFFFFFFF, +/*RoF2*/ 0, + +/*NPC*/ 0, +/*Merc*/ 0, +/*Bot*/ 0, +/*Pet*/ 0 + }; + + return local[ValidateMobVersion(version)]; +} + +uint64 EQLimits::EquipmentBitmask(uint32 version) { + static const uint64 local[_EmuClientCount] = { +/*Unknown*/ NOT_USED, +/*62*/ 0x00000000005FFFFF, +/*Titanium*/ 0x00000000005FFFFF, +/*SoF*/ 0x00000000007FFFFF, +/*SoD*/ 0x00000000007FFFFF, +/*Underfoot*/ 0x00000000007FFFFF, +/*RoF*/ 0x00000000007FFFFF, +/*RoF2*/ 0, + +/*NPC*/ 0, +/*Merc*/ 0, +/*Bot*/ 0, +/*Pet*/ 0 + }; + + return local[ValidateMobVersion(version)]; +} + +uint64 EQLimits::GeneralBitmask(uint32 version) { + static const uint64 local[_EmuClientCount] = { +/*Unknown*/ NOT_USED, +/*62*/ 0x000000007F800000, +/*Titanium*/ 0x000000007F800000, +/*SoF*/ 0x000000007F800000, +/*SoD*/ 0x000000007F800000, +/*Underfoot*/ 0x000000007F800000, +/*RoF*/ 0x00000001FF800000, +/*RoF2*/ 0, + +/*NPC*/ 0, +/*Merc*/ 0, +/*Bot*/ 0, +/*Pet*/ 0 + }; + + return local[ValidateMobVersion(version)]; +} + +uint64 EQLimits::CursorBitmask(uint32 version) { + static const uint64 local[_EmuClientCount] = { +/*Unknown*/ NOT_USED, +/*62*/ 0x0000000200000000, +/*Titanium*/ 0x0000000200000000, +/*SoF*/ 0x0000000200000000, +/*SoD*/ 0x0000000200000000, +/*Underfoot*/ 0x0000000200000000, +/*RoF*/ 0x0000000200000000, +/*RoF2*/ 0, + +/*NPC*/ 0, +/*Merc*/ 0, +/*Bot*/ 0, +/*Pet*/ 0 + }; + + return local[ValidateMobVersion(version)]; +} + +bool EQLimits::AllowsEmptyBagInBag(uint32 version) { + static const bool local[_EmuClientCount] = { +/*Unknown*/ false, +/*62*/ false, +/*Titanium*/ false, +/*SoF*/ false, +/*SoD*/ false, +/*Underfoot*/ false, +/*RoF*/ true, +/*RoF2*/ true, + +/*NPC*/ true, +/*Merc*/ true, +/*Bot*/ true, +/*Pet*/ true + }; + + return local[ValidateMobVersion(version)]; +} + +// items +uint16 EQLimits::ItemCommonSize(uint32 version) { + static const uint16 local[_EmuClientCount] = { +/*Unknown*/ NOT_USED, +/*62*/ 5, +/*Titanium*/ 5, +/*SoF*/ 5, +/*SoD*/ 5, +/*Underfoot*/ 5, +/*RoF*/ EmuConstants::ITEM_COMMON_SIZE, +/*RoF2*/ 0, + +/*NPC*/ 0, +/*Merc*/ 0, +/*Bot*/ 0, +/*Pet*/ 0 + }; + + return local[ValidateMobVersion(version)]; +} + +uint16 EQLimits::ItemContainerSize(uint32 version) { + static const uint16 local[_EmuClientCount] = { +/*Unknown*/ NOT_USED, +/*62*/ 10, +/*Titanium*/ 10, +/*SoF*/ 10, +/*SoD*/ 10, +/*Underfoot*/ 10, +/*RoF*/ EmuConstants::ITEM_CONTAINER_SIZE, +/*RoF2*/ 0, + +/*NPC*/ 0, +/*Merc*/ 0, +/*Bot*/ 0, +/*Pet*/ 0 + }; + + return local[ValidateMobVersion(version)]; +} + +bool EQLimits::CoinHasWeight(uint32 version) { + static const bool local[_EmuClientCount] = { +/*Unknown*/ true, +/*62*/ true, +/*Titanium*/ true, +/*SoF*/ true, +/*SoD*/ false, +/*Underfoot*/ false, +/*RoF*/ false, +/*RoF2*/ false, + +/*NPC*/ false, +/*Merc*/ false, +/*Bot*/ false, +/*Pet*/ false + }; + + return local[ValidateMobVersion(version)]; +} diff --git a/common/eq_dictionary.h b/common/eq_dictionary.h new file mode 100644 index 000000000..08f7dee04 --- /dev/null +++ b/common/eq_dictionary.h @@ -0,0 +1,118 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef EQ_DICTIONARY_H +#define EQ_DICTIONARY_H + +#include "types.h" +#include "eq_constants.h" +#include "clientversions.h" + +// an immutable value is required to initialize arrays, etc... use this class as a repository for those +typedef class { +public: + // database + static const EQClientVersion CHARACTER_CREATION_CLIENT = _EQCreationClient; + + // inventory + static uint16 InventoryMapSize(int16 map); + + static const uint16 MAP_POSSESSIONS_SIZE = 22; //_SlotCount; + static const uint16 MAP_BANK_SIZE = 24; + static const uint16 MAP_SHAREDBANK_SIZE = 2; + static const uint16 MAP_TRADE_SIZE = 8; + static const uint16 MAP_WORLD_SIZE = 10; + static const uint16 MAP_LIMBO_SIZE = 36; + static const uint16 MAP_TRIBUTE_SIZE = 5; + static const uint16 MAP_TROPHYTRIBUTE_SIZE = 0; + static const uint16 MAP_GUILDTRIBUTE_SIZE = 0; + static const uint16 MAP_MERCHANT_SIZE = 0; + static const uint16 MAP_DELETED_SIZE = 0; + static const uint16 MAP_CORPSE_SIZE = 22; //_SlotCount; // actual code still needs lots of work... + static const uint16 MAP_BAZAAR_SIZE = 80; //200; + static const uint16 MAP_INSPECT_SIZE = 22; //_SlotEquipmentCount; + static const uint16 MAP_REALESTATE_SIZE = 0; + static const uint16 MAP_VIEWMODPC_SIZE = NOT_USED; + static const uint16 MAP_VIEWMODBANK_SIZE = NOT_USED; + static const uint16 MAP_VIEWMODSHAREDBANK_SIZE = NOT_USED; + static const uint16 MAP_VIEWMODLIMBO_SIZE = NOT_USED; + static const uint16 MAP_ALTSTORAGE_SIZE = 0; + static const uint16 MAP_ARCHIVED_SIZE = 0; + static const uint16 MAP_MAIL_SIZE = 0; + static const uint16 MAP_GUILDTROPHYTRIBUTE_SIZE = 0; + static const uint16 MAP_KRONO_SIZE = 0; // this will be '1' when RoF2 is implemented + static const uint16 MAP_OTHER_SIZE = 0; + + //static const int16 EQUIPMENT_BEGIN = _SlotEquipmentBegin; + //static const int16 EQUIPMENT_END = _SlotEquipmentEnd; + static const uint16 EQUIPMENT_SIZE = 22; //_SlotEquipmentCount; // not ready for client usage..only equipment arrays for npcs... + + static const int16 GENERAL_BEGIN = 22; //_SlotGeneralBegin; + static const int16 GENERAL_END = 29; //_SlotGeneralEnd; + static const uint16 GENERAL_SIZE = 8; //_SlotGeneralCount; + + // items + static const uint16 ITEM_COMMON_SIZE = 5; + static const uint16 ITEM_CONTAINER_SIZE = 10; + + // player profile + //static const uint32 CLASS_BITMASK = 0; // needs value + //static const uint32 RACE_BITMASK = 0; // needs value + + // TODO: resolve naming convention and use for bandolier count versus size + //static const uint32 BANDOLIER_COUNT = 4; + static const uint32 BANDOLIER_SIZE = 4; + static const uint32 POTION_BELT_SIZE = 5; +} EmuConstants; + +typedef class { +public: + // client version validation (checks to avoid crashing zone server when accessing reference arrays) + // use this inside of class Client (limits to actual clients) + static bool IsValidClientVersion(uint32 version); + static uint32 ValidateClientVersion(uint32 version); + static EQClientVersion ValidateClientVersion(EQClientVersion version); + + // basically..any non-client classes - do not when setting a valid client + static bool IsValidNPCVersion(uint32 version); + static uint32 ValidateNPCVersion(uint32 version); + static EQClientVersion ValidateNPCVersion(EQClientVersion version); + + // these are 'universal' - do not when setting a valid client + static bool IsValidMobVersion(uint32 version); + static uint32 ValidateMobVersion(uint32 version); + static EQClientVersion ValidateMobVersion(EQClientVersion version); + + // inventory + static uint16 InventoryMapSize(int16 map, uint32 version); + static uint64 PossessionsBitmask(uint32 version); + static uint64 EquipmentBitmask(uint32 version); + static uint64 GeneralBitmask(uint32 version); + static uint64 CursorBitmask(uint32 version); + + static bool AllowsEmptyBagInBag(uint32 version); + + // items + static uint16 ItemCommonSize(uint32 version); + static uint16 ItemContainerSize(uint32 version); + + // player profile + static bool CoinHasWeight(uint32 version); +} EQLimits; + +#endif /* EQ_LIMITS_H */ diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index 674ed15b7..8c670a2e0 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -32,7 +32,8 @@ static const uint32 MAX_MERC_GRADES = 10; static const uint32 MAX_MERC_STANCES = 10; static const uint32 BLOCKED_BUFF_COUNT = 20; -#include "eq_constants.h" +//#include "eq_constants.h" +#include "eq_dictionary.h" /* ** Compiler override to ensure diff --git a/common/item_struct.h b/common/item_struct.h index 2c5d95d76..c91634a6e 100644 --- a/common/item_struct.h +++ b/common/item_struct.h @@ -42,7 +42,8 @@ * Made ya look! Ha! */ -#include "eq_constants.h" +//#include "eq_constants.h" +#include "eq_dictionary.h" /* ** Child struct of Item_Struct: @@ -68,7 +69,8 @@ struct InternalSerializedItem_Struct { const void * inst; }; -#define MAX_AUGMENT_SLOTS 5 +// use EmuConstants::ITEM_COMMON_SIZE +//#define MAX_AUGMENT_SLOTS 5 struct Item_Struct { bool IsEquipable(uint16 Race, uint16 Class) const; @@ -180,9 +182,9 @@ struct Item_Struct { int32 FactionAmt4; // Faction Amt 4 char CharmFile[32]; // ? uint32 AugType; - uint8 AugSlotType[MAX_AUGMENT_SLOTS]; // LDoN: Augment Slot 1-5 Type - uint8 AugSlotVisible[MAX_AUGMENT_SLOTS]; // LDoN: Augment Slot 1-5 Visible - uint8 AugSlotUnk2[MAX_AUGMENT_SLOTS]; // LDoN: Augment Slot 1-5 Unknown + uint8 AugSlotType[EmuConstants::ITEM_COMMON_SIZE]; // LDoN: Augment Slot 1-5 Type + uint8 AugSlotVisible[EmuConstants::ITEM_COMMON_SIZE]; // LDoN: Augment Slot 1-5 Visible + uint8 AugSlotUnk2[EmuConstants::ITEM_COMMON_SIZE]; // LDoN: Augment Slot 1-5 Unknown uint32 LDoNTheme; uint32 LDoNPrice; uint32 LDoNSold; diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 03d6c4c52..cff3f545c 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -439,7 +439,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) { const Item_Struct* item = GetItem(item_id); if (item) { - int16 put_slot_id = SLOT_INVALID; + int16 put_slot_id = INVALID_INDEX; ItemInst* inst = CreateBaseItem(item, charges); if (item->ItemClass == ItemClassCommon) { @@ -479,7 +479,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) { safe_delete(inst); // Save ptr to item in inventory - if (put_slot_id == SLOT_INVALID) { + if (put_slot_id == INVALID_INDEX) { LogFile->write(EQEMuLog::Error, "Warning: Invalid slot_id for item in shared bank inventory: %s=%i, item_id=%i, slot_id=%i", ((is_charid==true) ? "charid" : "acctid"), id, item_id, slot_id); @@ -535,7 +535,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) { const Item_Struct* item = GetItem(item_id); if (item) { - int16 put_slot_id = SLOT_INVALID; + int16 put_slot_id = INVALID_INDEX; ItemInst* inst = CreateBaseItem(item, charges); @@ -589,7 +589,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) { safe_delete(inst); // Save ptr to item in inventory - if (put_slot_id == SLOT_INVALID) { + if (put_slot_id == INVALID_INDEX) { LogFile->write(EQEMuLog::Error, "Warning: Invalid slot_id for item in inventory: charid=%i, item_id=%i, slot_id=%i", char_id, item_id, slot_id); @@ -641,7 +641,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv) aug[4] = (uint32)atoi(row[8]); bool instnodrop = (row[9] && (uint16)atoi(row[9])) ? true : false; const Item_Struct* item = GetItem(item_id); - int16 put_slot_id = SLOT_INVALID; + int16 put_slot_id = INVALID_INDEX; if(!item) continue; @@ -692,7 +692,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv) safe_delete(inst); // Save ptr to item in inventory - if (put_slot_id == SLOT_INVALID) { + if (put_slot_id == INVALID_INDEX) { LogFile->write(EQEMuLog::Error, "Warning: Invalid slot_id for item in inventory: name=%s, acctid=%i, item_id=%i, slot_id=%i", name, account_id, item_id, slot_id); diff --git a/common/skills.h b/common/skills.h index c6df0091b..88b05967f 100644 --- a/common/skills.h +++ b/common/skills.h @@ -53,7 +53,8 @@ enum SkillUseTypes : uint32 /*13879*/ SkillDivination, /*13880*/ SkillDodge, /*13881*/ SkillDoubleAttack, -/*13882*/ SkillDragonPunch, /*13924 SkillTailRake*/ +/*13882*/ SkillDragonPunch, +/*13924*/ SkillTailRake = SkillDragonPunch, // Iksar Monk equivilent /*13883*/ SkillDualWield, /*13884*/ SkillEagleStrike, /*13885*/ SkillEvocation, @@ -199,7 +200,7 @@ typedef enum { DIVINATION = 18, DODGE = 19, DOUBLE_ATTACK = 20, - DRAGON_PUNCH = 21 , //aka Tail Rake + DRAGON_PUNCH = 21, //aka Tail Rake DUAL_WIELD = 22, EAGLE_STRIKE = 23, EVOCATION = 24, diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index 386b31e2b..a3caf84c5 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -856,7 +856,7 @@ void Client::AI_Process() int16 ExtraAttackChanceBonus = spellbonuses.ExtraAttackChance + itembonuses.ExtraAttackChance + aabonuses.ExtraAttackChance; if (ExtraAttackChanceBonus && GetTarget()) { - ItemInst *wpn = GetInv().GetItem(SLOT_PRIMARY); + ItemInst *wpn = GetInv().GetItem(MainPrimary); if(wpn){ if(wpn->GetItem()->ItemType == ItemType2HSlash || wpn->GetItem()->ItemType == ItemType2HBlunt || diff --git a/zone/Object.cpp b/zone/Object.cpp index 1f4dc3654..11bc8f317 100644 --- a/zone/Object.cpp +++ b/zone/Object.cpp @@ -456,7 +456,7 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object) // the client updates itself and takes care of sending "duplicate lore item" messages if(sender->CheckLoreConflict(m_inst->GetItem())) { int16 loreslot = sender->GetInv().HasItem(m_inst->GetItem()->ID, 0, invWhereBank); - if(loreslot != SLOT_INVALID) // if the duplicate is in the bank, delete it. + if (loreslot != INVALID_INDEX) // if the duplicate is in the bank, delete it. sender->DeleteItemInInventory(loreslot); else cursordelete = true; // otherwise, we delete the new one @@ -470,11 +470,11 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object) parse->EventPlayer(EVENT_PLAYER_PICKUP, sender, buf, 0, &args); // Transfer item to client - sender->PutItemInInventory(SLOT_CURSOR, *m_inst, false); - sender->SendItemPacket(SLOT_CURSOR, m_inst, ItemPacketTrade); + sender->PutItemInInventory(MainCursor, *m_inst, false); + sender->SendItemPacket(MainCursor, m_inst, ItemPacketTrade); if(cursordelete) // delete the item if it's a duplicate lore. We have to do this because the client expects the item packet - sender->DeleteItemInInventory(SLOT_CURSOR); + sender->DeleteItemInInventory(MainCursor); if(!m_ground_spawn) safe_delete(m_inst); diff --git a/zone/attack.cpp b/zone/attack.cpp index 37759bc9a..5b20bf365 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -166,7 +166,7 @@ bool Mob::AttackAnimation(SkillUseTypes &skillinuse, int Hand, const ItemInst* w } // If we're attacking with the secondary hand, play the dual wield anim - if (Hand == 14) // DW anim + if (Hand == MainSecondary) // DW anim type = animDualWield; DoAnim(type); @@ -960,7 +960,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate dmg = weapon_item->GetItem()->Damage; } - for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){ + for(int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; x++){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ dmg += weapon_item->GetAugment(x)->GetItem()->Damage; if (hate) *hate += weapon_item->GetAugment(x)->GetItem()->Damage + weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt; @@ -997,7 +997,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate dmg = weapon_item->GetItem()->Damage; } - for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){ + for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; x++){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ dmg += weapon_item->GetAugment(x)->GetItem()->Damage; if (hate) *hate += weapon_item->GetAugment(x)->GetItem()->Damage + weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt; @@ -1034,7 +1034,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate } if(weapon_item){ - for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){ + for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; x++){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ if(weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt) eledmg += (weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt * against->ResistSpell(weapon_item->GetAugment(x)->GetItem()->ElemDmgType, 0, this) / 100); @@ -1063,7 +1063,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate } } - for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){ + for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; x++){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == against->GetBodyType()){ banedmg += weapon_item->GetAugment(x)->GetItem()->BaneDmgAmt; @@ -1108,7 +1108,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate } } - for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){ + for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; x++){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == against->GetBodyType()){ banedmg += weapon_item->GetAugment(x)->GetItem()->BaneDmgAmt; @@ -1170,12 +1170,12 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b ItemInst* weapon; - if (Hand == 14){ // Kaiyodo - Pick weapon from the attacking hand - weapon = GetInv().GetItem(SLOT_SECONDARY); + if (Hand == MainSecondary){ // Kaiyodo - Pick weapon from the attacking hand + weapon = GetInv().GetItem(MainSecondary); OffHandAtk(true); } else{ - weapon = GetInv().GetItem(SLOT_PRIMARY); + weapon = GetInv().GetItem(MainPrimary); OffHandAtk(false); } @@ -1244,7 +1244,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b int ucDamageBonus = 0; - if( Hand == 13 && GetLevel() >= 28 && IsWarriorClass() ) + if( Hand == MainPrimary && GetLevel() >= 28 && IsWarriorClass() ) { // Damage bonuses apply only to hits from the main hand (Hand == 13) by characters level 28 and above // who belong to a melee class. If we're here, then all of these conditions apply. @@ -1257,7 +1257,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b } #endif //Live AA - Sinister Strikes *Adds weapon damage bonus to offhand weapon. - if (Hand==14) { + if (Hand == MainSecondary) { if (aabonuses.SecondaryDmgInc || itembonuses.SecondaryDmgInc || spellbonuses.SecondaryDmgInc){ ucDamageBonus = GetWeaponDamageBonus( weapon ? weapon->GetItem() : (const Item_Struct*) nullptr ); @@ -1310,7 +1310,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b if (damage == -3) { if (bRiposte) return false; else { - if (Hand == 14) {// Do we even have it & was attack with mainhand? If not, don't bother with other calculations + if (Hand == MainSecondary) {// Do we even have it & was attack with mainhand? If not, don't bother with other calculations //Live AA - SlipperyAttacks //This spell effect most likely directly modifies the actual riposte chance when using offhand attack. int16 OffhandRiposteFail = aabonuses.OffhandRiposteFail + itembonuses.OffhandRiposteFail + spellbonuses.OffhandRiposteFail; @@ -1775,28 +1775,28 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool FaceTarget(GetTarget()); SkillUseTypes skillinuse = SkillHandtoHand; - if (Hand == 13) { + if (Hand == MainPrimary) { skillinuse = static_cast(GetPrimSkill()); OffHandAtk(false); } - if (Hand == 14) { + if (Hand == MainSecondary) { skillinuse = static_cast(GetSecSkill()); OffHandAtk(true); } //figure out what weapon they are using, if any const Item_Struct* weapon = nullptr; - if (Hand == 13 && equipment[SLOT_PRIMARY] > 0) - weapon = database.GetItem(equipment[SLOT_PRIMARY]); - else if (equipment[SLOT_SECONDARY]) - weapon = database.GetItem(equipment[SLOT_SECONDARY]); + if (Hand == MainPrimary && equipment[MainPrimary] > 0) + weapon = database.GetItem(equipment[MainPrimary]); + else if (equipment[MainSecondary]) + weapon = database.GetItem(equipment[MainSecondary]); //We dont factor much from the weapon into the attack. //Just the skill type so it doesn't look silly using punching animations and stuff while wielding weapons if(weapon) { mlog(COMBAT__ATTACKS, "Attacking with weapon: %s (%d) (too bad im not using it for much)", weapon->Name, weapon->ID); - if(Hand == 14 && weapon->ItemType == ItemTypeShield){ + if(Hand == MainSecondary && weapon->ItemType == ItemTypeShield){ mlog(COMBAT__ATTACKS, "Attack with shield canceled."); return false; } @@ -4074,7 +4074,7 @@ void Mob::TryWeaponProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on proced = false; if (!proced && inst) { - for (int r = 0; r < MAX_AUGMENT_SLOTS; r++) { + for (int r = 0; r < EmuConstants::ITEM_COMMON_SIZE; r++) { const ItemInst *aug_i = inst->GetAugment(r); if (!aug_i) // no aug, try next slot! continue; @@ -4118,11 +4118,11 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on, else ProcChance = GetProcChances(ProcBonus); - if (hand != 13) //Is Archery intened to proc at 50% rate? + if (hand != MainPrimary) //Is Archery intened to proc at 50% rate? ProcChance /= 2; bool rangedattk = false; - if (weapon && hand == 11) { + if (weapon && hand == MainRange) { if (weapon->ItemType == ItemTypeArrow || weapon->ItemType == ItemTypeLargeThrowing || weapon->ItemType == ItemTypeSmallThrowing || @@ -4131,7 +4131,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on, } for (uint32 i = 0; i < MAX_PROCS; i++) { - if (IsPet() && hand != 13) //Pets can only proc spell procs from their primay hand (ie; beastlord pets) + if (IsPet() && hand != MainPrimary) //Pets can only proc spell procs from their primay hand (ie; beastlord pets) continue; // If pets ever can proc from off hand, this will need to change // Not ranged @@ -4184,7 +4184,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on, } } - if (HasSkillProcs() && hand != 11){ //We check ranged skill procs within the attack functions. + if (HasSkillProcs() && hand != MainRange){ //We check ranged skill procs within the attack functions. uint16 skillinuse = 28; if (weapon) skillinuse = GetSkillByItemType(weapon->ItemType); @@ -4430,7 +4430,7 @@ void Mob::DoRiposte(Mob* defender) { if (!defender) return; - defender->Attack(this, SLOT_PRIMARY, true); + defender->Attack(this, MainPrimary, true); if (HasDied()) return; int16 DoubleRipChance = defender->aabonuses.GiveDoubleRiposte[0] + @@ -4444,7 +4444,7 @@ void Mob::DoRiposte(Mob* defender) { //Live AA - Double Riposte if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) { mlog(COMBAT__ATTACKS, "Preforming a double riposed (%d percent chance)", DoubleRipChance); - defender->Attack(this, SLOT_PRIMARY, true); + defender->Attack(this, MainPrimary, true); if (HasDied()) return; } diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index e9501c4dd..51db73157 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -139,21 +139,21 @@ void Client::CalcItemBonuses(StatBonuses* newbon) { unsigned int i; //should not include 21 (SLOT_AMMO) - for (i=0; i<21; i++) { + for (i = MainCharm; i < MainAmmo; i++) { const ItemInst* inst = m_inv[i]; if(inst == 0) continue; AddItemBonuses(inst, newbon); //Check if item is secondary slot is a 'shield'. Required for multiple spelll effects. - if (i == 14 && (m_inv.GetItem(14)->GetItem()->ItemType == ItemTypeShield)) + if (i == MainSecondary && (m_inv.GetItem(MainSecondary)->GetItem()->ItemType == ItemTypeShield)) ShieldEquiped(true); } //Power Source Slot if (GetClientVersion() >= EQClientSoF) { - const ItemInst* inst = m_inv[9999]; + const ItemInst* inst = m_inv[MainPowerSource]; if(inst) AddItemBonuses(inst, newbon); } @@ -528,7 +528,7 @@ void Client::AddItemBonuses(const ItemInst *inst, StatBonuses* newbon, bool isAu if (!isAug) { int i; - for(i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { AddItemBonuses(inst->GetAugment(i),newbon,true); } } @@ -2972,7 +2972,7 @@ void NPC::CalcItemBonuses(StatBonuses *newbon) { if(newbon){ - for(int i = 0; i < MAX_WORN_INVENTORY; i++){ + for(int i = 0; i < EmuConstants::EQUIPMENT_SIZE; i++){ const Item_Struct *cur = database.GetItem(equipment[i]); if(cur){ //basic stats @@ -3091,7 +3091,7 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y) } //iterate all augments - for(int x = 0; x < MAX_AUGMENT_SLOTS; ++x) + for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; ++x) { ItemInst * a_inst = inst->GetAugment(x); if(!a_inst) @@ -3160,7 +3160,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 < 22 || i == 9999) { + if(i <= MainAmmo || i == MainPowerSource) { parse->EventItem(EVENT_EQUIP_ITEM, this, inst, nullptr, "", i); } @@ -3170,7 +3170,7 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) { update_slot = true; } } else { - if(i < 22 || i == 9999) { + if(i <= MainAmmo || i == MainPowerSource) { parse->EventItem(EVENT_EQUIP_ITEM, this, inst, nullptr, "", i); } @@ -3178,7 +3178,7 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) { } //iterate all augments - for(int x = 0; x < MAX_AUGMENT_SLOTS; ++x) + for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; ++x) { ItemInst *a_inst = inst->GetAugment(x); if(!a_inst) diff --git a/zone/bot.cpp b/zone/bot.cpp index 86a2a9b64..34c5801e7 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -237,7 +237,7 @@ void Bot::SetBotSpellID(uint32 newSpellID) { uint32 Bot::GetBotArcheryRange() { uint32 result = 0; - ItemInst* rangeItem = GetBotItem(SLOT_RANGE); + ItemInst* rangeItem = GetBotItem(MainRange); if(!rangeItem) return 0; @@ -257,7 +257,7 @@ uint32 Bot::GetBotArcheryRange() { archeryColor = botweapon->Color; range =+ botweapon->Range; - rangeItem = GetBotItem(SLOT_AMMO); + rangeItem = GetBotItem(MainAmmo); if(rangeItem) botweapon = rangeItem->GetItem(); @@ -280,8 +280,8 @@ void Bot::ChangeBotArcherWeapons(bool isArcher) { || (GetClass()==SHADOWKNIGHT) || (GetClass()==ROGUE)) { if(!isArcher) { - BotAddEquipItem(SLOT_PRIMARY, GetBotItemBySlot(SLOT_PRIMARY)); - BotAddEquipItem(SLOT_SECONDARY, GetBotItemBySlot(SLOT_SECONDARY)); + BotAddEquipItem(MainPrimary, GetBotItemBySlot(MainPrimary)); + BotAddEquipItem(MainSecondary, GetBotItemBySlot(MainSecondary)); //archerbot->SendWearChange(MATERIAL_PRIMARY); //archerbot->SendWearChange(MATERIAL_SECONDARY); SetAttackTimer(); @@ -290,11 +290,11 @@ void Bot::ChangeBotArcherWeapons(bool isArcher) { else { //archerbot->SendWearChange(MATERIAL_PRIMARY); //archerbot->SendWearChange(MATERIAL_SECONDARY); - BotRemoveEquipItem(SLOT_PRIMARY); - BotRemoveEquipItem(SLOT_SECONDARY); + BotRemoveEquipItem(MainPrimary); + BotRemoveEquipItem(MainSecondary); //archerbot->SendBotArcheryWearChange(MATERIAL_PRIMARY, archeryMaterial, archeryColor); - BotAddEquipItem(SLOT_AMMO, GetBotItemBySlot(SLOT_AMMO)); - BotAddEquipItem(SLOT_SECONDARY, GetBotItemBySlot(SLOT_RANGE)); + BotAddEquipItem(MainAmmo, GetBotItemBySlot(MainAmmo)); + BotAddEquipItem(MainSecondary, GetBotItemBySlot(MainRange)); SetAttackTimer(); Say("My bow is true and ready."); } @@ -1291,7 +1291,7 @@ void Bot::GenerateArmorClass() uint16 Bot::GetPrimarySkillValue() { SkillUseTypes skill = HIGHEST_SKILL; //because nullptr == 0, which is 1H Slashing, & we want it to return 0 from GetSkill - bool equiped = m_inv.GetItem(SLOT_PRIMARY); + bool equiped = m_inv.GetItem(MainPrimary); if(!equiped) { @@ -1299,7 +1299,7 @@ uint16 Bot::GetPrimarySkillValue() } else { - uint8 type = m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType; //is this the best way to do this? + uint8 type = m_inv.GetItem(MainPrimary)->GetItem()->ItemType; //is this the best way to do this? switch(type) { case ItemType1HSlash: // 1H Slashing @@ -2630,7 +2630,7 @@ void Bot::LoadPet() { NPC *pet = GetPet()->CastToNPC(); SpellBuff_Struct petBuffs[BUFF_COUNT]; memset(petBuffs, 0, sizeof(petBuffs)); - uint32 petItems[MAX_WORN_INVENTORY]; + uint32 petItems[EmuConstants::EQUIPMENT_SIZE]; LoadPetBuffs(petBuffs, PetSaveId); LoadPetItems(petItems, PetSaveId); @@ -2747,7 +2747,7 @@ void Bot::LoadPetItems(uint32* petItems, uint32 botPetSaveId) { int ItemCount = 0; while(DataRow = mysql_fetch_row(DatasetResult)) { - if(ItemCount == MAX_WORN_INVENTORY) + if(ItemCount == EmuConstants::EQUIPMENT_SIZE) break; petItems[ItemCount] = atoi(DataRow[0]); @@ -2785,7 +2785,7 @@ void Bot::SavePet() { uint32 botPetId = pet->CastToNPC()->GetPetSpellID(); char* tempPetName = new char[64]; SpellBuff_Struct petBuffs[BUFF_COUNT]; - uint32 petItems[MAX_WORN_INVENTORY]; + uint32 petItems[EmuConstants::EQUIPMENT_SIZE]; pet->GetPetState(petBuffs, petItems, tempPetName); @@ -2867,7 +2867,7 @@ void Bot::SavePetItems(uint32* petItems, uint32 botPetSaveId) { char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE]; int ItemCount = 0; - while(ItemCount < MAX_WORN_INVENTORY) { + while (ItemCount < EmuConstants::EQUIPMENT_SIZE) { if(petItems[ItemCount] > 0) { if(!database.RunQuery(Query, MakeAnyLenString(&Query, "INSERT INTO botpetinventory (BotPetsId, ItemId) VALUES(%u, %u);", botPetSaveId, petItems[ItemCount]), TempErrorMessageBuffer)) { errorMessage = std::string(TempErrorMessageBuffer); @@ -3189,12 +3189,12 @@ void Bot::BotRangedAttack(Mob* other) { return; } - ItemInst* rangedItem = GetBotItem(SLOT_RANGE); + ItemInst* rangedItem = GetBotItem(MainRange); const Item_Struct* RangeWeapon = 0; if(rangedItem) RangeWeapon = rangedItem->GetItem(); - ItemInst* ammoItem = GetBotItem(SLOT_AMMO); + ItemInst* ammoItem = GetBotItem(MainAmmo); const Item_Struct* Ammo = 0; if(ammoItem) Ammo = ammoItem->GetItem(); @@ -3363,7 +3363,7 @@ void Bot::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes damage = -5; if(skillinuse == SkillBash){ - const ItemInst* inst = GetBotItem(SLOT_SECONDARY); + const ItemInst* inst = GetBotItem(MainSecondary); const Item_Struct* botweapon = 0; if(inst) botweapon = inst->GetItem(); @@ -3413,17 +3413,17 @@ void Bot::ApplySpecialAttackMod(SkillUseTypes skill, int32 &dmg, int32 &mindmg) case SkillFlyingKick: case SkillRoundKick: case SkillKick: - item_slot = SLOT_FEET; + item_slot = MainFeet; break; case SkillBash: - item_slot = SLOT_SECONDARY; + item_slot = MainSecondary; break; case SkillDragonPunch: case SkillEagleStrike: case SkillTigerClaw: - item_slot = SLOT_HANDS; + item_slot = MainHands; break; } @@ -3775,27 +3775,27 @@ void Bot::AI_Process() { //try main hand first if(attack_timer.Check()) { - Attack(GetTarget(), SLOT_PRIMARY); + Attack(GetTarget(), MainPrimary); - ItemInst *wpn = GetBotItem(SLOT_PRIMARY); - TryWeaponProc(wpn, GetTarget(), SLOT_PRIMARY); + ItemInst *wpn = GetBotItem(MainPrimary); + TryWeaponProc(wpn, GetTarget(), MainPrimary); bool tripleSuccess = false; if(BotOwner && GetTarget() && CanThisClassDoubleAttack()) { if(BotOwner && CheckBotDoubleAttack()) { - Attack(GetTarget(), SLOT_PRIMARY, true); + Attack(GetTarget(), MainPrimary, true); } if(BotOwner && GetTarget() && GetSpecialAbility(SPECATK_TRIPLE) && CheckBotDoubleAttack(true)) { tripleSuccess = true; - Attack(GetTarget(), SLOT_PRIMARY, true); + Attack(GetTarget(), MainPrimary, true); } //quad attack, does this belong here?? if(BotOwner && GetTarget() && GetSpecialAbility(SPECATK_QUAD) && CheckBotDoubleAttack(true)) { - Attack(GetTarget(), SLOT_PRIMARY, true); + Attack(GetTarget(), MainPrimary, true); } } @@ -3807,15 +3807,15 @@ void Bot::AI_Process() { if(MakeRandomInt(0, 100) < flurrychance) { Message_StringID(MT_NPCFlurry, YOU_FLURRY); - Attack(GetTarget(), SLOT_PRIMARY, false); - Attack(GetTarget(), SLOT_PRIMARY, false); + Attack(GetTarget(), MainPrimary, false); + Attack(GetTarget(), MainPrimary, false); } } int16 ExtraAttackChanceBonus = spellbonuses.ExtraAttackChance + itembonuses.ExtraAttackChance + aabonuses.ExtraAttackChance; if (GetTarget() && ExtraAttackChanceBonus) { - ItemInst *wpn = GetBotItem(SLOT_PRIMARY); + ItemInst *wpn = GetBotItem(MainPrimary); if(wpn){ if(wpn->GetItem()->ItemType == ItemType2HSlash || wpn->GetItem()->ItemType == ItemType2HBlunt || @@ -3823,7 +3823,7 @@ void Bot::AI_Process() { { if(MakeRandomInt(0, 100) < ExtraAttackChanceBonus) { - Attack(GetTarget(), SLOT_PRIMARY, false); + Attack(GetTarget(), MainPrimary, false); } } } @@ -3843,7 +3843,7 @@ void Bot::AI_Process() { //now off hand if(GetTarget() && attack_dw_timer.Check() && CanThisClassDualWield()) { - const ItemInst* instweapon = GetBotItem(SLOT_SECONDARY); + const ItemInst* instweapon = GetBotItem(MainSecondary); const Item_Struct* weapon = 0; //can only dual wield without a weapon if you're a monk if(instweapon || (botClass == MONK)) { @@ -3870,14 +3870,14 @@ void Bot::AI_Process() { if (random < DualWieldProbability){ // Max 78% of DW - Attack(GetTarget(), SLOT_SECONDARY); // Single attack with offhand + Attack(GetTarget(), MainSecondary); // Single attack with offhand - ItemInst *wpn = GetBotItem(SLOT_SECONDARY); - TryWeaponProc(wpn, GetTarget(), SLOT_SECONDARY); + ItemInst *wpn = GetBotItem(MainSecondary); + TryWeaponProc(wpn, GetTarget(), MainSecondary); if( CanThisClassDoubleAttack() && CheckBotDoubleAttack()) { if(GetTarget() && GetTarget()->GetHP() > -10) - Attack(GetTarget(), SLOT_SECONDARY); // Single attack with offhand + Attack(GetTarget(), MainSecondary); // Single attack with offhand } } } @@ -4096,7 +4096,7 @@ void Bot::PetAIProcess() { if(!botPet->BehindMob(botPet->GetTarget(), botPet->GetX(), botPet->GetY()) && botPet->GetTarget()->IsEnraged()) return; - if(botPet->Attack(GetTarget(), SLOT_PRIMARY)) // try the main hand + if(botPet->Attack(GetTarget(), MainPrimary)) // try the main hand if (botPet->GetTarget()) // Do we still have a target? { // We're a pet so we re able to dual attack @@ -4411,7 +4411,7 @@ void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) { ItemInst* inst = database.CreateItem(item_id, charges, aug[0], aug[1], aug[2], aug[3], aug[4]); if(inst) { - int16 put_slot_id = SLOT_INVALID; + int16 put_slot_id = INVALID_INDEX; if(instnodrop || ((slot_id >= 0) && (slot_id <= 21) && inst->GetItem()->Attuneable)) inst->SetInstNoDrop(true); if(color > 0) @@ -4429,7 +4429,7 @@ void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) { safe_delete(inst); // Save ptr to item in inventory - if (put_slot_id == SLOT_INVALID) { + if (put_slot_id == INVALID_INDEX) { LogFile->write(EQEMuLog::Error, "Warning: Invalid slot_id for item in inventory: botid=%i, item_id=%i, slot_id=%i", this->GetBotID(), item_id, slot_id); @@ -4595,7 +4595,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { uint32 spawnedbotid = 0; spawnedbotid = this->GetBotID(); - inst = GetBotItem(SLOT_HANDS); + inst = GetBotItem(MainHands); if(inst) { item = inst->GetItem(); if(item) { @@ -4604,7 +4604,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { } } - inst = GetBotItem(SLOT_HEAD); + inst = GetBotItem(MainHead); if(inst) { item = inst->GetItem(); if(item) { @@ -4613,7 +4613,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { } } - inst = GetBotItem(SLOT_ARMS); + inst = GetBotItem(MainArms); if(inst) { item = inst->GetItem(); if(item) { @@ -4622,7 +4622,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { } } - inst = GetBotItem(SLOT_BRACER01); + inst = GetBotItem(MainWrist1); if(inst) { item = inst->GetItem(); if(item) { @@ -4631,7 +4631,9 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { } } - inst = GetBotItem(SLOT_BRACER02); + /* + // non-live behavior + inst = GetBotItem(MainWrist2); if(inst) { item = inst->GetItem(); if(item) { @@ -4639,8 +4641,9 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { ns->spawn.colors[MaterialWrist].color = GetEquipmentColor(MaterialWrist); } } + */ - inst = GetBotItem(SLOT_CHEST); + inst = GetBotItem(MainChest); if(inst) { item = inst->GetItem(); if(item) { @@ -4649,7 +4652,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { } } - inst = GetBotItem(SLOT_LEGS); + inst = GetBotItem(MainLegs); if(inst) { item = inst->GetItem(); if(item) { @@ -4658,7 +4661,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { } } - inst = GetBotItem(SLOT_FEET); + inst = GetBotItem(MainFeet); if(inst) { item = inst->GetItem(); if(item) { @@ -4667,7 +4670,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { } } - inst = GetBotItem(SLOT_PRIMARY); + inst = GetBotItem(MainPrimary); if(inst) { item = inst->GetItem(); if(item) { @@ -4677,7 +4680,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { } } - inst = GetBotItem(SLOT_SECONDARY); + inst = GetBotItem(MainSecondary); if(inst) { item = inst->GetItem(); if(item) { @@ -6009,7 +6012,7 @@ void Bot::FinishTrade(Client* client, BotTradeType tradeType) { else if(tradeType == BotTradeClientNoDropNoTrade) { // Items being traded are found on the Client's cursor slot, slot id 30. This item can be either a single item or it can be a bag. // If it is a bag, then we have to search for items in slots 331 thru 340 - PerformTradeWithClient(SLOT_CURSOR, SLOT_CURSOR, client); + PerformTradeWithClient(MainCursor, MainCursor, client); // TODO: Add logic here to test if the item in SLOT_CURSOR is a container type, if it is then we need to call the following: // PerformTradeWithClient(331, 340, client); @@ -6038,7 +6041,7 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli charges[i] = inst->GetCharges(); } - if(i == SLOT_CURSOR) + if (i == MainCursor) UpdateClient = true; //EQoffline: will give the items to the bots and change the bot stats @@ -6046,7 +6049,7 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli std::string TempErrorMessage; const Item_Struct* mWeaponItem = inst->GetItem(); bool failedLoreCheck = false; - for(int m=0; mGetAugment(m); if(itm) { @@ -6075,17 +6078,17 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli if((mWeaponItem->Slots & (1 << j))) { how_many_slots++; if(!GetBotItem(j)) { - if(j == SLOT_PRIMARY) { + if(j == MainPrimary) { if((mWeaponItem->ItemType == ItemType2HSlash) || (mWeaponItem->ItemType == ItemType2HBlunt) || (mWeaponItem->ItemType == ItemType2HPiercing)) { - if(GetBotItem(SLOT_SECONDARY)) { + if(GetBotItem(MainSecondary)) { if(mWeaponItem && (mWeaponItem->ItemType == ItemType2HSlash) || (mWeaponItem->ItemType == ItemType2HBlunt) || (mWeaponItem->ItemType == ItemType2HPiercing)) { - if(client->CheckLoreConflict(GetBotItem(SLOT_SECONDARY)->GetItem())) { + if(client->CheckLoreConflict(GetBotItem(MainSecondary)->GetItem())) { failedLoreCheck = true; } } else { - ItemInst* remove_item = GetBotItem(SLOT_SECONDARY); - BotTradeSwapItem(client, SLOT_SECONDARY, 0, remove_item, remove_item->GetItem()->Slots, &TempErrorMessage, false); + ItemInst* remove_item = GetBotItem(MainSecondary); + BotTradeSwapItem(client, MainSecondary, 0, remove_item, remove_item->GetItem()->Slots, &TempErrorMessage, false); } } } @@ -6095,7 +6098,7 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli } break; } - else if(j == SLOT_SECONDARY) { + else if(j == MainSecondary) { if(inst->IsWeapon()) { if(CanThisClassDualWield()) { BotTradeAddItem(mWeaponItem->ID, inst, inst->GetCharges(), mWeaponItem->Slots, j, &TempErrorMessage); @@ -6111,10 +6114,10 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli success = true; } if(success) { - if(GetBotItem(SLOT_PRIMARY)) { - ItemInst* remove_item = GetBotItem(SLOT_PRIMARY); + if(GetBotItem(MainPrimary)) { + ItemInst* remove_item = GetBotItem(MainPrimary); if((remove_item->GetItem()->ItemType == ItemType2HSlash) || (remove_item->GetItem()->ItemType == ItemType2HBlunt) || (remove_item->GetItem()->ItemType == ItemType2HPiercing)) { - BotTradeSwapItem(client, SLOT_PRIMARY, 0, remove_item, remove_item->GetItem()->Slots, &TempErrorMessage, false); + BotTradeSwapItem(client, MainPrimary, 0, remove_item, remove_item->GetItem()->Slots, &TempErrorMessage, false); } } break; @@ -6133,7 +6136,7 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli if((mWeaponItem->Slots & (1 << j))) { swap_item = GetBotItem(j); failedLoreCheck = false; - for(int k=0; kGetAugment(k); if(itm) { @@ -6146,28 +6149,28 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli failedLoreCheck = true; } if(!failedLoreCheck) { - if(j == SLOT_PRIMARY) { + if(j == MainPrimary) { if((mWeaponItem->ItemType == ItemType2HSlash) || (mWeaponItem->ItemType == ItemType2HBlunt) || (mWeaponItem->ItemType == ItemType2HPiercing)) { - if(GetBotItem(SLOT_SECONDARY)) { - if(client->CheckLoreConflict(GetBotItem(SLOT_SECONDARY)->GetItem())) { + if(GetBotItem(MainSecondary)) { + if(client->CheckLoreConflict(GetBotItem(MainSecondary)->GetItem())) { failedLoreCheck = true; } else { - ItemInst* remove_item = GetBotItem(SLOT_SECONDARY); - BotTradeSwapItem(client, SLOT_SECONDARY, 0, remove_item, remove_item->GetItem()->Slots, &TempErrorMessage, false); + ItemInst* remove_item = GetBotItem(MainSecondary); + BotTradeSwapItem(client, MainSecondary, 0, remove_item, remove_item->GetItem()->Slots, &TempErrorMessage, false); } } } if(!failedLoreCheck) { - BotTradeSwapItem(client, SLOT_PRIMARY, inst, swap_item, mWeaponItem->Slots, &TempErrorMessage); + BotTradeSwapItem(client, MainPrimary, inst, swap_item, mWeaponItem->Slots, &TempErrorMessage); success = true; } break; } - else if(j == SLOT_SECONDARY) { + else if(j == MainSecondary) { if(inst->IsWeapon()) { if(CanThisClassDualWield()) { - BotTradeSwapItem(client, SLOT_SECONDARY, inst, swap_item, mWeaponItem->Slots, &TempErrorMessage); + BotTradeSwapItem(client, MainSecondary, inst, swap_item, mWeaponItem->Slots, &TempErrorMessage); success = true; } else { @@ -6176,13 +6179,13 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli } } else { - BotTradeSwapItem(client, SLOT_SECONDARY, inst, swap_item, mWeaponItem->Slots, &TempErrorMessage); + BotTradeSwapItem(client, MainSecondary, inst, swap_item, mWeaponItem->Slots, &TempErrorMessage); success = true; } - if(success && GetBotItem(SLOT_PRIMARY)) { - ItemInst* remove_item = GetBotItem(SLOT_PRIMARY); + if(success && GetBotItem(MainPrimary)) { + ItemInst* remove_item = GetBotItem(MainPrimary); if((remove_item->GetItem()->ItemType == ItemType2HSlash) || (remove_item->GetItem()->ItemType == ItemType2HBlunt) || (remove_item->GetItem()->ItemType == ItemType2HPiercing)) { - BotTradeSwapItem(client, SLOT_PRIMARY, 0, remove_item, remove_item->GetItem()->Slots, &TempErrorMessage, false); + BotTradeSwapItem(client, MainPrimary, 0, remove_item, remove_item->GetItem()->Slots, &TempErrorMessage, false); } } break; @@ -6441,12 +6444,12 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b FaceTarget(GetTarget()); ItemInst* weapon = nullptr; - if(Hand == SLOT_PRIMARY) { - weapon = GetBotItem(SLOT_PRIMARY); + if(Hand == MainPrimary) { + weapon = GetBotItem(MainPrimary); OffHandAtk(false); } - if(Hand == SLOT_SECONDARY) { - weapon = GetBotItem(SLOT_SECONDARY); + if(Hand == MainSecondary) { + weapon = GetBotItem(MainSecondary); OffHandAtk(true); } @@ -6513,7 +6516,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b int ucDamageBonus = 0; - if( Hand == SLOT_PRIMARY && GetLevel() >= 28 && IsWarriorClass() ) + if( Hand == MainPrimary && GetLevel() >= 28 && IsWarriorClass() ) { // Damage bonuses apply only to hits from the main hand (Hand == 13) by characters level 28 and above // who belong to a melee class. If we're here, then all of these conditions apply. @@ -6526,7 +6529,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b } #endif //Live AA - Sinister Strikes *Adds weapon damage bonus to offhand weapon. - if (Hand==SLOT_SECONDARY) { + if (Hand==MainSecondary) { if (aabonuses.SecondaryDmgInc || itembonuses.SecondaryDmgInc || spellbonuses.SecondaryDmgInc){ ucDamageBonus = GetWeaponDamageBonus( weapon ? weapon->GetItem() : (const Item_Struct*) nullptr ); @@ -6583,7 +6586,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b if (damage == -3) { if (FromRiposte) return false; else { - if (Hand == SLOT_SECONDARY) {// Do we even have it & was attack with mainhand? If not, don't bother with other calculations + if (Hand == MainSecondary) {// Do we even have it & was attack with mainhand? If not, don't bother with other calculations //Live AA - SlipperyAttacks //This spell effect most likely directly modifies the actual riposte chance when using offhand attack. int16 OffhandRiposteFail = aabonuses.OffhandRiposteFail + itembonuses.OffhandRiposteFail + spellbonuses.OffhandRiposteFail; @@ -7160,7 +7163,7 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { } } - for(int y = 0; y < MAX_AUGMENT_SLOTS; ++y) + for (int y = 0; y < EmuConstants::ITEM_COMMON_SIZE; ++y) { ItemInst *aug = nullptr; aug = ins->GetAugment(y); @@ -7737,13 +7740,13 @@ float Bot::GetProcChances(float ProcBonus, uint16 weapon_speed, uint16 hand) { float ProcChance = 0.0f; switch (hand) { - case SLOT_PRIMARY: + case MainPrimary: weapon_speed = attack_timer.GetDuration(); break; - case SLOT_SECONDARY: + case MainSecondary: weapon_speed = attack_dw_timer.GetDuration(); break; - case SLOT_RANGE: + case MainRange: weapon_speed = ranged_timer.GetDuration(); break; } @@ -7860,9 +7863,9 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) if(damage > 0 && (aabonuses.ShieldBlock || spellbonuses.ShieldBlock || itembonuses.ShieldBlock) && (!other->BehindMob(this, other->GetX(), other->GetY()) || bShieldBlockFromRear)) { - bool equiped = GetBotItem(SLOT_SECONDARY); + bool equiped = GetBotItem(MainSecondary); if(equiped) { - uint8 shield = GetBotItem(SLOT_SECONDARY)->GetItem()->ItemType; + uint8 shield = GetBotItem(MainSecondary)->GetItem()->ItemType; float bonusShieldBlock = 0.0f; if(shield == ItemTypeShield) { @@ -7875,9 +7878,9 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) if(damage > 0 && (aabonuses.TwoHandBluntBlock || spellbonuses.TwoHandBluntBlock || itembonuses.TwoHandBluntBlock) && (!other->BehindMob(this, other->GetX(), other->GetY()) || bShieldBlockFromRear)) { - bool equiped2 = GetBotItem(SLOT_PRIMARY); + bool equiped2 = GetBotItem(MainPrimary); if(equiped2) { - uint8 TwoHandBlunt = GetBotItem(SLOT_PRIMARY)->GetItem()->ItemType; + uint8 TwoHandBlunt = GetBotItem(MainPrimary)->GetItem()->ItemType; float bonusStaffBlock = 0.0f; if(TwoHandBlunt == ItemType2HBlunt) { @@ -8015,7 +8018,7 @@ void Bot::DoRiposte(Mob* defender) { if (!defender) return; - defender->Attack(this, SLOT_PRIMARY, true); + defender->Attack(this, MainPrimary, true); //double riposte int16 DoubleRipChance = defender->GetAABonuses().GiveDoubleRiposte[0] + @@ -8025,7 +8028,7 @@ void Bot::DoRiposte(Mob* defender) { if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) { mlog(COMBAT__ATTACKS, "Preforming a double riposte (%d percent chance)", DoubleRipChance); - defender->Attack(this, SLOT_PRIMARY, true); + defender->Attack(this, MainPrimary, true); } //Double Riposte effect, allows for a chance to do RIPOSTE with a skill specfic special attack (ie Return Kick). @@ -8049,7 +8052,7 @@ void Bot::DoSpecialAttackDamage(Mob *who, SkillUseTypes skill, int32 max_damage, hate = hate_override; if(skill == SkillBash) { - const ItemInst* inst = GetBotItem(SLOT_SECONDARY); + const ItemInst* inst = GetBotItem(MainSecondary); const Item_Struct* botweapon = 0; if(inst) botweapon = inst->GetItem(); @@ -8063,7 +8066,7 @@ void Bot::DoSpecialAttackDamage(Mob *who, SkillUseTypes skill, int32 max_damage, min_damage += min_damage * GetMeleeMinDamageMod_SE(skill) / 100; - if(HitChance && !who->CheckHitChance(this, skill, SLOT_PRIMARY)) + if(HitChance && !who->CheckHitChance(this, skill, MainPrimary)) max_damage = 0; else{ @@ -8120,7 +8123,7 @@ void Bot::TryBackstab(Mob *other, int ReuseTime) { bool bIsBehind = false; bool bCanFrontalBS = false; - const ItemInst* inst = GetBotItem(SLOT_PRIMARY); + const ItemInst* inst = GetBotItem(MainPrimary); const Item_Struct* botpiercer = nullptr; if(inst) botpiercer = inst->GetItem(); @@ -8206,11 +8209,11 @@ void Bot::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) int32 primaryweapondamage = 0; int32 backstab_dmg = 0; - ItemInst* botweaponInst = GetBotItem(SLOT_PRIMARY); + ItemInst* botweaponInst = GetBotItem(MainPrimary); if(botweaponInst) { primaryweapondamage = GetWeaponDamage(other, botweaponInst); backstab_dmg = botweaponInst->GetItem()->BackstabDmg; - for(int i = 0; i < MAX_AUGMENT_SLOTS; ++i) + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; ++i) { ItemInst *aug = botweaponInst->GetAugment(i); if(aug) @@ -8276,7 +8279,7 @@ void Bot::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) void Bot::RogueAssassinate(Mob* other) { - ItemInst* botweaponInst = GetBotItem(SLOT_PRIMARY); + ItemInst* botweaponInst = GetBotItem(MainPrimary); if(botweaponInst) { if(GetWeaponDamage(other, botweaponInst)) { other->Damage(this, 32000, SPELL_UNKNOWN, SkillBackstab); @@ -8366,10 +8369,10 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { if(level >= RuleI(Combat, NPCBashKickLevel)){ bool canBash = false; if((GetRace() == OGRE || GetRace() == TROLL || GetRace() == BARBARIAN) // Racial Slam - || (m_inv.GetItem(SLOT_SECONDARY) && m_inv.GetItem(SLOT_SECONDARY)->GetItem()->ItemType == ItemTypeShield) //Using Shield - || (m_inv.GetItem(SLOT_PRIMARY) && (m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HSlash - || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HBlunt - || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HPiercing) + || (m_inv.GetItem(MainSecondary) && m_inv.GetItem(MainSecondary)->GetItem()->ItemType == ItemTypeShield) //Using Shield + || (m_inv.GetItem(MainPrimary) && (m_inv.GetItem(MainPrimary)->GetItem()->ItemType == ItemType2HSlash + || m_inv.GetItem(MainPrimary)->GetItem()->ItemType == ItemType2HBlunt + || m_inv.GetItem(MainPrimary)->GetItem()->ItemType == ItemType2HPiercing) && GetAA(aa2HandBash) >= 1)) { //Using 2 hand weapon, but has AA 2 Hand Bash canBash = true; } @@ -8393,10 +8396,10 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { case PALADIN: if(level >= RuleI(Combat, NPCBashKickLevel)){ if((GetRace() == OGRE || GetRace() == TROLL || GetRace() == BARBARIAN) // Racial Slam - || (m_inv.GetItem(SLOT_SECONDARY) && m_inv.GetItem(SLOT_SECONDARY)->GetItem()->ItemType == ItemTypeShield) //Using Shield - || (m_inv.GetItem(SLOT_PRIMARY) && (m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HSlash - || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HBlunt - || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HPiercing) + || (m_inv.GetItem(MainSecondary) && m_inv.GetItem(MainSecondary)->GetItem()->ItemType == ItemTypeShield) //Using Shield + || (m_inv.GetItem(MainPrimary) && (m_inv.GetItem(MainPrimary)->GetItem()->ItemType == ItemType2HSlash + || m_inv.GetItem(MainPrimary)->GetItem()->ItemType == ItemType2HBlunt + || m_inv.GetItem(MainPrimary)->GetItem()->ItemType == ItemType2HPiercing) && GetAA(aa2HandBash) >= 1)) { //Using 2 hand weapon, but has AA 2 Hand Bash skill_to_use = SkillBash; } @@ -8443,8 +8446,8 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { { DoAnim(animTailRake); - if(GetWeaponDamage(target, GetBotItem(SLOT_SECONDARY)) <= 0 && - GetWeaponDamage(target, GetBotItem(SLOT_SHOULDER)) <= 0){ + if(GetWeaponDamage(target, GetBotItem(MainSecondary)) <= 0 && + GetWeaponDamage(target, GetBotItem(MainShoulders)) <= 0){ dmg = -5; } else{ @@ -8519,7 +8522,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { { DoAnim(animKick); - if(GetWeaponDamage(target, GetBotItem(SLOT_FEET)) <= 0){ + if(GetWeaponDamage(target, GetBotItem(MainFeet)) <= 0){ dmg = -5; } else{ @@ -8991,14 +8994,14 @@ void Bot::SetAttackTimer() { Timer* TimerToUse = nullptr; const Item_Struct* PrimaryWeapon = nullptr; - for (int i=SLOT_RANGE; i<=SLOT_SECONDARY; i++) { + for (int i=MainRange; i<=MainSecondary; i++) { //pick a timer - if (i == SLOT_PRIMARY) + if (i == MainPrimary) TimerToUse = &attack_timer; - else if (i == SLOT_RANGE) + else if (i == MainRange) TimerToUse = &ranged_timer; - else if(i == SLOT_SECONDARY) + else if(i == MainSecondary) TimerToUse = &attack_dw_timer; else //invalid slot (hands will always hit this) continue; @@ -9009,7 +9012,7 @@ void Bot::SetAttackTimer() { ItemToUse = ci->GetItem(); //special offhand stuff - if(i == SLOT_SECONDARY) { + if(i == MainSecondary) { //if we have a 2H weapon in our main hand, no dual if(PrimaryWeapon != nullptr) { if( PrimaryWeapon->ItemClass == ItemClassCommon @@ -9103,7 +9106,7 @@ void Bot::SetAttackTimer() { TimerToUse->SetAtTrigger(speed, true); } - if(i == SLOT_PRIMARY) + if(i == MainPrimary) PrimaryWeapon = ItemToUse; } } @@ -11551,10 +11554,10 @@ bool Bot::CheckLoreConflict(const Item_Struct* item) { return false; if (item->LoreGroup == -1) // Standard lore items; look everywhere except the shared bank, return the result - return (m_inv.HasItem(item->ID, 0, invWhereWorn) != SLOT_INVALID); + return (m_inv.HasItem(item->ID, 0, invWhereWorn) != INVALID_INDEX); //If the item has a lore group, we check for other items with the same group and return the result - return (m_inv.HasItemByLoreGroup(item->LoreGroup, invWhereWorn) != SLOT_INVALID); + return (m_inv.HasItemByLoreGroup(item->LoreGroup, invWhereWorn) != INVALID_INDEX); } bool Bot::GroupHasClass(Group* group, uint8 classId) { @@ -12160,7 +12163,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { bool is2Hweapon = false; for(int i=0; i<22; ++i) { - if((i == 14) && is2Hweapon) { + if((i == MainSecondary) && is2Hweapon) { continue; } @@ -12178,12 +12181,12 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(15, "I need something for my %s (Item %i)", equipped[i], i); continue; } - if((i == 13) && ((item2->ItemType == ItemType2HSlash) || (item2->ItemType == ItemType2HBlunt) || (item2->ItemType == ItemType2HPiercing))) { + if((i == MainPrimary) && ((item2->ItemType == ItemType2HSlash) || (item2->ItemType == ItemType2HBlunt) || (item2->ItemType == ItemType2HPiercing))) { is2Hweapon = true; } char* itemLink = 0; - if((i == 0) || (i == 11) || (i == 13) || (i == 14) || (i == 21)) { + if((i == MainCharm) || (i == MainRange) || (i == MainPrimary) || (i == MainSecondary) || (i == MainAmmo)) { if (c->GetClientVersion() >= EQClientSoF) { MakeAnyLenString(&itemLink, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", @@ -12300,7 +12303,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { // Don't allow the player to remove a lore item they already possess and cause a crash bool failedLoreCheck = false; if(itminst) { - for(int m=0; mGetAugment(m); if(itma) { @@ -12317,7 +12320,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(itm) { c->PushItemOnCursor(*itminst, true); Bot *gearbot = c->GetTarget()->CastToBot(); - if((slotId == SLOT_RANGE)||(slotId == SLOT_AMMO)||(slotId == SLOT_PRIMARY)||(slotId == SLOT_SECONDARY)) { + if((slotId == MainRange)||(slotId == MainAmmo)||(slotId == MainPrimary)||(slotId == MainSecondary)) { gearbot->SetBotArcher(false); } gearbot->RemoveBotItemBySlot(slotId, &TempErrorMessage); @@ -16270,8 +16273,8 @@ void EntityList::BotPickLock(Bot* rogue) curdist += (tmp * tmp); if((zdiff < 10) && (curdist <= 130)) { // All rogue items with lock pick bonuses are hands or primary - const ItemInst* item1 = rogue->GetBotItem(SLOT_HANDS); - const ItemInst* item2 = rogue->GetBotItem(SLOT_PRIMARY); + const ItemInst* item1 = rogue->GetBotItem(MainHands); + const ItemInst* item2 = rogue->GetBotItem(MainPrimary); float bonus1 = 0.0f; float bonus2 = 0.0f; @@ -16500,14 +16503,14 @@ int Bot::GetRawACNoShield(int &shield_ac) { int ac = itembonuses.AC + spellbonuses.AC; shield_ac = 0; - ItemInst* inst = GetBotItem(SLOT_SECONDARY); + ItemInst* inst = GetBotItem(MainSecondary); if(inst) { if(inst->GetItem()->ItemType == ItemTypeShield) { ac -= inst->GetItem()->AC; shield_ac = inst->GetItem()->AC; - for(uint8 i = 0; i < MAX_AUGMENT_SLOTS; i++) + for (uint8 i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { if(inst->GetAugment(i)) { diff --git a/zone/client.cpp b/zone/client.cpp index 12a9ada67..60ec66d29 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1867,52 +1867,57 @@ void Client::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) // (update: i think pp should do it, as this holds LoY dye - plus, this is ugly code with Inventory!) const Item_Struct* item = nullptr; const ItemInst* inst = nullptr; - if ((inst = m_inv[SLOT_HANDS]) && inst->IsType(ItemClassCommon)) { + if ((inst = m_inv[MainHands]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); ns->spawn.equipment[MaterialHands] = item->Material; ns->spawn.colors[MaterialHands].color = GetEquipmentColor(MaterialHands); } - if ((inst = m_inv[SLOT_HEAD]) && inst->IsType(ItemClassCommon)) { + if ((inst = m_inv[MainHead]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); ns->spawn.equipment[MaterialHead] = item->Material; ns->spawn.colors[MaterialHead].color = GetEquipmentColor(MaterialHead); } - if ((inst = m_inv[SLOT_ARMS]) && inst->IsType(ItemClassCommon)) { + if ((inst = m_inv[MainArms]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); ns->spawn.equipment[MaterialArms] = item->Material; ns->spawn.colors[MaterialArms].color = GetEquipmentColor(MaterialArms); } - if ((inst = m_inv[SLOT_BRACER01]) && inst->IsType(ItemClassCommon)) { + if ((inst = m_inv[MainWrist1]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); ns->spawn.equipment[MaterialWrist]= item->Material; ns->spawn.colors[MaterialWrist].color = GetEquipmentColor(MaterialWrist); } + + /* + // non-live behavior if ((inst = m_inv[SLOT_BRACER02]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); ns->spawn.equipment[MaterialWrist]= item->Material; ns->spawn.colors[MaterialWrist].color = GetEquipmentColor(MaterialWrist); } - if ((inst = m_inv[SLOT_CHEST]) && inst->IsType(ItemClassCommon)) { + */ + + if ((inst = m_inv[MainChest]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); ns->spawn.equipment[MaterialChest] = item->Material; ns->spawn.colors[MaterialChest].color = GetEquipmentColor(MaterialChest); } - if ((inst = m_inv[SLOT_LEGS]) && inst->IsType(ItemClassCommon)) { + if ((inst = m_inv[MainLegs]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); ns->spawn.equipment[MaterialLegs] = item->Material; ns->spawn.colors[MaterialLegs].color = GetEquipmentColor(MaterialLegs); } - if ((inst = m_inv[SLOT_FEET]) && inst->IsType(ItemClassCommon)) { + if ((inst = m_inv[MainFeet]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); ns->spawn.equipment[MaterialFeet] = item->Material; ns->spawn.colors[MaterialFeet].color = GetEquipmentColor(MaterialFeet); } - if ((inst = m_inv[SLOT_PRIMARY]) && inst->IsType(ItemClassCommon)) { + if ((inst = m_inv[MainPrimary]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); if (strlen(item->IDFile) > 2) ns->spawn.equipment[MaterialPrimary] = atoi(&item->IDFile[2]); } - if ((inst = m_inv[SLOT_SECONDARY]) && inst->IsType(ItemClassCommon)) { + if ((inst = m_inv[MainSecondary]) && inst->IsType(ItemClassCommon)) { item = inst->GetItem(); if (strlen(item->IDFile) > 2) ns->spawn.equipment[MaterialSecondary] = atoi(&item->IDFile[2]); @@ -2624,7 +2629,7 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){ if(!bindwound_timer.Enabled()) { //make sure we actually have a bandage... and consume it. int16 bslot = m_inv.HasItemByUse(ItemTypeBandage, 1, invWhereWorn|invWherePersonal); - if(bslot == SLOT_INVALID) { + if (bslot == INVALID_INDEX) { bind_out->type = 3; QueuePacket(outapp); bind_out->type = 7; //this is the wrong message, dont know the right one. @@ -2775,28 +2780,31 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){ return true; } -void Client::SetMaterial(int16 in_slot, uint32 item_id){ +void Client::SetMaterial(int16 in_slot, uint32 item_id) { const Item_Struct* item = database.GetItem(item_id); if (item && (item->ItemClass==ItemClassCommon)) { - if (in_slot==SLOT_HEAD) + if (in_slot==MainHead) m_pp.item_material[MaterialHead] = item->Material; - else if (in_slot==SLOT_CHEST) + else if (in_slot==MainChest) m_pp.item_material[MaterialChest] = item->Material; - else if (in_slot==SLOT_ARMS) + else if (in_slot==MainArms) m_pp.item_material[MaterialArms] = item->Material; - else if (in_slot==SLOT_BRACER01) + else if (in_slot==MainWrist1) m_pp.item_material[MaterialWrist] = item->Material; + /* + // non-live behavior else if (in_slot==SLOT_BRACER02) m_pp.item_material[MaterialWrist] = item->Material; - else if (in_slot==SLOT_HANDS) + */ + else if (in_slot==MainHands) m_pp.item_material[MaterialHands] = item->Material; - else if (in_slot==SLOT_LEGS) + else if (in_slot==MainLegs) m_pp.item_material[MaterialLegs] = item->Material; - else if (in_slot==SLOT_FEET) + else if (in_slot==MainFeet) m_pp.item_material[MaterialFeet] = item->Material; - else if (in_slot==SLOT_PRIMARY) - m_pp.item_material[MaterialPrimary] = atoi(item->IDFile+2); - else if (in_slot==SLOT_SECONDARY) + else if (in_slot==MainPrimary) + m_pp.item_material[MaterialPrimary] = atoi(item->IDFile+2); + else if (in_slot==MainSecondary) m_pp.item_material[MaterialSecondary] = atoi(item->IDFile+2); } } @@ -3118,25 +3126,28 @@ void Client::SetTint(int16 in_slot, uint32 color) { // Still need to reconcile bracer01 versus bracer02 void Client::SetTint(int16 in_slot, Color_Struct& color) { - if (in_slot==SLOT_HEAD) + if (in_slot==MainHead) m_pp.item_tint[MaterialHead].color=color.color; - else if (in_slot==SLOT_ARMS) + else if (in_slot==MainArms) m_pp.item_tint[MaterialArms].color=color.color; - else if (in_slot==SLOT_BRACER01) + else if (in_slot==MainWrist1) m_pp.item_tint[MaterialWrist].color=color.color; + /* + // non-live behavior else if (in_slot==SLOT_BRACER02) m_pp.item_tint[MaterialWrist].color=color.color; - else if (in_slot==SLOT_HANDS) + */ + else if (in_slot==MainHands) m_pp.item_tint[MaterialHands].color=color.color; - else if (in_slot==SLOT_PRIMARY) + else if (in_slot==MainPrimary) m_pp.item_tint[MaterialPrimary].color=color.color; - else if (in_slot==SLOT_SECONDARY) + else if (in_slot==MainSecondary) m_pp.item_tint[MaterialSecondary].color=color.color; - else if (in_slot==SLOT_CHEST) + else if (in_slot==MainChest) m_pp.item_tint[MaterialChest].color=color.color; - else if (in_slot==SLOT_LEGS) + else if (in_slot==MainLegs) m_pp.item_tint[MaterialLegs].color=color.color; - else if (in_slot==SLOT_FEET) + else if (in_slot==MainFeet) m_pp.item_tint[MaterialFeet].color=color.color; } @@ -3202,57 +3213,57 @@ void Client::LinkDead() } uint8 Client::SlotConvert(uint8 slot,bool bracer){ - uint8 slot2=0; + uint8 slot2=0; // why are we returning MainCharm instead of INVALID_INDEX? (must be a pre-charm segment...) if(bracer) - return SLOT_BRACER02; + return MainWrist2; switch(slot){ case MaterialHead: - slot2=SLOT_HEAD; + slot2=MainHead; break; case MaterialChest: - slot2=SLOT_CHEST; + slot2=MainChest; break; case MaterialArms: - slot2=SLOT_ARMS; + slot2=MainArms; break; case MaterialWrist: - slot2=SLOT_BRACER01; + slot2=MainWrist1; break; case MaterialHands: - slot2=SLOT_HANDS; + slot2=MainHands; break; case MaterialLegs: - slot2=SLOT_LEGS; + slot2=MainLegs; break; case MaterialFeet: - slot2=SLOT_FEET; + slot2=MainFeet; break; } return slot2; } uint8 Client::SlotConvert2(uint8 slot){ - uint8 slot2=0; + uint8 slot2=0; // same as above... switch(slot){ - case SLOT_HEAD: + case MainHead: slot2=MaterialHead; break; - case SLOT_CHEST: + case MainChest: slot2=MaterialChest; break; - case SLOT_ARMS: + case MainArms: slot2=MaterialArms; break; - case SLOT_BRACER01: + case MainWrist1: slot2=MaterialWrist; break; - case SLOT_HANDS: + case MainHands: slot2=MaterialHands; break; - case SLOT_LEGS: + case MainLegs: slot2=MaterialLegs; break; - case SLOT_FEET: + case MainFeet: slot2=MaterialFeet; break; } @@ -4900,7 +4911,7 @@ void Client::ShowSkillsWindow() if(GetSkill(it->second) > 0 || MaxSkill(it->second) > 0) { WindowText += it->first; // line up the values - for (int j = 0; j < MAX_AUGMENT_SLOTS; j++) + for (int j = 0; j < EmuConstants::ITEM_COMMON_SIZE; j++) WindowText += " "; WindowText += itoa(this->GetSkill(it->second)); if (MaxSkill(it->second) > 0) { @@ -7854,7 +7865,7 @@ void Client::TryItemTick(int slot) //Only look at augs in main inventory if(slot > 21) { return; } - for(int x = 0; x < MAX_AUGMENT_SLOTS; ++x) + for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; ++x) { ItemInst * a_inst = inst->GetAugment(x); if(!a_inst) { continue; } @@ -7911,7 +7922,7 @@ void Client::TryItemTimer(int slot) return; } - for(int x = 0; x < MAX_AUGMENT_SLOTS; ++x) + for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; ++x) { ItemInst * a_inst = inst->GetAugment(x); if(!a_inst) { diff --git a/zone/client.h b/zone/client.h index e26465628..70528b98e 100644 --- a/zone/client.h +++ b/zone/client.h @@ -799,7 +799,7 @@ public: void QSSwapItemAuditor(MoveItem_Struct* move_in, bool postaction_call = false); void PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootItem_Struct** bag_item_data = 0); bool AutoPutLootInInventory(ItemInst& inst, bool try_worn = false, bool try_cursor = true, ServerLootItem_Struct** bag_item_data = 0); - bool SummonItem(uint32 item_id, int16 charges = -1, uint32 aug1=0, uint32 aug2=0, uint32 aug3=0, uint32 aug4=0, uint32 aug5=0, bool attuned=false, uint16 to_slot=SLOT_CURSOR); + bool SummonItem(uint32 item_id, int16 charges = -1, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, bool attuned = false, uint16 to_slot = MainCursor); void SetStats(uint8 type,int16 set_val); void IncStats(uint8 type,int16 increase_val); void DropItem(int16 slot_id); diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 3bf2217cb..7ea18655f 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -1969,14 +1969,14 @@ int Client::GetRawACNoShield(int &shield_ac) const { int ac = itembonuses.AC + spellbonuses.AC; shield_ac = 0; - const ItemInst *inst = m_inv.GetItem(SLOT_SECONDARY); + const ItemInst *inst = m_inv.GetItem(MainSecondary); if(inst) { if(inst->GetItem()->ItemType == ItemTypeShield) { ac -= inst->GetItem()->AC; shield_ac = inst->GetItem()->AC; - for(uint8 i = 0; i < MAX_AUGMENT_SLOTS; i++) + for (uint8 i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { if(inst->GetAugment(i)) { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 61b432db5..f370f2420 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2031,7 +2031,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) LogFile->write(EQEMuLog::Debug, "OP ItemVerifyRequest: spell=%i, target=%i, inv=%i", spell_id, target_id, slot_id); - if ((slot_id < 30) || (slot_id == 9999) || (slot_id > 250 && slot_id < 331 && ((item->ItemType == ItemTypePotion) || item->PotionBelt))) // sanity check + if ((slot_id < MainCursor) || (slot_id == MainPowerSource) || (slot_id > 250 && slot_id < 331 && ((item->ItemType == ItemTypePotion) || item->PotionBelt))) // sanity check { ItemInst* p_inst = (ItemInst*)inst; @@ -2047,7 +2047,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) ItemInst* clickaug = 0; Item_Struct* augitem = 0; - for(r = 0; r < MAX_AUGMENT_SLOTS; r++) { + for (r = 0; r < EmuConstants::ITEM_COMMON_SIZE; r++) { const ItemInst* aug_i = inst->GetAugment(r); if(!aug_i) continue; @@ -2465,7 +2465,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) ItemInst *inst = database.CreateItem(item, charges); if(!AutoPutLootInInventory(*inst, true, true)) { - PutLootInInventory(SLOT_CURSOR, *inst); + PutLootInInventory(MainCursor, *inst); } Save(1); } @@ -5631,8 +5631,8 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) freeslotid = m_inv.FindFreeSlot(false, true, item->Size); //make sure we are not completely full... - if(freeslotid == SLOT_CURSOR) { - if(m_inv.GetItem(SLOT_CURSOR) != nullptr) { + if (freeslotid == MainCursor) { + if (m_inv.GetItem(MainCursor) != nullptr) { Message(13, "You do not have room for any more items."); safe_delete(outapp); safe_delete(inst); @@ -5640,7 +5640,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) } } - if(freeslotid == SLOT_INVALID) + if (freeslotid == INVALID_INDEX) { Message(13, "You do not have room for any more items."); safe_delete(outapp); @@ -6227,7 +6227,7 @@ void Client::Handle_OP_ClickDoor(const EQApplicationPacket *app) void Client::Handle_OP_CreateObject(const EQApplicationPacket *app) { - DropItem(SLOT_CURSOR); + DropItem(MainCursor); return; } @@ -9232,7 +9232,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { if (it==m_inv.cursor_begin()) continue; const ItemInst *inst=*it; - SendItemPacket(SLOT_CURSOR, inst, ItemPacketSummonItem); + SendItemPacket(MainCursor, inst, ItemPacketSummonItem); } } @@ -11037,8 +11037,8 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app) { } uint32 ApplyPoisonSuccessResult = 0; ApplyPoison_Struct* ApplyPoisonData = (ApplyPoison_Struct*)app->pBuffer; - const ItemInst* PrimaryWeapon = GetInv().GetItem(SLOT_PRIMARY); - const ItemInst* SecondaryWeapon = GetInv().GetItem(SLOT_SECONDARY); + const ItemInst* PrimaryWeapon = GetInv().GetItem(MainPrimary); + const ItemInst* SecondaryWeapon = GetInv().GetItem(MainSecondary); const ItemInst* PoisonItemInstance = GetInv()[ApplyPoisonData->inventorySlot]; bool IsPoison = PoisonItemInstance && (PoisonItemInstance->GetItem()->ItemType == ItemTypePoison); @@ -11822,7 +11822,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) return; } - ItemInst *CursorItemInst = GetInv().GetItem(SLOT_CURSOR); + ItemInst *CursorItemInst = GetInv().GetItem(MainCursor); bool Allowed = true; @@ -11879,7 +11879,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { GuildBankDepositAck(false); - DeleteItemInInventory(SLOT_CURSOR, 0, false); + DeleteItemInInventory(MainCursor, 0, false); } break; @@ -11900,7 +11900,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) case GuildBankWithdraw: { - if(GetInv()[SLOT_CURSOR]) + if (GetInv()[MainCursor]) { Message_StringID(13, GUILD_BANK_EMPTY_HANDS); @@ -11946,7 +11946,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { PushItemOnCursor(*inst); - SendItemPacket(SLOT_CURSOR, inst, ItemPacketSummonItem); + SendItemPacket(MainCursor, inst, ItemPacketSummonItem); GuildBanks->DeleteItem(GuildID(), gbwis->Area, gbwis->SlotID, gbwis->Quantity); } @@ -12752,7 +12752,7 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app) { ItemInst *inst = database.CreateItem(item, charges); if(!AutoPutLootInInventory(*inst, true, true)) { - PutLootInInventory(SLOT_CURSOR, *inst); + PutLootInInventory(MainCursor, *inst); } Save(1); @@ -12786,7 +12786,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) { SummonItem(item_id, max_currency); SetAlternateCurrencyValue(reclaim->currency_id, 0); } else { - SummonItem(item_id, reclaim->count, 0, 0, 0, 0, 0, false, SLOT_CURSOR); + SummonItem(item_id, reclaim->count, 0, 0, 0, 0, 0, false, MainCursor); AddAlternateCurrencyValue(reclaim->currency_id, -((int32)reclaim->count)); } } diff --git a/zone/client_process.cpp b/zone/client_process.cpp index f245c1d44..d5abb7f04 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -293,7 +293,7 @@ bool Client::Process() { } if(AutoFireEnabled()){ - ItemInst *ranged = GetInv().GetItem(SLOT_RANGE); + ItemInst *ranged = GetInv().GetItem(MainRange); if(ranged) { if(ranged->GetItem() && ranged->GetItem()->ItemType == ItemTypeBow){ @@ -404,7 +404,7 @@ bool Client::Process() { } else { Attack(auto_attack_target, 13); // Kaiyodo - added attacking hand to arguments } - ItemInst *wpn = GetInv().GetItem(SLOT_PRIMARY); + ItemInst *wpn = GetInv().GetItem(MainPrimary); TryWeaponProc(wpn, auto_attack_target, 13); bool tripleAttackSuccess = false; @@ -452,7 +452,7 @@ bool Client::Process() { int16 ExtraAttackChanceBonus = spellbonuses.ExtraAttackChance + itembonuses.ExtraAttackChance + aabonuses.ExtraAttackChance; if (auto_attack_target && ExtraAttackChanceBonus) { - ItemInst *wpn = GetInv().GetItem(SLOT_PRIMARY); + ItemInst *wpn = GetInv().GetItem(MainPrimary); if(wpn){ if(wpn->GetItem()->ItemType == ItemType2HSlash || wpn->GetItem()->ItemType == ItemType2HBlunt || @@ -511,7 +511,7 @@ bool Client::Process() { } else { Attack(auto_attack_target, 14); // Single attack with offhand } - ItemInst *wpn = GetInv().GetItem(SLOT_SECONDARY); + ItemInst *wpn = GetInv().GetItem(MainSecondary); TryWeaponProc(wpn, auto_attack_target, 14); if( CanThisClassDoubleAttack() && CheckDoubleAttack()) { @@ -1217,7 +1217,7 @@ void Client::OPMemorizeSpell(const EQApplicationPacket* app) switch(memspell->scribing) { case memSpellScribing: { // scribing spell to book - const ItemInst* inst = m_inv[SLOT_CURSOR]; + const ItemInst* inst = m_inv[MainCursor]; if(inst && inst->IsType(ItemClassCommon)) { @@ -1226,7 +1226,7 @@ void Client::OPMemorizeSpell(const EQApplicationPacket* app) if(item && item->Scroll.Effect == (int32)(memspell->spell_id)) { ScribeSpell(memspell->spell_id, memspell->slot); - DeleteItemInInventory(SLOT_CURSOR, 1, true); + DeleteItemInInventory(MainCursor, 1, true); } else Message(0,"Scribing spell: inst exists but item does not or spell ids do not match."); diff --git a/zone/command.cpp b/zone/command.cpp index ea54ead17..dbc368546 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -2977,12 +2977,12 @@ void command_peekinv(Client *c, const Seperator *sep) if(client->GetInv().CursorEmpty()) { // Display 'front' cursor slot even if 'empty' (item(30[0]) == null) if (c->GetClientVersion() >= EQClientSoF) { - c->Message((item==0), "CursorSlot: %i, Depth: %i, Item: %i (%c%06X00000000000000000000000000000000000000000000%s%c), Charges: %i", SLOT_CURSOR,i, + c->Message((item == 0), "CursorSlot: %i, Depth: %i, Item: %i (%c%06X00000000000000000000000000000000000000000000%s%c), Charges: %i", MainCursor, i, 0, 0x12, 0, "null", 0x12, 0); } else { - c->Message((item==0), "CursorSlot: %i, Depth: %i, Item: %i (%c%06X000000000000000000000000000000000000000%s%c), Charges: %i", SLOT_CURSOR,i, + c->Message((item == 0), "CursorSlot: %i, Depth: %i, Item: %i (%c%06X000000000000000000000000000000000000000%s%c), Charges: %i", MainCursor, i, 0, 0x12, 0, "null", 0x12, 0); } } @@ -2992,14 +2992,14 @@ void command_peekinv(Client *c, const Seperator *sep) item = (inst) ? inst->GetItem() : nullptr; if (c->GetClientVersion() >= EQClientSoF) { - c->Message((item==0), "CursorSlot: %i, Depth: %i, Item: %i (%c%06X00000000000000000000000000000000000000000000%s%c), Charges: %i", SLOT_CURSOR,i, + c->Message((item == 0), "CursorSlot: %i, Depth: %i, Item: %i (%c%06X00000000000000000000000000000000000000000000%s%c), Charges: %i", MainCursor, i, ((item==0)?0:item->ID),0x12, ((item==0)?0:item->ID), ((item==0)?"null":item->Name), 0x12, ((item==0)?0:inst->GetCharges())); } else { - c->Message((item==0), "CursorSlot: %i, Depth: %i, Item: %i (%c%06X000000000000000000000000000000000000000%s%c), Charges: %i", SLOT_CURSOR,i, + c->Message((item == 0), "CursorSlot: %i, Depth: %i, Item: %i (%c%06X000000000000000000000000000000000000000%s%c), Charges: %i", MainCursor, i, ((item==0)?0:item->ID),0x12, ((item==0)?0:item->ID), ((item==0)?"null":item->Name), 0x12, ((item==0)?0:inst->GetCharges())); @@ -3007,21 +3007,21 @@ void command_peekinv(Client *c, const Seperator *sep) if (inst && inst->IsType(ItemClassContainer) && i==0) { // 'CSD 1' - only display contents of slot 30[0] container..higher ones don't exist for (uint8 j=0; j<10; j++) { - const ItemInst* instbag = client->GetInv().GetItem(SLOT_CURSOR, j); + const ItemInst* instbag = client->GetInv().GetItem(MainCursor, j); item = (instbag) ? instbag->GetItem() : nullptr; if (c->GetClientVersion() >= EQClientSoF) { c->Message((item==0), " CursorBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%c%06X00000000000000000000000000000000000000000000%s%c), Charges: %i", - Inventory::CalcSlotId(SLOT_CURSOR, j), - SLOT_CURSOR, j, ((item==0)?0:item->ID),0x12, ((item==0)?0:item->ID), + Inventory::CalcSlotId(MainCursor, j), + MainCursor, j, ((item == 0) ? 0 : item->ID), 0x12, ((item == 0) ? 0 : item->ID), ((item==0)?"null":item->Name), 0x12, ((item==0)?0:instbag->GetCharges())); } else { c->Message((item==0), " CursorBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%c%06X000000000000000000000000000000000000000%s%c), Charges: %i", - Inventory::CalcSlotId(SLOT_CURSOR, j), - SLOT_CURSOR, j, ((item==0)?0:item->ID),0x12, ((item==0)?0:item->ID), + Inventory::CalcSlotId(MainCursor, j), + MainCursor, j, ((item == 0) ? 0 : item->ID), 0x12, ((item == 0) ? 0 : item->ID), ((item==0)?"null":item->Name), 0x12, ((item==0)?0:instbag->GetCharges())); } @@ -3533,7 +3533,7 @@ void command_equipitem(Client *c, const Seperator *sep) { uint32 slot_id = atoi(sep->arg[1]); if (sep->IsNumber(1) && (slot_id>=0) && (slot_id<=21)) { - const ItemInst* from_inst = c->GetInv().GetItem(SLOT_CURSOR); + const ItemInst* from_inst = c->GetInv().GetItem(MainCursor); const ItemInst* to_inst = c->GetInv().GetItem(slot_id); // added (desync issue when forcing stack to stack) bool partialmove = false; int16 movecount; @@ -3541,7 +3541,7 @@ void command_equipitem(Client *c, const Seperator *sep) if (from_inst && from_inst->IsType(ItemClassCommon)) { EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveItem, sizeof(MoveItem_Struct)); MoveItem_Struct* mi = (MoveItem_Struct*)outapp->pBuffer; - mi->from_slot = SLOT_CURSOR; + mi->from_slot = MainCursor; mi->to_slot = slot_id; // mi->number_in_stack = from_inst->GetCharges(); // replaced with con check for stacking @@ -4698,7 +4698,7 @@ void command_goto(Client *c, const Seperator *sep) void command_iteminfo(Client *c, const Seperator *sep) { - const ItemInst* inst = c->GetInv()[SLOT_CURSOR]; + const ItemInst* inst = c->GetInv()[MainCursor]; if (!inst) c->Message(13, "Error: You need an item on your cursor for this command"); diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 992649c03..031bdcec8 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -421,7 +421,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) if(cursor) { // all cursor items should be on corpse (client < SoF or RespawnFromHover = false) while(!client->GetInv().CursorEmpty()) - client->DeleteItemInInventory(SLOT_CURSOR, 0, false, false); + client->DeleteItemInInventory(MainCursor, 0, false, false); } else { // only visible cursor made it to corpse (client >= Sof and RespawnFromHover = true) std::list::const_iterator start = client->GetInv().cursor_begin(); @@ -1013,7 +1013,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a // Dont display the item if it's in a bag // Added cursor queue slots to corpse item visibility list. Nothing else should be making it to corpse. - if(!IsPlayerCorpse() || item_data->equipSlot <= 30 || item_data->equipSlot == 9999 || tCanLoot>=3 || + if(!IsPlayerCorpse() || item_data->equipSlot <= MainCursor || item_data->equipSlot == MainPowerSource || tCanLoot>=3 || (item_data->equipSlot >= 8000 && item_data->equipSlot <= 8999)) { if(i < corpselootlimit) { item = database.GetItem(item_data->item_id); @@ -1145,7 +1145,7 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) if(inst->IsAugmented()) { - for(int i=0; iGetAugment(i); if(itm) @@ -1227,11 +1227,11 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) if(lootitem->auto_loot) { if(!client->AutoPutLootInInventory(*inst, true, true, bag_item_data)) - client->PutLootInInventory(SLOT_CURSOR, *inst, bag_item_data); + client->PutLootInInventory(MainCursor, *inst, bag_item_data); } else { - client->PutLootInInventory(SLOT_CURSOR, *inst, bag_item_data); + client->PutLootInInventory(MainCursor, *inst, bag_item_data); } // Update any tasks that have an activity to loot this item. if(RuleB(TaskSystem, EnableTaskSystem)) diff --git a/zone/doors.cpp b/zone/doors.cpp index 5713c5aa7..ab0b54c8f 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -162,7 +162,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger) { if(!sender->KeyRingCheck(RuleI(Adventure, ItemIDToEnablePorts))) { - if(sender->GetInv().HasItem(RuleI(Adventure, ItemIDToEnablePorts)) == SLOT_INVALID) + if (sender->GetInv().HasItem(RuleI(Adventure, ItemIDToEnablePorts)) == INVALID_INDEX) { sender->Message_StringID(13, DUNGEON_SEALED); safe_delete(outapp); @@ -195,11 +195,11 @@ void Doors::HandleClick(Client* sender, uint8 trigger) uint8 keepoffkeyring = GetNoKeyring(); uint32 haskey = 0; uint32 playerkey = 0; - const ItemInst *lockpicks = sender->GetInv().GetItem(SLOT_CURSOR); + const ItemInst *lockpicks = sender->GetInv().GetItem(MainCursor); haskey = sender->GetInv().HasItem(keyneeded, 1); - if(haskey != SLOT_INVALID) + if (haskey != INVALID_INDEX) { playerkey = keyneeded; } diff --git a/zone/forage.cpp b/zone/forage.cpp index 7afae271a..637b4c895 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -206,10 +206,10 @@ uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, //we need this function to immediately determine, after we receive OP_Fishing, if we can even try to fish, otherwise we have to wait a while to get the failure bool Client::CanFish() { //make sure we still have a fishing pole on: - const ItemInst* Pole = m_inv[SLOT_PRIMARY]; + const ItemInst* Pole = m_inv[MainPrimary]; int32 bslot = m_inv.HasItemByUse(ItemTypeFishingBait, 1, invWhereWorn|invWherePersonal); const ItemInst* Bait = nullptr; - if(bslot != SLOT_INVALID) + if (bslot != INVALID_INDEX) Bait = m_inv.GetItem(bslot); if(!Pole || !Pole->IsType(ItemClassCommon) || Pole->GetItem()->ItemType != ItemTypeFishingPole) { @@ -297,7 +297,7 @@ void Client::GoFish() //make sure we still have a fishing pole on: int32 bslot = m_inv.HasItemByUse(ItemTypeFishingBait, 1, invWhereWorn|invWherePersonal); const ItemInst* Bait = nullptr; - if(bslot != SLOT_INVALID) + if (bslot != INVALID_INDEX) Bait = m_inv.GetItem(bslot); //if the bait isnt equipped, need to add its skill bonus @@ -358,12 +358,12 @@ void Client::GoFish() else { PushItemOnCursor(*inst); - SendItemPacket(SLOT_CURSOR,inst,ItemPacketSummonItem); + SendItemPacket(MainCursor, inst, ItemPacketSummonItem); if(RuleB(TaskSystem, EnableTaskSystem)) UpdateTasksForItem(ActivityFish, food_id); safe_delete(inst); - inst = m_inv.GetItem(SLOT_CURSOR); + inst = m_inv.GetItem(MainCursor); } } @@ -472,12 +472,12 @@ void Client::ForageItem(bool guarantee) { } else { PushItemOnCursor(*inst); - SendItemPacket(SLOT_CURSOR, inst, ItemPacketSummonItem); + SendItemPacket(MainCursor, inst, ItemPacketSummonItem); if(RuleB(TaskSystem, EnableTaskSystem)) UpdateTasksForItem(ActivityForage, foragedfood); safe_delete(inst); - inst = m_inv.GetItem(SLOT_CURSOR); + inst = m_inv.GetItem(MainCursor); } } diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 5292dd1c0..fb4315292 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -194,10 +194,10 @@ bool Client::CheckLoreConflict(const Item_Struct* item) { return false; if (item->LoreGroup == -1) // Standard lore items; look everywhere except the shared bank, return the result - return (m_inv.HasItem(item->ID, 0, ~invWhereSharedBank) != SLOT_INVALID); + return (m_inv.HasItem(item->ID, 0, ~invWhereSharedBank) != INVALID_INDEX); //If the item has a lore group, we check for other items with the same group and return the result - return (m_inv.HasItemByLoreGroup(item->LoreGroup, ~invWhereSharedBank) != SLOT_INVALID); + return (m_inv.HasItemByLoreGroup(item->LoreGroup, ~invWhereSharedBank) != INVALID_INDEX); } bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, bool attuned, uint16 to_slot) { @@ -244,7 +244,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, } */ - uint32 augments[MAX_AUGMENT_SLOTS] = { aug1, aug2, aug3, aug4, aug5 }; + uint32 augments[EmuConstants::ITEM_COMMON_SIZE] = { aug1, aug2, aug3, aug4, aug5 }; uint32 classes = item->Classes; uint32 races = item->Races; @@ -254,7 +254,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, bool enforcerestr = RuleB(Inventory, EnforceAugmentRestriction); bool enforceusable = RuleB(Inventory, EnforceAugmentUsability); - for(int iter = 0; iter < MAX_AUGMENT_SLOTS; ++iter) { + for (int iter = 0; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) { const Item_Struct* augtest = database.GetItem(augments[iter]); if(augtest == nullptr) { @@ -548,7 +548,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, } // add any validated augments - for(int iter = 0; iter < MAX_AUGMENT_SLOTS; ++iter) { + for (int iter = 0; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) { if(augments[iter]) inst->PutAugment(&database, iter, augments[iter]); } @@ -558,22 +558,22 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, inst->SetInstNoDrop(true); // check to see if item is usable in requested slot - if(enforceusable && (((to_slot >= 0) && (to_slot <= 21)) || (to_slot == 9999))) { - uint32 slottest = (to_slot == 9999) ? 22 : to_slot; + if(enforceusable && (((to_slot >= MainCharm) && (to_slot <= MainAmmo)) || (to_slot == MainPowerSource))) { + uint32 slottest = (to_slot == MainPowerSource) ? 22 : to_slot; // can't change '22' just yet... if(!(slots & ((uint32)1 << slottest))) { Message(0, "This item is not equipable at slot %u - moving to cursor.", to_slot); mlog(INVENTORY__ERROR, "Player %s on account %s attempted to equip an item unusable in slot %u - moved to cursor.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u)\n", GetName(), account_name, to_slot, item->ID, aug1, aug2, aug3, aug4, aug5); - to_slot = SLOT_CURSOR; + to_slot = MainCursor; } } // put item into inventory - if(to_slot == SLOT_CURSOR) { + if (to_slot == MainCursor) { PushItemOnCursor(*inst); - SendItemPacket(SLOT_CURSOR, inst, ItemPacketSummonItem); + SendItemPacket(MainCursor, inst, ItemPacketSummonItem); } else { PutItemInInventory(to_slot, *inst, true); @@ -586,7 +586,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, if(!IsDiscovered(item_id)) DiscoverItem(item_id); - for(int iter = 0; iter < MAX_AUGMENT_SLOTS; ++iter) { + for (int iter = 0; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) { if(augments[iter] && !IsDiscovered(augments[iter])) DiscoverItem(augments[iter]); } @@ -619,7 +619,7 @@ void Client::DropItem(int16 slot_id) } // Save client inventory change to database - if(slot_id == SLOT_CURSOR) { + if (slot_id == MainCursor) { std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(CharacterID(), s, e); } else { @@ -755,7 +755,7 @@ void Client::DeleteItemInInventory(int16 slot_id, int8 quantity, bool client_upd bool isDeleted = m_inv.DeleteItem(slot_id, quantity); const ItemInst* inst=nullptr; - if (slot_id==SLOT_CURSOR) { + if (slot_id == MainCursor) { std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); if(update_db) database.SaveCursor(character_id, s, e); @@ -807,7 +807,7 @@ bool Client::PushItemOnCursor(const ItemInst& inst, bool client_update) m_inv.PushCursor(inst); if (client_update) { - SendItemPacket(SLOT_CURSOR, &inst, ItemPacketSummonItem); + SendItemPacket(MainCursor, &inst, ItemPacketSummonItem); } std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); @@ -817,7 +817,7 @@ bool Client::PushItemOnCursor(const ItemInst& inst, bool client_update) bool Client::PutItemInInventory(int16 slot_id, const ItemInst& inst, bool client_update) { mlog(INVENTORY__SLOTS, "Putting item %s (%d) into slot %d", inst.GetItem()->Name, inst.GetItem()->ID, slot_id); - if (slot_id==SLOT_CURSOR) + if (slot_id == MainCursor) { return PushItemOnCursor(inst,client_update); } @@ -825,10 +825,10 @@ bool Client::PutItemInInventory(int16 slot_id, const ItemInst& inst, bool client m_inv.PutItem(slot_id, inst); if (client_update) { - SendItemPacket(slot_id, &inst, (slot_id==SLOT_CURSOR)?ItemPacketSummonItem:ItemPacketTrade); + SendItemPacket(slot_id, &inst, (slot_id == MainCursor) ? ItemPacketSummonItem : ItemPacketTrade); } - if (slot_id==SLOT_CURSOR) { + if (slot_id == MainCursor) { std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); return database.SaveCursor(this->CharacterID(), s, e); } else @@ -844,7 +844,7 @@ void Client::PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootI SendLootItemInPacket(&inst, slot_id); - if (slot_id==SLOT_CURSOR) { + if (slot_id == MainCursor) { std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(this->CharacterID(), s, e); } else @@ -919,25 +919,25 @@ bool Client::AutoPutLootInInventory(ItemInst& inst, bool try_worn, bool try_curs if (!m_inv[i]) { - if( i == SLOT_PRIMARY && inst.IsWeapon() ) // If item is primary slot weapon + if( i == MainPrimary && inst.IsWeapon() ) // If item is primary slot weapon { if( (inst.GetItem()->ItemType == ItemType2HSlash) || (inst.GetItem()->ItemType == ItemType2HBlunt) || (inst.GetItem()->ItemType == ItemType2HPiercing) ) // and uses 2hs \ 2hb \ 2hp { - if( m_inv[SLOT_SECONDARY] ) // and if secondary slot is not empty + if( m_inv[MainSecondary] ) // and if secondary slot is not empty { continue; // Can't auto-equip } } } - if( i== SLOT_SECONDARY && m_inv[SLOT_PRIMARY]) // check to see if primary slot is a two hander + if( i== MainSecondary && m_inv[MainPrimary]) // check to see if primary slot is a two hander { - uint8 use = m_inv[SLOT_PRIMARY]->GetItem()->ItemType; + uint8 use = m_inv[MainPrimary]->GetItem()->ItemType; if(use == ItemType2HSlash || use == ItemType2HBlunt || use == ItemType2HPiercing) continue; } if ( - i == SLOT_SECONDARY && + i == MainSecondary && inst.IsWeapon() && !CanThisClassDualWield() ) @@ -972,7 +972,7 @@ bool Client::AutoPutLootInInventory(ItemInst& inst, bool try_worn, bool try_curs // #3: put it in inventory bool is_arrow = (inst.GetItem()->ItemType == ItemTypeArrow) ? true : false; int16 slot_id = m_inv.FindFreeSlot(inst.IsType(ItemClassContainer), try_cursor, inst.GetItem()->Size, is_arrow); - if (slot_id != SLOT_INVALID) + if (slot_id != INVALID_INDEX) { PutLootInInventory(slot_id, inst, bag_item_data); return true; @@ -1000,7 +1000,7 @@ void Client::MoveItemCharges(ItemInst &from, int16 to_slot, uint8 type) tmp_inst->SetCharges(tmp_inst->GetCharges() + charges_to_move); from.SetCharges(from.GetCharges() - charges_to_move); SendLootItemInPacket(tmp_inst, to_slot); - if (to_slot==SLOT_CURSOR){ + if (to_slot == MainCursor){ std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(this->CharacterID(), s, e); } else @@ -1224,25 +1224,21 @@ void Client::SendLootItemInPacket(const ItemInst* inst, int16 slot_id) SendItemPacket(slot_id,inst, ItemPacketTrade); } -bool Client::IsValidSlot(uint32 slot) -{ - if((slot == (uint32)SLOT_INVALID) || // Destroying/Dropping item - (slot >= 0 && slot <= 30) || // Worn inventory, normal inventory, and cursor - (slot >= 251 && slot <= 340) || // Normal inventory bags and cursor bag - (slot >= 400 && slot <= 404) || // Tribute - (slot >= 2000 && slot <= 2023) || // Bank - (slot >= 2031 && slot <= 2270) || // Bank bags - (slot >= 2500 && slot <= 2501) || // Shared bank - (slot >= 2531 && slot <= 2550) || // Shared bank bags - (slot >= 3000 && slot <= 3007) || // Trade window - (slot >= 4000 && slot <= 4009) || // Tradeskill container - (slot == 9999)) // Power Source - { +bool Client::IsValidSlot(uint32 slot) { + if ((slot == (uint32)INVALID_INDEX) || // Destroying/Dropping item + (slot >= MainCharm && slot <= MainCursor) || // Worn inventory, normal inventory, and cursor + (slot >= 251 && slot <= 340) || // Normal inventory bags and cursor bag + (slot >= 400 && slot <= 404) || // Tribute + (slot >= 2000 && slot <= 2023) || // Bank + (slot >= 2031 && slot <= 2270) || // Bank bags + (slot >= 2500 && slot <= 2501) || // Shared bank + (slot >= 2531 && slot <= 2550) || // Shared bank bags + (slot >= 3000 && slot <= 3007) || // Trade window + (slot >= 4000 && slot <= 4009) || // Tradeskill container + (slot == MainPowerSource)) // Power Source return true; - } - else { + else return false; - } } bool Client::IsBankSlot(uint32 slot) @@ -1289,12 +1285,12 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { return true; } - if (move_in->to_slot == (uint32)SLOT_INVALID) { - if(move_in->from_slot == (uint32)SLOT_CURSOR) { + if (move_in->to_slot == (uint32)INVALID_INDEX) { + if (move_in->from_slot == (uint32)MainCursor) { mlog(INVENTORY__SLOTS, "Client destroyed item from cursor slot %d", move_in->from_slot); if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit - ItemInst *inst = m_inv.GetItem(SLOT_CURSOR); + ItemInst *inst = m_inv.GetItem(MainCursor); if(inst) { parse->EventItem(EVENT_DESTROY_ITEM, this, inst, nullptr, "", 0); } @@ -1309,9 +1305,9 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { return true; // Item deletetion } } - if(auto_attack && (move_in->from_slot == SLOT_PRIMARY || move_in->from_slot == SLOT_SECONDARY || move_in->from_slot == SLOT_RANGE)) + if(auto_attack && (move_in->from_slot == MainPrimary || move_in->from_slot == MainSecondary || move_in->from_slot == MainRange)) SetAttackTimer(); - else if(auto_attack && (move_in->to_slot == SLOT_PRIMARY || move_in->to_slot == SLOT_SECONDARY || move_in->to_slot == SLOT_RANGE)) + else if(auto_attack && (move_in->to_slot == MainPrimary || move_in->to_slot == MainSecondary || move_in->to_slot == MainRange)) SetAttackTimer(); // Step 1: Variables int16 src_slot_id = (int16)move_in->from_slot; @@ -1501,7 +1497,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } safe_delete(world_inst); - if (src_slot_id==SLOT_CURSOR) { + if (src_slot_id == MainCursor) { std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(character_id, s, e); } else @@ -1515,14 +1511,14 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { // Step 4: Check for entity trade if (dst_slot_id>=3000 && dst_slot_id<=3007) { - if (src_slot_id != SLOT_CURSOR) { + if (src_slot_id != MainCursor) { Kick(); return false; } if (with) { mlog(INVENTORY__SLOTS, "Trade item move from slot %d to slot %d (trade with %s)", src_slot_id, dst_slot_id, with->GetName()); // Fill Trade list with items from cursor - if (!m_inv[SLOT_CURSOR]) { + if (!m_inv[MainCursor]) { Message(13, "Error: Cursor item not located on server!"); return false; } @@ -1538,7 +1534,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit SummonItem(src_inst->GetID(), src_inst->GetCharges()); - DeleteItemInInventory(SLOT_CURSOR); + DeleteItemInInventory(MainCursor); return true; } @@ -1601,12 +1597,12 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } else { // Not dealing with charges - just do direct swap - if(src_inst && (dst_slot_id < 22 || dst_slot_id == 9999) && dst_slot_id >= 0) { + if(src_inst && (dst_slot_id <= MainAmmo || dst_slot_id == MainPowerSource) && dst_slot_id >= MainCharm) { if (src_inst->GetItem()->Attuneable) { src_inst->SetInstNoDrop(true); } if (src_inst->IsAugmented()) { - for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) { if (src_inst->GetAugment(i)) { if (src_inst->GetAugment(i)->GetItem()->Attuneable) { src_inst->GetAugment(i)->SetInstNoDrop(true); @@ -1619,7 +1615,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if(!m_inv.SwapItem(src_slot_id, dst_slot_id)) { return false; } mlog(INVENTORY__SLOTS, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id); - if(src_slot_id < 22 || src_slot_id == 9999) { + if(src_slot_id <= MainAmmo || src_slot_id == MainPowerSource) { if(src_inst) { parse->EventItem(EVENT_UNEQUIP_ITEM, this, src_inst, nullptr, "", src_slot_id); } @@ -1629,7 +1625,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } } - if(dst_slot_id < 22 || dst_slot_id == 9999) { + if(dst_slot_id <= MainAmmo || dst_slot_id == MainPowerSource) { if(dst_inst) { parse->EventItem(EVENT_UNEQUIP_ITEM, this, dst_inst, nullptr, "", dst_slot_id); } @@ -1646,12 +1642,12 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } // Step 7: Save change to the database - if (src_slot_id==SLOT_CURSOR){ + if (src_slot_id == MainCursor){ std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(character_id, s, e); } else database.SaveInventory(character_id, m_inv.GetItem(src_slot_id), src_slot_id); - if (dst_slot_id==SLOT_CURSOR) { + if (dst_slot_id == MainCursor) { std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(character_id, s, e); } else @@ -1665,14 +1661,17 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } void Client::SwapItemResync(MoveItem_Struct* move_slots) { + // wow..this thing created a helluva memory leak... + // with any luck..this won't be needed in the future + // resync the 'from' and 'to' slots on an as-needed basis // Not as effective as the full process, but less intrusive to gameplay -U mlog(INVENTORY__ERROR, "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 >= 0 && move_slots->from_slot <= 340) || move_slots->from_slot == 9999) { - int16 resync_slot = (Inventory::CalcSlotId(move_slots->from_slot) == SLOT_INVALID) ? move_slots->from_slot : Inventory::CalcSlotId(move_slots->from_slot); - if(IsValidSlot(resync_slot) && resync_slot != SLOT_INVALID) { + if((move_slots->from_slot >= MainCharm && move_slots->from_slot <= 340) || move_slots->from_slot == MainPowerSource) { + int16 resync_slot = (Inventory::CalcSlotId(move_slots->from_slot) == INVALID_INDEX) ? move_slots->from_slot : Inventory::CalcSlotId(move_slots->from_slot); + if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) { // This prevents the client from crashing when closing any 'phantom' bags -U const Item_Struct* token_struct = database.GetItem(22292); // 'Copper Coin' ItemInst* token_inst = database.CreateItem(token_struct, 1); @@ -1690,13 +1689,14 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { QueuePacket(outapp); safe_delete(outapp); } + safe_delete(token_inst); Message(14, "Source slot %i resyncronized.", move_slots->from_slot); } else { Message(13, "Could not resyncronize source slot %i.", move_slots->from_slot); } } else { - int16 resync_slot = (Inventory::CalcSlotId(move_slots->from_slot) == SLOT_INVALID) ? move_slots->from_slot : Inventory::CalcSlotId(move_slots->from_slot); - if(IsValidSlot(resync_slot) && resync_slot != SLOT_INVALID) { + int16 resync_slot = (Inventory::CalcSlotId(move_slots->from_slot) == INVALID_INDEX) ? move_slots->from_slot : Inventory::CalcSlotId(move_slots->from_slot); + if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) { if(m_inv[resync_slot]) { const Item_Struct* token_struct = database.GetItem(22292); // 'Copper Coin' ItemInst* token_inst = database.CreateItem(token_struct, 1); @@ -1704,6 +1704,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { SendItemPacket(resync_slot, token_inst, ItemPacketTrade); SendItemPacket(resync_slot, m_inv[resync_slot], ItemPacketTrade); + safe_delete(token_inst); Message(14, "Source slot %i resyncronized.", move_slots->from_slot); } else { Message(13, "Could not resyncronize source slot %i.", move_slots->from_slot); } @@ -1711,9 +1712,9 @@ 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 >= 0 && move_slots->to_slot <= 340) || move_slots->to_slot == 9999) { - int16 resync_slot = (Inventory::CalcSlotId(move_slots->to_slot) == SLOT_INVALID) ? move_slots->to_slot : Inventory::CalcSlotId(move_slots->to_slot); - if(IsValidSlot(resync_slot) && resync_slot != SLOT_INVALID) { + if((move_slots->to_slot >= MainCharm && move_slots->to_slot <= 340) || move_slots->to_slot == MainPowerSource) { + int16 resync_slot = (Inventory::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : Inventory::CalcSlotId(move_slots->to_slot); + if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) { const Item_Struct* token_struct = database.GetItem(22292); // 'Copper Coin' ItemInst* token_inst = database.CreateItem(token_struct, 1); @@ -1730,13 +1731,14 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { QueuePacket(outapp); safe_delete(outapp); } + safe_delete(token_inst); Message(14, "Destination slot %i resyncronized.", move_slots->to_slot); } else { Message(13, "Could not resyncronize destination slot %i.", move_slots->to_slot); } } else { - int16 resync_slot = (Inventory::CalcSlotId(move_slots->to_slot) == SLOT_INVALID) ? move_slots->to_slot : Inventory::CalcSlotId(move_slots->to_slot); - if(IsValidSlot(resync_slot) && resync_slot != SLOT_INVALID) { + int16 resync_slot = (Inventory::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : Inventory::CalcSlotId(move_slots->to_slot); + if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) { if(m_inv[resync_slot]) { const Item_Struct* token_struct = database.GetItem(22292); // 'Copper Coin' ItemInst* token_inst = database.CreateItem(token_struct, 1); @@ -1744,6 +1746,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { SendItemPacket(resync_slot, token_inst, ItemPacketTrade); SendItemPacket(resync_slot, m_inv[resync_slot], ItemPacketTrade); + safe_delete(token_inst); Message(14, "Destination slot %i resyncronized.", move_slots->to_slot); } else { Message(13, "Could not resyncronize destination slot %i.", move_slots->to_slot); } @@ -1857,7 +1860,7 @@ void Client::DyeArmor(DyeStruct* dye){ m_pp.item_tint[i].rgb.red!=dye->dye[i].rgb.red || m_pp.item_tint[i].rgb.green != dye->dye[i].rgb.green){ slot = m_inv.HasItem(32557, 1, invWherePersonal); - if(slot != SLOT_INVALID){ + if (slot != INVALID_INDEX){ DeleteItemInInventory(slot,1,true); uint8 slot2=SlotConvert(i); ItemInst* inst = this->m_inv.GetItem(slot2); @@ -2003,7 +2006,7 @@ void Client::RemoveNoRent(bool client_update) { const ItemInst* inst = m_inv[9999]; if(inst && !inst->GetItem()->NoRent) { mlog(INVENTORY__SLOTS, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); - DeleteItemInInventory(9999, 0, (GetClientVersion() >= EQClientSoF) ? client_update : false); // Ti slot non-existent + DeleteItemInInventory(MainPowerSource, 0, (GetClientVersion() >= EQClientSoF) ? client_update : false); // Ti slot non-existent } // containers @@ -2283,13 +2286,13 @@ static int16 BandolierSlotToWeaponSlot(int BandolierSlot) { switch(BandolierSlot) { case bandolierMainHand: - return SLOT_PRIMARY; + return MainPrimary; case bandolierOffHand: - return SLOT_SECONDARY; + return MainSecondary; case bandolierRange: - return SLOT_RANGE; + return MainRange; default: - return SLOT_AMMO; + return MainAmmo; } } @@ -2365,12 +2368,12 @@ void Client::SetBandolier(const EQApplicationPacket *app) { invWhereWorn|invWherePersonal); // removed 'invWhereCursor' argument from above and implemented slots 30, 331-340 checks here - if (slot == SLOT_INVALID) { - if (m_inv.GetItem(SLOT_CURSOR)) { - if (m_inv.GetItem(SLOT_CURSOR)->GetItem()->ID == m_pp.bandoliers[bss->number].items[BandolierSlot].item_id && - m_inv.GetItem(SLOT_CURSOR)->GetCharges() >= 1) // '> 0' the same, but this matches Inventory::_HasItem conditional check - slot = SLOT_CURSOR; - else if (m_inv.GetItem(SLOT_CURSOR)->GetItem()->ItemClass == 1) { + if (slot == INVALID_INDEX) { + if (m_inv.GetItem(MainCursor)) { + if (m_inv.GetItem(MainCursor)->GetItem()->ID == m_pp.bandoliers[bss->number].items[BandolierSlot].item_id && + m_inv.GetItem(MainCursor)->GetCharges() >= 1) // '> 0' the same, but this matches Inventory::_HasItem conditional check + slot = MainCursor; + else if (m_inv.GetItem(MainCursor)->GetItem()->ItemClass == 1) { for(int16 CursorBagSlot = 331; CursorBagSlot <= 340; CursorBagSlot++) { if (m_inv.GetItem(CursorBagSlot)) { if (m_inv.GetItem(CursorBagSlot)->GetItem()->ID == m_pp.bandoliers[bss->number].items[BandolierSlot].item_id && @@ -2385,7 +2388,7 @@ void Client::SetBandolier(const EQApplicationPacket *app) { } // if the player has this item in their inventory, - if(slot != SLOT_INVALID) { + if (slot != INVALID_INDEX) { // Pull the item out of the inventory BandolierItems[BandolierSlot] = m_inv.PopItem(slot); // If ammo with charges, only take one charge out to put in the range slot, that is what @@ -2410,7 +2413,7 @@ void Client::SetBandolier(const EQApplicationPacket *app) { } else { // The player doesn't have the required weapon with them. BandolierItems[BandolierSlot] = 0; - if(slot == SLOT_INVALID) { + if (slot == INVALID_INDEX) { _log(INVENTORY__BANDOLIER, "Character does not have required bandolier item for slot %i", WeaponSlot); ItemInst *InvItem = m_inv.PopItem(WeaponSlot); if(InvItem) { diff --git a/zone/loottables.cpp b/zone/loottables.cpp index e7adaff7e..41de7c6eb 100644 --- a/zone/loottables.cpp +++ b/zone/loottables.cpp @@ -219,7 +219,7 @@ void NPC::AddLootDrop(const Item_Struct *item2, ItemList* itemlist, int16 charge // it is an improvement. if (!item2->NoPet) { - for (int i=0; !found && iSlots & slots) { if(equipment[i]) @@ -260,7 +260,7 @@ void NPC::AddLootDrop(const Item_Struct *item2, ItemList* itemlist, int16 charge // @merth: IDFile size has been increased, this needs to change uint16 emat; if(item2->Material <= 0 - || item2->Slots & (1 << SLOT_PRIMARY | 1 << SLOT_SECONDARY)) { + || item2->Slots & (1 << MainPrimary | 1 << MainSecondary)) { memset(newid, 0, sizeof(newid)); for(int i=0;i<7;i++){ if (!isalpha(item2->IDFile[i])){ @@ -274,13 +274,13 @@ void NPC::AddLootDrop(const Item_Struct *item2, ItemList* itemlist, int16 charge emat = item2->Material; } - if (foundslot == SLOT_PRIMARY) { + if (foundslot == MainPrimary) { if (item2->Proc.Effect != 0) CastToMob()->AddProcToWeapon(item2->Proc.Effect, true); eslot = MaterialPrimary; } - else if (foundslot == SLOT_SECONDARY + else if (foundslot == MainSecondary && (GetOwner() != nullptr || (GetLevel() >= 13 && MakeRandomInt(0,99) < NPC_DW_CHANCE) || (item2->Damage==0)) && (item2->ItemType == ItemType1HSlash || item2->ItemType == ItemType1HBlunt || item2->ItemType == ItemTypeShield || item2->ItemType == ItemType1HPiercing)) @@ -290,25 +290,25 @@ void NPC::AddLootDrop(const Item_Struct *item2, ItemList* itemlist, int16 charge eslot = MaterialSecondary; } - else if (foundslot == SLOT_HEAD) { + else if (foundslot == MainHead) { eslot = MaterialHead; } - else if (foundslot == SLOT_CHEST) { + else if (foundslot == MainChest) { eslot = MaterialChest; } - else if (foundslot == SLOT_ARMS) { + else if (foundslot == MainArms) { eslot = MaterialArms; } - else if (foundslot == SLOT_BRACER01 || foundslot == SLOT_BRACER02) { + else if (foundslot == MainWrist1 || foundslot == MainWrist2) { eslot = MaterialWrist; } - else if (foundslot == SLOT_HANDS) { + else if (foundslot == MainHands) { eslot = MaterialHands; } - else if (foundslot == SLOT_LEGS) { + else if (foundslot == MainLegs) { eslot = MaterialLegs; } - else if (foundslot == SLOT_FEET) { + else if (foundslot == MainFeet) { eslot = MaterialFeet; } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 645932d1b..3a1a7154c 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1415,36 +1415,55 @@ luabind::scope lua_register_slot() { return luabind::class_("Slot") .enum_("constants") [ - luabind::value("Charm", static_cast(SLOT_CHARM)), - luabind::value("Ear1", static_cast(SLOT_EAR01)), - luabind::value("Head", static_cast(SLOT_HEAD)), - luabind::value("Face", static_cast(SLOT_FACE)), - luabind::value("Ear2", static_cast(SLOT_EAR02)), - luabind::value("Neck", static_cast(SLOT_NECK)), - luabind::value("Shoulder", static_cast(SLOT_SHOULDER)), - luabind::value("Arms", static_cast(SLOT_ARMS)), - luabind::value("Back", static_cast(SLOT_BACK)), - luabind::value("Bracer1", static_cast(SLOT_BRACER01)), - luabind::value("Bracer2", static_cast(SLOT_BRACER02)), - luabind::value("Range", static_cast(SLOT_RANGE)), - luabind::value("Hands", static_cast(SLOT_HANDS)), - luabind::value("Primary", static_cast(SLOT_PRIMARY)), - luabind::value("Secondary", static_cast(SLOT_SECONDARY)), - luabind::value("Ring1", static_cast(SLOT_RING01)), - luabind::value("Ring2", static_cast(SLOT_RING02)), - luabind::value("Chest", static_cast(SLOT_CHEST)), - luabind::value("Legs", static_cast(SLOT_LEGS)), - luabind::value("Feet", static_cast(SLOT_FEET)), - luabind::value("Waist", static_cast(SLOT_WAIST)), - luabind::value("Ammo", static_cast(SLOT_AMMO)), - luabind::value("PersonalBegin", static_cast(SLOT_PERSONAL_BEGIN)), - luabind::value("PersonalEnd", static_cast(SLOT_PERSONAL_END)), - luabind::value("Cursor", static_cast(SLOT_CURSOR)), - luabind::value("CursorEnd", 0xFFFE), - luabind::value("Tradeskill", static_cast(SLOT_TRADESKILL)), - luabind::value("Augment", static_cast(SLOT_AUGMENT)), - luabind::value("PowerSource", static_cast(SLOT_POWER_SOURCE)), - luabind::value("Invalid", 0xFFFF) + luabind::value("Charm", static_cast(MainCharm)), + luabind::value("Ear1", static_cast(MainEar1)), + luabind::value("Head", static_cast(MainHead)), + luabind::value("Face", static_cast(MainFace)), + luabind::value("Ear2", static_cast(MainEar2)), + luabind::value("Neck", static_cast(MainNeck)), + luabind::value("Shoulder", static_cast(MainShoulders)), // deprecated + luabind::value("Shoulders", static_cast(MainShoulders)), + luabind::value("Arms", static_cast(MainArms)), + luabind::value("Back", static_cast(MainBack)), + luabind::value("Bracer1", static_cast(MainWrist1)), // deprecated + luabind::value("Wrist1", static_cast(MainWrist1)), + luabind::value("Bracer2", static_cast(MainWrist2)), // deprecated + luabind::value("Wrist2", static_cast(MainWrist2)), + luabind::value("Range", static_cast(MainRange)), + luabind::value("Hands", static_cast(MainHands)), + luabind::value("Primary", static_cast(MainPrimary)), + luabind::value("Secondary", static_cast(MainSecondary)), + luabind::value("Ring1", static_cast(MainFinger1)), // deprecated + luabind::value("Finger1", static_cast(MainFinger1)), + luabind::value("Ring2", static_cast(MainFinger2)), // deprecated + luabind::value("Finger2", static_cast(MainFinger2)), + luabind::value("Chest", static_cast(MainChest)), + luabind::value("Legs", static_cast(MainLegs)), + luabind::value("Feet", static_cast(MainFeet)), + luabind::value("Waist", static_cast(MainWaist)), + luabind::value("PowerSource", static_cast(MainPowerSource)), + luabind::value("Ammo", static_cast(MainAmmo)), + luabind::value("General1", static_cast(MainGeneral1)), + luabind::value("General2", static_cast(MainGeneral2)), + luabind::value("General3", static_cast(MainGeneral3)), + luabind::value("General4", static_cast(MainGeneral4)), + luabind::value("General5", static_cast(MainGeneral5)), + luabind::value("General6", static_cast(MainGeneral6)), + luabind::value("General7", static_cast(MainGeneral7)), + luabind::value("General8", static_cast(MainGeneral8)), + //luabind::value("General9", static_cast(MainGeneral9)), + //luabind::value("General10", static_cast(MainGeneral10)), + //luabind::value("EquipmentBegin", static_cast(EmuConstants::EQUIPMENT_BEGIN)), + //luabind::value("EquipmentEnd", static_cast(EmuConstants::EQUIPMENT_END)), + luabind::value("PersonalBegin", static_cast(EmuConstants::GENERAL_BEGIN)), // deprecated + luabind::value("GeneralBegin", static_cast(EmuConstants::GENERAL_BEGIN)), + luabind::value("PersonalEnd", static_cast(EmuConstants::GENERAL_END)), // deprecated + luabind::value("GeneralEnd", static_cast(EmuConstants::GENERAL_END)), + luabind::value("Cursor", static_cast(MainCursor)), + luabind::value("CursorEnd", 0xFFFE), // deprecated + luabind::value("Tradeskill", static_cast(SLOT_TRADESKILL)), // deprecated + luabind::value("Augment", static_cast(SLOT_AUGMENT)), // deprecated + luabind::value("Invalid", INVALID_INDEX) ]; } diff --git a/zone/merc.cpp b/zone/merc.cpp index 3bcc9d577..ebf46c180 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -266,7 +266,7 @@ void Merc::CalcItemBonuses(StatBonuses* newbon) { unsigned int i; //should not include 21 (SLOT_AMMO) - for (i=0; iGetHP() > -10) - Attack(GetTarget(), SLOT_SECONDARY); // Single attack with offhand + Attack(GetTarget(), MainSecondary); // Single attack with offhand } } } @@ -2640,7 +2640,7 @@ int16 Merc::GetFocusEffect(focusType type, uint16 spell_id) { int16 focus_max_real = 0; //item focus - for(int x =0; x < MAX_WORN_INVENTORY; ++x) + for (int x = 0; x < EmuConstants::EQUIPMENT_SIZE; ++x) { TempItem = nullptr; if (equipment[x] == 0) diff --git a/zone/merc.h b/zone/merc.h index fd7f69fa4..dabf68789 100644 --- a/zone/merc.h +++ b/zone/merc.h @@ -48,7 +48,7 @@ public: //abstract virtual function implementations requird by base abstract class virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, SkillUseTypes attack_skill); virtual void Damage(Mob* from, int32 damage, uint16 spell_id, SkillUseTypes attack_skill, bool avoidable = true, int8 buffslot = -1, bool iBuffTic = false); - virtual bool Attack(Mob* other, int Hand = SLOT_PRIMARY, bool FromRiposte = false, bool IsStrikethrough = false, + virtual bool Attack(Mob* other, int Hand = MainPrimary, bool FromRiposte = false, bool IsStrikethrough = false, bool IsFromSpell = false, ExtraAttackOptions *opts = nullptr); virtual bool HasRaid() { return false; } virtual bool HasGroup() { return (GetGroup() ? true : false); } @@ -273,11 +273,11 @@ protected: std::map timers; uint16 skills[HIGHEST_SKILL+1]; - uint32 equipment[MAX_WORN_INVENTORY]; //this is an array of item IDs - uint16 d_meele_texture1; //this is an item Material value - uint16 d_meele_texture2; //this is an item Material value (offhand) - uint8 prim_melee_type; //Sets the Primary Weapon attack message and animation - uint8 sec_melee_type; //Sets the Secondary Weapon attack message and animation + uint32 equipment[EmuConstants::EQUIPMENT_SIZE]; //this is an array of item IDs + uint16 d_meele_texture1; //this is an item Material value + uint16 d_meele_texture2; //this is an item Material value (offhand) + uint8 prim_melee_type; //Sets the Primary Weapon attack message and animation + uint8 sec_melee_type; //Sets the Secondary Weapon attack message and animation private: diff --git a/zone/mob.cpp b/zone/mob.cpp index 340dfdfea..c97cd182e 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1955,14 +1955,14 @@ void Mob::SetAttackTimer() { Timer* TimerToUse = nullptr; const Item_Struct* PrimaryWeapon = nullptr; - for (int i=SLOT_RANGE; i<=SLOT_SECONDARY; i++) { + for (int i=MainRange; i<=MainSecondary; i++) { //pick a timer - if (i == SLOT_PRIMARY) + if (i == MainPrimary) TimerToUse = &attack_timer; - else if (i == SLOT_RANGE) + else if (i == MainRange) TimerToUse = &ranged_timer; - else if(i == SLOT_SECONDARY) + else if(i == MainSecondary) TimerToUse = &attack_dw_timer; else //invalid slot (hands will always hit this) continue; @@ -1983,7 +1983,7 @@ void Mob::SetAttackTimer() { } //special offhand stuff - if(i == SLOT_SECONDARY) { + if(i == MainSecondary) { //if we have a 2H weapon in our main hand, no dual if(PrimaryWeapon != nullptr) { if( PrimaryWeapon->ItemClass == ItemClassCommon @@ -2062,7 +2062,7 @@ void Mob::SetAttackTimer() { if(IsClient()) { float max_quiver = 0; - for(int r = SLOT_PERSONAL_BEGIN; r <= SLOT_PERSONAL_END; r++) + for(int r = EmuConstants::GENERAL_BEGIN; r <= EmuConstants::GENERAL_END; r++) { const ItemInst *pi = CastToClient()->GetInv().GetItem(r); if(!pi) @@ -2086,7 +2086,7 @@ void Mob::SetAttackTimer() { TimerToUse->SetAtTrigger(speed, true); } - if(i == SLOT_PRIMARY) + if(i == MainPrimary) PrimaryWeapon = ItemToUse; } @@ -2097,8 +2097,8 @@ bool Mob::CanThisClassDualWield(void) const { return(GetSkill(SkillDualWield) > 0); } else if(CastToClient()->HasSkill(SkillDualWield)) { - const ItemInst* pinst = CastToClient()->GetInv().GetItem(SLOT_PRIMARY); - const ItemInst* sinst = CastToClient()->GetInv().GetItem(SLOT_SECONDARY); + const ItemInst* pinst = CastToClient()->GetInv().GetItem(MainPrimary); + const ItemInst* sinst = CastToClient()->GetInv().GetItem(MainSecondary); // 2HS, 2HB, or 2HP if(pinst && pinst->IsWeapon()) { diff --git a/zone/npc.cpp b/zone/npc.cpp index 38989bccb..acf618efe 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -1296,7 +1296,7 @@ void NPC::PickPocket(Client* thief) { bool is_arrow = (item->ItemType == ItemTypeArrow) ? true : false; int slot_id = thief->GetInv().FindFreeSlot(false, true, inst->GetItem()->Size, is_arrow); if (/*!Equipped(item->ID) &&*/ - !item->Magic && item->NoDrop != 0 && !inst->IsType(ItemClassContainer) && slot_id != SLOT_INVALID + !item->Magic && item->NoDrop != 0 && !inst->IsType(ItemClassContainer) && slot_id != INVALID_INDEX /*&& steal_skill > item->StealSkill*/ ) { slot[x] = slot_id; diff --git a/zone/npc.h b/zone/npc.h index 07c81e79b..1e38f928f 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -454,11 +454,11 @@ protected: uint32 roambox_min_delay; uint16 skills[HIGHEST_SKILL+1]; - uint32 equipment[MAX_WORN_INVENTORY]; //this is an array of item IDs - uint16 d_meele_texture1; //this is an item Material value - uint16 d_meele_texture2; //this is an item Material value (offhand) - uint8 prim_melee_type; //Sets the Primary Weapon attack message and animation - uint8 sec_melee_type; //Sets the Secondary Weapon attack message and animation + uint32 equipment[EmuConstants::EQUIPMENT_SIZE]; //this is an array of item IDs + uint16 d_meele_texture1; //this is an item Material value + uint16 d_meele_texture2; //this is an item Material value (offhand) + uint8 prim_melee_type; //Sets the Primary Weapon attack message and animation + uint8 sec_melee_type; //Sets the Secondary Weapon attack message and animation AA_SwarmPetInfo *swarmInfoPtr; bool ldon_trapped; diff --git a/zone/pets.cpp b/zone/pets.cpp index d5946ce58..c7b4b1eac 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -411,12 +411,12 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, // the base items for the pet. These are always loaded // so that a rank 1 suspend minion does not kill things // like the special back items some focused pets may receive. - uint32 petinv[MAX_WORN_INVENTORY]; + uint32 petinv[EmuConstants::EQUIPMENT_SIZE]; memset(petinv, 0, sizeof(petinv)); const Item_Struct *item = 0; if (database.GetBasePetItems(record.equipmentset, petinv)) { - for (int i=0; iAddLootDrop(item, &npc->itemlist, 0, 1, 127, true, true); @@ -543,7 +543,7 @@ void NPC::GetPetState(SpellBuff_Struct *pet_buffs, uint32 *items, char *name) { strn0cpy(name, GetName(), 64); //save their items, we only care about what they are actually wearing - memcpy(items, equipment, sizeof(uint32)*MAX_WORN_INVENTORY); + memcpy(items, equipment, sizeof(uint32)*EmuConstants::EQUIPMENT_SIZE); //save their buffs. for (int i=0; i < GetPetMaxTotalSlots(); i++) { @@ -629,7 +629,7 @@ void NPC::SetPetState(SpellBuff_Struct *pet_buffs, uint32 *items) { } //restore their equipment... - for(i = 0; i < MAX_WORN_INVENTORY; i++) { + for (i = 0; i < EmuConstants::EQUIPMENT_SIZE; i++) { if(items[i] == 0) continue; @@ -693,7 +693,7 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) { while ((row = mysql_fetch_row(result))) { slot = atoi(row[0]); - if (slot >= MAX_WORN_INVENTORY) + if (slot >= EmuConstants::EQUIPMENT_SIZE) continue; if (items[slot] == 0) items[slot] = atoi(row[1]); diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 46bd810ad..3333bf0ba 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -74,17 +74,17 @@ void Mob::ApplySpecialAttackMod(SkillUseTypes skill, int32 &dmg, int32 &mindmg) case SkillFlyingKick: case SkillRoundKick: case SkillKick: - item_slot = SLOT_FEET; + item_slot = MainFeet; break; case SkillBash: - item_slot = SLOT_SECONDARY; + item_slot = MainSecondary; break; case SkillDragonPunch: case SkillEagleStrike: case SkillTigerClaw: - item_slot = SLOT_HANDS; + item_slot = MainHands; break; default: @@ -113,7 +113,7 @@ void Mob::DoSpecialAttackDamage(Mob *who, SkillUseTypes skill, int32 max_damage, { if(IsClient()) { - ItemInst *item = CastToClient()->GetInv().GetItem(SLOT_SECONDARY); + ItemInst *item = CastToClient()->GetInv().GetItem(MainSecondary); if(item) { if(item->GetItem()->ItemType == ItemTypeShield) @@ -200,7 +200,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) { //These two are not subject to the combat ability timer, as they //allready do their checking in conjunction with the attack timer //throwing weapons - if(ca_atk->m_atk == 11) { + if(ca_atk->m_atk == MainRange) { if (ca_atk->m_skill == SkillThrowing) { SetAttackTimer(); ThrowingAttack(GetTarget()); @@ -242,6 +242,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) { int32 skill_reduction = this->GetSkillReuseTime(ca_atk->m_skill); + // not sure what the '100' indicates..if ->m_atk is not used as 'slot' reference, then change MainRange above back to '11' if ((ca_atk->m_atk == 100) && (ca_atk->m_skill == SkillBash)) { // SLAM - Bash without a shield equipped if (GetTarget() != this) { @@ -249,8 +250,8 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) { DoAnim(animTailRake); int32 ht = 0; - if(GetWeaponDamage(GetTarget(), GetInv().GetItem(SLOT_SECONDARY)) <= 0 && - GetWeaponDamage(GetTarget(), GetInv().GetItem(SLOT_SHOULDER)) <= 0){ + if(GetWeaponDamage(GetTarget(), GetInv().GetItem(MainSecondary)) <= 0 && + GetWeaponDamage(GetTarget(), GetInv().GetItem(MainShoulders)) <= 0){ dmg = -5; } else{ @@ -329,7 +330,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) { DoAnim(animKick); int32 ht = 0; - if(GetWeaponDamage(GetTarget(), GetInv().GetItem(SLOT_FEET)) <= 0){ + if(GetWeaponDamage(GetTarget(), GetInv().GetItem(MainFeet)) <= 0){ dmg = -5; } else{ @@ -405,7 +406,7 @@ int Mob::MonkSpecialAttack(Mob* other, uint8 unchecked_type) int32 min_dmg = 1; int reuse = 0; SkillUseTypes skill_type; //to avoid casting... even though it "would work" - uint8 itemslot = SLOT_FEET; + uint8 itemslot = MainFeet; switch(unchecked_type) { @@ -421,7 +422,7 @@ int Mob::MonkSpecialAttack(Mob* other, uint8 unchecked_type) case SkillDragonPunch:{ skill_type = SkillDragonPunch; max_dmg = ((GetSTR()+GetSkill(skill_type)) * RuleI(Combat, DragonPunchBonus) / 100) + 26; - itemslot = SLOT_HANDS; + itemslot = MainHands; ApplySpecialAttackMod(skill_type, max_dmg, min_dmg); DoAnim(animTailRake); reuse = TailRakeReuseTime; @@ -431,7 +432,7 @@ int Mob::MonkSpecialAttack(Mob* other, uint8 unchecked_type) case SkillEagleStrike:{ skill_type = SkillEagleStrike; max_dmg = ((GetSTR()+GetSkill(skill_type)) * RuleI(Combat, EagleStrikeBonus) / 100) + 19; - itemslot = SLOT_HANDS; + itemslot = MainHands; ApplySpecialAttackMod(skill_type, max_dmg, min_dmg); DoAnim(animEagleStrike); reuse = EagleStrikeReuseTime; @@ -441,7 +442,7 @@ int Mob::MonkSpecialAttack(Mob* other, uint8 unchecked_type) case SkillTigerClaw:{ skill_type = SkillTigerClaw; max_dmg = ((GetSTR()+GetSkill(skill_type)) * RuleI(Combat, TigerClawBonus) / 100) + 12; - itemslot = SLOT_HANDS; + itemslot = MainHands; ApplySpecialAttackMod(skill_type, max_dmg, min_dmg); DoAnim(animTigerClaw); reuse = TigerClawReuseTime; @@ -511,7 +512,7 @@ void Mob::TryBackstab(Mob *other, int ReuseTime) { //make sure we have a proper weapon if we are a client. if(IsClient()) { - const ItemInst *wpn = CastToClient()->GetInv().GetItem(SLOT_PRIMARY); + const ItemInst *wpn = CastToClient()->GetInv().GetItem(MainPrimary); if(!wpn || (wpn->GetItem()->ItemType != ItemType1HPiercing)){ Message_StringID(13, BACKSTAB_WEAPON); return; @@ -593,11 +594,11 @@ void Mob::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) if(IsClient()){ const ItemInst *wpn = nullptr; - wpn = CastToClient()->GetInv().GetItem(SLOT_PRIMARY); + wpn = CastToClient()->GetInv().GetItem(MainPrimary); if(wpn) { primaryweapondamage = GetWeaponDamage(other, wpn); backstab_dmg = wpn->GetItem()->BackstabDmg; - for(int i = 0; i < MAX_AUGMENT_SLOTS; ++i) + for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; ++i) { ItemInst *aug = wpn->GetAugment(i); if(aug) @@ -676,7 +677,7 @@ void Mob::RogueAssassinate(Mob* other) { //can you dodge, parry, etc.. an assassinate?? //if so, use DoSpecialAttackDamage(other, BACKSTAB, 32000); instead - if(GetWeaponDamage(other, IsClient()?CastToClient()->GetInv().GetItem(SLOT_PRIMARY):(const ItemInst*)nullptr) > 0){ + if(GetWeaponDamage(other, IsClient()?CastToClient()->GetInv().GetItem(MainPrimary):(const ItemInst*)nullptr) > 0){ other->Damage(this, 32000, SPELL_UNKNOWN, SkillBackstab); }else{ other->Damage(this, -5, SPELL_UNKNOWN, SkillBackstab); @@ -695,20 +696,20 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { //Message(0, "Error: Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); return; } - const ItemInst* RangeWeapon = m_inv[SLOT_RANGE]; + const ItemInst* RangeWeapon = m_inv[MainRange]; //locate ammo - int ammo_slot = SLOT_AMMO; - const ItemInst* Ammo = m_inv[SLOT_AMMO]; + int ammo_slot = MainAmmo; + const ItemInst* Ammo = m_inv[MainAmmo]; if (!RangeWeapon || !RangeWeapon->IsType(ItemClassCommon)) { - mlog(COMBAT__RANGED, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(SLOT_RANGE), SLOT_RANGE); - Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have no bow!", GetItemIDAt(SLOT_RANGE)); + mlog(COMBAT__RANGED, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(MainRange), MainRange); + Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have no bow!", GetItemIDAt(MainRange)); return; } if (!Ammo || !Ammo->IsType(ItemClassCommon)) { - mlog(COMBAT__RANGED, "Ranged attack canceled. Missing or invalid ammo item (%d) in slot %d", GetItemIDAt(SLOT_AMMO), SLOT_AMMO); - Message(0, "Error: Ammo: GetItem(%i)==0, you have no ammo!", GetItemIDAt(SLOT_AMMO)); + mlog(COMBAT__RANGED, "Ranged attack canceled. Missing or invalid ammo item (%d) in slot %d", GetItemIDAt(MainAmmo), MainAmmo); + Message(0, "Error: Ammo: GetItem(%i)==0, you have no ammo!", GetItemIDAt(MainAmmo)); return; } @@ -733,7 +734,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { //first look for quivers int r; bool found = false; - for(r = SLOT_PERSONAL_BEGIN; r <= SLOT_PERSONAL_END; r++) { + for(r = EmuConstants::GENERAL_BEGIN; r <= EmuConstants::GENERAL_END; r++) { const ItemInst *pi = m_inv[r]; if(pi == nullptr || !pi->IsType(ItemClassContainer)) continue; @@ -765,7 +766,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { //if we dont find a quiver, look through our inventory again //not caring if the thing is a quiver. int32 aslot = m_inv.HasItem(AmmoItem->ID, 1, invWherePersonal); - if(aslot != SLOT_INVALID) { + if (aslot != INVALID_INDEX) { ammo_slot = aslot; Ammo = m_inv[aslot]; mlog(COMBAT__RANGED, "Using ammo from inventory stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges()); @@ -1165,19 +1166,19 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 return; } - int ammo_slot = SLOT_RANGE; - const ItemInst* RangeWeapon = m_inv[SLOT_RANGE]; + int ammo_slot = MainRange; + const ItemInst* RangeWeapon = m_inv[MainRange]; if (!RangeWeapon || !RangeWeapon->IsType(ItemClassCommon)) { - mlog(COMBAT__RANGED, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(SLOT_RANGE), SLOT_RANGE); - Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing to throw!", GetItemIDAt(SLOT_RANGE)); + mlog(COMBAT__RANGED, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(MainRange), MainRange); + Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing to throw!", GetItemIDAt(MainRange)); return; } const Item_Struct* item = RangeWeapon->GetItem(); if(item->ItemType != ItemTypeLargeThrowing && item->ItemType != ItemTypeSmallThrowing) { mlog(COMBAT__RANGED, "Ranged attack canceled. Ranged item %d is not a throwing weapon. type %d.", item->ItemType); - Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing useful to throw!", GetItemIDAt(SLOT_RANGE)); + Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing useful to throw!", GetItemIDAt(MainRange)); return; } @@ -1185,16 +1186,16 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 if(RangeWeapon->GetCharges() == 1) { //first check ammo - const ItemInst* AmmoItem = m_inv[SLOT_AMMO]; + const ItemInst* AmmoItem = m_inv[MainAmmo]; if(AmmoItem != nullptr && AmmoItem->GetID() == RangeWeapon->GetID()) { //more in the ammo slot, use it RangeWeapon = AmmoItem; - ammo_slot = SLOT_AMMO; + ammo_slot = MainAmmo; mlog(COMBAT__RANGED, "Using ammo from ammo slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges()); } else { //look through our inventory for more int32 aslot = m_inv.HasItem(item->ID, 1, invWherePersonal); - if(aslot != SLOT_INVALID) { + if (aslot != INVALID_INDEX) { //the item wont change, but the instance does, not that it matters ammo_slot = aslot; RangeWeapon = m_inv[aslot]; @@ -1768,8 +1769,8 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) { DoAnim(animTailRake); - if(GetWeaponDamage(ca_target, GetInv().GetItem(SLOT_SECONDARY)) <= 0 && - GetWeaponDamage(ca_target, GetInv().GetItem(SLOT_SHOULDER)) <= 0){ + if(GetWeaponDamage(ca_target, GetInv().GetItem(MainSecondary)) <= 0 && + GetWeaponDamage(ca_target, GetInv().GetItem(MainShoulders)) <= 0){ dmg = -5; } else{ @@ -1839,7 +1840,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) { DoAnim(animKick); - if(GetWeaponDamage(ca_target, GetInv().GetItem(SLOT_FEET)) <= 0){ + if(GetWeaponDamage(ca_target, GetInv().GetItem(MainFeet)) <= 0){ dmg = -5; } else{ @@ -2236,7 +2237,7 @@ void Mob::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes if(skillinuse == SkillBash){ if(IsClient()){ - ItemInst *item = CastToClient()->GetInv().GetItem(SLOT_SECONDARY); + ItemInst *item = CastToClient()->GetInv().GetItem(MainSecondary); if(item){ if(item->GetItem()->ItemType == ItemTypeShield) { hate += item->GetItem()->AC; diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 84c1ec889..0255cc0df 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -599,7 +599,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) snprintf(effect_desc, _EDLEN, "Flesh To Bone"); #endif if(IsClient()){ - ItemInst* transI = CastToClient()->GetInv().GetItem(SLOT_CURSOR); + ItemInst* transI = CastToClient()->GetInv().GetItem(MainCursor); if(transI && transI->IsType(ItemClassCommon) && transI->IsStackable()){ uint32 fcharges = transI->GetCharges(); //Does it sound like meat... maybe should check if it looks like meat too... @@ -609,7 +609,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) strstr(transI->GetItem()->Name, "Flesh") || strstr(transI->GetItem()->Name, "parts") || strstr(transI->GetItem()->Name, "Parts")){ - CastToClient()->DeleteItemInInventory(SLOT_CURSOR, fcharges, true); + CastToClient()->DeleteItemInInventory(MainCursor, fcharges, true); CastToClient()->SummonItem(13073, fcharges); } else{ @@ -1159,7 +1159,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) if (SummonedItem) { c->PushItemOnCursor(*SummonedItem); - c->SendItemPacket(SLOT_CURSOR, SummonedItem, ItemPacketSummonItem); + c->SendItemPacket(MainCursor, SummonedItem, ItemPacketSummonItem); safe_delete(SummonedItem); } SummonedItem = database.CreateItem(spell.base[i], charges); @@ -2983,7 +2983,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) if (SummonedItem) { Client *c=CastToClient(); c->PushItemOnCursor(*SummonedItem); - c->SendItemPacket(SLOT_CURSOR, SummonedItem, ItemPacketSummonItem); + c->SendItemPacket(MainCursor, SummonedItem, ItemPacketSummonItem); safe_delete(SummonedItem); } @@ -5070,7 +5070,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { } } - for(int y = 0; y < MAX_AUGMENT_SLOTS; ++y) + for (int y = 0; y < EmuConstants::ITEM_COMMON_SIZE; ++y) { if (SympatheticProcList.size() > MAX_SYMPATHETIC) continue; @@ -5226,7 +5226,7 @@ int16 Client::GetFocusEffect(focusType type, uint16 spell_id) { } } - for(int y = 0; y < MAX_AUGMENT_SLOTS; ++y) + for (int y = 0; y < EmuConstants::ITEM_COMMON_SIZE; ++y) { ItemInst *aug = nullptr; aug = ins->GetAugment(y); diff --git a/zone/spells.cpp b/zone/spells.cpp index f8ce8baa0..9bbfa8068 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -285,7 +285,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot, return(false); } } - if( itm && (itm->GetItem()->Click.Type == ET_EquipClick) && !(item_slot < 22 || item_slot == 9999) ){ + if( itm && (itm->GetItem()->Click.Type == ET_EquipClick) && !(item_slot <= MainAmmo || item_slot == MainPowerSource) ){ if (CastToClient()->GetClientVersion() < EQClientSoF) { // They are attempting to cast a must equip clicky without having it equipped LogFile->write(EQEMuLog::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); @@ -1195,7 +1195,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, uint16 slot, uint32 recastdelay = 0; uint32 recasttype = 0; - for(int r = 0; r < MAX_AUGMENT_SLOTS; r++) { + for (int r = 0; r < EmuConstants::ITEM_COMMON_SIZE; r++) { const ItemInst* aug_i = inst->GetAugment(r); if(!aug_i) diff --git a/zone/titles.cpp b/zone/titles.cpp index de79fa8f0..f51937dba 100644 --- a/zone/titles.cpp +++ b/zone/titles.cpp @@ -201,7 +201,7 @@ bool TitleManager::IsClientEligibleForTitle(Client *c, std::vector:: } - if((Title->ItemID >= 1) && (c->GetInv().HasItem(Title->ItemID, 0, 0xFF) == SLOT_INVALID)) + if ((Title->ItemID >= 1) && (c->GetInv().HasItem(Title->ItemID, 0, 0xFF) == INVALID_INDEX)) return false; if((Title->TitleSet > 0) && (!c->CheckTitle(Title->TitleSet))) diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 5df392fa3..f9b2969d8 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -482,7 +482,7 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac //because a HasItem on items with num > 1 only returns the //last-most slot... the results of this are useless to us //when we go to delete them because we cannot assume it is in a single stack. - if(user_inv.HasItem(item, num, invWherePersonal) != SLOT_INVALID) + if (user_inv.HasItem(item, num, invWherePersonal) != INVALID_INDEX) count += num; else MissingItems.push_back(item); @@ -524,7 +524,7 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac //we have to loop here to delete 1 at a time in case its in multiple stacks. for(k = 0; k < counts[r]; k++) { slot = user_inv.HasItem(items[r], 1, invWherePersonal); - if(slot == SLOT_INVALID) { + if (slot == INVALID_INDEX) { //WTF... I just checked this above, but just to be sure... //we cant undo the previous deletes without a lot of work. //so just call it quits, this shouldent ever happen anyways. diff --git a/zone/trading.cpp b/zone/trading.cpp index bc1a248a9..6e3a2780c 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -87,7 +87,7 @@ void Trade::AddEntity(uint16 from_slot_id, uint16 trade_slot_id) // Item always goes into trade bucket from cursor Client* client = owner->CastToClient(); - const ItemInst* inst = client->GetInv().GetItem(SLOT_CURSOR); + const ItemInst* inst = client->GetInv().GetItem(MainCursor); if (!inst) { client->Message(13, "Error: Could not find item on your cursor!"); return; @@ -105,7 +105,7 @@ void Trade::AddEntity(uint16 from_slot_id, uint16 trade_slot_id) } else { - if (client->GetInv().GetItem(SLOT_CURSOR)->GetID() != client->GetInv().GetItem(trade_slot_id)->GetID()) { + if (client->GetInv().GetItem(MainCursor)->GetID() != client->GetInv().GetItem(trade_slot_id)->GetID()) { client->Kick(); return; } @@ -318,7 +318,7 @@ void Client::ResetTrade() { { bool is_arrow = (TempItem->ItemType == ItemTypeArrow) ? true : false; int freeslotid = GetInv().FindFreeSlot(ins->IsType(ItemClassContainer), true, TempItem->Size, is_arrow); - if (freeslotid == SLOT_INVALID) + if (freeslotid == INVALID_INDEX) { DropInst(ins); } @@ -441,14 +441,14 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) if(QSPLT) { qsaudit->items[parent_offset].to_id = this->character_id; - qsaudit->items[parent_offset].to_slot = SLOT_CURSOR; + qsaudit->items[parent_offset].to_slot = MainCursor; if(inst->IsType(ItemClassContainer)) { for(uint8 bagslot_idx = 0; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) { const ItemInst* bag_inst = inst->GetItem(bagslot_idx); if(bag_inst == nullptr) { continue; } - int16 to_bagslot_id = Inventory::CalcSlotId(SLOT_CURSOR, bagslot_idx); + int16 to_bagslot_id = Inventory::CalcSlotId(MainCursor, bagslot_idx); qsaudit->items[++parent_offset].to_id = this->character_id; qsaudit->items[parent_offset].to_slot = to_bagslot_id; @@ -465,14 +465,14 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) if(QSPLT) { qsaudit->items[parent_offset].to_id = this->character_id; - qsaudit->items[parent_offset].to_slot = SLOT_CURSOR; + qsaudit->items[parent_offset].to_slot = MainCursor; if(inst->IsType(ItemClassContainer)) { for(uint8 bagslot_idx = 0; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) { const ItemInst* bag_inst = inst->GetItem(bagslot_idx); if(bag_inst == nullptr) { continue; } - int16 to_bagslot_id = Inventory::CalcSlotId(SLOT_CURSOR, bagslot_idx); + int16 to_bagslot_id = Inventory::CalcSlotId(MainCursor, bagslot_idx); qsaudit->items[++parent_offset].to_id = this->character_id; qsaudit->items[parent_offset].to_slot = to_bagslot_id; @@ -2214,7 +2214,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { if(!item || !Quantity || !Price || !QtyBuyerWants) return; - if(m_inv.HasItem(ItemID, Quantity, invWhereWorn|invWherePersonal|invWhereCursor) == SLOT_INVALID) { + if (m_inv.HasItem(ItemID, Quantity, invWhereWorn | invWherePersonal | invWhereCursor) == INVALID_INDEX) { Message(13, "You do not have %i %s on you.", Quantity, item->Name); return; } @@ -2264,7 +2264,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { int16 SellerSlot = m_inv.HasItem(ItemID, 1, invWhereWorn|invWherePersonal|invWhereCursor); // This shouldn't happen, as we already checked there was space in the Buyer's inventory - if(SellerSlot == SLOT_INVALID) { + if (SellerSlot == INVALID_INDEX) { if(i > 0) { // Set the Quantity to the actual number we successfully transferred. @@ -2316,7 +2316,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { // Find the slot on the seller that has a stack of at least 1 of the item int16 SellerSlot = m_inv.HasItem(ItemID, 1, invWhereWorn|invWherePersonal|invWhereCursor); - if(SellerSlot == SLOT_INVALID) { + if (SellerSlot == INVALID_INDEX) { _log(TRADING__BARTER, "Unexpected error while moving item from seller to buyer."); Message(13, "Internal error while processing transaction."); return; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 2178a15c9..dbd430252 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1992,7 +1992,7 @@ void ZoneDatabase::LoadMercEquipment(Merc *merc) { int itemCount = 0; while(DataRow = mysql_fetch_row(DatasetResult)) { - if(itemCount == MAX_WORN_INVENTORY) + if (itemCount == EmuConstants::EQUIPMENT_SIZE) break; if(atoi(DataRow[0]) > 0) { @@ -2768,7 +2768,7 @@ void ZoneDatabase::SavePetInfo(Client *c) { } } - for(i=0; iItems[i]) { database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `character_pet_inventory` (`char_id`, `pet`, `slot`, `item_id`) values (%u, 0, %u, %u)", @@ -2792,7 +2792,7 @@ void ZoneDatabase::SavePetInfo(Client *c) { } safe_delete_array(query); - for(i=0; iItems[i]) { database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `character_pet_inventory` (`char_id`, `pet`, `slot`, `item_id`) values (%u, 1, %u, %u)", @@ -2923,9 +2923,9 @@ void ZoneDatabase::LoadPetInfo(Client *c) { pi = suspended; else continue; - + int slot = atoi(row[1]); - if (slot < 0 || slot > MAX_WORN_INVENTORY) + if (slot < 0 || slot > EmuConstants::EQUIPMENT_SIZE) // if (slot == 22) { zone.TriggerRandomCrash(); } continue; pi->Items[slot] = atoul(row[2]); diff --git a/zone/zonedb.h b/zone/zonedb.h index e53b45530..7612ba84f 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -90,7 +90,7 @@ struct PetInfo { uint32 Mana; float size; SpellBuff_Struct Buffs[BUFF_COUNT]; - uint32 Items[MAX_WORN_INVENTORY]; + uint32 Items[EmuConstants::EQUIPMENT_SIZE]; char Name[64]; };