//----------------------------------------------------------------------------- // Purpose: Round timelimit has been hit //----------------------------------------------------------------------------- void CDiscArena::TimeOver( void ) { // Display the 10 second warning first if ( !m_bShownTimeWarning ) { m_bShownTimeWarning = TRUE; for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); if (pPlayer && (pPlayer->pev->groupinfo & pev->groupinfo) && pPlayer->m_bHasDisconnected != TRUE) ClientPrint( pPlayer->pev, HUD_PRINTCENTER, "#Time_Warning" ); } pev->nextthink = gpGlobals->time + 10; } else { for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); if (pPlayer && (pPlayer->pev->groupinfo & pev->groupinfo) && (pPlayer->m_bHasDisconnected != TRUE) ) ClientPrint( pPlayer->pev, HUD_PRINTCENTER, "#Time_Over" ); } // Increment both scores to force the game to end m_iTeamOneScore++; m_iTeamTwoScore++; BattleOver(); } }
void GameEngine::Shutdown() { BattleOver(); CleanParty(); CleanEnemies(); for( CityPtrItr i = mCities.begin(); i != mCities.end(); ++i ) { delete *i; } mCities.clear(); if( _instance ) { delete _instance; _instance = NULL; } }
bool CDiscArena::CheckBattleOver( void ) { bool bTeamOneAlive = false; bool bTeamTwoAlive = false; // See if the battle is finished int i; for ( i = 0; i < (m_iPlayersPerTeam * 2); i++ ) { if ( m_hCombatants[i] != NULL && ((CBasePlayer*)(CBaseEntity*)m_hCombatants[i])->IsAlive() ) { if ( ((CBaseEntity*)m_hCombatants[i])->pev->team == 1 ) bTeamOneAlive = true; else if ( ((CBaseEntity*)m_hCombatants[i])->pev->team == 2 ) bTeamTwoAlive = true; } } if ( !bTeamOneAlive || !bTeamTwoAlive ) { // Battle is finished. if (bTeamOneAlive) { m_iWinningTeam = 1; m_iTeamOneScore++; } else { m_iWinningTeam = 2; m_iTeamTwoScore++; } int iTeamInTheLead = 0; if ( m_iTeamOneScore > m_iTeamTwoScore ) iTeamInTheLead = 1; else if ( m_iTeamOneScore < m_iTeamTwoScore ) iTeamInTheLead = 2; // Send the message to the clients in the arena for ( int iPlayerNum = 1; iPlayerNum <= gpGlobals->maxClients; iPlayerNum++ ) { CBasePlayer *pPlayer = (CBasePlayer*)UTIL_PlayerByIndex( iPlayerNum ); if (pPlayer && (pPlayer->pev->groupinfo & pev->groupinfo) && (pPlayer->m_bHasDisconnected != TRUE) ) { MESSAGE_BEGIN( MSG_ONE, gmsgEndRnd, NULL, pPlayer->edict() ); WRITE_BYTE( m_iCurrRound ); WRITE_BYTE( 1 ); WRITE_BYTE( m_iPlayersPerTeam ); // Send down the winners of this round for (i = 0; i < (m_iPlayersPerTeam * 2); i++) { CBasePlayer *pPlayer = (CBasePlayer*)(CBaseEntity*)m_hCombatants[i]; if ( !pPlayer || pPlayer->pev->team != m_iWinningTeam ) continue; WRITE_SHORT( pPlayer->entindex() ); } // Send down the team who's winning the battle now if ( iTeamInTheLead == 0 ) { // It's a draw at the moment. // No need to send down player data. WRITE_BYTE( 0 ); } else { WRITE_BYTE( m_iPlayersPerTeam ); // Send down the winners of this round for (i = 0; i < (m_iPlayersPerTeam * 2); i++) { CBasePlayer *pPlayer = (CBasePlayer*)(CBaseEntity*)m_hCombatants[i]; if ( !pPlayer || pPlayer->pev->team != iTeamInTheLead ) continue; WRITE_SHORT( ((CBaseEntity*)m_hCombatants[i])->entindex() ); } } // Send down the scores if ( iTeamInTheLead == 1 ) { WRITE_BYTE( m_iTeamOneScore ); WRITE_BYTE( m_iTeamTwoScore ); } else { WRITE_BYTE( m_iTeamTwoScore ); WRITE_BYTE( m_iTeamOneScore ); } // Send down over or not if ( m_iTeamOneScore == m_iMaxRounds || m_iTeamTwoScore == m_iMaxRounds ) WRITE_BYTE( 1 ); else WRITE_BYTE( 0 ); MESSAGE_END(); } } BattleOver(); return true; } return false; }