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.
|
|
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
|
|
* 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-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-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"
|
2014-04-09 04:09:30 +02:00
|
|
|
|
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 }
|
|
|
|
};
|
|
|
|
|
|
|
|
rct_xy16 *gMapSelectionTiles = (rct_xy16*)0x009DE596;
|
|
|
|
|
2015-05-12 17:37:16 +02:00
|
|
|
bool LandPaintMode;
|
2015-05-15 17:28:27 +02:00
|
|
|
bool LandRightsMode;
|
2015-05-12 17:37:16 +02:00
|
|
|
|
2014-10-09 21:31:58 +02:00
|
|
|
int _sub_6A876D_save_x;
|
|
|
|
int _sub_6A876D_save_y;
|
|
|
|
|
2014-04-09 18:06:47 +02:00
|
|
|
static void tiles_init();
|
2014-10-09 21:31:58 +02:00
|
|
|
static void sub_6A87BB(int x, int y);
|
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);
|
2014-04-09 04:09:30 +02:00
|
|
|
|
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-01-29 18:47:35 +01:00
|
|
|
if (x < 0 || y < 0 || x > 255 || y > 255)
|
2015-01-29 18:45:08 +01:00
|
|
|
{
|
|
|
|
log_error("Trying to access element outside of range");
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-01-22 01:19:05 +01:00
|
|
|
return TILE_MAP_ELEMENT_POINTER(x + y * 256);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
uint8 mapFound = 0;
|
|
|
|
// 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;
|
|
|
|
}
|
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;
|
2014-10-09 21:31:58 +02:00
|
|
|
_sub_6A876D_save_x = 0;
|
|
|
|
_sub_6A876D_save_y = 0;
|
2015-02-09 19:32:58 +01:00
|
|
|
RCT2_GLOBAL(0x01358830, sint16) = size * 32 - 32;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16) = size * 32 - 2;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16) = size;
|
|
|
|
RCT2_GLOBAL(0x01358836, 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();
|
2014-04-09 04:09:30 +02:00
|
|
|
RCT2_CALLPROC_EBPSAFE(0x0068ADBC);
|
2014-04-09 12:16:35 +02:00
|
|
|
|
|
|
|
climate_reset(CLIMATE_WARM);
|
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-01-22 01:19:05 +01:00
|
|
|
do { } while (!map_element_is_last_for_tile(mapElement++));
|
2014-04-09 18:06:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Possible next free map element
|
|
|
|
RCT2_GLOBAL(0x0140E9A4, 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
|
|
|
*
|
2014-09-04 21:09:54 +02:00
|
|
|
* ax: x
|
|
|
|
* cx: y
|
2014-09-18 18:18:39 +02:00
|
|
|
* 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
|
2014-04-10 16:14:47 +02:00
|
|
|
if (x >= 8192 || y >= 8192)
|
|
|
|
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;
|
|
|
|
|
|
|
|
//
|
|
|
|
TILE_MAP_ELEMENT_POINTER(i) = mapElement;
|
|
|
|
do {
|
|
|
|
*mapElement = *mapElementFirst;
|
|
|
|
mapElementFirst->base_height = 255;
|
|
|
|
|
|
|
|
mapElement++;
|
|
|
|
mapElementFirst++;
|
2015-01-22 01:19:05 +01:00
|
|
|
} while (!map_element_is_last_for_tile(mapElement - 1));
|
2014-05-04 19:51:36 +02:00
|
|
|
|
|
|
|
// Update next free element?
|
|
|
|
mapElement = RCT2_GLOBAL(0x0140E9A4, rct_map_element*);
|
|
|
|
do {
|
|
|
|
mapElement--;
|
|
|
|
} while (mapElement->base_height == 255);
|
|
|
|
mapElement++;
|
|
|
|
RCT2_GLOBAL(0x0140E9A4, 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
|
|
|
|
*/
|
|
|
|
void sub_6A876D()
|
|
|
|
{
|
|
|
|
int i, x, y;
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Presumebly sub_6A87BB is too computationally expensive to call for every
|
|
|
|
// tile every update, so word_13CE774 and word_13CE776 store the x and y
|
|
|
|
// progress. A maximum of 128 calls is done per update.
|
|
|
|
x = _sub_6A876D_save_x;
|
|
|
|
y = _sub_6A876D_save_y;
|
|
|
|
for (i = 0; i < 128; i++) {
|
|
|
|
sub_6A87BB(x, y);
|
|
|
|
|
|
|
|
// Next x, y tile
|
|
|
|
x += 32;
|
|
|
|
if (x >= 8192) {
|
|
|
|
x = 0;
|
|
|
|
y += 32;
|
|
|
|
if (y >= 8192)
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_sub_6A876D_save_x = x;
|
|
|
|
_sub_6A876D_save_y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006A87BB
|
|
|
|
*/
|
|
|
|
static void sub_6A87BB(int x, int y)
|
|
|
|
{
|
|
|
|
RCT2_CALLPROC_X(0x006A87BB, x, 0, y, 0, 0, 0, 0);
|
2014-10-11 20:21:37 +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;
|
|
|
|
|
|
|
|
if (x < (256 * 32) && y < (256 * 32)) {
|
|
|
|
mapElement = map_get_surface_element_at(x / 32, y / 32);
|
2014-12-10 02:44:30 +01:00
|
|
|
if (mapElement->properties.surface.ownership & OWNERSHIP_OWNED)
|
2014-11-02 02:41:00 +01:00
|
|
|
return 1;
|
2014-10-11 20:21:37 +02:00
|
|
|
|
2014-12-10 02:44:30 +01:00
|
|
|
if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) {
|
2014-11-02 02:41:00 +01:00
|
|
|
z /= 8;
|
|
|
|
if (z < mapElement->base_height || z - 2 > mapElement->base_height)
|
2014-09-20 15:06:42 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2014-10-11 20:21:37 +02:00
|
|
|
}
|
|
|
|
|
2014-11-02 02:41:00 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 1729;
|
|
|
|
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);
|
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
|
|
|
}
|
|
|
|
|
2014-11-02 02:41:00 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 1729;
|
|
|
|
return 0;
|
2014-11-02 04:37:56 +01:00
|
|
|
}
|
2014-10-11 20:21:37 +02:00
|
|
|
|
2014-11-02 04:37:56 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006ECB60
|
|
|
|
* NOTE: x, y and z are in pixels, not tile units
|
|
|
|
*/
|
|
|
|
void map_invalidate_tile(int x, int y, int zLow, int zHigh)
|
|
|
|
{
|
|
|
|
RCT2_CALLPROC_X(0x006ECB60, x, 0, y, 0, zHigh, zLow, 0);
|
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;
|
2014-11-04 04:34:12 +01:00
|
|
|
money32 cost;
|
2015-04-16 04:02:47 +02:00
|
|
|
|
|
|
|
rct_scenery_entry *entry = g_smallSceneryEntries[scenery_type];
|
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-04-16 04:02:47 +02:00
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint32) = x + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint32) = y + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint32) = base_height * 8;
|
2014-11-04 04:34:12 +01:00
|
|
|
|
2015-04-16 04:02:47 +02:00
|
|
|
if (!(*ebx & 0x40) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0) {
|
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-04-16 04:02:47 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !(*ebx & 0x40)) {
|
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-04-16 04:02:47 +02:00
|
|
|
if (!map_is_location_owned(x, y, RCT2_GLOBAL(0x009DEA62, uint32))){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
|
|
|
|
2015-04-16 04:02:47 +02:00
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
while(map_element->type != map_element_type ||
|
|
|
|
map_element->base_height != base_height ||
|
|
|
|
map_element->properties.scenery.type != scenery_type ||
|
2015-04-18 23:48:17 +02:00
|
|
|
(*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_5)){
|
2015-04-16 04:02:47 +02:00
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-11-04 04:34:12 +01:00
|
|
|
|
|
|
|
// Remove element
|
2015-04-16 04:02:47 +02:00
|
|
|
if (*ebx & 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;
|
|
|
|
uint8 scenerymultiple_index = *edx >> 8;
|
|
|
|
uint8 map_element_direction = *ebx >> 8;
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
int z = map_element_height(x, y);
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint16) = z;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 12;
|
|
|
|
|
|
|
|
if (!(*ebx & 0x40) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
*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_SCENERY_MULTIPLE ||
|
|
|
|
map_element->base_height != base_height ||
|
|
|
|
map_element->properties.scenerymultiple.type >> 10 != scenerymultiple_index ||
|
|
|
|
(map_element->type & MAP_ELEMENT_DIRECTION_MASK) != map_element_direction){
|
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-04-18 23:48:17 +02:00
|
|
|
if((*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_5)){
|
2015-04-17 08:47:23 +02:00
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int ecx2 = map_element->properties.scenerymultiple.type >> 10;
|
|
|
|
rct_scenery_entry* scenery_entry = RCT2_ADDRESS(RCT2_ADDRESS_LARGE_SCENERY_ENTRIES, rct_scenery_entry*)[map_element->properties.scenerymultiple.type & 0x3FF];
|
|
|
|
if(scenery_entry->large_scenery.var_11 != 0xFF){
|
|
|
|
uint8 banner_num = map_element->type & MAP_ELEMENT_QUADRANT_MASK;
|
|
|
|
banner_num |= (map_element->properties.scenerymultiple.colour[0] & 0xE0) >> 2;
|
|
|
|
banner_num |= (map_element->properties.scenerymultiple.colour[1] & 0xE0) >> 5;
|
|
|
|
if(gBanners[banner_num].type != BANNER_NULL){
|
|
|
|
window_close_by_number(WC_BANNER, banner_num);
|
|
|
|
gBanners[banner_num].type = BANNER_NULL;
|
|
|
|
user_string_free(gBanners[banner_num].string_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int x2 = scenery_entry->large_scenery.tiles[ecx2].x_offset;
|
|
|
|
int y2 = scenery_entry->large_scenery.tiles[ecx2].y_offset;
|
|
|
|
int z2 = (base_height * 8) - scenery_entry->large_scenery.tiles[ecx2].z_offset;
|
|
|
|
switch(map_element->type & MAP_ELEMENT_DIRECTION_MASK){
|
|
|
|
case MAP_ELEMENT_DIRECTION_WEST:
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_NORTH:{
|
|
|
|
int temp = x2;
|
|
|
|
x2 = y2;
|
|
|
|
y2 = -temp;
|
|
|
|
}break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_EAST:
|
|
|
|
x2 = -x2;
|
|
|
|
y2 = -y2;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_SOUTH:{
|
|
|
|
int temp = y2;
|
|
|
|
y2 = x2;
|
|
|
|
x2 = -temp;
|
|
|
|
}break;
|
|
|
|
}
|
|
|
|
x2 = -x2 + x;
|
|
|
|
y2 = -y2 + y;
|
|
|
|
int i = 0;
|
|
|
|
while(1){
|
|
|
|
if(scenery_entry->large_scenery.tiles[i].x_offset == -1){
|
|
|
|
*ebx = scenery_entry->large_scenery.removal_price * 10;
|
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int x3 = scenery_entry->large_scenery.tiles[i].x_offset;
|
|
|
|
int y3 = scenery_entry->large_scenery.tiles[i].y_offset;
|
|
|
|
int z3 = scenery_entry->large_scenery.tiles[i].z_offset;
|
|
|
|
switch(map_element->type & MAP_ELEMENT_DIRECTION_MASK){
|
|
|
|
case MAP_ELEMENT_DIRECTION_WEST:
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_NORTH:{
|
|
|
|
int temp = x3;
|
|
|
|
x3 = y3;
|
|
|
|
y3 = -temp;
|
|
|
|
}break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_EAST:
|
|
|
|
x3 = -x3;
|
|
|
|
y3 = -y3;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_SOUTH:{
|
|
|
|
int temp = y3;
|
|
|
|
y3 = x3;
|
|
|
|
x3 = -temp;
|
|
|
|
}break;
|
|
|
|
}
|
|
|
|
x3 += x2;
|
|
|
|
y3 += y2;
|
|
|
|
z3 += z2;
|
2015-05-07 19:57:14 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)){
|
|
|
|
if (!map_is_location_owned(x3, y3, z3)){
|
2015-04-17 08:47:23 +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(x3 / 32, y3 / 32);
|
2015-05-07 20:16:00 +02:00
|
|
|
uint8 tile_not_found = 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) != map_element_direction)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((map_element->properties.scenerymultiple.type >> 10) != i)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (map_element->base_height != z3 / 8)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
map_invalidate_tile_full(x3, y3);
|
|
|
|
map_element_remove(map_element);
|
|
|
|
tile_not_found = 0;
|
|
|
|
break;
|
|
|
|
} while (!map_element_is_last_for_tile(map_element++));
|
|
|
|
|
|
|
|
if (tile_not_found){
|
|
|
|
log_error("Tile not found when trying to remove element!");
|
2015-04-17 08:47:23 +02:00
|
|
|
}
|
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
|
2015-04-17 08:47:23 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
int z = base_height * 8;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 12;
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint16) = z;
|
|
|
|
if(!(*ebx & 0x40) && RCT2_GLOBAL(0x009DEA6E, uint8) != 0){
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned(x, y, z - 16)){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
while(map_element->type != MAP_ELEMENT_TYPE_BANNER ||
|
|
|
|
map_element->properties.banner.position != banner_position){
|
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
2015-04-22 23:47:59 +02:00
|
|
|
*ebx = MONEY32_UNDEFINED;
|
2015-04-22 09:46:44 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-04-22 23:47:59 +02:00
|
|
|
rct_banner *banner = &gBanners[map_element->properties.banner.index];
|
|
|
|
uint8 banner_type = banner->type;
|
2015-04-22 09:46:44 +02:00
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
window_close_by_number(WC_BANNER, map_element->properties.banner.index);
|
|
|
|
user_string_free(banner->string_idx);
|
|
|
|
banner->type = BANNER_NULL;
|
|
|
|
map_invalidate_tile(x, y, z, z + 32);
|
|
|
|
map_element_remove(map_element);
|
|
|
|
}
|
2015-04-22 23:47:59 +02:00
|
|
|
rct_scenery_entry *scenery_entry = (rct_scenery_entry*)object_entry_groups[OBJECT_TYPE_BANNERS].chunks[banner_type];
|
2015-04-22 09:46:44 +02:00
|
|
|
*ebx = (scenery_entry->banner.price * -3) / 4;
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 12;
|
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 map_element_type = *ebx >> 8;
|
|
|
|
uint8 color1 = *ebp;
|
|
|
|
uint8 color2 = *ebp >> 8;
|
|
|
|
int z = base_height * 8;
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint16) = z;
|
2015-05-07 19:57:14 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)){
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
while(map_element->type != map_element_type ||
|
|
|
|
map_element->base_height != base_height ||
|
|
|
|
map_element->properties.scenery.type != scenery_type){
|
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
2015-04-17 22:56:19 +02:00
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
if((*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_5)){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
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-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)
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 12;
|
|
|
|
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;
|
|
|
|
int z = base_height * 8;
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint16) = z;
|
|
|
|
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)){
|
|
|
|
if(!map_is_location_in_park(x, y)){
|
|
|
|
*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) != map_element_direction||
|
|
|
|
((*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_5))){
|
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-04-18 23:48:17 +02:00
|
|
|
if((*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_5)){
|
2015-04-18 07:01:50 +02:00
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
2015-04-25 16:55:12 +02:00
|
|
|
rct_scenery_entry* scenery_entry = RCT2_ADDRESS(RCT2_ADDRESS_WALL_SCENERY_ENTRIES, rct_scenery_entry*)[map_element->properties.fence.type];
|
2015-04-18 07:01:50 +02:00
|
|
|
map_element->properties.fence.item[1] &= 0xE0;
|
|
|
|
map_element->properties.fence.item[1] |= color1;
|
|
|
|
map_element->flags &= 0x9F;
|
|
|
|
map_element->properties.fence.item[1] &= 0x1F;
|
|
|
|
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(x, y, z, z + 0x48);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 12;
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 map_element_direction = *ebx >> 8;
|
|
|
|
uint8 base_height = *edx;
|
|
|
|
uint8 scenerymultiple_index = *edx >> 8;
|
|
|
|
uint8 color1 = *ebp;
|
|
|
|
uint8 color2 = *ebp >> 8;
|
|
|
|
int z = map_element_height(x, y);
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint16) = z;
|
|
|
|
|
|
|
|
|
|
|
|
rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);
|
|
|
|
while(map_element_get_type(map_element) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE ||
|
|
|
|
map_element->base_height != base_height ||
|
|
|
|
map_element->properties.scenerymultiple.type >> 10 != scenerymultiple_index ||
|
|
|
|
(map_element->type & MAP_ELEMENT_DIRECTION_MASK) != map_element_direction){
|
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-04-18 23:48:17 +02:00
|
|
|
if((*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_5)){
|
2015-04-18 21:03:18 +02:00
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int ecx2 = map_element->properties.scenerymultiple.type >> 10;
|
|
|
|
rct_scenery_entry* scenery_entry = RCT2_ADDRESS(RCT2_ADDRESS_LARGE_SCENERY_ENTRIES, rct_scenery_entry*)[map_element->properties.scenerymultiple.type & 0x3FF];
|
|
|
|
int x2 = scenery_entry->large_scenery.tiles[ecx2].x_offset;
|
|
|
|
int y2 = scenery_entry->large_scenery.tiles[ecx2].y_offset;
|
|
|
|
int z2 = (base_height * 8) - scenery_entry->large_scenery.tiles[ecx2].z_offset;
|
|
|
|
switch(map_element->type & MAP_ELEMENT_DIRECTION_MASK){
|
|
|
|
case MAP_ELEMENT_DIRECTION_WEST:
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_NORTH:{
|
|
|
|
int temp = x2;
|
|
|
|
x2 = y2;
|
|
|
|
y2 = -temp;
|
|
|
|
}break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_EAST:
|
|
|
|
x2 = -x2;
|
|
|
|
y2 = -y2;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_SOUTH:{
|
|
|
|
int temp = y2;
|
|
|
|
y2 = x2;
|
|
|
|
x2 = -temp;
|
|
|
|
}break;
|
|
|
|
}
|
|
|
|
x2 = -x2 + x;
|
|
|
|
y2 = -y2 + y;
|
|
|
|
int i = 0;
|
|
|
|
while(1){
|
|
|
|
if(scenery_entry->large_scenery.tiles[i].x_offset == -1){
|
|
|
|
*ebx = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int x3 = scenery_entry->large_scenery.tiles[i].x_offset;
|
|
|
|
int y3 = scenery_entry->large_scenery.tiles[i].y_offset;
|
|
|
|
int z3 = scenery_entry->large_scenery.tiles[i].z_offset;
|
|
|
|
switch(map_element->type & MAP_ELEMENT_DIRECTION_MASK){
|
|
|
|
case MAP_ELEMENT_DIRECTION_WEST:
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_NORTH:{
|
|
|
|
int temp = x3;
|
|
|
|
x3 = y3;
|
|
|
|
y3 = -temp;
|
|
|
|
}break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_EAST:
|
|
|
|
x3 = -x3;
|
|
|
|
y3 = -y3;
|
|
|
|
break;
|
|
|
|
case MAP_ELEMENT_DIRECTION_SOUTH:{
|
|
|
|
int temp = y3;
|
|
|
|
y3 = x3;
|
|
|
|
x3 = -temp;
|
|
|
|
}break;
|
|
|
|
}
|
|
|
|
x3 += x2;
|
|
|
|
y3 += y2;
|
|
|
|
z3 += z2;
|
2015-05-07 19:57:14 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)){
|
|
|
|
if (!map_is_location_owned(x3, y3, z3)){
|
2015-04-18 21:03:18 +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(x3 / 32, y3 / 32);
|
|
|
|
while(map_element_get_type(map_element) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE ||
|
|
|
|
(map_element->type & MAP_ELEMENT_DIRECTION_MASK) != map_element_direction ||
|
|
|
|
map_element->properties.scenerymultiple.type >> 10 != i ||
|
|
|
|
map_element->base_height != base_height){
|
|
|
|
map_element++;
|
2015-04-18 21:03:18 +02:00
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
map_element->properties.scenerymultiple.colour[0] &= 0xE0;
|
|
|
|
map_element->properties.scenerymultiple.colour[0] |= color1;
|
|
|
|
map_element->properties.scenerymultiple.colour[1] &= 0xE0;
|
|
|
|
map_element->properties.scenerymultiple.colour[1] |= color2;
|
|
|
|
map_invalidate_tile_full(x3, y3);
|
2015-04-18 21:03:18 +02:00
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
|
2015-04-18 21:03:18 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
*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)
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 12;
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
uint8 base_height = *edx;
|
|
|
|
uint8 banner_position = *edx >> 8;
|
|
|
|
uint8 color = *ebp;
|
|
|
|
int z = (base_height * 8);
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint16) = x + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint16) = y + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint16) = z;
|
|
|
|
|
2015-05-07 19:57:14 +02:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)){
|
|
|
|
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);
|
|
|
|
while(map_element->type != MAP_ELEMENT_TYPE_BANNER ||
|
|
|
|
map_element->properties.banner.position != banner_position){
|
|
|
|
map_element++;
|
|
|
|
if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
|
|
|
return;
|
2015-04-18 23:48:17 +02: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;
|
|
|
|
map_invalidate_tile(x, y, z, z + 32);
|
2015-04-18 23:48:17 +02:00
|
|
|
}
|
2015-05-07 19:57:14 +02:00
|
|
|
|
2015-04-18 23:48:17 +02:00
|
|
|
*ebx = 0;
|
|
|
|
}
|
|
|
|
|
2014-11-04 04:34:12 +01:00
|
|
|
money32 sub_6A67C0(int x, int y, int z, int flags)
|
|
|
|
{
|
|
|
|
int eax, ebx, ecx, edx, esi, edi, ebp;
|
|
|
|
eax = x * 32;
|
|
|
|
ecx = y * 32;
|
|
|
|
ebx = flags & 0xFF;
|
|
|
|
edx = z & 0xFF;
|
|
|
|
RCT2_CALLFUNC_X(0x006A67C0, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
|
|
|
return ebx;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
*/
|
|
|
|
money32 map_clear_scenery_from_tile(int x, int y, int flags)
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
#ifdef CLEAR_SCENERY_REMOVES_PATHS
|
|
|
|
cost = sub_6A67C0(x, y, mapElement->base_height, flags);
|
|
|
|
if (cost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
|
|
|
|
totalCost += cost;
|
|
|
|
if (flags & 1)
|
|
|
|
goto restart_from_beginning;
|
|
|
|
#endif
|
|
|
|
break;
|
2015-04-16 04:02:47 +02:00
|
|
|
case MAP_ELEMENT_TYPE_SCENERY:{
|
|
|
|
int eax = x * 32;
|
|
|
|
int ebx = (mapElement->type << 8) | flags;
|
|
|
|
int ecx = y * 32;
|
|
|
|
int edx = (mapElement->properties.scenery.type << 8) | (mapElement->base_height);
|
|
|
|
int esi, edi, ebp;
|
|
|
|
game_command_remove_scenery(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
|
|
|
cost = ebx;
|
|
|
|
|
2014-11-04 04:34:12 +01:00
|
|
|
if (cost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
|
|
|
|
totalCost += cost;
|
|
|
|
if (flags & 1)
|
|
|
|
goto restart_from_beginning;
|
|
|
|
|
2015-04-16 04:02:47 +02:00
|
|
|
}break;
|
2015-04-16 01:17:43 +02:00
|
|
|
case MAP_ELEMENT_TYPE_FENCE:{
|
|
|
|
int eax = x * 32;
|
|
|
|
int ebx = flags;
|
|
|
|
int ecx = y * 32;
|
|
|
|
int edx = (mapElement->base_height << 8) | (mapElement->type & MAP_ELEMENT_DIRECTION_MASK);
|
|
|
|
int esi, edi, ebp;
|
|
|
|
game_command_remove_fence(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
|
|
|
cost = ebx;
|
|
|
|
|
2014-11-04 04:34:12 +01:00
|
|
|
if (cost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
|
|
|
|
totalCost += cost;
|
|
|
|
if (flags & 1)
|
|
|
|
goto restart_from_beginning;
|
|
|
|
|
2015-04-16 01:17:43 +02:00
|
|
|
}break;
|
2014-11-04 04:34:12 +01:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
money32 map_clear_scenery(int x0, int y0, int x1, int y1, int flags)
|
|
|
|
{
|
|
|
|
int x, y, z;
|
|
|
|
money32 totalCost, cost;
|
|
|
|
|
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);
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint16) = x;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint16) = y;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint16) = z;
|
|
|
|
|
|
|
|
x0 = clamp(0, x0, 255);
|
|
|
|
y0 = clamp(0, y0, 255);
|
|
|
|
x1 = clamp(0, x1, 255);
|
|
|
|
y1 = clamp(0, y1, 255);
|
|
|
|
|
|
|
|
totalCost = 0;
|
|
|
|
for (y = y0; y <= y1; y++) {
|
|
|
|
for (x = x0; x <= x1; x++) {
|
|
|
|
cost = map_clear_scenery_from_tile(x, y, flags);
|
|
|
|
if (cost == MONEY32_UNDEFINED)
|
|
|
|
return MONEY32_UNDEFINED;
|
|
|
|
|
|
|
|
totalCost += cost;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return totalCost;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 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(
|
|
|
|
(*eax & 0xFFFF) / 32,
|
|
|
|
(*ecx & 0xFFFF) / 32,
|
|
|
|
(*edi & 0xFFFF) / 32,
|
|
|
|
(*ebp & 0xFFFF) / 32,
|
|
|
|
*ebx & 0xFF
|
|
|
|
);
|
2014-11-05 03:55:29 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 17:40:27 +01:00
|
|
|
/* rct2: 0x00663CCD */
|
2015-01-11 14:37:27 +01:00
|
|
|
money32 map_change_surface_style(int x0, int y0, int x1, int y1, uint8 surface_style, uint8 edge_style, uint8 flags)
|
2015-01-10 17:40:27 +01:00
|
|
|
{
|
|
|
|
RCT2_GLOBAL(0x141F56C, uint8) = 12;
|
|
|
|
|
|
|
|
int x_mid, y_mid;
|
|
|
|
|
|
|
|
x_mid = (x0 + x1) / 2 + 16;
|
|
|
|
y_mid = (y0 + y1) / 2 + 16;
|
|
|
|
|
|
|
|
int height_mid = map_element_height(x_mid, y_mid);
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x9DEA5E, uint16) = x_mid;
|
|
|
|
RCT2_GLOBAL(0x9DEA60, uint16) = y_mid;
|
|
|
|
RCT2_GLOBAL(0x9DEA62, uint16) = height_mid;
|
|
|
|
RCT2_GLOBAL(0x9E32B4, uint32) = 0;
|
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
money32 cur_cost = 0;
|
|
|
|
|
2015-02-07 18:40:20 +01:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0){
|
2015-01-11 14:37:27 +01:00
|
|
|
cur_cost += RCT2_GLOBAL(0x9E32B4, uint32);
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return cur_cost;
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES){
|
|
|
|
cur_cost += RCT2_GLOBAL(0x9E32B4, uint32);
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return cur_cost;
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
for (int x = x0; x <= x1; x += 32){
|
|
|
|
for (int y = y0; y <= y1; y += 32){
|
2015-01-10 17:40:27 +01:00
|
|
|
if (x > 0x1FFF)continue;
|
|
|
|
if (y > 0x1FFF)continue;
|
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)){
|
2015-01-10 17:40:27 +01:00
|
|
|
if (!map_is_location_in_park(x, y))continue;
|
|
|
|
}
|
2015-01-11 14:37:27 +01:00
|
|
|
|
|
|
|
rct_map_element* map_element = map_get_surface_element_at(x / 32, y / 32);
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
if (surface_style != 0xFF){
|
2015-01-10 17:40:27 +01:00
|
|
|
uint8 cur_terrain = (
|
|
|
|
(map_element->type&MAP_ELEMENT_DIRECTION_MASK) << 3)
|
|
|
|
| (map_element->properties.surface.terrain >> 5);
|
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
if (surface_style != cur_terrain){
|
|
|
|
RCT2_GLOBAL(0x9E32B4, uint32) += RCT2_ADDRESS(0x97B8B8, uint32)[surface_style & 0x1F];
|
2015-01-10 17:40:27 +01:00
|
|
|
|
|
|
|
if (flags & 1){
|
|
|
|
map_element->properties.surface.terrain &= MAP_ELEMENT_WATER_HEIGHT_MASK;
|
|
|
|
map_element->type &= MAP_ELEMENT_QUADRANT_MASK | MAP_ELEMENT_TYPE_MASK;
|
|
|
|
|
|
|
|
//Save the new terrain
|
2015-01-11 14:37:27 +01:00
|
|
|
map_element->properties.surface.terrain |= surface_style << 5;
|
2015-01-10 17:40:27 +01:00
|
|
|
//Save the new direction mask
|
2015-01-11 14:37:27 +01:00
|
|
|
map_element->type |= (surface_style >> 3) & MAP_ELEMENT_DIRECTION_MASK;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
RCT2_CALLPROC_X(0x673883, x, 0, y, map_element_height(x, y), 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
if (edge_style != 0xFF){
|
|
|
|
uint8 cur_edge =
|
|
|
|
((map_element->type & 0x80) >> 4)
|
|
|
|
| (map_element->properties.surface.slope >> 5);
|
|
|
|
|
|
|
|
if (edge_style != cur_edge){
|
|
|
|
cur_cost++;
|
|
|
|
|
|
|
|
if (flags & 1){
|
|
|
|
map_element->properties.surface.slope &= MAP_ELEMENT_SLOPE_MASK;
|
|
|
|
map_element->type &= 0x7F;
|
2015-01-10 17:40:27 +01:00
|
|
|
|
2015-01-11 14:37:27 +01:00
|
|
|
//Save edge style
|
|
|
|
map_element->properties.surface.slope |= edge_style << 5;
|
|
|
|
//Save ???
|
|
|
|
map_element->type |= (edge_style << 4) & 0x80;
|
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & 1){
|
|
|
|
if (!(map_element->properties.surface.terrain & MAP_ELEMENT_SURFACE_TERRAIN_MASK)){
|
|
|
|
if (!(map_element->type & MAP_ELEMENT_DIRECTION_MASK)){
|
|
|
|
if ((map_element->properties.surface.grass_length & 7) != GRASS_LENGTH_CLEAR_0){
|
|
|
|
map_element->properties.surface.grass_length = GRASS_LENGTH_CLEAR_0;
|
|
|
|
map_invalidate_tile_full(x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
}
|
2015-01-11 14:37:27 +01:00
|
|
|
|
|
|
|
cur_cost *= 100;
|
|
|
|
|
|
|
|
cur_cost += RCT2_GLOBAL(0x9E32B4, uint32);
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return cur_cost;
|
2015-01-10 17:40:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rct2: 0x00663CCD */
|
2015-01-11 14:37:27 +01:00
|
|
|
void game_command_change_surface_style(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp){
|
|
|
|
//RCT2_CALLFUNC_X(0x663CCD, eax, ebx, ecx, edx, esi, edi, ebp);
|
|
|
|
//return;
|
|
|
|
|
|
|
|
*ebx = map_change_surface_style(
|
|
|
|
(*eax & 0xFFFF),
|
|
|
|
(*ecx & 0xFFFF),
|
|
|
|
(*edi & 0xFFFF),
|
|
|
|
(*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-04-14 23:17:19 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068C542
|
|
|
|
*/
|
|
|
|
void game_command_raise_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
int z = map_element_height(*eax, *ecx);
|
|
|
|
int ax = (uint16)*edx;
|
|
|
|
int ay = (uint16)*ebp;
|
|
|
|
int bx = (uint16)(*edx >> 16);
|
|
|
|
int by = (uint16)(*ebp >> 16);
|
|
|
|
uint16 selection_type = *edi;
|
|
|
|
|
2015-04-16 01:30:18 +02:00
|
|
|
int cost = MONEY32_UNDEFINED;
|
2015-04-14 23:17:19 +02:00
|
|
|
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY && RCT2_GLOBAL(0x009A8C28, uint8) == 1){
|
|
|
|
sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z);
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:19:02 +02:00
|
|
|
uint8 min_height = 0xFF;
|
2015-04-14 23:17:19 +02:00
|
|
|
|
|
|
|
// find lowest map element in selection
|
|
|
|
for(int yi = ay; yi <= by; yi += 32){
|
|
|
|
for(int xi = ax; xi <= bx; xi += 32){
|
2015-04-15 21:19:02 +02:00
|
|
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
|
|
|
if(min_height > map_element->base_height){
|
|
|
|
min_height = map_element->base_height;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int yi = ay; yi <= by; yi += 32){
|
|
|
|
for(int xi = ax; xi <= bx; xi += 32){
|
2015-04-15 21:19:02 +02:00
|
|
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
|
|
|
uint8 height = map_element->base_height;
|
|
|
|
if(height <= min_height){
|
2015-04-14 23:17:19 +02:00
|
|
|
uint8 dh = RCT2_ADDRESS(0x00981A1E, uint8)[(selection_type * 32) + (map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK)]; // lookup table
|
|
|
|
if(dh & 0x20){ // needs to be raised, otherwise just the slope type changes
|
2015-04-15 21:19:02 +02:00
|
|
|
height += 2;
|
2015-04-14 23:17:19 +02:00
|
|
|
dh &= ~0x20;
|
|
|
|
}
|
|
|
|
int ebx2 = *ebx;
|
2015-04-15 21:19:02 +02:00
|
|
|
int edx2 = (dh << 8) + height;
|
2015-04-14 23:17:19 +02:00
|
|
|
int edi2 = selection_type * 32;
|
|
|
|
RCT2_CALLFUNC_X(0x0066397F, &xi, &ebx2, &yi, &edx2, (int*)&map_element, &edi2, ebp); // actually apply the change
|
2015-04-16 01:30:18 +02:00
|
|
|
if(ebx2 != MONEY32_UNDEFINED){
|
|
|
|
if(cost == MONEY32_UNDEFINED){
|
2015-04-14 23:17:19 +02:00
|
|
|
cost = ebx2;
|
|
|
|
}else{
|
|
|
|
cost += ebx2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x141F56C, uint8) = 12;
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint32) = x;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint32) = y;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint32) = z;
|
|
|
|
*ebx = cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068C6D1
|
|
|
|
*/
|
|
|
|
void game_command_lower_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int x = *eax;
|
|
|
|
int y = *ecx;
|
|
|
|
int z = map_element_height(*eax, *ecx);
|
|
|
|
int ax = (uint16)*edx;
|
|
|
|
int ay = (uint16)*ebp;
|
|
|
|
int bx = (uint16)(*edx >> 16);
|
|
|
|
int by = (uint16)(*ebp >> 16);
|
|
|
|
uint16 selection_type = *edi;
|
|
|
|
|
2015-04-16 01:30:18 +02:00
|
|
|
int cost = MONEY32_UNDEFINED;
|
2015-04-14 23:17:19 +02:00
|
|
|
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY && RCT2_GLOBAL(0x009A8C28, uint8) == 1){
|
|
|
|
sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z);
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:19:02 +02:00
|
|
|
uint8 max_height = 0;
|
2015-04-14 23:17:19 +02:00
|
|
|
|
|
|
|
// find highest map element in selection
|
|
|
|
for(int yi = ay; yi <= by; yi += 32){
|
|
|
|
for(int xi = ax; xi <= bx; xi += 32){
|
2015-04-15 21:19:02 +02:00
|
|
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
|
|
|
uint8 base_height = map_element->base_height;
|
2015-04-14 23:17:19 +02:00
|
|
|
if(map_element->properties.surface.slope & 0xF){
|
2015-04-15 21:19:02 +02:00
|
|
|
base_height += 2;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
if(map_element->properties.surface.slope & 0x10){
|
2015-04-15 21:19:02 +02:00
|
|
|
base_height += 2;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
2015-04-15 21:19:02 +02:00
|
|
|
if(max_height < base_height){
|
|
|
|
max_height = base_height;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int yi = ay; yi <= by; yi += 32){
|
|
|
|
for(int xi = ax; xi <= bx; xi += 32){
|
2015-04-15 21:19:02 +02:00
|
|
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
|
|
|
uint8 height = map_element->base_height;
|
2015-04-14 23:17:19 +02:00
|
|
|
if(map_element->properties.surface.slope & 0xF){
|
2015-04-15 21:19:02 +02:00
|
|
|
height += 2;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
|
|
|
if(map_element->properties.surface.slope & 0x10){
|
2015-04-15 21:19:02 +02:00
|
|
|
height += 2;
|
2015-04-14 23:17:19 +02:00
|
|
|
}
|
2015-04-15 21:19:02 +02:00
|
|
|
if(height >= max_height){
|
|
|
|
height = map_element->base_height;
|
2015-04-14 23:17:19 +02:00
|
|
|
uint8 dh = RCT2_ADDRESS(0x00981ABE, uint8)[(selection_type * 32) + (map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK)]; // lookup table
|
|
|
|
if(dh & 0x20){ // needs to be lowered, otherwise just the slope type changes
|
2015-04-15 21:19:02 +02:00
|
|
|
height -= 2;
|
2015-04-14 23:17:19 +02:00
|
|
|
dh &= ~0x20;
|
|
|
|
}
|
|
|
|
int ebx2 = *ebx;
|
2015-04-15 21:19:02 +02:00
|
|
|
int edx2 = (dh << 8) + height;
|
2015-04-14 23:17:19 +02:00
|
|
|
int edi2 = selection_type * 32;
|
|
|
|
RCT2_CALLFUNC_X(0x0066397F, &xi, &ebx2, &yi, &edx2, (int*)&map_element, &edi2, ebp); // actually apply the change
|
2015-04-16 01:30:18 +02:00
|
|
|
if(ebx2 != MONEY32_UNDEFINED){
|
|
|
|
if(cost == MONEY32_UNDEFINED){
|
2015-04-14 23:17:19 +02:00
|
|
|
cost = ebx2;
|
|
|
|
}else{
|
|
|
|
cost += ebx2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x141F56C, uint8) = 12;
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint32) = x;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint32) = y;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint32) = z;
|
|
|
|
*ebx = cost;
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:19:02 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E66A0
|
|
|
|
*/
|
|
|
|
void game_command_raise_water(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int ax = (uint16)*eax;
|
|
|
|
int ay = (uint16)*ecx;
|
|
|
|
int bx = (uint16)*edi;
|
|
|
|
int by = (uint16)*ebp;
|
|
|
|
|
|
|
|
int cost = 0;
|
|
|
|
|
|
|
|
uint8 max_height = 0xFF;
|
|
|
|
|
|
|
|
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);
|
|
|
|
uint8 height = map_element->base_height;
|
|
|
|
if(map_element->properties.surface.terrain & 0x1F){
|
|
|
|
height = (map_element->properties.surface.terrain & 0x1F) * 2;
|
|
|
|
}
|
|
|
|
if(max_height > height){
|
|
|
|
max_height = height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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->base_height <= max_height){
|
|
|
|
uint8 height = (map_element->properties.surface.terrain & 0x1F);
|
|
|
|
if(height){
|
|
|
|
height *= 2;
|
|
|
|
if(height > max_height){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
height += 2;
|
|
|
|
}else{
|
|
|
|
height = map_element->base_height + 2;
|
|
|
|
}
|
|
|
|
int eax2 = xi, ebx2 = *ebx, ecx2 = yi, edx2 = (max_height << 8) + height, esi2, edi2, ebp2;
|
|
|
|
ebx2 = game_do_command_p(GAME_COMMAND_16, &eax2, &ebx2, &ecx2, &edx2, &esi2, &edi2, &ebp2);
|
2015-04-16 01:30:18 +02:00
|
|
|
if(ebx2 == MONEY32_UNDEFINED){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
2015-04-15 21:19:02 +02:00
|
|
|
return;
|
|
|
|
}else{
|
|
|
|
cost += ebx2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
int x = ((ax + bx) / 2) + 16;
|
|
|
|
int y = ((ay + by) / 2) + 16;
|
|
|
|
int z = map_element_height(x, y);
|
|
|
|
sint16 water_height_z = z >> 16;
|
|
|
|
sint16 base_height_z = z;
|
|
|
|
z = water_height_z;
|
|
|
|
if(!z){
|
|
|
|
z = base_height_z;
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint32) = x;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint32) = y;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint32) = z;
|
|
|
|
sound_play_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z);
|
|
|
|
}
|
|
|
|
*ebx = cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E6878
|
|
|
|
*/
|
|
|
|
void game_command_lower_water(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
|
|
|
|
{
|
|
|
|
int ax = (uint16)*eax;
|
|
|
|
int ay = (uint16)*ecx;
|
|
|
|
int bx = (uint16)*edi;
|
|
|
|
int by = (uint16)*ebp;
|
|
|
|
|
|
|
|
int cost = 0;
|
|
|
|
|
|
|
|
uint8 min_height = 0;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
uint8 height = map_element->properties.surface.terrain & 0x1F;
|
|
|
|
if(height){
|
|
|
|
height *= 2;
|
|
|
|
if(height > min_height){
|
|
|
|
min_height = height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
uint8 height = (map_element->properties.surface.terrain & 0x1F);
|
|
|
|
if(height){
|
|
|
|
height *= 2;
|
|
|
|
if(height < min_height){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
height -= 2;
|
2015-04-18 23:48:17 +02:00
|
|
|
int ebx2 = game_do_command(xi, *ebx, yi, (min_height << 8) + height, GAME_COMMAND_16, 0, 0);
|
2015-04-16 01:30:18 +02:00
|
|
|
if(ebx2 == MONEY32_UNDEFINED){
|
|
|
|
*ebx = MONEY32_UNDEFINED;
|
2015-04-15 21:19:02 +02:00
|
|
|
return;
|
|
|
|
}else{
|
|
|
|
cost += ebx2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(*ebx & GAME_COMMAND_FLAG_APPLY){
|
|
|
|
int x = ((ax + bx) / 2) + 16;
|
|
|
|
int y = ((ay + by) / 2) + 16;
|
|
|
|
int z = map_element_height(x, y);
|
|
|
|
sint16 water_height_z = z >> 16;
|
|
|
|
sint16 base_height_z = z;
|
|
|
|
z = water_height_z;
|
|
|
|
if(!z){
|
|
|
|
z = base_height_z;
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint32) = x;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint32) = y;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint32) = z;
|
|
|
|
sound_play_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z);
|
|
|
|
}
|
|
|
|
*ebx = cost;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x141F56C, uint8) = 12;
|
2015-04-16 04:02:47 +02:00
|
|
|
if(!(*ebx & 0x40) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0){
|
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-04-16 04:02:47 +02:00
|
|
|
if(!(*ebx & 0x40) && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned(x, y, base_height * 8)){
|
|
|
|
*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 ||
|
|
|
|
((*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_5))){
|
|
|
|
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-04-25 16:55:12 +02:00
|
|
|
rct_scenery_entry* scenery_entry = RCT2_ADDRESS(RCT2_ADDRESS_WALL_SCENERY_ENTRIES, rct_scenery_entry*)[map_element->properties.fence.type];
|
2015-04-17 08:47:23 +02:00
|
|
|
if(scenery_entry->wall.var_0D != 0xFF){
|
2015-04-16 04:02:47 +02:00
|
|
|
rct_banner* banner = &gBanners[map_element->properties.fence.item[0]];
|
|
|
|
if(banner->type != BANNER_NULL){
|
|
|
|
window_close_by_number(WC_BANNER, map_element->properties.fence.item[0]);
|
|
|
|
banner->type = BANNER_NULL;
|
|
|
|
user_string_free(banner->string_idx);
|
2015-04-16 01:17:43 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-16 04:02:47 +02:00
|
|
|
map_invalidate_tile(x, y, map_element->base_height * 8, (map_element->base_height * 8) + 72);
|
|
|
|
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;
|
|
|
|
RCT2_GLOBAL(0x009DEA5E, uint32) = x + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA60, uint32) = y + 16;
|
|
|
|
RCT2_GLOBAL(0x009DEA62, uint32) = base_height * 16;
|
|
|
|
RCT2_GLOBAL(0x141F56C, uint8) = 12;
|
|
|
|
if(RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0){
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned(x, y, base_height * 16)){
|
|
|
|
*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;
|
|
|
|
}
|
|
|
|
|
2014-11-05 03:55:29 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006EC6D7
|
|
|
|
*/
|
|
|
|
void map_invalidate_tile_full(int x, int y)
|
|
|
|
{
|
|
|
|
RCT2_CALLPROC_X(0x006EC6D7, x, 0, y, 0, 0, 0, 0);
|
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)
|
|
|
|
{
|
|
|
|
RCT2_CALLPROC_X(0x0068B280, 0, 0, 0, 0, (int)mapElement, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006A6AA7
|
|
|
|
* @param x x-coordinate in units (not tiles)
|
|
|
|
* @param y y-coordinate in units (not tiles)
|
|
|
|
*/
|
|
|
|
void sub_6A6AA7(int x, int y, rct_map_element *mapElement)
|
|
|
|
{
|
|
|
|
RCT2_CALLPROC_X(0x006A6AA7, x, 0, y, 0, (int)mapElement, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
RCT2_CALLPROC_EBPSAFE(0x006A7594);
|
|
|
|
sub_6A6AA7(it.x * 32, it.y * 32, it.element);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068AAE1
|
|
|
|
*/
|
|
|
|
void map_invalidate_selection_rect()
|
|
|
|
{
|
|
|
|
int x, y, x0, y0, x1, y1;
|
|
|
|
|
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
x0 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16);
|
|
|
|
y0 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16);
|
|
|
|
x1 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16);
|
|
|
|
y1 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16);
|
|
|
|
|
|
|
|
for (x = x0; x <= x1; x++)
|
|
|
|
for (y = y0; y <= y1; y++)
|
|
|
|
map_invalidate_tile_full(x, y);
|
2015-01-15 00:38:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B111
|
|
|
|
*/
|
|
|
|
void map_reorganise_elements()
|
|
|
|
{
|
|
|
|
RCT2_CALLPROC_EBPSAFE(0x0068B111);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B044
|
|
|
|
*/
|
|
|
|
int sub_68B044()
|
|
|
|
{
|
|
|
|
return (RCT2_CALLPROC_X(0x0068B044, 0, 0, 0, 0, 0, 0, 0) & 0x100) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B1F6
|
|
|
|
*/
|
|
|
|
rct_map_element *map_element_insert(int x, int y, int z, int flags)
|
|
|
|
{
|
|
|
|
rct_map_element *originalMapElement, *newMapElement, *insertedElement;
|
|
|
|
|
|
|
|
sub_68B044();
|
|
|
|
|
|
|
|
newMapElement = RCT2_GLOBAL(0x00140E9A4, rct_map_element*);
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x00140E9A4, rct_map_element*) = newMapElement;
|
|
|
|
return insertedElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068B932
|
|
|
|
*/
|
|
|
|
int map_can_construct_with_clear_at(int x, int y, int zLow, int zHigh, void *clearFunc, uint8 bl)
|
|
|
|
{
|
|
|
|
return (RCT2_CALLPROC_X(0x0068B932, x, bl, y, (zHigh << 8) | zLow, 0, 0, (int)clearFunc) & 0x100) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 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-04-22 23:47:59 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006BA278
|
|
|
|
*/
|
|
|
|
int sub_6BA278(int ebx)
|
|
|
|
{
|
|
|
|
int eax, ecx, edx, esi, edi, ebp;
|
|
|
|
RCT2_CALLFUNC_X(0x006BA278, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
|
|
|
return eax;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
int bannerIndex;
|
|
|
|
rct_banner *banner;
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
rct_scenery_entry *sceneryEntry;
|
|
|
|
|
|
|
|
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-04-16 20:37:51 +02:00
|
|
|
sceneryEntry = g_wallSceneryEntries[mapElement->properties.fence.type];
|
2015-02-13 21:55:49 +01:00
|
|
|
if (sceneryEntry->wall.var_0D != 255) {
|
|
|
|
bannerIndex = mapElement->properties.fence.item[0];
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72);
|
|
|
|
map_element_remove(mapElement);
|
|
|
|
mapElement -= 1;
|
|
|
|
} 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;
|
|
|
|
sub_6EC847(x, y, z0, z1);
|
2014-10-09 21:31:58 +02:00
|
|
|
}
|