OpenTTD Source 20260711-master-g3fb3006dff
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
 Save load date related variables as well as persistent tick counters. More...
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.
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 []
int _saved_scrollpos_x
int _saved_scrollpos_y
ZoomLevel _saved_scrollpos_zoom

Detailed Description

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

Definition in file misc_sl.cpp.

Function Documentation

◆ ResetViewportAfterLoadGame()

void ResetViewportAfterLoadGame ( )

Definition at line 56 of file misc_sl.cpp.

◆ SaveViewportBeforeSaveGame()

void SaveViewportBeforeSaveGame ( )

Definition at line 40 of file misc_sl.cpp.

Variable Documentation

◆ _age_cargo_skip_counter

uint8_t _age_cargo_skip_counter

Skip aging of cargo? Used before savegame version 162.

Definition at line 83 of file misc_sl.cpp.

Referenced by OrderList::AfterLoadVehiclesPhase1.

◆ _cur_tileloop_tile

TileIndex _cur_tileloop_tile
extern

Definition at line 799 of file landscape.cpp.

◆ _date_check_desc

const SaveLoad _date_check_desc[]
static
Initial value:
= {
}
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
Definition fios_gui.cpp:41
@ I32
A 32 bit signed int.
Definition saveload.h:683
@ U16
A 16 bit unsigned int.
Definition saveload.h:664
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition saveload.h:1124
@ BigDates
Saveload version: 31, SVN revision: 5999 Change date from 1920 - 2090 to 0 - 5 000 000.
Definition saveload.h:81
@ MinVersion
First savegame version.
Definition saveload.h:31
@ MaxVersion
Highest possible saveload version.
Definition saveload.h:421
static constexpr VarType I32
Store a 32 bits signed int.
Definition saveload.h:755

Definition at line 114 of file misc_sl.cpp.

◆ _date_desc

const SaveLoad _date_desc[]
static
Initial value:
= {
SLEG_VAR("next_disaster_start", _disaster_delay, VarTypes::U16),
SLEG_VAR("random_state[0]", _random.state[0], VarTypes::U32),
SLEG_VAR("random_state[1]", _random.state[1], VarTypes::U32),
SLEG_VAR("trees_tick_counter", _trees_tick_ctr, VarTypes::U8),
}
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 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==GameMode::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(CompanyCtrlAction::NewAI, CompanyID::Invalid(), CompanyRemoveReason::None, ClientID::Invalid);})
Start a new competitor company if possible.
uint16_t _disaster_delay
Delay counter for considering the next disaster.
GameSessionStats _game_session_stats
Statistics about the current session.
Definition gfx.cpp:52
PauseModes _pause_mode
The current pause mode.
Definition gfx.cpp:51
uint8_t _age_cargo_skip_counter
Skip aging of cargo? Used before savegame version 162.
Definition misc_sl.cpp:83
uint8_t _trees_tick_ctr
Determines when to consider building more trees.
Definition tree_cmd.cpp:45
Randomizer _random
Random used in the game state calculations.
@ U64
A 64 bit unsigned int.
Definition saveload.h:686
@ U32
A 32 bit unsigned int.
Definition saveload.h:684
@ U8
A 8 bit unsigned int.
Definition saveload.h:662
#define SLEG_CONDSSTR(name, variable, type, from, to)
Storage of a global std::string in some savegame versions.
Definition saveload.h:1155
#define SLEG_VAR(name, variable, type)
Storage of a global variable in every savegame version.
Definition saveload.h:1201
@ TownTolerancePauseMode
Saveload version: 4.0, SVN revision: 1 Town council tolerance and pause mode.
Definition saveload.h:38
@ U64TickCounter
Saveload version: 300, GitHub pull request: 10035 Make tick counter 64bit to avoid wrapping.
Definition saveload.h:340
@ AIStartDate
Saveload version: 309, GitHub pull request: 10653 Removal of individual AI start dates and added a g...
Definition saveload.h:350
@ MultipleRoadStops
Saveload version: 6.0, SVN revision: 1721 Multi tile road stops, and some map size related fixes.
Definition saveload.h:47
@ SavegameId
Saveload version: 313, GitHub pull request: 10719 Add an unique ID to every savegame (used to dedupl...
Definition saveload.h:355
@ NewGRFCustomCargoAging
Saveload version: 162, SVN revision: 22713 NewGRF influence on aging of cargo in vehicles.
Definition saveload.h:238
@ NextCompetitorStartOverflow
Saveload version: 109, SVN revision: 15075 Prevent overflow in the next competitor start counter.
Definition saveload.h:174
@ EconomyDate
Saveload version: 326, GitHub pull request: 10700 Split calendar and economy timers and dates.
Definition saveload.h:371
@ IndustryAcceptedHistory
Saveload version: 357, GitHub pull request: 14321 Add per-industry history of cargo delivered and wa...
Definition saveload.h:408
@ CalendarSubDateFract
Saveload version: 328, GitHub pull request: 11428 Add sub_date_fract to measure calendar days.
Definition saveload.h:373
static constexpr VarType U16
Store a 16 bits unsigned int.
Definition saveload.h:754
static constexpr VarType U8
Store a 8 bits unsigned int.
Definition saveload.h:752
static constexpr VarType STR
Store string.
Definition saveload.h:760
static constexpr VarType U64
Store a 64 bits unsigned int.
Definition saveload.h:758
static constexpr VarType U32
Store a 32 bits unsigned int.
Definition saveload.h:756
static constexpr VarType BOOL
Store a boolean (as int8).
Definition saveload.h:750

Definition at line 86 of file misc_sl.cpp.

◆ _disaster_delay

uint16_t _disaster_delay
extern

Delay counter for considering the next disaster.

Definition at line 57 of file disaster_vehicle.cpp.

◆ _saved_scrollpos_x

int _saved_scrollpos_x

Keep track of current game position.

Definition at line 35 of file misc_sl.cpp.

Referenced by AfterLoadGame().

◆ _saved_scrollpos_y

int _saved_scrollpos_y

Keep track of current game position.

Definition at line 36 of file misc_sl.cpp.

Referenced by AfterLoadGame().

◆ _saved_scrollpos_zoom

ZoomLevel _saved_scrollpos_zoom

Keep track of current game position.

Definition at line 37 of file misc_sl.cpp.

Referenced by AfterLoadGame().

◆ _trees_tick_ctr

uint8_t _trees_tick_ctr
extern

Determines when to consider building more trees.

Definition at line 45 of file tree_cmd.cpp.

Referenced by DecrementTreeCounter().

◆ _view_desc

◆ DATE

const DATEChunkHandler DATE
static

Definition at line 188 of file misc_sl.cpp.

◆ misc_chunk_handlers

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

Definition at line 190 of file misc_sl.cpp.

◆ VIEW

const VIEWChunkHandler VIEW
static

Definition at line 189 of file misc_sl.cpp.