1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 11:33:03 +01:00

Finish game command 20 change surface style

This commit is contained in:
Duncan Frost
2015-01-11 13:37:27 +00:00
parent 8a4e12a3f4
commit 974ecd904c
6 changed files with 85 additions and 35 deletions

View File

@@ -940,7 +940,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = {
game_command_emptysub,
game_command_emptysub,
game_command_emptysub,
game_command_raise_lower_land, // 20
game_command_change_surface_style, // 20
game_command_emptysub,
game_command_emptysub,
game_command_emptysub,

View File

@@ -42,7 +42,7 @@ enum GAME_COMMAND {
GAME_COMMAND_PLACE_PATH, // 17
GAME_COMMAND_18,
GAME_COMMAND_REMOVE_PATH, // 19
GAME_COMMAND_RAISE_LOWER_LAND, //Raise/lower land
GAME_COMMAND_CHANGE_SURFACE_STYLE, //20
GAME_COMMAND_21,
GAME_COMMAND_22, //To do with text input
GAME_COMMAND_23,

View File

@@ -1660,7 +1660,7 @@ void window_bubble_list_item(rct_window* w, int item_position){
*/
void window_resize_gui(int width, int height)
{
if (RCT2_GLOBAL(0x9DEA68, uint8) & 0xE){
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0xE){
window_resize_gui_scenario_editor(width, height);
return;
}

View File

@@ -646,7 +646,7 @@ static void window_game_top_toolbar_tool_down(){
1,
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16),
RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_SURFACE, uint8) | (RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) << 8),
GAME_COMMAND_RAISE_LOWER_LAND,
GAME_COMMAND_CHANGE_SURFACE_STYLE,
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16),
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16)
);

View File

@@ -708,7 +708,7 @@ void game_command_clear_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi
}
/* rct2: 0x00663CCD */
money32 map_raise_lower_land(int x0, int y0, int x1, int y1, uint8 terrain_surface, uint8 flags)
money32 map_change_surface_style(int x0, int y0, int x1, int y1, uint8 surface_style, uint8 edge_style, uint8 flags)
{
RCT2_GLOBAL(0x141F56C, uint8) = 12;
@@ -724,45 +724,53 @@ money32 map_raise_lower_land(int x0, int y0, int x1, int y1, uint8 terrain_surfa
RCT2_GLOBAL(0x9DEA62, uint16) = height_mid;
RCT2_GLOBAL(0x9E32B4, uint32) = 0;
money32 cur_cost = 0;
if (RCT2_GLOBAL(0x9DEA6E, uint8) != 0){
//663e62 return part
cur_cost += RCT2_GLOBAL(0x9E32B4, uint32);
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
return 0;
}
return cur_cost;
}
if (!(RCT2_GLOBAL(0x9DEA68, uint8) & 2) && RCT2_GLOBAL(0x13573E4, uint32) & 4){
//663e62 return part
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;
}
for (int x = x0; x < x1; x += 32){
for (int y = y0; y < y1; y += 32){
for (int x = x0; x <= x1; x += 32){
for (int y = y0; y <= y1; y += 32){
if (x > 0x1FFF)continue;
if (y > 0x1FFF)continue;
if (!(RCT2_GLOBAL(0x9DEA68, uint8) & 2)){
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)){
if (!map_is_location_in_park(x, y))continue;
}
rct_map_element* map_element = map_get_surface_element_at(x / 32, y / 32);
rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER((x | (y << 8)) >> 5);
while ((map_element->type&MAP_ELEMENT_TYPE_MASK) != MAP_ELEMENT_TYPE_SURFACE){
map_element++;
}
if (terrain_surface != 0xFF){
if (surface_style != 0xFF){
uint8 cur_terrain = (
(map_element->type&MAP_ELEMENT_DIRECTION_MASK) << 3)
| (map_element->properties.surface.terrain >> 5);
if (terrain_surface != cur_terrain){
RCT2_GLOBAL(0x9E32B4, uint32) += RCT2_ADDRESS(0x97B8B8, uint32)[terrain_surface & 0x1F];
if (surface_style != cur_terrain){
RCT2_GLOBAL(0x9E32B4, uint32) += RCT2_ADDRESS(0x97B8B8, uint32)[surface_style & 0x1F];
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
map_element->properties.surface.terrain |= terrain_surface << 5;
map_element->properties.surface.terrain |= surface_style << 5;
//Save the new direction mask
map_element->type |= terrain_surface >> 3;
map_element->type |= (surface_style >> 3) & MAP_ELEMENT_DIRECTION_MASK;
map_invalidate_tile_full(x, y);
RCT2_CALLPROC_X(0x673883, x, 0, y, map_element_height(x, y), 0, 0, 0);
@@ -770,21 +778,62 @@ money32 map_raise_lower_land(int x0, int y0, int x1, int y1, uint8 terrain_surfa
}
}
//0x663de2
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;
//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);
}
}
}
}
}
}
//0x663e62
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;
}
/* rct2: 0x00663CCD */
void game_command_raise_lower_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp){
*ebx = map_raise_lower_land(
(*eax & 0xFFFF) / 32,
(*ecx & 0xFFFF) / 32,
(*edi & 0xFFFF) / 32,
(*ebp & 0xFFFF) / 32,
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),
*edx & 0xFF,
(*edx & 0xFF00) >> 8,
*ebx & 0xFF
);
}

View File

@@ -24,10 +24,10 @@
#include "../common.h"
typedef struct {
uint8 slope; //4
uint8 terrain; //5
uint8 grass_length;
uint8 ownership;
uint8 slope; //4 0xE0 Edge Style, 0x1F Slope
uint8 terrain; //5 0xE0 Terrain Style, 0x1F Water height
uint8 grass_length; //6
uint8 ownership; //7
} rct_map_element_surface_properties;
typedef struct {
@@ -192,6 +192,7 @@ enum {
#define MAP_ELEMENT_DIRECTION_MASK 0x03
#define MAP_ELEMENT_SLOPE_MASK 0x1F
#define MAP_ELEMENT_SLOPE_EDGE_STYLE_MASK 0xE0
#define MAP_ELEMENT_WATER_HEIGHT_MASK 0x1F
#define MAP_ELEMENT_SURFACE_TERRAIN_MASK 0xE0
@@ -245,7 +246,7 @@ void map_invalidate_selection_rect();
void fountain_update_all();
void game_command_clear_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
void game_command_raise_lower_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
void game_command_change_surface_style(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
#define GET_MAP_ELEMENT(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element)[x]))
#define TILE_MAP_ELEMENT_POINTER(x) (RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[x])