34int _saved_scrollpos_x;
35int _saved_scrollpos_y;
38void SaveViewportBeforeSaveGame()
42 if (w ==
nullptr || w->
viewport ==
nullptr) {
44 _saved_scrollpos_x = INT_MAX;
45 _saved_scrollpos_y = INT_MAX;
48 _saved_scrollpos_x = w->
viewport->scrollpos_x;
49 _saved_scrollpos_y = w->
viewport->scrollpos_y;
50 _saved_scrollpos_zoom = w->
viewport->zoom;
54void ResetViewportAfterLoadGame()
58 w->
viewport->scrollpos_x = _saved_scrollpos_x;
59 w->
viewport->scrollpos_y = _saved_scrollpos_y;
60 w->
viewport->dest_scrollpos_x = _saved_scrollpos_x;
61 w->
viewport->dest_scrollpos_y = _saved_scrollpos_y;
82static const SaveLoad _date_desc[] = {
110static const SaveLoad _date_check_desc[] = {
117struct DATEChunkHandler : ChunkHandler {
118 DATEChunkHandler() : ChunkHandler(
'DATE', CH_TABLE) {}
153static const SaveLoad _view_desc[] = {
158 SLEG_VAR(
"zoom", _saved_scrollpos_zoom, SLE_UINT8),
161struct VIEWChunkHandler : ChunkHandler {
162 VIEWChunkHandler() : ChunkHandler(
'VIEW', CH_TABLE) {}
A timeout timer will fire once after the interval.
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 constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
static Date date
Current date in days (day counter).
static DateFract date_fract
Fractional part of the day.
static uint days_since_last_month
Number of days that have elapsed since the last month.
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
TimeoutTimer< TimerGameTick > _new_competitor_timeout({ TimerGameTick::Priority::CompetitorTimeout, 0 }, []() { if(_game_mode==GM_MENU||!AI::CanStartNew()) return;if(_networking &&Company::GetNumItems() >=_settings_client.network.max_companies) return;if(_settings_game.difficulty.competitors_interval==0) 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< Commands::CompanyControl >::Post(CCA_NEW_AI, CompanyID::Invalid(), CRR_NONE, INVALID_CLIENT_ID);})
Start a new competitor company if possible.
uint16_t _disaster_delay
Delay counter for considering the next disaster.
Declarations for savegames operations.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
GameSessionStats _game_session_stats
Statistics about the current session.
PauseModes _pause_mode
The current pause mode.
Functions related to the gfx engine.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
uint8_t _age_cargo_skip_counter
Skip aging of cargo? Used before savegame version 162.
uint8_t _trees_tick_ctr
Determines when to consider building more trees.
Loading for misc chunks before table headers were added.
const SaveLoadCompat _date_check_sl_compat[]
Original field order for _date_check_desc.
const SaveLoadCompat _date_sl_compat[]
Original field order for _date_desc.
const SaveLoadCompat _view_sl_compat[]
Original field order for _view_desc.
Randomizer _random
Random used in the game state calculations.
Pseudo random number generator.
A number of safeguards to prevent using unsafe methods.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlGlobList(const SaveLoadTable &slt)
Save or Load (a list of) global variables.
Functions/types related to saving and loading games.
#define SLEG_CONDSSTR(name, variable, type, from, to)
Storage of a global std::string in some savegame versions.
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
#define SLEG_VAR(name, variable, type)
Storage of a global variable in every savegame version.
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ SLV_AI_START_DATE
309 PR#10653 Removal of individual AI start dates and added a generic one.
@ 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
@ SLV_SAVEGAME_ID
313 PR#10719 Add an unique ID to every savegame (used to deduplicate surveys).
@ SLV_CALENDAR_SUB_DATE_FRACT
328 PR#11428 Add sub_date_fract to measure calendar days.
@ SLV_RIFF_TO_ARRAY
294 PR#9375 Changed many CH_RIFF chunks to CH_ARRAY chunks.
@ SL_MAX_VERSION
Highest possible saveload version.
@ SL_MIN_VERSION
First savegame version.
@ SLV_ECONOMY_DATE
326 PR#10700 Split calendar and economy timers and dates.
@ SLV_INDUSTRY_ACCEPTED_HISTORY
357 PR#14321 Add per-industry history of cargo delivered and waiting.
@ SLV_U64_TICK_COUNTER
300 PR#10035 Make tick counter 64bit to avoid wrapping.
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
ClientSettings _settings_client
The current settings for this game.
Definition of base types and functions in a cross-platform compatible way.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void LoadCheck(size_t) const override
Load the chunk for game preview.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
Data structure for viewport, display of a part of the world.
int width
Screen width of the viewport.
ZoomLevel zoom
The zoom level of the viewport.
int virtual_width
width << zoom
int height
Screen height of the viewport.
int virtual_height
height << zoom
Data structure for an opened window.
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.
Definition of the tick-based game-timer.
Functions related to (drawing on) viewports.
@ ZOOM_IN
Zoom in (get more detailed view).
@ ZOOM_NONE
Hack, used to update the button status.
@ ZOOM_OUT
Zoom out (get helicopter view).
Window * GetMainWindow()
Get the main window, i.e.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WC_MAIN_WINDOW
Main window; Window numbers:
Functions related to zooming.
int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZoomLevel::Min) When shifting right,...
ZoomLevel
All zoom levels we know.