示例#1
0
文件: g_bot.c 项目: 0culus/ioq3
/*
===============
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_Print( va( "%i arenas parsed\n", g_numArenas ) );
	
	for( n = 0; n < g_numArenas; n++ ) {
		Info_SetValueForKey( g_arenaInfos[n], "num", va( "%i", n ) );
	}
}
示例#2
0
文件: g_bot.c 项目: 0culus/ioq3
/*
===============
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_Print( va( "%i bots parsed\n", g_numBots ) );
}
示例#3
0
/*
===============
UI_SPUnlock_f
===============
*/
void UI_SPUnlock_f( void ) {
	char	arenaKey[16];
	char	scores[MAX_INFO_VALUE];
	int		level;
	int		tier;

	// get scores for skill 1
	trap_Cvar_VariableStringBuffer( "g_spScores1", scores, MAX_INFO_VALUE );

	// update scores
	for( level = 0; level < ui_numSinglePlayerArenas + ui_numSpecialSinglePlayerArenas; level++ ) {
		Com_sprintf( arenaKey, sizeof( arenaKey ), "l%i", level );
		Info_SetValueForKey( scores, arenaKey, "1" );
	}
	trap_Cvar_Set( "g_spScores1", scores );

	// unlock cinematics
	for( tier = 1; tier <= 8; tier++ ) {
		UI_ShowTierVideo( tier );
	}

	trap_Print( "All levels unlocked at skill level 1\n" );

	UI_SPLevelMenu_ReInit();
}
示例#4
0
/**
 * Delete a specific bot
 * @param clientNum [int] bot client id
 */
void G_BotDel( int clientNum ) {
	gentity_t *ent;

	if(clientNum < 0) return;

	ent = &g_entities[clientNum];
	if( !( ent->r.svFlags & SVF_BOT ) ) {
		trap_Print( va("'^7%s^7' is not a bot\n", ent->client->pers.netname) );
		return;
	}
    G_BotDebug(ent, BOT_VERB_IMPORTANT, BOT_DEBUG_GENERAL, "Bot deleted\n");
	ent->inuse = qfalse;
	ent->r.svFlags = 0;
	//BG_Free(ent->bot->path.crumb); 
	if(ent->bot) {
		BG_Free(ent->bot);
	}
    //LEPE:
    if(ent->client->pers.teamSelection == TEAM_HUMANS && level.humanBots > 0) {
        level.humanBots--;
    } else if(ent->client->pers.teamSelection == TEAM_ALIENS && level.alienBots > 0) {
        level.alienBots--;
    }
	ClientDisconnect(clientNum);
}
示例#5
0
/*
===============
UI_GetBotInfoByNumber
===============
*/
char *UI_GetBotInfoByNumber( int num ) {
	if( num < 0 || num >= ui_numBots ) {
		trap_Print( va( S_COLOR_RED "Invalid bot number: %i\n", num ) );
		return NULL;
	}
	return ui_botInfos[num];
}
示例#6
0
void CG_AddPMItem( popupMessageType_t type, const char* message, qhandle_t shader ) {
	pmListItem_t* listItem;
	char* end;

	if ( !message || !*message ) {
		return;
	}
	if ( type < 0 || type >= PM_NUM_TYPES ) {
		CG_Printf( "Invalid popup type: %d\n", type );
		return;
	}

	listItem = CG_FindFreePMItem();

	if ( !listItem ) {
		return;
	}

	if ( shader ) {
		listItem->shader = shader;
	} else {
		listItem->shader = cgs.media.pmImages[type];
	}

	listItem->inuse = true;
	listItem->type = type;
	Q_strncpyz( listItem->message, message, sizeof( cg_pmStack[0].message ) );

	// rain - moved this: print and THEN chop off the newline, as the
	// console deals with newlines perfectly.  We do chop off the newline
	// at the end, if any, though.
	if ( listItem->message[strlen( listItem->message ) - 1] == '\n' ) {
		listItem->message[strlen( listItem->message ) - 1] = 0;
	}

	trap_Print( va( "%s\n", listItem->message ) );

	// rain - added parens
	while ( ( end = strchr( listItem->message, '\n' ) ) ) {
		*end = '\0';
	}

	// rain - don't eat popups for empty lines
	if ( *listItem->message == '\0' ) {
		return;
	}

	if ( !cg_pmWaitingList ) {
		cg_pmWaitingList = listItem;
		listItem->time = cg.time;
	} else {
		pmListItem_t* loop = cg_pmWaitingList;
		while ( loop->next ) {
			loop = loop->next;
		}

		loop->next = listItem;
	}
}
示例#7
0
/*
===============
G_LoadBots
===============
*/
static void G_LoadBots(void)
{
	int             len;
	char           *filename;
	vmCvar_t        botsFile;
	fileHandle_t    f;
	char            buf[MAX_BOTS_TEXT];

	if(!bot_enable.integer)
	{
		return;
	}

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

	len = trap_FS_FOpenFile(filename, &f, FS_READ);
	if(!f)
	{
		trap_Print(va(S_COLOR_RED "file not found: %s\n", filename));
		return;
	}
	if(len >= MAX_BOTS_TEXT)
	{
		trap_Print(va(S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_BOTS_TEXT));
		trap_FS_FCloseFile(f);
		return;
	}

	trap_FS_Read(buf, len, f);
	buf[len] = 0;
	trap_FS_FCloseFile(f);

	g_numBots = Com_ParseInfos(buf, MAX_BOTS, g_botInfos);
	trap_Print(va("%i bots parsed\n", g_numBots));

	// load bot script
	Bot_ScriptLoad();
}
示例#8
0
/*
===============
G_LoadArenas
===============
*/
static void G_LoadArenas(void)
{
#ifdef QUAKESTUFF
	int             len;
	char           *filename;
	vmCvar_t        arenasFile;
	fileHandle_t    f;
	int             n;
	char            buf[MAX_ARENAS_TEXT];

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

	len = trap_FS_FOpenFile(filename, &f, FS_READ);
	if(!f)
	{
		trap_Print(va(S_COLOR_RED "file not found: %s\n", filename));
		return;
	}
	if(len >= MAX_ARENAS_TEXT)
	{
		trap_Print(va(S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_ARENAS_TEXT));
		trap_FS_FCloseFile(f);
		return;
	}

	trap_FS_Read(buf, len, f);
	buf[len] = 0;
	trap_FS_FCloseFile(f);

	g_numArenas = Com_ParseInfos(buf, MAX_ARENAS, g_arenaInfos);
	trap_Print(va("%i arenas parsed\n", g_numArenas));

	for(n = 0; n < g_numArenas; n++)
	{
		Info_SetValueForKey(g_arenaInfos[n], "num", va("%i", n));
	}
#endif
}
示例#9
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);
}
示例#10
0
文件: ui_atoms.c 项目: elhobbs/quake3
void QDECL Com_Printf( const char *msg, ... ) {
	va_list		argptr;
	char		text[1024];

	va_start (argptr, msg);
	vsprintf (text, msg, argptr);
	va_end (argptr);

	trap_Print( va("%s", text) );
}
void QDECL G_Printf( const char *fmt, ... ) {
	va_list		argptr;
	char		text[1024];

	va_start (argptr, fmt);
	Q_vsnprintf (text, sizeof(text), fmt, argptr);
	va_end (argptr);

	trap_Print( text );
}
示例#12
0
static void	UI_Cache_f() {
	int i;
	Display_CacheAll();
	if (trap_Argc() == 2) {
		for (i = 0; i < uiInfo.q3HeadCount; i++)
		{
			trap_Print( va("model %s\n", uiInfo.q3HeadNames[i]) );
		}
	}
}
void QDECL Com_Printf( const char *msg, ... ) {
	va_list		argptr;
	char		text[1024];

	va_start (argptr, msg);
	Q_vsnprintf (text, sizeof(text), msg, argptr);
	va_end (argptr);

	trap_Print( text );
}
示例#14
0
文件: tvm_main.c 项目: Picmip/qfusion
/*
* TVM_Printf
*/
void TVM_Printf( const char *format, ... ) {
	va_list argptr;
	char msg[1024];

	va_start( argptr, format );
	Q_vsnprintfz( msg, sizeof( msg ), format, argptr );
	va_end( argptr );

	trap_Print( msg );
}
示例#15
0
void QDECL Com_Printf( const char *msg, ... ) {
	va_list		argptr;
	char		text[1024];

	va_start (argptr, msg);
	Q_vsnprintf (text, sizeof(text), msg, argptr);
	va_end (argptr);
	__android_log_print(ANDROID_LOG_INFO, "quake", " %s ",text);

	trap_Print( va("%s", text) );
}
示例#16
0
void CG_DemosAddLog (const char *fmt, ...)
{
	va_list args;
	char text[MAX_PRINT_MSG];

	va_start(args, fmt);
	Q_vsnprintf(text, sizeof(text), fmt, args);
	va_end(args);

	trap_Print(va("^6q3mme: ^7%s\n", text));
}
static JSBool sys_print(JSContext *cx, unsigned argc, jsval *vp)
{
    JSString *s;
    char *message;
    if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &s))
        return JS_FALSE;
    message = JS_EncodeString(cx, s);
    trap_Print(message);
    JS_free(cx, message);
    JS_SET_RVAL(cx, vp, JSVAL_VOID);
    return JS_TRUE;
}
示例#18
0
/*
===============
Svcmd_AddBot_f
===============
*/
void Svcmd_AddBot_f( void ) {
	float			skill;
	int				delay;
	char			name[MAX_TOKEN_CHARS];
	char			altname[MAX_TOKEN_CHARS];
	char			string[MAX_TOKEN_CHARS];
	char			team[MAX_TOKEN_CHARS];

	// are bots enabled?
	if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
		return;
	}

	// name
	trap_Argv( 1, name, sizeof( name ) );
	if ( !name[0] ) {
		trap_Print( "Usage: Addbot <botname> [skill 1-5] [team] [msec delay] [altname]\n" );
		return;
	}

	// skill
	trap_Argv( 2, string, sizeof( string ) );
	if ( !string[0] ) {
		skill = 4;
	}
	else {
		skill = atof( string );
	}

	// team
	trap_Argv( 3, team, sizeof( team ) );

	// delay
	trap_Argv( 4, string, sizeof( string ) );
	if ( !string[0] ) {
		delay = 0;
	}
	else {
		delay = atoi( string );
	}

	// alternative name
	trap_Argv( 5, altname, sizeof( altname ) );

	G_AddBot( name, skill, team, delay, altname );

	// if this was issued during gameplay and we are playing locally,
	// go ahead and load the bot's media immediately
	if ( level.time - level.startTime > 1000 &&
		trap_Cvar_VariableIntegerValue( "cl_running" ) ) {
		trap_SendServerCommand( -1, "loaddefered\n" );	// FIXME: spelled wrong, but not changing for demo
	}
}
示例#19
0
void Com_Printf( const char *fmt, ... )
{
	va_list	argptr;
	char text[1024];

	va_start( argptr, fmt );
	vsnprintf( text, sizeof( text ), fmt, argptr );
	va_end( argptr );
	text[sizeof( text )-1] = 0;

	trap_Print( text );
}
示例#20
0
/*
=================
CG_HeadModelVoiceChats
=================
*/
int CG_HeadModelVoiceChats( char *filename ) {
	int	len, i;
	fileHandle_t f;
	char buf[MAX_VOICEFILESIZE];
	char **p, *ptr;
	char *token;

	len = trap_FS_FOpenFile( filename, &f, FS_READ );
	if ( !f ) {
		trap_Print( va( "voice chat file not found: %s\n", filename ) );
		return -1;
	}
	if ( len >= MAX_VOICEFILESIZE ) {
		trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i", filename, len, MAX_VOICEFILESIZE ) );
		trap_FS_FCloseFile( f );
		return -1;
	}

	trap_FS_Read( buf, len, f );
	buf[len] = 0;
	trap_FS_FCloseFile( f );

	ptr = buf;
	p = &ptr;

	token = COM_ParseExt(p, qtrue);
	if (!token || token[0] == 0) {
		return -1;
	}

	for ( i = 0; i < MAX_VOICEFILES; i++ ) {
		if ( !Q_stricmp(token, voiceChatLists[i].name) ) {
			return i;
		}
	}

	//FIXME: maybe try to load the .voice file which name is stored in token?

	return -1;
}
示例#21
0
void Com_DPrintf( const char *format, ... )
{
	va_list	argptr;
	char msg[1024];

	va_start( argptr, format );
	Q_vsnprintfz( msg, sizeof( msg ), format, argptr );
	va_end( argptr );

	if( trap_Cvar_Value("developer") > 0 ) {
		trap_Print( msg );
	}
}
示例#22
0
/*
===============
G_LoadBotsFromFile
===============
*/
static void G_LoadBotsFromFile( char *filename ) {
	int				len;
	fileHandle_t	f;
	char			buf[MAX_BOTS_TEXT];

	len = trap_FS_FOpenFile( filename, &f, FS_READ );
	if ( !f ) {
		trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
		return;
	}
	if ( len >= MAX_BOTS_TEXT ) {
		trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i\n", filename, len, MAX_BOTS_TEXT ) );
		trap_FS_FCloseFile( f );
		return;
	}

	trap_FS_Read( buf, len, f );
	buf[len] = 0;
	trap_FS_FCloseFile( f );

	g_numBots += G_ParseInfos( buf, MAX_BOTS - g_numBots, &g_botInfos[g_numBots] );
}
示例#23
0
/*
===============
UI_LoadArenasFromFile
===============
*/
static void UI_LoadArenasFromFile( char *filename ) {
	int len;
	fileHandle_t f;
	char buf[MAX_ARENAS_TEXT];

	len = trap_FS_FOpenFile( filename, &f, FS_READ );
	if ( !f ) {
		trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
		return;
	}
	if ( len >= MAX_ARENAS_TEXT ) {
		trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_ARENAS_TEXT ) );
		trap_FS_FCloseFile( f );
		return;
	}

	trap_FS_Read( buf, len, f );
	buf[len] = 0;
	trap_FS_FCloseFile( f );

	ui_numArenas += UI_ParseInfos( buf, MAX_ARENAS - ui_numArenas, &ui_arenaInfos[ui_numArenas] );
}
示例#24
0
文件: bot.c 项目: icanhas/yantar
/*
 * Svcmd_AddBot_f
 */
void
Svcmd_AddBot_f(void)
{
	float	skill;
	int	delay;
	char	name[MAX_TOKEN_CHARS];
	char	altname[MAX_TOKEN_CHARS];
	char	string[MAX_TOKEN_CHARS];
	char	team[MAX_TOKEN_CHARS];

	/* are bots enabled? */
	if(!trap_cvargeti("bot_enable"))
		return;

	/* name */
	trap_Argv(1, name, sizeof(name));
	if(!name[0]){
		trap_Print(
			"Usage: Addbot <botname> [skill 1-5] [team] [msec delay] [altname]\n");
		return;
	}

	/* skill */
	trap_Argv(2, string, sizeof(string));
	if(!string[0])
		skill = 4;
	else
		skill = atof(string);

	/* team */
	trap_Argv(3, team, sizeof(team));

	/* delay */
	trap_Argv(4, string, sizeof(string));
	if(!string[0])
		delay = 0;
	else
		delay = atoi(string);

	/* alternative name */
	trap_Argv(5, altname, sizeof(altname));

	G_AddBot(name, skill, team, delay, altname);

	/* if this was issued during gameplay and we are playing locally,
	 * go ahead and load the bot's media immediately */
	if(level.time - level.startTime > 1000 &&
	   trap_cvargeti("cl_running"))
		trap_SendServerCommand(-1, "loaddeferred\n");
}
示例#25
0
/*
===============
UI_LoadBotsFromFile
===============
*/
static void UI_LoadBotsFromFile(char* filename) {
    int             len;
    fileHandle_t    f;
    char            buf[MAX_BOTS_TEXT];

    len = trap_FS_FOpenFile(filename, &f, FS_READ);
    if (!f) {
        trap_Print(va(S_COLOR_RED "file not found: %s\n", filename));
        return;
    }
    if (len >= MAX_BOTS_TEXT) {
        trap_Print(va(S_COLOR_RED "file too large: %s is %i, max allowed is %i\n", filename, len, MAX_BOTS_TEXT));
        trap_FS_FCloseFile(f);
        return;
    }

    trap_FS_Read(buf, len, f);
    buf[len] = 0;
    trap_FS_FCloseFile(f);

    ui_numBots += UI_ParseInfos(buf, MAX_BOTS - ui_numBots, &ui_botInfos[ui_numBots]);
    if (outOfMemory) trap_Print(S_COLOR_YELLOW"WARNING: not enough memory in pool to load all bots\n");
}
示例#26
0
void QDECL Com_DPrintf( const char *msg, ... ) {
	va_list		argptr;
	char		text[1024];

	if (!trap_Cvar_VariableValue("developer")) {
		return;			// don't confuse non-developers with techie stuff...
	}

	va_start (argptr, msg);
	Q_vsnprintf (text, sizeof(text), msg, argptr);
	va_end (argptr);

	trap_Print( text );
}
示例#27
0
/*
===============
UI_SPUnlockMedals_f
===============
*/
void UI_SPUnlockMedals_f(void) {
    int     n;
    char    key[16];
    char    awardData[MAX_INFO_VALUE];

    trap_Cvar_VariableStringBuffer("g_spAwards", awardData, MAX_INFO_VALUE);

    for (n = 0; n < 6; n++) {
        Com_sprintf(key, sizeof(key), "a%i", n);
        Info_SetValueForKey(awardData, key, "100");
    }

    trap_Cvar_Set("g_spAwards", awardData);

    trap_Print("All levels unlocked at 100\n");
}
示例#28
0
void QDECL Com_Printf(const char *msg, ...) {
	va_list argptr;
	char    text[1024];

	va_start(argptr, msg);
	Q_vsnprintf(text, sizeof (text), msg, argptr);
	va_end(argptr);

#ifdef CGAMEDLL
	CG_Printf("%s", text);
#elif defined GAMEDLL
	G_Printf("%s", text);
#else
	trap_Print(va("%s", text));
#endif
}
示例#29
0
/*
===============
UI_GetArenaInfoByNumber
===============
*/
const char* UI_GetArenaInfoByNumber(int num) {
    int     n;
    char*    value;

    if (num < 0 || num >= ui_numArenas) {
        trap_Print(va(S_COLOR_RED "Invalid arena number: %i\n", num));
        return NULL;
    }

    for (n = 0; n < ui_numArenas; n++) {
        value = Info_ValueForKey(ui_arenaInfos[n], "num");
        if (*value && atoi(value) == num) {
            return ui_arenaInfos[n];
        }
    }

    return NULL;
}
示例#30
0
void G_refPrintf(gentity_t * ent, const char *fmt, ...)
{
	va_list         argptr;
	char            text[1024];

	va_start(argptr, fmt);
	Q_vsnprintf(text, sizeof(text), fmt, argptr);
	va_end(argptr);

	if(ent == NULL)
	{
		trap_Print(va("%s\n", text));	// CHRUKER: b047 - Added linebreak to the string
	}
	else
	{
		// CHRUKER: b046 - Was using the cpm command, but this is really just for the console
		CP(va("print \"%s\n\"", text));
	}
}