Exemplo n.º 1
0
void XBL_MM_Update_Session()
{
	// VVFIXME - Do we need to ensure that slot counts are right?
	// Our gamertag hasn't changed (I hope) so we leave that alone.

	// Get current map index, and gametype
	int index = mapNameToIndex( sv_mapname->string );
	if (index == MAP_ARRAY_SIZE)
	{
		Com_Error( ERR_FATAL, "Bad map name: %s\n", sv_mapname->string );
	}
	session.CurrentMap = index;
	session.GameType = sv_gametype->integer;

	// All other game options:
	session.FriendlyFire	= g_friendlyFire.integer;
	session.JediMastery		= g_maxForceRank.integer;
	session.SaberOnly		= HasSetSaberOnly();
	session.Dedicated		= com_dedicated->integer;

	// Update the advertised session info
	session.Update();
}
Exemplo n.º 2
0
// did this player earn the tactician award?
qboolean CalculateTactician(gentity_t *ent, int *kills)
{
#ifdef LOGGING_WEAPONS
	int			i = 0, nBestPlayer = -1, nKills = 0, nMostKills = 0;
	int			person = 0, weapon = 0;
	gentity_t	*player = NULL;
	int			wasPickedUpBySomeone[WP_NUM_WEAPONS];
	int			killsWithWeapon[WP_NUM_WEAPONS];
	int			playTime = (level.time - ent->client->pers.enterTime)/60000;

	if ( HasSetSaberOnly() )
	{//duh, only 1 weapon
		return qfalse;
	}
	if ( g_gametype.integer == GT_JEDIMASTER && ent->client->ps.isJediMaster )
	{//Jedi Master (was Borg queen) has only 1 weapon
		return qfalse;
	}
	//------------------------------------------------------ MUST HAVE ACHIEVED 2 KILLS PER MINUTE
	if (playTime<0.3)
		return qfalse;

	if ( ((float)ent->client->ps.persistant[PERS_SCORE])/((float)(playTime)) < 2.0 )
		return qfalse;
	//------------------------------------------------------ MUST HAVE ACHIEVED 2 KILLS PER MINUTE




	//------------------------------------------------------ FOR EVERY WEAPON, ADD UP TOTAL PICKUPS
	for (weapon = 0; weapon<WP_NUM_WEAPONS; weapon++)
			wasPickedUpBySomeone[weapon] = 0;				// CLEAR

	for (person=0; person<sv_maxclients.integer; person++)
	{
		for (weapon = 0; weapon<WP_NUM_WEAPONS; weapon++)
		{
			if (G_WeaponLogPickups[person][weapon]>0)
				wasPickedUpBySomeone[weapon]++;
		}
	}
	//------------------------------------------------------ FOR EVERY WEAPON, ADD UP TOTAL PICKUPS




	//------------------------------------------------------ FOR EVERY PERSON, CHECK FOR CANDIDATE
	for (person=0; person<sv_maxclients.integer; person++)
	{
		player = g_entities + person;
		if (!player->inuse)			continue;

		nKills = 0;											// This Persons's Kills
		for (weapon=0; weapon<WP_NUM_WEAPONS; weapon++)
			killsWithWeapon[weapon] = 0;					// CLEAR

		for (i=0; i<MOD_MAX; i++)
		{
			weapon = weaponFromMOD[i];									// Select Weapon
			killsWithWeapon[weapon] += G_WeaponLogKills[person][i];		// Store Num Kills With Weapon
		}

		weapon=WP_STUN_BATON;		// Start At Stun Baton
		//   keep looking through weapons if weapon is not on map, or if it is and we used it
		while( weapon<WP_NUM_WEAPONS && (!wasPickedUpBySomeone[weapon] || killsWithWeapon[weapon]>0) )
		{
			weapon++;
			nKills+=killsWithWeapon[weapon];							//  Update the number of kills
		}
		//
		// At this point we have either successfully gone through every weapon on the map and saw it had
		// been used, or we found one that WAS on the map and was NOT used
		//
		// so we look to see if the weapon==Max (i.e. we used every one) and then we check to see
		// if we got the most kills out of anyone else who did this.
		//
		if (weapon>=WP_NUM_WEAPONS && nKills>nMostKills)
		{
			// WE ARE A TACTICION CANDIDATE
			nMostKills  = nKills;
			nBestPlayer = person;
		}
	}
	//------------------------------------------------------ FOR EVERY PERSON, CHECK FOR CANDIDATE

	//Now, if we are the best player, return true and the number of kills we got
	if (nBestPlayer == ent->s.number)
	{
		*kills = nMostKills;
		return qtrue;
	}
#endif // LOGGING_WEAPONS
	return qfalse;
}
Exemplo n.º 3
0
void G_PrintStats(void) {
	const playerStat_t	*columns;
	gclient_t			*cl;
	int					stats[STAT_MAX];
	int					bestStats[STAT_MAX];
	qboolean			reallyBest[STAT_MAX] = { qfalse };
	int					i, j;

	if (level.numPlayingClients == 0) {
		return;
	}

	cl = &level.clients[level.sortedClients[0]];
	GetStats(bestStats, cl);

	for (i = 1; i < level.numPlayingClients; i++) {
		cl = &level.clients[level.sortedClients[i]];
		GetStats(stats, cl);

		for (j = 0; j <= STAT_MAX_ASC; j++) {
			if (stats[j] != bestStats[j]) {
				reallyBest[j] = qtrue;
			}
			if (stats[j] > bestStats[j]) {
				bestStats[j] = stats[j];
			}
		}
		for (; j < STAT_MAX; j++) {
			if (stats[j] != bestStats[j]) {
				reallyBest[j] = qtrue;
			}
			if (stats[j] < bestStats[j]) {
				bestStats[j] = stats[j];
			}
		}
	}

	// Don't highlight the stat if it's the same for all players
	for (j = 0; j < STAT_MAX; j++) {
		if (!reallyBest[j]) {
			bestStats[j] = INT_MAX;
		}
	}

	// disable stats irrelevant in current gametype. column arrays can
	// be removed at this point, but i'd rather keep line length under
	// firm control
	statCol[STAT_ACC].disabled = HasSetSaberOnly();
	statCol[STAT_IMPRESSIVE].disabled = (g_spawnWeapons.integer & WP_DISRUPTOR);

	trap_SendServerCommand(-1, "print \"\n\"");

	if (GT_Team(g_gametype.integer) && g_gametype.integer != GT_REDROVER) {
		if (g_gametype.integer == GT_CTF) {
			if (g_instagib.integer)
				columns = ictfColumns;
			else
				columns = ctfColumns;
		} else {
			if (g_instagib.integer)
				columns = iffaColumns;
			else
				columns = tffaColumns;
		}

		PrintStatsHeader(columns);

		PrintStatsSeparator(columns, teamColorString[TEAM_RED]);
		for (i = 0; i < level.numPlayingClients; i++) {
			cl = level.clients + level.sortedClients[i];
			if (cl->sess.sessionTeam == TEAM_RED)
				PrintClientStats(cl, columns, bestStats);
		}

		PrintStatsSeparator(columns, teamColorString[TEAM_BLUE]);
		for (i = 0; i < level.numPlayingClients; i++) {
			cl = level.clients + level.sortedClients[i];
			if (cl->sess.sessionTeam == TEAM_BLUE) {
				PrintClientStats(cl, columns, bestStats);
			}
		}
	} else {
		if (g_instagib.integer) {
			columns = iffaColumns;
		} else if (g_gametype.integer == GT_REDROVER) {
			columns = tffaColumns;
		} else {
			columns = ffaColumns;
		}

		PrintStatsHeader(columns);

		PrintStatsSeparator(columns, teamColorString[TEAM_FREE]);
		for (i = 0; i < level.numPlayingClients; i++) {
			cl = level.clients + level.sortedClients[i];
			PrintClientStats(cl, columns, bestStats);
		}
	}

	trap_SendServerCommand(-1, "print \"\n\"");

}
Exemplo n.º 4
0
// SOF2 had some silly two-stage thing. They stored off the session parms here, then used
// a couple globals to delay advertisement until later. I'm going to try and avoid that
void XBL_MM_Init_Session()
{
	// Fill in # of slots. OpenPublic is total slots, minus one for server, minus # reserved for private
	session.PrivateFilled		= 0;
	session.PrivateOpen			= sv_privateClients->integer;
	session.PublicFilled		= (com_dedicated->integer ? 0 : 1);	// Non-dedicated server fills a slot
	session.PublicOpen			= sv_maxclients->integer - (session.PrivateOpen + session.PublicFilled);
	session.TotalPlayers		= session.PublicFilled;

	// Get current map index, and gametype
	int index = mapNameToIndex( sv_mapname->string );
	if (index == MAP_ARRAY_SIZE)
	{
		Com_Error( ERR_FATAL, "Bad map name: %s\n", sv_mapname->string );
	}
	session.CurrentMap = index;
	session.GameType = sv_gametype->integer;

	// Copy the host's gamertag to the session name
	XONLINE_USER* pHostAccount = XBL_GetUserInfo( XBL_GetSelectedAccountIndex() );
	WCHAR sessionName[XONLINE_GAMERTAG_SIZE] = { 0 };
	if ( pHostAccount )
	{
		charToWchar( sessionName, pHostAccount->szGamertag );
	}
	else
	{
		charToWchar( sessionName, "unknown" );
	}
	session.SetSessionName( sessionName );

	// All other game options:
	session.FriendlyFire	= g_friendlyFire.integer;
	session.JediMastery		= g_maxForceRank.integer;
	session.SaberOnly		= HasSetSaberOnly();
	session.Dedicated		= com_dedicated->integer;

	// Actually create the session. If we don't call Process immediately, it explodes
	HRESULT hr = session.Create();
	if (hr != S_OK)
	{
		Com_Error( ERR_DROP, "Failed to create session: 0x%x\n", hr );
	}

	do
	{
		if( !XBL_PumpLogon() )
			return;
		hr = session.Process();
	} while ( session.IsCreating() );

	// VVFIXME - Better error handling
	if ( !session.Exists() )
	{
		Com_Error( ERR_DROP, "Failed to create session #2: 0x%x\n", hr );
	}

	// Fix for a bug. Server was using Notification API before advertising, so for
	// the first few seconds, had the wrong sessionID, and thus couldn't invite.
	// Force an update now:
	XBL_F_CheckJoinableStatus( true );
}
Exemplo n.º 5
0
void SP_misc_holocron(gentity_t *ent)
{
	vec3_t dest;
	trace_t tr;

	if (g_gametype.integer != GT_HOLOCRON)
	{
		G_FreeEntity(ent);
		return;
	}

	if (HasSetSaberOnly())
	{
		if (ent->count == FP_SABERATTACK ||
			ent->count == FP_SABERDEFEND ||
			ent->count == FP_SABERTHROW)
		{ //having saber holocrons in saber only mode is pointless
			G_FreeEntity(ent);
			return;
		}
	}

	ent->s.isJediMaster = qtrue;

	VectorSet( ent->r.maxs, 8, 8, 8 );
	VectorSet( ent->r.mins, -8, -8, -8 );

	ent->s.origin[2] += 0.1;
	ent->r.maxs[2] -= 0.1;

	VectorSet( dest, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] - 4096 );
	trap_Trace( &tr, ent->s.origin, ent->r.mins, ent->r.maxs, dest, ent->s.number, MASK_SOLID );
	if ( tr.startsolid )
	{
		G_Printf ("SP_misc_holocron: misc_holocron startsolid at %s\n", vtos(ent->s.origin));
		G_FreeEntity( ent );
		return;
	}

	//add the 0.1 back after the trace
	ent->r.maxs[2] += 0.1;

	// allow to ride movers
//	ent->s.groundEntityNum = tr.entityNum;

	G_SetOrigin( ent, tr.endpos );

	if (ent->count < 0)
	{
		ent->count = 0;
	}

	if (ent->count >= NUM_FORCE_POWERS)
	{
		ent->count = NUM_FORCE_POWERS-1;
	}
/*
	if (g_forcePowerDisable.integer &&
		(g_forcePowerDisable.integer & (1 << ent->count)))
	{
		G_FreeEntity(ent);
		return;
	}
*/
	//No longer doing this, causing too many complaints about accidentally setting no force powers at all
	//and starting a holocron game (making it basically just FFA)

	ent->enemy = NULL;

	ent->s.eFlags = EF_BOUNCE_HALF;

	ent->s.modelindex = (ent->count - 128);//G_ModelIndex(holocronTypeModels[ent->count]);
	ent->s.eType = ET_HOLOCRON;
	ent->s.pos.trType = TR_GRAVITY;
	ent->s.pos.trTime = level.time;

	ent->r.contents = CONTENTS_TRIGGER;
	ent->clipmask = MASK_SOLID;

	ent->s.trickedentindex4 = ent->count;

	if (forcePowerDarkLight[ent->count] == FORCE_DARKSIDE)
	{
		ent->s.trickedentindex3 = 1;
	}
	else if (forcePowerDarkLight[ent->count] == FORCE_LIGHTSIDE)
	{
		ent->s.trickedentindex3 = 2;
	}
	else
	{
		ent->s.trickedentindex3 = 3;
	}

	ent->physicsObject = qtrue;

	VectorCopy(ent->s.pos.trBase, ent->s.origin2); //remember the spawn spot

	ent->touch = HolocronTouch;

	trap_LinkEntity(ent);

	ent->think = HolocronThink;
	ent->nextthink = level.time + 50;
}