/* ==================== 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(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), 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], 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), 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], 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(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], 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]); break; } return 0; }
void S_UpdateMusic( void ) { int i, processed; ALint state; ALenum error; ALuint b; int num_processed_buffers; ALuint processed_buffers[MUSIC_BUFFERS]; if( !s_bgTrack ) return; if( !s_musicvolume->value && !s_bgTrack->isUrl ) return; if( s_bgTrackPaused || s_bgTrackLocked ) return; if( s_bgTrackBuffering ) { if( S_EoStream( s_bgTrack->stream ) ) { // we should now advance to the next track S_CloseMusicTrack( s_bgTrack ); } else { if( S_FTellSteam( s_bgTrack->stream ) < BACKGROUND_TRACK_BUFFERING_SIZE ) return; // in case we delayed openening to let the stream be cached for a while, // start actually reading from it now if( !S_ContOpenStream( s_bgTrack->stream ) ) { // let music_process do the dirty job of advancing to the next track S_CloseMusicTrack( s_bgTrack ); s_bgTrack->ignore = qtrue; } } s_bgTrackBuffering = qfalse; } if( !queued_buffers ) { // if we haven't queued any buffers yet, do it now num_processed_buffers = MUSIC_BUFFERS; memcpy( processed_buffers, buffers, sizeof( buffers ) ); } else { num_processed_buffers = 0; processed = 0; qalGetSourcei( source, AL_BUFFERS_PROCESSED, &processed ); while( processed-- ) { qalSourceUnqueueBuffers( source, 1, &b ); processed_buffers[num_processed_buffers++] = b; } } for( i = 0; i < num_processed_buffers; i++ ) { b = processed_buffers[i]; if( !music_process( b ) ) { Com_Printf( "Error processing music data\n" ); S_StopBackgroundTrack(); return; } qalSourceQueueBuffers( source, 1, &b ); if( ( error = qalGetError() ) != AL_NO_ERROR ) { Com_Printf( "Couldn't queue music data (%s)\n", S_ErrorMessage( error ) ); S_StopBackgroundTrack(); return; } } // If it's not still playing, give it a kick qalGetSourcei( source, AL_SOURCE_STATE, &state ); if( !queued_buffers || state != AL_PLAYING ) { queued_buffers = qtrue; qalSourcePlay( source ); } if( s_musicvolume->modified ) qalSourcef( source, AL_GAIN, s_musicvolume->value ); }
void S_StartBackgroundTrack( const char *intro, const char *loop ) { int count; const char *ext; bgTrack_t *t, f; bgTrack_t *introTrack, *loopTrack; ALenum error; int mode = 0; // Stop any existing music that might be playing S_StopBackgroundTrack(); if( !intro || !intro[0] ) return; s_bgTrackPaused = qfalse; ext = COM_FileExtension( intro ); if( ext && !Q_stricmp( ext, ".m3u" ) ) { // mode bits: // 1 - shuffle // 2 - loop the selected track if( loop && loop[0] ) mode = atoi( loop ); if( S_ReadPlaylistFile( intro, mode & 1 ? qtrue : qfalse ) ) goto start_playback; } // the intro track loops unless another loop track has been specified introTrack = S_AllocTrack( intro ); introTrack->next = introTrack->prev = introTrack; if( loop && loop[0] && Q_stricmp( intro, loop ) ) { loopTrack = S_AllocTrack( loop ); if( S_OpenMusicTrack( loopTrack ) ) { S_CloseMusicTrack( loopTrack ); loopTrack->next = introTrack->next = introTrack->prev = loopTrack; loopTrack->prev = introTrack; } } s_bgTrack = introTrack; start_playback: // this effectively precaches the first 15 scheduled tracks in the playlist for( count = 0, t = s_bgTrack; count < 15 && t && t != s_bgTrack; count++ ) { if( !t->isUrl ) { S_OpenMusicTrack( t ); if( t->next == t || t->next == s_bgTrack ) break; // break on an endless loop or full cycle if( !t->ignore && ( mode & 2 ) ) { // no point in precaching the whole playlist when we're only going // to loop one single track break; } } t = t->next; } // start playback with the first valid track if( count > 1 ) { memset( &f, 0, sizeof( f ) ); f.next = s_bgTrack; s_bgTrack = S_NextMusicTrack( &f ); } else { S_OpenMusicTrack( s_bgTrack ); } if( !s_bgTrack || s_bgTrack->ignore ) { S_StopBackgroundTrack(); return; } if( mode & 2 ) { // loop the same track over and over s_bgTrack->next = s_bgTrack->prev = s_bgTrack; } music_source_get(); if( !src ) { Com_Printf( "Error couldn't get source for music\n" ); S_StopBackgroundTrack(); return; } alloced_buffers = qfalse; queued_buffers = qfalse; qalGenBuffers( MUSIC_BUFFERS, buffers ); if( ( error = qalGetError() ) != AL_NO_ERROR ) { Com_Printf( "Error couldn't generate music buffers (%s)\n", S_ErrorMessage( error ) ); S_StopBackgroundTrack(); return; } alloced_buffers = qtrue; }
/* * S_StopAllSounds */ void S_StopAllSounds( void ) { S_StopAllSources(); S_StopBackgroundTrack(); }
/* ==================== CL_CgameSystemCalls The cgame module is making a system call ==================== */ intptr_t CL_CgameSystemCalls( intptr_t *args ) { switch ( args[0] ) { case CG_PRINT: Com_Printf( "%s", VMA( 1 ) ); return 0; case CG_ERROR: Com_Error( ERR_DROP, "%s", VMA( 1 ) ); return 0; case CG_MILLISECONDS: return Sys_Milliseconds(); case CG_CVAR_REGISTER: Cvar_Register( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[4] ); return 0; case CG_CVAR_UPDATE: Cvar_Update( VMA( 1 ) ); return 0; case CG_CVAR_SET: Cvar_Set( VMA( 1 ), VMA( 2 ) ); return 0; case CG_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( VMA( 1 ), VMA( 2 ), args[3] ); return 0; case CG_ARGC: return Cmd_Argc(); case CG_ARGV: Cmd_ArgvBuffer( args[1], VMA( 2 ), args[3] ); return 0; case CG_ARGS: Cmd_ArgsBuffer( VMA( 1 ), args[2] ); return 0; case CG_FS_FOPENFILE: return FS_FOpenFileByMode( VMA( 1 ), VMA( 2 ), args[3] ); case CG_FS_READ: FS_Read( VMA( 1 ), args[2], args[3] ); return 0; case CG_FS_WRITE: return FS_Write( VMA( 1 ), args[2], args[3] ); case CG_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case CG_SENDCONSOLECOMMAND: Cbuf_AddText( VMA( 1 ) ); return 0; case CG_ADDCOMMAND: CL_AddCgameCommand( VMA( 1 ) ); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommand( VMA( 1 ) ); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand( VMA( 1 ) ); return 0; case CG_UPDATESCREEN: // this is used during lengthy level loading, so pump message loop // Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN! // We can't call Com_EventLoop here, a restart will crash and this _does_ happen // if there is a map change while we are downloading at pk3. // ZOID SCR_UpdateScreen(); return 0; case CG_CM_LOADMAP: CL_CM_LoadMap( VMA( 1 ) ); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel( args[1] ); case CG_CM_TEMPBOXMODEL: return CM_TempBoxModel( VMA( 1 ), VMA( 2 ), qfalse ); case CG_CM_TEMPCAPSULEMODEL: return CM_TempBoxModel( VMA( 1 ), VMA( 2 ), qtrue ); case CG_CM_POINTCONTENTS: return CM_PointContents( VMA( 1 ), args[2] ); case CG_CM_TRANSFORMEDPOINTCONTENTS: return CM_TransformedPointContents( VMA( 1 ), args[2], VMA( 3 ), VMA( 4 ) ); case CG_CM_BOXTRACE: CM_BoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], /*int capsule*/ qfalse ); return 0; case CG_CM_TRANSFORMEDBOXTRACE: CM_TransformedBoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], VMA( 8 ), VMA( 9 ), /*int capsule*/ qfalse ); return 0; case CG_CM_CAPSULETRACE: CM_BoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], /*int capsule*/ qtrue ); return 0; case CG_CM_TRANSFORMEDCAPSULETRACE: CM_TransformedBoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], VMA( 8 ), VMA( 9 ), /*int capsule*/ qtrue ); return 0; case CG_CM_MARKFRAGMENTS: return re.MarkFragments( args[1], VMA( 2 ), VMA( 3 ), args[4], VMA( 5 ), args[6], VMA( 7 ) ); case CG_S_STARTSOUND: S_StartSound( VMA( 1 ), args[2], args[3], args[4] ); return 0; //----(SA) added case CG_S_STARTSOUNDEX: S_StartSoundEx( VMA( 1 ), args[2], args[3], args[4], args[5] ); return 0; //----(SA) end case CG_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case CG_S_CLEARLOOPINGSOUNDS: S_ClearLoopingSounds(); // (SA) modified so no_pvs sounds can function // RF, if killall, then stop all sounds if ( args[1] == 1 ) { S_ClearSounds( qtrue, qfalse ); } else if ( args[1] == 2 ) { S_ClearSounds( qtrue, qtrue ); } return 0; case CG_S_ADDLOOPINGSOUND: // FIXME MrE: handling of looping sounds changed S_AddLoopingSound( args[1], VMA( 2 ), VMA( 3 ), args[4], args[5], args[6] ); return 0; // not in use // case CG_S_ADDREALLOOPINGSOUND: // S_AddLoopingSound( args[1], VMA(2), VMA(3), args[4], args[5], args[6] ); // //S_AddRealLoopingSound( args[1], VMA(2), VMA(3), args[4], args[5] ); // return 0; //----(SA) added case CG_S_STOPSTREAMINGSOUND: S_StopEntStreamingSound( args[1] ); return 0; //----(SA) end case CG_S_STOPLOOPINGSOUND: // RF, not functional anymore, since we reverted to old looping code //S_StopLoopingSound( args[1] ); return 0; case CG_S_UPDATEENTITYPOSITION: S_UpdateEntityPosition( args[1], VMA( 2 ) ); return 0; // Ridah, talking animations case CG_S_GETVOICEAMPLITUDE: return S_GetVoiceAmplitude( args[1] ); // done. case CG_S_RESPATIALIZE: S_Respatialize( args[1], VMA( 2 ), VMA( 3 ), args[4] ); return 0; case CG_S_REGISTERSOUND: #ifdef DOOMSOUND ///// (SA) DOOMSOUND return S_RegisterSound( VMA( 1 ) ); #else return S_RegisterSound( VMA( 1 ), qfalse ); #endif ///// (SA) DOOMSOUND case CG_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( VMA( 1 ), VMA( 2 ), args[3] ); //----(SA) added fadeup time return 0; case CG_S_FADESTREAMINGSOUND: S_FadeStreamingSound( VMF( 1 ), args[2], args[3] ); //----(SA) added music/all-streaming options return 0; case CG_S_STARTSTREAMINGSOUND: S_StartStreamingSound( VMA( 1 ), VMA( 2 ), args[3], args[4], args[5] ); return 0; case CG_S_FADEALLSOUNDS: S_FadeAllSounds( VMF( 1 ), args[2] ); //----(SA) added return 0; case CG_R_LOADWORLDMAP: re.LoadWorld( VMA( 1 ) ); return 0; case CG_R_REGISTERMODEL: return re.RegisterModel( VMA( 1 ) ); case CG_R_REGISTERSKIN: return re.RegisterSkin( VMA( 1 ) ); //----(SA) added case CG_R_GETSKINMODEL: return re.GetSkinModel( args[1], VMA( 2 ), VMA( 3 ) ); case CG_R_GETMODELSHADER: return re.GetShaderFromModel( args[1], args[2], args[3] ); //----(SA) end case CG_R_REGISTERSHADER: return re.RegisterShader( VMA( 1 ) ); case CG_R_REGISTERFONT: re.RegisterFont( VMA( 1 ), args[2], VMA( 3 ) ); case CG_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( VMA( 1 ) ); case CG_R_CLEARSCENE: re.ClearScene(); return 0; case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA( 1 ) ); return 0; case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], VMA( 3 ) ); return 0; // Ridah case CG_R_ADDPOLYSTOSCENE: re.AddPolysToScene( args[1], args[2], VMA( 3 ), args[4] ); return 0; case CG_RB_ZOMBIEFXADDNEWHIT: re.ZombieFXAddNewHit( args[1], VMA( 2 ), VMA( 3 ) ); return 0; // done. // case CG_R_LIGHTFORPOINT: // return re.LightForPoint( VMA(1), VMA(2), VMA(3), VMA(4) ); case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[6] ); return 0; // case CG_R_ADDADDITIVELIGHTTOSCENE: // re.AddAdditiveLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); // return 0; case CG_R_ADDCORONATOSCENE: re.AddCoronaToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[6], args[7] ); return 0; case CG_R_SETFOG: re.SetFog( args[1], args[2], args[3], VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ) ); return 0; case CG_R_RENDERSCENE: re.RenderScene( VMA( 1 ) ); return 0; case CG_R_SETCOLOR: re.SetColor( VMA( 1 ) ); return 0; case CG_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 CG_R_DRAWSTRETCHPIC_GRADIENT: re.DrawStretchPicGradient( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[9], VMA( 10 ), args[11] ); return 0; case CG_R_MODELBOUNDS: re.ModelBounds( args[1], VMA( 2 ), VMA( 3 ) ); return 0; case CG_R_LERPTAG: return re.LerpTag( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[4] ); case CG_GETGLCONFIG: CL_GetGlconfig( VMA( 1 ) ); return 0; case CG_GETGAMESTATE: CL_GetGameState( VMA( 1 ) ); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber( VMA( 1 ), VMA( 2 ) ); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot( args[1], VMA( 2 ) ); case CG_GETSERVERCOMMAND: return CL_GetServerCommand( args[1] ); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd( args[1], VMA( 2 ) ); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue( args[1], args[2], VMF( 3 ), args[4] ); //----(SA) modified // NERVE - SMF - added fourth arg [cld] return 0; case CG_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case CG_KEY_ISDOWN: return Key_IsDown( args[1] ); case CG_KEY_GETCATCHER: return Key_GetCatcher(); case CG_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case CG_KEY_GETKEY: return Key_GetKey( VMA( 1 ) ); case CG_MEMSET: return (intptr_t)memset( VMA( 1 ), args[2], args[3] ); case CG_MEMCPY: return (intptr_t)memcpy( VMA( 1 ), VMA( 2 ), args[3] ); case CG_STRNCPY: return (intptr_t)strncpy( VMA( 1 ), VMA( 2 ), args[3] ); case CG_SIN: return FloatAsInt( sin( VMF( 1 ) ) ); case CG_COS: return FloatAsInt( cos( VMF( 1 ) ) ); case CG_ATAN2: return FloatAsInt( atan2( VMF( 1 ), VMF( 2 ) ) ); case CG_SQRT: return FloatAsInt( sqrt( VMF( 1 ) ) ); case CG_FLOOR: return FloatAsInt( floor( VMF( 1 ) ) ); case CG_CEIL: return FloatAsInt( ceil( VMF( 1 ) ) ); case CG_ACOS: return FloatAsInt( Q_acos( VMF( 1 ) ) ); case CG_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( VMA( 1 ) ); case CG_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( VMA( 1 ) ); case CG_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case CG_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], VMA( 2 ) ); case CG_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], VMA( 2 ), VMA( 3 ) ); case CG_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case CG_REAL_TIME: return Com_RealTime( VMA( 1 ) ); case CG_SNAPVECTOR: Sys_SnapVector( VMA( 1 ) ); return 0; case CG_SENDMOVESPEEDSTOGAME: SV_SendMoveSpeedsToGame( args[1], VMA( 2 ) ); return 0; case CG_CIN_PLAYCINEMATIC: return CIN_PlayCinematic( VMA( 1 ), args[2], args[3], args[4], args[5], args[6] ); case CG_CIN_STOPCINEMATIC: return CIN_StopCinematic( args[1] ); case CG_CIN_RUNCINEMATIC: return CIN_RunCinematic( args[1] ); case CG_CIN_DRAWCINEMATIC: CIN_DrawCinematic( args[1] ); return 0; case CG_CIN_SETEXTENTS: CIN_SetExtents( args[1], args[2], args[3], args[4], args[5] ); return 0; case CG_R_REMAP_SHADER: re.RemapShader( VMA( 1 ), VMA( 2 ), VMA( 3 ) ); return 0; case CG_TESTPRINTINT: Com_Printf( "%s%i\n", VMA( 1 ), args[2] ); return 0; case CG_TESTPRINTFLOAT: Com_Printf( "%s%f\n", VMA( 1 ), VMF( 2 ) ); return 0; case CG_LOADCAMERA: return loadCamera( args[1], VMA( 2 ) ); case CG_STARTCAMERA: if ( args[1] == 0 ) { // CAM_PRIMARY cl.cameraMode = qtrue; //----(SA) added } startCamera( args[1], args[2] ); return 0; //----(SA) added case CG_STOPCAMERA: if ( args[1] == 0 ) { // CAM_PRIMARY cl.cameraMode = qfalse; } // stopCamera(args[1]); return 0; //----(SA) end case CG_GETCAMERAINFO: return getCameraInfo( args[1], args[2], VMA( 3 ), VMA( 4 ), VMA( 5 ) ); case CG_GET_ENTITY_TOKEN: return re.GetEntityToken( VMA( 1 ), args[2] ); case CG_INGAME_POPUP: if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "briefing" ) ) { //----(SA) added VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_BRIEFING ); return 0; } if ( cls.state == CA_ACTIVE && !clc.demoplaying ) { // NERVE - SMF if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "UIMENU_WM_PICKTEAM" ) ) { VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_WM_PICKTEAM ); } else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "UIMENU_WM_PICKPLAYER" ) ) { VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_WM_PICKPLAYER ); } else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "UIMENU_WM_QUICKMESSAGE" ) ) { VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_WM_QUICKMESSAGE ); } else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "UIMENU_WM_LIMBO" ) ) { VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_WM_LIMBO ); } // -NERVE - SMF else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "hbook1" ) ) { //----(SA) VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_BOOK1 ); } else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "hbook2" ) ) { //----(SA) VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_BOOK2 ); } else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "hbook3" ) ) { //----(SA) VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_BOOK3 ); } else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "pregame" ) ) { //----(SA) added VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_PREGAME ); } else { VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_CLIPBOARD ); } } return 0; // NERVE - SMF case CG_INGAME_CLOSEPOPUP: VM_Call( uivm, UI_KEY_EVENT, K_ESCAPE, qtrue ); return 0; case CG_LIMBOCHAT: if ( VMA( 1 ) ) { CL_AddToLimboChat( VMA( 1 ) ); } return 0; // - NERVE - SMF case CG_GETMODELINFO: return SV_GetModelInfo( args[1], VMA( 2 ), VMA( 3 ) ); default: Com_Error( ERR_DROP, "Bad cgame system trap: %i", args[0] ); } return 0; }
/* ====================== S_UpdateBackgroundTrack ====================== */ void S_UpdateBackgroundTrack( void ) { int bufferSamples; int fileSamples; byte raw[30000]; // just enough to fit in a mac stack frame int fileBytes; int r; static float musicVolume = 0.5f; if ( !s_backgroundFile ) { return; } // graeme see if this is OK musicVolume = (musicVolume + (s_musicVolume->value * 2))/4.0f; // don't bother playing anything if musicvolume is 0 if ( musicVolume <= 0 ) { return; } // see how many samples should be copied into the raw buffer if ( s_rawend < s_soundtime ) { s_rawend = s_soundtime; } while ( s_rawend < s_soundtime + MAX_RAW_SAMPLES ) { bufferSamples = MAX_RAW_SAMPLES - (s_rawend - s_soundtime); // decide how much data needs to be read from the file fileSamples = (bufferSamples * dma.speed) / s_backgroundInfo.rate; // don't try and read past the end of the file if ( fileSamples > s_backgroundSamples ) { fileSamples = s_backgroundSamples; } // our max buffer size fileBytes = fileSamples * (s_backgroundInfo.width * s_backgroundInfo.channels); if ( fileBytes > sizeof(raw) ) { fileBytes = sizeof(raw); fileSamples = fileBytes / (s_backgroundInfo.width * s_backgroundInfo.channels); } r = Sys_StreamedRead( raw, 1, fileBytes, s_backgroundFile ); if ( r != fileBytes ) { Com_Printf("StreamedRead failure on music track\n"); S_StopBackgroundTrack(); return; } // byte swap if needed S_ByteSwapRawSamples( fileSamples, s_backgroundInfo.width, s_backgroundInfo.channels, raw ); // add to raw buffer S_RawSamples( fileSamples, s_backgroundInfo.rate, s_backgroundInfo.width, s_backgroundInfo.channels, raw, musicVolume ); s_backgroundSamples -= fileSamples; if ( !s_backgroundSamples ) { // loop if (s_backgroundLoop[0]) { Sys_EndStreamedFile( s_backgroundFile ); FS_FCloseFile( s_backgroundFile ); s_backgroundFile = 0; S_StartBackgroundTrack( s_backgroundLoop, s_backgroundLoop ); if ( !s_backgroundFile ) { return; // loop failed to restart } } else { s_backgroundFile = 0; return; } } } }
intptr_t CL_CgameSystemCalls( intptr_t *args ) { if( cls.cgInterface == 2 && args[0] >= CG_R_SETCLIPREGION && args[0] < CG_MEMSET ) { if( args[0] < CG_S_STOPBACKGROUNDTRACK - 1 ) args[0] += 1; else if( args[0] < CG_S_STOPBACKGROUNDTRACK + 4 ) args[0] += CG_PARSE_ADD_GLOBAL_DEFINE - CG_S_STOPBACKGROUNDTRACK + 1; else if( args[0] < CG_PARSE_ADD_GLOBAL_DEFINE + 4 ) args[0] -= 4; else if( args[0] >= CG_PARSE_SOURCE_FILE_AND_LINE && args[0] <= CG_S_SOUNDDURATION ) args[0] = CG_PARSE_SOURCE_FILE_AND_LINE - 1337 - args[0] ; } switch( args[0] ) { case CG_PRINT: Com_Printf( "%s", (const char*)VMA(1) ); return 0; case CG_ERROR: if( probingCG ) { cls.cgInterface = 2; // this is a 1.1.0 cgame return 0; } Com_Error( ERR_DROP, "%s", (const char*)VMA(1) ); return 0; case CG_MILLISECONDS: return Sys_Milliseconds(); case CG_CVAR_REGISTER: Cvar_Register( (vmCvar_t*)VMA(1), (const char*)VMA(2), (const char*)VMA(3), args[4] ); return 0; case CG_CVAR_UPDATE: Cvar_Update( (vmCvar_t*)VMA(1) ); return 0; case CG_CVAR_SET: Cvar_SetSafe( (const char*)VMA(1), (const char*)VMA(2) ); return 0; case CG_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( (const char*)VMA(1), (char*)VMA(2), args[3] ); return 0; case CG_ARGC: return Cmd_Argc(); case CG_ARGV: Cmd_ArgvBuffer( args[1], (char*)VMA(2), args[3] ); return 0; case CG_ARGS: Cmd_ArgsBuffer( (char*)VMA(1), args[2] ); return 0; case CG_LITERAL_ARGS: Cmd_LiteralArgsBuffer( (char*)VMA(1), args[2] ); return 0; case CG_FS_FOPENFILE: return FS_FOpenFileByMode( (const char*)VMA(1), (fileHandle_t*)VMA(2), (FS_Mode)args[3] ); case CG_FS_READ: FS_Read( VMA(1), args[2], args[3] ); return 0; case CG_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case CG_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case CG_FS_SEEK: return FS_Seek( (fileHandle_t)args[1], args[2], (FS_Origin)args[3] ); case CG_FS_GETFILELIST: return FS_GetFileList( (const char*)VMA(1), (const char*)VMA(2), (char*)VMA(3), args[4] ); case CG_SENDCONSOLECOMMAND: Cbuf_AddText( (const char*)VMA(1) ); return 0; case CG_ADDCOMMAND: Cmd_AddCommand( (const char*)VMA(1), NULL ); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommandSafe( (const char*)VMA(1) ); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand((const char*)VMA(1), false); return 0; case CG_UPDATESCREEN: // this is used during lengthy level loading, so pump message loop // Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN! // We can't call Com_EventLoop here, a restart will crash and this _does_ happen // if there is a map change while we are downloading at pk3. // ZOID SCR_UpdateScreen(); return 0; case CG_CM_LOADMAP: CL_CM_LoadMap( (const char*)VMA(1) ); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel( args[1] ); case CG_CM_TEMPBOXMODEL: return CM_TempBoxModel( (const float*)VMA(1), (const float*)VMA(2), false ); case CG_CM_TEMPCAPSULEMODEL: return CM_TempBoxModel( (const float*)VMA(1), (const float*)VMA(2), true ); case CG_CM_POINTCONTENTS: return CM_PointContents( (const float*)VMA(1), args[2] ); case CG_CM_TRANSFORMEDPOINTCONTENTS: return CM_TransformedPointContents( (const float*)VMA(1), (clipHandle_t)args[2], (const float*)VMA(3), (const float*)VMA(4) ); case CG_CM_BOXTRACE: CM_BoxTrace( (trace_t*)VMA(1), (const float*)VMA(2), (const float*)VMA(3), (float*)VMA(4), (float*)VMA(5), (clipHandle_t)args[6], args[7], TT_AABB ); return 0; case CG_CM_CAPSULETRACE: CM_BoxTrace( (trace_t*)VMA(1), (const float*)VMA(2), (const float*)VMA(3), (float*)VMA(4), (float*)VMA(5), (clipHandle_t)args[6], args[7], TT_CAPSULE ); return 0; case CG_CM_TRANSFORMEDBOXTRACE: CM_TransformedBoxTrace( (trace_t*)VMA(1), (const float*)VMA(2), (const float*)VMA(3), (float*)VMA(4), (float*)VMA(5), (clipHandle_t)args[6], args[7], (const float*)VMA(8), (const float*)VMA(9), TT_AABB ); return 0; case CG_CM_TRANSFORMEDCAPSULETRACE: CM_TransformedBoxTrace( (trace_t*)VMA(1), (const float*)VMA(2), (const float*)VMA(3), (float*)VMA(4), (float*)VMA(5), (clipHandle_t)args[6], args[7], (const float*)VMA(8), (const float*)VMA(9), TT_CAPSULE ); return 0; case CG_CM_BISPHERETRACE: CM_BiSphereTrace( (trace_t*)VMA(1), (const float*)VMA(2), (const float*)VMA(3), VMF(4), VMF(5), (clipHandle_t)args[6], args[7] ); return 0; case CG_CM_TRANSFORMEDBISPHERETRACE: CM_TransformedBiSphereTrace( (trace_t*)VMA(1), (const float*)VMA(2), (const float*)VMA(3), VMF(4), VMF(5), (clipHandle_t)args[6], args[7], (const float*)VMA(8) ); return 0; case CG_CM_MARKFRAGMENTS: { float (&arg2)[3][3] = *reinterpret_cast<float (*)[3][3]>(VMA(2)); return re.MarkFragments( args[1], arg2, (const float*)VMA(3), args[4], (float*)VMA(5), args[6], (markFragment_t*)VMA(7) ); } case CG_S_STARTSOUND: S_StartSound( (float*)VMA(1), args[2], args[3], (sfxHandle_t)args[4] ); return 0; case CG_S_STARTLOCALSOUND: S_StartLocalSound( (sfxHandle_t)args[1], args[2] ); return 0; case CG_S_CLEARLOOPINGSOUNDS: S_ClearLoopingSounds( (bool)args[1] ); return 0; case CG_S_ADDLOOPINGSOUND: S_AddLoopingSound( args[1], (const float*)VMA(2), (const float*)VMA(3), (sfxHandle_t)args[4] ); return 0; case CG_S_ADDREALLOOPINGSOUND: S_AddRealLoopingSound( args[1], (const float*)VMA(2), (const float*)VMA(3), (sfxHandle_t)args[4] ); return 0; case CG_S_STOPLOOPINGSOUND: S_StopLoopingSound( args[1] ); return 0; case CG_S_UPDATEENTITYPOSITION: S_UpdateEntityPosition( args[1], (const float*)VMA(2) ); return 0; case CG_S_RESPATIALIZE: { float (&arg3)[3][3] = *reinterpret_cast<float (*)[3][3]>(VMA(3)); S_Respatialize( args[1], (const float*)VMA(2), arg3, args[4] ); return 0; } case CG_S_REGISTERSOUND: return S_RegisterSound( (const char*)VMA(1), (bool)args[2] ); case CG_S_SOUNDDURATION: return S_SoundDuration( args[1] ); case CG_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( (const char*)VMA(1), (const char*)VMA(2) ); return 0; case CG_R_LOADWORLDMAP: re.LoadWorld( (const char*)VMA(1) ); return 0; case CG_R_REGISTERMODEL: return re.RegisterModel( (const char*)VMA(1) ); case CG_R_REGISTERSKIN: return re.RegisterSkin( (const char*)VMA(1) ); case CG_R_REGISTERSHADER: return re.RegisterShader( (const char*)VMA(1) ); case CG_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( (const char*)VMA(1) ); case CG_R_REGISTERFONT: re.RegisterFont( (const char*)VMA(1), args[2], (fontInfo_t*)VMA(3)); return 0; case CG_R_CLEARSCENE: re.ClearScene(); return 0; case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( (const refEntity_t*)VMA(1) ); return 0; case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene( (qhandle_t)args[1], args[2], (const polyVert_t*)VMA(3), 1 ); return 0; case CG_R_ADDPOLYSTOSCENE: re.AddPolyToScene( (qhandle_t)args[1], args[2], (const polyVert_t*)VMA(3), args[4] ); return 0; case CG_R_LIGHTFORPOINT: return re.LightForPoint( (float*)VMA(1), (float*)VMA(2), (float*)VMA(3), (float*)VMA(4) ); case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene( (const float*)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case CG_R_ADDADDITIVELIGHTTOSCENE: re.AddAdditiveLightToScene( (const float*)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case CG_R_RENDERSCENE: re.RenderScene( (const refdef_t*)VMA(1) ); return 0; case CG_R_SETCOLOR: re.SetColor( (const float*)VMA(1) ); return 0; case CG_R_SETCLIPREGION: re.SetClipRegion( (const float*)VMA(1) ); return 0; case CG_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), (qhandle_t)args[9] ); return 0; case CG_R_MODELBOUNDS: re.ModelBounds( (qhandle_t)args[1], (float*)VMA(2), (float*)VMA(3) ); return 0; case CG_R_LERPTAG: return re.LerpTag( (orientation_t*)VMA(1), args[2], args[3], args[4], VMF(5), (const char*)VMA(6) ); case CG_GETGLCONFIG: CL_GetGlconfig( (glconfig_t*)VMA(1) ); return 0; case CG_GETGAMESTATE: CL_GetGameState( (gameState_t*)VMA(1) ); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber( (int*)VMA(1), (int*)VMA(2) ); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot( args[1], (snapshot_t*)VMA(2) ); case CG_GETSERVERCOMMAND: return CL_GetServerCommand( args[1] ); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd( args[1], (usercmd_t*)VMA(2) ); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue( args[1], VMF(2) ); return 0; case CG_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case CG_KEY_ISDOWN: return Key_IsDown( args[1] ); case CG_KEY_GETCATCHER: return Key_GetCatcher(); case CG_KEY_SETCATCHER: // don't allow the cgame module to toggle the console Key_SetCatcher( ( args[1] & ~KEYCATCH_CONSOLE ) | ( Key_GetCatcher() & KEYCATCH_CONSOLE ) ); return 0; case CG_KEY_GETKEY: return Key_GetKey( (const char*)VMA(1) ); case CG_GETDEMOSTATE: return CL_DemoState( ); case CG_GETDEMOPOS: return CL_DemoPos( ); case CG_GETDEMONAME: CL_DemoName( (char*)VMA(1), args[2] ); return 0; case CG_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[1], (char*)VMA(2), args[3] ); return 0; case CG_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[1], (char*)VMA(2), args[3] ); return 0; case CG_KEY_SETBINDING: Key_SetBinding( args[1], (const char*)VMA(2) ); return 0; case CG_PARSE_ADD_GLOBAL_DEFINE: return Parse_AddGlobalDefine( (char*)VMA(1) ); case CG_PARSE_LOAD_SOURCE: return Parse_LoadSourceHandle( (const char*)VMA(1) ); case CG_PARSE_FREE_SOURCE: return Parse_FreeSourceHandle( args[1] ); case CG_PARSE_READ_TOKEN: return Parse_ReadTokenHandle( args[1], (pc_token_t*)VMA(2) ); case CG_PARSE_SOURCE_FILE_AND_LINE: return Parse_SourceFileAndLine( args[1], (char*)VMA(2), (int*)VMA(3) ); case CG_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( (bool)args[1] ); return 0; case CG_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode( ); case CG_FIELD_COMPLETELIST: Field_CompleteList( (char*)VMA(1) ); return 0; case CG_MEMSET: ::memset( VMA(1), args[2], args[3] ); return 0; case CG_MEMCPY: ::memcpy( VMA(1), VMA(2), args[3] ); return 0; case CG_STRNCPY: safe_strncpy( (char*)VMA(1), (const char*)VMA(2), args[3] ); return args[1]; case CG_SIN: return FloatAsInt( sin( VMF(1) ) ); case CG_COS: return FloatAsInt( cos( VMF(1) ) ); case CG_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case CG_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case CG_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case CG_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case CG_ACOS: return FloatAsInt( Q_acos( VMF(1) ) ); case CG_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case CG_REAL_TIME: return Com_RealTime( (qtime_t*)VMA(1) ); case CG_SNAPVECTOR: Q_SnapVector((float*)VMA(1)); return 0; case CG_CIN_PLAYCINEMATIC: return CIN_PlayCinematic((const char*)VMA(1), args[2], args[3], args[4], args[5], args[6]); case CG_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case CG_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case CG_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case CG_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case CG_R_REMAP_SHADER: re.RemapShader( (const char*)VMA(1), (const char*)VMA(2), (const char*)VMA(3) ); return 0; case CG_GET_ENTITY_TOKEN: return re.GetEntityToken( (char*)VMA(1), args[2] ); case CG_R_INPVS: return re.inPVS( (const float*)VMA(1), (const float*)VMA(2) ); default: assert(0); Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] ); } return 0; }
/* ================= S_StreamBackgroundTrack ================= */ void S_StreamBackgroundTrack( void ) { int bufferSamples; int fileSamples; byte raw[MAX_RAW_SAMPLES]; int r, fileBytes; if( !dma.initialized ) return; if( !s_bgTrack.stream ) return; if( s_listener.streaming ) return; // we are playing movie or somewhat // don't bother playing anything if musicvolume is 0 if( !s_musicvolume->value || s_listener.paused || s_listener.stream_paused ) return; if( !cl.background ) { // pause music by source type if( s_bgTrack.source == key_game && cls.key_dest == key_menu ) return; if( s_bgTrack.source == key_menu && cls.key_dest != key_menu ) return; } else if( cls.key_dest == key_console ) return; // see how many samples should be copied into the raw buffer if( s_rawend < soundtime ) s_rawend = soundtime; while( s_rawend < soundtime + MAX_RAW_SAMPLES ) { wavdata_t *info = FS_StreamInfo( s_bgTrack.stream ); bufferSamples = MAX_RAW_SAMPLES - (s_rawend - soundtime); // decide how much data needs to be read from the file fileSamples = bufferSamples * ((float)info->rate / SOUND_DMA_SPEED ); if( fileSamples <= 1 ) return; // no more samples need // our max buffer size fileBytes = fileSamples * ( info->width * info->channels ); if( fileBytes > sizeof( raw )) { fileBytes = sizeof( raw ); fileSamples = fileBytes / ( info->width * info->channels ); } // read r = FS_ReadStream( s_bgTrack.stream, fileBytes, raw ); if( r < fileBytes ) { fileBytes = r; fileSamples = r / ( info->width * info->channels ); } if( r > 0 ) { // add to raw buffer S_StreamRawSamples( fileSamples, info->rate, info->width, info->channels, raw ); } else { // loop if( s_bgTrack.loopName[0] ) { FS_FreeStream( s_bgTrack.stream ); s_bgTrack.stream = FS_OpenStream( va( "media/%s", s_bgTrack.loopName )); Q_strncpy( s_bgTrack.current, s_bgTrack.loopName, sizeof( s_bgTrack.current )); if( !s_bgTrack.stream ) return; S_CheckLerpingState(); } else { S_StopBackgroundTrack(); return; } } } }
int CL_CgameSystemCalls( int *args ) { switch( args[0] ) { case CG_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case CG_ERROR: Com_Error( ERR_DROP, "%s", VMA(1) ); return 0; case CG_MILLISECONDS: return Sys_Milliseconds(); case CG_CVAR_REGISTER: Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); return 0; case CG_CVAR_UPDATE: Cvar_Update( VMA(1) ); return 0; case CG_CVAR_SET: Cvar_Set( VMA(1), VMA(2) ); return 0; case CG_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] ); return 0; case CG_ARGC: return Cmd_Argc(); case CG_ARGV: Cmd_ArgvBuffer( args[1], VMA(2), args[3] ); return 0; case CG_ARGS: Cmd_ArgsBuffer( VMA(1), args[2] ); return 0; case CG_FS_FOPENFILE: return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] ); case CG_FS_READ: FS_Read2( VMA(1), args[2], args[3] ); return 0; case CG_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case CG_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case CG_FS_SEEK: return FS_Seek( args[1], args[2], args[3] ); case CG_SENDCONSOLECOMMAND: Cbuf_AddText( VMA(1) ); return 0; case CG_ADDCOMMAND: CL_AddCgameCommand( VMA(1) ); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommand( VMA(1) ); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand( VMA(1) ); return 0; case CG_UPDATESCREEN: // this is used during lengthy level loading, so pump message loop // Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN! // We can't call Com_EventLoop here, a restart will crash and this _does_ happen // if there is a map change while we are downloading at pk3. // ZOID SCR_UpdateScreen(); return 0; case CG_CM_LOADMAP: CL_CM_LoadMap( VMA(1) ); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel( args[1] ); case CG_CM_TEMPBOXMODEL: return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qfalse ); case CG_CM_TEMPCAPSULEMODEL: return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qtrue ); case CG_CM_POINTCONTENTS: return CM_PointContents( VMA(1), args[2] ); case CG_CM_TRANSFORMEDPOINTCONTENTS: return CM_TransformedPointContents( VMA(1), args[2], VMA(3), VMA(4) ); case CG_CM_BOXTRACE: CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse ); return 0; case CG_CM_CAPSULETRACE: CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue ); return 0; case CG_CM_TRANSFORMEDBOXTRACE: CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse ); return 0; case CG_CM_TRANSFORMEDCAPSULETRACE: CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qtrue ); return 0; case CG_CM_MARKFRAGMENTS: return re.MarkFragments( args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7) ); case CG_S_STARTSOUND: S_StartSound( args[4] ); return 0; case CG_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case CG_S_CLEARLOOPINGSOUNDS: S_ClearLoopingSounds(args[1]); return 0; case CG_S_ADDLOOPINGSOUND: S_AddLoopingSound( args[1], VMA(2), VMA(3), args[4] ); return 0; case CG_S_ADDREALLOOPINGSOUND: S_AddRealLoopingSound( args[1], VMA(2), VMA(3), args[4] ); return 0; case CG_S_STOPLOOPINGSOUND: S_StopLoopingSound( args[1] ); return 0; case CG_S_UPDATEENTITYPOSITION: S_UpdateEntityPosition( args[1], VMA(2) ); return 0; case CG_S_RESPATIALIZE: S_Respatialize( args[1], VMA(2), VMA(3), args[4] ); return 0; case CG_S_REGISTERSOUND: return S_RegisterSound( VMA(1), args[2] ); case CG_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( VMA(1), VMA(2) ); return 0; case CG_R_LOADWORLDMAP: re.LoadWorld( VMA(1) ); return 0; case CG_R_REGISTERMODEL: #ifdef IPHONE GLimp_AcquireGL(); return re.RegisterModel( VMA(1) ); GLimp_ReleaseGL(); #else return re.RegisterModel( VMA(1) ); #endif // IPHONE case CG_R_REGISTERSKIN: return re.RegisterSkin( VMA(1) ); case CG_R_REGISTERSHADER: #ifdef IPHONE_NOTYET GLimp_AcquireGL(); return re.RegisterShader( VMA(1) ); GLimp_ReleaseGL(); #else return re.RegisterShader( VMA(1) ); #endif // IPHONE case CG_R_REGISTERSHADERNOMIP: #ifdef IPHONE_NOTYET GLimp_AcquireGL(); return re.RegisterShaderNoMip( VMA(1) ); GLimp_ReleaseGL(); #else return re.RegisterShaderNoMip( VMA(1) ); #endif // IPHONE case CG_R_REGISTERFONT: re.RegisterFont( VMA(1), args[2], VMA(3)); case CG_R_CLEARSCENE: re.ClearScene(); return 0; case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA(1) ); return 0; case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], VMA(3), 1 ); return 0; case CG_R_ADDPOLYSTOSCENE: re.AddPolyToScene( args[1], args[2], VMA(3), args[4] ); return 0; case CG_R_LIGHTFORPOINT: return re.LightForPoint( VMA(1), VMA(2), VMA(3), VMA(4) ); case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case CG_R_ADDADDITIVELIGHTTOSCENE: re.AddAdditiveLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case CG_R_RENDERSCENE: re.RenderScene( VMA(1) ); return 0; case CG_R_SETCOLOR: re.SetColor( VMA(1) ); return 0; case CG_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 CG_R_MODELBOUNDS: re.ModelBounds( args[1], VMA(2), VMA(3) ); return 0; case CG_R_LERPTAG: return re.LerpTag( VMA(1), args[2], args[3], args[4], VMF(5), VMA(6) ); case CG_GETGLCONFIG: CL_GetGlconfig( VMA(1) ); return 0; case CG_GETGAMESTATE: CL_GetGameState( VMA(1) ); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber( VMA(1), VMA(2) ); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot( args[1], VMA(2) ); case CG_GETSERVERCOMMAND: return CL_GetServerCommand( args[1] ); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd( args[1], VMA(2) ); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue( args[1], VMF(2) ); return 0; case CG_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case CG_KEY_ISDOWN: return Key_IsDown( args[1] ); case CG_KEY_GETCATCHER: return Key_GetCatcher(); case CG_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case CG_KEY_GETKEY: return Key_GetKey( VMA(1) ); case CG_MEMSET: Com_Memset( VMA(1), args[2], args[3] ); return 0; case CG_MEMCPY: Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case CG_STRNCPY: return (int)strncpy( VMA(1), VMA(2), args[3] ); case CG_SIN: return FloatAsInt( sin( VMF(1) ) ); case CG_COS: return FloatAsInt( cos( VMF(1) ) ); case CG_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case CG_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case CG_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case CG_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case CG_ACOS: return FloatAsInt( Q_acos( VMF(1) ) ); case CG_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( VMA(1) ); case CG_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( VMA(1) ); case CG_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case CG_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) ); case CG_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) ); case CG_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case CG_REAL_TIME: return Com_RealTime( VMA(1) ); case CG_SNAPVECTOR: Sys_SnapVector( VMA(1) ); return 0; case CG_CIN_PLAYCINEMATIC: return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); case CG_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case CG_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case CG_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case CG_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case CG_R_REMAP_SHADER: re.RemapShader( VMA(1), VMA(2), VMA(3) ); return 0; /* case CG_LOADCAMERA: return loadCamera(VMA(1)); case CG_STARTCAMERA: startCamera(args[1]); return 0; case CG_GETCAMERAINFO: return getCameraInfo(args[1], VMA(2), VMA(3)); */ case CG_GET_ENTITY_TOKEN: return re.GetEntityToken( VMA(1), args[2] ); case CG_R_INPVS: return re.inPVS( VMA(1), VMA(2) ); default: assert(0); // bk010102 Com_Error( ERR_DROP, "Bad cgame system trap: %i", args[0] ); } return 0; }
/* ================== CL_ParseServerData ================== */ void CL_ParseServerData( sizebuf_t *msg ) { string gamefolder; qboolean background; int i; MsgDev( D_NOTE, "Serverdata packet received.\n" ); cls.demowaiting = false; // server is changed clgame.load_sequence++; // now all hud sprites are invalid // wipe the client_t struct if( !cls.changelevel && !cls.changedemo ) CL_ClearState (); cls.state = ca_connected; // parse protocol version number i = BF_ReadLong( msg ); cls.serverProtocol = i; if( i != PROTOCOL_VERSION ) Host_Error( "Server use invalid protocol (%i should be %i)\n", i, PROTOCOL_VERSION ); cl.servercount = BF_ReadLong( msg ); cl.checksum = BF_ReadLong( msg ); cl.playernum = BF_ReadByte( msg ); cl.maxclients = BF_ReadByte( msg ); clgame.maxEntities = BF_ReadWord( msg ); clgame.maxEntities = bound( 600, clgame.maxEntities, 4096 ); Q_strncpy( clgame.mapname, BF_ReadString( msg ), MAX_STRING ); Q_strncpy( clgame.maptitle, BF_ReadString( msg ), MAX_STRING ); background = BF_ReadOneBit( msg ); Q_strncpy( gamefolder, BF_ReadString( msg ), MAX_STRING ); host.features = (uint)BF_ReadLong( msg ); if( cl.maxclients > 1 && host.developer < 1 ) host.developer++; // set the background state if( cls.demoplayback && ( cls.demonum != -1 )) { // re-init mouse host.mouse_visible = false; cl.background = true; } else cl.background = background; if( cl.background ) // tell the game parts about background state Cvar_FullSet( "cl_background", "1", CVAR_READ_ONLY ); else Cvar_FullSet( "cl_background", "0", CVAR_READ_ONLY ); if( !cls.changelevel ) { // continue playing if we are changing level S_StopBackgroundTrack (); } #if 0 // NOTE: this is not tested as well. Use with precaution CL_ChangeGame( gamefolder, false ); #endif if( !cls.changedemo ) UI_SetActiveMenu( cl.background ); else if( !cls.demoplayback ) Key_SetKeyDest( key_menu ); cl.refdef.viewentity = cl.playernum + 1; // always keep viewent an actual menu.globals->maxClients = cl.maxclients; Q_strncpy( menu.globals->maptitle, clgame.maptitle, sizeof( menu.globals->maptitle )); if( !cls.changelevel && !cls.changedemo ) CL_InitEdicts (); // re-arrange edicts // get splash name if( cls.demoplayback && ( cls.demonum != -1 )) Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", cls.demoname, glState.wideScreen ? "16x9" : "4x3" )); else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, glState.wideScreen ? "16x9" : "4x3" )); Cvar_SetFloat( "scr_loading", 0.0f ); // reset progress bar if(( cl_allow_levelshots->integer && !cls.changelevel ) || cl.background ) { if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name->string ), true )) Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime) } if( scr_dark->integer ) { screenfade_t *sf = &clgame.fade; client_textmessage_t *title; title = CL_TextMessageGet( "GAMETITLE" ); if( title ) { // get settings from titles.txt sf->fadeEnd = title->holdtime + title->fadeout; sf->fadeReset = title->fadeout; } else sf->fadeEnd = sf->fadeReset = 4.0f; sf->fadeFlags = FFADE_IN; sf->fader = sf->fadeg = sf->fadeb = 0; sf->fadealpha = 255; sf->fadeSpeed = (float)sf->fadealpha / sf->fadeReset; sf->fadeReset += cl.time; sf->fadeEnd += sf->fadeReset; Cvar_SetFloat( "v_dark", 0.0f ); } // need to prep refresh at next oportunity cl.video_prepped = false; cl.audio_prepped = false; Q_memset( &clgame.movevars, 0, sizeof( clgame.movevars )); Q_memset( &clgame.oldmovevars, 0, sizeof( clgame.oldmovevars )); }
/* * S_UpdateBackgroundTrack */ void S_UpdateBackgroundTrack( void ) { int samples, maxSamples; int read, maxRead, total; float scale; uint8_t data[MAX_RAW_SAMPLES * 4]; if( !s_bgTrack ) { return; } if( !s_musicvolume->value && !s_bgTrack->muteOnPause ) { return; } if( s_bgTrackLoading || s_bgTrackPaused || s_bgTrackLocked > 0 ) { return; } if( !s_bgTrack->info.channels || !s_bgTrack->info.width ) { s_bgTrack->ignore = true; S_AdvanceBackgroundTrack( 1 ); return; } scale = (float)s_bgTrack->info.rate / dma.speed; maxSamples = sizeof( data ) / s_bgTrack->info.channels / s_bgTrack->info.width; while( 1 ) { unsigned int rawSamplesLength; rawSamplesLength = S_GetRawSamplesLength(); if( rawSamplesLength >= BACKGROUND_TRACK_PRELOAD_MSEC ) { return; } samples = BACKGROUND_TRACK_PRELOAD_MSEC - rawSamplesLength; samples = (float)samples / 1000.0 * s_bgTrack->info.rate / scale; if( samples > maxSamples ) { samples = maxSamples; } if( samples > MAX_RAW_SAMPLES ) { samples = MAX_RAW_SAMPLES; } maxRead = samples * s_bgTrack->info.channels * s_bgTrack->info.width; total = 0; while( total < maxRead ) { int seek; if( s_bgTrack->read ) { read = s_bgTrack->read( s_bgTrack, data + total, maxRead - total ); } else { read = trap_FS_Read( data + total, maxRead - total, s_bgTrack->file ); } if( !read ) { if( !s_bgTrack->loop ) { if( !S_AdvanceBackgroundTrack( 1 ) ) { if( !S_ValidMusicFile( s_bgTrack ) ) { S_StopBackgroundTrack(); return; } } if( s_bgTrackBuffering || s_bgTrackLoading ) { return; } } if( s_bgTrack->seek ) { seek = s_bgTrack->seek( s_bgTrack, s_bgTrack->info.dataofs ); } else { seek = trap_FS_Seek( s_bgTrack->file, s_bgTrack->info.dataofs, FS_SEEK_SET ); } if( seek ) { // if the seek have failed we're going to loop here forever unless // we stop now S_StopBackgroundTrack(); return; } } total += read; } byteSwapRawSamples( samples, s_bgTrack->info.width, s_bgTrack->info.channels, data ); S_RawSamples2( samples, s_bgTrack->info.rate, s_bgTrack->info.width, s_bgTrack->info.channels, data, s_bgTrackMuted ? 0 : s_musicvolume->value * 255 ); } }
/* ======================================================================================================================================= CL_CgameSystemCalls The cgame module is making a system call. ======================================================================================================================================= */ intptr_t CL_CgameSystemCalls(intptr_t *args) { switch (args[0]) { 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(VMA(1), 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_FLOOR: return FloatAsInt(floor(VMF(1))); case TRAP_CEIL: return FloatAsInt(ceil(VMF(1))); case TRAP_ACOS: return FloatAsInt(Q_acos(VMF(1))); case CG_PRINT: Com_Printf("%s", (const char *)VMA(1)); return 0; case CG_ERROR: Com_Error(ERR_DROP, "%s", (const char *)VMA(1)); return 0; case CG_MILLISECONDS: return Sys_Milliseconds(); case CG_REAL_TIME: return Com_RealTime(VMA(1)); case CG_SNAPVECTOR: Q_SnapVector(VMA(1)); return 0; case CG_ARGC: return Cmd_Argc(); case CG_ARGV: Cmd_ArgvBuffer(args[1], VMA(2), args[3]); return 0; case CG_ARGS: Cmd_ArgsBuffer(VMA(1), args[2]); return 0; case CG_ADDCOMMAND: CL_AddCgameCommand(VMA(1)); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommandSafe(VMA(1)); return 0; case CG_CMD_EXECUTETEXT: Cbuf_ExecuteTextSafe(args[1], VMA(2)); return 0; case CG_CVAR_REGISTER: Cvar_Register(VMA(1), VMA(2), VMA(3), args[4]); return 0; case CG_CVAR_UPDATE: Cvar_Update(VMA(1)); return 0; case CG_CVAR_SET: Cvar_SetSafe(VMA(1), VMA(2)); return 0; case CG_CVAR_SET_VALUE: Cvar_SetValueSafe(VMA(1), VMF(2)); return 0; case CG_CVAR_VARIABLE_VALUE: return FloatAsInt(Cvar_VariableValue(VMA(1))); case CG_CVAR_VARIABLE_INTEGER_VALUE: return Cvar_VariableIntegerValue(VMA(1)); case CG_CVAR_VARIABLE_STRING_BUFFER: Cvar_VariableStringBuffer(VMA(1), VMA(2), args[3]); return 0; case CG_FS_FOPENFILE: return FS_FOpenFileByMode(VMA(1), VMA(2), args[3]); case CG_FS_READ: FS_Read(VMA(1), args[2], args[3]); return 0; case CG_FS_WRITE: FS_Write(VMA(1), args[2], args[3]); return 0; case CG_FS_SEEK: return FS_Seek(args[1], args[2], args[3]); case CG_FS_FCLOSEFILE: FS_FCloseFile(args[1]); return 0; case CG_FS_GETFILELIST: return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]); case CG_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine(VMA(1)); case CG_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle(VMA(1)); case CG_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle(args[1]); case CG_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle(args[1], VMA(2)); case CG_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine(args[1], VMA(2), VMA(3)); case CG_GETGLCONFIG: CL_GetGlconfig(VMA(1)); return 0; case CG_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case CG_UPDATESCREEN: // this is used during lengthy level loading, so pump message loop //Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN! // we can't call Com_EventLoop here, a restart will crash and this _does_ happen if there is a map change while we are downloading at pk3. SCR_UpdateScreen(); return 0; case CG_GETGAMESTATE: CL_GetGameState(VMA(1)); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber(VMA(1), VMA(2)); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot(args[1], VMA(2)); case CG_GETSERVERCOMMAND: return CL_GetServerCommand(args[1]); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd(args[1], VMA(2)); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue(args[1], VMF(2)); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand(VMA(1), qfalse); return 0; case CG_CM_LOADMAP: CL_CM_LoadMap(VMA(1)); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel(args[1]); case CG_CM_MARKFRAGMENTS: return re.MarkFragments(args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7)); case CG_CM_POINTCONTENTS: return CM_PointContents(VMA(1), args[2]); case CG_CM_TRANSFORMEDPOINTCONTENTS: return CM_TransformedPointContents(VMA(1), args[2], VMA(3), VMA(4)); case CG_CM_TEMPBOXMODEL: return CM_TempBoxModel(VMA(1), VMA(2), /*int capsule*/ qfalse); case CG_CM_BOXTRACE: CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse); return 0; case CG_CM_TRANSFORMEDBOXTRACE: CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse); return 0; case CG_CM_TEMPCAPSULEMODEL: return CM_TempBoxModel(VMA(1), VMA(2), /*int capsule*/ qtrue); case CG_CM_CAPSULETRACE: CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue); return 0; case CG_CM_TRANSFORMEDCAPSULETRACE: CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qtrue); return 0; case CG_R_REGISTERMODEL: return re.RegisterModel(VMA(1)); case CG_R_REGISTERSHADEREX: return re.RegisterShaderEx(VMA(1), args[2], args[3]); case CG_R_REGISTERSHADER: return re.RegisterShader(VMA(1)); case CG_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip(VMA(1)); case CG_R_REGISTERFONT: re.RegisterFont(VMA(1), args[2], VMF(3), args[4], VMA(5)); return 0; case CG_R_RENDERSCENE: re.RenderScene(VMA(1)); return 0; case CG_R_CLEARSCENE: re.ClearScene(); return 0; case CG_R_SETCOLOR: re.SetColor(VMA(1)); return 0; case CG_R_LOADWORLDMAP: re.LoadWorld(VMA(1)); return 0; case CG_R_INPVS: return re.inPVS(VMA(1), VMA(2)); case CG_GET_ENTITY_TOKEN: return re.GetEntityToken(VMA(1), args[2]); case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene(VMA(1)); return 0; case CG_R_ADDPOLYREFENTITYTOSCENE: re.AddRefEntityToScene(VMA(1)); return 0; case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene(args[1], args[2], VMA(3), 1, args[4], args[5]); return 0; case CG_R_ADDPOLYSTOSCENE: re.AddPolyToScene(args[1], args[2], VMA(3), args[4], args[5], args[6]); return 0; case CG_R_ADDPOLYBUFFERTOSCENE: re.AddPolyBufferToScene(VMA(1)); return 0; case CG_R_LIGHTFORPOINT: return re.LightForPoint(VMA(1), VMA(2), VMA(3), VMA(4)); case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), args[7]); return 0; case CG_R_ADDADDITIVELIGHTTOSCENE: re.AddAdditiveLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6)); return 0; case CG_R_ADDVERTEXLIGHTTOSCENE: re.AddVertexLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6)); return 0; case CG_R_ADDJUNIORLIGHTTOSCENE: re.AddJuniorLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6)); return 0; case CG_R_ADDDIRECTEDLIGHTTOSCENE: re.AddDirectedLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5)); return 0; case CG_R_ADDCORONATOSCENE: re.AddCoronaToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6], args[7], args[8]); return 0; case CG_R_GET_GLOBAL_FOG: re.GetGlobalFog(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5)); return 0; case CG_R_GET_VIEW_FOG: re.GetViewFog(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), VMA(6), args[7]); return 0; case CG_R_MODELBOUNDS: return re.ModelBounds(args[1], VMA(2), VMA(3), args[4], args[5], VMF(6)); case CG_R_LERPTAG: return re.LerpTag(VMA(1), args[2], 0, args[3], 0, args[4], VMF(5), VMA(6), NULL, NULL, 0, 0, 0, 0, 0); case CG_R_LERPTAG_FRAMEMODEL: return re.LerpTag(VMA(1), args[2], args[3], args[4], args[5], args[6], VMF(7), VMA(8), VMA(9), NULL, 0, 0, 0, 0, 0); case CG_R_LERPTAG_TORSO: return re.LerpTag(VMA(1), args[2], args[3], args[4], args[5], args[6], VMF(7), VMA(8), VMA(9), VMA(10), args[11], args[12], args[13], args[14], VMF(15)); case CG_R_ALLOCSKINSURFACE: return re.AllocSkinSurface(VMA(1), args[2]); case CG_R_ADDSKINTOFRAME: return re.AddSkinToFrame(args[1], VMA(2)); case CG_R_SETCLIPREGION: re.SetClipRegion(VMA(1)); return 0; case CG_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 CG_R_DRAWSTRETCHPIC_GRADIENT: re.DrawStretchPicGradient(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9], VMA(10)); return 0; case CG_R_DRAWROTATEDPIC: // Tobias FIXME (activate): 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 CG_R_DRAW2DPOLYS: // Tobias FIXME (activate): re.Add2dPolys(VMA(1), args[2], args[3]); return 0; case CG_R_REMAP_SHADER: re.RemapShader(VMA(1), VMA(2), VMA(3)); return 0; case CG_S_REGISTERSOUND: return S_RegisterSound(VMA(1), args[2]); case CG_S_STARTLOCALSOUND: S_StartLocalSound(args[1], args[2]); return 0; case CG_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack(VMA(1), VMA(2)); return 0; case CG_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case CG_S_STARTSOUND: S_StartSound(VMA(1), args[2], args[3], args[4], args[5]); return 0; case CG_S_CLEARLOOPINGSOUNDS: S_ClearLoopingSounds(args[1]); return 0; case CG_S_ADDLOOPINGSOUND: S_AddLoopingSound(args[1], VMA(2), VMA(3), args[4], args[5]); return 0; case CG_S_ADDREALLOOPINGSOUND: S_AddRealLoopingSound(args[1], VMA(2), VMA(3), args[4], args[5]); return 0; case CG_S_STOPLOOPINGSOUND: S_StopLoopingSound(args[1]); return 0; case CG_S_UPDATEENTITYPOSITION: S_UpdateEntityPosition(args[1], VMA(2)); return 0; case CG_S_RESPATIALIZE: S_Respatialize(args[1], VMA(2), VMA(3), args[4]); return 0; case CG_KEY_GETCATCHER: return Key_GetCatcher(); case CG_KEY_SETCATCHER: // don't allow the cgame module to close the console Key_SetCatcher(args[1]|(Key_GetCatcher() & KEYCATCH_CONSOLE)); return 0; case CG_KEY_ISDOWN: return Key_IsDown(args[1]); case CG_KEY_GETKEY: return Key_GetKey(VMA(1)); case CG_CIN_PLAYCINEMATIC: return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); case CG_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case CG_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case CG_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case CG_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; /* case CG_LOADCAMERA: return loadCamera(VMA(1)); case CG_STARTCAMERA: startCamera(args[1]); return 0; case CG_GETCAMERAINFO: return getCameraInfo(args[1], VMA(2), VMA(3)); */ default: assert(0); Com_Error(ERR_DROP, "Bad cgame 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; }
/* * S_StopMusic */ static void S_StopMusic( void ) { S_StopBackgroundTrack(); }
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 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: { char *gameMem = (char *)VMA(1); const char *retMem = re->ShaderNameFromIndex(args[2]); if (retMem) { strcpy(gameMem, retMem); } else { gameMem[0] = 0; } } 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: // Don't allow the ui module to close the console Key_SetCatcher( args[1] | ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ); 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(); 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: char *languageName,*holdName; holdName = ((char *)VMA(2)); languageName = (char *) SE_GetLanguageName(args[1]); Q_strncpyz( holdName, languageName,128 ); return 0; case UI_SP_GETSTRINGTEXTSTRING: const char* text; assert(VMA(1)); assert(VMA(2)); text = SE_GetString((const char *) VMA(1)); Q_strncpyz( (char *) VMA(2), text, args[3] ); return qtrue; /* Ghoul2 Insert Start */ /* Ghoul2 Insert Start */ 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_REMOVEBOLT: // return G2API_RemoveBolt(*((CGhoul2Info_v *)VMA(1)), args[2]); case UI_G2_SETBOLTON: re->G2API_SetBoltInfo(*((CGhoul2Info_v *)args[1]), args[2], args[3]); return 0; #ifdef _SOF2 case UI_G2_ADDSKINGORE: re->G2API_AddSkinGore(*((CGhoul2Info_v *)args[1]),*(SSkinGoreData *)VMA(2)); return 0; #endif // _SOF2 /* Ghoul2 Insert End */ 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]); } // Jedi Knight Galaxies case UI_JKG_CHANGEPROTOCOL: return 0; case UI_SYSCALL_CG: currentVM = cgvm; return 0; case UI_SYSCALL_UI: currentVM = uivm; return 0; /* Ghoul2 Insert End */ 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; }
/* =============== CL_PlayCDTrack_f Emulate audio-cd system =============== */ void CL_PlayCDTrack_f( void ) { const char *command; static int track = 0; static qboolean paused = false; static qboolean looped = false; static qboolean enabled = true; if( Cmd_Argc() < 2 ) return; command = Cmd_Argv( 1 ); if( !enabled && Q_stricmp( command, "on" )) return; // CD-player is disabled if( !Q_stricmp( command, "play" )) { track = bound( 1, Q_atoi( Cmd_Argv( 2 )), MAX_CDTRACKS ); S_StartBackgroundTrack( clgame.cdtracks[track-1], NULL, 0 ); paused = false; looped = false; } else if( !Q_stricmp( command, "loop" )) { track = bound( 1, Q_atoi( Cmd_Argv( 2 )), MAX_CDTRACKS ); S_StartBackgroundTrack( clgame.cdtracks[track-1], clgame.cdtracks[track-1], 0 ); paused = false; looped = true; } else if( !Q_stricmp( command, "pause" )) { S_StreamSetPause( true ); paused = true; } else if( !Q_stricmp( command, "resume" )) { S_StreamSetPause( false ); paused = false; } else if( !Q_stricmp( command, "stop" )) { S_StopBackgroundTrack(); paused = false; looped = false; track = 0; } else if( !Q_stricmp( command, "on" )) { enabled = true; } else if( !Q_stricmp( command, "off" )) { enabled = false; } else if( !Q_stricmp( command, "info" )) { int i, maxTrack; for( maxTrack = i = 0; i < MAX_CDTRACKS; i++ ) if( Q_strlen( clgame.cdtracks[i] )) maxTrack++; Msg( "%u tracks\n", maxTrack ); if( track ) { if( paused ) Msg( "Paused %s track %u\n", looped ? "looping" : "playing", track ); else Msg( "Currently %s track %u\n", looped ? "looping" : "playing", track ); } Msg( "Volume is %f\n", Cvar_VariableValue( "musicvolume" )); return; } else Msg( "cd: unknown command %s\n", command ); }
/* ==================== CL_CgameSystemCalls The cgame module is making a system call ==================== */ intptr_t CL_CgameSystemCalls( intptr_t *args ) { switch( args[0] ) { case CG_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case CG_FATAL_ERROR: Com_Error( ERR_DROP, "%s", VMA(1) ); return 0; case CG_MILLISECONDS: return Sys_Milliseconds(); case CG_CVAR_REGISTER: Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); return 0; case CG_CVAR_UPDATE: Cvar_Update( VMA(1) ); return 0; case CG_CVAR_SET: Cvar_Set( VMA(1), VMA(2) ); return 0; case CG_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] ); return 0; case CG_ARGC: return Cmd_Argc(); case CG_ARGV: Cmd_ArgvBuffer( args[1], VMA(2), args[3] ); return 0; case CG_ARGVI: return atoi( Cmd_Argv( args[1] ) ); case CG_ARGS: Cmd_ArgsBuffer( VMA(1), args[2] ); return 0; case CG_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[1], VMA(2) ); return 0; case CG_FS_FOPENFILE: return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] ); case CG_FS_READ: FS_Read( VMA(1), args[2], args[3] ); return 0; case CG_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case CG_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case CG_SENDCONSOLECOMMAND: Cbuf_AddText( VMA(1) ); return 0; case CG_FORWARDCOMMAND: VM_Call( uivm, UI_CONSOLE_COMMAND, cls.realtime ); return 0; case CG_ADDCOMMAND: CL_AddCgameCommand( VMA(1) ); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommand( VMA(1) ); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand( VMA(1) ); return 0; case CG_UPDATESCREEN: // this is used during lengthy level loading, so pump message loop // Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN! // We can't call Com_EventLoop here, a restart will crash and this _does_ happen // if there is a map change while we are downloading at pk3. // ZOID SCR_UpdateScreen(); return 0; case CG_CM_LOADMAP: CL_CM_LoadMap( VMA(1) ); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel( args[1] ); case CG_CM_TEMPBOXMODEL: return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qfalse ); case CG_CM_TEMPCAPSULEMODEL: return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qtrue ); case CG_CM_POINTCONTENTS: return CM_PointContents( VMA(1), args[2] ); case CG_CM_TRANSFORMEDPOINTCONTENTS: return CM_TransformedPointContents( VMA(1), args[2], VMA(3), VMA(4) ); case CG_CM_BOXTRACE: CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse ); return 0; case CG_CM_CAPSULETRACE: CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue ); return 0; case CG_CM_TRANSFORMEDBOXTRACE: CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse ); return 0; case CG_CM_TRANSFORMEDCAPSULETRACE: CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qtrue ); return 0; case CG_CM_MARKFRAGMENTS: return re.MarkFragments( args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7) ); case CG_S_STARTSOUND: S_StartSound( VMA(1), args[2], args[3], args[4] ); return 0; case CG_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case CG_S_CLEARLOOPINGSOUNDS: S_ClearLoopingSounds(args[1]); return 0; case CG_S_ADDLOOPINGSOUND: S_AddLoopingSound( args[1], VMA(2), VMA(3), args[4] ); return 0; case CG_S_ADDREALLOOPINGSOUND: S_AddRealLoopingSound( args[1], VMA(2), VMA(3), args[4] ); return 0; case CG_S_STOPLOOPINGSOUND: S_StopLoopingSound( args[1] ); return 0; case CG_S_UPDATEENTITYPOSITION: S_UpdateEntityPosition( args[1], VMA(2) ); return 0; case CG_S_RESPATIALIZE: S_Respatialize( args[1], VMA(2), VMA(3), args[4] ); return 0; case CG_S_REGISTERSOUND: return S_RegisterSound( VMA(1), args[2] ); case CG_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( VMA(1), VMA(2) ); return 0; case CG_R_LOADWORLDMAP: CL_R_LoadWorld( VMA( 1 ) ); return 0; case CG_R_REGISTERMODEL: return re.RegisterModel( VMA(1) ); case CG_R_REGISTERSKIN: return re.RegisterSkin( VMA(1) ); case CG_R_REGISTERSHADER: return re.RegisterShader( VMA(1) ); case CG_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( VMA(1) ); case CG_R_REGISTERFONT: return re.RegisterFont( VMA(1) ); case CG_R_CLEARSCENE: re.ClearScene(); return 0; case CG_R_BUILDPOSE: { animGroupTransition_t trans; trans.animGroup = 0; trans.interp = 0; return re.BuildPose( args[1], VMA( 2 ), args[3], VMA( 4 ), args[5], NULL, 0, NULL, 0, &trans, 1 ); } case CG_R_BUILDPOSE2: return re.BuildPose( args[1], VMA( 2 ), 2, VMA( 3 ), 2, VMA( 4 ), 2, VMA( 5 ), 2, VMA( 6 ), 2 ); case CG_R_BUILDPOSE3: return re.BuildPose( args[1], VMA( 2 ), 1, 0, 0, VMA( 3 ), 1, 0, 0, VMA( 4 ), 1 ); case CG_R_LERPTAGFROMPOSE: return re.LerpTagFromPose( VMA( 1 ), args[2], args[3], VMA( 4 ) ); case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA(1) ); return 0; case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], VMA(3), 1 ); return 0; case CG_R_ADDPOLYSTOSCENE: re.AddPolyToScene( args[1], args[2], VMA(3), args[4] ); return 0; case CG_R_MENUBEGINSURF: re.MenuBeginSurf( args[1] ); return 0; case CG_R_MENUENDSURF: re.MenuEndSurf(); return 0; case CG_R_LIGHTFORPOINT: return re.LightForPoint( VMA(1), VMA(2), VMA(3), VMA(4) ); case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case CG_R_ADDADDITIVELIGHTTOSCENE: re.AddAdditiveLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case CG_R_RENDERSCENE: re.RenderScene( VMA(1) ); return 0; case CG_R_SETCOLOR: re.SetColor( VMA(1) ); return 0; case CG_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), NULL, VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); return 0; case CG_R_SHAPECREATE: { curve_t * c = VMA(1); int n = args[3]; int i; for ( i=0; i<n; i++ ) { c->pts = (vec2_t*)VM_ArgPtr((intptr_t)c->pts); c->uvs = (vec2_t*)VM_ArgPtr((intptr_t)c->uvs); c->colors = (vec4_t*)VM_ArgPtr((intptr_t)c->colors); c->indices = (short*)VM_ArgPtr((intptr_t)c->indices ); } return re.ShapeCreate( c, VMA( 2 ), n ); } case CG_R_SHAPEDRAW: re.ShapeDraw( args[1], args[2], VMA( 3 ) ); return 0; case CG_R_RENDERTEXT: CL_RenderText( VMA(1), VMF(2), VMA(3), VMA(4), args[5], (args[6])>>16, args[6]&0xFFFF, args[7], args[8], 0, args[9], VMA(10) ); return 0; case CG_R_GETFONT: memcpy( VMA(3), re.GetFontFromFontSet( args[1], VMF(2) ), sizeof(fontInfo_t) ); return 0; case CG_R_ROUNDRECT: SCR_FillRect( VMF(1), VMF(2), VMF(3), VMF(4), VMA(5), args[6] ); return 0; case CG_R_MODELBOUNDS: re.ModelBounds( args[1], VMA(2), VMA(3) ); return 0; case CG_R_LERPTAG: return re.LerpTag( VMA(1), args[2], args[3], args[4], VMF(5), VMA(6) ); case CG_GETGLCONFIG: CL_GetGlconfig( VMA(1) ); return 0; case CG_GETGAMESTATE: CL_GetGameState( VMA(1) ); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber( VMA(1), VMA(2) ); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot( args[1], VMA(2) ); case CG_GETSERVERCOMMAND: return CL_GetServerCommand( args[1] ); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd( args[1], VMA(2) ); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue( args[1], VMF(2) ); return 0; case CG_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case CG_KEY_ISDOWN: return Key_IsDown( args[1] ); case CG_KEY_GETCATCHER: return Key_GetCatcher(); case CG_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case CG_KEY_GETKEY: return Key_GetKey( VMA(1) ); case CG_MEMSET: Com_Memset( VMA(1), args[2], args[3] ); return 0; case CG_MEMCPY: Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case CG_STRNCPY: strncpy( VMA(1), VMA(2), args[3] ); return args[1]; case CG_SIN: return FloatAsInt( sin( VMF(1) ) ); case CG_COS: return FloatAsInt( cos( VMF(1) ) ); case CG_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case CG_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case CG_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case CG_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case CG_ACOS: return FloatAsInt( Q_acos( VMF(1) ) ); case CG_FMOD: return FloatAsInt( fmod( VMF(1),VMF(2) ) ); case CG_POW: return FloatAsInt( pow( VMF(1),VMF(2) ) ); case CG_ATAN: return FloatAsInt( atan( VMF(1) ) ); case CG_TAN: return FloatAsInt( tan( VMF(1)) ); case CG_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( VMA(1) ); case CG_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( VMA(1) ); case CG_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case CG_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) ); case CG_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) ); case CG_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case CG_REAL_TIME: return Com_RealTime( VMA(1) ); case CG_SNAPVECTOR: Sys_SnapVector( VMA(1) ); return 0; case CG_UPDATEGAMESTATE: return CL_UpdateGameState( VMA(1) ); case CG_CIN_PLAYCINEMATIC: return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); case CG_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case CG_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case CG_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case CG_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case CG_R_REMAP_SHADER: //ToDo: remove this trap return 0; /* case CG_LOADCAMERA: return loadCamera(VMA(1)); case CG_STARTCAMERA: startCamera(args[1]); return 0; case CG_GETCAMERAINFO: return getCameraInfo(args[1], VMA(2), VMA(3)); */ case CG_GET_ENTITY_TOKEN: return re.GetEntityToken( VMA(1), args[2] ); case CG_R_INPVS: return re.inPVS( VMA(1), VMA(2) ); case CG_Q_rand: return Rand_NextUInt32( &cl.db.rand ); case CG_SQL_LOADDB: { char * buffer; int length; length = FS_ReadFile( VMA(1), &buffer ); if ( length > 0 ) { sql_exec( &cl.db, buffer ); FS_FreeFile(buffer); } return 0; } break; case CG_SQL_EXEC: return sql_exec( &cl.db, VMA(1) ); case CG_SQL_PREPARE: return sql_prepare( &cl.db, VMA(1) ) != 0; case CG_SQL_BIND: return sql_bind( &cl.db, args ); case CG_SQL_BINDTEXT: return sql_bindtext( &cl.db, args[1], VMA(2) ); case CG_SQL_BINDINT: return sql_bindint( &cl.db, args[1], args[2] ); case CG_SQL_BINDARGS: { int i,n = Cmd_Argc(); for ( i=1; i<n; i++ ) { if ( !sql_bindtext( &cl.db, i, Cmd_Argv( i ) ) ) return 0; } } return 1; case CG_SQL_STEP: return sql_step( &cl.db ); case CG_SQL_COLUMNCOUNT: return sql_columncount( &cl.db ); case CG_SQL_COLUMNASTEXT: Q_strncpyz( VMA(1), sql_columnastext( &cl.db, args[3] ), args[2] ); break; case CG_SQL_COLUMNASINT: return sql_columnasint( &cl.db, args[1] ); case CG_SQL_COLUMNNAME: Q_strncpyz( VMA(1), sql_columnname( &cl.db, args[3] ), args[2] ); break; case CG_SQL_DONE: return sql_done( &cl.db ); case CG_SQL_COMPILE: return sql_compile( &cl.db, VMA(1) ); case CG_SQL_RUN: { char * buffer = VMA(1); int size = args[2]; int id = args[3]; int i; formatInfo_t * stmt = (formatInfo_t*)cl.db.stmts_byindex[ id ]; if ( stmt ) { sqlData_t params[ 3 ]; const char * r; for ( i=0; i<3; i++ ) { params[ i ].format = INTEGER; params[ i ].payload.integer = args[ 4+i ]; } r = sql_eval( &cl.db, stmt->print, 0, 0, 0, 0, params, 0 ).string; Q_strncpyz( buffer, r, size ); } else { buffer[ 0 ] = '\0'; } } break; default: assert(0); // bk010102 Com_Error( ERR_DROP, "Bad cgame 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", (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: 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_GET_CDKEY: CLUI_GetCDKey( VMA(1), args[2] ); return 0; case UI_SET_CDKEY: CLUI_SetCDKey( VMA(1) ); 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)); default: Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] ); } return 0; }
/* ==================== CL_CgameSystemCalls The cgame module is making a system call ==================== */ intptr_t CL_CgameSystemCalls( intptr_t *args ) { switch ( args[ 0 ] ) { case CG_PRINT: Com_Printf( "%s", ( char * ) VMA( 1 ) ); return 0; case CG_ERROR: Com_Error( ERR_DROP, "%s", ( char * ) VMA( 1 ) ); case CG_MILLISECONDS: return Sys_Milliseconds(); case CG_CVAR_REGISTER: Cvar_Register( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[ 4 ] ); return 0; case CG_CVAR_UPDATE: Cvar_Update( VMA( 1 ) ); return 0; case CG_CVAR_SET: Cvar_Set( VMA( 1 ), VMA( 2 ) ); return 0; case CG_CVAR_VARIABLESTRINGBUFFER: VM_CheckBlock( args[2], args[3], "CVARVSB" ); Cvar_VariableStringBuffer( VMA( 1 ), VMA( 2 ), args[ 3 ] ); return 0; case CG_CVAR_LATCHEDVARIABLESTRINGBUFFER: VM_CheckBlock( args[2], args[3], "CVARLVSB" ); Cvar_LatchedVariableStringBuffer( VMA( 1 ), VMA( 2 ), args[ 3 ] ); return 0; case CG_CVAR_VARIABLEINTEGERVALUE: return Cvar_VariableIntegerValue( VMA( 1 ) ); case CG_ARGC: return Cmd_Argc(); case CG_ARGV: VM_CheckBlock( args[2], args[3], "ARGV" ); Cmd_ArgvBuffer( args[ 1 ], VMA( 2 ), args[ 3 ] ); return 0; case CG_ARGS: VM_CheckBlock( args[1], args[2], "ARGS" ); Cmd_ArgsBuffer( VMA( 1 ), args[ 2 ] ); return 0; case CG_LITERAL_ARGS: // FIXME VM_CheckBlock( args[1], args[2], "LARGS" ); Cmd_LiteralArgsBuffer( VMA( 1 ), args[ 2 ] ); // Cmd_ArgsBuffer(VMA(1), args[2]); return 0; case CG_GETDEMOSTATE: return CL_DemoState(); case CG_GETDEMOPOS: return CL_DemoPos(); case CG_FS_FOPENFILE: return FS_FOpenFileByMode( VMA( 1 ), VMA( 2 ), args[ 3 ] ); case CG_FS_READ: VM_CheckBlock( args[1], args[2], "FSREAD" ); FS_Read2( VMA( 1 ), args[ 2 ], args[ 3 ] ); return 0; case CG_FS_WRITE: VM_CheckBlock( args[1], args[2], "FSWRITE" ); return FS_Write( VMA( 1 ), args[ 2 ], args[ 3 ] ); case CG_FS_FCLOSEFILE: FS_FCloseFile( args[ 1 ] ); return 0; case CG_FS_GETFILELIST: VM_CheckBlock( args[3], args[4], "FSGFL" ); return FS_GetFileList( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[ 4 ] ); case CG_FS_DELETEFILE: return FS_Delete( VMA( 1 ) ); case CG_SENDCONSOLECOMMAND: Cbuf_AddText( VMA( 1 ) ); return 0; case CG_ADDCOMMAND: CL_AddCgameCommand( VMA( 1 ) ); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommand( VMA( 1 ) ); return 0; case CG_COMPLETE_CALLBACK: if ( completer ) { completer( VMA( 1 ) ); } return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand( VMA( 1 ) ); return 0; case CG_UPDATESCREEN: SCR_UpdateScreen(); return 0; case CG_CM_LOADMAP: CL_CM_LoadMap( VMA( 1 ) ); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel( args[ 1 ] ); case CG_CM_TEMPBOXMODEL: return CM_TempBoxModel( VMA( 1 ), VMA( 2 ), qfalse ); case CG_CM_TEMPCAPSULEMODEL: return CM_TempBoxModel( VMA( 1 ), VMA( 2 ), qtrue ); case CG_CM_POINTCONTENTS: return CM_PointContents( VMA( 1 ), args[ 2 ] ); case CG_CM_TRANSFORMEDPOINTCONTENTS: return CM_TransformedPointContents( VMA( 1 ), args[ 2 ], VMA( 3 ), VMA( 4 ) ); case CG_CM_BOXTRACE: CM_BoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[ 6 ], args[ 7 ], TT_AABB ); return 0; case CG_CM_TRANSFORMEDBOXTRACE: CM_TransformedBoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[ 6 ], args[ 7 ], VMA( 8 ), VMA( 9 ), TT_AABB ); return 0; case CG_CM_CAPSULETRACE: CM_BoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[ 6 ], args[ 7 ], TT_CAPSULE ); return 0; case CG_CM_TRANSFORMEDCAPSULETRACE: CM_TransformedBoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[ 6 ], args[ 7 ], VMA( 8 ), VMA( 9 ), TT_CAPSULE ); return 0; case CG_CM_BISPHERETRACE: CM_BiSphereTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ], args[ 7 ] ); return 0; case CG_CM_TRANSFORMEDBISPHERETRACE: CM_TransformedBiSphereTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ], args[ 7 ], VMA( 8 ) ); return 0; case CG_CM_MARKFRAGMENTS: return re.MarkFragments( args[ 1 ], VMA( 2 ), VMA( 3 ), args[ 4 ], VMA( 5 ), args[ 6 ], VMA( 7 ) ); case CG_R_PROJECTDECAL: re.ProjectDecal( args[ 1 ], args[ 2 ], VMA( 3 ), VMA( 4 ), VMA( 5 ), args[ 6 ], args[ 7 ] ); return 0; case CG_R_CLEARDECALS: re.ClearDecals(); return 0; case CG_S_STARTSOUND: S_StartSound( VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ] ); return 0; case CG_S_STARTSOUNDEX: S_StartSoundEx( VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ] ); return 0; case CG_S_STARTLOCALSOUND: S_StartLocalSound( args[ 1 ], args[ 2 ] ); return 0; case CG_S_CLEARLOOPINGSOUNDS: S_ClearLoopingSounds( args[ 1 ] ); return 0; case CG_S_CLEARSOUNDS: /*if(args[1] == 0) { S_ClearSounds(qtrue, qfalse); } else if(args[1] == 1) { S_ClearSounds(qtrue, qtrue); }*/ return 0; case CG_S_ADDLOOPINGSOUND: S_AddLoopingSound( args[ 1 ], VMA( 2 ), VMA( 3 ), args[ 4 ] ); return 0; case CG_S_ADDREALLOOPINGSOUND: S_AddRealLoopingSound( args[ 1 ], VMA( 2 ), VMA( 3 ), args[ 4 ] ); return 0; case CG_S_STOPLOOPINGSOUND: S_StopLoopingSound( args[ 1 ] ); return 0; case CG_S_STOPSTREAMINGSOUND: // FIXME //S_StopEntStreamingSound(args[1]); return 0; case CG_S_UPDATEENTITYPOSITION: S_UpdateEntityPosition( args[ 1 ], VMA( 2 ) ); return 0; case CG_S_GETVOICEAMPLITUDE: return S_GetVoiceAmplitude( args[ 1 ] ); case CG_S_GETSOUNDLENGTH: return S_GetSoundLength( args[ 1 ] ); // ydnar: for looped sound starts case CG_S_GETCURRENTSOUNDTIME: return S_GetCurrentSoundTime(); case CG_S_RESPATIALIZE: S_Respatialize( args[ 1 ], VMA( 2 ), VMA( 3 ), args[ 4 ] ); return 0; case CG_S_REGISTERSOUND: #ifdef DOOMSOUND ///// (SA) DOOMSOUND return S_RegisterSound( VMA( 1 ) ); #else return S_RegisterSound( VMA( 1 ), args[ 2 ] ); #endif ///// (SA) DOOMSOUND case CG_S_STARTBACKGROUNDTRACK: //S_StartBackgroundTrack(VMA(1), VMA(2), args[3]); //----(SA) added fadeup time S_StartBackgroundTrack( VMA( 1 ), VMA( 2 ) ); return 0; case CG_S_FADESTREAMINGSOUND: // FIXME //S_FadeStreamingSound(VMF(1), args[2], args[3]); //----(SA) added music/all-streaming options return 0; case CG_S_STARTSTREAMINGSOUND: // FIXME //return S_StartStreamingSound(VMA(1), VMA(2), args[3], args[4], args[5]); return 0; case CG_R_LOADWORLDMAP: re.SetWorldVisData( CM_ClusterPVS( -1 ) ); re.LoadWorld( VMA( 1 ) ); return 0; case CG_R_REGISTERMODEL: return re.RegisterModel( VMA( 1 ) ); case CG_R_REGISTERSKIN: return re.RegisterSkin( VMA( 1 ) ); //----(SA) added case CG_R_GETSKINMODEL: return re.GetSkinModel( args[ 1 ], VMA( 2 ), VMA( 3 ) ); case CG_R_GETMODELSHADER: return re.GetShaderFromModel( args[ 1 ], args[ 2 ], args[ 3 ] ); //----(SA) end case CG_R_REGISTERSHADER: return re.RegisterShader( VMA( 1 ) ); case CG_R_REGISTERFONT: re.RegisterFontVM( VMA( 1 ), VMA( 2 ), args[ 3 ], VMA( 4 ) ); return 0; case CG_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( VMA( 1 ) ); #if defined( USE_REFLIGHT ) case CG_R_REGISTERSHADERLIGHTATTENUATION: return re.RegisterShaderLightAttenuation( VMA( 1 ) ); #endif case CG_R_CLEARSCENE: re.ClearScene(); return 0; case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA( 1 ) ); return 0; #if defined( USE_REFLIGHT ) case CG_R_ADDREFLIGHTSTOSCENE: re.AddRefLightToScene( VMA( 1 ) ); return 0; #endif case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[ 1 ], args[ 2 ], VMA( 3 ) ); return 0; case CG_R_ADDPOLYSTOSCENE: re.AddPolysToScene( args[ 1 ], args[ 2 ], VMA( 3 ), args[ 4 ] ); return 0; case CG_R_ADDPOLYBUFFERTOSCENE: re.AddPolyBufferToScene( VMA( 1 ) ); return 0; case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), args[ 7 ], args[ 8 ] ); return 0; case CG_R_ADDADDITIVELIGHTTOSCENE: re.AddAdditiveLightToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ) ); return 0; case CG_FS_SEEK: return FS_Seek( args[ 1 ], args[ 2 ], args[ 3 ] ); case CG_R_ADDCORONATOSCENE: re.AddCoronaToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ], args[ 7 ] ); return 0; case CG_R_SETFOG: re.SetFog( args[ 1 ], args[ 2 ], args[ 3 ], VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ) ); return 0; case CG_R_SETGLOBALFOG: re.SetGlobalFog( args[ 1 ], args[ 2 ], VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ) ); return 0; case CG_R_RENDERSCENE: re.RenderScene( VMA( 1 ) ); return 0; case CG_R_SAVEVIEWPARMS: re.SaveViewParms(); return 0; case CG_R_RESTOREVIEWPARMS: re.RestoreViewParms(); return 0; case CG_R_SETCOLOR: re.SetColor( VMA( 1 ) ); return 0; // Tremulous case CG_R_SETCLIPREGION: re.SetClipRegion( VMA( 1 ) ); return 0; case CG_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 CG_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 CG_R_DRAWSTRETCHPIC_GRADIENT: re.DrawStretchPicGradient( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[ 9 ], VMA( 10 ), args[ 11 ] ); return 0; case CG_R_DRAW2DPOLYS: re.Add2dPolys( VMA( 1 ), args[ 2 ], args[ 3 ] ); return 0; case CG_R_MODELBOUNDS: re.ModelBounds( args[ 1 ], VMA( 2 ), VMA( 3 ) ); return 0; case CG_R_LERPTAG: return re.LerpTag( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[ 4 ] ); case CG_GETGLCONFIG: CL_GetGlconfig( VMA( 1 ) ); return 0; case CG_GETGAMESTATE: CL_GetGameState( VMA( 1 ) ); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber( VMA( 1 ), VMA( 2 ) ); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot( args[ 1 ], VMA( 2 ) ); case CG_GETSERVERCOMMAND: return CL_GetServerCommand( args[ 1 ] ); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd( args[ 1 ], VMA( 2 ) ); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue( args[ 1 ], args[ 2 ], VMF( 3 ), args[ 4 ] ); return 0; case CG_SETCLIENTLERPORIGIN: CL_SetClientLerpOrigin( VMF( 1 ), VMF( 2 ), VMF( 3 ) ); return 0; case CG_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case CG_KEY_ISDOWN: return Key_IsDown( args[ 1 ] ); case CG_KEY_GETCATCHER: return Key_GetCatcher(); case CG_KEY_SETCATCHER: Key_SetCatcher( args[ 1 ] ); return 0; case CG_KEY_GETKEY: return Key_GetKey( VMA( 1 ) ); case CG_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case CG_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( args[ 1 ] ); return 0; case CG_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case CG_REAL_TIME: return Com_RealTime( VMA( 1 ) ); case CG_SNAPVECTOR: Q_SnapVector( VMA( 1 ) ); return 0; case CG_CIN_PLAYCINEMATIC: return CIN_PlayCinematic( VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ], args[ 6 ] ); case CG_CIN_STOPCINEMATIC: return CIN_StopCinematic( args[ 1 ] ); case CG_CIN_RUNCINEMATIC: return CIN_RunCinematic( args[ 1 ] ); case CG_CIN_DRAWCINEMATIC: CIN_DrawCinematic( args[ 1 ] ); return 0; case CG_CIN_SETEXTENTS: CIN_SetExtents( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] ); return 0; case CG_R_REMAP_SHADER: re.RemapShader( VMA( 1 ), VMA( 2 ), VMA( 3 ) ); return 0; case CG_GET_ENTITY_TOKEN: VM_CheckBlock( args[1], args[2], "GETET" ); return re.GetEntityToken( VMA( 1 ), args[ 2 ] ); case CG_INGAME_POPUP: if ( cls.state == CA_ACTIVE && !clc.demoplaying ) { if ( uivm ) { // Gordon: can be called as the system is shutting down VM_Call( uivm, UI_SET_ACTIVE_MENU, args[ 1 ] ); } } return 0; case CG_INGAME_CLOSEPOPUP: return 0; case CG_KEY_GETBINDINGBUF: VM_CheckBlock( args[2], args[3], "KEYGBB" ); Key_GetBindingBuf( args[ 1 ], VMA( 2 ), args[ 3 ] ); return 0; case CG_KEY_SETBINDING: Key_SetBinding( args[ 1 ], VMA( 2 ) ); return 0; case CG_PARSE_ADD_GLOBAL_DEFINE: return Parse_AddGlobalDefine( VMA( 1 ) ); case CG_PARSE_LOAD_SOURCE: return Parse_LoadSourceHandle( VMA( 1 ) ); case CG_PARSE_FREE_SOURCE: return Parse_FreeSourceHandle( args[ 1 ] ); case CG_PARSE_READ_TOKEN: return Parse_ReadTokenHandle( args[ 1 ], VMA( 2 ) ); case CG_PARSE_SOURCE_FILE_AND_LINE: return Parse_SourceFileAndLine( args[ 1 ], VMA( 2 ), VMA( 3 ) ); case CG_KEY_KEYNUMTOSTRINGBUF: VM_CheckBlock( args[2], args[3], "KEYNTSB" ); Key_KeynumToStringBuf( args[ 1 ], VMA( 2 ), args[ 3 ] ); return 0; case CG_KEY_BINDINGTOKEYS: Key_GetBindingByString( VMA( 1 ), VMA( 2 ), VMA( 3 ) ); return 0; case CG_S_FADEALLSOUNDS: // FIXME //S_FadeAllSounds(VMF(1), args[2], args[3]); return 0; case CG_R_INPVS: return re.inPVS( VMA( 1 ), VMA( 2 ) ); case CG_GETHUNKDATA: Com_GetHunkInfo( VMA( 1 ), VMA( 2 ) ); return 0; //bani - dynamic shaders case CG_R_LOADDYNAMICSHADER: return re.LoadDynamicShader( VMA( 1 ), VMA( 2 ) ); // fretn - render to texture case CG_R_RENDERTOTEXTURE: re.RenderToTexture( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] ); return 0; //bani case CG_R_GETTEXTUREID: return re.GetTextureId( VMA( 1 ) ); //bani - flush gl rendering buffers case CG_R_FINISH: re.Finish(); return 0; case CG_GETDEMONAME: VM_CheckBlock( args[1], args[2], "GETDM" ); CL_DemoName( VMA( 1 ), args[ 2 ] ); return 0; case CG_R_LIGHTFORPOINT: return re.LightForPoint( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ) ); case CG_S_SOUNDDURATION: return S_SoundDuration( args[ 1 ] ); #if defined( USE_REFENTITY_ANIMATIONSYSTEM ) case CG_R_REGISTERANIMATION: return re.RegisterAnimation( VMA( 1 ) ); case CG_R_CHECKSKELETON: return re.CheckSkeleton( VMA( 1 ), args[ 2 ], args[ 3 ] ); case CG_R_BUILDSKELETON: return re.BuildSkeleton( VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], VMF( 5 ), args[ 6 ] ); case CG_R_BLENDSKELETON: return re.BlendSkeleton( VMA( 1 ), VMA( 2 ), VMF( 3 ) ); case CG_R_BONEINDEX: return re.BoneIndex( args[ 1 ], VMA( 2 ) ); case CG_R_ANIMNUMFRAMES: return re.AnimNumFrames( args[ 1 ] ); case CG_R_ANIMFRAMERATE: return re.AnimFrameRate( args[ 1 ] ); #endif case CG_REGISTER_BUTTON_COMMANDS: CL_RegisterButtonCommands( VMA( 1 ) ); return 0; case CG_GETCLIPBOARDDATA: VM_CheckBlock( args[1], args[2], "GETCLIP" ); if ( cl_allowPaste->integer ) { CL_GetClipboardData( VMA(1), args[2], args[3] ); } else { ( (char *) VMA( 1 ) )[0] = '\0'; } return 0; case CG_QUOTESTRING: Cmd_QuoteStringBuffer( VMA( 1 ), VMA( 2 ), args[ 3 ] ); return 0; case CG_GETTEXT: strncpy( VMA(1), __(VMA(2)), args[3] ); return 0; case CG_PGETTEXT: strncpy( VMA( 1 ), C__( VMA( 2 ), VMA( 3 ) ), args[ 4 ] ); return 0; case CG_R_GLYPH: re.GlyphVM( args[1], VMA(2), VMA(3) ); return 0; case CG_R_GLYPHCHAR: re.GlyphCharVM( args[1], args[2], VMA(3) ); return 0; case CG_R_UREGISTERFONT: re.UnregisterFontVM( args[1] ); return 0; default: Com_Error( ERR_DROP, "Bad cgame system trap: %ld", ( long int ) args[ 0 ] ); } return 0; }
/* ==================== CL_CgameSystemCalls The cgame module is making a system call ==================== */ intptr_t CL_CgameSystemCalls(intptr_t * args) { switch (args[0]) { case CG_PRINT: Com_Printf("%s", (const char *)VMA(1)); return 0; case CG_ERROR: Com_Error(ERR_DROP, "%s", (const char *)VMA(1)); return 0; case CG_MILLISECONDS: return Sys_Milliseconds(); case CG_CVAR_REGISTER: Cvar_Register(VMA(1), VMA(2), VMA(3), args[4]); return 0; case CG_CVAR_UPDATE: Cvar_Update(VMA(1)); return 0; case CG_CVAR_SET: Cvar_Set(VMA(1), VMA(2)); return 0; case CG_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer(VMA(1), VMA(2), args[3]); return 0; case CG_ARGC: return Cmd_Argc(); case CG_ARGV: Cmd_ArgvBuffer(args[1], VMA(2), args[3]); return 0; case CG_ARGS: Cmd_ArgsBuffer(VMA(1), args[2]); return 0; case CG_FS_FOPENFILE: return FS_FOpenFileByMode(VMA(1), VMA(2), args[3]); case CG_FS_READ: FS_Read2(VMA(1), args[2], args[3]); return 0; case CG_FS_WRITE: FS_Write(VMA(1), args[2], args[3]); return 0; case CG_FS_FCLOSEFILE: FS_FCloseFile(args[1]); return 0; case CG_FS_SEEK: return FS_Seek(args[1], args[2], args[3]); case CG_FS_GETFILELIST: return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]); case CG_SENDCONSOLECOMMAND: Cbuf_AddText(VMA(1)); return 0; case CG_ADDCOMMAND: CL_AddCgameCommand(VMA(1)); return 0; case CG_REMOVECOMMAND: Cmd_RemoveCommand(VMA(1)); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand(VMA(1), qfalse); return 0; case CG_UPDATESCREEN: // this is used during lengthy level loading, so pump message loop // We can't call Com_EventLoop here, a restart will crash and this _does_ happen // if there is a map change while we are downloading at pk3. ZOID SCR_UpdateScreen(); return 0; case CG_CM_LOADMAP: CL_CM_LoadMap(VMA(1)); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel(args[1]); case CG_CM_TEMPBOXMODEL: return CM_TempBoxModel(VMA(1), VMA(2), /*int capsule */ qfalse); case CG_CM_TEMPCAPSULEMODEL: return CM_TempBoxModel(VMA(1), VMA(2), /*int capsule */ qtrue); case CG_CM_POINTCONTENTS: return CM_PointContents(VMA(1), args[2]); case CG_CM_TRANSFORMEDPOINTCONTENTS: return CM_TransformedPointContents(VMA(1), args[2], VMA(3), VMA(4)); case CG_CM_BOXTRACE: CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], TT_AABB); return 0; case CG_CM_CAPSULETRACE: CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], TT_CAPSULE); return 0; case CG_CM_TRANSFORMEDBOXTRACE: CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), TT_AABB); return 0; case CG_CM_TRANSFORMEDCAPSULETRACE: CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), TT_CAPSULE); return 0; case CG_CM_BISPHERETRACE: CM_BiSphereTrace(VMA(1), VMA(2), VMA(3), VMF(4), VMF(5), args[6], args[7]); return 0; case CG_CM_TRANSFORMEDBISPHERETRACE: CM_TransformedBiSphereTrace(VMA(1), VMA(2), VMA(3), VMF(4), VMF(5), args[6], args[7], VMA(8)); return 0; case CG_CM_MARKFRAGMENTS: return re.MarkFragments(args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7)); case CG_S_STARTSOUND: S_StartSound(VMA(1), args[2], args[3], args[4]); return 0; case CG_S_STARTLOCALSOUND: S_StartLocalSound(args[1], args[2]); return 0; case CG_S_CLEARLOOPINGSOUNDS: S_ClearLoopingSounds(args[1]); return 0; case CG_S_ADDLOOPINGSOUND: S_AddLoopingSound(args[1], VMA(2), VMA(3), args[4]); return 0; case CG_S_ADDREALLOOPINGSOUND: S_AddRealLoopingSound(args[1], VMA(2), VMA(3), args[4]); return 0; case CG_S_STOPLOOPINGSOUND: S_StopLoopingSound(args[1]); return 0; case CG_S_UPDATEENTITYPOSITION: S_UpdateEntityPosition(args[1], VMA(2)); return 0; case CG_S_RESPATIALIZE: S_Respatialize(args[1], VMA(2), VMA(3), args[4]); return 0; case CG_S_REGISTERSOUND: return S_RegisterSound(VMA(1)); case CG_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack(VMA(1), VMA(2)); return 0; case CG_R_LOADWORLDMAP: re.LoadWorld(VMA(1)); return 0; case CG_R_REGISTERMODEL: return re.RegisterModel(VMA(1)); case CG_R_REGISTERANIMATION: return re.RegisterAnimation(VMA(1)); case CG_R_REGISTERSKIN: return re.RegisterSkin(VMA(1)); case CG_R_REGISTERSHADER: return re.RegisterShader(VMA(1)); case CG_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip(VMA(1)); case CG_R_REGISTERSHADERLIGHTATTENUATION: return re.RegisterShaderLightAttenuation(VMA(1)); case CG_R_REGISTERFONT: re.RegisterFont(VMA(1), args[2], VMA(3)); case CG_R_CLEARSCENE: re.ClearScene(); return 0; case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene(VMA(1)); return 0; case CG_R_ADDREFLIGHTSTOSCENE: re.AddRefLightToScene(VMA(1)); return 0; case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene(args[1], args[2], VMA(3), 1); return 0; case CG_R_ADDPOLYSTOSCENE: re.AddPolyToScene(args[1], args[2], VMA(3), args[4]); return 0; case CG_R_LIGHTFORPOINT: return re.LightForPoint(VMA(1), VMA(2), VMA(3), VMA(4)); case CG_R_ADDLIGHTTOSCENE: re.AddLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5)); return 0; case CG_R_RENDERSCENE: re.RenderScene(VMA(1)); return 0; case CG_R_SETCOLOR: re.SetColor(VMA(1)); return 0; case CG_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 CG_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 CG_R_MODELBOUNDS: re.ModelBounds(args[1], VMA(2), VMA(3)); return 0; case CG_R_LERPTAG: return re.LerpTag(VMA(1), args[2], args[3], args[4], VMF(5), VMA(6)); case CG_R_CHECKSKELETON: return re.CheckSkeleton(VMA(1), args[2], args[3]); case CG_R_BUILDSKELETON: return re.BuildSkeleton(VMA(1), args[2], args[3], args[4], VMF(5), args[6]); case CG_R_BLENDSKELETON: return re.BlendSkeleton(VMA(1), VMA(2), VMF(3)); case CG_R_BONEINDEX: return re.BoneIndex(args[1], VMA(2)); case CG_R_ANIMNUMFRAMES: return re.AnimNumFrames(args[1]); case CG_R_ANIMFRAMERATE: return re.AnimFrameRate(args[1]); case CG_GETGLCONFIG: CL_GetGlconfig(VMA(1)); return 0; case CG_GETGAMESTATE: CL_GetGameState(VMA(1)); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber(VMA(1), VMA(2)); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot(args[1], VMA(2)); case CG_GETSERVERCOMMAND: return CL_GetServerCommand(args[1]); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd(args[1], VMA(2)); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue(args[1], VMF(2)); return 0; case CG_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case CG_KEY_ISDOWN: return Key_IsDown(args[1]); case CG_KEY_GETCATCHER: return Key_GetCatcher(); case CG_KEY_SETCATCHER: // Don't allow the cgame module to close the console Key_SetCatcher(args[1] | (Key_GetCatcher() & KEYCATCH_CONSOLE)); return 0; case CG_KEY_GETKEY: return Key_GetKey(VMA(1)); case CG_GETDEMOSTATE: return CL_DemoState(); case CG_GETDEMOPOS: return CL_DemoPos(); case CG_GETDEMONAME: CL_DemoName(VMA(1), args[2]); return 0; case CG_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf(args[1], VMA(2), args[3]); return 0; case CG_KEY_GETBINDINGBUF: Key_GetBindingBuf(args[1], VMA(2), args[3]); return 0; case CG_KEY_SETBINDING: Key_SetBinding(args[1], VMA(2)); return 0; case CG_PC_ADD_GLOBAL_DEFINE: return Parse_AddGlobalDefine(VMA(1)); case CG_PC_LOAD_SOURCE: return Parse_LoadSourceHandle(VMA(1)); case CG_PC_FREE_SOURCE: return Parse_FreeSourceHandle(args[1]); case CG_PC_READ_TOKEN: return Parse_ReadTokenHandle(args[1], VMA(2)); case CG_PC_SOURCE_FILE_AND_LINE: return Parse_SourceFileAndLine(args[1], VMA(2), VMA(3)); case CG_MEMSET: Com_Memset(VMA(1), args[2], args[3]); return 0; case CG_MEMCPY: Com_Memcpy(VMA(1), VMA(2), args[3]); return 0; case CG_STRNCPY: strncpy(VMA(1), VMA(2), args[3]); return args[1]; case CG_SIN: return FloatAsInt(sin(VMF(1))); case CG_COS: return FloatAsInt(cos(VMF(1))); case CG_ATAN2: return FloatAsInt(atan2(VMF(1), VMF(2))); case CG_SQRT: return FloatAsInt(sqrt(VMF(1))); case CG_FLOOR: return FloatAsInt(floor(VMF(1))); case CG_CEIL: return FloatAsInt(ceil(VMF(1))); case CG_ACOS: return FloatAsInt(Q_acos(VMF(1))); case CG_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case CG_REAL_TIME: return Com_RealTime(VMA(1)); case CG_CIN_PLAYCINEMATIC: return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); case CG_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case CG_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case CG_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case CG_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case CG_R_REMAP_SHADER: re.RemapShader(VMA(1), VMA(2), VMA(3)); return 0; /* case CG_LOADCAMERA: return loadCamera(VMA(1)); case CG_STARTCAMERA: startCamera(args[1]); return 0; case CG_GETCAMERAINFO: return getCameraInfo(args[1], VMA(2), VMA(3)); */ case CG_GET_ENTITY_TOKEN: return re.GetEntityToken(VMA(1), args[2]); case CG_R_INPVS: return re.inPVS(VMA(1), VMA(2)); default: assert(0); Com_Error(ERR_DROP, "Bad cgame system trap: %ld", (long int)args[0]); } return 0; }
void UI_DisplayContext::stopBackgroundTrack() { S_StopBackgroundTrack(); }