Add NewGRF global flag to allow rocky tiles in tropic desert zones

pull/461/head
Jonathan G Rennison 1 year ago
parent b1051fa131
commit 41fb98db09

@ -323,6 +323,11 @@ item (FEAT_GLOBALVARS) {
Some station names are always used first even when this is non-zero.
</td>
</tr>
<tr><td>allow_rocks_in_desert</td><td>0 or 1</td>
<td>
Sets whether rocky tiles are allowed to generate in and remain in desert zones (tropical climate).
</td>
</tr>
</table>
<p>Syntax example:
<pre class="code">

@ -361,6 +361,11 @@
The Action 0 ID field is ignored. The property length is 1 byte.
</p>
<p>This is indicated by the feature name: <font face="monospace">action0_global_default_object_generate_amount</font>, version 1</p>
<h4 id="global_allow_rocks_in_desert">Allow rocky tiles in desert zones (tropical climate) (mappable property: global_allow_rocks_in_desert)</h4>
<p>This sets whether rocky tiles are allowed to generate in and remain in desert zones (tropical climate).<br />
The Action 0 ID field is ignored. The property length is 1 byte. 0 is disabled (default). 1 is enabled.
</p>
<p>This is indicated by the feature name: <font face="monospace">action0_global_allow_rocks_in_desert</font>, version 1</p>
<br />
<h3 id="a0signals"><a href="https://newgrf-specs.tt-wiki.net/wiki/Action0">Action 0 - Signals (Feature 0E)</a></h3>
<p>Note that Action 0 feature 0E is not supported (does nothing) in standard OpenTTD.</p>

@ -24,6 +24,8 @@
#include "safeguards.h"
bool _allow_rocks_desert = false;
static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
{
static const Price clear_price_table[] = {
@ -298,6 +300,8 @@ static void TileLoopClearDesert(TileIndex tile)
if (current == expected) return;
if (_allow_rocks_desert && IsClearGround(tile, CLEAR_ROCKS)) return;
if (expected == 0) {
SetClearGroundDensity(tile, CLEAR_GRASS, 3);
} else {
@ -404,7 +408,7 @@ void GenerateClearTile()
do {
if (--j == 0) goto get_out;
tile_new = tile + TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
} while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT));
} while (!IsTileType(tile_new, MP_CLEAR) || (!_allow_rocks_desert && IsClearGround(tile_new, CLEAR_DESERT)));
tile = tile_new;
}
get_out:;

@ -167,6 +167,9 @@ void InitGRFGlobalVars()
extern uint8 _extra_station_names_probability;
_extra_station_names_probability = 0;
extern bool _allow_rocks_desert;
_allow_rocks_desert = false;
}
/** Actually load the sprite tables. */

@ -2850,6 +2850,13 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co
break;
}
case A0RPI_GLOBALVAR_ALLOW_ROCKS_DESERT: {
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
extern bool _allow_rocks_desert;
_allow_rocks_desert = (buf->ReadByte() != 0);
break;
}
default:
ret = HandleAction0PropertyDefault(buf, prop);
break;
@ -2922,6 +2929,7 @@ static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, c
case A0RPI_GLOBALVAR_EXTRA_STATION_NAMES_PROBABILITY:
case A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT:
case A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT:
case A0RPI_GLOBALVAR_ALLOW_ROCKS_DESERT:
buf->Skip(buf->ReadExtendedByte());
break;

@ -42,6 +42,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
GRFFeatureInfo("varaction2_railtype_signal_context", 1),
GRFFeatureInfo("action0_global_extra_station_names", 2),
GRFFeatureInfo("action0_global_default_object_generate_amount", 1),
GRFFeatureInfo("action0_global_allow_rocks_in_desert", 1),
GRFFeatureInfo("action0_signals_programmable_signals", 1),
GRFFeatureInfo("action0_signals_no_entry_signals", 1),
GRFFeatureInfo("action0_signals_restricted_signals", 2),
@ -86,6 +87,7 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_EXTRA_STATION_NAMES_PROBABILITY, "global_extra_station_names_probability"),
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT, "global_lighthouse_generate_amount"),
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT, "global_transmitter_generate_amount"),
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_ALLOW_ROCKS_DESERT, "global_allow_rocks_in_desert"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_ENABLE_PROGRAMMABLE_SIGNALS, "signals_enable_programmable_signals"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_ENABLE_NO_ENTRY_SIGNALS, "signals_enable_no_entry_signals"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_ENABLE_RESTRICTED_SIGNALS, "signals_enable_restricted_signals"),

@ -30,6 +30,7 @@ enum Action0RemapPropertyIds {
A0RPI_GLOBALVAR_EXTRA_STATION_NAMES_PROBABILITY,
A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT,
A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT,
A0RPI_GLOBALVAR_ALLOW_ROCKS_DESERT,
A0RPI_SIGNALS_ENABLE_PROGRAMMABLE_SIGNALS,
A0RPI_SIGNALS_ENABLE_NO_ENTRY_SIGNALS,
A0RPI_SIGNALS_ENABLE_RESTRICTED_SIGNALS,

Loading…
Cancel
Save