void VehiclePlacement::load(JsonObject &jo) { VehiclePlacement &placement = vplacements[vplacement_id(jo.get_string("id"))]; JsonArray locations = jo.get_array("locations"); while (locations.has_more()) { JsonObject jloc = locations.next_object(); placement.add(jmapgen_int(jloc, "x"), jmapgen_int(jloc, "y"), VehicleFacings(jloc, "facing")); } }
void VehicleFactory::load_vehicle_placement(JsonObject &jo) { const std::string placement_id = jo.get_string("id"); VehiclePlacement &placement = placements[placement_id]; JsonArray locations = jo.get_array("locations"); while (locations.has_more()) { JsonObject jloc = locations.next_object(); placement.add(jmapgen_int(jloc, "x"), jmapgen_int(jloc, "y"), VehicleFacings(jloc, "facing")); } }
VehicleFunction_json::VehicleFunction_json(JsonObject &jo) : vehicle(jo.get_string("vehicle")), number(jo, "number"), fuel(jo.get_int("fuel")), status(jo.get_int("status")) { if(jo.has_string("placement")) { placement = jo.get_string("placement"); } else { //location = std::make_unique<Vehicle_Location>(jmapgen_int(jo, "x"), jmapgen_int(jo, "y"), facings); // that would be better, but it won't exist until c++14, so for now we do this: VehicleFacings facings(jo, "facing"); location.reset(new VehicleLocation(jmapgen_int(jo, "x"), jmapgen_int(jo, "y"), facings)); } }