Exemple #1
0
/*
==================
CL_WriteClientChatLog
==================
*/
void CL_WriteClientChatLog( char *text ) 
{
	if ( cl_logs && cl_logs->integer ) 
	{
		if ( LogFileOpened == qfalse || !LogFileHandle ) 
		{
			CL_OpenClientLog();
		}
		if ( FS_Initialized() && LogFileOpened == qtrue ) 
		{
			if( cl.serverTime > 0 )
			{
				// varibles
				char NoColorMsg[MAXPRINTMSG];
				char Timestamp[ 60 ];
				char LogText[ 60 + MAXPRINTMSG ];
				if( cl_logs->integer == 1 )
				{
					//just do 3 stars to seperate from normal logging stuff
					Q_strncpyz( Timestamp, "***", sizeof( Timestamp ) );
				} 
				else if ( cl_logs->integer == 2 ) 
				{
					//just game time
					//do timestamp prep
					sprintf( Timestamp, "[%d:%02d]", cl.serverTime / 60000, ( cl.serverTime / 1000 ) % 60 ); //server Time
					
				} 
				else if ( cl_logs->integer == 3 )
				{
					//just system time
					//do timestamp prep
					//get current time/date info
					qtime_t now;
					Com_RealTime( &now );
					sprintf( Timestamp, "[%d:%02d]", now.tm_hour, now.tm_min ); //server Time
				} 
				else if( cl_logs->integer == 4 )
				{
					//all the data
					//do timestamp prep
					//get current time/date info
					qtime_t now;
					Com_RealTime( &now );
					sprintf( Timestamp, "[%d:%02d][%d:%02d]", now.tm_hour, now.tm_min, cl.serverTime / 60000, ( cl.serverTime / 1000 ) % 60 ); //server Time
				}
				//decolor the string
				Q_strncpyz( NoColorMsg, text, sizeof(NoColorMsg) );
				Q_CleanStr( NoColorMsg );
				//prepare text for log
				sprintf( LogText, "%s%s\n", Timestamp, NoColorMsg ); //thing to write to log
				//write to the file
				FS_Write( LogText, strlen( LogText ), LogFileHandle );
				//flush the file so we can see the data
				FS_ForceFlush( LogFileHandle );
			}
		}
	}
}
Exemple #2
0
/*
================
Con_DrawInput

Draw the editline after a ] prompt
================
*/
void Con_DrawInput( void )
{
	int     y;
	char    prompt[ MAX_STRING_CHARS ];
	vec4_t  color;
	qtime_t realtime;

	if ( cls.state != CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_CONSOLE ) )
	{
		return;
	}

	Com_RealTime( &realtime );

	y = con.vislines - ( SCR_ConsoleFontCharHeight() * 2 ) + 2;

	Com_sprintf( prompt,  sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, cl_consolePrompt->string );

	color[ 0 ] = 1.0f;
	color[ 1 ] = 1.0f;
	color[ 2 ] = 1.0f;
	color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : con.displayFrac * 2.0f );

	SCR_DrawSmallStringExt( con.xadjust + cl_conXOffset->integer, y + 10, prompt, color, qfalse, qfalse );

	Q_CleanStr( prompt );
	Field_Draw( &g_consoleField, con.xadjust + cl_conXOffset->integer + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), y + 10, qtrue, qtrue, color[ 3 ] );
}
Exemple #3
0
/*
Generate unique name for a new server demo file.
(We pretend there are no race conditions.)
*/
static void SV_NameServerDemo(char *filename, int length, const client_t *client)
{
        qtime_t time;
        char playername[64];

        Com_DPrintf("SV_NameServerDemo\n");

        Com_RealTime(&time);
        Q_strncpyz(playername, client->name, sizeof(playername));
        SVD_CleanPlayerName(playername);

        do {
                // TODO: really this should contain something identifying
                // the server instance it came from; but we could be on
                // (multiple) IPv4 and IPv6 interfaces; in the end, some
                // kind of server guid may be more appropriate; mission?
                // TODO: when the string gets too long (what exactly is
                // the limit?) it get's cut off at the end ruining the
                // file extension
                Com_sprintf(
                        filename, length-1, "serverdemos/%.4d-%.2d-%.2d_%.2d-%.2d-%.2d_%s_%d.dm_%d",
                        time.tm_year+1900, time.tm_mon, time.tm_mday,
                        time.tm_hour, time.tm_min, time.tm_sec,
                        playername,
                        Sys_Milliseconds(),
                        PROTOCOL_VERSION
                );
                filename[length-1] = '\0';
        } while (FS_FileExists(filename));
}
Exemple #4
0
/*
==================
CON_UpdateClock

Update the clock
==================
*/
static void CON_UpdateClock(void)
{
	qtime_t realtime;
	Com_RealTime(&realtime);
	werase(clockwin);
	CON_ColorPrint(clockwin, va("^0[^3%02d%c%02d^0]^7 ", realtime.tm_hour, (realtime.tm_sec & 1) ? ':' : ' ', realtime.tm_min), qtrue);
	wnoutrefresh(clockwin);
}
/*
=================
SCR_DrawClock
=================
*/
static void SCR_DrawClock( void ) {
	qtime_t	myTime;
	char	string[16];
	if (Cvar_VariableValue ("cl_drawclock")) {
		Com_RealTime( &myTime );
		Com_sprintf( string, sizeof ( string ), "%02i:%02i:%02i", myTime.tm_hour, myTime.tm_min, myTime.tm_sec );
		SCR_DrawStringExt( 320 - strlen( string ) * 4, 11, 8, string, g_color_table[ColorIndex(COLOR_CYAN)], qtrue, qfalse );
	}
}
Exemple #6
0
// Standard naming for screenshots/demos
static char *demoAutoGenerateDefaultFilename(void) {
	qtime_t ct;
	const char *pszServerInfo = cl.gameState.stringData + cl.gameState.stringOffsets[CS_SERVERINFO];
	
	Com_RealTime(&ct);
	return va("%d-%02d-%02d-%02d%02d%02d-%s",
								1900+ct.tm_year, ct.tm_mon+1,ct.tm_mday,
								ct.tm_hour, ct.tm_min, ct.tm_sec,
								COM_SkipPath(Info_ValueForKey(pszServerInfo, "mapname")));
}
/*
Generate unique name for a new server demo file.
(We pretend there are no race conditions.)
*/
static void SV_NameServerDemo(char *filename, int length, const client_t *client, char *fn) {

    qtime_t time;
    char playername[32];
    char demoName[64]; //@Barbatos

    Com_DPrintf("SV_NameServerDemo\n");

    Com_RealTime(&time);
    Q_strncpyz(playername, client->name, sizeof(playername));
    SVD_CleanPlayerName(playername);

    if (fn != NULL) {

        Q_strncpyz(demoName, fn, sizeof(demoName));

        #ifdef USE_DEMO_FORMAT_42
            Q_snprintf(filename, length-1, "%s/%s.urtdemo", sv_demofolder->string, demoName );
            if (FS_FileExists(filename)) {
                Q_snprintf(filename, length-1, "%s/%s_%d.urtdemo", sv_demofolder->string, demoName, Sys_Milliseconds() );
            }
        #else
            Q_snprintf(filename, length-1, "%s/%s.dm_%d", sv_demofolder->string, demoName , PROTOCOL_VERSION );
            if (FS_FileExists(filename)) {
                Q_snprintf(filename, length-1, "%s/%s_%d.dm_%d", sv_demofolder->string, demoName, Sys_Milliseconds() , PROTOCOL_VERSION );
            }
        #endif
    } else {
        #ifdef USE_DEMO_FORMAT_42
            Q_snprintf(
                filename, length-1, "%s/%.4d-%.2d-%.2d_%.2d-%.2d-%.2d_%s_%d.urtdemo",
                sv_demofolder->string, time.tm_year+1900, time.tm_mon + 1, time.tm_mday,
                time.tm_hour, time.tm_min, time.tm_sec,
                playername,
                Sys_Milliseconds()
            );
        #else
            Q_snprintf(
                filename, length-1, "%s/%.4d-%.2d-%.2d_%.2d-%.2d-%.2d_%s_%d.dm_%d",
                sv_demofolder->string, time.tm_year+1900, time.tm_mon + 1, time.tm_mday,
                time.tm_hour, time.tm_min, time.tm_sec,
                playername,
                Sys_Milliseconds(),
                PROTOCOL_VERSION
            );
        #endif
        filename[length-1] = '\0';

        if (FS_FileExists(filename)) {
            filename[0] = 0;
            return;
        }
    }
}
Exemple #8
0
/*
==================
CL_OpenClientLog
==================
*/
void CL_OpenClientLog(void) {
	if( cl_logs && cl_logs->integer ) {
		if( FS_Initialized() && LogFileOpened == qfalse ) {
			char FileLocation[ 255 ];
			char *nowString;
			//get current time/date info
			qtime_t now;
			Com_RealTime( &now );
			nowString = va( "%04d-%02d-%02d", 1900 + now.tm_year, 1 + now.tm_mon, now.tm_mday );
			sprintf(FileLocation,"logs/%s.log", nowString );
			LogFileHandle = FS_FOpenFileAppend( FileLocation ); //open file with filename as date
			LogFileOpened = qtrue; //var to tell if files open
		}
	}
}
Exemple #9
0
void SV_WriteAttackLog(const char *log)
{
	if (attHandle > 0)
	{
		char    string[512]; // 512 chars seem enough here
		qtime_t time;

		Com_RealTime(&time);
		Com_sprintf(string, sizeof(string), "%i/%i/%i %i:%i:%i %s", 1900 + time.tm_year, time.tm_mday, time.tm_mon + 1, time.tm_hour, time.tm_min, time.tm_sec, log);
		FS_Write(string, strlen(string), attHandle);
	}
	else
	{
		Com_Printf("%s", log);
	}
}
Exemple #10
0
/*
================
Con_DrawInput

Draw the editline after a ] prompt
================
*/
void Con_DrawInput( int linePosition, float overrideAlpha )
{
	char    prompt[ MAX_STRING_CHARS ];
	vec4_t  color;
	qtime_t realtime;

	Com_RealTime( &realtime );
	Com_sprintf( prompt,  sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, con_prompt->string );

	color[ 0 ] = 1.0f;
	color[ 1 ] = 1.0f;
	color[ 2 ] = 1.0f;
	color[ 3 ] = consoleState.currentAlphaFactor * overrideAlpha;

	SCR_DrawSmallStringExt( consoleState.margin.sides + consoleState.padding.sides, linePosition, prompt, color, qfalse, qfalse );

	Q_CleanStr( prompt );
	Field_Draw( g_consoleField, consoleState.margin.sides + consoleState.padding.sides + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), linePosition, qtrue, qtrue, color[ 3 ] );
}
/*
=================
SCR_DrawClock
=================
*/
void SCR_DrawClock(void) {
    int 		color, fontsize, posx, posy, hour;
    char 		string[16];
    qtime_t		myTime;

    color = cl_drawclockcolor->integer;
    fontsize = cl_drawclockfontsize->integer;
    posx = cl_drawclockposx->integer;
    posy = cl_drawclockposy->integer;

    if (cl_drawclock->integer) {
        Com_RealTime(&myTime);
        hour = myTime.tm_hour;
        if (cl_drawclock12->integer)
            hour = hourTo12(hour);

        Com_sprintf(string, sizeof(string), "%02i:%02i", hour, myTime.tm_min);
        SCR_DrawCondensedString(posx * 10, posy * 10, fontsize, string, g_color_table[color], qtrue);
    }
}
Exemple #12
0
/////////////////////////////////////////////////////////////////////
// Name        : SCR_DrawClock
// Description : Draw the clock
/////////////////////////////////////////////////////////////////////
void SCR_DrawClock(void) {
    
    qtime_t now;
    char    string[16];
   
    // if we are not supposed to draw the clock
    if (!Cvar_VariableValue("cl_drawClock")) {
        return;
    }
    
    // if 2D drawing is disabled
    if (!Cvar_VariableValue("cg_draw2D")) {
        return;
    }
    
    // if we are paused
    if (Cvar_VariableValue("cl_paused")) {
        return;
    }
    
    Com_RealTime(&now);
    Com_sprintf(string, sizeof(string), "%02i:%02i:%02i", now.tm_hour, now.tm_min, now.tm_sec);
    SCR_DrawStringExt(320 - (SCR_GetSmallStringWidth(string) / 2), 15, SMALLCHAR_WIDTH, string, g_color_table[7], qtrue);
}
Exemple #13
0
/*
====================
SV_GameSystemCalls

The module is making a system call
====================
*/
intptr_t SV_GameSystemCalls(intptr_t * args) {
	switch (args[0]) {
		case G_PRINT:
			Com_Printf("%s", (char *)VMA(1));
			return 0;
		case G_ERROR:
			Com_Error(ERR_DROP, "%s", (char *)VMA(1));
			return 0;
		case G_MILLISECONDS:
			return Sys_Milliseconds();
		case G_CVAR_REGISTER:
			Cvar_Register((vmCvar_t*)VMA(1), (char*)VMA(2), (char*)VMA(3), args[4]);
			return 0;
		case G_CVAR_UPDATE:
			Cvar_Update((vmCvar_t*)VMA(1));
			return 0;
		case G_CVAR_SET:
			Cvar_Set((const char *)VMA(1), (const char *)VMA(2));
			return 0;
		case G_CVAR_VARIABLE_INTEGER_VALUE:
			return Cvar_VariableIntegerValue((const char *)VMA(1));
		case G_CVAR_VARIABLE_STRING_BUFFER:
			Cvar_VariableStringBuffer((char *)VMA(1), (char*)VMA(2), args[3]);
			return 0;
		case G_CVAR_LATCHEDVARIABLESTRINGBUFFER:
			Cvar_LatchedVariableStringBuffer((char *)VMA(1), (char*)VMA(2), args[3]);
			return 0;
		case G_ARGC:
			return Cmd_Argc();
		case G_ARGV:
			Cmd_ArgvBuffer(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_SEND_CONSOLE_COMMAND:
			Cbuf_ExecuteText(args[1], (char *)VMA(2));
			return 0;
		case G_FS_FOPEN_FILE:
			return FS_FOpenFileByMode((char *)VMA(1), (fileHandle_t*)VMA(2), (fsMode_t)args[3]);
		case G_FS_READ:
			FS_Read2(VMA(1), args[2], args[3]);
			return 0;
		case G_FS_WRITE:
			return FS_Write(VMA(1), args[2], args[3]);
		case G_FS_RENAME:
			FS_Rename((char *)VMA(1), (char *)VMA(2));
			return 0;
		case G_FS_FCLOSE_FILE:
			FS_FCloseFile(args[1]);
			return 0;
		case G_FS_GETFILELIST:
			return FS_GetFileList((char *)VMA(1), (char *)VMA(2), (char*)VMA(3), args[4]);
		case G_LOCATE_GAME_DATA:
			SV_LocateGameData((sharedEntity_t*)VMA(1), args[2], args[3], (playerState_t*)VMA(4), args[5]);
			return 0;
		case G_DROP_CLIENT:
			SV_GameDropClient(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_SEND_SERVER_COMMAND:
			SV_GameSendServerCommand(args[1], (char*)VMA(2));
			return 0;
		case G_LINKENTITY:
			SV_LinkEntity((sharedEntity_t*)VMA(1));
			return 0;
		case G_UNLINKENTITY:
			SV_UnlinkEntity((sharedEntity_t*)VMA(1));
			return 0;
		case G_ENTITIES_IN_BOX:
			return SV_AreaEntities((float*)VMA(1), (float*)VMA(2), (int*)VMA(3), args[4]);
		case G_ENTITY_CONTACT:
			return SV_EntityContact((float*)VMA(1), (float*)VMA(2), (sharedEntity_t*)VMA(3), TT_AABB);
		case G_ENTITY_CONTACTCAPSULE:
			return SV_EntityContact((float*)VMA(1), (float*)VMA(2), (sharedEntity_t*)VMA(3), TT_CAPSULE);
		case G_TRACE:
			SV_Trace((trace_t*)VMA(1), (float*)VMA(2), (float*)VMA(3), (float*)VMA(4), (float*)VMA(5), args[6], args[7], TT_AABB);
			return 0;
		case G_TRACECAPSULE:
			SV_Trace((trace_t*)VMA(1), (float*)VMA(2), (float*)VMA(3), (float*)VMA(4), (float*)VMA(5), args[6], args[7], TT_CAPSULE);
			return 0;
		case G_POINT_CONTENTS:
			return SV_PointContents((float*)VMA(1), args[2]);
		case G_SET_BRUSH_MODEL:
			SV_SetBrushModel((sharedEntity_t*)VMA(1), (char*)VMA(2));
			return 0;
		case G_IN_PVS:
			return SV_inPVS((float*)VMA(1), (float*)VMA(2));
		case G_IN_PVS_IGNORE_PORTALS:
			return SV_inPVSIgnorePortals((float*)VMA(1), (float*)VMA(2));
		case G_SET_CONFIGSTRING:
			SV_SetConfigstring(args[1], (char*)VMA(2));
			return 0;
		case G_GET_CONFIGSTRING:
			SV_GetConfigstring(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_SET_CONFIGSTRING_RESTRICTIONS:
			SV_SetConfigstringRestrictions( args[1], (clientList_t*)VMA(2) );
			return 0;
		case G_SET_USERINFO:
			SV_SetUserinfo(args[1], (char*)VMA(2));
			return 0;
		case G_GET_USERINFO:
			SV_GetUserinfo(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_GET_SERVERINFO:
			SV_GetServerinfo((char*)VMA(1), args[2]);
			return 0;
		case G_ADJUST_AREA_PORTAL_STATE:
			SV_AdjustAreaPortalState((sharedEntity_t*)VMA(1),(bool)args[2]);
			return 0;
		case G_AREAS_CONNECTED:
			return CM_AreasConnected(args[1], args[2]);
		case G_UPDATE_SHARED_CONFIG:
			SV_UpdateSharedConfig( args[1], (char*)VMA(2) );
			return 0;
		case G_BOT_ALLOCATE_CLIENT:
			return SV_BotAllocateClient(args[1]);
		case G_BOT_FREE_CLIENT:
			SV_BotFreeClient(args[1]);
			return 0;
		case G_GET_USERCMD:
			SV_GetUsercmd(args[1], (usercmd_t*)VMA(2));
			return 0;
		case G_GET_ENTITY_TOKEN: {
			const char     *s;

			s = COM_Parse(&sv.entityParsePoint);
			Q_strncpyz((char*)VMA(1), s, args[2]);
			if(!sv.entityParsePoint && !s[0]) {
				return false;
			} else {
				return true;
			}
		}
		case G_DEBUG_POLYGON_CREATE:
			return BotImport_DebugPolygonCreate(args[1], args[2], (vec3_t*)VMA(3));
		case G_DEBUG_POLYGON_DELETE:
			BotImport_DebugPolygonDelete(args[1]);
			return 0;
		case G_REAL_TIME:
			return Com_RealTime((qtime_t*)VMA(1));
		case G_SNAPVECTOR:
			Q_SnapVector((float*)VMA(1));
			return 0;
		case G_SEND_GAMESTAT:
			SV_MasterGameStat( (char*)VMA(1) );
			return 0;
		case G_ADDCOMMAND:
			Cmd_AddCommand( (char*)VMA(1), NULL, (char*)VMA(3) );
			return 0;
		case G_REMOVECOMMAND:
			Cmd_RemoveCommand( (char*)VMA(1) );
			return 0;
		case G_GETTAG:
			return SV_GetTag(args[1], args[2], (char*)VMA(3), (orientation_t*)VMA(4));
		case G_REGISTERTAG:
			return SV_LoadTag((char*)VMA(1));
		case G_REGISTERSOUND:
			return S_RegisterSound((char*)VMA(1), (bool)args[2]);
		case G_GET_SOUND_LENGTH:
			return S_GetSoundLength(args[1]);
		case G_PARSE_ADD_GLOBAL_DEFINE:
			return Parse_AddGlobalDefine( (char*)VMA(1) );
		case G_PARSE_LOAD_SOURCE:
			return Parse_LoadSourceHandle( (char*)VMA(1) );
		case G_PARSE_FREE_SOURCE:
			return Parse_FreeSourceHandle( args[1] );
		case G_PARSE_READ_TOKEN:
			return Parse_ReadTokenHandle( args[1], (pc_token_t*)VMA(2) );
		case G_PARSE_SOURCE_FILE_AND_LINE:
			return Parse_SourceFileAndLine( args[1], (char*)VMA(2), (int*)VMA(3) );
		case BOTLIB_SETUP:
			return SV_BotLibSetup();
		case BOTLIB_SHUTDOWN:
			return SV_BotLibShutdown();
		case BOTLIB_LIBVAR_SET:
			return botlib_export->BotLibVarSet((char*)VMA(1), (char*)VMA(2));
		case BOTLIB_LIBVAR_GET:
			return botlib_export->BotLibVarGet((char*)VMA(1), (char*)VMA(2), args[3]);
		case BOTLIB_PC_ADD_GLOBAL_DEFINE:
			return Parse_AddGlobalDefine( (char*)VMA(1) );
		case BOTLIB_PC_LOAD_SOURCE:
			return Parse_LoadSourceHandle((char*)VMA(1));
		case BOTLIB_PC_FREE_SOURCE:
			return Parse_FreeSourceHandle(args[1]);
		case BOTLIB_PC_READ_TOKEN:
			return Parse_ReadTokenHandle(args[1], (pc_token_t*)VMA(2));
		case BOTLIB_PC_SOURCE_FILE_AND_LINE:
			return Parse_SourceFileAndLine(args[1], (char*)VMA(2), (int*)VMA(3));
		case BOTLIB_PC_UNREAD_TOKEN:
			Parse_UnreadLastTokenHandle(args[1]);
			return 0;
		case BOTLIB_START_FRAME:
			return botlib_export->BotLibStartFrame(VMF(1));
		case BOTLIB_LOAD_MAP:
			return botlib_export->BotLibLoadMap((char*)VMA(1));
		case BOTLIB_UPDATENTITY:
			return botlib_export->BotLibUpdateEntity(args[1], (bot_entitystate_t*)VMA(2));
		case BOTLIB_TEST:
			return botlib_export->Test( args[1], (char*)VMA(2), (float*)VMA(3), (float*)VMA(4) );
		case BOTLIB_GET_SNAPSHOT_ENTITY:
			return SV_BotGetSnapshotEntity(args[1], args[2]);
		case BOTLIB_GET_CONSOLE_MESSAGE:
			return SV_BotGetConsoleMessage(args[1], (char*)VMA(2), args[3]);
		case BOTLIB_USER_COMMAND:
			SV_ClientThink(&svs.clients[args[1]], (usercmd_t*)VMA(2));
			return 0;
		case BOTLIB_AAS_ENTITY_INFO:
			botlib_export->aas.AAS_EntityInfo(args[1], (aas_entityinfo_s*)VMA(2));
			return 0;
		case BOTLIB_AAS_INITIALIZED:
			return botlib_export->aas.AAS_Initialized();
		case BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX:
			botlib_export->aas.AAS_PresenceTypeBoundingBox( args[1], (float*)VMA(2), (float*)VMA(3) );
			return 0;
		case BOTLIB_AAS_TIME:
			return FloatAsInt(botlib_export->aas.AAS_Time());
		case BOTLIB_AAS_SETCURRENTWORLD:
			botlib_export->aas.AAS_SetCurrentWorld(args[1]);
			return 0;
		case BOTLIB_AAS_POINT_AREA_NUM:
			return botlib_export->aas.AAS_PointAreaNum( (float*)VMA(1) );
		case BOTLIB_AAS_TRACE_AREAS:
			return botlib_export->aas.AAS_TraceAreas( (float*)VMA(1), (float*)VMA(2), (int*)VMA(3), (vec3_t*)VMA(4), args[5] );
		case BOTLIB_AAS_BBOX_AREAS:
			return botlib_export->aas.AAS_BBoxAreas( (float*)VMA(1), (float*)VMA(2), (int*)VMA(3), args[4] );
		case BOTLIB_AAS_AREA_CENTER:
			botlib_export->aas.AAS_AreaCenter(args[1], (float*)VMA(2));
			return 0;
		case BOTLIB_AAS_AREA_WAYPOINT:
			return botlib_export->aas.AAS_AreaWaypoint(args[1], (float*)VMA(2));
		case BOTLIB_AAS_POINT_CONTENTS:
			return botlib_export->aas.AAS_PointContents((float*)VMA(1));
		case BOTLIB_AAS_NEXT_BSP_ENTITY:
			return botlib_export->aas.AAS_NextBSPEntity(args[1]);
		case BOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY:
			return botlib_export->aas.AAS_ValueForBSPEpairKey(args[1], (char*)VMA(2), (char*)VMA(3), args[4]);
		case BOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY:
			return botlib_export->aas.AAS_VectorForBSPEpairKey(args[1], (char*)VMA(2), (float*)VMA(3));
		case BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY:
			return botlib_export->aas.AAS_FloatForBSPEpairKey(args[1], (char*)VMA(2), (float*)VMA(3));
		case BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY:
			return botlib_export->aas.AAS_IntForBSPEpairKey(args[1], (char*)VMA(2), (int*)VMA(3));
		case BOTLIB_AAS_AREA_REACHABILITY:
			return botlib_export->aas.AAS_AreaReachability(args[1]);
		case BOTLIB_AAS_AREA_LADDER:
			return botlib_export->aas.AAS_AreaLadder(args[1]);
		case BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA:
			return botlib_export->aas.AAS_AreaTravelTimeToGoalArea(args[1], (float*)VMA(2), args[3], args[4]);
		case BOTLIB_AAS_SWIMMING:
			return botlib_export->aas.AAS_Swimming((float*)VMA(1));
		case BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT:
			return botlib_export->aas.AAS_PredictClientMovement((aas_clientmove_s*)VMA(1), args[2], (float*)VMA(3), args[4], args[5], (float*)VMA(6), (float*)VMA(7), args[8], args[9], VMF(10), args[11], args[12], args[13]);
		case BOTLIB_AAS_RT_SHOWROUTE:
			botlib_export->aas.AAS_RT_ShowRoute((float*)VMA(1), args[2], args[3]);
			return 0;
		case BOTLIB_AAS_NEARESTHIDEAREA:
			return botlib_export->aas.AAS_NearestHideArea(args[1], (float*)VMA(2), args[3], args[4], (float*)VMA(5), args[6], args[7], VMF(8), (float*)VMA(9));
		case BOTLIB_AAS_LISTAREASINRANGE:
			return botlib_export->aas.AAS_ListAreasInRange((float*)VMA(1), args[2], VMF(3), args[4], (vec3_t*)VMA(5), args[6]);
		case BOTLIB_AAS_AVOIDDANGERAREA:
			return botlib_export->aas.AAS_AvoidDangerArea((float*)VMA(1), args[2], (float*)VMA(3), args[4], VMF(5), args[6]);
		case BOTLIB_AAS_RETREAT:
			return botlib_export->aas.AAS_Retreat((int*)VMA(1), args[2], (float*)VMA(3), args[4], (float*)VMA(5), args[6], VMF(7), VMF(8), args[9]);
		case BOTLIB_AAS_ALTROUTEGOALS:
			return botlib_export->aas.AAS_AlternativeRouteGoals((float*)VMA(1), (float*)VMA(2), args[3], (aas_altroutegoal_t*)VMA(4), args[5], args[6]);
		case BOTLIB_AAS_SETAASBLOCKINGENTITY:
			botlib_export->aas.AAS_SetAASBlockingEntity((float*)VMA(1), (float*)VMA(2), args[3]);
			return 0;
		case BOTLIB_AAS_RECORDTEAMDEATHAREA:
			botlib_export->aas.AAS_RecordTeamDeathArea((float*)VMA(1), args[2], args[3], args[4], args[5]);
			return 0;
		case BOTLIB_EA_SAY:
			botlib_export->ea.EA_Say(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_SAY_TEAM:
			botlib_export->ea.EA_SayTeam(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_USE_ITEM:
			botlib_export->ea.EA_UseItem(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_DROP_ITEM:
			botlib_export->ea.EA_DropItem(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_USE_INV:
			botlib_export->ea.EA_UseInv(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_DROP_INV:
			botlib_export->ea.EA_DropInv(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_GESTURE:
			botlib_export->ea.EA_Gesture(args[1]);
			return 0;
		case BOTLIB_EA_COMMAND:
			botlib_export->ea.EA_Command(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_SELECT_WEAPON:
			botlib_export->ea.EA_SelectWeapon(args[1], args[2]);
			return 0;
		case BOTLIB_EA_TALK:
			botlib_export->ea.EA_Talk(args[1]);
			return 0;
		case BOTLIB_EA_ATTACK:
			botlib_export->ea.EA_Attack(args[1]);
			return 0;
		case BOTLIB_EA_RELOAD:
			botlib_export->ea.EA_Reload(args[1]);
			return 0;
		case BOTLIB_EA_USE:
			botlib_export->ea.EA_Use(args[1]);
			return 0;
		case BOTLIB_EA_RESPAWN:
			botlib_export->ea.EA_Respawn(args[1]);
			return 0;
		case BOTLIB_EA_JUMP:
			botlib_export->ea.EA_Jump(args[1]);
			return 0;
		case BOTLIB_EA_DELAYED_JUMP:
			botlib_export->ea.EA_DelayedJump(args[1]);
			return 0;
		case BOTLIB_EA_CROUCH:
			botlib_export->ea.EA_Crouch(args[1]);
			return 0;
		case BOTLIB_EA_WALK:
			botlib_export->ea.EA_Walk(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_UP:
			botlib_export->ea.EA_MoveUp(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_DOWN:
			botlib_export->ea.EA_MoveDown(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_FORWARD:
			botlib_export->ea.EA_MoveForward(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_BACK:
			botlib_export->ea.EA_MoveBack(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_LEFT:
			botlib_export->ea.EA_MoveLeft(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_RIGHT:
			botlib_export->ea.EA_MoveRight(args[1]);
			return 0;
		case BOTLIB_EA_MOVE:
			botlib_export->ea.EA_Move(args[1], (float*)VMA(2), VMF(3));
			return 0;
		case BOTLIB_EA_VIEW:
			botlib_export->ea.EA_View(args[1], (float*)VMA(2));
			return 0;
		case BOTLIB_EA_PRONE:
			botlib_export->ea.EA_Prone(args[1]);
			return 0;
		case BOTLIB_EA_END_REGULAR:
			botlib_export->ea.EA_EndRegular(args[1], VMF(2));
			return 0;
		case BOTLIB_EA_GET_INPUT:
			botlib_export->ea.EA_GetInput(args[1], VMF(2), (bot_input_t*)VMA(3));
			return 0;
		case BOTLIB_EA_RESET_INPUT:
			botlib_export->ea.EA_ResetInput(args[1], (bot_input_t*)VMA(2));
			return 0;
		case BOTLIB_AI_LOAD_CHARACTER:
			return botlib_export->ai.BotLoadCharacter((char*)VMA(1), args[2]);
		case BOTLIB_AI_FREE_CHARACTER:
			botlib_export->ai.BotFreeCharacter(args[1]);
			return 0;
		case BOTLIB_AI_CHARACTERISTIC_FLOAT:
			return FloatAsInt(botlib_export->ai.Characteristic_Float(args[1], args[2]));
		case BOTLIB_AI_CHARACTERISTIC_BFLOAT:
			return FloatAsInt(botlib_export->ai.Characteristic_BFloat(args[1], args[2], VMF(3), VMF(4)));
		case BOTLIB_AI_CHARACTERISTIC_INTEGER:
			return botlib_export->ai.Characteristic_Integer(args[1], args[2]);
		case BOTLIB_AI_CHARACTERISTIC_BINTEGER:
			return botlib_export->ai.Characteristic_BInteger(args[1], args[2], args[3], args[4]);
		case BOTLIB_AI_CHARACTERISTIC_STRING:
			botlib_export->ai.Characteristic_String(args[1], args[2], (char*)VMA(3), args[4]);
			return 0;
		case BOTLIB_AI_ALLOC_CHAT_STATE:
			return botlib_export->ai.BotAllocChatState();
		case BOTLIB_AI_FREE_CHAT_STATE:
			botlib_export->ai.BotFreeChatState(args[1]);
			return 0;
		case BOTLIB_AI_QUEUE_CONSOLE_MESSAGE:
			botlib_export->ai.BotQueueConsoleMessage(args[1], args[2], (char*)VMA(3));
			return 0;
		case BOTLIB_AI_REMOVE_CONSOLE_MESSAGE:
			botlib_export->ai.BotRemoveConsoleMessage(args[1], args[2]);
			return 0;
		case BOTLIB_AI_NEXT_CONSOLE_MESSAGE:
			return botlib_export->ai.BotNextConsoleMessage(args[1], (bot_consolemessage_s*)VMA(2));
		case BOTLIB_AI_NUM_CONSOLE_MESSAGE:
			return botlib_export->ai.BotNumConsoleMessages(args[1]);
		case BOTLIB_AI_INITIAL_CHAT:
			botlib_export->ai.BotInitialChat(args[1], (char*)VMA(2), args[3], (char*)VMA(4), (char*)VMA(5), (char*)VMA(6), (char*)VMA(7), (char*)VMA(8), (char*)VMA(9), (char*)VMA(10), (char*)VMA(11));
			return 0;
		case BOTLIB_AI_NUM_INITIAL_CHATS:
			return botlib_export->ai.BotNumInitialChats(args[1], (char*)VMA(2));
		case BOTLIB_AI_REPLY_CHAT:
			return botlib_export->ai.BotReplyChat(args[1], (char*)VMA(2), args[3], args[4], (char*)VMA(5), (char*)VMA(6), (char*)VMA(7), (char*)VMA(8), (char*)VMA(9), (char*)VMA(10), (char*)VMA(11), (char*)VMA(12));
		case BOTLIB_AI_CHAT_LENGTH:
			return botlib_export->ai.BotChatLength(args[1]);
		case BOTLIB_AI_ENTER_CHAT:
			botlib_export->ai.BotEnterChat(args[1], args[2], args[3]);
			return 0;
		case BOTLIB_AI_GET_CHAT_MESSAGE:
			botlib_export->ai.BotGetChatMessage(args[1], (char*)VMA(2), args[3]);
			return 0;
		case BOTLIB_AI_STRING_CONTAINS:
			return botlib_export->ai.StringContains((char*)VMA(1), (char*)VMA(2), args[3]);
		case BOTLIB_AI_FIND_MATCH:
			return botlib_export->ai.BotFindMatch((char*)VMA(1), (bot_match_s*)VMA(2), args[3]);
		case BOTLIB_AI_MATCH_VARIABLE:
			botlib_export->ai.BotMatchVariable((bot_match_s*)VMA(1), args[2], (char*)VMA(3), args[4]);
			return 0;
		case BOTLIB_AI_UNIFY_WHITE_SPACES:
			botlib_export->ai.UnifyWhiteSpaces((char*)VMA(1));
			return 0;
		case BOTLIB_AI_REPLACE_SYNONYMS:
			botlib_export->ai.BotReplaceSynonyms((char*)VMA(1), args[2]);
			return 0;
		case BOTLIB_AI_LOAD_CHAT_FILE:
			return botlib_export->ai.BotLoadChatFile(args[1], (char*)VMA(2), (char*)VMA(3));
		case BOTLIB_AI_SET_CHAT_GENDER:
			botlib_export->ai.BotSetChatGender(args[1], args[2]);
			return 0;
		case BOTLIB_AI_SET_CHAT_NAME:
			botlib_export->ai.BotSetChatName(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_AI_RESET_GOAL_STATE:
			botlib_export->ai.BotResetGoalState(args[1]);
			return 0;
		case BOTLIB_AI_RESET_AVOID_GOALS:
			botlib_export->ai.BotResetAvoidGoals(args[1]);
			return 0;
		case BOTLIB_AI_REMOVE_FROM_AVOID_GOALS:
			botlib_export->ai.BotRemoveFromAvoidGoals(args[1], args[2]);
			return 0;
		case BOTLIB_AI_PUSH_GOAL:
			botlib_export->ai.BotPushGoal(args[1], (bot_goal_s*)VMA(2));
			return 0;
		case BOTLIB_AI_POP_GOAL:
			botlib_export->ai.BotPopGoal(args[1]);
			return 0;
		case BOTLIB_AI_EMPTY_GOAL_STACK:
			botlib_export->ai.BotEmptyGoalStack(args[1]);
			return 0;
		case BOTLIB_AI_DUMP_AVOID_GOALS:
			botlib_export->ai.BotDumpAvoidGoals(args[1]);
			return 0;
		case BOTLIB_AI_DUMP_GOAL_STACK:
			botlib_export->ai.BotDumpGoalStack(args[1]);
			return 0;
		case BOTLIB_AI_GOAL_NAME:
			botlib_export->ai.BotGoalName(args[1], (char*)VMA(2), args[3]);
			return 0;
		case BOTLIB_AI_GET_TOP_GOAL:
			return botlib_export->ai.BotGetTopGoal(args[1], (bot_goal_s*)VMA(2));
		case BOTLIB_AI_GET_SECOND_GOAL:
			return botlib_export->ai.BotGetSecondGoal(args[1], (bot_goal_s*)VMA(2));
		case BOTLIB_AI_CHOOSE_LTG_ITEM:
			return botlib_export->ai.BotChooseLTGItem(args[1], (float*)VMA(2), (int*)VMA(3), args[4]);
		case BOTLIB_AI_CHOOSE_NBG_ITEM:
			return botlib_export->ai.BotChooseNBGItem(args[1], (float*)VMA(2), (int*)VMA(3), args[4], (bot_goal_s*)VMA(5), VMF(6));
		case BOTLIB_AI_TOUCHING_GOAL:
			return botlib_export->ai.BotTouchingGoal((float*)VMA(1), (bot_goal_s*)VMA(2));
		case BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE:
			return botlib_export->ai.BotItemGoalInVisButNotVisible(args[1], (float*)VMA(2), (float*)VMA(3), (bot_goal_s*)VMA(4));
		case BOTLIB_AI_GET_LEVEL_ITEM_GOAL:
			return botlib_export->ai.BotGetLevelItemGoal(args[1], (char*)VMA(2), (bot_goal_s*)VMA(3));
		case BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL:
			return botlib_export->ai.BotGetNextCampSpotGoal(args[1], (bot_goal_s*)VMA(2));
		case BOTLIB_AI_GET_MAP_LOCATION_GOAL:
			return botlib_export->ai.BotGetMapLocationGoal((char*)VMA(1), (bot_goal_s*)VMA(2));
		case BOTLIB_AI_AVOID_GOAL_TIME:
			return FloatAsInt(botlib_export->ai.BotAvoidGoalTime(args[1], args[2]));
		case BOTLIB_AI_INIT_LEVEL_ITEMS:
			botlib_export->ai.BotInitLevelItems();
			return 0;
		case BOTLIB_AI_UPDATE_ENTITY_ITEMS:
			botlib_export->ai.BotUpdateEntityItems();
			return 0;
		case BOTLIB_AI_LOAD_ITEM_WEIGHTS:
			return botlib_export->ai.BotLoadItemWeights(args[1], (char*)VMA(2));
		case BOTLIB_AI_FREE_ITEM_WEIGHTS:
			botlib_export->ai.BotFreeItemWeights(args[1]);
			return 0;
		case BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC:
			botlib_export->ai.BotInterbreedGoalFuzzyLogic(args[1], args[2], args[3]);
			return 0;
		case BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC:
			botlib_export->ai.BotSaveGoalFuzzyLogic(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC:
			botlib_export->ai.BotMutateGoalFuzzyLogic(args[1], VMF(2));
			return 0;
		case BOTLIB_AI_ALLOC_GOAL_STATE:
			return botlib_export->ai.BotAllocGoalState(args[1]);
		case BOTLIB_AI_FREE_GOAL_STATE:
			botlib_export->ai.BotFreeGoalState(args[1]);
			return 0;
		case BOTLIB_AI_RESET_MOVE_STATE:
			botlib_export->ai.BotResetMoveState(args[1]);
			return 0;
		case BOTLIB_AI_MOVE_TO_GOAL:
			botlib_export->ai.BotMoveToGoal((bot_moveresult_s*)VMA(1), args[2], (bot_goal_s*)VMA(3), args[4]);
			return 0;
		case BOTLIB_AI_MOVE_IN_DIRECTION:
			return botlib_export->ai.BotMoveInDirection(args[1], (float*)VMA(2), VMF(3), args[4]);
		case BOTLIB_AI_RESET_AVOID_REACH:
			botlib_export->ai.BotResetAvoidReach(args[1]);
			return 0;
		case BOTLIB_AI_RESET_LAST_AVOID_REACH:
			botlib_export->ai.BotResetLastAvoidReach(args[1]);
			return 0;
		case BOTLIB_AI_REACHABILITY_AREA:
			return botlib_export->ai.BotReachabilityArea((float*)VMA(1), args[2]);
		case BOTLIB_AI_MOVEMENT_VIEW_TARGET:
			return botlib_export->ai.BotMovementViewTarget(args[1], (bot_goal_s*)VMA(2), args[3], VMF(4), (float*)VMA(5));
		case BOTLIB_AI_PREDICT_VISIBLE_POSITION:
			return botlib_export->ai.BotPredictVisiblePosition((float*)VMA(1), args[2], (bot_goal_s*)VMA(3), args[4], (vec_t*)VMA(5));
		case BOTLIB_AI_ALLOC_MOVE_STATE:
			return botlib_export->ai.BotAllocMoveState();
		case BOTLIB_AI_FREE_MOVE_STATE:
			botlib_export->ai.BotFreeMoveState(args[1]);
			return 0;
		case BOTLIB_AI_INIT_MOVE_STATE:
			botlib_export->ai.BotInitMoveState(args[1], (bot_initmove_s*)VMA(2));
			return 0;
		case BOTLIB_AI_INIT_AVOID_REACH:
			botlib_export->ai.BotInitAvoidReach(args[1]);
			return 0;
		case BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON:
			return botlib_export->ai.BotChooseBestFightWeapon(args[1], (int*)VMA(2));
		case BOTLIB_AI_GET_WEAPON_INFO:
			botlib_export->ai.BotGetWeaponInfo(args[1], args[2], (weaponinfo_s*)VMA(3));
			return 0;
		case BOTLIB_AI_LOAD_WEAPON_WEIGHTS:
			return botlib_export->ai.BotLoadWeaponWeights(args[1], (char*)VMA(2));
		case BOTLIB_AI_ALLOC_WEAPON_STATE:
			return botlib_export->ai.BotAllocWeaponState();
		case BOTLIB_AI_FREE_WEAPON_STATE:
			botlib_export->ai.BotFreeWeaponState(args[1]);
			return 0;
		case BOTLIB_AI_RESET_WEAPON_STATE:
			botlib_export->ai.BotResetWeaponState(args[1]);
			return 0;
		case BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION:
			return botlib_export->ai.GeneticParentsAndChildSelection(args[1], (float*)VMA(2), (int*)VMA(3), (int*)VMA(4), (int*)VMA(5));
		case G_ADD_PHYSICS_ENTITY:
#ifdef USE_PHYSICS
			CMod_PhysicsAddEntity((sharedEntity_t*)VMA(1));
#endif
			return 0;
		case G_ADD_PHYSICS_STATIC:
#ifdef USE_PHYSICS
			CMod_PhysicsAddStatic((sharedEntity_t*)VMA(1));
#endif
			return 0;
		case TRAP_MEMSET:
			memset(VMA(1), args[2], args[3]);
			return 0;
		case TRAP_MEMCPY:
			memcpy(VMA(1), VMA(2), args[3]);
			return 0;
		case TRAP_STRNCPY:
			return (intptr_t)strncpy( (char*)VMA( 1 ), (char*)VMA( 2 ), args[3] );
		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:
			AxisMultiply((vec3_t*)VMA(1), (vec3_t*)VMA(2), (vec3_t*)VMA(3));
			return 0;
		case TRAP_ANGLEVECTORS:
			AngleVectors((vec_t*)VMA(1), (vec_t*)VMA(2), (vec_t*)VMA(3), (vec_t*)VMA(4));
			return 0;
		case TRAP_PERPENDICULARVECTOR:
			PerpendicularVector((vec_t*)VMA(1), (vec_t*)VMA(2));
			return 0;
		case TRAP_FLOOR:
			return FloatAsInt(floor(VMF(1)));
		case TRAP_CEIL:
			return FloatAsInt(ceil(VMF(1)));
		case G_SENDMESSAGE:
			SV_SendBinaryMessage(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_MESSAGESTATUS:
			return SV_BinaryMessageStatus(args[1]);
#if defined(ET_MYSQL)
        case G_SQL_RUNQUERY:
                return OW_RunQuery( (char*)VMA(1) );
        case G_SQL_FINISHQUERY:
                OW_FinishQuery( args[1] );
                return 0;
        case G_SQL_NEXTROW:
                return OW_NextRow( args[1] );
        case G_SQL_ROWCOUNT:
                return OW_RowCount( args[1] );
        case G_SQL_GETFIELDBYID:
                OW_GetFieldByID( args[1], args[2], (char*)VMA(3), args[4]  );
                return 0;
        case G_SQL_GETFIELDBYNAME:
                OW_GetFieldByName( args[1], (char*)VMA(2), (char*)VMA(3), args[4] );
                return 0;
        case G_SQL_GETFIELDBYID_INT:
                return OW_GetFieldByID_int( args[1], args[2] );
        case G_SQL_GETFIELDBYNAME_INT:
                return OW_GetFieldByName_int( args[1], (char*)VMA(2) );
        case G_SQL_FIELDCOUNT:
                return OW_FieldCount( args[1] );
        case G_SQL_CLEANSTRING:
                OW_CleanString( (char*)VMA(1), (char*)VMA(2), args[3] );
                return 0;
#endif
		case G_RSA_GENMSG:
			return SV_RSAGenMsg( (char*)VMA(1), (char*)VMA(2), (char*)VMA(3) );
		default:
			Com_Error( ERR_DROP, "Bad game system trap: %ld", (long int) args[0] );
	}
	return -1;
}
Exemple #14
0
//	The ui module is making a system call
qintptr CLWM_UISystemCalls( qintptr* args ) {
	switch ( args[ 0 ] ) {
	case WMUI_ERROR:
		common->Error( "%s", ( char* )VMA( 1 ) );
		return 0;

	case WMUI_PRINT:
		common->Printf( "%s", ( char* )VMA( 1 ) );
		return 0;

	case WMUI_MILLISECONDS:
		return Sys_Milliseconds();

	case WMUI_CVAR_REGISTER:
		Cvar_Register( ( vmCvar_t* )VMA( 1 ), ( char* )VMA( 2 ), ( char* )VMA( 3 ), args[ 4 ] );
		return 0;

	case WMUI_CVAR_UPDATE:
		Cvar_Update( ( vmCvar_t* )VMA( 1 ) );
		return 0;

	case WMUI_CVAR_SET:
		Cvar_Set( ( char* )VMA( 1 ), ( char* )VMA( 2 ) );
		return 0;

	case WMUI_CVAR_VARIABLEVALUE:
		return FloatAsInt( Cvar_VariableValue( ( char* )VMA( 1 ) ) );

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

	case WMUI_CVAR_SETVALUE:
		Cvar_SetValue( ( char* )VMA( 1 ), VMF( 2 ) );
		return 0;

	case WMUI_CVAR_RESET:
		Cvar_Reset( ( char* )VMA( 1 ) );
		return 0;

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

	case WMUI_CVAR_INFOSTRINGBUFFER:
		Cvar_InfoStringBuffer( args[ 1 ], MAX_INFO_STRING_Q3, ( char* )VMA( 2 ), args[ 3 ] );
		return 0;

	case WMUI_ARGC:
		return Cmd_Argc();

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

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

	case WMUI_FS_FOPENFILE:
		return FS_FOpenFileByMode( ( char* )VMA( 1 ), ( fileHandle_t* )VMA( 2 ), ( fsMode_t )args[ 3 ] );

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

	case WMUI_FS_WRITE:
		FS_Write( VMA( 1 ), args[ 2 ], args[ 3 ] );
		return 0;

	case WMUI_FS_FCLOSEFILE:
		FS_FCloseFile( args[ 1 ] );
		return 0;

	case WMUI_FS_DELETEFILE:
		return FS_Delete( ( char* )VMA( 1 ) );

	case WMUI_FS_GETFILELIST:
		return FS_GetFileList( ( char* )VMA( 1 ), ( char* )VMA( 2 ), ( char* )VMA( 3 ), args[ 4 ] );

	case WMUI_R_REGISTERMODEL:
		return R_RegisterModel( ( char* )VMA( 1 ) );

	case WMUI_R_REGISTERSKIN:
		return R_RegisterSkin( ( char* )VMA( 1 ) );

	case WMUI_R_REGISTERSHADERNOMIP:
		return R_RegisterShaderNoMip( ( char* )VMA( 1 ) );

	case WMUI_R_CLEARSCENE:
		R_ClearScene();
		return 0;

	case WMUI_R_ADDREFENTITYTOSCENE:
		CLWM_AddRefEntityToScene( ( wmrefEntity_t* )VMA( 1 ) );
		return 0;

	case WMUI_R_ADDPOLYTOSCENE:
		R_AddPolyToScene( args[ 1 ], args[ 2 ], ( polyVert_t* )VMA( 3 ), 1 );
		return 0;

	case WMUI_R_ADDPOLYSTOSCENE:
		R_AddPolyToScene( args[ 1 ], args[ 2 ], ( polyVert_t* )VMA( 3 ), args[ 4 ] );
		return 0;

	case WMUI_R_ADDLIGHTTOSCENE:
		R_AddLightToScene( ( float* )VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ] );
		return 0;

	case WMUI_R_ADDCORONATOSCENE:
		R_AddCoronaToScene( ( float* )VMA( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), args[ 6 ], args[ 7 ] );
		return 0;

	case WMUI_R_RENDERSCENE:
		CLWM_RenderScene( ( wmrefdef_t* )VMA( 1 ) );
		return 0;

	case WMUI_R_SETCOLOR:
		R_SetColor( ( float* )VMA( 1 ) );
		return 0;

	case WMUI_R_DRAWSTRETCHPIC:
		R_StretchPic( VMF( 1 ), VMF( 2 ), VMF( 3 ), VMF( 4 ), VMF( 5 ), VMF( 6 ), VMF( 7 ), VMF( 8 ), args[ 9 ] );
		return 0;

	case WMUI_R_MODELBOUNDS:
		R_ModelBounds( args[ 1 ], ( float* )VMA( 2 ), ( float* )VMA( 3 ) );
		return 0;

	case WMUI_UPDATESCREEN:
		SCR_UpdateScreen();
		return 0;

	case WMUI_CM_LERPTAG:
		return CLWM_LerpTag( ( orientation_t* )VMA( 1 ), ( wmrefEntity_t* )VMA( 2 ), ( char* )VMA( 3 ), args[ 4 ] );

	case WMUI_S_REGISTERSOUND:
		return S_RegisterSound( ( char* )VMA( 1 ) );

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

	case WMUI_KEY_KEYNUMTOSTRINGBUF:
		Key_KeynumToStringBuf( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] );
		return 0;

	case WMUI_KEY_GETBINDINGBUF:
		Key_GetBindingBuf( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] );
		return 0;

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

	case WMUI_KEY_ISDOWN:
		return Key_IsDown( args[ 1 ] );

	case WMUI_KEY_GETOVERSTRIKEMODE:
		return Key_GetOverstrikeMode();

	case WMUI_KEY_SETOVERSTRIKEMODE:
		Key_SetOverstrikeMode( args[ 1 ] );
		return 0;

	case WMUI_KEY_CLEARSTATES:
		Key_ClearStates();
		return 0;

	case WMUI_KEY_GETCATCHER:
		return Key_GetCatcher();

	case WMUI_KEY_SETCATCHER:
		KeyWM_SetCatcher( args[ 1 ] );
		return 0;

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

	case WMUI_GETCLIENTSTATE:
		UIT3_GetClientState( ( uiClientState_t* )VMA( 1 ) );
		return 0;

	case WMUI_GETGLCONFIG:
		CLWM_GetGlconfig( ( wmglconfig_t* )VMA( 1 ) );
		return 0;

	case WMUI_GETCONFIGSTRING:
		return CLWM_GetConfigString( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] );

	case WMUI_LAN_LOADCACHEDSERVERS:
		LAN_LoadCachedServers();
		return 0;

	case WMUI_LAN_SAVECACHEDSERVERS:
		LAN_SaveServersToCache();
		return 0;

	case WMUI_LAN_ADDSERVER:
		return LAN_AddServer( args[ 1 ], ( char* )VMA( 2 ), ( char* )VMA( 3 ) );

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

	case WMUI_LAN_GETPINGQUEUECOUNT:
		return CLT3_GetPingQueueCount();

	case WMUI_LAN_CLEARPING:
		CLT3_ClearPing( args[ 1 ] );
		return 0;

	case WMUI_LAN_GETPING:
		CLT3_GetPing( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ], ( int* )VMA( 4 ) );
		return 0;

	case WMUI_LAN_GETPINGINFO:
		CLT3_GetPingInfo( args[ 1 ], ( char* )VMA( 2 ), args[ 3 ] );
		return 0;

	case WMUI_LAN_GETSERVERCOUNT:
		return LAN_GetServerCount( args[ 1 ] );

	case WMUI_LAN_GETSERVERADDRESSSTRING:
		LAN_GetServerAddressString( args[ 1 ], args[ 2 ], ( char* )VMA( 3 ), args[ 4 ] );
		return 0;

	case WMUI_LAN_GETSERVERINFO:
		LAN_GetServerInfo( args[ 1 ], args[ 2 ], ( char* )VMA( 3 ), args[ 4 ] );
		return 0;

	case WMUI_LAN_GETSERVERPING:
		return LAN_GetServerPing( args[ 1 ], args[ 2 ] );

	case WMUI_LAN_MARKSERVERVISIBLE:
		LAN_MarkServerVisible( args[ 1 ], args[ 2 ], args[ 3 ] );
		return 0;

	case WMUI_LAN_SERVERISVISIBLE:
		return LAN_ServerIsVisible( args[ 1 ], args[ 2 ] );

	case WMUI_LAN_UPDATEVISIBLEPINGS:
		return CLT3_UpdateVisiblePings( args[ 1 ] );

	case WMUI_LAN_RESETPINGS:
		LAN_ResetPings( args[ 1 ] );
		return 0;

	case WMUI_LAN_SERVERSTATUS:
		return CLT3_ServerStatus( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] );

	case WMUI_SET_PBCLSTATUS:
		return 0;

	case WMUI_SET_PBSVSTATUS:
		return 0;

	case WMUI_LAN_COMPARESERVERS:
		return LAN_CompareServers( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] );

	case WMUI_MEMORY_REMAINING:
		return 0x4000000;

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

	case WMUI_SET_CDKEY:
		CLT3UI_SetCDKey( ( char* )VMA( 1 ) );
		return 0;

	case WMUI_R_REGISTERFONT:
		R_RegisterFont( ( char* )VMA( 1 ), args[ 2 ], ( fontInfo_t* )VMA( 3 ) );
		return 0;

	case WMUI_MEMSET:
		return ( qintptr )memset( VMA( 1 ), args[ 2 ], args[ 3 ] );

	case WMUI_MEMCPY:
		return ( qintptr )memcpy( VMA( 1 ), VMA( 2 ), args[ 3 ] );

	case WMUI_STRNCPY:
		String::NCpy( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] );
		return args[ 1 ];

	case WMUI_SIN:
		return FloatAsInt( sin( VMF( 1 ) ) );

	case WMUI_COS:
		return FloatAsInt( cos( VMF( 1 ) ) );

	case WMUI_ATAN2:
		return FloatAsInt( atan2( VMF( 1 ), VMF( 2 ) ) );

	case WMUI_SQRT:
		return FloatAsInt( sqrt( VMF( 1 ) ) );

	case WMUI_FLOOR:
		return FloatAsInt( floor( VMF( 1 ) ) );

	case WMUI_CEIL:
		return FloatAsInt( ceil( VMF( 1 ) ) );

	case WMUI_PC_ADD_GLOBAL_DEFINE:
		return PC_AddGlobalDefine( ( char* )VMA( 1 ) );
	case WMUI_PC_LOAD_SOURCE:
		return PC_LoadSourceHandle( ( char* )VMA( 1 ) );
	case WMUI_PC_FREE_SOURCE:
		return PC_FreeSourceHandle( args[ 1 ] );
	case WMUI_PC_READ_TOKEN:
		return PC_ReadTokenHandleQ3( args[ 1 ], ( q3pc_token_t* )VMA( 2 ) );
	case WMUI_PC_SOURCE_FILE_AND_LINE:
		return PC_SourceFileAndLine( args[ 1 ], ( char* )VMA( 2 ), ( int* )VMA( 3 ) );

	case WMUI_S_STOPBACKGROUNDTRACK:
		S_StopBackgroundTrack();
		return 0;
	case WMUI_S_STARTBACKGROUNDTRACK:
		S_StartBackgroundTrack( ( char* )VMA( 1 ), ( char* )VMA( 2 ), 0 );
		return 0;

	case WMUI_REAL_TIME:
		return Com_RealTime( ( qtime_t* )VMA( 1 ) );

	case WMUI_CIN_PLAYCINEMATIC:
		return CIN_PlayCinematicStretched( ( char* )VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ], args[ 6 ] );

	case WMUI_CIN_STOPCINEMATIC:
		return CIN_StopCinematic( args[ 1 ] );

	case WMUI_CIN_RUNCINEMATIC:
		return CIN_RunCinematic( args[ 1 ] );

	case WMUI_CIN_DRAWCINEMATIC:
		CIN_DrawCinematic( args[ 1 ] );
		return 0;

	case WMUI_CIN_SETEXTENTS:
		CIN_SetExtents( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] );
		return 0;

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

	case WMUI_VERIFY_CDKEY:
		return CLT3_CDKeyValidate( ( char* )VMA( 1 ), ( char* )VMA( 2 ) );

	case WMUI_CL_GETLIMBOSTRING:
		return CLT3_GetLimboString( args[ 1 ], ( char* )VMA( 2 ) );

	case WMUI_CL_TRANSLATE_STRING:
		CL_TranslateString( ( char* )VMA( 1 ), ( char* )VMA( 2 ) );
		return 0;

	case WMUI_CHECKAUTOUPDATE:
		return 0;

	case WMUI_GET_AUTOUPDATE:
		return 0;

	case WMUI_OPENURL:
		CLT3_OpenURL( ( const char* )VMA( 1 ) );
		return 0;

	default:
		common->Error( "Bad UI system trap: %i", static_cast<int>( args[ 0 ] ) );
	}
	return 0;
}
Exemple #15
0
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;
}
Exemple #16
0
/*
================
SV_SpawnServer

Change the server to a new map, taking all connected
clients along with it.
This is NOT called for map_restart
================
*/
void SV_SpawnServer( char *server, qboolean killBots ) {
	int			i;
	int			checksum;
	char		systemInfo[16384];
	const char	*p;

	// shut down the existing game if it is running
	SV_ShutdownGameProgs();

	Com_Printf ("------ Server Initialization ------\n");
	Com_Printf ("Server: %s\n",server);

	// if not running a dedicated server CL_MapLoading will connect the client to the server
	// also print some status stuff
	CL_MapLoading();

	// make sure all the client stuff is unloaded
	CL_ShutdownAll();

	// clear the whole hunk because we're (re)loading the server
	Hunk_Clear();

#ifndef DEDICATED
	// Restart renderer
	CL_StartHunkUsers( qtrue );
#endif

	// clear collision map data
	CM_ClearMap();

	// init client structures and svs.numSnapshotEntities 
	if ( !Cvar_VariableValue("sv_running") ) {
		SV_Startup();
	} else {
		// check for maxclients or democlients change
		if ( sv_maxclients->modified || sv_democlients->modified ) {
			SV_ChangeMaxClients();
		}
	}

	// clear pak references
	FS_ClearPakReferences(0);

	// allocate the snapshot entities on the hunk
	svs.snapshotEntities = Hunk_Alloc( sizeof(entityState_t)*svs.numSnapshotEntities, h_high );
	svs.nextSnapshotEntities = 0;

	// toggle the server bit so clients can detect that a
	// server has changed
	svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;

	for (i=0 ; i<sv_maxclients->integer ; i++) {
		// save when the server started for each client already connected
		if (svs.clients[i].state >= CS_CONNECTED) {
			svs.clients[i].oldServerTime = sv.time;
		}
	}

	// wipe the entire per-level structure
	SV_ClearServer();
	for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {
		sv.configstrings[i] = CopyString("");
	}

	// make sure we are not paused
	Cvar_Set("cl_paused", "0");

	// get a new checksum feed and restart the file system
	sv.checksumFeed = ( ((int) rand() << 16) ^ rand() ) ^ Com_Milliseconds();
	FS_Restart( sv.checksumFeed );

	CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum );

	// set serverinfo visible name
	Cvar_Set( "mapname", server );

	Cvar_Set( "sv_mapChecksum", va("%i",checksum) );

	// serverid should be different each time
	sv.serverId = com_frameTime;
	sv.restartedServerId = sv.serverId; // I suppose the init here is just to be safe
	sv.checksumFeedServerId = sv.serverId;
	Cvar_Set( "sv_serverid", va("%i", sv.serverId ) );

	// clear physics interaction links
	SV_ClearWorld ();
	
	// media configstring setting should be done during
	// the loading stage, so connected clients don't have
	// to load during actual gameplay
	sv.state = SS_LOADING;

	// load and spawn all other entities
	SV_InitGameProgs();

	// run a few frames to allow everything to settle
	for (i = 0;i < 3; i++)
	{
		VM_Call (gvm, GAME_RUN_FRAME, sv.time);
		sv.time += 100;
		svs.time += 100;
	}

	// create a baseline for more efficient communications
	SV_CreateBaseline ();

	for (i=0 ; i<sv_maxclients->integer ; i++) {
		// send the new gamestate to all connected clients
		if (svs.clients[i].state >= CS_CONNECTED) {
			char	*denied;

			// connect the client again
			denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse ) );	// firstTime = qfalse
			if ( denied ) {
				// this generally shouldn't happen, because the client
				// was connected before the level change
				SV_DropClient( &svs.clients[i], denied );
			} else {
				// when we get the next packet from a connected client,
				// the new gamestate will be sent
				svs.clients[i].state = CS_CONNECTED;
			}
		}
	}	

	// run another frame to allow things to look at all the players
	VM_Call (gvm, GAME_RUN_FRAME, sv.time);
	sv.time += 100;
	svs.time += 100;

	// if a dedicated server we need to touch the cgame because it could be in a
	// seperate pk3 file and the client will need to load the latest cgame.qvm
	if ( com_dedicated->integer ) {
		SV_TouchCGame();
	}

	// the server sends these to the clients so they will only
	// load pk3s also loaded at the server
	Cvar_Set( "sv_paks", sv_pure->integer ? FS_LoadedPakChecksums() : "" );
	Cvar_Set( "sv_pakNames", sv_pure->integer ? FS_LoadedPakNames() : "" );

	// the server sends these to the clients so they can figure
	// out which pk3s should be auto-downloaded
	p = FS_ReferencedPakChecksums();
	Cvar_Set( "sv_referencedPaks", p );
	p = FS_ReferencedPakNames();
	Cvar_Set( "sv_referencedPakNames", p );

	// save systeminfo and serverinfo strings
	Q_strncpyz( systemInfo, Cvar_InfoString_Big( CVAR_SYSTEMINFO ), sizeof( systemInfo ) );
	cvar_modifiedFlags &= ~CVAR_SYSTEMINFO;
	SV_SetConfigstring( CS_SYSTEMINFO, systemInfo );

	SV_SetConfigstring( CS_SERVERINFO, Cvar_InfoString( CVAR_SERVERINFO ) );
	cvar_modifiedFlags &= ~CVAR_SERVERINFO;

	// any media configstring setting now should issue a warning
	// and any configstring changes should be reliably transmitted
	// to all clients
	sv.state = SS_GAME;

	// send a heartbeat now so the master will get up to date info
	SV_Heartbeat_f();

	Hunk_SetMark();

	Com_Printf ("-----------------------------------\n");

	// start recording a demo
	if ( sv_autoDemo->integer ) {
		qtime_t	now;
		Com_RealTime( &now );
		Cbuf_AddText( va( "demo_record %04d%02d%02d%02d%02d%02d-%s\n",
			1900 + now.tm_year,
			1 + now.tm_mon,
			now.tm_mday,
			now.tm_hour,
			now.tm_min,
			now.tm_sec,
			server ) );
	}
}
Exemple #17
0
/*
================
CL_ParseSnapshot

If the snapshot is parsed properly, it will be copied to
cl.snap and saved in cl.snapshots[].  If the snapshot is invalid
for any reason, no changes to the state will be made at all.
================
*/
void CL_ParseSnapshot( msg_t *msg )
{
	int          len;
	clSnapshot_t *old;
	clSnapshot_t newSnap;
	int          deltaNum;
	int          oldMessageNum;
	int          i, packetNum;

	// get the reliable sequence acknowledge number
	// NOTE: now sent with all server to client messages
	//clc.reliableAcknowledge = MSG_ReadLong( msg );

	// read in the new snapshot to a temporary buffer
	// we will only copy to cl.snap if it is valid
	Com_Memset( &newSnap, 0, sizeof( newSnap ) );

	// we will have read any new server commands in this
	// message before we got to svc_snapshot
	newSnap.serverCommandNum = clc.serverCommandSequence;

	newSnap.serverTime = MSG_ReadLong( msg );

	// if we were just unpaused, we can only *now* really let the
	// change come into effect or the client hangs.
	cl_paused->modified = 0;

	newSnap.messageNum = clc.serverMessageSequence;

	deltaNum = MSG_ReadByte( msg );

	if ( !deltaNum )
	{
		newSnap.deltaNum = -1;
	}
	else
	{
		newSnap.deltaNum = newSnap.messageNum - deltaNum;
	}

	newSnap.snapFlags = MSG_ReadByte( msg );

	// If the frame is delta compressed from data that we
	// no longer have available, we must suck up the rest of
	// the frame, but not use it, then ask for a non-compressed
	// message
	if ( newSnap.deltaNum <= 0 )
	{
		newSnap.valid = qtrue; // uncompressed frame
		old = NULL;

		if ( clc.demorecording )
		{
			clc.demowaiting = qfalse; // we can start recording now
//          if(cl_autorecord->integer) {
//              Cvar_Set( "g_synchronousClients", "0" );
//          }
		}
		else
		{
			if ( cl_autorecord->integer /*&& Cvar_VariableValue( "g_synchronousClients") */ )
			{
				char    name[ 256 ];
				char    mapname[ MAX_QPATH ];
				char    *period;
				qtime_t time;

				Com_RealTime( &time );

				Q_strncpyz( mapname, cl.mapname, MAX_QPATH );

				for ( period = mapname; *period; period++ )
				{
					if ( *period == '.' )
					{
						*period = '\0';
						break;
					}
				}

				for ( period = mapname; *period; period++ )
				{
					if ( *period == '/' )
					{
						break;
					}
				}

				if ( *period )
				{
					period++;
				}

				Com_sprintf( name, sizeof( name ), "demos/%s_%04i-%02i-%02i_%02i%02i%02i.dm_%d", period,
				             1900 + time.tm_year, time.tm_mon + 1, time.tm_mday,
				             time.tm_hour, time.tm_min, time.tm_sec,
				             PROTOCOL_VERSION );

				CL_Record( name );
			}
		}
	}
	else
	{
		old = &cl.snapshots[ newSnap.deltaNum & PACKET_MASK ];

		if ( !old->valid )
		{
			// should never happen
			Com_Printf( "Delta from invalid frame (not supposed to happen!).\n" );
		}
		else if ( old->messageNum != newSnap.deltaNum )
		{
			// The frame that the server did the delta from
			// is too old, so we can't reconstruct it properly.
			Com_DPrintf( "Delta frame too old.\n" );
		}
		else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES - 128 )
		{
			Com_DPrintf( "Delta parseEntitiesNum too old.\n" );
		}
		else
		{
			newSnap.valid = qtrue; // valid delta parse
		}
	}

	// read areamask
	len = MSG_ReadByte( msg );

	if ( len > sizeof( newSnap.areamask ) )
	{
		Com_Error( ERR_DROP, "CL_ParseSnapshot: Invalid size %d for areamask.", len );
	}

	MSG_ReadData( msg, &newSnap.areamask, len );

	// read playerinfo
	SHOWNET( msg, "playerstate" );

	if ( old )
	{
		MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps );
	}
	else
	{
		MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps );
	}

	// read packet entities
	SHOWNET( msg, "packet entities" );
	CL_ParsePacketEntities( msg, old, &newSnap );

	// if not valid, dump the entire thing now that it has
	// been properly read
	if ( !newSnap.valid )
	{
		return;
	}

	// clear the valid flags of any snapshots between the last
	// received and this one, so if there was a dropped packet
	// it won't look like something valid to delta from next
	// time we wrap around in the buffer
	oldMessageNum = cl.snap.messageNum + 1;

	if ( newSnap.messageNum - oldMessageNum >= PACKET_BACKUP )
	{
		oldMessageNum = newSnap.messageNum - ( PACKET_BACKUP - 1 );
	}

	for ( ; oldMessageNum < newSnap.messageNum; oldMessageNum++ )
	{
		cl.snapshots[ oldMessageNum & PACKET_MASK ].valid = qfalse;
	}

	// copy to the current good spot
	cl.snap = newSnap;
	cl.snap.ping = 999;

	// calculate ping time
	for ( i = 0; i < PACKET_BACKUP; i++ )
	{
		packetNum = ( clc.netchan.outgoingSequence - 1 - i ) & PACKET_MASK;

		if ( cl.snap.ps.commandTime >= cl.outPackets[ packetNum ].p_serverTime )
		{
			cl.snap.ping = cls.realtime - cl.outPackets[ packetNum ].p_realtime;
			break;
		}
	}

	// save the frame off in the backup array for later delta comparisons
	cl.snapshots[ cl.snap.messageNum & PACKET_MASK ] = cl.snap;

	if ( cl_shownet->integer == 3 )
	{
		Com_Printf( "   snapshot:%i  delta:%i  ping:%i\n", cl.snap.messageNum, cl.snap.deltaNum, cl.snap.ping );
	}

	cl.newSnapshots = qtrue;
}
/*
====================
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_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( 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:
		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_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));
	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:
		// 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 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_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);
		Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] );
	}
	return 0;
}
Exemple #19
0
/*
====================
CL_UISystemCalls

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

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

	case UI_MILLISECONDS:
		return Sys_Milliseconds();

	case UI_CVAR_REGISTER:
		Cvar_Register( 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:
#ifdef IOS_NOTYET
		GLimp_AcquireGL();
		return re.RegisterModel( VMA(1) );
		GLimp_ReleaseGL();
#else
		return re.RegisterModel( VMA(1) );
#endif // IOS

	case UI_R_REGISTERSKIN:
#ifdef IOS_NOTYET
		GLimp_AcquireGL();
		return re.RegisterSkin( VMA(1) );
		GLimp_ReleaseGL();
#else
		return re.RegisterSkin( VMA(1) );
#endif // IOS

	case UI_R_REGISTERSHADERNOMIP:
#ifdef IOS_NOTYET
		GLimp_AcquireGL();
		return re.RegisterShaderNoMip( VMA(1) );
		GLimp_ReleaseGL();
#else
		return re.RegisterShaderNoMip( VMA(1) );
#endif // IOS

	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:
		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:
		return (int)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));
		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: %i", args[0] );

	}

	return 0;
}
Exemple #20
0
char *demoAutoFormat(const char* name) {	
	const	char *format;
	qboolean haveTag = qfalse;
	static char	outBuf[512];
	int			outIndex = 0;
	int			outLeft = sizeof(outBuf) - 1;
	
	int t = 0;
	char timeStamps[MAX_QPATH] = "";
	qtime_t ct;

	char playerName[MAX_QPATH], *mapName = COM_SkipPath(Info_ValueForKey((cl.gameState.stringData + cl.gameState.stringOffsets[CS_SERVERINFO]), "mapname"));
	Q_strncpyz(playerName, Info_ValueForKey((cl.gameState.stringData + cl.gameState.stringOffsets[CS_PLAYERS+cl.snap.ps.clientNum]), "n"), sizeof(playerName));
	Q_CleanStr(playerName, qtrue);
	Com_RealTime(&ct);
	
	format = cl_autoDemoFormat->string;
	if (!format || !format[0]) {
		if (!name || !name[0]) {
			format = "%t";
		} else {
			format = "%n_%t";
		}
	}

	while (*format && outLeft  > 0) {
		if (haveTag) {
			char ch = *format++;
			haveTag = qfalse;
			switch (ch) {
			case 'd':		//date
				Com_sprintf( outBuf + outIndex, outLeft, "%d-%02d-%02d-%02d%02d%02d",
								1900+ct.tm_year, ct.tm_mon+1,ct.tm_mday,
								ct.tm_hour, ct.tm_min, ct.tm_sec);
				outIndex += strlen( outBuf + outIndex );
				break;
			case 'm':		//map
				Com_sprintf( outBuf + outIndex, outLeft, "%s", mapName);
				outIndex += strlen( outBuf + outIndex );
				break;
			case 'n':		//custom demo name
				Com_sprintf( outBuf + outIndex, outLeft, "%s", name);
				outIndex += strlen( outBuf + outIndex );
				break;
			case 'p':		//current player name
				Com_sprintf( outBuf + outIndex, outLeft, "%s", playerName);
				outIndex += strlen( outBuf + outIndex );
				break;
			case 't':		//timestamp
				while (demoAuto.timeStamps[t] && t < MAX_TIMESTAMPS) {
					int min = demoAuto.timeStamps[t] / 60000;
					int sec = (demoAuto.timeStamps[t] / 1000) % 60;
					if (t == 0) {
						Com_sprintf(timeStamps, sizeof(timeStamps), "%02d%02d", min, sec);
					} else {
						Com_sprintf(timeStamps, sizeof(timeStamps), "%s_%02d%02d", timeStamps, min, sec);
					}
					t++;
				}
				Com_sprintf( outBuf + outIndex, outLeft, "%s", timeStamps);
				outIndex += strlen( outBuf + outIndex );
				break;
			case '%':
				outBuf[outIndex++] = '%';
				break;
			default:
				continue;
			}
			outLeft = sizeof(outBuf) - outIndex - 1;
			continue;
		}
		if (*format == '%') {
			haveTag = qtrue;
			format++;
			continue;
		}
		outBuf[outIndex++] = *format++;
		outLeft = sizeof(outBuf) - outIndex - 1;
	}
	outBuf[ outIndex ] = 0;
	return outBuf;
}
Exemple #21
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;
//----(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( args[1] ); // (SA) modified so no_pvs sounds can function
		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;
	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_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:
		return S_RegisterSound( VMA( 1 ), qfalse );
	case CG_S_STARTBACKGROUNDTRACK:
		S_StartBackgroundTrack( VMA( 1 ), VMA( 2 ) );
		return 0;
	case CG_S_STARTSTREAMINGSOUND:
		S_StartStreamingSound( VMA( 1 ), VMA( 2 ), args[3], args[4], args[5] );
		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 ) );
		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;
		// 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_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_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], args[5] );
		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_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:
		startCamera( args[1], args[2] );
		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 ( 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_QUICKMESSAGEALT" ) )    {
				VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_WM_QUICKMESSAGEALT );
			} else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "UIMENU_WM_LIMBO" ) )    {
				VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_WM_LIMBO );
			} else if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "UIMENU_WM_AUTOUPDATE" ) )    {
				VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_WM_AUTOUPDATE );
			}
			// -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 {
				VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_CLIPBOARD );
			}
		}
		return 0;

		// NERVE - SMF
	case CG_INGAME_CLOSEPOPUP:
		// if popup menu is up, then close it
		if ( VMA( 1 ) && !Q_stricmp( VMA( 1 ), "UIMENU_WM_LIMBO" ) ) {
			if ( VM_Call( uivm, UI_GET_ACTIVE_MENU ) == UIMENU_WM_LIMBO ) {
				VM_Call( uivm, UI_KEY_EVENT, K_ESCAPE, qtrue );
				VM_Call( uivm, UI_KEY_EVENT, K_ESCAPE, qtrue );
			}
		}
		return 0;

	case CG_LIMBOCHAT:
		if ( VMA( 1 ) ) {
			CL_AddToLimboChat( VMA( 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_TRANSLATE_STRING:
		CL_TranslateString( VMA( 1 ), VMA( 2 ) );
		return 0;
		// - NERVE - SMF
	default:
		Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] );
	}
	return 0;
}
Exemple #22
0
/**
 * @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]);
    }
}
Exemple #23
0
//	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;
}
/*
====================
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;
}
Exemple #25
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;
}
Exemple #26
0
/*
====================
CL_UISystemCalls

The ui module is making a system call
====================
*/
intptr_t CL_UISystemCalls(intptr_t * args) {
	switch (args[0]) {
		case UI_ERROR:
			Com_Error(ERR_DROP, "%s", (char *)VMA(1));
			return 0;
		case UI_PRINT:
			Com_Printf("%s", (char *)VMA(1));
			return 0;
		case UI_MILLISECONDS:
			return Sys_Milliseconds();
		case UI_CVAR_REGISTER:
			Cvar_Register((vmCvar_t*)VMA(1), (char*)VMA(2), (char*)VMA(3), args[4]);
			return 0;
		case UI_CVAR_UPDATE:
			Cvar_Update((vmCvar_t*)VMA(1));
			return 0;
		case UI_CVAR_SET:
			Cvar_Set((char*)VMA(1), (char*)VMA(2));
			return 0;
		case UI_CVAR_VARIABLEVALUE:
			return FloatAsInt(Cvar_VariableValue((char*)VMA(1)));
		case UI_CVAR_VARIABLESTRINGBUFFER:
			Cvar_VariableStringBuffer((char*)VMA(1), (char*)VMA(2), args[3]);
			return 0;
		case UI_CVAR_LATCHEDVARIABLESTRINGBUFFER:
			Cvar_LatchedVariableStringBuffer((char*)VMA(1), (char*)VMA(2), args[3]);
			return 0;
		case UI_CVAR_SETVALUE:
			Cvar_SetValue((char*)VMA(1), VMF(2));
			return 0;
		case UI_CVAR_RESET:
			Cvar_Reset((char*)VMA(1));
			return 0;
		case UI_CVAR_CREATE:
			Cvar_Get((char*)VMA(1), (char*)VMA(2), args[3], (char*)VMA(4));
			return 0;
		case UI_CVAR_INFOSTRINGBUFFER:
			Cvar_InfoStringBuffer(args[1], (char*)VMA(2), args[3]);
			return 0;
		case UI_ARGC:
			return Cmd_Argc();
		case UI_ARGV:
			Cmd_ArgvBuffer(args[1], (char*)VMA(2), args[3]);
			return 0;
		case UI_CMD_EXECUTETEXT:
			Cbuf_ExecuteText(args[1], (char*)VMA(2));
			return 0;
		case UI_ADDCOMMAND:
			Cmd_AddCommand((char*)VMA(1), NULL, (char*)VMA(3));
			return 0;
		case UI_FS_FOPENFILE:
			return FS_FOpenFileByMode((char*)VMA(1), (fileHandle_t*)VMA( 2 ), (fsMode_t)args[3] );
		case UI_FS_READ:
			FS_Read2(VMA(1), args[2], args[3]);
			return 0;
		case UI_FS_WRITE:
			FS_Write(VMA(1), args[2], args[3]);
			return 0;
		case UI_FS_FCLOSEFILE:
			FS_FCloseFile(args[1]);
			return 0;
		case UI_FS_DELETEFILE:
			return FS_Delete((char*)VMA(1));
		case UI_FS_GETFILELIST:
			return FS_GetFileList((char*)VMA(1), (char*)VMA(2), (char*)VMA(3), args[4]);
		case UI_FS_SEEK:
			return FS_Seek( args[1], args[2], args[3] );
		case UI_R_REGISTERMODEL:
			return re.RegisterModel((char*)VMA(1));
		case UI_R_REGISTERSKIN:
			return re.RegisterSkin((char*)VMA(1));
		case UI_R_REGISTERSHADERNOMIP:
			return re.RegisterShaderNoMip((char*)VMA(1));
		case UI_R_CLEARSCENE:
			re.ClearScene();
			return 0;
		case UI_R_ADDREFENTITYTOSCENE:
			re.AddRefEntityToScene((refEntity_t*)VMA(1));
			return 0;
		case UI_R_ADDPOLYTOSCENE:
			re.AddPolyToScene(args[1], args[2], (polyVert_t*)VMA(3));
			return 0;
		case UI_R_ADDPOLYSTOSCENE:
			re.AddPolysToScene(args[1], args[2], (polyVert_t*)VMA(3), args[4]);
			return 0;
		case UI_R_ADDLIGHTTOSCENE:
			re.AddLightToScene((vec_t*)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), args[7], args[8]);
			return 0;
		case UI_R_ADDCORONATOSCENE:
			re.AddCoronaToScene((vec_t*)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6], (bool)args[7]);
			return 0;
		case UI_R_RENDERSCENE:
			re.RenderScene((refdef_t*)VMA(1));
			return 0;
		case UI_R_SETCOLOR:
			re.SetColor((float*)VMA(1));
			return 0;
		case UI_R_SETCLIPREGION:
			re.SetClipRegion( (float*)VMA(1) );
			return 0;
		case UI_R_DRAW2DPOLYS:
			re.Add2dPolys((polyVert_t*)VMA(1), args[2], args[3]);
			return 0;
		case UI_R_DRAWSTRETCHPIC:
			re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9]);
			return 0;
		case UI_R_DRAWROTATEDPIC:
			re.DrawRotatedPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9], VMF(10));
			return 0;
		case UI_R_MODELBOUNDS:
			re.ModelBounds(args[1], (float*)VMA(2), (float*)VMA(3));
			return 0;
		case UI_UPDATESCREEN:
			SCR_UpdateScreen();
			return 0;
		case UI_CM_LERPTAG:
			return re.LerpTag((orientation_t*)VMA(1), (refEntity_t*)VMA(2), (char*)VMA(3), args[4]);
		case UI_S_REGISTERSOUND:
			return S_RegisterSound((char*)VMA(1), (bool)args[2]);
		case UI_S_STARTLOCALSOUND:
			//S_StartLocalSound(args[1], args[2], args[3]);
			S_StartLocalSound( args[1], args[2] );
			return 0;
		case UI_S_FADESTREAMINGSOUND:
			// Dushan - FIX ME
			//S_FadeStreamingSound(VMF(1), args[2], args[3]);
			return 0;
		case UI_S_FADEALLSOUNDS:
			// Dushan - FIX ME
			//S_FadeAllSounds(VMF(1), args[2], args[3]);
			return 0;
		case UI_KEY_KEYNUMTOSTRINGBUF:
			idKeyInput::KeynumToStringBuf(args[1], (char*)VMA(2), args[3]);
			return 0;
		case UI_KEY_GETBINDINGBUF:
			idKeyInput::GetBindingBuf(args[1], (char*)VMA(2), args[3]);
			return 0;
		case UI_KEY_SETBINDING:
			idKeyInput::SetBinding(args[1], (char*)VMA(2));
			return 0;
		case UI_KEY_BINDINGTOKEYS:
			idKeyInput::GetBindingByString((char*)VMA(1), (int*)VMA(2), (int*)VMA(3));
			return 0;
		case UI_KEY_ISDOWN:
			return idKeyInput::IsDown(args[1]);
		case UI_KEY_GETOVERSTRIKEMODE:
			return idKeyInput::GetOverstrikeMode();
		case UI_KEY_SETOVERSTRIKEMODE:
			idKeyInput::SetOverstrikeMode((bool)args[1]);
			return 0;
		case UI_KEY_CLEARSTATES:
			idKeyInput::ClearStates();
			return 0;
		case UI_KEY_GETCATCHER:
			return idKeyInput::GetCatcher();
		case UI_KEY_SETCATCHER:
			idKeyInput::SetCatcher(args[1]);
			return 0;
		case UI_GETCLIPBOARDDATA:
			GetClipboardData((char*)VMA(1), args[2]);
			return 0;
		case UI_GETCLIENTSTATE:
			GetClientState((uiClientState_t*)VMA(1));
			return 0;
		case UI_GETGLCONFIG:
			CL_GetGlconfig((glconfig_t*)VMA(1));
			return 0;
		case UI_GETCONFIGSTRING:
			return GetConfigString(args[1], (char*)VMA(2), args[3]);
		case UI_LAN_LOADCACHEDSERVERS:
			LAN_LoadCachedServers();
			return 0;
		case UI_LAN_SAVECACHEDSERVERS:
			LAN_SaveServersToCache();
			return 0;
		case UI_LAN_ADDSERVER:
			return LAN_AddServer(args[1], (char*)VMA(2), (char*)VMA(3));
		case UI_LAN_REMOVESERVER:
			LAN_RemoveServer(args[1], (char*)VMA(2));
			return 0;
		case UI_LAN_GETPINGQUEUECOUNT:
			return LAN_GetPingQueueCount();
		case UI_LAN_CLEARPING:
			LAN_ClearPing(args[1]);
			return 0;
		case UI_LAN_GETPING:
			LAN_GetPing(args[1], (char*)VMA(2), args[3], (int*)VMA(4));
			return 0;
		case UI_LAN_GETPINGINFO:
			LAN_GetPingInfo(args[1], (char*)VMA(2), args[3]);
			return 0;
		case UI_LAN_GETSERVERCOUNT:
			return LAN_GetServerCount(args[1]);
		case UI_LAN_GETSERVERADDRESSSTRING:
			LAN_GetServerAddressString(args[1], args[2], (char*)VMA(3), args[4]);
			return 0;
		case UI_LAN_GETSERVERINFO:
			LAN_GetServerInfo(args[1], args[2], (char*)VMA(3), args[4]);
			return 0;
		case UI_LAN_GETSERVERPING:
			return LAN_GetServerPing(args[1], args[2]);
		case UI_LAN_MARKSERVERVISIBLE:
			LAN_MarkServerVisible(args[1], args[2], (bool)args[3]);
			return 0;
		case UI_LAN_SERVERISVISIBLE:
			return LAN_ServerIsVisible(args[1], args[2]);
		case UI_LAN_UPDATEVISIBLEPINGS:
			return LAN_UpdateVisiblePings(args[1]);
		case UI_LAN_RESETPINGS:
			LAN_ResetPings(args[1]);
			return 0;
		case UI_LAN_SERVERSTATUS:
			return LAN_GetServerStatus((char*)VMA(1), (char*)VMA(2), args[3]);
		case UI_LAN_SERVERISINFAVORITELIST:
			return LAN_ServerIsInFavoriteList(args[1], args[2]);
		case UI_GETNEWS:
			return GetNews((bool)args[1]);
		case UI_LAN_COMPARESERVERS:
			return LAN_CompareServers(args[1], args[2], args[3], args[4], args[5]);
		case UI_MEMORY_REMAINING:
			return Hunk_MemoryRemaining();
		case UI_GET_CDKEY:
			CLUI_GetCDKey((char*)VMA(1), args[2]);
			return 0;
		case UI_SET_CDKEY:
			CLUI_SetCDKey((char*)VMA(1));
			return 0;
		case UI_R_REGISTERFONT:
			re.RegisterFont((char*)VMA(1), args[2], (fontInfo_t*)VMA(3));
			return 0;
		case UI_MEMSET:
			return (intptr_t)memset( VMA( 1 ), args[2], args[3] );
		case UI_MEMCPY:
			return (intptr_t)memcpy( VMA( 1 ), VMA( 2 ), args[3] );
		case UI_STRNCPY:
			return (intptr_t)strncpy( (char*)VMA( 1 ), (char*)VMA( 2 ), args[3] );
		case UI_SIN:
			return FloatAsInt(sin(VMF(1)));
		case UI_COS:
			return FloatAsInt(cos(VMF(1)));
		case UI_ATAN2:
			return FloatAsInt(atan2(VMF(1), VMF(2)));
		case UI_SQRT:
			return FloatAsInt(sqrt(VMF(1)));
		case UI_FLOOR:
			return FloatAsInt(floor(VMF(1)));
		case UI_CEIL:
			return FloatAsInt(ceil(VMF(1)));
		case UI_PARSE_ADD_GLOBAL_DEFINE:
			return Parse_AddGlobalDefine( (char*)VMA(1) );
		case UI_PARSE_LOAD_SOURCE:
			return Parse_LoadSourceHandle( (char*)VMA(1) );
		case UI_PARSE_FREE_SOURCE:
			return Parse_FreeSourceHandle( args[1] );
		case UI_PARSE_READ_TOKEN:
			return Parse_ReadTokenHandle( args[1], (pc_token_t*)VMA(2) );
		case UI_PARSE_SOURCE_FILE_AND_LINE:
			return Parse_SourceFileAndLine( args[1], (char*)VMA(2), (int*)VMA(3) );
		case UI_PC_ADD_GLOBAL_DEFINE:
			return Parse_AddGlobalDefine((char*)VMA(1));
		case UI_PC_REMOVE_ALL_GLOBAL_DEFINES:
			Parse_RemoveAllGlobalDefines();
			return 0;
		case UI_PC_LOAD_SOURCE:
			return Parse_LoadSourceHandle((char*)VMA(1));
		case UI_PC_FREE_SOURCE:
			return Parse_FreeSourceHandle(args[1]);
		case UI_PC_READ_TOKEN:
			return Parse_ReadTokenHandle(args[1], (pc_token_t*)VMA(2));
		case UI_PC_SOURCE_FILE_AND_LINE:
			return Parse_SourceFileAndLine(args[1], (char*)VMA(2), (int*)VMA(3));
		case UI_PC_UNREAD_TOKEN:
			Parse_UnreadLastTokenHandle(args[1]);
			return 0;
		case UI_S_STOPBACKGROUNDTRACK:
			S_StopBackgroundTrack();
			return 0;
		case UI_S_STARTBACKGROUNDTRACK:
			//S_StartBackgroundTrack(VMA(1), VMA(2), args[3]);	//----(SA) added fadeup time
			S_StartBackgroundTrack( (char*)VMA(1), (char*)VMA(2));
			return 0;
		case UI_REAL_TIME:
			return Com_RealTime((qtime_t*)VMA(1));
		case UI_CIN_PLAYCINEMATIC:
			Com_DPrintf("UI_CIN_PlayCinematic\n");
			return CIN_PlayCinematic((char*)VMA(1), args[2], args[3], args[4], args[5], args[6]);
		case UI_CIN_STOPCINEMATIC:
			return CIN_StopCinematic(args[1]);
		case UI_CIN_RUNCINEMATIC:
			return CIN_RunCinematic(args[1]);
		case UI_CIN_DRAWCINEMATIC:
			CIN_DrawCinematic(args[1]);
			return 0;
		case UI_CIN_SETEXTENTS:
			CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
			return 0;
		case UI_R_REMAP_SHADER:
			re.RemapShader((char*)VMA(1), (char*)VMA(2), (char*)VMA(3));
			return 0;
		case UI_CL_GETLIMBOSTRING:
			return CL_GetLimboString(args[1], (char*)VMA(2));
		case UI_CL_TRANSLATE_STRING:
			CL_TranslateString((char*)VMA(1), (char*)VMA(2));
			return 0;
		case UI_CHECKAUTOUPDATE:
#if !defined(UPDATE_SERVER)
			CL_CheckAutoUpdate();
#endif
			return 0;
		case UI_GET_AUTOUPDATE:
#if !defined(UPDATE_SERVER)
			CL_GetAutoUpdate();
#endif
			return 0;
		case UI_OPENURL:
			CL_OpenURL((char *)VMA(1));
			return 0;
		case UI_GETHUNKDATA:
			Com_GetHunkInfo((int*)VMA(1), (int*)VMA(2));
			return 0;
#if defined(USE_REFENTITY_ANIMATIONSYSTEM)
		case UI_R_REGISTERANIMATION:
			return re.RegisterAnimation((char *)VMA(1));
		case UI_R_BUILDSKELETON:
			return re.BuildSkeleton((refSkeleton_t*)VMA(1), args[2], args[3], args[4], VMF(5), (bool)args[6]);
		case UI_R_BLENDSKELETON:
			return re.BlendSkeleton((refSkeleton_t*)VMA(1), (refSkeleton_t*)VMA(2), VMF(3));
		case UI_R_BONEINDEX:
			return re.BoneIndex(args[1], (char *)VMA(2));
		case UI_R_ANIMNUMFRAMES:
			return re.AnimNumFrames(args[1]);
		case UI_R_ANIMFRAMERATE:
			return re.AnimFrameRate(args[1]);
#endif
		case UI_GETGLCONFIG2:
			CL_GetGlconfig2((glconfig2_t*)VMA(1));
			return 0;
		case UI_CON_GETTEXT:
			UI_Con_GetText( (char *)VMA( 1 ), args[2], args[3] );
			return 0;
		case UI_CVAR_VARIABLEINT:
			return Cvar_VariableIntegerValue( (char *)VMA(1) );
		case UI_R_DRAWSPRITE: {
				float * uv = (float*)VMA(5);
				re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), uv[0], uv[1], uv[2], uv[3], args[6]);
			} return 0;
		default:
			Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] );

	}

	return 0;
}
Exemple #27
0
/*
====================
CL_UISystemCalls

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

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

	case UI_MILLISECONDS:
		return Sys_Milliseconds();

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

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

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

	case UI_CVAR_VARIABLEVALUE:
		return FloatAsInt( Cvar_VariableValue( (const char *)VMA(1) ) );

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

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

	case UI_CVAR_RESET:
		Cvar_Reset( (const char *)VMA(1) );
		return 0;

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

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

	case UI_ARGC:
		return Cmd_Argc();

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

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

	case UI_FS_FOPENFILE:
		return FS_FOpenFileByMode( (const char *)VMA(1), (int *)VMA(2), (fsMode_t)args[3] );

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

	case UI_FS_WRITE:
		FS_Write( VMA(1), args[2], args[3] );
		return 0;

	case UI_FS_FCLOSEFILE:
		FS_FCloseFile( args[1] );
		return 0;

	case UI_FS_GETFILELIST:
		return FS_GetFileList( (const char *)VMA(1), (const char *)VMA(2), (char *)VMA(3), args[4] );

	case UI_R_REGISTERMODEL:
		return re.RegisterModel( (const char *)VMA(1) );

	case UI_R_REGISTERSKIN:
		return re.RegisterSkin( (const char *)VMA(1) );

	case UI_R_REGISTERSHADERNOMIP:
		return re.RegisterShaderNoMip( (const char *)VMA(1) );

	case UI_R_CLEARSCENE:
		re.ClearScene();
		return 0;

	case UI_R_ADDREFENTITYTOSCENE:
		re.AddRefEntityToScene( (const refEntity_t *)VMA(1) );
		return 0;

	case UI_R_ADDPOLYTOSCENE:
		re.AddPolyToScene( args[1], args[2], (const polyVert_t *)VMA(3), 1 );
		return 0;

	case UI_R_ADDLIGHTTOSCENE:
		re.AddLightToScene( (const float *)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) );
		return 0;

	case UI_R_RENDERSCENE:
		re.RenderScene( (const refdef_t *)VMA(1) );
		return 0;

	case UI_R_SETCOLOR:
		re.SetColor( (const float *)VMA(1) );
		return 0;

	case UI_R_DRAWSTRETCHPIC:
		re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] );
		return 0;

  case UI_R_MODELBOUNDS:
		re.ModelBounds( args[1], (float *)VMA(2), (float *)VMA(3) );
		return 0;

	case UI_UPDATESCREEN:
		SCR_UpdateScreen();
		return 0;

	case UI_CM_LERPTAG:
		re.LerpTag( (orientation_t *)VMA(1), args[2], args[3], args[4], VMF(5), (const char *)VMA(6) );
		return 0;

	case UI_S_REGISTERSOUND:
		return S_RegisterSound( (const char *)VMA(1) );

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

	case UI_KEY_KEYNUMTOSTRINGBUF:
		Key_KeynumToStringBuf( args[1], (char *)VMA(2), args[3] );
		return 0;

	case UI_KEY_GETBINDINGBUF:
		Key_GetBindingBuf( args[1], (char *)VMA(2), args[3] );
		return 0;

	case UI_KEY_SETBINDING:
		Key_SetBinding( args[1], (const char *)VMA(2) );
		return 0;

	case UI_KEY_ISDOWN:
		return Key_IsDown( args[1] );

	case UI_KEY_GETOVERSTRIKEMODE:
		return Key_GetOverstrikeMode();

	case UI_KEY_SETOVERSTRIKEMODE:
		Key_SetOverstrikeMode( (qboolean)args[1] );
		return 0;

	case UI_KEY_CLEARSTATES:
		Key_ClearStates();
		return 0;

	case UI_KEY_GETCATCHER:
		return Key_GetCatcher();

	case UI_KEY_SETCATCHER:
		Key_SetCatcher( args[1] );
		return 0;

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

	case UI_GETCLIENTSTATE:
		GetClientState( (uiClientState_t *)VMA(1) );
		return 0;		

	case UI_GETGLCONFIG:
		CL_GetGlconfig( (glconfig_t *)VMA(1) );
		return 0;

	case UI_GETCONFIGSTRING:
		return GetConfigString( args[1], (char *)VMA(2), args[3] );

	case UI_LAN_LOADCACHEDSERVERS:
		LAN_LoadCachedServers();
		return 0;

	case UI_LAN_SAVECACHEDSERVERS:
		LAN_SaveServersToCache();
		return 0;

	case UI_LAN_ADDSERVER:
		return LAN_AddServer(args[1], (const char *)VMA(2), (const char *)VMA(3));

	case UI_LAN_REMOVESERVER:
		LAN_RemoveServer(args[1], (const char *)VMA(2));
		return 0;

	case UI_LAN_GETPINGQUEUECOUNT:
		return LAN_GetPingQueueCount();

	case UI_LAN_CLEARPING:
		LAN_ClearPing( args[1] );
		return 0;

	case UI_LAN_GETPING:
		LAN_GetPing( args[1], (char *)VMA(2), args[3], (int *)VMA(4) );
		return 0;

	case UI_LAN_GETPINGINFO:
		LAN_GetPingInfo( args[1], (char *)VMA(2), args[3] );
		return 0;

	case UI_LAN_GETSERVERCOUNT:
		return LAN_GetServerCount(args[1]);

	case UI_LAN_GETSERVERADDRESSSTRING:
		LAN_GetServerAddressString( args[1], args[2], (char *)VMA(3), args[4] );
		return 0;

	case UI_LAN_GETSERVERINFO:
		LAN_GetServerInfo( args[1], args[2], (char *)VMA(3), args[4] );
		return 0;

	case UI_LAN_GETSERVERPING:
		return LAN_GetServerPing( args[1], args[2] );

	case UI_LAN_MARKSERVERVISIBLE:
		LAN_MarkServerVisible( args[1], args[2], (qboolean)args[3] );
		return 0;

	case UI_LAN_SERVERISVISIBLE:
		return LAN_ServerIsVisible( args[1], args[2] );

	case UI_LAN_UPDATEVISIBLEPINGS:
		return LAN_UpdateVisiblePings( args[1] );

	case UI_LAN_RESETPINGS:
		LAN_ResetPings( args[1] );
		return 0;

	case UI_LAN_SERVERSTATUS:
		return LAN_GetServerStatus( (char *)VMA(1), (char *)VMA(2), args[3] );

	case UI_LAN_COMPARESERVERS:
		return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] );

	case UI_MEMORY_REMAINING:
		return Hunk_MemoryRemaining();

#ifdef USE_CD_KEY
	case UI_GET_CDKEY:
		CLUI_GetCDKey( (char *)VMA(1), args[2] );
		return 0;

	case UI_SET_CDKEY:
		CLUI_SetCDKey( (char *)VMA(1) );
		return 0;
#endif	// USE_CD_KEY

	case UI_R_REGISTERFONT:
		return re.RegisterFont( (const char *)VMA(1) );

	case UI_R_FONT_STRLENPIXELS:
		return re.Font_StrLenPixels( (const char *)VMA(1), args[2], VMF(3) );

	case UI_R_FONT_STRLENCHARS:
		return re.Font_StrLenChars( (const char *)VMA(1) );

	case UI_R_FONT_STRHEIGHTPIXELS:
		return re.Font_HeightPixels( args[1], VMF(2) );

	case UI_R_FONT_DRAWSTRING:
		re.Font_DrawString( args[1], args[2], (const char *)VMA(3), (const float *) VMA(4), args[5], args[6], VMF(7) );
		return 0;

	case UI_LANGUAGE_ISASIAN:
		return re.Language_IsAsian();

	case UI_LANGUAGE_USESSPACES:
		return re.Language_UsesSpaces();

	case UI_ANYLANGUAGE_READCHARFROMSTRING:
		return re.AnyLanguage_ReadCharFromString( (const char *)VMA(1), (int *) VMA(2), (qboolean *) VMA(3) );

	case UI_MEMSET:
		Com_Memset( VMA(1), args[2], args[3] );
		return 0;

	case UI_MEMCPY:
		Com_Memcpy( VMA(1), VMA(2), args[3] );
		return 0;

	case UI_STRNCPY:
		return (int)strncpy( (char *)VMA(1), (const char *)VMA(2), args[3] );

	case UI_SIN:
		return FloatAsInt( sin( VMF(1) ) );

	case UI_COS:
		return FloatAsInt( cos( VMF(1) ) );

	case UI_ATAN2:
		return FloatAsInt( atan2( VMF(1), VMF(2) ) );

	case UI_SQRT:
		return FloatAsInt( sqrt( VMF(1) ) );

	case UI_FLOOR:
		return FloatAsInt( floor( VMF(1) ) );

	case UI_CEIL:
		return FloatAsInt( ceil( VMF(1) ) );

	case UI_PC_ADD_GLOBAL_DEFINE:
		return botlib_export->PC_AddGlobalDefine( (char *)VMA(1) );
	case UI_PC_LOAD_SOURCE:
		return botlib_export->PC_LoadSourceHandle( (const char *)VMA(1) );
	case UI_PC_FREE_SOURCE:
		return botlib_export->PC_FreeSourceHandle( args[1] );
	case UI_PC_READ_TOKEN:
		return botlib_export->PC_ReadTokenHandle( args[1], (struct pc_token_s *)VMA(2) );
	case UI_PC_SOURCE_FILE_AND_LINE:
		return botlib_export->PC_SourceFileAndLine( args[1], (char *)VMA(2), (int *)VMA(3) );
	case UI_PC_LOAD_GLOBAL_DEFINES:
		return botlib_export->PC_LoadGlobalDefines ( (char *)VMA(1) );
	case UI_PC_REMOVE_ALL_GLOBAL_DEFINES:
		botlib_export->PC_RemoveAllGlobalDefines ( );
		return 0;

	case UI_S_STOPBACKGROUNDTRACK:
		S_StopBackgroundTrack();
		return 0;
	case UI_S_STARTBACKGROUNDTRACK:
		S_StartBackgroundTrack( (const char *)VMA(1), (const char *)VMA(2), qfalse);
		return 0;

	case UI_REAL_TIME:
		return Com_RealTime( (struct qtime_s *)VMA(1) );

	case UI_CIN_PLAYCINEMATIC:
	  Com_DPrintf("UI_CIN_PlayCinematic\n");
	  return CIN_PlayCinematic((const char *)VMA(1), args[2], args[3], args[4], args[5], args[6]);

	case UI_CIN_STOPCINEMATIC:
	  return CIN_StopCinematic(args[1]);

	case UI_CIN_RUNCINEMATIC:
	  return CIN_RunCinematic(args[1]);

	case UI_CIN_DRAWCINEMATIC:
	  CIN_DrawCinematic(args[1]);
	  return 0;

	case UI_CIN_SETEXTENTS:
	  CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
	  return 0;

	case UI_R_REMAP_SHADER:
		re.RemapShader( (const char *)VMA(1), (const char *)VMA(2), (const char *)VMA(3) );
		return 0;

#ifdef USE_CD_KEY
	case UI_VERIFY_CDKEY:
		return CL_CDKeyValidate((const char *)VMA(1), (const char *)VMA(2));
#endif // USE_CD_KEY

	case UI_SP_REGISTER:
		return !!SP_Register((const char *)VMA(1),SP_REGISTER_MENU);

	case UI_SP_GETSTRINGTEXTSTRING:
		const char* text;

		assert(VMA(1));
		assert(VMA(2));
		text = SP_GetStringTextString((const char *) VMA(1));
		Q_strncpyz( (char *) VMA(2), text, args[3] );
		return qtrue;

/*
Ghoul2 Insert Start
*/
	case UI_G2_ANGLEOVERRIDE:
		return G2API_SetBoneAngles(*((CGhoul2Info_v *)VMA(1)), args[2], (const char *)VMA(3), (float *)VMA(4), args[5],
							 (const Eorientations) args[6], (const Eorientations) args[7], (const Eorientations) args[8],
							 (qhandle_t *)VMA(9), args[10], args[11] );
/*
Ghoul2 Insert End
*/
	default:
		Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] );

	}

	return 0;
}
Exemple #28
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_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_SETVALUE:
		Cvar_SetValueSafe( VMA(1), VMF(2) );
		return 0;

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

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

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

	case UI_ARGC:
		return Cmd_Argc();

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

	case UI_CMD_EXECUTETEXT:
		if(args[1] == 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_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_R_REGISTERMODEL:
		return re.RegisterModel( VMA(1) );

	case UI_R_REGISTERSKIN:
		return re.RegisterSkin( VMA(1) );

	case UI_R_REGISTERSHADERNOMIP:
		return re.RegisterShaderNoMip( VMA(1) );

	case UI_R_CLEARSCENE:
		re.ClearScene();
		return 0;

	case UI_R_ADDREFENTITYTOSCENE:
		re.AddRefEntityToScene( VMA(1) );
		return 0;

	case UI_R_ADDPOLYTOSCENE:
		re.AddPolyToScene( args[1], args[2], VMA(3), 1 );
		return 0;

	case UI_R_ADDLIGHTTOSCENE:
		re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) );
		return 0;

	case UI_R_RENDERSCENE:
		re.RenderScene( VMA(1) );
		return 0;

	case UI_R_SETCOLOR:
		re.SetColor( VMA(1) );
		return 0;

	case UI_R_DRAWSTRETCHPIC:
		re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] );
		return 0;

  case UI_R_MODELBOUNDS:
		re.ModelBounds( args[1], VMA(2), VMA(3) );
		return 0;

	case UI_UPDATESCREEN:
		SCR_UpdateScreen();
		return 0;

	case UI_CM_LERPTAG:
		re.LerpTag( VMA(1), args[2], args[3], args[4], VMF(5), VMA(6) );
		return 0;

	case UI_S_REGISTERSOUND:
		return S_RegisterSound( VMA(1), args[2] );

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

	case UI_KEY_KEYNUMTOSTRINGBUF:
		Key_KeynumToStringBuf( args[1], VMA(2), args[3] );
		return 0;

	case UI_KEY_GETBINDINGBUF:
		Key_GetBindingBuf( args[1], VMA(2), args[3] );
		return 0;

	case UI_KEY_SETBINDING:
		Key_SetBinding( args[1], VMA(2) );
		return 0;

	case UI_KEY_ISDOWN:
		return Key_IsDown( args[1] );

	case UI_KEY_GETOVERSTRIKEMODE:
		return Key_GetOverstrikeMode();

	case UI_KEY_SETOVERSTRIKEMODE:
		Key_SetOverstrikeMode( args[1] );
		return 0;

	case UI_KEY_CLEARSTATES:
		Key_ClearStates();
		return 0;

	case UI_KEY_GETCATCHER:
		return Key_GetCatcher();

	case UI_KEY_SETCATCHER:
		// Don't allow the ui module to close the console
		Key_SetCatcher( args[1] | ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) );
		return 0;

	case UI_GETCLIPBOARDDATA:
		CL_GetClipboardData( VMA(1), args[2] );
		return 0;

	case UI_GETCLIENTSTATE:
		GetClientState( VMA(1) );
		return 0;		

	case UI_GETGLCONFIG:
		CL_GetGlconfig( VMA(1) );
		return 0;

	case UI_GETCONFIGSTRING:
		return GetConfigString( args[1], VMA(2), args[3] );

	case UI_LAN_LOADCACHEDSERVERS:
		LAN_LoadCachedServers();
		return 0;

	case UI_LAN_SAVECACHEDSERVERS:
		LAN_SaveServersToCache();
		return 0;

	case UI_LAN_ADDSERVER:
		return LAN_AddServer(args[1], VMA(2), VMA(3));

	case UI_LAN_REMOVESERVER:
		LAN_RemoveServer(args[1], VMA(2));
		return 0;

	case UI_LAN_GETPINGQUEUECOUNT:
		return LAN_GetPingQueueCount();

	case UI_LAN_CLEARPING:
		LAN_ClearPing( args[1] );
		return 0;

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

	case UI_LAN_GETPINGINFO:
		LAN_GetPingInfo( args[1], VMA(2), args[3] );
		return 0;

	case UI_LAN_GETSERVERCOUNT:
		return LAN_GetServerCount(args[1]);

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

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

	case UI_LAN_GETSERVERPING:
		return LAN_GetServerPing( args[1], args[2] );

	case UI_LAN_MARKSERVERVISIBLE:
		LAN_MarkServerVisible( args[1], args[2], args[3] );
		return 0;

	case UI_LAN_SERVERISVISIBLE:
		return LAN_ServerIsVisible( args[1], args[2] );

	case UI_LAN_UPDATEVISIBLEPINGS:
		return LAN_UpdateVisiblePings( args[1] );

	case UI_LAN_RESETPINGS:
		LAN_ResetPings( args[1] );
		return 0;

	case UI_LAN_SERVERSTATUS:
		return LAN_GetServerStatus( VMA(1), VMA(2), args[3] );

	case UI_LAN_COMPARESERVERS:
		return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] );

	case UI_MEMORY_REMAINING:
		return Hunk_MemoryRemaining();

	case UI_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_S_STOPBACKGROUNDTRACK:
		S_StopBackgroundTrack();
		return 0;
	case UI_S_STARTBACKGROUNDTRACK:
		S_StartBackgroundTrack( VMA(1), VMA(2));
		return 0;

	case UI_REAL_TIME:
		return Com_RealTime( VMA(1) );

	case UI_CIN_PLAYCINEMATIC:
	  Com_DPrintf("UI_CIN_PlayCinematic\n");
	  return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]);

	case UI_CIN_STOPCINEMATIC:
	  return CIN_StopCinematic(args[1]);

	case UI_CIN_RUNCINEMATIC:
	  return CIN_RunCinematic(args[1]);

	case UI_CIN_DRAWCINEMATIC:
	  CIN_DrawCinematic(args[1]);
	  return 0;

	case UI_CIN_SETEXTENTS:
	  CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
	  return 0;

	case UI_R_REMAP_SHADER:
		re.RemapShader( VMA(1), VMA(2), VMA(3) );
		return 0;
		
	default:
		Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] );

	}

	return 0;
}
Exemple #29
0
/*
====================
CL_UISystemCalls

The ui module is making a system call
====================
*/
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:
		return (intptr_t)strncpy((char *)VMA(1), (const char *)VMA(2), args[3]);
	case TRAP_SIN:
		return FloatAsInt(sin(VMF(1)));
	case TRAP_COS:
		return FloatAsInt(cos(VMF(1)));
	case TRAP_ATAN2:
		return FloatAsInt(atan2(VMF(1), VMF(2)));
	case TRAP_SQRT:
		return FloatAsInt(sqrt(VMF(1)));
	case TRAP_MATRIXMULTIPLY:
		MatrixMultiply((vec3_t *)VMA(1), (vec3_t *)VMA(2), (vec3_t *)VMA(3));
		return 0;
	case TRAP_ANGLEVECTORS:
		AngleVectors((const float *)VMA(1), (float *)VMA(2), (float *)VMA(3), (float *)VMA(4));
		return 0;
	case TRAP_PERPENDICULARVECTOR:
		PerpendicularVector((float *)VMA(1), (const float *)VMA(2));
		return 0;
	case TRAP_FLOOR:
		return FloatAsInt(floor(VMF(1)));
	case TRAP_CEIL:
		return FloatAsInt(ceil(VMF(1)));
	case TRAP_TESTPRINTINT:
		return 0;
	case TRAP_TESTPRINTFLOAT:
		return 0;
	case TRAP_ACOS:
		return FloatAsInt(Q_acos(VMF(1)));
	case TRAP_ASIN:
		return FloatAsInt(Q_asin(VMF(1)));
	case UI_ERROR:
		Com_Error( ERR_DROP, "%s", VMA(1) );
		return 0;

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

	case UI_MILLISECONDS:
		return Sys_Milliseconds();

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

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

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

	case UI_CVAR_VARIABLEVALUE:
		return FloatAsInt( Cvar_VariableValue( (const char *)VMA(1) ) );

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

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

	case UI_CVAR_RESET:
		Cvar_Reset( (const char *)VMA(1) );
		return 0;

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

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

	case UI_ARGC:
		return Cmd_Argc();

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

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

	case UI_FS_FOPENFILE:
		return FS_FOpenFileByMode( (const char *)VMA(1), (int *)VMA(2), (fsMode_t)args[3] );

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

	case UI_FS_WRITE:
		FS_Write( VMA(1), args[2], args[3] );
		return 0;

	case UI_FS_FCLOSEFILE:
		FS_FCloseFile( args[1] );
		return 0;

	case UI_FS_GETFILELIST:
		return FS_GetFileList( (const char *)VMA(1), (const char *)VMA(2), (char *)VMA(3), args[4] );

	case UI_R_REGISTERMODEL:
		return re.RegisterModel( (const char *)VMA(1) );

	case UI_R_REGISTERSKIN:
		return re.RegisterSkin( (const char *)VMA(1) );

	case UI_R_REGISTERSHADERNOMIP:
		return re.RegisterShaderNoMip( (const char *)VMA(1) );

	case UI_R_SHADERNAMEFROMINDEX:
		{
			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:
#ifdef __ANDROID__
		re.Font_DrawString( VMF(1), VMF(2), (const char *)VMA(3), (const float *) VMA(4), args[5], args[6], VMF(7) );
#else
		{float ox, oy;
		if (cls.mmeState >= MME_STATE_DEFAULT) {
			ox = VMF(1); oy = VMF(2);
		} else {
			ox = args[1]; oy = args[2];
		}
		re.Font_DrawString( ox, oy, (const char *)VMA(3), (const float *) VMA(4), args[5], args[6], VMF(7) );}
		return 0;
#endif
	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((const intptr_t)VMA(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]);
		}
/*
Ghoul2 Insert End
*/
	case UI_MME_FONTRATIOFIX:
		re.FontRatioFix(VMF(1));
        return 0; 
	case UI_MME_EDITINGFIELD:
		cls.uiEditingField = (qboolean)args[1];
        return 0;	
	default:
		Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] );

	}

	return 0;
}
Exemple #30
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_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.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 ) );

			//----(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:
#ifdef IPHONE_NOTYET
			GLimp_AcquireGL();
			return re.RegisterShader( VMA( 1 ) );
			GLimp_ReleaseGL();
#else
			return re.RegisterShader( VMA( 1 ) );
#endif // IPHONE

		case CG_R_REGISTERFONT:
			re.RegisterFontVM( VMA( 1 ), VMA( 2 ), args[ 3 ], VMA( 4 ) );
			return 0;

		case CG_R_REGISTERSHADERNOMIP:
#ifdef IPHONE_NOTYET
			GLimp_AcquireGL();
			return re.RegisterShaderNoMip( VMA( 1 ) );
			GLimp_ReleaseGL();
#else
			return re.RegisterShaderNoMip( VMA( 1 ) );
#endif // IPHONE
#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_LOADCAMERA:
			//return loadCamera(args[1], VMA(2));
			return 0;

		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;
			//}
			return 0;

		case CG_GETCAMERAINFO:
			//return getCameraInfo(args[1], args[2], VMA(3), VMA(4), VMA(5));
			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;

		case CG_PUMPEVENTLOOP:
//      Com_EventLoop();
//      CL_WritePacket();
			return 0;

			//zinx - binary channel
		case CG_SENDMESSAGE:
			VM_CheckBlock( args[1], args[2], "SENDM" );
 			CL_SendBinaryMessage( VMA( 1 ), args[ 2 ] );
			return 0;

		case CG_MESSAGESTATUS:
			return CL_BinaryMessageStatus();

			//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_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;
}