Add NewGRF VarAction2 variable remapping infrastructure
This commit is contained in:
@@ -105,7 +105,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
* @param available will return false if ever the variable asked for does not exist
|
||||
* @return the value stored in the corresponding variable
|
||||
*/
|
||||
virtual uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const = 0;
|
||||
virtual uint32 GetNewGRFVariable(const struct ResolverObject &object, uint16 variable, byte parameter, bool *available) const = 0;
|
||||
|
||||
/**
|
||||
* Update the coordinated of the sign (as shown in the viewport).
|
||||
|
149
src/newgrf.cpp
149
src/newgrf.cpp
@@ -5295,6 +5295,17 @@ static void NewSpriteGroup(ByteReader *buf)
|
||||
adjust.type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2);
|
||||
adjust.and_mask = buf->ReadVarSize(varsize);
|
||||
|
||||
if (adjust.variable == 0x11) {
|
||||
for (const GRFVariableMapEntry &remap : _cur.grffile->grf_variable_remaps) {
|
||||
if (remap.feature == feature && remap.input_shift == adjust.shift_num && remap.input_mask == adjust.and_mask) {
|
||||
adjust.variable = remap.id;
|
||||
adjust.shift_num = remap.output_shift;
|
||||
adjust.and_mask = remap.output_mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (adjust.type != DSGA_TYPE_NONE) {
|
||||
adjust.add_val = buf->ReadVarSize(varsize);
|
||||
adjust.divmod_val = buf->ReadVarSize(varsize);
|
||||
@@ -8668,6 +8679,10 @@ struct GRFPropertyMapAction {
|
||||
std::string name;
|
||||
GRFPropertyMapFallbackMode fallback_mode;
|
||||
uint8 ttd_ver_var_bit;
|
||||
uint8 input_shift;
|
||||
uint8 output_shift;
|
||||
uint input_mask;
|
||||
uint output_mask;
|
||||
|
||||
void Reset(const char *tag, const char *desc)
|
||||
{
|
||||
@@ -8679,6 +8694,10 @@ struct GRFPropertyMapAction {
|
||||
this->name.clear();
|
||||
this->fallback_mode = GPMFM_IGNORE;
|
||||
this->ttd_ver_var_bit = 0;
|
||||
this->input_shift = 0;
|
||||
this->output_shift = 0;
|
||||
this->input_mask = 0;
|
||||
this->output_mask = 0;
|
||||
}
|
||||
|
||||
void ExecutePropertyRemapping()
|
||||
@@ -8733,6 +8752,34 @@ struct GRFPropertyMapAction {
|
||||
}
|
||||
}
|
||||
|
||||
void ExecuteVariableRemapping()
|
||||
{
|
||||
if (this->feature < 0) {
|
||||
grfmsg(2, "Action 14 %s remapping: no feature defined, doing nothing", this->descriptor);
|
||||
return;
|
||||
}
|
||||
if (this->name.empty()) {
|
||||
grfmsg(2, "Action 14 %s remapping: no name defined, doing nothing", this->descriptor);
|
||||
return;
|
||||
}
|
||||
bool success = false;
|
||||
const char *str = this->name.c_str();
|
||||
extern const GRFVariableMapDefinition _grf_action2_remappable_variables[];
|
||||
for (const GRFVariableMapDefinition *info = _grf_action2_remappable_variables; info->name != nullptr; info++) {
|
||||
if (info->feature == this->feature && strcmp(info->name, str) == 0) {
|
||||
_cur.grffile->grf_variable_remaps.push_back({ info->id, (uint8) this->feature, this->input_shift, this->output_shift, this->input_mask, this->output_mask });
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this->ttd_ver_var_bit > 0) {
|
||||
SB(_cur.grffile->var8D_overlay, this->ttd_ver_var_bit, 1, success ? 1 : 0);
|
||||
}
|
||||
if (!success) {
|
||||
grfmsg(2, "Unimplemented mapped %s: %s, feature: %X, mapped to 0", this->descriptor, str, this->feature);
|
||||
}
|
||||
}
|
||||
|
||||
void ExecuteAction5TypeRemapping()
|
||||
{
|
||||
if (this->prop_id < 0) {
|
||||
@@ -8869,6 +8916,82 @@ static bool ChangePropertyRemapSetTTDVerVarBit(size_t len, ByteReader *buf)
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Callback function for ->'RSFT' to set the input shift value for variable remapping. */
|
||||
static bool ChangePropertyRemapSetInputShift(size_t len, ByteReader *buf)
|
||||
{
|
||||
GRFPropertyMapAction &action = _current_grf_property_map_action;
|
||||
if (len != 1) {
|
||||
grfmsg(2, "Action 14 %s mapping: expected 1 byte for '%s'->'RSFT' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len);
|
||||
buf->Skip(len);
|
||||
} else {
|
||||
uint8 input_shift = buf->ReadByte();
|
||||
if (input_shift < 0x20) {
|
||||
action.input_shift = input_shift;
|
||||
} else {
|
||||
grfmsg(2, "Action 14 %s mapping: expected a shift value < 0x20 for '%s'->'RSFT' but got %u, ignoring this field", action.descriptor, action.tag_name, input_shift);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Callback function for ->'VSFT' to set the output shift value for variable remapping. */
|
||||
static bool ChangePropertyRemapSetOutputShift(size_t len, ByteReader *buf)
|
||||
{
|
||||
GRFPropertyMapAction &action = _current_grf_property_map_action;
|
||||
if (len != 1) {
|
||||
grfmsg(2, "Action 14 %s mapping: expected 1 byte for '%s'->'VSFT' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len);
|
||||
buf->Skip(len);
|
||||
} else {
|
||||
uint8 output_shift = buf->ReadByte();
|
||||
if (output_shift < 0x20) {
|
||||
action.output_shift = output_shift;
|
||||
} else {
|
||||
grfmsg(2, "Action 14 %s mapping: expected a shift value < 0x20 for '%s'->'VSFT' but got %u, ignoring this field", action.descriptor, action.tag_name, output_shift);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Callback function for ->'RMSK' to set the input mask value for variable remapping. */
|
||||
static bool ChangePropertyRemapSetInputMask(size_t len, ByteReader *buf)
|
||||
{
|
||||
GRFPropertyMapAction &action = _current_grf_property_map_action;
|
||||
if (len != 4) {
|
||||
grfmsg(2, "Action 14 %s mapping: expected 4 bytes for '%s'->'RMSK' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len);
|
||||
buf->Skip(len);
|
||||
} else {
|
||||
action.input_mask = buf->ReadDWord();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Callback function for ->'VMSK' to set the output mask value for variable remapping. */
|
||||
static bool ChangePropertyRemapSetOutputMask(size_t len, ByteReader *buf)
|
||||
{
|
||||
GRFPropertyMapAction &action = _current_grf_property_map_action;
|
||||
if (len != 4) {
|
||||
grfmsg(2, "Action 14 %s mapping: expected 4 bytes for '%s'->'VMSK' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len);
|
||||
buf->Skip(len);
|
||||
} else {
|
||||
action.output_mask = buf->ReadDWord();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Callback function for ->'VPRM' to set the output parameter value for variable remapping. */
|
||||
static bool ChangePropertyRemapSetOutputParam(size_t len, ByteReader *buf)
|
||||
{
|
||||
GRFPropertyMapAction &action = _current_grf_property_map_action;
|
||||
if (len != 4) {
|
||||
grfmsg(2, "Action 14 %s mapping: expected 4 bytes for '%s'->'VPRM' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len);
|
||||
buf->Skip(len);
|
||||
} else {
|
||||
buf->ReadDWord();
|
||||
/* This is not implemented yet, so just do nothing, but still validate that the format is correct */
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Action14 tags for the A0PM node */
|
||||
AllowedSubtags _tags_a0pm[] = {
|
||||
AllowedSubtags('NAME', ChangePropertyRemapName),
|
||||
@@ -8890,6 +9013,30 @@ static bool HandleAction0PropertyMap(ByteReader *buf)
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Action14 tags for the A2VM node */
|
||||
AllowedSubtags _tags_a2vm[] = {
|
||||
AllowedSubtags('NAME', ChangePropertyRemapName),
|
||||
AllowedSubtags('FEAT', ChangePropertyRemapFeature),
|
||||
AllowedSubtags('RSFT', ChangePropertyRemapSetInputShift),
|
||||
AllowedSubtags('RMSK', ChangePropertyRemapSetInputMask),
|
||||
AllowedSubtags('VSFT', ChangePropertyRemapSetOutputShift),
|
||||
AllowedSubtags('VMSK', ChangePropertyRemapSetOutputMask),
|
||||
AllowedSubtags('VPRM', ChangePropertyRemapSetOutputParam),
|
||||
AllowedSubtags('SETT', ChangePropertyRemapSetTTDVerVarBit),
|
||||
AllowedSubtags()
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback function for 'A2VM' (action 2 variable mapping)
|
||||
*/
|
||||
static bool HandleAction2VariableMap(ByteReader *buf)
|
||||
{
|
||||
_current_grf_property_map_action.Reset("A2VM", "variable");
|
||||
HandleNodes(buf, _tags_a2vm);
|
||||
_current_grf_property_map_action.ExecuteVariableRemapping();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Action14 tags for the A5TM node */
|
||||
AllowedSubtags _tags_a5tm[] = {
|
||||
AllowedSubtags('NAME', ChangePropertyRemapName),
|
||||
@@ -8915,6 +9062,7 @@ AllowedSubtags _tags_root_static[] = {
|
||||
AllowedSubtags('INFO', _tags_info),
|
||||
AllowedSubtags('FTST', SkipInfoChunk),
|
||||
AllowedSubtags('A0PM', SkipInfoChunk),
|
||||
AllowedSubtags('A2VM', SkipInfoChunk),
|
||||
AllowedSubtags('A5TM', SkipInfoChunk),
|
||||
AllowedSubtags()
|
||||
};
|
||||
@@ -8924,6 +9072,7 @@ AllowedSubtags _tags_root_feature_tests[] = {
|
||||
AllowedSubtags('INFO', SkipInfoChunk),
|
||||
AllowedSubtags('FTST', HandleFeatureTestInfo),
|
||||
AllowedSubtags('A0PM', HandleAction0PropertyMap),
|
||||
AllowedSubtags('A2VM', HandleAction2VariableMap),
|
||||
AllowedSubtags('A5TM', HandleAction5TypeMap),
|
||||
AllowedSubtags()
|
||||
};
|
||||
|
29
src/newgrf.h
29
src/newgrf.h
@@ -149,6 +149,34 @@ struct GRFFilePropertyRemapSet {
|
||||
}
|
||||
};
|
||||
|
||||
struct GRFVariableMapDefinition {
|
||||
const char *name; // nullptr indicates the end of the list
|
||||
int id;
|
||||
uint8 feature;
|
||||
|
||||
/** Create empty object used to identify the end of a list. */
|
||||
GRFVariableMapDefinition() :
|
||||
name(nullptr),
|
||||
id(0),
|
||||
feature(0)
|
||||
{}
|
||||
|
||||
GRFVariableMapDefinition(uint8 feature, int id, const char *name) :
|
||||
name(name),
|
||||
id(id),
|
||||
feature(feature)
|
||||
{}
|
||||
};
|
||||
|
||||
struct GRFVariableMapEntry {
|
||||
uint16 id = 0;
|
||||
uint8 feature = 0;
|
||||
uint8 input_shift = 0;
|
||||
uint8 output_shift = 0;
|
||||
uint32 input_mask = 0;
|
||||
uint32 output_mask = 0;
|
||||
};
|
||||
|
||||
/** The type of action 5 type. */
|
||||
enum Action5BlockType {
|
||||
A5BLOCK_FIXED, ///< Only allow replacing a whole block of sprites. (TTDP compatible)
|
||||
@@ -235,6 +263,7 @@ struct GRFFile : ZeroedMemoryAllocator {
|
||||
|
||||
GRFFilePropertyRemapSet action0_property_remaps[GSF_END];
|
||||
Action5TypeRemapSet action5_type_remaps;
|
||||
std::vector<GRFVariableMapEntry> grf_variable_remaps;
|
||||
std::vector<std::unique_ptr<const char, FreeDeleter>> remap_unknown_property_names;
|
||||
|
||||
uint32 param[0x80];
|
||||
|
@@ -38,7 +38,7 @@ struct AirportScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
void StorePSA(uint pos, int32 value) override;
|
||||
};
|
||||
|
||||
@@ -195,7 +195,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as)
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ uint32 AirportScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 AirportScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
switch (variable) {
|
||||
case 0x40: return this->layout;
|
||||
|
@@ -158,7 +158,7 @@ static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32
|
||||
return 0xFF << 8 | ats->grf_prop.subst_id; // so just give it the substitute
|
||||
}
|
||||
|
||||
/* virtual */ uint32 AirportTileScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 AirportTileScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
assert(this->st != nullptr);
|
||||
|
||||
|
@@ -38,7 +38,7 @@ struct AirportTileScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
};
|
||||
|
||||
/** Resolver for tiles of an airport. */
|
||||
|
@@ -30,7 +30,7 @@ struct CanalScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
};
|
||||
|
||||
/** Resolver object for canals. */
|
||||
@@ -59,7 +59,7 @@ struct CanalResolverObject : public ResolverObject {
|
||||
return IsTileType(this->tile, MP_WATER) ? GetWaterTileRandomBits(this->tile) : 0;
|
||||
}
|
||||
|
||||
/* virtual */ uint32 CanalScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 CanalScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
switch (variable) {
|
||||
/* Height of tile */
|
||||
|
@@ -424,7 +424,7 @@ static uint32 PositionHelper(const Vehicle *v, bool consecutive)
|
||||
return chain_before | chain_after << 8 | (chain_before + chain_after + consecutive) << 16;
|
||||
}
|
||||
|
||||
static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, byte variable, uint32 parameter, GetVariableExtra *extra)
|
||||
static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, uint16 variable, uint32 parameter, GetVariableExtra *extra)
|
||||
{
|
||||
if (_sprite_group_resolve_check_veh_check) {
|
||||
switch (variable) {
|
||||
@@ -1104,7 +1104,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
/* virtual */ uint32 VehicleScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 VehicleScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
if (this->v == nullptr) {
|
||||
/* Vehicle does not exist, so we're in a purchase list */
|
||||
|
@@ -39,7 +39,7 @@ struct VehicleScopeResolver : public ScopeResolver {
|
||||
void SetVehicle(const Vehicle *v) { this->v = v; }
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetTriggers() const override;
|
||||
};
|
||||
|
||||
|
@@ -18,6 +18,7 @@
|
||||
extern const GRFFeatureInfo _grf_feature_list[] = {
|
||||
GRFFeatureInfo("feature_test", 1),
|
||||
GRFFeatureInfo("property_mapping", 1),
|
||||
GRFFeatureInfo("variable_mapping", 1),
|
||||
GRFFeatureInfo("action5_type_id_mapping", 1),
|
||||
GRFFeatureInfo("action0_station_prop1B", 1),
|
||||
GRFFeatureInfo("action0_station_disallowed_bridge_pillars", 1),
|
||||
@@ -76,6 +77,11 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
|
||||
GRFPropertyMapDefinition(),
|
||||
};
|
||||
|
||||
/** Action14 Action2 remappable variable list */
|
||||
extern const GRFVariableMapDefinition _grf_action2_remappable_variables[] = {
|
||||
GRFVariableMapDefinition(),
|
||||
};
|
||||
|
||||
/** Action14 Action5 remappable type list */
|
||||
extern const Action5TypeRemapDefinition _grf_action5_remappable_types[] = {
|
||||
Action5TypeRemapDefinition("programmable_signals", A5BLOCK_ALLOW_OFFSET, SPR_PROGSIGNAL_BASE, 1, 32, "Programmable pre-signal graphics"),
|
||||
|
@@ -38,6 +38,9 @@ enum Action0RemapPropertyIds {
|
||||
};
|
||||
|
||||
|
||||
enum Action2VariableRemapIds {
|
||||
};
|
||||
|
||||
/** Action14 feature definition */
|
||||
struct GRFFeatureInfo {
|
||||
const char *name; // nullptr indicates the end of the list
|
||||
|
@@ -42,7 +42,7 @@ struct GenericScopeResolver : public ScopeResolver {
|
||||
{
|
||||
}
|
||||
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
|
||||
private:
|
||||
bool ai_callback; ///< Callback comes from the AI.
|
||||
@@ -119,7 +119,7 @@ void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *g
|
||||
_gcl[feature].push_front(GenericCallback(file, group));
|
||||
}
|
||||
|
||||
/* virtual */ uint32 GenericScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 GenericScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
if (this->ai_callback) {
|
||||
switch (variable) {
|
||||
|
@@ -322,7 +322,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
|
||||
/**
|
||||
* @note Used by the resolver to get values for feature 07 deterministic spritegroups.
|
||||
*/
|
||||
/* virtual */ uint32 HouseScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 HouseScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
switch (variable) {
|
||||
/* Construction stage. */
|
||||
@@ -446,7 +446,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
|
||||
/**
|
||||
* @note Used by the resolver to get values for feature 07 deterministic spritegroups.
|
||||
*/
|
||||
/* virtual */ uint32 FakeHouseScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 FakeHouseScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
switch (variable) {
|
||||
/* Construction stage. */
|
||||
|
@@ -50,7 +50,7 @@ struct HouseScopeResolver : public CommonHouseScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetTriggers() const override;
|
||||
};
|
||||
|
||||
@@ -70,7 +70,7 @@ struct FakeHouseScopeResolver : public CommonHouseScopeResolver {
|
||||
: CommonHouseScopeResolver(ro, house_id)
|
||||
{ }
|
||||
|
||||
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
/* virtual */ uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
};
|
||||
|
||||
/** Resolver object to be used for houses (feature 07 spritegroups). */
|
||||
|
@@ -155,7 +155,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
|
||||
return count << 16 | GB(closest_dist, 0, 16);
|
||||
}
|
||||
|
||||
/* virtual */ uint32 IndustriesScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 IndustriesScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
if (this->ro.callback == CBID_INDUSTRY_LOCATION) {
|
||||
/* Variables available during construction check. */
|
||||
|
@@ -33,7 +33,7 @@ struct IndustriesScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetTriggers() const override;
|
||||
void StorePSA(uint pos, int32 value) override;
|
||||
};
|
||||
|
@@ -58,7 +58,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
|
||||
return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x;
|
||||
}
|
||||
|
||||
/* virtual */ uint32 IndustryTileScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 IndustryTileScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
switch (variable) {
|
||||
/* Construction state of the tile: a value between 0 and 3 */
|
||||
|
@@ -31,7 +31,7 @@ struct IndustryTileScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetTriggers() const override;
|
||||
};
|
||||
|
||||
|
@@ -22,7 +22,7 @@ std::vector<const GRFFile *> _new_signals_grfs;
|
||||
return GB(tmp, 0, 2);
|
||||
}
|
||||
|
||||
/* virtual */ uint32 NewSignalsScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 NewSignalsScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
if (this->tile == INVALID_TILE) {
|
||||
switch (variable) {
|
||||
|
@@ -32,7 +32,7 @@ struct NewSignalsScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
};
|
||||
|
||||
/** Resolver object for rail types. */
|
||||
|
@@ -231,7 +231,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid,
|
||||
}
|
||||
|
||||
/** Used by the resolver to get values for feature 0F deterministic spritegroups. */
|
||||
/* virtual */ uint32 ObjectScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 ObjectScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
/* We get the town from the object, or we calculate the closest
|
||||
* town if we need to when there's no object. */
|
||||
|
@@ -134,7 +134,7 @@ struct ObjectScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
};
|
||||
|
||||
/** A resolver object to be used with feature 0F spritegroups. */
|
||||
|
@@ -23,7 +23,7 @@
|
||||
return GB(tmp, 0, 2);
|
||||
}
|
||||
|
||||
/* virtual */ uint32 RailTypeScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 RailTypeScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
if (this->tile == INVALID_TILE) {
|
||||
switch (variable) {
|
||||
|
@@ -32,7 +32,7 @@ struct RailTypeScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
};
|
||||
|
||||
/** Resolver object for rail types. */
|
||||
|
@@ -22,7 +22,7 @@
|
||||
return GB(tmp, 0, 2);
|
||||
}
|
||||
|
||||
/* virtual */ uint32 RoadTypeScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 RoadTypeScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
if (this->tile == INVALID_TILE) {
|
||||
switch (variable) {
|
||||
|
@@ -33,7 +33,7 @@ struct RoadTypeScopeResolver : public ScopeResolver {
|
||||
}
|
||||
|
||||
/* virtual */ uint32 GetRandomBits() const;
|
||||
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
/* virtual */ uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
};
|
||||
|
||||
/** Resolver object for road types. */
|
||||
|
@@ -56,7 +56,7 @@ TemporaryStorageArray<int32, 0x110> _temp_store;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *scope, byte variable, uint32 parameter, GetVariableExtra *extra)
|
||||
static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *scope, uint16 variable, uint32 parameter, GetVariableExtra *extra)
|
||||
{
|
||||
uint32 value;
|
||||
switch (variable) {
|
||||
@@ -106,7 +106,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc
|
||||
* @param[out] available Set to false, in case the variable does not exist.
|
||||
* @return Value
|
||||
*/
|
||||
/* virtual */ uint32 ScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 ScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
DEBUG(grf, 1, "Unhandled scope variable 0x%X", variable);
|
||||
extra->available = false;
|
||||
|
@@ -166,7 +166,7 @@ enum DeterministicSpriteGroupAdjustOperation {
|
||||
struct DeterministicSpriteGroupAdjust {
|
||||
DeterministicSpriteGroupAdjustOperation operation;
|
||||
DeterministicSpriteGroupAdjustType type;
|
||||
byte variable;
|
||||
uint16 variable;
|
||||
byte parameter; ///< Used for variables between 0x60 and 0x7F inclusive.
|
||||
byte shift_num;
|
||||
uint32 and_mask;
|
||||
@@ -326,7 +326,7 @@ struct ScopeResolver {
|
||||
virtual uint32 GetRandomBits() const;
|
||||
virtual uint32 GetTriggers() const;
|
||||
|
||||
virtual uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
virtual uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
virtual void StorePSA(uint reg, int32 value);
|
||||
};
|
||||
|
||||
|
@@ -268,7 +268,7 @@ TownScopeResolver *StationResolverObject::GetTown()
|
||||
return this->town_scope;
|
||||
}
|
||||
|
||||
/* virtual */ uint32 StationScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 StationScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
if (this->st == nullptr) {
|
||||
/* Station does not exist, so we're in a purchase list or the land slope check callback. */
|
||||
@@ -389,7 +389,7 @@ TownScopeResolver *StationResolverObject::GetTown()
|
||||
return this->st->GetNewGRFVariable(this->ro, variable, parameter, &(extra->available));
|
||||
}
|
||||
|
||||
uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
|
||||
uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable, byte parameter, bool *available) const
|
||||
{
|
||||
switch (variable) {
|
||||
case 0x48: { // Accepted cargo types
|
||||
@@ -460,7 +460,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
|
||||
uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, uint16 variable, byte parameter, bool *available) const
|
||||
{
|
||||
switch (variable) {
|
||||
case 0x48: return 0; // Accepted cargo types
|
||||
|
@@ -45,7 +45,7 @@ struct StationScopeResolver : public ScopeResolver {
|
||||
uint32 GetRandomBits() const override;
|
||||
uint32 GetTriggers() const override;
|
||||
|
||||
uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
};
|
||||
|
||||
/** Station resolver. */
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
/* virtual */ uint32 TownScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 TownScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
switch (variable) {
|
||||
/* Larger towns */
|
||||
@@ -148,7 +148,7 @@
|
||||
t->psa_list.push_back(psa);
|
||||
}
|
||||
|
||||
/* virtual */ uint32 FakeTownScopeResolver::GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32 FakeTownScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
switch (variable) {
|
||||
/* Town index */
|
||||
|
@@ -34,7 +34,7 @@ struct TownScopeResolver : public ScopeResolver {
|
||||
{
|
||||
}
|
||||
|
||||
virtual uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
virtual uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
virtual void StorePSA(uint reg, int32 value);
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ struct FakeTownScopeResolver : public ScopeResolver {
|
||||
FakeTownScopeResolver(ResolverObject &ro) : ScopeResolver(ro)
|
||||
{ }
|
||||
|
||||
virtual uint32 GetVariable(byte variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
virtual uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const;
|
||||
};
|
||||
|
||||
/** Resolver of town properties. */
|
||||
|
@@ -880,7 +880,7 @@ public:
|
||||
|
||||
bool IsWithinRangeOfDockingTile(TileIndex tile, uint max_distance) const;
|
||||
|
||||
uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const override;
|
||||
uint32 GetNewGRFVariable(const ResolverObject &object, uint16 variable, byte parameter, bool *available) const override;
|
||||
|
||||
void GetTileArea(TileArea *ta, StationType type) const override;
|
||||
};
|
||||
|
@@ -40,7 +40,7 @@ struct Waypoint FINAL : SpecializedStation<Waypoint, true> {
|
||||
return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
|
||||
}
|
||||
|
||||
uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override;
|
||||
uint32 GetNewGRFVariable(const struct ResolverObject &object, uint16 variable, byte parameter, bool *available) const override;
|
||||
|
||||
void GetTileArea(TileArea *ta, StationType type) const override;
|
||||
|
||||
|
Reference in New Issue
Block a user