Skip to content

Commit

Permalink
Renaming enum values p2
Browse files Browse the repository at this point in the history
  • Loading branch information
captainurist committed Oct 14, 2023
1 parent ace7c53 commit 67e9b63
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/Bin/CodeGen/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ int runItemIdCodeGen(CodeGenOptions options, GameResourceManager *resourceManage
enumName = "GEM_" + enumName;
}

if (desc.uMaterial == MATERIAL_ARTIFACT) {
if (desc.uMaterial == RARITY_ARTIFACT) {
enumName = "ARTIFACT_" + enumName;
} else if (desc.uMaterial == MATERIAL_RELIC) {
} else if (desc.uMaterial == RARITY_RELIC) {
enumName = "RELIC_" + enumName;
} else if (desc.uMaterial == MATERIAL_SPECIAL) {
} else if (desc.uMaterial == RARITY_SPECIAL) {
enumName = "RARE_" + enumName;
} else if (description.starts_with("Quest")) {
enumName = "QUEST_" + enumName;
Expand Down
11 changes: 6 additions & 5 deletions src/Engine/Objects/ItemEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ enum class ItemEnchantment : unsigned int {
using enum ItemEnchantment;

enum class ItemRarity : uint8_t {
MATERIAL_COMMON = 0,
MATERIAL_ARTIFACT = 1,
MATERIAL_RELIC = 2,
MATERIAL_SPECIAL = 3 // TODO(captainurist): RARE
RARITY_COMMON = 0,
RARITY_ARTIFACT = 1, // Artifacts always give positive bonuses.
RARITY_RELIC = 2, // Relics can be more powerful than artifacts but carry a penalty (have a negative bonus).
RARITY_SPECIAL = 3, // Pretty much just weak artifacts, and often quest items. Not in the loot table, so can
// only be found where the level designers have put them.
};
using enum ItemRarity;

Expand Down Expand Up @@ -700,7 +701,7 @@ enum class ItemId : int32_t {
ITEM_ARTIFACT_FORGE_GAUNTLETS = 534,
ITEM_ARTIFACT_HEROS_BELT = 535,
ITEM_ARTIFACT_LADYS_ESCORT = 536,
ITEM_RARE_CLANKERS_AMULET = 537,
ITEM_RARE_CLANKERS_AMULET = 537, // TODO(captainurist): RARE -> SPECIAL
ITEM_RARE_LIEUTENANTS_CUTLASS = 538,
ITEM_RARE_MEDUSAS_MIRROR = 539,
ITEM_RARE_LADY_CARMINES_DAGGER = 540,
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Objects/Items.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ struct ItemDesc { // 30h
uint8_t uDamageDice = 0; // 1e 22
uint8_t uDamageRoll = 0; // 1f 23
uint8_t uDamageMod = 0; // 20 24
ItemRarity uMaterial = MATERIAL_COMMON; // 21 25
ItemRarity uMaterial = RARITY_COMMON; // 21 25
ItemEnchantment _additional_value = ITEM_ENCHANTMENT_NULL; // 22 26
std::optional<CharacterAttributeType> _bonus_type;
char _bonus_strength = 0; // 24 28
Expand Down
22 changes: 11 additions & 11 deletions src/Engine/Tables/ItemTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ void ItemTable::Initialize(GameResourceManager *resourceManager) {
equipSkillMap["club"] = CHARACTER_SKILL_CLUB;

std::map<std::string, ItemRarity, ILess> materialMap;
materialMap["artifact"] = MATERIAL_ARTIFACT;
materialMap["relic"] = MATERIAL_RELIC;
materialMap["special"] = MATERIAL_SPECIAL;
materialMap["artifact"] = RARITY_ARTIFACT;
materialMap["relic"] = RARITY_RELIC;
materialMap["special"] = RARITY_SPECIAL;

char *lineContent;

Expand Down Expand Up @@ -161,14 +161,14 @@ void ItemTable::Initialize(GameResourceManager *resourceManager) {
pItems[item_counter].uDamageRoll = 0;
}
pItems[item_counter].uDamageMod = atoi(tokens[7]);
pItems[item_counter].uMaterial = valueOr(materialMap, tokens[8], MATERIAL_COMMON);
pItems[item_counter].uMaterial = valueOr(materialMap, tokens[8], RARITY_COMMON);
pItems[item_counter].uItemID_Rep_St = atoi(tokens[9]);
pItems[item_counter].pUnidentifiedName = removeQuotes(tokens[10]);
pItems[item_counter].uSpriteID = static_cast<SPRITE_OBJECT_TYPE>(atoi(tokens[11]));

pItems[item_counter]._additional_value = ITEM_ENCHANTMENT_NULL;
pItems[item_counter]._bonus_type = {};
if (pItems[item_counter].uMaterial == MATERIAL_SPECIAL) {
if (pItems[item_counter].uMaterial == RARITY_SPECIAL) {
for (CharacterAttributeType ii : allEnchantableAttributes()) {
if (iequals(tokens[12], standardEnchantments[ii].pOfName)) {
pItems[item_counter]._bonus_type = ii;
Expand All @@ -184,7 +184,7 @@ void ItemTable::Initialize(GameResourceManager *resourceManager) {
}
}

if ((pItems[item_counter].uMaterial == MATERIAL_SPECIAL) &&
if ((pItems[item_counter].uMaterial == RARITY_SPECIAL) &&
(pItems[item_counter]._bonus_type)) {
char b_s = atoi(tokens[13]);
if (b_s)
Expand Down Expand Up @@ -262,7 +262,7 @@ void ItemTable::Initialize(GameResourceManager *resourceManager) {

//----- (00456D17) --------------------------------------------------------
void ItemTable::SetSpecialBonus(ItemGen *pItem) {
if (pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL) {
if (pItems[pItem->uItemID].uMaterial == RARITY_SPECIAL) {
pItem->attributeEnchantment = pItems[pItem->uItemID]._bonus_type;
pItem->special_enchantment =
(ItemEnchantment)pItems[pItem->uItemID]._additional_value;
Expand All @@ -272,14 +272,14 @@ void ItemTable::SetSpecialBonus(ItemGen *pItem) {

//----- (00456D43) --------------------------------------------------------
bool ItemTable::IsMaterialSpecial(const ItemGen *pItem) {
return this->pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL;
return this->pItems[pItem->uItemID].uMaterial == RARITY_SPECIAL;
}

//----- (00456D5E) --------------------------------------------------------
bool ItemTable::IsMaterialNonCommon(const ItemGen *pItem) {
return pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL ||
pItems[pItem->uItemID].uMaterial == MATERIAL_RELIC ||
pItems[pItem->uItemID].uMaterial == MATERIAL_ARTIFACT;
return pItems[pItem->uItemID].uMaterial == RARITY_SPECIAL ||
pItems[pItem->uItemID].uMaterial == RARITY_RELIC ||
pItems[pItem->uItemID].uMaterial == RARITY_ARTIFACT;
}

//----- (00453B3C) --------------------------------------------------------
Expand Down

0 comments on commit 67e9b63

Please sign in to comment.