throw if modules are referenced that don't exist in config
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -102,7 +103,7 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
for (const PlacedModule& pm : modules)
|
||||
{
|
||||
const ModuleDef* modDef = findModuleDef(pm.moduleId);
|
||||
if (!modDef) { continue; }
|
||||
if (!modDef) { throw std::runtime_error("unknown module id '" + pm.moduleId + "'"); }
|
||||
|
||||
const double mx = static_cast<double>(modDef->playerProductionLevel);
|
||||
|
||||
@@ -173,7 +174,7 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
for (const PlacedModule& pm : modules)
|
||||
{
|
||||
const ModuleDef* modDef = findModuleDef(pm.moduleId);
|
||||
if (!modDef) { continue; }
|
||||
if (!modDef) { throw std::runtime_error("unknown module id '" + pm.moduleId + "'"); }
|
||||
|
||||
const double mx = static_cast<double>(modDef->playerProductionLevel);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "ShipStatsCalculator.h"
|
||||
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
#include "DynamicBodyComponent.h"
|
||||
@@ -67,7 +68,7 @@ ShipStats calculateShipStats(const GameConfig& config,
|
||||
for (const PlacedModule& pm : modules)
|
||||
{
|
||||
const ModuleDef* def = findModuleDef(pm.moduleId);
|
||||
if (!def) { continue; }
|
||||
if (!def) { throw std::runtime_error("unknown module id '" + pm.moduleId + "'"); }
|
||||
|
||||
const double mx = static_cast<double>(def->playerProductionLevel);
|
||||
|
||||
@@ -105,7 +106,7 @@ ShipStats calculateShipStats(const GameConfig& config,
|
||||
for (const PlacedModule& pm : modules)
|
||||
{
|
||||
const ModuleDef* def = findModuleDef(pm.moduleId);
|
||||
if (!def) { continue; }
|
||||
if (!def) { throw std::runtime_error("unknown module id '" + pm.moduleId + "'"); }
|
||||
|
||||
const double mx = static_cast<double>(def->playerProductionLevel);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user