예제 #1
0
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));
		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_SetSafe(VMA(1), VMA(2));
		return 0;
	case CG_CVAR_VARIABLESTRINGBUFFER:
		Cvar_VariableStringBuffer(VMA(1), VMA(2), args[3]);
		return 0;
	case CG_CVAR_LATCHEDVARIABLESTRINGBUFFER:
		Cvar_LatchedVariableStringBuffer(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_FS_GETFILELIST:
		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_RemoveCommandSafe(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], /*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_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], args[5]);
		return 0;
	case CG_S_STARTSOUNDEX:
		S_StartSoundEx(VMA(1), args[2], args[3], args[4], args[5], args[6]);
		return 0;
	case CG_S_STARTLOCALSOUND:
		S_StartLocalSound(args[1], args[2], args[3]);
		return 0;
	case CG_S_CLEARLOOPINGSOUNDS:
		S_ClearLoopingSounds();
		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:
		// FIXME handling of looping sounds changed
		S_AddLoopingSound(VMA(1), VMA(2), args[3], args[4], args[5], args[6]);
		return 0;
	case CG_S_ADDREALLOOPINGSOUND:
		S_AddRealLoopingSound(VMA(1), VMA(2), args[3], args[4], args[5], args[6]);
		return 0;
	case CG_S_STOPSTREAMINGSOUND:
		S_StopEntStreamingSound(args[1]);
		return 0;
	case CG_S_UPDATEENTITYPOSITION:
		S_UpdateEntityPosition(args[1], VMA(2));
		return 0;
	// talking animations
	case CG_S_GETVOICEAMPLITUDE:
		return S_GetVoiceAmplitude(args[1]);

	case CG_S_GETSOUNDLENGTH:
		return S_GetSoundLength(args[1]);

	// 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:
		return S_RegisterSound(VMA(1), args[2]);
	case CG_S_STARTBACKGROUNDTRACK:
		S_StartBackgroundTrack(VMA(1), VMA(2), args[3]);    // added fadeup time
		return 0;
	case CG_S_FADESTREAMINGSOUND:
		S_FadeStreamingSound(VMF(1), args[2], args[3]);     // added music/all-streaming options
		return 0;
	case CG_S_STARTSTREAMINGSOUND:
		return S_StartStreamingSound(VMA(1), VMA(2), args[3], args[4], args[5]);
	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));
	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]);
	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], VMA(3));
		return 0;
	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;
	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_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;
	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:
		// 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_KEY_GETOVERSTRIKEMODE:
		return Key_GetOverstrikeMode();
	case CG_KEY_SETOVERSTRIKEMODE:
		Key_SetOverstrikeMode(args[1]);
		return 0;

	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_PC_UNREAD_TOKEN:
		botlib_export->PC_UnreadLastTokenHandle(args[1]);
		return 0;

	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_TESTPRINTINT:
		Com_Printf("%s%li\n", (char *)VMA(1), (long)args[2]);
		return 0;
	case CG_TESTPRINTFLOAT:
		Com_Printf("%s%f\n", (char *)VMA(1), VMF(2));
		return 0;

	case CG_GET_ENTITY_TOKEN:
		return re.GetEntityToken(VMA(1), args[2]);

	case CG_INGAME_POPUP:
		if (cls.state == CA_ACTIVE && !clc.demoplaying)
		{
			if (uivm)     // can be called as the system is shutting down
			{
				VM_Call(uivm, UI_SET_ACTIVE_MENU, args[1]);
			}
		}
		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_KEY_KEYNUMTOSTRINGBUF:
		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_TRANSLATE_STRING:
		CL_TranslateString(VMA(1), VMA(2));
		return 0;

	case CG_S_FADEALLSOUNDS:
		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;

	// binary channel
	case CG_SENDMESSAGE:
		CL_SendBinaryMessage(VMA(1), args[2]);
		return 0;
	case CG_MESSAGESTATUS:
		return CL_BinaryMessageStatus();
	case CG_R_LOADDYNAMICSHADER:
		return re.LoadDynamicShader(VMA(1), VMA(2));
	case CG_R_RENDERTOTEXTURE:
		re.RenderToTexture(args[1], args[2], args[3], args[4], args[5]);
		return 0;
	case CG_R_GETTEXTUREID:
		return re.GetTextureId(VMA(1));
	// flush gl rendering buffers
	case CG_R_FINISH:
		re.Finish();
		return 0;

	case CG_LOADCAMERA:
	case CG_STARTCAMERA:
	case CG_STOPCAMERA:
	case CG_GETCAMERAINFO:
	case CG_PUMPEVENTLOOP:
	case CG_INGAME_CLOSEPOPUP:
	case CG_R_LIGHTFORPOINT: // re-added to avoid a crash when called - still in enum of cgameImport_t

		// This shows (developer 1) when the vanilla mod code is loaded or mods using obsolete system calls - see cases.
		Com_DPrintf("Obsolete cgame system trap: %ld\n", (long int) args[0]);
		return 0;

	default:
		Com_Error(ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0]);
		break;
	}
	return 0;
}
예제 #2
0
파일: cgame.cpp 프로젝트: janisl/jlquake
//	The cgame module is making a system call
qintptr CLWS_CgameSystemCalls( qintptr* args ) {
	switch ( args[ 0 ] ) {
	case WSCG_PRINT:
		common->Printf( "%s", ( char* )VMA( 1 ) );
		return 0;
	case WSCG_ERROR:
		common->Error( "%s", ( char* )VMA( 1 ) );
		return 0;
	case WSCG_MILLISECONDS:
		return Sys_Milliseconds();
	case WSCG_CVAR_REGISTER:
		Cvar_Register( ( vmCvar_t* )VMA( 1 ), ( char* )VMA( 2 ), ( char* )VMA( 3 ), args[ 4 ] );
		return 0;
	case WSCG_CVAR_UPDATE:
		Cvar_Update( ( vmCvar_t* )VMA( 1 ) );
		return 0;
	case WSCG_CVAR_SET:
		Cvar_Set( ( char* )VMA( 1 ), ( char* )VMA( 2 ) );
		return 0;
	case WSCG_CVAR_VARIABLESTRINGBUFFER:
		Cvar_VariableStringBuffer( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] );
		return 0;
	case WSCG_ARGC:
		return Cmd_Argc();
	case WSCG_ARGV:
		Cmd_ArgvBuffer( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] );
		return 0;
	case WSCG_ARGS:
		Cmd_ArgsBuffer( ( char* )VMA( 1 ), args[ 2 ] );
		return 0;
	case WSCG_FS_FOPENFILE:
		return FS_FOpenFileByMode( ( char* )VMA( 1 ), ( fileHandle_t* )VMA( 2 ), ( fsMode_t )args[ 3 ] );
	case WSCG_FS_READ:
		FS_Read( VMA( 1 ), args[ 2 ], args[ 3 ] );
		return 0;
	case WSCG_FS_WRITE:
		return FS_Write( VMA( 1 ), args[ 2 ], args[ 3 ] );
	case WSCG_FS_FCLOSEFILE:
		FS_FCloseFile( args[ 1 ] );
		return 0;
	case WSCG_SENDCONSOLECOMMAND:
		Cbuf_AddText( ( char* )VMA( 1 ) );
		return 0;
	case WSCG_ADDCOMMAND:
		CLT3_AddCgameCommand( ( char* )VMA( 1 ) );
		return 0;
	case WSCG_REMOVECOMMAND:
		Cmd_RemoveCommand( ( char* )VMA( 1 ) );
		return 0;
	case WSCG_SENDCLIENTCOMMAND:
		CL_AddReliableCommand( ( char* )VMA( 1 ) );
		return 0;
	case WSCG_UPDATESCREEN:
		SCR_UpdateScreen();
		return 0;
	case WSCG_CM_LOADMAP:
		CLT3_CM_LoadMap( ( char* )VMA( 1 ) );
		return 0;
	case WSCG_CM_NUMINLINEMODELS:
		return CM_NumInlineModels();
	case WSCG_CM_INLINEMODEL:
		return CM_InlineModel( args[ 1 ] );
	case WSCG_CM_TEMPBOXMODEL:
		return CM_TempBoxModel( ( float* )VMA( 1 ), ( float* )VMA( 2 ), false );
	case WSCG_CM_TEMPCAPSULEMODEL:
		return CM_TempBoxModel( ( float* )VMA( 1 ), ( float* )VMA( 2 ), true );
	case WSCG_CM_POINTCONTENTS:
		return CM_PointContentsQ3( ( float* )VMA( 1 ), args[ 2 ] );
	case WSCG_CM_TRANSFORMEDPOINTCONTENTS:
		return CM_TransformedPointContentsQ3( ( float* )VMA( 1 ), args[ 2 ], ( float* )VMA( 3 ), ( float* )VMA( 4 ) );
	case WSCG_CM_BOXTRACE:
		CM_BoxTraceQ3( ( q3trace_t* )VMA( 1 ), ( float* )VMA( 2 ), ( float* )VMA( 3 ), ( float* )VMA( 4 ), ( float* )VMA( 5 ), args[ 6 ], args[ 7 ], false );
		return 0;
	case WSCG_CM_TRANSFORMEDBOXTRACE:
		CM_TransformedBoxTraceQ3( ( q3trace_t* )VMA( 1 ), ( float* )VMA( 2 ), ( float* )VMA( 3 ), ( float* )VMA( 4 ), ( float* )VMA( 5 ), args[ 6 ], args[ 7 ], ( float* )VMA( 8 ), ( float* )VMA( 9 ), false );
		return 0;
	case WSCG_CM_CAPSULETRACE:
		CM_BoxTraceQ3( ( q3trace_t* )VMA( 1 ), ( float* )VMA( 2 ), ( float* )VMA( 3 ), ( float* )VMA( 4 ), ( float* )VMA( 5 ), args[ 6 ], args[ 7 ], true );
		return 0;
	case WSCG_CM_TRANSFORMEDCAPSULETRACE:
		CM_TransformedBoxTraceQ3( ( q3trace_t* )VMA( 1 ), ( float* )VMA( 2 ), ( float* )VMA( 3 ), ( float* )VMA( 4 ), ( float* )VMA( 5 ), args[ 6 ], args[ 7 ], ( float* )VMA( 8 ), ( float* )VMA( 9 ), true );
		return 0;
	case WSCG_CM_MARKFRAGMENTS:
		return R_MarkFragmentsWolf( args[ 1 ], ( const vec3_t* )VMA( 2 ), ( float* )VMA( 3 ), args[ 4 ], ( float* )VMA( 5 ), args[ 6 ], ( markFragment_t* )VMA( 7 ) );
	case WSCG_S_STARTSOUND:
		S_StartSound( ( float* )VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], 0.5 );
		return 0;
	case WSCG_S_STARTSOUNDEX:
		S_StartSoundEx( ( float* )VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ], 127 );
		return 0;
	case WSCG_S_STARTLOCALSOUND:
		S_StartLocalSound( args[ 1 ], args[ 2 ], 127 );
		return 0;
	case WSCG_S_CLEARLOOPINGSOUNDS:
		CLWS_ClearLoopingSounds( args[ 1 ] );
		return 0;
	case WSCG_S_ADDLOOPINGSOUND:
		// FIXME MrE: handling of looping sounds changed
		S_AddLoopingSound( args[ 1 ], ( float* )VMA( 2 ), ( float* )VMA( 3 ), args[ 4 ], args[ 5 ], args[ 6 ], 0 );
		return 0;
	case WSCG_S_STOPSTREAMINGSOUND:
		S_StopEntStreamingSound( args[ 1 ] );
		return 0;
	case WSCG_S_STOPLOOPINGSOUND:
		// RF, not functional anymore, since we reverted to old looping code
		return 0;
	case WSCG_S_UPDATEENTITYPOSITION:
		S_UpdateEntityPosition( args[ 1 ], ( float* )VMA( 2 ) );
		return 0;
	case WSCG_S_GETVOICEAMPLITUDE:
		return S_GetVoiceAmplitude( args[ 1 ] );
	case WSCG_S_RESPATIALIZE:
		S_Respatialize( args[ 1 ], ( float* )VMA( 2 ), ( vec3_t* )VMA( 3 ), args[ 4 ] );
		return 0;
	case WSCG_S_REGISTERSOUND:
		return S_RegisterSound( ( char* )VMA( 1 ) );
	case WSCG_S_STARTBACKGROUNDTRACK:
		S_StartBackgroundTrack( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] );			//----(SA)	added fadeup time
		return 0;
	case WSCG_S_FADESTREAMINGSOUND:
		S_FadeStreamingSound( VMF( 1 ), args[ 2 ], args[ 3 ] );		//----(SA)	added music/all-streaming options
		return 0;
	case WSCG_S_STARTSTREAMINGSOUND:
		S_StartStreamingSound( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ], args[ 4 ], args[ 5 ] );
		return 0;
	case WSCG_S_FADEALLSOUNDS:
		S_FadeAllSounds( VMF( 1 ), args[ 2 ], false );			//----(SA)	added
		return 0;
	case WSCG_R_LOADWORLDMAP:
		R_LoadWorld( ( char* )VMA( 1 ) );
		return 0;
	case WSCG_R_REGISTERMODEL:
		return R_RegisterModel( ( char* )VMA( 1 ) );
	case WSCG_R_REGISTERSKIN:
		return R_RegisterSkin( ( char* )VMA( 1 ) );
	case WSCG_R_GETSKINMODEL:
		return R_GetSkinModel( args[ 1 ], ( char* )VMA( 2 ), ( char* )VMA( 3 ) );
	case WSCG_R_GETMODELSHADER:
		return R_GetShaderFromModel( args[ 1 ], args[ 2 ], args[ 3 ] );
	case WSCG_R_REGISTERSHADER:
		return R_RegisterShader( ( char* )VMA( 1 ) );
	case WSCG_R_REGISTERFONT:
		R_RegisterFont( ( char* )VMA( 1 ), args[ 2 ], ( fontInfo_t* )VMA( 3 ) );
	case WSCG_R_REGISTERSHADERNOMIP:
		return R_RegisterShaderNoMip( ( char* )VMA( 1 ) );
	case WSCG_R_CLEARSCENE:
		R_ClearScene();
		return 0;
	case WSCG_R_ADDREFENTITYTOSCENE:
		CLWS_AddRefEntityToScene( ( wsrefEntity_t* )VMA( 1 ) );
		return 0;
	case WSCG_R_ADDPOLYTOSCENE:
		R_AddPolyToScene( args[ 1 ], args[ 2 ], ( polyVert_t* )VMA( 3 ), 1 );
		return 0;
	case WSCG_R_ADDPOLYSTOSCENE:
		R_AddPolyToScene( args[ 1 ], args[ 2 ], ( polyVert_t* )VMA( 3 ), args[ 4 ] );
		return 0;
	case WSCG_RB_ZOMBIEFXADDNEWHIT:
		return 0;
	case WSCG_R_ADDLIGHTTOSCENE:
		R_AddLightToScene( ( float* )VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ] );
		return 0;
	case WSCG_R_ADDCORONATOSCENE:
		R_AddCoronaToScene( ( float* )VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ], args[ 7 ] );
		return 0;
	case WSCG_R_SETFOG:
		R_SetFog( args[ 1 ], args[ 2 ], args[ 3 ], VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ) );
		return 0;
	case WSCG_R_RENDERSCENE:
		CLWS_RenderScene( ( wsrefdef_t* )VMA( 1 ) );
		return 0;
	case WSCG_R_SETCOLOR:
		R_SetColor( ( float* )VMA( 1 ) );
		return 0;
	case WSCG_R_DRAWSTRETCHPIC:
		R_StretchPic( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[ 9 ] );
		return 0;
	case WSCG_R_DRAWSTRETCHPIC_GRADIENT:
		R_StretchPicGradient( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[ 9 ], ( float* )VMA( 10 ), args[ 11 ] );
		return 0;
	case WSCG_R_MODELBOUNDS:
		R_ModelBounds( args[ 1 ], ( float* )VMA( 2 ), ( float* )VMA( 3 ) );
		return 0;
	case WSCG_R_LERPTAG:
		return CLWS_LerpTag( ( orientation_t* )VMA( 1 ), ( wsrefEntity_t* )VMA( 2 ), ( char* )VMA( 3 ), args[ 4 ] );
	case WSCG_GETGLCONFIG:
		CLWS_GetGlconfig( ( wsglconfig_t* )VMA( 1 ) );
		return 0;
	case WSCG_GETGAMESTATE:
		CLWS_GetGameState( ( wsgameState_t* )VMA( 1 ) );
		return 0;
	case WSCG_GETCURRENTSNAPSHOTNUMBER:
		CLWS_GetCurrentSnapshotNumber( ( int* )VMA( 1 ), ( int* )VMA( 2 ) );
		return 0;
	case WSCG_GETSNAPSHOT:
		return CLWS_GetSnapshot( args[ 1 ], ( wssnapshot_t* )VMA( 2 ) );
	case WSCG_GETSERVERCOMMAND:
		return CLT3_GetServerCommand( args[ 1 ] );
	case WSCG_GETCURRENTCMDNUMBER:
		return CLT3_GetCurrentCmdNumber();
	case WSCG_GETUSERCMD:
		return CLWS_GetUserCmd( args[ 1 ], ( wsusercmd_t* )VMA( 2 ) );
	case WSCG_SETUSERCMDVALUE:
		CLWS_SetUserCmdValue( args[ 1 ], args[ 2 ], VMF( 3 ), args[ 4 ] );				//----(SA)	modified	// NERVE - SMF - added fourth arg [cld]
		return 0;
	case WSCG_MEMORY_REMAINING:
		return 0x4000000;
	case WSCG_KEY_ISDOWN:
		return Key_IsDown( args[ 1 ] );
	case WSCG_KEY_GETCATCHER:
		return Key_GetCatcher();
	case WSCG_KEY_SETCATCHER:
		KeyQ3_SetCatcher( args[ 1 ] );
		return 0;
	case WSCG_KEY_GETKEY:
		return Key_GetKey( ( char* )VMA( 1 ) );

	case WSCG_MEMSET:
		return ( qintptr )memset( VMA( 1 ), args[ 2 ], args[ 3 ] );
	case WSCG_MEMCPY:
		return ( qintptr )memcpy( VMA( 1 ), VMA( 2 ), args[ 3 ] );
	case WSCG_STRNCPY:
		String::NCpy( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] );
		return args[ 1 ];
	case WSCG_SIN:
		return FloatAsInt( sin( VMF( 1 ) ) );
	case WSCG_COS:
		return FloatAsInt( cos( VMF( 1 ) ) );
	case WSCG_ATAN2:
		return FloatAsInt( atan2( VMF( 1 ), VMF( 2 ) ) );
	case WSCG_SQRT:
		return FloatAsInt( sqrt( VMF( 1 ) ) );
	case WSCG_FLOOR:
		return FloatAsInt( floor( VMF( 1 ) ) );
	case WSCG_CEIL:
		return FloatAsInt( ceil( VMF( 1 ) ) );
	case WSCG_ACOS:
		return FloatAsInt( idMath::ACos( VMF( 1 ) ) );

	case WSCG_PC_ADD_GLOBAL_DEFINE:
		return PC_AddGlobalDefine( ( char* )VMA( 1 ) );
	case WSCG_PC_LOAD_SOURCE:
		return PC_LoadSourceHandle( ( char* )VMA( 1 ) );
	case WSCG_PC_FREE_SOURCE:
		return PC_FreeSourceHandle( args[ 1 ] );
	case WSCG_PC_READ_TOKEN:
		return PC_ReadTokenHandleQ3( args[ 1 ], ( q3pc_token_t* )VMA( 2 ) );
	case WSCG_PC_SOURCE_FILE_AND_LINE:
		return PC_SourceFileAndLine( args[ 1 ], ( char* )VMA( 2 ), ( int* )VMA( 3 ) );

	case WSCG_S_STOPBACKGROUNDTRACK:
		S_StopBackgroundTrack();
		return 0;

	case WSCG_REAL_TIME:
		return Com_RealTime( ( qtime_t* )VMA( 1 ) );
	case WSCG_SNAPVECTOR:
		Sys_SnapVector( ( float* )VMA( 1 ) );
		return 0;

	case WSCG_SENDMOVESPEEDSTOGAME:
		SVWS_SendMoveSpeedsToGame( args[ 1 ], ( char* )VMA( 2 ) );
		return 0;

	case WSCG_CIN_PLAYCINEMATIC:
		return CIN_PlayCinematicStretched( ( char* )VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ], args[ 6 ] );
	case WSCG_CIN_STOPCINEMATIC:
		return CIN_StopCinematic( args[ 1 ] );
	case WSCG_CIN_RUNCINEMATIC:
		return CIN_RunCinematic( args[ 1 ] );
	case WSCG_CIN_DRAWCINEMATIC:
		CIN_DrawCinematic( args[ 1 ] );
		return 0;
	case WSCG_CIN_SETEXTENTS:
		CIN_SetExtents( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] );
		return 0;

	case WSCG_R_REMAP_SHADER:
		R_RemapShader( ( char* )VMA( 1 ), ( char* )VMA( 2 ), ( char* )VMA( 3 ) );
		return 0;

	case WSCG_TESTPRINTINT:
		common->Printf( "%s%i\n", ( char* )VMA( 1 ), static_cast<int>( args[ 2 ] ) );
		return 0;
	case WSCG_TESTPRINTFLOAT:
		common->Printf( "%s%f\n", ( char* )VMA( 1 ), VMF( 2 ) );
		return 0;

	case WSCG_LOADCAMERA:
		return loadCamera( args[ 1 ], ( char* )VMA( 2 ) );
	case WSCG_STARTCAMERA:
		CLWS_StartCamera( args[ 1 ], args[ 2 ] );
		return 0;
	case WSCG_STOPCAMERA:
		CLWS_StopCamera( args[ 1 ] );
		return 0;
	case WSCG_GETCAMERAINFO:
		return getCameraInfo( args[ 1 ], args[ 2 ], ( float* )VMA( 3 ), ( float* )VMA( 4 ), ( float* )VMA( 5 ) );

	case WSCG_GET_ENTITY_TOKEN:
		return R_GetEntityToken( ( char* )VMA( 1 ), args[ 2 ] );

	case WSCG_INGAME_POPUP:
		CLWS_InGamePopup( ( char* )VMA( 1 ) );
		return 0;

	case WSCG_INGAME_CLOSEPOPUP:
		UIT3_KeyEvent( K_ESCAPE, true );
		return 0;

	case WSCG_LIMBOCHAT:
		CLT3_AddToLimboChat( ( char* )VMA( 1 ) );
		return 0;

	case WSCG_GETMODELINFO:
		return SVWS_GetModelInfo( args[ 1 ], ( char* )VMA( 2 ), ( animModelInfo_t** )VMA( 3 ) );

	default:
		common->Error( "Bad cgame system trap: %i", static_cast<int>( args[ 0 ] ) );
	}
	return 0;
}
예제 #3
0
파일: cl_ui.c 프로젝트: etlegacy/etlegacy
/**
 * @brief The ui module is making a system call
 * @param[in] args
 * @return
 */
intptr_t CL_UISystemCalls(intptr_t *args)
{
    switch (args[0])
    {
    case UI_ERROR:
        Com_Error(ERR_DROP, "%s", (char *)VMA(1));
    case UI_PRINT:
        Com_Printf("%s", (char *)VMA(1));
        return 0;
    case UI_MILLISECONDS:
        return Sys_Milliseconds();
    case UI_CVAR_REGISTER:
        Cvar_Register(VMA(1), VMA(2), VMA(3), args[4]);
        return 0;
    case UI_CVAR_UPDATE:
        Cvar_Update(VMA(1));
        return 0;
    case UI_CVAR_SET:
        Cvar_SetSafe(VMA(1), VMA(2));
        return 0;
    case UI_CVAR_VARIABLEVALUE:
        return FloatAsInt(Cvar_VariableValue(VMA(1)));
    case UI_CVAR_VARIABLESTRINGBUFFER:
        Cvar_VariableStringBuffer(VMA(1), VMA(2), args[3]);
        return 0;
    case UI_CVAR_LATCHEDVARIABLESTRINGBUFFER:
        Cvar_LatchedVariableStringBuffer(VMA(1), VMA(2), args[3]);
        return 0;
    case UI_CVAR_SETVALUE:
        Cvar_SetValueSafe(VMA(1), VMF(2));
        return 0;
    case UI_CVAR_RESET:
        Cvar_Reset(VMA(1));
        return 0;
    case UI_CVAR_CREATE:
        Cvar_Register(NULL, VMA(1), VMA(2), args[3]);
        return 0;
    case UI_CVAR_INFOSTRINGBUFFER:
        Cvar_InfoStringBuffer(args[1], VMA(2), args[3]);
        return 0;
    case UI_ARGC:
        return Cmd_Argc();
    case UI_ARGV:
        Cmd_ArgvBuffer(args[1], VMA(2), args[3]);
        return 0;
    case UI_CMD_EXECUTETEXT:
        if (args[1] == EXEC_NOW
                && (!strncmp(VMA(2), "snd_restart", 11)
                    || !strncmp(VMA(2), "vid_restart", 11)
                    || !strncmp(VMA(2), "quit", 5)))
        {
            Com_Printf(S_COLOR_YELLOW "turning EXEC_NOW '%.11s' into EXEC_INSERT\n", (const char *)VMA(2));
            args[1] = EXEC_INSERT;
        }
        Cbuf_ExecuteText(args[1], VMA(2));
        return 0;
    case UI_ADDCOMMAND:
        Cmd_AddCommand(VMA(1));
        return 0;
    case UI_FS_FOPENFILE:
        return FS_FOpenFileByMode(VMA(1), VMA(2), (fsMode_t)args[3]);
    case UI_FS_READ:
        FS_Read(VMA(1), args[2], args[3]);
        return 0;
    case UI_FS_WRITE:
        FS_Write(VMA(1), args[2], args[3]);
        return 0;
    case UI_FS_FCLOSEFILE:
        FS_FCloseFile(args[1]);
        return 0;
    case UI_FS_DELETEFILE:
        return FS_Delete(VMA(1));
    case UI_FS_GETFILELIST:
        return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]);
    case UI_R_REGISTERMODEL:
        return re.RegisterModel(VMA(1));
    case UI_R_REGISTERSKIN:
        return re.RegisterSkin(VMA(1));
    case UI_R_REGISTERSHADERNOMIP:
        return re.RegisterShaderNoMip(VMA(1));
    case UI_R_CLEARSCENE:
        re.ClearScene();
        return 0;
    case UI_R_ADDREFENTITYTOSCENE:
        re.AddRefEntityToScene(VMA(1));
        return 0;
    case UI_R_ADDPOLYTOSCENE:
        re.AddPolyToScene(args[1], args[2], VMA(3));
        return 0;
    case UI_R_ADDPOLYSTOSCENE:
        re.AddPolysToScene(args[1], args[2], VMA(3), args[4]);
        return 0;
    case UI_R_ADDLIGHTTOSCENE:
        // new dlight code
        re.AddLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), args[7], args[8]);
        return 0;
    case UI_R_ADDCORONATOSCENE:
        re.AddCoronaToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6], (qboolean)args[7]);
        return 0;
    case UI_R_RENDERSCENE:
        re.RenderScene(VMA(1));
        return 0;
    case UI_R_SETCOLOR:
        re.SetColor(VMA(1));
        return 0;
    case UI_R_DRAW2DPOLYS:
        re.Add2dPolys(VMA(1), args[2], args[3]);
        return 0;
    case UI_R_DRAWSTRETCHPIC:
        re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9]);
        return 0;
    case UI_R_DRAWROTATEDPIC:
        re.DrawRotatedPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9], VMF(10));
        return 0;
    case UI_R_MODELBOUNDS:
        re.ModelBounds(args[1], VMA(2), VMA(3));
        return 0;
    case UI_UPDATESCREEN:
        SCR_UpdateScreen();
        return 0;
    case UI_CM_LERPTAG:
        return re.LerpTag(VMA(1), VMA(2), VMA(3), args[4]);
    case UI_S_REGISTERSOUND:
        return S_RegisterSound(VMA(1), (qboolean)args[2]);
    case UI_S_STARTLOCALSOUND:
        S_StartLocalSound(args[1], args[2], args[3]);
        return 0;
    case UI_S_FADESTREAMINGSOUND:
        S_FadeStreamingSound(VMF(1), args[2], args[3]);
        return 0;
    case UI_S_FADEALLSOUNDS:
        S_FadeAllSounds(VMF(1), args[2], (qboolean)args[3]);
        return 0;
    case UI_KEY_KEYNUMTOSTRINGBUF:
        Key_KeynumToStringBuf(args[1], VMA(2), args[3]);
        return 0;
    case UI_KEY_GETBINDINGBUF:
        Key_GetBindingBuf(args[1], VMA(2), args[3]);
        return 0;
    case UI_KEY_SETBINDING:
        Key_SetBinding(args[1], VMA(2));
        return 0;
    case UI_KEY_BINDINGTOKEYS:
        Key_GetBindingByString(VMA(1), VMA(2), VMA(3));
        return 0;
    case UI_KEY_ISDOWN:
        return Key_IsDown(args[1]);
    case UI_KEY_GETOVERSTRIKEMODE:
        return Key_GetOverstrikeMode();
    case UI_KEY_SETOVERSTRIKEMODE:
        Key_SetOverstrikeMode((qboolean)args[1]);
        return 0;
    case UI_KEY_CLEARSTATES:
        Key_ClearStates();
        return 0;
    case UI_KEY_GETCATCHER:
        return Key_GetCatcher();
    case UI_KEY_SETCATCHER:
        // Don't allow the ui module to close the console
        Key_SetCatcher(args[1] | (Key_GetCatcher() & KEYCATCH_CONSOLE));
        return 0;
    case UI_GETCLIPBOARDDATA:
        GetClipboardData(VMA(1), args[2]);
        return 0;
    case UI_GETCLIENTSTATE:
        GetClientState(VMA(1));
        return 0;
    case UI_GETGLCONFIG:
        CL_GetGlconfig(VMA(1));
        return 0;
    case UI_GETCONFIGSTRING:
        return GetConfigString(args[1], VMA(2), args[3]);
    case UI_LAN_LOADCACHEDSERVERS:
        LAN_LoadCachedServers();
        return 0;
    case UI_LAN_SAVECACHEDSERVERS:
        //LAN_SaveServersToFile(); // now done on add/remove fav server so we no longer save LAN favs on shutdown & restart
        return 0;
    case UI_LAN_ADDSERVER:
        return LAN_AddServer(args[1], VMA(2), VMA(3));
    case UI_LAN_REMOVESERVER:
        LAN_RemoveServer(args[1], VMA(2));
        return 0;
    case UI_LAN_GETPINGQUEUECOUNT:
        return LAN_GetPingQueueCount();
    case UI_LAN_CLEARPING:
        LAN_ClearPing(args[1]);
        return 0;
    case UI_LAN_GETPING:
        LAN_GetPing(args[1], VMA(2), args[3], VMA(4));
        return 0;
    case UI_LAN_GETPINGINFO:
        LAN_GetPingInfo(args[1], VMA(2), args[3]);
        return 0;
    case UI_LAN_GETSERVERCOUNT:
        return LAN_GetServerCount(args[1]);
    case UI_LAN_GETSERVERADDRESSSTRING:
        LAN_GetServerAddressString(args[1], args[2], VMA(3), args[4]);
        return 0;
    case UI_LAN_GETSERVERINFO:
        LAN_GetServerInfo(args[1], args[2], VMA(3), args[4]);
        return 0;
    case UI_LAN_GETSERVERPING:
        return LAN_GetServerPing(args[1], args[2]);
    case UI_LAN_MARKSERVERVISIBLE:
        LAN_MarkServerVisible(args[1], args[2], (qboolean)args[3]);
        return 0;
    case UI_LAN_SERVERISVISIBLE:
        return LAN_ServerIsVisible(args[1], args[2]);
    case UI_LAN_UPDATEVISIBLEPINGS:
        return LAN_UpdateVisiblePings(args[1]);
    case UI_LAN_RESETPINGS:
        LAN_ResetPings(args[1]);
        return 0;
    case UI_LAN_SERVERSTATUS:
        return LAN_GetServerStatus(VMA(1), VMA(2), args[3]);
    case UI_LAN_SERVERISINFAVORITELIST:
        return LAN_ServerIsInFavoriteList(args[1], args[2]);
    case UI_LAN_COMPARESERVERS:
        return LAN_CompareServers(args[1], args[2], args[3], args[4], args[5]);
    case UI_MEMORY_REMAINING:
        return Hunk_MemoryRemaining();
    case UI_R_REGISTERFONT:
        re.RegisterFont(VMA(1), args[2], VMA(3), (args[4] == qtrue));
        return 0;
    case UI_MEMSET:
        return (intptr_t)memset(VMA(1), args[2], args[3]);
    case UI_MEMCPY:
        return (intptr_t)memcpy(VMA(1), VMA(2), args[3]);
    case UI_STRNCPY:
        return (intptr_t)strncpy(VMA(1), VMA(2), args[3]);
    case UI_SIN:
        return FloatAsInt(sin(VMF(1)));
    case UI_COS:
        return FloatAsInt(cos(VMF(1)));
    case UI_ATAN2:
        return FloatAsInt(atan2(VMF(1), VMF(2)));
    case UI_SQRT:
        return FloatAsInt(sqrt(VMF(1)));
    case UI_FLOOR:
        return FloatAsInt(floor(VMF(1)));
    case UI_CEIL:
        return FloatAsInt(ceil(VMF(1)));
    case UI_PC_ADD_GLOBAL_DEFINE:
        return botlib_export->PC_AddGlobalDefine(VMA(1));
    case UI_PC_REMOVE_ALL_GLOBAL_DEFINES:
        botlib_export->PC_RemoveAllGlobalDefines();
        return 0;
    case UI_PC_LOAD_SOURCE:
        return botlib_export->PC_LoadSourceHandle(VMA(1));
    case UI_PC_FREE_SOURCE:
        return botlib_export->PC_FreeSourceHandle(args[1]);
    case UI_PC_READ_TOKEN:
        return botlib_export->PC_ReadTokenHandle(args[1], VMA(2));
    case UI_PC_SOURCE_FILE_AND_LINE:
        return botlib_export->PC_SourceFileAndLine(args[1], VMA(2), VMA(3));
    case UI_PC_UNREAD_TOKEN:
        botlib_export->PC_UnreadLastTokenHandle(args[1]);
        return 0;
    case UI_S_STOPBACKGROUNDTRACK:
        S_StopBackgroundTrack();
        return 0;
    case UI_S_STARTBACKGROUNDTRACK:
        S_StartBackgroundTrack(VMA(1), VMA(2), args[3]); // added fadeup time
        return 0;
    case UI_REAL_TIME:
        return Com_RealTime(VMA(1));
    case UI_CIN_PLAYCINEMATIC:
        Com_DPrintf("UI_CIN_PlayCinematic\n");
        return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]);
    case UI_CIN_STOPCINEMATIC:
        return CIN_StopCinematic(args[1]);
    case UI_CIN_RUNCINEMATIC:
        return CIN_RunCinematic(args[1]);
    case UI_CIN_DRAWCINEMATIC:
        CIN_DrawCinematic(args[1]);
        return 0;
    case UI_CIN_SETEXTENTS:
        CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
        return 0;
    case UI_R_REMAP_SHADER:
        re.RemapShader(VMA(1), VMA(2), VMA(3));
        return 0;
    case UI_CL_GETLIMBOSTRING:
        return CL_GetLimboString(args[1], VMA(2));
    case UI_CL_TRANSLATE_STRING:
        CL_TranslateStringMod(VMA(1), VMA(2));
        return 0;
    case UI_CHECKAUTOUPDATE:
        CL_RequestMasterData(qfalse);
        return 0;
    case UI_GET_AUTOUPDATE:
        Com_GetAutoUpdate();
        return 0;
    case UI_OPENURL:
        CL_OpenURL((const char *)VMA(1));
        return 0;
    case UI_GETHUNKDATA:
        Com_GetHunkInfo(VMA(1), VMA(2));
        return 0;
    // obsolete
    case UI_SET_PBCLSTATUS:
    case UI_SET_PBSVSTATUS:
        return 0;
    default:
        Com_Error(ERR_DROP, "Bad UI system trap: %ld", (long int) args[0]);
    }
}
예제 #4
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_SetSafe(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_RemoveCommandSafe(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
// 		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;

	case CG_S_STARTSOUNDEX:
		S_StartSoundEx(VMA(1), args[2], args[3], args[4], args[5]);
		return 0;
// end
	case CG_S_STARTLOCALSOUND:
		S_StartLocalSound(args[1], args[2]);
		return 0;
	case CG_S_CLEARLOOPINGSOUNDS:
		S_ClearLoopingSounds(args[1]); // (SA) modified so no_pvs sounds can function
		// 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;

	case CG_S_STOPSTREAMINGSOUND:
		S_StopEntStreamingSound(args[1]);
		return 0;
	case CG_S_STOPLOOPINGSOUND:
		// 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;
// 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]); // added fadeup time
		S_StartBackgroundTrack(VMA(1), VMA(2));
		return 0;
	case CG_S_FADESTREAMINGSOUND:
		S_FadeStreamingSound(VMF(1), args[2], args[3]); // 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]);  
		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));
		
	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]);
			case CG_R_REGISTERSHADER:
		return re.RegisterShader(VMA(1));
	case CG_R_REGISTERFONT:
		re.RegisterFont(VMA(1), args[2], VMA(3));
		return 0;
	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]);   // modified	// 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:
		// 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_MEMSET:
		Com_Memset(VMA(1), args[2], args[3]);
		return args[1];
	case CG_MEMCPY:
		Com_Memcpy(VMA(1), VMA(2), args[3]);
		return args[1];
	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_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:
		Q_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", (const char *)VMA(1), args[2]);
		return 0;
	case CG_TESTPRINTFLOAT:
// 		Com_Printf("%s%f\n", (const char *)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; 
		}

		startCamera(args[1], args[2]);
		return 0;

	case CG_STOPCAMERA:
		if (args[1] == 0) { // CAM_PRIMARY
			cl.cameraMode = qfalse;
		}
// 		stopCamera(args[1]);
		return 0;
	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 (clc.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));
	// New in IORTCW
	case CG_ALLOC:
		return VM_Alloc(args[1]);
	default:
		assert(0);
		Com_Error(ERR_DROP, "Bad cgame system trap: %ld", (long int)args[0]);
	}

	return 0;
}
예제 #5
0
파일: cl_ui.c 프로젝트: phobosanomaly/rtcw
/*
====================
CL_UISystemCalls

The ui module is making a system call
====================
*/
intptr_t CL_UISystemCalls( intptr_t *args ) {
	switch ( args[0] ) {
	case UI_ERROR:
		Com_Error( ERR_DROP, "%s", VMA( 1 ) );
		return 0;

	case UI_PRINT:
		Com_Printf( "%s", VMA( 1 ) );
		return 0;

	case UI_MILLISECONDS:
		return Sys_Milliseconds();

	case UI_CVAR_REGISTER:
		Cvar_Register( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[4] );
		return 0;

	case UI_CVAR_UPDATE:
		Cvar_Update( VMA( 1 ) );
		return 0;

	case UI_CVAR_SET:
		Cvar_Set( VMA( 1 ), VMA( 2 ) );
		return 0;

	case UI_CVAR_VARIABLEVALUE:
		return FloatAsInt( Cvar_VariableValue( VMA( 1 ) ) );

	case UI_CVAR_VARIABLESTRINGBUFFER:
		Cvar_VariableStringBuffer( VMA( 1 ), VMA( 2 ), args[3] );
		return 0;

	case UI_CVAR_SETVALUE:
		Cvar_SetValue( VMA( 1 ), VMF( 2 ) );
		return 0;

	case UI_CVAR_RESET:
		Cvar_Reset( VMA( 1 ) );
		return 0;

	case UI_CVAR_CREATE:
		Cvar_Get( VMA( 1 ), VMA( 2 ), args[3] );
		return 0;

	case UI_CVAR_INFOSTRINGBUFFER:
		Cvar_InfoStringBuffer( args[1], VMA( 2 ), args[3] );
		return 0;

	case UI_ARGC:
		return Cmd_Argc();

	case UI_ARGV:
		Cmd_ArgvBuffer( args[1], VMA( 2 ), args[3] );
		return 0;

	case UI_CMD_EXECUTETEXT:
		Cbuf_ExecuteText( args[1], VMA( 2 ) );
		return 0;

	case UI_FS_FOPENFILE:
		return FS_FOpenFileByMode( VMA( 1 ), VMA( 2 ), args[3] );

	case UI_FS_READ:
		FS_Read( VMA( 1 ), args[2], args[3] );
		return 0;

//----(SA)	added
	case UI_FS_SEEK:
		FS_Seek( args[1], args[2], args[3] );
		return 0;
//----(SA)	end

	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;

		// Ridah
	case UI_R_ADDPOLYSTOSCENE:
		re.AddPolysToScene( args[1], args[2], VMA( 3 ), args[4] );
		return 0;
		// done.

	case UI_R_ADDLIGHTTOSCENE:
		re.AddLightToScene( VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[6] );
		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_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:
		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 ), qfalse );
#endif  ///// (SA) DOOMSOUND

	case UI_S_STARTLOCALSOUND:
		S_StartLocalSound( args[1], args[2] );
		return 0;

//----(SA)	added
	case UI_S_FADESTREAMINGSOUND:
		S_FadeStreamingSound( VMF( 1 ), args[2], args[3] );
		return 0;

	case UI_S_FADEALLSOUNDS:
		S_FadeAllSounds( VMF( 1 ), args[2] );
		return 0;
//----(SA)	end

	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:
		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_R_REGISTERFONT:
		re.RegisterFont( VMA( 1 ), args[2], VMA( 3 ) );
		return 0;

	case UI_MEMSET:
		return (intptr_t)memset( VMA( 1 ), args[2], args[3] );

	case UI_MEMCPY:
		return (intptr_t)memcpy( VMA( 1 ), VMA( 2 ), args[3] );

	case UI_STRNCPY:
		return (intptr_t)strncpy( 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_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 ), args[3] );   //----(SA)	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_VERIFY_CDKEY:
		return CL_CDKeyValidate( VMA( 1 ), VMA( 2 ) );

		// NERVE - SMF
	case UI_CL_GETLIMBOSTRING:
		return CL_GetLimboString( args[1], VMA( 2 ) );
		// -NERVE - SMF

	default:
		Com_Error( ERR_DROP, "Bad UI system trap: %i", (int)args[0] );

	}

	return 0;
}
예제 #6
0
파일: cl_ui.cpp 프로젝트: bibendovsky/rtcw
//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;
}