OpenTTD Source  1.11.2
gamelog.h File Reference
#include "newgrf_config.h"

Go to the source code of this file.

Typedefs

typedef void GamelogPrintProc(const char *s)
 Callback for printing text. More...
 

Enumerations

enum  GamelogActionType {
  GLAT_START, GLAT_LOAD, GLAT_GRF, GLAT_CHEAT,
  GLAT_SETTING, GLAT_GRFBUG, GLAT_EMERGENCY, GLAT_END,
  GLAT_NONE = 0xFF
}
 The actions we log. More...
 

Functions

void GamelogStartAction (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 GamelogStopAction ()
 Stops logging of any changes.
 
void GamelogStopAnyAction ()
 
void GamelogFree (struct LoggedAction *gamelog_action, uint gamelog_actions)
 Frees the memory allocated by a gamelog.
 
void GamelogReset ()
 Resets and frees all memory allocated - used before loading or starting a new game.
 
void GamelogPrint (GamelogPrintProc *proc)
 Prints active gamelog. More...
 
void GamelogPrintDebug (int level)
 Prints gamelog to debug output. More...
 
void GamelogPrintConsole ()
 Print the gamelog data to the console.
 
void GamelogEmergency ()
 Logs a emergency savegame.
 
bool GamelogTestEmergency ()
 Finds out if current game is a loaded emergency savegame.
 
void GamelogRevision ()
 Logs a change in game revision.
 
void GamelogMode ()
 Logs a change in game mode (scenario editor or game)
 
void GamelogOldver ()
 Logs loading from savegame without gamelog.
 
void GamelogSetting (const char *name, int32 oldval, int32 newval)
 Logs change in game settings. More...
 
void GamelogGRFUpdate (const GRFConfig *oldg, const GRFConfig *newg)
 Compares two NewGRF lists and logs any change. More...
 
void GamelogGRFAddList (const GRFConfig *newg)
 Logs adding of list of GRFs. More...
 
void GamelogGRFRemove (uint32 grfid)
 Logs removal of a GRF. More...
 
void GamelogGRFAdd (const GRFConfig *newg)
 Logs adding of a GRF. More...
 
void GamelogGRFCompatible (const GRFIdentifier *newg)
 Logs loading compatible GRF (the same ID, but different MD5 hash) More...
 
void GamelogTestRevision ()
 Finds out if current revision is different than last revision stored in the savegame. More...
 
void GamelogTestMode ()
 Finds last stored game mode or landscape. More...
 
bool GamelogGRFBugReverse (uint32 grfid, uint16 internal_id)
 Logs GRF bug - rail vehicle has different length after reversing. More...
 
void GamelogInfo (struct LoggedAction *gamelog_action, uint gamelog_actions, uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs)
 Get some basic information from the given gamelog. More...
 

Detailed Description

Functions to be called to log possibly unsafe game events

Definition in file gamelog.h.

Typedef Documentation

◆ GamelogPrintProc

typedef void GamelogPrintProc(const char *s)

Callback for printing text.

Parameters
sThe string to print.

Definition at line 39 of file gamelog.h.

Enumeration Type Documentation

◆ GamelogActionType

The actions we log.

Enumerator
GLAT_START 

Game created.

GLAT_LOAD 

Game loaded.

GLAT_GRF 

GRF changed.

GLAT_CHEAT 

Cheat was used.

GLAT_SETTING 

Setting changed.

GLAT_GRFBUG 

GRF bug was triggered.

GLAT_EMERGENCY 

Emergency savegame.

GLAT_END 

So we know how many GLATs are there.

GLAT_NONE 

No logging active; in savegames, end of list.

Definition at line 16 of file gamelog.h.

Function Documentation

◆ GamelogGRFAdd()

void GamelogGRFAdd ( const GRFConfig newg)

Logs adding of a GRF.

Parameters
newgadded GRF

Definition at line 618 of file gamelog.cpp.

References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLAT_LOAD, GLAT_START, GLCT_GRFADD, LoggedChange::grfadd, GRFConfig::ident, and IsLoggableGrfConfig().

Referenced by GamelogGRFAddList(), and GamelogGRFUpdate().

◆ GamelogGRFAddList()

void GamelogGRFAddList ( 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 681 of file gamelog.cpp.

References _gamelog_action_type, GamelogGRFAdd(), GLAT_LOAD, GLAT_START, and GRFConfig::next.

◆ GamelogGRFBugReverse()

bool GamelogGRFBugReverse ( uint32  grfid,
uint16  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 569 of file gamelog.cpp.

References _gamelog_action, _gamelog_actions, GamelogGRFBug(), GamelogStartAction(), GamelogStopAction(), GBUG_VEH_LENGTH, GLAT_GRFBUG, and GLCT_GRFBUG.

Referenced by VehicleLengthChanged().

◆ GamelogGRFCompatible()

void GamelogGRFCompatible ( const GRFIdentifier newg)

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

Parameters
newgnew (updated) GRF

Definition at line 635 of file gamelog.cpp.

References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLAT_LOAD, GLCT_GRFCOMPAT, and LoggedChange::grfcompat.

Referenced by GamelogGRFUpdate().

◆ GamelogGRFRemove()

void GamelogGRFRemove ( uint32  grfid)

Logs removal of a GRF.

Parameters
grfidID of removed GRF

Definition at line 604 of file gamelog.cpp.

References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLAT_LOAD, and GLCT_GRFREM.

Referenced by GamelogGRFUpdate().

◆ GamelogGRFUpdate()

void GamelogGRFUpdate ( const GRFConfig oldc,
const GRFConfig newc 
)

Compares two NewGRF lists and logs any change.

Parameters
oldcoriginal GRF list
newcnew GRF list

Definition at line 722 of file gamelog.cpp.

References free(), GamelogGRFAdd(), GamelogGRFCompatible(), GamelogGRFMove(), GamelogGRFParameters(), GamelogGRFRemove(), GenerateGRFList(), GRFIdentifier::grfid, GRFConfig::ident, GRFIdentifier::md5sum, GRFConfig::num_params, and GRFConfig::param.

Referenced by NewGRFConfirmationCallback().

◆ GamelogInfo()

void GamelogInfo ( LoggedAction gamelog_action,
uint  gamelog_actions,
uint32 *  last_ottd_rev,
byte *  ever_modified,
bool *  removed_newgrfs 
)

Get some basic information from the given gamelog.

Parameters
gamelog_actionPointer to the gamelog to extract information from.
gamelog_actionsNumber of actions in the given gamelog.
[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 806 of file gamelog.cpp.

References GLCT_GRFREM, and GLCT_REVISION.

◆ GamelogPrint()

void GamelogPrint ( GamelogPrintProc proc)

Prints active gamelog.

Parameters
procthe procedure to draw with

Definition at line 192 of file gamelog.cpp.

References _gamelog_action, _gamelog_actions, GLAT_END, la_text, lastof, and seprintf().

Referenced by GamelogPrintConsole(), GamelogPrintDebug(), and CrashLog::LogGamelog().

◆ GamelogPrintDebug()

void GamelogPrintDebug ( 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 369 of file gamelog.cpp.

References _gamelog_print_level, and GamelogPrint().

Referenced by GamelogStopAction().

◆ GamelogSetting()

void GamelogSetting ( const char *  name,
int32  oldval,
int32  newval 
)

Logs change in game settings.

Only non-networksafe settings are logged

Parameters
namesetting name
oldvalold setting value
newvalnew setting value

Definition at line 486 of file gamelog.cpp.

References _gamelog_action_type, GamelogChange(), GLAT_SETTING, GLCT_SETTING, and stredup().

◆ GamelogStartAction()

void GamelogStartAction ( 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 69 of file gamelog.cpp.

References _gamelog_action_type, and GLAT_NONE.

Referenced by GamelogEmergency(), GamelogGRFBugReverse(), and NewGRFConfirmationCallback().

◆ GamelogTestMode()

void GamelogTestMode ( )

Finds last stored game mode or landscape.

Any change is logged

Definition at line 526 of file gamelog.cpp.

References _gamelog_action, _gamelog_actions, GLCT_MODE, and LoggedChange::mode.

◆ GamelogTestRevision()

void GamelogTestRevision ( )

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 503 of file gamelog.cpp.

References _gamelog_action, _gamelog_actions, GetGamelogRevisionString(), and GLCT_REVISION.