summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-08 18:25:51 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-08 18:25:51 +0000
commitce2104ed4783138596dfc56a0829222fccdf5b34 (patch)
tree3359d19b723ceaeb39e4f388d41c2ce17de26f60 /src
parent814f47a3cc63934c2f111ec87a3d84bc2b4524c4 (diff)
downloadopenttd-ce2104ed4783138596dfc56a0829222fccdf5b34.tar.xz
(svn r11784) -Codechange: set up initial engine data in one place
Diffstat (limited to 'src')
-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);