GRF: Add generic mechanism to observe which features have been tested

This commit is contained in:
Jonathan G Rennison
2023-02-12 21:50:52 +00:00
parent 53835cef8e
commit a85b3d7de7
3 changed files with 15 additions and 3 deletions

View File

@@ -9231,6 +9231,9 @@ struct GRFFeatureTest {
} else { } else {
grfmsg(2, "Action 14 feature test: feature test: doing nothing: %u", has_feature ? 1 : 0); grfmsg(2, "Action 14 feature test: feature test: doing nothing: %u", has_feature ? 1 : 0);
} }
if (this->feature != nullptr && this->feature->observation_flag != GFTOF_INVALID) {
SetBit(_cur.grffile->observed_feature_tests, this->feature->observation_flag);
}
} }
}; };

View File

@@ -358,6 +358,8 @@ struct GRFFile : ZeroedMemoryAllocator {
uint32 var8D_overlay; ///< Overlay for global variable 8D (action 0x14) uint32 var8D_overlay; ///< Overlay for global variable 8D (action 0x14)
uint32 var9D_overlay; ///< Overlay for global variable 9D (action 0x14) uint32 var9D_overlay; ///< Overlay for global variable 9D (action 0x14)
uint32 observed_feature_tests; ///< Observed feature test bits (see: GRFFeatureTestObservationFlag)
const SpriteGroup *new_signals_group; ///< New signals sprite group const SpriteGroup *new_signals_group; ///< New signals sprite group
byte new_signal_ctrl_flags; ///< Ctrl flags for new signals byte new_signal_ctrl_flags; ///< Ctrl flags for new signals
byte new_signal_extra_aspects; ///< Number of extra aspects for new signals byte new_signal_extra_aspects; ///< Number of extra aspects for new signals

View File

@@ -85,20 +85,27 @@ enum Action2VariableRemapIds {
A2VRI_SIGNALS_SIGNAL_STYLE, A2VRI_SIGNALS_SIGNAL_STYLE,
}; };
enum GRFFeatureTestObservationFlag : uint8 {
GFTOF_INVALID = 0xFF,
};
/** Action14 feature definition */ /** Action14 feature definition */
struct GRFFeatureInfo { struct GRFFeatureInfo {
const char *name; // nullptr indicates the end of the list const char *name; // nullptr indicates the end of the list
uint16 version; uint16 version;
GRFFeatureTestObservationFlag observation_flag;
/** Create empty object used to identify the end of a list. */ /** Create empty object used to identify the end of a list. */
GRFFeatureInfo() : GRFFeatureInfo() :
name(nullptr), name(nullptr),
version(0) version(0),
observation_flag(GFTOF_INVALID)
{} {}
GRFFeatureInfo(const char *name, uint16 version) : GRFFeatureInfo(const char *name, uint16 version, GRFFeatureTestObservationFlag observation_flag = GFTOF_INVALID) :
name(name), name(name),
version(version) version(version),
observation_flag(observation_flag)
{} {}
}; };