Пример #1
0
void DrawStartSeverLevelshot(void)
{
	char startmap[MAX_QPATH];
	char mapshotname[MAX_QPATH];
	int i = s_startmap_list.curvalue;

	Q_strlcpy (startmap, strchr(mapnames[i], '\n') + 1, sizeof(startmap));

	SCR_FillRect (SCREEN_WIDTH / 2 + 44, SCREEN_HEIGHT / 2 - 100, 244, 184, colorWhite);

	if (levelshotvalid[i] == M_UNSET)
	{
		// init levelshot
		Com_sprintf(mapshotname, sizeof(mapshotname), "levelshots/%s.png", startmap);
		if (RE_Draw_RegisterPic(mapshotname))
			levelshotvalid[i] = M_FOUND;
		else
			levelshotvalid[i] = M_MISSING;
	}

	if (levelshotvalid[i] == M_FOUND)
	{
		Com_sprintf (mapshotname, sizeof(mapshotname), "levelshots/%s.png", startmap);
		SCR_DrawPic (SCREEN_WIDTH / 2 + 46, SCREEN_HEIGHT / 2 - 98, 240, 180, mapshotname);
	}
	else if (levelshotvalid[nummaps] == M_FOUND)
	{
		SCR_DrawPic (SCREEN_WIDTH / 2 + 46, SCREEN_HEIGHT / 2 - 98, 240, 180, "levelshots/unknownmap.png");
	}
	else
	{
		SCR_FillRect (SCREEN_WIDTH / 2 + 46, SCREEN_HEIGHT / 2 - 98, 240, 180, colorBlack);
	}
}
Пример #2
0
void Con_DrawConsoleScrollbar( void )
{
	vec4_t color;
	const int	freeConsoleHeight = consoleState.height - consoleState.padding.top - consoleState.padding.bottom;
	const float scrollBarX = cls.glconfig.vidWidth - consoleState.margin.sides - consoleState.padding.sides - 2 * consoleState.border.sides;
	const float scrollBarY = consoleState.margin.top + consoleState.border.top + consoleState.padding.top + freeConsoleHeight * 0.10f;
	const float scrollBarLength = freeConsoleHeight * 0.80f;
	const float scrollBarWidth = consoleState.border.sides * 2;

	const float scrollHandleLength = consoleState.usedScrollbackLengthInLines
	                                 ? scrollBarLength * std::min( 1.0f, (float) consoleState.visibleAmountOfLines / consoleState.usedScrollbackLengthInLines )
	                                 : 0;

	const float scrollBarLengthPerLine = ( scrollBarLength - scrollHandleLength ) / ( consoleState.usedScrollbackLengthInLines - consoleState.visibleAmountOfLines );
	// that may result in -NaN

	const float relativeScrollLineIndex = consoleState.currentLine - consoleState.usedScrollbackLengthInLines
				+ std::min(consoleState.visibleAmountOfLines, consoleState.usedScrollbackLengthInLines);

	const float scrollHandlePostition = ( scrollBarLengthPerLine == scrollBarLengthPerLine )
	                                  ? scrollBarLengthPerLine * ( consoleState.bottomDisplayedLine - relativeScrollLineIndex )
	                                  : 0; // we may get this: +/- NaN is never equal to itself

	//draw the scrollBar
	color[ 0 ] = 0.2f;
	color[ 1 ] = 0.2f;
	color[ 2 ] = 0.2f;
	color[ 3 ] = 0.75f * consoleState.currentAlphaFactor;

	SCR_FillRect( scrollBarX, scrollBarY, scrollBarWidth, scrollBarLength, color );

	//draw the handle
	if ( scrollHandlePostition >= 0 && scrollHandleLength > 0 )
	{
		color[ 0 ] = 0.5f;
		color[ 1 ] = 0.5f;
		color[ 2 ] = 0.5f;
		color[ 3 ] = consoleState.currentAlphaFactor;

		SCR_FillRect( scrollBarX, scrollBarY + scrollHandlePostition, scrollBarWidth, scrollHandleLength, color );
	}
	else if ( consoleState.usedScrollbackLengthInLines ) //this happens when line appending gets us over the top position in a roll-lock situation (scrolling itself won't do that)
	{
		color[ 0 ] = (-scrollHandlePostition * 5.0f)/10;
		color[ 1 ] = 0.5f;
		color[ 2 ] = 0.5f;
		color[ 3 ] = consoleState.currentAlphaFactor;

		SCR_FillRect( scrollBarX, scrollBarY, scrollBarWidth, scrollHandleLength, color );
	}

	if(con_debug->integer) {
		Con_DrawRightFloatingTextLine( 6, NULL, va( "Scrollbar (px): Size %d HandleSize %d Position %d", (int) scrollBarLength, (int) scrollHandleLength, (int) scrollHandlePostition ) );
	}
}
Пример #3
0
static void SpinControl_Draw(menulist_s *s)
{
	float	*color;
	float	x, y;
	int		style = 0;
	qboolean focus;

	x = s->generic.x;
	y =	s->generic.y;

	focus = (s->generic.parent->cursor == s->generic.menuPosition);

	if (s->generic.flags & QMF_GRAYED) {
		color = colorTextDisabled;
	} else if (focus) {
		color = colorTextHighlight;
		style |= FONT_PULSE;
	} else if (s->generic.flags & QMF_BLINK) {
		color = colorTextHighlight;
		style |= FONT_BLINK;
	} else {
		color = colorTextNormal;
	}

	if (focus) {
		// draw cursor
		SCR_FillRect(s->generic.left, s->generic.top, s->generic.right-s->generic.left+1, s->generic.bottom-s->generic.top+1, colorListbar);
		SCR_DrawString(x, y, "\15", SMALLCHAR_SIZE, FONT_CENTER | FONT_BLINK, color);
	}

	SCR_DrawString(x - SMALLCHAR_SIZE, y, s->generic.name, SMALLCHAR_SIZE, style | FONT_RIGHT, color);
	SCR_DrawString(x + SMALLCHAR_SIZE, y, s->itemnames[s->curvalue], SMALLCHAR_SIZE, style, color);
}
Пример #4
0
void UI_FillPal( int x, int y, int w, int h, int c ) {
	if ( ( unsigned )c > 255 ) {
		common->FatalError( "UI_FillPal: bad color" );
	}
	float colour[ 4 ] = { r_palette[ c ][ 0 ] / 255.0, r_palette[ c ][ 1 ] / 255.0, r_palette[ c ][ 2 ] / 255.0, 1 };
	SCR_FillRect( x, y, w, h, colour );
}
Пример #5
0
void ScrollList_Draw(menulist_s *l)
{
	float		x;
	float		u;
	float		y;
	int			i;
	int			base;
	int			column;
	float*		color;
	qboolean	hasfocus;
	int			style;

	hasfocus = (l->generic.parent->cursor == l->generic.menuPosition);

	x = l->generic.x;
	for (column = 0; column < l->columns; column++) {
		y = l->generic.y;
		base = l->top + column * l->height;
		for (i = base; i < base + l->height; i++) {
			if (i >= l->numitems) {
				break;
			}

			if (i == l->curvalue) {
				u = x - 2;
				if (l->generic.flags & QMF_CENTER_JUSTIFY) {
					u -= (l->width * SMALLCHAR_SIZE) / 2 + 1;
				}

				SCR_FillRect(u, y, l->width*SMALLCHAR_SIZE, SMALLCHAR_SIZE+2, colorListbar);
				color = colorTextHighlight;

				if (hasfocus) {
					style = FONT_PULSE;
				} else {
					style = 0;
				}
			} else {
				color = colorTextNormal;
				style = 0;
			}

			if (l->generic.flags & QMF_CENTER_JUSTIFY) {
				style |= FONT_CENTER;
			}

			SCR_DrawString(x, y, l->itemnames[i], SMALLCHAR_SIZE, style, color);

			y += SMALLCHAR_SIZE;
		}
		x += (l->width + l->seperation) * SMALLCHAR_SIZE;
	}
}
Пример #6
0
void MenuField_Draw(menufield_s *f)
{
	int		x;
	int		y;
	int		w;
	int		style;
	qboolean focus;
	float	*color;

	x =	f->generic.x;
	y =	f->generic.y;

	if (f->generic.flags & QMF_SMALLFONT) {
		w = SMALLCHAR_SIZE;
		style = FONT_SMALL;
	} else {
		w = BIGCHAR_SIZE;
		style = 0;
	}

	if (Menu_ItemAtCursor(f->generic.parent) == f) {
		focus = qtrue;
		style |= FONT_PULSE;
	} else {
		focus = qfalse;
	}

	if (f->generic.flags & QMF_GRAYED) {
		color = colorTextDisabled;
	} else if (focus) {
		color = colorTextHighlight;
	} else {
		color = colorTextNormal;
	}

	if (focus) {
		// draw cursor
		SCR_FillRect(f->generic.left, f->generic.top, f->generic.right-f->generic.left+1, f->generic.bottom-f->generic.top+1, colorListbar);
		SCR_DrawString(x, y, "\15", w, FONT_CENTER | FONT_BLINK, color);
	}

	if (f->generic.name) {
		SCR_DrawString(x - w, y, f->generic.name, w, FONT_RIGHT, color);
	}

	MField_Draw(&f->field, x + w, y, w, style, color);
}
Пример #7
0
void Con_DrawScrollbackMarkerline( int lineDrawPosition )
{
	vec4_t color;

	//to not run into the scrollbar
	const int scrollBarImpliedPadding = 2 * consoleState.padding.sides + 2 * consoleState.border.sides;

	color[ 0 ] = 0.8f;
	color[ 1 ] = 0.0f;
	color[ 2 ] = 0.0f;
	color[ 3 ] = 0.5f * consoleState.currentAlphaFactor;

	SCR_FillRect(	consoleState.margin.sides + consoleState.border.sides + consoleState.padding.sides/2,
					lineDrawPosition + SCR_ConsoleFontCharVPadding(),
					cls.glconfig.vidWidth - 2 * consoleState.margin.sides - 2 * consoleState.border.sides - consoleState.padding.sides/2 - scrollBarImpliedPadding,
					1, color );
}
Пример #8
0
/*
================
Con_DrawBackground

Draws the background of the console (on the virtual 640x480 resolution)
================
*/
void Con_DrawBackground( void )
{
	vec4_t color;
	const int consoleWidth = cls.glconfig.vidWidth - 2 * consoleState.margin.sides;

	// draw the background
	color[ 0 ] = con_colorRed->value;
	color[ 1 ] = con_colorGreen->value;
	color[ 2 ] = con_colorBlue->value;
	color[ 3 ] = con_colorAlpha->value * consoleState.currentAlphaFactor;

	SCR_FillRect( consoleState.margin.sides, consoleState.margin.top, consoleWidth, consoleState.height, color );

	// draw the backgrounds borders
	color[ 0 ] = con_borderColorRed->value;
	color[ 1 ] = con_borderColorGreen->value;
	color[ 2 ] = con_borderColorBlue->value;
	color[ 3 ] = con_borderColorAlpha->value * consoleState.currentAlphaFactor;

	if ( con_margin->integer )
	{
		//top border
		SCR_FillRect( consoleState.margin.sides - consoleState.border.sides,
		              consoleState.margin.top - consoleState.border.top,
		              consoleWidth + consoleState.border.sides, consoleState.border.top, color );
		//left border
		SCR_FillRect( consoleState.margin.sides - consoleState.border.sides, consoleState.margin.top,
		              consoleState.border.sides, consoleState.height + consoleState.border.bottom, color );

		//right border
		SCR_FillRect( cls.glconfig.vidWidth - consoleState.margin.sides, consoleState.margin.top - consoleState.border.top,
		              consoleState.border.sides, consoleState.border.top + consoleState.height, color );

		//bottom border
		SCR_FillRect( consoleState.margin.sides, consoleState.height + consoleState.margin.top + consoleState.border.top - consoleState.border.bottom,
		              consoleWidth + consoleState.border.sides, consoleState.border.bottom, color );
	}
	else
	{
		//bottom border
		SCR_FillRect( 0, consoleState.height, consoleWidth, consoleState.border.bottom, color );
	}
}
Пример #9
0
/*
================
Con_DrawSolidConsole

Draws the console with the solid background
================
*/
void Con_DrawSolidConsole( float frac )
{
	int    i, x, y;
	int    rows;
	int    row;
	int    lines;
//	qhandle_t    conShader;
	int    currentColor;
	vec4_t color;
	float  yVer;
	float  totalwidth;
	float  currentWidthLocation = 0;

	const int charHeight = SCR_ConsoleFontCharHeight();

	if ( scr_conUseOld->integer )
	{
		lines = cls.glconfig.vidHeight * frac;

		if ( lines <= 0 )
		{
			return;
		}

		if ( lines > cls.glconfig.vidHeight )
		{
			lines = cls.glconfig.vidHeight;
		}
	}
	else
	{
		lines = cls.glconfig.vidHeight * frac;
	}
	lines += charHeight / ( CONSOLE_FONT_VPADDING + 1 );

	// on wide screens, we will center the text
	if (!scr_conUseOld->integer)
	{
		con.xadjust = 15;
	}

	SCR_AdjustFrom640 (&con.xadjust, NULL, NULL, NULL);

	// draw the background
	if ( scr_conUseOld->integer )
	{
		yVer = 5 + charHeight;
		y = frac * SCREEN_HEIGHT;

		if ( y < 1 )
		{
			y = 0;
		}
		else
		{
			if ( scr_conUseShader->integer )
			{
				SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader );
			}
			else
			{
				// This will be overwritten, so i'll just abuse it here, no need to define another array
				color[ 0 ] = scr_conColorRed->value;
				color[ 1 ] = scr_conColorGreen->value;
				color[ 2 ] = scr_conColorBlue->value;
				color[ 3 ] = scr_conColorAlpha->value;

				SCR_FillRect( 0, 0, SCREEN_WIDTH, y, color );
			}
		}

		color[ 0 ] = scr_conBarColorRed->value;
		color[ 1 ] = scr_conBarColorGreen->value;
		color[ 2 ] = scr_conBarColorBlue->value;
		color[ 3 ] = scr_conBarColorAlpha->value;

		SCR_FillRect( 0, y, SCREEN_WIDTH, scr_conBarSize->value, color );
	}
	else
	{
		yVer = 10;
		SCR_AdjustFrom640( NULL, &yVer, NULL, NULL );
		yVer = floor( yVer + 5 + charHeight );

		color[ 0 ] = scr_conColorRed->value;
		color[ 1 ] = scr_conColorGreen->value;
		color[ 2 ] = scr_conColorBlue->value;
		color[ 3 ] = frac * 2 * scr_conColorAlpha->value;
		SCR_FillRect( 10, 10, 620, 460 * scr_conHeight->integer * 0.01, color );

		color[ 0 ] = scr_conBarColorRed->value;
		color[ 1 ] = scr_conBarColorGreen->value;
		color[ 2 ] = scr_conBarColorBlue->value;
		color[ 3 ] = frac * 2 * scr_conBarColorAlpha->value;
		SCR_FillRect( 10, 10, 620, 1, color );  //top
		SCR_FillRect( 10, 460 * scr_conHeight->integer * 0.01 + 10, 621, 1, color );  //bottom
		SCR_FillRect( 10, 10, 1, 460 * scr_conHeight->integer * 0.01, color );  //left
		SCR_FillRect( 630, 10, 1, 460 * scr_conHeight->integer * 0.01, color );  //right
	}

	// draw the version number

	color[ 0 ] = 1.0f;
	color[ 1 ] = 1.0f;
	color[ 2 ] = 1.0f;
	color[ 3 ] = ( scr_conUseOld->integer ? 0.75f : frac * 0.75f );
	re.SetColor( color );

	i = strlen( Q3_VERSION );
	totalwidth = SCR_ConsoleFontStringWidth( Q3_VERSION, i ) + cl_conXOffset->integer;

	if ( !scr_conUseOld->integer )
	{
		totalwidth += 30;
	}

	currentWidthLocation = cls.glconfig.vidWidth - totalwidth;

	for ( x = 0; x < i; x++ )
	{
		int ch = Q_UTF8CodePoint( &Q3_VERSION[ x ] );
		SCR_DrawConsoleFontUnichar( currentWidthLocation, yVer, ch );
		currentWidthLocation += SCR_ConsoleFontUnicharWidth( ch );
	}

	// engine string
	i = strlen( Q3_ENGINE );
	totalwidth = SCR_ConsoleFontStringWidth( Q3_ENGINE, i ) + cl_conXOffset->integer;

	if ( !scr_conUseOld->integer )
	{
		totalwidth += 30;
	}

	currentWidthLocation = cls.glconfig.vidWidth - totalwidth;

	for ( x = 0; x < i; x++ )
	{
		int ch = Q_UTF8CodePoint( &Q3_ENGINE[ x ] );
		SCR_DrawConsoleFontUnichar( currentWidthLocation, yVer + charHeight, ch );
		currentWidthLocation += SCR_ConsoleFontUnicharWidth( ch );
	}

	// draw the input prompt, user text, and cursor if desired
	// moved back here (have observed render issues to do with time taken)
	Con_DrawInput();

	// draw the text
	con.vislines = lines;
	rows = ( lines ) / SCR_ConsoleFontCharHeight() - 3; // rows of text to draw

	if ( scr_conUseOld->integer )
	{
		rows++;
	}

	y = lines - ( SCR_ConsoleFontCharHeight() * 3 ) + 10;

	// draw from the bottom up
	if ( con.display != con.current )
	{
		// draw arrows to show the buffer is backscrolled
		const int hatWidth = SCR_ConsoleFontUnicharWidth( '^' );

		color[ 0 ] = 1.0f;
		color[ 1 ] = 0.0f;
		color[ 2 ] = 0.0f;
		color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : frac * 2.0f );
		re.SetColor( color );

		for ( x = 0; x < con.linewidth - ( scr_conUseOld->integer ? 0 : 4 ); x += 4 )
		{
			SCR_DrawConsoleFontUnichar( con.xadjust + ( x + 1 ) * hatWidth, y, '^' );
		}

		y -= charHeight;
		rows--;
	}

	row = con.display;

	if ( con.x == 0 )
	{
		row--;
	}

	currentColor = 7;
	color[ 0 ] = g_color_table[ currentColor ][ 0 ];
	color[ 1 ] = g_color_table[ currentColor ][ 1 ];
	color[ 2 ] = g_color_table[ currentColor ][ 2 ];
	color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : frac * 2.0f );
	re.SetColor( color );

	for ( i = 0; i < rows; i++, y -= charHeight, row-- )
	{
		conChar_t *text;

		if ( row < 0 )
		{
			break;
		}

		if ( con.current - row >= con.totallines )
		{
			// past scrollback wrap point
			continue;
		}

		text = con.text + CON_LINE( row );

		currentWidthLocation = cl_conXOffset->integer;

		for ( x = 0; x < con.linewidth && text[x].ch; ++x )
		{
			if ( text[ x ].ink != currentColor )
			{
				currentColor = text[ x ].ink;
				color[ 0 ] = g_color_table[ currentColor ][ 0 ];
				color[ 1 ] = g_color_table[ currentColor ][ 1 ];
				color[ 2 ] = g_color_table[ currentColor ][ 2 ];
				color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : frac * 2.0f );
				re.SetColor( color );
			}

			SCR_DrawConsoleFontUnichar( con.xadjust + currentWidthLocation, y, text[ x ].ch );
			currentWidthLocation += SCR_ConsoleFontUnicharWidth( text[ x ].ch );
		}
	}

	re.SetColor( NULL );
}
Пример #10
0
/*
================
SCR_FillRect

Coordinates are 640*480 virtual values
=================
*/
void SCR_FillAdjustedRect( float x, float y, float width, float height, const float *color )
{
	SCR_AdjustFrom640( &x, &y, &width, &height );
	SCR_FillRect( x, y, width, height, color );
}
Пример #11
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;
}