mirror of https://github.com/OpenRCT2/OpenRCT2.git
Clean up and match coding style
This commit is contained in:
parent
e5ad14e3f5
commit
1fc7793c2a
446
src/world/map.c
446
src/world/map.c
|
@ -1667,267 +1667,6 @@ const uint8 map_element_lower_styles[5][32] = {
|
||||||
{ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x0D, 0x0E, 0x00 },
|
{ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x0D, 0x0E, 0x00 },
|
||||||
};
|
};
|
||||||
|
|
||||||
//Hack: pushes variables to the stack before jumping to address
|
|
||||||
//These functions are temporary and are used for debugging the decompiled code.
|
|
||||||
#ifdef __GNUC__
|
|
||||||
static int callcode_push3(int address, int stackvar1, int stackvar2, int stackvar3, int *_eax, int *_ebx, int *_ecx, int *_edx, int *_esi, int *_edi, int *_ebp)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
__asm__ ( "\
|
|
||||||
\n\
|
|
||||||
/* Store C's base pointer*/ \n\
|
|
||||||
push %%ebp \n\
|
|
||||||
push %%ebx \n\
|
|
||||||
\n\
|
|
||||||
/* Store %[address] to call*/ \n\
|
|
||||||
push %[address] \n\
|
|
||||||
\n\
|
|
||||||
/* Set all registers to the input values*/ \n\
|
|
||||||
mov %[_eax], %%eax \n\
|
|
||||||
mov (%%eax), %%eax \n\
|
|
||||||
mov %[_ebx], %%ebx \n\
|
|
||||||
mov (%%ebx), %%ebx \n\
|
|
||||||
mov %[_ecx], %%ecx \n\
|
|
||||||
mov (%%ecx), %%ecx \n\
|
|
||||||
mov %[_edx], %%edx \n\
|
|
||||||
mov (%%edx), %%edx \n\
|
|
||||||
mov %[_esi], %%esi \n\
|
|
||||||
mov (%%esi), %%esi \n\
|
|
||||||
mov %[_edi], %%edi \n\
|
|
||||||
mov (%%edi), %%edi \n\
|
|
||||||
push $_foo \n\
|
|
||||||
push %[stackvar1] \n\
|
|
||||||
push %[stackvar2] \n\
|
|
||||||
push %[stackvar3] \n\
|
|
||||||
mov %[_ebp], %%ebp \n\
|
|
||||||
mov (%%ebp), %%ebp \n\
|
|
||||||
\n\
|
|
||||||
/* Call function*/ \n\
|
|
||||||
/* Push registers required by function */ \n\
|
|
||||||
/* call *(%%esp) */ \n\
|
|
||||||
jmp *16(%%esp) \n\
|
|
||||||
_foo: \n\
|
|
||||||
\n\
|
|
||||||
/* Store output eax */ \n\
|
|
||||||
push %%eax \n\
|
|
||||||
push %%ebp \n\
|
|
||||||
push %%ebx \n\
|
|
||||||
mov 20(%%esp), %%ebp \n\
|
|
||||||
mov 16(%%esp), %%ebx \n\
|
|
||||||
/* Get resulting ecx, edx, esi, edi registers*/ \n\
|
|
||||||
mov %[_edi], %%eax \n\
|
|
||||||
mov %%edi, (%%eax) \n\
|
|
||||||
mov %[_esi], %%eax \n\
|
|
||||||
mov %%esi, (%%eax) \n\
|
|
||||||
mov %[_edx], %%eax \n\
|
|
||||||
mov %%edx, (%%eax) \n\
|
|
||||||
mov %[_ecx], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
/* Pop ebx reg into ecx*/ \n\
|
|
||||||
pop %%ecx \n\
|
|
||||||
mov %[_ebx], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
\n\
|
|
||||||
/* Pop ebp reg into ecx */\n\
|
|
||||||
pop %%ecx \n\
|
|
||||||
mov %[_ebp], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
\n\
|
|
||||||
pop %%eax \n\
|
|
||||||
/* Get resulting eax register*/ \n\
|
|
||||||
mov %[_eax], %%ecx \n\
|
|
||||||
mov %%eax, (%%ecx) \n\
|
|
||||||
\n\
|
|
||||||
/* Save flags as return in eax*/ \n\
|
|
||||||
lahf \n\
|
|
||||||
/* Pop address*/ \n\
|
|
||||||
pop %%ebp \n\
|
|
||||||
\n\
|
|
||||||
pop %%ebx \n\
|
|
||||||
pop %%ebp \n\
|
|
||||||
/* Load result with flags */ \n\
|
|
||||||
mov %%eax, %[result] \n\
|
|
||||||
" : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp), [result] "+m" (result)
|
|
||||||
|
|
||||||
: [stackvar1] "m" (stackvar1), [stackvar2] "m" (stackvar2), [stackvar3] "m" (stackvar3)
|
|
||||||
: "eax","ecx","edx","esi","edi"
|
|
||||||
);
|
|
||||||
return result&0xFF00;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int callcode_push2(int address, int stackvar1, int stackvar2, int *_eax, int *_ebx, int *_ecx, int *_edx, int *_esi, int *_edi, int *_ebp)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
__asm__ ( "\
|
|
||||||
\n\
|
|
||||||
/* Store C's base pointer*/ \n\
|
|
||||||
push %%ebp \n\
|
|
||||||
push %%ebx \n\
|
|
||||||
\n\
|
|
||||||
/* Store %[address] to call*/ \n\
|
|
||||||
push %[address] \n\
|
|
||||||
\n\
|
|
||||||
/* Set all registers to the input values*/ \n\
|
|
||||||
mov %[_eax], %%eax \n\
|
|
||||||
mov (%%eax), %%eax \n\
|
|
||||||
mov %[_ebx], %%ebx \n\
|
|
||||||
mov (%%ebx), %%ebx \n\
|
|
||||||
mov %[_ecx], %%ecx \n\
|
|
||||||
mov (%%ecx), %%ecx \n\
|
|
||||||
mov %[_edx], %%edx \n\
|
|
||||||
mov (%%edx), %%edx \n\
|
|
||||||
mov %[_esi], %%esi \n\
|
|
||||||
mov (%%esi), %%esi \n\
|
|
||||||
mov %[_edi], %%edi \n\
|
|
||||||
mov (%%edi), %%edi \n\
|
|
||||||
push $foo \n\
|
|
||||||
push %[stackvar1] \n\
|
|
||||||
push %[stackvar2] \n\
|
|
||||||
mov %[_ebp], %%ebp \n\
|
|
||||||
mov (%%ebp), %%ebp \n\
|
|
||||||
\n\
|
|
||||||
/* Call function*/ \n\
|
|
||||||
/* Push registers required by function */ \n\
|
|
||||||
/* call *(%%esp) */ \n\
|
|
||||||
jmp *12(%%esp) \n\
|
|
||||||
foo: \n\
|
|
||||||
\n\
|
|
||||||
/* Store output eax */ \n\
|
|
||||||
push %%eax \n\
|
|
||||||
push %%ebp \n\
|
|
||||||
push %%ebx \n\
|
|
||||||
mov 20(%%esp), %%ebp \n\
|
|
||||||
mov 16(%%esp), %%ebx \n\
|
|
||||||
/* Get resulting ecx, edx, esi, edi registers*/ \n\
|
|
||||||
mov %[_edi], %%eax \n\
|
|
||||||
mov %%edi, (%%eax) \n\
|
|
||||||
mov %[_esi], %%eax \n\
|
|
||||||
mov %%esi, (%%eax) \n\
|
|
||||||
mov %[_edx], %%eax \n\
|
|
||||||
mov %%edx, (%%eax) \n\
|
|
||||||
mov %[_ecx], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
/* Pop ebx reg into ecx*/ \n\
|
|
||||||
pop %%ecx \n\
|
|
||||||
mov %[_ebx], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
\n\
|
|
||||||
/* Pop ebp reg into ecx */\n\
|
|
||||||
pop %%ecx \n\
|
|
||||||
mov %[_ebp], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
\n\
|
|
||||||
pop %%eax \n\
|
|
||||||
/* Get resulting eax register*/ \n\
|
|
||||||
mov %[_eax], %%ecx \n\
|
|
||||||
mov %%eax, (%%ecx) \n\
|
|
||||||
\n\
|
|
||||||
/* Save flags as return in eax*/ \n\
|
|
||||||
lahf \n\
|
|
||||||
/* Pop address*/ \n\
|
|
||||||
pop %%ebp \n\
|
|
||||||
\n\
|
|
||||||
pop %%ebx \n\
|
|
||||||
pop %%ebp \n\
|
|
||||||
/* Load result with flags */ \n\
|
|
||||||
mov %%eax, %[result] \n\
|
|
||||||
" : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp), [result] "+m" (result)
|
|
||||||
|
|
||||||
: [stackvar1] "m" (stackvar1), [stackvar2] "m" (stackvar2)
|
|
||||||
: "eax","ecx","edx","esi","edi"
|
|
||||||
);
|
|
||||||
return result&0xFF00;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int callcode_push1(int address, int stackvar, int *_eax, int *_ebx, int *_ecx, int *_edx, int *_esi, int *_edi, int *_ebp)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
__asm__ ( "\
|
|
||||||
\n\
|
|
||||||
/* Store C's base pointer*/ \n\
|
|
||||||
push %%ebp \n\
|
|
||||||
push %%ebx \n\
|
|
||||||
\n\
|
|
||||||
/* Store %[address] to call*/ \n\
|
|
||||||
push %[address] \n\
|
|
||||||
\n\
|
|
||||||
/* Set all registers to the input values*/ \n\
|
|
||||||
mov %[_eax], %%eax \n\
|
|
||||||
mov (%%eax), %%eax \n\
|
|
||||||
mov %[_ebx], %%ebx \n\
|
|
||||||
mov (%%ebx), %%ebx \n\
|
|
||||||
mov %[_ecx], %%ecx \n\
|
|
||||||
mov (%%ecx), %%ecx \n\
|
|
||||||
mov %[_edx], %%edx \n\
|
|
||||||
mov (%%edx), %%edx \n\
|
|
||||||
mov %[_esi], %%esi \n\
|
|
||||||
mov (%%esi), %%esi \n\
|
|
||||||
mov %[_edi], %%edi \n\
|
|
||||||
mov (%%edi), %%edi \n\
|
|
||||||
/* Hack: called code should return back to this function */ \n\
|
|
||||||
push $__foo \n\
|
|
||||||
/* Push variable */\n\
|
|
||||||
push %[stackvar] \n\
|
|
||||||
mov %[_ebp], %%ebp \n\
|
|
||||||
mov (%%ebp), %%ebp \n\
|
|
||||||
\n\
|
|
||||||
/* Call function*/ \n\
|
|
||||||
/* call *(%%esp) */ \n\
|
|
||||||
/* int $3 */\n\
|
|
||||||
jmp *8(%%esp) \n\
|
|
||||||
__foo: \n\
|
|
||||||
\n\
|
|
||||||
/* Store output eax */ \n\
|
|
||||||
push %%eax \n\
|
|
||||||
push %%ebp \n\
|
|
||||||
push %%ebx \n\
|
|
||||||
mov 20(%%esp), %%ebp \n\
|
|
||||||
mov 16(%%esp), %%ebx \n\
|
|
||||||
/* Get resulting ecx, edx, esi, edi registers*/ \n\
|
|
||||||
mov %[_edi], %%eax \n\
|
|
||||||
mov %%edi, (%%eax) \n\
|
|
||||||
mov %[_esi], %%eax \n\
|
|
||||||
mov %%esi, (%%eax) \n\
|
|
||||||
mov %[_edx], %%eax \n\
|
|
||||||
mov %%edx, (%%eax) \n\
|
|
||||||
mov %[_ecx], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
/* Pop ebx reg into ecx*/ \n\
|
|
||||||
pop %%ecx \n\
|
|
||||||
mov %[_ebx], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
\n\
|
|
||||||
/* Pop ebp reg into ecx */\n\
|
|
||||||
pop %%ecx \n\
|
|
||||||
mov %[_ebp], %%eax \n\
|
|
||||||
mov %%ecx, (%%eax) \n\
|
|
||||||
\n\
|
|
||||||
pop %%eax \n\
|
|
||||||
/* Get resulting eax register*/ \n\
|
|
||||||
mov %[_eax], %%ecx \n\
|
|
||||||
mov %%eax, (%%ecx) \n\
|
|
||||||
\n\
|
|
||||||
/* Save flags as return in eax*/ \n\
|
|
||||||
lahf \n\
|
|
||||||
/* Pop address*/ \n\
|
|
||||||
pop %%ebp \n\
|
|
||||||
\n\
|
|
||||||
pop %%ebx \n\
|
|
||||||
pop %%ebp \n\
|
|
||||||
/* Load result with flags */ \n\
|
|
||||||
mov %%eax, %[result] \n\
|
|
||||||
" : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp), [result] "+m" (result)
|
|
||||||
|
|
||||||
: [stackvar] "m" (stackvar)
|
|
||||||
: "eax","ecx","edx","esi","edi"
|
|
||||||
);
|
|
||||||
return result&0xFF00;
|
|
||||||
}
|
|
||||||
#endif //__GNUC__
|
|
||||||
|
|
||||||
static money32 map_set_land_height(int flags, int x, int y, int height, int style, int selectionType)
|
static money32 map_set_land_height(int flags, int x, int y, int height, int style, int selectionType)
|
||||||
{
|
{
|
||||||
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) {
|
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) {
|
||||||
|
@ -1971,46 +1710,38 @@ static money32 map_set_land_height(int flags, int x, int y, int height, int styl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Continuing decompilation - work in progress
|
//Uncomment to use vanilla code
|
||||||
* Known bugs (introduced by disassembly):
|
/*
|
||||||
* none! Still requires testing, though.
|
registers regs = {0};
|
||||||
* Original bugs:
|
regs.eax = x;
|
||||||
* Lowering the land tile underneath a wall removes the wall.
|
regs.ebx = flags;
|
||||||
* Land can be raised over flat scenery items (gardens, for example) without removing them.
|
regs.ecx = y;
|
||||||
* Removal price of walls is not added.
|
regs.dl = height;
|
||||||
* Removal price of flat scenery is not counted when raising the center of a tile.
|
regs.dh = style;
|
||||||
|
regs.esi = 0;
|
||||||
|
regs.edi = selectionType << 5;
|
||||||
|
regs.ebp = 0;
|
||||||
|
RCT2_CALLFUNC_Y(0x006639FE, ®s); return regs.ebx;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int eax = x, ebx = flags, ecx = y, edi = selectionType << 5, ebp = 0;
|
|
||||||
uint32 edx = (style << 8) | height;
|
|
||||||
//dl: height
|
|
||||||
//dh: style
|
|
||||||
uint32 esi = 0;
|
|
||||||
|
|
||||||
//Uncomment to use vanilla code
|
|
||||||
//RCT2_CALLFUNC_X(0x006639FE, &eax, &ebx, &ecx, (int *)&edx, (int *)&esi, &edi, &ebp); return ebx;
|
|
||||||
|
|
||||||
RCT2_GLOBAL(0x9E2E18, money32) = MONEY(0, 0);
|
RCT2_GLOBAL(0x9E2E18, money32) = MONEY(0, 0);
|
||||||
if(ebx&GAME_COMMAND_FLAG_APPLY)
|
if(flags & GAME_COMMAND_FLAG_APPLY)
|
||||||
{
|
{
|
||||||
footpath_remove_litter(x, y, map_element_height(x, y));
|
footpath_remove_litter(x, y, map_element_height(x, y));
|
||||||
map_remove_walls_at(x, y, height * 8 - 16, height * 8 + 32);
|
map_remove_walls_at(x, y, height * 8 - 16, height * 8 + 32);
|
||||||
}
|
}
|
||||||
RCT2_GLOBAL(0x9E2E18, money32) += MONEY(20, 0);
|
RCT2_GLOBAL(0x9E2E18, money32) += MONEY(20, 0);
|
||||||
|
|
||||||
rct_map_element *mapElement = map_get_first_element_at(x/32, y/32); //mapElement = esi
|
//Check for obstructing scenery
|
||||||
|
rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||||
int zHigh = height+4; //zHigh = dh
|
|
||||||
|
|
||||||
//loc_663A54:
|
|
||||||
do{
|
do{
|
||||||
int elementType = map_element_get_type(mapElement); //elementType = eax
|
if(map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SCENERY)
|
||||||
rct_scenery_entry *sceneryEntry; //eax
|
|
||||||
|
|
||||||
if(elementType!=MAP_ELEMENT_TYPE_SCENERY || height>mapElement->clearance_height || zHigh<(mapElement)->base_height)
|
|
||||||
continue;
|
continue;
|
||||||
elementType = mapElement->properties.scenery.type;
|
if(height > mapElement->clearance_height)
|
||||||
sceneryEntry = RCT2_ADDRESS(RCT2_ADDRESS_SMALL_SCENERY_ENTRIES, rct_scenery_entry *)[elementType];
|
continue;
|
||||||
|
if(height + 4 < mapElement->base_height)
|
||||||
|
continue;
|
||||||
|
rct_scenery_entry *sceneryEntry = RCT2_ADDRESS(RCT2_ADDRESS_SMALL_SCENERY_ENTRIES, rct_scenery_entry *)[mapElement->properties.scenery.type]; //sceneryEntry = eax
|
||||||
if(sceneryEntry->small_scenery.height > 64 && RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_TREE_REMOVAL)
|
if(sceneryEntry->small_scenery.height > 64 && RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_FORBID_TREE_REMOVAL)
|
||||||
{
|
{
|
||||||
map_obstruction_set_error_text(mapElement);
|
map_obstruction_set_error_text(mapElement);
|
||||||
|
@ -2021,17 +1752,16 @@ static money32 map_set_land_height(int flags, int x, int y, int height, int styl
|
||||||
map_element_remove(mapElement--);
|
map_element_remove(mapElement--);
|
||||||
}while(!map_element_is_last_for_tile(mapElement++));
|
}while(!map_element_is_last_for_tile(mapElement++));
|
||||||
|
|
||||||
mapElement = map_get_first_element_at(x/32, y/32); //mapElement = esi
|
//Check for obstructing rides
|
||||||
|
mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||||
//loc_663AC4:
|
|
||||||
do{
|
do{
|
||||||
if(map_element_get_type(mapElement)!=8) //eax
|
if(map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK)
|
||||||
continue;
|
continue;
|
||||||
int rideIndex = mapElement->properties.track.ride_index; //rideIndex = ebp
|
int rideIndex = mapElement->properties.track.ride_index;
|
||||||
int maxHeight = GET_RIDE_ENTRY(GET_RIDE(rideIndex)->subtype)->max_height; //maxHeight = eax
|
int maxHeight = GET_RIDE_ENTRY(GET_RIDE(rideIndex)->subtype)->max_height;
|
||||||
if(maxHeight == 0)
|
if(maxHeight == 0)
|
||||||
maxHeight = RCT2_GLOBAL(0x97D218 + 8 * GET_RIDE(rideIndex)->type, uint8);
|
maxHeight = RCT2_GLOBAL(0x97D218 + 8 * GET_RIDE(rideIndex)->type, uint8);
|
||||||
int zDelta = mapElement->clearance_height-height; //zDelta = ebx
|
int zDelta = mapElement->clearance_height - height;
|
||||||
if(zDelta >= 0 && zDelta/2 > maxHeight && gCheatsDisableSupportLimits == false)
|
if(zDelta >= 0 && zDelta/2 > maxHeight && gCheatsDisableSupportLimits == false)
|
||||||
{
|
{
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_SUPPORTS_CANT_BE_EXTENDED;
|
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_SUPPORTS_CANT_BE_EXTENDED;
|
||||||
|
@ -2039,92 +1769,84 @@ static money32 map_set_land_height(int flags, int x, int y, int height, int styl
|
||||||
}
|
}
|
||||||
}while(!map_element_is_last_for_tile(mapElement++));
|
}while(!map_element_is_last_for_tile(mapElement++));
|
||||||
|
|
||||||
mapElement = map_get_surface_element_at(x/32, y/32);
|
uint8 zCorner = height; //z position of highest corner of tile
|
||||||
|
rct_map_element *surfaceElement = map_get_surface_element_at(x / 32, y / 32);
|
||||||
if(mapElement->type&MAP_ELEMENT_TYPE_FLAG_HIGHLIGHT)
|
if(surfaceElement->type & MAP_ELEMENT_TYPE_FLAG_HIGHLIGHT)
|
||||||
{
|
{
|
||||||
int waterHeight = mapElement->properties.surface.terrain&MAP_ELEMENT_WATER_HEIGHT_MASK; //waterHeight = ecx
|
int waterHeight = surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK;
|
||||||
if(waterHeight != 0)
|
if(waterHeight != 0)
|
||||||
{
|
{
|
||||||
waterHeight = waterHeight*2-2;
|
if(style & 0x1F)
|
||||||
uint8 unk = height; //unk = bh
|
|
||||||
if((style&0x1F))
|
|
||||||
{
|
{
|
||||||
unk += 2;
|
zCorner += 2;
|
||||||
if((style&0x10))
|
if(style & 0x10)
|
||||||
{
|
{
|
||||||
unk += 2;
|
zCorner += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//loc_663B6A:
|
if(zCorner > waterHeight * 2 - 2)
|
||||||
if(unk>waterHeight)
|
{
|
||||||
|
surfaceElement++;
|
||||||
|
map_obstruction_set_error_text(surfaceElement);
|
||||||
|
return MONEY32_UNDEFINED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zCorner = height;
|
||||||
|
if(style & 0xF)
|
||||||
|
{
|
||||||
|
zCorner += 2;
|
||||||
|
if(style & 0x10)
|
||||||
|
{
|
||||||
|
zCorner += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(map_can_construct_with_clear_at(x, y, height, zCorner, RCT2_ADDRESS(0x663CB9, void), 0xF) == false)
|
||||||
|
return MONEY32_UNDEFINED;
|
||||||
|
|
||||||
|
mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||||
|
do{
|
||||||
|
int elementType = map_element_get_type(mapElement);
|
||||||
|
|
||||||
|
if(elementType == MAP_ELEMENT_TYPE_FENCE)
|
||||||
|
continue;
|
||||||
|
if(elementType == MAP_ELEMENT_TYPE_SCENERY)
|
||||||
|
continue;
|
||||||
|
if(mapElement->flags & 0x10)
|
||||||
|
continue;
|
||||||
|
if(mapElement == surfaceElement)
|
||||||
|
continue;
|
||||||
|
if(mapElement > surfaceElement)
|
||||||
|
{
|
||||||
|
if(zCorner > mapElement->base_height)
|
||||||
{
|
{
|
||||||
//rct2: 0x663C5A
|
|
||||||
mapElement++;
|
|
||||||
map_obstruction_set_error_text(mapElement);
|
map_obstruction_set_error_text(mapElement);
|
||||||
return MONEY32_UNDEFINED;
|
return MONEY32_UNDEFINED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
//loc_663B72:
|
|
||||||
|
|
||||||
uint8 unk = height; //unk = bh
|
|
||||||
|
|
||||||
if((style&0xF))
|
|
||||||
{
|
|
||||||
unk += 2;
|
|
||||||
if((style&0x10))
|
|
||||||
{
|
|
||||||
unk += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//rct2: 0x663B93
|
|
||||||
if(map_can_construct_with_clear_at(x, y, height, unk, RCT2_ADDRESS(0x663CB9, void), 0xF)==false)
|
|
||||||
return MONEY32_UNDEFINED;
|
|
||||||
|
|
||||||
rct_map_element *mapElement2 = map_get_first_element_at(x/32, y/32); //mapElement2 = edi
|
|
||||||
|
|
||||||
|
|
||||||
//loc_663BB5:
|
|
||||||
do{
|
|
||||||
int elementType = map_element_get_type(mapElement2); //elementType = al
|
|
||||||
|
|
||||||
if(elementType==MAP_ELEMENT_TYPE_FENCE || elementType==MAP_ELEMENT_TYPE_SCENERY || mapElement2->flags&0x10 || mapElement2==mapElement)
|
|
||||||
continue;
|
|
||||||
if(mapElement2>mapElement)
|
|
||||||
{
|
|
||||||
if(unk > mapElement2->base_height)
|
|
||||||
{
|
|
||||||
map_obstruction_set_error_text(mapElement2);
|
|
||||||
return MONEY32_UNDEFINED;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(height < mapElement2->clearance_height)
|
if(height < mapElement->clearance_height)
|
||||||
{
|
{
|
||||||
map_obstruction_set_error_text(mapElement2);
|
map_obstruction_set_error_text(mapElement);
|
||||||
return MONEY32_UNDEFINED;
|
return MONEY32_UNDEFINED;
|
||||||
}
|
}
|
||||||
}while(!map_element_is_last_for_tile(mapElement2++));
|
}while(!map_element_is_last_for_tile(mapElement++));
|
||||||
|
|
||||||
//rct2: 0x663BE4
|
if(flags & GAME_COMMAND_FLAG_APPLY)
|
||||||
if((flags&GAME_COMMAND_FLAG_APPLY))
|
|
||||||
{
|
{
|
||||||
//rct2: 0x663BEB
|
surfaceElement = map_get_surface_element_at(x / 32, y / 32);
|
||||||
mapElement = map_get_surface_element_at(x/32, y/32);
|
surfaceElement->base_height = height;
|
||||||
mapElement->base_height = height;
|
surfaceElement->clearance_height = height;
|
||||||
mapElement->clearance_height = height;
|
surfaceElement->properties.surface.slope &= MAP_ELEMENT_SLOPE_EDGE_STYLE_MASK;
|
||||||
mapElement->properties.surface.slope &= MAP_ELEMENT_SLOPE_EDGE_STYLE_MASK;
|
surfaceElement->properties.surface.slope |= style;
|
||||||
mapElement->properties.surface.slope |= style;
|
int slope = surfaceElement->properties.surface.terrain & MAP_ELEMENT_SLOPE_MASK;
|
||||||
//rct2: 0x663C17
|
|
||||||
int slope = mapElement->properties.surface.terrain&MAP_ELEMENT_SLOPE_MASK; //slope = bh
|
|
||||||
if(slope != 0 && slope <= height / 2)
|
if(slope != 0 && slope <= height / 2)
|
||||||
mapElement->properties.surface.terrain &= MAP_ELEMENT_SURFACE_TERRAIN_MASK;
|
surfaceElement->properties.surface.terrain &= MAP_ELEMENT_SURFACE_TERRAIN_MASK;
|
||||||
map_invalidate_tile_full(x, y);
|
map_invalidate_tile_full(x, y);
|
||||||
}
|
}
|
||||||
//rct2: 0x663C30
|
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
|
||||||
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32)&0x800)
|
|
||||||
return 0;
|
return 0;
|
||||||
return RCT2_GLOBAL(0x9E2E18, money32);
|
return RCT2_GLOBAL(0x9E2E18, money32);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue