2014-04-09 04:09:30 +02:00
|
|
|
/*****************************************************************************
|
2014-05-03 11:34:11 +02:00
|
|
|
* Copyright (c) 2014 Ted John, Peter Hill
|
2014-04-09 04:09:30 +02:00
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* This file is part of OpenRCT2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2014-04-09 04:09:30 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2014-04-09 04:09:30 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../addresses.h"
|
2015-04-14 23:17:19 +02:00
|
|
|
#include "../audio/audio.h"
|
2015-07-12 02:46:52 +02:00
|
|
|
#include "../cheats.h"
|
|
|
|
#include "../config.h"
|
|
|
|
#include "../cursors.h"
|
2015-01-27 22:18:30 +01:00
|
|
|
#include "../game.h"
|
2015-02-13 21:55:49 +01:00
|
|
|
#include "../interface/window.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../localisation/date.h"
|
2014-11-04 04:34:12 +01:00
|
|
|
#include "../localisation/localisation.h"
|
2015-02-08 15:31:37 +01:00
|
|
|
#include "../management/finance.h"
|
2015-09-06 18:36:55 +02:00
|
|
|
#include "../openrct2.h"
|
2015-09-10 23:16:41 +02:00
|
|
|
#include "../ride/ride_data.h"
|
2015-09-06 18:36:55 +02:00
|
|
|
#include "../ride/track.h"
|
|
|
|
#include "../ride/track_data.h"
|
2015-03-22 18:04:30 +01:00
|
|
|
#include "../scenario.h"
|
2015-02-13 21:55:49 +01:00
|
|
|
#include "banner.h"
|
2014-04-09 12:16:35 +02:00
|
|
|
#include "climate.h"
|
2015-04-25 16:55:12 +02:00
|
|
|
#include "footpath.h"
|
2014-04-09 04:09:30 +02:00
|
|
|
#include "map.h"
|
2015-04-22 23:47:59 +02:00
|
|
|
#include "map_animation.h"
|
2014-11-04 04:34:12 +01:00
|
|
|
#include "park.h"
|
|
|
|
#include "scenery.h"
|
2015-07-12 02:46:52 +02:00
|
|
|
|
2015-12-12 21:08:09 +01:00
|
|
|
/**
|
|
|
|
* Replaces 0x00993CCC, 0x00993CCE
|
|
|
|
*/
|
2014-12-17 21:45:27 +01:00
|
|
|
const rct_xy16 TileDirectionDelta[] = {
|
|
|
|
{ -32, 0 },
|
|
|
|
{ 0, +32 },
|
|
|
|
{ +32, 0 },
|
|
|
|
{ 0, -32 },
|
|
|
|
{ -32, +32 },
|
|
|
|
{ +32, +32 },
|
|
|
|
{ +32, -32 },
|
|
|
|
{ -32, -32 }
|
|
|
|
};
|
|
|
|
|
2015-07-14 00:49:39 +02:00
|
|
|
rct_map_element *gMapElements = (rct_map_element*)RCT2_ADDRESS_MAP_ELEMENTS;
|
|
|
|
rct_map_element **gMapElementTilePointers = (rct_map_element**)RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS;
|
2014-12-17 21:45:27 +01:00
|
|
|
rct_xy16 *gMapSelectionTiles = (rct_xy16*)0x009DE596;
|
2015-07-01 16:17:25 +02:00
|
|
|
rct2_peep_spawn *gPeepSpawns = (rct2_peep_spawn*)RCT2_ADDRESS_PEEP_SPAWNS;
|
2014-12-17 21:45:27 +01:00
|
|
|
|
2015-10-11 13:26:33 +02:00
|
|
|
bool gLandMountainMode;
|
|
|
|
bool gLandPaintMode;
|
2015-05-15 17:28:27 +02:00
|
|
|
bool LandRightsMode;
|
2015-06-05 18:38:52 +02:00
|
|
|
bool gClearSmallScenery;
|
|
|
|
bool gClearLargeScenery;
|
|
|
|
bool gClearFootpath;
|
2015-05-12 17:37:16 +02:00
|
|
|
|
2014-04-09 18:06:47 +02:00
|
|
|
static void tiles_init();
|
2015-03-22 18:04:30 +01:00
|
|
|
static void map_update_grass_length(int x, int y, rct_map_element *mapElement);
|
|
|
|
static void map_set_grass_length(int x, int y, rct_map_element *mapElement, int length);
|
2015-06-20 17:24:38 +02:00
|
|
|
static void sub_68AE2A(int x, int y);
|
2015-07-09 17:04:24 +02:00
|
|
|
static void translate_3d_to_2d(int rotation, int *x, int *y);
|
2015-09-06 18:36:55 +02:00
|
|
|
static void map_obstruction_set_error_text(rct_map_element *mapElement);
|
2014-04-09 04:09:30 +02:00
|
|
|
|
2015-07-06 19:57:36 +02:00
|
|
|
void rotate_map_coordinates(sint16 *x, sint16 *y, int rotation)
|
|
|
|
{
|
2015-05-19 23:08:51 +02:00
|
|
|
int temp;
|
2015-07-06 19:57:36 +02:00
|
|
|
|
|
|
|
switch (rotation) {
|
2015-05-19 23:08:51 +02:00
|
|
|
case MAP_ELEMENT_DIRECTION_WEST:
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_NORTH:
|
|
|
|
temp = *x;
|
|
|
|
*x = *y;
|
|
|
|
*y = -temp;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_EAST:
|
|
|
|
*x = -*x;
|
|
|
|
*y = -*y;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_SOUTH:
|
|
|
|
temp = *y;
|
|
|
|
*y = *x;
|
|
|
|
*x = -temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-23 03:37:06 +02:00
|
|
|
rct_xy16 coordinate_3d_to_2d(const rct_xyz16* coordinate_3d, int rotation){
|
2015-06-21 17:22:09 +02:00
|
|
|
rct_xy16 coordinate_2d;
|
|
|
|
|
|
|
|
switch (rotation){
|
|
|
|
case 0:
|
|
|
|
coordinate_2d.x = coordinate_3d->y - coordinate_3d->x;
|
|
|
|
coordinate_2d.y = (coordinate_3d->y + coordinate_3d->x) / 2 - coordinate_3d->z;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
coordinate_2d.x = -coordinate_3d->y - coordinate_3d->x;
|
|
|
|
coordinate_2d.y = (coordinate_3d->y - coordinate_3d->x) / 2 - coordinate_3d->z;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
coordinate_2d.x = -coordinate_3d->y + coordinate_3d->x;
|
|
|
|
coordinate_2d.y = (-coordinate_3d->y - coordinate_3d->x) / 2 - coordinate_3d->z;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
coordinate_2d.x = coordinate_3d->y + coordinate_3d->x;
|
|
|
|
coordinate_2d.y = (-coordinate_3d->y + coordinate_3d->x) / 2 - coordinate_3d->z;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return coordinate_2d;
|
|
|
|
}
|
|
|
|
|
2015-01-22 01:19:05 +01:00
|
|
|
void map_element_iterator_begin(map_element_iterator *it)
|
|
|
|
{
|
|
|
|
it->x = 0;
|
|
|
|
it->y = 0;
|
|
|
|
it->element = map_get_first_element_at(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int map_element_iterator_next(map_element_iterator *it)
|
|
|
|
{
|
|
|
|
if (it->element == NULL) {
|
|
|
|
it->element = map_get_first_element_at(it->x, it->y);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!map_element_is_last_for_tile(it->element)) {
|
|
|
|
it->element++;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it->x < 255) {
|
|
|
|
it->x++;
|
|
|
|
it->element = map_get_first_element_at(it->x, it->y);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it->y < 255) {
|
|
|
|
it->x = 0;
|
|
|
|
it->y++;
|
|
|
|
it->element = map_get_first_element_at(it->x, it->y);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void map_element_iterator_restart_for_tile(map_element_iterator *it)
|
|
|
|
{
|
|
|
|
it->element = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element *map_get_first_element_at(int x, int y)
|
|
|
|
{
|
2015-10-20 20:16:30 +02:00
|
|
|
if (x < 0 || y < 0 || x > 255 || y > 255) {
|
2015-06-27 16:17:54 +02:00
|
|
|
log_error("Trying to access element outside of range");
|
2015-01-29 18:45:08 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
2015-01-22 01:19:05 +01:00
|
|
|
return TILE_MAP_ELEMENT_POINTER(x + y * 256);
|
|
|
|
}
|
|
|
|
|
2015-06-27 16:17:54 +02:00
|
|
|
void map_set_tile_elements(int x, int y, rct_map_element *elements)
|
|
|
|
{
|
2015-10-20 20:16:30 +02:00
|
|
|
if (x < 0 || y < 0 || x > 255 || y > 255) {
|
2015-06-27 16:17:54 +02:00
|
|
|
log_error("Trying to access element outside of range");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TILE_MAP_ELEMENT_POINTER(x + y * 256) = elements;
|
|
|
|
}
|
|
|
|
|
2015-01-22 01:19:05 +01:00
|
|
|
int map_element_is_last_for_tile(rct_map_element *element)
|
|
|
|
{
|
|
|
|
return element->flags & MAP_ELEMENT_FLAG_LAST_TILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int map_element_get_type(rct_map_element *element)
|
|
|
|
{
|
|
|
|
return element->type & MAP_ELEMENT_TYPE_MASK;
|
|
|
|
}
|
|
|
|
|
2015-06-27 16:17:54 +02:00
|
|
|
int map_element_get_direction(rct_map_element *element)
|
|
|
|
{
|
|
|
|
return element->type & MAP_ELEMENT_DIRECTION_MASK;
|
|
|
|
}
|
|
|
|
|
2014-09-18 00:42:18 +02:00
|
|
|
int map_element_get_terrain(rct_map_element *element)
|
|
|
|
{
|
|
|
|
int terrain = (element->properties.surface.terrain >> 5) & 7;
|
|
|
|
if (element->type & 1)
|
|
|
|
terrain |= (1 << 3);
|
|
|
|
return terrain;
|
|
|
|
}
|
|
|
|
|
|
|
|
int map_element_get_terrain_edge(rct_map_element *element)
|
|
|
|
{
|
|
|
|
int terrain_edge = (element->properties.surface.slope >> 5) & 7;
|
|
|
|
if (element->type & 128)
|
|
|
|
terrain_edge |= (1 << 3);
|
|
|
|
return terrain_edge;
|
|
|
|
}
|
|
|
|
|
2014-04-13 23:23:56 +02:00
|
|
|
void map_element_set_terrain(rct_map_element *element, int terrain)
|
|
|
|
{
|
|
|
|
// Bit 3 for terrain is stored in element.type bit 0
|
|
|
|
if (terrain & 8)
|
|
|
|
element->type |= 1;
|
|
|
|
else
|
|
|
|
element->type &= ~1;
|
|
|
|
|
|
|
|
// Bits 0, 1, 2 for terrain are stored in element.terrain bit 5, 6, 7
|
|
|
|
element->properties.surface.terrain &= ~0xE0;
|
2015-02-13 04:29:40 +01:00
|
|
|
element->properties.surface.terrain |= (terrain & 7) << 5;
|
2014-04-13 23:23:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void map_element_set_terrain_edge(rct_map_element *element, int terrain)
|
|
|
|
{
|
2014-09-18 00:42:18 +02:00
|
|
|
// Bit 3 for terrain is stored in element.type bit 7
|
2014-04-13 23:23:56 +02:00
|
|
|
if (terrain & 8)
|
|
|
|
element->type |= 128;
|
|
|
|
else
|
|
|
|
element->type &= ~128;
|
|
|
|
|
|
|
|
// Bits 0, 1, 2 for terrain are stored in element.slope bit 5, 6, 7
|
|
|
|
element->properties.surface.slope &= ~0xE0;
|
2014-09-18 00:42:18 +02:00
|
|
|
element->properties.surface.slope |= (terrain & 7) << 5;
|
2014-04-13 23:23:56 +02:00
|
|
|
}
|
|
|
|
|
2014-05-03 22:34:22 +02:00
|
|
|
rct_map_element *map_get_surface_element_at(int x, int y)
|
|
|
|
{
|
2015-01-22 01:19:05 +01:00
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x, y);
|
2014-05-03 22:34:22 +02:00
|
|
|
|
2015-05-17 08:58:51 +02:00
|
|
|
if (mapElement == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2014-05-03 22:34:22 +02:00
|
|
|
// Find the first surface element
|
2015-01-22 01:19:05 +01:00
|
|
|
while (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SURFACE) {
|
|
|
|
if (map_element_is_last_for_tile(mapElement))
|
2014-05-03 22:34:22 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
mapElement++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
}
|
|
|
|
|
2015-05-04 19:08:22 +02:00
|
|
|
rct_map_element* map_get_path_element_at(int x, int y, int z){
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x, y);
|
|
|
|
|
2015-05-17 08:58:51 +02:00
|
|
|
if (mapElement == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2015-05-04 19:08:22 +02:00
|
|
|
// Find the path element at known z
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
|
|
|
|
continue;
|
|
|
|
if (mapElement->base_height != z)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-11-13 19:30:14 +01:00
|
|
|
|
|
|
|
rct_map_element* map_get_banner_element_at(int x, int y, int z, uint8 position) {
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x, y);
|
|
|
|
|
|
|
|
if (mapElement == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Find the banner element at known z and position
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_BANNER)
|
|
|
|
continue;
|
|
|
|
if (mapElement->base_height != z)
|
|
|
|
continue;
|
|
|
|
if (mapElement->properties.banner.position != position)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-04-09 04:09:30 +02:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-04-09 04:09:30 +02:00
|
|
|
* rct2: 0x0068AB4C
|
|
|
|
*/
|
2015-02-09 19:32:58 +01:00
|
|
|
void map_init(int size)
|
2014-04-09 04:09:30 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
rct_map_element *map_element;
|
|
|
|
|
2014-04-09 12:16:35 +02:00
|
|
|
date_reset();
|
2014-04-09 04:09:30 +02:00
|
|
|
RCT2_GLOBAL(0x0138B580, sint16) = 0;
|
|
|
|
RCT2_GLOBAL(0x010E63B8, sint32) = 0;
|
|
|
|
|
2014-04-09 18:06:47 +02:00
|
|
|
for (i = 0; i < MAX_TILE_MAP_ELEMENT_POINTERS; i++) {
|
2014-04-09 04:09:30 +02:00
|
|
|
map_element = GET_MAP_ELEMENT(i);
|
2014-04-24 19:53:42 +02:00
|
|
|
map_element->type = (MAP_ELEMENT_TYPE_SURFACE << 2);
|
2014-04-10 05:02:06 +02:00
|
|
|
map_element->flags = MAP_ELEMENT_FLAG_LAST_TILE;
|
|
|
|
map_element->base_height = 14;
|
|
|
|
map_element->clearance_height = 14;
|
2014-04-24 19:53:42 +02:00
|
|
|
map_element->properties.surface.slope = 0;
|
2014-04-10 05:02:06 +02:00
|
|
|
map_element->properties.surface.grass_length = 1;
|
|
|
|
map_element->properties.surface.ownership = 0;
|
2015-02-13 04:29:40 +01:00
|
|
|
map_element->properties.surface.terrain = 0;
|
2014-04-13 23:23:56 +02:00
|
|
|
|
|
|
|
map_element_set_terrain(map_element, TERRAIN_GRASS);
|
2014-04-24 19:53:42 +02:00
|
|
|
map_element_set_terrain_edge(map_element, TERRAIN_EDGE_ROCK);
|
2014-04-09 04:09:30 +02:00
|
|
|
}
|
|
|
|
|
2015-03-22 18:04:30 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GRASS_SCENERY_TILEPOS, sint16) = 0;
|
2015-07-07 03:07:47 +02:00
|
|
|
RCT2_GLOBAL(0x013CE774, sint16) = 0;
|
|
|
|
RCT2_GLOBAL(0x013CE776, sint16) = 0;
|
2015-06-13 19:58:58 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) = size * 32 - 32;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, sint16) = size * 32 - 2;
|
2015-02-09 19:32:58 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16) = size;
|
2015-06-13 19:58:58 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, sint16) = size * 32 - 33;
|
2014-04-09 04:09:30 +02:00
|
|
|
RCT2_GLOBAL(0x01359208, sint16) = 7;
|
2014-04-10 16:14:47 +02:00
|
|
|
map_update_tile_pointers();
|
2015-07-02 01:37:55 +02:00
|
|
|
map_remove_out_of_range_elements();
|
2014-04-09 12:16:35 +02:00
|
|
|
climate_reset(CLIMATE_WARM);
|
2014-04-09 18:06:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-04-09 18:06:47 +02:00
|
|
|
* rct2: 0x0068AFFD
|
|
|
|
*/
|
2014-04-10 16:14:47 +02:00
|
|
|
void map_update_tile_pointers()
|
2014-04-09 18:06:47 +02:00
|
|
|
{
|
2015-01-22 01:19:05 +01:00
|
|
|
int i, x, y;
|
2014-04-09 18:06:47 +02:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_TILE_MAP_ELEMENT_POINTERS; i++)
|
|
|
|
TILE_MAP_ELEMENT_POINTER(i) = TILE_UNDEFINED_MAP_ELEMENT;
|
|
|
|
|
|
|
|
rct_map_element *mapElement = RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element);
|
|
|
|
rct_map_element **tile = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*);
|
|
|
|
for (y = 0; y < 256; y++) {
|
|
|
|
for (x = 0; x < 256; x++) {
|
|
|
|
*tile++ = mapElement;
|
2015-11-14 12:56:13 +01:00
|
|
|
while (!map_element_is_last_for_tile(mapElement++));
|
2014-04-09 18:06:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-14 12:56:13 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) = mapElement;
|
2014-04-10 16:14:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-02 21:25:42 +02:00
|
|
|
* Return the absolute height of an element, given its (x,y) coordinates
|
2014-09-18 18:18:39 +02:00
|
|
|
*
|
2015-12-11 16:38:37 +01:00
|
|
|
* ax: x
|
|
|
|
* cx: y
|
|
|
|
* dx: return remember to & with 0xFFFF if you don't want water affecting results
|
2014-04-10 16:14:47 +02:00
|
|
|
* rct2: 0x00662783
|
|
|
|
*/
|
2014-05-02 21:25:42 +02:00
|
|
|
int map_element_height(int x, int y)
|
2014-04-10 16:14:47 +02:00
|
|
|
{
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
2014-05-02 21:25:42 +02:00
|
|
|
// Off the map
|
2015-09-21 18:41:09 +02:00
|
|
|
if ((unsigned)x >= 8192 || (unsigned)y >= 8192)
|
2014-04-10 16:14:47 +02:00
|
|
|
return 16;
|
|
|
|
|
2014-05-03 22:34:22 +02:00
|
|
|
// Truncate subtile coordinates
|
2014-05-02 21:25:42 +02:00
|
|
|
int x_tile = x & 0xFFFFFFE0;
|
|
|
|
int y_tile = y & 0xFFFFFFE0;
|
2014-04-10 16:14:47 +02:00
|
|
|
|
2014-05-03 22:34:22 +02:00
|
|
|
// Get the surface element for the tile
|
|
|
|
mapElement = map_get_surface_element_at(x_tile / 32, y_tile / 32);
|
2014-04-10 16:14:47 +02:00
|
|
|
|
2014-05-02 21:25:42 +02:00
|
|
|
uint32 height =
|
2014-04-10 16:14:47 +02:00
|
|
|
((mapElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK) << 20) |
|
|
|
|
(mapElement->base_height << 3);
|
|
|
|
|
2014-05-02 21:25:42 +02:00
|
|
|
uint32 slope = (mapElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK);
|
|
|
|
uint8 extra_height = (slope & 0x10) >> 4; // 0x10 is the 5th bit - sets slope to double height
|
2014-05-03 10:24:25 +02:00
|
|
|
// Remove the extra height bit
|
2014-05-02 21:25:42 +02:00
|
|
|
slope &= 0xF;
|
|
|
|
|
2014-08-24 15:52:38 +02:00
|
|
|
sint8 quad, quad_extra; // which quadrant the element is in?
|
2014-05-03 10:22:20 +02:00
|
|
|
// quad_extra is for extra height tiles
|
2014-05-02 21:25:42 +02:00
|
|
|
|
2014-05-03 10:24:25 +02:00
|
|
|
uint8 xl, yl; // coordinates across this tile
|
2014-05-02 21:25:42 +02:00
|
|
|
|
|
|
|
uint8 TILE_SIZE = 31;
|
|
|
|
|
|
|
|
xl = x & 0x1f;
|
|
|
|
yl = y & 0x1f;
|
|
|
|
|
2014-05-03 10:24:25 +02:00
|
|
|
// Slope logic:
|
|
|
|
// Each of the four bits in slope represents that corner being raised
|
|
|
|
// slope == 15 (all four bits) is not used and slope == 0 is flat
|
|
|
|
// If the extra_height bit is set, then the slope goes up two z-levels
|
|
|
|
|
|
|
|
// We arbitrarily take the SW corner to be closest to the viewer
|
2014-05-02 21:25:42 +02:00
|
|
|
|
|
|
|
// One corner up
|
|
|
|
if ((slope == 1) || (slope == 2) || (slope == 4) || (slope == 8)) {
|
2014-05-03 10:24:25 +02:00
|
|
|
switch (slope) {
|
|
|
|
case 1: // NE corner up
|
|
|
|
quad = xl + yl - TILE_SIZE;
|
|
|
|
break;
|
|
|
|
case 2: // SE corner up
|
|
|
|
quad = xl - yl;
|
|
|
|
break;
|
|
|
|
case 4: // SW corner up
|
|
|
|
quad = TILE_SIZE - yl - xl;
|
|
|
|
break;
|
|
|
|
case 8: // NW corner up
|
2014-08-24 15:52:38 +02:00
|
|
|
quad = yl - xl;
|
2014-05-03 10:24:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// If the element is in the quadrant with the slope, raise its height
|
|
|
|
if (quad > 0) {
|
|
|
|
height += quad / 2;
|
|
|
|
}
|
2014-05-02 21:25:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// One side up
|
2014-05-03 10:24:25 +02:00
|
|
|
switch (slope) {
|
2014-05-02 21:25:42 +02:00
|
|
|
case 3: // E side up
|
2014-08-24 18:38:30 +02:00
|
|
|
height += xl / 2 + 1;
|
2014-05-03 10:24:25 +02:00
|
|
|
break;
|
2014-05-02 21:25:42 +02:00
|
|
|
case 6: // S side up
|
2014-05-03 10:24:25 +02:00
|
|
|
height += (TILE_SIZE - yl) / 2;
|
|
|
|
break;
|
2014-05-02 21:25:42 +02:00
|
|
|
case 9: // N side up
|
2014-05-03 10:24:25 +02:00
|
|
|
height += yl / 2;
|
|
|
|
height++;
|
|
|
|
break;
|
2014-05-02 21:25:42 +02:00
|
|
|
case 12: // W side up
|
2014-05-03 10:24:25 +02:00
|
|
|
height += (TILE_SIZE - xl) / 2;
|
|
|
|
break;
|
2014-05-02 21:25:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// One corner down
|
|
|
|
if ((slope == 7) || (slope == 11) || (slope == 13) || (slope == 14)) {
|
2014-05-03 10:24:25 +02:00
|
|
|
switch (slope) {
|
|
|
|
case 7: // NW corner down
|
|
|
|
quad_extra = xl + TILE_SIZE - yl;
|
|
|
|
quad = xl - yl;
|
|
|
|
break;
|
|
|
|
case 11: // SW corner down
|
|
|
|
quad_extra = xl + yl;
|
2014-08-24 18:38:30 +02:00
|
|
|
quad = xl + yl - TILE_SIZE - 1;
|
2014-05-03 10:24:25 +02:00
|
|
|
break;
|
|
|
|
case 13: // SE corner down
|
|
|
|
quad_extra = TILE_SIZE - xl + yl;
|
2014-08-24 18:38:30 +02:00
|
|
|
quad = yl - xl;
|
2014-05-03 10:24:25 +02:00
|
|
|
break;
|
|
|
|
case 14: // NE corner down
|
|
|
|
quad_extra = (TILE_SIZE - xl) + (TILE_SIZE - yl);
|
2014-08-24 15:52:38 +02:00
|
|
|
quad = TILE_SIZE - yl - xl - 1;
|
2014-05-03 10:24:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (extra_height) {
|
|
|
|
height += quad_extra / 2;
|
|
|
|
height++;
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
// This tile is essentially at the next height level
|
|
|
|
height += 0x10;
|
|
|
|
// so we move *down* the slope
|
|
|
|
if (quad < 0) {
|
|
|
|
height += quad / 2;
|
|
|
|
}
|
2014-05-02 21:25:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Valleys
|
2014-05-03 10:22:20 +02:00
|
|
|
if ((slope == 5) || (slope == 10)) {
|
2014-05-03 10:24:25 +02:00
|
|
|
switch (slope) {
|
|
|
|
case 5: // NW-SE valley
|
|
|
|
if (xl + yl <= TILE_SIZE + 1) {
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
quad = TILE_SIZE - xl - yl;
|
|
|
|
break;
|
|
|
|
case 10: // NE-SW valley
|
|
|
|
quad = xl - yl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (quad > 0) {
|
|
|
|
height += quad / 2;
|
|
|
|
}
|
2014-05-02 21:25:42 +02:00
|
|
|
}
|
2014-04-10 16:14:47 +02:00
|
|
|
|
2014-05-02 21:25:42 +02:00
|
|
|
return height;
|
2014-04-21 11:27:48 +02:00
|
|
|
}
|
2014-05-04 19:51:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B089
|
|
|
|
*/
|
|
|
|
void sub_68B089()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
rct_map_element *mapElementFirst, *mapElement;
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
i = RCT2_GLOBAL(0x0010E63B8, uint32);
|
|
|
|
do {
|
|
|
|
i++;
|
|
|
|
if (i >= MAX_TILE_MAP_ELEMENT_POINTERS)
|
|
|
|
i = 0;
|
2014-05-12 02:45:45 +02:00
|
|
|
} while (TILE_MAP_ELEMENT_POINTER(i) == TILE_UNDEFINED_MAP_ELEMENT);
|
2014-05-04 19:51:36 +02:00
|
|
|
RCT2_GLOBAL(0x0010E63B8, uint32) = i;
|
|
|
|
|
|
|
|
mapElementFirst = mapElement = TILE_MAP_ELEMENT_POINTER(i);
|
|
|
|
do {
|
|
|
|
mapElement--;
|
2014-05-12 02:45:45 +02:00
|
|
|
if (mapElement < (rct_map_element*)RCT2_ADDRESS_MAP_ELEMENTS)
|
2014-05-04 19:51:36 +02:00
|
|
|
break;
|
|
|
|
} while (mapElement->base_height == 255);
|
|
|
|
mapElement++;
|
|
|
|
|
|
|
|
if (mapElement == mapElementFirst)
|
|
|
|
return;
|
|
|
|
|
2015-10-20 20:16:30 +02:00
|
|
|
//
|
2014-05-04 19:51:36 +02:00
|
|
|
TILE_MAP_ELEMENT_POINTER(i) = mapElement;
|
|
|
|
do {
|
|
|
|
*mapElement = *mapElementFirst;
|
|
|
|
mapElementFirst->base_height = 255;
|
|
|
|
|
|
|
|
mapElementFirst++;
|
2015-11-14 12:56:13 +01:00
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
2014-05-04 19:51:36 +02:00
|
|
|
|
2015-11-14 12:56:13 +01:00
|
|
|
mapElement = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*);
|
2014-05-04 19:51:36 +02:00
|
|
|
do {
|
|
|
|
mapElement--;
|
|
|
|
} while (mapElement->base_height == 255);
|
|
|
|
mapElement++;
|
2015-11-14 12:56:13 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) = mapElement;
|
2014-05-26 15:22:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the tile at coordinate at height counts as connected.
|
2014-06-08 06:14:55 +02:00
|
|
|
* @return 1 if connected, 0 otherwise
|
2014-05-26 15:22:52 +02:00
|
|
|
*/
|
2015-01-22 01:19:05 +01:00
|
|
|
int map_coord_is_connected(int x, int y, int z, uint8 faceDirection)
|
2014-05-26 15:22:52 +02:00
|
|
|
{
|
2015-01-22 01:19:05 +01:00
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x, y);
|
2014-05-26 15:22:52 +02:00
|
|
|
|
2015-01-22 01:19:05 +01:00
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
|
|
|
|
continue;
|
2014-05-26 15:22:52 +02:00
|
|
|
|
2015-01-22 01:19:05 +01:00
|
|
|
rct_map_element_path_properties props = mapElement->properties.path;
|
|
|
|
uint8 pathType = props.type >> 2;
|
|
|
|
uint8 pathDirection = props.type & 3;
|
2014-05-26 15:22:52 +02:00
|
|
|
|
2015-01-22 01:19:05 +01:00
|
|
|
if (pathType & 1) {
|
|
|
|
if (pathDirection == faceDirection) {
|
|
|
|
if (z == mapElement->base_height + 2)
|
2014-05-26 15:22:52 +02:00
|
|
|
return 1;
|
2015-01-22 01:19:05 +01:00
|
|
|
} else if ((pathDirection ^ 2) == faceDirection && z == mapElement->base_height) {
|
2014-05-26 15:22:52 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2015-01-22 01:19:05 +01:00
|
|
|
} else {
|
|
|
|
if (z == mapElement->base_height)
|
2014-05-26 15:22:52 +02:00
|
|
|
return 1;
|
2015-01-22 01:19:05 +01:00
|
|
|
}
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
2014-05-26 15:22:52 +02:00
|
|
|
|
2015-01-22 01:19:05 +01:00
|
|
|
return 0;
|
2014-05-26 15:22:52 +02:00
|
|
|
}
|
|
|
|
|
2014-10-09 21:31:58 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006A876D
|
|
|
|
*/
|
2015-11-14 01:08:31 +01:00
|
|
|
void map_update_path_wide_flags()
|
2014-10-09 21:31:58 +02:00
|
|
|
{
|
|
|
|
int i, x, y;
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
|
|
|
|
return;
|
|
|
|
|
2015-07-30 23:57:15 +02:00
|
|
|
// Presumebly update_path_wide_flags is too computationally expensive to call for every
|
2014-10-09 21:31:58 +02:00
|
|
|
// tile every update, so word_13CE774 and word_13CE776 store the x and y
|
|
|
|
// progress. A maximum of 128 calls is done per update.
|
2015-07-07 03:07:47 +02:00
|
|
|
x = RCT2_GLOBAL(0x013CE774, sint16);
|
|
|
|
y = RCT2_GLOBAL(0x013CE776, sint16);
|
2014-10-09 21:31:58 +02:00
|
|
|
for (i = 0; i < 128; i++) {
|
2015-11-14 01:12:19 +01:00
|
|
|
footpath_update_path_wide_flags(x, y);
|
2014-10-09 21:31:58 +02:00
|
|
|
|
|
|
|
// Next x, y tile
|
|
|
|
x += 32;
|
|
|
|
if (x >= 8192) {
|
|
|
|
x = 0;
|
|
|
|
y += 32;
|
|
|
|
if (y >= 8192)
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-07-07 03:07:47 +02:00
|
|
|
RCT2_GLOBAL(0x013CE774, sint16) = x;
|
|
|
|
RCT2_GLOBAL(0x013CE776, sint16) = y;
|
2014-10-09 21:31:58 +02:00
|
|
|
}
|
|
|
|
|
2014-12-10 02:44:30 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006A7B84
|
|
|
|
*/
|
|
|
|
int map_height_from_slope(int x, int y, int slope)
|
|
|
|
{
|
|
|
|
if (!(slope & 4))
|
|
|
|
return 0;
|
2014-09-20 15:06:42 +02:00
|
|
|
|
2014-12-10 02:44:30 +01:00
|
|
|
switch (slope & 3) {
|
2014-09-20 15:06:42 +02:00
|
|
|
case 0:
|
|
|
|
return (31 - (x & 31)) / 2;
|
|
|
|
case 1:
|
|
|
|
return (y & 31) / 2;
|
|
|
|
case 2:
|
|
|
|
return (x & 31) / 2;
|
|
|
|
case 3:
|
|
|
|
return (31 - (y & 31)) / 2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-02 02:41:00 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00664F72
|
|
|
|
*/
|
2015-01-15 00:38:48 +01:00
|
|
|
int map_is_location_owned(int x, int y, int z)
|
2014-11-02 02:41:00 +01:00
|
|
|
{
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
2016-01-03 00:49:08 +01:00
|
|
|
// This check is to avoid throwing lots of messages in logs.
|
2014-11-02 02:41:00 +01:00
|
|
|
if (x < (256 * 32) && y < (256 * 32)) {
|
|
|
|
mapElement = map_get_surface_element_at(x / 32, y / 32);
|
2016-01-03 00:49:08 +01:00
|
|
|
if (mapElement != NULL) {
|
|
|
|
if (mapElement->properties.surface.ownership & OWNERSHIP_OWNED)
|
2014-09-20 15:06:42 +02:00
|
|
|
return 1;
|
2016-01-03 00:49:08 +01:00
|
|
|
|
|
|
|
if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) {
|
|
|
|
z /= 8;
|
|
|
|
if (z < mapElement->base_height || z - 2 > mapElement->base_height)
|
|
|
|
return 1;
|
|
|
|
}
|
2014-09-20 15:06:42 +02:00
|
|
|
}
|
2014-10-11 20:21:37 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 17:01:31 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_LAND_NOT_OWNED_BY_PARK;
|
2014-11-02 02:41:00 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00664F2C
|
|
|
|
*/
|
|
|
|
int map_is_location_in_park(int x, int y)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
|
|
|
if (x < (256 * 32) && y < (256 * 32)) {
|
|
|
|
mapElement = map_get_surface_element_at(x / 32, y / 32);
|
2015-10-04 01:35:26 +02:00
|
|
|
if (mapElement == NULL)
|
|
|
|
return 0;
|
2014-12-10 02:44:30 +01:00
|
|
|
if (mapElement->properties.surface.ownership & OWNERSHIP_OWNED)
|
|
|
|
return 1;
|
2014-10-11 20:21:37 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 17:01:31 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_LAND_NOT_OWNED_BY_PARK;
|
2014-11-02 02:41:00 +01:00
|
|
|
return 0;
|
2014-11-02 04:37:56 +01:00
|
|
|
}
|
2014-10-11 20:21:37 +02:00
|
|
|
|
2015-08-04 17:01:31 +02:00
|
|
|
bool map_is_location_owned_or_has_rights(int x, int y)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
|
|
|
if (x < (256 * 32) && y < (256 * 32)) {
|
|
|
|
mapElement = map_get_surface_element_at(x / 32, y / 32);
|
|
|
|
if (mapElement->properties.surface.ownership & OWNERSHIP_OWNED) return true;
|
|
|
|
if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-04 04:34:12 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E0E01
|
|
|
|
*/
|
2015-04-16 04:02:47 +02:00
|
|
|
void game_command_remove_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
2014-11-04 04:34:12 +01:00
|
|
|
{
|
2015-04-16 04:02:47 +02:00
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 base_height = *edx;
|
|
|
|
uint8 scenery_type = *edx >> 8;
|
|
|
|
uint8 map_element_type = *ebx >> 8;
|
2015-11-14 01:08:31 +01:00
|
|
|
uint8 flags = *ebx & 0xFF;
|
2014-11-04 04:34:12 +01:00
|
|
|
money32 cost;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-04-16 04:02:47 +02:00
|
|
|
rct_scenery_entry *entry = g_smallSceneryEntries[scenery_type];
|
2016-01-03 00:49:08 +01:00
|
|
|
if (entry == (rct_scenery_entry *)0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
log_warning("Invalid game command for scenery removal, scenery_type = %u", scenery_type);
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2014-11-04 04:34:12 +01:00
|
|
|
cost = entry->small_scenery.removal_price * 10;
|
|
|
|
|
2015-02-08 15:31:37 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = base_height * 8;
|
2014-11-04 04:34:12 +01:00
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
if (!(flags & GAME_COMMAND_FLAG_GHOST) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) {
|
2014-11-04 04:34:12 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
2015-04-16 04:02:47 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !(flags & GAME_COMMAND_FLAG_GHOST) && !gCheatsSandboxMode) {
|
2014-11-04 04:34:12 +01:00
|
|
|
// Check if allowed to remove item
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_TREE_REMOVAL) {
|
|
|
|
if (entry->small_scenery.height > 64) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY;
|
2015-04-16 04:02:47 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the land is owned
|
2015-08-17 00:25:17 +02:00
|
|
|
if (!map_is_location_owned(x, y, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32))){
|
2015-04-16 04:02:47 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
bool sceneryFound = false;
|
2015-04-16 04:02:47 +02:00
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
2015-11-14 01:08:31 +01:00
|
|
|
do {
|
|
|
|
if (map_element->type != map_element_type)
|
|
|
|
continue;
|
|
|
|
if (map_element->base_height != base_height)
|
|
|
|
continue;
|
|
|
|
if (map_element->properties.scenery.type != scenery_type)
|
|
|
|
continue;
|
|
|
|
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sceneryFound = true;
|
|
|
|
break;
|
|
|
|
} while (!map_element_is_last_for_tile(map_element++));
|
|
|
|
|
|
|
|
if (sceneryFound == false){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
2015-04-16 04:02:47 +02:00
|
|
|
}
|
2014-11-04 04:34:12 +01:00
|
|
|
|
|
|
|
// Remove element
|
2015-11-14 01:08:31 +01:00
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
2014-11-05 03:55:29 +01:00
|
|
|
map_invalidate_tile_full(x, y);
|
2015-04-16 04:02:47 +02:00
|
|
|
map_element_remove(map_element);
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
2015-04-16 04:02:47 +02:00
|
|
|
*ebx = (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY ? 0 : cost);
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
|
|
|
|
2015-04-17 08:47:23 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B8E1B
|
|
|
|
*/
|
|
|
|
void game_command_remove_large_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
uint8 base_height = *edx;
|
2015-11-14 01:08:31 +01:00
|
|
|
uint8 tileIndex = *edx >> 8;
|
2015-04-17 08:47:23 +02:00
|
|
|
uint8 map_element_direction = *ebx >> 8;
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
int z = map_element_height(x, y);
|
2015-11-14 01:08:31 +01:00
|
|
|
uint8 flags = *ebx & 0xFF;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = z;
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
if (!(flags & GAME_COMMAND_FLAG_GHOST) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) {
|
2015-04-17 08:47:23 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
bool element_found = false;
|
2015-04-17 08:47:23 +02:00
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
2016-01-03 00:49:08 +01:00
|
|
|
if (map_element == NULL)
|
|
|
|
{
|
|
|
|
log_warning("Invalid game command for scenery removal, x = %d, y = %d", x, y);
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-05-19 23:08:51 +02:00
|
|
|
do {
|
|
|
|
if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (map_element->base_height != base_height)
|
|
|
|
continue;
|
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
if ((map_element->properties.scenerymultiple.type >> 10) != tileIndex)
|
2015-05-19 23:08:51 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) != map_element_direction)
|
|
|
|
continue;
|
|
|
|
|
2015-06-27 10:52:00 +02:00
|
|
|
// If we are removing ghost elements
|
2015-11-14 01:08:31 +01:00
|
|
|
if((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST))
|
2015-06-27 10:52:00 +02:00
|
|
|
continue;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
element_found = true;
|
2015-05-19 23:08:51 +02:00
|
|
|
break;
|
|
|
|
} while (!map_element_is_last_for_tile(map_element++));
|
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
if (element_found == false){
|
2015-05-19 23:08:51 +02:00
|
|
|
*ebx = 0;
|
|
|
|
return;
|
2015-04-17 08:47:23 +02:00
|
|
|
}
|
2015-05-19 23:08:51 +02:00
|
|
|
|
2015-06-15 22:56:26 +02:00
|
|
|
map_element_remove_banner_entry(map_element);
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-15 22:56:26 +02:00
|
|
|
rct_scenery_entry* scenery_entry = g_largeSceneryEntries[map_element->properties.scenerymultiple.type & 0x3FF];
|
2015-10-20 20:16:30 +02:00
|
|
|
rct_xyz16 firstTile = {
|
2015-11-14 01:08:31 +01:00
|
|
|
.x = scenery_entry->large_scenery.tiles[tileIndex].x_offset,
|
|
|
|
.y = scenery_entry->large_scenery.tiles[tileIndex].y_offset,
|
|
|
|
.z = (base_height * 8) - scenery_entry->large_scenery.tiles[tileIndex].z_offset
|
2015-05-19 23:08:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
rotate_map_coordinates(&firstTile.x, &firstTile.y, map_element_direction);
|
|
|
|
|
|
|
|
firstTile.x = x - firstTile.x;
|
|
|
|
firstTile.y = y - firstTile.y;
|
|
|
|
|
2015-11-10 20:04:36 +01:00
|
|
|
bool calculate_cost = true;
|
2015-05-19 23:08:51 +02:00
|
|
|
for (int i = 0; scenery_entry->large_scenery.tiles[i].x_offset != -1; i++){
|
|
|
|
|
|
|
|
rct_xyz16 currentTile = {
|
|
|
|
.x = scenery_entry->large_scenery.tiles[i].x_offset,
|
|
|
|
.y = scenery_entry->large_scenery.tiles[i].y_offset,
|
|
|
|
.z = scenery_entry->large_scenery.tiles[i].z_offset
|
|
|
|
};
|
|
|
|
|
|
|
|
rotate_map_coordinates(¤tTile.x, ¤tTile.y, map_element_direction);
|
|
|
|
|
|
|
|
currentTile.x += firstTile.x;
|
|
|
|
currentTile.y += firstTile.y;
|
|
|
|
currentTile.z += firstTile.z;
|
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode){
|
2015-05-19 23:08:51 +02:00
|
|
|
if (!map_is_location_owned(currentTile.x, currentTile.y, currentTile.z)){
|
2015-04-17 08:47:23 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
}
|
|
|
|
|
2015-05-19 23:08:51 +02:00
|
|
|
// If not applying then no need to delete the actual element
|
2015-11-14 01:08:31 +01:00
|
|
|
if (!(flags & GAME_COMMAND_FLAG_APPLY)) {
|
|
|
|
if (flags & (1 << 7)) {
|
2015-11-10 20:04:36 +01:00
|
|
|
if (map_element->flags & (1 << 6))
|
|
|
|
calculate_cost = false;
|
|
|
|
map_element->flags |= (1 << 6);
|
|
|
|
}
|
2015-05-19 23:08:51 +02:00
|
|
|
continue;
|
2015-11-10 20:04:36 +01:00
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-05-19 23:08:51 +02:00
|
|
|
rct_map_element* sceneryElement = map_get_first_element_at(currentTile.x / 32, currentTile.y / 32);
|
2015-11-14 01:08:31 +01:00
|
|
|
element_found = false;
|
2015-05-19 23:08:51 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (map_element_get_type(sceneryElement) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE)
|
|
|
|
continue;
|
2015-05-07 20:16:00 +02:00
|
|
|
|
2015-05-19 23:08:51 +02:00
|
|
|
if ((sceneryElement->type & MAP_ELEMENT_DIRECTION_MASK) != map_element_direction)
|
|
|
|
continue;
|
2015-05-07 20:16:00 +02:00
|
|
|
|
2015-05-19 23:08:51 +02:00
|
|
|
if ((sceneryElement->properties.scenerymultiple.type >> 10) != i)
|
|
|
|
continue;
|
2015-05-07 20:16:00 +02:00
|
|
|
|
2015-05-19 23:08:51 +02:00
|
|
|
if (sceneryElement->base_height != currentTile.z / 8)
|
|
|
|
continue;
|
2015-05-07 20:16:00 +02:00
|
|
|
|
2015-06-27 10:52:00 +02:00
|
|
|
// If we are removing ghost elements
|
2015-11-14 01:08:31 +01:00
|
|
|
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(sceneryElement->flags & MAP_ELEMENT_FLAG_GHOST))
|
2015-06-27 10:52:00 +02:00
|
|
|
continue;
|
|
|
|
|
2015-05-19 23:08:51 +02:00
|
|
|
map_invalidate_tile_full(currentTile.x, currentTile.y);
|
|
|
|
map_element_remove(sceneryElement);
|
2015-11-14 01:08:31 +01:00
|
|
|
element_found = true;
|
2015-05-19 23:08:51 +02:00
|
|
|
break;
|
|
|
|
} while (!map_element_is_last_for_tile(sceneryElement++));
|
2015-05-07 20:16:00 +02:00
|
|
|
|
2015-11-14 01:08:31 +01:00
|
|
|
if (element_found == false){
|
2015-05-19 23:08:51 +02:00
|
|
|
log_error("Tile not found when trying to remove element!");
|
2015-04-17 08:47:23 +02:00
|
|
|
}
|
|
|
|
}
|
2015-05-19 23:08:51 +02:00
|
|
|
|
|
|
|
*ebx = scenery_entry->large_scenery.removal_price * 10;
|
2016-01-02 15:52:37 +01:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY ||
|
2015-11-10 20:04:36 +01:00
|
|
|
calculate_cost == false){
|
2015-05-19 23:08:51 +02:00
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
return;
|
2015-04-17 08:47:23 +02:00
|
|
|
}
|
|
|
|
|
2015-04-22 09:46:44 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006BA058
|
|
|
|
*/
|
|
|
|
void game_command_remove_banner(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 base_height = *edx;
|
|
|
|
uint8 banner_position = *edx >> 8;
|
2015-11-13 19:30:14 +01:00
|
|
|
uint8 flags = *ebx & 0xFF;
|
2015-04-22 09:46:44 +02:00
|
|
|
int z = base_height * 8;
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = z;
|
2015-11-13 19:30:14 +01:00
|
|
|
|
|
|
|
if(!(flags & GAME_COMMAND_FLAG_GHOST) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode){
|
2015-04-22 09:46:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-11-13 19:30:14 +01:00
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, z - 16)){
|
2015-04-22 09:46:44 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-11-13 19:30:14 +01:00
|
|
|
|
|
|
|
// Slight modification to the code so that it now checks height as well
|
|
|
|
// This was causing a bug with banners on two paths stacked.
|
|
|
|
rct_map_element* map_element = map_get_banner_element_at(x / 32, y / 32, base_height, banner_position);
|
|
|
|
if (map_element == NULL){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
2015-04-22 09:46:44 +02:00
|
|
|
}
|
2015-11-13 19:30:14 +01:00
|
|
|
|
2015-04-22 23:47:59 +02:00
|
|
|
rct_banner *banner = &gBanners[map_element->properties.banner.index];
|
2015-11-13 19:30:14 +01:00
|
|
|
rct_scenery_entry *scenery_entry = g_bannerSceneryEntries[banner->type];
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
2015-06-15 22:56:26 +02:00
|
|
|
map_element_remove_banner_entry(map_element);
|
2015-07-06 19:57:36 +02:00
|
|
|
map_invalidate_tile_zoom1(x, y, z, z + 32);
|
2015-04-22 09:46:44 +02:00
|
|
|
map_element_remove(map_element);
|
|
|
|
}
|
2015-11-13 19:30:14 +01:00
|
|
|
|
2015-04-22 09:46:44 +02:00
|
|
|
*ebx = (scenery_entry->banner.price * -3) / 4;
|
2015-11-13 19:30:14 +01:00
|
|
|
|
2015-04-22 09:46:44 +02:00
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-17 22:56:19 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E0F26
|
|
|
|
*/
|
|
|
|
void game_command_set_scenery_colour(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-04-18 07:01:50 +02:00
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
2015-04-17 22:56:19 +02:00
|
|
|
uint8 base_height = *edx;
|
|
|
|
uint8 scenery_type = *edx >> 8;
|
|
|
|
uint8 color1 = *ebp;
|
|
|
|
uint8 color2 = *ebp >> 8;
|
2015-11-12 20:22:08 +01:00
|
|
|
uint8 flags = *ebx & 0xFF;
|
2015-04-17 22:56:19 +02:00
|
|
|
int z = base_height * 8;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = z;
|
2015-11-12 20:22:08 +01:00
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode){
|
2015-05-07 19:57:14 +02:00
|
|
|
if (!map_is_location_owned(x, y, z)){
|
2015-04-17 22:56:19 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
}
|
|
|
|
|
2015-11-12 20:22:08 +01:00
|
|
|
// Previously it would do a search for type of bh (set from calling function) instead of just small scenery
|
|
|
|
// Unsure if this was a mistake.
|
|
|
|
rct_map_element* map_element = map_get_small_scenery_element_at(x, y, base_height, scenery_type);
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-12 20:22:08 +01:00
|
|
|
if (map_element == NULL) {
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
2015-04-17 22:56:19 +02:00
|
|
|
}
|
2015-05-30 13:24:27 +02:00
|
|
|
|
2015-11-12 20:22:08 +01:00
|
|
|
if((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)){
|
2015-05-07 19:57:14 +02:00
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
2015-11-12 20:22:08 +01:00
|
|
|
|
|
|
|
if(flags & GAME_COMMAND_FLAG_APPLY){
|
2015-05-07 19:57:14 +02:00
|
|
|
map_element->properties.scenery.colour_1 &= 0xE0;
|
|
|
|
map_element->properties.scenery.colour_1 |= color1;
|
|
|
|
map_element->properties.scenery.colour_2 &= 0xE0;
|
|
|
|
map_element->properties.scenery.colour_2 |= color2;
|
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-04-17 22:56:19 +02:00
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
2015-04-18 07:01:50 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E56B5
|
|
|
|
*/
|
|
|
|
void game_command_set_fence_colour(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-04-18 07:01:50 +02:00
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 map_element_direction = *edx;
|
|
|
|
uint8 base_height = *edx >> 8;
|
|
|
|
uint8 color1 = *ebx >> 8;
|
|
|
|
uint8 color2 = *ebp;
|
|
|
|
uint8 color3 = *ebp >> 8;
|
2015-11-12 20:22:08 +01:00
|
|
|
uint8 flags = *ebx & 0xFF;
|
2015-04-18 07:01:50 +02:00
|
|
|
int z = base_height * 8;
|
2015-11-12 20:22:08 +01:00
|
|
|
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = z;
|
2015-11-12 20:22:08 +01:00
|
|
|
|
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) &&
|
|
|
|
!map_is_location_in_park(x, y) &&
|
|
|
|
!gCheatsSandboxMode) {
|
|
|
|
|
2015-06-21 13:42:31 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
2015-11-12 20:22:08 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool fence_found = false;
|
|
|
|
rct_map_element* map_element = map_get_fence_element_at(x, y, base_height, map_element_direction);
|
|
|
|
|
|
|
|
if (map_element == NULL) {
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) {
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(flags & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
rct_scenery_entry* scenery_entry = g_wallSceneryEntries[map_element->properties.fence.type];
|
|
|
|
map_element->properties.fence.item[1] &= 0xE0;
|
|
|
|
map_element->properties.fence.item[1] |= color1;
|
2016-01-02 15:52:37 +01:00
|
|
|
map_element->properties.fence.item[1] &= 0x1F;
|
2015-11-12 20:22:08 +01:00
|
|
|
map_element->flags &= 0x9F;
|
|
|
|
map_element->properties.fence.item[1] |= (color2 & 0x7) * 32;
|
|
|
|
map_element->flags |= (color2 & 0x18) * 4;
|
|
|
|
|
|
|
|
if(scenery_entry->wall.flags & 0x80){
|
|
|
|
map_element->properties.fence.item[0] = color3;
|
|
|
|
}
|
|
|
|
map_invalidate_tile_zoom1(x, y, z, z + 72);
|
2015-04-18 07:01:50 +02:00
|
|
|
}
|
2015-11-12 20:22:08 +01:00
|
|
|
|
|
|
|
*ebx = 0;
|
2015-04-18 07:01:50 +02:00
|
|
|
}
|
|
|
|
|
2015-04-18 21:03:18 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B909A
|
|
|
|
*/
|
|
|
|
void game_command_set_large_scenery_colour(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-04-18 21:03:18 +02:00
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 map_element_direction = *ebx >> 8;
|
2015-11-11 21:24:59 +01:00
|
|
|
uint8 flags = *ebx & 0xFF;
|
2015-04-18 21:03:18 +02:00
|
|
|
uint8 base_height = *edx;
|
2015-11-11 21:24:59 +01:00
|
|
|
uint8 tileIndex = *edx >> 8;
|
2015-04-18 21:03:18 +02:00
|
|
|
uint8 color1 = *ebp;
|
|
|
|
uint8 color2 = *ebp >> 8;
|
|
|
|
int z = map_element_height(x, y);
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = z;
|
2015-04-18 21:03:18 +02:00
|
|
|
|
2015-11-11 21:24:59 +01:00
|
|
|
rct_map_element *map_element = map_get_large_scenery_segment(x, y, base_height, map_element_direction, tileIndex);
|
2015-04-18 21:03:18 +02:00
|
|
|
|
2015-11-11 21:24:59 +01:00
|
|
|
if(map_element == NULL){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
2015-04-18 21:03:18 +02:00
|
|
|
}
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-11 21:24:59 +01:00
|
|
|
if((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)){
|
2015-04-18 21:03:18 +02:00
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
2015-11-11 21:24:59 +01:00
|
|
|
|
2016-01-11 21:00:22 +01:00
|
|
|
rct_scenery_entry *scenery_entry = g_largeSceneryEntries[map_element->properties.scenerymultiple.type & 0x3FF];
|
2015-11-11 21:24:59 +01:00
|
|
|
|
|
|
|
// Work out the base tile coordinates (Tile with index 0)
|
|
|
|
rct_xyz16 baseTile = {
|
|
|
|
.x = scenery_entry->large_scenery.tiles[tileIndex].x_offset,
|
|
|
|
.y = scenery_entry->large_scenery.tiles[tileIndex].y_offset,
|
|
|
|
.z = (base_height * 8) - scenery_entry->large_scenery.tiles[tileIndex].z_offset
|
|
|
|
};
|
|
|
|
rotate_map_coordinates(&baseTile.x, &baseTile.y, map_element_direction);
|
|
|
|
baseTile.x = x - baseTile.x;
|
|
|
|
baseTile.y = y - baseTile.y;
|
|
|
|
|
|
|
|
for (int i = 0; scenery_entry->large_scenery.tiles[i].x_offset != -1; ++i) {
|
|
|
|
assert(i < 256);
|
|
|
|
|
|
|
|
// Work out the current tile coordinates
|
|
|
|
rct_xyz16 currentTile = {
|
|
|
|
.x = scenery_entry->large_scenery.tiles[i].x_offset,
|
|
|
|
.y = scenery_entry->large_scenery.tiles[i].y_offset,
|
|
|
|
.z = scenery_entry->large_scenery.tiles[i].z_offset
|
|
|
|
};
|
|
|
|
rotate_map_coordinates(¤tTile.x, ¤tTile.y, map_element_direction);
|
|
|
|
currentTile.x += baseTile.x;
|
|
|
|
currentTile.y += baseTile.y;
|
|
|
|
currentTile.z += baseTile.z;
|
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode){
|
2015-11-11 21:24:59 +01:00
|
|
|
if (!map_is_location_owned(currentTile.x, currentTile.y, currentTile.z)){
|
2015-04-18 21:03:18 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
}
|
|
|
|
|
2015-11-11 21:24:59 +01:00
|
|
|
if(flags & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
rct_map_element* mapElement = map_get_large_scenery_segment(
|
2016-01-02 15:52:37 +01:00
|
|
|
currentTile.x,
|
|
|
|
currentTile.y,
|
|
|
|
base_height,
|
|
|
|
map_element_direction,
|
2015-11-11 21:24:59 +01:00
|
|
|
i);
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-11-11 21:24:59 +01:00
|
|
|
mapElement->properties.scenerymultiple.colour[0] &= 0xE0;
|
|
|
|
mapElement->properties.scenerymultiple.colour[0] |= color1;
|
|
|
|
mapElement->properties.scenerymultiple.colour[1] &= 0xE0;
|
|
|
|
mapElement->properties.scenerymultiple.colour[1] |= color2;
|
|
|
|
|
|
|
|
map_invalidate_tile_full(currentTile.x, currentTile.y);
|
|
|
|
}
|
2015-04-18 21:03:18 +02:00
|
|
|
}
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
2015-04-18 23:48:17 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006BA16A
|
|
|
|
*/
|
|
|
|
void game_command_set_banner_colour(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-04-18 23:48:17 +02:00
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 base_height = *edx;
|
|
|
|
uint8 banner_position = *edx >> 8;
|
|
|
|
uint8 color = *ebp;
|
|
|
|
int z = (base_height * 8);
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = z;
|
2015-04-18 23:48:17 +02:00
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode){
|
2015-05-07 19:57:14 +02:00
|
|
|
if (!map_is_location_owned(x, y, z - 16)){
|
2015-04-18 23:48:17 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
2015-11-11 21:24:59 +01:00
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_BANNER)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (map_element->properties.banner.position != banner_position)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
} while (!map_element_is_last_for_tile(map_element++));
|
|
|
|
|
|
|
|
if (found == false){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
2015-04-18 23:48:17 +02:00
|
|
|
}
|
2015-11-11 21:24:59 +01:00
|
|
|
|
2015-05-07 19:57:14 +02:00
|
|
|
rct_window* window = window_find_by_number(WC_BANNER, map_element->properties.banner.index);
|
|
|
|
if(window){
|
|
|
|
window_invalidate(window);
|
|
|
|
}
|
|
|
|
gBanners[map_element->properties.banner.index].colour = color;
|
2015-07-06 19:57:36 +02:00
|
|
|
map_invalidate_tile_zoom1(x, y, z, z + 32);
|
2015-04-18 23:48:17 +02:00
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-04-18 23:48:17 +02:00
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
2014-11-04 04:34:12 +01:00
|
|
|
// This will cause clear scenery to remove paths
|
|
|
|
// This should be a flag for the game command which can be set via a checkbox on the clear scenery window.
|
|
|
|
// #define CLEAR_SCENERY_REMOVES_PATHS
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068DFE4
|
|
|
|
*/
|
2015-07-18 19:22:59 +02:00
|
|
|
money32 map_clear_scenery_from_tile(int x, int y, int clear, int flags)
|
2014-11-04 04:34:12 +01:00
|
|
|
{
|
|
|
|
int type;
|
|
|
|
money32 cost, totalCost;
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
|
|
|
totalCost = 0;
|
|
|
|
|
|
|
|
restart_from_beginning:
|
2015-01-22 01:19:05 +01:00
|
|
|
mapElement = map_get_first_element_at(x, y);
|
2014-11-04 04:34:12 +01:00
|
|
|
do {
|
2015-01-22 01:19:05 +01:00
|
|
|
type = map_element_get_type(mapElement);
|
2014-11-04 04:34:12 +01:00
|
|
|
switch (type) {
|
|
|
|
case MAP_ELEMENT_TYPE_PATH:
|
2015-07-18 19:22:59 +02:00
|
|
|
if (clear & (1 << 2)) {
|
|
|
|
int eax = x * 32;
|
|
|
|
int ebx = flags;
|
|
|
|
int ecx = y * 32;
|
|
|
|
int edx = mapElement->base_height;
|
2015-08-14 23:06:15 +02:00
|
|
|
int edi = 0, ebp = 0;
|
2015-07-18 19:22:59 +02:00
|
|
|
cost = game_do_command(eax, ebx, ecx, edx, GAME_COMMAND_REMOVE_PATH, edi, ebp);
|
|
|
|
|
2015-06-05 18:38:52 +02:00
|
|
|
if (cost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
|
|
|
|
totalCost += cost;
|
|
|
|
if (flags & 1)
|
|
|
|
goto restart_from_beginning;
|
|
|
|
} break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY:
|
2015-07-18 19:22:59 +02:00
|
|
|
if (clear & (1 << 0)) {
|
2015-06-05 18:38:52 +02:00
|
|
|
int eax = x * 32;
|
|
|
|
int ebx = (mapElement->type << 8) | flags;
|
|
|
|
int ecx = y * 32;
|
|
|
|
int edx = (mapElement->properties.scenery.type << 8) | (mapElement->base_height);
|
2015-08-14 23:06:15 +02:00
|
|
|
int edi = 0, ebp = 0;
|
2015-07-18 19:22:59 +02:00
|
|
|
cost = game_do_command(eax, ebx, ecx, edx, GAME_COMMAND_REMOVE_SCENERY, edi, ebp);
|
2015-06-05 18:38:52 +02:00
|
|
|
|
|
|
|
if (cost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
|
|
|
|
totalCost += cost;
|
|
|
|
if (flags & 1)
|
|
|
|
goto restart_from_beginning;
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MAP_ELEMENT_TYPE_FENCE:
|
2015-07-18 19:22:59 +02:00
|
|
|
if (clear & (1 << 0)) {
|
2015-06-05 18:38:52 +02:00
|
|
|
int eax = x * 32;
|
|
|
|
int ebx = flags;
|
|
|
|
int ecx = y * 32;
|
|
|
|
int edx = (mapElement->base_height << 8) | (mapElement->type & MAP_ELEMENT_DIRECTION_MASK);
|
2015-08-14 23:06:15 +02:00
|
|
|
int edi = 0, ebp = 0;
|
2015-07-18 19:22:59 +02:00
|
|
|
cost = game_do_command(eax, ebx, ecx, edx, GAME_COMMAND_REMOVE_FENCE, edi, ebp);
|
2015-06-05 18:38:52 +02:00
|
|
|
|
|
|
|
if (cost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
|
|
|
|
totalCost += cost;
|
|
|
|
if (flags & 1)
|
|
|
|
goto restart_from_beginning;
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE:
|
2015-07-18 19:22:59 +02:00
|
|
|
if (clear & (1 << 1)) {
|
2015-06-05 18:38:52 +02:00
|
|
|
int eax = x * 32;
|
|
|
|
int ebx = flags | ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) << 8);
|
|
|
|
int ecx = y * 32;
|
|
|
|
int edx = mapElement->base_height | ((mapElement->properties.scenerymultiple.type >> 10) << 8);
|
2015-08-14 23:06:15 +02:00
|
|
|
int edi = 0, ebp = 0;
|
2015-11-10 20:04:36 +01:00
|
|
|
cost = game_do_command(eax, ebx | (1 << 7), ecx, edx, GAME_COMMAND_REMOVE_LARGE_SCENERY, edi, ebp);
|
2015-06-05 18:38:52 +02:00
|
|
|
|
|
|
|
if (cost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
|
|
|
|
totalCost += cost;
|
|
|
|
if (flags & 1)
|
|
|
|
goto restart_from_beginning;
|
|
|
|
|
|
|
|
} break;
|
2014-11-04 04:34:12 +01:00
|
|
|
break;
|
|
|
|
}
|
2015-01-22 01:19:05 +01:00
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
2014-11-04 04:34:12 +01:00
|
|
|
|
|
|
|
return totalCost;
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
* Function to clear the flag that is set to prevent cost duplication
|
2015-11-10 20:04:36 +01:00
|
|
|
* when using the clear scenery tool with large scenery.
|
|
|
|
*/
|
2015-11-10 20:38:48 +01:00
|
|
|
void map_reset_clear_large_scenery_flag(){
|
2015-11-10 20:04:36 +01:00
|
|
|
rct_map_element* mapElement;
|
2015-11-10 20:38:48 +01:00
|
|
|
// TODO: Improve efficiency of this
|
|
|
|
for (int y = 0; y <= 255; y++) {
|
|
|
|
for (int x = 0; x <= 255; x++) {
|
|
|
|
mapElement = map_get_first_element_at(x, y);
|
2015-11-10 20:04:36 +01:00
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_SCENERY_MULTIPLE) {
|
|
|
|
mapElement->flags &= ~(1 << 6);
|
|
|
|
}
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-18 19:22:59 +02:00
|
|
|
money32 map_clear_scenery(int x0, int y0, int x1, int y1, int clear, int flags)
|
2014-11-04 04:34:12 +01:00
|
|
|
{
|
|
|
|
int x, y, z;
|
|
|
|
money32 totalCost, cost;
|
2015-08-04 17:01:31 +02:00
|
|
|
bool noValidTiles;
|
2014-11-04 04:34:12 +01:00
|
|
|
|
2015-02-08 15:31:37 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2014-11-04 04:34:12 +01:00
|
|
|
|
|
|
|
x = (x0 + x1) / 2 + 16;
|
|
|
|
y = (y0 + y1) / 2 + 16;
|
|
|
|
z = map_element_height(x, y);
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = z;
|
2014-11-04 04:34:12 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
x0 = max(x0, 32);
|
|
|
|
y0 = max(y0, 32);
|
2015-06-13 19:58:58 +02:00
|
|
|
x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
|
|
|
y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
2014-11-04 04:34:12 +01:00
|
|
|
|
2015-08-04 17:01:31 +02:00
|
|
|
noValidTiles = true;
|
2014-11-04 04:34:12 +01:00
|
|
|
totalCost = 0;
|
2015-06-10 16:41:50 +02:00
|
|
|
for (y = y0; y <= y1; y += 32) {
|
|
|
|
for (x = x0; x <= x1; x += 32) {
|
2015-08-11 17:54:21 +02:00
|
|
|
if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode || map_is_location_owned_or_has_rights(x, y)) {
|
2015-08-07 17:11:10 +02:00
|
|
|
cost = map_clear_scenery_from_tile(x / 32, y / 32, clear, flags);
|
2015-08-04 17:01:31 +02:00
|
|
|
if (cost != MONEY32_UNDEFINED) {
|
|
|
|
noValidTiles = false;
|
|
|
|
totalCost += cost;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_LAND_NOT_OWNED_BY_PARK;
|
|
|
|
}
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-10 20:04:36 +01:00
|
|
|
if (clear & (1 << 1)) {
|
2015-11-10 20:38:48 +01:00
|
|
|
map_reset_clear_large_scenery_flag();
|
2015-11-10 20:04:36 +01:00
|
|
|
}
|
|
|
|
|
2015-08-04 17:01:31 +02:00
|
|
|
return noValidTiles ? MONEY32_UNDEFINED : totalCost;
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068DF91
|
|
|
|
*/
|
|
|
|
void game_command_clear_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
*ebx = map_clear_scenery(
|
2015-06-10 16:41:50 +02:00
|
|
|
(sint16)(*eax & 0xFFFF),
|
|
|
|
(sint16)(*ecx & 0xFFFF),
|
|
|
|
(sint16)(*edi & 0xFFFF),
|
|
|
|
(sint16)(*ebp & 0xFFFF),
|
2015-07-18 19:22:59 +02:00
|
|
|
*edx,
|
2014-11-04 04:34:12 +01:00
|
|
|
*ebx & 0xFF
|
|
|
|
);
|
2014-11-05 03:55:29 +01:00
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00663CCD
|
|
|
|
*/
|
2015-06-10 16:41:50 +02:00
|
|
|
money32 map_change_surface_style(int x0, int y0, int x1, int y1, uint8 surfaceStyle, uint8 edgeStyle, uint8 flags)
|
2015-01-10 17:40:27 +01:00
|
|
|
{
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
x0 = max(x0, 32);
|
|
|
|
y0 = max(y0, 32);
|
2015-06-13 19:58:58 +02:00
|
|
|
x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
|
|
|
y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
int xMid, yMid;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
xMid = (x0 + x1) / 2 + 16;
|
|
|
|
yMid = (y0 + y1) / 2 + 16;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
int heightMid = map_element_height(xMid, yMid);
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = xMid;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = yMid;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = heightMid;
|
2015-06-10 16:41:50 +02:00
|
|
|
RCT2_GLOBAL(0x009E32B4, uint32) = 0;
|
2015-01-11 14:37:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
money32 cost = 0;
|
2015-01-11 14:37:27 +01:00
|
|
|
|
2015-06-10 18:12:21 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) {
|
2015-06-10 16:41:50 +02:00
|
|
|
cost += RCT2_GLOBAL(0x009E32B4, uint32);
|
|
|
|
return (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) ? 0 : cost;
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES) {
|
2015-06-10 16:41:50 +02:00
|
|
|
cost += RCT2_GLOBAL(0x009E32B4, uint32);
|
|
|
|
return (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) ? 0 : cost;
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
for (int x = x0; x <= x1; x += 32) {
|
|
|
|
for (int y = y0; y <= y1; y += 32) {
|
|
|
|
if (x > 0x1FFF) continue;
|
|
|
|
if (y > 0x1FFF) continue;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) {
|
2015-06-10 16:41:50 +02:00
|
|
|
if (!map_is_location_in_park(x, y)) continue;
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
rct_map_element* mapElement = map_get_surface_element_at(x / 32, y / 32);
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
if (surfaceStyle != 0xFF){
|
2015-01-10 17:40:27 +01:00
|
|
|
uint8 cur_terrain = (
|
2015-06-10 16:41:50 +02:00
|
|
|
(mapElement->type&MAP_ELEMENT_DIRECTION_MASK) << 3) |
|
|
|
|
(mapElement->properties.surface.terrain >> 5);
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
if (surfaceStyle != cur_terrain) {
|
|
|
|
RCT2_GLOBAL(0x009E32B4, uint32) += RCT2_ADDRESS(0x0097B8B8, uint32)[surfaceStyle & 0x1F];
|
2015-01-10 17:40:27 +01:00
|
|
|
if (flags & 1){
|
2015-06-10 16:41:50 +02:00
|
|
|
mapElement->properties.surface.terrain &= MAP_ELEMENT_WATER_HEIGHT_MASK;
|
|
|
|
mapElement->type &= MAP_ELEMENT_QUADRANT_MASK | MAP_ELEMENT_TYPE_MASK;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
|
|
|
//Save the new terrain
|
2015-06-10 16:41:50 +02:00
|
|
|
mapElement->properties.surface.terrain |= surfaceStyle << 5;
|
|
|
|
|
2015-01-10 17:40:27 +01:00
|
|
|
//Save the new direction mask
|
2015-06-10 16:41:50 +02:00
|
|
|
mapElement->type |= (surfaceStyle >> 3) & MAP_ELEMENT_DIRECTION_MASK;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
|
|
|
map_invalidate_tile_full(x, y);
|
2015-06-29 18:22:01 +02:00
|
|
|
footpath_remove_litter(x, y, map_element_height(x, y));
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
if (edgeStyle != 0xFF) {
|
|
|
|
uint8 currentEdge =
|
|
|
|
((mapElement->type & 0x80) >> 4) |
|
|
|
|
(mapElement->properties.surface.slope >> 5);
|
2015-01-11 14:37:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
if (edgeStyle != currentEdge){
|
|
|
|
cost++;
|
2015-01-11 14:37:27 +01:00
|
|
|
|
|
|
|
if (flags & 1){
|
2015-06-10 16:41:50 +02:00
|
|
|
mapElement->properties.surface.slope &= MAP_ELEMENT_SLOPE_MASK;
|
|
|
|
mapElement->type &= 0x7F;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
//Save edge style
|
2015-06-10 16:41:50 +02:00
|
|
|
mapElement->properties.surface.slope |= edgeStyle << 5;
|
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
//Save ???
|
2015-06-10 16:41:50 +02:00
|
|
|
mapElement->type |= (edgeStyle << 4) & 0x80;
|
2015-01-11 14:37:27 +01:00
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
if (flags & 1) {
|
|
|
|
if (!(mapElement->properties.surface.terrain & MAP_ELEMENT_SURFACE_TERRAIN_MASK)) {
|
|
|
|
if (!(mapElement->type & MAP_ELEMENT_DIRECTION_MASK)) {
|
|
|
|
if ((mapElement->properties.surface.grass_length & 7) != GRASS_LENGTH_CLEAR_0) {
|
|
|
|
mapElement->properties.surface.grass_length = GRASS_LENGTH_CLEAR_0;
|
2015-01-11 14:37:27 +01:00
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
}
|
2015-01-11 14:37:27 +01:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
cost *= 100;
|
|
|
|
cost += RCT2_GLOBAL(0x009E32B4, uint32);
|
|
|
|
return (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) ? 0 : cost;
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00663CCD
|
|
|
|
*/
|
2015-06-10 16:41:50 +02:00
|
|
|
void game_command_change_surface_style(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
2015-01-11 14:37:27 +01:00
|
|
|
*ebx = map_change_surface_style(
|
2015-06-10 16:41:50 +02:00
|
|
|
(sint16)(*eax & 0xFFFF),
|
|
|
|
(sint16)(*ecx & 0xFFFF),
|
|
|
|
(sint16)(*edi & 0xFFFF),
|
|
|
|
(sint16)(*ebp & 0xFFFF),
|
2015-01-10 17:40:27 +01:00
|
|
|
*edx & 0xFF,
|
2015-01-11 14:37:27 +01:00
|
|
|
(*edx & 0xFF00) >> 8,
|
2015-01-10 17:40:27 +01:00
|
|
|
*ebx & 0xFF
|
2015-06-10 16:41:50 +02:00
|
|
|
);
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
|
2015-05-19 01:25:58 +02:00
|
|
|
//0x00981A1E
|
|
|
|
const uint8 map_element_raise_styles[5][32] = {
|
2015-06-10 16:41:50 +02:00
|
|
|
{ 0x01, 0x1B, 0x03, 0x1B, 0x05, 0x21, 0x07, 0x21, 0x09, 0x1B, 0x0B, 0x1B, 0x0D, 0x21, 0x20, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x23, 0x18, 0x19, 0x1A, 0x3B, 0x1C, 0x29, 0x24, 0x1F },
|
|
|
|
{ 0x02, 0x03, 0x17, 0x17, 0x06, 0x07, 0x17, 0x17, 0x0A, 0x0B, 0x22, 0x22, 0x0E, 0x20, 0x22, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x37, 0x18, 0x19, 0x1A, 0x23, 0x1C, 0x28, 0x26, 0x1F },
|
|
|
|
{ 0x04, 0x05, 0x06, 0x07, 0x1E, 0x24, 0x1E, 0x24, 0x0C, 0x0D, 0x0E, 0x20, 0x1E, 0x24, 0x1E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x26, 0x18, 0x19, 0x1A, 0x21, 0x1C, 0x2C, 0x3E, 0x1F },
|
|
|
|
{ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x20, 0x1D, 0x1D, 0x28, 0x28, 0x1D, 0x1D, 0x28, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x22, 0x18, 0x19, 0x1A, 0x29, 0x1C, 0x3D, 0x2C, 0x1F },
|
|
|
|
{ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x20, 0x20, 0x20, 0x21, 0x20, 0x28, 0x24, 0x20 },
|
|
|
|
};
|
|
|
|
|
|
|
|
//0x00981ABE
|
|
|
|
const uint8 map_element_lower_styles[5][32] = {
|
|
|
|
{ 0x2E, 0x00, 0x2E, 0x02, 0x3E, 0x04, 0x3E, 0x06, 0x2E, 0x08, 0x2E, 0x0A, 0x3E, 0x0C, 0x3E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x06, 0x18, 0x19, 0x1A, 0x0B, 0x1C, 0x0C, 0x3E, 0x1F },
|
|
|
|
{ 0x2D, 0x2D, 0x00, 0x01, 0x2D, 0x2D, 0x04, 0x05, 0x3D, 0x3D, 0x08, 0x09, 0x3D, 0x3D, 0x0C, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x07, 0x18, 0x19, 0x1A, 0x09, 0x1C, 0x3D, 0x0C, 0x1F },
|
|
|
|
{ 0x2B, 0x3B, 0x2B, 0x3B, 0x00, 0x01, 0x02, 0x03, 0x2B, 0x3B, 0x2B, 0x3B, 0x08, 0x09, 0x0A, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x03, 0x18, 0x19, 0x1A, 0x3B, 0x1C, 0x09, 0x0E, 0x1F },
|
|
|
|
{ 0x27, 0x27, 0x37, 0x37, 0x27, 0x27, 0x37, 0x37, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x37, 0x18, 0x19, 0x1A, 0x03, 0x1C, 0x0D, 0x06, 0x1F },
|
|
|
|
{ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x0D, 0x0E, 0x00 },
|
2015-05-19 01:25:58 +02:00
|
|
|
};
|
|
|
|
|
2015-07-12 02:46:52 +02:00
|
|
|
static money32 map_set_land_height(int flags, int x, int y, int height, int style, int selectionType)
|
2015-06-08 23:19:06 +02:00
|
|
|
{
|
2015-06-10 18:12:21 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) {
|
2015-06-08 23:19:06 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) {
|
2015-06-08 23:19:06 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:58:58 +02:00
|
|
|
if (x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16) || y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)) {
|
2015-06-08 23:19:06 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_OFF_EDGE_OF_MAP;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (height < 2) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_TOO_LOW;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (height > 62) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_TOO_HIGH;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
} else if (height == 62 && (style & 0x1F) != 0) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_TOO_HIGH;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (height == 60 && (style & 0x10)) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_TOO_HIGH;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) {
|
2015-06-08 23:19:06 +02:00
|
|
|
if (!map_is_location_in_park(x, y)) {
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
}
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-13 00:02:04 +01:00
|
|
|
//Uncomment to use vanilla code
|
2015-11-15 22:48:27 +01:00
|
|
|
/*
|
|
|
|
registers regs = {0};
|
|
|
|
regs.eax = x;
|
|
|
|
regs.ebx = flags;
|
|
|
|
regs.ecx = y;
|
|
|
|
regs.dl = height;
|
|
|
|
regs.dh = style;
|
|
|
|
regs.esi = 0;
|
|
|
|
regs.edi = selectionType << 5;
|
|
|
|
regs.ebp = 0;
|
|
|
|
RCT2_CALLFUNC_Y(0x006639FE, ®s); return regs.ebx;
|
|
|
|
*/
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-14 02:50:20 +01:00
|
|
|
RCT2_GLOBAL(0x9E2E18, money32) = MONEY(0, 0);
|
2015-11-15 22:48:27 +01:00
|
|
|
if(flags & GAME_COMMAND_FLAG_APPLY)
|
2015-11-13 00:02:04 +01:00
|
|
|
{
|
2015-11-14 02:50:20 +01:00
|
|
|
footpath_remove_litter(x, y, map_element_height(x, y));
|
2016-01-09 23:46:08 +01:00
|
|
|
if(!gCheatsDisableClearanceChecks)
|
|
|
|
map_remove_walls_at(x, y, height * 8 - 16, height * 8 + 32);
|
2015-11-13 00:02:04 +01:00
|
|
|
}
|
2015-11-14 02:50:20 +01:00
|
|
|
RCT2_GLOBAL(0x9E2E18, money32) += MONEY(20, 0);
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-15 22:48:27 +01:00
|
|
|
//Check for obstructing scenery
|
2016-01-02 15:52:37 +01:00
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
do{
|
2015-11-15 22:48:27 +01:00
|
|
|
if(map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SCENERY)
|
|
|
|
continue;
|
|
|
|
if(height > mapElement->clearance_height)
|
2015-11-13 20:48:21 +01:00
|
|
|
continue;
|
2015-11-15 22:48:27 +01:00
|
|
|
if(height + 4 < mapElement->base_height)
|
|
|
|
continue;
|
2016-01-11 21:00:22 +01:00
|
|
|
rct_scenery_entry *sceneryEntry = g_smallSceneryEntries[mapElement->properties.scenery.type]; //sceneryEntry = eax
|
2015-11-15 22:48:27 +01:00
|
|
|
if(sceneryEntry->small_scenery.height > 64 && RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_TREE_REMOVAL)
|
2015-11-13 00:02:04 +01:00
|
|
|
{
|
2015-11-13 20:48:21 +01:00
|
|
|
map_obstruction_set_error_text(mapElement);
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
2015-11-14 02:50:20 +01:00
|
|
|
RCT2_GLOBAL(0x9E2E18, money32) += MONEY(sceneryEntry->small_scenery.removal_price, 0);
|
2015-11-15 22:48:27 +01:00
|
|
|
if(flags & GAME_COMMAND_FLAG_APPLY)
|
2015-11-14 02:50:20 +01:00
|
|
|
map_element_remove(mapElement--);
|
|
|
|
}while(!map_element_is_last_for_tile(mapElement++));
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-16 19:09:11 +01:00
|
|
|
//Check for ride support limits
|
|
|
|
if(gCheatsDisableSupportLimits==false)
|
|
|
|
{
|
|
|
|
mapElement = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
do{
|
|
|
|
if(map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK)
|
|
|
|
continue;
|
|
|
|
int rideIndex = mapElement->properties.track.ride_index;
|
|
|
|
int maxHeight = GET_RIDE_ENTRY(GET_RIDE(rideIndex)->subtype)->max_height;
|
|
|
|
if(maxHeight == 0)
|
|
|
|
maxHeight = RCT2_GLOBAL(0x97D218 + 8 * GET_RIDE(rideIndex)->type, uint8);
|
|
|
|
int zDelta = mapElement->clearance_height - height;
|
|
|
|
if(zDelta >= 0 && zDelta/2 > maxHeight)
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_SUPPORTS_CANT_BE_EXTENDED;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
}while(!map_element_is_last_for_tile(mapElement++));
|
|
|
|
}
|
2015-06-08 23:19:06 +02:00
|
|
|
|
2015-11-15 22:48:27 +01:00
|
|
|
uint8 zCorner = height; //z position of highest corner of tile
|
|
|
|
rct_map_element *surfaceElement = map_get_surface_element_at(x / 32, y / 32);
|
|
|
|
if(surfaceElement->type & MAP_ELEMENT_TYPE_FLAG_HIGHLIGHT)
|
2015-11-13 00:02:04 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
int waterHeight = surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK;
|
|
|
|
if(waterHeight != 0)
|
2015-11-13 00:02:04 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
if(style & 0x1F)
|
2015-11-13 05:47:36 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
zCorner += 2;
|
|
|
|
if(style & 0x10)
|
2015-11-13 05:47:36 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
zCorner += 2;
|
2015-11-13 05:47:36 +01:00
|
|
|
}
|
|
|
|
}
|
2015-11-15 22:48:27 +01:00
|
|
|
if(zCorner > waterHeight * 2 - 2)
|
2015-11-13 05:47:36 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
surfaceElement++;
|
|
|
|
map_obstruction_set_error_text(surfaceElement);
|
2015-11-13 05:47:36 +01:00
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
2015-11-13 00:02:04 +01:00
|
|
|
}
|
|
|
|
}
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-15 22:48:27 +01:00
|
|
|
zCorner = height;
|
|
|
|
if(style & 0xF)
|
2015-11-13 00:02:04 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
zCorner += 2;
|
|
|
|
if(style & 0x10)
|
2015-11-13 00:02:04 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
zCorner += 2;
|
2015-11-13 00:02:04 +01:00
|
|
|
}
|
|
|
|
}
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-15 22:48:27 +01:00
|
|
|
if(map_can_construct_with_clear_at(x, y, height, zCorner, RCT2_ADDRESS(0x663CB9, void), 0xF) == false)
|
2015-11-13 00:02:04 +01:00
|
|
|
return MONEY32_UNDEFINED;
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-15 22:48:27 +01:00
|
|
|
mapElement = map_get_first_element_at(x / 32, y / 32);
|
2016-01-02 15:52:37 +01:00
|
|
|
do{
|
2015-11-15 22:48:27 +01:00
|
|
|
int elementType = map_element_get_type(mapElement);
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-15 22:48:27 +01:00
|
|
|
if(elementType == MAP_ELEMENT_TYPE_FENCE)
|
|
|
|
continue;
|
|
|
|
if(elementType == MAP_ELEMENT_TYPE_SCENERY)
|
|
|
|
continue;
|
|
|
|
if(mapElement->flags & 0x10)
|
|
|
|
continue;
|
|
|
|
if(mapElement == surfaceElement)
|
2015-11-15 18:01:34 +01:00
|
|
|
continue;
|
2015-11-15 22:48:27 +01:00
|
|
|
if(mapElement > surfaceElement)
|
2015-11-15 18:01:34 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
if(zCorner > mapElement->base_height)
|
2015-11-15 18:01:34 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
map_obstruction_set_error_text(mapElement);
|
2015-11-15 18:01:34 +01:00
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2015-11-15 22:48:27 +01:00
|
|
|
if(height < mapElement->clearance_height)
|
2015-11-15 18:01:34 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
map_obstruction_set_error_text(mapElement);
|
2015-11-15 18:01:34 +01:00
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
2015-11-15 22:48:27 +01:00
|
|
|
}while(!map_element_is_last_for_tile(mapElement++));
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-15 22:48:27 +01:00
|
|
|
if(flags & GAME_COMMAND_FLAG_APPLY)
|
2015-11-15 19:20:01 +01:00
|
|
|
{
|
2015-11-15 22:48:27 +01:00
|
|
|
surfaceElement = map_get_surface_element_at(x / 32, y / 32);
|
|
|
|
surfaceElement->base_height = height;
|
|
|
|
surfaceElement->clearance_height = height;
|
|
|
|
surfaceElement->properties.surface.slope &= MAP_ELEMENT_SLOPE_EDGE_STYLE_MASK;
|
|
|
|
surfaceElement->properties.surface.slope |= style;
|
|
|
|
int slope = surfaceElement->properties.surface.terrain & MAP_ELEMENT_SLOPE_MASK;
|
|
|
|
if(slope != 0 && slope <= height / 2)
|
|
|
|
surfaceElement->properties.surface.terrain &= MAP_ELEMENT_SURFACE_TERRAIN_MASK;
|
2015-11-15 19:20:01 +01:00
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
}
|
2015-11-15 22:48:27 +01:00
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
|
2015-11-15 19:20:01 +01:00
|
|
|
return 0;
|
|
|
|
return RCT2_GLOBAL(0x9E2E18, money32);
|
2015-06-08 23:19:06 +02:00
|
|
|
}
|
|
|
|
|
2015-07-12 02:46:52 +02:00
|
|
|
void game_command_set_land_height(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp)
|
|
|
|
{
|
|
|
|
*ebx = map_set_land_height(
|
|
|
|
*ebx & 0xFF,
|
|
|
|
*eax & 0xFFFF,
|
|
|
|
*ecx & 0xFFFF,
|
|
|
|
*edx & 0xFF,
|
|
|
|
(*edx >> 8) & 0xFF,
|
|
|
|
*edi >> 5
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-10-04 01:07:22 +02:00
|
|
|
money32 map_set_land_ownership(uint8 flags, sint16 x1, sint16 y1, sint16 x2, sint16 y2, uint8 newOwnership) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LAND_PURCHASE * 4;
|
|
|
|
|
|
|
|
if (!(flags & GAME_COMMAND_FLAG_APPLY))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x009E2E28, uint8) = 0;
|
|
|
|
|
2015-10-04 21:22:50 +02:00
|
|
|
for (sint16 y = y1; y <= y2; y += 32) {
|
|
|
|
for (sint16 x = x1; x <= x2; x += 32) {
|
2015-10-04 01:07:22 +02:00
|
|
|
if (x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16))
|
|
|
|
continue;
|
|
|
|
if (y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
map_buy_land_rights(x, y, x2, y2, 6, flags | (newOwnership << 8));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(RCT2_GLOBAL(0x9E2E28, uint8) & 1)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sint16 x = clamp(0, x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16));
|
|
|
|
sint16 y = clamp(0, y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16));
|
|
|
|
|
|
|
|
x += 16;
|
|
|
|
y += 16;
|
|
|
|
|
|
|
|
sint16 z = map_element_height(x, y) & 0xFFFF;
|
2015-11-18 01:03:15 +01:00
|
|
|
audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z);
|
2015-10-04 01:07:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006648E3
|
|
|
|
*/
|
2015-10-04 01:07:22 +02:00
|
|
|
void game_command_set_land_ownership(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp)
|
|
|
|
{
|
|
|
|
*ebx = map_set_land_ownership(
|
|
|
|
*ebx & 0xFF,
|
|
|
|
*eax & 0xFFFF,
|
|
|
|
*ecx & 0xFFFF,
|
|
|
|
*edi & 0xFFFF,
|
|
|
|
*ebp & 0xFFFF,
|
|
|
|
*edx & 0xFF
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int by, int selectionType)
|
2015-04-14 23:17:19 +02:00
|
|
|
{
|
2015-06-10 16:41:50 +02:00
|
|
|
money32 cost = 0;
|
2015-04-14 23:17:19 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
|
2015-11-18 01:03:15 +01:00
|
|
|
audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z);
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:19:02 +02:00
|
|
|
uint8 min_height = 0xFF;
|
2015-04-14 23:17:19 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
ax = max(ax, 32);
|
|
|
|
ay = max(ay, 32);
|
2015-06-13 19:58:58 +02:00
|
|
|
bx = min(bx, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
|
|
|
by = min(by, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
2015-06-10 16:41:50 +02:00
|
|
|
|
2015-04-14 23:17:19 +02:00
|
|
|
// find lowest map element in selection
|
2015-06-10 16:41:50 +02:00
|
|
|
for (int yi = ay; yi <= by; yi += 32) {
|
|
|
|
for (int xi = ax; xi <= bx; xi += 32) {
|
|
|
|
rct_map_element *map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
|
|
|
if (map_element != NULL && min_height > map_element->base_height) {
|
|
|
|
min_height = map_element->base_height;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
for (int yi = ay; yi <= by; yi += 32) {
|
|
|
|
for (int xi = ax; xi <= bx; xi += 32) {
|
|
|
|
rct_map_element *map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
|
|
|
if (map_element != NULL) {
|
2015-06-09 14:24:02 +02:00
|
|
|
uint8 height = map_element->base_height;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (height <= min_height){
|
|
|
|
uint8 newStyle = map_element_raise_styles[selectionType][map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK];
|
|
|
|
if (newStyle & 0x20) { // needs to be raised
|
2015-06-09 14:24:02 +02:00
|
|
|
height += 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
newStyle &= ~0x20;
|
2015-06-09 14:24:02 +02:00
|
|
|
}
|
2015-07-12 02:46:52 +02:00
|
|
|
money32 tileCost = map_set_land_height(flags, xi, yi, height, newStyle, selectionType);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (tileCost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
cost += tileCost;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-10 16:41:50 +02:00
|
|
|
|
2015-11-10 22:34:09 +01:00
|
|
|
// Force ride construction to recheck area
|
|
|
|
RCT2_GLOBAL(0x00F440B0, uint8) |= 8;
|
|
|
|
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z;
|
2015-06-10 16:41:50 +02:00
|
|
|
return cost;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
money32 lower_land(int flags, int x, int y, int z, int ax, int ay, int bx, int by, int selectionType)
|
2015-04-14 23:17:19 +02:00
|
|
|
{
|
2015-06-10 16:41:50 +02:00
|
|
|
money32 cost = 0;
|
2015-04-14 23:17:19 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
|
2015-11-18 01:03:15 +01:00
|
|
|
audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z);
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:19:02 +02:00
|
|
|
uint8 max_height = 0;
|
2015-04-14 23:17:19 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
ax = max(ax, 32);
|
|
|
|
ay = max(ay, 32);
|
2015-06-13 19:58:58 +02:00
|
|
|
bx = min(bx, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
|
|
|
by = min(by, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
2015-06-10 16:41:50 +02:00
|
|
|
|
2015-04-14 23:17:19 +02:00
|
|
|
// find highest map element in selection
|
2015-06-10 16:41:50 +02:00
|
|
|
for (int yi = ay; yi <= by; yi += 32) {
|
|
|
|
for (int xi = ax; xi <= bx; xi += 32) {
|
|
|
|
rct_map_element *map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
|
|
|
if (map_element != NULL) {
|
2015-06-09 14:24:02 +02:00
|
|
|
uint8 base_height = map_element->base_height;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element->properties.surface.slope & 0xF)
|
2015-06-09 14:24:02 +02:00
|
|
|
base_height += 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element->properties.surface.slope & 0x10)
|
2015-06-09 14:24:02 +02:00
|
|
|
base_height += 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (max_height < base_height)
|
2015-06-09 14:24:02 +02:00
|
|
|
max_height = base_height;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
for (int yi = ay; yi <= by; yi += 32) {
|
|
|
|
for (int xi = ax; xi <= bx; xi += 32) {
|
|
|
|
rct_map_element *map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
|
|
|
if (map_element != NULL) {
|
2015-06-09 14:24:02 +02:00
|
|
|
uint8 height = map_element->base_height;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element->properties.surface.slope & 0xF)
|
2015-06-09 14:24:02 +02:00
|
|
|
height += 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element->properties.surface.slope & 0x10)
|
2015-06-09 14:24:02 +02:00
|
|
|
height += 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (height >= max_height) {
|
2015-06-09 14:24:02 +02:00
|
|
|
height = map_element->base_height;
|
2015-06-10 16:41:50 +02:00
|
|
|
uint8 newStyle = map_element_lower_styles[selectionType][map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK];
|
|
|
|
if (newStyle & 0x20) { // needs to be lowered
|
2015-06-09 14:24:02 +02:00
|
|
|
height -= 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
newStyle &= ~0x20;
|
2015-06-09 14:24:02 +02:00
|
|
|
}
|
2015-07-12 02:46:52 +02:00
|
|
|
money32 tileCost = map_set_land_height(flags, xi, yi, height, newStyle, selectionType);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (tileCost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
cost += tileCost;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-10 16:41:50 +02:00
|
|
|
|
2015-11-10 22:34:09 +01:00
|
|
|
// Force ride construction to recheck area
|
|
|
|
RCT2_GLOBAL(0x00F440B0, uint8) |= 8;
|
|
|
|
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z;
|
2015-06-10 16:41:50 +02:00
|
|
|
return cost;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags)
|
|
|
|
{
|
2015-05-27 18:40:57 +02:00
|
|
|
money32 cost = 0;
|
2015-04-15 21:19:02 +02:00
|
|
|
|
|
|
|
uint8 max_height = 0xFF;
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
x0 = max(x0, 32);
|
|
|
|
y0 = max(y0, 32);
|
2015-06-13 19:58:58 +02:00
|
|
|
x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
|
|
|
y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
2015-06-10 16:41:50 +02:00
|
|
|
|
|
|
|
for (int yi = y0; yi <= y1; yi += 32) {
|
|
|
|
for (int xi = x0; xi <= x1; xi += 32) {
|
2015-04-15 21:19:02 +02:00
|
|
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element != NULL) {
|
2015-06-09 14:24:02 +02:00
|
|
|
uint8 height = map_element->base_height;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element->properties.surface.terrain & 0x1F)
|
2015-06-09 14:24:02 +02:00
|
|
|
height = (map_element->properties.surface.terrain & 0x1F) * 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (max_height > height)
|
2015-06-09 14:24:02 +02:00
|
|
|
max_height = height;
|
2015-04-15 21:19:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
for (int yi = y0; yi <= y1; yi += 32) {
|
|
|
|
for (int xi = x0; xi <= x1; xi += 32) {
|
2015-04-15 21:19:02 +02:00
|
|
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element != NULL) {
|
2015-06-09 14:24:02 +02:00
|
|
|
if (map_element->base_height <= max_height){
|
|
|
|
uint8 height = (map_element->properties.surface.terrain & 0x1F);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (height != 0) {
|
2015-06-09 14:24:02 +02:00
|
|
|
height *= 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (height > max_height)
|
2015-06-09 14:24:02 +02:00
|
|
|
continue;
|
|
|
|
height += 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
} else {
|
2015-06-09 14:24:02 +02:00
|
|
|
height = map_element->base_height + 2;
|
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-29 18:36:07 +02:00
|
|
|
money32 tileCost = game_do_command(xi, flags, yi, (max_height << 8) + height, GAME_COMMAND_SET_WATER_HEIGHT, 0, 0);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (tileCost == MONEY32_UNDEFINED)
|
2015-06-09 14:24:02 +02:00
|
|
|
return MONEY32_UNDEFINED;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
cost += tileCost;
|
2015-04-15 21:19:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-10 16:41:50 +02:00
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
2015-05-27 18:40:57 +02:00
|
|
|
int x = ((x0 + x1) / 2) + 16;
|
|
|
|
int y = ((y0 + y1) / 2) + 16;
|
2015-04-15 21:19:02 +02:00
|
|
|
int z = map_element_height(x, y);
|
|
|
|
sint16 water_height_z = z >> 16;
|
|
|
|
sint16 base_height_z = z;
|
|
|
|
z = water_height_z;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (z != 0)
|
2015-04-15 21:19:02 +02:00
|
|
|
z = base_height_z;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z;
|
2015-11-18 01:03:15 +01:00
|
|
|
audio_play_sound_at_location(SOUND_LAYING_OUT_WATER, x, y, z);
|
2015-04-15 21:19:02 +02:00
|
|
|
}
|
2015-06-10 16:41:50 +02:00
|
|
|
|
2015-11-10 22:34:09 +01:00
|
|
|
// Force ride construction to recheck area
|
|
|
|
RCT2_GLOBAL(0x00F440B0, uint8) |= 8;
|
|
|
|
|
2015-05-27 18:40:57 +02:00
|
|
|
return cost;
|
2015-04-15 21:19:02 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags)
|
2015-04-15 21:19:02 +02:00
|
|
|
{
|
2015-05-27 18:40:57 +02:00
|
|
|
money32 cost = 0;
|
2015-04-15 21:19:02 +02:00
|
|
|
|
|
|
|
uint8 min_height = 0;
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
x0 = max(x0, 32);
|
|
|
|
y0 = max(y0, 32);
|
2015-06-13 19:58:58 +02:00
|
|
|
x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
|
|
|
y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
2015-06-10 16:41:50 +02:00
|
|
|
|
2015-05-27 18:40:57 +02:00
|
|
|
for (int yi = y0; yi <= y1; yi += 32){
|
|
|
|
for (int xi = x0; xi <= x1; xi += 32){
|
2015-04-15 21:19:02 +02:00
|
|
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element != NULL) {
|
2015-06-09 14:24:02 +02:00
|
|
|
uint8 height = map_element->properties.surface.terrain & 0x1F;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (height != 0) {
|
2015-06-09 14:24:02 +02:00
|
|
|
height *= 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (height > min_height)
|
2015-06-09 14:24:02 +02:00
|
|
|
min_height = height;
|
2015-04-15 21:19:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
for (int yi = y0; yi <= y1; yi += 32) {
|
|
|
|
for (int xi = x0; xi <= x1; xi += 32) {
|
2015-04-15 21:19:02 +02:00
|
|
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (map_element != NULL) {
|
2015-06-09 14:24:02 +02:00
|
|
|
uint8 height = (map_element->properties.surface.terrain & 0x1F);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (height != 0) {
|
2015-06-09 14:24:02 +02:00
|
|
|
height *= 2;
|
2015-06-10 16:41:50 +02:00
|
|
|
if (height < min_height)
|
2015-06-09 14:24:02 +02:00
|
|
|
continue;
|
|
|
|
height -= 2;
|
2015-06-29 18:36:07 +02:00
|
|
|
int tileCost = game_do_command(xi, flags, yi, (min_height << 8) + height, GAME_COMMAND_SET_WATER_HEIGHT, 0, 0);
|
2015-06-10 16:41:50 +02:00
|
|
|
if (tileCost == MONEY32_UNDEFINED)
|
2015-06-09 14:24:02 +02:00
|
|
|
return MONEY32_UNDEFINED;
|
2015-06-10 16:41:50 +02:00
|
|
|
cost += tileCost;
|
2015-04-15 21:19:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-10 16:41:50 +02:00
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
2015-05-27 18:40:57 +02:00
|
|
|
int x = ((x0 + x1) / 2) + 16;
|
|
|
|
int y = ((y0 + y1) / 2) + 16;
|
2015-04-15 21:19:02 +02:00
|
|
|
int z = map_element_height(x, y);
|
|
|
|
sint16 water_height_z = z >> 16;
|
|
|
|
sint16 base_height_z = z;
|
|
|
|
z = water_height_z;
|
2015-06-10 17:38:27 +02:00
|
|
|
if (z == 0)
|
2015-04-15 21:19:02 +02:00
|
|
|
z = base_height_z;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z;
|
2015-11-18 01:03:15 +01:00
|
|
|
audio_play_sound_at_location(SOUND_LAYING_OUT_WATER, x, y, z);
|
2015-04-15 21:19:02 +02:00
|
|
|
}
|
2015-06-10 16:41:50 +02:00
|
|
|
|
2015-11-10 22:34:09 +01:00
|
|
|
// Force ride construction to recheck area
|
|
|
|
RCT2_GLOBAL(0x00F440B0, uint8) |= 8;
|
|
|
|
|
2015-05-27 18:40:57 +02:00
|
|
|
return cost;
|
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068C542
|
|
|
|
*/
|
|
|
|
void game_command_raise_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
*ebx = raise_land(
|
|
|
|
*ebx,
|
|
|
|
*eax,
|
|
|
|
*ecx,
|
|
|
|
map_element_height(*eax, *ecx),
|
|
|
|
(sint16)(*edx & 0xFFFF),
|
|
|
|
(sint16)(*ebp & 0xFFFF),
|
|
|
|
*edx >> 16,
|
|
|
|
*ebp >> 16,
|
|
|
|
*edi & 0xFFFF
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068C6D1
|
|
|
|
*/
|
|
|
|
void game_command_lower_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
*ebx = lower_land(
|
|
|
|
*ebx,
|
|
|
|
*eax,
|
|
|
|
*ecx,
|
|
|
|
map_element_height(*eax, *ecx),
|
|
|
|
(sint16)(*edx & 0xFFFF),
|
|
|
|
(sint16)(*ebp & 0xFFFF),
|
|
|
|
*edx >> 16,
|
|
|
|
*ebp >> 16,
|
|
|
|
*edi & 0xFFFF
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-10-11 12:39:01 +02:00
|
|
|
static int map_get_corner_height(rct_map_element *mapElement, int direction)
|
2015-10-11 03:23:39 +02:00
|
|
|
{
|
|
|
|
int z = mapElement->base_height;
|
|
|
|
int slope = mapElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
2015-10-11 12:39:01 +02:00
|
|
|
switch (direction) {
|
|
|
|
case 0:
|
2015-10-11 03:23:39 +02:00
|
|
|
if (slope & 1) {
|
|
|
|
z += 2;
|
|
|
|
if (slope == 27) {
|
|
|
|
z += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-10-11 12:39:01 +02:00
|
|
|
case 1:
|
2015-10-11 03:23:39 +02:00
|
|
|
if (slope & 2) {
|
|
|
|
z += 2;
|
|
|
|
if (slope == 23) {
|
|
|
|
z += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-10-11 12:39:01 +02:00
|
|
|
case 2:
|
2015-10-11 03:23:39 +02:00
|
|
|
if (slope & 4) {
|
|
|
|
z += 2;
|
|
|
|
if (slope == 30) {
|
|
|
|
z += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-10-11 12:39:01 +02:00
|
|
|
case 3:
|
2015-10-11 03:23:39 +02:00
|
|
|
if (slope & 8) {
|
|
|
|
z += 2;
|
|
|
|
if (slope == 29) {
|
|
|
|
z += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2015-10-11 12:39:01 +02:00
|
|
|
* rct2: 0x0068C3B2 slope 1, style 0
|
|
|
|
* rct2: 0x0068C47A slope 2, style 1
|
|
|
|
* rct2: 0x0068C222 slope 4, style 2
|
|
|
|
* rct2: 0x0068C2EA slope 8, style 3
|
2015-10-11 03:23:39 +02:00
|
|
|
*/
|
2015-10-11 13:31:57 +02:00
|
|
|
static money32 smooth_land_tile(int direction, uint8 flags, int x, int y, int targetBaseZ, int minBaseZ)
|
2015-10-11 03:23:39 +02:00
|
|
|
{
|
|
|
|
// Check if inside map bounds
|
|
|
|
if (x < 0 || y < 0 || x >= (256 * 32) || y >= (256 * 32)) {
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get height of tile
|
|
|
|
rct_map_element *mapElement = map_get_surface_element_at(x >> 5, y >> 5);
|
2016-01-03 00:49:08 +01:00
|
|
|
if (mapElement == NULL)
|
|
|
|
{
|
|
|
|
log_warning("Invalid coordinates for land smoothing, x = %d, y = %d", x, y);
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
2015-10-11 13:31:57 +02:00
|
|
|
int baseZ = map_get_corner_height(mapElement, direction);
|
2015-10-11 03:23:39 +02:00
|
|
|
|
|
|
|
// Check if tile is same height as target tile
|
|
|
|
if (baseZ == targetBaseZ) {
|
|
|
|
// No need to raise or lower
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 style;
|
|
|
|
if (targetBaseZ <= baseZ) {
|
|
|
|
baseZ = baseZ - targetBaseZ;
|
|
|
|
if (baseZ <= minBaseZ) {
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
targetBaseZ = mapElement->base_height;
|
|
|
|
int slope = mapElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
2015-10-11 12:39:01 +02:00
|
|
|
style = map_element_lower_styles[direction][slope];
|
2015-10-11 03:23:39 +02:00
|
|
|
if (style & 0x20) {
|
|
|
|
targetBaseZ -= 2;
|
|
|
|
style &= ~0x20;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
baseZ = targetBaseZ - baseZ;
|
|
|
|
if (baseZ <= minBaseZ) {
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
targetBaseZ = mapElement->base_height;
|
|
|
|
int slope = mapElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
2015-10-11 12:39:01 +02:00
|
|
|
style = map_element_raise_styles[direction][slope];
|
2015-10-11 03:23:39 +02:00
|
|
|
if ((style & 0x20) != 0) {
|
|
|
|
targetBaseZ += 2;
|
|
|
|
style &= ~0x20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return game_do_command(x, flags, y, targetBaseZ | (style << 8), GAME_COMMAND_SET_LAND_HEIGHT, 0, 0);
|
|
|
|
}
|
|
|
|
|
2015-10-11 12:39:01 +02:00
|
|
|
money32 smooth_land(int flags, int centreX, int centreY, int mapLeft, int mapTop, int mapRight, int mapBottom, int command)
|
2015-10-10 21:26:17 +02:00
|
|
|
{
|
2015-10-11 13:26:33 +02:00
|
|
|
// Cap bounds to map
|
|
|
|
mapLeft = max(mapLeft, 32);
|
|
|
|
mapTop = max(mapTop, 32);
|
|
|
|
mapRight = min(mapRight, 255 * 32);
|
|
|
|
mapBottom = min(mapBottom, 255 * 32);
|
|
|
|
|
2015-10-11 12:39:01 +02:00
|
|
|
int commandType;
|
2015-10-11 03:23:39 +02:00
|
|
|
int centreZ = map_element_height(centreX, centreY);
|
2015-10-11 12:39:01 +02:00
|
|
|
int mapLeftRight = mapLeft | (mapRight << 16);
|
|
|
|
int mapTopBottom = mapTop | (mapBottom << 16);
|
2015-10-11 03:23:39 +02:00
|
|
|
|
|
|
|
// Play sound (only once)
|
|
|
|
if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
|
2015-11-18 01:03:15 +01:00
|
|
|
audio_play_sound_at_location(SOUND_PLACE_ITEM, centreX, centreY, centreZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
money32 totalCost = 0;
|
|
|
|
|
|
|
|
// First raise / lower the centre tile
|
|
|
|
money32 result;
|
2015-10-11 12:39:01 +02:00
|
|
|
commandType = command == 1 ? GAME_COMMAND_RAISE_LAND : GAME_COMMAND_LOWER_LAND;
|
|
|
|
result = game_do_command(centreX, flags, centreY, mapLeftRight, commandType, 4, mapTopBottom);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int x, y, z;
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
|
|
|
x = mapLeft;
|
|
|
|
y = mapTop;
|
|
|
|
mapElement = map_get_surface_element_at(x >> 5, y >> 5);
|
2016-01-03 00:49:08 +01:00
|
|
|
if (mapElement == NULL)
|
|
|
|
{
|
|
|
|
log_warning("Invalid coordinates for land smoothing, x = %d, y = %d", x, y);
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
2015-10-11 03:23:39 +02:00
|
|
|
int slope = mapElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
|
|
|
if (slope != 0) {
|
2015-10-11 12:39:01 +02:00
|
|
|
commandType = command == 0xFFFF ? GAME_COMMAND_RAISE_LAND : GAME_COMMAND_LOWER_LAND;
|
|
|
|
result = game_do_command(centreX, flags, centreY, mapLeftRight, commandType, 4, mapTopBottom);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
|
|
|
|
x = mapLeft;
|
|
|
|
y = mapTop;
|
|
|
|
mapElement = map_get_surface_element_at(x >> 5, y >> 5);
|
|
|
|
slope = mapElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
2015-10-11 12:39:01 +02:00
|
|
|
if (slope != 0) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = centreX;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = centreY;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = centreZ;
|
|
|
|
return totalCost * 4;
|
|
|
|
}
|
2015-10-11 03:23:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
x = mapLeft;
|
|
|
|
y = mapTop;
|
2015-10-11 12:39:01 +02:00
|
|
|
int size = ((mapRight - mapLeft) >> 5) + 1;
|
2015-10-11 13:31:57 +02:00
|
|
|
int initialMinZ = -2;
|
2015-10-11 03:23:39 +02:00
|
|
|
|
2015-10-11 13:26:33 +02:00
|
|
|
for (; size <= 256; size += 2) {
|
2015-10-11 12:39:01 +02:00
|
|
|
initialMinZ += 2;
|
2015-10-11 13:31:57 +02:00
|
|
|
int minZ = initialMinZ * 2;
|
2015-10-11 03:23:39 +02:00
|
|
|
x -= 32;
|
|
|
|
y -= 32;
|
|
|
|
|
|
|
|
// Corner (North-West)
|
|
|
|
mapElement = map_get_surface_element_at(mapLeft >> 5, mapTop >> 5);
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 2);
|
|
|
|
result = smooth_land_tile(0, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
y += 32;
|
|
|
|
|
|
|
|
// Side (West)
|
2015-10-11 12:39:01 +02:00
|
|
|
for (int i = 0; i < size; i++) {
|
2015-10-11 03:23:39 +02:00
|
|
|
int y2 = clamp(mapTop, y, mapBottom);
|
|
|
|
mapElement = map_get_surface_element_at(mapLeft >> 5, y2 >> 5);
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 2);
|
|
|
|
result = smooth_land_tile(1, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
minZ -= 2;
|
|
|
|
if (y >= mapTop) {
|
|
|
|
minZ += 2;
|
|
|
|
if (y > mapBottom) {
|
|
|
|
minZ += 2;
|
|
|
|
}
|
|
|
|
}
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 3);
|
|
|
|
result = smooth_land_tile(0, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
|
|
|
|
y += 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Corner (South-West)
|
|
|
|
mapElement = map_get_surface_element_at(mapLeft >> 5, mapBottom >> 5);
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 3);
|
|
|
|
result = smooth_land_tile(1, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
x += 32;
|
|
|
|
|
|
|
|
// Side (South)
|
2015-10-11 12:39:01 +02:00
|
|
|
for (int i = 0; i < size; i++) {
|
2015-10-11 03:23:39 +02:00
|
|
|
int x2 = clamp(mapLeft, x, mapRight);
|
|
|
|
mapElement = map_get_surface_element_at(x2 >> 5, mapBottom >> 5);
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 3);
|
|
|
|
result = smooth_land_tile(2, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
minZ -= 2;
|
|
|
|
if (x >= mapLeft) {
|
|
|
|
minZ += 2;
|
|
|
|
if (x > mapRight) {
|
|
|
|
minZ += 2;
|
|
|
|
}
|
|
|
|
}
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 0);
|
|
|
|
result = smooth_land_tile(1, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
|
|
|
|
x += 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Corner (South-East)
|
|
|
|
mapElement = map_get_surface_element_at(mapRight >> 5, mapBottom >> 5);
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 0);
|
|
|
|
result = smooth_land_tile(2, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
y -= 32;
|
|
|
|
|
|
|
|
// Side (East)
|
2015-10-11 12:39:01 +02:00
|
|
|
for (int i = 0; i < size; i++) {
|
2015-10-11 03:23:39 +02:00
|
|
|
int y2 = clamp(mapTop, y, mapBottom);
|
|
|
|
mapElement = map_get_surface_element_at(mapRight >> 5, y2 >> 5);
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 0);
|
|
|
|
result = smooth_land_tile(3, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
minZ -= 2;
|
|
|
|
if (y <= mapBottom) {
|
|
|
|
minZ += 2;
|
|
|
|
if (y < mapTop) {
|
|
|
|
minZ += 2;
|
|
|
|
}
|
|
|
|
}
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 1);
|
|
|
|
result = smooth_land_tile(2, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
|
|
|
|
y -= 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Corner (North-East)
|
|
|
|
mapElement = map_get_surface_element_at(mapRight >> 5, mapTop >> 5);
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 1);
|
|
|
|
result = smooth_land_tile(3, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
x -= 32;
|
|
|
|
|
|
|
|
// Side (North)
|
2015-10-11 12:39:01 +02:00
|
|
|
for (int i = 0; i < size; i++) {
|
2015-10-11 03:23:39 +02:00
|
|
|
int x2 = clamp(mapLeft, x, mapRight);
|
|
|
|
mapElement = map_get_surface_element_at(x2 >> 5, mapTop >> 5);
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 1);
|
|
|
|
result = smooth_land_tile(0, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
minZ -= 2;
|
|
|
|
if (x <= mapRight) {
|
|
|
|
minZ += 2;
|
|
|
|
if (x < mapLeft) {
|
|
|
|
minZ += 2;
|
|
|
|
}
|
|
|
|
}
|
2015-10-11 12:39:01 +02:00
|
|
|
z = map_get_corner_height(mapElement, 2);
|
|
|
|
result = smooth_land_tile(3, flags, x, y, z, minZ);
|
2015-10-11 03:23:39 +02:00
|
|
|
if (result != MONEY32_UNDEFINED) {
|
|
|
|
totalCost += result;
|
|
|
|
}
|
|
|
|
|
|
|
|
x -= 32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-11 12:39:01 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = centreX;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = centreY;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = centreZ;
|
|
|
|
return totalCost * 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068BC01
|
|
|
|
*/
|
|
|
|
void game_command_smooth_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int flags = *ebx & 0xFF;
|
|
|
|
int centreX = *eax & 0xFFFF;
|
|
|
|
int centreY = *ecx & 0xFFFF;
|
2015-10-11 13:26:33 +02:00
|
|
|
int mapLeft = (sint16)(*edx & 0xFFFF);
|
|
|
|
int mapTop = (sint16)(*ebp & 0xFFFF);
|
|
|
|
int mapRight = (sint16)(*edx >> 16);
|
|
|
|
int mapBottom = (sint16)(*ebp >> 16);
|
2015-10-11 12:39:01 +02:00
|
|
|
int command = *edi;
|
|
|
|
*ebx = smooth_land(flags, centreX, centreY, mapLeft, mapTop, mapRight, mapBottom, command);
|
2015-10-10 21:26:17 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 16:41:50 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E66A0
|
|
|
|
*/
|
|
|
|
void game_command_raise_water(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
*ebx = raise_water(
|
|
|
|
(sint16)(*eax & 0xFFFF),
|
|
|
|
(sint16)(*ecx & 0xFFFF),
|
|
|
|
(sint16)(*edi & 0xFFFF),
|
|
|
|
(sint16)(*ebp & 0xFFFF),
|
|
|
|
(uint8)*ebx
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-05-27 18:40:57 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E6878
|
|
|
|
*/
|
|
|
|
void game_command_lower_water(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
*ebx = lower_water(
|
2015-10-20 20:16:30 +02:00
|
|
|
(sint16)(*eax & 0xFFFF),
|
|
|
|
(sint16)(*ecx & 0xFFFF),
|
|
|
|
(sint16)(*edi & 0xFFFF),
|
|
|
|
(sint16)(*ebp & 0xFFFF),
|
2015-06-10 16:41:50 +02:00
|
|
|
(uint8)*ebx
|
|
|
|
);
|
2015-04-15 21:19:02 +02:00
|
|
|
}
|
|
|
|
|
2015-06-29 19:39:10 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E650F
|
|
|
|
*/
|
|
|
|
void game_command_set_water_height(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 base_height = *edx;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, sint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, sint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = base_height * 8;
|
2015-06-29 19:39:10 +02:00
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-07-02 20:02:59 +02:00
|
|
|
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES){
|
2015-06-29 19:39:10 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-29 19:39:10 +02:00
|
|
|
if(base_height < 2){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_LOW;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(base_height >= 58){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_HIGH;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) || y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16)){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_OFF_EDGE_OF_MAP;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-02 20:02:59 +02:00
|
|
|
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_in_park(x, y)){
|
2015-06-29 19:39:10 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
int element_height = map_element_height(x, y);
|
|
|
|
footpath_remove_litter(x, y, element_height);
|
2016-01-09 23:46:08 +01:00
|
|
|
if(!gCheatsDisableClearanceChecks)
|
|
|
|
map_remove_walls_at_z(x, y, element_height);
|
2015-06-29 19:39:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element* map_element = map_get_surface_element_at(x / 32, y / 32);
|
2015-11-16 05:31:37 +01:00
|
|
|
int zHigh = map_element->base_height;
|
|
|
|
int zLow = base_height;
|
2015-06-29 19:39:10 +02:00
|
|
|
if(map_element->properties.surface.terrain & 0x1F){
|
2015-11-16 05:31:37 +01:00
|
|
|
zHigh = (map_element->properties.surface.terrain & 0x1F) * 2;
|
2015-06-29 19:39:10 +02:00
|
|
|
}
|
2015-11-16 05:31:37 +01:00
|
|
|
if(zLow > zHigh){
|
|
|
|
int temp = zHigh;
|
|
|
|
zHigh = zLow;
|
|
|
|
zLow = temp;
|
2015-06-29 19:39:10 +02:00
|
|
|
}
|
|
|
|
|
2015-11-16 05:31:37 +01:00
|
|
|
if(map_can_construct_at(x, y, zLow, zHigh, 0xFF)){
|
2015-06-29 19:39:10 +02:00
|
|
|
if(map_element->type & 0x40){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
int new_terrain = map_element->properties.surface.terrain & 0xE0;
|
|
|
|
if(base_height > map_element->base_height){
|
|
|
|
new_terrain |= (base_height / 2);
|
|
|
|
}
|
|
|
|
map_element->properties.surface.terrain = new_terrain;
|
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
}
|
|
|
|
*ebx = 250;
|
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-16 01:17:43 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E5597
|
|
|
|
*/
|
|
|
|
void game_command_remove_fence(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 base_height = (*edx >> 8);
|
|
|
|
uint8 direction = *edx;
|
|
|
|
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-06-10 18:12:21 +02:00
|
|
|
if(!(*ebx & 0x40) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode){
|
2015-04-16 01:17:43 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
2015-04-16 01:30:18 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
2015-04-16 01:17:43 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-06-26 23:40:09 +02:00
|
|
|
if(!(*ebx & 0x40) && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, base_height * 8)){
|
2015-04-16 04:02:47 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
while(map_element_get_type(map_element) != MAP_ELEMENT_TYPE_FENCE ||
|
|
|
|
map_element->base_height != base_height ||
|
|
|
|
(map_element->type & MAP_ELEMENT_DIRECTION_MASK) != direction ||
|
2015-06-15 18:27:11 +02:00
|
|
|
((*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST))){
|
2015-04-16 04:02:47 +02:00
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
|
|
|
*ebx = 0;
|
2015-04-16 01:17:43 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-04-16 04:02:47 +02:00
|
|
|
}
|
2015-05-26 18:55:25 +02:00
|
|
|
|
|
|
|
if (!(*ebx & GAME_COMMAND_FLAG_APPLY)){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-15 22:56:26 +02:00
|
|
|
map_element_remove_banner_entry(map_element);
|
2015-07-06 19:57:36 +02:00
|
|
|
map_invalidate_tile_zoom1(x, y, map_element->base_height * 8, (map_element->base_height * 8) + 72);
|
2015-04-16 04:02:47 +02:00
|
|
|
map_element_remove(map_element);
|
2015-04-16 01:17:43 +02:00
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
2015-04-22 23:47:59 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B9E6D
|
|
|
|
*/
|
|
|
|
void game_command_place_banner(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int x = (uint16)*eax;
|
|
|
|
int y = (uint16)*ecx;
|
|
|
|
uint8 base_height = *edx;
|
|
|
|
uint8 edge = *edx >> 8;
|
|
|
|
uint8 colour = *edi;
|
|
|
|
uint8 type = *ebx >> 8;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = base_height * 16;
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-06-10 18:12:21 +02:00
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0 || gConfigCheat.build_in_pause_mode){
|
2015-04-22 23:47:59 +02:00
|
|
|
if(sub_68B044() && x < 8192 && y < 8192){
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
int dl = base_height * 2;
|
|
|
|
int ch = (base_height - 1) * 2;
|
|
|
|
while(map_element_get_type(map_element) != MAP_ELEMENT_TYPE_PATH ||
|
|
|
|
(map_element->base_height != dl && map_element->base_height != ch) ||
|
|
|
|
!(map_element->properties.path.edges & (1 << edge))){
|
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-06-26 23:40:09 +02:00
|
|
|
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, base_height * 16)){
|
2015-04-22 23:47:59 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
dl = (base_height + 1) * 2;
|
|
|
|
while(map_element->type != MAP_ELEMENT_TYPE_BANNER ||
|
|
|
|
map_element->base_height != dl ||
|
|
|
|
(map_element->properties.banner.position & 0x3) != edge){
|
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
2015-04-23 18:36:31 +02:00
|
|
|
int banner_index = create_new_banner(*ebx);
|
|
|
|
if(banner_index == BANNER_NULL){
|
2015-04-22 23:47:59 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-04-23 18:36:31 +02:00
|
|
|
*edi = banner_index;
|
2015-04-22 23:47:59 +02:00
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
rct_map_element* new_map_element = map_element_insert(x / 32, y / 32, (base_height + 1) * 2, 0);
|
2015-04-23 18:36:31 +02:00
|
|
|
gBanners[banner_index].type = type;
|
|
|
|
gBanners[banner_index].colour = colour;
|
|
|
|
gBanners[banner_index].x = x / 32;
|
|
|
|
gBanners[banner_index].y = y / 32;
|
2015-04-22 23:47:59 +02:00
|
|
|
new_map_element->type = MAP_ELEMENT_TYPE_BANNER;
|
|
|
|
new_map_element->clearance_height = new_map_element->base_height + 2;
|
|
|
|
new_map_element->properties.banner.position = edge;
|
|
|
|
new_map_element->properties.banner.flags = 0xFF;
|
|
|
|
new_map_element->properties.banner.unused = 0;
|
2015-04-23 18:36:31 +02:00
|
|
|
new_map_element->properties.banner.index = banner_index;
|
2015-04-22 23:47:59 +02:00
|
|
|
if(*ebx & 0x40){
|
|
|
|
new_map_element->flags |= 0x10;
|
|
|
|
}
|
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
map_animation_create(0x0A, x, y, new_map_element->base_height);
|
|
|
|
}
|
|
|
|
rct_scenery_entry *scenery_entry = (rct_scenery_entry*)object_entry_groups[OBJECT_TYPE_BANNERS].chunks[type];
|
|
|
|
*ebx = scenery_entry->banner.price;
|
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_BANNER_SIGN_IN_THE_WAY;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
}
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
2015-05-12 21:08:36 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E08F4
|
|
|
|
*/
|
|
|
|
void game_command_place_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-05-12 21:08:36 +02:00
|
|
|
int x = (uint16)*eax;
|
|
|
|
int y = (uint16)*ecx;
|
|
|
|
uint8 color2 = *edi >> 16;
|
|
|
|
uint8 rotation = *edi;
|
|
|
|
int z = *ebp;
|
|
|
|
uint8 scenery_type = *ebx >> 8;
|
|
|
|
uint8 quadrant = *edx;
|
|
|
|
uint8 color1 = *edx >> 8;
|
|
|
|
int F64F1D = 0;
|
|
|
|
int F64EC8 = z;
|
|
|
|
int base_height = map_element_height(x, y);
|
|
|
|
if(base_height & 0xFFFF0000){
|
|
|
|
base_height >>= 16;
|
|
|
|
}
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = base_height;
|
2015-05-12 21:08:36 +02:00
|
|
|
if(F64EC8){
|
|
|
|
base_height = F64EC8;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = base_height;
|
2015-05-12 21:08:36 +02:00
|
|
|
}
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) += 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) += 16;
|
2015-06-10 18:12:21 +02:00
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0 || gConfigCheat.build_in_pause_mode){
|
2015-05-12 21:08:36 +02:00
|
|
|
if(sub_68B044()){
|
2015-06-13 19:58:58 +02:00
|
|
|
if(RCT2_GLOBAL(0x009D8150, uint8) & 1 || (x <= RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16) && y <= RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16))){
|
2015-05-12 21:08:36 +02:00
|
|
|
rct_scenery_entry* scenery_entry = (rct_scenery_entry*)object_entry_groups[OBJECT_TYPE_SMALL_SCENERY].chunks[scenery_type];
|
2015-06-19 18:26:22 +02:00
|
|
|
if(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE || !(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG9)){
|
|
|
|
if(scenery_entry->small_scenery.flags & (SMALL_SCENERY_FLAG9 | SMALL_SCENERY_FLAG24 | SMALL_SCENERY_FLAG25)){
|
|
|
|
quadrant = 0;
|
|
|
|
}
|
2015-05-12 21:08:36 +02:00
|
|
|
}
|
|
|
|
int x2 = x;
|
|
|
|
int y2 = y;
|
|
|
|
if(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE){
|
|
|
|
x2 += 16;
|
|
|
|
y2 += 16;
|
|
|
|
}else{
|
|
|
|
x2 += RCT2_ADDRESS(0x009A3E74, uint8)[(quadrant & 3) * 2] - 1;
|
|
|
|
y2 += RCT2_ADDRESS(0x009A3E75, uint8)[(quadrant & 3) * 2] - 1;
|
|
|
|
}
|
|
|
|
int base_height2 = map_element_height(x2, y2);
|
|
|
|
if(base_height2 & 0xFFFF0000){
|
|
|
|
base_height2 >>= 16;
|
|
|
|
if(F64EC8 == 0){
|
|
|
|
F64F1D = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(F64EC8 == 0){
|
|
|
|
F64EC8 = base_height2;
|
|
|
|
}
|
2015-06-26 23:40:09 +02:00
|
|
|
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, F64EC8)){
|
2015-05-12 21:08:36 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY && !(*ebx & 0x40)){
|
2015-06-09 03:09:18 +02:00
|
|
|
footpath_remove_litter(x, y, F64EC8);
|
2015-09-06 18:36:55 +02:00
|
|
|
if(!gCheatsDisableClearanceChecks && (scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS)) {
|
2015-07-06 21:29:36 +02:00
|
|
|
map_remove_walls_at(x, y, F64EC8, F64EC8 + scenery_entry->small_scenery.height);
|
2015-05-12 21:08:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
while(map_element_get_type(map_element) != MAP_ELEMENT_TYPE_SURFACE){
|
|
|
|
map_element++;
|
|
|
|
}
|
2015-06-26 23:40:09 +02:00
|
|
|
if(!gCheatsDisableClearanceChecks && (map_element->properties.surface.terrain & 0x1F)){
|
2015-05-12 21:08:36 +02:00
|
|
|
int water_height = ((map_element->properties.surface.terrain & 0x1F) * 16) - 1;
|
|
|
|
if(water_height > F64EC8){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CANT_BUILD_THIS_UNDERWATER;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-06-26 23:40:09 +02:00
|
|
|
if(!gCheatsDisableClearanceChecks && !(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG18)){
|
2015-05-12 21:08:36 +02:00
|
|
|
if(F64F1D != 0){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CAN_ONLY_BUILD_THIS_ON_LAND;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(map_element->properties.surface.terrain & 0x1F){
|
|
|
|
if(((map_element->properties.surface.terrain & 0x1F) * 16) > F64EC8){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CAN_ONLY_BUILD_THIS_ON_LAND;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-26 23:40:09 +02:00
|
|
|
if(gCheatsDisableClearanceChecks || !(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_REQUIRE_FLAT_SURFACE) || z != 0 || F64F1D != 0 || !(map_element->properties.surface.slope & 0x1F)){
|
2015-07-23 19:55:51 +02:00
|
|
|
if(gCheatsDisableSupportLimits || scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG18 || z == 0){
|
2015-05-12 21:08:36 +02:00
|
|
|
l_6E0B78: ;
|
|
|
|
int bp = quadrant;
|
|
|
|
int zLow = F64EC8 / 8;
|
|
|
|
int zHigh = zLow + ((scenery_entry->small_scenery.height + 7) / 8);
|
|
|
|
int bl = 0xF;
|
|
|
|
if(!(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE)){
|
|
|
|
bp ^= 2;
|
|
|
|
bl = 1;
|
|
|
|
bl <<= bp;
|
|
|
|
}
|
|
|
|
if(!(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG24)){
|
|
|
|
if(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG9 && scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE){
|
|
|
|
if(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG25){
|
|
|
|
bp ^= 2;
|
|
|
|
bp += rotation;
|
|
|
|
bp &= 3;
|
|
|
|
bl = 0xBB;
|
2015-05-19 01:25:58 +02:00
|
|
|
bl = rol8(bl, bp);
|
2015-05-12 21:08:36 +02:00
|
|
|
bl &= 0xF;
|
|
|
|
}else{
|
|
|
|
bp += rotation;
|
|
|
|
bp &= 1;
|
|
|
|
bl = 0xA;
|
2015-05-30 01:37:00 +02:00
|
|
|
bl >>= bp;
|
2015-05-12 21:08:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
bp ^= 2;
|
|
|
|
bp += rotation;
|
|
|
|
bp &= 3;
|
|
|
|
bl = 0x33;
|
2015-05-19 01:25:58 +02:00
|
|
|
bl = rol8(bl, bp);
|
2015-05-12 21:08:36 +02:00
|
|
|
bl &= 0xF;
|
|
|
|
}
|
|
|
|
if(z == 0){
|
|
|
|
bl |= 0xF0;
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x00F64F22, uint16) = x;
|
|
|
|
RCT2_GLOBAL(0x00F64F24, uint16) = y;
|
|
|
|
RCT2_GLOBAL(0x00F64F1E, uint32) = (uint32)(ebx - 1); //0x006E0D6E uses [F64F1E+4] to read ebx value
|
2015-06-26 23:40:09 +02:00
|
|
|
if(gCheatsDisableClearanceChecks || map_can_construct_with_clear_at(x, y, zLow, zHigh, (void*)0x006E0D6E, bl)){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(0x00F64F14, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) & 0x3;
|
2015-05-12 21:08:36 +02:00
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
int flags = (bl & 0xf);
|
|
|
|
rct_map_element* new_map_element = map_element_insert(x / 32, y / 32, zLow, flags);
|
2015-08-19 05:53:24 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_MAP_ELEMENT, rct_map_element*) = new_map_element;
|
2015-05-12 21:08:36 +02:00
|
|
|
uint8 type = quadrant << 6;
|
|
|
|
type |= MAP_ELEMENT_TYPE_SCENERY;
|
|
|
|
type |= rotation;
|
|
|
|
new_map_element->type = type;
|
|
|
|
new_map_element->properties.scenery.type = scenery_type;
|
|
|
|
new_map_element->properties.scenery.age = 0;
|
|
|
|
new_map_element->properties.scenery.colour_1 = color1;
|
|
|
|
new_map_element->properties.scenery.colour_2 = color2;
|
|
|
|
new_map_element->clearance_height = new_map_element->base_height + ((scenery_entry->small_scenery.height + 7) / 8);
|
|
|
|
if(z != 0){
|
|
|
|
new_map_element->properties.scenery.colour_1 |= 0x20;
|
|
|
|
}
|
|
|
|
if(*ebx & 0x40){
|
|
|
|
new_map_element->flags |= 0x10;
|
|
|
|
}
|
|
|
|
map_invalidate_tile_full(x, y);
|
2015-05-19 01:25:58 +02:00
|
|
|
if(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_ANIMATED){
|
2015-05-12 21:08:36 +02:00
|
|
|
map_animation_create(2, x, y, new_map_element->base_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*ebx = (scenery_entry->small_scenery.price * 10);
|
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(F64F1D == 0){
|
|
|
|
if((map_element->properties.surface.terrain & 0x1F) || (map_element->base_height * 8) != F64EC8){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_LEVEL_LAND_REQUIRED;
|
|
|
|
}else{
|
|
|
|
goto l_6E0B78;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CAN_ONLY_BUILD_THIS_ON_LAND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_LEVEL_LAND_REQUIRED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
}
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
2015-09-06 18:36:55 +02:00
|
|
|
static bool map_is_location_at_edge(int x, int y)
|
|
|
|
{
|
|
|
|
return x < 32 || y < 32 || x >= ((256 - 1) * 32) || y >= ((256 - 1) * 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E5CBA
|
|
|
|
*/
|
|
|
|
static bool map_place_fence_check_obstruction_with_track(rct_scenery_entry *wall, int x, int y, int z0, int z1, int edge, rct_map_element *trackElement)
|
|
|
|
{
|
|
|
|
const rct_preview_track *trackBlock;
|
|
|
|
int z, direction;
|
|
|
|
|
|
|
|
int trackType = trackElement->properties.track.type;
|
|
|
|
int sequence = trackElement->properties.track.sequence & 0x0F;
|
|
|
|
int typeAndSequence = (trackType << 4) | sequence;
|
|
|
|
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 (RCT2_ADDRESS(0x0099AA94, uint8)[typeAndSequence] & (1 << direction)) {
|
|
|
|
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_18)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (RCT2_ADDRESS(0x00999A94, uint8)[typeAndSequence] & (1 << direction)) {
|
|
|
|
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_18)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-09-06 18:36:55 +02:00
|
|
|
if (!(wall->wall.flags & WALL_SCENERY_FLAG5)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-10 23:16:41 +02:00
|
|
|
if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) {
|
2015-09-06 18:36:55 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_ride_type *rideEntry = GET_RIDE_ENTRY(ride->subtype);
|
|
|
|
if (rideEntry->flags & RIDE_ENTRY_FLAG_16) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x0141F725, uint8) |= 1;
|
|
|
|
if (z0 & 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sequence == 0) {
|
|
|
|
if (RCT2_GLOBAL(0x0099BA64 + (trackType * 16), uint8) & 0x40) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gTrackDefinitions[trackType].bank_start == 0) {
|
|
|
|
if (!(RCT2_ADDRESS(0x009968BB, uint8)[trackType * 10] & 4)) {
|
|
|
|
direction = (trackElement->type & 3) ^ 2;
|
|
|
|
if (direction == edge) {
|
|
|
|
trackBlock = &TrackBlocks[trackType][sequence];
|
|
|
|
z = RCT2_GLOBAL(0x009968BD + (trackType * 10), uint8);
|
|
|
|
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
|
|
|
if (z == z0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trackBlock = &TrackBlocks[trackType][sequence + 1];
|
|
|
|
if (trackBlock->index != 0xFF) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gTrackDefinitions[trackType].bank_end != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
direction = RCT2_ADDRESS(0x009968BC, uint8)[trackType * 10];
|
|
|
|
if (direction & 4) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
direction = (trackElement->type + direction) & 3;
|
|
|
|
if (direction != edge) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
trackBlock = &TrackBlocks[trackType][sequence];
|
|
|
|
z = RCT2_GLOBAL(0x009968BF + (trackType * 10), uint8);
|
|
|
|
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
|
|
|
if (z != z0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-20 01:05:30 +02:00
|
|
|
/**
|
2015-07-06 21:29:36 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006E5C1A
|
|
|
|
*/
|
2015-09-06 18:36:55 +02:00
|
|
|
static bool map_place_fence_check_obstruction(rct_scenery_entry *wall, int x, int y, int z0, int z1, int edge)
|
2015-07-06 21:29:36 +02:00
|
|
|
{
|
2015-09-06 18:36:55 +02:00
|
|
|
int entryType, sequence;
|
|
|
|
rct_scenery_entry *entry;
|
|
|
|
rct_large_scenery_tile *tile;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x0141F725, uint8) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) = 1;
|
|
|
|
if (map_is_location_at_edge(x, y)) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_OFF_EDGE_OF_MAP;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
do {
|
|
|
|
int 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_FENCE) {
|
|
|
|
int direction = mapElement->type & 3;
|
|
|
|
if (edge == direction) {
|
|
|
|
map_obstruction_set_error_text(mapElement);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((mapElement->flags & 0x0F) == 0) continue;
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
map_obstruction_set_error_text(mapElement);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE:
|
|
|
|
entryType = mapElement->properties.scenerymultiple.type & 0x3FF;
|
|
|
|
sequence = mapElement->properties.scenerymultiple.type >> 10;
|
|
|
|
entry = g_largeSceneryEntries[entryType];
|
|
|
|
tile = &entry->large_scenery.tiles[sequence];
|
|
|
|
|
|
|
|
int direction = ((edge - mapElement->type) & 3) + 8;
|
|
|
|
if (!(tile->var_7 & (1 << direction))) {
|
|
|
|
map_obstruction_set_error_text(mapElement);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY:
|
|
|
|
entryType = mapElement->properties.scenery.type;
|
|
|
|
entry = g_smallSceneryEntries[entryType];
|
|
|
|
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 (!map_place_fence_check_obstruction_with_track(wall, x, y, z0, z1, edge, mapElement)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
return true;
|
2015-07-06 21:29:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E519A
|
|
|
|
*/
|
2015-06-20 01:05:30 +02:00
|
|
|
void game_command_place_fence(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp){
|
|
|
|
rct_xyz16 position = {
|
|
|
|
.x = *eax & 0xFFFF,
|
|
|
|
.y = *ecx & 0xFFFF,
|
|
|
|
.z = *edi & 0xFFFF
|
|
|
|
};
|
|
|
|
|
|
|
|
uint8 flags = *ebx & 0xFF;
|
|
|
|
uint8 fence_type = (*ebx >> 8) & 0xFF;
|
|
|
|
uint8 primary_colour = (*edx >> 8) & 0xFF;
|
|
|
|
uint8 secondary_colour = *ebp & 0xFF;
|
|
|
|
uint8 tertiary_colour = (*ebp >> 8) & 0xFF;
|
|
|
|
uint8 edge = *edx & 0xFF;
|
2015-06-21 13:07:44 +02:00
|
|
|
|
|
|
|
// *not used*
|
2015-06-20 01:05:30 +02:00
|
|
|
RCT2_GLOBAL(0x00141F726, uint8) = secondary_colour;
|
2015-06-21 13:07:44 +02:00
|
|
|
// *not used*
|
2015-06-20 01:05:30 +02:00
|
|
|
RCT2_GLOBAL(0x00141F727, uint8) = tertiary_colour;
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
|
|
|
// Banner index *not used*
|
2015-06-20 01:05:30 +02:00
|
|
|
RCT2_GLOBAL(0x00141F728, uint8) = 0xFF;
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, sint16) = position.x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, sint16) = position.y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, sint16) = position.z;
|
2015-06-20 01:05:30 +02:00
|
|
|
|
|
|
|
if (position.z == 0){
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, sint16) = map_element_height(position.x, position.y) & 0xFFFF;
|
2015-06-20 01:05:30 +02:00
|
|
|
}
|
|
|
|
|
2015-06-21 13:40:44 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) &&
|
2015-06-26 23:40:09 +02:00
|
|
|
!(flags & (1 << 7)) && !gCheatsSandboxMode){
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-06-20 01:05:30 +02:00
|
|
|
if (position.z == 0){
|
|
|
|
if (!map_is_location_in_park(position.x, position.y)){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!map_is_location_owned(position.x, position.y, position.z)){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 bp = 0;
|
|
|
|
if (position.z == 0){
|
|
|
|
rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32);
|
|
|
|
if (map_element == NULL){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
position.z = map_element->base_height * 8;
|
|
|
|
|
|
|
|
uint8 slope = map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
|
|
|
bp = RCT2_ADDRESS(0x009A3FEC, uint8)[slope + (edge & 3) * 32];
|
|
|
|
if (bp & (1 << 0)){
|
|
|
|
position.z += 16;
|
|
|
|
bp &= ~(1 << 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x00141F721, uint16) = position.z / 8;
|
|
|
|
RCT2_GLOBAL(0x00141F720, uint8) = primary_colour;
|
|
|
|
RCT2_GLOBAL(0x00141F723, uint8) = bp;
|
|
|
|
|
|
|
|
rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32);
|
|
|
|
if (map_element == NULL){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){
|
|
|
|
uint16 water_height = map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK;
|
|
|
|
water_height *= 16;
|
|
|
|
|
|
|
|
if (position.z < water_height){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CANT_BUILD_THIS_UNDERWATER;
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (position.z / 8 < map_element->base_height){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(bp & 0xC0)){
|
|
|
|
uint8 new_edge = (edge + 2) & 3;
|
2015-11-16 21:19:58 +01:00
|
|
|
uint8 new_base_height = map_element->base_height;
|
|
|
|
new_base_height += 2;
|
2015-06-20 01:05:30 +02:00
|
|
|
if (map_element->properties.surface.slope & (1 << new_edge)){
|
2015-11-16 21:19:58 +01:00
|
|
|
if (position.z / 8 < new_base_height){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_element->properties.surface.slope & (1 << 4)){
|
|
|
|
new_edge = (new_edge - 1) & 3;
|
|
|
|
|
|
|
|
if (map_element->properties.surface.slope & (1 << new_edge)){
|
|
|
|
new_edge = (new_edge + 2) & 3;
|
|
|
|
if (map_element->properties.surface.slope & (1 << new_edge)){
|
2015-11-16 21:19:58 +01:00
|
|
|
new_base_height += 2;
|
|
|
|
if (position.z / 8 < new_base_height){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-11-16 21:19:58 +01:00
|
|
|
new_base_height -= 2;
|
2015-06-20 01:05:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new_edge = (edge + 3) & 3;
|
|
|
|
if (map_element->properties.surface.slope & (1 << new_edge)){
|
2015-11-16 21:19:58 +01:00
|
|
|
if (position.z / 8 < new_base_height){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_element->properties.surface.slope & (1 << 4)){
|
|
|
|
new_edge = (new_edge - 1) & 3;
|
|
|
|
|
|
|
|
if (map_element->properties.surface.slope & (1 << new_edge)){
|
|
|
|
new_edge = (new_edge + 2) & 3;
|
|
|
|
if (map_element->properties.surface.slope & (1 << new_edge)){
|
2015-11-16 21:19:58 +01:00
|
|
|
new_base_height += 2;
|
|
|
|
if (position.z / 8 < new_base_height){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-21 13:07:44 +02:00
|
|
|
int banner_index = 0xFF;
|
2015-06-20 01:05:30 +02:00
|
|
|
rct_scenery_entry* fence = g_wallSceneryEntries[fence_type];
|
|
|
|
if (fence->wall.var_0D != 0xFF){
|
2015-06-21 13:07:44 +02:00
|
|
|
banner_index = create_new_banner(fence->wall.var_0D);
|
2015-06-20 01:05:30 +02:00
|
|
|
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(0x00141F728, uint8) = banner_index;
|
2015-06-20 01:05:30 +02:00
|
|
|
if (banner_index == 0xFF){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_banner* banner = &gBanners[banner_index];
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
banner->flags |= (1 << 3);
|
|
|
|
banner->type = 0;
|
|
|
|
banner->x = position.x / 32;
|
|
|
|
banner->y = position.y / 32;
|
|
|
|
|
2015-07-11 21:24:27 +02:00
|
|
|
int rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z);
|
|
|
|
if (rideIndex != -1) {
|
|
|
|
banner->colour = rideIndex & 0xFF;
|
2015-06-20 01:05:30 +02:00
|
|
|
banner->flags |= BANNER_FLAG_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bp = RCT2_GLOBAL(0x00141F723, uint8);
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x00141F722, uint8) = position.z / 8;
|
|
|
|
if (bp & 0xC0){
|
|
|
|
if (fence->wall.flags & WALL_SCENERY_FLAG3){
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = 3133;
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x00141F722, uint8) += 2;
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x00141F722, uint8) += fence->wall.height;
|
|
|
|
|
2015-06-26 23:40:09 +02:00
|
|
|
if (!(flags & (1 << 7)) && !gCheatsDisableClearanceChecks){
|
2015-09-06 18:36:55 +02:00
|
|
|
if (!map_place_fence_check_obstruction(fence, position.x, position.y, RCT2_GLOBAL(0x00141F721, uint8), RCT2_GLOBAL(0x00141F722, uint8), edge)) {
|
2015-06-20 01:05:30 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sub_68B044()){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
map_element = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0);
|
|
|
|
|
|
|
|
map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8);
|
|
|
|
|
|
|
|
map_element->clearance_height = RCT2_GLOBAL(0x00141F722, uint8);
|
|
|
|
|
|
|
|
map_element->type = bp | edge | MAP_ELEMENT_TYPE_FENCE;
|
|
|
|
|
|
|
|
map_element->properties.fence.item[1] = primary_colour;
|
|
|
|
map_element->properties.fence.item[1] |= (secondary_colour & 7) << 5;
|
|
|
|
map_element->flags |= (secondary_colour & 0x18) << 2;
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(0x00141F725, uint8) & 1){
|
|
|
|
map_element->properties.fence.item[2] |= (1 << 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
map_element->properties.fence.type = fence_type;
|
2015-06-21 13:07:44 +02:00
|
|
|
if (banner_index != 0xFF){
|
|
|
|
map_element->properties.fence.item[0] = banner_index;
|
2015-06-20 01:05:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fence->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){
|
|
|
|
map_element->properties.fence.item[0] = tertiary_colour;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & (1 << 6)){
|
|
|
|
map_element->flags |= MAP_ELEMENT_FLAG_GHOST;
|
|
|
|
}
|
|
|
|
|
2015-08-19 05:53:24 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_MAP_ELEMENT, rct_map_element*) = map_element;
|
2015-07-06 19:57:36 +02:00
|
|
|
map_invalidate_tile_zoom1(position.x, position.y, map_element->base_height * 8, map_element->base_height * 8 + 72);
|
2015-06-20 01:05:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
*ebx = fence->wall.price;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-15 00:15:21 +02:00
|
|
|
money32 map_place_fence(
|
|
|
|
int type, int x, int y, int z, int edge, int primaryColour, int secondaryColour, int tertiaryColour, int flags
|
|
|
|
) {
|
|
|
|
int 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);
|
|
|
|
game_command_place_fence(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
|
|
|
return ebx;
|
|
|
|
}
|
|
|
|
|
2015-06-14 13:56:12 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006B893C
|
|
|
|
*/
|
|
|
|
void game_command_place_large_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
2015-06-21 13:07:44 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
2015-06-14 13:56:12 +02:00
|
|
|
int x = (sint16)*eax;
|
|
|
|
int y = (sint16)*ecx;
|
2015-10-20 20:16:30 +02:00
|
|
|
int z = (sint16)*ebp;
|
2015-06-14 13:56:12 +02:00
|
|
|
uint8 color1 = *edx;
|
|
|
|
uint8 color2 = *edx >> 8;
|
|
|
|
uint8 flags = *ebx;
|
|
|
|
uint8 rotation = *ebx >> 8;
|
|
|
|
uint8 entry_index = *edi;
|
|
|
|
int base_height = map_element_height(x, y);
|
2015-08-17 00:25:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, sint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, sint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, sint16) = base_height;
|
2015-06-14 13:56:12 +02:00
|
|
|
RCT2_GLOBAL(0x00F64F14, uint8) = 0;
|
|
|
|
uint8 banner_id = 0xFF;
|
2015-11-14 17:44:03 +01:00
|
|
|
|
|
|
|
// Supports cost
|
|
|
|
RCT2_GLOBAL(0x00F4389A, money32) = 0;
|
|
|
|
|
2015-11-18 23:32:23 +01:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) {
|
2015-11-14 17:44:03 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-03 00:49:08 +01:00
|
|
|
if (entry_index >= 128)
|
|
|
|
{
|
|
|
|
log_warning("Invalid game command for scenery placement, entry_index = %u", entry_index);
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
if (!sub_68B044()) {
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-11 21:00:22 +01:00
|
|
|
rct_scenery_entry *scenery_entry = g_largeSceneryEntries[entry_index];
|
2016-01-03 00:49:08 +01:00
|
|
|
if (scenery_entry == (rct_scenery_entry *)0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
log_warning("Invalid game command for scenery placement, entry_index = %u", entry_index);
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-11-14 17:44:03 +01:00
|
|
|
if(scenery_entry->large_scenery.var_11 != 0xFF){
|
|
|
|
banner_id = create_new_banner(flags);
|
|
|
|
|
|
|
|
if (banner_id == MAX_BANNERS) {
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
|
|
|
rct_banner* banner = &gBanners[banner_id];
|
|
|
|
banner->flags |= BANNER_FLAG_1;
|
|
|
|
banner->type = 0;
|
|
|
|
banner->x = x / 32;
|
|
|
|
banner->y = y / 32;
|
|
|
|
|
|
|
|
int rideIndex = banner_get_closest_ride_index(x, y, z);
|
|
|
|
if (rideIndex != -1) {
|
|
|
|
banner->colour = rideIndex;
|
|
|
|
banner->flags |= BANNER_FLAG_2;
|
2015-06-14 13:56:12 +02:00
|
|
|
}
|
2015-11-14 17:44:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
sint16 maxHeight = 0xFFFF;
|
|
|
|
for (rct_large_scenery_tile* tile = scenery_entry->large_scenery.tiles;
|
|
|
|
tile->x_offset != -1;
|
|
|
|
tile++) {
|
|
|
|
|
|
|
|
rct_xy16 curTile = {
|
|
|
|
.x = tile->x_offset,
|
|
|
|
.y = tile->y_offset
|
|
|
|
};
|
|
|
|
|
|
|
|
rotate_map_coordinates(&curTile.x, &curTile.y, rotation);
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
curTile.x += x;
|
|
|
|
curTile.y += y;
|
|
|
|
|
|
|
|
if(curTile.x >= 0x1FFF || curTile.y >= 0x1FFF || curTile.x < 0 || curTile.y < 0){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element* map_element = map_get_surface_element_at(curTile.x / 32, curTile.y / 32);
|
|
|
|
if(map_element != NULL){
|
|
|
|
int height = map_element->base_height * 8;
|
|
|
|
|
|
|
|
if(map_element->properties.scenerymultiple.type & 0xF){
|
|
|
|
height += 16;
|
|
|
|
if(map_element->properties.scenerymultiple.type & 0x10){
|
|
|
|
height += 16;
|
2015-06-14 13:56:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
if(height > maxHeight){
|
|
|
|
maxHeight = height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(z != 0){
|
|
|
|
maxHeight = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, sint16) = maxHeight;
|
|
|
|
uint8 tile_num = 0;
|
|
|
|
for (rct_large_scenery_tile* tile = scenery_entry->large_scenery.tiles;
|
|
|
|
tile->x_offset != -1;
|
|
|
|
tile++, tile_num++) {
|
|
|
|
|
|
|
|
rct_xy16 curTile = {
|
|
|
|
.x = tile->x_offset,
|
|
|
|
.y = tile->y_offset
|
|
|
|
};
|
2015-11-10 22:34:09 +01:00
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
rotate_map_coordinates(&curTile.x, &curTile.y, rotation);
|
|
|
|
|
|
|
|
curTile.x += x;
|
|
|
|
curTile.y += y;
|
|
|
|
|
|
|
|
int zLow = (tile->z_offset + maxHeight) / 8;
|
|
|
|
int zHigh = (tile->z_clearance / 8) + zLow;
|
|
|
|
|
|
|
|
int bx = tile->var_7 >> 12;
|
|
|
|
bx <<= rotation;
|
|
|
|
uint8 bl = bx;
|
|
|
|
uint8 bh = bl >> 4;
|
|
|
|
bl &= 0xF;
|
|
|
|
bl |= bh;
|
|
|
|
uint8 F43887 = bl;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x00F43892, sint16) = curTile.x;
|
|
|
|
RCT2_GLOBAL(0x00F43894, sint16) = curTile.y;
|
|
|
|
RCT2_GLOBAL(0x00F43896, uint32) = (uint32)(ebx - 3); // this is how ebx flags var is passed to 0x006B8D88
|
|
|
|
if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(curTile.x, curTile.y, zLow, zHigh, (void*)0x006B8D88, bl)) {
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) & ELEMENT_IS_UNDERWATER) || (RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) & 2)) {
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-11-10 22:34:09 +01:00
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
int b = RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) & 0x3;
|
|
|
|
if (!gCheatsDisableClearanceChecks) {
|
|
|
|
if (RCT2_GLOBAL(0x00F64F14, uint8) && !(RCT2_GLOBAL(0x00F64F14, uint8) & b)) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
2015-06-14 13:56:12 +02:00
|
|
|
}
|
2015-11-14 17:44:03 +01:00
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x00F64F14, uint8) = b;
|
|
|
|
|
|
|
|
if (curTile.x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) || curTile.y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16)) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_OFF_EDGE_OF_MAP;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
2015-06-14 13:56:12 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-11-14 17:44:03 +01:00
|
|
|
|
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) &&
|
|
|
|
!map_is_location_owned(curTile.x, curTile.y, zLow * 8) &&
|
|
|
|
!gCheatsSandboxMode) {
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
|
|
|
if (!(flags & GAME_COMMAND_FLAG_GHOST)) {
|
|
|
|
footpath_remove_litter(curTile.x, curTile.y, zLow * 8);
|
|
|
|
if (!gCheatsDisableClearanceChecks) {
|
|
|
|
map_remove_walls_at(curTile.x, curTile.y, zLow * 8, zHigh * 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rct_map_element *new_map_element = map_element_insert(curTile.x / 32, curTile.y / 32, zLow, F43887);
|
|
|
|
map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, curTile.x, curTile.y, zLow);
|
|
|
|
|
|
|
|
new_map_element->clearance_height = zHigh;
|
|
|
|
new_map_element->type = MAP_ELEMENT_TYPE_SCENERY_MULTIPLE | rotation;
|
|
|
|
|
2016-01-02 15:52:37 +01:00
|
|
|
new_map_element->properties.scenerymultiple.type =
|
|
|
|
(tile_num << 10) |
|
2015-11-14 17:44:03 +01:00
|
|
|
entry_index;
|
|
|
|
|
|
|
|
new_map_element->properties.scenerymultiple.colour[0] = color1;
|
|
|
|
new_map_element->properties.scenerymultiple.colour[1] = color2;
|
|
|
|
|
|
|
|
if (banner_id != 0xFF) {
|
|
|
|
new_map_element->type |= banner_id & 0xC0;
|
|
|
|
new_map_element->properties.scenerymultiple.colour[0] |= (banner_id & 0x38) << 2;
|
|
|
|
new_map_element->properties.scenerymultiple.colour[1] |= (banner_id & 7) << 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_GHOST) {
|
|
|
|
new_map_element->flags |= MAP_ELEMENT_FLAG_GHOST;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tile_num == 0) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_MAP_ELEMENT, rct_map_element*) = new_map_element;
|
|
|
|
}
|
|
|
|
map_invalidate_tile_full(curTile.x, curTile.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Force ride construction to recheck area
|
|
|
|
RCT2_GLOBAL(0x00F440B0, uint8) |= 8;
|
|
|
|
|
|
|
|
*ebx = (scenery_entry->large_scenery.price * 10) + RCT2_GLOBAL(0x00F4389A, money32);
|
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
*ebx = 0;
|
2015-06-14 13:56:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-10 01:40:59 +01:00
|
|
|
int map_get_station(rct_map_element *mapElement)
|
|
|
|
{
|
|
|
|
return (mapElement->properties.track.sequence & 0x70) >> 4;
|
2014-11-24 03:58:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B280
|
|
|
|
*/
|
|
|
|
void map_element_remove(rct_map_element *mapElement)
|
|
|
|
{
|
2015-06-28 14:31:46 +02:00
|
|
|
if (!map_element_is_last_for_tile(mapElement)){
|
|
|
|
do{
|
|
|
|
*mapElement = *(mapElement + 1);
|
|
|
|
} while (!map_element_is_last_for_tile(++mapElement));
|
|
|
|
}
|
|
|
|
(mapElement - 1)->flags |= MAP_ELEMENT_FLAG_LAST_TILE;
|
|
|
|
mapElement->base_height = 0xFF;
|
|
|
|
|
2015-11-14 12:56:13 +01:00
|
|
|
if ((mapElement + 1) == RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*)){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*)--;
|
2015-06-28 14:31:46 +02:00
|
|
|
}
|
2014-11-24 03:58:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00675A8E
|
|
|
|
*/
|
|
|
|
void map_remove_all_rides()
|
|
|
|
{
|
2015-01-22 01:19:05 +01:00
|
|
|
map_element_iterator it;
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2015-01-22 01:19:05 +01:00
|
|
|
map_element_iterator_begin(&it);
|
|
|
|
do {
|
|
|
|
switch (map_element_get_type(it.element)) {
|
|
|
|
case MAP_ELEMENT_TYPE_PATH:
|
|
|
|
if (it.element->type & 1) {
|
|
|
|
it.element->properties.path.type &= ~8;
|
|
|
|
it.element->properties.path.addition_status = 255;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_ENTRANCE:
|
|
|
|
if (it.element->properties.entrance.type == ENTRANCE_TYPE_PARK_ENTRANCE)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// fall-through
|
|
|
|
case MAP_ELEMENT_TYPE_TRACK:
|
2015-06-09 03:36:02 +02:00
|
|
|
sub_6A7594();
|
2015-07-06 23:12:45 +02:00
|
|
|
footpath_remove_edges_at(it.x * 32, it.y * 32, it.element);
|
2015-01-22 01:19:05 +01:00
|
|
|
map_element_remove(it.element);
|
|
|
|
map_element_iterator_restart_for_tile(&it);
|
|
|
|
break;
|
2014-11-24 03:58:48 +01:00
|
|
|
}
|
2015-01-22 01:19:05 +01:00
|
|
|
} while (map_element_iterator_next(&it));
|
2014-12-17 21:45:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068AB1B
|
|
|
|
*/
|
|
|
|
void map_invalidate_map_selection_tiles()
|
|
|
|
{
|
|
|
|
rct_xy16 *position;
|
|
|
|
|
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 1)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (position = gMapSelectionTiles; position->x != -1; position++)
|
|
|
|
map_invalidate_tile_full(position->x, position->y);
|
|
|
|
}
|
|
|
|
|
2015-07-09 17:04:24 +02:00
|
|
|
void map_get_bounding_box(int ax, int ay, int bx, int by, int *left, int *top, int *right, int *bottom)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
x = ax;
|
|
|
|
y = ay;
|
2015-10-30 11:00:35 +01:00
|
|
|
translate_3d_to_2d(get_current_rotation(), &x, &y);
|
2015-07-09 17:04:24 +02:00
|
|
|
*left = x;
|
|
|
|
*right = x;
|
|
|
|
*top = y;
|
|
|
|
*bottom = y;
|
|
|
|
x = bx;
|
|
|
|
y = ay;
|
2015-10-30 11:00:35 +01:00
|
|
|
translate_3d_to_2d(get_current_rotation(), &x, &y);
|
2015-07-09 17:04:24 +02:00
|
|
|
if (x < *left) *left = x;
|
|
|
|
if (x > *right) *right = x;
|
|
|
|
if (y > *bottom) *bottom = y;
|
|
|
|
if (y < *top) *top = y;
|
|
|
|
x = bx;
|
|
|
|
y = by;
|
2015-10-30 11:00:35 +01:00
|
|
|
translate_3d_to_2d(get_current_rotation(), &x, &y);
|
2015-07-09 17:04:24 +02:00
|
|
|
if (x < *left) *left = x;
|
|
|
|
if (x > *right) *right = x;
|
|
|
|
if (y > *bottom) *bottom = y;
|
|
|
|
if (y < *top) *top = y;
|
|
|
|
x = ax;
|
|
|
|
y = by;
|
2015-10-30 11:00:35 +01:00
|
|
|
translate_3d_to_2d(get_current_rotation(), &x, &y);
|
2015-07-09 17:04:24 +02:00
|
|
|
if (x < *left) *left = x;
|
|
|
|
if (x > *right) *right = x;
|
|
|
|
if (y > *bottom) *bottom = y;
|
|
|
|
if (y < *top) *top = y;
|
|
|
|
}
|
|
|
|
|
2014-12-17 21:45:27 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068AAE1
|
|
|
|
*/
|
|
|
|
void map_invalidate_selection_rect()
|
|
|
|
{
|
2015-07-09 17:04:24 +02:00
|
|
|
int x0, y0, x1, y1, left, right, top, bottom;
|
2015-11-15 22:05:30 +01:00
|
|
|
rct_viewport **vp;
|
2014-12-17 21:45:27 +01:00
|
|
|
|
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0)))
|
|
|
|
return;
|
|
|
|
|
2015-07-09 17:04:24 +02:00
|
|
|
x0 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) + 16;
|
|
|
|
y0 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) + 16;
|
|
|
|
x1 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) + 16;
|
|
|
|
y1 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + 16;
|
|
|
|
map_get_bounding_box(x0, y0, x1, y1, &left, &top, &right, &bottom);
|
|
|
|
left -= 32;
|
|
|
|
right += 32;
|
|
|
|
bottom += 32;
|
|
|
|
top -= 32 + 2080;
|
|
|
|
|
2015-11-15 22:05:30 +01:00
|
|
|
vp = RCT2_ADDRESS(RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY, rct_viewport*);
|
|
|
|
while (*vp != NULL) {
|
|
|
|
viewport_invalidate(*vp, left, top, right, bottom);
|
|
|
|
vp++;
|
2015-07-09 17:04:24 +02:00
|
|
|
}
|
2015-01-15 00:38:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B111
|
|
|
|
*/
|
|
|
|
void map_reorganise_elements()
|
|
|
|
{
|
2015-06-28 17:50:21 +02:00
|
|
|
platform_set_cursor(CURSOR_ZZZ);
|
|
|
|
|
2016-01-14 21:18:55 +01:00
|
|
|
rct_map_element* new_map_elements = malloc(0x30000 * sizeof(rct_map_element));
|
2015-06-28 17:50:21 +02:00
|
|
|
rct_map_element* new_elements_pointer = new_map_elements;
|
|
|
|
|
|
|
|
if (new_map_elements == NULL || new_map_elements == (rct_map_element*)-1){
|
|
|
|
error_string_quit(4370, 0xFFFF);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-30 19:08:49 +02:00
|
|
|
uint32 num_elements;
|
|
|
|
|
2015-06-28 19:59:55 +02:00
|
|
|
for (int y = 0; y < 256; y++) {
|
|
|
|
for (int x = 0; x < 256; x++) {
|
|
|
|
rct_map_element *startElement = map_get_first_element_at(x, y);
|
|
|
|
rct_map_element *endElement = startElement;
|
2015-06-28 17:50:21 +02:00
|
|
|
while (!map_element_is_last_for_tile(endElement++));
|
|
|
|
|
2015-06-30 19:08:49 +02:00
|
|
|
num_elements = endElement - startElement;
|
|
|
|
memcpy(new_elements_pointer, startElement, num_elements * sizeof(rct_map_element));
|
|
|
|
new_elements_pointer += num_elements;
|
2015-06-28 17:50:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-30 19:08:49 +02:00
|
|
|
num_elements = (new_elements_pointer - new_map_elements);
|
2015-06-28 17:50:21 +02:00
|
|
|
memcpy(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element), new_map_elements, num_elements * sizeof(rct_map_element));
|
2015-06-30 19:08:49 +02:00
|
|
|
memset(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element) + num_elements, 0, (0x30000 - num_elements) * sizeof(rct_map_element));
|
2015-06-28 17:50:21 +02:00
|
|
|
|
2016-01-14 21:18:55 +01:00
|
|
|
free(new_map_elements);
|
2015-06-28 17:50:21 +02:00
|
|
|
|
|
|
|
map_update_tile_pointers();
|
2015-01-15 00:38:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B044
|
|
|
|
*/
|
|
|
|
int sub_68B044()
|
|
|
|
{
|
2015-11-14 12:56:13 +01:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
|
2015-06-28 14:53:24 +02:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (int i = 1000; i != 0; --i)
|
|
|
|
sub_68B089();
|
|
|
|
|
2015-11-14 12:56:13 +01:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
|
2015-06-28 14:53:24 +02:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
map_reorganise_elements();
|
|
|
|
|
2015-11-14 12:56:13 +01:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
|
2015-06-28 14:53:24 +02:00
|
|
|
return 1;
|
|
|
|
else{
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = 894;
|
2015-06-28 14:53:24 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2015-01-15 00:38:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B1F6
|
|
|
|
*/
|
|
|
|
rct_map_element *map_element_insert(int x, int y, int z, int flags)
|
|
|
|
{
|
|
|
|
rct_map_element *originalMapElement, *newMapElement, *insertedElement;
|
|
|
|
|
|
|
|
sub_68B044();
|
|
|
|
|
2015-11-14 12:56:13 +01:00
|
|
|
newMapElement = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*);
|
2015-01-15 00:38:48 +01:00
|
|
|
originalMapElement = TILE_MAP_ELEMENT_POINTER(y * 256 + x);
|
|
|
|
|
|
|
|
// Set tile index pointer to point to new element block
|
|
|
|
TILE_MAP_ELEMENT_POINTER(y * 256 + x) = newMapElement;
|
|
|
|
|
|
|
|
// Copy all elements that are below the insert height
|
|
|
|
while (z >= originalMapElement->base_height) {
|
|
|
|
// Copy over map element
|
|
|
|
*newMapElement = *originalMapElement;
|
|
|
|
originalMapElement->base_height = 255;
|
|
|
|
originalMapElement++;
|
|
|
|
newMapElement++;
|
|
|
|
|
|
|
|
if ((newMapElement - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE) {
|
|
|
|
// No more elements above the insert element
|
|
|
|
(newMapElement - 1)->flags &= ~MAP_ELEMENT_FLAG_LAST_TILE;
|
|
|
|
flags |= MAP_ELEMENT_FLAG_LAST_TILE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert new map element
|
|
|
|
insertedElement = newMapElement;
|
|
|
|
newMapElement->base_height = z;
|
|
|
|
newMapElement->flags = flags;
|
|
|
|
newMapElement->clearance_height = z;
|
|
|
|
*((uint32*)&newMapElement->properties) = 0;
|
|
|
|
newMapElement++;
|
|
|
|
|
|
|
|
// Insert rest of map elements above insert height
|
|
|
|
if (!(flags & MAP_ELEMENT_FLAG_LAST_TILE)) {
|
|
|
|
do {
|
|
|
|
// Copy over map element
|
|
|
|
*newMapElement = *originalMapElement;
|
|
|
|
originalMapElement->base_height = 255;
|
|
|
|
originalMapElement++;
|
|
|
|
newMapElement++;
|
|
|
|
} while (!((newMapElement - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE));
|
|
|
|
}
|
|
|
|
|
2015-11-14 12:56:13 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) = newMapElement;
|
2015-01-15 00:38:48 +01:00
|
|
|
return insertedElement;
|
|
|
|
}
|
|
|
|
|
2015-09-06 14:37:00 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068BB18
|
|
|
|
*/
|
|
|
|
static void map_obstruction_set_error_text(rct_map_element *mapElement)
|
|
|
|
{
|
|
|
|
rct_string_id errorStringId;
|
|
|
|
rct_ride *ride;
|
|
|
|
rct_scenery_entry *sceneryEntry;
|
|
|
|
|
|
|
|
errorStringId = STR_OBJECT_IN_THE_WAY;
|
|
|
|
switch (map_element_get_type(mapElement)) {
|
|
|
|
case MAP_ELEMENT_TYPE_SURFACE:
|
|
|
|
errorStringId = STR_RAISE_OR_LOWER_LAND_FIRST;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_PATH:
|
|
|
|
errorStringId = STR_FOOTPATH_IN_THE_WAY;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_TRACK:
|
|
|
|
ride = GET_RIDE(mapElement->properties.track.ride_index);
|
|
|
|
errorStringId = STR_X_IN_THE_WAY;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = ride->name;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = ride->name_arguments;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY:
|
|
|
|
sceneryEntry = g_smallSceneryEntries[mapElement->properties.scenery.type];
|
|
|
|
errorStringId = STR_X_IN_THE_WAY;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = sceneryEntry->name;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_ENTRANCE:
|
|
|
|
switch (mapElement->properties.entrance.type) {
|
|
|
|
case ENTRANCE_TYPE_RIDE_ENTRANCE:
|
|
|
|
errorStringId = STR_RIDE_ENTRANCE_IN_THE_WAY;
|
|
|
|
break;
|
|
|
|
case ENTRANCE_TYPE_RIDE_EXIT:
|
|
|
|
errorStringId = STR_RIDE_EXIT_IN_THE_WAY;
|
|
|
|
break;
|
|
|
|
case ENTRANCE_TYPE_PARK_ENTRANCE:
|
|
|
|
errorStringId = STR_PARK_ENTRANCE_IN_THE_WAY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_FENCE:
|
|
|
|
sceneryEntry = g_wallSceneryEntries[mapElement->properties.scenery.type];
|
|
|
|
errorStringId = STR_X_IN_THE_WAY;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = sceneryEntry->name;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE:
|
|
|
|
sceneryEntry = g_largeSceneryEntries[mapElement->properties.scenery.type];
|
|
|
|
errorStringId = STR_X_IN_THE_WAY;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = sceneryEntry->name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = errorStringId;
|
|
|
|
}
|
|
|
|
|
2015-01-15 00:38:48 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B932
|
2015-11-15 05:45:13 +01:00
|
|
|
* ax = x
|
|
|
|
* cx = y
|
|
|
|
* dl = zLow
|
|
|
|
* dh = zHigh
|
|
|
|
* ebp = clearFunc
|
|
|
|
* bl = bl
|
2015-01-15 00:38:48 +01:00
|
|
|
*/
|
|
|
|
int map_can_construct_with_clear_at(int x, int y, int zLow, int zHigh, void *clearFunc, uint8 bl)
|
|
|
|
{
|
2015-07-25 03:03:06 +02:00
|
|
|
RCT2_GLOBAL(0x00F1AD40, void*) = clearFunc;
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) = 1;
|
2015-07-25 03:03:06 +02:00
|
|
|
if (x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) || y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) || x < 32 || y < 32) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_OFF_EDGE_OF_MAP;
|
2015-10-20 20:16:30 +02:00
|
|
|
return false;
|
2015-07-25 03:03:06 +02:00
|
|
|
}
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_SURFACE) {
|
|
|
|
if (zLow < map_element->clearance_height && zHigh > map_element->base_height && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) {
|
|
|
|
if (map_element->flags & (bl & 0x0F)) {
|
|
|
|
goto loc_68BABC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int water_height = ((map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK) * 2);
|
2015-07-25 16:50:59 +02:00
|
|
|
if (water_height && water_height > zLow && map_element->base_height < zHigh) {
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) |= 4;
|
2015-07-25 16:50:59 +02:00
|
|
|
if (water_height < zHigh) {
|
2015-07-25 03:03:06 +02:00
|
|
|
goto loc_68BAE6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loc_68B9B7:
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION) {
|
|
|
|
int al = zHigh - map_element->base_height;
|
|
|
|
if (al >= 0) {
|
|
|
|
if (al > 18) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_LOCAL_AUTHORITY_WONT_ALLOW_CONSTRUCTION_ABOVE_TREE_HEIGHT;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((bl & 0xF0) != 0xF0) {
|
|
|
|
if (map_element->base_height >= zHigh) {
|
|
|
|
// loc_68BA81
|
2015-08-27 16:19:17 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) |= 2;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) &= 0xFE;
|
2015-07-25 03:03:06 +02:00
|
|
|
} else {
|
|
|
|
int al = map_element->base_height;
|
|
|
|
int ah = al;
|
|
|
|
int cl = al;
|
|
|
|
int ch = al;
|
2015-07-25 16:50:59 +02:00
|
|
|
uint8 slope = map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK;
|
2015-07-25 03:03:06 +02:00
|
|
|
if (slope & 1) {
|
|
|
|
al += 2;
|
|
|
|
if (slope == 0x1B)
|
|
|
|
al += 2;
|
|
|
|
}
|
|
|
|
if (slope & 2) {
|
|
|
|
ah += 2;
|
|
|
|
if (slope == 0x17)
|
|
|
|
ah += 2;
|
|
|
|
}
|
|
|
|
if (slope & 4) {
|
|
|
|
cl += 2;
|
|
|
|
if (slope == 0x1E)
|
|
|
|
cl += 2;
|
|
|
|
}
|
|
|
|
if (slope & 8) {
|
|
|
|
ch += 2;
|
|
|
|
if (slope == 0x1D)
|
|
|
|
ch += 2;
|
|
|
|
}
|
|
|
|
int bh = zLow + 4;
|
2015-10-28 08:02:30 +01:00
|
|
|
if ((!(bl & 1) || ((bl & 0x10 || zLow >= al) && bh >= al)) &&
|
|
|
|
(!(bl & 2) || ((bl & 0x20 || zLow >= ah) && bh >= ah)) &&
|
|
|
|
(!(bl & 4) || ((bl & 0x40 || zLow >= cl) && bh >= cl)) &&
|
|
|
|
(!(bl & 8) || ((bl & 0x80 || zLow >= ch) && bh >= ch))) {
|
2015-07-25 03:03:06 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
loc_68BABC:
|
|
|
|
if (RCT2_GLOBAL(0x00F1AD40, void*) != (void*)0xFFFFFFFF) {
|
|
|
|
int zero = 0;
|
|
|
|
if (!(RCT2_CALLFUNC_X((int)RCT2_GLOBAL(0x00F1AD40, void*), &zero, &zero, &zero, &zero, (int*)&map_element, &zero, &zero) & 0x100)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (map_element != (rct_map_element*)0xFFFFFFF) {
|
2015-09-06 14:37:00 +02:00
|
|
|
map_obstruction_set_error_text(map_element);
|
2015-07-25 03:03:06 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
loc_68BAE6:
|
|
|
|
if (RCT2_GLOBAL(0x00F1AD40, void*) != (void*)0xFFFFFFFF) {
|
|
|
|
int zero = 0;
|
|
|
|
if (!(RCT2_CALLFUNC_X((int)RCT2_GLOBAL(0x00F1AD40, void*), &zero, &zero, &zero, &zero, (int*)&map_element, &zero, &zero) & 0x100)) {
|
|
|
|
goto loc_68B9B7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (map_element != (rct_map_element*)0xFFFFFFF) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CANNOT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_WATER;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!map_element_is_last_for_tile(map_element++));
|
|
|
|
return true;
|
2015-01-15 00:38:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B93A
|
|
|
|
*/
|
|
|
|
int map_can_construct_at(int x, int y, int zLow, int zHigh, uint8 bl)
|
|
|
|
{
|
|
|
|
return map_can_construct_with_clear_at(x, y, zLow, zHigh, (void*)0xFFFFFFFF, bl);
|
2015-02-13 21:55:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-02-13 21:55:49 +01:00
|
|
|
* rct2: 0x006E5935
|
|
|
|
*/
|
|
|
|
void map_remove_intersecting_walls(int x, int y, int z0, int z1, int direction)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
|
|
|
mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (mapElement->clearance_height <= z0 || mapElement->base_height >= z1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (direction != (mapElement->type & 3))
|
|
|
|
continue;
|
|
|
|
|
2015-06-17 17:32:50 +02:00
|
|
|
map_element_remove_banner_entry(mapElement);
|
2015-07-06 19:57:36 +02:00
|
|
|
map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72);
|
2015-02-13 21:55:49 +01:00
|
|
|
map_element_remove(mapElement);
|
2015-06-17 17:32:50 +02:00
|
|
|
mapElement--;
|
2015-02-13 21:55:49 +01:00
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
2015-03-22 18:04:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates grass length, scenery age and jumping fountains.
|
|
|
|
*
|
|
|
|
* rct2: 0x006646E1
|
|
|
|
*/
|
|
|
|
void map_update_tiles()
|
|
|
|
{
|
|
|
|
int ignoreScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER;
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & ignoreScreenFlags)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Update 43 more tiles
|
|
|
|
for (int j = 0; j < 43; j++) {
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
uint16 interleaved_xy = RCT2_GLOBAL(RCT2_ADDRESS_GRASS_SCENERY_TILEPOS, sint16);
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
x = (x << 1) | (interleaved_xy & 1);
|
|
|
|
interleaved_xy >>= 1;
|
|
|
|
y = (y << 1) | (interleaved_xy & 1);
|
|
|
|
interleaved_xy >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element *mapElement = map_get_surface_element_at(x, y);
|
|
|
|
if (mapElement != NULL) {
|
|
|
|
map_update_grass_length(x * 32, y * 32, mapElement);
|
|
|
|
scenery_update_tile(x * 32, y * 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GRASS_SCENERY_TILEPOS, sint16)++;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GRASS_SCENERY_TILEPOS, sint16) &= 0xFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006647A1
|
|
|
|
*/
|
|
|
|
static void map_update_grass_length(int x, int y, rct_map_element *mapElement)
|
|
|
|
{
|
|
|
|
// Check if tile is grass
|
|
|
|
if ((mapElement->properties.surface.terrain & 0xE0) && !(mapElement->type & 3))
|
|
|
|
return;
|
|
|
|
|
|
|
|
int grassLength = mapElement->properties.surface.grass_length & 7;
|
|
|
|
|
|
|
|
// Check if grass is underwater or outside park
|
|
|
|
int waterHeight = (mapElement->properties.surface.terrain & 0x1F) * 2;
|
|
|
|
if (waterHeight > mapElement->base_height || !map_is_location_in_park(x, y)) {
|
|
|
|
if (grassLength != GRASS_LENGTH_CLEAR_0)
|
|
|
|
map_set_grass_length(x, y, mapElement, GRASS_LENGTH_CLEAR_0);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Grass can't grow any further
|
|
|
|
if (grassLength == GRASS_LENGTH_CLUMPS_2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int z0 = mapElement->base_height;
|
|
|
|
int z1 = mapElement->base_height + 2;
|
|
|
|
if (mapElement->properties.surface.slope & 0x10)
|
|
|
|
z1 += 2;
|
|
|
|
|
|
|
|
// Check objects above grass
|
|
|
|
rct_map_element *mapElementAbove = mapElement;
|
|
|
|
for (;;) {
|
|
|
|
if (mapElementAbove->flags & MAP_ELEMENT_FLAG_LAST_TILE) {
|
|
|
|
// Grow grass
|
|
|
|
if (mapElement->properties.surface.grass_length < 0xF0) {
|
|
|
|
mapElement->properties.surface.grass_length += 0x10;
|
|
|
|
} else {
|
|
|
|
mapElement->properties.surface.grass_length += 0x10;
|
|
|
|
mapElement->properties.surface.grass_length ^= 8;
|
|
|
|
if (mapElement->properties.surface.grass_length & 8) {
|
|
|
|
// Random growth rate
|
|
|
|
mapElement->properties.surface.grass_length |= scenario_rand() & 0x70;
|
|
|
|
} else {
|
|
|
|
// Increase length
|
|
|
|
map_set_grass_length(x, y, mapElement, grassLength + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mapElementAbove++;
|
|
|
|
if (map_element_get_type(mapElementAbove) == MAP_ELEMENT_TYPE_FENCE)
|
|
|
|
continue;
|
|
|
|
if (z0 >= mapElementAbove->clearance_height)
|
|
|
|
continue;
|
|
|
|
if (z1 < mapElementAbove->base_height)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void map_set_grass_length(int x, int y, rct_map_element *mapElement, int length)
|
|
|
|
{
|
|
|
|
int z0, z1;
|
|
|
|
|
|
|
|
mapElement->properties.surface.grass_length = length;
|
|
|
|
z0 = mapElement->base_height * 8;
|
|
|
|
z1 = z0 + 16;
|
2015-07-06 19:57:36 +02:00
|
|
|
map_invalidate_tile(x, y, z0, z1);
|
2015-06-09 03:36:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void sub_6A7594()
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(0x00F3EFF4, uint32) = 0x00F3EFF8;
|
2015-06-09 14:24:02 +02:00
|
|
|
}
|
2015-06-09 17:19:05 +02:00
|
|
|
|
2015-06-15 22:56:26 +02:00
|
|
|
int map_element_get_banner_index(rct_map_element *mapElement)
|
|
|
|
{
|
|
|
|
rct_scenery_entry* sceneryEntry;
|
|
|
|
|
|
|
|
switch (map_element_get_type(mapElement)) {
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE:
|
|
|
|
sceneryEntry = g_largeSceneryEntries[mapElement->properties.scenerymultiple.type & 0x3FF];
|
|
|
|
if (sceneryEntry->large_scenery.var_11 == 0xFF)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return
|
|
|
|
(mapElement->type & MAP_ELEMENT_QUADRANT_MASK) |
|
2015-06-17 17:32:50 +02:00
|
|
|
((mapElement->properties.scenerymultiple.colour[0] & 0xE0) >> 2) |
|
2015-06-15 22:56:26 +02:00
|
|
|
((mapElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5);
|
|
|
|
case MAP_ELEMENT_TYPE_FENCE:
|
|
|
|
sceneryEntry = g_wallSceneryEntries[mapElement->properties.fence.type];
|
|
|
|
if (sceneryEntry->wall.var_0D == 0xFF)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return mapElement->properties.fence.item[0];
|
|
|
|
case MAP_ELEMENT_TYPE_BANNER:
|
|
|
|
return mapElement->properties.banner.index;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void map_element_remove_banner_entry(rct_map_element *mapElement)
|
|
|
|
{
|
|
|
|
int bannerIndex = map_element_get_banner_index(mapElement);
|
|
|
|
if (bannerIndex == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rct_banner* banner = &gBanners[bannerIndex];
|
|
|
|
if (banner->type != BANNER_NULL) {
|
|
|
|
window_close_by_number(WC_BANNER, bannerIndex);
|
|
|
|
banner->type = BANNER_NULL;
|
|
|
|
user_string_free(banner->string_idx);
|
|
|
|
}
|
2015-06-20 17:24:38 +02:00
|
|
|
}
|
|
|
|
|
2015-07-02 01:37:55 +02:00
|
|
|
/**
|
|
|
|
* Removes elements that are out of the map size range and crops the park perimeter.
|
|
|
|
* rct2: 0x0068ADBC
|
|
|
|
*/
|
|
|
|
void map_remove_out_of_range_elements()
|
2015-06-20 17:24:38 +02:00
|
|
|
{
|
|
|
|
int mapMaxXY = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16);
|
|
|
|
|
|
|
|
for (int y = 0; y < (256 * 32); y += 32) {
|
|
|
|
for (int x = 0; x < (256 * 32); x += 32) {
|
|
|
|
if (x == 0 || y == 0 || x >= mapMaxXY || y >= mapMaxXY) {
|
|
|
|
sub_68AE2A(x, y);
|
|
|
|
} else if (x >= mapMaxXY - 32 || y >= mapMaxXY - 32) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) += 32;
|
|
|
|
map_buy_land_rights(x, y, x, y, 6, GAME_COMMAND_FLAG_APPLY);
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) -= 32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-02 01:37:55 +02:00
|
|
|
/**
|
|
|
|
* Copies the terrain and slope from the edge of the map to the new tiles. Used when increasing the size of the map.
|
|
|
|
* rct2: 0x0068AC15
|
|
|
|
*/
|
|
|
|
void map_extend_boundary_surface()
|
|
|
|
{
|
|
|
|
rct_map_element *existingMapElement, *newMapElement;
|
|
|
|
int x, y, z, slope;
|
|
|
|
|
|
|
|
y = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16) - 2;
|
|
|
|
for (x = 0; x < 256; x++) {
|
|
|
|
existingMapElement = map_get_surface_element_at(x, y - 1);
|
|
|
|
newMapElement = map_get_surface_element_at(x, y);
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-07-02 01:37:55 +02:00
|
|
|
newMapElement->type = (newMapElement->type & 0x7C) | (existingMapElement->type & 0x83);
|
|
|
|
newMapElement->properties.surface.slope = existingMapElement->properties.surface.slope & 0xE0;
|
|
|
|
newMapElement->properties.surface.terrain = existingMapElement->properties.surface.terrain;
|
|
|
|
newMapElement->properties.surface.grass_length = existingMapElement->properties.surface.grass_length;
|
|
|
|
newMapElement->properties.surface.ownership = 0;
|
|
|
|
|
|
|
|
z = existingMapElement->base_height;
|
|
|
|
slope = existingMapElement->properties.surface.slope & 9;
|
|
|
|
if (slope == 9) {
|
|
|
|
z += 2;
|
|
|
|
slope = 0;
|
|
|
|
if (existingMapElement->properties.surface.slope & 0x10) {
|
|
|
|
slope = 1;
|
|
|
|
if (existingMapElement->properties.surface.slope & 0x04) {
|
|
|
|
slope = 8;
|
|
|
|
if (existingMapElement->properties.surface.slope & 0x02) {
|
|
|
|
slope = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (slope & 1) slope |= 2;
|
|
|
|
if (slope & 8) slope |= 4;
|
|
|
|
|
|
|
|
newMapElement->properties.surface.slope |= slope;
|
|
|
|
newMapElement->base_height = z;
|
|
|
|
newMapElement->clearance_height = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
x = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16) - 2;
|
|
|
|
for (y = 0; y < 256; y++) {
|
|
|
|
existingMapElement = map_get_surface_element_at(x - 1, y);
|
|
|
|
newMapElement = map_get_surface_element_at(x, y);
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-07-02 01:37:55 +02:00
|
|
|
newMapElement->type = (newMapElement->type & 0x7C) | (existingMapElement->type & 0x83);
|
|
|
|
newMapElement->properties.surface.slope = existingMapElement->properties.surface.slope & 0xE0;
|
|
|
|
newMapElement->properties.surface.terrain = existingMapElement->properties.surface.terrain;
|
|
|
|
newMapElement->properties.surface.grass_length = existingMapElement->properties.surface.grass_length;
|
|
|
|
newMapElement->properties.surface.ownership = 0;
|
|
|
|
|
|
|
|
z = existingMapElement->base_height;
|
|
|
|
slope = existingMapElement->properties.surface.slope & 3;
|
|
|
|
if (slope == 3) {
|
|
|
|
z += 2;
|
|
|
|
slope = 0;
|
|
|
|
if (existingMapElement->properties.surface.slope & 0x10) {
|
|
|
|
slope = 1;
|
|
|
|
if (existingMapElement->properties.surface.slope & 0x04) {
|
|
|
|
slope = 2;
|
|
|
|
if (existingMapElement->properties.surface.slope & 0x08) {
|
|
|
|
slope = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (slope & 1) slope |= 8;
|
|
|
|
if (slope & 2) slope |= 4;
|
|
|
|
|
|
|
|
newMapElement->properties.surface.slope |= slope;
|
|
|
|
newMapElement->base_height = z;
|
|
|
|
newMapElement->clearance_height = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-06-20 17:24:38 +02:00
|
|
|
static void sub_68AE2A(int x, int y)
|
|
|
|
{
|
|
|
|
for (;;) {
|
|
|
|
rct2_peep_spawn *peepSpawns = RCT2_ADDRESS(RCT2_ADDRESS_PEEP_SPAWNS, rct2_peep_spawn);
|
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
|
if ((peepSpawns[i].x & 0xFFE0) == x && (peepSpawns[i].y & 0xFFE0) == y) {
|
|
|
|
peepSpawns[i].x = 0xFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
|
|
|
next_element:
|
|
|
|
switch (map_element_get_type(mapElement)) {
|
|
|
|
case MAP_ELEMENT_TYPE_SURFACE:
|
|
|
|
mapElement->base_height = 2;
|
|
|
|
mapElement->clearance_height = 2;
|
|
|
|
mapElement->properties.surface.slope = 0;
|
|
|
|
mapElement->properties.surface.terrain = 0;
|
|
|
|
mapElement->properties.surface.grass_length = 1;
|
|
|
|
mapElement->properties.surface.ownership = 0;
|
|
|
|
if (!map_element_is_last_for_tile(mapElement++))
|
|
|
|
goto next_element;
|
|
|
|
|
|
|
|
return;
|
|
|
|
case MAP_ELEMENT_TYPE_ENTRANCE:
|
|
|
|
viewport_interaction_remove_park_entrance(mapElement, x, y);
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_FENCE:
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_REMOVE_THIS;
|
|
|
|
game_do_command(
|
|
|
|
x,
|
|
|
|
GAME_COMMAND_FLAG_APPLY,
|
|
|
|
y,
|
|
|
|
(mapElement->type & MAP_ELEMENT_DIRECTION_MASK) | (mapElement->base_height << 8),
|
|
|
|
GAME_COMMAND_REMOVE_FENCE,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE:
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_REMOVE_THIS;
|
|
|
|
game_do_command(
|
|
|
|
x,
|
|
|
|
(GAME_COMMAND_FLAG_APPLY) | (mapElement->type & MAP_ELEMENT_DIRECTION_MASK),
|
|
|
|
y,
|
|
|
|
(mapElement->base_height) | (((mapElement->properties.scenerymultiple.type >> 8) >> 2) << 8),
|
|
|
|
GAME_COMMAND_REMOVE_LARGE_SCENERY,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_TYPE_BANNER:
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_REMOVE_THIS;
|
|
|
|
game_do_command(
|
|
|
|
x,
|
|
|
|
GAME_COMMAND_FLAG_APPLY,
|
|
|
|
y,
|
|
|
|
(mapElement->base_height) | ((mapElement->properties.banner.position & 3) << 8),
|
|
|
|
GAME_COMMAND_REMOVE_BANNER,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
map_element_remove(mapElement);
|
|
|
|
break;
|
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
}
|
2015-06-21 13:40:44 +02:00
|
|
|
}
|
2015-06-27 16:17:54 +02:00
|
|
|
|
|
|
|
int map_get_highest_z(int tileX, int tileY)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
int z;
|
|
|
|
|
|
|
|
mapElement = map_get_surface_element_at(tileX, tileY);
|
|
|
|
if (mapElement == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
z = mapElement->base_height * 8;
|
|
|
|
|
|
|
|
// Raise z so that is above highest point of land and water on tile
|
|
|
|
if ((mapElement->properties.surface.slope & 0x0F) != 0)
|
|
|
|
z += 16;
|
|
|
|
if ((mapElement->properties.surface.slope & 0x10) != 0)
|
|
|
|
z += 16;
|
|
|
|
|
|
|
|
z = max(z, (mapElement->properties.surface.terrain & 0x1F) * 16);
|
|
|
|
return z;
|
|
|
|
}
|
2015-06-28 18:45:19 +02:00
|
|
|
|
|
|
|
bool map_element_is_underground(rct_map_element *mapElement)
|
|
|
|
{
|
|
|
|
do {
|
|
|
|
mapElement++;
|
|
|
|
if (map_element_is_last_for_tile(mapElement - 1))
|
|
|
|
return false;
|
|
|
|
} while (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SURFACE);
|
|
|
|
return true;
|
|
|
|
}
|
2015-07-06 18:59:37 +02:00
|
|
|
|
|
|
|
rct_map_element *map_get_large_scenery_segment(int x, int y, int z, int direction, int sequence)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
2016-01-03 00:49:08 +01:00
|
|
|
if (mapElement == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-07-06 18:59:37 +02:00
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE)
|
|
|
|
continue;
|
|
|
|
if (mapElement->base_height != z)
|
|
|
|
continue;
|
|
|
|
if ((mapElement->properties.scenerymultiple.type >> 10) != sequence)
|
|
|
|
continue;
|
|
|
|
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != direction)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-11-12 20:22:08 +01:00
|
|
|
rct_map_element *map_get_fence_element_at(int x, int y, int z, int direction)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE)
|
|
|
|
continue;
|
|
|
|
if (mapElement->base_height != z)
|
|
|
|
continue;
|
|
|
|
if (map_element_get_direction(mapElement) != direction)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element *map_get_small_scenery_element_at(int x, int y, int z, int type)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SCENERY)
|
|
|
|
continue;
|
|
|
|
if (mapElement->base_height != z)
|
|
|
|
continue;
|
|
|
|
if (mapElement->properties.scenery.type != type)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-06 18:59:37 +02:00
|
|
|
bool map_large_scenery_get_origin(
|
|
|
|
int x, int y, int z, int direction, int sequence,
|
2015-11-14 17:44:03 +01:00
|
|
|
int *outX, int *outY, int *outZ, rct_map_element** outElement
|
2015-07-06 18:59:37 +02:00
|
|
|
) {
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
rct_scenery_entry *sceneryEntry;
|
|
|
|
rct_large_scenery_tile *tile;
|
2015-07-06 19:57:36 +02:00
|
|
|
sint16 offsetX, offsetY;
|
2015-07-06 18:59:37 +02:00
|
|
|
|
|
|
|
mapElement = map_get_large_scenery_segment(x, y, z, direction, sequence);
|
|
|
|
if (mapElement == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
sceneryEntry = g_largeSceneryEntries[(mapElement->properties.scenerymultiple.type) & 0x3FF];
|
|
|
|
tile = &sceneryEntry->large_scenery.tiles[sequence];
|
|
|
|
|
|
|
|
offsetX = tile->x_offset;
|
|
|
|
offsetY = tile->y_offset;
|
2015-07-06 19:57:36 +02:00
|
|
|
rotate_map_coordinates(&offsetX, &offsetY, direction);
|
2015-07-06 18:59:37 +02:00
|
|
|
|
|
|
|
*outX = x - offsetX;
|
|
|
|
*outY = y - offsetY;
|
|
|
|
*outZ = (z * 8) - tile->z_offset;
|
2015-11-14 17:44:03 +01:00
|
|
|
if (outElement != NULL)
|
|
|
|
*outElement = mapElement;
|
2015-07-06 18:59:37 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-06 18:59:37 +02:00
|
|
|
* rct2: 0x006B9B05
|
|
|
|
*/
|
2015-12-13 19:27:20 +01:00
|
|
|
bool sign_set_colour(int x, int y, int z, int direction, int sequence, uint8 mainColour, uint8 textColour)
|
2015-07-06 18:59:37 +02:00
|
|
|
{
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
rct_scenery_entry *sceneryEntry;
|
|
|
|
rct_large_scenery_tile *sceneryTiles, *tile;
|
2015-07-06 19:57:36 +02:00
|
|
|
sint16 offsetX, offsetY;
|
|
|
|
int x0, y0, z0;
|
2015-07-06 18:59:37 +02:00
|
|
|
|
2015-12-13 19:27:20 +01:00
|
|
|
if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, &mapElement)) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-06 18:59:37 +02:00
|
|
|
|
|
|
|
sceneryEntry = g_largeSceneryEntries[(mapElement->properties.scenerymultiple.type) & 0x3FF];
|
|
|
|
sceneryTiles = sceneryEntry->large_scenery.tiles;
|
|
|
|
|
|
|
|
// Iterate through each tile of the large scenery element
|
|
|
|
sequence = 0;
|
|
|
|
for (tile = sceneryTiles; tile->x_offset != -1; tile++, sequence++) {
|
|
|
|
offsetX = tile->x_offset;
|
|
|
|
offsetY = tile->y_offset;
|
2015-07-06 19:57:36 +02:00
|
|
|
rotate_map_coordinates(&offsetX, &offsetY, direction);
|
2015-07-06 18:59:37 +02:00
|
|
|
|
|
|
|
x = x0 + offsetX;
|
|
|
|
y = y0 + offsetY;
|
|
|
|
z = (z0 + tile->z_offset) / 8;
|
|
|
|
mapElement = map_get_large_scenery_segment(x, y, z, direction, sequence);
|
|
|
|
if (mapElement != NULL) {
|
|
|
|
mapElement->properties.scenerymultiple.colour[0] &= 0xE0;
|
|
|
|
mapElement->properties.scenerymultiple.colour[1] &= 0xE0;
|
|
|
|
mapElement->properties.scenerymultiple.colour[0] |= mainColour;
|
|
|
|
mapElement->properties.scenerymultiple.colour[1] |= textColour;
|
|
|
|
|
2015-07-06 19:57:36 +02:00
|
|
|
map_invalidate_tile(x, y, mapElement->base_height * 8 , mapElement->clearance_height * 8);
|
2015-07-06 18:59:37 +02:00
|
|
|
}
|
|
|
|
}
|
2015-12-13 19:27:20 +01:00
|
|
|
|
|
|
|
return true;
|
2015-07-06 18:59:37 +02:00
|
|
|
}
|
2015-07-06 19:57:36 +02:00
|
|
|
|
2015-07-06 21:29:36 +02:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-06 21:29:36 +02:00
|
|
|
* rct2: 0x006E588E
|
|
|
|
*/
|
|
|
|
void map_remove_walls_at(int x, int y, int z0, int z1)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
|
|
|
z0 /= 8;
|
|
|
|
z1 /= 8;
|
|
|
|
repeat:
|
|
|
|
mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE)
|
|
|
|
continue;
|
|
|
|
if (z0 >= mapElement->clearance_height)
|
|
|
|
continue;
|
|
|
|
if (z1 <= mapElement->base_height)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
map_element_remove_banner_entry(mapElement);
|
2015-11-27 20:17:35 +01:00
|
|
|
map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72);
|
2015-07-06 21:29:36 +02:00
|
|
|
map_element_remove(mapElement);
|
|
|
|
goto repeat;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-06 21:29:36 +02:00
|
|
|
* rct2: 0x006E57E6
|
|
|
|
*/
|
|
|
|
void map_remove_walls_at_z(int x, int y, int z)
|
|
|
|
{
|
|
|
|
map_remove_walls_at(x, y, z, z + 48);
|
|
|
|
}
|
|
|
|
|
2015-07-06 19:57:36 +02:00
|
|
|
static void translate_3d_to_2d(int rotation, int *x, int *y)
|
|
|
|
{
|
|
|
|
int rx, ry;
|
|
|
|
|
|
|
|
switch (rotation & 3) {
|
|
|
|
case 0:
|
|
|
|
rx = (*y) - (*x);
|
|
|
|
ry = (*x) + (*y);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
rx = -(*x) - (*y);
|
|
|
|
ry = (*y) - (*x);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rx = (*x) - (*y);
|
|
|
|
ry = -(*x) - (*y);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
rx = (*x) + (*y);
|
|
|
|
ry = (*x) - (*y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ry /= 2;
|
|
|
|
|
|
|
|
*x = rx;
|
|
|
|
*y = ry;
|
|
|
|
}
|
|
|
|
|
|
|
|
void map_invalidate_tile_under_zoom(int x, int y, int z0, int z1, int maxZoom)
|
|
|
|
{
|
|
|
|
int x1, y1, x2, y2;
|
2015-11-15 22:05:30 +01:00
|
|
|
rct_viewport **vp;
|
2015-07-06 19:57:36 +02:00
|
|
|
|
|
|
|
x += 16;
|
|
|
|
y += 16;
|
2015-10-30 11:00:35 +01:00
|
|
|
translate_3d_to_2d(get_current_rotation(), &x, &y);
|
2015-07-06 19:57:36 +02:00
|
|
|
|
|
|
|
x1 = x - 32;
|
|
|
|
y1 = y - 32 - z1;
|
|
|
|
x2 = x + 32;
|
|
|
|
y2 = y + 32 - z0;
|
|
|
|
|
2015-11-15 22:05:30 +01:00
|
|
|
vp = RCT2_ADDRESS(RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY, rct_viewport*);
|
|
|
|
while (!gOpenRCT2Headless && *vp != 0) {
|
|
|
|
if (maxZoom == -1 || (*vp)->zoom <= maxZoom) {
|
|
|
|
viewport_invalidate(*vp, x1, y1, x2, y2);
|
2015-07-06 19:57:36 +02:00
|
|
|
}
|
2015-11-15 22:05:30 +01:00
|
|
|
vp++;
|
2015-07-06 19:57:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006EC847
|
|
|
|
*/
|
|
|
|
void map_invalidate_tile(int x, int y, int z0, int z1)
|
|
|
|
{
|
|
|
|
map_invalidate_tile_under_zoom(x, y, z0, z1, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006ECB60
|
|
|
|
*/
|
|
|
|
void map_invalidate_tile_zoom1(int x, int y, int z0, int z1)
|
|
|
|
{
|
|
|
|
map_invalidate_tile_under_zoom(x, y, z0, z1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006EC9CE
|
|
|
|
*/
|
|
|
|
void map_invalidate_tile_zoom0(int x, int y, int z0, int z1)
|
|
|
|
{
|
|
|
|
map_invalidate_tile_under_zoom(x, y, z0, z1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006EC6D7
|
|
|
|
*/
|
|
|
|
void map_invalidate_tile_full(int x, int y)
|
|
|
|
{
|
|
|
|
map_invalidate_tile(x, y, 0, 2080);
|
|
|
|
}
|
2015-07-07 20:09:12 +02:00
|
|
|
|
|
|
|
void map_invalidate_element(int x, int y, rct_map_element *mapElement)
|
|
|
|
{
|
2015-11-27 20:17:35 +01:00
|
|
|
map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8);
|
2015-07-07 20:09:12 +02:00
|
|
|
}
|
2015-07-11 19:23:59 +02:00
|
|
|
|
|
|
|
int map_get_tile_side(int mapX, int mapY)
|
|
|
|
{
|
|
|
|
int subMapX = mapX & (32 - 1);
|
|
|
|
int subMapY = mapY & (32 - 1);
|
|
|
|
return (subMapX < subMapY) ?
|
|
|
|
((subMapX + subMapY) < 32 ? 0 : 1):
|
|
|
|
((subMapX + subMapY) < 32 ? 3 : 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int map_get_tile_quadrant(int mapX, int mapY)
|
|
|
|
{
|
|
|
|
int subMapX = mapX & (32 - 1);
|
|
|
|
int subMapY = mapY & (32 - 1);
|
|
|
|
return (subMapX > 16) ?
|
|
|
|
(subMapY < 16 ? 1 : 0):
|
|
|
|
(subMapY < 16 ? 2 : 3);
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00693BFF
|
|
|
|
*/
|
2015-07-25 12:16:59 +02:00
|
|
|
bool map_surface_is_blocked(sint16 x, sint16 y){
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
if (x >= 8192 || y >= 8192)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
mapElement = map_get_surface_element_at(x / 32, y / 32);
|
|
|
|
|
|
|
|
sint16 water_height = mapElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK;
|
|
|
|
water_height *= 2;
|
|
|
|
if (water_height > mapElement->base_height)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
sint16 base_z = mapElement->base_height;
|
|
|
|
sint16 clear_z = mapElement->base_height + 2;
|
|
|
|
if (mapElement->properties.surface.slope & (1 << 4))
|
|
|
|
clear_z += 2;
|
|
|
|
|
|
|
|
while (!map_element_is_last_for_tile(mapElement++)){
|
|
|
|
if (clear_z >= mapElement->clearance_height)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (base_z < mapElement->base_height)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH ||
|
|
|
|
map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_FENCE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SCENERY)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
rct_scenery_entry* scenery = g_smallSceneryEntries[mapElement->properties.scenery.type];
|
|
|
|
if (scenery->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-31 12:42:46 +02:00
|
|
|
/* Clears all map elements, to be used before generating a new map */
|
|
|
|
void map_clear_all_elements()
|
|
|
|
{
|
|
|
|
for (int y = 0; y < (256 * 32); y += 32) {
|
|
|
|
for (int x = 0; x < (256 * 32); x += 32) {
|
|
|
|
sub_68AE2A(x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-01 22:24:24 +02:00
|
|
|
|
|
|
|
money32 place_park_entrance(int flags, sint16 x, sint16 y, sint16 z, uint8 direction) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LAND_PURCHASE * 4;
|
|
|
|
|
2015-10-28 11:44:08 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, sint16) = x;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, sint16) = y;
|
2015-10-01 22:24:24 +02:00
|
|
|
// ??
|
2015-10-28 11:44:08 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, sint16) = (z & 0xFF) << 4;
|
2015-10-01 22:24:24 +02:00
|
|
|
|
|
|
|
if (!sub_68B044()) {
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x <= 32 || y <= 32 || x >= (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) - 32) || y >= (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) - 32)) {
|
|
|
|
RCT2_GLOBAL(0x00141E9AC, rct_string_id) = 3215;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
sint8 entranceNum = -1;
|
|
|
|
for (uint8 i = 0; i < 4; ++i) {
|
|
|
|
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] == (sint16)0x8000) {
|
|
|
|
entranceNum = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entranceNum == -1) {
|
|
|
|
RCT2_GLOBAL(0x00141E9AC, rct_string_id) = 3227;
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[entranceNum] = x;
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[entranceNum] = y;
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[entranceNum] = (z & 0xFF) << 4;
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8)[entranceNum] = direction;
|
|
|
|
}
|
|
|
|
|
2015-10-04 01:35:26 +02:00
|
|
|
sint8 zLow = (z & 0xFF) * 2;
|
|
|
|
sint8 zHigh = zLow + 12;
|
2015-10-01 22:24:24 +02:00
|
|
|
if (!map_can_construct_at(x, y, zLow, zHigh, 0xF)) {
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
|
|
|
|
|
|
|
if (!(flags & GAME_COMMAND_FLAG_GHOST)) {
|
|
|
|
rct_map_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32);
|
|
|
|
surfaceElement->properties.surface.ownership = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element* newElement = map_element_insert(x / 32, y / 32, zLow, 0xF);
|
|
|
|
newElement->clearance_height = zHigh;
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_GHOST) {
|
|
|
|
newElement->flags |= MAP_ELEMENT_FLAG_GHOST;
|
|
|
|
}
|
|
|
|
|
|
|
|
newElement->type = MAP_ELEMENT_TYPE_ENTRANCE;
|
|
|
|
newElement->type |= direction;
|
|
|
|
newElement->properties.entrance.index = 0;
|
|
|
|
newElement->properties.entrance.type = ENTRANCE_TYPE_PARK_ENTRANCE;
|
|
|
|
newElement->properties.entrance.path_type = RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_PATH_ID, uint16) & 0xFF;
|
|
|
|
|
|
|
|
if (!(flags & GAME_COMMAND_FLAG_GHOST)) {
|
|
|
|
footpath_connect_edges(x, y, newElement, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
update_park_fences(x, y);
|
|
|
|
update_park_fences(x - 32, y);
|
|
|
|
update_park_fences(x + 32, y);
|
|
|
|
update_park_fences(x, y - 32);
|
|
|
|
update_park_fences(x, y + 32);
|
|
|
|
|
2015-11-27 20:17:35 +01:00
|
|
|
map_invalidate_tile(x, y, newElement->base_height * 8, newElement->clearance_height * 8);
|
2015-10-01 22:24:24 +02:00
|
|
|
|
|
|
|
map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, x, y, zLow);
|
|
|
|
}
|
|
|
|
|
|
|
|
x += TileDirectionDelta[(direction - 1) & 0x3].x;
|
|
|
|
y += TileDirectionDelta[(direction - 1) & 0x3].y;
|
|
|
|
|
|
|
|
if (!map_can_construct_at(x, y, zLow, zHigh, 0xF)) {
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
|
|
|
|
|
|
|
if (!(flags & GAME_COMMAND_FLAG_GHOST)) {
|
|
|
|
rct_map_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32);
|
|
|
|
surfaceElement->properties.surface.ownership = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element* newElement = map_element_insert(x / 32, y / 32, zLow, 0xF);
|
|
|
|
newElement->clearance_height = zHigh;
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_GHOST) {
|
|
|
|
newElement->flags |= MAP_ELEMENT_FLAG_GHOST;
|
|
|
|
}
|
|
|
|
|
|
|
|
newElement->type = MAP_ELEMENT_TYPE_ENTRANCE;
|
|
|
|
newElement->type |= direction;
|
|
|
|
newElement->properties.entrance.index = 1;
|
|
|
|
newElement->properties.entrance.type = ENTRANCE_TYPE_PARK_ENTRANCE;
|
|
|
|
|
|
|
|
update_park_fences(x, y);
|
|
|
|
update_park_fences(x - 32, y);
|
|
|
|
update_park_fences(x + 32, y);
|
|
|
|
update_park_fences(x, y - 32);
|
|
|
|
update_park_fences(x, y + 32);
|
|
|
|
|
2015-11-27 20:17:35 +01:00
|
|
|
map_invalidate_tile(x, y, newElement->base_height * 8, newElement->clearance_height * 8);
|
2015-10-01 22:24:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
x += TileDirectionDelta[(direction + 1) & 0x3].x * 2;
|
|
|
|
y += TileDirectionDelta[(direction + 1) & 0x3].y * 2;
|
|
|
|
|
|
|
|
if (!map_can_construct_at(x, y, zLow, zHigh, 0xF)) {
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_APPLY) {
|
|
|
|
|
|
|
|
if (!(flags & GAME_COMMAND_FLAG_GHOST)) {
|
|
|
|
rct_map_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32);
|
|
|
|
surfaceElement->properties.surface.ownership = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element* newElement = map_element_insert(x / 32, y / 32, zLow, 0xF);
|
|
|
|
newElement->clearance_height = zHigh;
|
|
|
|
|
|
|
|
if (flags & GAME_COMMAND_FLAG_GHOST) {
|
|
|
|
newElement->flags |= MAP_ELEMENT_FLAG_GHOST;
|
|
|
|
}
|
|
|
|
|
|
|
|
newElement->type = MAP_ELEMENT_TYPE_ENTRANCE;
|
|
|
|
newElement->type |= direction;
|
|
|
|
newElement->properties.entrance.index = 2;
|
|
|
|
newElement->properties.entrance.type = ENTRANCE_TYPE_PARK_ENTRANCE;
|
|
|
|
|
|
|
|
update_park_fences(x, y);
|
|
|
|
update_park_fences(x - 32, y);
|
|
|
|
update_park_fences(x + 32, y);
|
|
|
|
update_park_fences(x, y - 32);
|
|
|
|
update_park_fences(x, y + 32);
|
|
|
|
|
2015-11-27 20:17:35 +01:00
|
|
|
map_invalidate_tile(x, y, newElement->base_height * 8, newElement->clearance_height * 8);
|
2015-10-01 22:24:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006666E7
|
|
|
|
*/
|
2015-10-01 22:24:24 +02:00
|
|
|
void game_command_place_park_entrance(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) {
|
|
|
|
*ebx = place_park_entrance(
|
|
|
|
*ebx & 0xFF,
|
|
|
|
*eax & 0xFFFF,
|
|
|
|
*ecx & 0xFFFF,
|
|
|
|
*edx & 0xFFFF,
|
|
|
|
(*ebx >> 8) & 0xFF);
|
2015-10-25 17:00:21 +01:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:25:43 +01:00
|
|
|
void game_command_set_banner_name(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) {
|
|
|
|
static char newName[128];
|
|
|
|
|
2016-01-03 00:49:08 +01:00
|
|
|
if ((*ecx >= MAX_BANNERS) || (*ecx < 0))
|
|
|
|
{
|
|
|
|
log_warning("Invalid game command for setting banner name, banner id = %d", *ecx);
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-10-31 09:25:43 +01:00
|
|
|
rct_banner* banner = &gBanners[*ecx];
|
|
|
|
|
|
|
|
int nameChunkIndex = *eax & 0xFFFF;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS * 4;
|
|
|
|
int nameChunkOffset = nameChunkIndex - 1;
|
|
|
|
if (nameChunkOffset < 0)
|
|
|
|
nameChunkOffset = 2;
|
|
|
|
nameChunkOffset *= 12;
|
2016-01-03 00:49:08 +01:00
|
|
|
nameChunkOffset = min(nameChunkOffset, countof(newName) - 12);
|
2015-10-31 09:25:43 +01:00
|
|
|
RCT2_GLOBAL(newName + nameChunkOffset + 0, uint32) = *edx;
|
|
|
|
RCT2_GLOBAL(newName + nameChunkOffset + 4, uint32) = *ebp;
|
|
|
|
RCT2_GLOBAL(newName + nameChunkOffset + 8, uint32) = *edi;
|
|
|
|
|
|
|
|
if (nameChunkIndex != 0) {
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-13 19:27:20 +01:00
|
|
|
utf8 *buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, utf8);
|
2015-10-31 09:25:43 +01:00
|
|
|
utf8 *dst = buffer;
|
|
|
|
dst = utf8_write_codepoint(dst, FORMAT_COLOUR_CODE_START + banner->text_colour);
|
|
|
|
strncpy(dst, newName, 32);
|
|
|
|
|
|
|
|
rct_string_id stringId = user_string_allocate(128, buffer);
|
|
|
|
if (stringId) {
|
|
|
|
rct_string_id prev_string_id = banner->string_idx;
|
|
|
|
banner->string_idx = stringId;
|
|
|
|
user_string_free(prev_string_id);
|
|
|
|
rct_window* w = window_bring_to_front_by_number(WC_BANNER, *ecx);
|
|
|
|
if (w) {
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 2984;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void game_command_set_sign_name(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) {
|
|
|
|
static char newName[128];
|
|
|
|
|
2016-01-03 00:49:08 +01:00
|
|
|
if ((*ecx >= MAX_BANNERS) || (*ecx < 0))
|
|
|
|
{
|
|
|
|
log_warning("Invalid game command for setting sign name, banner id = %d", *ecx);
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-10-31 09:25:43 +01:00
|
|
|
rct_banner* banner = &gBanners[*ecx];
|
|
|
|
int x = banner->x << 5;
|
|
|
|
int y = banner->y << 5;
|
|
|
|
|
|
|
|
int nameChunkIndex = *eax & 0xFFFF;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS * 4;
|
|
|
|
int nameChunkOffset = nameChunkIndex - 1;
|
|
|
|
if (nameChunkOffset < 0)
|
|
|
|
nameChunkOffset = 2;
|
|
|
|
nameChunkOffset *= 12;
|
2016-01-03 00:49:08 +01:00
|
|
|
nameChunkOffset = min(nameChunkOffset, countof(newName) - 12);
|
2015-10-31 09:25:43 +01:00
|
|
|
RCT2_GLOBAL(newName + nameChunkOffset + 0, uint32) = *edx;
|
|
|
|
RCT2_GLOBAL(newName + nameChunkOffset + 4, uint32) = *ebp;
|
|
|
|
RCT2_GLOBAL(newName + nameChunkOffset + 8, uint32) = *edi;
|
|
|
|
|
|
|
|
if (nameChunkIndex != 0) {
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newName[0] != 0) {
|
|
|
|
rct_string_id string_id = user_string_allocate(128, newName);
|
|
|
|
if (string_id != 0) {
|
|
|
|
rct_string_id prev_string_id = banner->string_idx;
|
|
|
|
banner->string_idx = string_id;
|
|
|
|
user_string_free(prev_string_id);
|
|
|
|
|
|
|
|
banner->flags &= ~(BANNER_FLAG_2);
|
|
|
|
gfx_invalidate_screen();
|
|
|
|
} else {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 2984;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
int rideIndex = banner_get_closest_ride_index(x, y, 16);
|
|
|
|
if (rideIndex == -1) {
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
banner->colour = rideIndex;
|
|
|
|
banner->flags |= BANNER_FLAG_2;
|
|
|
|
|
|
|
|
rct_string_id prev_string_id = banner->string_idx;
|
|
|
|
banner->string_idx = 778;
|
|
|
|
user_string_free(prev_string_id);
|
|
|
|
gfx_invalidate_screen();
|
|
|
|
}
|
|
|
|
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void game_command_set_banner_style(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) {
|
2016-01-03 00:49:08 +01:00
|
|
|
if ((*ecx >= MAX_BANNERS) || (*ecx < 0))
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_INVALID_SELECTION_OF_OBJECTS;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-10-31 09:25:43 +01:00
|
|
|
rct_banner* banner = &gBanners[*ecx];
|
|
|
|
|
|
|
|
banner->colour = (uint8)*edx;
|
|
|
|
banner->text_colour = (uint8)*edi;
|
|
|
|
banner->flags = (uint8)*ebp;
|
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
uint8 bannerIndex = *ecx & 0xFF;
|
|
|
|
|
2015-10-31 09:25:43 +01:00
|
|
|
int x = banner->x << 5;
|
|
|
|
int y = banner->y << 5;
|
|
|
|
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
2015-11-14 17:44:03 +01:00
|
|
|
bool bannerFound = false;
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_BANNER)
|
|
|
|
continue;
|
2015-10-31 09:25:43 +01:00
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
if (map_element->properties.banner.index != bannerIndex)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bannerFound = true;
|
2015-11-17 20:04:43 +01:00
|
|
|
break;
|
2015-11-14 17:44:03 +01:00
|
|
|
} while (!map_element_is_last_for_tile(map_element++));
|
2015-10-31 09:25:43 +01:00
|
|
|
|
2015-11-14 17:44:03 +01:00
|
|
|
if (bannerFound == false) {
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-10-31 09:25:43 +01:00
|
|
|
map_element->properties.banner.flags = 0xFF;
|
|
|
|
if (banner->flags & BANNER_FLAG_NO_ENTRY){
|
|
|
|
map_element->properties.banner.flags &= ~(1 << map_element->properties.banner.position);
|
|
|
|
}
|
|
|
|
|
|
|
|
int colourCodepoint = FORMAT_COLOUR_CODE_START + banner->text_colour;
|
|
|
|
|
2015-12-13 19:27:20 +01:00
|
|
|
utf8 buffer[256];
|
2015-10-31 09:25:43 +01:00
|
|
|
format_string(buffer, banner->string_idx, 0);
|
|
|
|
int firstCodepoint = utf8_get_next(buffer, NULL);
|
|
|
|
if (firstCodepoint >= FORMAT_COLOUR_CODE_START && firstCodepoint <= FORMAT_COLOUR_CODE_END) {
|
|
|
|
utf8_write_codepoint(buffer, colourCodepoint);
|
|
|
|
} else {
|
|
|
|
utf8_insert_codepoint(buffer, colourCodepoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_string_id stringId = user_string_allocate(128, buffer);
|
|
|
|
if (stringId != 0) {
|
|
|
|
rct_string_id prev_string_id = banner->string_idx;
|
|
|
|
banner->string_idx = stringId;
|
|
|
|
user_string_free(prev_string_id);
|
|
|
|
rct_window* w = window_bring_to_front_by_number(WC_BANNER, *ecx);
|
|
|
|
if (w) {
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 2984;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
2016-01-02 15:52:37 +01:00
|
|
|
void game_command_set_sign_style(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) {
|
2015-11-14 12:56:13 +01:00
|
|
|
uint8 bannerId = *ecx & 0xFF;
|
|
|
|
rct_banner *banner = &gBanners[bannerId];
|
2015-10-31 09:25:43 +01:00
|
|
|
int x = banner->x << 5;
|
|
|
|
int y = banner->y << 5;
|
|
|
|
|
2015-11-14 13:40:40 +01:00
|
|
|
uint8 mainColour = (uint8)*edx;
|
|
|
|
uint8 textColour = (uint8)*edi;
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-10-31 09:25:43 +01:00
|
|
|
if (*ebp == 0) { // small sign
|
2016-01-02 15:52:37 +01:00
|
|
|
|
2015-10-31 09:25:43 +01:00
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
2015-11-14 12:56:13 +01:00
|
|
|
bool fence_found = false;
|
|
|
|
do{
|
|
|
|
if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_FENCE)
|
|
|
|
continue;
|
2015-10-31 09:25:43 +01:00
|
|
|
|
2015-11-14 12:56:13 +01:00
|
|
|
rct_scenery_entry* scenery_entry = g_wallSceneryEntries[map_element->properties.fence.type];
|
|
|
|
if (scenery_entry->wall.var_0D == 0xFF)
|
|
|
|
continue;
|
|
|
|
if (map_element->properties.fence.item[0] != bannerId)
|
|
|
|
continue;
|
|
|
|
fence_found = true;
|
|
|
|
break;
|
|
|
|
} while (!map_element_is_last_for_tile(map_element++));
|
|
|
|
|
|
|
|
if (fence_found == false) {
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
2015-10-31 09:25:43 +01:00
|
|
|
}
|
|
|
|
map_element->flags &= 0x9F;
|
|
|
|
map_element->properties.fence.item[1] =
|
2015-11-14 13:40:40 +01:00
|
|
|
mainColour |
|
|
|
|
((textColour & 0x7) << 5);
|
|
|
|
map_element->flags |= ((textColour & 0x18) << 2);
|
2015-10-31 09:25:43 +01:00
|
|
|
|
|
|
|
map_invalidate_tile(x, y, map_element->base_height * 8, map_element->clearance_height * 8);
|
|
|
|
} else { // large sign
|
2015-11-14 12:56:13 +01:00
|
|
|
rct_map_element *mapElement = banner_get_map_element(bannerId);
|
2015-10-31 09:25:43 +01:00
|
|
|
if (mapElement == NULL || map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 2984;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-13 19:27:20 +01:00
|
|
|
if (!sign_set_colour(
|
2015-10-31 09:25:43 +01:00
|
|
|
banner->x * 32,
|
|
|
|
banner->y * 32,
|
|
|
|
mapElement->base_height,
|
|
|
|
mapElement->type & 3,
|
|
|
|
mapElement->properties.scenerymultiple.type >> 10,
|
2015-11-14 13:40:40 +01:00
|
|
|
mainColour,
|
|
|
|
textColour
|
2015-12-13 19:27:20 +01:00
|
|
|
)) {
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2015-10-31 09:25:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
rct_window* w = window_bring_to_front_by_number(WC_BANNER, *ecx);
|
|
|
|
if (w) {
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
2015-10-25 17:00:21 +01:00
|
|
|
/**
|
2015-11-01 15:58:46 +01:00
|
|
|
* Gets the track element at x, y, z.
|
2015-10-25 17:00:21 +01:00
|
|
|
* @param x x units, not tiles.
|
|
|
|
* @param y y units, not tiles.
|
|
|
|
* @param z Base height.
|
|
|
|
*/
|
|
|
|
rct_map_element *map_get_track_element_at(int x, int y, int z)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue;
|
|
|
|
if (mapElement->base_height != z) continue;
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-10-25 22:25:54 +01:00
|
|
|
|
|
|
|
/**
|
2015-11-01 15:58:46 +01:00
|
|
|
* Gets the track element at x, y, z that is the given track type.
|
2015-10-25 22:25:54 +01:00
|
|
|
* @param x x units, not tiles.
|
|
|
|
* @param y y units, not tiles.
|
|
|
|
* @param z Base height.
|
2015-11-01 15:58:46 +01:00
|
|
|
* @param trackType
|
2015-10-25 22:25:54 +01:00
|
|
|
*/
|
|
|
|
rct_map_element *map_get_track_element_at_of_type(int x, int y, int z, int trackType)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue;
|
|
|
|
if (mapElement->base_height != z) continue;
|
|
|
|
if (mapElement->properties.track.type != trackType) continue;
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-11-01 15:58:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the track element at x, y, z that is the given track type and sequence.
|
|
|
|
* @param x x units, not tiles.
|
|
|
|
* @param y y units, not tiles.
|
|
|
|
* @param z Base height.
|
|
|
|
* @param trackType
|
|
|
|
* @param sequence
|
|
|
|
*/
|
|
|
|
rct_map_element *map_get_track_element_at_of_type_seq(int x, int y, int z, int trackType, int sequence)
|
|
|
|
{
|
|
|
|
rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
|
|
|
do {
|
|
|
|
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue;
|
|
|
|
if (mapElement->base_height != z) continue;
|
|
|
|
if (mapElement->properties.track.type != trackType) continue;
|
|
|
|
if ((mapElement->properties.track.sequence & 0x0F) != sequence) continue;
|
|
|
|
|
|
|
|
return mapElement;
|
|
|
|
} while (!map_element_is_last_for_tile(mapElement++));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|