Ejemplo n.º 1
0
Archivo: g_bot.c Proyecto: otty/cake3
/*
===============
G_LoadArenas
===============
*/
static void G_LoadArenas(void)
{
	int             numdirs;
	vmCvar_t        arenasFile;
	char            filename[128];
	char            dirlist[1024];
	char           *dirptr;
	int             i, n;
	int             dirlen;

	g_numArenas = 0;

	trap_Cvar_Register(&arenasFile, "g_arenasFile", "", CVAR_INIT | CVAR_ROM);
	if(*arenasFile.string)
	{
		G_LoadArenasFromFile(arenasFile.string);
	}
	else
	{
		G_LoadArenasFromFile("scripts/arenas.txt");
	}

	// get all arenas from .arena files
	numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 1024);
	dirptr = dirlist;
	for(i = 0; i < numdirs; i++, dirptr += dirlen + 1)
	{
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/");
		strcat(filename, dirptr);
		G_LoadArenasFromFile(filename);
	}
	trap_Printf(va("%i arenas parsed\n", g_numArenas));

	for(n = 0; n < g_numArenas; n++)
	{
		Info_SetValueForKey(g_arenaInfos[n], "num", va("%i", n));
	}
}
Ejemplo n.º 2
0
Archivo: g_bot.c Proyecto: otty/cake3
/*
===============
G_LoadBots
===============
*/
static void G_LoadBots(void)
{
	vmCvar_t        botsFile;
	int             numdirs;
	char            filename[128];
	char            dirlist[1024];
	char           *dirptr;
	int             i;
	int             dirlen;

	if(!trap_Cvar_VariableIntegerValue("bot_enable"))
	{
		return;
	}

	g_numBots = 0;

	trap_Cvar_Register(&botsFile, "g_botsFile", "", CVAR_INIT | CVAR_ROM);
	if(*botsFile.string)
	{
		G_LoadBotsFromFile(botsFile.string);
	}
	else
	{
		G_LoadBotsFromFile("scripts/bots.txt");
	}

	// get all bots from .bot files
	numdirs = trap_FS_GetFileList("scripts", ".bot", dirlist, 1024);
	dirptr = dirlist;
	for(i = 0; i < numdirs; i++, dirptr += dirlen + 1)
	{
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/");
		strcat(filename, dirptr);
		G_LoadBotsFromFile(filename);
	}
	trap_Printf(va("%i bots parsed\n", g_numBots));
}
Ejemplo n.º 3
0
void BG_SiegeLoadTeams(void)
{
	int numFiles;
	int filelen;
	char filelist[4096];
	char filename[MAX_QPATH];
	char* fileptr;
	int i;

	bgNumSiegeTeams = 0;

	numFiles = trap_FS_GetFileList("ext_data/Siege/Teams", ".team", filelist, 4096 );
	fileptr = filelist;

	for (i = 0; i < numFiles; i++, fileptr += filelen+1)
	{
		filelen = strlen(fileptr);
		strcpy(filename, "ext_data/Siege/Teams/");
		strcat(filename, fileptr);
		BG_SiegeParseTeamFile(filename);
	}
}
Ejemplo n.º 4
0
/*
===============
UI_LoadBots
===============
*/
void UI_LoadBots( void )
{
	vmCvar_t botsFile;
	int      numdirs;
	char     filename[ 128 ];
	char     dirlist[ 1024 ];
	char      *dirptr;
	int      i;
	int      dirlen;

	ui_numBots = 0;

	trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT | CVAR_ROM );

	if ( *botsFile.string )
	{
		UI_LoadBotsFromFile( botsFile.string );
	}
	else
	{
		UI_LoadBotsFromFile( "scripts/bots.txt" );
	}

	// get all bots from .bot files
	numdirs = trap_FS_GetFileList( "scripts", ".bot", dirlist, 1024 );

	dirptr = dirlist;

	for ( i = 0; i < numdirs; i++, dirptr += dirlen + 1 )
	{
		dirlen = strlen( dirptr );
		strcpy( filename, "scripts/" );
		strcat( filename, dirptr );
		UI_LoadBotsFromFile( filename );
	}

	trap_Print( va( "%i bots parsed\n", ui_numBots ) );
}
Ejemplo n.º 5
0
/*
===============
CG_LoadTrailSystems

Load trail system templates
===============
*/
void CG_LoadTrailSystems()
{
	int  i, numFiles, fileLen;
	char fileList[ MAX_TRAIL_FILES * MAX_QPATH ];
	char fileName[ MAX_QPATH ];
	char *filePtr;

	//clear out the old
	numBaseTrailSystems = 0;
	numBaseTrailBeams = 0;

	for ( i = 0; i < MAX_BASETRAIL_SYSTEMS; i++ )
	{
		baseTrailSystem_t *bts = &baseTrailSystems[ i ];
		memset( bts, 0, sizeof( baseTrailSystem_t ) );
	}

	for ( i = 0; i < MAX_BASETRAIL_BEAMS; i++ )
	{
		baseTrailBeam_t *btb = &baseTrailBeams[ i ];
		memset( btb, 0, sizeof( baseTrailBeam_t ) );
	}

	//and bring in the new
	numFiles = trap_FS_GetFileList( "scripts", ".trail",
	                                fileList, MAX_TRAIL_FILES * MAX_QPATH );
	filePtr = fileList;

	for ( i = 0; i < numFiles; i++, filePtr += fileLen + 1 )
	{
		fileLen = strlen( filePtr );
		strcpy( fileName, "scripts/" );
		strcat( fileName, filePtr );
		// Log::Notice(_( "...loading '%s'"), fileName );
		CG_ParseTrailFile( fileName );
	}
}
Ejemplo n.º 6
0
void G_PrintConfigs(gentity_t *ent)
{
	char configNames[8192];
	char filename[MAX_QPATH];
	int  numconfigs = 0, i = 0, namelen = 0;
	char *configPointer;
	G_Printf("Starting to read configs\n");
	numconfigs    = trap_FS_GetFileList("configs", ".config", configNames, sizeof(configNames));
	configPointer = configNames;
	for (i = 0; i < numconfigs; i++, configPointer += namelen + 1)
	{
		namelen = strlen(configPointer);
		strcpy(filename, Q_StrReplace(configPointer, ".config", ""));
		if (!Q_stricmp(filename, g_customConfig.string))
		{
			G_refPrintf(ent, "^7Config: ^3%s ^2- in use", filename);
		}
		else
		{
			G_refPrintf(ent, "^7Config: ^3%s", filename);
		}
	}
	G_Printf("Config list done\n");
}
Ejemplo n.º 7
0
void CG_LocateCampaign(void)
{
	/*	int			numdirs;
		char		filename[MAX_QPATH];
		char		dirlist[1024];
		char*		dirptr;
		int			i, dirlen;
		qboolean	found = qfalse;

		// get all campaigns from .campaign files
		numdirs = trap_FS_GetFileList( "scripts", ".campaign", dirlist, 1024 );
		dirptr  = dirlist;
		for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
			dirlen = strlen(dirptr);
			strcpy(filename, "scripts/");
			strcat(filename, dirptr);
			if(CG_FindCurrentCampaignInFile(filename, &cgs.campaignData)) {
				found = qtrue;
				break;
			}
		}

		if(!found) {
			return;
		}

		for(i = 0; i < cgs.campaignData.mapCount; i++ ) {
			Com_sprintf( filename, sizeof(filename), "scripts/%s.arena", cgs.campaignData.mapnames[i] );
			// Gordon: horrible hack, but i dont plan to parse EVERY .arena to get a map briefing...
			if(	!CG_FindArenaInfo( "scripts/wolfmp.arena", cgs.campaignData.mapnames[i], &cgs.campaignData.arenas[i] ) &&
				!CG_FindArenaInfo( "scripts/wolfxp.arena", cgs.campaignData.mapnames[i], &cgs.campaignData.arenas[i] ) &&
				!CG_FindArenaInfo( filename, cgs.campaignData.mapnames[i], &cgs.campaignData.arenas[i] )) {
				return;
			}
		}

		cgs.campaignInfoLoaded = qtrue;*/

	int             numdirs;
	char            filename[MAX_QPATH];
	char            dirlist[1024];
	char           *dirptr;
	int             i, dirlen;
	qboolean        found = qfalse;

	// get all campaigns from .campaign files
	numdirs = trap_FS_GetFileList("scripts", ".campaign", dirlist, 1024);
	dirptr = dirlist;

	for (i = 0; i < numdirs; i++, dirptr += dirlen + 1)
	{
		dirlen = strlen(dirptr);
		Q_strncpyz(filename, "scripts/", MAX_QPATH);
		Q_strcat(filename, MAX_QPATH, dirptr);

		if (CG_FindCampaignInFile(filename, cgs.currentCampaign, &cgs.campaignData))
		{
			found = qtrue;
			break;
		}
	}

	if (!found)
	{
		return;
	}

	for (i = 0; i < cgs.campaignData.mapCount; i++)
	{
		Com_sprintf(filename, sizeof(filename), "scripts/%s.arena", cgs.campaignData.mapnames[i]);

		// Gordon: horrible hack, but i dont plan to parse EVERY .arena to get a map briefing...
		if (/*!CG_FindArenaInfo( "scripts/wolfmp.arena", cgs.campaignData.mapnames[i], &cgs.campaignData.arenas[i] ) &&
								   !CG_FindArenaInfo( "scripts/wolfxp.arena", cgs.campaignData.mapnames[i], &cgs.campaignData.arenas[i] ) && */
		    !CG_FindArenaInfo(filename, cgs.campaignData.mapnames[i], &cgs.campaignData.arenas[i]))
		{
			return;
		}
	}

	cgs.campaignInfoLoaded = qtrue;
}
Ejemplo n.º 8
0
void UI_SaberLoadParms( void ) 
{
	int			len, totallen, saberExtFNLen, fileCnt, i;
	char		*holdChar, *marker;
	char		saberExtensionListBuf[2048];			//	The list of file names read in
	fileHandle_t f;
	char buffer[MAX_MENUFILE];
	
	//[DynamicMemory_Sabers]
#ifdef DYNAMICMEMORY_SABERS
	int maxLen;
#endif
	//[/DynamicMemory_Sabers]

	//ui.Printf( "UI Parsing *.sab saber definitions\n" );
	
	ui_saber_parms_parsed = qtrue;
	UI_CacheSaberGlowGraphics();

//[DynamicMemory_Sabers] moved down lower
	/*
	//set where to store the first one
	totallen = 0;
	marker = SaberParms;
	marker[0] = '\0';
	*/

	//we werent initilizing saberExtFNLen, which is Bad
	//this is just a general bug fix, not for the purpose of [DynamicMemory_Sabers]
	saberExtFNLen = 0;
///[DynamicMemory_Sabers]


	//now load in the extra .npc extensions
	fileCnt = trap_FS_GetFileList("ext_data/sabers", ".sab", saberExtensionListBuf, sizeof(saberExtensionListBuf) );

	holdChar = saberExtensionListBuf;

//[DynamicMemory_Sabers]
#ifdef DYNAMICMEMORY_SABERS
	maxLen = 0;
	saberExtFNLen = -1;
	for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 ) {
		saberExtFNLen = strlen( holdChar );
		len = trap_FS_FOpenFile( va( "ext_data/sabers/%s", holdChar), &f, FS_READ );
		if(!f)
			continue;
		trap_FS_FCloseFile(f);
		maxLen += len;
	}
	//what do we do if totallen is zero?  will never happen, but COULD happen in theory...
	//trap_TrueMalloc(&SaberParms, totallen+1); //+1 for null char, needed?
	maxLen++; //for ending null char
	UI_AllocMem(&SaberParms, maxLen);
	if(!SaberParms)
		//ERR_FATAL or any level isnt used with Com_Error
		Com_Error(ERR_FATAL, "Saber parsing: Out of memory!");
	holdChar = saberExtensionListBuf;
#endif
//[/DynamicMemory_Sabers]

//[DynamicMemory_Sabers] moved to here
	//set where to store the first one
	totallen = 0;
	marker = SaberParms;
	marker[0] = '\0';

	saberExtFNLen = -1;
///[DynamicMemory_Sabers]

	for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 ) 
	{
		saberExtFNLen = strlen( holdChar );

		len = trap_FS_FOpenFile( va( "ext_data/sabers/%s", holdChar), &f, FS_READ );

		if (!f)
		{
			continue;
		}

		if ( len == -1 ) 
		{
			Com_Printf( "UI_SaberLoadParms: error reading %s\n", holdChar );
		}
		else
		{
			if (len > sizeof(buffer) )
			{
				Com_Error( ERR_FATAL, "UI_SaberLoadParms: file %s too large to read (max=%d)", holdChar, sizeof(buffer) );
			}
			trap_FS_Read( buffer, len, f );
			trap_FS_FCloseFile( f );
			buffer[len] = 0;

			if ( totallen && *(marker-1) == '}' )
			{//don't let it end on a } because that should be a stand-alone token
				strcat( marker, " " );
				totallen++;
				marker++; 
			}
			len = COM_Compress( buffer );

//[DynamicMemory_Sabers]
#ifndef DYNAMICMEMORY_SABERS
			if ( totallen + len >= MAX_SABER_DATA_SIZE ) {
				Com_Error( ERR_FATAL, "UI_SaberLoadParms: ran out of space before reading %s\n(you must make the .sab files smaller)", holdChar );
			}
#else
			if ( totallen + len >= maxLen ) {
				Com_Error( ERR_FATAL, "UI_SaberLoadParms: ran out of space before reading %s\n(This should never happen)", holdChar );
			}
#endif
//[/DynamicMemory_Sabers]
			strcat( marker, buffer );

			totallen += len;
			marker += len;
		}
	}
}
Ejemplo n.º 9
0
void G_ParseCampaigns(void)
{
	int      i;
	qboolean mapFound = qfalse;

	level.campaignCount   = 0;
	level.currentCampaign = -1;
	memset(&g_campaigns, 0, sizeof(g_campaignInfo_t) * MAX_CAMPAIGNS);

	if (g_gametype.integer != GT_WOLF_CAMPAIGN)
	{
		trap_Cvar_Set("g_oldCampaign", "");
		trap_Cvar_Set("g_currentCampaign", "");
		trap_Cvar_Set("g_currentCampaignMap", "0");
		return;
	}

	if (g_campaignFile.string[0])
	{
		if (G_LoadCampaignsFromFile(g_campaignFile.string))
		{
			mapFound = qtrue;
		}
	}

	if (!mapFound)
	{
		// get all campaigns from .campaign files
		int  dirlen;
		int  numdirs = trap_FS_GetFileList("scripts", ".campaign", bigTextBuffer, sizeof(bigTextBuffer));
		char filename[MAX_QPATH]; // was 128
		char *dirptr = bigTextBuffer;

		for (i = 0; i < numdirs; i++, dirptr += dirlen + 1)
		{
			// log a warning if server has more than MAX_CAMPAIGNS
			if (level.campaignCount >= MAX_CAMPAIGNS)
			{
				G_LogPrintf("WARNING G_ParseCampaigns: number of campaigns larger then MAX_CAMPAIGNS\n");
				break;
			}

			dirlen = strlen(dirptr);
			strcpy(filename, "scripts/");
			strcat(filename, dirptr);

			if (G_LoadCampaignsFromFile(filename))
			{
				mapFound = qtrue;
			}
		}
	}

	if (!mapFound)
	{
		// map isn't found in the current campaign, see if it's the first map in another campaign
		for (i = 0; i < level.campaignCount; i++)
		{
			if (!Q_stricmp(g_campaigns[i].mapnames[0], level.rawmapname))
			{
				// someone manually specified a /map command, and it's the first map in a campaign
				trap_Cvar_Set("g_currentCampaign", g_campaigns[i].shortname);
				trap_Cvar_Set("g_currentCampaignMap", "0");

				level.newCampaign = qtrue;

				g_campaigns[level.campaignCount].current = 0;
				level.currentCampaign                    = i;

				break;
			}
		}

		if (i == level.campaignCount)
		{
			char buf[MAX_STRING_CHARS];

			if (trap_Argc() < 1) // command not found, throw error
			{
				G_Error("Usage 'map <mapname>\n'");
			}

			trap_Argv(0, buf, sizeof(buf));

			if (!(*buf)) // command not found, throw error
			{
				G_Error("Usage 'map <mapname>\n'");
			}

			// no campaign found, fallback to GT_WOLF
			// and reload the map
			trap_Cvar_Set("g_gametype", "2");
			trap_SendConsoleCommand(EXEC_APPEND, va("%s %s\n", buf, level.rawmapname));
		}
	}
}
Ejemplo n.º 10
0
/*
===============
UI_LoadArenas
===============
*/
void UI_LoadArenas( void ) {
	int			numdirs;
	vmCvar_t	arenasFile;
	char		filename[128];
	char		dirlist[1024];
	char*		dirptr;
	int			i, n;
	int			dirlen;
	char		*type;

	ui_numArenas = 0;
	uiInfo.mapCount = 0;

	trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM );
	if( *arenasFile.string ) {
		UI_LoadArenasFromFile(arenasFile.string);
	}
	else {
		UI_LoadArenasFromFile("scripts/arenas.txt");
	}

	// get all arenas from .arena files
	numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 1024 );
	dirptr  = dirlist;
	for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/");
		strcat(filename, dirptr);
		UI_LoadArenasFromFile(filename);
	}
	trap_Print( va( "%i arenas parsed\n", ui_numArenas ) );
	if (UI_OutOfMemory()) {
		trap_Print(S_COLOR_YELLOW"WARNING: not anough memory in pool to load all arenas\n");
	}

	for( n = 0; n < ui_numArenas; n++ ) {
		// determine type

		uiInfo.mapList[uiInfo.mapCount].cinematic = -1;
		uiInfo.mapList[uiInfo.mapCount].mapLoadName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "map"));
		uiInfo.mapList[uiInfo.mapCount].mapName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "longname"));
		uiInfo.mapList[uiInfo.mapCount].levelShot = -1;
		uiInfo.mapList[uiInfo.mapCount].imageName = String_Alloc(va("levelshots/%s", uiInfo.mapList[uiInfo.mapCount].mapLoadName));
		uiInfo.mapList[uiInfo.mapCount].typeBits = 0;

		type = Info_ValueForKey( ui_arenaInfos[n], "type" );
		// if no type specified, it will be treated as "ffa"
		if( *type ) {
			if( strstr( type, "ffa" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);
			}
			if( strstr( type, "tourney" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_TOURNAMENT);
			}
			if( strstr( type, "ctf" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_CTF);
			}
			if( strstr( type, "oneflag" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_1FCTF);
			}
			if( strstr( type, "overload" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_OBELISK);
			}
			if( strstr( type, "harvester" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_HARVESTER);
			}
		} else {
			uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);
		}

		uiInfo.mapCount++;
		if (uiInfo.mapCount >= MAX_MAPS) {
			break;
		}
	}
}
Ejemplo n.º 11
0
int strap_FS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize )
{
    return trap_FS_GetFileList (path, extension, listbuf, bufsize);
}
Ejemplo n.º 12
0
static void Performance_Init( void )
{
    menucommon_t *menuitem;
    int yoffset = 0;

    char custom_resolution[64];
    static char **resolutions;

    static char *colordepth_names[] = { "desktop", "16 bits", "32 bits", 0 };

    static char *plighting_names[] = { "vertex (fast)", "lightmaps (normal)", "per pixel (quality)", "per pixel (no specular)", 0 };

    static char **texfilter_names;
    int anisotropic, spinindex;

#ifndef PREDEFINES_PROFILES
    if( !gfx_profiles )
    {
        int i = 0, num, total, len;
        char *current, buffer[1024];
        total = trap_FS_GetFileList( "profiles", ".cfg", NULL, 0, 0, 0 );

        if( total )
            gfx_profiles = UI_Malloc( sizeof( char * ) * ( total + 1 ) );

        while( i < total )
        {
            if( ( num = trap_FS_GetFileList( "profiles", ".cfg", buffer, sizeof( buffer ), i, total ) ) == 0 )
            {
                i++; // can happen if the filename is too long to fit into the buffer or we're done
                continue;
            }

            // add profiles to profiles list
            for( current = buffer ; num ; i++, num--, current += len )
            {
                len = strlen( current ) + 1;
                if( strncmp( current, "gfx_", 4 ) )
                    continue;

                COM_StripExtension( current );

                gfx_profiles[i] = UI_Malloc( strlen( current + 4 ) + 1 );
                strcpy( gfx_profiles[i], current + 4 );
            }
        }
    }
#endif

    if( !resolutions )
    {   // count video modes
        int i, width, height;
        qboolean wideScreen;

        for( i = 0; trap_VID_GetModeInfo( &width, &height, &wideScreen, i - 1 ); i++ ) ;

        resolutions = (char **)UI_Malloc( sizeof( char * ) * ( i + 1 ) );

        for( i = 0; trap_VID_GetModeInfo( &width, &height, &wideScreen, i - 1 ); i++ )
        {
            Q_snprintfz( custom_resolution, sizeof( custom_resolution ), "%s%s%i x %i", i ? "" : "custom: ", ( wideScreen ? "W " : "" ), width, height );
            resolutions[i] = UI_CopyString( custom_resolution );
        }
        resolutions[i] = NULL;
    }

    if( !texfilter_names )
    {
        int i, count;

        for( count = 0; ; count++ )
        {
            if( trap_Cvar_Value( "gl_ext_texture_filter_anisotropic_max" ) <= (1<<count) )
                break;
        }

        texfilter_names = (char **)UI_Malloc( sizeof( char * ) * ( count + 1 + 1 ) );

        texfilter_names[0] = UI_CopyString( "bilinear" );
        for( i = 0; i < count; i++ )
            texfilter_names[i+1] = UI_CopyString( va( "trilinear %ixAF", (1<<i) ) );
        texfilter_names[i+1] = NULL;
    }

    menuitem = UI_InitMenuItem( "m_performance_title1", "GRAPHICS OPTIONS", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_profile", "profile", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, gfx_profiles, trap_Cvar_Value( "ui_gfxprofile" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_applyprofile", "apply profile", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, ApplyProfileButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += 1.5 * UI_SetupButton( menuitem, qtrue );

    menuitem = UI_InitMenuItem( "m_performance_resolution", "resolution", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, resolutions, max( trap_Cvar_Value( "r_mode" ), -1 ) + 1 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_fullscreen", "fullscreen", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, noyes_names, trap_Cvar_Value( "vid_fullscreen" ) != 0 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_swapinterval", "vertical sync", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, noyes_names, trap_Cvar_Value( "r_swapinterval" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_gamma", "brightness", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, bound( (int)( trap_Cvar_Value( "r_gamma" ) * 10.0f ), 5, 13 ), 5, 13 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_colorbits", "color quality", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    if( !Q_stricmp( trap_Cvar_String( "r_colorbits" ), "16" ) )
        UI_SetupSpinControl( menuitem, colordepth_names, 1 );
    else if( !Q_stricmp( trap_Cvar_String( "r_colorbits" ), "32" ) )
        UI_SetupSpinControl( menuitem, colordepth_names, 2 );
    else
        UI_SetupSpinControl( menuitem, colordepth_names, 0 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_picmip", "texture quality", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, 6-trap_Cvar_Value( "r_picmip" ), 0, 6 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_filter", "texture filter", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    anisotropic = trap_Cvar_Value( "r_texturefilter" );
    if( anisotropic >= 2 )
        spinindex = NEARESTEXPOF2( anisotropic ) + 1;
    else if( !Q_stricmp( trap_Cvar_String( "r_texturemode" ), "GL_LINEAR_MIPMAP_NEAREST" ) )
        spinindex = 0;
    else
        spinindex = 1;
    UI_SetupSpinControl( menuitem, texfilter_names, spinindex );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_skymip", "sky quality", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, (trap_Cvar_Value( "r_fastsky" ) ? 0 : 4-trap_Cvar_Value( "r_skymip" )), 0, 4 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_LOD_slider", "geometry level of detail", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, 4-max( trap_Cvar_Value( "r_lodbias" ), NEARESTEXPOF2( trap_Cvar_Value( "r_subdivisions" ) ) ), 0, 4 );
    yoffset += trap_SCR_strHeight( menuitem->font );

#if 0
    menuitem = UI_InitMenuItem( "m_performance_glsl", "opengl shaders", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, offon_names, trap_Cvar_Value( "gl_ext_GLSL" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );
#endif

    if( trap_Cvar_Value( "r_lighting_vertexlight" ) )
        spinindex = 0;
    else if( !trap_Cvar_Value( "r_lighting_deluxemapping" ) )
        spinindex = 1;
    else if( trap_Cvar_Value( "r_lighting_specular" ) )
        spinindex = 2;
    else
        spinindex = 3;

    menuitem = UI_InitMenuItem( "m_performance_pplighting", "lighting", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, plighting_names, spinindex );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_back", "back", -16, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_genericBackFunc );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );
    menuitem = UI_InitMenuItem( "m_performance_apply", "apply", 16, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, ApplyButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;;

    yoffset += trap_SCR_strHeight( uis.fontSystemSmall );

    menuitem = UI_InitMenuItem( "m_performance_advanced", "advanced options", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, AdvancedButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );

    Menu_Center( &s_performance_menu );
    Menu_Init( &s_performance_menu, qfalse );
}
Ejemplo n.º 13
0
void G_ParseCampaigns( void ) {
	int numdirs;
	char filename[128];
	char dirlist[1024];
	char*       dirptr;
	int i;
	int dirlen;
	qboolean mapFound = qfalse;

	level.campaignCount = 0;
	level.currentCampaign = -1;
	memset( &g_campaigns, 0, sizeof( g_campaignInfo_t ) * MAX_CAMPAIGNS );

	// get all campaigns from .campaign files
	numdirs = trap_FS_GetFileList( "scripts", ".campaign", dirlist, 1024 );
	dirptr  = dirlist;
	for ( i = 0; i < numdirs && level.campaignCount < MAX_CAMPAIGNS; i++, dirptr += dirlen + 1 ) {
		dirlen = strlen( dirptr );
		strcpy( filename, "scripts/" );
		strcat( filename, dirptr );

		if ( G_LoadCampaignsFromFile( filename ) ) {
			mapFound = qtrue;
		}
	}

	if ( g_gametype.integer != GT_WOLF_CAMPAIGN ) {
		trap_Cvar_Set( "g_oldCampaign", "" );
		trap_Cvar_Set( "g_currentCampaign", "" );
		trap_Cvar_Set( "g_currentCampaignMap", "0" );
	} else if ( !mapFound ) {
		// map isn't found in the current campaign, see if it's the first map in another campaign
		for ( i = 0; i < level.campaignCount; i++ ) {
			if ( !Q_stricmp( g_campaigns[i].mapnames[0], level.rawmapname ) ) {
				// someone manually specified a /map command, and it's the first map in a campaign
				trap_Cvar_Set( "g_oldCampaign", g_currentCampaign.string );
				trap_Cvar_Set( "g_currentCampaign", g_campaigns[i].shortname );
				trap_Cvar_Set( "g_currentCampaignMap", "0" );

				level.newCampaign = qtrue;

				g_campaigns[level.campaignCount].current = 0;
				level.currentCampaign = i;

				break;
			}
		}

		if ( i == level.campaignCount ) {
			char buf[MAX_STRING_CHARS]; // fretn

			if ( trap_Argc() < 1 ) { // command not found, throw error
				G_Error( "Usage 'map <mapname>\n'" );
			}

			trap_Argv( 0, buf, sizeof( buf ) );

			if ( !buf ) { // command not found, throw error
				G_Error( "Usage 'map <mapname>\n'" );
			}

			// no campaign found, fallback to GT_WOLF
			// and reload the map
			trap_Cvar_Set( "g_gametype", "2" );
			trap_SendConsoleCommand( EXEC_APPEND, va( "%s %s", buf, level.rawmapname ) );
		}
	}
}
/*
===============
Demos_MenuInit
===============
*/
static void Demos_MenuInit( void ) {
	int		i,j;
	int		len, extlen;
	char	*demoname, extension[32];

	memset( &s_demos, 0 ,sizeof(demos_t) );
	s_demos.menu.key = UI_DemosMenu_Key;

	Demos_Cache();

	s_demos.menu.fullscreen = qtrue;
	s_demos.menu.wrapAround = qtrue;
	s_demos.menu.bgparts	= BGP_DEMOBG|BGP_SIMPLEBG;

	s_demos.left.generic.type		= MTYPE_BITMAP1024S;
	s_demos.left.x					= 96;//367;
	s_demos.left.y					= 240;//524;
	s_demos.left.w					= 38;//99;
	s_demos.left.h					= 98;//38;
	s_demos.left.shader				= trap_R_RegisterShaderNoMip(ART_ARROWUP0);
	s_demos.left.mouseovershader	= trap_R_RegisterShaderNoMip(ART_ARROWUP1);
	s_demos.left.generic.callback	= Demos_MenuEvent;
	s_demos.left.generic.id			= ID_LEFT;

	s_demos.right.generic.type		= MTYPE_BITMAP1024S;
	s_demos.right.x					= 96;//561;
	s_demos.right.y					= 422;//524;
	s_demos.right.w					= 38;//98;
	s_demos.right.h					= 98;//38;
	s_demos.right.shader			= trap_R_RegisterShaderNoMip(ART_ARROWDOWN0);
	s_demos.right.mouseovershader	= trap_R_RegisterShaderNoMip(ART_ARROWDOWN1);
	s_demos.right.generic.callback	= Demos_MenuEvent;
	s_demos.right.generic.id		= ID_RIGHT;

	s_demos.back.generic.type		= MTYPE_BITMAP;
	s_demos.back.generic.name		= ART_BACK0;
	s_demos.back.generic.flags		= QMF_LEFT_JUSTIFY | QMF_PULSEIFFOCUS;
    s_demos.back.generic.x			= 8;
	s_demos.back.generic.y			= 440;
	s_demos.back.generic.id			= ID_BACK;
	s_demos.back.generic.callback	= Demos_MenuEvent;
    s_demos.back.width				= 80;
	s_demos.back.height				= 40;
	s_demos.back.focuspic			= ART_BACK1;
	s_demos.back.focuspicinstead	= qtrue;

	s_demos.go.generic.type		= MTYPE_BITMAP1024S;
	s_demos.go.x				= 84;//815;
	s_demos.go.y				= 350;//633;
	s_demos.go.w				= 63;//181;
	s_demos.go.h				= 63;//110;
	s_demos.go.shader			= trap_R_RegisterShaderNoMip(ART_GO0);
	s_demos.go.mouseovershader	= trap_R_RegisterShaderNoMip(ART_GO1);
	s_demos.go.generic.callback	= Demos_MenuEvent;
	s_demos.go.generic.id		= ID_GO;

	s_demos.list.generic.type		= MTYPE_SCROLLLIST;
	s_demos.list.generic.flags		= QMF_PULSEIFFOCUS;
	s_demos.list.generic.callback	= Demos_MenuEvent;
	s_demos.list.generic.id			= ID_LIST;
	s_demos.list.generic.x			= 100;
	s_demos.list.generic.y			= 60;
	s_demos.list.width				= 28;
	s_demos.list.height				= 20;
	s_demos.list.columns			= 1;

	demoname = s_demos.names;
	s_demos.list.itemnames = (const char **)s_demos.demolist;	
	
	j=0;
	while( demo_protocols[j] )
	{
		int demosToAdd;
		Com_sprintf(extension, sizeof(extension), ".%s%d", DEMOEXT, demo_protocols[j] );
		demosToAdd = trap_FS_GetFileList("demos", extension, demoname, ARRAY_LEN(s_demos.names) - (demoname - s_demos.names) );

		for(i=0; i < demosToAdd; i++)
		{		
			s_demos.list.itemnames[ s_demos.list.numitems++ ] = demoname;		
		
			len = strlen(demoname);
			demoname += len + 1;

			if( s_demos.list.numitems >= MAX_DEMOS )
				break;
		}
		
		if( s_demos.list.numitems >= MAX_DEMOS )
			break;
		j++;
	}

	if( 0 == s_demos.list.numitems )
	{
		s_demos.list.itemnames[0] = "No Demos Found.";
		s_demos.list.numitems = 1;

		//degenerate case, not selectable
		s_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
	}

	qsort( s_demos.list.itemnames, s_demos.list.numitems, sizeof( s_demos.list.itemnames[0] ), UI_SortDemos );

	Menu_AddItem( &s_demos.menu, &s_demos.list );
	Menu_AddItem( &s_demos.menu, &s_demos.left );
	Menu_AddItem( &s_demos.menu, &s_demos.right );
	Menu_AddItem( &s_demos.menu, &s_demos.back );
	Menu_AddItem( &s_demos.menu, &s_demos.go );
}
Ejemplo n.º 15
0
/*
===============
LoadConfig_MenuInit
===============
*/
static void LoadConfig_MenuInit( void ) {
	int		i;
	int		len;
	char	*configname;

	UI_LoadConfig_Cache();

	memset( &s_configs, 0 ,sizeof(configs_t) );
	s_configs.menu.wrapAround = qtrue;
	s_configs.menu.fullscreen = qtrue;

	s_configs.banner.generic.type	= MTYPE_BTEXT;
	s_configs.banner.generic.x		= 320;
	s_configs.banner.generic.y		= 16;
	s_configs.banner.string			= "LOAD CONFIG";
	s_configs.banner.color			= text_banner_color;
	s_configs.banner.style			= UI_CENTER;

	s_configs.framel.generic.type	= MTYPE_BITMAP;
	s_configs.framel.generic.name	= ART_FRAMEL;
	s_configs.framel.generic.flags	= QMF_INACTIVE;
	s_configs.framel.generic.x		= 0;  
	s_configs.framel.generic.y		= 78;
	s_configs.framel.width			= 256;
	s_configs.framel.height			= 329;

	s_configs.framer.generic.type	= MTYPE_BITMAP;
	s_configs.framer.generic.name	= ART_FRAMER;
	s_configs.framer.generic.flags	= QMF_INACTIVE;
	s_configs.framer.generic.x		= 376;
	s_configs.framer.generic.y		= 76;
	s_configs.framer.width			= 256;
	s_configs.framer.height			= 334;

	s_configs.arrows.generic.type	= MTYPE_BITMAP;
	s_configs.arrows.generic.name	= ART_ARROWS;
	s_configs.arrows.generic.flags	= QMF_INACTIVE;
	s_configs.arrows.generic.x		= 320-ARROWS_WIDTH/2;
	s_configs.arrows.generic.y		= 400;
	s_configs.arrows.width			= ARROWS_WIDTH;
	s_configs.arrows.height			= ARROWS_HEIGHT;

	s_configs.left.generic.type		= MTYPE_BITMAP;
	s_configs.left.generic.flags	= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
	s_configs.left.generic.x		= 320-ARROWS_WIDTH/2;
	s_configs.left.generic.y		= 400;
	s_configs.left.generic.id		= ID_LEFT;
	s_configs.left.generic.callback	= LoadConfig_MenuEvent;
	s_configs.left.width			= ARROWS_WIDTH/2;
	s_configs.left.height			= ARROWS_HEIGHT;
	s_configs.left.focuspic			= ART_ARROWLEFT;

	s_configs.right.generic.type	= MTYPE_BITMAP;
	s_configs.right.generic.flags	= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
	s_configs.right.generic.x		= 320;
	s_configs.right.generic.y		= 400;
	s_configs.right.generic.id		= ID_RIGHT;
	s_configs.right.generic.callback = LoadConfig_MenuEvent;
	s_configs.right.width			= ARROWS_WIDTH/2;
	s_configs.right.height			= ARROWS_HEIGHT;
	s_configs.right.focuspic		= ART_ARROWRIGHT;

	s_configs.back.generic.type		= MTYPE_BITMAP;
	s_configs.back.generic.name		= ART_BACK0;
	s_configs.back.generic.flags	= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
	s_configs.back.generic.id		= ID_BACK;
	s_configs.back.generic.callback	= LoadConfig_MenuEvent;
	s_configs.back.generic.x		= 0;
	s_configs.back.generic.y		= 480-64;
	s_configs.back.width			= 128;
	s_configs.back.height			= 64;
	s_configs.back.focuspic			= ART_BACK1;

	s_configs.go.generic.type		= MTYPE_BITMAP;
	s_configs.go.generic.name		= ART_FIGHT0;
	s_configs.go.generic.flags		= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
	s_configs.go.generic.id			= ID_GO;
	s_configs.go.generic.callback	= LoadConfig_MenuEvent;
	s_configs.go.generic.x			= 640;
	s_configs.go.generic.y			= 480-64;
	s_configs.go.width				= 128;
	s_configs.go.height				= 64;
	s_configs.go.focuspic			= ART_FIGHT1;

	// scan for configs
	s_configs.list.generic.type		= MTYPE_SCROLLLIST;
	s_configs.list.generic.flags	= QMF_PULSEIFFOCUS;
	s_configs.list.generic.callback	= LoadConfig_MenuEvent;
	s_configs.list.generic.id		= ID_LIST;
	s_configs.list.generic.x		= 118;
	s_configs.list.generic.y		= 130;
	s_configs.list.width			= 16;
	s_configs.list.height			= 14;
	s_configs.list.numitems			= trap_FS_GetFileList( "", "cfg", s_configs.names, NAMEBUFSIZE );
	s_configs.list.itemnames		= (const char **)s_configs.configlist;
	s_configs.list.columns			= 3;

	if (!s_configs.list.numitems) {
		strcpy(s_configs.names,"No Files Found.");
		s_configs.list.numitems = 1;

		//degenerate case, not selectable
		s_configs.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
	}
	else if (s_configs.list.numitems > MAX_CONFIGS)
		s_configs.list.numitems = MAX_CONFIGS;
	
	configname = s_configs.names;
	for ( i = 0; i < s_configs.list.numitems; i++ ) {
		s_configs.list.itemnames[i] = configname;
		
		// strip extension
		len = strlen( configname );
		if (!Q_stricmp(configname +  len - 4,".cfg"))
			configname[len-4] = '\0';

		configname += len + 1;
	}

	Menu_AddItem( &s_configs.menu, &s_configs.banner );
	Menu_AddItem( &s_configs.menu, &s_configs.framel );
	Menu_AddItem( &s_configs.menu, &s_configs.framer );
	Menu_AddItem( &s_configs.menu, &s_configs.list );
	Menu_AddItem( &s_configs.menu, &s_configs.arrows );
	Menu_AddItem( &s_configs.menu, &s_configs.left );
	Menu_AddItem( &s_configs.menu, &s_configs.right );
	Menu_AddItem( &s_configs.menu, &s_configs.back );
	Menu_AddItem( &s_configs.menu, &s_configs.go );
}
Ejemplo n.º 16
0
/*
===============
UI_LoadArenas
===============
*/
void UI_LoadArenas( void )
{
	int  numdirs;
	char filename[ 128 ];
	char dirlist[ 1024 ];
	char *dirptr;
	int  i, n;
	int  dirlen;
	char *type;

	ui_numArenas = 0;
	uiInfo.mapCount = 0;

	// get all arenas from .arena files
	numdirs = trap_FS_GetFileList( "scripts", ".arena", dirlist, 1024 );
	dirptr = dirlist;

	for ( i = 0; i < numdirs; i++, dirptr += dirlen + 1 )
	{
		dirlen = strlen( dirptr );
		strcpy( filename, "scripts/" );
		strcat( filename, dirptr );
		UI_LoadArenasFromFile( filename );
	}

	trap_Print( va( "%i arenas parsed\n", ui_numArenas ) );

	if ( UI_OutOfMemory() )
	{
		trap_Print( S_COLOR_YELLOW "WARNING: not anough memory in pool to load all arenas\n" );
	}

	for ( n = 0; n < ui_numArenas; n++ )
	{
		// determine type
		type = Info_ValueForKey( ui_arenaInfos[ n ], "type" );
		// if no type specified, it will be treated as "ffa"

		if ( *type && strstr( type, "tremulous" ) )
		{
			uiInfo.mapList[ uiInfo.mapCount ].typeBits |= ( 1 << 0 );
		}
		else
		{
			continue; //not a trem map
		}

		uiInfo.mapList[ uiInfo.mapCount ].cinematic = -1;
		uiInfo.mapList[ uiInfo.mapCount ].mapLoadName = String_Alloc( Info_ValueForKey( ui_arenaInfos[ n ], "map" ) );
		uiInfo.mapList[ uiInfo.mapCount ].mapName = String_Alloc( Info_ValueForKey( ui_arenaInfos[ n ], "longname" ) );
		uiInfo.mapList[ uiInfo.mapCount ].levelShot = -1;
		uiInfo.mapList[ uiInfo.mapCount ].imageName = String_Alloc( va( "levelshots/%s", uiInfo.mapList[ uiInfo.mapCount ].mapLoadName ) );

		uiInfo.mapCount++;

		if ( uiInfo.mapCount >= MAX_MAPS )
		{
			break;
		}
	}

	qsort( uiInfo.mapList, uiInfo.mapCount, sizeof( mapInfo ), UI_MapNameCompare );
}
Ejemplo n.º 17
0
/** G_LuaInit()
* Initialises the Lua API interface 
*/
qboolean G_LuaInit()
{
	//load from cvar
	int             i, len, num_vm = 0;
	char            buff[MAX_CVAR_VALUE_STRING], *crt;

	//load from files
	int             numdirs;
	int             numFiles;
	char            filename[128];
	char            dirlist[1024];
	char           *dirptr;
	int             dirlen;

	G_Printf("------- G_LuaInit -------\n");

	if(lua_modules.string[0])
	{
		//Load lua modules from the cvar
		Q_strncpyz(buff, lua_modules.string, sizeof(buff));
		len = strlen(buff);
		crt = buff;

		for(i = 0; i < LUA_NUM_VM; i++)
			lVM[i] = NULL;

		for(i = 0; i <= len; i++)
		{
			if(buff[i] == ' ' || buff[i] == '\0' || buff[i] == ',' || buff[i] == ';')
			{
				buff[i] = '\0';
				if(LoadLuaFile(crt, num_vm, VMT_GAMESCRIPT))
				{
					num_vm++;
					G_Printf("  %s Loaded\n", crt);
				}
				else
				{
					G_Printf("  %s Failed\n", crt);
				}

				// prepare for next iteration
				if(i + 1 < len)
					crt = buff + i + 1;
				else
					crt = NULL;
				if(num_vm >= LUA_NUM_VM)
				{
					LOG("Lua API: too many lua files specified, only the first %d have been loaded\n", LUA_NUM_VM);
					break;
				}
			}
		}
	}

	//Load lua modules in global folder
	numFiles = 0;
	numdirs = trap_FS_GetFileList("scripts/lua/global/", ".lua", dirlist, 1024);
	dirptr = dirlist;
	for(i = 0; i < numdirs; i++, dirptr += dirlen + 1)
	{
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/lua/global/");
		strcat(filename, dirptr);
		numFiles++;

		// load the file
		//G_LoadLuaScript(NULL, filename);
		if(LoadLuaFile(filename, num_vm, VMT_GAMESCRIPT))
		{
			num_vm++;
			G_Printf("  %s Loaded\n", filename);
		}
		else
		{
			G_Printf("  %s Failed\n", filename);
		}

		if(num_vm >= LUA_NUM_VM)
		{
			LOG("Lua API: too many lua files specified, only the first %d have been loaded\n", LUA_NUM_VM);
			break;
		}
	}

	Com_Printf("%i global files parsed\n", numFiles);

	//*
	numFiles = 0;
	trap_Cvar_VariableStringBuffer("mapname", buff, sizeof(buff));
	sprintf(filename, "scripts/lua/%s/", buff);
	numdirs = trap_FS_GetFileList(filename, ".lua", dirlist, 1024);
	dirptr = dirlist;
	for(i = 0; i < numdirs; i++, dirptr += dirlen + 1)
	{
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/lua/");
		strcat(filename, buff);
		strcat(filename, "/");
		strcat(filename, dirptr);
		numFiles++;

		// load the file
		//G_LoadLuaScript(NULL, filename);
		if(LoadLuaFile(filename, num_vm, VMT_MAPSCRIPT))
		{
			num_vm++;
			G_Printf("  %s Loaded\n", filename);
		}
		else
		{
			G_Printf("  %s Failed\n", filename);
		}

		if(num_vm >= LUA_NUM_VM)
		{
			LOG("Lua API: too many lua files specified, only the first %d have been loaded\n", LUA_NUM_VM);
			break;
		}
	}

	Com_Printf("%i map files parsed\n", numFiles);
	//*/

	G_Printf("------- G_LuaInit Finish -------\n");

	return qtrue;
}
Ejemplo n.º 18
0
/*
===============
Demos_MenuInit
===============
*/
static void Demos_MenuInit( void ) {
	int		i;
	int		len;
	char	*demoname, extension[32];

	memset( &s_demos, 0 ,sizeof(demos_t) );
	s_demos.menu.key = UI_DemosMenu_Key;

	Demos_Cache();

	s_demos.menu.fullscreen = qtrue;
	s_demos.menu.wrapAround = qtrue;

	s_demos.banner.generic.type		= MTYPE_BTEXT;
	s_demos.banner.generic.x		= 320;
	s_demos.banner.generic.y		= 16;
	s_demos.banner.string			= "DEMOS";
	s_demos.banner.color			= color_white;
	s_demos.banner.style			= UI_CENTER;

	s_demos.framel.generic.type		= MTYPE_BITMAP;
	s_demos.framel.generic.name		= ART_FRAMEL;
	s_demos.framel.generic.flags	= QMF_INACTIVE;
	s_demos.framel.generic.x		= 0;  
	s_demos.framel.generic.y		= 78;
	s_demos.framel.width			= 256;
	s_demos.framel.height			= 329;

	s_demos.framer.generic.type		= MTYPE_BITMAP;
	s_demos.framer.generic.name		= ART_FRAMER;
	s_demos.framer.generic.flags	= QMF_INACTIVE;
	s_demos.framer.generic.x		= 376;
	s_demos.framer.generic.y		= 76;
	s_demos.framer.width			= 256;
	s_demos.framer.height			= 334;

	s_demos.arrows.generic.type		= MTYPE_BITMAP;
	s_demos.arrows.generic.name		= ART_ARROWS;
	s_demos.arrows.generic.flags	= QMF_INACTIVE;
	s_demos.arrows.generic.x		= 320-ARROWS_WIDTH/2;
	s_demos.arrows.generic.y		= 400;
	s_demos.arrows.width			= ARROWS_WIDTH;
	s_demos.arrows.height			= ARROWS_HEIGHT;

	s_demos.left.generic.type		= MTYPE_BITMAP;
	s_demos.left.generic.flags		= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
	s_demos.left.generic.x			= 320-ARROWS_WIDTH/2;
	s_demos.left.generic.y			= 400;
	s_demos.left.generic.id			= ID_LEFT;
	s_demos.left.generic.callback	= Demos_MenuEvent;
	s_demos.left.width				= ARROWS_WIDTH/2;
	s_demos.left.height				= ARROWS_HEIGHT;
	s_demos.left.focuspic			= ART_ARROWLEFT;

	s_demos.right.generic.type		= MTYPE_BITMAP;
	s_demos.right.generic.flags		= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
	s_demos.right.generic.x			= 320;
	s_demos.right.generic.y			= 400;
	s_demos.right.generic.id		= ID_RIGHT;
	s_demos.right.generic.callback	= Demos_MenuEvent;
	s_demos.right.width				= ARROWS_WIDTH/2;
	s_demos.right.height			= ARROWS_HEIGHT;
	s_demos.right.focuspic			= ART_ARROWRIGHT;

	s_demos.back.generic.type		= MTYPE_BITMAP;
	s_demos.back.generic.name		= ART_BACK0;
	s_demos.back.generic.flags		= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
	s_demos.back.generic.id			= ID_BACK;
	s_demos.back.generic.callback	= Demos_MenuEvent;
	s_demos.back.generic.x			= 0;
	s_demos.back.generic.y			= 480-64;
	s_demos.back.width				= 128;
	s_demos.back.height				= 64;
	s_demos.back.focuspic			= ART_BACK1;

	s_demos.go.generic.type			= MTYPE_BITMAP;
	s_demos.go.generic.name			= ART_GO0;
	s_demos.go.generic.flags		= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
	s_demos.go.generic.id			= ID_GO;
	s_demos.go.generic.callback		= Demos_MenuEvent;
	s_demos.go.generic.x			= 640;
	s_demos.go.generic.y			= 480-64;
	s_demos.go.width				= 128;
	s_demos.go.height				= 64;
	s_demos.go.focuspic				= ART_GO1;

	s_demos.list.generic.type		= MTYPE_SCROLLLIST;
	s_demos.list.generic.flags		= QMF_PULSEIFFOCUS;
	s_demos.list.generic.callback	= Demos_MenuEvent;
	s_demos.list.generic.id			= ID_LIST;
	s_demos.list.generic.x			= 118;
	s_demos.list.generic.y			= 130;
	s_demos.list.width				= 16;
	s_demos.list.height				= 14;
	Com_sprintf(extension, sizeof(extension), "dm_%d", (int)trap_Cvar_VariableValue( "protocol" ) );
	s_demos.list.numitems			= trap_FS_GetFileList( "demos", extension, s_demos.names, NAMEBUFSIZE );
	s_demos.list.itemnames			= (const char **)s_demos.demolist;
	s_demos.list.columns			= 3;

	if (!s_demos.list.numitems) {
		strcpy( s_demos.names, "No Demos Found." );
		s_demos.list.numitems = 1;

		//degenerate case, not selectable
		s_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
	}
	else if (s_demos.list.numitems > MAX_DEMOS)
		s_demos.list.numitems = MAX_DEMOS;

	demoname = s_demos.names;
	for ( i = 0; i < s_demos.list.numitems; i++ ) {
		s_demos.list.itemnames[i] = demoname;
		
		// strip extension
		len = strlen( demoname );
		if (!Q_stricmp(demoname +  len - 4,".dm3"))
			demoname[len-4] = '\0';

		Q_strupr(demoname);

		demoname += len + 1;
	}

	Menu_AddItem( &s_demos.menu, &s_demos.banner );
	Menu_AddItem( &s_demos.menu, &s_demos.framel );
	Menu_AddItem( &s_demos.menu, &s_demos.framer );
	Menu_AddItem( &s_demos.menu, &s_demos.list );
	Menu_AddItem( &s_demos.menu, &s_demos.arrows );
	Menu_AddItem( &s_demos.menu, &s_demos.left );
	Menu_AddItem( &s_demos.menu, &s_demos.right );
	Menu_AddItem( &s_demos.menu, &s_demos.back );
	Menu_AddItem( &s_demos.menu, &s_demos.go );
}
Ejemplo n.º 19
0
/*
===============
Demos_MenuInit
===============
*/
static void Demos_MenuInit( void ) 
{
	int		i,x,y;
	int		len;
	char	*demoname;

	memset( &s_demos, 0 ,sizeof(demos_t) );
	s_demos.menu.key = UI_DemosMenu_Key;

	UI_DemosMenu_Cache();

	s_demos.menu.fullscreen					= qtrue;
	s_demos.menu.wrapAround					= qtrue;
	s_demos.menu.draw						= Demos_MenuDraw;
	s_demos.menu.descX						= MENU_DESC_X;
	s_demos.menu.descY						= MENU_DESC_Y;	
	s_demos.menu.titleX						= MENU_TITLE_X;
	s_demos.menu.titleY						= MENU_TITLE_Y;
	s_demos.menu.titleI						= MNT_DEMOS_TITLE;
	s_demos.menu.footNoteEnum				= MNT_DEMOS;

	s_demos.main.generic.type				= MTYPE_BITMAP;      
	s_demos.main.generic.flags				= QMF_HIGHLIGHT_IF_FOCUS;
	s_demos.main.generic.x					= 482;
	s_demos.main.generic.y					= 136;
	s_demos.main.generic.name				= BUTTON_GRAPHIC_LONGRIGHT;
	s_demos.main.generic.id					= ID_MAINMENU;
	s_demos.main.generic.callback			= Demos_MenuEvent;
	s_demos.main.width						= MENU_BUTTON_MED_WIDTH;
	s_demos.main.height						= MENU_BUTTON_MED_HEIGHT;
	s_demos.main.color						= CT_DKPURPLE1;
	s_demos.main.color2						= CT_LTPURPLE1;
	s_demos.main.textX						= MENU_BUTTON_TEXT_X;
	s_demos.main.textY						= MENU_BUTTON_TEXT_Y;
	s_demos.main.textEnum					= MBT_MAINMENU;
	s_demos.main.textcolor					= CT_BLACK;
	s_demos.main.textcolor2					= CT_WHITE;

	s_demos.engage.generic.type				= MTYPE_BITMAP;      
	s_demos.engage.generic.flags			= (QMF_INACTIVE|QMF_GRAYED);
	s_demos.engage.generic.x				= 283;
	s_demos.engage.generic.y				= 101;
	s_demos.engage.generic.name				= GRAPHIC_SQUARE;
	s_demos.engage.generic.id				= ID_ENGAGE;
	s_demos.engage.generic.callback			= Demos_MenuEvent;
	s_demos.engage.width					= MENU_BUTTON_MED_WIDTH;
	s_demos.engage.height					= MENU_BUTTON_MED_HEIGHT;
	s_demos.engage.color					= CT_DKPURPLE1;
	s_demos.engage.color2					= CT_LTPURPLE1;
	s_demos.engage.textX					= MENU_BUTTON_TEXT_X;
	s_demos.engage.textY					= MENU_BUTTON_TEXT_Y;
	s_demos.engage.textEnum					= MBT_ENGAGEDEMO;
	s_demos.engage.textcolor				= CT_BLACK;
	s_demos.engage.textcolor2				= CT_WHITE;

	s_demos.upArrow.generic.type			= MTYPE_BITMAP;
	s_demos.upArrow.generic.flags			= (QMF_INACTIVE|QMF_GRAYED);
	s_demos.upArrow.generic.x				= 486;
	s_demos.upArrow.generic.y				= 195;
	s_demos.upArrow.generic.name			= "menu/common/arrow_up_16.tga";
	s_demos.upArrow.generic.id				= ID_UP;
	s_demos.upArrow.generic.callback		= Demos_MenuEvent;
	s_demos.upArrow.width					= 14;
	s_demos.upArrow.height					= 14;
	s_demos.upArrow.color					= CT_DKGOLD1;;
	s_demos.upArrow.color2					= CT_LTGOLD1;;
	s_demos.upArrow.textcolor				= CT_BLACK;
	s_demos.upArrow.textcolor2				= CT_WHITE;

	s_demos.downArrow.generic.type			= MTYPE_BITMAP;
	s_demos.downArrow.generic.flags			= (QMF_INACTIVE|QMF_GRAYED);
	s_demos.downArrow.generic.x				= 486;
	s_demos.downArrow.generic.y				= 404;
	s_demos.downArrow.generic.name			= "menu/common/arrow_dn_16.tga";
	s_demos.downArrow.generic.id			= ID_DOWN;
	s_demos.downArrow.generic.callback		= Demos_MenuEvent;
	s_demos.downArrow.width					= 14;
	s_demos.downArrow.height				= 14;
	s_demos.downArrow.color					= CT_DKGOLD1;
	s_demos.downArrow.color2				= CT_LTGOLD1;
	s_demos.downArrow.textcolor				= CT_BLACK;
	s_demos.downArrow.textcolor2			= CT_WHITE;

	s_demos.currentFile.generic.type		= MTYPE_BITMAP;      
	s_demos.currentFile.generic.flags		= QMF_INACTIVE;
	s_demos.currentFile.generic.x			= 218;
	s_demos.currentFile.generic.y			= 68;
	s_demos.currentFile.generic.name		= BUTTON_GRAPHIC_LONGRIGHT;
	s_demos.currentFile.generic.id			= ID_MAINMENU;
	s_demos.currentFile.generic.callback	= Demos_MenuEvent;
	s_demos.currentFile.width				= MENU_BUTTON_MED_WIDTH;
	s_demos.currentFile.height				= MENU_BUTTON_MED_HEIGHT;
	s_demos.currentFile.color				= CT_BLACK;
	s_demos.currentFile.color2				= CT_BLACK;
	s_demos.currentFile.textX				= MENU_BUTTON_TEXT_X;
	s_demos.currentFile.textY				= MENU_BUTTON_TEXT_Y;
	s_demos.currentFile.textEnum			= MNT_NONE;
	s_demos.currentFile.textPtr				= NULL;
	s_demos.currentFile.textcolor			= CT_YELLOW;

	s_demos.list.generic.type				= MTYPE_SCROLLLIST;
	s_demos.list.generic.flags				= QMF_PULSEIFFOCUS;
	s_demos.list.generic.callback			= Demos_MenuEvent;
	s_demos.list.generic.id					= ID_LIST;
	s_demos.list.generic.x					= 118;
	s_demos.list.generic.y					= 170;
	s_demos.list.width						= 16;
	s_demos.list.height						= 14;
	s_demos.list.numitems					= trap_FS_GetFileList( "demos", ".efdemo", s_demos.names, NAMEBUFSIZE );
	s_demos.list.itemnames					= (const char **)s_demos.demolist;
	s_demos.list.columns					= 3;

	x = 225;
	y = 200;
	i=0;
	while (g_demoline[i])
	{
		((menubitmap_s *)g_demoline[i])->generic.type			= MTYPE_BITMAP;      
		((menubitmap_s *)g_demoline[i])->generic.flags			= QMF_INACTIVE | QMF_HIDDEN;
		((menubitmap_s *)g_demoline[i])->generic.x				= x;
		((menubitmap_s *)g_demoline[i])->generic.y				= y;
		((menubitmap_s *)g_demoline[i])->generic.name			= PIC_UNDERLINE;
		((menubitmap_s *)g_demoline[i])->generic.callback		= Demos_MenuEvent;
		((menubitmap_s *)g_demoline[i])->generic.id				= ID_DEMOCOMMENT1+i;
		((menubitmap_s *)g_demoline[i])->width					= 240;
		((menubitmap_s *)g_demoline[i])->height					= 16;
		((menubitmap_s *)g_demoline[i])->color					= CT_DKPURPLE1;
		((menubitmap_s *)g_demoline[i])->color2					= CT_LTPURPLE1;
		((menubitmap_s *)g_demoline[i])->textPtr				= NULL;
		((menubitmap_s *)g_demoline[i])->textX					= 4;
		((menubitmap_s *)g_demoline[i])->textY					= 1;
		((menubitmap_s *)g_demoline[i])->textcolor				= CT_DKGOLD1;
		((menubitmap_s *)g_demoline[i])->textcolor2				= CT_LTGOLD1;
		((menubitmap_s *)g_demoline[i])->textStyle				= UI_TINYFONT;
//		((menubitmap_s *)g_demoline[i])->textEnum				= MBT_DEMOLINE;

		Menu_AddItem( &s_demos.menu, ( void * )g_demoline[i]);
		y += 18;
		++i;
	}

	// No demos??
	if (!s_demos.list.numitems) 
	{
		strcpy( s_demos.names, menu_normal_text[MNT_NO_DEMOS_FOUND] );
		s_demos.list.numitems = 1;
	}
	else if (s_demos.list.numitems > MAX_DEMOS)
	{// Too many demos???
		s_demos.list.numitems = MAX_DEMOS;
	}

	//TiM - If the list is longer than we can fit, enable the scroll buttons
	if ( s_demos.list.numitems > MAX_DEMODISP ) {
		s_demos.upArrow.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;	
		s_demos.downArrow.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;	
	}

	// Point fields to demo names
	i=0;
	demoname = s_demos.names;
	//TiM - instead of sending the list names directly to the controls, we'll populate an array
	//with them and then selectively add the ones we want at the time to the controls. :)
	while ( i < s_demos.list.numitems ) {
		if ( !demoname )
			break;
		
		// strip extension
		len = strlen( demoname );
		if ( len>7 && !Q_stricmp(demoname +  len - 7,".efdemo"))
		{
			demoname[len-7] = '\0';
		}
		//Q_strupr(demoname);

		//insert into the array
		s_demos.demolist[i] = demoname;

		//increment
		demoname += len + 1;
		i++;
	}

	//Populate the controls with the values from the array	
	DemoMenu_PopulateList( s_demos.currentDemoIndex ); 

	Menu_AddItem( &s_demos.menu, &s_demos.main );
//	Menu_AddItem( &s_demos.menu, &s_demos.list );
	Menu_AddItem( &s_demos.menu, &s_demos.engage );
	Menu_AddItem( &s_demos.menu, &s_demos.currentFile );
	Menu_AddItem( &s_demos.menu, &s_demos.upArrow );
	Menu_AddItem( &s_demos.menu, &s_demos.downArrow );
}
Ejemplo n.º 20
0
void UI_SaberLoadParms( void ) 
{
	int			len, totallen, saberExtFNLen, fileCnt, i;
	char		*holdChar, *marker;
	char		saberExtensionListBuf[2048];			//	The list of file names read in
	fileHandle_t f;
	char buffer[MAX_MENUFILE];

	//ui.Printf( "UI Parsing *.sab saber definitions\n" );
	
	ui_saber_parms_parsed = qtrue;
	UI_CacheSaberGlowGraphics();

	//set where to store the first one
	totallen = 0;
	marker = SaberParms;
	marker[0] = '\0';

	//now load in the extra .npc extensions
	fileCnt = trap_FS_GetFileList("ext_data/sabers", ".sab", saberExtensionListBuf, sizeof(saberExtensionListBuf) );

	holdChar = saberExtensionListBuf;
	for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 ) 
	{
		saberExtFNLen = strlen( holdChar );

		len = trap_FS_FOpenFile( va( "ext_data/sabers/%s", holdChar), &f, FS_READ );

		if (!f)
		{
			continue;
		}

		if ( len == -1 ) 
		{
			Com_Printf( "UI_SaberLoadParms: error reading %s\n", holdChar );
		}
		else
		{
			if (len > sizeof(buffer) )
			{
				Com_Error( ERR_FATAL, "UI_SaberLoadParms: file %s too large to read (max=%d)", holdChar, sizeof(buffer) );
			}
			trap_FS_Read( buffer, len, f );
			trap_FS_FCloseFile( f );
			buffer[len] = 0;

			if ( totallen && *(marker-1) == '}' )
			{//don't let it end on a } because that should be a stand-alone token
				strcat( marker, " " );
				totallen++;
				marker++; 
			}
			len = COM_Compress( buffer );

			if ( totallen + len >= MAX_SABER_DATA_SIZE ) {
				Com_Error( ERR_FATAL, "UI_SaberLoadParms: ran out of space before reading %s\n(you must make the .sab files smaller)", holdChar );
			}
			strcat( marker, buffer );

			totallen += len;
			marker += len;
		}
	}
}
Ejemplo n.º 21
0
/*
===============
UI_LoadArenas
===============
*/
void UI_LoadArenas( void ) {
    int			numdirs;
//	vmCvar_t	arenasFile;
    char		filename[128];
    char		dirlist[1024];
    char*		dirptr;
    int			i/*, n*/;
    int			dirlen;
    //char		*type, *str;

    ui_numArenas = 0;
    uiInfo.mapCount = 0;

    /*	NERVE - SMF - commented out
    	trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM );
    	if( *arenasFile.string ) {
    		UI_LoadArenasFromFile(arenasFile.string);
    	}
    	else {
    		UI_LoadArenasFromFile("scripts/arenas.txt");
    	}
    */
    // get all arenas from .arena files
    numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 1024 );
    dirptr  = dirlist;
    for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
        dirlen = strlen(dirptr);
        strcpy(filename, "scripts/");
        strcat(filename, dirptr);
        UI_LoadArenasFromFile(filename);
    }
//	trap_DPrint( va( "%i arenas parsed\n", ui_numArenas ) ); // JPW NERVE pulled per atvi req
    /*	if (UI_OutOfMemory()) {
    		trap_Print(S_COLOR_YELLOW"WARNING: not anough memory in pool to load all arenas\n");
    	}*/

    /*	for( n = 0; n < ui_numArenas; n++ ) {
    		// determine type

    		uiInfo.mapList[uiInfo.mapCount].cinematic = -1;
    		uiInfo.mapList[uiInfo.mapCount].mapLoadName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "map"));
    		uiInfo.mapList[uiInfo.mapCount].mapName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "longname"));
    		uiInfo.mapList[uiInfo.mapCount].levelShot = -1;
    		uiInfo.mapList[uiInfo.mapCount].imageName = String_Alloc(va("levelshots/%s", uiInfo.mapList[uiInfo.mapCount].mapLoadName));
    		uiInfo.mapList[uiInfo.mapCount].typeBits = 0;

    		uiInfo.mapList[uiInfo.mapCount].briefing = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "briefing"));
    		uiInfo.mapList[uiInfo.mapCount].lmsbriefing = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "lmsbriefing"));
    //		uiInfo.mapList[uiInfo.mapCount].objectives = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "objectives"));*/
    // Gordon: cant use "\" in a key/pair translating * to \n for the moment, reeally should be using PC_ parsing stuff for this too
    // eek, no ; either.....

    // Arnout: THIS IS BAD DO NOT MODIFY A STRING AFTER IT IS ALLOCATED
    /*{
    	char* p;
    	while(p = strchr(uiInfo.mapList[uiInfo.mapCount].description, '*')) {
    		*p = '\n';
    	}

    	while(p = strchr(uiInfo.mapList[uiInfo.mapCount].objectives, '*')) {
    		*p = '\n';
    	}
    }*/

    // NERVE - SMF
    // set timelimit
    /*		str = Info_ValueForKey( ui_arenaInfos[n], "Timelimit" );
    		if ( *str )
    			uiInfo.mapList[uiInfo.mapCount].Timelimit = atoi( str );
    		else
    			uiInfo.mapList[uiInfo.mapCount].Timelimit = 0;

    		// set axis respawn time
    		str = Info_ValueForKey( ui_arenaInfos[n], "AxisRespawnTime" );
    		if ( *str )
    			uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime = atoi( str );
    		else
    			uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime = 0;

    		// set allied respawn time
    		str = Info_ValueForKey( ui_arenaInfos[n], "AlliedRespawnTime" );
    		if ( *str )
    			uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime = atoi( str );
    		else
    			uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime = 0;
    		// -NERVE - SMF

    		type = Info_ValueForKey( ui_arenaInfos[n], "type" );
    		if( *type ) {
    			// NERVE - SMF
    			if( strstr( type, "wolfsp" ) ) {
    				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_SINGLE_PLAYER);
    			}
    			if( strstr( type, "wolflms" ) ) {
    				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_LMS);
    			}
    			if( strstr( type, "wolfmp" ) ) {
    				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF);
    			}
    			if( strstr( type, "wolfsw" ) ) {
    				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_STOPWATCH);
    			}
    			// -NERVE - SMF
    		} else { // Gordon: default is wolf now
    			uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF);
    		}

    		str = Info_ValueForKey( ui_arenaInfos[n], "mapposition_x" );
    		if ( *str ) {
    			uiInfo.mapList[uiInfo.mapCount].mappos[0] = atof(str);
    		} else {
    			uiInfo.mapList[uiInfo.mapCount].mappos[0] = 0.f;
    		}

    		str = Info_ValueForKey( ui_arenaInfos[n], "mapposition_y" );
    		if ( *str ) {
    			uiInfo.mapList[uiInfo.mapCount].mappos[1] = atof(str);
    		} else {
    			uiInfo.mapList[uiInfo.mapCount].mappos[1] = 0.f;
    		}

    		uiInfo.mapCount++;
    		if (uiInfo.mapCount >= MAX_MAPS) {
    			break;
    		}
    	}*/

    // CHRUKER: b090 - Sorting the map list
    qsort( uiInfo.mapList, uiInfo.mapCount, sizeof(uiInfo.mapList[0]), UI_SortArenas );
}
Ejemplo n.º 22
0
/*
===============
UI_LoadCampaigns
===============
*/
void UI_LoadCampaigns( void ) {
    int			numdirs;
    char		filename[128];
    char		dirlist[1024];
    char*		dirptr;
    int			i, j;
    int			dirlen;
    long		hash;
    char		*ch;

    uiInfo.campaignCount = 0;
    memset( &uiInfo.campaignList, 0, sizeof(uiInfo.campaignList) );

    // get all campaigns from .campaign files
    numdirs = trap_FS_GetFileList( "scripts", ".campaign", dirlist, 1024 );
    dirptr  = dirlist;
    for (i = 0; i < numdirs && uiInfo.campaignCount < MAX_CAMPAIGNS; i++, dirptr += dirlen+1) {
        dirlen = strlen(dirptr);
        strcpy(filename, "scripts/");
        strcat(filename, dirptr);
        UI_LoadCampaignsFromFile(filename);
        //UI_LoadCampaignsFromFile( filename, uiInfo.campaignList, &uiInfo.campaignCount, MAX_CAMPAIGNS );
        //UI_LinkCampaignsToArenas();
    }
//	trap_DPrint( va( "%i campaigns parsed\n", ui_numCampaigns ) ); // JPW NERVE pulled per atvi req
    if (UI_OutOfMemory()) {
        trap_Print( S_COLOR_YELLOW"WARNING: not anough memory in pool to load all campaigns\n" );
    }

    // Sort the campaigns for single player

    // first, find the initial campaign
    for( i = 0; i < uiInfo.campaignCount; i++ ) {
        if( !(uiInfo.campaignList[i].typeBits & (1 << GT_SINGLE_PLAYER) ) )
            continue;

        if( uiInfo.campaignList[i].initial ) {
            uiInfo.campaignList[i].order = 0;
            break;
        }
    }

    // now use the initial nextCampaignShortName to find the next one, etc etc for single player campaigns
    // rain - don't let i go above the maximum number of campaigns
    while( i < MAX_CAMPAIGNS ) {
        j = UI_FindCampaignInCampaignList( uiInfo.campaignList[i].nextCampaignShortName );

        if( j == -1 )
            break;

        uiInfo.campaignList[j].order = uiInfo.campaignList[i].order + 1;
        i = j;
    }

    // Load the campaign save
    BG_LoadCampaignSave( va( "profiles/%s/campaign.dat", cl_profile.string ), &uiInfo.campaignStatus, cl_profile.string );

    for( i = 0; i < uiInfo.campaignCount; i++ ) {
        // generate hash for campaign shortname
        for( hash = 0, ch = (char *)uiInfo.campaignList[i].campaignShortName; *ch != '\0'; ch++ ) {
            hash += (long)(tolower(*ch))*((ch-uiInfo.campaignList[i].campaignShortName)+119);
        }

        // find the entry in the campaignsave
        for( j = 0; j < uiInfo.campaignStatus.header.numCampaigns; j++ ) {
            if( hash == uiInfo.campaignStatus.campaigns[j].shortnameHash ) {
                uiInfo.campaignList[i].unlocked = qtrue;
                uiInfo.campaignList[i].progress = uiInfo.campaignStatus.campaigns[j].progress;
                uiInfo.campaignList[i].cpsCampaign = &uiInfo.campaignStatus.campaigns[j];
            }
        }

        /*if( !uiInfo.campaignStatus.header.numCampaigns ||
        	j == uiInfo.campaignStatus.header.numCampaigns ) {
        	// not found, so not unlocked
        	uiInfo.campaignList[i].unlocked = qfalse;
        	uiInfo.campaignList[i].progress = 0;
        	uiInfo.campaignList[i].cpsCampaign = NULL;
        }*/
    }
    // CHRUKER: b090 - Sorting the campaign list
    qsort( uiInfo.campaignList, uiInfo.campaignCount, sizeof(uiInfo.campaignList[0]), UI_SortCampaigns );
}
Ejemplo n.º 23
0
/*
===============
UI_LoadArenas
===============
*/
static void UI_LoadArenas(void) {
    int         numdirs;
    vmCvar_t    arenasFile;
    char        filename[128];
    char        dirlist[2048];
    char*       dirptr;
    int         i, n;
    int         dirlen;
    char*        type;
    char*        tag;
    int         singlePlayerNum, specialNum, otherNum;

    ui_numArenas = 0;

    trap_Cvar_Register(&arenasFile, "g_arenasFile", "", CVAR_INIT | CVAR_ROM);
    if (*arenasFile.string) {
        UI_LoadArenasFromFile(arenasFile.string);
    } else {
        UI_LoadArenasFromFile("scripts/arenas.txt");
    }

    // get all arenas from .arena files
    numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 2048);
    dirptr  = dirlist;
    for (i = 0; i < numdirs; i++, dirptr += dirlen + 1) {
        dirlen = strlen(dirptr);
        strcpy(filename, "scripts/");
        strcat(filename, dirptr);
        UI_LoadArenasFromFile(filename);
    }
    trap_Print(va("%i arenas parsed\n", ui_numArenas));
    if (outOfMemory) trap_Print(S_COLOR_YELLOW"WARNING: not enough memory in pool to load all arenas\n");

    // set initial numbers
    for (n = 0; n < ui_numArenas; n++) {
        Info_SetValueForKey(ui_arenaInfos[n], "num", va("%i", n));
    }

    // go through and count single players levels
    ui_numSinglePlayerArenas = 0;
    ui_numSpecialSinglePlayerArenas = 0;
    for (n = 0; n < ui_numArenas; n++) {
        // determine type
        type = Info_ValueForKey(ui_arenaInfos[n], "type");

        // if no type specified, it will be treated as "ffa"
        if (!*type) {
            continue;
        }

        if (strstr(type, "single")) {
            // check for special single player arenas (training, final)
            tag = Info_ValueForKey(ui_arenaInfos[n], "special");
            if (*tag) {
                ui_numSpecialSinglePlayerArenas++;
                continue;
            }

            ui_numSinglePlayerArenas++;
        }
    }

    n = ui_numSinglePlayerArenas % ARENAS_PER_TIER;
    if (n != 0) {
        ui_numSinglePlayerArenas -= n;
        trap_Print(va("%i arenas ignored to make count divisible by %i\n", n, ARENAS_PER_TIER));
    }

    // go through once more and assign number to the levels
    singlePlayerNum = 0;
    specialNum = singlePlayerNum + ui_numSinglePlayerArenas;
    otherNum = specialNum + ui_numSpecialSinglePlayerArenas;
    for (n = 0; n < ui_numArenas; n++) {
        // determine type
        type = Info_ValueForKey(ui_arenaInfos[n], "type");

        // if no type specified, it will be treated as "ffa"
        if (*type) {
            if (strstr(type, "single")) {
                // check for special single player arenas (training, final)
                tag = Info_ValueForKey(ui_arenaInfos[n], "special");
                if (*tag) {
                    Info_SetValueForKey(ui_arenaInfos[n], "num", va("%i", specialNum++));
                    continue;
                }

                Info_SetValueForKey(ui_arenaInfos[n], "num", va("%i", singlePlayerNum++));
                continue;
            }
        }

        Info_SetValueForKey(ui_arenaInfos[n], "num", va("%i", otherNum++));
    }
}
Ejemplo n.º 24
0
/*
=================
PlayerModel_BuildList
=================
*/
static void PlayerModel_BuildList( void )
{
	int		numdirs;
	int		numfiles;
	char	dirlist[2048];
	char	filelist[2048];
	char	skinname[MAX_QPATH];
	char*	dirptr;
	char*	fileptr;
	int		i;
	int		j;
	int		dirlen;
	int		filelen;
	qboolean precache;

	precache = trap_Cvar_VariableValue("com_buildscript");

	s_playermodel.modelpage = 0;
	s_playermodel.nummodels = 0;

	// iterate directory of all player models
	numdirs = trap_FS_GetFileList("models/players", "/", dirlist, 2048 );
	dirptr  = dirlist;
	for (i=0; i<numdirs && s_playermodel.nummodels < MAX_PLAYERMODELS; i++,dirptr+=dirlen+1)
	{
		dirlen = strlen(dirptr);
		
		if (dirlen && dirptr[dirlen-1]=='/') dirptr[dirlen-1]='\0';

		if (!strcmp(dirptr,".") || !strcmp(dirptr,".."))
			continue;
			
		// iterate all skin files in directory
		numfiles = trap_FS_GetFileList( va("models/players/%s",dirptr), "$images", filelist, 2048 );
		fileptr  = filelist;
		for (j=0; j<numfiles && s_playermodel.nummodels < MAX_PLAYERMODELS;j++,fileptr+=filelen+1)
		{
			filelen = strlen(fileptr);

			COM_StripExtension(fileptr,skinname, sizeof(skinname));

			// look for icon_????
			if (!Q_stricmpn(skinname,"icon_",5))
			{
				Com_sprintf( s_playermodel.modelnames[s_playermodel.nummodels++],
					sizeof( s_playermodel.modelnames[s_playermodel.nummodels] ),
					"models/players/%s/%s", dirptr, skinname );
				//if (s_playermodel.nummodels >= MAX_PLAYERMODELS)
				//	return;
			}

			if( precache ) {
				trap_S_RegisterSound( va( "sound/player/announce/%s_wins.wav", skinname), qfalse );
			}
		}
	}	

	//APSFIXME - Degenerate no models case

	s_playermodel.numpages = s_playermodel.nummodels/MAX_MODELSPERPAGE;
	if (s_playermodel.nummodels % MAX_MODELSPERPAGE)
		s_playermodel.numpages++;
}
Ejemplo n.º 25
0
/*
===============
Demos_MenuInit
===============
*/
static void Demos_MenuInit (const char *dirName)
{
	int		i;
	int		len;
	char	*demoname, extension[32];

	memset( &s_demos, 0 ,sizeof(demos_t) );
	s_demos.menu.key = UI_DemosMenu_Key;
	Q_strncpyz(s_demos.dirName, dirName, sizeof(s_demos.dirName));
	//Com_sprintf(s_demos.dirName, sizeof(s_demos.dirName), "%s%s", UseQuakeLiveDir ? "ql:" : "", dirName);
	//Com_Printf("dirname '%s'\n", s_demos.dirName);
	Demos_Cache();

	s_demos.menu.fullscreen = qtrue;
	s_demos.menu.wrapAround = qtrue;

	s_demos.banner.generic.type		= MTYPE_BTEXT;  //MTYPE_PTEXT;  //MTYPE_BTEXT;
	s_demos.banner.generic.x		= 320;
	s_demos.banner.generic.y		= 16;
	//s_demos.banner.width 	= 10;
	//s_demos.banner.height   = 10;
	s_demos.banner.string			= "DEMOS";
	s_demos.banner.color			= color_white;
	s_demos.banner.style			= UI_CENTER;

	s_demos.framel.generic.type		= MTYPE_BITMAP;
	s_demos.framel.generic.name		= ART_FRAMEL;
	s_demos.framel.generic.flags	= QMF_INACTIVE;
	s_demos.framel.generic.x		= 0;
	s_demos.framel.generic.y		= 78;
	s_demos.framel.width			= 256;
	s_demos.framel.height			= 329;

	s_demos.framer.generic.type		= MTYPE_BITMAP;
	s_demos.framer.generic.name		= ART_FRAMER;
	s_demos.framer.generic.flags	= QMF_INACTIVE;
	s_demos.framer.generic.x		= 376;
	s_demos.framer.generic.y		= 76;
	s_demos.framer.width			= 256;
	s_demos.framer.height			= 334;

#if 1
	s_demos.arrows.generic.type		= MTYPE_BITMAP;
	s_demos.arrows.generic.name		= ART_ARROWS;
	s_demos.arrows.generic.flags	= QMF_INACTIVE;
	s_demos.arrows.generic.x		= 320-ARROWS_WIDTH/2;
	s_demos.arrows.generic.y		= 400;
	s_demos.arrows.width			= ARROWS_WIDTH;
	s_demos.arrows.height			= ARROWS_HEIGHT;
#endif

#if 0
	s_demos.left.generic.type		= MTYPE_BITMAP;
	s_demos.left.generic.flags		= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
	s_demos.left.generic.x			= 320-ARROWS_WIDTH/2;
	s_demos.left.generic.y			= 400;
	s_demos.left.generic.id			= ID_LEFT;
	s_demos.left.generic.callback	= Demos_MenuEvent;
	s_demos.left.width				= ARROWS_WIDTH/2;
	s_demos.left.height				= ARROWS_HEIGHT;
	s_demos.left.focuspic			= ART_ARROWLEFT;

	s_demos.right.generic.type		= MTYPE_BITMAP;
	s_demos.right.generic.flags		= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
	s_demos.right.generic.x			= 320;
	s_demos.right.generic.y			= 400;
	s_demos.right.generic.id		= ID_RIGHT;
	s_demos.right.generic.callback	= Demos_MenuEvent;
	s_demos.right.width				= ARROWS_WIDTH/2;
	s_demos.right.height			= ARROWS_HEIGHT;
	s_demos.right.focuspic			= ART_ARROWRIGHT;
#endif

	s_demos.back.generic.type		= MTYPE_BITMAP;
	s_demos.back.generic.name		= ART_BACK0;
	s_demos.back.generic.flags		= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
	s_demos.back.generic.id			= ID_BACK;
	s_demos.back.generic.callback	= Demos_MenuEvent;
	s_demos.back.generic.x			= 0;
	s_demos.back.generic.y			= 480-64;
	s_demos.back.width				= 128;
	s_demos.back.height				= 64;
	s_demos.back.focuspic			= ART_BACK1;

	s_demos.go.generic.type			= MTYPE_BITMAP;
	s_demos.go.generic.name			= ART_GO0;
	s_demos.go.generic.flags		= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
	s_demos.go.generic.id			= ID_GO;
	s_demos.go.generic.callback		= Demos_MenuEvent;
	s_demos.go.generic.x			= 640;
	s_demos.go.generic.y			= 480-64;
	s_demos.go.width				= 128;
	s_demos.go.height				= 64;
	s_demos.go.focuspic				= ART_GO1;

	s_demos.list.generic.type		= MTYPE_SCROLLLIST;
	s_demos.list.generic.flags		= QMF_PULSEIFFOCUS;
	s_demos.list.generic.callback	= Demos_MenuEvent;
	s_demos.list.generic.id			= ID_LIST;
	s_demos.list.generic.x			= 20;  //118;
	s_demos.list.generic.y			= 90;  //130;
	s_demos.list.width				= 40;  //16;
	s_demos.list.height				= 20;  //14;
	Com_sprintf(extension, sizeof(extension), ".%s%d", DEMOEXT, (int) trap_Cvar_VariableValue("protocol"));
	//s_demos.list.numitems			= trap_FS_GetFileList( "demos", extension, s_demos.names, NAMEBUFSIZE );
	//s_demos.list.numitems			= trap_FS_GetFileList("demos", "*wantDirs", s_demos.names, NAMEBUFSIZE);
	s_demos.list.numitems			= trap_FS_GetFileList(dirName, "*wantDirs", s_demos.names, NAMEBUFSIZE);
	s_demos.list.itemnames			= (const char **)s_demos.demolist;
	s_demos.list.columns			= 1;

	if (!s_demos.list.numitems) {
		//strcpy( s_demos.names, "No Demos Found." );
		Q_strncpyz(s_demos.names, "../", sizeof(s_demos.names));
		s_demos.list.numitems = 1;

		//degenerate case, not selectable
		s_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
	}
	else if (s_demos.list.numitems > MAX_DEMOS) {
		Com_Printf("^1maximum number of demos (%d) for a directory, skipping some demos\n", MAX_DEMOS);
		s_demos.list.numitems = MAX_DEMOS;
	}

	demoname = s_demos.names;

	for ( i = 0; i < s_demos.list.numitems; i++ ) {
		s_demos.list.itemnames[i] = demoname;

		len = strlen( demoname );
#if 0
		// strip extension
		if (!Q_stricmp(demoname +  len - 4,".dm3"))
			demoname[len-4] = '\0';
#endif
//		Q_strupr(demoname);

		demoname += len + 1;
	}

	qsort(s_demos.list.itemnames, s_demos.list.numitems, sizeof(char *), CmpStrings);

#if 0
	for (i = 0;  i < s_demos.list.numitems;  i++) {
		Com_Printf("%d: %s\n", i, s_demos.list.itemnames[i]);
	}
#endif

	Menu_AddItem( &s_demos.menu, &s_demos.banner );
	//Menu_AddItem( &s_demos.menu, &s_demos.framel );
	//Menu_AddItem( &s_demos.menu, &s_demos.framer );
	Menu_AddItem( &s_demos.menu, &s_demos.list );
	//Menu_AddItem( &s_demos.menu, &s_demos.arrows );
	//Menu_AddItem( &s_demos.menu, &s_demos.left );
	//Menu_AddItem( &s_demos.menu, &s_demos.right );
	Menu_AddItem( &s_demos.menu, &s_demos.back );
	Menu_AddItem( &s_demos.menu, &s_demos.go );
}
Ejemplo n.º 26
0
/*
===============
UI_LoadArenas
===============
*/
void UI_LoadArenas( void ) {
	int numdirs;
//	vmCvar_t	arenasFile;
	char filename[128];
	char dirlist[1024];
	char*       dirptr;
	int i, n;
	int dirlen;
	const char        *type, *str;

	ui_numArenas = 0;
	uiInfo.mapCount = 0;

/*	NERVE - SMF - commented out
	trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM );
	if( *arenasFile.string ) {
		UI_LoadArenasFromFile(arenasFile.string);
	}
	else {
		UI_LoadArenasFromFile("scripts/arenas.txt");
	}
*/
	// get all arenas from .arena files
	numdirs = trap_FS_GetFileList( "scripts", ".arena", dirlist, 1024 );
	dirptr  = dirlist;
	for ( i = 0; i < numdirs; i++, dirptr += dirlen + 1 ) {
		dirlen = strlen( dirptr );
		strcpy( filename, "scripts/" );
		strcat( filename, dirptr );
		UI_LoadArenasFromFile( filename );
	}
//	trap_DPrint( va( "%i arenas parsed\n", ui_numArenas ) ); // JPW NERVE pulled per atvi req
	if ( UI_OutOfMemory() ) {
		trap_Print( S_COLOR_YELLOW "WARNING: not anough memory in pool to load all arenas\n" );
	}

	for ( n = 0; n < ui_numArenas; n++ ) {
		// determine type

		uiInfo.mapList[uiInfo.mapCount].cinematic = -1;
		uiInfo.mapList[uiInfo.mapCount].mapLoadName = String_Alloc( Info_ValueForKey( ui_arenaInfos[n], "map" ) );
		uiInfo.mapList[uiInfo.mapCount].mapName = String_Alloc( Info_ValueForKey( ui_arenaInfos[n], "longname" ) );
		uiInfo.mapList[uiInfo.mapCount].levelShot = -1;
		uiInfo.mapList[uiInfo.mapCount].imageName = String_Alloc( va( "levelshots/%s", uiInfo.mapList[uiInfo.mapCount].mapLoadName ) );
		uiInfo.mapList[uiInfo.mapCount].typeBits = 0;

		// NERVE - SMF
		// set timelimit
		str = Info_ValueForKey( ui_arenaInfos[n], "Timelimit" );
		if ( *str ) {
			uiInfo.mapList[uiInfo.mapCount].Timelimit = atoi( str );
		} else {
			uiInfo.mapList[uiInfo.mapCount].Timelimit = 0;
		}

		// set axis respawn time
		str = Info_ValueForKey( ui_arenaInfos[n], "AxisRespawnTime" );
		if ( *str ) {
			uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime = atoi( str );
		} else {
			uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime = 0;
		}

		// set allied respawn time
		str = Info_ValueForKey( ui_arenaInfos[n], "AlliedRespawnTime" );
		if ( *str ) {
			uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime = atoi( str );
		} else {
			uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime = 0;
		}
		// -NERVE - SMF

		type = Info_ValueForKey( ui_arenaInfos[n], "type" );
		// if no type specified, it will be treated as "ffa"
		if ( *type ) {
			if ( strstr( type, "ffa" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_FFA );
			}
			if ( strstr( type, "tourney" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_TOURNAMENT );
			}
			if ( strstr( type, "ctf" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_CTF );
			}
			// NERVE - SMF
			if ( strstr( type, "wolfmp" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_WOLF );
			}
			if ( strstr( type, "wolfsw" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_WOLF_STOPWATCH );
			}
			if ( strstr( type, "wolfcp" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_WOLF_CP );
			}
			// -NERVE - SMF
#ifdef MISSIONPACK
			if ( strstr( type, "oneflag" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_1FCTF );
			}
			if ( strstr( type, "overload" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_OBELISK );
			}
			if ( strstr( type, "harvester" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_HARVESTER );
			}
#endif  // #ifdef MISSIONPACK
		} else {
			uiInfo.mapList[uiInfo.mapCount].typeBits |= ( 1 << GT_FFA );
		}

		uiInfo.mapCount++;
		if ( uiInfo.mapCount >= MAX_MAPS ) {
			break;
		}
	}
}
Ejemplo n.º 27
0
/*
============
BG_VoiceList
============
*/
static voice_t *BG_VoiceList( void )
{
	char    fileList[ MAX_VOICES * ( MAX_VOICE_NAME_LEN + 6 ) ] = { "" };
	int     numFiles, i, fileLen = 0;
	int     count = 0;
	char    *filePtr;
	voice_t *voices = NULL;
	voice_t *top = NULL;

	numFiles = trap_FS_GetFileList( "voice", ".voice", fileList,
	                                sizeof( fileList ) );

	if ( numFiles < 1 )
	{
		return NULL;
	}

	// special case for default.voice.  this file is REQUIRED and will
	// always be loaded first in the event of overflow of voice definitions
	if ( !trap_FS_FOpenFile( "voice/default.voice", NULL, FS_READ ) )
	{
		Com_Printf( "voice/default.voice missing, voice system disabled.\n" );
		return NULL;
	}

	voices = ( voice_t * ) BG_Alloc( sizeof( voice_t ) );
	Q_strncpyz( voices->name, "default", sizeof( voices->name ) );
	voices->cmds = NULL;
	voices->next = NULL;
	count = 1;

	top = voices;

	filePtr = fileList;

	for ( i = 0; i < numFiles; i++, filePtr += fileLen + 1 )
	{
		fileLen = strlen( filePtr );

		// accounted for above
		if ( !Q_stricmp( filePtr, "default.voice" ) )
		{
			continue;
		}

		if ( fileLen >= MAX_VOICE_NAME_LEN + 6 )
		{
			Com_Printf( S_WARNING "MAX_VOICE_NAME_LEN is %d. "
			            "skipping \"%s\", filename too long\n", MAX_VOICE_NAME_LEN, filePtr );
			continue;
		}

		// trap_FS_GetFileList() buffer has overflowed
		if ( !trap_FS_FOpenFile( va( "voice/%s", filePtr ), NULL, FS_READ ) )
		{
			Com_Printf( S_WARNING "BG_VoiceList(): detected "
			            "an invalid .voice file \"%s\" in directory listing.  You have "
			            "probably named one or more .voice files with outrageously long "
			            "names.\n", filePtr );
			break;
		}

		if ( count >= MAX_VOICES )
		{
			Com_Printf( S_WARNING ".voice file overflow.  "
			            "%d of %d .voice files loaded.  MAX_VOICES is %d\n",
			            count, numFiles, MAX_VOICES );
			break;
		}

		voices->next = ( voice_t * ) BG_Alloc( sizeof( voice_t ) );
		voices = voices->next;

		Q_strncpyz( voices->name, filePtr, sizeof( voices->name ) );
		// strip extension
		voices->name[ fileLen - 6 ] = '\0';
		voices->cmds = NULL;
		voices->next = NULL;
		count++;
	}

	return top;
}