OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
15 #include "../timer/timer_game_calendar.h"
16 #include "../timer/timer_game_economy.h"
17 #include "../zoom_func.h"
18 #include "../window_gui.h"
19 #include "../window_func.h"
20 #include "../viewport_func.h"
21 #include "../gfx_func.h"
22 #include "../core/random_func.hpp"
24 #include "../timer/timer.h"
25 #include "../timer/timer_game_tick.h"
27 #include "../safeguards.h"
34 int _saved_scrollpos_x;
35 int _saved_scrollpos_y;
38 void SaveViewportBeforeSaveGame()
42 if (w ==
nullptr || w->
viewport ==
nullptr) {
44 _saved_scrollpos_x = INT_MAX;
45 _saved_scrollpos_y = INT_MAX;
54 void ResetViewportAfterLoadGame()
82 static const SaveLoad _date_desc[] = {
109 static const SaveLoad _date_check_desc[] = {
152 static const SaveLoad _view_desc[] = {
157 SLEG_VAR(
"zoom", _saved_scrollpos_zoom, SLE_UINT8),
static TickCounter counter
Monotonic counter, in ticks, since start of game.
static constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
The date of the first day of the original base year.
@ ZOOM_OUT
Zoom out (get helicopter view).
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
@ SLV_U64_TICK_COUNTER
300 PR#10035 Make tick counter 64bit to avoid wrapping.
#define SLEG_CONDSSTR(name, variable, type, from, to)
Storage of a global std::string in some savegame versions.
static DateFract date_fract
Fractional part of the day.
int width
Screen width of the viewport.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
@ ZOOM_LVL_END
End for iteration.
@ SL_MIN_VERSION
First savegame version.
ViewportData * viewport
Pointer to viewport data, if present.
int height
Screen height of the viewport.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
@ ZOOM_NONE
Hack, used to update the button status.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
@ SLV_ECONOMY_DATE
326 PR#10700 Split calendar and economy timers and dates.
void Load() const override
Load the chunk.
const SaveLoadCompat _date_check_sl_compat[]
Original field order for _date_check_desc.
TimeoutTimer< TimerGameTick > _new_competitor_timeout
Start a new competitor company if possible.
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
Randomizer _random
Random used in the game state calculations.
static DateFract date_fract
Fractional part of the day.
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
ClientSettings _settings_client
The current settings for this game.
int32_t dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
void Save() const override
Save the chunk.
static uint16_t sub_date_fract
Subpart of date_fract that we use when calendar days are slower than economy days.
Handlers and description of chunk.
ZoomLevel zoom_max
maximum zoom out level
@ ZOOM_LVL_MIN
Minimum zoom level.
void SlGlobList(const SaveLoadTable &slt)
Save or Load (a list of) global variables.
@ SLV_CALENDAR_SUB_DATE_FRACT
328 PR#11428 Add sub_date_fract to measure calendar days.
@ ZOOM_IN
Zoom in (get more detailed view).
Data structure for viewport, display of a part of the world.
int32_t dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
std::string savegame_id
Unique ID of the savegame.
#define SLEG_VAR(name, variable, type)
Storage of a global variable in every savegame version.
PauseMode _pause_mode
The current pause mode.
int32_t scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
@ SLV_RIFF_TO_ARRAY
294 PR#9375 Changed many CH_RIFF chunks to CH_ARRAY chunks.
@ SL_MAX_VERSION
Highest possible saveload version.
const SaveLoadCompat _date_sl_compat[]
Original field order for _date_desc.
uint16_t _disaster_delay
Delay counter for considering the next disaster.
int virtual_width
width << zoom
@ 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
GameSessionStats _game_session_stats
Statistics about the current session.
uint _cur_company_tick_index
used to generate a name for one company that doesn't have a name yet per tick
ZoomLevel zoom_min
minimum zoom out level
void Load() const override
Load the chunk.
void LoadCheck(size_t) const override
Load the chunk for game preview.
@ ZOOM_LVL_MAX
Maximum zoom level.
A timeout timer will fire once after the interval.
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
const SaveLoadCompat _view_sl_compat[]
Original field order for _view_desc.
Window * GetMainWindow()
Get the main window, i.e.
int32_t scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
@ WC_MAIN_WINDOW
Main window; Window numbers:
@ SLV_AI_START_DATE
309 PR#10653 Removal of individual AI start dates and added a generic one.
ZoomLevel zoom
The zoom level of the viewport.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
uint32_t state[2]
The state of the randomizer.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
uint8_t _trees_tick_ctr
Determines when to consider building more trees.
static Date date
Current date in days (day counter).
@ SLV_SAVEGAME_ID
313 PR#10719 Add an unique ID to every savegame (used to deduplicate surveys).
Data structure for an opened window.
void Save() const override
Save the chunk.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
int virtual_height
height << zoom
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_MIN) When shifting right,...
uint8_t _age_cargo_skip_counter
Skip aging of cargo? Used before savegame version 162.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
GUISettings gui
settings related to the GUI
ZoomLevel
All zoom levels we know.
static Date date
Current date in days (day counter).