OpenTTD Source  20240919-master-gdf0233f4c2
Gamelog Class Reference

Public Member Functions

void StartAction (GamelogActionType at)
 Stores information about new action, but doesn't allocate it Action is allocated only when there is at least one change. More...
 
void StopAction ()
 Stops logging of any changes.
 
void StopAnyAction ()
 
void Reset ()
 Resets and frees all memory allocated - used before loading or starting a new game.
 
void Print (std::function< void(const std::string &)> proc)
 Prints active gamelog. More...
 
void PrintDebug (int level)
 Prints gamelog to debug output. More...
 
void PrintConsole ()
 Print the gamelog data to the console.
 
void Emergency ()
 Logs a emergency savegame.
 
bool TestEmergency ()
 Finds out if current game is a loaded emergency savegame.
 
void Revision ()
 Logs a change in game revision.
 
void Mode ()
 Logs a change in game mode (scenario editor or game)
 
void Oldver ()
 Logs loading from savegame without gamelog.
 
void Setting (const std::string &name, int32_t oldval, int32_t newval)
 Logs change in game settings. More...
 
void GRFUpdate (const GRFConfig *oldg, const GRFConfig *newg)
 Compares two NewGRF lists and logs any change. More...
 
void GRFAddList (const GRFConfig *newg)
 Logs adding of list of GRFs. More...
 
void GRFRemove (uint32_t grfid)
 Logs removal of a GRF. More...
 
void GRFAdd (const GRFConfig *newg)
 Logs adding of a GRF. More...
 
void GRFBug (uint32_t grfid, uint8_t bug, uint64_t data)
 Logs triggered GRF bug. More...
 
bool GRFBugReverse (uint32_t grfid, uint16_t internal_id)
 Logs GRF bug - rail vehicle has different length after reversing. More...
 
void GRFCompatible (const GRFIdentifier *newg)
 Logs loading compatible GRF (the same ID, but different MD5 hash) More...
 
void GRFMove (uint32_t grfid, int32_t offset)
 Logs changing GRF order. More...
 
void GRFParameters (uint32_t grfid)
 Logs change in GRF parameters. More...
 
void TestRevision ()
 Finds out if current revision is different than last revision stored in the savegame. More...
 
void TestMode ()
 Finds last stored game mode or landscape. More...
 
void Info (uint32_t *last_ottd_rev, uint8_t *ever_modified, bool *removed_newgrfs)
 Get some basic information from the given gamelog. More...
 
const GRFIdentifierGetOverriddenIdentifier (const GRFConfig *c)
 Try to find the overridden GRF identifier of the given GRF. More...
 

Private Member Functions

void Change (std::unique_ptr< LoggedChange > &&change)
 Allocates a new LoggedAction if needed, and add the change when action is active. More...
 

Private Attributes

std::unique_ptr< GamelogInternalDatadata
 
GamelogActionType action_type
 
struct LoggedActioncurrent_action
 

Friends

struct GLOGChunkHandler
 

Detailed Description

Definition at line 49 of file gamelog.h.

Member Function Documentation

◆ Change()

void Gamelog::Change ( std::unique_ptr< LoggedChange > &&  change)
private

Allocates a new LoggedAction if needed, and add the change when action is active.

Parameters
changeThe actual change.

Definition at line 335 of file gamelog.cpp.

References LoggedAction::at, LoggedAction::change, TimerGameTick::counter, GLAT_NONE, and LoggedAction::tick.

Referenced by Emergency(), GRFAdd(), GRFBug(), GRFCompatible(), GRFMove(), GRFParameters(), GRFRemove(), Mode(), Oldver(), Revision(), and Setting().

◆ GetOverriddenIdentifier()

const GRFIdentifier * Gamelog::GetOverriddenIdentifier ( const GRFConfig c)

Try to find the overridden GRF identifier of the given GRF.

Parameters
cthe GRF to get the 'previous' version of.
Returns
the GRF identifier or c if none could be found.

Definition at line 712 of file gamelog.cpp.

References LoggedAction::at, LoggedAction::change, GLAT_LOAD, GLCT_GRFCOMPAT, GRFIdentifier::grfid, and GRFConfig::ident.

Referenced by HandleSavegameLoadCrash().

◆ GRFAdd()

void Gamelog::GRFAdd ( const GRFConfig newg)

Logs adding of a GRF.

Parameters
newgadded GRF

Definition at line 528 of file gamelog.cpp.

References Change(), GLAT_GRF, GLAT_LOAD, GLAT_START, GRFConfig::ident, and IsLoggableGrfConfig().

Referenced by GRFAddList(), and GRFUpdate().

◆ GRFAddList()

void Gamelog::GRFAddList ( const GRFConfig newg)

Logs adding of list of GRFs.

Useful when old savegame is loaded or when new game is started

Parameters
newghead of GRF linked list

Definition at line 578 of file gamelog.cpp.

References GLAT_LOAD, GLAT_START, GRFAdd(), and GRFConfig::next.

◆ GRFBug()

void Gamelog::GRFBug ( uint32_t  grfid,
uint8_t  bug,
uint64_t  data 
)

Logs triggered GRF bug.

Parameters
grfidID of problematic GRF
bugtype of bug,
See also
enum GRFBugs
Parameters
dataadditional data

Definition at line 466 of file gamelog.cpp.

References Change(), and GLAT_GRFBUG.

◆ GRFBugReverse()

bool Gamelog::GRFBugReverse ( uint32_t  grfid,
uint16_t  internal_id 
)

Logs GRF bug - rail vehicle has different length after reversing.

Ensures this is logged only once for each GRF and engine type This check takes some time, but it is called pretty seldom, so it doesn't matter that much (ideally it shouldn't be called at all).

Parameters
grfidthe broken NewGRF
internal_idthe internal ID of whatever's broken in the NewGRF
Returns
true iff a unique record was done

Definition at line 482 of file gamelog.cpp.

Referenced by VehicleLengthChanged().

◆ GRFCompatible()

void Gamelog::GRFCompatible ( const GRFIdentifier newg)

Logs loading compatible GRF (the same ID, but different MD5 hash)

Parameters
newgnew (updated) GRF

Definition at line 542 of file gamelog.cpp.

References Change(), GLAT_GRF, and GLAT_LOAD.

Referenced by GRFUpdate().

◆ GRFMove()

void Gamelog::GRFMove ( uint32_t  grfid,
int32_t  offset 
)

Logs changing GRF order.

Parameters
grfidGRF that is moved
offsethow far it is moved, positive = moved down

Definition at line 554 of file gamelog.cpp.

References Change(), and GLAT_GRF.

Referenced by GRFUpdate().

◆ GRFParameters()

void Gamelog::GRFParameters ( uint32_t  grfid)

Logs change in GRF parameters.

Details about parameters changed are not stored

Parameters
grfidID of GRF to store

Definition at line 566 of file gamelog.cpp.

References Change(), and GLAT_GRF.

Referenced by GRFUpdate().

◆ GRFRemove()

void Gamelog::GRFRemove ( uint32_t  grfid)

Logs removal of a GRF.

Parameters
grfidID of removed GRF

Definition at line 517 of file gamelog.cpp.

References Change(), GLAT_GRF, and GLAT_LOAD.

Referenced by GRFUpdate().

◆ GRFUpdate()

void Gamelog::GRFUpdate ( const GRFConfig oldc,
const GRFConfig newc 
)

Compares two NewGRF lists and logs any change.

Parameters
oldcoriginal GRF list
newcnew GRF list

Definition at line 606 of file gamelog.cpp.

References GenerateGRFList(), GRFAdd(), GRFCompatible(), GRFIdentifier::grfid, GRFMove(), GRFParameters(), GRFRemove(), GRFConfig::ident, GRFIdentifier::md5sum, GRFConfig::num_params, and GRFConfig::param.

Referenced by NewGRFConfirmationCallback().

◆ Info()

void Gamelog::Info ( uint32_t *  last_ottd_rev,
uint8_t *  ever_modified,
bool *  removed_newgrfs 
)

Get some basic information from the given gamelog.

Parameters
[out]last_ottd_revOpenTTD NewGRF version from the binary that saved the savegame last.
[out]ever_modifiedMax value of 'modified' from all binaries that ever saved this savegame.
[out]removed_newgrfsSet to true if any NewGRFs have been removed.

Definition at line 685 of file gamelog.cpp.

References LoggedAction::change, GLCT_GRFREM, GLCT_REVISION, and LoggedChangeRevision::newgrf.

◆ Print()

void Gamelog::Print ( std::function< void(const std::string &)>  proc)

Prints active gamelog.

Parameters
procthe procedure to draw with

Definition at line 147 of file gamelog.cpp.

References LoggedAction::at, LoggedAction::change, GLAT_END, la_text, and LoggedAction::tick.

Referenced by PrintConsole(), PrintDebug(), and SurveyGamelog().

◆ PrintDebug()

void Gamelog::PrintDebug ( int  level)

Prints gamelog to debug output.

Code is executed even when there will be no output. It is called very seldom, so it doesn't matter that much. At least it gives more uniform code...

Parameters
leveldebug level we need to print stuff

Definition at line 323 of file gamelog.cpp.

References Debug, and Print().

Referenced by StopAction().

◆ Setting()

void Gamelog::Setting ( const std::string &  name,
int32_t  oldval,
int32_t  newval 
)

Logs change in game settings.

Only non-networksafe settings are logged

Parameters
namesetting name
oldvalold setting value
newvalnew setting value

Definition at line 413 of file gamelog.cpp.

References Change(), and GLAT_SETTING.

Referenced by IntSettingDesc::ChangeValue().

◆ StartAction()

void Gamelog::StartAction ( GamelogActionType  at)

Stores information about new action, but doesn't allocate it Action is allocated only when there is at least one change.

Parameters
attype of action

Definition at line 65 of file gamelog.cpp.

References GLAT_NONE.

Referenced by IntSettingDesc::ChangeValue(), Emergency(), and NewGRFConfirmationCallback().

◆ TestMode()

void Gamelog::TestMode ( )

Finds last stored game mode or landscape.

Any change is logged

Definition at line 446 of file gamelog.cpp.

References LoggedAction::change, GLCT_MODE, and LoggedChangeMode::mode.

◆ TestRevision()

void Gamelog::TestRevision ( )

Finds out if current revision is different than last revision stored in the savegame.

Appends GLCT_REVISION when the revision string changed

Definition at line 425 of file gamelog.cpp.

References LoggedAction::change, GetGamelogRevisionString(), GLCT_REVISION, and LoggedChangeRevision::text.


The documentation for this class was generated from the following files: