OpenTTD Source 20260711-master-g3fb3006dff
gamelog.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef GAMELOG_H
11#define GAMELOG_H
12
13#include "newgrf_config.h"
14#include "newgrf_type.h"
15
28
45
46struct LoggedChange;
47struct LoggedAction;
49
50class Gamelog {
51private:
52 std::unique_ptr<GamelogInternalData> data;
53 GamelogActionType action_type;
54 struct LoggedAction *current_action;
55
56 void Change(std::unique_ptr<LoggedChange> &&change);
57
58public:
59 Gamelog();
60 ~Gamelog();
61
63 void StopAction();
64 void StopAnyAction();
65
66 void Reset();
67
68 void Print(std::function<void(const std::string &)> proc);
69 void PrintDebug(int level);
70 void PrintConsole();
71
72 void Emergency();
73 bool TestEmergency();
74
75 void Revision();
76 void Mode();
77 void Oldver();
78 void Setting(const std::string &name, int32_t oldval, int32_t newval);
79
80 void GRFUpdate(const GRFConfigList &oldg, const GRFConfigList &newg);
81 void GRFAddList(const GRFConfigList &newg);
82 void GRFRemove(GrfID grfid);
83 void GRFAdd(const GRFConfig &newg);
84 void GRFBug(GrfID grfid, ::GRFBug bug, uint64_t data);
85 bool GRFBugReverse(GrfID grfid, uint16_t internal_id);
86 void GRFCompatible(const GRFIdentifier &newg);
87 void GRFMove(GrfID grfid, int32_t offset);
88 void GRFParameters(GrfID grfid);
89
90 void TestRevision();
91 void TestMode();
92
93 void Info(uint32_t *last_ottd_rev, uint8_t *ever_modified, bool *removed_newgrfs);
95
96 /* Saveload handler for gamelog needs access to internal data. */
97 friend struct GLOGChunkHandler;
98};
99
100extern Gamelog _gamelog;
101
102#endif /* GAMELOG_H */
void TestRevision()
Finds out if current revision is different than last revision stored in the savegame.
Definition gamelog.cpp:425
const GRFIdentifier & GetOverriddenIdentifier(const GRFConfig &c)
Try to find the overridden GRF identifier of the given GRF.
Definition gamelog.cpp:713
bool GRFBugReverse(GrfID grfid, uint16_t internal_id)
Logs GRF bug - rail vehicle has different length after reversing.
Definition gamelog.cpp:482
void Mode()
Logs a change in game mode (scenario editor or game).
Definition gamelog.cpp:389
void Info(uint32_t *last_ottd_rev, uint8_t *ever_modified, bool *removed_newgrfs)
Get some basic information from the given gamelog.
Definition gamelog.cpp:686
void PrintDebug(int level)
Prints gamelog to debug output.
Definition gamelog.cpp:322
void PrintConsole()
Print the gamelog data to the console.
Definition gamelog.cpp:309
void GRFParameters(GrfID grfid)
Logs change in GRF parameters.
Definition gamelog.cpp:566
void Revision()
Logs a change in game revision.
Definition gamelog.cpp:378
void StartAction(GamelogActionType at)
Stores information about new action, but doesn't allocate it Action is allocated only when there is a...
Definition gamelog.cpp:67
void Reset()
Resets and frees all memory allocated - used before loading or starting a new game.
Definition gamelog.cpp:96
void GRFRemove(GrfID grfid)
Logs removal of a GRF.
Definition gamelog.cpp:517
void GRFMove(GrfID grfid, int32_t offset)
Logs changing GRF order.
Definition gamelog.cpp:554
void GRFAddList(const GRFConfigList &newg)
Logs adding of list of GRFs.
Definition gamelog.cpp:578
~Gamelog()
Needs to be manually defined due to incomplete definition of GamelogInternalData in the header.
Definition gamelog.cpp:41
void GRFCompatible(const GRFIdentifier &newg)
Logs loading compatible GRF (the same ID, but different MD5 hash).
Definition gamelog.cpp:542
void Oldver()
Logs loading from savegame without gamelog.
Definition gamelog.cpp:399
void Emergency()
Logs a emergency savegame.
Definition gamelog.cpp:351
void TestMode()
Finds last stored game mode or landscape.
Definition gamelog.cpp:446
void StopAction()
Stops logging of any changes.
Definition gamelog.cpp:76
void GRFBug(GrfID grfid, ::GRFBug bug, uint64_t data)
Logs triggered GRF bug.
Definition gamelog.cpp:466
void Setting(const std::string &name, int32_t oldval, int32_t newval)
Logs change in game settings.
Definition gamelog.cpp:413
void Print(std::function< void(const std::string &)> proc)
Prints active gamelog.
Definition gamelog.cpp:146
void GRFAdd(const GRFConfig &newg)
Logs adding of a GRF.
Definition gamelog.cpp:528
void GRFUpdate(const GRFConfigList &oldg, const GRFConfigList &newg)
Compares two NewGRF lists and logs any change.
Definition gamelog.cpp:607
void Change(std::unique_ptr< LoggedChange > &&change)
Allocates a new LoggedAction if needed, and add the change when action is active.
Definition gamelog.cpp:334
bool TestEmergency()
Finds out if current game is a loaded emergency savegame.
Definition gamelog.cpp:364
Gamelog _gamelog
Gamelog instance.
Definition gamelog.cpp:31
GamelogChangeType
Type of logged change.
Definition gamelog.h:30
@ GRFCompat
Loading compatible GRF.
Definition gamelog.h:37
@ GRFAdd
Removed GRF.
Definition gamelog.h:35
@ Revision
Changed game revision string.
Definition gamelog.h:32
@ GRFParam
GRF parameter changed.
Definition gamelog.h:38
@ GRFRem
Added GRF.
Definition gamelog.h:36
@ GRFMove
GRF order changed.
Definition gamelog.h:39
@ Mode
Scenario editor x Game, different landscape.
Definition gamelog.h:31
@ OldVer
Loaded from savegame without logged data.
Definition gamelog.h:33
GamelogActionType
The actions we log.
Definition gamelog.h:17
@ Setting
Setting changed.
Definition gamelog.h:22
@ None
No logging active; in savegames, end of list.
Definition gamelog.h:26
@ End
End marker.
Definition gamelog.h:25
@ GRF
GRF changed.
Definition gamelog.h:20
@ Emergency
Emergency savegame.
Definition gamelog.h:24
@ Start
Game created.
Definition gamelog.h:18
@ Load
Game loaded.
Definition gamelog.h:19
Functions to find and configure NewGRFs.
GRFBug
Encountered GRF bugs.
Commonly used types for the NewGRF implementation.
uint32_t GrfID
The unique identifier of a NewGRF.
Definition newgrf_type.h:15
@ Gamelog
Saveload version: 98, SVN revision: 13375 Logging of important actions/situations in the save.
Definition saveload.h:161
Info about each of the cheats.
Definition cheat_type.h:16
Information about GRF, used in the game and (part of it) in savegames.
Basic data to distinguish a GRF.
Container for some internal data.
Contains information about one logged action that caused at least one logged change.
Container for any change that we deem needs to be logged.