From a3e6e113fe1f5a00d2d62ddac207a3bc12dec97c Mon Sep 17 00:00:00 2001 From: michi_cc Date: Fri, 4 Nov 2011 15:04:29 +0000 Subject: (svn r23112) -Codechange: Check if vehicle chain lengths stays constant when auto-refitting. --- src/vehicle.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/vehicle.cpp') diff --git a/src/vehicle.cpp b/src/vehicle.cpp index e15638f69..d990d3d55 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -52,6 +52,7 @@ #include "bridge_map.h" #include "tunnel_map.h" #include "depot_map.h" +#include "gamelog.h" #include "table/strings.h" @@ -233,6 +234,22 @@ void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRF DEBUG(grf, 0, "%s", buffer + 3); } +/** + * Logs a bug in GRF and shows a warning message if this + * is for the first time this happened. + * @param u first vehicle of chain + */ +void VehicleLengthChanged(const Vehicle *u) +{ + /* show a warning once for each engine in whole game and once for each GRF after each game load */ + const Engine *engine = u->GetEngine(); + uint32 grfid = engine->grf_prop.grffile->grfid; + GRFConfig *grfconfig = GetGRFConfig(grfid); + if (GamelogGRFBugReverse(grfid, engine->grf_prop.local_id) || !HasBit(grfconfig->grf_bugs, GBUG_VEH_LENGTH)) { + ShowNewGrfVehicleError(u->engine_type, STR_NEWGRF_BROKEN, STR_NEWGRF_BROKEN_VEHICLE_LENGTH, GBUG_VEH_LENGTH, true); + } +} + /** * Vehicle constructor. * @param type Type of the new vehicle. -- cgit v1.2.3-54-g00ecf