Skip to content

Commit

Permalink
Merge pull request OpenEnroth#1337 from captainurist/macos_fixes_398
Browse files Browse the repository at this point in the history
Enum renamings in ItemEnums.h
  • Loading branch information
captainurist authored Oct 15, 2023
2 parents 46095dc + 83e5537 commit 4518f6d
Show file tree
Hide file tree
Showing 30 changed files with 488 additions and 486 deletions.
26 changes: 15 additions & 11 deletions src/Bin/CodeGen/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,28 @@ int runItemIdCodeGen(CodeGenOptions options, GameResourceManager *resourceManage
if (!contains(description, "off-balance"))
enumName += "_FIXED";

if (desc.uEquipType == EQUIP_REAGENT) {
// Shorten enum names for letters.
if (enumName.starts_with("LETTER_FROM") && contains(enumName, "_TO_"))
enumName = enumName.substr(0, enumName.find("_TO_"));

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.") {
Expand All @@ -113,16 +117,16 @@ 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;
}

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) {
enumName = "RARE_" + enumName;
} else if (desc.uMaterial == RARITY_SPECIAL) {
enumName = "SPECIAL_" + enumName;
} else if (description.starts_with("Quest")) {
enumName = "QUEST_" + enumName;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Engine/Conditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ MM_DECLARE_OPERATORS_FOR_FLAGS(ConditionFlags)

struct ConditionTableEntry {
ConditionFlags flags;
ITEM_ENCHANTMENT enchantment = ITEM_ENCHANTMENT_NULL;
ItemEnchantment enchantment = ITEM_ENCHANTMENT_NULL;
std::array<ConditionEquipment, 3> equipment = {{}};

constexpr ConditionTableEntry() = default;
constexpr ConditionTableEntry(ConditionFlags flags,
ITEM_ENCHANTMENT enchantment = ITEM_ENCHANTMENT_NULL,
ItemEnchantment enchantment = ITEM_ENCHANTMENT_NULL,
ItemId item1 = ITEM_NULL,
ItemSlot slot1 = ITEM_SLOT_INVALID,
ItemId item2 = ITEM_NULL,
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ void RegeneratePartyHealthMana() {
recovery_HP = true;
}
} else {
ITEM_ENCHANTMENT special_enchantment = equppedItem.special_enchantment;
ItemEnchantment special_enchantment = equppedItem.special_enchantment;
if (special_enchantment == ITEM_ENCHANTMENT_OF_REGENERATION
|| special_enchantment == ITEM_ENCHANTMENT_OF_LIFE
|| special_enchantment == ITEM_ENCHANTMENT_OF_PHOENIX
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Events/EventIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ EventIR EventIR::parse(const RawEvent *evt, size_t size) {
break;
case EVENT_ReceiveDamage:
requireSize(11);
ir.data.damage_descr.damage_type = static_cast<DAMAGE_TYPE>(evt->v6);
ir.data.damage_descr.damage_type = static_cast<DamageType>(evt->v6);
ir.data.damage_descr.damage = EVT_DWORD(&evt->v7);
break;
case EVENT_SetSnow:
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Events/EventIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class EventIR {
int y;
} sound_descr;
struct {
DAMAGE_TYPE damage_type;
DamageType damage_type;
int damage;
} damage_descr;
struct {
Expand Down
4 changes: 2 additions & 2 deletions src/Engine/Graphics/Indoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,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);
Expand Down Expand Up @@ -2046,7 +2046,7 @@ void SpawnRandomTreasure(MapInfo *mapInfo, SpawnPoint *a2) {
a1a.uType = pItemTable->pItems[a1a.containing_item.uItemID].uSpriteID;
a1a.containing_item.SetIdentified();
a1a.uObjectDescID = pObjectList->ObjectIDByItemID(a1a.uType);
a1a.containing_item.special_enchantment = (ITEM_ENCHANTMENT)v34;
a1a.containing_item.special_enchantment = (ItemEnchantment)v34;
} else {
if (!a1a.containing_item.GenerateArtifact())
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Graphics/Outdoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,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);
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Graphics/Viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions src/Engine/Objects/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void Actor::SetRandomGoldIfTheresNoItem() {
if (v2) {
this->items[3].uItemID = ITEM_GOLD_SMALL;
this->items[3].special_enchantment =
(ITEM_ENCHANTMENT)v2; // actual gold amount
(ItemEnchantment)v2; // actual gold amount
}
}
}
Expand Down Expand Up @@ -2341,7 +2341,7 @@ void Actor::ActorDamageFromMonster(Pid attacker_id,
ABILITY_INDEX a4) {
int v4; // ebx@1
int dmgToRecv; // qax@8
DAMAGE_TYPE v12; // ecx@20
DamageType v12; // ecx@20
int finalDmg; // edi@30
int pushDistance; // [sp+20h] [bp+Ch]@34

Expand Down Expand Up @@ -2391,7 +2391,7 @@ void Actor::ActorDamageFromMonster(Pid attacker_id,
->pInfos[pActors[attacker_id.id()].monsterInfo.uSpell2ID]
.damageType;
} else if (a4 == ABILITY_SPECIAL) {
v12 = static_cast<DAMAGE_TYPE>(pActors[attacker_id.id()].monsterInfo.field_3C_some_special_attack);
v12 = static_cast<DamageType>(pActors[attacker_id.id()].monsterInfo.field_3C_some_special_attack);
} else {
v12 = DAMAGE_PHYSICAL;
}
Expand Down Expand Up @@ -3034,7 +3034,7 @@ void Actor::DamageMonsterFromParty(Pid a1, unsigned int uActorID_Monster,
int v61; // [sp+58h] [bp-14h]@1
bool isLifeStealing; // [sp+5Ch] [bp-10h]@1
int uDamageAmount; // [sp+60h] [bp-Ch]@1
DAMAGE_TYPE attackElement; // [sp+64h] [bp-8h]@27
DamageType attackElement; // [sp+64h] [bp-8h]@27

projectileSprite = 0;
uDamageAmount = 0;
Expand Down Expand Up @@ -3792,7 +3792,7 @@ bool Actor::ActorHitOrMiss(Character *pPlayer) {
}

//----- (0042756B) --------------------------------------------------------
int Actor::CalcMagicalDamageToActor(DAMAGE_TYPE dmgType,
int Actor::CalcMagicalDamageToActor(DamageType dmgType,
signed int incomingDmg) {
int v4; // edx@1
int v5; // ecx@1
Expand Down Expand Up @@ -3859,7 +3859,7 @@ int Actor::CalcMagicalDamageToActor(DAMAGE_TYPE dmgType,
}

//----- (00427662) --------------------------------------------------------
bool Actor::DoesDmgTypeDoDamage(DAMAGE_TYPE uType) {
bool Actor::DoesDmgTypeDoDamage(DamageType uType) {
signed int resist; // esi@2

switch (uType) {
Expand Down
4 changes: 2 additions & 2 deletions src/Engine/Objects/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ class Actor {
ABILITY_INDEX special_ability_use_check(int a2);
bool _4273BB_DoesHitOtherActor(Actor *defender, int a3, int a4);
bool ActorHitOrMiss(Character *pPlayer);
int CalcMagicalDamageToActor(DAMAGE_TYPE dmgType, int incomingDmg);
bool DoesDmgTypeDoDamage(DAMAGE_TYPE uType);
int CalcMagicalDamageToActor(DamageType dmgType, int incomingDmg);
bool DoesDmgTypeDoDamage(DamageType uType);

int id = -1; // Actor index in pActors array.
std::string name;
Expand Down
Loading

0 comments on commit 4518f6d

Please sign in to comment.