mirror of https://github.com/OpenRCT2/OpenRCT2.git
Enforce the bracket and line width rule
This commit is contained in:
parent
c5e9698f0c
commit
84a0060090
|
@ -57,6 +57,7 @@ void SawyerChunkReader::SkipChunk()
|
|||
|
||||
std::shared_ptr<SawyerChunk> SawyerChunkReader::ReadChunk()
|
||||
{
|
||||
Guard::Assert(false, "Test");
|
||||
uint64 originalPosition = _stream->GetPosition();
|
||||
try
|
||||
{
|
||||
|
|
|
@ -33,7 +33,14 @@ extern "C"
|
|||
*
|
||||
* rct2: 0x006E5CBA
|
||||
*/
|
||||
static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, rct_map_element *trackElement, bool *wallAcrossTrack)
|
||||
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;
|
||||
|
@ -41,53 +48,70 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sin
|
|||
sint32 trackType = trackElement->properties.track.type;
|
||||
sint32 sequence = trackElement->properties.track.sequence & 0x0F;
|
||||
direction = (edge - trackElement->type) & 3;
|
||||
rct_ride *ride = get_ride(trackElement->properties.track.ride_index);
|
||||
rct_ride * ride = get_ride(trackElement->properties.track.ride_index);
|
||||
|
||||
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) {
|
||||
if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) {
|
||||
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) {
|
||||
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE))
|
||||
{
|
||||
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)) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction))
|
||||
{
|
||||
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) {
|
||||
if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) {
|
||||
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) {
|
||||
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
|
||||
if (rideEntry->flags & RIDE_ENTRY_FLAG_16)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*wallAcrossTrack = true;
|
||||
if (z0 & 1) {
|
||||
if (z0 & 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sequence == 0) {
|
||||
if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) {
|
||||
if (sequence == 0)
|
||||
{
|
||||
if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TrackDefinitions[trackType].bank_start == 0) {
|
||||
if (!(TrackCoordinates[trackType].rotation_begin & 4)) {
|
||||
if (TrackDefinitions[trackType].bank_start == 0)
|
||||
{
|
||||
if (!(TrackCoordinates[trackType].rotation_begin & 4))
|
||||
{
|
||||
direction = (trackElement->type & 3) ^ 2;
|
||||
if (direction == edge) {
|
||||
if (direction == edge)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -96,28 +120,33 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sin
|
|||
}
|
||||
|
||||
trackBlock = &TrackBlocks[trackType][sequence + 1];
|
||||
if (trackBlock->index != 0xFF) {
|
||||
if (trackBlock->index != 0xFF)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TrackDefinitions[trackType].bank_end != 0) {
|
||||
if (TrackDefinitions[trackType].bank_end != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
direction = TrackCoordinates[trackType].rotation_end;
|
||||
if (direction & 4) {
|
||||
if (direction & 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
direction = (trackElement->type + direction) & 3;
|
||||
if (direction != edge) {
|
||||
if (direction != edge)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -128,28 +157,38 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sin
|
|||
*
|
||||
* rct2: 0x006E5C1A
|
||||
*/
|
||||
static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, bool *wallAcrossTrack)
|
||||
static bool WallCheckObstruction(rct_scenery_entry * wall,
|
||||
sint32 x,
|
||||
sint32 y,
|
||||
sint32 z0,
|
||||
sint32 z1,
|
||||
sint32 edge,
|
||||
bool * wallAcrossTrack)
|
||||
{
|
||||
sint32 entryType, sequence;
|
||||
rct_scenery_entry *entry;
|
||||
rct_large_scenery_tile *tile;
|
||||
rct_scenery_entry * entry;
|
||||
rct_large_scenery_tile * tile;
|
||||
|
||||
*wallAcrossTrack = false;
|
||||
gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND;
|
||||
if (map_is_location_at_edge(x, y)) {
|
||||
if (map_is_location_at_edge(x, y))
|
||||
{
|
||||
gGameCommandErrorText = STR_OFF_EDGE_OF_MAP;
|
||||
return false;
|
||||
}
|
||||
|
||||
rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||
do {
|
||||
rct_map_element * mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||
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;
|
||||
}
|
||||
|
@ -157,12 +196,14 @@ static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, si
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
@ -174,7 +215,8 @@ static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, si
|
|||
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;
|
||||
}
|
||||
|
@ -183,21 +225,27 @@ static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, si
|
|||
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++));
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#pragma region Edge Slopes Table
|
||||
|
||||
enum
|
||||
{
|
||||
EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01
|
||||
|
@ -245,10 +293,20 @@ static const uint8 EdgeSlopes[][4] = {
|
|||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint8 primaryColour, uint8 secondaryColour, uint8 tertiaryColour, uint8 flags) {
|
||||
rct_xyz16 position = {
|
||||
money32 WallPlace(uint8 wallType,
|
||||
sint16 x,
|
||||
sint16 y,
|
||||
sint16 z,
|
||||
uint8 edge,
|
||||
uint8 primaryColour,
|
||||
uint8 secondaryColour,
|
||||
uint8 tertiaryColour,
|
||||
uint8 flags)
|
||||
{
|
||||
rct_xyz16 position =
|
||||
{
|
||||
x,
|
||||
y,
|
||||
z
|
||||
|
@ -259,82 +317,103 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint
|
|||
gCommandPosition.y = position.y + 16;
|
||||
gCommandPosition.z = position.z;
|
||||
|
||||
if (position.z == 0){
|
||||
if (position.z == 0)
|
||||
{
|
||||
gCommandPosition.z = map_element_height(position.x, position.y) & 0xFFFF;
|
||||
}
|
||||
|
||||
if (game_is_paused() && !gCheatsBuildInPauseMode){
|
||||
if (game_is_paused() && !gCheatsBuildInPauseMode)
|
||||
{
|
||||
gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) &&
|
||||
!(flags & GAME_COMMAND_FLAG_7) && !gCheatsSandboxMode){
|
||||
!(flags & GAME_COMMAND_FLAG_7) &&
|
||||
!gCheatsSandboxMode)
|
||||
{
|
||||
|
||||
if (position.z == 0){
|
||||
if (!map_is_location_in_park(position.x, position.y)){
|
||||
if (position.z == 0)
|
||||
{
|
||||
if (!map_is_location_in_park(position.x, position.y))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
}
|
||||
else if (!map_is_location_owned(position.x, position.y, position.z)){
|
||||
else if (!map_is_location_owned(position.x, position.y, position.z))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
uint8 bp = 0;
|
||||
if (position.z == 0){
|
||||
rct_map_element* surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32);
|
||||
if (surfaceElement == NULL){
|
||||
if (position.z == 0)
|
||||
{
|
||||
rct_map_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32);
|
||||
if (surfaceElement == NULL)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
position.z = surfaceElement->base_height * 8;
|
||||
|
||||
uint8 slope = surfaceElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
||||
bp = EdgeSlopes[slope][edge & 3];
|
||||
if (bp & EDGE_SLOPE_ELEVATED) {
|
||||
if (bp & EDGE_SLOPE_ELEVATED)
|
||||
{
|
||||
position.z += 16;
|
||||
bp &= ~(1 << 0);
|
||||
}
|
||||
}
|
||||
|
||||
rct_map_element* surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32);
|
||||
if (surfaceElement == NULL){
|
||||
rct_map_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32);
|
||||
if (surfaceElement == NULL)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){
|
||||
if (surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK)
|
||||
{
|
||||
uint16 waterHeight = surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK;
|
||||
waterHeight *= 16;
|
||||
|
||||
if (position.z < waterHeight){
|
||||
if (position.z < waterHeight)
|
||||
{
|
||||
gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
if (position.z / 8 < surfaceElement->base_height){
|
||||
if (position.z / 8 < surfaceElement->base_height)
|
||||
{
|
||||
gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (!(bp & 0xC0)){
|
||||
if (!(bp & 0xC0))
|
||||
{
|
||||
uint8 newEdge = (edge + 2) & 3;
|
||||
uint8 newBaseHeight = surfaceElement->base_height;
|
||||
newBaseHeight += 2;
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge)){
|
||||
if (position.z / 8 < newBaseHeight){
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge))
|
||||
{
|
||||
if (position.z / 8 < newBaseHeight)
|
||||
{
|
||||
gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (surfaceElement->properties.surface.slope & (1 << 4)){
|
||||
if (surfaceElement->properties.surface.slope & (1 << 4))
|
||||
{
|
||||
newEdge = (newEdge - 1) & 3;
|
||||
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge)){
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge))
|
||||
{
|
||||
newEdge = (newEdge + 2) & 3;
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge)){
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge))
|
||||
{
|
||||
newBaseHeight += 2;
|
||||
if (position.z / 8 < newBaseHeight){
|
||||
if (position.z / 8 < newBaseHeight)
|
||||
{
|
||||
gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
@ -345,20 +424,26 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint
|
|||
}
|
||||
|
||||
newEdge = (edge + 3) & 3;
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge)){
|
||||
if (position.z / 8 < newBaseHeight){
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge))
|
||||
{
|
||||
if (position.z / 8 < newBaseHeight)
|
||||
{
|
||||
gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (surfaceElement->properties.surface.slope & (1 << 4)){
|
||||
if (surfaceElement->properties.surface.slope & (1 << 4))
|
||||
{
|
||||
newEdge = (newEdge - 1) & 3;
|
||||
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge)){
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge))
|
||||
{
|
||||
newEdge = (newEdge + 2) & 3;
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge)){
|
||||
if (surfaceElement->properties.surface.slope & (1 << newEdge))
|
||||
{
|
||||
newBaseHeight += 2;
|
||||
if (position.z / 8 < newBaseHeight){
|
||||
if (position.z / 8 < newBaseHeight)
|
||||
{
|
||||
gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
@ -368,28 +453,34 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint
|
|||
}
|
||||
}
|
||||
sint32 bannerIndex = 0xFF;
|
||||
rct_scenery_entry* wallEntry = get_wall_entry(wallType);
|
||||
rct_scenery_entry * wallEntry = get_wall_entry(wallType);
|
||||
// Have to check both -1 and NULL, 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 == NULL)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
if (wallEntry->wall.scrolling_mode != 0xFF){
|
||||
|
||||
if (wallEntry->wall.scrolling_mode != 0xFF)
|
||||
{
|
||||
bannerIndex = create_new_banner(flags);
|
||||
|
||||
if (bannerIndex == 0xFF){
|
||||
if (bannerIndex == 0xFF)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
rct_banner* banner = &gBanners[bannerIndex];
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY){
|
||||
rct_banner * banner = &gBanners[bannerIndex];
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
banner->flags |= (1 << 3);
|
||||
banner->type = 0;
|
||||
banner->x = position.x / 32;
|
||||
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;
|
||||
}
|
||||
|
@ -397,8 +488,10 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint
|
|||
}
|
||||
|
||||
uint8 clearanceHeight = position.z / 8;
|
||||
if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) {
|
||||
if (wallEntry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE){
|
||||
if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS))
|
||||
{
|
||||
if (wallEntry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE)
|
||||
{
|
||||
gGameCommandErrorText = STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
@ -407,18 +500,29 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint
|
|||
clearanceHeight += wallEntry->wall.height;
|
||||
|
||||
bool wallAcrossTrack = false;
|
||||
if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks){
|
||||
if (!WallCheckObstruction(wallEntry, position.x, position.y, position.z / 8, clearanceHeight, edge, &wallAcrossTrack)) {
|
||||
if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks)
|
||||
{
|
||||
if (!WallCheckObstruction(wallEntry,
|
||||
position.x,
|
||||
position.y,
|
||||
position.z / 8,
|
||||
clearanceHeight,
|
||||
edge,
|
||||
&wallAcrossTrack))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
if (!map_check_free_elements_and_reorganise(1)){
|
||||
if (!map_check_free_elements_and_reorganise(1))
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY){
|
||||
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
rct_xyz16 coord;
|
||||
coord.x = position.x + 16;
|
||||
coord.y = position.y + 16;
|
||||
|
@ -426,7 +530,7 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint
|
|||
network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord);
|
||||
}
|
||||
|
||||
rct_map_element* mapElement = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0);
|
||||
rct_map_element * mapElement = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0);
|
||||
assert(mapElement != NULL);
|
||||
|
||||
map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8);
|
||||
|
@ -439,20 +543,24 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint
|
|||
mapElement->properties.wall.colour_1 |= (secondaryColour & 7) << 5;
|
||||
mapElement->flags |= (secondaryColour & 0x18) << 2;
|
||||
|
||||
if (wallAcrossTrack) {
|
||||
if (wallAcrossTrack)
|
||||
{
|
||||
mapElement->properties.wall.animation |= (1 << 2);
|
||||
}
|
||||
|
||||
mapElement->properties.wall.type = wallType;
|
||||
if (bannerIndex != 0xFF){
|
||||
if (bannerIndex != 0xFF)
|
||||
{
|
||||
mapElement->properties.wall.banner_index = bannerIndex;
|
||||
}
|
||||
|
||||
if (wallEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){
|
||||
if (wallEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
|
||||
{
|
||||
mapElement->properties.wall.colour_3 = tertiaryColour;
|
||||
}
|
||||
|
||||
if (flags & (1 << 6)){
|
||||
if (flags & (1 << 6))
|
||||
{
|
||||
mapElement->flags |= MAP_ELEMENT_FLAG_GHOST;
|
||||
}
|
||||
|
||||
|
@ -460,32 +568,44 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint
|
|||
map_invalidate_tile_zoom1(position.x, position.y, mapElement->base_height * 8, mapElement->base_height * 8 + 72);
|
||||
}
|
||||
|
||||
if (gParkFlags & PARK_FLAGS_NO_MONEY){
|
||||
if (gParkFlags & PARK_FLAGS_NO_MONEY)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
return wallEntry->wall.price;
|
||||
}
|
||||
}
|
||||
|
||||
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){
|
||||
if(!(flags & GAME_COMMAND_FLAG_GHOST) &&
|
||||
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(!(flags & GAME_COMMAND_FLAG_GHOST) &&
|
||||
!(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 {
|
||||
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)
|
||||
|
@ -497,13 +617,16 @@ money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8
|
|||
|
||||
wallFound = true;
|
||||
break;
|
||||
} while (!map_element_is_last_for_tile(wallElement++));
|
||||
}
|
||||
while (!map_element_is_last_for_tile(wallElement++));
|
||||
|
||||
if (!(flags & GAME_COMMAND_FLAG_APPLY) || (wallFound == false)) {
|
||||
if (!(flags & GAME_COMMAND_FLAG_APPLY) || (wallFound == false))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) {
|
||||
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
rct_xyz16 coord;
|
||||
coord.x = x + 16;
|
||||
coord.y = y + 16;
|
||||
|
@ -517,7 +640,14 @@ money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8
|
|||
return 0;
|
||||
}
|
||||
|
||||
money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 primaryColour, uint8 secondaryColour, uint8 tertiaryColour, uint8 flags)
|
||||
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;
|
||||
|
@ -528,23 +658,27 @@ money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uin
|
|||
|
||||
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);
|
||||
rct_map_element * wallElement = map_get_wall_element_at(x, y, baseHeight, direction);
|
||||
|
||||
if (wallElement == NULL) {
|
||||
if (wallElement == NULL)
|
||||
{
|
||||
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){
|
||||
rct_scenery_entry* scenery_entry = get_wall_entry(wallElement->properties.wall.type);
|
||||
if(flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
rct_scenery_entry * scenery_entry = get_wall_entry(wallElement->properties.wall.type);
|
||||
wallElement->properties.wall.colour_1 &= 0xE0;
|
||||
wallElement->properties.wall.colour_1 |= primaryColour;
|
||||
wallElement->properties.wall.colour_1 &= 0x1F;
|
||||
|
@ -552,7 +686,8 @@ money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uin
|
|||
wallElement->properties.wall.colour_1 |= (secondaryColour & 0x7) * 32;
|
||||
wallElement->flags |= (secondaryColour & 0x18) * 4;
|
||||
|
||||
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;
|
||||
}
|
||||
map_invalidate_tile_zoom1(x, y, z, z + 72);
|
||||
|
@ -563,7 +698,7 @@ money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uin
|
|||
|
||||
extern "C"
|
||||
{
|
||||
uint8 wall_get_animation_frame(rct_map_element *wallElement) {
|
||||
uint8 wall_get_animation_frame(rct_map_element * wallElement) {
|
||||
return (wallElement->properties.wall.animation >> 3) & 0xF;
|
||||
}
|
||||
|
||||
|
@ -573,13 +708,14 @@ extern "C"
|
|||
*/
|
||||
void wall_remove_at(sint32 x, sint32 y, sint32 z0, sint32 z1)
|
||||
{
|
||||
rct_map_element *mapElement;
|
||||
rct_map_element * mapElement;
|
||||
|
||||
z0 /= 8;
|
||||
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;
|
||||
if (z0 >= mapElement->clearance_height)
|
||||
|
@ -591,7 +727,8 @@ 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++));
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -609,10 +746,11 @@ extern "C"
|
|||
*/
|
||||
void wall_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction)
|
||||
{
|
||||
rct_map_element *mapElement;
|
||||
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;
|
||||
|
||||
|
@ -626,14 +764,22 @@ 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++));
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 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,
|
||||
*eax & 0xFFFF,
|
||||
|
@ -647,9 +793,16 @@ 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;
|
||||
|
@ -666,7 +819,13 @@ extern "C"
|
|||
*
|
||||
* rct2: 0x006E5597
|
||||
*/
|
||||
void game_command_remove_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp)
|
||||
void game_command_remove_wall(sint32 * eax,
|
||||
sint32 * ebx,
|
||||
sint32 * ecx,
|
||||
sint32 * edx,
|
||||
sint32 * esi,
|
||||
sint32 * edi,
|
||||
sint32 * ebp)
|
||||
{
|
||||
*ebx = WallRemove(
|
||||
*eax & 0xFFFF,
|
||||
|
@ -681,7 +840,13 @@ extern "C"
|
|||
*
|
||||
* rct2: 0x006E56B5
|
||||
*/
|
||||
void game_command_set_wall_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp)
|
||||
void game_command_set_wall_colour(sint32 * eax,
|
||||
sint32 * ebx,
|
||||
sint32 * ecx,
|
||||
sint32 * edx,
|
||||
sint32 * esi,
|
||||
sint32 * edi,
|
||||
sint32 * ebp)
|
||||
{
|
||||
*ebx = WallSetColour(
|
||||
*eax & 0xFFFF,
|
||||
|
|
Loading…
Reference in New Issue