NewGRF: Only extend value of road stops variable 68 if feature tested for
This commit is contained in:
@@ -5973,6 +5973,11 @@ static void NewSpriteGroup(ByteReader *buf)
|
||||
}
|
||||
}
|
||||
|
||||
if (info.scope_feature == GSF_ROADSTOPS && HasBit(_cur.grffile->observed_feature_tests, GFTOF_ROAD_STOPS)) {
|
||||
if (adjust.variable == 0x68) adjust.variable = A2VRI_ROADSTOP_INFO_NEARBY_TILES_EXT;
|
||||
if (adjust.variable == 0x7B && adjust.parameter == 0x68) adjust.parameter = A2VRI_ROADSTOP_INFO_NEARBY_TILES_EXT;
|
||||
}
|
||||
|
||||
if (adjust.type != DSGA_TYPE_NONE) {
|
||||
adjust.add_val = buf->ReadVarSize(varsize);
|
||||
adjust.divmod_val = buf->ReadVarSize(varsize);
|
||||
|
@@ -60,7 +60,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
|
||||
GRFFeatureInfo("action0_object_edge_foundation_mode", 2),
|
||||
GRFFeatureInfo("action0_object_flood_resistant", 1),
|
||||
GRFFeatureInfo("action0_object_viewport_map_tile_type", 1),
|
||||
GRFFeatureInfo("road_stops", 9),
|
||||
GRFFeatureInfo("road_stops", 9, GFTOF_ROAD_STOPS),
|
||||
GRFFeatureInfo("new_landscape", 2),
|
||||
GRFFeatureInfo("more_objects_per_grf", 1, GFTOF_MORE_OBJECTS_PER_GRF),
|
||||
GRFFeatureInfo("more_action2_ids", 1, GFTOF_MORE_ACTION2_IDS),
|
||||
|
@@ -79,6 +79,7 @@ enum Action2VariableRemapIds {
|
||||
A2VRI_OBJECT_FOUNDATION_SLOPE = 0x100,
|
||||
A2VRI_OBJECT_FOUNDATION_SLOPE_CHANGE,
|
||||
A2VRI_VEHICLE_CURRENT_SPEED_SCALED,
|
||||
A2VRI_ROADSTOP_INFO_NEARBY_TILES_EXT,
|
||||
A2VRI_ROADSTOP_INFO_NEARBY_TILES_V2,
|
||||
A2VRI_RAILTYPE_SIGNAL_RESTRICTION_INFO,
|
||||
A2VRI_RAILTYPE_SIGNAL_CONTEXT,
|
||||
@@ -105,6 +106,7 @@ enum GRFFeatureTestObservationFlag : uint8 {
|
||||
GFTOF_TOWN_ZONE_CALLBACK,
|
||||
GFTOF_MORE_VARACTION2_TYPES,
|
||||
GFTOF_MULTI_PART_SHIPS,
|
||||
GFTOF_ROAD_STOPS,
|
||||
|
||||
GFTOF_INVALID = 0xFF,
|
||||
};
|
||||
|
@@ -94,6 +94,8 @@ static bool IsExpensiveRoadStopsVariable(uint16 variable)
|
||||
case 0x68:
|
||||
case 0x6A:
|
||||
case 0x6B:
|
||||
case A2VRI_ROADSTOP_INFO_NEARBY_TILES_EXT:
|
||||
case A2VRI_ROADSTOP_INFO_NEARBY_TILES_V2:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@@ -67,7 +67,7 @@ uint32 RoadStopScopeResolver::GetTriggers() const
|
||||
return this->st == nullptr ? 0 : this->st->waiting_triggers;
|
||||
}
|
||||
|
||||
uint32 RoadStopScopeResolver::GetNearbyRoadStopsInfo(uint32 parameter, bool v2) const
|
||||
uint32 RoadStopScopeResolver::GetNearbyRoadStopsInfo(uint32 parameter, RoadStopScopeResolver::NearbyRoadStopInfoMode mode) const
|
||||
{
|
||||
if (this->tile == INVALID_TILE) return 0xFFFFFFFF;
|
||||
TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
|
||||
@@ -93,10 +93,16 @@ uint32 RoadStopScopeResolver::GetNearbyRoadStopsInfo(uint32 parameter, bool v2)
|
||||
res |= (GetDriveThroughStopDisallowedRoadDirections(nearby_tile) << 21);
|
||||
}
|
||||
|
||||
if (v2) {
|
||||
return (res << 8) | localidx;
|
||||
} else {
|
||||
return res | (localidx & 0xFF) | ((localidx & 0xFF00) << 16);
|
||||
switch (mode) {
|
||||
case NearbyRoadStopInfoMode::Standard:
|
||||
default:
|
||||
return res | std::min<uint16>(localidx, 0xFF);
|
||||
|
||||
case NearbyRoadStopInfoMode::Extended:
|
||||
return res | (localidx & 0xFF) | ((localidx & 0xFF00) << 16);
|
||||
|
||||
case NearbyRoadStopInfoMode::V2:
|
||||
return (res << 8) | localidx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,12 +197,17 @@ uint32 RoadStopScopeResolver::GetVariable(uint16 variable, uint32 parameter, Get
|
||||
|
||||
/* Road stop info of nearby tiles */
|
||||
case 0x68: {
|
||||
return this->GetNearbyRoadStopsInfo(parameter, false);
|
||||
return this->GetNearbyRoadStopsInfo(parameter, NearbyRoadStopInfoMode::Standard);
|
||||
}
|
||||
|
||||
/* Road stop info of nearby tiles: extended */
|
||||
case A2VRI_ROADSTOP_INFO_NEARBY_TILES_EXT: {
|
||||
return this->GetNearbyRoadStopsInfo(parameter, NearbyRoadStopInfoMode::Extended);
|
||||
}
|
||||
|
||||
/* Road stop info of nearby tiles: v2 */
|
||||
case A2VRI_ROADSTOP_INFO_NEARBY_TILES_V2: {
|
||||
return this->GetNearbyRoadStopsInfo(parameter, true);
|
||||
return this->GetNearbyRoadStopsInfo(parameter, NearbyRoadStopInfoMode::V2);
|
||||
}
|
||||
|
||||
/* GRFID of nearby road stop tiles */
|
||||
|
@@ -102,7 +102,12 @@ struct RoadStopScopeResolver : public ScopeResolver {
|
||||
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
||||
|
||||
private:
|
||||
uint32 GetNearbyRoadStopsInfo(uint32 parameter, bool v2) const;
|
||||
enum class NearbyRoadStopInfoMode {
|
||||
Standard,
|
||||
Extended,
|
||||
V2,
|
||||
};
|
||||
uint32 GetNearbyRoadStopsInfo(uint32 parameter, NearbyRoadStopInfoMode mode) const;
|
||||
};
|
||||
|
||||
/** Road stop resolver. */
|
||||
|
@@ -1945,6 +1945,7 @@ static const NIVariable _nif_roadstops[] = {
|
||||
NIV(0x69, "information about cargo accepted in the past"),
|
||||
NIV(0x6A, "GRFID of nearby road stop tiles"),
|
||||
NIV(0x6B, "Road info of nearby plain road tiles"),
|
||||
NIV(A2VRI_ROADSTOP_INFO_NEARBY_TILES_EXT, "road stop info of nearby tiles ext"),
|
||||
NIV(A2VRI_ROADSTOP_INFO_NEARBY_TILES_V2, "road stop info of nearby tiles v2"),
|
||||
NIV_END(),
|
||||
};
|
||||
|
Reference in New Issue
Block a user