Fix team arena cursor; prevent crashes caused by invalid pointer when switching to TA and back

This commit is contained in:
Petr Bartos 2022-03-24 17:59:42 +01:00
parent 56d1334007
commit 95951c27f9
3 changed files with 20 additions and 17 deletions

View file

@ -933,9 +933,6 @@ void UI_MouseEvent( int dx, int dy )
else if (uis.cursory > SCREEN_HEIGHT+16)
uis.cursory = SCREEN_HEIGHT+16;
vr->menuCursorX = &uis.cursorx;
vr->menuCursorY = &uis.cursory;
// region test the active menu items
for (i=0; i<uis.activemenu->nitems; i++)
{

View file

@ -50,13 +50,17 @@ Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, i
case UI_INIT: {
int ptr[2] = {arg1, arg2};
vr = (vr_clientinfo_t *) (*(long *) (ptr));
UI_Init();
vr->menuCursorX = &uis.cursorx;
vr->menuCursorY = &uis.cursory;
}
return 0;
case UI_SHUTDOWN:
UI_Shutdown();
case UI_SHUTDOWN: {
vr->menuCursorX = NULL;
vr->menuCursorY = NULL;
UI_Shutdown();
}
return 0;
case UI_KEY_EVENT:

View file

@ -163,15 +163,20 @@ Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, i
return UI_API_VERSION;
case UI_INIT: {
int ptr[2] = {arg1, arg2};
vr = (vr_clientinfo_t *) (*(long *) (ptr));
_UI_Init(arg0);
}
return 0;
int ptr[2] = {arg1, arg2};
vr = (vr_clientinfo_t *) (*(long *) (ptr));
_UI_Init(arg0);
vr->menuCursorX = &uiInfo.uiDC.cursorx;
vr->menuCursorY = &uiInfo.uiDC.cursory;
}
return 0;
case UI_SHUTDOWN:
_UI_Shutdown();
return 0;
case UI_SHUTDOWN: {
vr->menuCursorX = NULL;
vr->menuCursorY = NULL;
_UI_Shutdown();
}
return 0;
case UI_KEY_EVENT:
_UI_KeyEvent( arg0, arg1 );
@ -5272,9 +5277,6 @@ void _UI_MouseEvent( int dx, int dy )
else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT+16)
uiInfo.uiDC.cursory = SCREEN_HEIGHT+16;
vr->menuCursorX = &uiInfo.uiDC.cursorx;
vr->menuCursorY = &uiInfo.uiDC.cursory;
if (Menu_Count() > 0) {
//menuDef_t *menu = Menu_GetFocused();
//Menu_HandleMouseMove(menu, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory);