Skip to content

Commit

Permalink
add check if null to ComponentSimulator
Browse files Browse the repository at this point in the history
  • Loading branch information
Siocnarff committed Nov 5, 2020
1 parent e9605de commit e7bd1f1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/eng/buildings/ComponentSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()));
Expand Down

0 comments on commit e7bd1f1

Please sign in to comment.