From e7bd1f12770683103571536cd38bb5152e2e4b2b Mon Sep 17 00:00:00 2001 From: Siocnarff Date: Thu, 5 Nov 2020 12:00:18 +0200 Subject: [PATCH] add check if null to ComponentSimulator --- src/eng/buildings/ComponentSimulator.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/eng/buildings/ComponentSimulator.cpp b/src/eng/buildings/ComponentSimulator.cpp index 9fe20fe..4485e48 100644 --- a/src/eng/buildings/ComponentSimulator.cpp +++ b/src/eng/buildings/ComponentSimulator.cpp @@ -3,9 +3,6 @@ using namespace eng; void ComponentSimulator::testComponent(Component* component) { - if (!component) { - return; - } int label = component->quality; label += (rand()%5)-2; if (label > 100) { @@ -21,7 +18,9 @@ void ComponentSimulator::testComponent(Component* component) { void ComponentSimulator::testComponents(Car* car) { for (Component* component : car->components) { - testComponent(component); + if (component) { + testComponent(component); + } } pr::Doc::detail("Components of car "); pr::Doc::detail(std::to_string(car->getId()));