mirror of
https://github.com/fortressforever/fortressforever-2013.git
synced 2024-11-22 20:41:14 +00:00
add some helper functions for more dynamic active team management
This commit is contained in:
parent
c26dad0a15
commit
e9669129a7
2 changed files with 58 additions and 2 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include "ff_sv_dll_interface.h"
|
#include "ff_sv_dll_interface.h"
|
||||||
#include "hl2mp_cvars.h"
|
#include "hl2mp_cvars.h"
|
||||||
#include "ff_sh_team_manager.h"
|
#include "ff_sh_team_manager.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include "hl2mp_bot_temp.h"
|
#include "hl2mp_bot_temp.h"
|
||||||
|
@ -193,7 +194,57 @@ char *sTeamNames[] =
|
||||||
"#FF_TEAM_CUSTOM7",
|
"#FF_TEAM_CUSTOM7",
|
||||||
"#FF_TEAM_CUSTOM8",
|
"#FF_TEAM_CUSTOM8",
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
void CFF_SH_Rules::AddTeam( const char *pTeamName, const int iNum )
|
||||||
|
{
|
||||||
|
CFF_SH_TeamManager *pTeam = static_cast<CFF_SH_TeamManager*>(CreateEntityByName( "ff_team_manager" ));
|
||||||
|
if ( pTeam )
|
||||||
|
{
|
||||||
|
pTeam->Init( pTeamName, iNum );
|
||||||
|
g_Teams.AddToTail( pTeam );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add a new team and use next available unused team number
|
||||||
|
void CFF_SH_Rules::AddTeam( const char *pTeamName )
|
||||||
|
{
|
||||||
|
CFF_SH_TeamManager *pTeam = static_cast<CFF_SH_TeamManager*>(CreateEntityByName( "ff_team_manager" ));
|
||||||
|
if ( !pTeam )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int iNum = 0;
|
||||||
|
|
||||||
|
for ( int i = 0; i < g_Teams.Count(); ++i )
|
||||||
|
iNum = max ( g_Teams[i]->GetTeamNumber(), iNum );
|
||||||
|
|
||||||
|
pTeam->Init( pTeamName, ++iNum );
|
||||||
|
g_Teams.AddToTail( pTeam );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFF_SH_Rules::RemoveTeam( const char *pTeamName )
|
||||||
|
{
|
||||||
|
int foundIdx = -1;
|
||||||
|
for ( int i = 0; i < g_Teams.Count(); ++i )
|
||||||
|
{
|
||||||
|
if ( g_Teams[i] && FStrEq( pTeamName, g_Teams[i]->GetName( ) ) )
|
||||||
|
{
|
||||||
|
foundIdx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( foundIdx != -1 )
|
||||||
|
g_Teams.Remove( foundIdx );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFF_SH_Rules::RemoveTeam( const int iIndex )
|
||||||
|
{
|
||||||
|
if ( iIndex >= 0 && iIndex < g_Teams.Count( ) )
|
||||||
|
g_Teams.Remove( iIndex );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GAME_DLL
|
||||||
|
|
||||||
CFF_SH_Rules::CFF_SH_Rules()
|
CFF_SH_Rules::CFF_SH_Rules()
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,6 +138,11 @@ public:
|
||||||
const char *GetChatFormat( bool bTeamOnly, CBasePlayer *pPlayer );
|
const char *GetChatFormat( bool bTeamOnly, CBasePlayer *pPlayer );
|
||||||
bool IsSpawnPointValid( CBaseEntity *pSpot, CBasePlayer *pPlayer );
|
bool IsSpawnPointValid( CBaseEntity *pSpot, CBasePlayer *pPlayer );
|
||||||
|
|
||||||
|
void AddTeam( const char *pTeamName, const int iNum );
|
||||||
|
void AddTeam( const char *pTeamName );
|
||||||
|
void RemoveTeam( const char *pTeamName );
|
||||||
|
void RemoveTeam( const int iIndex );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
virtual void ClientDisconnected( edict_t *pClient );
|
virtual void ClientDisconnected( edict_t *pClient );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue