Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DisabledReason scoped enum #551

Merged
merged 2 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions OPHD/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ std::map<MineProductionRate, std::string> MINE_YIELD_TRANSLATION =

std::map<DisabledReason, std::string> DISABLED_REASON_TABLE =
{
{ DisabledReason::DISABLED_NONE, constants::STRUCTURE_DISABLED_NONE },

{ DisabledReason::DISABLED_CHAP, constants::STRUCTURE_DISABLED_CHAP },
{ DisabledReason::DISABLED_DISCONNECTED, constants::STRUCTURE_DISABLED_DISCONNECTED },
{ DisabledReason::DISABLED_ENERGY, constants::STRUCTURE_DISABLED_ENERGY },
{ DisabledReason::DISABLED_POPULATION, constants::STRUCTURE_DISABLED_POPULATION },
{ DisabledReason::DISABLED_REFINED_RESOURCES, constants::STRUCTURE_DISABLED_REFINED_RESOURCES },
{ DisabledReason::DISABLED_STRUCTURAL_INTEGRITY, constants::STRUCTURE_DISABLED_STRUCTURAL_INTEGRITY }
{ DisabledReason::None, constants::STRUCTURE_DISABLED_NONE },

{ DisabledReason::Chap, constants::STRUCTURE_DISABLED_CHAP },
{ DisabledReason::Disconnected, constants::STRUCTURE_DISABLED_DISCONNECTED },
{ DisabledReason::Energy, constants::STRUCTURE_DISABLED_ENERGY },
{ DisabledReason::Population, constants::STRUCTURE_DISABLED_POPULATION },
{ DisabledReason::RefinedResources, constants::STRUCTURE_DISABLED_REFINED_RESOURCES },
{ DisabledReason::StructuralIntegrity, constants::STRUCTURE_DISABLED_STRUCTURAL_INTEGRITY }
};


Expand Down
18 changes: 9 additions & 9 deletions OPHD/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ enum class MineProductionRate
/**
*
*/
enum DisabledReason
enum class DisabledReason
{
DISABLED_NONE, /**< Not Disabled, default reason. */

DISABLED_CHAP, /**< Requires atmosphere, no atmosphere available. */
DISABLED_DISCONNECTED, /**< Not connected to Command Center */
DISABLED_ENERGY, /**< Not enough Energy to operate. */
DISABLED_POPULATION, /**< Insufficient workers or scientists (or both) */
DISABLED_REFINED_RESOURCES, /**< Insufficient mined and refined resources */
DISABLED_STRUCTURAL_INTEGRITY /**< Structural integrity out of operating tolerances (damaged structure) */
None, /**< Not Disabled, default reason. */

Chap, /**< Requires atmosphere, no atmosphere available. */
Disconnected, /**< Not connected to Command Center */
Energy, /**< Not enough Energy to operate. */
Population, /**< Insufficient workers or scientists (or both) */
RefinedResources, /**< Insufficient mined and refined resources */
StructuralIntegrity /**< Structural integrity out of operating tolerances (damaged structure) */
};


Expand Down
10 changes: 5 additions & 5 deletions OPHD/StructureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ void StructureManager::updateStructures(ResourcePool& resourcePool, PopulationPo
// Connection Check
if (!structureConnected(structure) && !structure->selfSustained())
{
structure->disable(DisabledReason::DISABLED_DISCONNECTED);
structure->disable(DisabledReason::Disconnected);
continue;
}

// CHAP Check
if (structure->requiresCHAP() && !chapAvailable)
{
structure->disable(DisabledReason::DISABLED_CHAP);
structure->disable(DisabledReason::Chap);
continue;
}

Expand All @@ -166,7 +166,7 @@ void StructureManager::updateStructures(ResourcePool& resourcePool, PopulationPo
if (!popPool.enoughPopulationAvailable(Population::PersonRole::ROLE_WORKER, (*_populationRequired)[0]) ||
!popPool.enoughPopulationAvailable(Population::PersonRole::ROLE_SCIENTIST, (*_populationRequired)[1]))
{
structure->disable(DisabledReason::DISABLED_POPULATION);
structure->disable(DisabledReason::Population);
continue;
}
else
Expand All @@ -180,8 +180,8 @@ void StructureManager::updateStructures(ResourcePool& resourcePool, PopulationPo
if (!structure->isIdle()) //-V571
{
/// \fixme Ugly. Special case code specifically to determine if energy is the reason for a disabled structure.
if (structure->resourcesIn().energy() > resourcePool.energy()) { structure->disable(DisabledReason::DISABLED_ENERGY); }
else { structure->disable(DisabledReason::DISABLED_REFINED_RESOURCES); }
if (structure->resourcesIn().energy() > resourcePool.energy()) { structure->disable(DisabledReason::Energy); }
else { structure->disable(DisabledReason::RefinedResources); }
continue;
}
}
Expand Down
4 changes: 2 additions & 2 deletions OPHD/Things/Structures/Structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void Structure::enable()
sprite().resume();
sprite().color(NAS2D::Color::White);
state(StructureState::OPERATIONAL);
mDisabledReason = DisabledReason::DISABLED_NONE;
mDisabledReason = DisabledReason::None;
mIdleReason = IdleReason::IDLE_NONE;
}

Expand All @@ -117,7 +117,7 @@ void Structure::idle(IdleReason reason)

sprite().pause();
sprite().color(NAS2D::Color{255, 255, 255, 185});
mDisabledReason = DisabledReason::DISABLED_NONE;
mDisabledReason = DisabledReason::None;
mIdleReason = reason;
state(StructureState::IDLE);
}
Expand Down
2 changes: 1 addition & 1 deletion OPHD/Things/Structures/Structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class Structure: public Thing
ResourcePool mProductionPool; /**< Resource pool used for production. */
ResourcePool mStoragePool; /**< Resource storage pool. */

DisabledReason mDisabledReason = DisabledReason::DISABLED_NONE;
DisabledReason mDisabledReason = DisabledReason::None;
IdleReason mIdleReason = IdleReason::IDLE_NONE;

bool mRepairable = true; /**< Indicates whether or not the Structure can be repaired. Useful for forcing some Structures to die at the end of their life. */
Expand Down