Fix: Abort loading savegame if road vehicle is on invalid road type. (#10622)

This can happen if NewGRFs are missing so that engine or road type definitions are wrong.
This commit is contained in:
PeterN 2023-04-10 19:23:18 +01:00 committed by GitHub
parent ce24709576
commit ce046f6d17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -401,9 +401,11 @@ void AfterLoadVehicles(bool part_of_load)
rv->roadtype = Engine::Get(rv->engine_type)->u.road.roadtype;
rv->compatible_roadtypes = GetRoadTypeInfo(rv->roadtype)->powered_roadtypes;
RoadTramType rtt = GetRoadTramType(rv->roadtype);
for (RoadVehicle *u = rv; u != nullptr; u = u->Next()) {
u->roadtype = rv->roadtype;
u->compatible_roadtypes = rv->compatible_roadtypes;
if (GetRoadType(u->tile, rtt) == INVALID_ROADTYPE) SlErrorCorrupt("Road vehicle on invalid road type");
}
RoadVehUpdateCache(rv);