diff --git a/OpenTESArena/src/Interface/AutomapUiView.cpp b/OpenTESArena/src/Interface/AutomapUiView.cpp index a2d7ec463..1afa5fe61 100644 --- a/OpenTESArena/src/Interface/AutomapUiView.cpp +++ b/OpenTESArena/src/Interface/AutomapUiView.cpp @@ -105,7 +105,7 @@ const Color &AutomapUiView::getPixelColor(const VoxelTraitsDefinition &floorDef, } else { - const TransitionType transitionType = transitionDef->getType(); + const TransitionType transitionType = transitionDef->type; if ((transitionType == TransitionType::CityGate) || (transitionType == TransitionType::EnterInterior) || (transitionType == TransitionType::ExitInterior)) @@ -114,7 +114,7 @@ const Color &AutomapUiView::getPixelColor(const VoxelTraitsDefinition &floorDef, } else if (transitionType == TransitionType::LevelChange) { - const TransitionDefinition::LevelChangeDef &levelChangeDef = transitionDef->getLevelChange(); + const LevelChangeTransitionDefinition &levelChangeDef = transitionDef->levelChange; return levelChangeDef.isLevelUp ? AutomapUiView::ColorLevelUp : AutomapUiView::ColorLevelDown; } else @@ -219,7 +219,7 @@ const Color &AutomapUiView::getWildPixelColor(const VoxelTraitsDefinition &floor } else { - const TransitionType transitionType = transitionDef->getType(); + const TransitionType transitionType = transitionDef->type; if ((transitionType == TransitionType::CityGate) || (transitionType == TransitionType::EnterInterior) || (transitionType == TransitionType::ExitInterior)) @@ -232,7 +232,7 @@ const Color &AutomapUiView::getWildPixelColor(const VoxelTraitsDefinition &floor } else if (transitionType == TransitionType::LevelChange) { - const TransitionDefinition::LevelChangeDef &levelChangeDef = transitionDef->getLevelChange(); + const LevelChangeTransitionDefinition &levelChangeDef = transitionDef->levelChange; return levelChangeDef.isLevelUp ? AutomapUiView::ColorLevelUp : AutomapUiView::ColorLevelDown; } else diff --git a/OpenTESArena/src/Interface/AutomapUiView.h b/OpenTESArena/src/Interface/AutomapUiView.h index a34872680..081eec0b1 100644 --- a/OpenTESArena/src/Interface/AutomapUiView.h +++ b/OpenTESArena/src/Interface/AutomapUiView.h @@ -22,11 +22,11 @@ class GameState; class Renderer; class Texture; -class TransitionDefinition; class VoxelChunkManager; enum class CardinalDirectionName; +struct TransitionDefinition; struct VoxelTraitsDefinition; namespace AutomapUiView diff --git a/OpenTESArena/src/Player/PlayerLogicController.cpp b/OpenTESArena/src/Player/PlayerLogicController.cpp index 9d3f7f4b1..cf66835a9 100644 --- a/OpenTESArena/src/Player/PlayerLogicController.cpp +++ b/OpenTESArena/src/Player/PlayerLogicController.cpp @@ -630,7 +630,7 @@ void PlayerLogicController::handleScreenToWorldInteraction(Game &game, const Int if (chunk.tryGetTransitionDefID(voxel.x, voxel.y, voxel.z, &transitionDefID)) { const TransitionDefinition &transitionDef = chunk.getTransitionDef(transitionDefID); - if (transitionDef.getType() != TransitionType::LevelChange) + if (transitionDef.type != TransitionType::LevelChange) { MapLogicController::handleMapTransition(game, hit, transitionDef); } diff --git a/OpenTESArena/src/Voxels/VoxelChunkManager.cpp b/OpenTESArena/src/Voxels/VoxelChunkManager.cpp index 3990562e4..543c00b98 100644 --- a/OpenTESArena/src/Voxels/VoxelChunkManager.cpp +++ b/OpenTESArena/src/Voxels/VoxelChunkManager.cpp @@ -308,14 +308,14 @@ void VoxelChunkManager::populateWildChunkBuildingNames(VoxelChunk &chunk, } const TransitionDefinition &transitionDef = chunk.getTransitionDef(transitionDefID); - if (transitionDef.getType() != TransitionType::EnterInterior) + if (transitionDef.type != TransitionType::EnterInterior) { continue; } - const TransitionDefinition::InteriorEntranceDef &interiorEntranceDef = transitionDef.getInteriorEntrance(); + const InteriorEntranceTransitionDefinition &interiorEntranceDef = transitionDef.interiorEntrance; const MapGeneration::InteriorGenInfo &interiorGenInfo = interiorEntranceDef.interiorGenInfo; - const ArenaTypes::InteriorType interiorType = interiorGenInfo.getInteriorType(); + const ArenaTypes::InteriorType interiorType = interiorGenInfo.interiorType; LevelVoxelBuildingNameID buildingNameID; if (!buildingNameInfo.tryGetBuildingNameID(interiorType, &buildingNameID)) diff --git a/OpenTESArena/src/World/MapGeneration.cpp b/OpenTESArena/src/World/MapGeneration.cpp index 8c33c57fd..4eac7de58 100644 --- a/OpenTESArena/src/World/MapGeneration.cpp +++ b/OpenTESArena/src/World/MapGeneration.cpp @@ -1758,16 +1758,16 @@ namespace MapGeneration } const TransitionDefinition &transitionDef = outLevelInfoDef->getTransitionDef(*transitionDefID); - const TransitionType transitionType = transitionDef.getType(); + const TransitionType transitionType = transitionDef.type; if (transitionType != TransitionType::EnterInterior) { // Not a transition to an interior. return std::nullopt; } - const auto &interiorEntranceDef = transitionDef.getInteriorEntrance(); + const InteriorEntranceTransitionDefinition &interiorEntranceDef = transitionDef.interiorEntrance; const InteriorGenInfo &interiorGenInfo = interiorEntranceDef.interiorGenInfo; - return interiorGenInfo.getInteriorType(); + return interiorGenInfo.interiorType; }; // Lambda for looping through main-floor voxels and generating names for *MENU blocks that @@ -2057,16 +2057,16 @@ namespace MapGeneration { const LevelTransitionPlacementDefinition &placementDef = levelDef.getTransitionPlacementDef(i); const TransitionDefinition &transitionDef = outLevelInfoDef->getTransitionDef(placementDef.id); - const TransitionType transitionType = transitionDef.getType(); + const TransitionType transitionType = transitionDef.type; if (transitionType != TransitionType::EnterInterior) { // Not a transition to an interior. continue; } - const auto &interiorEntranceDef = transitionDef.getInteriorEntrance(); + const InteriorEntranceTransitionDefinition &interiorEntranceDef = transitionDef.interiorEntrance; const InteriorGenInfo &interiorGenInfo = interiorEntranceDef.interiorGenInfo; - if (interiorGenInfo.getInteriorType() != interiorType) + if (interiorGenInfo.interiorType != interiorType) { // Not the interior we're generating a name for. continue; @@ -2141,31 +2141,17 @@ MapGeneration::InteriorGenInfo::InteriorGenInfo() void MapGeneration::InteriorGenInfo::initPrefab(const std::string &mifName, ArenaTypes::InteriorType interiorType, const std::optional &rulerIsMale) { this->type = InteriorGenType::Prefab; + this->interiorType = interiorType; this->prefab.init(mifName, interiorType, rulerIsMale); } void MapGeneration::InteriorGenInfo::initDungeon(const LocationDungeonDefinition &dungeonDef, bool isArtifactDungeon) { this->type = InteriorGenType::Dungeon; + this->interiorType = ArenaTypes::InteriorType::Dungeon; this->dungeon.init(dungeonDef, isArtifactDungeon); } -ArenaTypes::InteriorType MapGeneration::InteriorGenInfo::getInteriorType() const -{ - if (this->type == InteriorGenType::Prefab) - { - return this->prefab.interiorType; - } - else if (this->type == InteriorGenType::Dungeon) - { - return ArenaTypes::InteriorType::Dungeon; - } - else - { - DebugUnhandledReturnMsg(ArenaTypes::InteriorType, std::to_string(static_cast(this->type))); - } -} - void MapGeneration::CityGenInfo::init(std::string &&mifName, std::string &&cityTypeName, ArenaTypes::CityType cityType, uint32_t citySeed, uint32_t rulerSeed, int raceID, bool isPremade, bool coastal, bool rulerIsMale, bool palaceIsMainQuestDungeon, Buffer &&reservedBlocks, diff --git a/OpenTESArena/src/World/MapGeneration.h b/OpenTESArena/src/World/MapGeneration.h index 05f9aef5c..27baf838c 100644 --- a/OpenTESArena/src/World/MapGeneration.h +++ b/OpenTESArena/src/World/MapGeneration.h @@ -62,6 +62,7 @@ namespace MapGeneration struct InteriorGenInfo { InteriorGenType type; + ArenaTypes::InteriorType interiorType; InteriorPrefabGenInfo prefab; InteriorDungeonGenInfo dungeon; @@ -69,8 +70,6 @@ namespace MapGeneration void initPrefab(const std::string &mifName, ArenaTypes::InteriorType interiorType, const std::optional &rulerIsMale); void initDungeon(const LocationDungeonDefinition &dungeonDef, bool isArtifactDungeon); - - ArenaTypes::InteriorType getInteriorType() const; }; // Input: 1 .MIF + 1 weather .INF diff --git a/OpenTESArena/src/World/MapLogicController.cpp b/OpenTESArena/src/World/MapLogicController.cpp index 9967ee387..ea9f6f40d 100644 --- a/OpenTESArena/src/World/MapLogicController.cpp +++ b/OpenTESArena/src/World/MapLogicController.cpp @@ -108,7 +108,7 @@ void MapLogicController::handleTriggers(Game &game, const CoordInt3 &coord, Text void MapLogicController::handleMapTransition(Game &game, const RayCastHit &hit, const TransitionDefinition &transitionDef) { - const TransitionType transitionType = transitionDef.getType(); + const TransitionType transitionType = transitionDef.type; DebugAssert(transitionType != TransitionType::LevelChange); DebugAssert(hit.type == RayCastHitType::Voxel); @@ -235,13 +235,13 @@ void MapLogicController::handleMapTransition(Game &game, const RayCastHit &hit, return hitCoord + delta; }(); - const TransitionDefinition::InteriorEntranceDef &interiorEntranceDef = transitionDef.getInteriorEntrance(); + const InteriorEntranceTransitionDefinition &interiorEntranceDef = transitionDef.interiorEntrance; const MapGeneration::InteriorGenInfo &interiorGenInfo = interiorEntranceDef.interiorGenInfo; MapDefinition mapDefinition; if (!mapDefinition.initInterior(interiorGenInfo, textureManager)) { - DebugLogError("Couldn't init MapDefinition for interior type " + std::to_string(static_cast(interiorGenInfo.getInteriorType())) + "."); + DebugLogError("Couldn't init MapDefinition for interior type " + std::to_string(static_cast(interiorGenInfo.interiorType)) + "."); return; } @@ -592,11 +592,11 @@ void MapLogicController::handleLevelTransition(Game &game, const CoordInt3 &play }; // See if it's a level up or level down transition. Ignore other transition types. - if (transitionDef.getType() == TransitionType::LevelChange) + if (transitionDef.type == TransitionType::LevelChange) { const int activeLevelIndex = gameState.getActiveLevelIndex(); const int levelCount = interiorMapDef.getLevels().getCount(); - const TransitionDefinition::LevelChangeDef &levelChangeDef = transitionDef.getLevelChange(); + const LevelChangeTransitionDefinition &levelChangeDef = transitionDef.levelChange; if (levelChangeDef.isLevelUp) { // Level up transition. If the custom function has a target, call it and reset it (necessary diff --git a/OpenTESArena/src/World/MapLogicController.h b/OpenTESArena/src/World/MapLogicController.h index 5effe21b8..5333a917c 100644 --- a/OpenTESArena/src/World/MapLogicController.h +++ b/OpenTESArena/src/World/MapLogicController.h @@ -5,9 +5,9 @@ class Game; class TextBox; -class TransitionDefinition; struct RayCastHit; +struct TransitionDefinition; namespace MapLogicController { diff --git a/OpenTESArena/src/World/TransitionDefinition.cpp b/OpenTESArena/src/World/TransitionDefinition.cpp index 7325c40bb..848aaeb25 100644 --- a/OpenTESArena/src/World/TransitionDefinition.cpp +++ b/OpenTESArena/src/World/TransitionDefinition.cpp @@ -2,12 +2,12 @@ #include "components/debug/Debug.h" -void TransitionDefinition::InteriorEntranceDef::init(MapGeneration::InteriorGenInfo &&interiorGenInfo) +void InteriorEntranceTransitionDefinition::init(MapGeneration::InteriorGenInfo &&interiorGenInfo) { this->interiorGenInfo = std::move(interiorGenInfo); } -void TransitionDefinition::LevelChangeDef::init(bool isLevelUp) +void LevelChangeTransitionDefinition::init(bool isLevelUp) { this->isLevelUp = isLevelUp; } @@ -17,46 +17,24 @@ TransitionDefinition::TransitionDefinition() this->type = static_cast(-1); } -void TransitionDefinition::init(TransitionType type) -{ - this->type = type; -} - void TransitionDefinition::initCityGate() { - this->init(TransitionType::CityGate); + this->type = TransitionType::CityGate; } void TransitionDefinition::initInteriorEntrance(MapGeneration::InteriorGenInfo &&interiorGenInfo) { - this->init(TransitionType::EnterInterior); + this->type = TransitionType::EnterInterior; this->interiorEntrance.init(std::move(interiorGenInfo)); } void TransitionDefinition::initInteriorExit() { - this->init(TransitionType::ExitInterior); + this->type = TransitionType::ExitInterior; } void TransitionDefinition::initLevelChange(bool isLevelUp) { - this->init(TransitionType::LevelChange); + this->type = TransitionType::LevelChange; this->levelChange.init(isLevelUp); } - -TransitionType TransitionDefinition::getType() const -{ - return this->type; -} - -const TransitionDefinition::InteriorEntranceDef &TransitionDefinition::getInteriorEntrance() const -{ - DebugAssert(this->type == TransitionType::EnterInterior); - return this->interiorEntrance; -} - -const TransitionDefinition::LevelChangeDef &TransitionDefinition::getLevelChange() const -{ - DebugAssert(this->type == TransitionType::LevelChange); - return this->levelChange; -} diff --git a/OpenTESArena/src/World/TransitionDefinition.h b/OpenTESArena/src/World/TransitionDefinition.h index 3cbc0b496..3503cfd34 100644 --- a/OpenTESArena/src/World/TransitionDefinition.h +++ b/OpenTESArena/src/World/TransitionDefinition.h @@ -4,40 +4,33 @@ #include "MapGeneration.h" #include "TransitionType.h" -// @todo: share with both voxels and entities; probably delete EntityDefinition variant of this class. -class TransitionDefinition +struct InteriorEntranceTransitionDefinition { -public: - struct InteriorEntranceDef - { - MapGeneration::InteriorGenInfo interiorGenInfo; + MapGeneration::InteriorGenInfo interiorGenInfo; + + void init(MapGeneration::InteriorGenInfo &&interiorGenInfo); +}; - void init(MapGeneration::InteriorGenInfo &&interiorGenInfo); - }; +struct LevelChangeTransitionDefinition +{ + bool isLevelUp; - struct LevelChangeDef - { - bool isLevelUp; + void init(bool isLevelUp); +}; - void init(bool isLevelUp); - }; -private: +// @todo: share with both voxels and entities; probably delete EntityDefinition variant of this class. +struct TransitionDefinition +{ TransitionType type; - InteriorEntranceDef interiorEntrance; - LevelChangeDef levelChange; + InteriorEntranceTransitionDefinition interiorEntrance; + LevelChangeTransitionDefinition levelChange; - void init(TransitionType type); -public: TransitionDefinition(); void initCityGate(); void initInteriorEntrance(MapGeneration::InteriorGenInfo &&interiorGenInfo); void initInteriorExit(); void initLevelChange(bool isLevelUp); - - TransitionType getType() const; - const InteriorEntranceDef &getInteriorEntrance() const; - const LevelChangeDef &getLevelChange() const; }; #endif