Files
@ r28486:aff297ed5a05
Branch filter:
Location: cpp/openttd-patchpack/source/src/gamelog_internal.h - annotation
r28486:aff297ed5a05
6.7 KiB
text/x-c
Codechange: Allow constexpr NWidgetPart construction.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r14248:a9050881acd7 r10571:99cb9a95b4cf r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27384:b919ab98bb53 r27376:7e6826313302 r27376:7e6826313302 r23269:0ff1cc4177d3 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27384:b919ab98bb53 r27376:7e6826313302 r10571:99cb9a95b4cf r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27223:23146c90355d r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r27376:7e6826313302 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r27376:7e6826313302 r10571:99cb9a95b4cf r27376:7e6826313302 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r27223:23146c90355d r27223:23146c90355d r27223:23146c90355d r10571:99cb9a95b4cf r10571:99cb9a95b4cf | /*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file gamelog_internal.h Declaration shared among gamelog.cpp and saveload/gamelog_sl.cpp */
#ifndef GAMELOG_INTERNAL_H
#define GAMELOG_INTERNAL_H
#include "gamelog.h"
/**
* Information about the presence of a Grf at a certain point during gamelog history
* Note about missing Grfs:
* Changes to missing Grfs are not logged including manual removal of the Grf.
* So if the gamelog tells a Grf is missing we do not know whether it was readded or completely removed
* at some later point.
*/
struct GRFPresence {
const GRFConfig *gc; ///< GRFConfig, if known
bool was_missing; ///< Grf was missing during some gameload in the past
GRFPresence(const GRFConfig *gc) : gc(gc), was_missing(false) {}
GRFPresence() = default;
};
using GrfIDMapping = std::map<uint32_t, GRFPresence>;
struct LoggedChange {
LoggedChange(GamelogChangeType type = GLCT_NONE) : ct(type) {}
virtual ~LoggedChange() {}
virtual void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) = 0;
GamelogChangeType ct;
};
struct LoggedChangeMode : LoggedChange {
LoggedChangeMode() : LoggedChange(GLCT_MODE) {}
LoggedChangeMode(byte mode, byte landscape) :
LoggedChange(GLCT_MODE), mode(mode), landscape(landscape) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
byte mode; ///< new game mode - Editor x Game
byte landscape; ///< landscape (temperate, arctic, ...)
};
struct LoggedChangeRevision : LoggedChange {
LoggedChangeRevision() : LoggedChange(GLCT_REVISION) {}
LoggedChangeRevision(const std::string &text, uint32_t newgrf, uint16_t slver, byte modified) :
LoggedChange(GLCT_REVISION), text(text), newgrf(newgrf), slver(slver), modified(modified) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
std::string text; ///< revision string, _openttd_revision
uint32_t newgrf; ///< _openttd_newgrf_version
uint16_t slver; ///< _sl_version
byte modified; //< _openttd_revision_modified
};
struct LoggedChangeOldVersion : LoggedChange {
LoggedChangeOldVersion() : LoggedChange(GLCT_OLDVER) {}
LoggedChangeOldVersion(uint32_t type, uint32_t version) :
LoggedChange(GLCT_OLDVER), type(type), version(version) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
uint32_t type; ///< type of savegame, @see SavegameType
uint32_t version; ///< major and minor version OR ttdp version
};
struct LoggedChangeGRFAdd : LoggedChange, GRFIdentifier {
LoggedChangeGRFAdd() : LoggedChange(GLCT_GRFADD) {}
LoggedChangeGRFAdd(const GRFIdentifier &ident) :
LoggedChange(GLCT_GRFADD), GRFIdentifier(ident) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
};
struct LoggedChangeGRFRemoved : LoggedChange {
LoggedChangeGRFRemoved() : LoggedChange(GLCT_GRFREM) {}
LoggedChangeGRFRemoved(uint32_t grfid) :
LoggedChange(GLCT_GRFREM), grfid(grfid) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
uint32_t grfid; ///< ID of removed GRF
};
struct LoggedChangeGRFChanged : LoggedChange, GRFIdentifier {
LoggedChangeGRFChanged() : LoggedChange(GLCT_GRFCOMPAT) {}
LoggedChangeGRFChanged(const GRFIdentifier &ident) :
LoggedChange(GLCT_GRFCOMPAT), GRFIdentifier(ident) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
};
struct LoggedChangeGRFParameterChanged : LoggedChange {
LoggedChangeGRFParameterChanged() : LoggedChange(GLCT_GRFPARAM) {}
LoggedChangeGRFParameterChanged(uint32_t grfid) :
LoggedChange(GLCT_GRFPARAM), grfid(grfid) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
uint32_t grfid; ///< ID of GRF with changed parameters
};
struct LoggedChangeGRFMoved : LoggedChange {
LoggedChangeGRFMoved() : LoggedChange(GLCT_GRFMOVE) {}
LoggedChangeGRFMoved(uint32_t grfid, int32_t offset) :
LoggedChange(GLCT_GRFMOVE), grfid(grfid), offset(offset) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
uint32_t grfid; ///< ID of moved GRF
int32_t offset; ///< offset, positive = move down
};
struct LoggedChangeSettingChanged : LoggedChange {
LoggedChangeSettingChanged() : LoggedChange(GLCT_SETTING) {}
LoggedChangeSettingChanged(const std::string &name, int32_t oldval, int32_t newval) :
LoggedChange(GLCT_SETTING), name(name), oldval(oldval), newval(newval) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
std::string name; ///< name of the setting
int32_t oldval; ///< old value
int32_t newval; ///< new value
};
struct LoggedChangeGRFBug : LoggedChange {
LoggedChangeGRFBug() : LoggedChange(GLCT_GRFBUG) {}
LoggedChangeGRFBug(uint64_t data, uint32_t grfid, byte bug) :
LoggedChange(GLCT_GRFBUG), data(data), grfid(grfid), bug(bug) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
uint64_t data; ///< additional data
uint32_t grfid; ///< ID of problematic GRF
byte bug; ///< type of bug, @see enum GRFBugs
};
struct LoggedChangeEmergencySave : LoggedChange {
LoggedChangeEmergencySave() : LoggedChange(GLCT_EMERGENCY) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
};
/** Contains information about one logged action that caused at least one logged change */
struct LoggedAction {
std::vector<std::unique_ptr<LoggedChange>> change; ///< Logged changes in this action
GamelogActionType at; ///< Type of action
uint64_t tick; ///< Tick when it happened
};
struct GamelogInternalData {
std::vector<LoggedAction> action;
};
#endif /* GAMELOG_INTERNAL_H */
|