#include "stdafx.h"
#include "openttd.h"
#include "saveload/saveload.h"
#include "core/alloc_func.hpp"
#include "core/bitmath_func.hpp"
#include "core/math_func.hpp"
#include "network/core/config.h"
#include "variables.h"
#include "string_func.h"
#include "settings_type.h"
#include "newgrf_config.h"
#include "gamelog.h"
#include "gamelog_internal.h"
#include "console_func.h"
#include "debug.h"
#include "rev.h"
#include <string.h>
#include <stdarg.h>
Go to the source code of this file.
Data Structures | |
| struct | GRFList |
| List of GRFs using array of pointers instead of linked list. More... | |
Enumerations | |
| enum | { GAMELOG_BUF_LEN = 1024 } |
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. | |
| static void | AddDebugText (char *buf, const char *s,...) |
| static void | PrintGrfFilename (char *buf, uint grfid) |
| Prints GRF filename if found. | |
| static void | PrintGrfInfo (char *buf, uint grfid, const uint8 *md5sum) |
| Prints GRF ID, checksum and filename if found. | |
| assert_compile (lengthof(la_text)==GLAT_END) | |
| void | GamelogPrint (GamelogPrintProc *proc) |
| Prints active gamelog. | |
| static void | GamelogPrintConsoleProc (const char *s) |
| void | GamelogPrintConsole () |
| static void | GamelogPrintDebugProc (const char *s) |
| void | GamelogPrintDebug (int level) |
| Prints gamelog to debug output. | |
| static LoggedChange * | GamelogChange (GamelogChangeType ct) |
| Allocates new LoggedChange and new LoggedAction if needed. | |
| 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 | GamelogPatch (const char *name, int32 oldval, int32 newval) |
| Logs change in game patches. | |
| 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. | |
| static void | GamelogGRFBug (uint32 grfid, byte bug, uint64 data) |
| Logs triggered GRF bug. | |
| bool | GamelogGRFBugReverse (uint32 grfid, uint16 internal_id) |
| Logs GRF bug - rail vehicle has different length after reversing. | |
| static bool | IsLoggableGrfConfig (const GRFConfig *g) |
| Decides if GRF should be logged. | |
| 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). | |
| static void | GamelogGRFMove (uint32 grfid, int32 offset) |
| Logs changing GRF order. | |
| static void | GamelogGRFParameters (uint32 grfid) |
| Logs change in GRF parameters. | |
| void | GamelogGRFAddList (const GRFConfig *newg) |
| Logs adding of list of GRFs. | |
| static GRFList * | GenerateGRFList (const GRFConfig *grfc) |
| Generates GRFList. | |
| void | GamelogGRFUpdate (const GRFConfig *oldc, const GRFConfig *newc) |
| Compares two NewGRF lists and logs any change. | |
Variables | |
| const uint16 | SAVEGAME_VERSION |
| current savegame version | |
| SavegameType | _savegame_type |
| type of savegame we are loading | |
| uint32 | _ttdp_version |
| version of TTDP savegame (if applicable) | |
| uint16 | _sl_version |
| the major savegame version identifier | |
| byte | _sl_minor_version |
| the minor savegame version, DO NOT USE! | |
| static GamelogActionType | _gamelog_action_type = GLAT_NONE |
| action to record if anything changes | |
| LoggedAction * | _gamelog_action = NULL |
| first logged action | |
| uint | _gamelog_actions = 0 |
| number of actions | |
| static LoggedAction * | _current_action = NULL |
| current action we are logging, NULL when there is no action active | |
| static int | _dbgofs = 0 |
| offset in current output buffer | |
| static const char * | la_text [] |
| Text messages for various logged actions. | |
| static int | _gamelog_print_level = 0 |
| gamelog debug level we need to print stuff | |
Definition in file gamelog.cpp.
| anonymous enum |
Definition at line 87 of file gamelog.cpp.
| static LoggedChange* GamelogChange | ( | GamelogChangeType | ct | ) | [static] |
Allocates new LoggedChange and new LoggedAction if needed.
If there is no action active, NULL is returned.
| ct | type of change |
Definition at line 298 of file gamelog.cpp.
References _gamelog_action_type, _gamelog_actions, LoggedAction::at, LoggedAction::change, LoggedAction::changes, LoggedChange::ct, GLAT_NONE, ReallocT(), and LoggedAction::tick.
Referenced by GamelogGRFAdd(), GamelogGRFBug(), GamelogGRFCompatible(), GamelogGRFMove(), GamelogGRFParameters(), GamelogGRFRemove(), GamelogMode(), GamelogOldver(), GamelogPatch(), and GamelogRevision().
| void GamelogGRFAdd | ( | const GRFConfig * | newg | ) |
Logs adding of a GRF.
| newg | added GRF |
Definition at line 492 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLAT_LOAD, GLAT_START, GLCT_GRFADD, LoggedChange::grfadd, 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 551 of file gamelog.cpp.
References _gamelog_action_type, GamelogGRFAdd(), GLAT_LOAD, GLAT_START, and GRFConfig::next.
| static void GamelogGRFBug | ( | uint32 | grfid, | |
| byte | bug, | |||
| uint64 | data | |||
| ) | [static] |
Logs triggered GRF bug.
| grfid | ID of problematic GRF | |
| bug | type of bug, |
| data | additional data |
Definition at line 427 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_GRFBUG, GLCT_GRFBUG, and LoggedChange::grfbug.
Referenced by 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).
| engine | engine to log |
Definition at line 446 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 508 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLAT_LOAD, GLCT_GRFCOMPAT, and LoggedChange::grfcompat.
Referenced by GamelogGRFUpdate(), and IsGoodGRFConfigList().
| static void GamelogGRFMove | ( | uint32 | grfid, | |
| int32 | offset | |||
| ) | [static] |
Logs changing GRF order.
| grfid | GRF that is moved | |
| offset | how far it is moved, positive = moved down |
Definition at line 522 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLCT_GRFMOVE, and LoggedChange::grfmove.
Referenced by GamelogGRFUpdate().
| static void GamelogGRFParameters | ( | uint32 | grfid | ) | [static] |
Logs change in GRF parameters.
Details about parameters changed are not stored
| grfid | ID of GRF to store |
Definition at line 537 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLCT_GRFPARAM, and LoggedChange::grfparam.
Referenced by GamelogGRFUpdate().
| void GamelogGRFRemove | ( | uint32 | grfid | ) |
Logs removal of a GRF.
| grfid | ID of removed GRF |
Definition at line 479 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_GRF, GLAT_LOAD, GLCT_GRFREM, and LoggedChange::grfrem.
Referenced by GamelogGRFUpdate(), and IsGoodGRFConfigList().
Compares two NewGRF lists and logs any change.
| oldc | original GRF list | |
| newc | new GRF list |
Definition at line 590 of file gamelog.cpp.
References GamelogGRFAdd(), GamelogGRFCompatible(), GamelogGRFMove(), GamelogGRFParameters(), GamelogGRFRemove(), GenerateGRFList(), GRFList::grf, GRFIdentifier::grfid, GRFIdentifier::md5sum, GRFList::n, GRFConfig::num_params, and GRFConfig::param.
Referenced by NewGRFConfirmationCallback().
| void GamelogPatch | ( | const char * | name, | |
| int32 | oldval, | |||
| int32 | newval | |||
| ) |
Logs change in game patches.
Only non-networksafe patches are logged
| name | patch name | |
| oldval | old patch value | |
| newval | new patch value |
Definition at line 368 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_PATCH, GLCT_PATCH, and LoggedChange::patch.
Referenced by CmdChangePatchSetting().
| 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 286 of file gamelog.cpp.
References GamelogPrint().
Referenced by GamelogStopAction().
| void GamelogRevision | ( | ) |
Logs a change in game revision.
| revision | new revision string |
Definition at line 324 of file gamelog.cpp.
References _gamelog_action_type, GamelogChange(), GLAT_LOAD, GLAT_START, GLCT_REVISION, lastof, LoggedChange::revision, SAVEGAME_VERSION, and strecpy().
Referenced by GamelogTestRevision().
| 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(), CmdChangePatchSetting(), GamelogGRFBugReverse(), NewGRFConfirmationCallback(), and SaveOrLoad().
| void GamelogTestMode | ( | ) |
Finds last stored game mode or landscape.
Any change is logged
Definition at line 406 of file gamelog.cpp.
References _gamelog_actions, _settings_game, LoggedAction::change, GameSettings::game_creation, GamelogMode(), GLCT_MODE, GameCreationSettings::landscape, and LoggedChange::mode.
Referenced by 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 384 of file gamelog.cpp.
References _gamelog_actions, LoggedAction::change, GamelogRevision(), GLCT_REVISION, and LoggedChange::revision.
Generates GRFList.
| grfc | head of GRF linked list |
Definition at line 569 of file gamelog.cpp.
References GRFList::grf, IsLoggableGrfConfig(), GRFList::n, and GRFConfig::next.
Referenced by GamelogGRFUpdate().
| static bool IsLoggableGrfConfig | ( | const GRFConfig * | g | ) | [inline, static] |
Decides if GRF should be logged.
| g | grf to determine |
Definition at line 471 of file gamelog.cpp.
References GRFConfig::flags, GCF_STATIC, GCS_NOT_FOUND, HasBit(), and GRFConfig::status.
Referenced by GamelogGRFAdd(), and GenerateGRFList().
| static void PrintGrfFilename | ( | char * | buf, | |
| uint | grfid | |||
| ) | [static] |
Prints GRF filename if found.
| grfid | GRF which filename to print |
Definition at line 108 of file gamelog.cpp.
References GRFConfig::filename.
Referenced by GamelogPrint(), and PrintGrfInfo().
| static void PrintGrfInfo | ( | char * | buf, | |
| uint | grfid, | |||
| const uint8 * | md5sum | |||
| ) | [static] |
Prints GRF ID, checksum and filename if found.
| grfid | GRF ID | |
| md5sum | array of md5sum to print |
Definition at line 121 of file gamelog.cpp.
References BSWAP32(), lastof, md5sumToString(), and PrintGrfFilename().
Referenced by GamelogPrint().
const char* la_text[] [static] |
Initial value:
{
"new game started",
"game loaded",
"GRF config changed",
"cheat was used",
"patch settings changed",
"GRF bug triggered",
}
Definition at line 136 of file gamelog.cpp.
Referenced by GamelogPrint().
1.5.6