Ejemplo n.º 1
0
/*
* CG_RegisterConfigStrings
*/
static void CG_RegisterConfigStrings( void )
{
	int i;
	const char *cs;

	cg.precacheCount = cg.precacheTotal = 0;

	for( i = 0; i < CS_GENERAL; i++ )
	{
		trap_GetConfigString( i, cgs.configStrings[i], MAX_CONFIGSTRING_CHARS );

		cs = cgs.configStrings[i];
		if( i >= CS_MODELS && cs[0] )
		{
			if( i >= CS_LOCATIONS && i < CS_LOCATIONS + MAX_LOCATIONS )
				continue;

			if( ( i >= CS_SOUNDS && i < CS_SOUNDS + MAX_SOUNDS ) && ( cs[0] == '*' ) )
				continue;

			cg.precacheTotal++;
		}
	}

	// if we got the server settings configstring, update our local copy of the data
	CG_UpdateTVServerString();

	GS_SetGametypeName( cgs.configStrings[CS_GAMETYPENAME] );

	trap_Cmd_ExecuteText( EXEC_NOW, va( "exec configs/client/%s.cfg silent", gs.gametypeName ) );

	CG_SC_AutoRecordAction( cgs.configStrings[i] );
}
Ejemplo n.º 2
0
/*
* G_Gametype_Init
*/
void G_Gametype_Init( void )
{
	bool changed = false;
	const char *mapGametype;

	g_gametypes_list = trap_Cvar_Get( "g_gametypes_list", "", CVAR_NOSET|CVAR_ARCHIVE );
	G_Gametype_GenerateGametypesList(); // fill the g_gametypes_list cvar

	// empty string to allow all
	g_votable_gametypes = trap_Cvar_Get( "g_votable_gametypes", "", CVAR_ARCHIVE );

	if( !g_gametype ) // first time initialized
		changed = true;

	g_gametype = trap_Cvar_Get( "g_gametype", "dm", CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH );

	//get the match cvars too
	g_warmup_timelimit = trap_Cvar_Get( "g_warmup_timelimit", "5", CVAR_ARCHIVE );
	g_postmatch_timelimit = trap_Cvar_Get( "g_postmatch_timelimit", "4", CVAR_ARCHIVE );
	g_countdown_time = trap_Cvar_Get( "g_countdown_time", "5", CVAR_ARCHIVE );
	g_match_extendedtime = trap_Cvar_Get( "g_match_extendedtime", "2", CVAR_ARCHIVE );

	// game settings
	g_timelimit = trap_Cvar_Get( "g_timelimit", "10", CVAR_ARCHIVE );
	g_scorelimit = trap_Cvar_Get( "g_scorelimit", "0", CVAR_ARCHIVE );
	g_allow_falldamage = trap_Cvar_Get( "g_allow_falldamage", "1", CVAR_ARCHIVE );
	g_allow_selfdamage = trap_Cvar_Get( "g_allow_selfdamage", "1", CVAR_ARCHIVE );
	g_allow_teamdamage = trap_Cvar_Get( "g_allow_teamdamage", "1", CVAR_ARCHIVE );
	g_allow_bunny = trap_Cvar_Get( "g_allow_bunny", "1", CVAR_ARCHIVE|CVAR_READONLY );

	// map-specific gametype
	mapGametype = G_asCallMapGametype();
	if( mapGametype[0] && G_Gametype_Exists( mapGametype ) )
		trap_Cvar_Set( g_gametype->name, mapGametype );

	// update latched gametype change
	if( g_gametype->latched_string )
	{
		if( G_Gametype_Exists( g_gametype->latched_string ) )
		{
			trap_Cvar_ForceSet( "g_gametype", va( "%s", g_gametype->latched_string ) );
			changed = true;
		}
		else
		{
			G_Printf( "G_Gametype: Invalid new gametype, change ignored\n" );
			trap_Cvar_ForceSet( "g_gametype", va( "%s", g_gametype->string ) );
		}
	}

	if( !G_Gametype_Exists( g_gametype->string ) )
	{
		G_Printf( "G_Gametype: Wrong value: '%s'. Setting up with default (dm)\n", g_gametype->string );
		trap_Cvar_ForceSet( "g_gametype", "dm" );
		changed = true;
	}

	G_Printf( "-------------------------------------\n" );
	G_Printf( "Initalizing '%s' gametype\n", g_gametype->string );

	if( changed )
	{
		const char *configs_path = "configs/server/gametypes/";

		G_InitChallengersQueue();

		// print a hint for admins so they know there's a chance to execute a
		// config here, but don't show it as an error, because it isn't
		G_Printf( "loading %s%s.cfg\n", configs_path, g_gametype->string );
		trap_Cmd_ExecuteText( EXEC_NOW, va( "exec %s%s.cfg silent\n", configs_path, g_gametype->string ) );
		trap_Cbuf_Execute();

		// on a listen server, override gametype-specific settings in config
		trap_Cmd_ExecuteText( EXEC_NOW, "vstr ui_startservercmd\n" );
		trap_Cbuf_Execute();
	}

	// fixme: we are doing this twice because the gametype may check for GS_Instagib
	G_CheckCvars(); // update GS_Instagib, GS_FallDamage, etc

	G_Gametype_SetDefaults();

	// Init the current gametype
	if( !GT_asLoadScript( g_gametype->string ) )
		G_Gametype_GENERIC_Init();

	GS_SetGametypeName( g_gametype->string );

	trap_ConfigString( CS_GAMETYPENAME, g_gametype->string );

	G_CheckCvars(); // update GS_Instagib, GS_FallDamage, etc

	// ch : if new gametype has been initialized, transfer the
	// client-specific ratings to gametype-specific list
	if( changed )
		G_TransferRatings();
}
Ejemplo n.º 3
0
/*
* CG_ConfigString
*/
void CG_ConfigString( int i, const char *s )
{
	size_t len;

	// wsw : jal : warn if configstring overflow
	len = strlen( s );
	if( len >= MAX_CONFIGSTRING_CHARS )
		CG_Printf( "%sWARNING:%s Configstring %i overflowed\n", S_COLOR_YELLOW, S_COLOR_WHITE, i );

	if( i < 0 || i >= MAX_CONFIGSTRINGS )
		CG_Error( "configstring > MAX_CONFIGSTRINGS" );

	Q_strncpyz( cgs.configStrings[i], s, sizeof( cgs.configStrings[i] ) );

	// do something apropriate
	if( i == CS_MAPNAME )
	{
		CG_RegisterLevelMinimap();
	}
	else if( i == CS_TVSERVER )
	{
		CG_UpdateTVServerString();
	}
	else if( i == CS_GAMETYPETITLE )
	{
	}
	else if( i == CS_GAMETYPENAME )
	{
		GS_SetGametypeName( cgs.configStrings[CS_GAMETYPENAME] );
	}
	else if( i == CS_AUTORECORDSTATE )
	{
		CG_SC_AutoRecordAction( cgs.configStrings[i] );
	}
	else if( i >= CS_MODELS && i < CS_MODELS+MAX_MODELS )
	{
		if( cgs.configStrings[i][0] == '$' )	// indexed pmodel
			cgs.pModelsIndex[i-CS_MODELS] = CG_RegisterPlayerModel( cgs.configStrings[i]+1 );
		else
			cgs.modelDraw[i-CS_MODELS] = CG_RegisterModel( cgs.configStrings[i] );
	}
	else if( i >= CS_SOUNDS && i < CS_SOUNDS+MAX_SOUNDS )
	{
		if( cgs.configStrings[i][0] != '*' )
			cgs.soundPrecache[i-CS_SOUNDS] = trap_S_RegisterSound( cgs.configStrings[i] );
	}
	else if( i >= CS_IMAGES && i < CS_IMAGES+MAX_IMAGES )
	{
		cgs.imagePrecache[i-CS_IMAGES] = trap_R_RegisterPic( cgs.configStrings[i] );
	}
	else if( i >= CS_SKINFILES && i < CS_SKINFILES+MAX_SKINFILES )
	{
		cgs.skinPrecache[i-CS_SKINFILES] = trap_R_RegisterSkinFile( cgs.configStrings[i] );
	}
	else if( i >= CS_LIGHTS && i < CS_LIGHTS+MAX_LIGHTSTYLES )
	{
		CG_SetLightStyle( i - CS_LIGHTS );
	}
	else if( i >= CS_ITEMS && i < CS_ITEMS+MAX_ITEMS )
	{
		CG_ValidateItemDef( i - CS_ITEMS, cgs.configStrings[i] );
	}
	else if( i >= CS_PLAYERINFOS && i < CS_PLAYERINFOS+MAX_CLIENTS )
	{
		CG_LoadClientInfo( &cgs.clientInfo[i-CS_PLAYERINFOS], cgs.configStrings[i], i-CS_PLAYERINFOS );
	}
	else if( i >= CS_GAMECOMMANDS && i < CS_GAMECOMMANDS+MAX_GAMECOMMANDS )
	{
		if( !cgs.demoPlaying )
		{
			trap_Cmd_AddCommand( cgs.configStrings[i], NULL );
			if( !Q_stricmp( cgs.configStrings[i], "gametypemenu" ) ) {
				cgs.hasGametypeMenu = qtrue;
			}
		}
	}
	else if( i >= CS_WEAPONDEFS && i < CS_WEAPONDEFS + MAX_WEAPONDEFS )
	{
		CG_OverrideWeapondef( i - CS_WEAPONDEFS, cgs.configStrings[i] );
	}
}