OpenTTD Source 20250205-master-gfd85ab1e2c
gamelog_internal.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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef GAMELOG_INTERNAL_H
11#define GAMELOG_INTERNAL_H
12
13#include "gamelog.h"
14#include "landscape_type.h"
15
24 const GRFConfig *gc;
26
27 GRFPresence(const GRFConfig *gc) : gc(gc), was_missing(false) {}
28 GRFPresence() = default;
29};
30using GrfIDMapping = std::map<uint32_t, GRFPresence>;
31
33 LoggedChange(GamelogChangeType type = GLCT_NONE) : ct(type) {}
34 virtual ~LoggedChange() = default;
35 virtual void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) = 0;
36
38};
39
44 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
45
46 uint8_t mode;
48};
49
52 LoggedChangeRevision(const std::string &text, uint32_t newgrf, uint16_t slver, uint8_t modified) :
53 LoggedChange(GLCT_REVISION), text(text), newgrf(newgrf), slver(slver), modified(modified) {}
54 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
55
56 std::string text;
57 uint32_t newgrf;
58 uint16_t slver;
59 uint8_t modified; //< _openttd_revision_modified
60};
61
64 LoggedChangeOldVersion(uint32_t type, uint32_t version) :
66 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
67
68 uint32_t type;
69 uint32_t version;
70};
71
74 LoggedChangeGRFAdd(const GRFIdentifier &ident) :
76 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
77};
78
83 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
84
85 uint32_t grfid;
86};
87
92 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
93};
94
99 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
100
101 uint32_t grfid;
102};
103
106 LoggedChangeGRFMoved(uint32_t grfid, int32_t offset) :
108 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
109
110 uint32_t grfid;
111 int32_t offset;
112};
113
116 LoggedChangeSettingChanged(const std::string &name, int32_t oldval, int32_t newval) :
118 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
119
120 std::string name;
121 int32_t oldval;
122 int32_t newval;
123};
124
127 LoggedChangeGRFBug(uint64_t data, uint32_t grfid, GRFBug bug) :
129 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
130
131 uint64_t data;
132 uint32_t grfid;
134};
135
138 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
139};
140
141
144 std::vector<std::unique_ptr<LoggedChange>> change;
146 uint64_t tick;
147};
148
150 std::vector<LoggedAction> action;
151};
152
153#endif /* GAMELOG_INTERNAL_H */
Functions to be called to log fundamental changes to the game.
GamelogChangeType
Type of logged change.
Definition gamelog.h:29
@ GLCT_MODE
Scenario editor x Game, different landscape.
Definition gamelog.h:30
@ GLCT_OLDVER
Loaded from savegame without logged data.
Definition gamelog.h:32
@ GLCT_SETTING
Non-networksafe setting value changed.
Definition gamelog.h:33
@ GLCT_GRFCOMPAT
Loading compatible GRF.
Definition gamelog.h:36
@ GLCT_GRFADD
Removed GRF.
Definition gamelog.h:34
@ GLCT_EMERGENCY
Emergency savegame.
Definition gamelog.h:40
@ GLCT_GRFPARAM
GRF parameter changed.
Definition gamelog.h:37
@ GLCT_GRFMOVE
GRF order changed.
Definition gamelog.h:38
@ GLCT_GRFREM
Added GRF.
Definition gamelog.h:35
@ GLCT_GRFBUG
GRF bug triggered.
Definition gamelog.h:39
@ GLCT_REVISION
Changed game revision string.
Definition gamelog.h:31
@ GLCT_NONE
In savegames, end of list.
Definition gamelog.h:42
GamelogActionType
The actions we log.
Definition gamelog.h:16
Types related to the landscape.
LandscapeType
Landscape types.
GRFBug
Encountered GRF bugs.
Information about GRF, used in the game and (part of it) in savegames.
Basic data to distinguish a GRF.
Information about the presence of a Grf at a certain point during gamelog history Note about missing ...
bool was_missing
Grf was missing during some gameload in the past.
const GRFConfig * gc
GRFConfig, if known.
Contains information about one logged action that caused at least one logged change.
uint64_t tick
Tick when it happened.
std::vector< std::unique_ptr< LoggedChange > > change
Logged changes in this action.
GamelogActionType at
Type of action.
GRFBug bug
type of bug,
uint64_t data
additional data
uint32_t grfid
ID of problematic GRF.
uint32_t grfid
ID of moved GRF.
int32_t offset
offset, positive = move down
uint32_t grfid
ID of GRF with changed parameters.
uint32_t grfid
ID of removed GRF.
LandscapeType landscape
landscape (temperate, arctic, ...)
uint8_t mode
new game mode - Editor x Game
uint32_t type
type of savegame,
uint32_t version
major and minor version OR ttdp version
std::string text
revision string, _openttd_revision
uint16_t slver
_sl_version
uint32_t newgrf
_openttd_newgrf_version
std::string name
name of the setting