// restarts everyone and the world
void CBaseRoundRules::FullRestart(bool bResetScores, bool bResetCustom)
{
	// - respawns all players
	for(iCount = 0; iCount <= gpGlobals->maxClients; iCount++)
	{
		CBasePlayer *pPlayer = (CBasePlayer*)UTIL_PlayerByIndex(iCount);

		if(pPlayer)
		{
			if(pPlayer->m_iTeamRespawningAs != UNDEFINED && pPlayer->m_iClassRespawningAs != UNDEFINED)
			{
				if(pPlayer->m_iTeamRespawningAs != SPECS)
				{
					pPlayer->m_bHasDied = true;
					pPlayer->m_bIsAllowedToRespawn = true;
					// ben note : override the check in respawn player as we do want to respawn everyone
					pPlayer->PlayerDeathThink();
					pPlayer->pev->sequence = pPlayer->LookupActivity( ACT_WALK );
					pPlayer->m_fSequenceFinished = true;	
				}
			}
		}
	}

	// - returns world to default settings
	ResetWorld(bResetCustom);

	// - resets the scores of all to 0 damage, 0 kills and 0 deaths
	if(bResetScores)
	{
		for(iCount = 0; iCount  <= gpGlobals->maxClients; iCount++)
		{
			CBasePlayer *pPlayer = (CBasePlayer*)UTIL_PlayerByIndex(iCount);
			if(pPlayer)
			{
				// -- reset any other variables to default here
				pPlayer->m_flCapturePoints = 0.0;
				pPlayer->m_flDamageDone = 0.0;
				pPlayer->pev->frags = 0;
				pPlayer->m_iDeaths = 0;
			}
		}
		
		// -- get the hud and scoreboard to reset
		extern int gmsgResetScores;
		MESSAGE_BEGIN(MSG_ALL, gmsgResetScores);
		WRITE_BYTE(1);
		MESSAGE_END();

		// -- reset the server side scores
		g_pBGRules->iBritishScore = 0;
		g_pBGRules->iAmericanScore = 0;
		CVAR_SET_FLOAT("mp_britishscore", g_pBGRules->iBritishScore);
		CVAR_SET_FLOAT("mp_americanscore", g_pBGRules->iAmericanScore);
	}

	// - set a new round state
	SetRoundState(ROUND_NOTSTARTED);
}
// returns the current round state
ROUND_STATE CBaseRoundRules::GetRoundState()
{
	// check validity of current round state
	if(!m_iRoundState)
	{
		// - report the error
		ALERT(at_console, "Null Round State\n");
		UTIL_LogPrintf(ROUND_LOGGING, "World triggered \"Null Round State\"\n");

		// - set a default round state to help the game recover
		SetRoundState(ROUND_NOTSTARTED, false);
		return m_iRoundState;
	}

	return m_iRoundState;
}
// starts a dummy round, which will just be forgotten when enough players join
void CBaseRoundRules::StartDummyRound()
{
	// - set the round time on the servers
	if(ROUND_TIME > GetRoundTimeLimit())
	{
		SetRoundLength(GetRoundTimeLimit());
	}
	else
	{
		SetRoundLength(ROUND_TIME);
	}
	// - set the round time on the clients
	// ben notes : moved into the set round length function so it is always upto date on the clients

	// - update the round status
	SetRoundState(ROUND_WAITING_FOR_PLAYERS, false);
}
void MMatchRuleAssassinate::OnRoundBegin()
{
    MMatchServer* pServer = MMatchServer::GetInstance();
    MMatchStage* pStage = GetStage();
    if (pServer==NULL || pStage==NULL) return;

    m_uidRedCommander = ChooseCommander(MMT_RED);
    m_uidBlueCommander = ChooseCommander(MMT_BLUE);
    if ( (m_uidRedCommander == MUID(0,0)) || (m_uidBlueCommander == MUID(0,0)) ) {
        // Wait the game
        SetRoundState(MMATCH_ROUNDSTATE_FREE);
        return;
    }

    // Let players know the commander...
    MCommand* pCmd = pServer->CreateCommand(MC_MATCH_ASSIGN_COMMANDER, MUID(0,0));
    pCmd->AddParameter(new MCmdParamUID(m_uidRedCommander));
    pCmd->AddParameter(new MCmdParamUID(m_uidBlueCommander));
    pServer->RouteToStage(pStage->GetUID(), pCmd);

//	OutputDebugString("Assassinate::OnRoundBegin() \n");
}
void CCMatchRuleAssassinate::ChooseAdminAsCommander()
{
	m_bIsAdminCommander = !m_bIsAdminCommander;

	CCMatchServer* pServer = CCMatchServer::GetInstance();
	CCMatchStage* pStage = GetStage();
	if (pServer==NULL || pStage==NULL) return;

	m_uidRedCommander = ChooseCommander(CCMT_RED);
	m_uidBlueCommander = ChooseCommander(CCMT_BLUE);
	if ( (m_uidRedCommander == CCUID(0,0)) || (m_uidBlueCommander == CCUID(0,0)) ) {
		// Wait the game
		SetRoundState(CCMATCH_ROUNDSTATE_FREE);
		return;
	}

	// Let players know the commander...
	CCCommand* pCmd = pServer->CreateCommand(MC_MATCH_ASSIGN_COMMANDER, CCUID(0,0));
	pCmd->AddParameter(new CCCmdParamCCUID(m_uidRedCommander));
	pCmd->AddParameter(new CCCmdParamCCUID(m_uidBlueCommander));
	pServer->RouteToStage(pStage->GetUID(), pCmd);
}