Beispiel #1
0
/**
 * @brief Shuffle active players onto teams
 */
void G_shuffleTeams(void)
{
	int       i;
	team_t    cTeam; //, cMedian = level.numNonSpectatorClients / 2;
	int       cnt = 0;
	int       sortClients[MAX_CLIENTS];
	gclient_t *cl;

	G_teamReset(TEAM_AXIS, qtrue);
	G_teamReset(TEAM_ALLIES, qtrue);

	for (i = 0; i < level.numConnectedClients; i++)
	{
		cl = level.clients + level.sortedClients[i];

		if (cl->sess.sessionTeam != TEAM_AXIS && cl->sess.sessionTeam != TEAM_ALLIES)
		{
			continue;
		}

		sortClients[cnt++] = level.sortedClients[i];
	}

	qsort(sortClients, cnt, sizeof(int), G_SortPlayersByXP);

	for (i = 0; i < cnt; i++)
	{
		cl = level.clients + sortClients[i];

		//	cTeam = (i % 2) + TEAM_AXIS;
		cTeam = (((i + 1) % 4) - ((i + 1) % 2)) / 2 + TEAM_AXIS;

		if (cl->sess.sessionTeam != cTeam)
		{
			G_LeaveTank(g_entities + sortClients[i], qfalse);
			G_RemoveClientFromFireteams(sortClients[i], qtrue, qfalse);
			if (g_landminetimeout.integer)
			{
				G_ExplodeMines(g_entities + sortClients[i]);
			}
			G_FadeItems(g_entities + sortClients[i], MOD_SATCHEL);
		}

		cl->sess.sessionTeam = cTeam;

		G_UpdateCharacter(cl);
		ClientUserinfoChanged(sortClients[i]);
		ClientBegin(sortClients[i]);
	}

	AP("cp \"^1Teams have been shuffled!\n\"");
}
Beispiel #2
0
// Checks to see if a specified team is allowing players to join.
qboolean G_teamJoinCheck(int team_num, gentity_t *ent) {
	int cnt = TeamCount(-1, team_num);

	// Sanity check
	if (cnt == 0) {
		G_teamReset(team_num);
		teamInfo[team_num].team_lock = qfalse;
	}

	// Check for locked teams
	if (team_num == TEAM_AXIS || team_num == TEAM_ALLIES) {
		if ((int)ent->client->sess.sessionTeam == team_num) {
			return qtrue;
		}
		// Check for full teams
		if (team_maxplayers.integer > 0 && team_maxplayers.integer <= cnt) {
			G_printFull(va("The %s team is full!", aTeams[team_num]), ent);
			return qfalse;

			// Check for locked teams
		} else if (teamInfo[team_num].team_lock && (!(ent->client->pers.invite & team_num))) {
			G_printFull(va("The %s team is LOCKED!", aTeams[team_num]), ent);
			return qfalse;
		}
	}

	return qtrue;
}
Beispiel #3
0
void G_initMatch( void ) {
	int i;

	for ( i = TEAM_AXIS; i <= TEAM_ALLIES; i++ ) {
		G_teamReset( i, false );
	}
}
Beispiel #4
0
/**
 * @brief Check if we need to reset the game state due to an empty team
 * @param[in] nTeam
 */
void G_verifyMatchState(team_t nTeam)
{
	if ((level.lastRestartTime + 1000) < level.time && (nTeam == TEAM_ALLIES || nTeam == TEAM_AXIS) &&
	    (g_gamestate.integer == GS_PLAYING || g_gamestate.integer == GS_WARMUP_COUNTDOWN || g_gamestate.integer == GS_INTERMISSION))
	{
		if (TeamCount(-1, nTeam) == 0)
		{
			if (g_doWarmup.integer > 0)
			{
				level.lastRestartTime = level.time;
				if (g_gametype.integer == GT_WOLF_STOPWATCH)
				{
					trap_Cvar_Set("g_currentRound", "0");
					trap_Cvar_Set("g_nextTimeLimit", "0");
				}

				trap_SendConsoleCommand(EXEC_APPEND, va("map_restart 0 %i\n", GS_WARMUP));

			}
			else
			{
				teamInfo[nTeam].team_lock = qfalse;
			}

			G_teamReset(nTeam, qtrue);
		}
	}

	// Cleanup of ready count
	G_checkReady();
}
Beispiel #5
0
/**
 * @brief Swaps active players on teams
 */
void G_swapTeams(void)
{
	int       i;
	gclient_t *cl;

	for (i = TEAM_AXIS; i <= TEAM_ALLIES; i++)
	{
		G_teamReset(i, qtrue);
	}

	for (i = 0; i < level.numConnectedClients; i++)
	{
		cl = level.clients + level.sortedClients[i];

		if (cl->sess.sessionTeam == TEAM_AXIS)
		{
			cl->sess.sessionTeam = TEAM_ALLIES;
		}
		else if (cl->sess.sessionTeam == TEAM_ALLIES)
		{
			cl->sess.sessionTeam = TEAM_AXIS;
		}
		else
		{
			continue;
		}

		G_UpdateCharacter(cl);
		ClientUserinfoChanged(level.sortedClients[i]);
		ClientBegin(level.sortedClients[i]);
	}

	AP("cp \"^1Teams have been swapped!\n\"");
}
Beispiel #6
0
/**
 * @brief Checks to see if a specified team is allowing players to join.
 * @param[in] team_num
 * @param[in] ent
 * @return
 */
qboolean G_teamJoinCheck(team_t team_num, gentity_t *ent)
{
	int cnt = TeamCount(-1, team_num);

	// Sanity check
	if (cnt == 0)
	{
		G_teamReset(team_num, qtrue);
		teamInfo[team_num].team_lock = qfalse;
	}

	// Check for locked teams
	if ((team_num == TEAM_AXIS || team_num == TEAM_ALLIES))
	{
		if (ent->client->sess.sessionTeam == team_num)
		{
			return qtrue;
		}

		if (g_gametype.integer != GT_WOLF_LMS)
		{
			// Check for full teams
			if (team_maxplayers.integer > 0 && team_maxplayers.integer <= cnt)
			{
				G_printFull(va("The %s team is full!", aTeams[team_num]), ent);
				return qfalse;

				// Check for locked teams
			}
			else if (teamInfo[team_num].team_lock && (!(ent->client->pers.invite & team_num)))
			{
				G_printFull(va("The %s team is LOCKED!", aTeams[team_num]), ent);
				return qfalse;
			}
		}
		else
		{
			if (team_maxplayers.integer > 0 && team_maxplayers.integer <= cnt)
			{
				G_printFull(va("The %s team is full!", aTeams[team_num]), ent);
				return qfalse;
			}
			else if (g_gamestate.integer == GS_PLAYING && g_lms_lockTeams.integer && (!(ent->client->pers.invite & team_num)))
			{
				G_printFull(va("The %s team is LOCKED!", aTeams[team_num]), ent);
				return qfalse;
			}
		}
	}

	return qtrue;
}