mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Merge pull request #5274 from IntelOrca/refactor/wall-cpp
Clean up wall.cpp
This commit is contained in:
@@ -268,6 +268,11 @@ sint32 map_element_is_last_for_tile(const rct_map_element *element)
|
||||
return element->flags & MAP_ELEMENT_FLAG_LAST_TILE;
|
||||
}
|
||||
|
||||
bool map_element_is_ghost(const rct_map_element *element)
|
||||
{
|
||||
return element->flags & MAP_ELEMENT_FLAG_GHOST;
|
||||
}
|
||||
|
||||
uint8 map_element_get_scenery_quadrant(const rct_map_element *element)
|
||||
{
|
||||
return (element->type & MAP_ELEMENT_QUADRANT_MASK) >> 6;
|
||||
|
||||
@@ -414,6 +414,7 @@ rct_map_element *map_get_first_element_at(sint32 x, sint32 y);
|
||||
rct_map_element *map_get_nth_element_at(sint32 x, sint32 y, sint32 n);
|
||||
void map_set_tile_elements(sint32 x, sint32 y, rct_map_element *elements);
|
||||
sint32 map_element_is_last_for_tile(const rct_map_element *element);
|
||||
bool map_element_is_ghost(const rct_map_element *element);
|
||||
uint8 map_element_get_scenery_quadrant(const rct_map_element *element);
|
||||
sint32 map_element_get_type(const rct_map_element *element);
|
||||
sint32 map_element_get_direction(const rct_map_element *element);
|
||||
|
||||
@@ -19,56 +19,63 @@
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../cheats.h"
|
||||
#include "../game.h"
|
||||
#include "../localisation/string_ids.h"
|
||||
#include "../ride/track.h"
|
||||
#include "../ride/track_data.h"
|
||||
#include "map.h"
|
||||
#include "park.h"
|
||||
#include "scenery.h"
|
||||
#include "../cheats.h"
|
||||
#include "../game.h"
|
||||
#include "../ride/track.h"
|
||||
#include "../ride/track_data.h"
|
||||
#include "../localisation/string_ids.h"
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the given track type can have a wall placed on the edge of the given direction.
|
||||
* Some thin tracks for example are allowed to have walls either side of the track, but wider tracks can not.
|
||||
*/
|
||||
static bool TrackIsAllowedWallEdges(uint8 rideType, uint8 trackType, uint8 trackSequence, uint8 direction)
|
||||
{
|
||||
if (!ride_type_has_flag(rideType, RIDE_TYPE_FLAG_TRACK_NO_WALLS))
|
||||
{
|
||||
if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE))
|
||||
{
|
||||
if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][trackSequence] & (1 << direction))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TrackSequenceElementAllowedWallEdges[trackType][trackSequence] & (1 << direction))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E5CBA
|
||||
*/
|
||||
static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall,
|
||||
sint32 x,
|
||||
sint32 y,
|
||||
sint32 z0,
|
||||
sint32 z1,
|
||||
static bool WallCheckObstructionWithTrack(rct_scenery_entry * wall,
|
||||
sint32 x,
|
||||
sint32 y,
|
||||
sint32 z0,
|
||||
sint32 z1,
|
||||
sint32 edge,
|
||||
rct_map_element * trackElement,
|
||||
bool * wallAcrossTrack)
|
||||
{
|
||||
const rct_preview_track *trackBlock;
|
||||
sint32 z, direction;
|
||||
|
||||
sint32 trackType = trackElement->properties.track.type;
|
||||
sint32 sequence = trackElement->properties.track.sequence & 0x0F;
|
||||
direction = (edge - trackElement->type) & 3;
|
||||
sint32 direction = (edge - trackElement->type) & 3;
|
||||
rct_ride * ride = get_ride(trackElement->properties.track.ride_index);
|
||||
|
||||
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE))
|
||||
if (TrackIsAllowedWallEdges(ride->type, trackType, sequence, direction))
|
||||
{
|
||||
if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction))
|
||||
{
|
||||
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction))
|
||||
{
|
||||
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR))
|
||||
@@ -76,24 +83,26 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0))
|
||||
// The following code checks if a door is allowed on the track
|
||||
if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
|
||||
if (rideEntry->flags & RIDE_ENTRY_FLAG_16)
|
||||
if (rideEntry->flags & RIDE_ENTRY_FLAG_16)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*wallAcrossTrack = true;
|
||||
if (z0 & 1)
|
||||
if (z0 & 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sequence == 0)
|
||||
sint32 z;
|
||||
if (sequence == 0)
|
||||
{
|
||||
if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS)
|
||||
{
|
||||
@@ -105,12 +114,12 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall,
|
||||
if (!(TrackCoordinates[trackType].rotation_begin & 4))
|
||||
{
|
||||
direction = (trackElement->type & 3) ^ 2;
|
||||
if (direction == edge)
|
||||
if (direction == edge)
|
||||
{
|
||||
trackBlock = &TrackBlocks[trackType][sequence];
|
||||
const rct_preview_track * trackBlock = &TrackBlocks[trackType][sequence];
|
||||
z = TrackCoordinates[trackType].z_begin;
|
||||
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
||||
if (z == z0)
|
||||
if (z == z0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -119,7 +128,7 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall,
|
||||
}
|
||||
}
|
||||
|
||||
trackBlock = &TrackBlocks[trackType][sequence + 1];
|
||||
const rct_preview_track * trackBlock = &TrackBlocks[trackType][sequence + 1];
|
||||
if (trackBlock->index != 0xFF)
|
||||
{
|
||||
return false;
|
||||
@@ -137,7 +146,7 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall,
|
||||
}
|
||||
|
||||
direction = (trackElement->type + direction) & 3;
|
||||
if (direction != edge)
|
||||
if (direction != edge)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -145,7 +154,7 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall,
|
||||
trackBlock = &TrackBlocks[trackType][sequence];
|
||||
z = TrackCoordinates[trackType].z_end;
|
||||
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
||||
if (z != z0)
|
||||
if (z != z0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -157,10 +166,10 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall,
|
||||
*
|
||||
* rct2: 0x006E5C1A
|
||||
*/
|
||||
static bool WallCheckObstruction(rct_scenery_entry * wall,
|
||||
sint32 x,
|
||||
sint32 y,
|
||||
sint32 z0,
|
||||
static bool WallCheckObstruction(rct_scenery_entry * wall,
|
||||
sint32 x,
|
||||
sint32 y,
|
||||
sint32 z0,
|
||||
sint32 z1,
|
||||
sint32 edge,
|
||||
bool * wallAcrossTrack)
|
||||
@@ -178,16 +187,16 @@ static bool WallCheckObstruction(rct_scenery_entry * wall,
|
||||
}
|
||||
|
||||
rct_map_element * mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||
do
|
||||
do
|
||||
{
|
||||
sint32 elementType = map_element_get_type(mapElement);
|
||||
if (elementType == MAP_ELEMENT_TYPE_SURFACE) continue;
|
||||
if (z0 >= mapElement->clearance_height) continue;
|
||||
if (z1 <= mapElement->base_height) continue;
|
||||
if (elementType == MAP_ELEMENT_TYPE_WALL)
|
||||
if (elementType == MAP_ELEMENT_TYPE_WALL)
|
||||
{
|
||||
sint32 direction = mapElement->type & 3;
|
||||
if (edge == direction)
|
||||
if (edge == direction)
|
||||
{
|
||||
map_obstruction_set_error_text(mapElement);
|
||||
return false;
|
||||
@@ -196,13 +205,12 @@ static bool WallCheckObstruction(rct_scenery_entry * wall,
|
||||
}
|
||||
if ((mapElement->flags & 0x0F) == 0) continue;
|
||||
|
||||
switch (elementType)
|
||||
{
|
||||
switch (elementType) {
|
||||
case MAP_ELEMENT_TYPE_ENTRANCE:
|
||||
map_obstruction_set_error_text(mapElement);
|
||||
return false;
|
||||
case MAP_ELEMENT_TYPE_PATH:
|
||||
if (mapElement->properties.path.edges & (1 << edge))
|
||||
if (mapElement->properties.path.edges & (1 << edge))
|
||||
{
|
||||
map_obstruction_set_error_text(mapElement);
|
||||
return false;
|
||||
@@ -215,7 +223,7 @@ static bool WallCheckObstruction(rct_scenery_entry * wall,
|
||||
tile = &entry->large_scenery.tiles[sequence];
|
||||
{
|
||||
sint32 direction = ((edge - mapElement->type) & 3) + 8;
|
||||
if (!(tile->var_7 & (1 << direction)))
|
||||
if (!(tile->var_7 & (1 << direction)))
|
||||
{
|
||||
map_obstruction_set_error_text(mapElement);
|
||||
return false;
|
||||
@@ -225,20 +233,20 @@ static bool WallCheckObstruction(rct_scenery_entry * wall,
|
||||
case MAP_ELEMENT_TYPE_SCENERY:
|
||||
entryType = mapElement->properties.scenery.type;
|
||||
entry = get_small_scenery_entry(entryType);
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS)
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS)
|
||||
{
|
||||
map_obstruction_set_error_text(mapElement);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MAP_ELEMENT_TYPE_TRACK:
|
||||
if (!WallCheckObstructionWithTrack(wall, x, y, z0, z1, edge, mapElement, wallAcrossTrack))
|
||||
if (!WallCheckObstructionWithTrack(wall, x, y, z0, z1, edge, mapElement, wallAcrossTrack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
|
||||
return true;
|
||||
@@ -246,14 +254,14 @@ static bool WallCheckObstruction(rct_scenery_entry * wall,
|
||||
|
||||
#pragma region Edge Slopes Table
|
||||
|
||||
enum
|
||||
enum EDGE_SLOPE
|
||||
{
|
||||
EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01
|
||||
EDGE_SLOPE_UPWARDS = (1 << 6), // 0x40
|
||||
EDGE_SLOPE_DOWNWARDS = (1 << 7), // 0x80
|
||||
EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01
|
||||
EDGE_SLOPE_UPWARDS = (1 << 6), // 0x40
|
||||
EDGE_SLOPE_DOWNWARDS = (1 << 7), // 0x80
|
||||
|
||||
EDGE_SLOPE_UPWARDS_ELEVATED = EDGE_SLOPE_UPWARDS | EDGE_SLOPE_ELEVATED,
|
||||
EDGE_SLOPE_DOWNWARDS_ELEVATED = EDGE_SLOPE_DOWNWARDS | EDGE_SLOPE_ELEVATED,
|
||||
EDGE_SLOPE_UPWARDS_ELEVATED = EDGE_SLOPE_UPWARDS | EDGE_SLOPE_ELEVATED,
|
||||
EDGE_SLOPE_DOWNWARDS_ELEVATED = EDGE_SLOPE_DOWNWARDS | EDGE_SLOPE_ELEVATED,
|
||||
};
|
||||
|
||||
/** rct2: 0x009A3FEC */
|
||||
@@ -295,22 +303,17 @@ static const uint8 EdgeSlopes[][4] = {
|
||||
|
||||
#pragma endregion
|
||||
|
||||
static money32 WallPlace(uint8 wallType,
|
||||
sint16 x,
|
||||
sint16 y,
|
||||
sint16 z,
|
||||
static money32 WallPlace(uint8 wallType,
|
||||
sint16 x,
|
||||
sint16 y,
|
||||
sint16 z,
|
||||
uint8 edge,
|
||||
uint8 primaryColour,
|
||||
uint8 secondaryColour,
|
||||
uint8 tertiaryColour,
|
||||
uint8 flags)
|
||||
uint8 flags)
|
||||
{
|
||||
rct_xyz16 position =
|
||||
{
|
||||
x,
|
||||
y,
|
||||
z
|
||||
};
|
||||
rct_xyz16 position = { x, y, z };
|
||||
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
|
||||
gCommandPosition.x = position.x + 16;
|
||||
@@ -329,7 +332,7 @@ static money32 WallPlace(uint8 wallType,
|
||||
}
|
||||
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) &&
|
||||
!(flags & GAME_COMMAND_FLAG_7) &&
|
||||
!(flags & GAME_COMMAND_FLAG_7) &&
|
||||
!gCheatsSandboxMode)
|
||||
{
|
||||
|
||||
@@ -350,7 +353,7 @@ static money32 WallPlace(uint8 wallType,
|
||||
if (position.z == 0)
|
||||
{
|
||||
rct_map_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32);
|
||||
if (surfaceElement == NULL)
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
@@ -358,7 +361,7 @@ static money32 WallPlace(uint8 wallType,
|
||||
|
||||
uint8 slope = surfaceElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
||||
edgeSlope = EdgeSlopes[slope][edge & 3];
|
||||
if (edgeSlope & EDGE_SLOPE_ELEVATED)
|
||||
if (edgeSlope & EDGE_SLOPE_ELEVATED)
|
||||
{
|
||||
position.z += 16;
|
||||
edgeSlope &= ~EDGE_SLOPE_ELEVATED;
|
||||
@@ -366,7 +369,7 @@ static money32 WallPlace(uint8 wallType,
|
||||
}
|
||||
|
||||
rct_map_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32);
|
||||
if (surfaceElement == NULL)
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
@@ -454,9 +457,9 @@ static money32 WallPlace(uint8 wallType,
|
||||
}
|
||||
sint32 bannerIndex = 0xFF;
|
||||
rct_scenery_entry * wallEntry = get_wall_entry(wallType);
|
||||
// Have to check both -1 and NULL, as one can be a invalid object,
|
||||
// Have to check both -1 and nullptr, as one can be a invalid object,
|
||||
// while the other can be invalid index
|
||||
if ((uintptr_t)wallEntry == (uintptr_t)-1 || wallEntry == NULL)
|
||||
if ((uintptr_t)wallEntry == (uintptr_t)-1 || wallEntry == nullptr)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
@@ -479,7 +482,7 @@ static money32 WallPlace(uint8 wallType,
|
||||
banner->y = position.y / 32;
|
||||
|
||||
sint32 rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z);
|
||||
if (rideIndex != -1)
|
||||
if (rideIndex != -1)
|
||||
{
|
||||
banner->colour = rideIndex & 0xFF;
|
||||
banner->flags |= BANNER_FLAG_LINKED_TO_RIDE;
|
||||
@@ -499,15 +502,15 @@ static money32 WallPlace(uint8 wallType,
|
||||
}
|
||||
clearanceHeight += wallEntry->wall.height;
|
||||
|
||||
bool wallAcrossTrack = false;
|
||||
bool wallAcrossTrack = false;
|
||||
if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks)
|
||||
{
|
||||
if (!WallCheckObstruction(wallEntry,
|
||||
position.x,
|
||||
position.y,
|
||||
position.z / 8,
|
||||
clearanceHeight,
|
||||
edge,
|
||||
if (!WallCheckObstruction(wallEntry,
|
||||
position.x,
|
||||
position.y,
|
||||
position.z / 8,
|
||||
clearanceHeight,
|
||||
edge,
|
||||
&wallAcrossTrack))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
@@ -521,7 +524,7 @@ static money32 WallPlace(uint8 wallType,
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
rct_xyz16 coord;
|
||||
coord.x = position.x + 16;
|
||||
@@ -531,7 +534,7 @@ static money32 WallPlace(uint8 wallType,
|
||||
}
|
||||
|
||||
rct_map_element * mapElement = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0);
|
||||
assert(mapElement != NULL);
|
||||
assert(mapElement != nullptr);
|
||||
|
||||
map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8);
|
||||
|
||||
@@ -542,7 +545,7 @@ static money32 WallPlace(uint8 wallType,
|
||||
mapElement->properties.wall.colour_1 = primaryColour;
|
||||
wall_element_set_secondary_colour(mapElement, secondaryColour);
|
||||
|
||||
if (wallAcrossTrack)
|
||||
if (wallAcrossTrack)
|
||||
{
|
||||
mapElement->properties.wall.animation |= WALL_ANIMATION_FLAG_ACROSS_TRACK;
|
||||
}
|
||||
@@ -577,54 +580,53 @@ static money32 WallPlace(uint8 wallType,
|
||||
}
|
||||
}
|
||||
|
||||
static rct_map_element * GetFirstWallElementAt(sint32 x, sint32 y, uint8 baseZ, uint8 direction, bool isGhost)
|
||||
{
|
||||
rct_map_element * mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||
do
|
||||
{
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue;
|
||||
if (mapElement->base_height != baseZ) continue;
|
||||
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != direction) continue;
|
||||
if (map_element_is_ghost(mapElement) != isGhost) continue;
|
||||
return mapElement;
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags)
|
||||
{
|
||||
if (!map_is_location_valid(x, y))
|
||||
if (!map_is_location_valid(x, y))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
|
||||
if(!(flags & GAME_COMMAND_FLAG_GHOST) &&
|
||||
game_is_paused() &&
|
||||
!gCheatsBuildInPauseMode)
|
||||
bool isGhost = (flags & GAME_COMMAND_FLAG_GHOST) != 0;
|
||||
if (!isGhost &&
|
||||
game_is_paused() &&
|
||||
!gCheatsBuildInPauseMode)
|
||||
{
|
||||
gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if(!(flags & GAME_COMMAND_FLAG_GHOST) &&
|
||||
!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) &&
|
||||
!gCheatsSandboxMode &&
|
||||
!map_is_location_owned(x, y, baseHeight * 8))
|
||||
if (!isGhost &&
|
||||
!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) &&
|
||||
!gCheatsSandboxMode &&
|
||||
!map_is_location_owned(x, y, baseHeight * 8))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
bool wallFound = false;
|
||||
rct_map_element * wallElement = map_get_first_element_at(x / 32, y / 32);
|
||||
do
|
||||
{
|
||||
if (map_element_get_type(wallElement) != MAP_ELEMENT_TYPE_WALL)
|
||||
continue;
|
||||
if (wallElement->base_height != baseHeight)
|
||||
continue;
|
||||
if ((wallElement->type & MAP_ELEMENT_DIRECTION_MASK) != direction)
|
||||
continue;
|
||||
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->flags & MAP_ELEMENT_FLAG_GHOST))
|
||||
continue;
|
||||
|
||||
wallFound = true;
|
||||
break;
|
||||
}
|
||||
while (!map_element_is_last_for_tile(wallElement++));
|
||||
|
||||
if (!(flags & GAME_COMMAND_FLAG_APPLY) || (wallFound == false))
|
||||
rct_map_element * wallElement = GetFirstWallElementAt(x, y, baseHeight, direction, isGhost);
|
||||
if (!(flags & GAME_COMMAND_FLAG_APPLY) || (wallElement == nullptr))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
if (gGameCommandNestLevel == 1 && !isGhost)
|
||||
{
|
||||
rct_xyz16 coord;
|
||||
coord.x = x + 16;
|
||||
@@ -639,14 +641,14 @@ static money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static money32 WallSetColour(sint16 x,
|
||||
sint16 y,
|
||||
uint8 baseHeight,
|
||||
uint8 direction,
|
||||
uint8 primaryColour,
|
||||
uint8 secondaryColour,
|
||||
uint8 tertiaryColour,
|
||||
uint8 flags)
|
||||
static money32 WallSetColour(sint16 x,
|
||||
sint16 y,
|
||||
uint8 baseHeight,
|
||||
uint8 direction,
|
||||
uint8 primaryColour,
|
||||
uint8 secondaryColour,
|
||||
uint8 tertiaryColour,
|
||||
uint8 flags)
|
||||
{
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
|
||||
sint32 z = baseHeight * 8;
|
||||
@@ -657,31 +659,30 @@ static money32 WallSetColour(sint16 x,
|
||||
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) &&
|
||||
!map_is_location_in_park(x, y) &&
|
||||
!gCheatsSandboxMode)
|
||||
!gCheatsSandboxMode)
|
||||
{
|
||||
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
rct_map_element * wallElement = map_get_wall_element_at(x, y, baseHeight, direction);
|
||||
|
||||
if (wallElement == NULL)
|
||||
if (wallElement == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->flags & MAP_ELEMENT_FLAG_GHOST))
|
||||
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->flags & MAP_ELEMENT_FLAG_GHOST))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(flags & GAME_COMMAND_FLAG_APPLY)
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
rct_scenery_entry * scenery_entry = get_wall_entry(wallElement->properties.wall.type);
|
||||
wallElement->properties.wall.colour_1 = primaryColour;
|
||||
wall_element_set_secondary_colour(wallElement, secondaryColour);
|
||||
|
||||
if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
|
||||
if (scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
|
||||
{
|
||||
wallElement->properties.wall.colour_3 = tertiaryColour;
|
||||
}
|
||||
@@ -731,7 +732,7 @@ extern "C"
|
||||
z1 /= 8;
|
||||
repeat:
|
||||
mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
do
|
||||
do
|
||||
{
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL)
|
||||
continue;
|
||||
@@ -744,10 +745,10 @@ extern "C"
|
||||
map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72);
|
||||
map_element_remove(mapElement);
|
||||
goto repeat;
|
||||
}
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E57E6
|
||||
@@ -766,7 +767,7 @@ extern "C"
|
||||
rct_map_element * mapElement;
|
||||
|
||||
mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
do
|
||||
do
|
||||
{
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL)
|
||||
continue;
|
||||
@@ -781,7 +782,7 @@ extern "C"
|
||||
map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72);
|
||||
map_element_remove(mapElement);
|
||||
mapElement--;
|
||||
}
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
}
|
||||
|
||||
@@ -789,13 +790,13 @@ extern "C"
|
||||
*
|
||||
* rct2: 0x006E519A
|
||||
*/
|
||||
void game_command_place_wall(sint32 * eax,
|
||||
sint32 * ebx,
|
||||
sint32 * ecx,
|
||||
sint32 * edx,
|
||||
sint32 * esi,
|
||||
sint32 * edi,
|
||||
sint32 * ebp)
|
||||
void game_command_place_wall(sint32 * eax,
|
||||
sint32 * ebx,
|
||||
sint32 * ecx,
|
||||
sint32 * edx,
|
||||
sint32 * esi,
|
||||
sint32 * edi,
|
||||
sint32 * ebp)
|
||||
{
|
||||
*ebx = WallPlace(
|
||||
(*ebx >> 8) & 0xFF,
|
||||
@@ -810,24 +811,23 @@ extern "C"
|
||||
);
|
||||
}
|
||||
|
||||
money32 wall_place(sint32 type,
|
||||
sint32 x,
|
||||
sint32 y,
|
||||
sint32 z,
|
||||
sint32 edge,
|
||||
sint32 primaryColour,
|
||||
sint32 secondaryColour,
|
||||
sint32 tertiaryColour,
|
||||
sint32 flags)
|
||||
money32 wall_place(sint32 type,
|
||||
sint32 x,
|
||||
sint32 y,
|
||||
sint32 z,
|
||||
sint32 edge,
|
||||
sint32 primaryColour,
|
||||
sint32 secondaryColour,
|
||||
sint32 tertiaryColour,
|
||||
sint32 flags)
|
||||
{
|
||||
sint32 eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
|
||||
eax = x;
|
||||
ebx = flags | (type << 8);
|
||||
ecx = y;
|
||||
edx = edge | (primaryColour << 8);
|
||||
edi = z;
|
||||
ebp = secondaryColour | (tertiaryColour << 8);
|
||||
sint32 eax = x;
|
||||
sint32 ebx = flags | (type << 8);
|
||||
sint32 ecx = y;
|
||||
sint32 edx = edge | (primaryColour << 8);
|
||||
sint32 esi = 0;
|
||||
sint32 edi = z;
|
||||
sint32 ebp = secondaryColour | (tertiaryColour << 8);
|
||||
game_command_place_wall(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
return ebx;
|
||||
}
|
||||
@@ -836,12 +836,12 @@ extern "C"
|
||||
*
|
||||
* rct2: 0x006E5597
|
||||
*/
|
||||
void game_command_remove_wall(sint32 * eax,
|
||||
sint32 * ebx,
|
||||
sint32 * ecx,
|
||||
sint32 * edx,
|
||||
sint32 * esi,
|
||||
sint32 * edi,
|
||||
void game_command_remove_wall(sint32 * eax,
|
||||
sint32 * ebx,
|
||||
sint32 * ecx,
|
||||
sint32 * edx,
|
||||
sint32 * esi,
|
||||
sint32 * edi,
|
||||
sint32 * ebp)
|
||||
{
|
||||
*ebx = WallRemove(
|
||||
@@ -852,17 +852,17 @@ extern "C"
|
||||
*ebx & 0xFF
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E56B5
|
||||
*/
|
||||
void game_command_set_wall_colour(sint32 * eax,
|
||||
sint32 * ebx,
|
||||
sint32 * ecx,
|
||||
sint32 * edx,
|
||||
sint32 * esi,
|
||||
sint32 * edi,
|
||||
void game_command_set_wall_colour(sint32 * eax,
|
||||
sint32 * ebx,
|
||||
sint32 * ecx,
|
||||
sint32 * edx,
|
||||
sint32 * esi,
|
||||
sint32 * edi,
|
||||
sint32 * ebp)
|
||||
{
|
||||
*ebx = WallSetColour(
|
||||
|
||||
Reference in New Issue
Block a user