Fixed dropdown location after pickup. Labbeld variables to make it easier to read

This commit is contained in:
Duncan Frost 2014-09-18 16:52:56 +01:00
parent 7002720f24
commit b40ebfe7a2
1 changed files with 25 additions and 18 deletions

View File

@ -1179,7 +1179,7 @@ void window_peep_overview_tool_update(){
}
/* rct2: 0x664F72 */
int sub_664F72(int x, int y, int edx){
int sub_664F72(int x, int y, int z){
if (x > 0x1FFF || y > 0x1FFF){
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1;
return 1;
@ -1192,10 +1192,10 @@ int sub_664F72(int x, int y, int edx){
return 1;
}
edx >>= 3;
if ((edx & 0xFF) < map_element->base_height)return 0;
edx = (edx & 0xFF) - 2;
if (edx > map_element->base_height)return 0;
z >>= 3;
if ((z & 0xFF) < map_element->base_height)return 0;
z = (z & 0xFF) - 2;
if (z > map_element->base_height)return 0;
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1;
return 1;
@ -1211,25 +1211,32 @@ void window_peep_overview_tool_down(){
if (widgetIndex != WIDX_PICKUP) return;
int eax = x, ebx = y, ecx = 0, edx = widgetIndex, edi = 0, esi = (int)w, ebp = 0;
ebx += 16;
RCT2_CALLFUNC_X(0x689726, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
int dest_x = x, dest_y = y, ecx = 0, edx = widgetIndex, edi = 0, esi = (int)w, ebp = 0;
dest_y += 16;
RCT2_CALLFUNC_X(0x689726, &dest_x, &dest_y, &ecx, &edx, &esi, &edi, &ebp);
if (eax == 0x8000)return;
if (dest_x == 0x8000)return;
eax += 16;
ecx = ebx + 16;
edx = ((uint8*)edx)[2] * 8 + 16;
int _eax = eax & 0xFFE0, _ebx = ebx & 0xFFE0;
if (sub_664F72(eax & 0xFFE0, ebx & 0xFFE0, edx)){
// Set the coordinate of destination to be exactly
// in the middle of a tile.
dest_x += 16;
dest_y += 16;
// Set the tile coordinate to top left of tile
int tile_y = dest_y & 0xFFE0;
int tile_x = dest_x & 0xFFE0;
int dest_z = ((uint8*)edx)[2] * 8 + 16;
if (sub_664F72(tile_x, tile_y, dest_z)){
window_error_open(0x785,-1);
return;
}
int _edx = edx>>3;
int _edx = dest_z >> 3;
_edx &= 0xFFFF00FF;
_edx |= edx << 8;
_edx |= dest_z << 8;
_edx += 0x100;
int flags = RCT2_CALLPROC_X(0x68B93A, eax & 0xFFE0, 0xF, ebx & 0xFFE0, _edx, (int)w, 0, 0);
int flags = RCT2_CALLPROC_X(0x68B93A, tile_x, 0xF, tile_y, _edx, (int)w, 0, 0);
if (flags & 0x100){
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) != 0x3A5 ){
@ -1241,7 +1248,7 @@ void window_peep_overview_tool_down(){
}
rct_peep* peep = GET_PEEP(w->number);
RCT2_CALLPROC_X(0x0069E9D3, eax, 0, ebx, edx, (int)peep, 0, 0);
RCT2_CALLPROC_X(0x0069E9D3, dest_x, 0, dest_y, dest_z, (int)peep, 0, 0);
RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0);
RCT2_CALLPROC_X(0x0069A409, 0, 0, 0, 0, (int)peep, 0, 0);
peep->state = 0;