mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
3 Commits
9e52bee7d8
...
d7d23e6684
Author | SHA1 | Date |
---|---|---|
|
d7d23e6684 | |
|
baced00e9f | |
|
13f24c25ca |
|
@ -267,6 +267,7 @@ STR_UNITS_YEARS :{NUM}{NBSP}jaar
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}period{P "" en}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filter:
|
||||
|
|
|
@ -267,6 +267,7 @@ STR_UNITS_YEARS :{NUM}{NBSP}year
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}period{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filter:
|
||||
|
|
|
@ -268,6 +268,7 @@ STR_UNITS_YEARS :{NUM}{NBSP}ano{
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}período{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filtrar:
|
||||
|
@ -1302,6 +1303,9 @@ STR_CONFIG_SETTING_INTEREST_RATE_HELPTEXT :A taxa de inter
|
|||
STR_CONFIG_SETTING_RUNNING_COSTS :Custos de explotación: {STRING}
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_HELPTEXT :Establece o nivel de mantemento e custo de operación de vehículos e infraestrutura
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_LOW :Baixo
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_MEDIUM :Medio
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_HIGH :Alto
|
||||
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_SPEED :Velocidade de construción: {STRING}
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_SPEED_HELPTEXT :Limita a cantidade de accións construtivas das IAs
|
||||
|
@ -1324,6 +1328,9 @@ STR_CONFIG_SETTING_SUBSIDY_DURATION_DISABLED :Sen subvención
|
|||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS :Custos de construción: {STRING}
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_HELPTEXT :Fixa o nivel de custos de construción e compra
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_LOW :Baixo
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_MEDIUM :Medio
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_HIGH :Alto
|
||||
|
||||
STR_CONFIG_SETTING_RECESSIONS :Recesións económicas: {STRING}
|
||||
STR_CONFIG_SETTING_RECESSIONS_HELPTEXT :Se está activado, a economía pode entrar en recesión periódicamente. Durante unha recesión tódalas producións son significativamente máis baixas (volvendo ao nivel anterior cando a recesión remata)
|
||||
|
@ -2079,9 +2086,9 @@ STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED_HELPTEXT :A clase de merc
|
|||
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT :Xeito de distribución para outros tipos de mercadoría: {STRING}
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT_HELPTEXT :"Asimétrico" significa que calquera cantidade de mercadorías pode ser enviada en calquera dirección. "Manual" significa que non haberá distribución automática para estas mercadorías
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_MANUAL :manual
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_ASYMMETRIC :asimétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_SYMMETRIC :simétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_MANUAL :Manual
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_ASYMMETRIC :Asimétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_SYMMETRIC :Simétrica
|
||||
|
||||
STR_CONFIG_SETTING_LINKGRAPH_ACCURACY :Precisión da distribución: {STRING}
|
||||
STR_CONFIG_SETTING_LINKGRAPH_ACCURACY_HELPTEXT :Canto máis alto sexa o valor, máis tempo de CPU levará o cálculo de distribución. Se leva demasiado tempo podes experimentar retraso. Se sen embargo o fixas nun valor baixo, a distribución será imprecisa, e pode que a carga non sexa enviada aos destinos que ti queres
|
||||
|
|
|
@ -739,7 +739,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Clique n
|
|||
STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Clique numa faixa para a remover da lista (apenas Personalização 1 ou Personalização 2)
|
||||
|
||||
# Highscore window
|
||||
STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Melhores empresas
|
||||
STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}As melhores empresas
|
||||
STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}.
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Negociante
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Empresário
|
||||
|
@ -749,7 +749,7 @@ STR_HIGHSCORE_PERFORMANCE_TITLE_MAGNATE :Magnata
|
|||
STR_HIGHSCORE_PERFORMANCE_TITLE_MOGUL :Grande magnata
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_TYCOON_OF_THE_CENTURY :Magnata do século
|
||||
STR_HIGHSCORE_NAME :{PRESIDENT_NAME}, {COMPANY}
|
||||
STR_HIGHSCORE_STATS :{BIG_FONT}'{STRING}' ({COMMA})
|
||||
STR_HIGHSCORE_STATS :{BIG_FONT}"{STRING}" ({COMMA})
|
||||
STR_HIGHSCORE_COMPANY_ACHIEVES_STATUS :{BIG_FONT}{BLACK}{COMPANY} conquista o estatuto de '{STRING}'!
|
||||
STR_HIGHSCORE_PRESIDENT_OF_COMPANY_ACHIEVES_STATUS :{BIG_FONT}{WHITE}{PRESIDENT_NAME} de {COMPANY} conquista o estatuto de '{STRING}'!
|
||||
|
||||
|
@ -3117,8 +3117,8 @@ STR_INDUSTRY_CARGOES_SELECT_INDUSTRY_TOOLTIP :{BLACK}Selecion
|
|||
# Land area window
|
||||
STR_LAND_AREA_INFORMATION_CAPTION :{WHITE}Informações do Terreno
|
||||
STR_LAND_AREA_INFORMATION_LOCATION_TOOLTIP :{BLACK}Centrar visualização na localização do mosaico. Ctrl+Clique para abrir uma nova janela de visualização nesse mosaico.
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A :{BLACK}Custo para limpar: {LTBLUE}N/D
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR :{BLACK}Custo para limpar: {RED}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A :{BLACK}Custo de desobstrução: {LTBLUE}N/D
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR :{BLACK}Custo de desobstrução: {RED}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_REVENUE_WHEN_CLEARED :{BLACK}Receitas apuradas: {LTBLUE}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_OWNER_N_A :N/D
|
||||
STR_LAND_AREA_INFORMATION_OWNER :{BLACK}Proprietário: {LTBLUE}{STRING}
|
||||
|
@ -3126,7 +3126,7 @@ STR_LAND_AREA_INFORMATION_ROAD_OWNER :{BLACK}Dono da
|
|||
STR_LAND_AREA_INFORMATION_TRAM_OWNER :{BLACK}Dono da linha de eléctrico: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_RAIL_OWNER :{BLACK}Dono da linha férrea: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY :{BLACK}Autoridade local: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE :Nenhum
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE :Nenhuma
|
||||
STR_LAND_AREA_INFORMATION_LANDINFO_COORDS :{BLACK}Coordenadas: {LTBLUE}{NUM} x {NUM} x {NUM}
|
||||
STR_LAND_AREA_INFORMATION_LANDINFO_INDEX :{BLACK}Índice do mosaico: {LTBLUE}{NUM} ({HEX})
|
||||
STR_LAND_AREA_INFORMATION_BUILD_DATE :{BLACK}Construído/renovado: {LTBLUE}{DATE_LONG}
|
||||
|
@ -3685,9 +3685,9 @@ STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER :{BLACK}No inver
|
|||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL :{ORANGE}{STRING}{GREEN} fo{G 0 i i i ram ram} entregue{G 0 "" "" "" s s}
|
||||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{RED} (ainda necessário)
|
||||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{GREEN} (entregue)
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}Localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS}
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}Localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS} (financiada)
|
||||
STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}Localidade {RED}não{BLACK} está a crescer
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}A localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS}
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}A localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS} (financiada)
|
||||
STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}A localidade {RED}não{BLACK} está a crescer
|
||||
STR_TOWN_VIEW_NOISE_IN_TOWN :{BLACK}Limite de ruído na localidade: {ORANGE}{COMMA}{BLACK} máx: {ORANGE}{COMMA}
|
||||
STR_TOWN_VIEW_CENTER_TOOLTIP :{BLACK}Centrar visualização na localização da localidade. Ctrl+Clique para abrir um novo visualizador na localização da localidade
|
||||
STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON :{BLACK}Autoridade Local
|
||||
|
@ -3700,7 +3700,7 @@ STR_TOWN_VIEW_EXPAND_BUILDINGS_BUTTON :{BLACK}Expandir
|
|||
STR_TOWN_VIEW_EXPAND_BUILDINGS_TOOLTIP :{BLACK}Aumentar os edifícios da localidade
|
||||
STR_TOWN_VIEW_EXPAND_ROADS_BUTTON :{BLACK}Expandir estradas
|
||||
STR_TOWN_VIEW_EXPAND_ROADS_TOOLTIP :{BLACK}Aumentar as estradas da localidade
|
||||
STR_TOWN_VIEW_DELETE_BUTTON :{BLACK}Apagar
|
||||
STR_TOWN_VIEW_DELETE_BUTTON :{BLACK}Remover
|
||||
STR_TOWN_VIEW_DELETE_TOOLTIP :{BLACK}Remover completamente esta localidade
|
||||
|
||||
STR_TOWN_VIEW_RENAME_TOWN_BUTTON :Renomear Localidade
|
||||
|
@ -3943,7 +3943,7 @@ STR_FINANCES_INFRASTRUCTURE_BUTTON :{BLACK}Infraest
|
|||
STR_COMPANY_VIEW_CAPTION :{WHITE}{COMPANY} {BLACK}{COMPANY_NUM}
|
||||
STR_COMPANY_VIEW_PRESIDENT_MANAGER_TITLE :{WHITE}{PRESIDENT_NAME}{}{GOLD}(Presidente)
|
||||
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE :{GOLD}Inaugurado: {WHITE}{NUM}
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE :{GOLD}Inaugurada em: {WHITE}{NUM}
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE_WALLCLOCK :{GOLD}Inaugurada: {WHITE}{NUM} (período {NUM})
|
||||
STR_COMPANY_VIEW_COLOUR_SCHEME_TITLE :{GOLD}Cores:
|
||||
STR_COMPANY_VIEW_VEHICLES_TITLE :{GOLD}Veículos:
|
||||
|
|
|
@ -268,6 +268,7 @@ STR_UNITS_YEARS :{NUM}{NBSP}año
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}período{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filtrar:
|
||||
|
|
|
@ -193,6 +193,7 @@ static uint32_t GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint
|
|||
/* Get airport tile ID at offset */
|
||||
case 0x62: return GetAirportTileIDAtOffset(GetNearbyTile(parameter, this->tile), this->st, this->ro.grffile->grfid);
|
||||
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->ats->badges, parameter);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,25 @@
|
|||
/** @file newgrf_badge.cpp Functionality for NewGRF badges. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "house.h"
|
||||
#include "industry_map.h"
|
||||
#include "newgrf.h"
|
||||
#include "newgrf_airporttiles.h"
|
||||
#include "newgrf_badge.h"
|
||||
#include "newgrf_badge_type.h"
|
||||
#include "newgrf_object.h"
|
||||
#include "newgrf_roadstop.h"
|
||||
#include "newgrf_station.h"
|
||||
#include "newgrf_spritegroup.h"
|
||||
#include "rail.h"
|
||||
#include "rail_map.h"
|
||||
#include "station_map.h"
|
||||
#include "stringfilter_type.h"
|
||||
#include "strings_func.h"
|
||||
#include "tile_map.h"
|
||||
#include "timer/timer_game_calendar.h"
|
||||
#include "town_map.h"
|
||||
#include "tunnelbridge_map.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
|
@ -216,7 +228,173 @@ BadgeResolverObject::BadgeResolverObject(const Badge &badge, GrfSpecFeature feat
|
|||
}
|
||||
|
||||
/**
|
||||
* Test for a matching badge in a list of badges, returning the number of matching bits.
|
||||
* Test if a list of badges contains a badge.
|
||||
* @param badges List of badges.
|
||||
* @param badge Badge to find.
|
||||
* @returns true iff the badge appears in the list.
|
||||
*/
|
||||
static bool BadgesContains(std::span<const BadgeID> badges, BadgeID badge)
|
||||
{
|
||||
return std::ranges::find(badges, badge) != std::end(badges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a rail type has a badge.
|
||||
* @param rt Rail type to test.
|
||||
* @param badge Badge to find.
|
||||
* @returns true iff the rail type has the badge.
|
||||
*/
|
||||
static bool RailTypeHasBadge(RailType rt, BadgeID badge)
|
||||
{
|
||||
return rt != INVALID_RAILTYPE && BadgesContains(GetRailTypeInfo(rt)->badges, badge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a road type has a badge.
|
||||
* @param rt Road type to test.
|
||||
* @param badge Badge to find.
|
||||
* @returns true iff the road type has the badge.
|
||||
*/
|
||||
static bool RoadTypeHasBadge(RoadType rt, BadgeID badge)
|
||||
{
|
||||
return rt != INVALID_ROADTYPE && BadgesContains(GetRoadTypeInfo(rt)->badges, badge);
|
||||
}
|
||||
|
||||
using TileHasBadgeProc = bool(*)(TileIndex tile, BadgeID badge, GrfSpecFeatures features);
|
||||
|
||||
static bool TileHasBadge_Rail(TileIndex tile, BadgeID badge, GrfSpecFeatures features)
|
||||
{
|
||||
if (features.Test(GrfSpecFeature::GSF_RAILTYPES) && RailTypeHasBadge(GetRailType(tile), badge)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TileHasBadge_Road(TileIndex tile, BadgeID badge, GrfSpecFeatures features)
|
||||
{
|
||||
if (features.Test(GrfSpecFeature::GSF_ROADTYPES) && RoadTypeHasBadge(GetRoadTypeRoad(tile), badge)) return true;
|
||||
if (features.Test(GrfSpecFeature::GSF_TRAMTYPES) && RoadTypeHasBadge(GetRoadTypeTram(tile), badge)) return true;
|
||||
if (features.Test(GrfSpecFeature::GSF_RAILTYPES) && IsLevelCrossing(tile) && RailTypeHasBadge(GetRailType(tile), badge)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TileHasBadge_Town(TileIndex tile, BadgeID badge, GrfSpecFeatures features)
|
||||
{
|
||||
if (features.Test(GrfSpecFeature::GSF_HOUSES) && BadgesContains(HouseSpec::Get(GetHouseType(tile))->badges, badge)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TileHasBadge_Station(TileIndex tile, BadgeID badge, GrfSpecFeatures features)
|
||||
{
|
||||
switch (GetStationType(tile)) {
|
||||
case StationType::Rail:
|
||||
case StationType::RailWaypoint:
|
||||
if (features.Test(GrfSpecFeature::GSF_STATIONS)) {
|
||||
if (const StationSpec *spec = GetStationSpec(tile); spec != nullptr && BadgesContains(spec->badges, badge)) return true;
|
||||
}
|
||||
if (features.Test(GrfSpecFeature::GSF_RAILTYPES) && RailTypeHasBadge(GetRailType(tile), badge)) return true;
|
||||
return false;
|
||||
|
||||
case StationType::Bus:
|
||||
case StationType::Truck:
|
||||
case StationType::RoadWaypoint:
|
||||
if (features.Test(GrfSpecFeature::GSF_ROADSTOPS)) {
|
||||
if (const RoadStopSpec *spec = GetRoadStopSpec(tile); spec != nullptr && BadgesContains(spec->badges, badge)) return true;
|
||||
}
|
||||
if (features.Test(GrfSpecFeature::GSF_ROADTYPES) && RoadTypeHasBadge(GetRoadTypeRoad(tile), badge)) return true;
|
||||
if (features.Test(GrfSpecFeature::GSF_TRAMTYPES) && RoadTypeHasBadge(GetRoadTypeTram(tile), badge)) return true;
|
||||
return false;
|
||||
|
||||
case StationType::Airport:
|
||||
if (features.Test(GrfSpecFeature::GSF_AIRPORTTILES) && BadgesContains(AirportTileSpec::GetByTile(tile)->badges, badge)) return true;
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool TileHasBadge_Industry(TileIndex tile, BadgeID badge, GrfSpecFeatures features)
|
||||
{
|
||||
if (features.Test(GrfSpecFeature::GSF_INDUSTRYTILES) && BadgesContains(GetIndustryTileSpec(GetIndustryGfx(tile))->badges, badge)) return true;
|
||||
if (features.Test(GrfSpecFeature::GSF_INDUSTRIES) && BadgesContains(GetIndustrySpec(GetIndustryType(tile))->badges, badge)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TileHasBadge_TunnelBridge(TileIndex tile, BadgeID badge, GrfSpecFeatures features)
|
||||
{
|
||||
switch (GetTunnelBridgeTransportType(tile)) {
|
||||
case TransportType::TRANSPORT_RAIL:
|
||||
if (features.Test(GrfSpecFeature::GSF_RAILTYPES) && RailTypeHasBadge(GetRailType(tile), badge)) return true;
|
||||
return false;
|
||||
|
||||
case TransportType::TRANSPORT_ROAD:
|
||||
if (features.Test(GrfSpecFeature::GSF_ROADTYPES) && RoadTypeHasBadge(GetRoadTypeRoad(tile), badge)) return true;
|
||||
if (features.Test(GrfSpecFeature::GSF_TRAMTYPES) && RoadTypeHasBadge(GetRoadTypeTram(tile), badge)) return true;
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool TileHasBadge_Object(TileIndex tile, BadgeID badge, GrfSpecFeatures features)
|
||||
{
|
||||
if (features.Test(GrfSpecFeature::GSF_OBJECTS) && BadgesContains(ObjectSpec::GetByTile(tile)->badges, badge)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a tile has an item containing the specified badge.
|
||||
* @param tile Tile to query.
|
||||
* @param badge Badge to search for.
|
||||
* @param features GRF features to include in the test.
|
||||
* @returns true iff the badge 'is on' the tile.
|
||||
*/
|
||||
static bool TileHasBadge(TileIndex tile, BadgeID badge, GrfSpecFeatures features)
|
||||
{
|
||||
/* Per-tiletype functions for badge testing. Like _tile_type_procs, this is 16 entries as GetTileType() reads 4 bits. */
|
||||
static constexpr std::array<TileHasBadgeProc, 16> tile_procs = {
|
||||
nullptr,
|
||||
TileHasBadge_Rail,
|
||||
TileHasBadge_Road,
|
||||
TileHasBadge_Town,
|
||||
nullptr,
|
||||
TileHasBadge_Station,
|
||||
nullptr,
|
||||
nullptr,
|
||||
TileHasBadge_Industry,
|
||||
TileHasBadge_TunnelBridge,
|
||||
TileHasBadge_Object,
|
||||
};
|
||||
|
||||
TileHasBadgeProc proc = tile_procs[GetTileType(tile)];
|
||||
return proc != nullptr && proc(tile, badge, features);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for a matching badge 'on' a specific map tile.
|
||||
* @param grffile GRF file of the current varaction.
|
||||
* @param tile Tile to test.
|
||||
* @param parameter GRF-local badge index.
|
||||
* @param features GRF features to include in the test.
|
||||
* @returns true iff the badge is present.
|
||||
*/
|
||||
uint32_t GetNearbyBadgeVariableResult(const GRFFile &grffile, TileIndex tile, const ResolverObject &object)
|
||||
{
|
||||
GrfSpecFeatures features = static_cast<GrfSpecFeatures>(object.GetRegister(0x101));
|
||||
if (features.None()) return 0;
|
||||
|
||||
uint32_t parameter = object.GetRegister(0x100);
|
||||
if (parameter >= std::size(grffile.badge_list)) return UINT_MAX;
|
||||
|
||||
/* NewGRF cannot be expected to know the bounds of the map. If the tile is invalid it doesn't have the queried badge. */
|
||||
if (!IsValidTile(tile)) return 0;
|
||||
|
||||
BadgeID index = grffile.badge_list[parameter];
|
||||
return TileHasBadge(tile, index, features);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for a matching badge in a list of badges.
|
||||
* @param grffile GRF file of the current varaction.
|
||||
* @param badges List of badges to test.
|
||||
* @param parameter GRF-local badge index.
|
||||
|
@ -227,7 +405,7 @@ uint32_t GetBadgeVariableResult(const GRFFile &grffile, std::span<const BadgeID>
|
|||
if (parameter >= std::size(grffile.badge_list)) return UINT_MAX;
|
||||
|
||||
BadgeID index = grffile.badge_list[parameter];
|
||||
return std::ranges::find(badges, index) != std::end(badges);
|
||||
return BadgesContains(badges, index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,6 +64,7 @@ Badge *GetBadgeByLabel(std::string_view label);
|
|||
Badge *GetClassBadge(BadgeClassID class_index);
|
||||
std::span<const BadgeID> GetClassBadges();
|
||||
|
||||
uint32_t GetNearbyBadgeVariableResult(const GRFFile &grffile, TileIndex tile, const ResolverObject &object);
|
||||
uint32_t GetBadgeVariableResult(const struct GRFFile &grffile, std::span<const BadgeID> badges, uint32_t parameter);
|
||||
|
||||
PalSpriteID GetBadgeSprite(const Badge &badge, GrfSpecFeature feature, std::optional<TimerGameCalendar::Date> introduction_date, PaletteID remap);
|
||||
|
|
|
@ -444,6 +444,7 @@ static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex start_ti
|
|||
return _house_mngr.GetGRFID(house_id);
|
||||
}
|
||||
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, HouseSpec::Get(this->house_id)->badges, parameter);
|
||||
}
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(const ResolverObject &objec
|
|||
/* Variables available during construction check. */
|
||||
|
||||
switch (variable) {
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, GetIndustrySpec(this->type)->badges, parameter);
|
||||
|
||||
case 0x80: return this->tile.base();
|
||||
|
@ -354,6 +355,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(const ResolverObject &objec
|
|||
NOT_REACHED();
|
||||
}
|
||||
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, GetIndustrySpec(this->type)->badges, parameter);
|
||||
|
||||
/* Get a variable from the persistent storage */
|
||||
|
|
|
@ -93,6 +93,7 @@ uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile)
|
|||
/* Get industry tile ID at offset */
|
||||
case 0x62: return GetIndustryIDAtOffset(GetNearbyTile(parameter, this->tile), this->industry, this->ro.grffile->grfid);
|
||||
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, GetIndustryTileSpec(GetIndustryGfx(this->tile))->badges, parameter);
|
||||
}
|
||||
|
||||
|
|
|
@ -291,6 +291,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(const ResolverObject &objec
|
|||
/* Object view */
|
||||
case 0x48: return this->view;
|
||||
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->spec->badges, parameter);
|
||||
|
||||
/*
|
||||
|
@ -364,6 +365,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(const ResolverObject &objec
|
|||
/* Count of object, distance of closest instance */
|
||||
case 0x64: return GetCountAndDistanceOfClosestInstance(this->ro, parameter, this->ro.grffile->grfid, this->tile, this->obj);
|
||||
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->spec->badges, parameter);
|
||||
}
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@ uint32_t RoadStopScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] u
|
|||
return 0xFFFE;
|
||||
}
|
||||
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->roadstopspec->badges, parameter);
|
||||
|
||||
case 0xF0: return this->st == nullptr ? 0 : this->st->facilities.base(); // facilities
|
||||
|
|
|
@ -295,6 +295,12 @@ TownScopeResolver *StationResolverObject::GetTown()
|
|||
}
|
||||
break;
|
||||
|
||||
case 0x79:
|
||||
if (this->axis != INVALID_AXIS && this->tile != INVALID_TILE) {
|
||||
return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile, true, this->axis), this->ro);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->statspec->badges, parameter);
|
||||
|
||||
case 0xFA: return ClampTo<uint16_t>(TimerGameCalendar::date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value
|
||||
|
@ -398,6 +404,7 @@ TownScopeResolver *StationResolverObject::GetTown()
|
|||
return 0xFFFE;
|
||||
}
|
||||
|
||||
case 0x79: return GetNearbyBadgeVariableResult(*this->ro.grffile, GetNearbyTile(parameter, this->tile), this->ro);
|
||||
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->statspec->badges, parameter);
|
||||
|
||||
/* General station variables */
|
||||
|
|
Loading…
Reference in New Issue