mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-25 08:22:17 +00:00
Codechange: make GamelogChangeType a scoped enum
This commit is contained in:
+9
-9
@@ -359,13 +359,13 @@ void Gamelog::Emergency()
|
||||
|
||||
/**
|
||||
* Finds out if current game is a loaded emergency savegame.
|
||||
* @return \c true iff an action with GLCT_EMERGENCY change exists.
|
||||
* @return \c true iff an action with GamelogChangeType::Emergency change exists.
|
||||
*/
|
||||
bool Gamelog::TestEmergency()
|
||||
{
|
||||
for (const LoggedAction &la : this->data->action) {
|
||||
for (const auto &lc : la.change) {
|
||||
if (lc->ct == GLCT_EMERGENCY) return true;
|
||||
if (lc->ct == GamelogChangeType::Emergency) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ void Gamelog::Setting(const std::string &name, int32_t oldval, int32_t newval)
|
||||
|
||||
/**
|
||||
* Finds out if current revision is different than last revision stored in the savegame.
|
||||
* Appends GLCT_REVISION when the revision string changed
|
||||
* Appends GamelogChangeType::Revision when the revision string changed
|
||||
*/
|
||||
void Gamelog::TestRevision()
|
||||
{
|
||||
@@ -428,7 +428,7 @@ void Gamelog::TestRevision()
|
||||
|
||||
for (const LoggedAction &la : this->data->action) {
|
||||
for (const auto &lc : la.change) {
|
||||
if (lc->ct == GLCT_REVISION) rev = static_cast<const LoggedChangeRevision *>(lc.get());
|
||||
if (lc->ct == GamelogChangeType::Revision) rev = static_cast<const LoggedChangeRevision *>(lc.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ void Gamelog::TestMode()
|
||||
|
||||
for (const LoggedAction &la : this->data->action) {
|
||||
for (const auto &lc : la.change) {
|
||||
if (lc->ct == GLCT_MODE) mode = static_cast<const LoggedChangeMode *>(lc.get());
|
||||
if (lc->ct == GamelogChangeType::Mode) mode = static_cast<const LoggedChangeMode *>(lc.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ bool Gamelog::GRFBugReverse(uint32_t grfid, uint16_t internal_id)
|
||||
{
|
||||
for (const LoggedAction &la : this->data->action) {
|
||||
for (const auto &lc : la.change) {
|
||||
if (lc->ct == GLCT_GRFBUG) {
|
||||
if (lc->ct == GamelogChangeType::GRFBug) {
|
||||
LoggedChangeGRFBug *bug = static_cast<LoggedChangeGRFBug *>(lc.get());
|
||||
if (bug->grfid == grfid && bug->bug == GRFBug::VehLength && bug->data == internal_id) {
|
||||
return false;
|
||||
@@ -690,14 +690,14 @@ void Gamelog::Info(uint32_t *last_ottd_rev, uint8_t *ever_modified, bool *remove
|
||||
switch (lc->ct) {
|
||||
default: break;
|
||||
|
||||
case GLCT_REVISION: {
|
||||
case GamelogChangeType::Revision: {
|
||||
const LoggedChangeRevision *rev = static_cast<const LoggedChangeRevision *>(lc.get());
|
||||
*last_ottd_rev = rev->newgrf;
|
||||
*ever_modified = std::max(*ever_modified, rev->modified);
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCT_GRFREM:
|
||||
case GamelogChangeType::GRFRem:
|
||||
*removed_newgrfs = true;
|
||||
break;
|
||||
}
|
||||
@@ -716,7 +716,7 @@ const GRFIdentifier &Gamelog::GetOverriddenIdentifier(const GRFConfig &c)
|
||||
if (la.at != GamelogActionType::Load) return c.ident;
|
||||
|
||||
for (const auto &lc : la.change) {
|
||||
if (lc->ct != GLCT_GRFCOMPAT) continue;
|
||||
if (lc->ct != GamelogChangeType::GRFCompat) continue;
|
||||
|
||||
const LoggedChangeGRFChanged &grf = *static_cast<const LoggedChangeGRFChanged *>(lc.get());
|
||||
if (grf.grfid == c.ident.grfid) return grf;
|
||||
|
||||
+14
-14
@@ -26,20 +26,20 @@ enum class GamelogActionType : uint8_t {
|
||||
};
|
||||
|
||||
/** Type of logged change */
|
||||
enum GamelogChangeType : uint8_t {
|
||||
GLCT_MODE, ///< Scenario editor x Game, different landscape
|
||||
GLCT_REVISION, ///< Changed game revision string
|
||||
GLCT_OLDVER, ///< Loaded from savegame without logged data
|
||||
GLCT_SETTING, ///< Non-networksafe setting value changed
|
||||
GLCT_GRFADD, ///< Removed GRF
|
||||
GLCT_GRFREM, ///< Added GRF
|
||||
GLCT_GRFCOMPAT, ///< Loading compatible GRF
|
||||
GLCT_GRFPARAM, ///< GRF parameter changed
|
||||
GLCT_GRFMOVE, ///< GRF order changed
|
||||
GLCT_GRFBUG, ///< GRF bug triggered
|
||||
GLCT_EMERGENCY, ///< Emergency savegame
|
||||
GLCT_END, ///< So we know how many GLCTs are there
|
||||
GLCT_NONE = 0xFF, ///< In savegames, end of list
|
||||
enum class GamelogChangeType : uint8_t {
|
||||
Mode, ///< Scenario editor x Game, different landscape.
|
||||
Revision, ///< Changed game revision string.
|
||||
OldVer, ///< Loaded from savegame without logged data.
|
||||
Setting, ///< Non-networksafe setting value changed.
|
||||
GRFAdd, ///< Removed GRF.
|
||||
GRFRem, ///< Added GRF.
|
||||
GRFCompat, ///< Loading compatible GRF.
|
||||
GRFParam, ///< GRF parameter changed.
|
||||
GRFMove, ///< GRF order changed.
|
||||
GRFBug, ///< GRF bug triggered.
|
||||
Emergency, ///< Emergency savegame.
|
||||
End, ///< End marker.
|
||||
None = 0xFF, ///< In savegames, end of list.
|
||||
};
|
||||
|
||||
struct LoggedChange;
|
||||
|
||||
+22
-22
@@ -31,7 +31,7 @@ struct GRFPresence {
|
||||
using GrfIDMapping = std::map<uint32_t, GRFPresence>;
|
||||
|
||||
struct LoggedChange {
|
||||
LoggedChange(GamelogChangeType type = GLCT_NONE) : ct(type) {}
|
||||
LoggedChange(GamelogChangeType type = GamelogChangeType::None) : ct(type) {}
|
||||
/** Ensure the destructor of the sub classes are called as well. */
|
||||
virtual ~LoggedChange() = default;
|
||||
|
||||
@@ -49,7 +49,7 @@ struct LoggedChange {
|
||||
/** Log element for the change of the game mode and landscape. */
|
||||
struct LoggedChangeMode : LoggedChange {
|
||||
/** Constructor for savegame loading. */
|
||||
LoggedChangeMode() : LoggedChange(GLCT_MODE) {}
|
||||
LoggedChangeMode() : LoggedChange(GamelogChangeType::Mode) {}
|
||||
|
||||
/**
|
||||
* Create the log for changing the game mode.
|
||||
@@ -57,7 +57,7 @@ struct LoggedChangeMode : LoggedChange {
|
||||
* @param landscape The new landscape.
|
||||
*/
|
||||
LoggedChangeMode(GameMode mode, LandscapeType landscape) :
|
||||
LoggedChange(GLCT_MODE), mode(mode), landscape(landscape) {}
|
||||
LoggedChange(GamelogChangeType::Mode), mode(mode), landscape(landscape) {}
|
||||
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
|
||||
|
||||
GameMode mode{}; ///< new game mode - Editor x Game
|
||||
@@ -65,9 +65,9 @@ struct LoggedChangeMode : LoggedChange {
|
||||
};
|
||||
|
||||
struct LoggedChangeRevision : LoggedChange {
|
||||
LoggedChangeRevision() : LoggedChange(GLCT_REVISION) {}
|
||||
LoggedChangeRevision() : LoggedChange(GamelogChangeType::Revision) {}
|
||||
LoggedChangeRevision(const std::string &text, uint32_t newgrf, uint16_t slver, uint8_t modified) :
|
||||
LoggedChange(GLCT_REVISION), text(text), newgrf(newgrf), slver(slver), modified(modified) {}
|
||||
LoggedChange(GamelogChangeType::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
|
||||
@@ -77,9 +77,9 @@ struct LoggedChangeRevision : LoggedChange {
|
||||
};
|
||||
|
||||
struct LoggedChangeOldVersion : LoggedChange {
|
||||
LoggedChangeOldVersion() : LoggedChange(GLCT_OLDVER) {}
|
||||
LoggedChangeOldVersion() : LoggedChange(GamelogChangeType::OldVer) {}
|
||||
LoggedChangeOldVersion(uint32_t type, uint32_t version) :
|
||||
LoggedChange(GLCT_OLDVER), type(type), version(version) {}
|
||||
LoggedChange(GamelogChangeType::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 = 0; ///< type of savegame, @see SavegameType
|
||||
@@ -87,41 +87,41 @@ struct LoggedChangeOldVersion : LoggedChange {
|
||||
};
|
||||
|
||||
struct LoggedChangeGRFAdd : LoggedChange, GRFIdentifier {
|
||||
LoggedChangeGRFAdd() : LoggedChange(GLCT_GRFADD) {}
|
||||
LoggedChangeGRFAdd() : LoggedChange(GamelogChangeType::GRFAdd) {}
|
||||
LoggedChangeGRFAdd(const GRFIdentifier &ident) :
|
||||
LoggedChange(GLCT_GRFADD), GRFIdentifier(ident) {}
|
||||
LoggedChange(GamelogChangeType::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() : LoggedChange(GamelogChangeType::GRFRem) {}
|
||||
LoggedChangeGRFRemoved(uint32_t grfid) :
|
||||
LoggedChange(GLCT_GRFREM), grfid(grfid) {}
|
||||
LoggedChange(GamelogChangeType::GRFRem), grfid(grfid) {}
|
||||
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
|
||||
|
||||
uint32_t grfid = 0; ///< ID of removed GRF
|
||||
};
|
||||
|
||||
struct LoggedChangeGRFChanged : LoggedChange, GRFIdentifier {
|
||||
LoggedChangeGRFChanged() : LoggedChange(GLCT_GRFCOMPAT) {}
|
||||
LoggedChangeGRFChanged() : LoggedChange(GamelogChangeType::GRFCompat) {}
|
||||
LoggedChangeGRFChanged(const GRFIdentifier &ident) :
|
||||
LoggedChange(GLCT_GRFCOMPAT), GRFIdentifier(ident) {}
|
||||
LoggedChange(GamelogChangeType::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() : LoggedChange(GamelogChangeType::GRFParam) {}
|
||||
LoggedChangeGRFParameterChanged(uint32_t grfid) :
|
||||
LoggedChange(GLCT_GRFPARAM), grfid(grfid) {}
|
||||
LoggedChange(GamelogChangeType::GRFParam), grfid(grfid) {}
|
||||
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
|
||||
|
||||
uint32_t grfid = 0; ///< ID of GRF with changed parameters
|
||||
};
|
||||
|
||||
struct LoggedChangeGRFMoved : LoggedChange {
|
||||
LoggedChangeGRFMoved() : LoggedChange(GLCT_GRFMOVE) {}
|
||||
LoggedChangeGRFMoved() : LoggedChange(GamelogChangeType::GRFMove) {}
|
||||
LoggedChangeGRFMoved(uint32_t grfid, int32_t offset) :
|
||||
LoggedChange(GLCT_GRFMOVE), grfid(grfid), offset(offset) {}
|
||||
LoggedChange(GamelogChangeType::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 = 0; ///< ID of moved GRF
|
||||
@@ -129,9 +129,9 @@ struct LoggedChangeGRFMoved : LoggedChange {
|
||||
};
|
||||
|
||||
struct LoggedChangeSettingChanged : LoggedChange {
|
||||
LoggedChangeSettingChanged() : LoggedChange(GLCT_SETTING) {}
|
||||
LoggedChangeSettingChanged() : LoggedChange(GamelogChangeType::Setting) {}
|
||||
LoggedChangeSettingChanged(const std::string &name, int32_t oldval, int32_t newval) :
|
||||
LoggedChange(GLCT_SETTING), name(name), oldval(oldval), newval(newval) {}
|
||||
LoggedChange(GamelogChangeType::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
|
||||
@@ -140,9 +140,9 @@ struct LoggedChangeSettingChanged : LoggedChange {
|
||||
};
|
||||
|
||||
struct LoggedChangeGRFBug : LoggedChange {
|
||||
LoggedChangeGRFBug() : LoggedChange(GLCT_GRFBUG) {}
|
||||
LoggedChangeGRFBug() : LoggedChange(GamelogChangeType::GRFBug) {}
|
||||
LoggedChangeGRFBug(uint64_t data, uint32_t grfid, GRFBug bug) :
|
||||
LoggedChange(GLCT_GRFBUG), data(data), grfid(grfid), bug(bug) {}
|
||||
LoggedChange(GamelogChangeType::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 = 0; ///< additional data
|
||||
@@ -151,7 +151,7 @@ struct LoggedChangeGRFBug : LoggedChange {
|
||||
};
|
||||
|
||||
struct LoggedChangeEmergencySave : LoggedChange {
|
||||
LoggedChangeEmergencySave() : LoggedChange(GLCT_EMERGENCY) {}
|
||||
LoggedChangeEmergencySave() : LoggedChange(GamelogChangeType::Emergency) {}
|
||||
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
|
||||
};
|
||||
|
||||
|
||||
+39
-39
@@ -29,13 +29,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_MODE) return;
|
||||
if (lc->ct != GamelogChangeType::Mode) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_MODE) return;
|
||||
if (lc->ct != GamelogChangeType::Mode) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -58,13 +58,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_REVISION) return;
|
||||
if (lc->ct != GamelogChangeType::Revision) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_REVISION) return;
|
||||
if (lc->ct != GamelogChangeType::Revision) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_STRING_GAMELOG)) {
|
||||
@@ -87,13 +87,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_OLDVER) return;
|
||||
if (lc->ct != GamelogChangeType::OldVer) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_OLDVER) return;
|
||||
if (lc->ct != GamelogChangeType::OldVer) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -111,13 +111,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_SETTING) return;
|
||||
if (lc->ct != GamelogChangeType::Setting) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_SETTING) return;
|
||||
if (lc->ct != GamelogChangeType::Setting) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -134,13 +134,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFADD) return;
|
||||
if (lc->ct != GamelogChangeType::GRFAdd) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFADD) return;
|
||||
if (lc->ct != GamelogChangeType::GRFAdd) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -156,13 +156,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFREM) return;
|
||||
if (lc->ct != GamelogChangeType::GRFRem) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFREM) return;
|
||||
if (lc->ct != GamelogChangeType::GRFRem) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -179,13 +179,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFCOMPAT) return;
|
||||
if (lc->ct != GamelogChangeType::GRFCompat) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFCOMPAT) return;
|
||||
if (lc->ct != GamelogChangeType::GRFCompat) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -201,13 +201,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFPARAM) return;
|
||||
if (lc->ct != GamelogChangeType::GRFParam) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFPARAM) return;
|
||||
if (lc->ct != GamelogChangeType::GRFParam) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -224,13 +224,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFMOVE) return;
|
||||
if (lc->ct != GamelogChangeType::GRFMove) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFMOVE) return;
|
||||
if (lc->ct != GamelogChangeType::GRFMove) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -248,13 +248,13 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFBUG) return;
|
||||
if (lc->ct != GamelogChangeType::GRFBug) return;
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_GRFBUG) return;
|
||||
if (lc->ct != GamelogChangeType::GRFBug) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public:
|
||||
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_EMERGENCY) return;
|
||||
if (lc->ct != GamelogChangeType::Emergency) return;
|
||||
|
||||
_is_emergency_save = true;
|
||||
SlObject(lc, this->GetDescription());
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
|
||||
void Load(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_EMERGENCY) return;
|
||||
if (lc->ct != GamelogChangeType::Emergency) return;
|
||||
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
}
|
||||
@@ -292,19 +292,19 @@ public:
|
||||
static std::unique_ptr<LoggedChange> MakeLoggedChange(GamelogChangeType type)
|
||||
{
|
||||
switch (type) {
|
||||
case GLCT_MODE: return std::make_unique<LoggedChangeMode>();
|
||||
case GLCT_REVISION: return std::make_unique<LoggedChangeRevision>();
|
||||
case GLCT_OLDVER: return std::make_unique<LoggedChangeOldVersion>();
|
||||
case GLCT_SETTING: return std::make_unique<LoggedChangeSettingChanged>();
|
||||
case GLCT_GRFADD: return std::make_unique<LoggedChangeGRFAdd>();
|
||||
case GLCT_GRFREM: return std::make_unique<LoggedChangeGRFRemoved>();
|
||||
case GLCT_GRFCOMPAT: return std::make_unique<LoggedChangeGRFChanged>();
|
||||
case GLCT_GRFPARAM: return std::make_unique<LoggedChangeGRFParameterChanged>();
|
||||
case GLCT_GRFMOVE: return std::make_unique<LoggedChangeGRFMoved>();
|
||||
case GLCT_GRFBUG: return std::make_unique<LoggedChangeGRFBug>();
|
||||
case GLCT_EMERGENCY: return std::make_unique<LoggedChangeEmergencySave>();
|
||||
case GLCT_END:
|
||||
case GLCT_NONE:
|
||||
case GamelogChangeType::Mode: return std::make_unique<LoggedChangeMode>();
|
||||
case GamelogChangeType::Revision: return std::make_unique<LoggedChangeRevision>();
|
||||
case GamelogChangeType::OldVer: return std::make_unique<LoggedChangeOldVersion>();
|
||||
case GamelogChangeType::Setting: return std::make_unique<LoggedChangeSettingChanged>();
|
||||
case GamelogChangeType::GRFAdd: return std::make_unique<LoggedChangeGRFAdd>();
|
||||
case GamelogChangeType::GRFRem: return std::make_unique<LoggedChangeGRFRemoved>();
|
||||
case GamelogChangeType::GRFCompat: return std::make_unique<LoggedChangeGRFChanged>();
|
||||
case GamelogChangeType::GRFParam: return std::make_unique<LoggedChangeGRFParameterChanged>();
|
||||
case GamelogChangeType::GRFMove: return std::make_unique<LoggedChangeGRFMoved>();
|
||||
case GamelogChangeType::GRFBug: return std::make_unique<LoggedChangeGRFBug>();
|
||||
case GamelogChangeType::Emergency: return std::make_unique<LoggedChangeEmergencySave>();
|
||||
case GamelogChangeType::End:
|
||||
case GamelogChangeType::None:
|
||||
default:
|
||||
SlErrorCorrupt("Invalid gamelog action type");
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public:
|
||||
SlSetStructListLength(la->change.size());
|
||||
|
||||
for (auto &lc : la->change) {
|
||||
assert(lc->ct < GLCT_END);
|
||||
assert(lc->ct < GamelogChangeType::End);
|
||||
SlObject(lc.get(), this->GetDescription());
|
||||
}
|
||||
}
|
||||
@@ -348,9 +348,9 @@ public:
|
||||
void Load(LoggedAction *la) const override
|
||||
{
|
||||
if (IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY)) {
|
||||
uint8_t type;
|
||||
while ((type = SlReadByte()) != GLCT_NONE) {
|
||||
if (type >= GLCT_END) SlErrorCorrupt("Invalid gamelog change type");
|
||||
GamelogChangeType type;
|
||||
while ((type = static_cast<GamelogChangeType>(SlReadByte())) != GamelogChangeType::None) {
|
||||
if (type >= GamelogChangeType::End) SlErrorCorrupt("Invalid gamelog change type");
|
||||
LoadChange(la, (GamelogChangeType)type);
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user