Road stops: Add flag to read draw mode from register 0x100

pull/507/head
Jonathan G Rennison 1 year ago
parent 177a00ac12
commit 62053779b5

@ -93,6 +93,8 @@
<span class="indent">Only show in the tram build menu (not road). (This only takes effect from <span class="code">road_stops</span> version 4).</span></p>
<p><b>RST_GENERAL_FLAG_BUILD_MENU_DRAW_DISABLED_VIEWS</b><br />
<span class="indent">Use custom graphics for disabled road stop views. (This only takes effect from <span class="code">road_stops</span> version 8).</span></p>
<p><b>RST_GENERAL_FLAG_DRAW_MODE_REGISTER</b><br />
<span class="indent">Read the road stop draw mode from variable 0x100 (set using STORE_TEMP), this overrides the <span class="code">draw_mode</span> property. (This only takes effect from <span class="code">road_stops</span> version 9).</span></p>
</td></tr>
<tr><td>minimum_bridge_height</td><td>Array of 6 items [0..255, ...]</td><td>Minimum clearances required for a bridge for each of the <a href="#roadstop_views">6 views/rotations</a> (or 0 to not allow any bridge). Values are given in height level units (1 level == 8px).</td></tr>
<tr><td>disallowed_bridge_pillars</td><td>Array of 6 items [bitmask(RST_BRIDGE_PILLAR_FLAG_, ...), ...]</td><td>

@ -159,6 +159,7 @@
<tr><td>5</td><td>20</td><td>Only show in the road build menu (not tram).</br>This requires <font face="monospace">road_stops</font>, version 4.</td></tr>
<tr><td>6</td><td>40</td><td>Only show in the tram build menu (not road).</br>This requires <font face="monospace">road_stops</font>, version 4.</td></tr>
<tr><td>7</td><td>80</td><td>Use custom graphics for disabled road stop views.</br>This requires <font face="monospace">road_stops</font>, version 8.</td></tr>
<tr><td>8</td><td>100</td><td>Read the road stop draw mode from variable 0x100, this overrides the <a href="#roadstop_draw_mode">roadstop_draw_mode</a> property.</br>This requires <font face="monospace">road_stops</font>, version 9.</td></tr>
</table>
The default value is 0 (no flags enabled).
</p>

@ -5183,7 +5183,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, const
if (MappedPropertyLengthMismatch(buf, 4, mapping_entry)) break;
FALLTHROUGH;
case 0x12: // General flags
rs->flags = (uint8)buf->ReadDWord(); // Future-proofing, size this as 4 bytes, but we only need one byte's worth of flags at present
rs->flags = (uint16)buf->ReadDWord(); // Future-proofing, size this as 4 bytes, but we only need two bytes' worth of flags at present
break;
case A0RPI_ROADSTOP_MIN_BRIDGE_HEIGHT:

@ -330,9 +330,16 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
SpriteID image = dts->ground.sprite;
PaletteID pal = dts->ground.pal;
RoadStopDrawMode draw_mode;
if (HasBit(spec->flags, RSF_DRAW_MODE_REGISTER)) {
draw_mode = (RoadStopDrawMode)GetRegister(0x100);
} else {
draw_mode = spec->draw_mode;
}
if (type == STATION_ROADWAYPOINT) {
DrawSprite(SPR_ROAD_PAVED_STRAIGHT_X, PAL_NONE, x, y);
if ((spec->draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND) && GB(image, 0, SPRITE_WIDTH) != 0) {
if ((draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND) && GB(image, 0, SPRITE_WIDTH) != 0) {
DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y);
}
} else if (GB(image, 0, SPRITE_WIDTH) != 0) {
@ -344,7 +351,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
uint sprite_offset = 5 - view;
/* Road underlay takes precedence over tram */
if (type == STATION_ROADWAYPOINT || spec->draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) {
if (type == STATION_ROADWAYPOINT || draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) {
if (rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND);
DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
@ -357,7 +364,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
}
} else {
/* Drive-in stop */
if ((spec->draw_mode & ROADSTOP_DRAW_MODE_ROAD) && rti->UsesOverlay()) {
if ((draw_mode & ROADSTOP_DRAW_MODE_ROAD) && rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_ROADSTOP);
DrawSprite(ground + view, PAL_NONE, x, y);
}

@ -72,6 +72,7 @@ enum RoadStopSpecFlags {
RSF_BUILD_MENU_ROAD_ONLY, ///< Only show in the road build menu (not tram).
RSF_BUILD_MENU_TRAM_ONLY, ///< Only show in the tram build menu (not road).
RSF_BUILD_MENU_DRAW_DISABLED_VIEWS, ///< Use custom road stop graphics for disabled views
RSF_DRAW_MODE_REGISTER, ///< Use custom road stop graphics for disabled views
};
enum RoadStopSpecIntlFlags {
@ -145,7 +146,7 @@ struct RoadStopSpec {
RoadStopAvailabilityType stop_type = ROADSTOPTYPE_ALL;
RoadStopDrawMode draw_mode = ROADSTOP_DRAW_MODE_ROAD | ROADSTOP_DRAW_MODE_OVERLAY;
uint8 callback_mask = 0;
uint8 flags = 0;
uint16 flags = 0;
uint8 internal_flags = 0; ///< Bitmask of internal spec flags (RoadStopSpecIntlFlags)
CargoTypes cargo_triggers = 0; ///< Bitmask of cargo types which cause trigger re-randomizing

@ -3551,7 +3551,9 @@ draw_default_foundation:
StationType type = GetStationType(ti->tile);
const RoadStopSpec *stopspec = GetRoadStopSpec(ti->tile);
RoadStopDrawMode stop_draw_mode = (RoadStopDrawMode)0;
if (stopspec != nullptr) {
stop_draw_mode = stopspec->draw_mode;
int view = dir;
if (IsDriveThroughStopTile(ti->tile)) view += 4;
st = BaseStation::GetByTile(ti->tile);
@ -3559,6 +3561,9 @@ draw_default_foundation:
const SpriteGroup *group = object.Resolve();
if (group != nullptr && group->type == SGT_TILELAYOUT) {
const DrawTileSprites *dts = ((const TileLayoutSpriteGroup *)group)->ProcessRegisters(nullptr);
if (HasBit(stopspec->flags, RSF_DRAW_MODE_REGISTER)) {
stop_draw_mode = (RoadStopDrawMode)GetRegister(0x100);
}
t = dts;
if (type == STATION_ROADWAYPOINT && (stopspec->draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND)) {
draw_ground = true;
@ -3576,7 +3581,7 @@ draw_default_foundation:
}
if (IsDriveThroughStopTile(ti->tile)) {
if (type != STATION_ROADWAYPOINT && (stopspec == nullptr || (stopspec->draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) != 0)) {
if (type != STATION_ROADWAYPOINT && (stopspec == nullptr || (stop_draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) != 0)) {
uint sprite_offset = axis == AXIS_X ? 1 : 0;
DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
}
@ -3589,7 +3594,7 @@ draw_default_foundation:
/* Non-drivethrough road stops are only valid for roads. */
assert_tile(road_rt != INVALID_ROADTYPE && tram_rt == INVALID_ROADTYPE, ti->tile);
if ((stopspec == nullptr || (stopspec->draw_mode & ROADSTOP_DRAW_MODE_ROAD) != 0) && road_rti->UsesOverlay()) {
if ((stopspec == nullptr || (stop_draw_mode & ROADSTOP_DRAW_MODE_ROAD) != 0) && road_rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_ROADSTOP);
DrawGroundSprite(ground + dir, PAL_NONE);
}

Loading…
Cancel
Save