/** * Get a SaveLoad array for a link graph. * @return SaveLoad array for link graph. */ const SaveLoad *GetLinkGraphDesc() { static const SaveLoad link_graph_desc[] = { SLE_VAR(LinkGraph, last_compression, SLE_INT32), SLEG_VAR(_num_nodes, SLE_UINT16), SLE_VAR(LinkGraph, cargo, SLE_UINT8), SLE_END() }; return link_graph_desc; }
const SaveLoad *GetTileMatrixDesc() { /* Here due to private member vars. */ static const SaveLoad _tilematrix_desc[] = { SLE_VAR(AcceptanceMatrix, area.tile, SLE_UINT32), SLE_VAR(AcceptanceMatrix, area.w, SLE_UINT16), SLE_VAR(AcceptanceMatrix, area.h, SLE_UINT16), SLE_END() }; return _tilematrix_desc; }
const SaveLoad *GetOrderDescription() { static const SaveLoad _order_desc[] = { SLE_VAR(Order, type, SLE_UINT8), SLE_VAR(Order, flags, SLE_UINT8), SLE_VAR(Order, dest, SLE_UINT16), SLE_REF(Order, next, REF_ORDER), SLE_CONDVAR(Order, refit_cargo, SLE_UINT8, 36, SL_MAX_VERSION), SLE_CONDVAR(Order, refit_subtype, SLE_UINT8, 36, SL_MAX_VERSION), SLE_CONDVAR(Order, wait_time, SLE_UINT16, 67, SL_MAX_VERSION), SLE_CONDVAR(Order, travel_time, SLE_UINT16, 67, SL_MAX_VERSION), /* Leftover from the minor savegame version stuff * We will never use those free bytes, but we have to keep this line to allow loading of old savegames */ SLE_CONDNULL(10, 5, 35), SLE_END() }; return _order_desc; }
/** * Get a SaveLoad array for a link graph job. The settings struct is derived from * the global settings saveload array. The exact entries are calculated when the function * is called the first time. * It's necessary to keep a copy of the settings for each link graph job so that you can * change the settings while in-game and still not mess with current link graph runs. * Of course the settings have to be saved and loaded, too, to avoid desyncs. * @return Array of SaveLoad structs. */ const SaveLoad *GetLinkGraphJobDesc() { static SmallVector<SaveLoad, 16> saveloads; static const char *prefix = "linkgraph."; /* Build the SaveLoad array on first call and don't touch it later on */ if (saveloads.Length() == 0) { size_t offset_gamesettings = cpp_offsetof(GameSettings, linkgraph); size_t offset_component = cpp_offsetof(LinkGraphJob, settings); size_t prefixlen = strlen(prefix); int setting = 0; const SettingDesc *desc = GetSettingDescription(setting); while (desc->save.cmd != SL_END) { if (desc->desc.name != NULL && strncmp(desc->desc.name, prefix, prefixlen) == 0) { SaveLoad sl = desc->save; char *&address = reinterpret_cast<char *&>(sl.address); address -= offset_gamesettings; address += offset_component; *(saveloads.Append()) = sl; } desc = GetSettingDescription(++setting); } const SaveLoad job_desc[] = { SLE_VAR(LinkGraphJob, join_date, SLE_INT32), SLE_VAR(LinkGraphJob, link_graph.index, SLE_UINT16), SLE_END() }; int i = 0; do { *(saveloads.Append()) = job_desc[i++]; } while (saveloads[saveloads.Length() - 1].cmd != SL_END); } return &saveloads[0]; }
/** * Wrapper function to get the GoodsEntry's internal structure while * some of the variables itself are private. * @return the saveload description for GoodsEntry. */ const SaveLoad *GetGoodsDesc() { static const SaveLoad goods_desc[] = { SLEG_CONDVAR( _waiting_acceptance, SLE_UINT16, 0, 67), SLE_CONDVAR(GoodsEntry, acceptance_pickup, SLE_UINT8, 68, SL_MAX_VERSION), SLE_CONDNULL(2, 51, 67), SLE_VAR(GoodsEntry, days_since_pickup, SLE_UINT8), SLE_VAR(GoodsEntry, rating, SLE_UINT8), SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, 0, 6), SLEG_CONDVAR( _cargo_source, SLE_UINT16, 7, 67), SLEG_CONDVAR( _cargo_source_xy, SLE_UINT32, 44, 67), SLEG_CONDVAR( _cargo_days, SLE_UINT8, 0, 67), SLE_VAR(GoodsEntry, last_speed, SLE_UINT8), SLE_VAR(GoodsEntry, last_age, SLE_UINT8), SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, 14, 64), SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, 65, 67), SLE_CONDLST(GoodsEntry, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION), SLE_END() }; return goods_desc; }
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file gamelog_sl.cpp Code handling saving and loading of gamelog data */ #include "../stdafx.h" #include "../gamelog_internal.h" #include "../fios.h" #include "saveload.h" #include "../safeguards.h" static const SaveLoad _glog_action_desc[] = { SLE_VAR(LoggedAction, tick, SLE_UINT16), SLE_END() }; static const SaveLoad _glog_mode_desc[] = { SLE_VAR(LoggedChange, mode.mode, SLE_UINT8), SLE_VAR(LoggedChange, mode.landscape, SLE_UINT8), SLE_END() }; static const SaveLoad _glog_revision_desc[] = { SLE_ARR(LoggedChange, revision.text, SLE_UINT8, GAMELOG_REVISION_LENGTH), SLE_VAR(LoggedChange, revision.newgrf, SLE_UINT32), SLE_VAR(LoggedChange, revision.slver, SLE_UINT16), SLE_VAR(LoggedChange, revision.modified, SLE_UINT8), SLE_END()
static const SaveLoad schedule_desc[] = { SLE_LST(LinkGraphSchedule, schedule, REF_LINK_GRAPH), SLE_LST(LinkGraphSchedule, running, REF_LINK_GRAPH_JOB), SLE_END() }; return schedule_desc; } /* Edges and nodes are saved in the correct order, so we don't need to save their IDs. */ /** * SaveLoad desc for a link graph node. */ static const SaveLoad _node_desc[] = { SLE_CONDVAR(Node, xy, SLE_UINT32, 191, SL_MAX_VERSION), SLE_VAR(Node, supply, SLE_UINT32), SLE_VAR(Node, demand, SLE_UINT32), SLE_VAR(Node, station, SLE_UINT16), SLE_VAR(Node, last_update, SLE_INT32), SLE_END() }; /** * SaveLoad desc for a link graph edge. */ static const SaveLoad _edge_desc[] = { SLE_CONDNULL(4, 0, 190), // distance SLE_VAR(Edge, capacity, SLE_UINT32), SLE_VAR(Edge, usage, SLE_UINT32), SLE_VAR(Edge, last_unrestricted_update, SLE_INT32), SLE_CONDVAR(Edge, last_restricted_update, SLE_INT32, 187, SL_MAX_VERSION),
default: break; } } } _railtype_list.Clear(); } /** Container for a label for SaveLoad system */ struct LabelObject { uint32 label; }; static const SaveLoad _label_object_desc[] = { SLE_VAR(LabelObject, label, SLE_UINT32), SLE_END(), }; static void Save_RAIL() { LabelObject lo; for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) { lo.label = GetRailTypeInfo(r)->label; SlSetArrayIndex(r); SlObject(&lo, _label_object_desc); } }
/* * This file is part of OpenTTD. * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file goal_sl.cpp Code handling saving and loading of goals */ #include "../stdafx.h" #include "../goal_base.h" #include "saveload.h" static const SaveLoad _goals_desc[] = { SLE_VAR(Goal, company, SLE_UINT16), SLE_VAR(Goal, type, SLE_UINT16), SLE_VAR(Goal, dst, SLE_UINT32), SLE_STR(Goal, text, SLE_STR | SLF_ALLOW_CONTROL, 0), SLE_CONDSTR(Goal, progress, SLE_STR | SLF_ALLOW_CONTROL, 0, 182, SL_MAX_VERSION), SLE_CONDVAR(Goal, completed, SLE_BOOL, 182, SL_MAX_VERSION), SLE_END() }; static void Save_GOAL() { Goal *s; FOR_ALL_GOALS(s) { SlSetArrayIndex(s->index); SlObject(s, _goals_desc); }
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file object_sl.cpp Code handling saving and loading of objects */ #include "../stdafx.h" #include "../object_base.h" #include "../object_map.h" #include "saveload.h" #include "newgrf_sl.h" #include "../safeguards.h" static const SaveLoad _object_desc[] = { SLE_VAR(Object, location.tile, SLE_UINT32), SLE_VAR(Object, location.w, SLE_FILE_U8 | SLE_VAR_U16), SLE_VAR(Object, location.h, SLE_FILE_U8 | SLE_VAR_U16), SLE_REF(Object, town, REF_TOWN), SLE_VAR(Object, build_date, SLE_UINT32), SLE_CONDVAR(Object, colour, SLE_UINT8, SLV_148, SL_MAX_VERSION), SLE_CONDVAR(Object, view, SLE_UINT8, SLV_155, SL_MAX_VERSION), SLE_CONDVAR(Object, type, SLE_UINT16, SLV_186, SL_MAX_VERSION), SLE_END() }; static void Save_OBJS() { Object *o;
* OpenCoaster Tycoon is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenCoaster Tycoon. If not, see <http://www.gnu.org/licenses/>. */ /** @file industry_sl.cpp Code handling saving and loading of industries */ #include "../stdafx.h" #include "../industry.h" #include "saveload.h" #include "newgrf_sl.h" static const SaveLoad _industry_desc[] = { SLE_CONDVAR(Industry, location.tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), SLE_CONDVAR(Industry, location.tile, SLE_UINT32, 6, SL_MAX_VERSION), SLE_VAR(Industry, location.w, SLE_FILE_U8 | SLE_VAR_U16), SLE_VAR(Industry, location.h, SLE_FILE_U8 | SLE_VAR_U16), SLE_REF(Industry, town, REF_TOWN), SLE_CONDNULL( 2, 0, 60), ///< used to be industry's produced_cargo SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 2, 78, SL_MAX_VERSION), SLE_CONDARR(Industry, incoming_cargo_waiting, SLE_UINT16, 3, 70, SL_MAX_VERSION), SLE_ARR(Industry, produced_cargo_waiting, SLE_UINT16, 2), SLE_ARR(Industry, production_rate, SLE_UINT8, 2), SLE_CONDNULL( 3, 0, 60), ///< used to be industry's accepts_cargo SLE_CONDARR(Industry, accepts_cargo, SLE_UINT8, 3, 78, SL_MAX_VERSION), SLE_VAR(Industry, prod_level, SLE_UINT8), SLE_ARR(Industry, this_month_production, SLE_UINT16, 2), SLE_ARR(Industry, this_month_transported, SLE_UINT16, 2), SLE_ARR(Industry, last_month_pct_transported, SLE_UINT8, 2), SLE_ARR(Industry, last_month_production, SLE_UINT16, 2), SLE_ARR(Industry, last_month_transported, SLE_UINT16, 2),
UpdateTownRadius(town); UpdateTownCargos(town); } } /** Save and load of towns. */ static const SaveLoad _town_desc[] = { SLE_CONDVAR(Town, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), SLE_CONDVAR(Town, xy, SLE_UINT32, 6, SL_MAX_VERSION), SLE_CONDNULL(2, 0, 2), ///< population, no longer in use SLE_CONDNULL(4, 3, 84), ///< population, no longer in use SLE_CONDNULL(2, 0, 91), ///< num_houses, no longer in use SLE_CONDVAR(Town, townnamegrfid, SLE_UINT32, 66, SL_MAX_VERSION), SLE_VAR(Town, townnametype, SLE_UINT16), SLE_VAR(Town, townnameparts, SLE_UINT32), SLE_CONDSTR(Town, name, SLE_STR, 0, 84, SL_MAX_VERSION), SLE_VAR(Town, flags, SLE_UINT8), SLE_CONDVAR(Town, statues, SLE_FILE_U8 | SLE_VAR_U16, 0, 103), SLE_CONDVAR(Town, statues, SLE_UINT16, 104, SL_MAX_VERSION), SLE_CONDNULL(1, 0, 1), ///< sort_index, no longer in use SLE_CONDVAR(Town, have_ratings, SLE_FILE_U8 | SLE_VAR_U16, 0, 103), SLE_CONDVAR(Town, have_ratings, SLE_UINT16, 104, SL_MAX_VERSION), SLE_CONDARR(Town, ratings, SLE_INT16, 8, 0, 103), SLE_CONDARR(Town, ratings, SLE_INT16, MAX_COMPANIES, 104, SL_MAX_VERSION), /* failed bribe attempts are stored since savegame format 4 */ SLE_CONDARR(Town, unwanted, SLE_INT8, 8, 4, 103),
{ uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO; int vt = IsSavegameVersionBefore(65) ? SLE_FILE_I32 : SLE_FILE_I64; SlArray(NULL, num_cargo, vt | SLE_VAR_NULL); SlArray(NULL, num_cargo, SLE_FILE_U16 | SLE_VAR_NULL); } static const SaveLoad _economy_desc[] = { SLE_CONDNULL(4, 0, 64), // max_loan SLE_CONDNULL(8, 65, 143), // max_loan SLE_CONDVAR(Economy, old_max_loan_unround, SLE_FILE_I32 | SLE_VAR_I64, 0, 64), SLE_CONDVAR(Economy, old_max_loan_unround, SLE_INT64, 65, 125), SLE_CONDVAR(Economy, old_max_loan_unround_fract, SLE_UINT16, 70, 125), SLE_CONDVAR(Economy, inflation_prices, SLE_UINT64, 126, SL_MAX_VERSION), SLE_CONDVAR(Economy, inflation_payment, SLE_UINT64, 126, 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_CONDVAR(Economy, industry_helper, SLE_INT64, 181, SL_MAX_VERSION), SLE_END() }; /** Economy variables */ static void Save_ECMY() { SlObject(&_economy, _economy_desc); } /** Economy variables */
UpdateWaypointOrder(&v->current_order); } _old_waypoints.Reset(); } static const SaveLoad _old_waypoint_desc[] = { SLE_CONDVAR(OldWaypoint, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), SLE_CONDVAR(OldWaypoint, xy, SLE_UINT32, 6, SL_MAX_VERSION), SLE_CONDVAR(OldWaypoint, town_index, SLE_UINT16, 12, 121), SLE_CONDREF(OldWaypoint, town, REF_TOWN, 122, SL_MAX_VERSION), SLE_CONDVAR(OldWaypoint, town_cn, SLE_FILE_U8 | SLE_VAR_U16, 12, 88), SLE_CONDVAR(OldWaypoint, town_cn, SLE_UINT16, 89, SL_MAX_VERSION), SLE_CONDVAR(OldWaypoint, string_id, SLE_STRINGID, 0, 83), SLE_CONDSTR(OldWaypoint, name, SLE_STR, 0, 84, SL_MAX_VERSION), SLE_VAR(OldWaypoint, delete_ctr, SLE_UINT8), SLE_CONDVAR(OldWaypoint, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30), SLE_CONDVAR(OldWaypoint, build_date, SLE_INT32, 31, SL_MAX_VERSION), SLE_CONDVAR(OldWaypoint, localidx, SLE_UINT8, 3, SL_MAX_VERSION), SLE_CONDVAR(OldWaypoint, grfid, SLE_UINT32, 17, SL_MAX_VERSION), SLE_CONDVAR(OldWaypoint, owner, SLE_UINT8, 101, SL_MAX_VERSION), SLE_END() }; static void Load_WAYP() { /* Precaution for when loading failed and it didn't get cleared */ _old_waypoints.Clear();
/** Called after load to trash broken pages. */ void AfterLoadStoryBook() { if (IsSavegameVersionBefore(185)) { /* Trash all story pages and page elements because * they were saved with wrong data types. */ _story_page_element_pool.CleanPool(); _story_page_pool.CleanPool(); } } static const SaveLoad _story_page_elements_desc[] = { SLE_CONDVAR(StoryPageElement, sort_value, SLE_FILE_U16 | SLE_VAR_U32, 0, 184), SLE_CONDVAR(StoryPageElement, sort_value, SLE_UINT32, 185, SL_MAX_VERSION), SLE_VAR(StoryPageElement, page, SLE_UINT16), SLE_CONDVAR(StoryPageElement, type, SLE_FILE_U16 | SLE_VAR_U8, 0, 184), SLE_CONDVAR(StoryPageElement, type, SLE_UINT8, 185, SL_MAX_VERSION), SLE_VAR(StoryPageElement, referenced_id, SLE_UINT32), SLE_STR(StoryPageElement, text, SLE_STR | SLF_ALLOW_CONTROL, 0), SLE_END() }; static void Save_STORY_PAGE_ELEMENT() { StoryPageElement *s; FOR_ALL_STORY_PAGE_ELEMENTS(s) { SlSetArrayIndex(s->index); SlObject(s, _story_page_elements_desc); } }
/** @file signs_sl.cpp Code handling saving and loading of economy data */ #include "../stdafx.h" #include "../signs_base.h" #include "saveload.h" static const SaveLoad _sign_desc[] = { SLE_CONDVAR(Sign, name, SLE_NAME, 0, 83), SLE_CONDSTR(Sign, name, SLE_STR, 0, 84, SL_MAX_VERSION), SLE_CONDVAR(Sign, x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4), SLE_CONDVAR(Sign, y, SLE_FILE_I16 | SLE_VAR_I32, 0, 4), SLE_CONDVAR(Sign, x, SLE_INT32, 5, SL_MAX_VERSION), SLE_CONDVAR(Sign, y, SLE_INT32, 5, SL_MAX_VERSION), SLE_CONDVAR(Sign, owner, SLE_UINT8, 6, SL_MAX_VERSION), SLE_VAR(Sign, z, SLE_UINT8), SLE_END() }; /** Save all signs */ static void Save_SIGN() { Sign *si; FOR_ALL_SIGNS(si) { SlSetArrayIndex(si->index); SlObject(si, _sign_desc); } } /** Load all signs */
} RebuildTownCaches(); } /** Save and load of towns. */ static const SaveLoad _town_desc[] = { SLE_CONDVAR(Town, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), SLE_CONDVAR(Town, xy, SLE_UINT32, 6, SL_MAX_VERSION), SLE_CONDNULL(2, 0, 2), ///< population, no longer in use SLE_CONDNULL(4, 3, 84), ///< population, no longer in use SLE_CONDNULL(2, 0, 91), ///< num_houses, no longer in use SLE_CONDVAR(Town, townnamegrfid, SLE_UINT32, 66, SL_MAX_VERSION), SLE_VAR(Town, townnametype, SLE_UINT16), SLE_VAR(Town, townnameparts, SLE_UINT32), SLE_CONDSTR(Town, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), SLE_VAR(Town, flags, SLE_UINT8), SLE_CONDVAR(Town, statues, SLE_FILE_U8 | SLE_VAR_U16, 0, 103), SLE_CONDVAR(Town, statues, SLE_UINT16, 104, SL_MAX_VERSION), SLE_CONDNULL(1, 0, 1), ///< sort_index, no longer in use SLE_CONDVAR(Town, have_ratings, SLE_FILE_U8 | SLE_VAR_U16, 0, 103), SLE_CONDVAR(Town, have_ratings, SLE_UINT16, 104, SL_MAX_VERSION), SLE_CONDARR(Town, ratings, SLE_INT16, 8, 0, 103), SLE_CONDARR(Town, ratings, SLE_INT16, MAX_COMPANIES, 104, SL_MAX_VERSION), /* failed bribe attempts are stored since savegame format 4 */ SLE_CONDARR(Town, unwanted, SLE_INT8, 8, 4, 103),
/* First construct the drive through entries */ RoadStop *rs; FOR_ALL_ROADSTOPS(rs) { if (IsDriveThroughStopTile(rs->xy)) rs->MakeDriveThrough(); } /* And then rebuild the data in those entries */ FOR_ALL_ROADSTOPS(rs) { if (!HasBit(rs->status, RoadStop::RSSFB_BASE_ENTRY)) continue; rs->GetEntry(DIAGDIR_NE)->Rebuild(rs); rs->GetEntry(DIAGDIR_NW)->Rebuild(rs); } } static const SaveLoad _roadstop_desc[] = { SLE_VAR(RoadStop, xy, SLE_UINT32), SLE_CONDNULL(1, 0, 44), SLE_VAR(RoadStop, status, SLE_UINT8), /* Index was saved in some versions, but this is not needed */ SLE_CONDNULL(4, 0, 8), SLE_CONDNULL(2, 0, 44), SLE_CONDNULL(1, 0, 25), SLE_REF(RoadStop, next, REF_ROADSTOPS), SLE_CONDNULL(2, 0, 44), SLE_CONDNULL(4, 0, 24), SLE_CONDNULL(1, 25, 25), SLE_END() };
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file group_sl.cpp Code handling saving and loading of economy data */ #include "../stdafx.h" #include "../group.h" #include "saveload.h" static const SaveLoad _group_desc[] = { SLE_CONDVAR(Group, name, SLE_NAME, 0, 83), SLE_CONDSTR(Group, name, SLE_STR, 0, 84, SL_MAX_VERSION), SLE_VAR(Group, num_vehicle, SLE_UINT16), SLE_VAR(Group, owner, SLE_UINT8), SLE_VAR(Group, vehicle_type, SLE_UINT8), SLE_VAR(Group, replace_protection, SLE_BOOL), SLE_END() }; static void Save_GRPS() { Group *g; FOR_ALL_GROUPS(g) { SlSetArrayIndex(g->index); SlObject(g, _group_desc); } }
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file engine_sl.cpp Code handling saving and loading of engines */ #include "../stdafx.h" #include "saveload_internal.h" #include "../engine_base.h" #include <map> static const SaveLoad _engine_desc[] = { SLE_CONDVAR(Engine, intro_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), SLE_CONDVAR(Engine, intro_date, SLE_INT32, 31, SL_MAX_VERSION), SLE_CONDVAR(Engine, age, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), SLE_CONDVAR(Engine, age, SLE_INT32, 31, SL_MAX_VERSION), SLE_VAR(Engine, reliability, SLE_UINT16), SLE_VAR(Engine, reliability_spd_dec, SLE_UINT16), SLE_VAR(Engine, reliability_start, SLE_UINT16), SLE_VAR(Engine, reliability_max, SLE_UINT16), SLE_VAR(Engine, reliability_final, SLE_UINT16), SLE_VAR(Engine, duration_phase_1, SLE_UINT16), SLE_VAR(Engine, duration_phase_2, SLE_UINT16), SLE_VAR(Engine, duration_phase_3, SLE_UINT16), SLE_CONDNULL(1, 0, 120), SLE_VAR(Engine, flags, SLE_UINT8), SLE_CONDNULL(1, 0, 178), // old preview_company_rank SLE_CONDVAR(Engine, preview_asked, SLE_UINT16, 179, SL_MAX_VERSION), SLE_CONDVAR(Engine, preview_company, SLE_UINT8, 179, SL_MAX_VERSION), SLE_VAR(Engine, preview_wait, SLE_UINT8), SLE_CONDNULL(1, 0, 44),
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file newgrf_sl.cpp Code handling saving and loading of newgrf config */ #include "../stdafx.h" #include "../fios.h" #include "saveload.h" #include "newgrf_sl.h" #include "../safeguards.h" /** Save and load the mapping between a spec and the NewGRF it came from. */ static const SaveLoad _newgrf_mapping_desc[] = { SLE_VAR(EntityIDMapping, grfid, SLE_UINT32), SLE_VAR(EntityIDMapping, entity_id, SLE_UINT8), SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8), SLE_END() }; /** * Save a GRF ID + local id -> OpenTTD's id mapping. * @param mapping The mapping to save. */ void Save_NewGRFMapping(const OverrideManagerBase &mapping) { for (uint i = 0; i < mapping.GetMaxMapping(); i++) { SlSetArrayIndex(i); SlObject(&mapping.mapping_ID[i], _newgrf_mapping_desc); }
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file autoreplace_sl.cpp Code handling saving and loading of autoreplace rules */ #include "../stdafx.h" #include "../autoreplace_base.h" #include "saveload.h" #include "../safeguards.h" 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, SLV_60, SL_MAX_VERSION), SLE_CONDVAR(EngineRenew, replace_when_old, SLE_BOOL, SLV_175, SL_MAX_VERSION), SLE_END() }; static void Save_ERNW() { EngineRenew *er; FOR_ALL_ENGINE_RENEWS(er) { SlSetArrayIndex(er->index); SlObject(er, _engine_renew_desc);