Update virtual floor to better indicate blocked areas (#7837)

This commit is contained in:
ζeh Matt 2018-08-07 15:39:52 +02:00 committed by Aaron van Geffen
parent f3f4776afd
commit e87e9f1b2e
2 changed files with 44 additions and 22 deletions

View File

@ -3,6 +3,7 @@
- Feature: [#5993] Ride window prices can now be set via text input. - Feature: [#5993] Ride window prices can now be set via text input.
- Feature: [#6998] Guests now wait for passing vehicles before crossing railway tracks. - Feature: [#6998] Guests now wait for passing vehicles before crossing railway tracks.
- Feature: [#7694] Debug option to visualize paths that the game detects as wide. - Feature: [#7694] Debug option to visualize paths that the game detects as wide.
- Feature: [#7713] The virtual floor now takes land ownership rights into account.
- Feature: [#7771] Danish translation. - Feature: [#7771] Danish translation.
- Feature: [#7797, #7802, #7821, #7830] Add sprite font glyphs for Danish, Norwegian, Russian, Turkish, Catalan and Romanian. - Feature: [#7797, #7802, #7821, #7830] Add sprite font glyphs for Danish, Norwegian, Russian, Turkish, Catalan and Romanian.
- Fix: [#3177] Wrong keys displayed in shortcut menu. - Fix: [#3177] Wrong keys displayed in shortcut menu.

View File

@ -9,6 +9,7 @@
#include "VirtualFloor.h" #include "VirtualFloor.h"
#include "../Cheats.h"
#include "../Input.h" #include "../Input.h"
#include "../config/Config.h" #include "../config/Config.h"
#include "../interface/Viewport.h" #include "../interface/Viewport.h"
@ -199,12 +200,15 @@ bool virtual_floor_tile_is_floor(int16_t x, int16_t y)
} }
static void virtual_floor_get_tile_properties( static void virtual_floor_get_tile_properties(
int16_t x, int16_t y, int16_t height, bool* outOccupied, uint8_t* outOccupiedEdges, bool* outBelowGround, bool* outLit) int16_t x, int16_t y, int16_t height, bool* outOccupied, bool* tileOwned, uint8_t* outOccupiedEdges, bool* outBelowGround,
bool* aboveGround, bool* outLit)
{ {
*outOccupied = false; *outOccupied = false;
*outOccupiedEdges = 0; *outOccupiedEdges = 0;
*outBelowGround = false; *outBelowGround = false;
*outLit = false; *outLit = false;
*aboveGround = false;
*tileOwned = false;
// See if we are a selected tile // See if we are a selected tile
if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
@ -229,6 +233,11 @@ static void virtual_floor_get_tile_properties(
} }
} }
*tileOwned = map_is_location_owned(x, y, height);
if (gCheatsSandboxMode)
*tileOwned = true;
// Iterate through the map elements of the current tile to find: // Iterate through the map elements of the current tile to find:
// * Surfaces, which may put us underground // * Surfaces, which may put us underground
// * Walls / banners, which are displayed as occupied edges // * Walls / banners, which are displayed as occupied edges
@ -249,6 +258,10 @@ static void virtual_floor_get_tile_properties(
*outBelowGround = true; *outBelowGround = true;
*outOccupied = true; *outOccupied = true;
} }
if (height > tileElement->base_height)
{
*aboveGround = true;
}
continue; continue;
} }
@ -298,11 +311,13 @@ void virtual_floor_paint(paint_session* session)
uint8_t occupiedEdges; uint8_t occupiedEdges;
bool weAreBelowGround; bool weAreBelowGround;
bool weAreLit; bool weAreLit;
bool weAreOwned;
bool weAreAboveGround;
uint8_t litEdges = 0; uint8_t litEdges = 0;
virtual_floor_get_tile_properties( virtual_floor_get_tile_properties(
session->MapPosition.x, session->MapPosition.y, virtualFloorClipHeight, &weAreOccupied, &occupiedEdges, session->MapPosition.x, session->MapPosition.y, virtualFloorClipHeight, &weAreOccupied, &weAreOwned, &occupiedEdges,
&weAreBelowGround, &weAreLit); &weAreBelowGround, &weAreAboveGround, &weAreLit);
// Move the bits around to match the current rotation // Move the bits around to match the current rotation
occupiedEdges |= occupiedEdges << 4; occupiedEdges |= occupiedEdges << 4;
@ -321,20 +336,22 @@ void virtual_floor_paint(paint_session* session)
uint8_t theirOccupiedEdges; uint8_t theirOccupiedEdges;
bool theyAreBelowGround; bool theyAreBelowGround;
bool theyAreLit; bool theyAreLit;
bool theyAreOwned;
bool theyAreAboveGround;
virtual_floor_get_tile_properties( virtual_floor_get_tile_properties(
theirLocationX, theirLocationY, virtualFloorClipHeight, &theyAreOccupied, &theirOccupiedEdges, &theyAreBelowGround, theirLocationX, theirLocationY, virtualFloorClipHeight, &theyAreOccupied, &theyAreOwned, &theirOccupiedEdges,
&theyAreLit); &theyAreBelowGround, &theyAreAboveGround, &theyAreLit);
if (theirOccupiedEdges & (1 << ((effectiveRotation + 2) % 4))) if (theirOccupiedEdges & (1 << ((effectiveRotation + 2) % 4)) && (weAreOwned && !theyAreOwned))
{ {
occupiedEdges |= 1 << i; occupiedEdges |= 1 << i;
} }
if (weAreLit != theyAreLit) if (weAreLit != theyAreLit || (weAreOwned && !theyAreOwned))
{ {
litEdges |= 1 << i; litEdges |= 1 << i;
} }
else if (weAreOccupied != theyAreOccupied || weAreBelowGround != theyAreBelowGround) else if ((weAreOccupied != theyAreOccupied || weAreBelowGround != theyAreBelowGround) && weAreOwned)
{ {
occupiedEdges |= 1 << i; occupiedEdges |= 1 << i;
} }
@ -347,41 +364,45 @@ void virtual_floor_paint(paint_session* session)
// Edges which are internal to objects (i.e., the tile on both sides // Edges which are internal to objects (i.e., the tile on both sides
// is occupied/lit) are not rendered to provide visual clarity. // is occupied/lit) are not rendered to provide visual clarity.
uint8_t dullEdges = 0xF & ~occupiedEdges & ~litEdges; uint8_t dullEdges = 0xF & ~occupiedEdges & ~litEdges;
uint8_t paintEdges = (weAreOccupied || weAreLit) ? ~dullEdges : 0xF; uint8_t paintEdges = ((weAreOccupied || weAreLit) && weAreOwned) ? ~dullEdges : 0xF;
if (paintEdges & 0x1) if (paintEdges & EDGE_NE)
{ {
sub_98197C( sub_98197C(
session, session,
SPR_G2_SELECTION_EDGE_NE | (!(occupiedEdges & 0x1) ? ((litEdges & 0x1) ? remap_lit : remap_base) : remap_edge), 0, SPR_G2_SELECTION_EDGE_NE
0, 0, 0, 1, _virtualFloorHeight, 5, 5, _virtualFloorHeight + ((dullEdges & 0x1) ? -2 : 0)); | (!(occupiedEdges & EDGE_NE) ? ((litEdges & EDGE_NE) ? remap_lit : remap_base) : remap_edge),
0, 0, 0, 0, 1, _virtualFloorHeight, 5, 5, _virtualFloorHeight + ((dullEdges & EDGE_NE) ? -2 : 0));
} }
if (paintEdges & 0x2) if (paintEdges & EDGE_SE)
{ {
sub_98197C( sub_98197C(
session, session,
SPR_G2_SELECTION_EDGE_SE | (!(occupiedEdges & 0x2) ? ((litEdges & 0x2) ? remap_lit : remap_base) : remap_edge), 0, SPR_G2_SELECTION_EDGE_SE
0, 1, 1, 1, _virtualFloorHeight, 16, 27, _virtualFloorHeight + ((dullEdges & 0x2) ? -2 : 0)); | (!(occupiedEdges & EDGE_SE) ? ((litEdges & EDGE_SE) ? remap_lit : remap_base) : remap_edge),
0, 0, 1, 1, 1, _virtualFloorHeight, 16, 27, _virtualFloorHeight + ((dullEdges & EDGE_SE) ? -2 : 0));
} }
if (paintEdges & 0x4) if (paintEdges & EDGE_SW)
{ {
sub_98197C( sub_98197C(
session, session,
SPR_G2_SELECTION_EDGE_SW | (!(occupiedEdges & 0x4) ? ((litEdges & 0x4) ? remap_lit : remap_base) : remap_edge), 0, SPR_G2_SELECTION_EDGE_SW
0, 1, 1, 1, _virtualFloorHeight, 27, 16, _virtualFloorHeight + ((dullEdges & 0x4) ? -2 : 0)); | (!(occupiedEdges & EDGE_SW) ? ((litEdges & EDGE_SW) ? remap_lit : remap_base) : remap_edge),
0, 0, 1, 1, 1, _virtualFloorHeight, 27, 16, _virtualFloorHeight + ((dullEdges & EDGE_SW) ? -2 : 0));
} }
if (paintEdges & 0x8) if (paintEdges & EDGE_NW)
{ {
sub_98197C( sub_98197C(
session, session,
SPR_G2_SELECTION_EDGE_NW | (!(occupiedEdges & 0x8) ? ((litEdges & 0x8) ? remap_lit : remap_base) : remap_edge), 0, SPR_G2_SELECTION_EDGE_NW
0, 0, 0, 1, _virtualFloorHeight, 5, 5, _virtualFloorHeight + ((dullEdges & 0x8) ? -2 : 0)); | (!(occupiedEdges & EDGE_NW) ? ((litEdges & EDGE_NW) ? remap_lit : remap_base) : remap_edge),
0, 0, 0, 0, 1, _virtualFloorHeight, 5, 5, _virtualFloorHeight + ((dullEdges & EDGE_NW) ? -2 : 0));
} }
if (gConfigGeneral.virtual_floor_style != VIRTUAL_FLOOR_STYLE_GLASSY) if (gConfigGeneral.virtual_floor_style != VIRTUAL_FLOOR_STYLE_GLASSY)
return; return;
if (!weAreOccupied && !weAreLit) if (!weAreOccupied && !weAreLit && weAreAboveGround && weAreOwned)
{ {
int32_t imageColourFlats = SPR_G2_SURFACE_GLASSY_RECOLOURABLE | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT int32_t imageColourFlats = SPR_G2_SURFACE_GLASSY_RECOLOURABLE | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT
| PALETTE_WATER << 19; | PALETTE_WATER << 19;