Esempio n. 1
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( "[skipnotify]%i arenas parsed\n", ui_numArenas ) );

	if ( UI_OutOfMemory() )
	{
		trap_Print( S_WARNING "not enough 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"

		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 );
}
Esempio n. 2
0
/*
===============
UI_LoadArenas
===============
*/
void UI_LoadArenas(void)
{
	int             numdirs;
	char            filename[128];
	char            dirlist[MAX_ARENAS];
	char           *dirptr;
	int             i, n;
	int             dirlen;

	ui_numArenas = 0;
	uiInfo.mapCount = 0;

	// get all arenas from .arena files
	numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, MAX_ARENAS);
	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( "[skipnotify]%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++)
	{
		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);
}
Esempio n. 3
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;
		}
	}
}
Esempio n. 4
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 );
}
Esempio n. 5
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;
		}
	}
}
Esempio n. 6
0
void UI_LoadArenas( void ) {
	int			numdirs;
	char		filename[MAX_QPATH];
	char		dirlist[MAPSBUFSIZE];
	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, ARRAY_LEN( dirlist ) );
	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( "%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);
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_TEAM);
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_JEDIMASTER);
			}
			if( strstr( type, "holocron" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_HOLOCRON);
			}
			if( strstr( type, "jedimaster" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_JEDIMASTER);
			}
			if( strstr( type, "duel" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_DUEL);
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_POWERDUEL);
			}
			if( strstr( type, "powerduel" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_DUEL);
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_POWERDUEL);
			}
			if( strstr( type, "siege" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_SIEGE);
			}
			if( strstr( type, "ctf" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_CTF);
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_CTY);
			}
			if( strstr( type, "cty" ) ) {
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_CTY);
			}
		} else {
			uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);
			uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_JEDIMASTER);
		}

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