MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / LoadOldVehicleUnion

Function LoadOldVehicleUnion

src/saveload/oldloader_sl.cpp:1132–1159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1130};
1131
1132static bool LoadOldVehicleUnion(LoadgameState &ls, int)
1133{
1134 Vehicle *v = Vehicle::GetIfValid(_current_vehicle_id);
1135 uint temp = ls.total_read;
1136 bool res;
1137
1138 if (v == nullptr) {
1139 res = LoadChunk(ls, nullptr, vehicle_empty_chunk);
1140 } else {
1141 switch (v->type) {
1142 default: SlErrorCorrupt("Invalid vehicle type");
1143 case VEH_TRAIN : res = LoadChunk(ls, v, vehicle_train_chunk); break;
1144 case VEH_ROAD : res = LoadChunk(ls, v, vehicle_road_chunk); break;
1145 case VEH_SHIP : res = LoadChunk(ls, v, vehicle_ship_chunk); break;
1146 case VEH_AIRCRAFT: res = LoadChunk(ls, v, vehicle_air_chunk); break;
1147 case VEH_EFFECT : res = LoadChunk(ls, v, vehicle_effect_chunk); break;
1148 case VEH_DISASTER: res = LoadChunk(ls, v, vehicle_disaster_chunk); break;
1149 }
1150 }
1151
1152 /* This chunk size should always be 10 bytes */
1153 if (ls.total_read - temp != 10) {
1154 Debug(oldloader, 0, "Assert failed in VehicleUnion: invalid chunk size");
1155 return false;
1156 }
1157
1158 return res;
1159}
1160
1161static uint16_t _cargo_count;
1162

Callers

nothing calls this directly

Calls 2

LoadChunkFunction · 0.85
SlErrorCorruptFunction · 0.85

Tested by

no test coverage detected