@@ -102,13 +102,13 @@ uint32 RoadStopScopeResolver::GetVariabl
case 0x44: return get_road_type_variable(RTT_TRAM);
/* Town zone and Manhattan distance of closest town */
case 0x45: {
if (this->tile == INVALID_TILE) return HZB_TOWN_EDGE << 16;
const Town *t = (this->st == nullptr) ? ClosestTownFromTile(this->tile, UINT_MAX) : this->st->town;
return t != nullptr ? (GetTownRadiusGroup(t, this->tile) << 16 | std::min(DistanceManhattan(this->tile, t->xy), 0xFFFFu)) : HZB_TOWN_EDGE << 16;
return t != nullptr ? (GetTownRadiusGroup(t, this->tile) << 16 | ClampTo<uint16_t>(DistanceManhattan(this->tile, t->xy))) : HZB_TOWN_EDGE << 16;
}
/* Get square of Euclidian distance of closest town */
case 0x46: {
if (this->tile == INVALID_TILE) return 0;
@@ -173,13 +173,13 @@ uint32 RoadStopScopeResolver::GetVariabl
const RoadStopSpecList ssl = BaseStation::GetByTile(nearby_tile)->roadstop_speclist[GetCustomRoadStopSpecIndex(nearby_tile)];
return ssl.grfid;
case 0xF0: return this->st == nullptr ? 0 : this->st->facilities; // facilities
case 0xFA: return Clamp((this->st == nullptr ? TimerGameCalendar::date : this->st->build_date) - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // build date
case 0xFA: return ClampTo<uint16_t>((this->st == nullptr ? TimerGameCalendar::date : this->st->build_date) - DAYS_TILL_ORIGINAL_BASE_YEAR); // build date
if (this->st != nullptr) return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
*available = false;
return UINT_MAX;