From ace7c53ca36c03824c836e16395af6f2e18a0ba9 Mon Sep 17 00:00:00 2001 From: captainurist <73941350+captainurist@users.noreply.github.com> Date: Sat, 14 Oct 2023 20:30:57 +0100 Subject: [PATCH] Renaming enum values p1 --- src/Bin/CodeGen/CodeGen.cpp | 14 ++-- src/Engine/Graphics/Indoor.cpp | 2 +- src/Engine/Graphics/Outdoor.cpp | 2 +- src/Engine/Graphics/Viewport.cpp | 2 +- src/Engine/Objects/Character.cpp | 60 ++++++++-------- src/Engine/Objects/ItemEnchantment.h | 4 +- src/Engine/Objects/ItemEnums.h | 68 +++++++++--------- src/Engine/Objects/Items.cpp | 10 +-- src/Engine/Objects/Items.h | 20 +++--- src/Engine/SaveLoad.cpp | 2 +- src/Engine/Spells/CastSpellInfo.cpp | 2 +- src/Engine/Tables/ItemTable.cpp | 102 +++++++++++++-------------- src/Engine/Tables/ItemTable.h | 2 +- src/GUI/UI/UICharacter.cpp | 44 ++++++------ src/GUI/UI/UIPopup.cpp | 24 +++---- 15 files changed, 179 insertions(+), 179 deletions(-) diff --git a/src/Bin/CodeGen/CodeGen.cpp b/src/Bin/CodeGen/CodeGen.cpp index 6e74575985fc..b8c20feb7480 100644 --- a/src/Bin/CodeGen/CodeGen.cpp +++ b/src/Bin/CodeGen/CodeGen.cpp @@ -86,24 +86,24 @@ int runItemIdCodeGen(CodeGenOptions options, GameResourceManager *resourceManage if (!contains(description, "off-balance")) enumName += "_FIXED"; - if (desc.uEquipType == EQUIP_REAGENT) { + if (desc.uEquipType == ITEM_TYPE_REAGENT) { enumName = "REAGENT_" + enumName; - } else if (desc.uEquipType == EQUIP_POTION) { + } else if (desc.uEquipType == ITEM_TYPE_POTION) { if (!enumName.starts_with("POTION_")) enumName = "POTION_" + enumName; if (enumName.ends_with("_POTION")) enumName = enumName.substr(0, enumName.size() - 7); - } else if (desc.uEquipType == EQUIP_SPELL_SCROLL) { + } else if (desc.uEquipType == ITEM_TYPE_SPELL_SCROLL) { enumName = "SCROLL_" + enumName; - } else if (desc.uEquipType == EQUIP_BOOK) { + } else if (desc.uEquipType == ITEM_TYPE_BOOK) { enumName = "SPELLBOOK_" + enumName; - } else if (desc.uEquipType == EQUIP_MESSAGE_SCROLL) { + } else if (desc.uEquipType == ITEM_TYPE_MESSAGE_SCROLL) { if (enumName.ends_with("_RECIPE")) { enumName = "RECIPE_" + enumName.substr(0, enumName.size() - 7); } else if (!enumName.starts_with("MESSAGE_")) { enumName = "MESSAGE_" + enumName; } - } else if (desc.uEquipType == EQUIP_GOLD) { + } else if (desc.uEquipType == ITEM_TYPE_GOLD) { if (description == "A small pile of gold coins.") { enumName = "GOLD_SMALL"; } else if (description == "A pile of gold coins.") { @@ -113,7 +113,7 @@ int runItemIdCodeGen(CodeGenOptions options, GameResourceManager *resourceManage } else { throw Exception("Unrecognized gold pile description '{}'", description); } - } else if (desc.uEquipType == EQUIP_GEM) { + } else if (desc.uEquipType == ITEM_TYPE_GEM) { enumName = "GEM_" + enumName; } diff --git a/src/Engine/Graphics/Indoor.cpp b/src/Engine/Graphics/Indoor.cpp index bc186cf94dc0..779ae64b5f73 100644 --- a/src/Engine/Graphics/Indoor.cpp +++ b/src/Engine/Graphics/Indoor.cpp @@ -979,7 +979,7 @@ void PrepareToLoadBLV(bool bLoading) { if (pSpriteObjects[i].uObjectDescID) { if (pSpriteObjects[i].containing_item.uItemID != ITEM_NULL) { if (pSpriteObjects[i].containing_item.uItemID != ITEM_POTION_BOTTLE && - pItemTable->pItems[pSpriteObjects[i].containing_item.uItemID].uEquipType == EQUIP_POTION && + pItemTable->pItems[pSpriteObjects[i].containing_item.uItemID].uEquipType == ITEM_TYPE_POTION && !pSpriteObjects[i].containing_item.potionPower) pSpriteObjects[i].containing_item.potionPower = grng->random(15) + 5; pItemTable->SetSpecialBonus(&pSpriteObjects[i].containing_item); diff --git a/src/Engine/Graphics/Outdoor.cpp b/src/Engine/Graphics/Outdoor.cpp index 3a57dc3163a4..d1debfa7e4f3 100644 --- a/src/Engine/Graphics/Outdoor.cpp +++ b/src/Engine/Graphics/Outdoor.cpp @@ -1188,7 +1188,7 @@ void OutdoorLocation::ArrangeSpriteObjects() { } if (pSpriteObjects[i].containing_item.uItemID != ITEM_NULL) { if (pSpriteObjects[i].containing_item.uItemID != ITEM_POTION_BOTTLE && - pItemTable->pItems[pSpriteObjects[i].containing_item.uItemID].uEquipType == EQUIP_POTION && + pItemTable->pItems[pSpriteObjects[i].containing_item.uItemID].uEquipType == ITEM_TYPE_POTION && !pSpriteObjects[i].containing_item.potionPower) pSpriteObjects[i].containing_item.potionPower = grng->random(15) + 5; pItemTable->SetSpecialBonus(&pSpriteObjects[i].containing_item); diff --git a/src/Engine/Graphics/Viewport.cpp b/src/Engine/Graphics/Viewport.cpp index 1cb3c20e13b1..9876c57291e9 100644 --- a/src/Engine/Graphics/Viewport.cpp +++ b/src/Engine/Graphics/Viewport.cpp @@ -222,7 +222,7 @@ void ViewingParams::_443365() { } void ItemInteraction(unsigned int item_id) { - if (pItemTable->pItems[pSpriteObjects[item_id].containing_item.uItemID].uEquipType == EQUIP_GOLD) { + if (pItemTable->pItems[pSpriteObjects[item_id].containing_item.uItemID].uEquipType == ITEM_TYPE_GOLD) { pParty->partyFindsGold(pSpriteObjects[item_id].containing_item.goldAmount, GOLD_RECEIVE_SHARE); } else { if (pParty->pPickedItem.uItemID != ITEM_NULL) { diff --git a/src/Engine/Objects/Character.cpp b/src/Engine/Objects/Character.cpp index 4e076419089f..3e334b390500 100644 --- a/src/Engine/Objects/Character.cpp +++ b/src/Engine/Objects/Character.cpp @@ -117,28 +117,28 @@ static constexpr IndexedArray pEquipTypeToBodyAnchor = { // 4E8398 - {EQUIP_SINGLE_HANDED, ITEM_SLOT_MAIN_HAND}, - {EQUIP_TWO_HANDED, ITEM_SLOT_MAIN_HAND}, - {EQUIP_BOW, ITEM_SLOT_BOW}, - {EQUIP_ARMOUR, ITEM_SLOT_ARMOUR}, - {EQUIP_SHIELD, ITEM_SLOT_OFF_HAND}, - {EQUIP_HELMET, ITEM_SLOT_HELMET}, - {EQUIP_BELT, ITEM_SLOT_BELT}, - {EQUIP_CLOAK, ITEM_SLOT_CLOAK}, - {EQUIP_GAUNTLETS, ITEM_SLOT_GAUTNLETS}, - {EQUIP_BOOTS, ITEM_SLOT_BOOTS}, - {EQUIP_RING, ITEM_SLOT_RING1}, - {EQUIP_AMULET, ITEM_SLOT_AMULET}, - {EQUIP_WAND, ITEM_SLOT_MAIN_HAND}, - {EQUIP_REAGENT, ITEM_SLOT_INVALID}, - {EQUIP_POTION, ITEM_SLOT_INVALID}, - {EQUIP_SPELL_SCROLL, ITEM_SLOT_INVALID}, - {EQUIP_BOOK, ITEM_SLOT_INVALID}, - {EQUIP_MESSAGE_SCROLL, ITEM_SLOT_INVALID}, - {EQUIP_GOLD, ITEM_SLOT_INVALID}, - {EQUIP_GEM, ITEM_SLOT_INVALID}, - {EQUIP_NONE, ITEM_SLOT_INVALID} +static constexpr IndexedArray pEquipTypeToBodyAnchor = { // 4E8398 + {ITEM_TYPE_SINGLE_HANDED, ITEM_SLOT_MAIN_HAND}, + {ITEM_TYPE_TWO_HANDED, ITEM_SLOT_MAIN_HAND}, + {ITEM_TYPE_BOW, ITEM_SLOT_BOW}, + {ITEM_TYPE_ARMOUR, ITEM_SLOT_ARMOUR}, + {ITEM_TYPE_SHIELD, ITEM_SLOT_OFF_HAND}, + {ITEM_TYPE_HELMET, ITEM_SLOT_HELMET}, + {ITEM_TYPE_BELT, ITEM_SLOT_BELT}, + {ITEM_TYPE_CLOAK, ITEM_SLOT_CLOAK}, + {ITEM_TYPE_GAUNTLETS, ITEM_SLOT_GAUTNLETS}, + {ITEM_TYPE_BOOTS, ITEM_SLOT_BOOTS}, + {ITEM_TYPE_RING, ITEM_SLOT_RING1}, + {ITEM_TYPE_AMULET, ITEM_SLOT_AMULET}, + {ITEM_TYPE_WAND, ITEM_SLOT_MAIN_HAND}, + {ITEM_TYPE_REAGENT, ITEM_SLOT_INVALID}, + {ITEM_TYPE_POTION, ITEM_SLOT_INVALID}, + {ITEM_TYPE_SPELL_SCROLL, ITEM_SLOT_INVALID}, + {ITEM_TYPE_BOOK, ITEM_SLOT_INVALID}, + {ITEM_TYPE_MESSAGE_SCROLL, ITEM_SLOT_INVALID}, + {ITEM_TYPE_GOLD, ITEM_SLOT_INVALID}, + {ITEM_TYPE_GEM, ITEM_SLOT_INVALID}, + {ITEM_TYPE_NONE, ITEM_SLOT_INVALID} }; static constexpr unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, @@ -848,7 +848,7 @@ bool Character::CanRepair(ItemGen *pItem) const { // TODO(Nik-RE-dev): is check for boots correct? if (CheckHiredNPCSpeciality(Smith) && pItem->isWeapon() || CheckHiredNPCSpeciality(Armorer) && pItem->isArmor() || - CheckHiredNPCSpeciality(Alchemist) && pItem->GetItemEquipType() >= EQUIP_BOOTS) + CheckHiredNPCSpeciality(Alchemist) && pItem->GetItemEquipType() >= ITEM_TYPE_BOOTS) return true; // check against hired help if (val.mastery() == CHARACTER_SKILL_MASTERY_GRANDMASTER) // gm repair @@ -1569,10 +1569,10 @@ StealResult Character::StealFromActor(unsigned int uActorID, int _steal_perm, in if (carriedItemId != ITEM_NULL) { // load item into tempitem actroPtr->carriedItemId = ITEM_NULL; tempItem.uItemID = carriedItemId; - if (pItemTable->pItems[carriedItemId].uEquipType == EQUIP_WAND) { + if (pItemTable->pItems[carriedItemId].uEquipType == ITEM_TYPE_WAND) { tempItem.uNumCharges = grng->random(6) + pItemTable->pItems[carriedItemId].uDamageMod + 1; tempItem.uMaxCharges = tempItem.uNumCharges; - } else if (pItemTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE) { + } else if (pItemTable->pItems[carriedItemId].uEquipType == ITEM_TYPE_POTION && carriedItemId != ITEM_POTION_BOTTLE) { tempItem.potionPower = 2 * grng->random(4) + 2; } } else { @@ -1735,7 +1735,7 @@ int Character::ReceiveSpecialAttackEffect(SPECIAL_ATTACK_TYPE attType, Actor *pA this->pEquipment.uArmor - 1; if ((i == ITEM_SLOT_OFF_HAND || i == ITEM_SLOT_MAIN_HAND) && - GetEquippedItemEquipType(i) == EQUIP_SHIELD) + GetEquippedItemEquipType(i) == ITEM_TYPE_SHIELD) itemstobreaklist[itemstobreakcounter++] = this->pEquipment.pIndices[i] - 1; } @@ -1759,9 +1759,9 @@ int Character::ReceiveSpecialAttackEffect(SPECIAL_ATTACK_TYPE attType, Actor *pA if ((i == ITEM_SLOT_OFF_HAND || i == ITEM_SLOT_MAIN_HAND) && (GetEquippedItemEquipType(i) == - EQUIP_SINGLE_HANDED || + ITEM_TYPE_SINGLE_HANDED || GetEquippedItemEquipType(i) == - EQUIP_TWO_HANDED)) + ITEM_TYPE_TWO_HANDED)) itemstobreaklist[itemstobreakcounter++] = this->pEquipment.pIndices[i] - 1; } @@ -2017,7 +2017,7 @@ int Character::GetAttackRecoveryTime(bool bRangedAttack) const { uint shield_recovery = 0; if (HasItemEquipped(ITEM_SLOT_OFF_HAND)) { - if (GetEquippedItemEquipType(ITEM_SLOT_OFF_HAND) == EQUIP_SHIELD) { + if (GetEquippedItemEquipType(ITEM_SLOT_OFF_HAND) == ITEM_TYPE_SHIELD) { CharacterSkillType skill_type = GetOffHandItem()->GetPlayerSkillType(); uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; float multiplier = GetArmorRecoveryMultiplierFromSkillLevel(skill_type, 1.0f, 0, 0, 0); @@ -7464,7 +7464,7 @@ MerchantPhrase Character::SelectPhrasesTransaction(ItemGen *pItem, BuildingType case BUILDING_ALCHEMY_SHOP: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS && !isRecipe(idemId)) return MERCHANT_PHRASE_INVALID_ACTION; - if (equipType != EQUIP_REAGENT && equipType != EQUIP_POTION && equipType != EQUIP_MESSAGE_SCROLL) + if (equipType != ITEM_TYPE_REAGENT && equipType != ITEM_TYPE_POTION && equipType != ITEM_TYPE_MESSAGE_SCROLL) return MERCHANT_PHRASE_INCOMPATIBLE_ITEM; break; default: diff --git a/src/Engine/Objects/ItemEnchantment.h b/src/Engine/Objects/ItemEnchantment.h index 3aeadd746be8..20c60886c4b1 100644 --- a/src/Engine/Objects/ItemEnchantment.h +++ b/src/Engine/Objects/ItemEnchantment.h @@ -22,7 +22,7 @@ struct ItemEnchantmentTable { // Bonus|Sta|Of // Name|Arm|Shld|Helm|Belt|Cape|Gaunt|Boot|Ring|Amul std::string pBonusStat; std::string pOfName; - IndexedArray chancesByItemType; + IndexedArray chancesByItemType; }; struct ItemSpecialEnchantmentTable { // 1Ch @@ -32,7 +32,7 @@ struct ItemSpecialEnchantmentTable { // 1Ch std::string pBonusStatement; // 0 std::string pNameAdd; // 4 - IndexedArray to_item_apply; // 8 + IndexedArray to_item_apply; // 8 int iValue; // 14 int iTreasureLevel; // 18 }; diff --git a/src/Engine/Objects/ItemEnums.h b/src/Engine/Objects/ItemEnums.h index 495c62b34a2a..ace2a3626464 100644 --- a/src/Engine/Objects/ItemEnums.h +++ b/src/Engine/Objects/ItemEnums.h @@ -1003,7 +1003,7 @@ enum class ItemId : int32_t { ITEM_FIRST_REAL_POTION = ITEM_POTION_CURE_WOUNDS, ITEM_LAST_REAL_POTION = ITEM_POTION_REJUVENATION, - // TODO(captainurist): ITEM_POTION_BOTTLE equip type is EQUIP_POTION, but we don't have an empty bottle in the range below. Not good. + // TODO(captainurist): ITEM_POTION_BOTTLE equip type is ITEM_TYPE_POTION, but we don't have an empty bottle in the range below. Not good. ITEM_FIRST_POTION = ITEM_POTION_CATALYST, ITEM_LAST_POTION = ITEM_POTION_REJUVENATION, @@ -1183,36 +1183,36 @@ inline SpellId spellForWand(ItemId wand) { } enum class ItemType : uint8_t { - EQUIP_SINGLE_HANDED = 0, - EQUIP_TWO_HANDED = 1, - EQUIP_BOW = 2, - EQUIP_ARMOUR = 3, - EQUIP_SHIELD = 4, - EQUIP_HELMET = 5, - EQUIP_BELT = 6, - EQUIP_CLOAK = 7, - EQUIP_GAUNTLETS = 8, - EQUIP_BOOTS = 9, - EQUIP_RING = 10, - EQUIP_AMULET = 11, - EQUIP_WAND = 12, - EQUIP_REAGENT = 13, - EQUIP_POTION = 14, - EQUIP_SPELL_SCROLL = 15, - EQUIP_BOOK = 16, - EQUIP_MESSAGE_SCROLL = 17, - EQUIP_GOLD = 18, - EQUIP_GEM = 19, - EQUIP_NONE = 20, // Ores, quest items. - - EQUIP_FIRST = EQUIP_SINGLE_HANDED, - EQUIP_LAST = EQUIP_NONE, - - EQUIP_FIRST_SPECIAL_ENCHANTABLE = EQUIP_SINGLE_HANDED, - EQUIP_LAST_SPECIAL_ENCHANTABLE = EQUIP_AMULET, - - EQUIP_FIRST_NORMAL_ENCHANTABLE = EQUIP_ARMOUR, - EQUIP_LAST_NORMAL_ENCHANTABLE = EQUIP_AMULET, + ITEM_TYPE_SINGLE_HANDED = 0, + ITEM_TYPE_TWO_HANDED = 1, + ITEM_TYPE_BOW = 2, + ITEM_TYPE_ARMOUR = 3, + ITEM_TYPE_SHIELD = 4, + ITEM_TYPE_HELMET = 5, + ITEM_TYPE_BELT = 6, + ITEM_TYPE_CLOAK = 7, + ITEM_TYPE_GAUNTLETS = 8, + ITEM_TYPE_BOOTS = 9, + ITEM_TYPE_RING = 10, + ITEM_TYPE_AMULET = 11, + ITEM_TYPE_WAND = 12, + ITEM_TYPE_REAGENT = 13, + ITEM_TYPE_POTION = 14, + ITEM_TYPE_SPELL_SCROLL = 15, + ITEM_TYPE_BOOK = 16, + ITEM_TYPE_MESSAGE_SCROLL = 17, + ITEM_TYPE_GOLD = 18, + ITEM_TYPE_GEM = 19, + ITEM_TYPE_NONE = 20, // Ores, quest items. + + ITEM_TYPE_FIRST = ITEM_TYPE_SINGLE_HANDED, + ITEM_TYPE_LAST = ITEM_TYPE_NONE, + + ITEM_TYPE_FIRST_SPECIAL_ENCHANTABLE = ITEM_TYPE_SINGLE_HANDED, + ITEM_TYPE_LAST_SPECIAL_ENCHANTABLE = ITEM_TYPE_AMULET, + + ITEM_TYPE_FIRST_NORMAL_ENCHANTABLE = ITEM_TYPE_ARMOUR, + ITEM_TYPE_LAST_NORMAL_ENCHANTABLE = ITEM_TYPE_AMULET, }; using enum ItemType; @@ -1222,7 +1222,7 @@ using enum ItemType; * armor, rings, amulets, etc. */ inline bool isPassiveEquipment(ItemType type) { - return type >= EQUIP_ARMOUR && type <= EQUIP_AMULET; + return type >= ITEM_TYPE_ARMOUR && type <= ITEM_TYPE_AMULET; } /** @@ -1231,7 +1231,7 @@ inline bool isPassiveEquipment(ItemType type) { * equipment except amulets and rings. */ inline bool isArmor(ItemType type) { - return type >= EQUIP_ARMOUR && type <= EQUIP_BOOTS; + return type >= ITEM_TYPE_ARMOUR && type <= ITEM_TYPE_BOOTS; } /** @@ -1240,7 +1240,7 @@ inline bool isArmor(ItemType type) { * considered weapons. */ inline bool isWeapon(ItemType type) { - return type >= EQUIP_SINGLE_HANDED && type <= EQUIP_BOW; + return type >= ITEM_TYPE_SINGLE_HANDED && type <= ITEM_TYPE_BOW; } /** diff --git a/src/Engine/Objects/Items.cpp b/src/Engine/Objects/Items.cpp index a60270ea7f16..6081bfc9a90c 100644 --- a/src/Engine/Objects/Items.cpp +++ b/src/Engine/Objects/Items.cpp @@ -187,8 +187,8 @@ std::string ItemGen::GetDisplayName() { //----- (004564B3) -------------------------------------------------------- std::string ItemGen::GetIdentifiedName() { ItemType equip_type = GetItemEquipType(); - if ((equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || - (equip_type == EQUIP_GOLD)) { + if ((equip_type == ITEM_TYPE_REAGENT) || (equip_type == ITEM_TYPE_POTION) || + (equip_type == ITEM_TYPE_GOLD)) { return pItemTable->pItems[uItemID].name; } @@ -688,7 +688,7 @@ bool ItemGen::IsRegularEnchanmentForAttribute(CharacterAttributeType attrToGet) ItemType ItemGen::GetItemEquipType() const { // to avoid nzi - is this safe?? if (this->uItemID == ITEM_NULL) - return EQUIP_NONE; + return ITEM_TYPE_NONE; else return pItemTable->pItems[this->uItemID].uEquipType; } @@ -725,14 +725,14 @@ std::string GetItemTextureFilename(ItemId item_id, int index, int shoulder) { int texture_id = std::to_underlying(valueOr(itemTextureIdByItemId, item_id, item_id)); switch (pItemTable->pItems[item_id].uEquipType) { - case EQUIP_ARMOUR: + case ITEM_TYPE_ARMOUR: if (shoulder == 0) return fmt::format("item{:03}v{}", texture_id, index); else if (shoulder == 1) return fmt::format("item{:03}v{}a1", texture_id, index); else // shoulder == 2 return fmt::format("item{:03}v{}a2", texture_id, index); - case EQUIP_CLOAK: + case ITEM_TYPE_CLOAK: if (shoulder == 0) return fmt::format("item{:03}v{}", texture_id, index); else // shoulder == 1 diff --git a/src/Engine/Objects/Items.h b/src/Engine/Objects/Items.h index 9dafdec07359..c5b1e18ace5c 100644 --- a/src/Engine/Objects/Items.h +++ b/src/Engine/Objects/Items.h @@ -67,32 +67,32 @@ struct ItemGen { // 0x24 bool canSellRepairIdentifyAt(HouseId houseId); bool isGold() const { - return GetItemEquipType() == EQUIP_GOLD; + return GetItemEquipType() == ITEM_TYPE_GOLD; } bool isShield() const { - return GetItemEquipType() == EQUIP_SHIELD; + return GetItemEquipType() == ITEM_TYPE_SHIELD; } bool isWand() const { - return GetItemEquipType() == EQUIP_WAND; + return GetItemEquipType() == ITEM_TYPE_WAND; } bool isPotion() const { - return GetItemEquipType() == EQUIP_POTION; + return GetItemEquipType() == ITEM_TYPE_POTION; } bool isBook() const { - return GetItemEquipType() == EQUIP_BOOK; + return GetItemEquipType() == ITEM_TYPE_BOOK; } bool isReagent() const { - return GetItemEquipType() == EQUIP_REAGENT; + return GetItemEquipType() == ITEM_TYPE_REAGENT; } bool isSpellScroll() const { - return GetItemEquipType() == EQUIP_SPELL_SCROLL; + return GetItemEquipType() == ITEM_TYPE_SPELL_SCROLL; } bool isMessageScroll() const { - return GetItemEquipType() == EQUIP_MESSAGE_SCROLL; + return GetItemEquipType() == ITEM_TYPE_MESSAGE_SCROLL; } bool isMeleeWeapon() const { - return GetItemEquipType() == EQUIP_SINGLE_HANDED || GetItemEquipType() == EQUIP_TWO_HANDED; + return GetItemEquipType() == ITEM_TYPE_SINGLE_HANDED || GetItemEquipType() == ITEM_TYPE_TWO_HANDED; } bool isWeapon() const { return ::isWeapon(GetItemEquipType()); @@ -132,7 +132,7 @@ struct ItemDesc { // 30h int16_t field_1A = 0; // 16 int16_t uEquipX = 0; // 18 1c int16_t uEquipY = 0; // 1a 1e - ItemType uEquipType = EQUIP_NONE; // 1c 20 + ItemType uEquipType = ITEM_TYPE_NONE; // 1c 20 CharacterSkillType uSkillType = CHARACTER_SKILL_MISC; // 1d 21 uint8_t uDamageDice = 0; // 1e 22 uint8_t uDamageRoll = 0; // 1f 23 diff --git a/src/Engine/SaveLoad.cpp b/src/Engine/SaveLoad.cpp index 5c94b3f38afd..ea50fd3348ad 100644 --- a/src/Engine/SaveLoad.cpp +++ b/src/Engine/SaveLoad.cpp @@ -107,7 +107,7 @@ void LoadGame(unsigned int uSlot) { int pItemID = pParty->pCharacters[i] .pInventoryItemList[uEquipIdx - 1] .uItemID; - if (pItemTable->pItems[pItemID].uEquipType == EQUIP_WAND && + if (pItemTable->pItems[pItemID].uEquipType == ITEM_TYPE_WAND && pItemID) { // жезл __debugbreak(); // looks like offset in player's inventory // and wand_lut much like case in 0042ECB5 diff --git a/src/Engine/Spells/CastSpellInfo.cpp b/src/Engine/Spells/CastSpellInfo.cpp index ff8b0bc400b1..da0987e4fed1 100644 --- a/src/Engine/Spells/CastSpellInfo.cpp +++ b/src/Engine/Spells/CastSpellInfo.cpp @@ -1968,7 +1968,7 @@ void CastSpellInfoHelpers::castSpell() { } else { for (const ItemGen &actorItem : pActors[monster_id].items) { if (actorItem.uItemID != ITEM_NULL && - pItemTable->pItems[actorItem.uItemID].uEquipType != EQUIP_GOLD) { + pItemTable->pItems[actorItem.uItemID].uEquipType != ITEM_TYPE_GOLD) { item = actorItem; } } diff --git a/src/Engine/Tables/ItemTable.cpp b/src/Engine/Tables/ItemTable.cpp index 3a3ce6d1b1c1..91b9879b8969 100644 --- a/src/Engine/Tables/ItemTable.cpp +++ b/src/Engine/Tables/ItemTable.cpp @@ -28,29 +28,29 @@ static void strtokSkipLines(int n) { //----- (00456D84) -------------------------------------------------------- void ItemTable::Initialize(GameResourceManager *resourceManager) { std::map equipStatMap; - equipStatMap["weapon"] = EQUIP_SINGLE_HANDED; - equipStatMap["weapon2"] = EQUIP_TWO_HANDED; - equipStatMap["weapon1or2"] = EQUIP_SINGLE_HANDED; - equipStatMap["missile"] = EQUIP_BOW; - equipStatMap["bow"] = EQUIP_BOW; - equipStatMap["armor"] = EQUIP_ARMOUR; - equipStatMap["shield"] = EQUIP_SHIELD; - equipStatMap["helm"] = EQUIP_HELMET; - equipStatMap["belt"] = EQUIP_BELT; - equipStatMap["cloak"] = EQUIP_CLOAK; - equipStatMap["gauntlets"] = EQUIP_GAUNTLETS; - equipStatMap["boots"] = EQUIP_BOOTS; - equipStatMap["ring"] = EQUIP_RING; - equipStatMap["amulet"] = EQUIP_AMULET; - equipStatMap["weaponw"] = EQUIP_WAND; - equipStatMap["herb"] = EQUIP_REAGENT; - equipStatMap["reagent"] = EQUIP_REAGENT; - equipStatMap["bottle"] = EQUIP_POTION; - equipStatMap["sscroll"] = EQUIP_SPELL_SCROLL; - equipStatMap["book"] = EQUIP_BOOK; - equipStatMap["mscroll"] = EQUIP_MESSAGE_SCROLL; - equipStatMap["gold"] = EQUIP_GOLD; - equipStatMap["gem"] = EQUIP_GEM; + equipStatMap["weapon"] = ITEM_TYPE_SINGLE_HANDED; + equipStatMap["weapon2"] = ITEM_TYPE_TWO_HANDED; + equipStatMap["weapon1or2"] = ITEM_TYPE_SINGLE_HANDED; + equipStatMap["missile"] = ITEM_TYPE_BOW; + equipStatMap["bow"] = ITEM_TYPE_BOW; + equipStatMap["armor"] = ITEM_TYPE_ARMOUR; + equipStatMap["shield"] = ITEM_TYPE_SHIELD; + equipStatMap["helm"] = ITEM_TYPE_HELMET; + equipStatMap["belt"] = ITEM_TYPE_BELT; + equipStatMap["cloak"] = ITEM_TYPE_CLOAK; + equipStatMap["gauntlets"] = ITEM_TYPE_GAUNTLETS; + equipStatMap["boots"] = ITEM_TYPE_BOOTS; + equipStatMap["ring"] = ITEM_TYPE_RING; + equipStatMap["amulet"] = ITEM_TYPE_AMULET; + equipStatMap["weaponw"] = ITEM_TYPE_WAND; + equipStatMap["herb"] = ITEM_TYPE_REAGENT; + equipStatMap["reagent"] = ITEM_TYPE_REAGENT; + equipStatMap["bottle"] = ITEM_TYPE_POTION; + equipStatMap["sscroll"] = ITEM_TYPE_SPELL_SCROLL; + equipStatMap["book"] = ITEM_TYPE_BOOK; + equipStatMap["mscroll"] = ITEM_TYPE_MESSAGE_SCROLL; + equipStatMap["gold"] = ITEM_TYPE_GOLD; + equipStatMap["gem"] = ITEM_TYPE_GEM; std::map equipSkillMap; equipSkillMap["staff"] = CHARACTER_SKILL_STAFF; @@ -147,7 +147,7 @@ void ItemTable::Initialize(GameResourceManager *resourceManager) { pItems[item_counter].iconName = removeQuotes(tokens[1]); pItems[item_counter].name = removeQuotes(tokens[2]); pItems[item_counter].uValue = atoi(tokens[3]); - pItems[item_counter].uEquipType = valueOr(equipStatMap, tokens[4], EQUIP_NONE); + pItems[item_counter].uEquipType = valueOr(equipStatMap, tokens[4], ITEM_TYPE_NONE); pItems[item_counter].uSkillType = valueOr(equipSkillMap, tokens[5], CHARACTER_SKILL_MISC); auto diceRollTokens = tokenize(tokens[6], 'd'); if (diceRollTokens.size() == 2) { @@ -387,10 +387,10 @@ void ItemTable::generateItem(ItemTreasureLevel treasure_level, RandomItemType uT CharacterSkillType requested_skill = CHARACTER_SKILL_INVALID; switch (uTreasureType) { case RANDOM_ITEM_WEAPON: - requested_equip = EQUIP_SINGLE_HANDED; + requested_equip = ITEM_TYPE_SINGLE_HANDED; break; case RANDOM_ITEM_ARMOR: - requested_equip = EQUIP_ARMOUR; + requested_equip = ITEM_TYPE_ARMOUR; break; case RANDOM_ITEM_MICS: requested_skill = CHARACTER_SKILL_MISC; @@ -429,43 +429,43 @@ void ItemTable::generateItem(ItemTreasureLevel treasure_level, RandomItemType uT requested_skill = CHARACTER_SKILL_PLATE; break; case RANDOM_ITEM_SHIELD: - requested_equip = EQUIP_SHIELD; + requested_equip = ITEM_TYPE_SHIELD; break; case RANDOM_ITEM_HELMET: - requested_equip = EQUIP_HELMET; + requested_equip = ITEM_TYPE_HELMET; break; case RANDOM_ITEM_BELT: - requested_equip = EQUIP_BELT; + requested_equip = ITEM_TYPE_BELT; break; case RANDOM_ITEM_CLOAK: - requested_equip = EQUIP_CLOAK; + requested_equip = ITEM_TYPE_CLOAK; break; case RANDOM_ITEM_GAUNTLETS: - requested_equip = EQUIP_GAUNTLETS; + requested_equip = ITEM_TYPE_GAUNTLETS; break; case RANDOM_ITEM_BOOTS: - requested_equip = EQUIP_BOOTS; + requested_equip = ITEM_TYPE_BOOTS; break; case RANDOM_ITEM_RING: - requested_equip = EQUIP_RING; + requested_equip = ITEM_TYPE_RING; break; case RANDOM_ITEM_AMULET: - requested_equip = EQUIP_AMULET; + requested_equip = ITEM_TYPE_AMULET; break; case RANDOM_ITEM_WAND: - requested_equip = EQUIP_WAND; + requested_equip = ITEM_TYPE_WAND; break; case RANDOM_ITEM_SPELL_SCROLL: - requested_equip = EQUIP_SPELL_SCROLL; + requested_equip = ITEM_TYPE_SPELL_SCROLL; break; case RANDOM_ITEM_POTION: - requested_equip = EQUIP_POTION; + requested_equip = ITEM_TYPE_POTION; break; case RANDOM_ITEM_REAGENT: - requested_equip = EQUIP_REAGENT; + requested_equip = ITEM_TYPE_REAGENT; break; case RANDOM_ITEM_GEM: - requested_equip = EQUIP_GEM; + requested_equip = ITEM_TYPE_GEM; break; default: __debugbreak(); // check this condition @@ -556,21 +556,21 @@ void ItemTable::generateItem(ItemTreasureLevel treasure_level, RandomItemType uT } // try get special enhansment switch (outItem->GetItemEquipType()) { - case EQUIP_SINGLE_HANDED: - case EQUIP_TWO_HANDED: - case EQUIP_BOW: + case ITEM_TYPE_SINGLE_HANDED: + case ITEM_TYPE_TWO_HANDED: + case ITEM_TYPE_BOW: if (!uBonusChanceWpSpecial[treasure_level]) return; if (grng->random(100) >= uBonusChanceWpSpecial[treasure_level]) return; break; - case EQUIP_ARMOUR: - case EQUIP_SHIELD: - case EQUIP_HELMET: - case EQUIP_BELT: - case EQUIP_CLOAK: - case EQUIP_GAUNTLETS: - case EQUIP_BOOTS: - case EQUIP_RING: { + case ITEM_TYPE_ARMOUR: + case ITEM_TYPE_SHIELD: + case ITEM_TYPE_HELMET: + case ITEM_TYPE_BELT: + case ITEM_TYPE_CLOAK: + case ITEM_TYPE_GAUNTLETS: + case ITEM_TYPE_BOOTS: + case ITEM_TYPE_RING: { if (!uBonusChanceStandart[treasure_level]) return; int bonusChanceRoll = grng->random(100); // edx@86 if (bonusChanceRoll < uBonusChanceStandart[treasure_level]) { @@ -604,7 +604,7 @@ void ItemTable::generateItem(ItemTreasureLevel treasure_level, RandomItemType uT } } break; - case EQUIP_WAND: + case ITEM_TYPE_WAND: outItem->uNumCharges = grng->random(6) + outItem->GetDamageMod() + 1; outItem->uMaxCharges = outItem->uNumCharges; return; diff --git a/src/Engine/Tables/ItemTable.h b/src/Engine/Tables/ItemTable.h index 3e5d6171f98f..87403a3e045f 100644 --- a/src/Engine/Tables/ItemTable.h +++ b/src/Engine/Tables/ItemTable.h @@ -44,7 +44,7 @@ struct ItemTable { IndexedArray uBonusChanceStandart; // 1169c IndexedArray uBonusChanceSpecial; // 116B4 IndexedArray uBonusChanceWpSpecial; // 116cc -116e4 - IndexedArray chanceByItemTypeSums; // 116E4h -11708h + IndexedArray chanceByItemTypeSums; // 116E4h -11708h IndexedArray bonusRanges; // 45C2h*4 =11708h unsigned int pSpecialEnchantments_count; // 11798h char field_1179C; diff --git a/src/GUI/UI/UICharacter.cpp b/src/GUI/UI/UICharacter.cpp index 801e00ae6d01..a7bc9a0bd853 100644 --- a/src/GUI/UI/UICharacter.cpp +++ b/src/GUI/UI/UICharacter.cpp @@ -1018,7 +1018,7 @@ void CharacterUI_DrawPaperdoll(Character *player) { ItemGen *itemMainHand = player->GetMainHandItem(); ItemGen *itemOffHand = player->GetOffHandItem(); - bool bTwoHandedGrip = itemMainHand && (itemMainHand->GetItemEquipType() == EQUIP_TWO_HANDED || itemMainHand->GetPlayerSkillType() == CHARACTER_SKILL_SPEAR && !itemOffHand); + bool bTwoHandedGrip = itemMainHand && (itemMainHand->GetItemEquipType() == ITEM_TYPE_TWO_HANDED || itemMainHand->GetPlayerSkillType() == CHARACTER_SKILL_SPEAR && !itemOffHand); // Aqua-Lung if (player->hasUnderwaterSuitEquipped()) { @@ -1762,7 +1762,7 @@ void OnPaperdollLeftClick() { ItemId v50; // [sp+38h] [bp-14h]@50 // int v51; // [sp+3Ch] [bp-10h]@1 int freeslot; // [sp+40h] [bp-Ch]@5 - ItemType pEquipType = EQUIP_NONE; + ItemType pEquipType = ITEM_TYPE_NONE; CastSpellInfo *pSpellInfo; int twohandedequip = 0; @@ -1771,7 +1771,7 @@ void OnPaperdollLeftClick() { int mainhandequip = pParty->activeCharacter().pEquipment.uMainHand; unsigned int shieldequip = pParty->activeCharacter().pEquipment.uOffHand; - if (mainhandequip && pParty->activeCharacter().pInventoryItemList[mainhandequip - 1].GetItemEquipType() == EQUIP_TWO_HANDED) { + if (mainhandequip && pParty->activeCharacter().pInventoryItemList[mainhandequip - 1].GetItemEquipType() == ITEM_TYPE_TWO_HANDED) { twohandedequip = mainhandequip; } @@ -1809,20 +1809,20 @@ void OnPaperdollLeftClick() { } if (pParty->pPickedItem.uItemID == ITEM_QUEST_WETSUIT) { // wetsuit check is done above - pParty->activeCharacter().EquipBody(EQUIP_ARMOUR); + pParty->activeCharacter().EquipBody(ITEM_TYPE_ARMOUR); WetsuitOn(pParty->activeCharacterIndex()); return; } switch (pEquipType) { - case EQUIP_BOW: - case EQUIP_ARMOUR: - case EQUIP_HELMET: - case EQUIP_BELT: - case EQUIP_CLOAK: - case EQUIP_GAUNTLETS: - case EQUIP_BOOTS: - case EQUIP_AMULET: + case ITEM_TYPE_BOW: + case ITEM_TYPE_ARMOUR: + case ITEM_TYPE_HELMET: + case ITEM_TYPE_BELT: + case ITEM_TYPE_CLOAK: + case ITEM_TYPE_GAUNTLETS: + case ITEM_TYPE_BOOTS: + case ITEM_TYPE_AMULET: if (!pParty->activeCharacter().HasSkill(pSkillType)) { // hasnt got the skill to use that pParty->activeCharacter().playReaction(SPEECH_CANT_EQUIP); @@ -1830,7 +1830,7 @@ void OnPaperdollLeftClick() { } if (pParty->activeCharacter().hasUnderwaterSuitEquipped() && - (pEquipType != EQUIP_ARMOUR || engine->IsUnderwater())) { // cant put anything on wearing wetsuit + (pEquipType != ITEM_TYPE_ARMOUR || engine->IsUnderwater())) { // cant put anything on wearing wetsuit pAudioPlayer->playUISound(SOUND_error); return; } @@ -1843,7 +1843,7 @@ void OnPaperdollLeftClick() { return; // ------------------------dress rings(одевание колец)---------------------------------- - case EQUIP_RING: + case ITEM_TYPE_RING: if (pParty->activeCharacter().hasUnderwaterSuitEquipped()) { // cant put anything // on wearing wetsuit pAudioPlayer->playUISound(SOUND_error); @@ -1918,7 +1918,7 @@ void OnPaperdollLeftClick() { } // ------------------dress shield(одеть щит)------------------------------------------------------ - case EQUIP_SHIELD: //Щит + case ITEM_TYPE_SHIELD: //Щит if (pParty->activeCharacter().hasUnderwaterSuitEquipped()) { // в акваланге pAudioPlayer->playUISound(SOUND_error); return; @@ -1963,8 +1963,8 @@ void OnPaperdollLeftClick() { pParty->activeCharacter().pEquipment.uMainHand = 0; return; // -------------------------taken in hand(взять в руку)------------------------------------------- - case EQUIP_SINGLE_HANDED: - case EQUIP_WAND: + case ITEM_TYPE_SINGLE_HANDED: + case ITEM_TYPE_WAND: if (pParty->activeCharacter().hasUnderwaterSuitEquipped() && pParty->pPickedItem.uItemID != ITEM_BLASTER && pParty->pPickedItem.uItemID != ITEM_BLASTER_RIFLE) { @@ -1990,7 +1990,7 @@ void OnPaperdollLeftClick() { _this.uBodyAnchor = ITEM_SLOT_OFF_HAND; pParty->activeCharacter().pInventoryItemList[shieldequip] = _this; pParty->activeCharacter().pEquipment.uOffHand = shieldequip + 1; - if (pEquipType != EQUIP_WAND) { + if (pEquipType != ITEM_TYPE_WAND) { return; } v50 = _this.uItemID; @@ -2002,7 +2002,7 @@ void OnPaperdollLeftClick() { pParty->activeCharacter().pInventoryItemList[v23] = pParty->pPickedItem; pParty->activeCharacter().pEquipment.uOffHand = v23 + 1; mouse->RemoveHoldingItem(); - if (pEquipType != EQUIP_WAND) return; + if (pEquipType != ITEM_TYPE_WAND) return; v50 = pParty->activeCharacter().pInventoryItemList[v23].uItemID; break; } @@ -2015,7 +2015,7 @@ void OnPaperdollLeftClick() { pParty->activeCharacter().pInventoryItemList[v26] = pParty->pPickedItem; pParty->activeCharacter().pEquipment.uMainHand = v26 + 1; mouse->RemoveHoldingItem(); - if (pEquipType != EQUIP_WAND) return; + if (pEquipType != ITEM_TYPE_WAND) return; break; } --mainhandequip; @@ -2026,14 +2026,14 @@ void OnPaperdollLeftClick() { _this.uBodyAnchor = ITEM_SLOT_MAIN_HAND; pParty->activeCharacter().pInventoryItemList[mainhandequip] = _this; pParty->activeCharacter().pEquipment.uMainHand = mainhandequip + 1; - if (pEquipType == EQUIP_WAND) v50 = _this.uItemID; + if (pEquipType == ITEM_TYPE_WAND) v50 = _this.uItemID; if (twohandedequip) { pParty->activeCharacter().pEquipment.uOffHand = 0; } break; // ---------------------------take two hands(взять двумя // руками)--------------------------------- - case EQUIP_TWO_HANDED: + case ITEM_TYPE_TWO_HANDED: if (pParty->activeCharacter().hasUnderwaterSuitEquipped()) { pAudioPlayer->playUISound(SOUND_error); return; diff --git a/src/GUI/UI/UIPopup.cpp b/src/GUI/UI/UIPopup.cpp index 0d2721a31391..484db5aef0ec 100644 --- a/src/GUI/UI/UIPopup.cpp +++ b/src/GUI/UI/UIPopup.cpp @@ -447,8 +447,8 @@ void GameUI_DrawItemInfo(struct ItemGen *inspect_item) { pItemTable->pItems[inspect_item->uItemID].pUnidentifiedName); switch (inspect_item->GetItemEquipType()) { - case EQUIP_SINGLE_HANDED: - case EQUIP_TWO_HANDED: { + case ITEM_TYPE_SINGLE_HANDED: + case ITEM_TYPE_TWO_HANDED: { text[1] = fmt::format("{}: +{} {}: {}d{}", localization->GetString(LSTR_ATTACK), inspect_item->GetDamageMod(), @@ -460,7 +460,7 @@ void GameUI_DrawItemInfo(struct ItemGen *inspect_item) { break; } - case EQUIP_BOW: + case ITEM_TYPE_BOW: text[1] = fmt::format("{}: +{} {}: {}d{}", localization->GetString(LSTR_SHOOT), inspect_item->GetDamageMod(), @@ -471,15 +471,15 @@ void GameUI_DrawItemInfo(struct ItemGen *inspect_item) { text[1] += fmt::format("+{}", inspect_item->GetDamageMod()); break; - case EQUIP_ARMOUR: - case EQUIP_SHIELD: - case EQUIP_HELMET: - case EQUIP_BELT: - case EQUIP_CLOAK: - case EQUIP_GAUNTLETS: - case EQUIP_BOOTS: - case EQUIP_RING: - case EQUIP_AMULET: + case ITEM_TYPE_ARMOUR: + case ITEM_TYPE_SHIELD: + case ITEM_TYPE_HELMET: + case ITEM_TYPE_BELT: + case ITEM_TYPE_CLOAK: + case ITEM_TYPE_GAUNTLETS: + case ITEM_TYPE_BOOTS: + case ITEM_TYPE_RING: + case ITEM_TYPE_AMULET: if (inspect_item->GetDamageDice()) text[1] = fmt::format("{}: +{}", localization->GetString(LSTR_ARMOR),