diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -648,10 +648,6 @@
>
-
-
@@ -692,10 +688,6 @@
>
-
-
@@ -1044,6 +1036,10 @@
>
+
+
@@ -1360,10 +1356,6 @@
>
-
-
@@ -2009,6 +2001,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
@@ -689,10 +685,6 @@
>
-
-
@@ -1041,6 +1033,10 @@
>
+
+
@@ -1357,10 +1353,6 @@
>
-
-
@@ -2006,6 +1998,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
index].state](c);
}
-
-
-static const SaveLoad _company_ai_desc[] = {
- SLE_VAR(CompanyAI, state, SLE_UINT8),
- SLE_VAR(CompanyAI, tick, SLE_UINT8),
- SLE_CONDVAR(CompanyAI, state_counter, SLE_FILE_U16 | SLE_VAR_U32, 0, 12),
- SLE_CONDVAR(CompanyAI, state_counter, SLE_UINT32, 13, SL_MAX_VERSION),
- SLE_VAR(CompanyAI, timeout_counter, SLE_UINT16),
-
- SLE_VAR(CompanyAI, state_mode, SLE_UINT8),
- SLE_VAR(CompanyAI, banned_tile_count, SLE_UINT8),
- SLE_VAR(CompanyAI, railtype_to_use, SLE_UINT8),
-
- SLE_VAR(CompanyAI, cargo_type, SLE_UINT8),
- SLE_VAR(CompanyAI, num_wagons, SLE_UINT8),
- SLE_VAR(CompanyAI, build_kind, SLE_UINT8),
- SLE_VAR(CompanyAI, num_build_rec, SLE_UINT8),
- SLE_VAR(CompanyAI, num_loco_to_build, SLE_UINT8),
- SLE_VAR(CompanyAI, num_want_fullload, SLE_UINT8),
-
- SLE_VAR(CompanyAI, route_type_mask, SLE_UINT8),
-
- SLE_CONDVAR(CompanyAI, start_tile_a, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(CompanyAI, start_tile_a, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(CompanyAI, cur_tile_a, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(CompanyAI, cur_tile_a, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_VAR(CompanyAI, start_dir_a, SLE_UINT8),
- SLE_VAR(CompanyAI, cur_dir_a, SLE_UINT8),
-
- SLE_CONDVAR(CompanyAI, start_tile_b, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(CompanyAI, start_tile_b, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(CompanyAI, cur_tile_b, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(CompanyAI, cur_tile_b, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_VAR(CompanyAI, start_dir_b, SLE_UINT8),
- SLE_VAR(CompanyAI, cur_dir_b, SLE_UINT8),
-
- SLE_REF(CompanyAI, cur_veh, REF_VEHICLE),
-
- SLE_ARR(CompanyAI, wagon_list, SLE_UINT16, 9),
- SLE_ARR(CompanyAI, order_list_blocks, SLE_UINT8, 20),
- SLE_ARR(CompanyAI, banned_tiles, SLE_UINT16, 16),
-
- SLE_CONDNULL(64, 2, SL_MAX_VERSION),
- SLE_END()
-};
-
-static const SaveLoad _company_ai_build_rec_desc[] = {
- SLE_CONDVAR(AiBuildRec, spec_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(AiBuildRec, spec_tile, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(AiBuildRec, use_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(AiBuildRec, use_tile, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_VAR(AiBuildRec, rand_rng, SLE_UINT8),
- SLE_VAR(AiBuildRec, cur_building_rule, SLE_UINT8),
- SLE_VAR(AiBuildRec, unk6, SLE_UINT8),
- SLE_VAR(AiBuildRec, unk7, SLE_UINT8),
- SLE_VAR(AiBuildRec, buildcmd_a, SLE_UINT8),
- SLE_VAR(AiBuildRec, buildcmd_b, SLE_UINT8),
- SLE_VAR(AiBuildRec, direction, SLE_UINT8),
- SLE_VAR(AiBuildRec, cargo, SLE_UINT8),
- SLE_END()
-};
-
-
-void SaveLoad_AI(CompanyID company)
-{
- CompanyAI *cai = &_companies_ai[company];
- SlObject(cai, _company_ai_desc);
- for (int i = 0; i != cai->num_build_rec; i++) {
- SlObject(&cai->src + i, _company_ai_build_rec_desc);
- }
-}
diff --git a/src/ai/default/default.h b/src/ai/default/default.h
--- a/src/ai/default/default.h
+++ b/src/ai/default/default.h
@@ -10,7 +10,6 @@
#include "../../rail_type.h"
void AiDoGameLoop(Company *c);
-void SaveLoad_AI(CompanyID company);
struct AiBuildRec {
TileIndex spec_tile;
diff --git a/src/ai/trolly/trolly.h b/src/ai/trolly/trolly.h
--- a/src/ai/trolly/trolly.h
+++ b/src/ai/trolly/trolly.h
@@ -10,6 +10,7 @@
#include "../../vehicle_type.h"
#include "../../date_type.h"
#include "../../engine_type.h"
+#include "../../direction_type.h"
/*
* These defines can be altered to change the behavoir of the AI
diff --git a/src/aircraft.h b/src/aircraft.h
--- a/src/aircraft.h
+++ b/src/aircraft.h
@@ -99,6 +99,11 @@ void UpdateAirplanesOnNewStation(const S
*/
void UpdateAircraftCache(Vehicle *v);
+void AircraftLeaveHangar(Vehicle *v);
+void AircraftNextAirportPos_and_Order(Vehicle *v);
+void SetAircraftPosition(Vehicle *v, int x, int y, int z);
+byte GetAircraftFlyingAltitude(const Vehicle *v);
+
/**
* This class 'wraps' Vehicle; you do not actually instantiate this class.
* You create a Vehicle using AllocateVehicle, so it is added to the pool
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -82,9 +82,6 @@ static bool AirportFindFreeTerminal(Vehi
static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *apc);
static void CrashAirplane(Vehicle *v);
-void AircraftNextAirportPos_and_Order(Vehicle *v);
-static byte GetAircraftFlyingAltitude(const Vehicle *v);
-
static const SpriteID _aircraft_sprite[] = {
0x0EB5, 0x0EBD, 0x0EC5, 0x0ECD,
0x0ED5, 0x0EDD, 0x0E9D, 0x0EA5,
@@ -727,7 +724,7 @@ static void HelicopterTickHandler(Vehicl
EndVehicleMove(u);
}
-static void SetAircraftPosition(Vehicle *v, int x, int y, int z)
+void SetAircraftPosition(Vehicle *v, int x, int y, int z)
{
v->x_pos = x;
v->y_pos = y;
@@ -883,7 +880,7 @@ static int UpdateAircraftSpeed(Vehicle *
* @param v The vehicle. Should be an aircraft
* @returns Altitude in pixel units
*/
-static byte GetAircraftFlyingAltitude(const Vehicle *v)
+byte GetAircraftFlyingAltitude(const Vehicle *v)
{
/* Make sure Aircraft fly no lower so that they don't conduct
* CFITs (controlled flight into terrain)
@@ -1433,7 +1430,7 @@ void AircraftNextAirportPos_and_Order(Ve
v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, apc);
}
-static void AircraftLeaveHangar(Vehicle *v)
+void AircraftLeaveHangar(Vehicle *v)
{
v->cur_speed = 0;
v->subspeed = 0;
@@ -2096,42 +2093,6 @@ Station *GetTargetAirportIfValid(const V
return st->airport_tile == INVALID_TILE ? NULL : st;
}
-/** need to be called to load aircraft from old version */
-void UpdateOldAircraft()
-{
- /* set airport_flags to 0 for all airports just to be sure */
- Station *st;
- FOR_ALL_STATIONS(st) {
- st->airport_flags = 0; // reset airport
- }
-
- Vehicle *v_oldstyle;
- FOR_ALL_VEHICLES(v_oldstyle) {
- /* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor)
- * skip those */
- if (v_oldstyle->type == VEH_AIRCRAFT && IsNormalAircraft(v_oldstyle)) {
- /* airplane in terminal stopped doesn't hurt anyone, so goto next */
- if (v_oldstyle->vehstatus & VS_STOPPED && v_oldstyle->u.air.state == 0) {
- v_oldstyle->u.air.state = HANGAR;
- continue;
- }
-
- AircraftLeaveHangar(v_oldstyle); // make airplane visible if it was in a depot for example
- v_oldstyle->vehstatus &= ~VS_STOPPED; // make airplane moving
- v_oldstyle->u.air.state = FLYING;
- AircraftNextAirportPos_and_Order(v_oldstyle); // move it to the entry point of the airport
- GetNewVehiclePosResult gp = GetNewVehiclePos(v_oldstyle);
- v_oldstyle->tile = 0; // aircraft in air is tile=0
-
- /* correct speed of helicopter-rotors */
- if (v_oldstyle->subtype == AIR_HELICOPTER) v_oldstyle->Next()->Next()->cur_speed = 32;
-
- /* set new position x,y,z */
- SetAircraftPosition(v_oldstyle, gp.x, gp.y, GetAircraftFlyingAltitude(v_oldstyle));
- }
- }
-}
-
/**
* Updates the status of the Aircraft heading or in the station
* @param st Station been updated
diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp
--- a/src/animated_tile.cpp
+++ b/src/animated_tile.cpp
@@ -4,7 +4,6 @@
#include "stdafx.h"
#include "openttd.h"
-#include "saveload.h"
#include "landscape.h"
#include "core/alloc_func.hpp"
#include "functions.h"
@@ -14,7 +13,7 @@ TileIndex *_animated_tile_list = NULL;
/** The number of animated tiles in the current state. */
uint _animated_tile_count = 0;
/** The number of slots for animated tiles allocated currently. */
-static uint _animated_tile_allocated = 0;
+uint _animated_tile_allocated = 0;
/**
* Removes the given tile from the animated tile table.
@@ -90,46 +89,3 @@ void InitializeAnimatedTiles()
_animated_tile_count = 0;
_animated_tile_allocated = 256;
}
-
-/**
- * Save the ANIT chunk.
- */
-static void Save_ANIT()
-{
- SlSetLength(_animated_tile_count * sizeof(*_animated_tile_list));
- SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32);
-}
-
-/**
- * Load the ANIT chunk; the chunk containing the animated tiles.
- */
-static void Load_ANIT()
-{
- /* Before version 80 we did NOT have a variable length animated tile table */
- if (CheckSavegameVersion(80)) {
- /* In pre version 6, we has 16bit per tile, now we have 32bit per tile, convert it ;) */
- SlArray(_animated_tile_list, 256, CheckSavegameVersion(6) ? (SLE_FILE_U16 | SLE_VAR_U32) : SLE_UINT32);
-
- for (_animated_tile_count = 0; _animated_tile_count < 256; _animated_tile_count++) {
- if (_animated_tile_list[_animated_tile_count] == 0) break;
- }
- return;
- }
-
- _animated_tile_count = (uint)SlGetFieldLength() / sizeof(*_animated_tile_list);
-
- /* Determine a nice rounded size for the amount of allocated tiles */
- _animated_tile_allocated = 256;
- while (_animated_tile_allocated < _animated_tile_count) _animated_tile_allocated *= 2;
-
- _animated_tile_list = ReallocT(_animated_tile_list, _animated_tile_allocated);
- SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32);
-}
-
-/**
- * "Definition" imported by the saveload code to be able to load and save
- * the animated tile table.
- */
-extern const ChunkHandler _animated_tile_chunk_handlers[] = {
- { 'ANIT', Save_ANIT, Load_ANIT, CH_RIFF | CH_LAST},
-};
diff --git a/src/autoreplace.cpp b/src/autoreplace.cpp
--- a/src/autoreplace.cpp
+++ b/src/autoreplace.cpp
@@ -6,7 +6,6 @@
#include "openttd.h"
#include "debug.h"
#include "command_func.h"
-#include "saveload.h"
#include "group.h"
#include "autoreplace_base.h"
#include "oldpool_func.h"
@@ -102,46 +101,6 @@ CommandCost RemoveEngineReplacement(Engi
return CMD_ERROR;
}
-static const SaveLoad _engine_renew_desc[] = {
- SLE_VAR(EngineRenew, from, SLE_UINT16),
- SLE_VAR(EngineRenew, to, SLE_UINT16),
-
- SLE_REF(EngineRenew, next, REF_ENGINE_RENEWS),
- SLE_CONDVAR(EngineRenew, group_id, SLE_UINT16, 60, SL_MAX_VERSION),
- SLE_END()
-};
-
-static void Save_ERNW()
-{
- EngineRenew *er;
-
- FOR_ALL_ENGINE_RENEWS(er) {
- SlSetArrayIndex(er->index);
- SlObject(er, _engine_renew_desc);
- }
-}
-
-static void Load_ERNW()
-{
- int index;
-
- while ((index = SlIterateArray()) != -1) {
- EngineRenew *er = new (index) EngineRenew();
- SlObject(er, _engine_renew_desc);
-
- /* Advanced vehicle lists, ungrouped vehicles got added */
- if (CheckSavegameVersion(60)) {
- er->group_id = ALL_GROUP;
- } else if (CheckSavegameVersion(71)) {
- if (er->group_id == DEFAULT_GROUP) er->group_id = ALL_GROUP;
- }
- }
-}
-
-extern const ChunkHandler _autoreplace_chunk_handlers[] = {
- { 'ERNW', Save_ERNW, Load_ERNW, CH_ARRAY | CH_LAST},
-};
-
void InitializeEngineRenews()
{
/* Clean the engine renew pool and create 1 block in it */
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -3,10 +3,8 @@
/** @file cargopacket.cpp Implementation of the cargo packets */
#include "stdafx.h"
-#include "openttd.h"
#include "station_base.h"
#include "cargopacket.h"
-#include "saveload.h"
#include "oldpool_func.h"
/* Initialize the cargopacket-pool */
@@ -43,42 +41,6 @@ bool CargoPacket::SameSource(const Cargo
return this->source_xy == cp->source_xy && this->days_in_transit == cp->days_in_transit && this->paid_for == cp->paid_for;
}
-static const SaveLoad _cargopacket_desc[] = {
- SLE_VAR(CargoPacket, source, SLE_UINT16),
- SLE_VAR(CargoPacket, source_xy, SLE_UINT32),
- SLE_VAR(CargoPacket, loaded_at_xy, SLE_UINT32),
- SLE_VAR(CargoPacket, count, SLE_UINT16),
- SLE_VAR(CargoPacket, days_in_transit, SLE_UINT8),
- SLE_VAR(CargoPacket, feeder_share, SLE_INT64),
- SLE_VAR(CargoPacket, paid_for, SLE_BOOL),
-
- SLE_END()
-};
-
-static void Save_CAPA()
-{
- CargoPacket *cp;
-
- FOR_ALL_CARGOPACKETS(cp) {
- SlSetArrayIndex(cp->index);
- SlObject(cp, _cargopacket_desc);
- }
-}
-
-static void Load_CAPA()
-{
- int index;
-
- while ((index = SlIterateArray()) != -1) {
- CargoPacket *cp = new (index) CargoPacket();
- SlObject(cp, _cargopacket_desc);
- }
-}
-
-extern const ChunkHandler _cargopacket_chunk_handlers[] = {
- { 'CAPA', Save_CAPA, Load_CAPA, CH_ARRAY | CH_LAST},
-};
-
/*
*
* Cargo list implementation
diff --git a/src/cheat.cpp b/src/cheat.cpp
--- a/src/cheat.cpp
+++ b/src/cheat.cpp
@@ -3,7 +3,6 @@
/** @file cheat.cpp Handling (loading/saving/initializing) of cheats. */
#include "stdafx.h"
-#include "saveload.h"
#include "cheat_type.h"
Cheats _cheats;
@@ -13,31 +12,6 @@ void InitializeCheats()
memset(&_cheats, 0, sizeof(Cheats));
}
-static void Save_CHTS()
-{
- /* Cannot use lengthof because _cheats is of type Cheats, not Cheat */
- byte count = sizeof(_cheats) / sizeof(Cheat);
- Cheat *cht = (Cheat*) &_cheats;
- Cheat *cht_last = &cht[count];
-
- SlSetLength(count * 2);
- for (; cht != cht_last; cht++) {
- SlWriteByte(cht->been_used);
- SlWriteByte(cht->value);
- }
-}
-
-static void Load_CHTS()
-{
- Cheat *cht = (Cheat*)&_cheats;
- size_t count = SlGetFieldLength() / 2;
-
- for (uint i = 0; i < count; i++) {
- cht[i].been_used = (SlReadByte() != 0);
- cht[i].value = (SlReadByte() != 0);
- }
-}
-
bool CheatHasBeenUsed()
{
/* Cannot use lengthof because _cheats is of type Cheats, not Cheat */
@@ -50,8 +24,3 @@ bool CheatHasBeenUsed()
return false;
}
-
-
-extern const ChunkHandler _cheat_chunk_handlers[] = {
- { 'CHTS', Save_CHTS, Load_CHTS, CH_RIFF | CH_LAST}
-};
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -10,7 +10,7 @@
#include "company_func.h"
#include "gfx_func.h"
#include "date_func.h"
-#include "saveload.h"
+#include "saveload/saveload.h"
#include "window_gui.h"
#include "newgrf.h"
#include "settings_type.h"
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -10,7 +10,6 @@
#include "company_gui.h"
#include "town.h"
#include "news_func.h"
-#include "saveload.h"
#include "command_func.h"
#include "network/network.h"
#include "network/network_func.h"
@@ -111,74 +110,6 @@ void DrawCompanyIcon(CompanyID c, int x,
}
/**
- * Converts an old company manager's face format to the new company manager's face format
- *
- * Meaning of the bits in the old face (some bits are used in several times):
- * - 4 and 5: chin
- * - 6 to 9: eyebrows
- * - 10 to 13: nose
- * - 13 to 15: lips (also moustache for males)
- * - 16 to 19: hair
- * - 20 to 22: eye color
- * - 20 to 27: tie, ear rings etc.
- * - 28 to 30: glasses
- * - 19, 26 and 27: race (bit 27 set and bit 19 equal to bit 26 = black, otherwise white)
- * - 31: gender (0 = male, 1 = female)
- *
- * @param face the face in the old format
- * @return the face in the new format
- */
-CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
-{
- CompanyManagerFace cmf = 0;
- GenderEthnicity ge = GE_WM;
-
- if (HasBit(face, 31)) SetBit(ge, GENDER_FEMALE);
- if (HasBit(face, 27) && (HasBit(face, 26) == HasBit(face, 19))) SetBit(ge, ETHNICITY_BLACK);
-
- SetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, ge, ge);
- SetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge, GB(face, 28, 3) <= 1);
- SetCompanyManagerFaceBits(cmf, CMFV_EYE_COLOUR, ge, HasBit(ge, ETHNICITY_BLACK) ? 0 : ClampU(GB(face, 20, 3), 5, 7) - 5);
- SetCompanyManagerFaceBits(cmf, CMFV_CHIN, ge, ScaleCompanyManagerFaceValue(CMFV_CHIN, ge, GB(face, 4, 2)));
- SetCompanyManagerFaceBits(cmf, CMFV_EYEBROWS, ge, ScaleCompanyManagerFaceValue(CMFV_EYEBROWS, ge, GB(face, 6, 4)));
- SetCompanyManagerFaceBits(cmf, CMFV_HAIR, ge, ScaleCompanyManagerFaceValue(CMFV_HAIR, ge, GB(face, 16, 4)));
- SetCompanyManagerFaceBits(cmf, CMFV_JACKET, ge, ScaleCompanyManagerFaceValue(CMFV_JACKET, ge, GB(face, 20, 2)));
- SetCompanyManagerFaceBits(cmf, CMFV_COLLAR, ge, ScaleCompanyManagerFaceValue(CMFV_COLLAR, ge, GB(face, 22, 2)));
- SetCompanyManagerFaceBits(cmf, CMFV_GLASSES, ge, GB(face, 28, 1));
-
- uint lips = GB(face, 10, 4);
- if (!HasBit(ge, GENDER_FEMALE) && lips < 4) {
- SetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge, true);
- SetCompanyManagerFaceBits(cmf, CMFV_MOUSTACHE, ge, max(lips, 1U) - 1);
- } else {
- if (!HasBit(ge, GENDER_FEMALE)) {
- lips = lips * 15 / 16;
- lips -= 3;
- if (HasBit(ge, ETHNICITY_BLACK) && lips > 8) lips = 0;
- } else {
- lips = ScaleCompanyManagerFaceValue(CMFV_LIPS, ge, lips);
- }
- SetCompanyManagerFaceBits(cmf, CMFV_LIPS, ge, lips);
-
- uint nose = GB(face, 13, 3);
- if (ge == GE_WF) {
- nose = (nose * 3 >> 3) * 3 >> 2; // There is 'hole' in the nose sprites for females
- } else {
- nose = ScaleCompanyManagerFaceValue(CMFV_NOSE, ge, nose);
- }
- SetCompanyManagerFaceBits(cmf, CMFV_NOSE, ge, nose);
- }
-
- uint tie_earring = GB(face, 24, 4);
- if (!HasBit(ge, GENDER_FEMALE) || tie_earring < 3) { // Not all females have an earring
- if (HasBit(ge, GENDER_FEMALE)) SetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge, true);
- SetCompanyManagerFaceBits(cmf, CMFV_TIE_EARRING, ge, HasBit(ge, GENDER_FEMALE) ? tie_earring : ScaleCompanyManagerFaceValue(CMFV_TIE_EARRING, ge, tie_earring / 2));
- }
-
- return cmf;
-}
-
-/**
* Checks whether a company manager's face is a valid encoding.
* Unused bits are not enforced to be 0.
* @param cmf the fact to check
@@ -936,159 +867,3 @@ CommandCost CmdCompanyCtrl(TileIndex til
return CommandCost();
}
-
-/* Save/load of companies */
-static const SaveLoad _company_desc[] = {
- SLE_VAR(Company, name_2, SLE_UINT32),
- SLE_VAR(Company, name_1, SLE_STRINGID),
- SLE_CONDSTR(Company, name, SLE_STR, 0, 84, SL_MAX_VERSION),
-
- SLE_VAR(Company, president_name_1, SLE_UINT16),
- SLE_VAR(Company, president_name_2, SLE_UINT32),
- SLE_CONDSTR(Company, president_name, SLE_STR, 0, 84, SL_MAX_VERSION),
-
- SLE_VAR(Company, face, SLE_UINT32),
-
- /* money was changed to a 64 bit field in savegame version 1. */
- SLE_CONDVAR(Company, money, SLE_VAR_I64 | SLE_FILE_I32, 0, 0),
- SLE_CONDVAR(Company, money, SLE_INT64, 1, SL_MAX_VERSION),
-
- SLE_CONDVAR(Company, current_loan, SLE_VAR_I64 | SLE_FILE_I32, 0, 64),
- SLE_CONDVAR(Company, current_loan, SLE_INT64, 65, SL_MAX_VERSION),
-
- SLE_VAR(Company, colour, SLE_UINT8),
- SLE_VAR(Company, money_fraction, SLE_UINT8),
- SLE_CONDVAR(Company, avail_railtypes, SLE_UINT8, 0, 57),
- SLE_VAR(Company, block_preview, SLE_UINT8),
-
- SLE_CONDVAR(Company, cargo_types, SLE_FILE_U16 | SLE_VAR_U32, 0, 93),
- SLE_CONDVAR(Company, cargo_types, SLE_UINT32, 94, SL_MAX_VERSION),
- SLE_CONDVAR(Company, location_of_HQ, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(Company, location_of_HQ, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(Company, last_build_coordinate, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(Company, last_build_coordinate, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(Company, inaugurated_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
- SLE_CONDVAR(Company, inaugurated_year, SLE_INT32, 31, SL_MAX_VERSION),
-
- SLE_ARR(Company, share_owners, SLE_UINT8, 4),
-
- SLE_VAR(Company, num_valid_stat_ent, SLE_UINT8),
-
- SLE_VAR(Company, quarters_of_bankrupcy, SLE_UINT8),
- SLE_CONDVAR(Company, bankrupt_asked, SLE_FILE_U8 | SLE_VAR_U16, 0, 103),
- SLE_CONDVAR(Company, bankrupt_asked, SLE_UINT16, 104, SL_MAX_VERSION),
- SLE_VAR(Company, bankrupt_timeout, SLE_INT16),
- SLE_CONDVAR(Company, bankrupt_value, SLE_VAR_I64 | SLE_FILE_I32, 0, 64),
- SLE_CONDVAR(Company, bankrupt_value, SLE_INT64, 65, SL_MAX_VERSION),
-
- /* yearly expenses was changed to 64-bit in savegame version 2. */
- SLE_CONDARR(Company, yearly_expenses, SLE_FILE_I32 | SLE_VAR_I64, 3 * 13, 0, 1),
- SLE_CONDARR(Company, yearly_expenses, SLE_INT64, 3 * 13, 2, SL_MAX_VERSION),
-
- SLE_CONDVAR(Company, is_ai, SLE_BOOL, 2, SL_MAX_VERSION),
- SLE_CONDNULL(1, 4, 99),
-
- /* Engine renewal settings */
- SLE_CONDNULL(512, 16, 18),
- SLE_CONDREF(Company, engine_renew_list, REF_ENGINE_RENEWS, 19, SL_MAX_VERSION),
- SLE_CONDVAR(Company, engine_renew, SLE_BOOL, 16, SL_MAX_VERSION),
- SLE_CONDVAR(Company, engine_renew_months, SLE_INT16, 16, SL_MAX_VERSION),
- SLE_CONDVAR(Company, engine_renew_money, SLE_UINT32, 16, SL_MAX_VERSION),
- SLE_CONDVAR(Company, renew_keep_length, SLE_BOOL, 2, SL_MAX_VERSION), // added with 16.1, but was blank since 2
-
- /* reserve extra space in savegame here. (currently 63 bytes) */
- SLE_CONDNULL(63, 2, SL_MAX_VERSION),
-
- SLE_END()
-};
-
-static const SaveLoad _company_economy_desc[] = {
- /* these were changed to 64-bit in savegame format 2 */
- SLE_CONDVAR(CompanyEconomyEntry, income, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
- SLE_CONDVAR(CompanyEconomyEntry, income, SLE_INT64, 2, SL_MAX_VERSION),
- SLE_CONDVAR(CompanyEconomyEntry, expenses, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
- SLE_CONDVAR(CompanyEconomyEntry, expenses, SLE_INT64, 2, SL_MAX_VERSION),
- SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
- SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_INT64, 2, SL_MAX_VERSION),
-
- SLE_VAR(CompanyEconomyEntry, delivered_cargo, SLE_INT32),
- SLE_VAR(CompanyEconomyEntry, performance_history, SLE_INT32),
-
- SLE_END()
-};
-
-static const SaveLoad _company_livery_desc[] = {
- SLE_CONDVAR(Livery, in_use, SLE_BOOL, 34, SL_MAX_VERSION),
- SLE_CONDVAR(Livery, colour1, SLE_UINT8, 34, SL_MAX_VERSION),
- SLE_CONDVAR(Livery, colour2, SLE_UINT8, 34, SL_MAX_VERSION),
- SLE_END()
-};
-
-static void SaveLoad_PLYR(Company *c)
-{
- int i;
-
- SlObject(c, _company_desc);
-
- /* Write AI? */
- if (!IsHumanCompany(c->index)) {
- SaveLoad_AI(c->index);
- }
-
- /* Write economy */
- SlObject(&c->cur_economy, _company_economy_desc);
-
- /* Write old economy entries. */
- for (i = 0; i < c->num_valid_stat_ent; i++) {
- SlObject(&c->old_economy[i], _company_economy_desc);
- }
-
- /* Write each livery entry. */
- int num_liveries = CheckSavegameVersion(63) ? LS_END - 4 : (CheckSavegameVersion(85) ? LS_END - 2: LS_END);
- for (i = 0; i < num_liveries; i++) {
- SlObject(&c->livery[i], _company_livery_desc);
- }
-
- if (num_liveries < LS_END) {
- /* We want to insert some liveries somewhere in between. This means some have to be moved. */
- memmove(&c->livery[LS_FREIGHT_WAGON], &c->livery[LS_PASSENGER_WAGON_MONORAIL], (LS_END - LS_FREIGHT_WAGON) * sizeof(c->livery[0]));
- c->livery[LS_PASSENGER_WAGON_MONORAIL] = c->livery[LS_MONORAIL];
- c->livery[LS_PASSENGER_WAGON_MAGLEV] = c->livery[LS_MAGLEV];
- }
-
- if (num_liveries == LS_END - 4) {
- /* Copy bus/truck liveries over to trams */
- c->livery[LS_PASSENGER_TRAM] = c->livery[LS_BUS];
- c->livery[LS_FREIGHT_TRAM] = c->livery[LS_TRUCK];
- }
-}
-
-static void Save_PLYR()
-{
- Company *c;
- FOR_ALL_COMPANIES(c) {
- SlSetArrayIndex(c->index);
- SlAutolength((AutolengthProc*)SaveLoad_PLYR, c);
- }
-}
-
-static void Load_PLYR()
-{
- int index;
- while ((index = SlIterateArray()) != -1) {
- Company *c = new (index) Company();
- SaveLoad_PLYR(c);
- _company_colours[index] = c->colour;
-
- /* This is needed so an AI is attached to a loaded AI */
- if (c->is_ai && (!_networking || _network_server) && _ai.enabled) {
- /* Clear the memory of the new AI, otherwise we might be doing wrong things. */
- memset(&_companies_ainew[index], 0, sizeof(CompanyAiNew));
- AI_StartNewAI(c->index);
- }
- }
-}
-
-extern const ChunkHandler _company_chunk_handlers[] = {
- { 'PLYR', Save_PLYR, Load_PLYR, CH_ARRAY | CH_LAST},
-};
diff --git a/src/company_manager_face.h b/src/company_manager_face.h
--- a/src/company_manager_face.h
+++ b/src/company_manager_face.h
@@ -7,6 +7,8 @@
#include "core/random_func.hpp"
#include "core/bitmath_func.hpp"
+#include "table/sprites.h"
+#include "company_type.h"
/** The gender/race combinations that we have faces for */
enum GenderEthnicity {
@@ -228,7 +230,6 @@ static inline SpriteID GetCompanyManager
}
void DrawCompanyManagerFace(CompanyManagerFace face, int color, int x, int y);
-CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face);
bool IsValidCompanyManagerFace(CompanyManagerFace cmf);
#endif /* COMPANY_MANAGER_FACE_H */
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -8,7 +8,7 @@
#include "debug.h"
#include "engine_func.h"
#include "landscape.h"
-#include "saveload.h"
+#include "saveload/saveload.h"
#include "variables.h"
#include "network/network.h"
#include "network/network_func.h"
diff --git a/src/date.cpp b/src/date.cpp
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -15,7 +15,7 @@
#include "vehicle_base.h"
#include "debug.h"
#include "rail_gui.h"
-#include "saveload.h"
+#include "saveload/saveload.h"
Year _cur_year; ///< Current year, starting at 0
Month _cur_month; ///< Current month (0..11)
diff --git a/src/depot.cpp b/src/depot.cpp
--- a/src/depot.cpp
+++ b/src/depot.cpp
@@ -3,10 +3,8 @@
/** @file depot.cpp Handling of depots. */
#include "stdafx.h"
-#include "openttd.h"
#include "depot_base.h"
#include "landscape.h"
-#include "saveload.h"
#include "order_func.h"
#include "window_func.h"
#include "oldpool_func.h"
@@ -51,35 +49,3 @@ void InitializeDepots()
_Depot_pool.CleanPool();
_Depot_pool.AddBlockToPool();
}
-
-
-static const SaveLoad _depot_desc[] = {
- SLE_CONDVAR(Depot, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(Depot, xy, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_VAR(Depot, town_index, SLE_UINT16),
- SLE_END()
-};
-
-static void Save_DEPT()
-{
- Depot *depot;
-
- FOR_ALL_DEPOTS(depot) {
- SlSetArrayIndex(depot->index);
- SlObject(depot, _depot_desc);
- }
-}
-
-static void Load_DEPT()
-{
- int index;
-
- while ((index = SlIterateArray()) != -1) {
- Depot *depot = new (index) Depot();
- SlObject(depot, _depot_desc);
- }
-}
-
-extern const ChunkHandler _depot_chunk_handlers[] = {
- { 'DEPT', Save_DEPT, Load_DEPT, CH_ARRAY | CH_LAST},
-};
diff --git a/src/economy.cpp b/src/economy.cpp
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -9,7 +9,6 @@
#include "company_base.h"
#include "company_func.h"
#include "command_func.h"
-#include "saveload.h"
#include "industry.h"
#include "industry_map.h"
#include "town.h"
@@ -767,7 +766,7 @@ void SetPriceBaseMultiplier(uint price,
* Initialize the variables that will maintain the daily industry change system.
* @param init_counter specifies if the counter is required to be initialized
*/
-static void StartupIndustryDailyChanges(bool init_counter)
+void StartupIndustryDailyChanges(bool init_counter)
{
uint map_size = MapLogX() + MapLogY();
/* After getting map size, it needs to be scaled appropriately and divided by 31,
@@ -1121,37 +1120,6 @@ no_add:;
InvalidateWindow(WC_SUBSIDIES_LIST, 0);
}
-static const SaveLoad _subsidies_desc[] = {
- SLE_VAR(Subsidy, cargo_type, SLE_UINT8),
- SLE_VAR(Subsidy, age, SLE_UINT8),
- SLE_CONDVAR(Subsidy, from, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
- SLE_CONDVAR(Subsidy, from, SLE_UINT16, 5, SL_MAX_VERSION),
- SLE_CONDVAR(Subsidy, to, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
- SLE_CONDVAR(Subsidy, to, SLE_UINT16, 5, SL_MAX_VERSION),
- SLE_END()
-};
-
-static void Save_SUBS()
-{
- int i;
- Subsidy *s;
-
- for (i = 0; i != lengthof(_subsidies); i++) {
- s = &_subsidies[i];
- if (s->cargo_type != CT_INVALID) {
- SlSetArrayIndex(i);
- SlObject(s, _subsidies_desc);
- }
- }
-}
-
-static void Load_SUBS()
-{
- int index;
- while ((index = SlIterateArray()) != -1)
- SlObject(&_subsidies[index], _subsidies_desc);
-}
-
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type)
{
const CargoSpec *cs = GetCargo(cargo_type);
@@ -1994,54 +1962,3 @@ CommandCost CmdBuyCompany(TileIndex tile
}
return CommandCost(EXPENSES_OTHER, c->bankrupt_value);
}
-
-/** Prices */
-static void SaveLoad_PRIC()
-{
- int vt = CheckSavegameVersion(65) ? (SLE_FILE_I32 | SLE_VAR_I64) : SLE_INT64;
- SlArray(&_price, NUM_PRICES, vt);
- SlArray(&_price_frac, NUM_PRICES, SLE_UINT16);
-}
-
-/** Cargo payment rates */
-static void SaveLoad_CAPR()
-{
- uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO;
- int vt = CheckSavegameVersion(65) ? (SLE_FILE_I32 | SLE_VAR_I64) : SLE_INT64;
- SlArray(&_cargo_payment_rates, num_cargo, vt);
- SlArray(&_cargo_payment_rates_frac, num_cargo, SLE_UINT16);
-}
-
-static const SaveLoad _economy_desc[] = {
- SLE_CONDVAR(Economy, max_loan, SLE_FILE_I32 | SLE_VAR_I64, 0, 64),
- SLE_CONDVAR(Economy, max_loan, SLE_INT64, 65, SL_MAX_VERSION),
- SLE_CONDVAR(Economy, max_loan_unround, SLE_FILE_I32 | SLE_VAR_I64, 0, 64),
- SLE_CONDVAR(Economy, max_loan_unround, SLE_INT64, 65, SL_MAX_VERSION),
- SLE_CONDVAR(Economy, max_loan_unround_fract, SLE_UINT16, 70, SL_MAX_VERSION),
- SLE_VAR(Economy, fluct, SLE_INT16),
- SLE_VAR(Economy, interest_rate, SLE_UINT8),
- SLE_VAR(Economy, infl_amount, SLE_UINT8),
- SLE_VAR(Economy, infl_amount_pr, SLE_UINT8),
- SLE_CONDVAR(Economy, industry_daily_change_counter, SLE_UINT32, 102, SL_MAX_VERSION),
- SLE_END()
-};
-
-/** Economy variables */
-static void Save_ECMY()
-{
- SlObject(&_economy, _economy_desc);
-}
-
-/** Economy variables */
-static void Load_ECMY()
-{
- SlObject(&_economy, _economy_desc);
- StartupIndustryDailyChanges(CheckSavegameVersion(102)); // old savegames will need to be initialized
-}
-
-extern const ChunkHandler _economy_chunk_handlers[] = {
- { 'PRIC', SaveLoad_PRIC, SaveLoad_PRIC, CH_RIFF | CH_AUTO_LENGTH},
- { 'CAPR', SaveLoad_CAPR, SaveLoad_CAPR, CH_RIFF | CH_AUTO_LENGTH},
- { 'SUBS', Save_SUBS, Load_SUBS, CH_ARRAY},
- { 'ECMY', Save_ECMY, Load_ECMY, CH_RIFF | CH_LAST},
-};
diff --git a/src/economy_func.h b/src/economy_func.h
--- a/src/economy_func.h
+++ b/src/economy_func.h
@@ -34,6 +34,7 @@ Pair SetupSubsidyDecodeParam(const Subsi
void DeleteSubsidyWithTown(TownID index);
void DeleteSubsidyWithIndustry(IndustryID index);
void DeleteSubsidyWithStation(StationID index);
+void StartupIndustryDailyChanges(bool init_counter);
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp
--- a/src/effectvehicle.cpp
+++ b/src/effectvehicle.cpp
@@ -15,7 +15,6 @@
#include "gfx_func.h"
#include "news_func.h"
#include "command_func.h"
-#include "saveload.h"
#include "company_func.h"
#include "debug.h"
#include "vehicle_gui.h"
diff --git a/src/engine.cpp b/src/engine.cpp
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -9,7 +9,6 @@
#include "company_func.h"
#include "command_func.h"
#include "news_func.h"
-#include "saveload.h"
#include "variables.h"
#include "train.h"
#include "aircraft.h"
@@ -27,7 +26,6 @@
#include "oldpool_func.h"
#include "core/alloc_func.hpp"
#include "vehicle_func.h"
-#include