14#include "script/script_gui.h"
33#include "viewport_kdtree.h"
35#include "3rdparty/monocypher/monocypher.h"
40extern void MakeNewgameSettingsLive();
42void InitializeSound();
44void InitializeVehicles();
46void InitializeRoadGui();
47void InitializeAirportGui();
48void InitializeDockGui();
49void InitializeGraphGui();
51void InitializeTownGui();
52void InitializeIndustries();
54void InitializeTrees();
68 std::array<uint8_t, 32> random_bytes;
71 auto current_time = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
72 std::string coding_string = fmt::format(
"{}{}", current_time, subject);
74 std::array<uint8_t, 16> digest;
75 crypto_blake2b_ctx ctx;
76 crypto_blake2b_init(&ctx, digest.size());
77 crypto_blake2b_update(&ctx, random_bytes.data(), random_bytes.size());
78 crypto_blake2b_update(&ctx,
reinterpret_cast<const uint8_t *
>(coding_string.data()), coding_string.size());
79 crypto_blake2b_final(&ctx, digest.data());
92void InitializeGame(uint size_x, uint size_y,
bool reset_date,
bool reset_settings)
103 _cur_tileloop_tile = 1;
105 if (reset_settings) MakeNewgameSettingsLive();
107 _newgrf_profilers.clear();
126 RebuildStationKdtree();
128 RebuildViewportKdtree();
135 InitializeVehicles();
138 InitializeLandscape();
141 InitializeAirportGui();
143 InitializeGraphGui();
148 InitializeIndustries();
Base functions for all AIs.
void InitializeAnimatedTiles()
Initialize all animated tile variables to some known begin point.
static void Initialize()
Initialize the AI system.
static void Initialize()
Initialize the Game system.
void Mode()
Logs a change in game mode (scenario editor or game)
void GRFAddList(const GRFConfig *newg)
Logs adding of list of GRFs.
void Revision()
Logs a change in game revision.
void StartAction(GamelogActionType at)
Stores information about new action, but doesn't allocate it Action is allocated only when there is a...
void Reset()
Resets and frees all memory allocated - used before loading or starting a new game.
void StopAction()
Stops logging of any changes.
static void Clear()
Clear all link graphs and jobs from the schedule.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static void SetDate(Date date, DateFract fract)
Set the date.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
static void SetDate(Date date, DateFract fract)
Set the date.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static TickCounter counter
Monotonic counter, in ticks, since start of game.
void InitializeEconomy()
Resets economy to initial values.
Functions related to the economy.
Base functions for all Games.
Gamelog _gamelog
Gamelog instance.
Functions to be called to log fundamental changes to the game.
@ GLAT_START
Game created.
PauseMode _pause_mode
The current pause mode.
uint16_t _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
GameSessionStats _game_session_stats
Statistics about the current session.
Functions related to the gfx engine.
Functions related to OTTD's landscape.
Declaration of link graph schedule used for cargo distribution.
void InitializeObjects()
Initialize/reset the objects.
void InitializeCheats()
Reinitialise all the cheats.
void GenerateSavegameId()
Generate an unique savegame ID.
void InitializeObjectGui()
Reset all data of the object GUI.
std::string GenerateUid(std::string_view subject)
Generate an unique ID.
void InitializeMusic()
Prepare the music system for use.
void InitializeRailGui()
Initialize rail building GUI settings.
void InitializeCompanies()
Initialize the pool of companies.
void InitializeOldNames()
Initialize the old names table memory.
void NetworkInitChatMessage()
Initialize all buffers of the chat visualisation.
Network functions used by other parts of OpenTTD.
void ResetPersistentNewGRFData()
Reset NewGRF data which is stored persistently in savegames.
Base for the NewGRF implementation.
GRFConfig * _grfconfig
First item in list of current GRF set up.
Functions related to NewGRF houses.
Profiling of NewGRF action 2 handling.
Functions related to news.
void InitNewsItemStructs()
Initialize the news-items data structures.
@ PM_UNPAUSED
A normal unpaused game.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
@ PT_NORMAL
Normal pool containing game objects.
void RandomBytesWithFallback(std::span< uint8_t > buf)
Fill the given buffer with random bytes.
A number of safeguards to prevent using unsafe methods.
void InitializeScriptGui()
Reset the Script windows to their initial state.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Declarations for accessing the k-d tree of stations.
Definition of base types and functions in a cross-platform compatible way.
std::string FormatArrayAsHex(std::span< const uint8_t > data)
Format a byte array into a continuous hex string.
TimerGameCalendar::Year starting_year
starting date
std::string savegame_id
Unique ID of the savegame.
GameCreationSettings game_creation
settings used during the creation of a game (map)
static void Allocate(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
static void Clean(PoolType)
Clean all pools of given type.
TileIndex redsq
The tile that has to get a red selection.
Functions related to text effects.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition of the game-calendar-timer.
Definition of the game-economy-timer.
Definition of the tick-based game-timer.
Declarations for accessing the k-d tree of towns.
void UnInitWindowSystem()
Close down the windowing system.
Window functions not directly related to making/drawing windows.