예제 #1
0
static void IN_DeactivateMouse(void)
{
	if (!SDL_WasInit(SDL_INIT_VIDEO))
	{
		return;
	}

	SDL_SetRelativeMouseMode( SDL_FALSE );
	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if (!Cvar_VariableIntegerValue("r_fullscreen"))
		SDL_ShowCursor(1);

	if (!mouseAvailable)
	{
		return;
	}

	if (mouseActive)
	{
		IN_GobbleMotionEvents();
		SDL_SetWindowGrab( SDLvidscreen, SDL_FALSE );
		mouseActive = qfalse;
	}
}
예제 #2
0
/*
==================
SV_Map_f

Restart the server on a different map, but clears a cvar so that typing "map blah" doesn't try and preserve
player weapons/ammo/etc from the previous level that you haven't really exited (ie ignores KEEP_PREV on spawn points)
==================
*/
static void SV_Map_f( void ) 
{
	Cvar_Set( sCVARNAME_PLAYERSAVE, "");
	Cvar_Set( "spawntarget", "" );
	Cvar_Set("tier_storyinfo", "0");
	Cvar_Set("tiers_complete", "");
//	SCR_UnprecacheScreenshot();

	ForceReload_e eForceReload = eForceReload_NOTHING;	// default for normal load

	char *cmd = Cmd_Argv( 0 );
	if ( !Q_stricmp( cmd, "devmapbsp") )
		eForceReload = eForceReload_BSP;
	else if ( !Q_stricmp( cmd, "devmapmdl") )
		eForceReload = eForceReload_MODELS;
	else if ( !Q_stricmp( cmd, "devmapall") )
		eForceReload = eForceReload_ALL;

	qboolean cheat = (qboolean)(!Q_stricmpn( cmd, "devmap", 6 ) );

	// retain old cheat state
	if ( !cheat && Cvar_VariableIntegerValue( "helpUsObi" ) )
		cheat = qtrue;

	if (SV_Map_( eForceReload ))
	{
		// set the cheat value
		// if the level was started with "map <levelname>", then
		// cheats will not be allowed.  If started with "devmap <levelname>"
		// then cheats will be allowed
		Cvar_Set( "helpUsObi", cheat ? "1" : "0" );
	}
}
예제 #3
0
파일: cl_scrn.c 프로젝트: Razish/QtZ
// This is called every frame, and can also be called explicitly to flush text to the screen.
void SCR_UpdateScreen( void ) {
	static int	recursive;

	if ( !scr_initialized ) {
		return;				// not initialized yet
	}

	if ( ++recursive > 2 ) {
		Com_Error( ERR_FATAL, "SCR_UpdateScreen: recursively called" );
	}
	recursive = 1;

	// If there is no VM, there are also no rendering commands issued. Stop the renderer in
	// that case.
	if ( cls.uiStarted || com_dedicated->integer )
	{
		// XXX
		int in_anaglyphMode = Cvar_VariableIntegerValue("r_anaglyphMode");
		// if running in stereo, we need to draw the frame twice
		if ( cls.glconfig.stereoEnabled || in_anaglyphMode) {
			SCR_DrawScreenField( STEREO_LEFT );
			SCR_DrawScreenField( STEREO_RIGHT );
		} else {
			SCR_DrawScreenField( STEREO_CENTER );
		}

		if ( com_speeds->integer ) {
			re->EndFrame( &time_frontend, &time_backend );
		} else {
			re->EndFrame( NULL, NULL );
		}
	}
	
	recursive = 0;
}
예제 #4
0
void IN_AutoMapToggle(void)
{

	if (Cvar_VariableIntegerValue("cg_drawRadar"))
	{
		Cvar_Set("cg_drawRadar", "0");
	}
	else
	{
		Cvar_Set("cg_drawRadar", "1");
	}
	/*
	if (r_autoMap && r_autoMap->integer)
	{ //automap off, radar on
		Cvar_Set("r_autoMap", "0");
		Cvar_Set("cg_drawRadar", "1");
	}
	else if (Cvar_VariableIntegerValue("cg_drawRadar"))
	{ //radar off, automap should be off too
		Cvar_Set("cg_drawRadar", "0");
	}
	else
	{ //turn automap on
		Cvar_Set("r_autoMap", "1");
	}
	*/
}
예제 #5
0
/*
===============
IN_DeactivateMouse
===============
*/
void IN_DeactivateMouse( void )
{
	if ( !SDL_WasInit( SDL_INIT_VIDEO ) )
	{
		return;
	}

	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if ( !Cvar_VariableIntegerValue( "r_fullscreen" ) )
	{
		SDL_ShowCursor( 1 );
	}

	if ( !mouseAvailable )
	{
		return;
	}

#ifdef MACOS_X_ACCELERATION_HACK

	if ( mouseActive ) // mac os x mouse accel hack
	{
		if ( originalMouseSpeed != -1.0 )
		{
			io_connect_t mouseDev = IN_GetIOHandle();

			if ( mouseDev != 0 )
			{
				Com_DPrintf( "restoring mouse acceleration to: %f\n", originalMouseSpeed );

				if ( IOHIDSetAccelerationWithKey( mouseDev, CFSTR( kIOHIDMouseAccelerationType ), originalMouseSpeed ) != kIOReturnSuccess )
				{
					Com_DPrintf( "Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n" );
				}

				IOServiceClose( mouseDev );
			}
			else
			{
				Com_DPrintf( "Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n" );
			}
		}
	}

#endif

	if ( mouseActive )
	{
		IN_GobbleMotionEvents();

		SDL_WM_GrabInput( SDL_GRAB_OFF );

		// Don't warp the mouse unless the cursor is within the window
		//if( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS )
		//SDL_WarpMouse( cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 );

		mouseActive = qfalse;
	}
}
예제 #6
0
파일: ai_team.c 프로젝트: zturtleman/recoil
/*
==================
BotNumTeamMates
==================
*/
int BotNumTeamMates(bot_state_t *bs)
{
    int i, numplayers;
    char buf[MAX_INFO_STRING];
    static int maxclients;

    if (!maxclients)
        maxclients = Cvar_VariableIntegerValue("sv_maxclients");

    numplayers = 0;
    for (i = 0; i < maxclients && i < MAX_CLIENTS; i++)
    {
        SV_SetConfigstring(CS_PLAYERS+i, buf);
        //if no config string or no name
        if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
        //skip spectators
        if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
        //
        if (BotSameTeam(bs, i))
        {
            numplayers++;
        }
    }
    return numplayers;
}
예제 #7
0
/*
==============
Sys_GLimpInit

Windows specific GL implementation initialisation
==============
*/
void Sys_GLimpInit( void )
{
#ifndef DEDICATED
    if( !SDL_VIDEODRIVER_externallySet )
    {
        // It's a little bit weird having in_mouse control the
        // video driver, but from ioq3's point of view they're
        // virtually the same except for the mouse input anyway
        if( Cvar_VariableIntegerValue( "in_mouse" ) == -1 )
        {
            // Use the windib SDL backend, which is closest to
            // the behaviour of idq3 with in_mouse set to -1
            _putenv( "SDL_VIDEODRIVER=windib" );
        }
        else
        {
            // Use the DirectX SDL backend
            _putenv( "SDL_VIDEODRIVER=directx" );
        }

        // RTCW treats all keys the same by default.
        _putenv("SDL_DISABLE_LOCK_KEYS=1");
    }
#endif
}
예제 #8
0
파일: sdl_input.c 프로젝트: pzychotic/ioq3
/*
===============
IN_ActivateMouse
===============
*/
static void IN_ActivateMouse( void )
{
	if (!mouseAvailable || !SDL_WasInit( SDL_INIT_VIDEO ) )
		return;

	if( !mouseActive )
	{
		SDL_SetRelativeMouseMode( SDL_TRUE );
		SDL_SetWindowGrab( SDL_window, 1 );

		IN_GobbleMotionEvents( );
	}

	// in_nograb makes no sense in fullscreen mode
	if( !Cvar_VariableIntegerValue("r_fullscreen") )
	{
		if( in_nograb->modified || !mouseActive )
		{
			if( in_nograb->integer )
				SDL_SetWindowGrab( SDL_window, 0 );
			else
				SDL_SetWindowGrab( SDL_window, 1 );

			in_nograb->modified = qfalse;
		}
	}

	mouseActive = qtrue;
}
예제 #9
0
파일: bot.cpp 프로젝트: janisl/jlquake
void SVT3_BotInitBotLib() {
	if ( debugpolygons ) {
		Mem_Free( debugpolygons );
	}
	bot_maxdebugpolys = GGameType & GAME_Quake3 ? Cvar_VariableIntegerValue( "bot_maxdebugpolys" ) : 128;
	debugpolygons = ( bot_debugpoly_t* )Mem_Alloc( sizeof ( bot_debugpoly_t ) * bot_maxdebugpolys );
}
예제 #10
0
/*
==================
CL_SystemInfoChanged

The systeminfo configstring has been changed, so parse
new information out of it.  This will happen at every
gamestate, and possibly during gameplay.
==================
*/
void CL_SystemInfoChanged( void ) {
	char			*systemInfo;
	const char		*s;
	char			key[MAX_INFO_KEY];
	char			value[MAX_INFO_VALUE];

	systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ];
	cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );

	s = Info_ValueForKey( systemInfo, "helpUsObi" );
	if ( atoi(s) == 0 ) {
		Cvar_SetCheatState();
	}

	// scan through all the variables in the systeminfo and locally set cvars to match
	s = systemInfo;
	while ( s ) {
		Info_NextPair( &s, key, value );
		if ( !key[0] ) {
			break;
		}

		Cvar_Set( key, value );
	}
	extern cvar_t *s_language;
	if ( ( Q_stricmp( "DEUTSCH", s_language->string ) == 0 )//voice language is German
			|| (sp_language->integer == SP_LANGUAGE_GERMAN )//text language is German
			|| Cvar_VariableIntegerValue("ui_iscensored") == 1 )
	{
		Cvar_Set( "g_dismemberment", "0");
	}
}
예제 #11
0
파일: sdl_input.c 프로젝트: TexZK/iortcw
/*
===============
IN_DeactivateMouse
===============
*/
static void IN_DeactivateMouse( void )
{
	if( !SDL_WasInit( SDL_INIT_VIDEO ) )
		return;

	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if( !Cvar_VariableIntegerValue("r_fullscreen") )
		SDL_ShowCursor( 1 );

	if( !mouseAvailable )
		return;

	if( mouseActive )
	{
		IN_GobbleMotionEvents( );

		SDL_SetWindowGrab( SDL_window, SDL_FALSE );
		SDL_SetRelativeMouseMode( SDL_FALSE );

		// Don't warp the mouse unless the cursor is within the window
		if( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_MOUSE_FOCUS )
			SDL_WarpMouseInWindow( SDL_window, cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 );

		mouseActive = qfalse;
	}
}
예제 #12
0
파일: tr_main.cpp 프로젝트: FeniXb3/OpenJK
/*
** R_CullPointAndRadius
*/
int R_CullPointAndRadius( const vec3_t pt, float radius )
{
	int		i;
	float	dist;
	cplane_t	*frust;
	qboolean mightBeClipped = qfalse;

	if ( r_nocull->integer==1 ) {
		return CULL_CLIP;
	}

	// check against frustum planes
#ifndef __NO_JK2
	if( Cvar_VariableIntegerValue("com_jk2") )
	{
		// They used 4 frustrum planes in JK2, and 5 in JKA --eez
		for (i = 0 ; i < 4 ; i++) 
		{
			frust = &tr.viewParms.frustum[i];

			dist = DotProduct( pt, frust->normal) - frust->dist;
			if ( dist < -radius )
			{
				return CULL_OUT;
			}
			else if ( dist <= radius ) 
			{
				mightBeClipped = qtrue;
			}
		}
	}
	else
	{
#endif
	for (i = 0 ; i < 5 ; i++) 
	{
		frust = &tr.viewParms.frustum[i];

		dist = DotProduct( pt, frust->normal) - frust->dist;
		if ( dist < -radius )
		{
			return CULL_OUT;
		}
		else if ( dist <= radius ) 
		{
			mightBeClipped = qtrue;
		}
	}
#ifndef __NO_JK2
	}
#endif

	if ( mightBeClipped )
	{
		return CULL_CLIP;
	}

	return CULL_IN;		// completely inside frustum
}
예제 #13
0
bool Sys_DLLNeedsUnpacking()
{
#if defined(_JK2EXE)
	return false;
#else
	return Cvar_VariableIntegerValue("sv_pure") != 0;
#endif
}
예제 #14
0
파일: g_spawn.c 프로젝트: osfpsproject/MF2
/*
============
G_ItemDisabled
============
*/
int G_ItemDisabled( gitem_t *item ) 
{

	char name[128];

	Com_sprintf(name, sizeof(name), "disable_%s", item->classname);
	return Cvar_VariableIntegerValue( name );
}
예제 #15
0
/*
===============
GLimp_StartDriverAndSetMode
===============
*/
static qboolean GLimp_StartDriverAndSetMode(glconfig_t *glConfig, const windowDesc_t *windowDesc, int mode, qboolean fullscreen, qboolean noborder)
{
	rserr_t err;

	if (!SDL_WasInit(SDL_INIT_VIDEO))
	{
		const char *driverName;

		if (SDL_Init(SDL_INIT_VIDEO) == -1)
		{
			Com_Printf( "SDL_Init( SDL_INIT_VIDEO ) FAILED (%s)\n", SDL_GetError());
			return qfalse;
		}

		driverName = SDL_GetCurrentVideoDriver();

		if (!driverName)
		{
			Com_Error( ERR_FATAL, "No video driver initialized" );
			return qfalse;
		}

		Com_Printf( "SDL using driver \"%s\"\n", driverName );
		Cvar_Set( "r_sdlDriver", driverName );
	}

	if (SDL_GetNumVideoDisplays() <= 0)
	{
		Com_Error( ERR_FATAL, "SDL_GetNumVideoDisplays() FAILED (%s)", SDL_GetError() );
	}

	if (fullscreen && Cvar_VariableIntegerValue( "in_nograb" ) )
	{
		Com_Printf( "Fullscreen not allowed with in_nograb 1\n");
		Cvar_Set( "r_fullscreen", "0" );
		r_fullscreen->modified = qfalse;
		fullscreen = qfalse;
	}

	err = GLimp_SetMode(glConfig, windowDesc, CLIENT_WINDOW_TITLE, mode, fullscreen, noborder);

	switch ( err )
	{
		case RSERR_INVALID_FULLSCREEN:
			Com_Printf( "...WARNING: fullscreen unavailable in this mode\n" );
			return qfalse;
		case RSERR_INVALID_MODE:
			Com_Printf( "...WARNING: could not set the given mode (%d)\n", mode );
			return qfalse;
		case RSERR_UNKNOWN:
			Com_Printf( "...ERROR: no display modes could be found.\n" );
			return qfalse;
		default:
			break;
	}

	return qtrue;
}
예제 #16
0
파일: sv_bot.cpp 프로젝트: Jsoucek/q3ce
/*
==================
SV_BotInitBotLib
==================
*/
void SV_BotInitBotLib(void) {
	botlib_import_t	botlib_import;

	if ( !Cvar_VariableIntegerValue("fs_restrict") && !Sys_CheckCD() ) {
		Com_Error( ERR_NEED_CD, "Game CD not in drive" );
	}

	if (debugpolygons) Z_Free(debugpolygons);
	bot_maxdebugpolys = Cvar_VariableIntegerValue("bot_maxdebugpolys");
	debugpolygons = (bot_debugpoly_t *)Z_Malloc(sizeof(bot_debugpoly_t) * bot_maxdebugpolys);

	botlib_import.Print = BotImport_Print;
	botlib_import.Trace = BotImport_Trace;
	botlib_import.EntityTrace = BotImport_EntityTrace;
	botlib_import.PointContents = BotImport_PointContents;
	botlib_import.inPVS = BotImport_inPVS;
	botlib_import.BSPEntityData = BotImport_BSPEntityData;
	botlib_import.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;
	botlib_import.BotClientCommand = BotClientCommand;

	//memory management
	botlib_import.GetMemory = BotImport_GetMemory;
	botlib_import.FreeMemory = BotImport_FreeMemory;
	botlib_import.AvailableMemory = Z_AvailableMemory;
	botlib_import.HunkAlloc = BotImport_HunkAlloc;

	// file system access
	botlib_import.FS_FOpenFile = FS_FOpenFileByMode;
	botlib_import.FS_Read = FS_Read2;
	botlib_import.FS_Write = FS_Write;
	botlib_import.FS_FCloseFile = FS_FCloseFile;
	botlib_import.FS_Seek = FS_Seek;

	//debug lines
	botlib_import.DebugLineCreate = BotImport_DebugLineCreate;
	botlib_import.DebugLineDelete = BotImport_DebugLineDelete;
	botlib_import.DebugLineShow = BotImport_DebugLineShow;

	//debug polygons
	botlib_import.DebugPolygonCreate = BotImport_DebugPolygonCreate;
	botlib_import.DebugPolygonDelete = BotImport_DebugPolygonDelete;

	botlib_export = (botlib_export_t *)GetBotLibAPI( BOTLIB_API_VERSION, &botlib_import );
	assert(botlib_export); 	// bk001129 - somehow we end up with a zero import.
}
예제 #17
0
void IN_GenCMD19( void )
{
	if (Cvar_VariableIntegerValue("d_saberStanceDebug"))
	{
		Com_Printf("SABERSTANCEDEBUG: Gencmd on client set successfully.\n");
	}
	cl.gcmdSendValue = qtrue;
	cl.gcmdValue = GENCMD_SABERATTACKCYCLE;
}
예제 #18
0
void SV_FixBrokenRules( void )
{
	int gt = Cvar_VariableIntegerValue( "g_gametype" );
	if( gt == GT_DUEL || gt == GT_POWERDUEL )
	{
		Cvar_SetValue( "fraglimit", 1 );
		Cvar_SetValue( "timelimit", 0 );
	}
}
예제 #19
0
/*
=================
SV_LoadGame_f
=================
*/
void    SV_LoadGame_f( void ) {
	char filename[MAX_QPATH], mapname[MAX_QPATH];
	byte *buffer;
	int size;

	Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
	if ( !filename[0] ) {
		Com_Printf( "You must specify a savegame to load\n" );
		return;
	}
	if ( Q_strncmp( filename, "save/", 5 ) && Q_strncmp( filename, "save\\", 5 ) ) {
		Q_strncpyz( filename, va( "save/%s", filename ), sizeof( filename ) );
	}
	if ( !strstr( filename, ".svg" ) ) {
		Q_strcat( filename, sizeof( filename ), ".svg" );
	}

	size = FS_ReadFile( filename, NULL );
	if ( size < 0 ) {
		Com_Printf( "Can't find savegame %s\n", filename );
		return;
	}

	buffer = Hunk_AllocateTempMemory( size );
	FS_ReadFile( filename, (void **)&buffer );

	// read the mapname, if it is the same as the current map, then do a fast load
	Com_sprintf( mapname, sizeof( mapname ), buffer + sizeof( int ) );

	if ( com_sv_running->integer && ( com_frameTime != sv.serverId ) ) {
		// check mapname
		if ( !Q_stricmp( mapname, sv_mapname->string ) ) {    // same

			if ( Q_stricmp( filename, "save/current.svg" ) != 0 ) {
				// copy it to the current savegame file
				FS_WriteFile( "save/current.svg", buffer, size );
			}

			Hunk_FreeTempMemory( buffer );

			Cvar_Set( "savegame_loading", "2" );  // 2 means it's a restart, so stop rendering until we are loaded
			SV_MapRestart_f();  // savegame will be loaded after restart

			return;
		}
	}

	Hunk_FreeTempMemory( buffer );

	// otherwise, do a slow load
	if ( Cvar_VariableIntegerValue( "sv_cheats" ) ) {
		Cbuf_ExecuteText( EXEC_APPEND, va( "spdevmap %s", filename ) );
	} else {    // no cheats
		Cbuf_ExecuteText( EXEC_APPEND, va( "spmap %s", filename ) );
	}
}
예제 #20
0
/*
====================
CL_InitCGame

Should only be called by CL_StartHunkUsers
====================
*/
void CL_InitCGame( void ) {
	const char			*info;
	const char			*mapname;
	int					t1, t2;
	vmInterpret_t		interpret;

	t1 = Sys_Milliseconds();

	// put away the console
	Con_Close();

	// find the current mapname
	info = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ];
	mapname = Info_ValueForKey( info, "mapname" );
	Com_sprintf( cl.mapname, sizeof( cl.mapname ), "maps/%s.bsp", mapname );

	// load the dll or bytecode
	if ( cl_connectedToPureServer != 0 ) {
		// if sv_pure is set we only allow qvms to be loaded
		interpret = VMI_COMPILED;
	}
	else {
		interpret = (vmInterpret_t)Cvar_VariableIntegerValue( "vm_cgame" ); // ***GREGS_VC9_PORT_MOD*** -- changed Cvar_VariableValue to Cvar_VariableIntegerValue because float to enums are not allowed anymore; also added typecast
	}
	cgvm = VM_Create( "cgame", CL_CgameSystemCalls, interpret );
	if ( !cgvm ) {
		Com_Error( ERR_DROP, "VM_Create on cgame failed" );
	}
	cls.state = CA_LOADING;

	// init for this gamestate
	// use the lastExecutedServerCommand instead of the serverCommandSequence
	// otherwise server commands sent just before a gamestate are dropped
	VM_Call( cgvm, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum );

	// we will send a usercmd this frame, which
	// will cause the server to send us the first snapshot
	cls.state = CA_PRIMED;

	t2 = Sys_Milliseconds();

	Com_Printf( "CL_InitCGame: %5.2f seconds\n", (t2-t1)/1000.0 );

	// have the renderer touch all its images, so they are present
	// on the card even if the driver does deferred loading
	re.EndRegistration();

	// make sure everything is paged in
	if (!Sys_LowPhysicalMemory()) {
		Com_TouchMemory();
	}

	// clear anything that got printed
	Con_ClearNotify ();
}
예제 #21
0
파일: sv_bot.c 프로젝트: Razish/QtZ
void SV_BotInitBotLib( void ) {
	botlib_import_t	botlib_import;
	GetBotLibAPI_t GetBotLibAPI;
	char dllName[MAX_OSPATH] = "botlib_"ARCH_STRING DLL_EXT;

	if( !(botlibLib = Sys_LoadDll( dllName, qfalse )) )
	{
		Com_Printf( "failed:\n\"%s\"\n", Sys_LibraryError() );
		Com_Error( ERR_FATAL, "Failed to load botlib" );
	}

	GetBotLibAPI = (GetBotLibAPI_t)Sys_LoadFunction( botlibLib, "GetBotLibAPI" );
	if ( !GetBotLibAPI )
		Com_Error(ERR_FATAL, "Can't load symbol GetBotLibAPI: '%s'",  Sys_LibraryError());

	if (debugpolygons) Z_Free(debugpolygons);
	bot_maxdebugpolys = Cvar_VariableIntegerValue("bot_maxdebugpolys");
	debugpolygons = Z_Malloc(sizeof(bot_debugpoly_t) * bot_maxdebugpolys);

	botlib_import.Print = BotImport_Print;
	botlib_import.Error = Com_Error;
	botlib_import.Trace = BotImport_Trace;
	botlib_import.EntityTrace = BotImport_EntityTrace;
	botlib_import.PointContents = BotImport_PointContents;
	botlib_import.inPVS = BotImport_inPVS;
	botlib_import.BSPEntityData = BotImport_BSPEntityData;
	botlib_import.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;
	botlib_import.BotClientCommand = BotClientCommand;

	//memory management
	botlib_import.GetMemory = BotImport_GetMemory;
	botlib_import.FreeMemory = BotImport_FreeMemory;
	botlib_import.AvailableMemory = Z_AvailableMemory;
	botlib_import.HunkAlloc = BotImport_HunkAlloc;

	// file system access
	botlib_import.FS_FOpenFile = FS_FOpenFileByMode;
	botlib_import.FS_Read = FS_Read2;
	botlib_import.FS_Write = FS_Write;
	botlib_import.FS_FCloseFile = FS_FCloseFile;
	botlib_import.FS_Seek = FS_Seek;

	//debug lines
	botlib_import.DebugLineCreate = BotImport_DebugLineCreate;
	botlib_import.DebugLineDelete = BotImport_DebugLineDelete;
	botlib_import.DebugLineShow = BotImport_DebugLineShow;

	//debug polygons
	botlib_import.DebugPolygonCreate = BotImport_DebugPolygonCreate;
	botlib_import.DebugPolygonDelete = BotImport_DebugPolygonDelete;

	botlib_export = (botlib_export_t *)GetBotLibAPI( BOTLIB_API_VERSION, &botlib_import );
	assert(botlib_export); 	// somehow we end up with a zero import.
}
예제 #22
0
/*
===============
GLimp_StartDriverAndSetMode
===============
*/
static qboolean GLimp_StartDriverAndSetMode(int mode, qboolean fullscreen, qboolean noborder)
{
	int i;
	rserr_t err;

	if (!SDL_WasInit(SDL_INIT_VIDEO))
	{
		char *driverName;

		if (SDL_Init(SDL_INIT_VIDEO) == -1)
		{
			Com_Printf( "SDL_Init( SDL_INIT_VIDEO ) FAILED (%s)\n",
					SDL_GetError());
			return qfalse;
		}

		if (!SDL_GetNumVideoDrivers())
		{
			Com_Printf( "SDL_GetNumVideoDrivers( ) FAILED (%s)\n",
					SDL_GetError());
			return qfalse;
		}

		//
		// TODO: Prompt the user to choose a specific video driver.
		driverName = SDL_GetVideoDriver( 0 );
		Com_Printf( "SDL using driver \"%s\"\n", driverName );
		Cvar_Set( "r_sdlDriver", driverName );
	}

	if (fullscreen && Cvar_VariableIntegerValue( "in_nograb" ) )
	{
		Com_Printf( "Fullscreen not allowed with in_nograb 1\n");
		Cvar_Set( "r_fullscreen", "0" );
		r_fullscreen->modified = qfalse;
		fullscreen = qfalse;
	}

	err = GLimp_SetMode(mode, fullscreen, noborder);

	switch ( err )
	{
		case RSERR_INVALID_FULLSCREEN:
			Com_Printf( "...WARNING: fullscreen unavailable in this mode\n" );
			return qfalse;
		case RSERR_INVALID_MODE:
			Com_Printf( "...WARNING: could not set the given mode (%d)\n", mode );
			return qfalse;
		default:
			break;
	}

	return qtrue;
}
예제 #23
0
void CRMInstance::DrawAutomapSymbol()
{
	// draw proper symbol on map for instance
	switch (GetAutomapSymbol())
	{
		default:
		case AUTOMAP_NONE:
			if (HasObjective())
				CM_TM_AddObjective(GetOrigin()[0], GetOrigin()[1], GetSide());
			break;
		case AUTOMAP_BLD:
			CM_TM_AddBuilding(GetOrigin()[0], GetOrigin()[1], GetSide());
			if (HasObjective())
				CM_TM_AddObjective(GetOrigin()[0], GetOrigin()[1], GetSide());
			break;
		case AUTOMAP_OBJ:
			CM_TM_AddObjective(GetOrigin()[0], GetOrigin()[1], GetSide());
			break;
		case AUTOMAP_START:
			CM_TM_AddStart(GetOrigin()[0], GetOrigin()[1], GetSide());
			break;
		case AUTOMAP_END:
			CM_TM_AddEnd(GetOrigin()[0], GetOrigin()[1], GetSide());
			break;
		case AUTOMAP_ENEMY:
			if (HasObjective())
				CM_TM_AddObjective(GetOrigin()[0], GetOrigin()[1]);
			if (1 == Cvar_VariableIntegerValue("rmg_automapshowall"))
				CM_TM_AddNPC(GetOrigin()[0], GetOrigin()[1], false);
			break;
		case AUTOMAP_FRIEND:
			if (HasObjective())
				CM_TM_AddObjective(GetOrigin()[0], GetOrigin()[1]);
			if (1 == Cvar_VariableIntegerValue("rmg_automapshowall"))
				CM_TM_AddNPC(GetOrigin()[0], GetOrigin()[1], true);
			break;
		case AUTOMAP_WALL:
			CM_TM_AddWallRect(GetOrigin()[0], GetOrigin()[1], GetSide());
			break;
	}
}
예제 #24
0
파일: ai_team.c 프로젝트: zturtleman/recoil
/*
==================
BotSortTeamMatesByBaseTravelTime
==================
*/
int BotSortTeamMatesByBaseTravelTime(bot_state_t *bs, int *teammates, int maxteammates)
{

    int i, j, k, numteammates, traveltime;
    char buf[MAX_INFO_STRING];
    static int maxclients;
    int traveltimes[MAX_CLIENTS];
    bot_goal_t *goal = NULL;

    if (gametype == GT_CTF || gametype == GT_1FCTF)
    {
        if (BotTeam(bs) == TEAM_RED)
            goal = &ctf_redflag;
        else
            goal = &ctf_blueflag;
    }
    if (!maxclients)
        maxclients = Cvar_VariableIntegerValue("sv_maxclients");

    numteammates = 0;
    for (i = 0; i < maxclients && i < MAX_CLIENTS; i++)
    {
        SV_SetConfigstring(CS_PLAYERS+i, buf);
        //if no config string or no name
        if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
        //skip spectators
        if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
        //
        if (BotSameTeam(bs, i))
        {
            //
            traveltime = BotClientTravelTimeToGoal(i, goal);
            //
            for (j = 0; j < numteammates; j++)
            {
                if (traveltime < traveltimes[j])
                {
                    for (k = numteammates; k > j; k--)
                    {
                        traveltimes[k] = traveltimes[k-1];
                        teammates[k] = teammates[k-1];
                    }
                    break;
                }
            }
            traveltimes[j] = traveltime;
            teammates[j] = i;
            numteammates++;
            if (numteammates >= maxteammates) break;
        }
    }
    return numteammates;
}
예제 #25
0
파일: bot.cpp 프로젝트: janisl/jlquake
void SVT3_BotInitCvars() {
	if ( GGameType & ( GAME_WolfMP | GAME_ET ) ) {
		Cvar_Get( "bot_enable", "0", 0 );					//enable the bot
	} else {
		Cvar_Get( "bot_enable", "1", 0 );					//enable the bot
	}
	Cvar_Get( "bot_developer", "0", CVAR_CHEAT );			//bot developer mode
	Cvar_Get( "bot_debug", "0", CVAR_CHEAT );				//enable bot debugging
	Cvar_Get( "bot_groundonly", "1", 0 );					//only show ground faces of areas
	Cvar_Get( "bot_reachability", "0", 0 );					//show all reachabilities to other areas
	if ( GGameType & GAME_ET ) {
		Cvar_Get( "bot_thinktime", "50", CVAR_CHEAT );		//msec the bots thinks
		Cvar_Get( "bot_nochat", "1", 0 );					//disable chats
		Cvar_Get( "bot_rocketjump", "0", 0 );				//enable rocket jumping
		Cvar_Get( "bot_norcd", "0", 0 );					//enable creation of RCD file
	} else {
		Cvar_Get( "bot_thinktime", "100", CVAR_CHEAT );		//msec the bots thinks
		Cvar_Get( "bot_nochat", "0", 0 );					//disable chats
		Cvar_Get( "bot_rocketjump", "1", 0 );				//enable rocket jumping
	}
	Cvar_Get( "bot_reloadcharacters", "0", 0 );				//reload the bot characters each time
	Cvar_Get( "bot_testichat", "0", 0 );					//test ichats
	Cvar_Get( "bot_testrchat", "0", 0 );					//test rchats
	Cvar_Get( "bot_fastchat", "0", 0 );						//fast chatting bots
	Cvar_Get( "bot_grapple", "0", 0 );						//enable grapple
	if ( GGameType & ( GAME_WolfSP | GAME_WolfMP ) ) {
		Cvar_Get( "bot_miniplayers", "0", 0 );				//minimum players in a team or the game
	}
	if ( GGameType & GAME_Quake3 ) {
		Cvar_Get( "bot_minplayers", "0", 0 );					//minimum players in a team or the game
		Cvar_Get( "bot_visualizejumppads", "0", CVAR_CHEAT );	//show jumppads
		Cvar_Get( "bot_forceclustering", "0", 0 );				//force cluster calculations
		Cvar_Get( "bot_forcereachability", "0", 0 );			//force reachability calculations
		Cvar_Get( "bot_forcewrite", "0", 0 );					//force writing aas file
		Cvar_Get( "bot_aasoptimize", "0", 0 );					//no aas file optimisation
		Cvar_Get( "bot_saveroutingcache", "0", 0 );				//save routing cache
		Cvar_Get( "bot_maxdebugpolys", "2", 0 );				//maximum number of debug polys
		Cvar_Get( "bot_testsolid", "0", CVAR_CHEAT );			//test for solid areas
		Cvar_Get( "bot_testclusters", "0", CVAR_CHEAT );		//test the AAS clusters
		Cvar_Get( "bot_pause", "0", CVAR_CHEAT );				//pause the bots thinking
		Cvar_Get( "bot_report", "0", CVAR_CHEAT );				//get a full report in ctf
		Cvar_Get( "bot_challenge", "0", 0 );					//challenging bot
		Cvar_Get( "bot_interbreedchar", "", CVAR_CHEAT );		//bot character used for interbreeding
		Cvar_Get( "bot_interbreedbots", "10", CVAR_CHEAT );		//number of bots used for interbreeding
		Cvar_Get( "bot_interbreedcycle", "20", CVAR_CHEAT );	//bot interbreeding cycle
		Cvar_Get( "bot_interbreedwrite", "", CVAR_CHEAT );		//write interbreeded bots to this file
	}

	if ( GGameType & GAME_ET ) {
		bot_enable = Cvar_VariableIntegerValue( "bot_enable" );
	}
}
예제 #26
0
/**
 * @brief This routine is responsible for initializing the OS specific portions of OpenGL
 */
void GLimp_Init(glconfig_t *glConfig, windowContext_t *context)
{
	GLimp_InitCvars();

	if (Cvar_VariableIntegerValue("com_abnormalExit"))
	{
		Cvar_Set("r_mode", va("%d", R_MODE_FALLBACK));
		Cvar_Set("r_fullscreen", "0");
		Cvar_Set("r_centerWindow", "0");
		Cvar_Set("com_abnormalExit", "0");
	}

	Sys_GLimpInit();

	// Create the window and set up the context
	if (GLimp_StartDriverAndSetMode(glConfig, r_mode->integer, (qboolean) !!r_fullscreen->integer, (qboolean) !!r_noborder->integer, context))
	{
		goto success;
	}

	// Try again, this time in a platform specific "safe mode"
	Sys_GLimpSafeInit();

	if (GLimp_StartDriverAndSetMode(glConfig, r_mode->integer, (qboolean) !!r_fullscreen->integer, qfalse, context))
	{
		goto success;
	}

	// Finally, try the default screen resolution
	if (r_mode->integer != R_MODE_FALLBACK)
	{
		Com_Printf("Setting r_mode %d failed, falling back on r_mode %d\n", r_mode->integer, R_MODE_FALLBACK);
		if (GLimp_StartDriverAndSetMode(glConfig, R_MODE_FALLBACK, qfalse, qfalse, context))
		{
			goto success;
		}
	}

	// Nothing worked, give up
	Com_Error(ERR_VID_FATAL, "GLimp_Init() - could not load OpenGL subsystem\n");

success:
	// Only using SDL_SetWindowBrightness to determine if hardware gamma is supported
	glConfig->deviceSupportsGamma = !r_ignorehwgamma->integer && SDL_SetWindowBrightness(main_window, 1.0f) >= 0;

	re.InitOpenGL();

	Cvar_Get("r_availableModes", "", CVAR_ROM);

	// This depends on SDL_INIT_VIDEO, hence having it here
	IN_Init();
}
예제 #27
0
파일: sv_ccmds.c 프로젝트: Lrns123/jkaq3
static void SV_ForceToggle_f( void ) {
	int bits = Cvar_VariableIntegerValue("g_forcePowerDisable");
	int i, val;
	char *s;
	const char *enablestrings[] =
	{
		"Disabled",
		"Enabled"
	};

	if ( Cmd_Argc() != 2 ) {
		for(i = 0; i < NUM_FORCE_POWERS; i++ ) {
			Com_Printf ("%i - %s - Status: %s\n", i, forcePowers[i], enablestrings[!(bits & (1<<i))]);
		}
		Com_Printf ("Example usage: forcetoggle 3(toggles PUSH)\n");
		return;
	}

	s = Cmd_Argv(1);

	if( Q_isanumber( s ) ) {
		val = atoi(s);
		if( val >= 0 && val < NUM_FORCE_POWERS) {
			bits = Cvar_VariableIntegerValue("g_forcePowerDisable");
			bits ^= (1 << val);
			Com_Printf ("%s has been %s.\n", forcePowers[val], (bits & (1<<val)) ? "disabled" : "enabled");
			Cvar_SetValue("g_forcePowerDisable", bits);
		}
		else {
			Com_Printf ("Specified a power that does not exist.\n");
		}
	}
	else {
		for(i = 0; i < NUM_FORCE_POWERS; i++ ) {
			Com_Printf ("%i - %s - Status: %s\n", i, forcePowers[i], enablestrings[!(bits & (1<<i))]);
		}
		Com_Printf ("Example usage: forcetoggle 3(toggles PUSH)\n");
	}
}
예제 #28
0
파일: cvar.cpp 프로젝트: pwolfe/OpenJK
/*
============
Cvar_Toggle_f

Toggles a cvar for easy single key binding
============
*/
void Cvar_Toggle_f( void ) {
	int		v;

	if ( Cmd_Argc() != 2 ) {
		Com_Printf ("usage: toggle <variable>\n");
		return;
	}

	v = Cvar_VariableIntegerValue( Cmd_Argv( 1 ) );
	v = !v;

	Cvar_Set2 (Cmd_Argv(1), va("%i", v), qfalse);
}
예제 #29
0
/*
==================
SV_AddOperatorCommands
==================
 */
void SV_AddOperatorCommands(void) {
    static qboolean initialized;

    if (initialized) {
        return;
    }
    initialized = qtrue;

    Cmd_AddCommand("heartbeat", SV_Heartbeat_f);
    Cmd_AddCommand("kick", SV_Kick_f);
#ifndef STANDALONE
    if (!Cvar_VariableIntegerValue("com_standalone")) {
        Cmd_AddCommand("banUser", SV_Ban_f);
        Cmd_AddCommand("banClient", SV_BanNum_f);
    }
#endif
    Cmd_AddCommand("clientkick", SV_KickNum_f);
    Cmd_AddCommand("status", SV_Status_f);
    Cmd_AddCommand("serverinfo", SV_Serverinfo_f);
    Cmd_AddCommand("systeminfo", SV_Systeminfo_f);
    Cmd_AddCommand("dumpuser", SV_DumpUser_f);
    Cmd_AddCommand("map_restart", SV_MapRestart_f);
    Cmd_AddCommand("sectorlist", SV_SectorList_f);
    Cmd_AddCommand("map", SV_Map_f);
    Cmd_SetCommandCompletionFunc("map", SV_CompleteMapName);
#ifndef PRE_RELEASE_DEMO
    Cmd_AddCommand("devmap", SV_Map_f);
    Cmd_SetCommandCompletionFunc("devmap", SV_CompleteMapName);
    Cmd_AddCommand("spmap", SV_Map_f);
    Cmd_SetCommandCompletionFunc("spmap", SV_CompleteMapName);
    Cmd_AddCommand("spdevmap", SV_Map_f);
    Cmd_SetCommandCompletionFunc("spdevmap", SV_CompleteMapName);
#endif
    Cmd_AddCommand("killserver", SV_KillServer_f);
    if (com_dedicated->integer) {
        Cmd_AddCommand("say", SV_ConSay_f);
    }

    Cmd_AddCommand("rehashbans", SV_RehashBans_f);
    Cmd_AddCommand("listbans", SV_ListBans_f);
    Cmd_AddCommand("banaddr", SV_BanAddr_f);
    Cmd_AddCommand("exceptaddr", SV_ExceptAddr_f);
    Cmd_AddCommand("bandel", SV_BanDel_f);
    Cmd_AddCommand("exceptdel", SV_ExceptDel_f);
    Cmd_AddCommand("flushbans", SV_FlushBans_f);

    Cmd_AddCommand("forcecvar", SV_ForceCvar_f);
#ifdef USE_RUBY
    Cmd_AddCommand("ruby", SV_Ruby_f);
#endif
}
예제 #30
0
// extern void G_DemoKeypress();
// extern void CG_SkipCredits(void);
void IN_CommonJoyPress(int controller, fakeAscii_t button, bool pressed)
{
	// Check for special cases for map hack
	// This should be #ifdef'd out in FINAL_BUILD, but I really don't care.
	// If someone wants to copy the retail version to their modded xbox and
	// edit the config file to turn on maphack, let them.
	if (Cvar_VariableIntegerValue("cl_maphack"))
	{
		if (_UIRunning && button == A_JOY11 && pressed)
		{
			// Left trigger -> F1
			Sys_QueEvent( 0, SE_KEY, A_F1, pressed, 0, NULL );
			return;
		}
		else if (_UIRunning && button == A_JOY12 && pressed)
		{
			// Right trigger -> F2
			Sys_QueEvent( 0, SE_KEY, A_F2, pressed, 0, NULL );
			return;
		}
		else if (_UIRunning && button == A_JOY4 && pressed)
		{
			// Start button -> F3
			IN_SetMainController(controller);
			Sys_QueEvent( 0, SE_KEY, A_F3, pressed, 0, NULL );
			return;
		}
	}


	if(IN_GetMainController() == controller || _UIRunning)
	{
		// Always map start button to ESCAPE
		if (!_UIRunning && button == A_JOY4 && cls.state != CA_CINEMATIC)
			Sys_QueEvent( 0, SE_KEY, A_ESCAPE, pressed, 0, NULL );

#ifdef DEBUG_CONTROLLER
		if (controller != 3)
#endif
			Sys_QueEvent( 0, SE_KEY, _UIRunning ? UIJoy2Key(button) : button, pressed, 0, NULL );
	}

#ifdef DEBUG_CONTROLLER
	if (controller == 3 && pressed)
	{
		HandleDebugJoystickPress(button);
		return;
	}
#endif
}