message: Add guards against potentially dereferencing null pointers when reading xml nodes for robot command center
diff: @@ -440,16 +440,14 @@ void MapViewState::readStructures(Xml::XmlElement* element)
  factory.productionComplete().connect(this, &MapViewState::factoryProductionComplete);
  }
  - /**
  - * This is a little fragile in that it assumes that everything it expects is
  - * encoded in the XML savegame. While there are some basic guards in place when
  - * loading the code doesn't do any checking for garbage for the sake of brevity.
  - */
  if (structure.isRobotCommand())
  {
  - auto& rcc = *static_cast<RobotCommand*>(&structure);
  - XmlAttribute* robotsAttribute = structureNode->firstChildElement("robots")->firstAttribute();
  -
  + auto robotsElement = structureNode->firstChildElement("robots");
  + if (robotsElement)
  + {
  + auto robotsAttribute = robotsElement->firstAttribute();
  + if (robotsAttribute)
  + {
  for (const auto& string : NAS2D::split(robotsAttribute->value(), ','))
  {
  const auto robotId = NAS2D::stringTo<int>(string);
  @@ -457,12 +455,14 @@ void MapViewState::readStructures(Xml::XmlElement* element)
  {
  if (robot->id() == robotId)
  {
  - rcc.addRobot(robot);
  + static_cast<RobotCommand*>(&structure)->addRobot(robot);
  break;
  }
  }
  }
  }
  + }
  + }
  structure.populationAvailable()[0] = pop0;
  structure.populationAvailable()[1] = pop1;
  