OpenTTD Source 20260208-master-g43af8e94d0
gamelog.cpp File Reference

Definition of functions used for logging of fundamental changes to the game. More...

#include "stdafx.h"
#include "saveload/saveload.h"
#include "string_func.h"
#include "settings_type.h"
#include "gamelog_internal.h"
#include "console_func.h"
#include "debug.h"
#include "timer/timer_game_calendar.h"
#include "timer/timer_game_tick.h"
#include "rev.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

static std::string GetGamelogRevisionString ()
 Return the revision string for the current client version, for use in gamelog.
static void AddGrfInfo (std::back_insert_iterator< std::string > &output_iterator, uint32_t grfid, const MD5Hash *md5sum, const GRFConfig *gc)
 Adds the GRF ID, checksum and filename if found to the output iterator.
static bool IsLoggableGrfConfig (const GRFConfig &g)
 Decides if GRF should be logged.
static std::vector< const GRFConfig * > GenerateGRFList (const GRFConfigList &grfc)
 Generates GRFList.

Variables

const SaveLoadVersion SAVEGAME_VERSION
 current savegame version
SavegameType _savegame_type
 type of savegame we are loading
uint32_t _ttdp_version
 version of TTDP savegame (if applicable)
SaveLoadVersion _sl_version
 the major savegame version identifier
uint8_t _sl_minor_version
 the minor savegame version, DO NOT USE!
Gamelog _gamelog
 Gamelog instance.
static const std::string_view la_text []
 Text messages for various logged actions.

Detailed Description

Definition of functions used for logging of fundamental changes to the game.

Definition in file gamelog.cpp.

Function Documentation

◆ AddGrfInfo()

void AddGrfInfo ( std::back_insert_iterator< std::string > & output_iterator,
uint32_t grfid,
const MD5Hash * md5sum,
const GRFConfig * gc )
static

Adds the GRF ID, checksum and filename if found to the output iterator.

Parameters
output_iteratorThe iterator to add the GRF info to.
grfidGRF ID
md5sumarray of md5sum to print, if known
gcGrfConfig, if known

Definition at line 108 of file gamelog.cpp.

References FGCM_ANY, GRFConfig::filename, FindGRFConfig(), and FormatArrayAsHex().

Referenced by LoggedChangeGRFAdd::FormatTo(), LoggedChangeGRFBug::FormatTo(), LoggedChangeGRFChanged::FormatTo(), LoggedChangeGRFMoved::FormatTo(), LoggedChangeGRFParameterChanged::FormatTo(), and LoggedChangeGRFRemoved::FormatTo().

◆ GenerateGRFList()

std::vector< const GRFConfig * > GenerateGRFList ( const GRFConfigList & grfc)
static

Generates GRFList.

Parameters
grfcthe GRFConfigList.

Definition at line 590 of file gamelog.cpp.

References IsLoggableGrfConfig().

Referenced by Gamelog::GRFUpdate().

◆ GetGamelogRevisionString()

std::string GetGamelogRevisionString ( )
static

Return the revision string for the current client version, for use in gamelog.

Definition at line 47 of file gamelog.cpp.

Referenced by Gamelog::Revision(), and Gamelog::TestRevision().

◆ IsLoggableGrfConfig()

bool IsLoggableGrfConfig ( const GRFConfig & g)
inlinestatic

Decides if GRF should be logged.

Parameters
ggrf to determine
Returns
true iff GRF is not static and is loaded

Definition at line 507 of file gamelog.cpp.

References GRFConfig::flags, GCS_NOT_FOUND, Static, GRFConfig::status, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by GenerateGRFList(), and Gamelog::GRFAdd().

Variable Documentation

◆ _gamelog

◆ _savegame_type

SavegameType _savegame_type
extern

type of savegame we are loading

Definition at line 77 of file saveload.cpp.

Referenced by Order::ConvertFromOldSavegame(), DoLoad(), LoadChunk(), LoadOldCustomString(), Vehicle::LoadOldVehicle, and Gamelog::Oldver().

◆ _sl_minor_version

uint8_t _sl_minor_version
extern

the minor savegame version, DO NOT USE!

Definition at line 82 of file saveload.cpp.

Referenced by DetermineSaveLoadFormat(), IsSavegameVersionBefore(), Gamelog::Oldver(), and SaveOrLoad().

◆ _sl_version

◆ _ttdp_version

uint32_t _ttdp_version
extern

version of TTDP savegame (if applicable)

Definition at line 80 of file saveload.cpp.

Referenced by Gamelog::Oldver().

◆ la_text

const std::string_view la_text[]
static
Initial value:
= {
"new game started",
"game loaded",
"GRF config changed",
"cheat was used",
"settings changed",
"GRF bug triggered",
"emergency savegame",
}

Text messages for various logged actions.

Definition at line 130 of file gamelog.cpp.

Referenced by Gamelog::Print().