mirror of https://github.com/OpenRCT2/OpenRCT2.git
Cleanup of last goto's.
This commit is contained in:
parent
6818d31492
commit
e406869fe4
152
src/game.c
152
src/game.c
|
@ -51,21 +51,6 @@ void game_handle_keyboard_input();
|
|||
|
||||
void process_mouse_over(int x, int y);
|
||||
|
||||
int stack[30];
|
||||
int stackPtr = 0;
|
||||
|
||||
void push(int var)
|
||||
{
|
||||
stack[stackPtr] = var;
|
||||
stackPtr++;
|
||||
}
|
||||
|
||||
int pop(void)
|
||||
{
|
||||
return stack[--stackPtr];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006ED801
|
||||
|
@ -82,6 +67,10 @@ void sub_0x6ED801(int x, int y){
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006ED990
|
||||
*/
|
||||
void sub_0x6ED990(char cursor_id){
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == INPUT_STATE_RESIZING)
|
||||
{
|
||||
|
@ -107,148 +96,111 @@ void process_mouse_over(int x, int y)
|
|||
rct_window* window;
|
||||
rct_window* subWindow;
|
||||
|
||||
|
||||
int widgetId;
|
||||
int cursorId;
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
|
||||
eax = x;
|
||||
ebx = y;
|
||||
edx = CURSOR_ARROW;
|
||||
cursorId = CURSOR_ARROW;
|
||||
RCT2_GLOBAL(0x9A9808, sint16) = -1;
|
||||
//RCT2_CALLFUNC_X(0x6EA845, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
window = window_find_from_point(x, y);
|
||||
|
||||
if (window == NULL)
|
||||
if (window != NULL)
|
||||
{
|
||||
goto loc_6ED983;
|
||||
}
|
||||
widgetId = window_find_widget_from_point(window, x, y);
|
||||
|
||||
RCT2_GLOBAL(0x1420046, sint16) = (widgetId & 0xFFFF);
|
||||
if (widgetId == 0xFFFF)
|
||||
if (widgetId != 0xFFFF)
|
||||
{
|
||||
goto loc_6ED983;
|
||||
}
|
||||
|
||||
if (window->widgets[widgetId].type != WWT_VIEWPORT)
|
||||
{
|
||||
goto loc_6ED8EE;
|
||||
}
|
||||
switch (window->widgets[widgetId].type){
|
||||
case WWT_VIEWPORT:
|
||||
if ((RCT2_GLOBAL(0x9DE518, int) & 0x8) == 0)
|
||||
{
|
||||
int _edx = edx;
|
||||
edx = cursorId;
|
||||
eax = x;
|
||||
ebx = y;
|
||||
//Find out if there is a clickable item under pointer
|
||||
RCT2_CALLFUNC_X(0X6ED9D0, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
edx = _edx;
|
||||
|
||||
if ((ebx & 0xFF) == 2 || (ebx & 0xFF) == 8 || (ebx & 0xFF) == 3)
|
||||
{
|
||||
edx = CURSOR_HAND_POINT;
|
||||
ebx = y;
|
||||
eax = x;
|
||||
sub_0x6ED990(edx);
|
||||
sub_0x6ED990(CURSOR_HAND_POINT);
|
||||
return;
|
||||
}
|
||||
goto loc_6ED983;
|
||||
break;
|
||||
}
|
||||
edx = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8);
|
||||
cursorId = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8);
|
||||
subWindow = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber));
|
||||
ebp = (int)subWindow;
|
||||
if (subWindow == NULL)
|
||||
{
|
||||
goto loc_6ED983;
|
||||
break;
|
||||
}
|
||||
ebx = ebx & 0xFFFFFF00;
|
||||
edi = edx;
|
||||
edi = cursorId;
|
||||
esi = subWindow;
|
||||
ebp = *(int*)esi;
|
||||
RCT2_CALLFUNC_X(subWindow->event_handlers[WE_UNKNOWN_0E], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
edx = edi;
|
||||
if ((ebx & 0xFF) == 0)
|
||||
cursorId = edi;
|
||||
if ((ebx & 0xFF) != 0)
|
||||
{
|
||||
goto loc_6ED983;
|
||||
}
|
||||
else
|
||||
{
|
||||
ebx = y;
|
||||
eax = x;
|
||||
sub_0x6ED990(edx);
|
||||
sub_0x6ED990(cursorId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
loc_6ED8EE:
|
||||
if (window->widgets[widgetId].type != WWT_RESIZE && window->widgets[widgetId].type != WWT_FRAME)
|
||||
{
|
||||
goto loc_6ED93D;
|
||||
}
|
||||
break;
|
||||
case WWT_FRAME:
|
||||
case WWT_RESIZE:
|
||||
if (!(window->flags & 0x100))
|
||||
{
|
||||
goto loc_6ED93D;
|
||||
break;
|
||||
}
|
||||
if (window->min_width == window->max_width && window->min_height == window->max_height)
|
||||
{
|
||||
goto loc_6ED93D;
|
||||
break;
|
||||
}
|
||||
if (x < window->x + window->width - 0x13)
|
||||
{
|
||||
goto loc_6ED93D;
|
||||
break;
|
||||
}
|
||||
if (y < window->y + window->height - 0x13)
|
||||
{
|
||||
goto loc_6ED93D;
|
||||
break;
|
||||
}
|
||||
edx = CURSOR_DIAGONAL_ARROWS;
|
||||
goto loc_6ED983;
|
||||
|
||||
loc_6ED93D:
|
||||
cursorId = CURSOR_DIAGONAL_ARROWS;
|
||||
break;
|
||||
case WWT_SCROLL:
|
||||
RCT2_GLOBAL(0x9DE558, uint16) = x;
|
||||
RCT2_GLOBAL(0x9DE55A, uint16) = y;
|
||||
push(eax);
|
||||
push(ebx);
|
||||
push(edx);
|
||||
if (window->widgets[widgetId].type != WWT_SCROLL)
|
||||
int output_x, output_y, output_scroll_area, scroll_id;
|
||||
widget_scroll_get_part(window, window->widgets, x, y, &output_x, &output_y, &output_scroll_area, &scroll_id);
|
||||
cursorId = scroll_id;
|
||||
if (output_scroll_area != SCROLL_PART_VIEW)
|
||||
{
|
||||
goto loc_6ED95C;
|
||||
cursorId = CURSOR_ARROW;
|
||||
break;
|
||||
}
|
||||
{
|
||||
int output_x, output_y, output_cx, output_dx;
|
||||
widget_scroll_get_part(window, window->widgets, eax, ebx, &output_x, &output_y, &output_cx, &output_dx);
|
||||
edx = output_dx;
|
||||
if (output_cx != 0)
|
||||
{
|
||||
goto loc_6ED980;
|
||||
}
|
||||
}
|
||||
loc_6ED95C:
|
||||
{
|
||||
ecx = eax;
|
||||
edx = ebx;
|
||||
eax = RCT2_GLOBAL(0x1420046, uint16);
|
||||
//Fall through to default
|
||||
default:
|
||||
ecx = x;
|
||||
edx = y;
|
||||
eax = widgetId;
|
||||
ebx = 0xFFFFFFFF;
|
||||
int _edi = edi;
|
||||
edi = (int)&window->widgets[widgetId];
|
||||
|
||||
RCT2_CALLFUNC_X(window->event_handlers[WE_UNKNOWN_17], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
edi = _edi;
|
||||
if (ebx == 0xFFFFFFFF)
|
||||
{
|
||||
goto loc_6ED980;
|
||||
cursorId = CURSOR_ARROW;
|
||||
break;
|
||||
}
|
||||
edx = ebx;
|
||||
ebx = pop();
|
||||
ebx = pop();
|
||||
eax = pop();
|
||||
goto loc_6ED983;
|
||||
cursorId = ebx;
|
||||
break;
|
||||
}
|
||||
loc_6ED980:
|
||||
edx = pop();
|
||||
ebx = pop();
|
||||
eax = pop();
|
||||
|
||||
loc_6ED983:
|
||||
RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp);
|
||||
}
|
||||
}
|
||||
RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, cursorId, esi, edi, ebp);
|
||||
//itemUnderCursor(&eax, &ebx, &ecx, &edx);
|
||||
|
||||
sub_0x6ED990(edx);
|
||||
sub_0x6ED990(cursorId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue