Handle invalid strings from game scripts more leniently
[openttd/fttd.git] / src / gamelog.h
blobb3c0424f540930f81c7d5fd20a23b213d731ebd6
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file gamelog.h Functions to be called to log possibly unsafe game events */
12 #ifndef GAMELOG_H
13 #define GAMELOG_H
15 #include <memory>
16 #include <vector>
18 #include "newgrf_config.h"
19 #include "saveload/saveload_data.h"
21 /** The type of entries we log. */
22 enum GamelogEntryType {
23 GLOG_START, ///< Game starts
24 GLOG_STARTED, ///< Game started
25 GLOG_LOAD, ///< Game load
26 GLOG_LOADED, ///< Game loaded
27 GLOG_MODE, ///< Switch between scenario editor and game
28 GLOG_REVISION, ///< Changed game revision string
29 GLOG_LEGACYREV, ///< Changed game revision string (legacy)
30 GLOG_OLDVER, ///< Loaded from savegame without logged data
31 GLOG_EMERGENCY, ///< Emergency savegame
32 GLOG_SETTING, ///< Setting changed
33 GLOG_CHEAT, ///< Cheat was used
34 GLOG_GRFBEGIN, ///< GRF config change beginning
35 GLOG_GRFEND, ///< GRF config change end
36 GLOG_GRFADD, ///< GRF added
37 GLOG_GRFREM, ///< GRF removed
38 GLOG_GRFCOMPAT, ///< Compatible GRF loaded
39 GLOG_GRFPARAM, ///< GRF parameter changed
40 GLOG_GRFMOVE, ///< GRF order changed
41 GLOG_GRFBUG, ///< GRF bug was triggered
42 GLOG_ENTRYTYPE_END, ///< So we know how many entry types there are
45 struct GamelogPrintBuffer;
47 /** Gamelog entry base class. */
48 struct GamelogEntry {
49 GamelogEntryType type;
51 GamelogEntry(GamelogEntryType t) : type(t) { }
53 virtual ~GamelogEntry()
57 virtual void Print(GamelogPrintBuffer *buf) = 0;
60 /** Gamelog structure. */
61 struct Gamelog : std::vector<std::unique_ptr<GamelogEntry> > {
62 void append(GamelogEntry *entry) {
63 this->push_back(std::unique_ptr<GamelogEntry>(entry));
67 void GamelogReset();
69 void GamelogInfo(const Gamelog *gamelog, uint32 *last_rev, byte *ever_modified, bool *removed_newgrfs);
71 /**
72 * Callback for printing text.
73 * @param s The string to print.
75 typedef void GamelogPrintProc(const char *s);
76 void GamelogPrint(GamelogPrintProc *proc); // needed for WIN32 / WINCE crash.log
78 void GamelogPrintDebug(int level);
79 void GamelogPrintConsole();
81 void GamelogAddStart();
82 void GamelogAddStarted();
84 void GamelogAddLoad();
85 void GamelogAddLoaded();
87 void GamelogAddRevision();
88 void GamelogTestRevision();
89 void GamelogAddMode();
90 void GamelogTestMode();
91 void GamelogOldver(const SavegameTypeVersion *stv);
93 void GamelogEmergency();
94 bool GamelogTestEmergency();
96 void GamelogSetting(const char *name, int32 oldval, int32 newval);
98 void GamelogGRFBegin();
99 void GamelogGRFEnd();
101 void GamelogGRFAdd(const GRFConfig *newg);
102 void GamelogGRFAddList(const GRFConfig *newg);
103 void GamelogGRFRemove(uint32 grfid);
104 void GamelogGRFCompatible(const GRFIdentifier *newg);
105 void GamelogGRFUpdate(const GRFConfig *oldg, const GRFConfig *newg);
107 bool GamelogGRFBugReverse(uint32 grfid, uint16 internal_id);
109 #endif /* GAMELOG_H */