/* ==================== CL_UISystemCalls The ui module is making a system call ==================== */ intptr_t CL_UISystemCalls( intptr_t *args ) { switch( args[0] ) { case UI_ERROR: Com_Error( ERR_DROP, "%s", VMA(1) ); return 0; case UI_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( VMA(1) ); return 0; case UI_CVAR_SET: Cvar_Set( VMA(1), VMA(2) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( VMA(1) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue( VMA(1), VMF(2) ); return 0; case UI_CVAR_RESET: Cvar_Reset( VMA(1) ); return 0; case UI_CVAR_CREATE: Cvar_Get( VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], VMA(2), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], VMA(2), args[3] ); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[1], VMA(2) ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] ); case UI_FS_READ: FS_Read2( VMA(1), args[2], args[3] ); return 0; case UI_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_GETFILELIST: return FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] ); case UI_FS_SEEK: return FS_Seek( args[1], args[2], args[3] ); case UI_R_REGISTERMODEL: return re.RegisterModel( VMA(1) ); case UI_R_REGISTERSKIN: return re.RegisterSkin( VMA(1) ); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( VMA(1) ); case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA(1) ); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], VMA(3), 1 ); return 0; case UI_R_ADDLIGHTTOSCENE: re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case UI_R_RENDERSCENE: re.RenderScene( VMA(1) ); return 0; case UI_R_SETCOLOR: re.SetColor( VMA(1) ); return 0; case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); return 0; case UI_R_MODELBOUNDS: re.ModelBounds( args[1], VMA(2), VMA(3) ); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: re.LerpTag( VMA(1), args[2], args[3], args[4], VMF(5), VMA(6) ); return 0; case UI_S_REGISTERSOUND: return S_RegisterSound( VMA(1), args[2] ); case UI_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[1], VMA(2), args[3] ); return 0; case UI_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[1], VMA(2), args[3] ); return 0; case UI_KEY_SETBINDING: Key_SetBinding( args[1], VMA(2) ); return 0; case UI_KEY_ISDOWN: return Key_IsDown( args[1] ); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( args[1] ); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case UI_GETCLIPBOARDDATA: CL_GetClipboardData( VMA(1), args[2] ); return 0; case UI_GETCLIENTSTATE: GetClientState( VMA(1) ); return 0; case UI_GETGLCONFIG: CL_GetGlconfig( VMA(1) ); return 0; case UI_GETCONFIGSTRING: return GetConfigString( args[1], VMA(2), args[3] ); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case UI_LAN_ADDSERVER: return LAN_AddServer(args[1], VMA(2), VMA(3)); case UI_LAN_REMOVESERVER: LAN_RemoveServer(args[1], VMA(2)); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing( args[1] ); return 0; case UI_LAN_GETPING: LAN_GetPing( args[1], VMA(2), args[3], VMA(4) ); return 0; case UI_LAN_GETPINGINFO: LAN_GetPingInfo( args[1], VMA(2), args[3] ); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount(args[1]); case UI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString( args[1], args[2], VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERINFO: LAN_GetServerInfo( args[1], args[2], VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing( args[1], args[2] ); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible( args[1], args[2], args[3] ); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible( args[1], args[2] ); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings( args[1] ); case UI_LAN_RESETPINGS: LAN_ResetPings( args[1] ); return 0; case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus( VMA(1), VMA(2), args[3] ); case UI_LAN_COMPARESERVERS: return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case UI_SET_PBCLSTATUS: return 0; case UI_R_REGISTERFONT: re.RegisterFont( VMA(1), args[2], VMA(3)); return 0; case UI_MEMSET: Com_Memset( VMA(1), args[2], args[3] ); return 0; case UI_MEMCPY: Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case UI_STRNCPY: strncpy( VMA(1), VMA(2), args[3] ); return args[1]; case UI_SIN: return FloatAsInt( sin( VMF(1) ) ); case UI_COS: return FloatAsInt( cos( VMF(1) ) ); case UI_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case UI_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case UI_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case UI_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case UI_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( VMA(1) ); case UI_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( VMA(1) ); case UI_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case UI_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) ); case UI_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) ); case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( VMA(1), VMA(2)); return 0; case UI_REAL_TIME: return Com_RealTime( VMA(1) ); case UI_CIN_PLAYCINEMATIC: Com_DPrintf("UI_CIN_PlayCinematic\n"); return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case UI_R_REMAP_SHADER: re.RemapShader( VMA(1), VMA(2), VMA(3) ); return 0; default: Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] ); } return 0; }
/* ==================== CL_UISystemCalls The ui module is making a system call ==================== */ intptr_t CL_UISystemCalls(intptr_t * args) { switch (args[0]) { case UI_ERROR: Com_Error(ERR_DROP, "%s", (char *)VMA(1)); return 0; case UI_PRINT: Com_Printf("%s", (char *)VMA(1)); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register((vmCvar_t*)VMA(1), (char*)VMA(2), (char*)VMA(3), args[4]); return 0; case UI_CVAR_UPDATE: Cvar_Update((vmCvar_t*)VMA(1)); return 0; case UI_CVAR_SET: Cvar_Set((char*)VMA(1), (char*)VMA(2)); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt(Cvar_VariableValue((char*)VMA(1))); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer((char*)VMA(1), (char*)VMA(2), args[3]); return 0; case UI_CVAR_LATCHEDVARIABLESTRINGBUFFER: Cvar_LatchedVariableStringBuffer((char*)VMA(1), (char*)VMA(2), args[3]); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue((char*)VMA(1), VMF(2)); return 0; case UI_CVAR_RESET: Cvar_Reset((char*)VMA(1)); return 0; case UI_CVAR_CREATE: Cvar_Get((char*)VMA(1), (char*)VMA(2), args[3], (char*)VMA(4)); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer(args[1], (char*)VMA(2), args[3]); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer(args[1], (char*)VMA(2), args[3]); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText(args[1], (char*)VMA(2)); return 0; case UI_ADDCOMMAND: Cmd_AddCommand((char*)VMA(1), NULL, (char*)VMA(3)); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode((char*)VMA(1), (fileHandle_t*)VMA( 2 ), (fsMode_t)args[3] ); case UI_FS_READ: FS_Read2(VMA(1), args[2], args[3]); return 0; case UI_FS_WRITE: FS_Write(VMA(1), args[2], args[3]); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile(args[1]); return 0; case UI_FS_DELETEFILE: return FS_Delete((char*)VMA(1)); case UI_FS_GETFILELIST: return FS_GetFileList((char*)VMA(1), (char*)VMA(2), (char*)VMA(3), args[4]); case UI_FS_SEEK: return FS_Seek( args[1], args[2], args[3] ); case UI_R_REGISTERMODEL: return re.RegisterModel((char*)VMA(1)); case UI_R_REGISTERSKIN: return re.RegisterSkin((char*)VMA(1)); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip((char*)VMA(1)); case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene((refEntity_t*)VMA(1)); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene(args[1], args[2], (polyVert_t*)VMA(3)); return 0; case UI_R_ADDPOLYSTOSCENE: re.AddPolysToScene(args[1], args[2], (polyVert_t*)VMA(3), args[4]); return 0; case UI_R_ADDLIGHTTOSCENE: re.AddLightToScene((vec_t*)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), args[7], args[8]); return 0; case UI_R_ADDCORONATOSCENE: re.AddCoronaToScene((vec_t*)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6], (bool)args[7]); return 0; case UI_R_RENDERSCENE: re.RenderScene((refdef_t*)VMA(1)); return 0; case UI_R_SETCOLOR: re.SetColor((float*)VMA(1)); return 0; case UI_R_SETCLIPREGION: re.SetClipRegion( (float*)VMA(1) ); return 0; case UI_R_DRAW2DPOLYS: re.Add2dPolys((polyVert_t*)VMA(1), args[2], args[3]); return 0; case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9]); return 0; case UI_R_DRAWROTATEDPIC: re.DrawRotatedPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9], VMF(10)); return 0; case UI_R_MODELBOUNDS: re.ModelBounds(args[1], (float*)VMA(2), (float*)VMA(3)); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: return re.LerpTag((orientation_t*)VMA(1), (refEntity_t*)VMA(2), (char*)VMA(3), args[4]); case UI_S_REGISTERSOUND: return S_RegisterSound((char*)VMA(1), (bool)args[2]); case UI_S_STARTLOCALSOUND: //S_StartLocalSound(args[1], args[2], args[3]); S_StartLocalSound( args[1], args[2] ); return 0; case UI_S_FADESTREAMINGSOUND: // Dushan - FIX ME //S_FadeStreamingSound(VMF(1), args[2], args[3]); return 0; case UI_S_FADEALLSOUNDS: // Dushan - FIX ME //S_FadeAllSounds(VMF(1), args[2], args[3]); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: idKeyInput::KeynumToStringBuf(args[1], (char*)VMA(2), args[3]); return 0; case UI_KEY_GETBINDINGBUF: idKeyInput::GetBindingBuf(args[1], (char*)VMA(2), args[3]); return 0; case UI_KEY_SETBINDING: idKeyInput::SetBinding(args[1], (char*)VMA(2)); return 0; case UI_KEY_BINDINGTOKEYS: idKeyInput::GetBindingByString((char*)VMA(1), (int*)VMA(2), (int*)VMA(3)); return 0; case UI_KEY_ISDOWN: return idKeyInput::IsDown(args[1]); case UI_KEY_GETOVERSTRIKEMODE: return idKeyInput::GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: idKeyInput::SetOverstrikeMode((bool)args[1]); return 0; case UI_KEY_CLEARSTATES: idKeyInput::ClearStates(); return 0; case UI_KEY_GETCATCHER: return idKeyInput::GetCatcher(); case UI_KEY_SETCATCHER: idKeyInput::SetCatcher(args[1]); return 0; case UI_GETCLIPBOARDDATA: GetClipboardData((char*)VMA(1), args[2]); return 0; case UI_GETCLIENTSTATE: GetClientState((uiClientState_t*)VMA(1)); return 0; case UI_GETGLCONFIG: CL_GetGlconfig((glconfig_t*)VMA(1)); return 0; case UI_GETCONFIGSTRING: return GetConfigString(args[1], (char*)VMA(2), args[3]); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case UI_LAN_ADDSERVER: return LAN_AddServer(args[1], (char*)VMA(2), (char*)VMA(3)); case UI_LAN_REMOVESERVER: LAN_RemoveServer(args[1], (char*)VMA(2)); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing(args[1]); return 0; case UI_LAN_GETPING: LAN_GetPing(args[1], (char*)VMA(2), args[3], (int*)VMA(4)); return 0; case UI_LAN_GETPINGINFO: LAN_GetPingInfo(args[1], (char*)VMA(2), args[3]); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount(args[1]); case UI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString(args[1], args[2], (char*)VMA(3), args[4]); return 0; case UI_LAN_GETSERVERINFO: LAN_GetServerInfo(args[1], args[2], (char*)VMA(3), args[4]); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing(args[1], args[2]); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible(args[1], args[2], (bool)args[3]); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible(args[1], args[2]); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings(args[1]); case UI_LAN_RESETPINGS: LAN_ResetPings(args[1]); return 0; case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus((char*)VMA(1), (char*)VMA(2), args[3]); case UI_LAN_SERVERISINFAVORITELIST: return LAN_ServerIsInFavoriteList(args[1], args[2]); case UI_GETNEWS: return GetNews((bool)args[1]); case UI_LAN_COMPARESERVERS: return LAN_CompareServers(args[1], args[2], args[3], args[4], args[5]); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case UI_GET_CDKEY: CLUI_GetCDKey((char*)VMA(1), args[2]); return 0; case UI_SET_CDKEY: CLUI_SetCDKey((char*)VMA(1)); return 0; case UI_R_REGISTERFONT: re.RegisterFont((char*)VMA(1), args[2], (fontInfo_t*)VMA(3)); return 0; case UI_MEMSET: return (intptr_t)memset( VMA( 1 ), args[2], args[3] ); case UI_MEMCPY: return (intptr_t)memcpy( VMA( 1 ), VMA( 2 ), args[3] ); case UI_STRNCPY: return (intptr_t)strncpy( (char*)VMA( 1 ), (char*)VMA( 2 ), args[3] ); case UI_SIN: return FloatAsInt(sin(VMF(1))); case UI_COS: return FloatAsInt(cos(VMF(1))); case UI_ATAN2: return FloatAsInt(atan2(VMF(1), VMF(2))); case UI_SQRT: return FloatAsInt(sqrt(VMF(1))); case UI_FLOOR: return FloatAsInt(floor(VMF(1))); case UI_CEIL: return FloatAsInt(ceil(VMF(1))); case UI_PARSE_ADD_GLOBAL_DEFINE: return Parse_AddGlobalDefine( (char*)VMA(1) ); case UI_PARSE_LOAD_SOURCE: return Parse_LoadSourceHandle( (char*)VMA(1) ); case UI_PARSE_FREE_SOURCE: return Parse_FreeSourceHandle( args[1] ); case UI_PARSE_READ_TOKEN: return Parse_ReadTokenHandle( args[1], (pc_token_t*)VMA(2) ); case UI_PARSE_SOURCE_FILE_AND_LINE: return Parse_SourceFileAndLine( args[1], (char*)VMA(2), (int*)VMA(3) ); case UI_PC_ADD_GLOBAL_DEFINE: return Parse_AddGlobalDefine((char*)VMA(1)); case UI_PC_REMOVE_ALL_GLOBAL_DEFINES: Parse_RemoveAllGlobalDefines(); return 0; case UI_PC_LOAD_SOURCE: return Parse_LoadSourceHandle((char*)VMA(1)); case UI_PC_FREE_SOURCE: return Parse_FreeSourceHandle(args[1]); case UI_PC_READ_TOKEN: return Parse_ReadTokenHandle(args[1], (pc_token_t*)VMA(2)); case UI_PC_SOURCE_FILE_AND_LINE: return Parse_SourceFileAndLine(args[1], (char*)VMA(2), (int*)VMA(3)); case UI_PC_UNREAD_TOKEN: Parse_UnreadLastTokenHandle(args[1]); return 0; case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: //S_StartBackgroundTrack(VMA(1), VMA(2), args[3]); //----(SA) added fadeup time S_StartBackgroundTrack( (char*)VMA(1), (char*)VMA(2)); return 0; case UI_REAL_TIME: return Com_RealTime((qtime_t*)VMA(1)); case UI_CIN_PLAYCINEMATIC: Com_DPrintf("UI_CIN_PlayCinematic\n"); return CIN_PlayCinematic((char*)VMA(1), args[2], args[3], args[4], args[5], args[6]); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case UI_R_REMAP_SHADER: re.RemapShader((char*)VMA(1), (char*)VMA(2), (char*)VMA(3)); return 0; case UI_CL_GETLIMBOSTRING: return CL_GetLimboString(args[1], (char*)VMA(2)); case UI_CL_TRANSLATE_STRING: CL_TranslateString((char*)VMA(1), (char*)VMA(2)); return 0; case UI_CHECKAUTOUPDATE: #if !defined(UPDATE_SERVER) CL_CheckAutoUpdate(); #endif return 0; case UI_GET_AUTOUPDATE: #if !defined(UPDATE_SERVER) CL_GetAutoUpdate(); #endif return 0; case UI_OPENURL: CL_OpenURL((char *)VMA(1)); return 0; case UI_GETHUNKDATA: Com_GetHunkInfo((int*)VMA(1), (int*)VMA(2)); return 0; #if defined(USE_REFENTITY_ANIMATIONSYSTEM) case UI_R_REGISTERANIMATION: return re.RegisterAnimation((char *)VMA(1)); case UI_R_BUILDSKELETON: return re.BuildSkeleton((refSkeleton_t*)VMA(1), args[2], args[3], args[4], VMF(5), (bool)args[6]); case UI_R_BLENDSKELETON: return re.BlendSkeleton((refSkeleton_t*)VMA(1), (refSkeleton_t*)VMA(2), VMF(3)); case UI_R_BONEINDEX: return re.BoneIndex(args[1], (char *)VMA(2)); case UI_R_ANIMNUMFRAMES: return re.AnimNumFrames(args[1]); case UI_R_ANIMFRAMERATE: return re.AnimFrameRate(args[1]); #endif case UI_GETGLCONFIG2: CL_GetGlconfig2((glconfig2_t*)VMA(1)); return 0; case UI_CON_GETTEXT: UI_Con_GetText( (char *)VMA( 1 ), args[2], args[3] ); return 0; case UI_CVAR_VARIABLEINT: return Cvar_VariableIntegerValue( (char *)VMA(1) ); case UI_R_DRAWSPRITE: { float * uv = (float*)VMA(5); re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), uv[0], uv[1], uv[2], uv[3], args[6]); } return 0; default: Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] ); } return 0; }
// The ui module is making a system call qintptr CLWM_UISystemCalls( qintptr* args ) { switch ( args[ 0 ] ) { case WMUI_ERROR: common->Error( "%s", ( char* )VMA( 1 ) ); return 0; case WMUI_PRINT: common->Printf( "%s", ( char* )VMA( 1 ) ); return 0; case WMUI_MILLISECONDS: return Sys_Milliseconds(); case WMUI_CVAR_REGISTER: Cvar_Register( ( vmCvar_t* )VMA( 1 ), ( char* )VMA( 2 ), ( char* )VMA( 3 ), args[ 4 ] ); return 0; case WMUI_CVAR_UPDATE: Cvar_Update( ( vmCvar_t* )VMA( 1 ) ); return 0; case WMUI_CVAR_SET: Cvar_Set( ( char* )VMA( 1 ), ( char* )VMA( 2 ) ); return 0; case WMUI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( ( char* )VMA( 1 ) ) ); case WMUI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] ); return 0; case WMUI_CVAR_SETVALUE: Cvar_SetValue( ( char* )VMA( 1 ), VMF( 2 ) ); return 0; case WMUI_CVAR_RESET: Cvar_Reset( ( char* )VMA( 1 ) ); return 0; case WMUI_CVAR_CREATE: Cvar_Get( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] ); return 0; case WMUI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[ 1 ], MAX_INFO_STRING_Q3, ( char* )VMA( 2 ), args[ 3 ] ); return 0; case WMUI_ARGC: return Cmd_Argc(); case WMUI_ARGV: Cmd_ArgvBuffer( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] ); return 0; case WMUI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[ 1 ], ( char* )VMA( 2 ) ); return 0; case WMUI_FS_FOPENFILE: return FS_FOpenFileByMode( ( char* )VMA( 1 ), ( fileHandle_t* )VMA( 2 ), ( fsMode_t )args[ 3 ] ); case WMUI_FS_READ: FS_Read( VMA( 1 ), args[ 2 ], args[ 3 ] ); return 0; case WMUI_FS_WRITE: FS_Write( VMA( 1 ), args[ 2 ], args[ 3 ] ); return 0; case WMUI_FS_FCLOSEFILE: FS_FCloseFile( args[ 1 ] ); return 0; case WMUI_FS_DELETEFILE: return FS_Delete( ( char* )VMA( 1 ) ); case WMUI_FS_GETFILELIST: return FS_GetFileList( ( char* )VMA( 1 ), ( char* )VMA( 2 ), ( char* )VMA( 3 ), args[ 4 ] ); case WMUI_R_REGISTERMODEL: return R_RegisterModel( ( char* )VMA( 1 ) ); case WMUI_R_REGISTERSKIN: return R_RegisterSkin( ( char* )VMA( 1 ) ); case WMUI_R_REGISTERSHADERNOMIP: return R_RegisterShaderNoMip( ( char* )VMA( 1 ) ); case WMUI_R_CLEARSCENE: R_ClearScene(); return 0; case WMUI_R_ADDREFENTITYTOSCENE: CLWM_AddRefEntityToScene( ( wmrefEntity_t* )VMA( 1 ) ); return 0; case WMUI_R_ADDPOLYTOSCENE: R_AddPolyToScene( args[ 1 ], args[ 2 ], ( polyVert_t* )VMA( 3 ), 1 ); return 0; case WMUI_R_ADDPOLYSTOSCENE: R_AddPolyToScene( args[ 1 ], args[ 2 ], ( polyVert_t* )VMA( 3 ), args[ 4 ] ); return 0; case WMUI_R_ADDLIGHTTOSCENE: R_AddLightToScene( ( float* )VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ] ); return 0; case WMUI_R_ADDCORONATOSCENE: R_AddCoronaToScene( ( float* )VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ], args[ 7 ] ); return 0; case WMUI_R_RENDERSCENE: CLWM_RenderScene( ( wmrefdef_t* )VMA( 1 ) ); return 0; case WMUI_R_SETCOLOR: R_SetColor( ( float* )VMA( 1 ) ); return 0; case WMUI_R_DRAWSTRETCHPIC: R_StretchPic( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[ 9 ] ); return 0; case WMUI_R_MODELBOUNDS: R_ModelBounds( args[ 1 ], ( float* )VMA( 2 ), ( float* )VMA( 3 ) ); return 0; case WMUI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case WMUI_CM_LERPTAG: return CLWM_LerpTag( ( orientation_t* )VMA( 1 ), ( wmrefEntity_t* )VMA( 2 ), ( char* )VMA( 3 ), args[ 4 ] ); case WMUI_S_REGISTERSOUND: return S_RegisterSound( ( char* )VMA( 1 ) ); case WMUI_S_STARTLOCALSOUND: S_StartLocalSound( args[ 1 ], args[ 2 ], 127 ); return 0; case WMUI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] ); return 0; case WMUI_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] ); return 0; case WMUI_KEY_SETBINDING: Key_SetBinding( args[ 1 ], ( char* )VMA( 2 ) ); return 0; case WMUI_KEY_ISDOWN: return Key_IsDown( args[ 1 ] ); case WMUI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case WMUI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( args[ 1 ] ); return 0; case WMUI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case WMUI_KEY_GETCATCHER: return Key_GetCatcher(); case WMUI_KEY_SETCATCHER: KeyWM_SetCatcher( args[ 1 ] ); return 0; case WMUI_GETCLIPBOARDDATA: CLT3_GetClipboardData( ( char* )VMA( 1 ), args[ 2 ] ); return 0; case WMUI_GETCLIENTSTATE: UIT3_GetClientState( ( uiClientState_t* )VMA( 1 ) ); return 0; case WMUI_GETGLCONFIG: CLWM_GetGlconfig( ( wmglconfig_t* )VMA( 1 ) ); return 0; case WMUI_GETCONFIGSTRING: return CLWM_GetConfigString( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] ); case WMUI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case WMUI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case WMUI_LAN_ADDSERVER: return LAN_AddServer( args[ 1 ], ( char* )VMA( 2 ), ( char* )VMA( 3 ) ); case WMUI_LAN_REMOVESERVER: LAN_RemoveServer( args[ 1 ], ( char* )VMA( 2 ) ); return 0; case WMUI_LAN_GETPINGQUEUECOUNT: return CLT3_GetPingQueueCount(); case WMUI_LAN_CLEARPING: CLT3_ClearPing( args[ 1 ] ); return 0; case WMUI_LAN_GETPING: CLT3_GetPing( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ], ( int* )VMA( 4 ) ); return 0; case WMUI_LAN_GETPINGINFO: CLT3_GetPingInfo( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] ); return 0; case WMUI_LAN_GETSERVERCOUNT: return LAN_GetServerCount( args[ 1 ] ); case WMUI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString( args[ 1 ], args[ 2 ], ( char* )VMA( 3 ), args[ 4 ] ); return 0; case WMUI_LAN_GETSERVERINFO: LAN_GetServerInfo( args[ 1 ], args[ 2 ], ( char* )VMA( 3 ), args[ 4 ] ); return 0; case WMUI_LAN_GETSERVERPING: return LAN_GetServerPing( args[ 1 ], args[ 2 ] ); case WMUI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible( args[ 1 ], args[ 2 ], args[ 3 ] ); return 0; case WMUI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible( args[ 1 ], args[ 2 ] ); case WMUI_LAN_UPDATEVISIBLEPINGS: return CLT3_UpdateVisiblePings( args[ 1 ] ); case WMUI_LAN_RESETPINGS: LAN_ResetPings( args[ 1 ] ); return 0; case WMUI_LAN_SERVERSTATUS: return CLT3_ServerStatus( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] ); case WMUI_SET_PBCLSTATUS: return 0; case WMUI_SET_PBSVSTATUS: return 0; case WMUI_LAN_COMPARESERVERS: return LAN_CompareServers( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] ); case WMUI_MEMORY_REMAINING: return 0x4000000; case WMUI_GET_CDKEY: CLT3UI_GetCDKey( ( char* )VMA( 1 ), args[ 2 ] ); return 0; case WMUI_SET_CDKEY: CLT3UI_SetCDKey( ( char* )VMA( 1 ) ); return 0; case WMUI_R_REGISTERFONT: R_RegisterFont( ( char* )VMA( 1 ), args[ 2 ], ( fontInfo_t* )VMA( 3 ) ); return 0; case WMUI_MEMSET: return ( qintptr )memset( VMA( 1 ), args[ 2 ], args[ 3 ] ); case WMUI_MEMCPY: return ( qintptr )memcpy( VMA( 1 ), VMA( 2 ), args[ 3 ] ); case WMUI_STRNCPY: String::NCpy( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] ); return args[ 1 ]; case WMUI_SIN: return FloatAsInt( sin( VMF( 1 ) ) ); case WMUI_COS: return FloatAsInt( cos( VMF( 1 ) ) ); case WMUI_ATAN2: return FloatAsInt( atan2( VMF( 1 ), VMF( 2 ) ) ); case WMUI_SQRT: return FloatAsInt( sqrt( VMF( 1 ) ) ); case WMUI_FLOOR: return FloatAsInt( floor( VMF( 1 ) ) ); case WMUI_CEIL: return FloatAsInt( ceil( VMF( 1 ) ) ); case WMUI_PC_ADD_GLOBAL_DEFINE: return PC_AddGlobalDefine( ( char* )VMA( 1 ) ); case WMUI_PC_LOAD_SOURCE: return PC_LoadSourceHandle( ( char* )VMA( 1 ) ); case WMUI_PC_FREE_SOURCE: return PC_FreeSourceHandle( args[ 1 ] ); case WMUI_PC_READ_TOKEN: return PC_ReadTokenHandleQ3( args[ 1 ], ( q3pc_token_t* )VMA( 2 ) ); case WMUI_PC_SOURCE_FILE_AND_LINE: return PC_SourceFileAndLine( args[ 1 ], ( char* )VMA( 2 ), ( int* )VMA( 3 ) ); case WMUI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case WMUI_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( ( char* )VMA( 1 ), ( char* )VMA( 2 ), 0 ); return 0; case WMUI_REAL_TIME: return Com_RealTime( ( qtime_t* )VMA( 1 ) ); case WMUI_CIN_PLAYCINEMATIC: return CIN_PlayCinematicStretched( ( char* )VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ], args[ 6 ] ); case WMUI_CIN_STOPCINEMATIC: return CIN_StopCinematic( args[ 1 ] ); case WMUI_CIN_RUNCINEMATIC: return CIN_RunCinematic( args[ 1 ] ); case WMUI_CIN_DRAWCINEMATIC: CIN_DrawCinematic( args[ 1 ] ); return 0; case WMUI_CIN_SETEXTENTS: CIN_SetExtents( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] ); return 0; case WMUI_R_REMAP_SHADER: R_RemapShader( ( char* )VMA( 1 ), ( char* )VMA( 2 ), ( char* )VMA( 3 ) ); return 0; case WMUI_VERIFY_CDKEY: return CLT3_CDKeyValidate( ( char* )VMA( 1 ), ( char* )VMA( 2 ) ); case WMUI_CL_GETLIMBOSTRING: return CLT3_GetLimboString( args[ 1 ], ( char* )VMA( 2 ) ); case WMUI_CL_TRANSLATE_STRING: CL_TranslateString( ( char* )VMA( 1 ), ( char* )VMA( 2 ) ); return 0; case WMUI_CHECKAUTOUPDATE: return 0; case WMUI_GET_AUTOUPDATE: return 0; case WMUI_OPENURL: CLT3_OpenURL( ( const char* )VMA( 1 ) ); return 0; default: common->Error( "Bad UI system trap: %i", static_cast<int>( args[ 0 ] ) ); } return 0; }
/* ============== SV_InitGame A brand new game has been started. If mvd_spawn is non-zero, load the built-in MVD game module. ============== */ void SV_InitGame( unsigned mvd_spawn ) { int i, entnum; edict_t *ent; client_t *client; if( svs.initialized ) { // cause any connected clients to reconnect SV_Shutdown( "Server restarted\n", ERR_RECONNECT | mvd_spawn ); } else { #if USE_CLIENT // make sure the client is down CL_Disconnect( ERR_RECONNECT ); SCR_BeginLoadingPlaque(); #endif CM_FreeMap( &sv.cm ); SV_FreeFile( sv.entitystring ); memset( &sv, 0, sizeof( sv ) ); #if USE_FPS // set up default frametime for main loop sv.frametime = BASE_FRAMETIME; #endif } // get any latched variable changes (maxclients, etc) Cvar_GetLatchedVars (); #if !USE_CLIENT Cvar_Reset( sv_recycle ); #endif if( mvd_spawn ) { Cvar_Set( "deathmatch", "1" ); Cvar_Set( "coop", "0" ); } else { if( Cvar_VariableInteger( "coop" ) && Cvar_VariableInteger( "deathmatch" ) ) { Com_Printf( "Deathmatch and Coop both set, disabling Coop\n" ); Cvar_Set( "coop", "0" ); } // dedicated servers can't be single player and are usually DM // so unless they explicity set coop, force it to deathmatch if( Com_IsDedicated() ) { if( !Cvar_VariableInteger( "coop" ) ) Cvar_Set( "deathmatch", "1" ); } } // init clients if( Cvar_VariableInteger( "deathmatch" ) ) { if( sv_maxclients->integer <= 1 ) { Cvar_SetInteger( sv_maxclients, 8, FROM_CODE ); } else if( sv_maxclients->integer > CLIENTNUM_RESERVED ) { Cvar_SetInteger( sv_maxclients, CLIENTNUM_RESERVED, FROM_CODE ); } } else if( Cvar_VariableInteger( "coop" ) ) { if( sv_maxclients->integer <= 1 || sv_maxclients->integer > 4 ) Cvar_Set( "maxclients", "4" ); } else { // non-deathmatch, non-coop is one player Cvar_FullSet( "maxclients", "1", CVAR_SERVERINFO|CVAR_LATCH, FROM_CODE ); } // enable networking if( sv_maxclients->integer > 1 ) { NET_Config( NET_SERVER ); } svs.client_pool = SV_Mallocz( sizeof( client_t ) * sv_maxclients->integer ); svs.num_entities = sv_maxclients->integer * UPDATE_BACKUP * MAX_PACKET_ENTITIES; svs.entities = SV_Mallocz( sizeof( entity_state_t ) * svs.num_entities ); #if USE_MVD_SERVER // initialize MVD server if( !mvd_spawn ) { SV_MvdInit(); } #endif Cvar_ClampInteger( sv_reserved_slots, 0, sv_maxclients->integer - 1 ); #if USE_ZLIB svs.z.zalloc = SV_Zalloc; svs.z.zfree = SV_Zfree; if( deflateInit2( &svs.z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 9, Z_DEFAULT_STRATEGY ) != Z_OK ) { Com_Error( ERR_FATAL, "%s: deflateInit2() failed", __func__ ); } #endif // init game #if USE_MVD_CLIENT if( mvd_spawn ) { if( ge ) { SV_ShutdownGameProgs(); } ge = &mvd_ge; ge->Init(); } else #endif SV_InitGameProgs(); // send heartbeat very soon svs.last_heartbeat = -(HEARTBEAT_SECONDS-5)*1000; for( i = 0; i < sv_maxclients->integer; i++ ) { client = svs.client_pool + i; entnum = i + 1; ent = EDICT_NUM( entnum ); ent->s.number = entnum; client->edict = ent; client->number = i; } #if USE_AC_SERVER AC_Connect( mvd_spawn ); #endif svs.initialized = qtrue; }
/* ==================== CL_UISystemCalls The ui module is making a system call ==================== */ int CL_UISystemCalls( int *args ) { switch( args[0] ) { case UI_ERROR: Com_Error( ERR_DROP, "%s", VMA(1) ); return 0; case UI_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( (vmCvar_t *)VMA(1), (const char *)VMA(2), (const char *)VMA(3), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( (vmCvar_t *)VMA(1) ); return 0; case UI_CVAR_SET: Cvar_Set( (const char *)VMA(1), (const char *)VMA(2) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( (const char *)VMA(1) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( (const char *)VMA(1), (char *)VMA(2), args[3] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue( (const char *)VMA(1), VMF(2) ); return 0; case UI_CVAR_RESET: Cvar_Reset( (const char *)VMA(1) ); return 0; case UI_CVAR_CREATE: Cvar_Get( (const char *)VMA(1), (const char *)VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], (char *)VMA(2), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], (char *)VMA(2), args[3] ); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[1], (const char *)VMA(2) ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( (const char *)VMA(1), (int *)VMA(2), (fsMode_t)args[3] ); case UI_FS_READ: FS_Read2( VMA(1), args[2], args[3] ); return 0; case UI_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_GETFILELIST: return FS_GetFileList( (const char *)VMA(1), (const char *)VMA(2), (char *)VMA(3), args[4] ); case UI_R_REGISTERMODEL: return re.RegisterModel( (const char *)VMA(1) ); case UI_R_REGISTERSKIN: return re.RegisterSkin( (const char *)VMA(1) ); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( (const char *)VMA(1) ); case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( (const refEntity_t *)VMA(1) ); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], (const polyVert_t *)VMA(3), 1 ); return 0; case UI_R_ADDLIGHTTOSCENE: re.AddLightToScene( (const float *)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case UI_R_RENDERSCENE: re.RenderScene( (const refdef_t *)VMA(1) ); return 0; case UI_R_SETCOLOR: re.SetColor( (const float *)VMA(1) ); return 0; case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); return 0; case UI_R_MODELBOUNDS: re.ModelBounds( args[1], (float *)VMA(2), (float *)VMA(3) ); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: re.LerpTag( (orientation_t *)VMA(1), args[2], args[3], args[4], VMF(5), (const char *)VMA(6) ); return 0; case UI_S_REGISTERSOUND: return S_RegisterSound( (const char *)VMA(1) ); case UI_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[1], (char *)VMA(2), args[3] ); return 0; case UI_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[1], (char *)VMA(2), args[3] ); return 0; case UI_KEY_SETBINDING: Key_SetBinding( args[1], (const char *)VMA(2) ); return 0; case UI_KEY_ISDOWN: return Key_IsDown( args[1] ); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( (qboolean)args[1] ); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case UI_GETCLIPBOARDDATA: GetClipboardData( (char *)VMA(1), args[2] ); return 0; case UI_GETCLIENTSTATE: GetClientState( (uiClientState_t *)VMA(1) ); return 0; case UI_GETGLCONFIG: CL_GetGlconfig( (glconfig_t *)VMA(1) ); return 0; case UI_GETCONFIGSTRING: return GetConfigString( args[1], (char *)VMA(2), args[3] ); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case UI_LAN_ADDSERVER: return LAN_AddServer(args[1], (const char *)VMA(2), (const char *)VMA(3)); case UI_LAN_REMOVESERVER: LAN_RemoveServer(args[1], (const char *)VMA(2)); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing( args[1] ); return 0; case UI_LAN_GETPING: LAN_GetPing( args[1], (char *)VMA(2), args[3], (int *)VMA(4) ); return 0; case UI_LAN_GETPINGINFO: LAN_GetPingInfo( args[1], (char *)VMA(2), args[3] ); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount(args[1]); case UI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString( args[1], args[2], (char *)VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERINFO: LAN_GetServerInfo( args[1], args[2], (char *)VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing( args[1], args[2] ); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible( args[1], args[2], (qboolean)args[3] ); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible( args[1], args[2] ); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings( args[1] ); case UI_LAN_RESETPINGS: LAN_ResetPings( args[1] ); return 0; case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus( (char *)VMA(1), (char *)VMA(2), args[3] ); case UI_LAN_COMPARESERVERS: return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); #ifdef USE_CD_KEY case UI_GET_CDKEY: CLUI_GetCDKey( (char *)VMA(1), args[2] ); return 0; case UI_SET_CDKEY: CLUI_SetCDKey( (char *)VMA(1) ); return 0; #endif // USE_CD_KEY case UI_R_REGISTERFONT: return re.RegisterFont( (const char *)VMA(1) ); case UI_R_FONT_STRLENPIXELS: return re.Font_StrLenPixels( (const char *)VMA(1), args[2], VMF(3) ); case UI_R_FONT_STRLENCHARS: return re.Font_StrLenChars( (const char *)VMA(1) ); case UI_R_FONT_STRHEIGHTPIXELS: return re.Font_HeightPixels( args[1], VMF(2) ); case UI_R_FONT_DRAWSTRING: re.Font_DrawString( args[1], args[2], (const char *)VMA(3), (const float *) VMA(4), args[5], args[6], VMF(7) ); return 0; case UI_LANGUAGE_ISASIAN: return re.Language_IsAsian(); case UI_LANGUAGE_USESSPACES: return re.Language_UsesSpaces(); case UI_ANYLANGUAGE_READCHARFROMSTRING: return re.AnyLanguage_ReadCharFromString( (const char *)VMA(1), (int *) VMA(2), (qboolean *) VMA(3) ); case UI_MEMSET: Com_Memset( VMA(1), args[2], args[3] ); return 0; case UI_MEMCPY: Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case UI_STRNCPY: return (int)strncpy( (char *)VMA(1), (const char *)VMA(2), args[3] ); case UI_SIN: return FloatAsInt( sin( VMF(1) ) ); case UI_COS: return FloatAsInt( cos( VMF(1) ) ); case UI_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case UI_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case UI_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case UI_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case UI_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( (char *)VMA(1) ); case UI_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( (const char *)VMA(1) ); case UI_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case UI_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], (struct pc_token_s *)VMA(2) ); case UI_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], (char *)VMA(2), (int *)VMA(3) ); case UI_PC_LOAD_GLOBAL_DEFINES: return botlib_export->PC_LoadGlobalDefines ( (char *)VMA(1) ); case UI_PC_REMOVE_ALL_GLOBAL_DEFINES: botlib_export->PC_RemoveAllGlobalDefines ( ); return 0; case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( (const char *)VMA(1), (const char *)VMA(2), qfalse); return 0; case UI_REAL_TIME: return Com_RealTime( (struct qtime_s *)VMA(1) ); case UI_CIN_PLAYCINEMATIC: Com_DPrintf("UI_CIN_PlayCinematic\n"); return CIN_PlayCinematic((const char *)VMA(1), args[2], args[3], args[4], args[5], args[6]); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case UI_R_REMAP_SHADER: re.RemapShader( (const char *)VMA(1), (const char *)VMA(2), (const char *)VMA(3) ); return 0; #ifdef USE_CD_KEY case UI_VERIFY_CDKEY: return CL_CDKeyValidate((const char *)VMA(1), (const char *)VMA(2)); #endif // USE_CD_KEY case UI_SP_REGISTER: return !!SP_Register((const char *)VMA(1),SP_REGISTER_MENU); case UI_SP_GETSTRINGTEXTSTRING: const char* text; assert(VMA(1)); assert(VMA(2)); text = SP_GetStringTextString((const char *) VMA(1)); Q_strncpyz( (char *) VMA(2), text, args[3] ); return qtrue; /* Ghoul2 Insert Start */ case UI_G2_ANGLEOVERRIDE: return G2API_SetBoneAngles(*((CGhoul2Info_v *)VMA(1)), args[2], (const char *)VMA(3), (float *)VMA(4), args[5], (const Eorientations) args[6], (const Eorientations) args[7], (const Eorientations) args[8], (qhandle_t *)VMA(9), args[10], args[11] ); /* Ghoul2 Insert End */ default: Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] ); } return 0; }
/* VID_Init This routine is responsible for initializing the OS specific portions of OpenGL. Under Win32 this means dealing with the pixelformats and doing the wgl interface stuff. */ qboolean VID_Init(void) { const char *extensions; int ret; gl_driver = Cvar_Get("gl_driver", "opengl32", CVAR_ARCHIVE | CVAR_REFRESH); gl_drawbuffer = Cvar_Get("gl_drawbuffer", "GL_BACK", 0); gl_swapinterval = Cvar_Get("gl_swapinterval", "1", CVAR_ARCHIVE); gl_allow_software = Cvar_Get("gl_allow_software", "0", 0); gl_colorbits = Cvar_Get("gl_colorbits", "0", CVAR_REFRESH); gl_depthbits = Cvar_Get("gl_depthbits", "0", CVAR_REFRESH); gl_stencilbits = Cvar_Get("gl_stencilbits", "8", CVAR_REFRESH); gl_multisamples = Cvar_Get("gl_multisamples", "0", CVAR_REFRESH); // don't allow absolute or relative paths FS_SanitizeFilenameVariable(gl_driver); // load and initialize the OpenGL driver ret = LoadGL(gl_driver->string); // attempt to recover if this was a minidriver if (ret == FAIL_SOFT && glw.minidriver) { Com_Printf("...falling back to opengl32\n"); Cvar_Reset(gl_driver); ret = LoadGL(gl_driver->string); } // it failed, abort if (ret) return qfalse; // initialize WGL extensions WGL_InitExtensions(QWGL_ARB_extensions_string); if (qwglGetExtensionsStringARB) extensions = qwglGetExtensionsStringARB(win.dc); else extensions = NULL; // fall back to GL_EXTENSIONS for legacy drivers if (!extensions || !*extensions) extensions = (const char *)qwglGetString(GL_EXTENSIONS); glw.extensions = WGL_ParseExtensionString(extensions); if (glw.extensions & QWGL_EXT_swap_control) { if (glw.extensions & QWGL_EXT_swap_control_tear) Com_Printf("...enabling WGL_EXT_swap_control(_tear)\n"); else Com_Printf("...enabling WGL_EXT_swap_control\n"); WGL_InitExtensions(QWGL_EXT_swap_control); gl_swapinterval->changed = gl_swapinterval_changed; gl_swapinterval_changed(gl_swapinterval); } else { Com_Printf("WGL_EXT_swap_control not found\n"); Cvar_Set("gl_swapinterval", "0"); } gl_drawbuffer->changed = gl_drawbuffer_changed; gl_drawbuffer_changed(gl_drawbuffer); VID_SetMode(); return qtrue; }
/** * @brief The ui module is making a system call * @param[in] args * @return */ intptr_t CL_UISystemCalls(intptr_t *args) { switch (args[0]) { case UI_ERROR: Com_Error(ERR_DROP, "%s", (char *)VMA(1)); case UI_PRINT: Com_Printf("%s", (char *)VMA(1)); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register(VMA(1), VMA(2), VMA(3), args[4]); return 0; case UI_CVAR_UPDATE: Cvar_Update(VMA(1)); return 0; case UI_CVAR_SET: Cvar_SetSafe(VMA(1), VMA(2)); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt(Cvar_VariableValue(VMA(1))); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer(VMA(1), VMA(2), args[3]); return 0; case UI_CVAR_LATCHEDVARIABLESTRINGBUFFER: Cvar_LatchedVariableStringBuffer(VMA(1), VMA(2), args[3]); return 0; case UI_CVAR_SETVALUE: Cvar_SetValueSafe(VMA(1), VMF(2)); return 0; case UI_CVAR_RESET: Cvar_Reset(VMA(1)); return 0; case UI_CVAR_CREATE: Cvar_Register(NULL, VMA(1), VMA(2), args[3]); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer(args[1], VMA(2), args[3]); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer(args[1], VMA(2), args[3]); return 0; case UI_CMD_EXECUTETEXT: if (args[1] == EXEC_NOW && (!strncmp(VMA(2), "snd_restart", 11) || !strncmp(VMA(2), "vid_restart", 11) || !strncmp(VMA(2), "quit", 5))) { Com_Printf(S_COLOR_YELLOW "turning EXEC_NOW '%.11s' into EXEC_INSERT\n", (const char *)VMA(2)); args[1] = EXEC_INSERT; } Cbuf_ExecuteText(args[1], VMA(2)); return 0; case UI_ADDCOMMAND: Cmd_AddCommand(VMA(1)); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode(VMA(1), VMA(2), (fsMode_t)args[3]); case UI_FS_READ: FS_Read(VMA(1), args[2], args[3]); return 0; case UI_FS_WRITE: FS_Write(VMA(1), args[2], args[3]); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile(args[1]); return 0; case UI_FS_DELETEFILE: return FS_Delete(VMA(1)); case UI_FS_GETFILELIST: return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]); case UI_R_REGISTERMODEL: return re.RegisterModel(VMA(1)); case UI_R_REGISTERSKIN: return re.RegisterSkin(VMA(1)); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip(VMA(1)); case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene(VMA(1)); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene(args[1], args[2], VMA(3)); return 0; case UI_R_ADDPOLYSTOSCENE: re.AddPolysToScene(args[1], args[2], VMA(3), args[4]); return 0; case UI_R_ADDLIGHTTOSCENE: // new dlight code re.AddLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), args[7], args[8]); return 0; case UI_R_ADDCORONATOSCENE: re.AddCoronaToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6], (qboolean)args[7]); return 0; case UI_R_RENDERSCENE: re.RenderScene(VMA(1)); return 0; case UI_R_SETCOLOR: re.SetColor(VMA(1)); return 0; case UI_R_DRAW2DPOLYS: re.Add2dPolys(VMA(1), args[2], args[3]); return 0; case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9]); return 0; case UI_R_DRAWROTATEDPIC: re.DrawRotatedPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9], VMF(10)); return 0; case UI_R_MODELBOUNDS: re.ModelBounds(args[1], VMA(2), VMA(3)); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: return re.LerpTag(VMA(1), VMA(2), VMA(3), args[4]); case UI_S_REGISTERSOUND: return S_RegisterSound(VMA(1), (qboolean)args[2]); case UI_S_STARTLOCALSOUND: S_StartLocalSound(args[1], args[2], args[3]); return 0; case UI_S_FADESTREAMINGSOUND: S_FadeStreamingSound(VMF(1), args[2], args[3]); return 0; case UI_S_FADEALLSOUNDS: S_FadeAllSounds(VMF(1), args[2], (qboolean)args[3]); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf(args[1], VMA(2), args[3]); return 0; case UI_KEY_GETBINDINGBUF: Key_GetBindingBuf(args[1], VMA(2), args[3]); return 0; case UI_KEY_SETBINDING: Key_SetBinding(args[1], VMA(2)); return 0; case UI_KEY_BINDINGTOKEYS: Key_GetBindingByString(VMA(1), VMA(2), VMA(3)); return 0; case UI_KEY_ISDOWN: return Key_IsDown(args[1]); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode((qboolean)args[1]); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: // Don't allow the ui module to close the console Key_SetCatcher(args[1] | (Key_GetCatcher() & KEYCATCH_CONSOLE)); return 0; case UI_GETCLIPBOARDDATA: GetClipboardData(VMA(1), args[2]); return 0; case UI_GETCLIENTSTATE: GetClientState(VMA(1)); return 0; case UI_GETGLCONFIG: CL_GetGlconfig(VMA(1)); return 0; case UI_GETCONFIGSTRING: return GetConfigString(args[1], VMA(2), args[3]); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: //LAN_SaveServersToFile(); // now done on add/remove fav server so we no longer save LAN favs on shutdown & restart return 0; case UI_LAN_ADDSERVER: return LAN_AddServer(args[1], VMA(2), VMA(3)); case UI_LAN_REMOVESERVER: LAN_RemoveServer(args[1], VMA(2)); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing(args[1]); return 0; case UI_LAN_GETPING: LAN_GetPing(args[1], VMA(2), args[3], VMA(4)); return 0; case UI_LAN_GETPINGINFO: LAN_GetPingInfo(args[1], VMA(2), args[3]); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount(args[1]); case UI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString(args[1], args[2], VMA(3), args[4]); return 0; case UI_LAN_GETSERVERINFO: LAN_GetServerInfo(args[1], args[2], VMA(3), args[4]); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing(args[1], args[2]); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible(args[1], args[2], (qboolean)args[3]); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible(args[1], args[2]); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings(args[1]); case UI_LAN_RESETPINGS: LAN_ResetPings(args[1]); return 0; case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus(VMA(1), VMA(2), args[3]); case UI_LAN_SERVERISINFAVORITELIST: return LAN_ServerIsInFavoriteList(args[1], args[2]); case UI_LAN_COMPARESERVERS: return LAN_CompareServers(args[1], args[2], args[3], args[4], args[5]); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case UI_R_REGISTERFONT: re.RegisterFont(VMA(1), args[2], VMA(3), (args[4] == qtrue)); return 0; case UI_MEMSET: return (intptr_t)memset(VMA(1), args[2], args[3]); case UI_MEMCPY: return (intptr_t)memcpy(VMA(1), VMA(2), args[3]); case UI_STRNCPY: return (intptr_t)strncpy(VMA(1), VMA(2), args[3]); case UI_SIN: return FloatAsInt(sin(VMF(1))); case UI_COS: return FloatAsInt(cos(VMF(1))); case UI_ATAN2: return FloatAsInt(atan2(VMF(1), VMF(2))); case UI_SQRT: return FloatAsInt(sqrt(VMF(1))); case UI_FLOOR: return FloatAsInt(floor(VMF(1))); case UI_CEIL: return FloatAsInt(ceil(VMF(1))); case UI_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine(VMA(1)); case UI_PC_REMOVE_ALL_GLOBAL_DEFINES: botlib_export->PC_RemoveAllGlobalDefines(); return 0; case UI_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle(VMA(1)); case UI_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle(args[1]); case UI_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle(args[1], VMA(2)); case UI_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine(args[1], VMA(2), VMA(3)); case UI_PC_UNREAD_TOKEN: botlib_export->PC_UnreadLastTokenHandle(args[1]); return 0; case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack(VMA(1), VMA(2), args[3]); // added fadeup time return 0; case UI_REAL_TIME: return Com_RealTime(VMA(1)); case UI_CIN_PLAYCINEMATIC: Com_DPrintf("UI_CIN_PlayCinematic\n"); return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case UI_R_REMAP_SHADER: re.RemapShader(VMA(1), VMA(2), VMA(3)); return 0; case UI_CL_GETLIMBOSTRING: return CL_GetLimboString(args[1], VMA(2)); case UI_CL_TRANSLATE_STRING: CL_TranslateStringMod(VMA(1), VMA(2)); return 0; case UI_CHECKAUTOUPDATE: CL_RequestMasterData(qfalse); return 0; case UI_GET_AUTOUPDATE: Com_GetAutoUpdate(); return 0; case UI_OPENURL: CL_OpenURL((const char *)VMA(1)); return 0; case UI_GETHUNKDATA: Com_GetHunkInfo(VMA(1), VMA(2)); return 0; // obsolete case UI_SET_PBCLSTATUS: case UI_SET_PBSVSTATUS: return 0; default: Com_Error(ERR_DROP, "Bad UI system trap: %ld", (long int) args[0]); } }
/* ============ Win_SetMode ============ */ void Win_SetMode( void ) { DEVMODE dm; int freq, depth; if( vid_fullscreen->integer > 0 ) { // parse vid_modelist specification VID_GetModeFS( &win.rc, &freq, &depth ); Com_DPrintf( "...setting fullscreen mode: %dx%d\n", win.rc.width, win.rc.height ); memset( &dm, 0, sizeof( dm ) ); dm.dmSize = sizeof( dm ); dm.dmPelsWidth = win.rc.width; dm.dmPelsHeight = win.rc.height; dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; if( freq ) { dm.dmDisplayFrequency = freq; dm.dmFields |= DM_DISPLAYFREQUENCY; Com_DPrintf( "...using display frequency of %d\n", freq ); } if( depth ) { dm.dmBitsPerPel = depth; dm.dmFields |= DM_BITSPERPEL; Com_DPrintf( "...using bitdepth of %d\n", depth ); #ifdef _DEBUG } else if( developer->integer ) { HDC hdc; int bitspixel; hdc = GetDC( NULL ); bitspixel = GetDeviceCaps( hdc, BITSPIXEL ); ReleaseDC( NULL, hdc ); Com_DPrintf( "...using desktop bitdepth of %d\n", bitspixel ); #endif } Com_DPrintf( "...calling CDS: " ); if( ChangeDisplaySettings( &dm, CDS_FULLSCREEN ) == DISP_CHANGE_SUCCESSFUL ) { Com_DPrintf( "ok\n" ); win.dm = dm; win.flags |= QVF_FULLSCREEN; Win_SetPosition(); win.mode_changed = 0; return; } Com_DPrintf( "failed\n" ); Cvar_Reset( vid_fullscreen ); } // parse vid_geometry specification VID_GetGeometry( &win.rc ); // align client area win.rc.width &= ~7; win.rc.height &= ~1; // don't allow too small size if( win.rc.width < 320 ) win.rc.width = 320; if( win.rc.height < 240 ) win.rc.height = 240; Com_DPrintf( "...setting windowed mode: %dx%d+%d+%d\n", win.rc.width, win.rc.height, win.rc.x, win.rc.y ); ChangeDisplaySettings( NULL, 0 ); memset( &win.dm, 0, sizeof( win.dm ) ); win.flags &= ~QVF_FULLSCREEN; Win_SetPosition(); win.mode_changed = 0; // set vid_geometry back VID_SetGeometry( &win.rc ); }
intptr_t CL_UISystemCalls( intptr_t *args ) { switch ( args[0] ) { //rww - alright, DO NOT EVER add a GAME/CGAME/UI generic call without adding a trap to match, and //all of these traps must be shared and have cases in sv_game, cl_cgame, and cl_ui. They must also //all be in the same order, and start at 100. case TRAP_MEMSET: Com_Memset( VMA(1), args[2], args[3] ); return 0; case TRAP_MEMCPY: Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case TRAP_STRNCPY: strncpy( (char *)VMA(1), (const char *)VMA(2), args[3] ); return args[1]; case TRAP_SIN: return FloatAsInt( sin( VMF(1) ) ); case TRAP_COS: return FloatAsInt( cos( VMF(1) ) ); case TRAP_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case TRAP_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case TRAP_MATRIXMULTIPLY: MatrixMultiply( (vec3_t *)VMA(1), (vec3_t *)VMA(2), (vec3_t *)VMA(3) ); return 0; case TRAP_ANGLEVECTORS: AngleVectors( (const float *)VMA(1), (float *)VMA(2), (float *)VMA(3), (float *)VMA(4) ); return 0; case TRAP_PERPENDICULARVECTOR: PerpendicularVector( (float *)VMA(1), (const float *)VMA(2) ); return 0; case TRAP_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case TRAP_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case TRAP_TESTPRINTINT: return 0; case TRAP_TESTPRINTFLOAT: return 0; case TRAP_ACOS: return FloatAsInt( Q_acos( VMF(1) ) ); case TRAP_ASIN: return FloatAsInt( Q_asin( VMF(1) ) ); case UI_ERROR: Com_Error( ERR_DROP, "%s", VMA(1) ); return 0; case UI_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( (vmCvar_t *)VMA(1), (const char *)VMA(2), (const char *)VMA(3), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( (vmCvar_t *)VMA(1) ); return 0; case UI_CVAR_SET: Cvar_Set( (const char *)VMA(1), (const char *)VMA(2) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( (const char *)VMA(1) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( (const char *)VMA(1), (char *)VMA(2), args[3] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue( (const char *)VMA(1), VMF(2) ); return 0; case UI_CVAR_RESET: Cvar_Reset( (const char *)VMA(1) ); return 0; case UI_CVAR_CREATE: Cvar_Get( (const char *)VMA(1), (const char *)VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], (char *)VMA(2), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], (char *)VMA(2), args[3] ); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[1], (const char *)VMA(2) ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( (const char *)VMA(1), (int *)VMA(2), (fsMode_t)args[3] ); case UI_FS_READ: FS_Read2( VMA(1), args[2], args[3] ); return 0; case UI_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_GETFILELIST: return FS_GetFileList( (const char *)VMA(1), (const char *)VMA(2), (char *)VMA(3), args[4] ); case UI_R_REGISTERMODEL: return re->RegisterModel( (const char *)VMA(1) ); case UI_R_REGISTERSKIN: return re->RegisterSkin( (const char *)VMA(1) ); case UI_R_REGISTERSHADERNOMIP: return re->RegisterShaderNoMip( (const char *)VMA(1) ); case UI_R_SHADERNAMEFROMINDEX: CL_R_ShaderNameFromIndex( (char *)VMA(1), args[2] ); return 0; case UI_R_CLEARSCENE: re->ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re->AddRefEntityToScene( (const refEntity_t *)VMA(1) ); return 0; case UI_R_ADDPOLYTOSCENE: re->AddPolyToScene( args[1], args[2], (const polyVert_t *)VMA(3), 1 ); return 0; case UI_R_ADDLIGHTTOSCENE: #ifdef VV_LIGHTING VVLightMan.RE_AddLightToScene( (const float *)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); #else re->AddLightToScene( (const float *)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); #endif return 0; case UI_R_RENDERSCENE: re->RenderScene( (const refdef_t *)VMA(1) ); return 0; case UI_R_SETCOLOR: re->SetColor( (const float *)VMA(1) ); return 0; case UI_R_DRAWSTRETCHPIC: re->DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); return 0; case UI_R_MODELBOUNDS: re->ModelBounds( args[1], (float *)VMA(2), (float *)VMA(3) ); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: re->LerpTag( (orientation_t *)VMA(1), args[2], args[3], args[4], VMF(5), (const char *)VMA(6) ); return 0; case UI_S_REGISTERSOUND: return S_RegisterSound( (const char *)VMA(1) ); case UI_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[1], (char *)VMA(2), args[3] ); return 0; case UI_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[1], (char *)VMA(2), args[3] ); return 0; case UI_KEY_SETBINDING: Key_SetBinding( args[1], (const char *)VMA(2) ); return 0; case UI_KEY_ISDOWN: return Key_IsDown( args[1] ); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( (qboolean)args[1] ); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case UI_GETCLIPBOARDDATA: GetClipboardData( (char *)VMA(1), args[2] ); return 0; case UI_GETCLIENTSTATE: CL_GetClientState( (uiClientState_t *)VMA(1) ); return 0; case UI_GETGLCONFIG: CL_GetGlconfig( (glconfig_t *)VMA(1) ); return 0; case UI_GETCONFIGSTRING: return GetConfigString( args[1], (char *)VMA(2), args[3] ); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case UI_LAN_ADDSERVER: return LAN_AddServer(args[1], (const char *)VMA(2), (const char *)VMA(3)); case UI_LAN_REMOVESERVER: LAN_RemoveServer(args[1], (const char *)VMA(2)); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing( args[1] ); return 0; case UI_LAN_GETPING: LAN_GetPing( args[1], (char *)VMA(2), args[3], (int *)VMA(4) ); return 0; case UI_LAN_GETPINGINFO: LAN_GetPingInfo( args[1], (char *)VMA(2), args[3] ); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount(args[1]); case UI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString( args[1], args[2], (char *)VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERINFO: LAN_GetServerInfo( args[1], args[2], (char *)VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing( args[1], args[2] ); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible( args[1], args[2], (qboolean)args[3] ); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible( args[1], args[2] ); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings( args[1] ); case UI_LAN_RESETPINGS: LAN_ResetPings( args[1] ); return 0; case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus( (char *)VMA(1), (char *)VMA(2), args[3] ); case UI_LAN_COMPARESERVERS: return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case UI_R_REGISTERFONT: return re->RegisterFont( (const char *)VMA(1) ); case UI_R_FONT_STRLENPIXELS: return re->Font_StrLenPixels( (const char *)VMA(1), args[2], VMF(3) ); case UI_R_FONT_STRLENCHARS: return re->Font_StrLenChars( (const char *)VMA(1) ); case UI_R_FONT_STRHEIGHTPIXELS: return re->Font_HeightPixels( args[1], VMF(2) ); case UI_R_FONT_DRAWSTRING: re->Font_DrawString( args[1], args[2], (const char *)VMA(3), (const float *) VMA(4), args[5], args[6], VMF(7) ); return 0; case UI_LANGUAGE_ISASIAN: return re->Language_IsAsian(); case UI_LANGUAGE_USESSPACES: return re->Language_UsesSpaces(); case UI_ANYLANGUAGE_READCHARFROMSTRING: return re->AnyLanguage_ReadCharFromString( (const char *)VMA(1), (int *) VMA(2), (qboolean *) VMA(3) ); case UI_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( (char *)VMA(1) ); case UI_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( (const char *)VMA(1) ); case UI_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case UI_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], (struct pc_token_s *)VMA(2) ); case UI_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], (char *)VMA(2), (int *)VMA(3) ); case UI_PC_LOAD_GLOBAL_DEFINES: return botlib_export->PC_LoadGlobalDefines ( (char *)VMA(1) ); case UI_PC_REMOVE_ALL_GLOBAL_DEFINES: botlib_export->PC_RemoveAllGlobalDefines ( ); return 0; case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( (const char *)VMA(1), (const char *)VMA(2), qfalse ); return 0; case UI_REAL_TIME: return Com_RealTime( (struct qtime_s *)VMA(1) ); case UI_CIN_PLAYCINEMATIC: Com_DPrintf("UI_CIN_PlayCinematic\n"); return CIN_PlayCinematic((const char *)VMA(1), args[2], args[3], args[4], args[5], args[6]); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case UI_R_REMAP_SHADER: re->RemapShader( (const char *)VMA(1), (const char *)VMA(2), (const char *)VMA(3) ); return 0; case UI_SP_GETNUMLANGUAGES: return SE_GetNumLanguages(); case UI_SP_GETLANGUAGENAME: CL_SE_GetLanguageName( args[1], (char *)VMA(2) ); return 0; case UI_SP_GETSTRINGTEXTSTRING: return CL_SE_GetStringTextString( (const char *)VMA(1), (char *)VMA(2), args[3] ); case UI_G2_LISTSURFACES: re->G2API_ListSurfaces( (CGhoul2Info *) args[1] ); return 0; case UI_G2_LISTBONES: re->G2API_ListBones( (CGhoul2Info *) args[1], args[2]); return 0; case UI_G2_HAVEWEGHOULMODELS: return re->G2API_HaveWeGhoul2Models( *((CGhoul2Info_v *)args[1]) ); case UI_G2_SETMODELS: re->G2API_SetGhoul2ModelIndexes( *((CGhoul2Info_v *)args[1]),(qhandle_t *)VMA(2),(qhandle_t *)VMA(3)); return 0; case UI_G2_GETBOLT: return re->G2API_GetBoltMatrix(*((CGhoul2Info_v *)args[1]), args[2], args[3], (mdxaBone_t *)VMA(4), (const float *)VMA(5),(const float *)VMA(6), args[7], (qhandle_t *)VMA(8), (float *)VMA(9)); case UI_G2_GETBOLT_NOREC: re->G2API_BoltMatrixReconstruction( qfalse );//gG2_GBMNoReconstruct = qtrue; return re->G2API_GetBoltMatrix(*((CGhoul2Info_v *)args[1]), args[2], args[3], (mdxaBone_t *)VMA(4), (const float *)VMA(5),(const float *)VMA(6), args[7], (qhandle_t *)VMA(8), (float *)VMA(9)); case UI_G2_GETBOLT_NOREC_NOROT: //RAZFIXME: cgame reconstructs bolt matrix, why is this different? re->G2API_BoltMatrixReconstruction( qfalse );//gG2_GBMNoReconstruct = qtrue; re->G2API_BoltMatrixSPMethod( qtrue );//gG2_GBMUseSPMethod = qtrue; return re->G2API_GetBoltMatrix(*((CGhoul2Info_v *)args[1]), args[2], args[3], (mdxaBone_t *)VMA(4), (const float *)VMA(5),(const float *)VMA(6), args[7], (qhandle_t *)VMA(8), (float *)VMA(9)); case UI_G2_INITGHOUL2MODEL: #ifdef _FULL_G2_LEAK_CHECKING g_G2AllocServer = 0; #endif return re->G2API_InitGhoul2Model((CGhoul2Info_v **)VMA(1), (const char *)VMA(2), args[3], (qhandle_t) args[4], (qhandle_t) args[5], args[6], args[7]); case UI_G2_COLLISIONDETECT: case UI_G2_COLLISIONDETECTCACHE: return 0; //not supported for ui case UI_G2_ANGLEOVERRIDE: return re->G2API_SetBoneAngles(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3), (float *)VMA(4), args[5], (const Eorientations) args[6], (const Eorientations) args[7], (const Eorientations) args[8], (qhandle_t *)VMA(9), args[10], args[11] ); case UI_G2_CLEANMODELS: #ifdef _FULL_G2_LEAK_CHECKING g_G2AllocServer = 0; #endif re->G2API_CleanGhoul2Models((CGhoul2Info_v **)VMA(1)); // re->G2API_CleanGhoul2Models((CGhoul2Info_v **)args[1]); return 0; case UI_G2_PLAYANIM: return re->G2API_SetBoneAnim(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3), args[4], args[5], args[6], VMF(7), args[8], VMF(9), args[10]); case UI_G2_GETBONEANIM: { CGhoul2Info_v &g2 = *((CGhoul2Info_v *)args[1]); int modelIndex = args[10]; return re->G2API_GetBoneAnim(&g2[modelIndex], (const char*)VMA(2), args[3], (float *)VMA(4), (int *)VMA(5), (int *)VMA(6), (int *)VMA(7), (float *)VMA(8), (int *)VMA(9)); } case UI_G2_GETBONEFRAME: { //rwwFIXMEFIXME: Just make a G2API_GetBoneFrame func too. This is dirty. CGhoul2Info_v &g2 = *((CGhoul2Info_v *)args[1]); int modelIndex = args[6]; int iDontCare1 = 0, iDontCare2 = 0, iDontCare3 = 0; float fDontCare1 = 0; return re->G2API_GetBoneAnim(&g2[modelIndex], (const char*)VMA(2), args[3], (float *)VMA(4), &iDontCare1, &iDontCare2, &iDontCare3, &fDontCare1, (int *)VMA(5)); } case UI_G2_GETGLANAME: // return (int)G2API_GetGLAName(*((CGhoul2Info_v *)VMA(1)), args[2]); { char *point = ((char *)VMA(3)); char *local; local = re->G2API_GetGLAName(*((CGhoul2Info_v *)args[1]), args[2]); if (local) { strcpy(point, local); } } return 0; case UI_G2_COPYGHOUL2INSTANCE: return (int)re->G2API_CopyGhoul2Instance(*((CGhoul2Info_v *)args[1]), *((CGhoul2Info_v *)args[2]), args[3]); case UI_G2_COPYSPECIFICGHOUL2MODEL: re->G2API_CopySpecificG2Model(*((CGhoul2Info_v *)args[1]), args[2], *((CGhoul2Info_v *)args[3]), args[4]); return 0; case UI_G2_DUPLICATEGHOUL2INSTANCE: #ifdef _FULL_G2_LEAK_CHECKING g_G2AllocServer = 0; #endif re->G2API_DuplicateGhoul2Instance(*((CGhoul2Info_v *)args[1]), (CGhoul2Info_v **)VMA(2)); return 0; case UI_G2_HASGHOUL2MODELONINDEX: return (int)re->G2API_HasGhoul2ModelOnIndex((CGhoul2Info_v **)VMA(1), args[2]); //return (int)G2API_HasGhoul2ModelOnIndex((CGhoul2Info_v **)args[1], args[2]); case UI_G2_REMOVEGHOUL2MODEL: #ifdef _FULL_G2_LEAK_CHECKING g_G2AllocServer = 0; #endif return (int)re->G2API_RemoveGhoul2Model((CGhoul2Info_v **)VMA(1), args[2]); //return (int)G2API_RemoveGhoul2Model((CGhoul2Info_v **)args[1], args[2]); case UI_G2_ADDBOLT: return re->G2API_AddBolt(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3)); case UI_G2_SETBOLTON: re->G2API_SetBoltInfo(*((CGhoul2Info_v *)args[1]), args[2], args[3]); return 0; case UI_G2_SETROOTSURFACE: return re->G2API_SetRootSurface(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3)); case UI_G2_SETSURFACEONOFF: return re->G2API_SetSurfaceOnOff(*((CGhoul2Info_v *)args[1]), (const char *)VMA(2), /*(const int)VMA(3)*/args[3]); case UI_G2_SETNEWORIGIN: return re->G2API_SetNewOrigin(*((CGhoul2Info_v *)args[1]), /*(const int)VMA(2)*/args[2]); case UI_G2_GETTIME: return re->G2API_GetTime(0); case UI_G2_SETTIME: re->G2API_SetTime(args[1], args[2]); return 0; case UI_G2_SETRAGDOLL: return 0; //not supported for ui break; case UI_G2_ANIMATEG2MODELS: return 0; //not supported for ui break; case UI_G2_SETBONEIKSTATE: return re->G2API_SetBoneIKState(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3), args[4], (sharedSetBoneIKStateParams_t *)VMA(5)); case UI_G2_IKMOVE: return re->G2API_IKMove(*((CGhoul2Info_v *)args[1]), args[2], (sharedIKMoveParams_t *)VMA(3)); case UI_G2_GETSURFACENAME: { //Since returning a pointer in such a way to a VM seems to cause MASSIVE FAILURE<tm>, we will shove data into the pointer the vm passes instead char *point = ((char *)VMA(4)); char *local; int modelindex = args[3]; CGhoul2Info_v &g2 = *((CGhoul2Info_v *)args[1]); local = re->G2API_GetSurfaceName(&g2[modelindex], args[2]); if (local) { strcpy(point, local); } } return 0; case UI_G2_SETSKIN: { CGhoul2Info_v &g2 = *((CGhoul2Info_v *)args[1]); int modelIndex = args[2]; return re->G2API_SetSkin(&g2[modelIndex], args[3], args[4]); } case UI_G2_ATTACHG2MODEL: { CGhoul2Info_v *g2From = ((CGhoul2Info_v *)args[1]); CGhoul2Info_v *g2To = ((CGhoul2Info_v *)args[3]); return re->G2API_AttachG2Model(*g2From, args[2], *g2To, args[4], args[5]); } default: Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] ); } return 0; }
/* ================ SV_ActivateServer activate server on changed map, run physics ================ */ void SV_ActivateServer( void ) { int i, numFrames; if( !svs.initialized ) return; // custom muzzleflashes pfnPrecacheModel( "sprites/muzzleflash.spr" ); pfnPrecacheModel( "sprites/muzzleflash1.spr" ); pfnPrecacheModel( "sprites/muzzleflash2.spr" ); pfnPrecacheModel( "sprites/muzzleflash3.spr" ); // rocket flare pfnPrecacheModel( "sprites/animglow01.spr" ); // ricochet sprite pfnPrecacheModel( "sprites/richo1.spr" ); // Activate the DLL server code svgame.dllFuncs.pfnServerActivate( svgame.edicts, svgame.numEntities, svgame.globals->maxClients ); // create a baseline for more efficient communications SV_CreateBaseline(); // check and count all files that marked by user as unmodified (typically is a player models etc) sv.num_consistency_resources = SV_TransferConsistencyInfo(); // send serverinfo to all connected clients for( i = 0; i < sv_maxclients->integer; i++ ) { if( svs.clients[i].state >= cs_connected ) { Netchan_Clear( &svs.clients[i].netchan ); svs.clients[i].delta_sequence = -1; } } numFrames = (sv.loadgame) ? 1 : 2; if( !sv.loadgame || svgame.globals->changelevel ) host.frametime = 0.1f; // GoldSrc rules // NOTE: this stuff is breaking sound from func_rotating in multiplayer // e.g. ambience\boomer.wav on snark_pit.bsp numFrames *= sv_maxclients->integer; // run some frames to allow everything to settle for( i = 0; i < numFrames; i++ ) { SV_Physics(); } // invoke to refresh all movevars Q_memset( &svgame.oldmovevars, 0, sizeof( movevars_t )); svgame.globals->changelevel = false; // changelevel ends here // setup hostflags sv.hostflags = 0; // tell what kind of server has been started. if( svgame.globals->maxClients > 1 ) { MsgDev( D_INFO, "%i player server started\n", svgame.globals->maxClients ); Cvar_Reset( "clockwindow" ); } else { // clear the ugly moving delay in singleplayer Cvar_SetFloat( "clockwindow", 0.0f ); MsgDev( D_INFO, "Game started\n" ); } if( host.type == HOST_DEDICATED ) { Mod_FreeUnused (); } sv.state = ss_active; physinfo->modified = true; sv.changelevel = false; sv.paused = false; Host_SetServerState( sv.state ); if( sv_maxclients->integer > 1 && public_server->integer ) { MsgDev( D_INFO, "Adding your server to master server list\n" ); Master_Add( ); } }
/* ==================== CL_UISystemCalls The ui module is making a system call ==================== */ intptr_t CL_UISystemCalls( intptr_t *args ) { // Com_Printf( "SYSCALL(%d)\n", args[0]); switch( args[0] ) { case UI_ERROR: Com_Error( ERR_DROP, "%s", (const char*)VMA(1) ); return 0; case UI_PRINT: Com_Printf( "%s", (const char*)VMA(1) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( VMA(1) ); return 0; case UI_CVAR_SET: Cvar_Set( VMA(1), VMA(2) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( VMA(1) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue( VMA(1), VMF(2) ); return 0; case UI_CVAR_RESET: Cvar_Reset( VMA(1) ); return 0; case UI_CVAR_CREATE: Cvar_Get( VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], VMA(2), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], VMA(2), args[3] ); return 0; case UI_CMD_EXECUTETEXT: if(args[1] == 0 && (!strncmp(VMA(2), "snd_restart", 11) || !strncmp(VMA(2), "vid_restart", 11) || !strncmp(VMA(2), "quit", 5))) { Com_Printf (S_COLOR_YELLOW "turning EXEC_NOW '%.11s' into EXEC_INSERT\n", (const char*)VMA(2)); args[1] = EXEC_INSERT; } Cbuf_ExecuteText( args[1], VMA(2) ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] ); case UI_FS_READ: FS_Read2( VMA(1), args[2], args[3] ); return 0; case UI_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_GETFILELIST: return FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] ); case UI_FS_SEEK: return FS_Seek( args[1], args[2], args[3] ); case UI_R_REGISTERMODEL: return re.RegisterModel( VMA(1) ); case UI_R_REGISTERSKIN: return re.RegisterSkin( VMA(1) ); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( VMA(1) ); case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA(1) ); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], VMA(3), 1 ); return 0; case UI_R_ADDLIGHTTOSCENE: re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case UI_R_RENDERSCENE: re.RenderScene( VMA(1) ); return 0; case UI_R_SETCOLOR: re.SetColor( VMA(1) ); return 0; case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); return 0; case UI_R_MODELBOUNDS: re.ModelBounds( args[1], VMA(2), VMA(3) ); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: re.LerpTag( VMA(1), args[2], args[3], args[4], VMF(5), VMA(6) ); return 0; case UI_S_REGISTERSOUND: return S_RegisterSound( VMA(1), args[2] ); case UI_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[1], VMA(2), args[3] ); return 0; case UI_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[1], VMA(2), args[3] ); return 0; case UI_KEY_SETBINDING: Key_SetBinding( args[1], VMA(2) ); return 0; case UI_KEY_ISDOWN: return Key_IsDown( args[1] ); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( args[1] ); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: // Don't allow the ui module to close the console Key_SetCatcher( args[1] | ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ); return 0; case UI_GETCLIPBOARDDATA: CL_GetClipboardData( VMA(1), args[2] ); return 0; case UI_GETCLIENTSTATE: GetClientState( VMA(1) ); return 0; case UI_GETGLCONFIG: CL_GetGlconfig( VMA(1) ); return 0; case UI_GETCONFIGSTRING: return GetConfigString( args[1], VMA(2), args[3] ); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case UI_LAN_ADDSERVER: return LAN_AddServer(args[1], VMA(2), VMA(3)); case UI_LAN_REMOVESERVER: LAN_RemoveServer(args[1], VMA(2)); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing( args[1] ); return 0; case UI_LAN_GETPING: LAN_GetPing( args[1], VMA(2), args[3], VMA(4) ); return 0; case UI_LAN_GETPINGINFO: LAN_GetPingInfo( args[1], VMA(2), args[3] ); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount(args[1]); case UI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString( args[1], args[2], VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERINFO: LAN_GetServerInfo( args[1], args[2], VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing( args[1], args[2] ); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible( args[1], args[2], args[3] ); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible( args[1], args[2] ); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings( args[1] ); case UI_LAN_RESETPINGS: LAN_ResetPings( args[1] ); return 0; case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus( VMA(1), VMA(2), args[3] ); case UI_LAN_COMPARESERVERS: return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case UI_GET_CDKEY: CLUI_GetCDKey( VMA(1), args[2] ); return 0; case UI_SET_CDKEY: #ifndef STANDALONE CLUI_SetCDKey( VMA(1) ); #endif return 0; case UI_SET_PBCLSTATUS: return 0; case UI_R_REGISTERFONT: re.RegisterFont( VMA(1), args[2], VMA(3)); return 0; case UI_MEMSET: Com_Memset( VMA(1), args[2], args[3] ); return 0; case UI_MEMCPY: Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case UI_STRNCPY: strncpy( VMA(1), VMA(2), args[3] ); return args[1]; case UI_SIN: return FloatAsInt( sin( VMF(1) ) ); case UI_COS: return FloatAsInt( cos( VMF(1) ) ); case UI_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case UI_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case UI_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case UI_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case UI_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( VMA(1) ); case UI_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( VMA(1) ); case UI_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case UI_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) ); case UI_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) ); case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( VMA(1), VMA(2)); return 0; case UI_REAL_TIME: return Com_RealTime( VMA(1) ); case UI_CIN_PLAYCINEMATIC: Com_DPrintf("UI_CIN_PlayCinematic\n"); return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case UI_R_REMAP_SHADER: re.RemapShader( VMA(1), VMA(2), VMA(3) ); return 0; case UI_VERIFY_CDKEY: return CL_CDKeyValidate(VMA(1), VMA(2)); #ifdef USE_AUTH case UI_NET_STRINGTOADR: return NET_StringToAdr(VMA(1), VMA(2), NA_IP); case UI_Q_VSNPRINTF: return Q_vsnprintf(VMA(1), (size_t)VMA(2), VMA(3), VMA(4)); case UI_NET_SENDPACKET: { netadr_t addr; const char *destination = VMA(4); NET_StringToAdr(destination, &addr, NA_IP); NET_SendPacket(args[1], args[2], VMA(3), addr); } return 0; case UI_COPYSTRING: return (intptr_t)CopyString(VMA(1)); case UI_SYS_STARTPROCESS: //Sys_StartProcess(VMA(1), (qboolean) VMA(2)); return 0; #endif default: Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] ); } return 0; }
/* ==================== CL_UISystemCalls The ui module is making a system call ==================== */ intptr_t CL_UISystemCalls( intptr_t *args ) { switch ( args[ 0 ] ) { case UI_ERROR: Com_Error( ERR_DROP, "%s", ( char * ) VMA( 1 ) ); case UI_PRINT: Com_Printf( "%s", ( char * ) VMA( 1 ) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[ 4 ] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( VMA( 1 ) ); return 0; case UI_CVAR_SET: Cvar_Set( VMA( 1 ), VMA( 2 ) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( VMA( 1 ) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: VM_CheckBlock( args[2], args[3], "CVARVSB" ); Cvar_VariableStringBuffer( VMA( 1 ), VMA( 2 ), args[ 3 ] ); return 0; case UI_CVAR_LATCHEDVARIABLESTRINGBUFFER: VM_CheckBlock( args[2], args[3], "CVARLVSB" ); Cvar_LatchedVariableStringBuffer( VMA( 1 ), VMA( 2 ), args[ 3 ] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue( VMA( 1 ), VMF( 2 ) ); return 0; case UI_CVAR_RESET: Cvar_Reset( VMA( 1 ) ); return 0; case UI_CVAR_CREATE: Cvar_Get( VMA( 1 ), VMA( 2 ), args[ 3 ] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: VM_CheckBlock( args[2], args[3], "CVARISB" ); Cvar_InfoStringBuffer( args[ 1 ], VMA( 2 ), args[ 3 ] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: VM_CheckBlock( args[2], args[3], "ARGV" ); Cmd_ArgvBuffer( args[ 1 ], VMA( 2 ), args[ 3 ] ); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[ 1 ], VMA( 2 ) ); return 0; case UI_ADDCOMMAND: Cmd_AddCommand( VMA( 1 ), NULL ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( VMA( 1 ), VMA( 2 ), args[ 3 ] ); case UI_FS_READ: VM_CheckBlock( args[1], args[2], "FSREAD" ); FS_Read2( VMA( 1 ), args[ 2 ], args[ 3 ] ); return 0; case UI_FS_WRITE: VM_CheckBlock( args[1], args[2], "FSWRITE" ); FS_Write( VMA( 1 ), args[ 2 ], args[ 3 ] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[ 1 ] ); return 0; case UI_FS_DELETEFILE: return FS_Delete( VMA( 1 ) ); case UI_FS_GETFILELIST: VM_CheckBlock( args[3], args[4], "FSGFL" ); return FS_GetFileList( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[ 4 ] ); case UI_FS_SEEK: return FS_Seek( args[ 1 ], args[ 2 ], args[ 3 ] ); case UI_R_REGISTERMODEL: return re.RegisterModel( VMA( 1 ) ); case UI_R_REGISTERSKIN: return re.RegisterSkin( VMA( 1 ) ); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( VMA( 1 ) ); case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA( 1 ) ); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[ 1 ], args[ 2 ], VMA( 3 ) ); return 0; // Ridah case UI_R_ADDPOLYSTOSCENE: re.AddPolysToScene( args[ 1 ], args[ 2 ], VMA( 3 ), args[ 4 ] ); return 0; // done. case UI_R_ADDLIGHTTOSCENE: // ydnar: new dlight code //% re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6] ); re.AddLightToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), args[ 7 ], args[ 8 ] ); return 0; case UI_R_ADDCORONATOSCENE: re.AddCoronaToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ], args[ 7 ] ); return 0; case UI_R_RENDERSCENE: re.RenderScene( VMA( 1 ) ); return 0; case UI_R_SETCOLOR: re.SetColor( VMA( 1 ) ); return 0; // Tremulous case UI_R_SETCLIPREGION: re.SetClipRegion( VMA( 1 ) ); return 0; case UI_R_DRAW2DPOLYS: re.Add2dPolys( VMA( 1 ), args[ 2 ], args[ 3 ] ); return 0; case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[ 9 ] ); return 0; case UI_R_DRAWROTATEDPIC: re.DrawRotatedPic( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[ 9 ], VMF( 10 ) ); return 0; case UI_R_MODELBOUNDS: re.ModelBounds( args[ 1 ], VMA( 2 ), VMA( 3 ) ); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: return re.LerpTag( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[ 4 ] ); case UI_S_REGISTERSOUND: #ifdef DOOMSOUND ///// (SA) DOOMSOUND return S_RegisterSound( VMA( 1 ) ); #else return S_RegisterSound( VMA( 1 ), args[ 2 ] ); #endif ///// (SA) DOOMSOUND case UI_S_STARTLOCALSOUND: //S_StartLocalSound(args[1], args[2], args[3]); S_StartLocalSound( args[ 1 ], args[ 2 ] ); return 0; case UI_S_FADESTREAMINGSOUND: // FIXME //S_FadeStreamingSound(VMF(1), args[2], args[3]); return 0; case UI_S_FADEALLSOUNDS: // FIXME //S_FadeAllSounds(VMF(1), args[2], args[3]); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: VM_CheckBlock( args[2], args[3], "KEYNTSB" ); Key_KeynumToStringBuf( args[ 1 ], VMA( 2 ), args[ 3 ] ); return 0; case UI_KEY_GETBINDINGBUF: VM_CheckBlock( args[2], args[3], "KEYGBB" ); Key_GetBindingBuf( args[ 1 ], VMA( 2 ), args[ 3 ] ); return 0; case UI_KEY_SETBINDING: Key_SetBinding( args[ 1 ], VMA( 2 ) ); return 0; case UI_KEY_BINDINGTOKEYS: Key_GetBindingByString( VMA( 1 ), VMA( 2 ), VMA( 3 ) ); return 0; case UI_KEY_ISDOWN: return Key_IsDown( args[ 1 ] ); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( args[ 1 ] ); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: Key_SetCatcher( args[ 1 ] ); return 0; case UI_GETCLIPBOARDDATA: VM_CheckBlock( args[1], args[2], "UIGCD" ); if ( cl_allowPaste->integer ) { CL_GetClipboardData( VMA( 1 ), args[ 2 ], args[ 3 ] ); } else { ( (char *) VMA( 1 ) )[0] = '\0'; } return 0; case UI_GETCLIENTSTATE: GetClientState( VMA( 1 ) ); return 0; case UI_GETGLCONFIG: CL_GetGlconfig( VMA( 1 ) ); return 0; case UI_GETCONFIGSTRING: VM_CheckBlock( args[2], args[3], "UIGCS" ); return GetConfigString( args[ 1 ], VMA( 2 ), args[ 3 ] ); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case UI_LAN_ADDSERVER: return LAN_AddServer( args[ 1 ], VMA( 2 ), VMA( 3 ) ); case UI_LAN_REMOVESERVER: LAN_RemoveServer( args[ 1 ], VMA( 2 ) ); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing( args[ 1 ] ); return 0; case UI_LAN_GETPING: VM_CheckBlock( args[2], args[3], "UILANGP" ); LAN_GetPing( args[ 1 ], VMA( 2 ), args[ 3 ], VMA( 4 ) ); return 0; case UI_LAN_GETPINGINFO: VM_CheckBlock( args[2], args[3], "UILANGPI" ); LAN_GetPingInfo( args[ 1 ], VMA( 2 ), args[ 3 ] ); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount( args[ 1 ] ); case UI_LAN_GETSERVERADDRESSSTRING: VM_CheckBlock( args[3], args[4], "UILANGSAS" ); LAN_GetServerAddressString( args[ 1 ], args[ 2 ], VMA( 3 ), args[ 4 ] ); return 0; case UI_LAN_GETSERVERINFO: VM_CheckBlock( args[3], args[4], "UILANGSI" ); LAN_GetServerInfo( args[ 1 ], args[ 2 ], VMA( 3 ), args[ 4 ] ); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing( args[ 1 ], args[ 2 ] ); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible( args[ 1 ], args[ 2 ], args[ 3 ] ); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible( args[ 1 ], args[ 2 ] ); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings( args[ 1 ] ); case UI_LAN_RESETPINGS: LAN_ResetPings( args[ 1 ] ); return 0; case UI_LAN_SERVERSTATUS: VM_CheckBlock( args[2], args[3], "UILANGSS" ); return LAN_GetServerStatus( VMA( 1 ), VMA( 2 ), args[ 3 ] ); case UI_LAN_SERVERISINFAVORITELIST: return LAN_ServerIsInFavoriteList( args[ 1 ], args[ 2 ] ); case UI_GETNEWS: return GetNews( args[ 1 ] ); case UI_LAN_COMPARESERVERS: return LAN_CompareServers( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] ); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case UI_R_REGISTERFONT: re.RegisterFontVM( VMA( 1 ), VMA( 2 ), args[ 3 ], VMA( 4 ) ); return 0; case UI_PARSE_ADD_GLOBAL_DEFINE: return Parse_AddGlobalDefine( VMA( 1 ) ); case UI_PARSE_LOAD_SOURCE: return Parse_LoadSourceHandle( VMA( 1 ) ); case UI_PARSE_FREE_SOURCE: return Parse_FreeSourceHandle( args[ 1 ] ); case UI_PARSE_READ_TOKEN: return Parse_ReadTokenHandle( args[ 1 ], VMA( 2 ) ); case UI_PARSE_SOURCE_FILE_AND_LINE: return Parse_SourceFileAndLine( args[ 1 ], VMA( 2 ), VMA( 3 ) ); case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: //S_StartBackgroundTrack(VMA(1), VMA(2), args[3]); //----(SA) added fadeup time S_StartBackgroundTrack( VMA( 1 ), VMA( 2 ) ); return 0; case UI_REAL_TIME: return Com_RealTime( VMA( 1 ) ); case UI_CIN_PLAYCINEMATIC: Com_DPrintf( "UI_CIN_PlayCinematic\n" ); return CIN_PlayCinematic( VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ], args[ 6 ] ); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic( args[ 1 ] ); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic( args[ 1 ] ); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic( args[ 1 ] ); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] ); return 0; case UI_R_REMAP_SHADER: re.RemapShader( VMA( 1 ), VMA( 2 ), VMA( 3 ) ); return 0; case UI_GETHUNKDATA: Com_GetHunkInfo( VMA( 1 ), VMA( 2 ) ); return 0; case UI_QUOTESTRING: Cmd_QuoteStringBuffer( VMA( 1 ), VMA( 2 ), args[ 3 ] ); return 0; #if defined( USE_REFENTITY_ANIMATIONSYSTEM ) case UI_R_REGISTERANIMATION: return re.RegisterAnimation( VMA( 1 ) ); case UI_R_BUILDSKELETON: return re.BuildSkeleton( VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], VMF( 5 ), args[ 6 ] ); case UI_R_BLENDSKELETON: return re.BlendSkeleton( VMA( 1 ), VMA( 2 ), VMF( 3 ) ); case UI_R_BONEINDEX: return re.BoneIndex( args[ 1 ], VMA( 2 ) ); case UI_R_ANIMNUMFRAMES: return re.AnimNumFrames( args[ 1 ] ); case UI_R_ANIMFRAMERATE: return re.AnimFrameRate( args[ 1 ] ); #endif case UI_GETTEXT: VM_CheckBlock( args[1], args[3], "UIGETTEXT" ); Q_strncpyz( VMA(1), __(VMA(2)), args[3] ); return 0; case UI_R_GLYPH: re.GlyphVM( args[1], VMA(2), VMA(3) ); return 0; case UI_R_GLYPHCHAR: re.GlyphCharVM( args[1], args[2], VMA(3) ); return 0; case UI_R_UREGISTERFONT: re.UnregisterFontVM( args[1] ); return 0; case UI_PGETTEXT: VM_CheckBlock( args[ 1 ], args[ 4 ], "UIPGETTEXT" ); Q_strncpyz( VMA( 1 ), C__( VMA( 2 ), VMA( 3 ) ), args[ 4 ] ); return 0; default: Com_Error( ERR_DROP, "Bad UI system trap: %ld", ( long int ) args[ 0 ] ); } return 0; }
//BBi //int CL_UISystemCalls( int *args ) { intptr_t CL_UISystemCalls ( intptr_t* args) { //BBi switch ( args[0] ) { case UI_ERROR: #if !defined RTCW_ET Com_Error( ERR_DROP, "%s", VMA( 1 ) ); #else Com_Error( ERR_DROP, "%s", (char *)VMA( 1 ) ); #endif // RTCW_XX return 0; case UI_PRINT: #if !defined RTCW_ET Com_Printf( "%s", VMA( 1 ) ); #else Com_Printf( "%s", (char *)VMA( 1 ) ); #endif // RTCW_XX return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( static_cast<vmCvar_t*> (VMA( 1 )), static_cast<const char*> (VMA( 2 )), static_cast<const char*> (VMA( 3 )), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( static_cast<vmCvar_t*> (VMA( 1 )) ); return 0; case UI_CVAR_SET: Cvar_Set( static_cast<const char*> (VMA( 1 )), static_cast<char*> (VMA( 2 )) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( static_cast<const char*> (VMA( 1 )) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( static_cast<const char*> (VMA( 1 )), static_cast<char*> (VMA( 2 )), args[3] ); return 0; #if defined RTCW_ET case UI_CVAR_LATCHEDVARIABLESTRINGBUFFER: Cvar_LatchedVariableStringBuffer( static_cast<const char*> (VMA( 1 )), static_cast<char*> (VMA( 2 )), args[3] ); return 0; #endif // RTCW_XX case UI_CVAR_SETVALUE: Cvar_SetValue( static_cast<const char*> (VMA( 1 )), VMF( 2 ) ); return 0; case UI_CVAR_RESET: Cvar_Reset( static_cast<const char*> (VMA( 1 )) ); return 0; case UI_CVAR_CREATE: Cvar_Get( static_cast<const char*> (VMA( 1 )), static_cast<char*> (VMA( 2 )), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], static_cast<char*> (VMA( 2 )), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], static_cast<char*> (VMA( 2 )), args[3] ); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[1], static_cast<const char*> (VMA( 2 )) ); return 0; #if defined RTCW_ET case UI_ADDCOMMAND: Cmd_AddCommand( static_cast<const char*> (VMA( 1 )), NULL ); return 0; #endif // RTCW_XX case UI_FS_FOPENFILE: return FS_FOpenFileByMode( static_cast<const char*> (VMA( 1 )), static_cast<fileHandle_t*> (VMA( 2 )), fsMode_t (args[3]) ); case UI_FS_READ: FS_Read( VMA( 1 ), args[2], args[3] ); return 0; #if defined RTCW_SP //----(SA) added case UI_FS_SEEK: FS_Seek( args[1], args[2], args[3] ); return 0; //----(SA) end #endif // RTCW_XX case UI_FS_WRITE: FS_Write( VMA( 1 ), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_DELETEFILE: return FS_Delete( static_cast<char*> (VMA( 1 )) ); case UI_FS_GETFILELIST: return FS_GetFileList( static_cast<const char*> (VMA( 1 )), static_cast<const char*> (VMA( 2 )), static_cast<char*> (VMA( 3 )), args[4] ); case UI_R_REGISTERMODEL: return re.RegisterModel( static_cast<const char*> (VMA( 1 )) ); case UI_R_REGISTERSKIN: return re.RegisterSkin( static_cast<const char*> (VMA( 1 )) ); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( static_cast<const char*> (VMA( 1 )) ); case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( static_cast<const refEntity_t*> (VMA( 1 )) ); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], static_cast<const polyVert_t*> (VMA( 3 )) ); return 0; // Ridah case UI_R_ADDPOLYSTOSCENE: re.AddPolysToScene( args[1], args[2], static_cast<const polyVert_t*> (VMA( 3 )), args[4] ); return 0; // done. case UI_R_ADDLIGHTTOSCENE: #if !defined RTCW_ET re.AddLightToScene( static_cast<const vec_t*> (VMA( 1 )), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[6] ); #else // ydnar: new dlight code //% re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6] ); re.AddLightToScene( static_cast<const vec_t*> (VMA( 1 )), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), args[7], args[8] ); #endif // RTCW_XX return 0; case UI_R_ADDCORONATOSCENE: re.AddCoronaToScene( static_cast<const vec_t*> (VMA( 1 )), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[6], args[7] ); return 0; case UI_R_RENDERSCENE: re.RenderScene( static_cast<const refdef_t*> (VMA( 1 )) ); return 0; case UI_R_SETCOLOR: re.SetColor( static_cast<const float*> (VMA( 1 )) ); return 0; #if defined RTCW_ET case UI_R_DRAW2DPOLYS: re.Add2dPolys( static_cast<polyVert_t*> (VMA( 1 )), args[2], args[3] ); return 0; #endif // RTCW_XX case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[9] ); return 0; #if defined RTCW_ET case UI_R_DRAWROTATEDPIC: re.DrawRotatedPic( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[9], VMF( 10 ) ); return 0; #endif // RTCW_XX case UI_R_MODELBOUNDS: re.ModelBounds( args[1], static_cast<vec_t*> (VMA( 2 )), static_cast<vec_t*> (VMA( 3 )) ); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: return re.LerpTag( static_cast<orientation_t*> (VMA( 1 )), static_cast<refEntity_t*> (VMA( 2 )), static_cast<const char*> (VMA( 3 )), args[4] ); case UI_S_REGISTERSOUND: #ifdef DOOMSOUND ///// (SA) DOOMSOUND return S_RegisterSound( VMA( 1 ) ); #else #if !defined RTCW_ET return S_RegisterSound( static_cast<const char*> (VMA( 1 )), qfalse ); #else return S_RegisterSound( static_cast<const char*> (VMA( 1 )), args[2] ); #endif // RTCW_XX #endif ///// (SA) DOOMSOUND case UI_S_STARTLOCALSOUND: #if !defined RTCW_ET S_StartLocalSound( args[1], args[2] ); #else S_StartLocalSound( args[1], args[2], args[3] ); #endif // RTCW_XX return 0; #if !defined RTCW_MP //----(SA) added case UI_S_FADESTREAMINGSOUND: S_FadeStreamingSound( VMF( 1 ), args[2], args[3] ); return 0; case UI_S_FADEALLSOUNDS: #if !defined RTCW_ET S_FadeAllSounds( VMF( 1 ), args[2] ); #else S_FadeAllSounds( VMF( 1 ), args[2], args[3] ); #endif // RTCW_XX return 0; //----(SA) end #endif // RTCW_XX case UI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[1], static_cast<char*> (VMA( 2 )), args[3] ); return 0; case UI_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[1], static_cast<char*> (VMA( 2 )), args[3] ); return 0; case UI_KEY_SETBINDING: Key_SetBinding( args[1], static_cast<const char*> (VMA( 2 )) ); return 0; #if defined RTCW_ET case UI_KEY_BINDINGTOKEYS: Key_GetBindingByString( static_cast<const char*> (VMA( 1 )), static_cast<int*> (VMA( 2 )), static_cast<int*> (VMA( 3 )) ); return 0; #endif // RTCW_XX case UI_KEY_ISDOWN: return Key_IsDown( args[1] ); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( args[1] ); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case UI_GETCLIPBOARDDATA: GetClipboardData( static_cast<char*> (VMA( 1 )), args[2] ); return 0; case UI_GETCLIENTSTATE: GetClientState( static_cast<uiClientState_t*> (VMA( 1 )) ); return 0; case UI_GETGLCONFIG: CL_GetGlconfig( static_cast<glconfig_t*> (VMA( 1 )) ); return 0; case UI_GETCONFIGSTRING: return GetConfigString( args[1], static_cast<char*> (VMA( 2 )), args[3] ); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case UI_LAN_ADDSERVER: return LAN_AddServer( args[1], static_cast<const char*> (VMA( 2 )), static_cast<const char*> (VMA( 3 )) ); case UI_LAN_REMOVESERVER: LAN_RemoveServer( args[1], static_cast<const char*> (VMA( 2 )) ); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing( args[1] ); return 0; case UI_LAN_GETPING: LAN_GetPing( args[1], static_cast<char*> (VMA( 2 )), args[3], static_cast<int*> (VMA( 4 )) ); return 0; case UI_LAN_GETPINGINFO: LAN_GetPingInfo( args[1], static_cast<char*> (VMA( 2 )), args[3] ); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount( args[1] ); case UI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString( args[1], args[2], static_cast<char*> (VMA( 3 )), args[4] ); return 0; case UI_LAN_GETSERVERINFO: LAN_GetServerInfo( args[1], args[2], static_cast<char*> (VMA( 3 )), args[4] ); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing( args[1], args[2] ); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible( args[1], args[2], args[3] ); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible( args[1], args[2] ); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings( args[1] ); case UI_LAN_RESETPINGS: LAN_ResetPings( args[1] ); return 0; case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus( static_cast<char*> (VMA( 1 )), static_cast<char*> (VMA( 2 )), args[3] ); #if defined RTCW_ET case UI_LAN_SERVERISINFAVORITELIST: return LAN_ServerIsInFavoriteList( args[1], args[2] ); #endif // RTCW_XX #if !defined RTCW_SP case UI_SET_PBCLSTATUS: return 0; case UI_SET_PBSVSTATUS: return 0; #endif // RTCW_XX case UI_LAN_COMPARESERVERS: return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case UI_GET_CDKEY: CLUI_GetCDKey( static_cast<char*> (VMA( 1 )), args[2] ); return 0; case UI_SET_CDKEY: CLUI_SetCDKey( static_cast<char*> (VMA( 1 )) ); return 0; case UI_R_REGISTERFONT: re.RegisterFont( static_cast<const char*> (VMA( 1 )), args[2], static_cast<fontInfo_t*> (VMA( 3 )) ); return 0; case UI_MEMSET: return (int)memset( VMA( 1 ), args[2], args[3] ); case UI_MEMCPY: return (int)memcpy( VMA( 1 ), VMA( 2 ), args[3] ); case UI_STRNCPY: return (int)strncpy( static_cast<char*> (VMA( 1 )), static_cast<const char*> (VMA( 2 )), args[3] ); case UI_SIN: return FloatAsInt( c::sin( VMF( 1 ) ) ); case UI_COS: return FloatAsInt( c::cos( VMF( 1 ) ) ); case UI_ATAN2: return FloatAsInt( c::atan2( VMF( 1 ), VMF( 2 ) ) ); case UI_SQRT: return FloatAsInt( c::sqrt( VMF( 1 ) ) ); case UI_FLOOR: return FloatAsInt( c::floor( VMF( 1 ) ) ); case UI_CEIL: return FloatAsInt( c::ceil( VMF( 1 ) ) ); case UI_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( static_cast<char*> (VMA( 1 )) ); #if defined RTCW_ET case UI_PC_REMOVE_ALL_GLOBAL_DEFINES: botlib_export->PC_RemoveAllGlobalDefines(); return 0; #endif // RTCW_XX case UI_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( static_cast<const char*> (VMA( 1 )) ); case UI_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case UI_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], static_cast<pc_token_t*> (VMA( 2 )) ); case UI_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], static_cast<char*> (VMA( 2 )), static_cast<int*> (VMA( 3 )) ); #if defined RTCW_ET case UI_PC_UNREAD_TOKEN: botlib_export->PC_UnreadLastTokenHandle( args[1] ); return 0; #endif // RTCW_XX case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: #if !defined RTCW_MP S_StartBackgroundTrack( static_cast<const char*> (VMA( 1 )), static_cast<const char*> (VMA( 2 )), args[3] ); //----(SA) added fadeup time #else S_StartBackgroundTrack( static_cast<const char*> (VMA( 1 )), static_cast<const char*> (VMA( 2 )) ); #endif // RTCW_XX return 0; case UI_REAL_TIME: return Com_RealTime( static_cast<qtime_t*> (VMA( 1 )) ); case UI_CIN_PLAYCINEMATIC: Com_DPrintf( "UI_CIN_PlayCinematic\n" ); return CIN_PlayCinematic( static_cast<const char*> (VMA( 1 )), args[2], args[3], args[4], args[5], args[6] ); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic( args[1] ); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic( args[1] ); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic( args[1] ); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents( args[1], args[2], args[3], args[4], args[5] ); return 0; case UI_R_REMAP_SHADER: re.RemapShader( static_cast<const char*> (VMA( 1 )), static_cast<const char*> (VMA( 2 )), static_cast<const char*> (VMA( 3 )) ); return 0; case UI_VERIFY_CDKEY: return CL_CDKeyValidate( static_cast<const char*> (VMA( 1 )), static_cast<const char*> (VMA( 2 )) ); // NERVE - SMF case UI_CL_GETLIMBOSTRING: return CL_GetLimboString( args[1], static_cast<char*> (VMA( 2 )) ); #if defined RTCW_SP // -NERVE - SMF #endif // RTCW_XX #if !defined RTCW_SP case UI_CL_TRANSLATE_STRING: CL_TranslateString( static_cast<const char*> (VMA( 1 )), static_cast<char*> (VMA( 2 )) ); return 0; // -NERVE - SMF // DHM - Nerve case UI_CHECKAUTOUPDATE: CL_CheckAutoUpdate(); return 0; case UI_GET_AUTOUPDATE: CL_GetAutoUpdate(); return 0; // DHM - Nerve case UI_OPENURL: CL_OpenURL( (const char *)VMA( 1 ) ); return 0; #endif // RTCW_XX #if defined RTCW_ET case UI_GETHUNKDATA: Com_GetHunkInfo( static_cast<int*> (VMA( 1 )), static_cast<int*> (VMA( 2 )) ); return 0; #endif // RTCW_XX default: Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] ); } return 0; }
qboolean __cdecl Com_LoadDvarsFromBuffer(const char **inputbuf, unsigned int length, const char *data_p, const char *filename) { const char *cvar_name; int i, count; char buf[16384]; const char* line; Com_Memset(buf, 0, sizeof(buf)); for(i = 0; i < length; i++) { Cvar_Reset(inputbuf[i]); } Com_BeginParseSession(filename); count = 0; while ( (cvar_name = Com_Parse(&data_p)) && cvar_name[0]) { for(i = 0; i < length; i++) { if(!Q_stricmp(cvar_name, inputbuf[i])) break; } if(i == length) { if(com_developer && com_developer->integer) { Com_PrintWarning("WARNING: unknown cvar '%s' in file '%s'\n", cvar_name, filename); } Com_SkipRestOfLine(&data_p); }else{ line = Com_ParseOnLine(&data_p); if(com_developer && com_developer->integer) { Cvar_Set(inputbuf[i], line); }else{ if((!Q_strncmp(inputbuf[i],"bg_shock_viewKickPeriod", 23) || !Q_strncmp(inputbuf[i],"bg_shock_viewKickFadeTime", 25)) && (line[0] == '0' && line[1] == '\0')) { /* Quite this spam */ }else{ Cvar_Set(inputbuf[i], line); } } if ( !buf[i] ) { buf[i] = 1; ++count; } } } Com_EndParseSession(); if ( length == count ) { /* No Errors */ return 1; } Com_PrintError("ERROR: the following cvars were not specified in file '%s'\n", filename); for(i = 0; i < length; i++) { while ( buf[i] && i < length ) { ++i; } if(i < length) Com_PrintError(" %s\n", inputbuf[i]); } return 0; }