Skip to content

Commit

Permalink
Merge pull request OpenEnroth#1934 from captainurist/macos_fixes_623
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
captainurist authored Feb 16, 2025
2 parents e0651df + b42b731 commit b5ae476
Show file tree
Hide file tree
Showing 32 changed files with 388 additions and 352 deletions.
26 changes: 13 additions & 13 deletions src/Bin/CodeGen/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ int runItemIdCodeGen(const CodeGenOptions &options, GameResourceManager *resourc
CodeGenMap map;
map.insert(ITEM_NULL, "NULL", "");

for(ItemId i : itemTable.pItems.indices()) {
const ItemDesc &desc = itemTable.pItems[i];
for(ItemId i : itemTable.items.indices()) {
const ItemDesc &desc = itemTable.items[i];
std::string icon = desc.iconName;
std::string name = desc.name;
std::string description = desc.pDescription;
std::string description = desc.description;

if (icon.empty() || icon == "null") {
map.insert(i, "", "Unused.");
Expand Down Expand Up @@ -97,24 +97,24 @@ int runItemIdCodeGen(const CodeGenOptions &options, GameResourceManager *resourc
if (enumName.starts_with("LETTER_FROM") && enumName.contains("_TO_"))
enumName = enumName.substr(0, enumName.find("_TO_"));

if (desc.uEquipType == ITEM_TYPE_REAGENT) {
if (desc.type == ITEM_TYPE_REAGENT) {
enumName = "REAGENT_" + enumName;
} else if (desc.uEquipType == ITEM_TYPE_POTION) {
} else if (desc.type == 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 == ITEM_TYPE_SPELL_SCROLL) {
} else if (desc.type == ITEM_TYPE_SPELL_SCROLL) {
enumName = "SCROLL_" + enumName;
} else if (desc.uEquipType == ITEM_TYPE_BOOK) {
} else if (desc.type == ITEM_TYPE_BOOK) {
enumName = "SPELLBOOK_" + enumName;
} else if (desc.uEquipType == ITEM_TYPE_MESSAGE_SCROLL) {
} else if (desc.type == 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 == ITEM_TYPE_GOLD) {
} else if (desc.type == ITEM_TYPE_GOLD) {
if (description == "A small pile of gold coins.") {
enumName = "GOLD_SMALL";
} else if (description == "A pile of gold coins.") {
Expand All @@ -124,15 +124,15 @@ int runItemIdCodeGen(const CodeGenOptions &options, GameResourceManager *resourc
} else {
throw Exception("Unrecognized gold pile description '{}'", description);
}
} else if (desc.uEquipType == ITEM_TYPE_GEM) {
} else if (desc.type == ITEM_TYPE_GEM) {
enumName = "GEM_" + enumName;
}

if (desc.uMaterial == RARITY_ARTIFACT) {
if (desc.rarity == RARITY_ARTIFACT) {
enumName = "ARTIFACT_" + enumName;
} else if (desc.uMaterial == RARITY_RELIC) {
} else if (desc.rarity == RARITY_RELIC) {
enumName = "RELIC_" + enumName;
} else if (desc.uMaterial == RARITY_SPECIAL) {
} else if (desc.rarity == RARITY_SPECIAL) {
enumName = "SPECIAL_" + enumName;
} else if (description.starts_with("Quest")) {
enumName = "QUEST_" + enumName;
Expand Down
4 changes: 3 additions & 1 deletion src/Engine/Data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ set(ENGINE_DATA_HEADERS
PortraitFrameData.h
TileData.h
TileEnums.h
TileEnumFunctions.h)
TileEnumFunctions.h
StandardEnchantmentData.h
SpecialEnchantmentData.h)

add_library(engine_data STATIC ${ENGINE_DATA_SOURCES} ${ENGINE_DATA_HEADERS})
target_link_libraries(engine_data PUBLIC library_serialization utility)
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Data/PortraitFrameData.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "Engine/Objects/CharacterEnums.h" // TODO(captainurist): doesn't belong here, move out.
#include "Engine/Objects/CharacterEnums.h" // TODO(captainurist): Data -> Objects dependency, we don't want that.

#include "Engine/Time/Duration.h"

Expand Down
16 changes: 16 additions & 0 deletions src/Engine/Data/SpecialEnchantmentData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <string>

#include "Engine/Objects/ItemEnums.h" // TODO(captainurist): Data -> Objects dependency, we don't want that.

#include "Utility/IndexedArray.h"

struct SpecialEnchantmentData {
std::string description; // Enchantment description, e.g. "Explosive impact!".
std::string itemSuffixOrPrefix; // Suffix or prefix for the enchanted item, e.g. "of Carnage". Whether it's a prefix
// or a suffix is hardcoded in item name generation function.
IndexedArray<char, ITEM_TYPE_FIRST_SPECIAL_ENCHANTABLE, ITEM_TYPE_LAST_SPECIAL_ENCHANTABLE> chanceByItemType;
int additionalValue; // Value in gold added to enchanted item's base value.
int iTreasureLevel;
};
13 changes: 13 additions & 0 deletions src/Engine/Data/StandardEnchantmentData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <string>

#include "Utility/IndexedArray.h"

#include "Engine/Objects/ItemEnums.h" // TODO(captainurist): Data -> Objects dependency, we don't want that.

struct StandardEnchantmentData {
std::string attributeName; // Name of the attribute this applies to, e.g. "Might" or "Armsmaster skill".
std::string itemSuffix; // Suffix for the enchanted item, e.g. "of Might" or "of Arms".
IndexedArray<unsigned char, ITEM_TYPE_FIRST_NORMAL_ENCHANTABLE, ITEM_TYPE_LAST_NORMAL_ENCHANTABLE> chanceByItemType;
};
8 changes: 4 additions & 4 deletions src/Engine/Graphics/Indoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ void loadAndPrepareBLV(MapId mapid, bool bLoading) {
if (pSpriteObjects[i].uObjectDescID) {
if (pSpriteObjects[i].containing_item.itemId != ITEM_NULL) {
if (pSpriteObjects[i].containing_item.itemId != ITEM_POTION_BOTTLE &&
pItemTable->pItems[pSpriteObjects[i].containing_item.itemId].uEquipType == ITEM_TYPE_POTION &&
pItemTable->items[pSpriteObjects[i].containing_item.itemId].type == 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 @@ -1986,7 +1986,7 @@ int SpawnEncounterMonsters(MapInfo *map_info, int enc_index) {
int DropTreasureAt(ItemTreasureLevel trs_level, RandomItemType trs_type, Vec3f pos, uint16_t facing) {
SpriteObject a1;
pItemTable->generateItem(trs_level, trs_type, &a1.containing_item);
a1.uType = pItemTable->pItems[a1.containing_item.itemId].uSpriteID;
a1.uType = pItemTable->items[a1.containing_item.itemId].spriteId;
a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
a1.vPosition = pos;
a1.uFacing = facing;
Expand Down Expand Up @@ -2019,12 +2019,12 @@ void SpawnRandomTreasure(MapInfo *mapInfo, SpawnPoint *a2) {
}

a1a.containing_item.generateGold(a2->uItemIndex);
a1a.uType = pItemTable->pItems[a1a.containing_item.itemId].uSpriteID;
a1a.uType = pItemTable->items[a1a.containing_item.itemId].spriteId;
a1a.uObjectDescID = pObjectList->ObjectIDByItemID(a1a.uType);
} else {
if (!a1a.containing_item.GenerateArtifact())
return;
a1a.uType = pItemTable->pItems[a1a.containing_item.itemId].uSpriteID;
a1a.uType = pItemTable->items[a1a.containing_item.itemId].spriteId;
a1a.uObjectDescID = pObjectList->ObjectIDByItemID(a1a.uType);
a1a.containing_item.Reset(); // TODO(captainurist): this needs checking
}
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 @@ -630,7 +630,7 @@ void OutdoorLocation::ArrangeSpriteObjects() {
}
if (pSpriteObjects[i].containing_item.itemId != ITEM_NULL) {
if (pSpriteObjects[i].containing_item.itemId != ITEM_POTION_BOTTLE &&
pItemTable->pItems[pSpriteObjects[i].containing_item.itemId].uEquipType == ITEM_TYPE_POTION &&
pItemTable->items[pSpriteObjects[i].containing_item.itemId].type == 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
4 changes: 2 additions & 2 deletions src/Engine/Graphics/Viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ void ViewingParams::_443365() {
}

void ItemInteraction(unsigned int item_id) {
if (pItemTable->pItems[pSpriteObjects[item_id].containing_item.itemId].uEquipType == ITEM_TYPE_GOLD) {
if (pItemTable->items[pSpriteObjects[item_id].containing_item.itemId].type == ITEM_TYPE_GOLD) {
pParty->partyFindsGold(pSpriteObjects[item_id].containing_item.goldAmount, GOLD_RECEIVE_SHARE);
} else {
if (pParty->pPickedItem.itemId != ITEM_NULL) {
return;
}

engine->_statusBar->setEvent(LSTR_FMT_YOU_FOUND_ITEM, pItemTable->pItems[pSpriteObjects[item_id].containing_item.itemId].pUnidentifiedName);
engine->_statusBar->setEvent(LSTR_FMT_YOU_FOUND_ITEM, pItemTable->items[pSpriteObjects[item_id].containing_item.itemId].unidentifiedName);

// TODO: WTF? 184 / 185 qbits are associated with Tatalia's Mercenery Guild Harmondale raids. Are these about castle's tapestries ?
if (pSpriteObjects[item_id].containing_item.itemId == ITEM_ARTIFACT_SPLITTER) {
Expand Down
8 changes: 4 additions & 4 deletions src/Engine/Objects/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ void Actor::Die(unsigned int uActorID) {
drop.itemId = itemDropForMonsterType(monsterTypeForMonsterId(actor->monsterInfo.id));

if (grng->random(100) < 20 && drop.itemId != ITEM_NULL) {
SpriteObject::dropItemAt(pItemTable->pItems[drop.itemId].uSpriteID,
SpriteObject::dropItemAt(pItemTable->items[drop.itemId].spriteId,
actor->pos + Vec3f(0, 0, 16), grng->random(200) + 200, 1, true, 0, &drop);
}

Expand Down Expand Up @@ -3576,7 +3576,7 @@ void Actor::LootActor() {
Dst.Reset();
Dst.itemId = this->carriedItemId;

StatusBarItemFound(foundGold, pItemTable->pItems[Dst.itemId].pUnidentifiedName);
StatusBarItemFound(foundGold, pItemTable->items[Dst.itemId].unidentifiedName);

if (Dst.isWand()) {
Dst.numCharges = grng->random(6) + Dst.GetDamageMod() + 1;
Expand Down Expand Up @@ -3612,7 +3612,7 @@ void Actor::LootActor() {
Dst = this->items[3];
this->items[3].Reset();

StatusBarItemFound(foundGold, pItemTable->pItems[Dst.itemId].pUnidentifiedName);
StatusBarItemFound(foundGold, pItemTable->items[Dst.itemId].unidentifiedName);

if (!pParty->addItemToParty(&Dst)) {
pParty->setHoldingItem(&Dst);
Expand All @@ -3623,7 +3623,7 @@ void Actor::LootActor() {
if (grng->random(100) < this->monsterInfo.treasureDropChance && this->monsterInfo.treasureLevel != ITEM_TREASURE_LEVEL_INVALID) {
pItemTable->generateItem(this->monsterInfo.treasureLevel, this->monsterInfo.treasureType, &Dst);

StatusBarItemFound(foundGold, pItemTable->pItems[Dst.itemId].pUnidentifiedName);
StatusBarItemFound(foundGold, pItemTable->items[Dst.itemId].unidentifiedName);

if (!pParty->addItemToParty(&Dst)) {
pParty->setHoldingItem(&Dst);
Expand Down
Loading

0 comments on commit b5ae476

Please sign in to comment.