Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 64-bit calling convention on Windows #98

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/client/cl_cgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static void CL_SetClientLerpOrigin( float x, float y, float z ) {

qboolean CL_CGameCheckKeyExec( int key ) {
if ( cgvm ) {
return VM_Call( cgvm, 1, CG_CHECKEXECKEY, key );
return VM_Call( cgvm, CG_CHECKEXECKEY, key );
} else {
return qfalse;
}
Expand Down Expand Up @@ -421,7 +421,7 @@ static qboolean CL_GetServerCommand( int serverCommandNumber ) {
if ( !strcmp( cmd, "popup" ) ) { // direct server to client popup request, bypassing cgame
// trap_UI_Popup(Cmd_Argv(1));
// if ( cls.state == CA_ACTIVE && !clc.demoplaying ) {
// VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_CLIPBOARD);
// VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_CLIPBOARD);
// Menus_OpenByName(Cmd_Argv(1));
// }
return qfalse;
Expand Down Expand Up @@ -542,7 +542,7 @@ void CL_CGameBinaryMessageReceived( const char *buf, int buflen, int serverTime
// TODO error instead or is this sufficient?
if ( !cgvm )
return;
VM_Call( cgvm, 3, CG_MESSAGERECEIVED, buf, buflen, serverTime );
VM_Call( cgvm, CG_MESSAGERECEIVED, buf, buflen, serverTime );
}

/*
Expand Down Expand Up @@ -584,7 +584,7 @@ void CL_ShutdownCGame( void ) {
return;
}

VM_Call( cgvm, 0, CG_SHUTDOWN );
VM_Call( cgvm, CG_SHUTDOWN );
VM_Free( cgvm );
cgvm = NULL;
Cmd_UnregisterModule( MODULE_CGAME );
Expand Down Expand Up @@ -1094,7 +1094,7 @@ static intptr_t CL_CgameSystemCalls( intptr_t *args ) {
case CG_INGAME_POPUP:
if ( cls.state == CA_ACTIVE && !clc.demoplaying ) {
if ( uivm ) { // Gordon: can be called as the system is shutting down
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, args[1] );
VM_Call( uivm, UI_SET_ACTIVE_MENU, args[1] );
}
}
return 0;
Expand Down Expand Up @@ -1345,10 +1345,10 @@ void CL_InitCGame( void ) {
// otherwise server commands sent just before a gamestate are dropped
//bani - added clc.demoplaying, since some mods need this at init time, and drawactiveframe is too late for them
if ( currentGameMod == GAMEMOD_LEGACY ) {
VM_Call( cgvm, 7, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum, clc.demoplaying, qtrue, NULL, com_legacyVersion->integer );
VM_Call( cgvm, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum, clc.demoplaying, qtrue, NULL, com_legacyVersion->integer );
}
else {
VM_Call( cgvm, 4, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum, clc.demoplaying );
VM_Call( cgvm, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum, clc.demoplaying );
}

// reset any CVAR_CHEAT cvars registered by cgame
Expand Down Expand Up @@ -1398,7 +1398,7 @@ qboolean CL_GameCommand( void ) {
return qfalse;
}

bRes = (qboolean)VM_Call( cgvm, 0, CG_CONSOLE_COMMAND );
bRes = (qboolean)VM_Call( cgvm, CG_CONSOLE_COMMAND );

Cbuf_NestedReset();

Expand All @@ -1412,7 +1412,7 @@ CL_CGameRendering
=====================
*/
void CL_CGameRendering( stereoFrame_t stereo ) {
VM_Call( cgvm, 3, CG_DRAW_ACTIVE_FRAME, cl.serverTime, stereo, clc.demoplaying );
VM_Call( cgvm, CG_DRAW_ACTIVE_FRAME, cl.serverTime, stereo, clc.demoplaying );
#ifdef _DEBUG
VM_Debug( 0 );
#endif
Expand Down Expand Up @@ -1714,7 +1714,7 @@ qboolean CL_GetTag( int clientNum, char *tagname, orientation_t *orientation ) {
return qfalse;
}

return VM_Call( cgvm, 3, CG_GET_TAG, clientNum, tagname, orientation );
return VM_Call( cgvm, CG_GET_TAG, clientNum, tagname, orientation );
}

qboolean CL_CgameRunning( void ) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cl_cin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
if ( cinTable[currentHandle].alterGameState ) {
// close the menu
if ( uivm ) {
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_NONE );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NONE );
}
} else {
cinTable[currentHandle].playonwalls = cl_inGameVideo->integer;
Expand Down
4 changes: 2 additions & 2 deletions src/client/cl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,15 @@ void CL_MouseEvent( int dx, int dy /*, int time*/ ) {
cl.mouseDx[cl.mouseIndex] += dx;
cl.mouseDy[cl.mouseIndex] += dy;
} else {
VM_Call( uivm, 2, UI_MOUSE_EVENT, dx, dy );
VM_Call( uivm, UI_MOUSE_EVENT, dx, dy );
}

} else if ( Key_GetCatcher() & KEYCATCH_CGAME ) {
if ( cl_bypassMouseInput->integer == 1 ) {
cl.mouseDx[cl.mouseIndex] += dx;
cl.mouseDy[cl.mouseIndex] += dy;
} else {
VM_Call( cgvm, 2, CG_MOUSE_EVENT, dx, dy );
VM_Call( cgvm, CG_MOUSE_EVENT, dx, dy );
}
} else {
cl.mouseDx[cl.mouseIndex] += dx;
Expand Down
28 changes: 14 additions & 14 deletions src/client/cl_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,13 @@ static void CL_KeyDownEvent( int key, unsigned time )
// escape always gets out of CGAME stuff
if (Key_GetCatcher( ) & KEYCATCH_CGAME) {
Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CGAME );
VM_Call( cgvm, 1, CG_EVENT_HANDLING, CGAME_EVENT_NONE );
VM_Call( cgvm, CG_EVENT_HANDLING, CGAME_EVENT_NONE );
return;
}

if ( !( Key_GetCatcher( ) & KEYCATCH_UI ) ) {
if ( cls.state == CA_ACTIVE && !clc.demoplaying ) {
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_INGAME );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_INGAME );
}
else if ( cls.state != CA_DISCONNECTED ) {
#if 0
Expand All @@ -702,12 +702,12 @@ static void CL_KeyDownEvent( int key, unsigned time )
CL_FlushMemory();
}
#endif
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
}
return;
}

VM_Call( uivm, 2, UI_KEY_EVENT, key, qtrue );
VM_Call( uivm, UI_KEY_EVENT, key, qtrue );
return;
}

Expand All @@ -730,12 +730,12 @@ static void CL_KeyDownEvent( int key, unsigned time )
Console_Key( key );
}
} else if ( (Key_GetCatcher() & KEYCATCH_UI) && uivm && !bypassMenu ) {
if ( !onlybinds || VM_Call( uivm, 0, UI_WANTSBINDKEYS ) ) {
VM_Call( uivm, 2, UI_KEY_EVENT, key, qtrue );
if ( !onlybinds || VM_Call( uivm, UI_WANTSBINDKEYS ) ) {
VM_Call( uivm, UI_KEY_EVENT, key, qtrue );
}
} else if ( (Key_GetCatcher() & KEYCATCH_CGAME) && cgvm && !bypassMenu ) {
if ( !onlybinds || VM_Call( cgvm, 0, CG_WANTSBINDKEYS ) ) {
VM_Call( cgvm, 2, CG_KEY_EVENT, key, qtrue );
if ( !onlybinds || VM_Call( cgvm, CG_WANTSBINDKEYS ) ) {
VM_Call( cgvm, CG_KEY_EVENT, key, qtrue );
}
} else if ( Key_GetCatcher() & KEYCATCH_MESSAGE ) {
if ( !onlybinds ) {
Expand Down Expand Up @@ -799,12 +799,12 @@ static void CL_KeyUpEvent( int key, unsigned time )
}

if ( Key_GetCatcher( ) & KEYCATCH_UI && uivm ) {
if ( !onlybinds || VM_Call( uivm, 0, UI_WANTSBINDKEYS ) ) {
VM_Call( uivm, 2, UI_KEY_EVENT, key, qfalse );
if ( !onlybinds || VM_Call( uivm, UI_WANTSBINDKEYS ) ) {
VM_Call( uivm, UI_KEY_EVENT, key, qfalse );
}
} else if ( Key_GetCatcher( ) & KEYCATCH_CGAME && cgvm ) {
if ( !onlybinds || VM_Call( cgvm, 0, CG_WANTSBINDKEYS ) ) {
VM_Call( cgvm, 2, CG_KEY_EVENT, key, qfalse );
if ( !onlybinds || VM_Call( cgvm, CG_WANTSBINDKEYS ) ) {
VM_Call( cgvm, CG_KEY_EVENT, key, qfalse );
}
}
}
Expand Down Expand Up @@ -847,11 +847,11 @@ void CL_CharEvent( int key )
}
else if ( Key_GetCatcher( ) & KEYCATCH_UI )
{
VM_Call( uivm, 2, UI_KEY_EVENT, key | K_CHAR_FLAG, qtrue );
VM_Call( uivm, UI_KEY_EVENT, key | K_CHAR_FLAG, qtrue );
}
else if ( Key_GetCatcher( ) & KEYCATCH_CGAME )
{
VM_Call( cgvm, 2, CG_KEY_EVENT, key | K_CHAR_FLAG, qtrue );
VM_Call( cgvm, CG_KEY_EVENT, key | K_CHAR_FLAG, qtrue );
}
else if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE )
{
Expand Down
10 changes: 5 additions & 5 deletions src/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ qboolean CL_Disconnect( qboolean showMainMenu ) {
Key_ClearStates();

if ( uivm && showMainMenu ) {
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_NONE );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NONE );
}

// Remove pure paks
Expand Down Expand Up @@ -1616,7 +1616,7 @@ void CL_Disconnect_f( void ) {
CL_FlushMemory();
}
if ( uivm ) {
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
}
}
}
Expand Down Expand Up @@ -3116,7 +3116,7 @@ static void CL_CheckTimeout( void ) {
CL_FlushMemory();
}
if ( uivm ) {
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
}
return;
}
Expand Down Expand Up @@ -3335,12 +3335,12 @@ void CL_Frame( int msec, int realMsec ) {
if ( cls.cddialog ) {
// bring up the cd error dialog if needed
cls.cddialog = qfalse;
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_NEED_CD );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NEED_CD );
} else if ( cls.state == CA_DISCONNECTED && !( Key_GetCatcher( ) & KEYCATCH_UI )
&& !com_sv_running->integer && uivm ) {
// if disconnected, bring up the menu
S_StopAllSounds();
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
}

aviRecord = CL_VideoRecording();
Expand Down
16 changes: 8 additions & 8 deletions src/client/cl_scrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {

re.BeginFrame( stereoFrame );

uiFullscreen = (uivm && VM_Call( uivm, 0, UI_IS_FULLSCREEN ));
uiFullscreen = (uivm && VM_Call( uivm, UI_IS_FULLSCREEN ));

// wide aspect ratio screens need to have the sides cleared
// unless they are displaying game renderings
Expand Down Expand Up @@ -556,20 +556,20 @@ static void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
case CA_DISCONNECTED:
// force menu up
S_StopAllSounds();
VM_Call( uivm, 1, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );
break;
case CA_CONNECTING:
case CA_CHALLENGING:
case CA_CONNECTED:
// connecting clients will only show the connection dialog
// refresh to update the time
VM_Call( uivm, 1, UI_REFRESH, cls.realtime );
VM_Call( uivm, 1, UI_DRAW_CONNECT_SCREEN, qfalse );
VM_Call( uivm, UI_REFRESH, cls.realtime );
VM_Call( uivm, UI_DRAW_CONNECT_SCREEN, qfalse );
break;
// // Ridah, if the cgame is valid, fall through to there
// if (!cls.cgameStarted || !com_sv_running->integer) {
// // connecting clients will only show the connection dialog
// VM_Call( uivm, 1, UI_DRAW_CONNECT_SCREEN, qfalse );
// VM_Call( uivm, UI_DRAW_CONNECT_SCREEN, qfalse );
// break;
// }
case CA_LOADING:
Expand All @@ -581,8 +581,8 @@ static void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
// also draw the connection information, so it doesn't
// flash away too briefly on local or lan games
// refresh to update the time
VM_Call( uivm, 1, UI_REFRESH, cls.realtime );
VM_Call( uivm, 1, UI_DRAW_CONNECT_SCREEN, qtrue );
VM_Call( uivm, UI_REFRESH, cls.realtime );
VM_Call( uivm, UI_DRAW_CONNECT_SCREEN, qtrue );
break;
case CA_ACTIVE:
// always supply STEREO_CENTER as vieworg offset is now done by the engine.
Expand All @@ -597,7 +597,7 @@ static void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {

// the menu draws next
if ( (Key_GetCatcher( ) & KEYCATCH_UI) && uivm ) {
VM_Call( uivm, 1, UI_REFRESH, cls.realtime );
VM_Call( uivm, UI_REFRESH, cls.realtime );
}

// console draws next
Expand Down
14 changes: 7 additions & 7 deletions src/client/cl_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ void CL_ShutdownUI( void ) {
if ( !uivm ) {
return;
}
VM_Call( uivm, 0, UI_SHUTDOWN );
VM_Call( uivm, UI_SHUTDOWN );
VM_Free( uivm );
uivm = NULL;
Cmd_UnregisterModule( MODULE_UI );
Expand Down Expand Up @@ -1397,7 +1397,7 @@ void CL_InitUI( void ) {
}

// sanity check
v = VM_Call( uivm, 0, UI_GETAPIVERSION );
v = VM_Call( uivm, UI_GETAPIVERSION );
if ( v != UI_API_VERSION ) {
// Free uivm now, so UI_SHUTDOWN doesn't get called later.
VM_Free( uivm );
Expand All @@ -1409,24 +1409,24 @@ void CL_InitUI( void ) {
else {
// init for this gamestate
if ( currentGameMod == GAMEMOD_LEGACY || currentGameMod == GAMEMOD_ETJUMP )
VM_Call( uivm, 3, UI_INIT, ( cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE ), qtrue, com_legacyVersion->integer );
VM_Call( uivm, UI_INIT, ( cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE ), qtrue, com_legacyVersion->integer );
else
VM_Call( uivm, 1, UI_INIT, ( cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE ) );
VM_Call( uivm, UI_INIT, ( cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE ) );
}
}


qboolean UI_usesUniqueCDKey() {
if ( uivm ) {
return ( VM_Call( uivm, 0, UI_HASUNIQUECDKEY ) == qtrue );
return ( VM_Call( uivm, UI_HASUNIQUECDKEY ) == qtrue );
} else {
return qfalse;
}
}

qboolean UI_checkKeyExec( int key ) {
if ( uivm ) {
return VM_Call( uivm, 1, UI_CHECKEXECKEY, key );
return VM_Call( uivm, UI_CHECKEXECKEY, key );
} else {
return qfalse;
}
Expand All @@ -1444,5 +1444,5 @@ qboolean UI_GameCommand( void ) {
return qfalse;
}

return VM_Call( uivm, 1, UI_CONSOLE_COMMAND, cls.realtime );
return VM_Call( uivm, UI_CONSOLE_COMMAND, cls.realtime );
}
4 changes: 3 additions & 1 deletion src/qcommon/qcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ void VM_Forced_Unload_Start(void);
void VM_Forced_Unload_Done(void);
vm_t *VM_Restart( vm_t *vm );

intptr_t QDECL VM_Call( vm_t *vm, int nargs, int callNum, ... );
#define VM_CALL_END (-1337)
intptr_t QDECL VM_CallFunc(vm_t* vm, int callNum, ...);
#define VM_Call(...) VM_CallFunc(__VA_ARGS__, VM_CALL_END)

void VM_Debug( int level );

Expand Down
15 changes: 8 additions & 7 deletions src/qcommon/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ locals from sp
==============
*/

intptr_t QDECL VM_Call( vm_t *vm, int nargs, int callnum, ... )
intptr_t QDECL VM_CallFunc( vm_t *vm, int callnum, ... )
{
intptr_t r = 0;
int i;
Expand All @@ -314,22 +314,23 @@ intptr_t QDECL VM_Call( vm_t *vm, int nargs, int callnum, ... )
if ( vm_debugLevel ) {
Com_Printf( "VM_Call( %d )\n", callnum );
}

if ( nargs >= MAX_VMMAIN_CALL_ARGS ) {
Com_Error( ERR_DROP, "VM_Call: nargs >= MAX_VMMAIN_CALL_ARGS" );
}
#endif

++vm->callLevel;
// if we have a dll loaded, call it directly
if ( vm->entryPoint )
{
//rcg010207 - see dissertation at top of VM_DllSyscall() in this file.
intptr_t args[MAX_VMMAIN_CALL_ARGS-1] = { 0 };
intptr_t args[MAX_VMMAIN_CALL_ARGS] = { 0, 0, 0, 0, 0, 0, 0, 0 };
va_list ap;
va_start( ap, callnum );
for ( i = 0; i < nargs; i++ ) {
for ( i = 0; i < ARRAY_LEN(args); i++ ) {
args[i] = va_arg( ap, intptr_t );

if (VM_CALL_END == (int)args[i]) {
args[i] = 0;
break;
}
}
va_end(ap);

Expand Down
2 changes: 1 addition & 1 deletion src/server/sv_bot.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ SV_BotFrame
if ( !gvm ) {
return;
}
VM_Call( gvm, 1, BOTAI_START_FRAME, time );
VM_Call( gvm, BOTAI_START_FRAME, time );
}*/


Expand Down
Loading