NewGRF: Add extended house variables to get uncapped building counts

This commit is contained in:
Jonathan G Rennison 2024-08-04 15:04:29 +01:00
parent 3f5e10ab38
commit 318b86083b
6 changed files with 47 additions and 0 deletions

View File

@ -38,6 +38,7 @@
<li><a href="#builtin-functions">Builtin functions</a></li>
<li><a href="#switch-types">Additional switch types</a></li>
<li><a href="#ship-callbacks">Ship callbacks</a></li>
<li><a href="#house-variables">House variables</a></li>
<li><a href="#railtype-properties">Railtype properties</a></li>
<li><a href="#railtype-variables">Railtype variables</a></li>
<li><a href="#roadtype-properties">Roadtype properties</a></li>
@ -95,6 +96,14 @@
<span class="code">getbits(extra_callback_info1, 0, 8)</span> contains the index of the part of the ship. The first/primary part is 0, each subsequent part increases the value by 1.
</p>
<h3 id="house-variables"><a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Houses#House_variables">House variables</a></h3>
<p>Variables in the table below which are not supported by the version of OpenTTD being used return a value of 0.</p>
<table>
<tr><th>Name</th><th>Value range</th><th>Comment</th></tr>
<tr><td>same_house_count_town_uncapped</td><td>0..4294967295</td><td>Number of the houses with the same ID in the same town as this house (not clamped to 0xFF)</td></tr>
<tr><td>same_house_count_map_uncapped</td><td>0..4294967295</td><td>Number of the houses with the same ID on the entire map (not clamped to 0xFF)</td></tr>
</table>
<h3 id="railtype-properties"><a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Railtypes#Railtype_properties">Railtype properties</a></h3>
<table>
<tr><th>Property</th><th>Value range</th><th>Comment</th></tr>

View File

@ -50,6 +50,7 @@
<li><a href="#varaction2_additional_types">Variational Action 2 - Additional Types</a></li>
<li><a href="#varaction2_vehicles">Variational Action 2 - Vehicles</a></li>
<li><a href="#varaction2_station">Variational Action 2 - Stations</a></li>
<li><a href="#varaction2_house">Variational Action 2 - Houses</a></li>
<li><a href="#varaction2_railtypes">Variational Action 2 - Railtypes</a></li>
<li><a href="#varaction2_object">Variational Action 2 - Objects</a></li>
<li><a href="#varaction2_airporttiles">Variational Action 2 - Airport tiles</a></li>
@ -826,6 +827,24 @@
This requires <font face="monospace">varaction2_station_station_nearby_info_v2</font>, version 1.
</p>
<br />
<h3 id="varaction2_house"><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Houses">Variational Action 2 - Houses</a></h3>
<h4 id="house_same_id_town_count">Building count: same ID, current town (mappable variable: house_same_id_town_count)</h4>
<p>This is the same as bits 0 - 7 of <a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Houses#Building_counts_.2844.29">44/Building counts</a>, except not clamped to a maximum of 0xFF.<br />
This requires <font face="monospace">varaction2_house_uncapped_building_counts</font>, version 1.
</p>
<h4 id="house_same_class_town_count">Building count: same class, current town (mappable variable: house_same_class_town_count)</h4>
<p>This is the same as bits 16 - 23 of <a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Houses#Building_counts_.2844.29">44/Building counts</a>, except not clamped to a maximum of 0xFF.<br />
This requires <font face="monospace">varaction2_house_uncapped_building_counts</font>, version 1.
</p>
<h4 id="house_same_id_map_count">Building count: same ID, whole map (mappable variable: house_same_id_map_count)</h4>
<p>This is the same as bits 8 - 15 of <a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Houses#Building_counts_.2844.29">44/Building counts</a>, except not clamped to a maximum of 0xFF.<br />
This requires <font face="monospace">varaction2_house_uncapped_building_counts</font>, version 1.
</p>
<h4 id="house_same_class_map_count">Building count: same class, total (mappable variable: house_same_class_map_count)</h4>
<p>This is the same as bits 24 - 31 of <a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Houses#Building_counts_.2844.29">44/Building counts</a>, except not clamped to a maximum of 0xFF.<br />
This requires <font face="monospace">varaction2_house_uncapped_building_counts</font>, version 1.
</p>
<br />
<h3 id="varaction2_railtypes"><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Railtypes">Variational Action 2 - Railtypes</a></h3>
<h4 id="railtype_signal_restriction_info">Signal routing restriction information (mappable variable: railtype_signal_restriction_info)</h4>
<p>This applies to <a href="https://newgrf-specs.tt-wiki.net/wiki/Action3/Railtypes#Signal_sprites_.280B.29">Action 2/3 - Railtype custom signal sprites</a>.<br />

View File

@ -74,6 +74,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
GRFFeatureInfo("more_varaction2_types", 1, GFTOF_MORE_VARACTION2_TYPES),
GRFFeatureInfo("multi_part_ships", 3, GFTOF_MULTI_PART_SHIPS),
GRFFeatureInfo("more_stations_per_grf", 1),
GRFFeatureInfo("varaction2_house_uncapped_building_counts", 1),
GRFFeatureInfo(),
};
@ -157,6 +158,10 @@ extern const GRFVariableMapDefinition _grf_action2_remappable_variables[] = {
GRFVariableMapDefinition(GSF_STATIONS, A2VRI_STATION_INFO_NEARBY_TILES_V2, "station_station_info_nearby_tiles_v2"),
GRFVariableMapDefinition(GSF_OBJECTS, A2VRI_OBJECT_FOUNDATION_SLOPE, "object_foundation_tile_slope"),
GRFVariableMapDefinition(GSF_OBJECTS, A2VRI_OBJECT_FOUNDATION_SLOPE_CHANGE, "object_foundation_change_tile_slope"),
GRFVariableMapDefinition(GSF_HOUSES, A2VRI_HOUSE_SAME_ID_MAP_COUNT, "house_same_id_map_count"),
GRFVariableMapDefinition(GSF_HOUSES, A2VRI_HOUSE_SAME_CLASS_MAP_COUNT, "house_same_class_map_count"),
GRFVariableMapDefinition(GSF_HOUSES, A2VRI_HOUSE_SAME_ID_TOWN_COUNT, "house_same_id_town_count"),
GRFVariableMapDefinition(GSF_HOUSES, A2VRI_HOUSE_SAME_CLASS_TOWN_COUNT, "house_same_class_town_count"),
GRFVariableMapDefinition(GSF_ROADSTOPS, 0x40, "roadstop_view"),
GRFVariableMapDefinition(GSF_ROADSTOPS, 0x41, "roadstop_type"),
GRFVariableMapDefinition(GSF_ROADSTOPS, 0x42, "roadstop_terrain_type"),

View File

@ -81,6 +81,10 @@ enum Action2VariableRemapIds {
A2VRI_OBJECT_FOUNDATION_SLOPE,
A2VRI_OBJECT_FOUNDATION_SLOPE_CHANGE,
A2VRI_VEHICLE_CURRENT_SPEED_SCALED,
A2VRI_HOUSE_SAME_ID_MAP_COUNT,
A2VRI_HOUSE_SAME_CLASS_MAP_COUNT,
A2VRI_HOUSE_SAME_ID_TOWN_COUNT,
A2VRI_HOUSE_SAME_CLASS_TOWN_COUNT,
A2VRI_ROADSTOP_INFO_NEARBY_TILES_EXT,
A2VRI_ROADSTOP_INFO_NEARBY_TILES_V2,
A2VRI_ROADSTOP_ROAD_INFO_NEARBY_TILES,

View File

@ -23,6 +23,7 @@
#include "newgrf_cargo.h"
#include "station_base.h"
#include "newgrf_analysis.h"
#include "newgrf_extension.h"
#include "safeguards.h"
@ -411,6 +412,11 @@ static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex tile, Ho
/* Number of this type of building on the map. */
case 0x44: return GetNumHouses(this->house_id, this->town);
case A2VRI_HOUSE_SAME_ID_MAP_COUNT: return _building_counts.id_count[this->house_id];
case A2VRI_HOUSE_SAME_CLASS_MAP_COUNT: return _building_counts.class_count[HouseSpec::Get(this->house_id)->class_id];
case A2VRI_HOUSE_SAME_ID_TOWN_COUNT: return this->town->cache.building_counts.id_count[this->house_id];
case A2VRI_HOUSE_SAME_CLASS_TOWN_COUNT: return this->town->cache.building_counts.class_count[HouseSpec::Get(this->house_id)->class_id];
/* Whether the town is being created or just expanded. */
case 0x45: return _generating_world ? 1 : 0;

View File

@ -937,6 +937,10 @@ static const NIVariable _niv_house[] = {
NIV(0x65, "distance of nearest house matching a given criterion"),
NIV(0x66, "class and ID of nearby house tile"),
NIV(0x67, "GRFID of nearby house tile"),
NIV(A2VRI_HOUSE_SAME_ID_MAP_COUNT, "building count: same ID, map"),
NIV(A2VRI_HOUSE_SAME_CLASS_MAP_COUNT, "building count: same class, map"),
NIV(A2VRI_HOUSE_SAME_ID_TOWN_COUNT, "building count: same ID, town"),
NIV(A2VRI_HOUSE_SAME_CLASS_TOWN_COUNT, "building count: same class, town"),
NIV_END()
};