summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/engine.cpp28
-rw-r--r--src/engine.h2
-rw-r--r--src/misc.cpp2
-rw-r--r--src/newgrf.cpp9
-rw-r--r--src/oldloader.cpp2
5 files changed, 20 insertions, 23 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 856c2c25c..102b64316 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -38,6 +38,24 @@ enum {
};
+void SetupEngines()
+{
+ /* Copy original static engine data */
+ memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info));
+ memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info));
+ memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info));
+ memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info));
+ memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info));
+
+ /* Add type to engines */
+ Engine* e = _engines;
+ do e->type = VEH_TRAIN; while (++e < &_engines[ROAD_ENGINES_INDEX]);
+ do e->type = VEH_ROAD; while (++e < &_engines[SHIP_ENGINES_INDEX]);
+ do e->type = VEH_SHIP; while (++e < &_engines[AIRCRAFT_ENGINES_INDEX]);
+ do e->type = VEH_AIRCRAFT; while (++e < &_engines[TOTAL_NUM_ENGINES]);
+}
+
+
void ShowEnginePreviewWindow(EngineID engine);
void DeleteCustomEngineNames()
@@ -108,16 +126,6 @@ static void CalcEngineReliability(Engine *e)
InvalidateWindowClasses(WC_REPLACE_VEHICLE);
}
-void AddTypeToEngines()
-{
- Engine* e = _engines;
-
- do e->type = VEH_TRAIN; while (++e < &_engines[ROAD_ENGINES_INDEX]);
- do e->type = VEH_ROAD; while (++e < &_engines[SHIP_ENGINES_INDEX]);
- do e->type = VEH_SHIP; while (++e < &_engines[AIRCRAFT_ENGINES_INDEX]);
- do e->type = VEH_AIRCRAFT; while (++e < &_engines[TOTAL_NUM_ENGINES]);
-}
-
void StartupEngines()
{
Engine *e;
diff --git a/src/engine.h b/src/engine.h
index ef9d608fc..58f90289a 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -153,7 +153,7 @@ enum {
static const EngineID INVALID_ENGINE = 0xFFFF;
-void AddTypeToEngines();
+void SetupEngines();
void StartupEngines();
diff --git a/src/misc.cpp b/src/misc.cpp
index 56347723f..6d52a47c1 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -56,8 +56,6 @@ void InitializeGame(int mode, uint size_x, uint size_y)
{
AllocateMap(size_x, size_y);
- AddTypeToEngines(); // make sure all engines have a type
-
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
_pause_game = 0;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 2b24efff6..c47a74452 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -5063,11 +5063,7 @@ static void ResetNewGRFData()
CleanUpGRFTownNames();
/* Copy/reset original engine info data */
- memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info));
- memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info));
- memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info));
- memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info));
- memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info));
+ SetupEngines();
/* Copy/reset original bridge info data
* First, free sprite table data */
@@ -5124,9 +5120,6 @@ static void ResetNewGRFData()
/* Reset NewGRF errors. */
ResetNewGRFErrors();
- /* Add engine type to engine data. This is needed for the refit precalculation. */
- AddTypeToEngines();
-
/* Set up the default cargo types */
SetupCargoForClimate(_opt.landscape);
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 68c5dfb9c..3d5b5872a 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -1631,8 +1631,6 @@ static bool LoadOldMain(LoadgameState *ls)
FixOldStations();
FixOldVehicles();
- AddTypeToEngines();
-
/* We have a new difficulty setting */
_opt.diff.town_council_tolerance = Clamp(_opt.diff_level, 0, 2);