Functions to be called to log possibly unsafe game events. More...
#include "newgrf_config.h"
Go to the source code of this file.
Typedefs | |
typedef void | GamelogPrintProc (const char *s) |
Callback for printing text. | |
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. | |
void | GamelogStopAction () |
Stops logging of any changes. | |
void | GamelogReset () |
Resets and frees all memory allocated - used before loading or starting a new game. | |
void | GamelogPrint (GamelogPrintProc *proc) |
Prints active gamelog. | |
void | GamelogPrintDebug (int level) |
Prints gamelog to debug output. | |
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. | |
void | GamelogGRFUpdate (const GRFConfig *oldg, const GRFConfig *newg) |
Compares two NewGRF lists and logs any change. | |
void | GamelogGRFAddList (const GRFConfig *newg) |
Logs adding of list of GRFs. | |
void | GamelogGRFRemove (uint32 grfid) |
Logs removal of a GRF. | |
void | GamelogGRFAdd (const GRFConfig *newg) |
Logs adding of a GRF. | |
void | GamelogGRFCompatible (const GRFIdentifier *newg) |
Logs loading compatible GRF (the same ID, but different MD5 hash). | |
void | GamelogTestRevision () |
Finds out if current revision is different than last revision stored in the savegame. | |
void | GamelogTestMode () |
Finds last stored game mode or landscape. | |
bool | GamelogGRFBugReverse (uint32 grfid, uint16 internal_id) |
Logs GRF bug - rail vehicle has different length after reversing. |
Functions to be called to log possibly unsafe game events.
Definition in file gamelog.h.
typedef void GamelogPrintProc(const char *s) |
enum GamelogActionType |
The actions we log.
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. |
void GamelogGRFAdd | ( | const GRFConfig * | newg | ) |
Logs adding of a GRF.
newg | added GRF |
Definition at line 598 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().
void GamelogGRFAddList | ( | const GRFConfig * | newg | ) |
Logs adding of list of GRFs.
Useful when old savegame is loaded or when new game is started
newg | head of GRF linked list |
Definition at line 661 of file gamelog.cpp.
References _gamelog_action_type, GamelogGRFAdd(), GLAT_LOAD, GLAT_START, and GRFConfig::next.
Referenced by AfterLoadGame().
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).
grfid | the broken NewGRF | |
internal_id | the internal ID of whatever's broken in the NewGRF |
Definition at line 549 of file gamelog.cpp.
References _gamelog_actions, LoggedAction::change, GamelogGRFBug(), GamelogStartAction(), GamelogStopAction(), GBUG_VEH_LENGTH, GLAT_GRFBUG, and GLCT_GRFBUG.
Referenced by RailVehicleLengthChanged().
void GamelogGRFCompatible | ( | const GRFIdentifier * | newg | ) |
Logs loading compatible GRF (the same ID, but different MD5 hash).
newg | new (updated) GRF |
Definition at line 615 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLAT_LOAD, GLCT_GRFCOMPAT, and LoggedChange::grfcompat.
Referenced by AfterLoadGame(), and GamelogGRFUpdate().
void GamelogGRFRemove | ( | uint32 | grfid | ) |
Logs removal of a GRF.
grfid | ID of removed GRF |
Definition at line 584 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLAT_LOAD, and GLCT_GRFREM.
Referenced by AfterLoadGame(), and GamelogGRFUpdate().
Compares two NewGRF lists and logs any change.
oldc | original GRF list | |
newc | new GRF list |
Definition at line 702 of file gamelog.cpp.
References GamelogGRFAdd(), GamelogGRFCompatible(), GamelogGRFMove(), GamelogGRFParameters(), GamelogGRFRemove(), GenerateGRFList(), GRFIdentifier::grfid, GRFConfig::ident, GRFIdentifier::md5sum, GRFConfig::num_params, and GRFConfig::param.
Referenced by NewGRFConfirmationCallback().
void GamelogPrint | ( | GamelogPrintProc * | proc | ) |
Prints active gamelog.
proc | the procedure to draw with |
Definition at line 171 of file gamelog.cpp.
References _dbgofs, _gamelog_actions, abs(), BSWAP32(), SmallMap< T, U, S >::Contains(), SmallVector< T, S >::End(), SmallMap< T, U, S >::Erase(), FGCM_EXACT, SmallMap< T, U, S >::Find(), FindGRFConfig(), GAMELOG_BUF_LEN, GB(), GBUG_VEH_LENGTH, GLAT_END, GLAT_LOAD, GLCT_EMERGENCY, GLCT_GRFADD, GLCT_GRFBUG, GLCT_GRFCOMPAT, GLCT_GRFMOVE, GLCT_GRFPARAM, GLCT_GRFREM, GLCT_MODE, GLCT_OLDVER, GLCT_REVISION, GLCT_SETTING, la_text, PrintGrfInfo(), SGT_OTTD, SGT_TTD, SGT_TTDP1, SGT_TTDP2, and SGT_TTO.
Referenced by GamelogPrintConsole(), GamelogPrintDebug(), and CrashLog::LogGamelog().
void GamelogPrintConsole | ( | ) |
Print the gamelog data to the console.
Definition at line 330 of file gamelog.cpp.
References GamelogPrint().
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...
level | debug level we need to print stuff |
Definition at line 349 of file gamelog.cpp.
References GamelogPrint().
Referenced by AfterLoadGame(), and GamelogStopAction().
void GamelogSetting | ( | const char * | name, | |
int32 | oldval, | |||
int32 | newval | |||
) |
Logs change in game settings.
Only non-networksafe settings are logged
name | setting name | |
oldval | old setting value | |
newval | new setting value |
Definition at line 466 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_SETTING, and GLCT_SETTING.
Referenced by CmdChangeSetting().
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.
at | type of action |
Definition at line 45 of file gamelog.cpp.
References _gamelog_action_type, and GLAT_NONE.
Referenced by ClickChangeClimateCheat(), CmdChangeSetting(), DoLoad(), GamelogEmergency(), GamelogGRFBugReverse(), NewGRFConfirmationCallback(), and SaveOrLoad().
void GamelogTestMode | ( | ) |
Finds last stored game mode or landscape.
Any change is logged
Definition at line 506 of file gamelog.cpp.
References _gamelog_actions, _settings_game, LoggedAction::change, GameSettings::game_creation, GamelogMode(), GLCT_MODE, GameCreationSettings::landscape, and LoggedChange::mode.
Referenced by AfterLoadGame(), and ClickChangeClimateCheat().
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 483 of file gamelog.cpp.
References _gamelog_actions, LoggedAction::change, GamelogRevision(), and GLCT_REVISION.
Referenced by AfterLoadGame().