예제 #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 );
}
예제 #2
0
	static int Menu_SetFont( lua_State *L ) {
		menuDef_t *menu = CheckMenu( L, 1 );
		const char *font = luaL_checkstring( L, 2 );
		if ( trap->R_RegisterFont( font ) ) {
			menu->font = String_Alloc( font );
		}
		return 0;
	}
예제 #3
0
파일: ui_gameinfo.c 프로젝트: otty/cake3
/*
===============
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);
}
예제 #4
0
/**
* @brief Same as PC_String_Parse except it uses a trap call
* to client's gettext translation function.
*/
qboolean PC_String_ParseTranslate(int handle, const char **out)
{
	pc_token_t token;

	if (!trap_PC_ReadToken(handle, &token))
	{
		return qfalse;
	}

	*(out) = String_Alloc(__(token.string));

	return qtrue;
}
예제 #5
0
qboolean String_Parse(char **p, const char **out)
{
	char *token;

	token = COM_ParseExt(p, qfalse);
	if (token && token[0] != 0)
	{
		*(out) = String_Alloc(token);
		return qtrue;
	}

	return qfalse;
}
예제 #6
0
qboolean PC_Script_Parse(int handle, const char **out)
{
	char       script[4096];
	pc_token_t token;

	memset(script, 0, sizeof(script));
	// scripts start with { and have ; separated command lists.. commands are command, arg..
	// basically we want everything between the { } as it will be interpreted at run time

	if (!trap_PC_ReadToken(handle, &token))
	{
		return qfalse;
	}

	if (Q_stricmp(token.string, "{") != 0)
	{
		return qfalse;
	}

	while (1)
	{
		if (!trap_PC_ReadToken(handle, &token))
		{
			return qfalse;
		}

		if (Q_stricmp(token.string, "}") == 0)
		{
			*out = String_Alloc(script);
			return qtrue;
		}

		if (token.string[1] != '\0')
		{
			Q_strcat(script, 4096, va("\"%s\"", token.string));
		}
		else
		{
			Q_strcat(script, 4096, token.string);
		}

		Q_strcat(script, 4096, " ");
	}

	return qfalse;
}
예제 #7
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;
		}
	}
}
예제 #8
0
//void UI_SaberGetHiltInfo( const char *singleHilts[MAX_SABER_HILTS], const char *staffHilts[MAX_SABER_HILTS] )
void UI_SaberGetHiltInfo(void){
	int	numSingleHilts = 0, numStaffHilts = 0;
	const char	*saberName;
	const char	*token;
	const char	*p;

	//go through all the loaded sabers and put the valid ones in the proper list
	p = SaberParms;
	COM_BeginParseSession("saberlist");

	// look for a saber
	while ( p )
	{
		token = COM_ParseExt( &p, qtrue );
		if ( token[0] == 0 )
		{//invalid name
			continue;
		}
		saberName = String_Alloc( token );
		//see if there's a "{" on the next line
		SkipRestOfLine( &p );

		if ( UI_ParseLiteralSilent( &p, "{" ) ) 
		{//nope, not a name, keep looking
			continue;
		}

		//this is a saber name
		if ( !UI_SaberValidForPlayerInMP( saberName ) )
		{
			SkipBracedSection( &p );
			continue;
		}

		if ( UI_IsSaberTwoHanded( saberName ) )
		{
#ifndef DYNAMICMEMORY_SABERS
			if ( numStaffHilts < MAX_SABER_HILTS-1 )//-1 because we have to NULL terminate the list
			{
				staffHilts[numStaffHilts++] = saberName;
			}
			else
			{
				Com_Printf( "WARNING: too many two-handed sabers, ignoring saber '%s'\n", saberName );
			}
#else
			UI_ReaAllocMem((void *)&saberStaffHiltInfo, sizeof(char *), numStaffHilts+1);
			saberStaffHiltInfo[numStaffHilts++] = (char *) saberName;
#endif
		}
		else
		{
#ifndef DYNAMICMEMORY_SABERS
			if ( numSingleHilts < MAX_SABER_HILTS-1 )//-1 because we have to NULL terminate the list
			{
				singleHilts[numSingleHilts++] = saberName;
			}
			else
			{
				Com_Printf( "WARNING: too many one-handed sabers, ignoring saber '%s'\n", saberName );
			}
#else
			UI_ReaAllocMem((void *)&saberSingleHiltInfo, sizeof(char *), numSingleHilts+1);
			saberSingleHiltInfo[numSingleHilts++] = (char *) saberName;
#endif
		}
		//skip the whole braced section and move on to the next entry
		SkipBracedSection( &p );
	}
	//null terminate the list so the UI code knows where to stop listing them
#ifndef DYNAMICMEMORY_SABERS
	singleHilts[numSingleHilts] = NULL;
	staffHilts[numStaffHilts] = NULL;
#else
	saberSingleHiltCount = numSingleHilts;
	saberStaffHiltCount = numStaffHilts;
#endif
}
예제 #9
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;
		}
	}
}
예제 #10
0
파일: ui_gameinfo.c 프로젝트: BSzili/OpenJK
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;
		}
	}
}
예제 #11
0
	static int Menu_SoundLoop( lua_State *L ) {
		menuDef_t *menu = CheckMenu( L, 1 );
		const char *sound = luaL_checkstring( L, 2 );
		menu->soundName = String_Alloc( sound );
		return 0;
	}
예제 #12
0
	static int Menu_SetName( lua_State *L ) {
		menuDef_t *menu = CheckMenu( L, 1 );
		menu->window.name = String_Alloc( luaL_checkstring( L, 2 ) );
		return 0;
	}