OpenTTD Source  20241108-master-g80f628063a
misc_sl.cpp File Reference

Saving and loading of things that didn't fit anywhere else. More...

#include "../stdafx.h"
#include "saveload.h"
#include "compat/misc_sl_compat.h"
#include "../timer/timer_game_calendar.h"
#include "../timer/timer_game_economy.h"
#include "../zoom_func.h"
#include "../window_gui.h"
#include "../window_func.h"
#include "../viewport_func.h"
#include "../gfx_func.h"
#include "../core/random_func.hpp"
#include "../fios.h"
#include "../timer/timer.h"
#include "../timer/timer_game_tick.h"
#include "../safeguards.h"

Go to the source code of this file.

Data Structures

struct  DATEChunkHandler
 
struct  VIEWChunkHandler
 

Functions

void SaveViewportBeforeSaveGame ()
 
void ResetViewportAfterLoadGame ()
 
const ChunkHandlerTable _misc_chunk_handlers (misc_chunk_handlers)
 

Variables

TileIndex _cur_tileloop_tile
 
uint16_t _disaster_delay
 Delay counter for considering the next disaster.
 
uint8_t _trees_tick_ctr
 Determines when to consider building more trees.
 
int _saved_scrollpos_x
 
int _saved_scrollpos_y
 
ZoomLevel _saved_scrollpos_zoom
 
uint8_t _age_cargo_skip_counter
 Skip aging of cargo? Used before savegame version 162.
 
TimeoutTimer< TimerGameTick_new_competitor_timeout
 
static const SaveLoad _date_desc []
 
static const SaveLoad _date_check_desc []
 
static const SaveLoad _view_desc []
 
static const DATEChunkHandler DATE
 
static const VIEWChunkHandler VIEW
 
static const ChunkHandlerRef misc_chunk_handlers []
 

Detailed Description

Saving and loading of things that didn't fit anywhere else.

Definition in file misc_sl.cpp.

Variable Documentation

◆ _date_check_desc

const SaveLoad _date_check_desc[]
static
Initial value:
= {
SLEG_CONDVAR("date", _load_check_data.current_date, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
SLEG_CONDVAR("date", _load_check_data.current_date, SLE_INT32, SLV_31, SL_MAX_VERSION),
}
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
Definition: fios_gui.cpp:41
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition: saveload.h:1074
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:395
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:31
@ SLV_31
31 5999
Definition: saveload.h:80

Definition at line 109 of file misc_sl.cpp.

◆ _date_desc

const SaveLoad _date_desc[]
static
Initial value:
= {
SLEG_CONDVAR("date", TimerGameCalendar::date, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
SLEG_VAR("date_fract", TimerGameCalendar::date_fract, SLE_UINT16),
SLEG_CONDVAR("tick_counter", TimerGameTick::counter, SLE_FILE_U16 | SLE_VAR_U64, SL_MIN_VERSION, SLV_U64_TICK_COUNTER),
SLEG_CONDVAR("age_cargo_skip_counter", _age_cargo_skip_counter, SLE_UINT8, SL_MIN_VERSION, SLV_162),
SLEG_CONDVAR("cur_tileloop_tile", _cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
SLEG_CONDVAR("cur_tileloop_tile", _cur_tileloop_tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
SLEG_VAR("next_disaster_start", _disaster_delay, SLE_UINT16),
SLEG_VAR("random_state[0]", _random.state[0], SLE_UINT32),
SLEG_VAR("random_state[1]", _random.state[1], SLE_UINT32),
SLEG_VAR("company_tick_counter", _cur_company_tick_index, SLE_FILE_U8 | SLE_VAR_U32),
SLEG_VAR("trees_tick_counter", _trees_tick_ctr, SLE_UINT8),
SLEG_CONDVAR("pause_mode", _pause_mode, SLE_UINT8, SLV_4, SL_MAX_VERSION),
SLEG_CONDVAR("next_competitor_start", _new_competitor_timeout.period.value, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_109),
SLEG_CONDVAR("next_competitor_start", _new_competitor_timeout.period.value, SLE_UINT32, SLV_109, SLV_AI_START_DATE),
SLEG_CONDVAR("competitors_interval", _new_competitor_timeout.period.value, SLE_UINT32, SLV_AI_START_DATE, SL_MAX_VERSION),
SLEG_CONDVAR("competitors_interval_elapsed", _new_competitor_timeout.storage.elapsed, SLE_UINT32, SLV_AI_START_DATE, SL_MAX_VERSION),
SLEG_CONDVAR("competitors_interval_fired", _new_competitor_timeout.fired, SLE_BOOL, SLV_AI_START_DATE, SL_MAX_VERSION),
}
static uint16_t sub_date_fract
Subpart of date_fract that we use when calendar days are slower than economy days.
static Date date
Current date in days (day counter).
static DateFract date_fract
Fractional part of the day.
static Date date
Current date in days (day counter).
static DateFract date_fract
Fractional part of the day.
static TickCounter counter
Monotonic counter, in ticks, since start of game.
uint _cur_company_tick_index
used to generate a name for one company that doesn't have a name yet per tick
Definition: company_cmd.cpp:56
TimeoutTimer< TimerGameTick > _new_competitor_timeout({ TimerGameTick::Priority::COMPETITOR_TIMEOUT, 0 }, []() { if(_game_mode==GM_MENU||!AI::CanStartNew()) return;if(_networking &&Company::GetNumItems() >=_settings_client.network.max_companies) return;uint8_t n=0;for(const Company *c :Company::Iterate()) { if(c->is_ai) n++;} if(n >=_settings_game.difficulty.max_no_competitors) return;Command< CMD_COMPANY_CTRL >::Post(CCA_NEW_AI, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);})
Start a new competitor company if possible.
PauseMode _pause_mode
The current pause mode.
Definition: gfx.cpp:50
GameSessionStats _game_session_stats
Statistics about the current session.
Definition: gfx.cpp:51
uint16_t _disaster_delay
Delay counter for considering the next disaster.
uint8_t _age_cargo_skip_counter
Skip aging of cargo? Used before savegame version 162.
Definition: misc_sl.cpp:79
uint8_t _trees_tick_ctr
Determines when to consider building more trees.
Definition: tree_cmd.cpp:55
Randomizer _random
Random used in the game state calculations.
Definition: random_func.cpp:37
#define SLEG_CONDSSTR(name, variable, type, from, to)
Storage of a global std::string in some savegame versions.
Definition: saveload.h:1105
#define SLEG_VAR(name, variable, type)
Storage of a global variable in every savegame version.
Definition: saveload.h:1151
@ SLV_AI_START_DATE
309 PR#10653 Removal of individual AI start dates and added a generic one.
Definition: saveload.h:350
@ SLV_4
4.0 1 4.1 122 0.3.3, 0.3.4 4.2 1222 0.3.5 4.3 1417 4.4 1426
Definition: saveload.h:37
@ SLV_6
6.0 1721 6.1 1768
Definition: saveload.h:46
@ SLV_SAVEGAME_ID
313 PR#10719 Add an unique ID to every savegame (used to deduplicate surveys).
Definition: saveload.h:355
@ SLV_CALENDAR_SUB_DATE_FRACT
328 PR#11428 Add sub_date_fract to measure calendar days.
Definition: saveload.h:373
@ SLV_ECONOMY_DATE
326 PR#10700 Split calendar and economy timers and dates.
Definition: saveload.h:371
@ SLV_109
109 15075
Definition: saveload.h:173
@ SLV_162
162 22713
Definition: saveload.h:237
@ SLV_U64_TICK_COUNTER
300 PR#10035 Make tick counter 64bit to avoid wrapping.
Definition: saveload.h:340
std::string savegame_id
Unique ID of the savegame.
Definition: openttd.h:57
uint32_t state[2]
The state of the randomizer.
Definition: random_func.hpp:29

Definition at line 82 of file misc_sl.cpp.

◆ _view_desc

const SaveLoad _view_desc[]
static
Initial value:
= {
SLEG_CONDVAR("x", _saved_scrollpos_x, SLE_FILE_I16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_6),
SLEG_CONDVAR("x", _saved_scrollpos_x, SLE_INT32, SLV_6, SL_MAX_VERSION),
SLEG_CONDVAR("y", _saved_scrollpos_y, SLE_FILE_I16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_6),
SLEG_CONDVAR("y", _saved_scrollpos_y, SLE_INT32, SLV_6, SL_MAX_VERSION),
SLEG_VAR("zoom", _saved_scrollpos_zoom, SLE_UINT8),
}

Definition at line 152 of file misc_sl.cpp.

◆ misc_chunk_handlers

const ChunkHandlerRef misc_chunk_handlers[]
static
Initial value:
= {
DATE,
VIEW,
}

Definition at line 183 of file misc_sl.cpp.