mirror of
https://github.com/fortressforever/fortressforever-2013.git
synced 2024-11-10 07:11:45 +00:00
fix FF_TEAM enum being bigger than an int
fix old default PickDefaultSpawnTeam() code trying to put you on non-existent COMBINE/REBEL and crashing messing with adding teams by name only
This commit is contained in:
parent
b420c98fc4
commit
4ca5b64b5f
5 changed files with 21 additions and 85 deletions
|
@ -68,6 +68,7 @@ END_SEND_TABLE()
|
|||
BEGIN_DATADESC( CFF_SV_Player )
|
||||
END_DATADESC()
|
||||
|
||||
//PrecacheModel("models/player/soldier/soldier.mdl");
|
||||
const char *g_ppszRandomCitizenModels[] =
|
||||
{
|
||||
"models/humans/group03/male_01.mdl",
|
||||
|
@ -242,52 +243,12 @@ void CFF_SV_Player::GiveDefaultItems( void )
|
|||
|
||||
void CFF_SV_Player::PickDefaultSpawnTeam( void )
|
||||
{
|
||||
if ( GetTeamNumber() == 0 )
|
||||
{
|
||||
if ( FFRules()->IsTeamplay() == false )
|
||||
{
|
||||
if ( GetModelPtr() == NULL )
|
||||
{
|
||||
const char *szModelName = NULL;
|
||||
szModelName = engine->GetClientConVarValue( engine->IndexOfEdict( edict() ), "cl_playermodel" );
|
||||
if ( GetTeamNumber() != FF_TEAM_UNASSIGNED )
|
||||
return;
|
||||
|
||||
if ( ValidatePlayerModel( szModelName ) == false )
|
||||
{
|
||||
char szReturnString[512];
|
||||
|
||||
Q_snprintf( szReturnString, sizeof (szReturnString ), "cl_playermodel models/combine_soldier.mdl\n" );
|
||||
engine->ClientCommand ( edict(), szReturnString );
|
||||
}
|
||||
|
||||
ChangeTeam( TEAM_UNASSIGNED );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CTeam *pCombine = g_Teams[TEAM_COMBINE];
|
||||
CTeam *pRebels = g_Teams[TEAM_REBELS];
|
||||
|
||||
if ( pCombine == NULL || pRebels == NULL )
|
||||
{
|
||||
ChangeTeam( random->RandomInt( TEAM_COMBINE, TEAM_REBELS ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( pCombine->GetNumPlayers() > pRebels->GetNumPlayers() )
|
||||
{
|
||||
ChangeTeam( TEAM_REBELS );
|
||||
}
|
||||
else if ( pCombine->GetNumPlayers() < pRebels->GetNumPlayers() )
|
||||
{
|
||||
ChangeTeam( TEAM_COMBINE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeTeam( random->RandomInt( TEAM_COMBINE, TEAM_REBELS ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// FF TODO: remove once team hud is in / or auto assign
|
||||
// temp hack assumes FF_TEAM_ONE is present
|
||||
ChangeTeam ( FF_TEAM_ONE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -181,18 +181,6 @@ char *sTeamNames[] =
|
|||
{
|
||||
"#FF_TEAM_UNASSIGNED",
|
||||
"#FF_TEAM_SPECTATOR",
|
||||
"#FF_TEAM_BLUE",
|
||||
"#FF_TEAM_RED",
|
||||
"#FF_TEAM_YELLOW",
|
||||
"#FF_TEAM_GREEN",
|
||||
"#FF_TEAM_CUSTOM1",
|
||||
"#FF_TEAM_CUSTOM2",
|
||||
"#FF_TEAM_CUSTOM3",
|
||||
"#FF_TEAM_CUSTOM4",
|
||||
"#FF_TEAM_CUSTOM5",
|
||||
"#FF_TEAM_CUSTOM6",
|
||||
"#FF_TEAM_CUSTOM7",
|
||||
"#FF_TEAM_CUSTOM8",
|
||||
};
|
||||
|
||||
|
||||
|
@ -250,16 +238,12 @@ CFF_SH_Rules::CFF_SH_Rules()
|
|||
{
|
||||
#ifndef CLIENT_DLL
|
||||
// Create the team managers
|
||||
// TODO: right now this creates a team for every team name string,
|
||||
// hook this into lua and have it create teams as needed per map
|
||||
// or something cool like that
|
||||
for ( int i = 0; i < ARRAYSIZE( sTeamNames ); i++ )
|
||||
{
|
||||
CFF_SH_TeamManager *pTeam = static_cast<CFF_SH_TeamManager*>(CreateEntityByName( "ff_team_manager" ));
|
||||
pTeam->Init( sTeamNames[i], i );
|
||||
// TODO: hook into lua
|
||||
AddTeam( "Unassigned" );
|
||||
AddTeam( "Spectators" );
|
||||
|
||||
g_Teams.AddToTail( pTeam );
|
||||
}
|
||||
AddTeam( "Badass guys" );
|
||||
AddTeam( "COol dudes" );
|
||||
|
||||
// Dexter: slammed this to always true instead of the cvar for now
|
||||
//m_bTeamPlayEnabled = teamplay.GetBool();
|
||||
|
|
|
@ -55,13 +55,12 @@ enum FF_TEAM
|
|||
FF_TEAM_TWENTYSIX,
|
||||
FF_TEAM_TWENTYSEVEN,
|
||||
FF_TEAM_TWENTYEIGHT,
|
||||
FF_TEAM_TWENTYNINE,
|
||||
FF_TEAM_TWENTYNINE, // WARNING: Do not add more than 31 as more will not work with a bit mask.
|
||||
FF_TEAM_THIRTY,
|
||||
FF_TEAM_THIRTYONE, // WARNING: Do not add more than 31 as more will not work with a bit mask.
|
||||
|
||||
FF_TEAM_LAST = FF_TEAM_THIRTYONE
|
||||
FF_TEAM_LAST = FF_TEAM_THIRTY // if you're worried about bitmask dont forget FF_TEAM_ONE started from 2 you dork.
|
||||
};
|
||||
|
||||
// if you really want to use int here dont forget 31 is the sign bit
|
||||
const int FF_TEAM_BITS[] =
|
||||
{
|
||||
0, 0, (1<<0), (1<<1), (1<<2),
|
||||
|
@ -70,7 +69,7 @@ const int FF_TEAM_BITS[] =
|
|||
(1<<13), (1<<14), (1<<15), (1<<16), (1<<17),
|
||||
(1<<18), (1<<19), (1<<20), (1<<21), (1<<22),
|
||||
(1<<23), (1<<24), (1<<25), (1<<26), (1<<27),
|
||||
(1<<28), (1<<29), (1<<30)
|
||||
(1<<28), (1<<29), (1<<30), (1<<31),
|
||||
};
|
||||
|
||||
enum FF_WEAPON
|
||||
|
|
|
@ -279,26 +279,18 @@ int CFF_SH_TeamManager::PickAutoJoinTeam( )
|
|||
return FF_TEAM_ONE;
|
||||
}
|
||||
|
||||
bool CFF_SH_TeamManager::IsTeamFull() const
|
||||
bool CFF_SH_TeamManager::IsTeamFull( )
|
||||
{
|
||||
if (m_iMaxPlayers == 0)
|
||||
return false;
|
||||
|
||||
int numActive = 0;
|
||||
for( int i = 1; i <= gpGlobals->maxClients; i++ )
|
||||
{
|
||||
CFF_SV_Player *pPlayer = (CFF_SV_Player *) UTIL_PlayerByIndex( i );
|
||||
if( pPlayer && pPlayer->GetTeamNumber( ) == GetTeamNumber( ) )
|
||||
numActive++;
|
||||
}
|
||||
|
||||
return m_iMaxPlayers == 0 ||numActive > m_iMaxPlayers; // GetNumPlayers( ) > m_iMaxPlayers;
|
||||
// rely on gameplay to always be on which keeps count for us
|
||||
return m_iMaxPlayers == 0 || GetNumPlayers( ) > m_iMaxPlayers;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//ConCommand ff_team( "ff_team",
|
||||
//ConCommand ff_team( "ffdbg_dump_teams",
|
||||
|
||||
#if defined (_DEBUG) && defined (GAME_DLL)
|
||||
void DebugSetTeamName_f( const CCommand &args )
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
static bool HandlePlayerTeamCommand( CFF_SV_Player &pPlayer, int iNewTeam );
|
||||
static int PickAutoJoinTeam( );
|
||||
|
||||
bool IsTeamFull() const;
|
||||
bool IsTeamFull();
|
||||
#endif // GAME_DLL
|
||||
|
||||
// shared getters
|
||||
|
|
Loading…
Reference in a new issue