OpenTTD Source 20260711-master-g3fb3006dff
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef GAMELOG_INTERNAL_H
11#define GAMELOG_INTERNAL_H
12
13#include "gamelog.h"
14#include "openttd.h"
15#include "landscape_type.h"
16
25 const GRFConfig *gc = nullptr;
26 bool was_missing = false;
27
33
35 GRFPresence() = default;
36};
37using GrfIDMapping = std::map<GrfID, GRFPresence>;
38
46
48 virtual ~LoggedChange() = default;
49
56 virtual void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) = 0;
57
59};
60
78
83
93 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
94
95 std::string text{};
96 uint32_t newgrf = 0;
97 uint16_t slver = 0;
98 uint8_t modified = 0;
99};
100
105
113 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
114
115 uint32_t type = 0;
116 uint32_t version = 0;
117};
118
123
130 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
131};
132
137
144 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
145
147};
148
153
160 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
161};
162
178
183
191 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
192
194 int32_t offset = 0;
195};
196
201
210 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
211
212 std::string name{};
213 int32_t oldval = 0;
214 int32_t newval = 0;
215};
216
221
230 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
231
232 uint64_t data = 0;
235};
236
241 void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
242};
243
244
247 std::vector<std::unique_ptr<LoggedChange>> change;
249 uint64_t tick = 0;
250};
251
254 std::vector<LoggedAction> action;
255};
256
257#endif /* GAMELOG_INTERNAL_H */
Functions to be called to log fundamental changes to the game.
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
@ None
In savegames, end of list.
Definition gamelog.h:43
@ 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
@ Emergency
Emergency savegame.
Definition gamelog.h:24
std::map< GrfID, GRFPresence > GrfIDMapping
A mapping from GrfID to the GRFPresence.
Types related to the landscape.
LandscapeType
Landscape types.
GRFBug
Encountered GRF bugs.
uint32_t GrfID
The unique identifier of a NewGRF.
Definition newgrf_type.h:15
Some generic types.
GameMode
Mode which defines the state of the game.
Definition openttd.h:18
Information about GRF, used in the game and (part of it) in savegames.
Basic data to distinguish a GRF.
GRFPresence()=default
Create an empty presence.
bool was_missing
Grf was missing during some gameload in the past.
GRFPresence(const GRFConfig *gc)
Create the presence.
const GRFConfig * gc
GRFConfig, if known.
Container for some internal data.
std::vector< LoggedAction > action
The known actions.
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.
LoggedChangeEmergencySave()
Create the entry.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:302
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:229
LoggedChangeGRFAdd(const GRFIdentifier &ident)
Create a log entry for an added NewGRF.
LoggedChangeGRFAdd()
Constructor for savegame loading.
GRFBug bug
type of bug,
LoggedChangeGRFBug()
Constructor for savegame loading.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:291
GrfID grfid
ID of problematic GRF.
uint64_t data
additional data
LoggedChangeGRFBug(uint64_t data, GrfID grfid, GRFBug bug)
Create a NewGRF bug log entry.
LoggedChangeGRFChanged(const GRFIdentifier &ident)
Create a log entry for a changed NewGRF.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:262
LoggedChangeGRFChanged()
Constructor for savegame loading.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:281
LoggedChangeGRFMoved(GrfID grfid, int32_t offset)
Create a log entry for a moved NewGRF.
LoggedChangeGRFMoved()
Constructor for savegame loading.
int32_t offset
offset, positive = move down
GrfID grfid
ID of moved GRF.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:272
GrfID grfid
ID of GRF with changed parameters.
LoggedChangeGRFParameterChanged()
Constructor for savegame loading.
LoggedChangeGRFParameterChanged(GrfID grfid)
Create a log entry for a parameter change of a NewGRF.
GrfID grfid
ID of removed GRF.
LoggedChangeGRFRemoved()
Constructor for savegame loading.
LoggedChangeGRFRemoved(GrfID grfid)
Create a log entry for a removed NewGRF.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:240
LandscapeType landscape
landscape (temperate, arctic, ...)
LoggedChangeMode(GameMode mode, LandscapeType landscape)
Create the log for changing the game mode.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:170
GameMode mode
new game mode - Editor x Game
LoggedChangeMode()
Constructor for savegame loading.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:191
LoggedChangeOldVersion(uint32_t type, uint32_t version)
Create the entry.
LoggedChangeOldVersion()
Constructor for savegame loading.
uint32_t type
type of savegame,
uint32_t version
major and minor version OR ttdp version
std::string text
revision string, _openttd_revision
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:176
uint16_t slver
_sl_version
LoggedChangeRevision(const std::string &text, uint32_t newgrf, uint16_t slver, uint8_t modified)
Create the new log entry.
LoggedChangeRevision()
Constructor for savegame loading.
uint32_t newgrf
_openttd_newgrf_version
uint8_t modified
_openttd_revision_modified
std::string name
name of the setting
LoggedChangeSettingChanged(const std::string &name, int32_t oldval, int32_t newval)
Create the log entry.
LoggedChangeSettingChanged()
Constructor for savegame loading.
void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override
Format the content of this change into the given output.
Definition gamelog.cpp:223
virtual void FormatTo(std::back_insert_iterator< std::string > &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type)=0
Format the content of this change into the given output.
GamelogChangeType ct
The type of change.
LoggedChange(GamelogChangeType type=GamelogChangeType::None)
Create the log entry.
virtual ~LoggedChange()=default
Ensure the destructor of the sub classes are called as well.