Add new landscape flag to enable drawing rocks covered by snow

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

@ -64,6 +64,12 @@
</table>
</td>
</tr>
<tr><td>enable_draw_snowy_rocks</td><td>0 or 1</td>
<td>
Enable drawing of rock tiles covered by snow, for this GRF.<br />
(This only takes effect from <font face="monospace">new_landscape</font> version 2).
</td>
</tr>
</table>
<h3 id="newlandscape_variables">New Landscape Variables</h3>

@ -48,6 +48,7 @@
<table>
<tr><th>Mappable name</th><th>Size in bytes</th><th>Description</th></tr>
<tr><td><a href="#newlandscape_enable_recolour">newlandscape_enable_recolour</a></td><td>1</td><td>Enable recolour</td></tr>
<tr><td><a href="#newlandscape_enable_draw_snowy_rocks">newlandscape_enable_draw_snowy_rocks</a></td><td>1</td><td>Enable drawing rocky tiles covered by snow</td></tr>
</table>
<h4 id="newlandscape_enable_recolour">Enable recolouring for new landscape graphics (mappable property: newlandscape_enable_recolour)</h4>
@ -59,6 +60,11 @@
</table></p>
<p>The property length is 1 byte. 0 is disabled (default). 1 is enabled.</p>
<h4 id="newlandscape_enable_draw_snowy_rocks">Enable drawing rocky tiles covered by snow (mappable property: newlandscape_enable_draw_snowy_rocks)</h4>
<p>When enabled, drawing of rocky tiles covered by snow is enabled for this GRF.</p>
<p>The property length is 1 byte. 0 is disabled (default). 1 is enabled.<br />
This requires <font face="monospace">new_landscape</font>, version 2.</p>
<h3 id="a2roadstops">Action 2 - New Landscape</h3>
<p>See the <a href="https://newgrf-specs.tt-wiki.net/wiki/Action2">Action 2 Specification</a> for background information.</p>

@ -81,22 +81,22 @@ inline SpriteID GetSpriteIDForRocksUsingOffset(const uint slope_to_sprite_offset
return ((HasGrfMiscBit(GMB_SECOND_ROCKY_TILE_SET) && (TileHash(x, y) & 1)) ? SPR_FLAT_ROCKY_LAND_2 : SPR_FLAT_ROCKY_LAND_1) + slope_to_sprite_offset;
}
void DrawCustomSpriteIDForRocks(const TileInfo *ti)
bool DrawCustomSpriteIDForRocks(const TileInfo *ti, uint8 slope_to_sprite_offset, bool require_snow_flag)
{
uint8 slope_to_sprite_offset = SlopeToSpriteOffset(ti->tileh);
for (const GRFFile *grf : _new_landscape_rocks_grfs) {
if (require_snow_flag && !HasBit(grf->new_landscape_ctrl_flags, NLCF_ROCKS_DRAW_SNOWY_ENABLED)) continue;
NewLandscapeResolverObject object(grf, ti, NEW_LANDSCAPE_ROCKS);
const SpriteGroup *group = object.Resolve();
if (group != nullptr && group->GetNumResults() > slope_to_sprite_offset) {
PaletteID pal = HasBit(grf->new_landscape_ctrl_flags, NLCF_ROCKS_RECOLOUR_ENABLED) ? GB(GetRegister(0x100), 0, 24) : PAL_NONE;
DrawGroundSprite(group->GetResult() + slope_to_sprite_offset, pal);
return;
return true;
}
}
DrawGroundSprite(GetSpriteIDForRocksUsingOffset(slope_to_sprite_offset, ti->x, ti->y), PAL_NONE);
return false;
}
SpriteID GetSpriteIDForFields(const Slope slope, const uint field_type)
@ -104,6 +104,11 @@ SpriteID GetSpriteIDForFields(const Slope slope, const uint field_type)
return _clear_land_sprites_farmland[field_type] + SlopeToSpriteOffset(slope);
}
inline SpriteID GetSpriteIDForSnowDesertUsingOffset(const uint slope_to_sprite_offset, const uint density)
{
return _clear_land_sprites_snow_desert[density] + slope_to_sprite_offset;
}
SpriteID GetSpriteIDForSnowDesert(const Slope slope, const uint density)
{
return _clear_land_sprites_snow_desert[density] + SlopeToSpriteOffset(slope);
@ -162,7 +167,9 @@ static void DrawTile_Clear(TileInfo *ti, DrawTileProcParams params)
case CLEAR_ROCKS:
if (!params.no_ground_tiles) {
DrawCustomSpriteIDForRocks(ti);
uint8 slope_to_sprite_offset = SlopeToSpriteOffset(ti->tileh);
if (DrawCustomSpriteIDForRocks(ti, slope_to_sprite_offset, false)) break;
DrawGroundSprite(GetSpriteIDForRocksUsingOffset(slope_to_sprite_offset, ti->x, ti->y), PAL_NONE);
}
break;
@ -174,6 +181,15 @@ static void DrawTile_Clear(TileInfo *ti, DrawTileProcParams params)
break;
case CLEAR_SNOW:
if (!params.no_ground_tiles) {
uint8 slope_to_sprite_offset = SlopeToSpriteOffset(ti->tileh);
if (GetRawClearGround(ti->tile) == CLEAR_ROCKS && !_new_landscape_rocks_grfs.empty()) {
if (DrawCustomSpriteIDForRocks(ti, slope_to_sprite_offset, true)) break;
}
DrawGroundSprite(GetSpriteIDForSnowDesertUsingOffset(slope_to_sprite_offset, GetClearDensity(ti->tile)), PAL_NONE);
}
break;
case CLEAR_DESERT:
if (!params.no_ground_tiles) DrawGroundSprite(GetSpriteIDForSnowDesert(ti->tileh, GetClearDensity(ti->tile)), PAL_NONE);
break;

@ -5183,6 +5183,15 @@ static ChangeInfoResult NewLandscapeChangeInfo(uint id, int numinfo, int prop, c
break;
}
case A0RPI_NEWLANDSCAPE_ENABLE_DRAW_SNOWY_ROCKS: {
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
bool enabled = (buf->ReadByte() != 0 ? 1 : 0);
if (id == NLA3ID_CUSTOM_ROCKS) {
SB(_cur.grffile->new_landscape_ctrl_flags, NLCF_ROCKS_DRAW_SNOWY_ENABLED, 1, enabled);
}
break;
}
default:
ret = HandleAction0PropertyDefault(buf, prop);
break;

@ -286,8 +286,9 @@ enum NewSignalAction3ID {
/** New landscape control flags. */
enum NewLandscapeCtrlFlags {
NLCF_ROCKS_SET = 0, ///< Custom landscape rocks sprites group set.
NLCF_ROCKS_RECOLOUR_ENABLED = 1, ///< Recolour sprites enabled for rocks
NLCF_ROCKS_SET = 0, ///< Custom landscape rocks sprites group set.
NLCF_ROCKS_RECOLOUR_ENABLED = 1, ///< Recolour sprites enabled for rocks
NLCF_ROCKS_DRAW_SNOWY_ENABLED = 2, ///< Enable drawing rock tiles on snow
};
/** New landscape action 3 IDs. */

@ -1172,7 +1172,7 @@ GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
switch (GetTileType(tile)) {
default: return GSF_INVALID;
case MP_CLEAR:
if (IsClearGround(tile, CLEAR_ROCKS)) return GSF_NEWLANDSCAPE;
if (GetRawClearGround(tile) == CLEAR_ROCKS) return GSF_NEWLANDSCAPE;
return GSF_INVALID;
case MP_RAILWAY: {
extern std::vector<const GRFFile *> _new_signals_grfs;

@ -56,7 +56,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
GRFFeatureInfo("action0_object_flood_resistant", 1),
GRFFeatureInfo("action0_object_viewport_map_tile_type", 1),
GRFFeatureInfo("road_stops", 4),
GRFFeatureInfo("new_landscape", 1),
GRFFeatureInfo("new_landscape", 2),
GRFFeatureInfo(),
};
@ -125,6 +125,7 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_DISALLOWED_BRIDGE_PILLARS, "roadstop_disallowed_bridge_pillars"),
GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_COST_MULTIPLIERS, "roadstop_cost_multipliers"),
GRFPropertyMapDefinition(GSF_NEWLANDSCAPE, A0RPI_NEWLANDSCAPE_ENABLE_RECOLOUR, "newlandscape_enable_recolour"),
GRFPropertyMapDefinition(GSF_NEWLANDSCAPE, A0RPI_NEWLANDSCAPE_ENABLE_DRAW_SNOWY_ROCKS, "newlandscape_enable_draw_snowy_rocks"),
GRFPropertyMapDefinition(),
};

@ -68,6 +68,7 @@ enum Action0RemapPropertyIds {
A0RPI_ROADSTOP_DISALLOWED_BRIDGE_PILLARS,
A0RPI_ROADSTOP_COST_MULTIPLIERS,
A0RPI_NEWLANDSCAPE_ENABLE_RECOLOUR,
A0RPI_NEWLANDSCAPE_ENABLE_DRAW_SNOWY_ROCKS,
};

Loading…
Cancel
Save