mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fixed crash when using land/water tool outside map
This commit is contained in:
parent
aae1288332
commit
a09b103895
192
src/world/map.c
192
src/world/map.c
|
@ -1509,8 +1509,11 @@ void game_command_raise_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
|
||||||
for(int yi = ay; yi <= by; yi += 32){
|
for(int yi = ay; yi <= by; yi += 32){
|
||||||
for(int xi = ax; xi <= bx; xi += 32){
|
for(int xi = ax; xi <= bx; xi += 32){
|
||||||
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
||||||
if(min_height > map_element->base_height){
|
if (map_element != NULL)
|
||||||
min_height = map_element->base_height;
|
{
|
||||||
|
if(min_height > map_element->base_height){
|
||||||
|
min_height = map_element->base_height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1518,19 +1521,22 @@ void game_command_raise_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
|
||||||
for(int yi = ay; yi <= by; yi += 32){
|
for(int yi = ay; yi <= by; yi += 32){
|
||||||
for(int xi = ax; xi <= bx; xi += 32){
|
for(int xi = ax; xi <= bx; xi += 32){
|
||||||
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
||||||
uint8 height = map_element->base_height;
|
if (map_element != NULL)
|
||||||
if(height <= min_height){
|
{
|
||||||
uint8 new_style = map_element_raise_styles[selection_type][map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK];
|
uint8 height = map_element->base_height;
|
||||||
if(new_style & 0x20){ // needs to be raised
|
if(height <= min_height){
|
||||||
height += 2;
|
uint8 new_style = map_element_raise_styles[selection_type][map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK];
|
||||||
new_style &= ~0x20;
|
if(new_style & 0x20){ // needs to be raised
|
||||||
}
|
height += 2;
|
||||||
int ebx2 = sub_66397F(*ebx, xi, yi, height, new_style, selection_type);
|
new_style &= ~0x20;
|
||||||
if(ebx2 == MONEY32_UNDEFINED){
|
}
|
||||||
*ebx = MONEY32_UNDEFINED;
|
int ebx2 = sub_66397F(*ebx, xi, yi, height, new_style, selection_type);
|
||||||
return;
|
if(ebx2 == MONEY32_UNDEFINED){
|
||||||
}else{
|
*ebx = MONEY32_UNDEFINED;
|
||||||
cost += ebx2;
|
return;
|
||||||
|
}else{
|
||||||
|
cost += ebx2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1578,15 +1584,18 @@ void game_command_lower_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
|
||||||
for(int yi = ay; yi <= by; yi += 32){
|
for(int yi = ay; yi <= by; yi += 32){
|
||||||
for(int xi = ax; xi <= bx; xi += 32){
|
for(int xi = ax; xi <= bx; xi += 32){
|
||||||
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
||||||
uint8 base_height = map_element->base_height;
|
if (map_element != NULL)
|
||||||
if(map_element->properties.surface.slope & 0xF){
|
{
|
||||||
base_height += 2;
|
uint8 base_height = map_element->base_height;
|
||||||
}
|
if(map_element->properties.surface.slope & 0xF){
|
||||||
if(map_element->properties.surface.slope & 0x10){
|
base_height += 2;
|
||||||
base_height += 2;
|
}
|
||||||
}
|
if(map_element->properties.surface.slope & 0x10){
|
||||||
if(max_height < base_height){
|
base_height += 2;
|
||||||
max_height = base_height;
|
}
|
||||||
|
if(max_height < base_height){
|
||||||
|
max_height = base_height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1594,26 +1603,29 @@ void game_command_lower_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
|
||||||
for(int yi = ay; yi <= by; yi += 32){
|
for(int yi = ay; yi <= by; yi += 32){
|
||||||
for(int xi = ax; xi <= bx; xi += 32){
|
for(int xi = ax; xi <= bx; xi += 32){
|
||||||
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
||||||
uint8 height = map_element->base_height;
|
if (map_element != NULL)
|
||||||
if(map_element->properties.surface.slope & 0xF){
|
{
|
||||||
height += 2;
|
uint8 height = map_element->base_height;
|
||||||
}
|
if(map_element->properties.surface.slope & 0xF){
|
||||||
if(map_element->properties.surface.slope & 0x10){
|
height += 2;
|
||||||
height += 2;
|
|
||||||
}
|
|
||||||
if(height >= max_height){
|
|
||||||
height = map_element->base_height;
|
|
||||||
uint8 new_style = map_element_lower_styles[selection_type][map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK];
|
|
||||||
if(new_style & 0x20){ // needs to be lowered
|
|
||||||
height -= 2;
|
|
||||||
new_style &= ~0x20;
|
|
||||||
}
|
}
|
||||||
int ebx2 = sub_66397F(*ebx, xi, yi, height, new_style, selection_type);
|
if(map_element->properties.surface.slope & 0x10){
|
||||||
if(ebx2 == MONEY32_UNDEFINED){
|
height += 2;
|
||||||
*ebx = MONEY32_UNDEFINED;
|
}
|
||||||
return;
|
if(height >= max_height){
|
||||||
}else{
|
height = map_element->base_height;
|
||||||
cost += ebx2;
|
uint8 new_style = map_element_lower_styles[selection_type][map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK];
|
||||||
|
if(new_style & 0x20){ // needs to be lowered
|
||||||
|
height -= 2;
|
||||||
|
new_style &= ~0x20;
|
||||||
|
}
|
||||||
|
int ebx2 = sub_66397F(*ebx, xi, yi, height, new_style, selection_type);
|
||||||
|
if(ebx2 == MONEY32_UNDEFINED){
|
||||||
|
*ebx = MONEY32_UNDEFINED;
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
cost += ebx2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1633,12 +1645,15 @@ money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags){
|
||||||
for (int yi = y0; yi <= y1; yi += 32){
|
for (int yi = y0; yi <= y1; yi += 32){
|
||||||
for (int xi = x0; xi <= x1; xi += 32){
|
for (int xi = x0; xi <= x1; xi += 32){
|
||||||
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
||||||
uint8 height = map_element->base_height;
|
if (map_element != NULL)
|
||||||
if (map_element->properties.surface.terrain & 0x1F){
|
{
|
||||||
height = (map_element->properties.surface.terrain & 0x1F) * 2;
|
uint8 height = map_element->base_height;
|
||||||
}
|
if (map_element->properties.surface.terrain & 0x1F){
|
||||||
if (max_height > height){
|
height = (map_element->properties.surface.terrain & 0x1F) * 2;
|
||||||
max_height = height;
|
}
|
||||||
|
if (max_height > height){
|
||||||
|
max_height = height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1647,25 +1662,28 @@ money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags){
|
||||||
for (int xi = x0; xi <= x1; xi += 32){
|
for (int xi = x0; xi <= x1; xi += 32){
|
||||||
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
||||||
|
|
||||||
if (map_element->base_height <= max_height){
|
if (map_element != NULL)
|
||||||
uint8 height = (map_element->properties.surface.terrain & 0x1F);
|
{
|
||||||
if (height){
|
if (map_element->base_height <= max_height){
|
||||||
height *= 2;
|
uint8 height = (map_element->properties.surface.terrain & 0x1F);
|
||||||
if (height > max_height){
|
if (height){
|
||||||
continue;
|
height *= 2;
|
||||||
|
if (height > max_height){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
height += 2;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
height = map_element->base_height + 2;
|
||||||
}
|
}
|
||||||
height += 2;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
height = map_element->base_height + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
money32 cost2 = game_do_command(xi, flags, yi, (max_height << 8) + height, GAME_COMMAND_16, 0, 0);
|
money32 cost2 = game_do_command(xi, flags, yi, (max_height << 8) + height, GAME_COMMAND_16, 0, 0);
|
||||||
if (cost2 == MONEY32_UNDEFINED){
|
if (cost2 == MONEY32_UNDEFINED){
|
||||||
return MONEY32_UNDEFINED;
|
return MONEY32_UNDEFINED;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
cost += cost2;
|
cost += cost2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1711,11 +1729,14 @@ money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags){
|
||||||
for (int xi = x0; xi <= x1; xi += 32){
|
for (int xi = x0; xi <= x1; xi += 32){
|
||||||
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
||||||
|
|
||||||
uint8 height = map_element->properties.surface.terrain & 0x1F;
|
if (map_element != NULL)
|
||||||
if (height){
|
{
|
||||||
height *= 2;
|
uint8 height = map_element->properties.surface.terrain & 0x1F;
|
||||||
if (height > min_height){
|
if (height){
|
||||||
min_height = height;
|
height *= 2;
|
||||||
|
if (height > min_height){
|
||||||
|
min_height = height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1725,19 +1746,22 @@ money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags){
|
||||||
for (int xi = x0; xi <= x1; xi += 32){
|
for (int xi = x0; xi <= x1; xi += 32){
|
||||||
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
|
||||||
|
|
||||||
uint8 height = (map_element->properties.surface.terrain & 0x1F);
|
if (map_element != NULL)
|
||||||
if (height){
|
{
|
||||||
height *= 2;
|
uint8 height = (map_element->properties.surface.terrain & 0x1F);
|
||||||
if (height < min_height){
|
if (height){
|
||||||
continue;
|
height *= 2;
|
||||||
}
|
if (height < min_height){
|
||||||
height -= 2;
|
continue;
|
||||||
int cost2 = game_do_command(xi, flags, yi, (min_height << 8) + height, GAME_COMMAND_16, 0, 0);
|
}
|
||||||
if (cost2 == MONEY32_UNDEFINED){
|
height -= 2;
|
||||||
return MONEY32_UNDEFINED;
|
int cost2 = game_do_command(xi, flags, yi, (min_height << 8) + height, GAME_COMMAND_16, 0, 0);
|
||||||
}
|
if (cost2 == MONEY32_UNDEFINED){
|
||||||
else{
|
return MONEY32_UNDEFINED;
|
||||||
cost += cost2;
|
}
|
||||||
|
else{
|
||||||
|
cost += cost2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue