Updated to use numbers instead of names for the team defs and added some testing weapon definitions.

This commit is contained in:
hlstriker 2013-11-09 14:56:57 +00:00 committed by squeek
parent 04397c4005
commit b420c98fc4
4 changed files with 94 additions and 168 deletions

View file

@ -951,21 +951,23 @@ void CFF_SV_Player::ChangeTeam( int iTeam )
bool CFF_SV_Player::ClientCommand( const CCommand &args )
{
if ( FStrEq( args[0], "spectate" ) || FStrEq( args[0], "team" ) )
if( FStrEq(args[0], "spectate") )
{
if ( ShouldRunRateLimitedCommand( args ) )
{
const char *team;
if( ShouldRunRateLimitedCommand(args) )
CFF_SH_TeamManager::HandlePlayerTeamCommand( *this, FF_TEAM_SPECTATE );
return true;
}
if ( FStrEq( args[0], "team" ) )
{
if( !ShouldRunRateLimitedCommand(args) || args.ArgC() < 2 )
return BaseClass::ClientCommand( args );
int iNewTeam = Q_atoi(args[1]) + 1;
if( iNewTeam >= FF_TEAM_ONE )
CFF_SH_TeamManager::HandlePlayerTeamCommand( *this, iNewTeam );
if ( args.ArgC() < 2) // || FStrEq( args[0], "spectate" ) )
return false;
if ( FStrEq( args[0], "spectate" ) )
team = "spec";
else
team = args[1];
// let the team manager earn its namesake and handle that crap
return CFF_SH_TeamManager::HandlePlayerTeamCommand( *this, team );
}
return true;
}
@ -1554,7 +1556,7 @@ void CFF_SV_Player::PreChangeTeam( int iOldTeam, int iNewTeam )
// lua player_killed
RemoveAllItems( true );
if ( IsAlive() && GetTeamNumber( ) >= TEAM_BLUE )
if ( IsAlive() && GetTeamNumber( ) >= FF_TEAM_ONE )
{
KillPlayer( );

View file

@ -4,27 +4,8 @@
#pragma once
#endif
// FF Team stuff
// note, when ported i switched to an enum so we have our custom team stuff a little more obvious
typedef enum
{
TEAM_BLUE = 2,
TEAM_RED,
TEAM_YELLOW,
TEAM_GREEN,
TEAM_CUSTOM1,
TEAM_CUSTOM2,
TEAM_CUSTOM3,
TEAM_CUSTOM4,
TEAM_CUSTOM5,
TEAM_CUSTOM6,
TEAM_CUSTOM7,
TEAM_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INE,
FF_TEAM_TEN,
FF_TEAM_ELEVEN,
FF_TEAM_TWELVE,
FF_TEAM_THIRTEEN,
FF_TEAM_FOURTEEN,
FF_TEAM_FIFTEEN,
FF_TEAM_SIXTEEN,
FF_TEAM_SEVENTEEN,
FF_TEAM_EIGHTEEN,
FF_TEAM_NINETEEN,
FF_TEAM_TWENTY,
FF_TEAM_TWENTYONE,
FF_TEAM_TWENTYTWO,
FF_TEAM_TWENTYTHREE,
FF_TEAM_TWENTYFOUR,
FF_TEAM_TWENTYFIVE,
FF_TEAM_TWENTYSIX,
FF_TEAM_TWENTYSEVEN,
FF_TEAM_TWENTYEIGHT,
FF_TEAM_TWENTYNINE,
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
};
const int FF_TEAM_BITS[] =
@ -89,4 +73,25 @@ const int FF_TEAM_BITS[] =
(1<<28), (1<<29), (1<<30)
};
enum FF_WEAPON
{
FF_WEAPON_PISTOL = 0,
FF_WEAPON_PHYSCANNON,
FF_WEAPON_SMG1,
};
const int FF_WEAPON_BITS[] =
{
(1<<0),
(1<<1),
(1<<2)
};
const string_t FF_WEAPON_NAME[] =
{
MAKE_STRING("weapon_pistol"),
MAKE_STRING("weapon_physcannon"),
MAKE_STRING("weapon_smg1")
};
#endif // FF_SH_SHAREDDEFS_H

View file

@ -234,119 +234,38 @@ int CFF_SH_TeamManager::GetTeamLimits( void )
}
#ifdef GAME_DLL
bool CFF_SH_TeamManager::HandlePlayerTeamCommand( CFF_SV_Player &pPlayer, const char *pTeamName )
bool CFF_SH_TeamManager::HandlePlayerTeamCommand( CFF_SV_Player &pPlayer, int iNewTeam )
{
if ( !pTeamName )
if( iNewTeam == FF_TEAM_AUTO_ASSIGN )
iNewTeam = PickAutoJoinTeam();
if ( iNewTeam < FF_TEAM_SPECTATE || iNewTeam > FF_TEAM_LAST )
return false;
int iOldTeam = pPlayer.GetTeamNumber();
int iTeam = TEAM_UNASSIGNED;
if ( FStrEq( pTeamName, "auto" ) )
{
iTeam = PickAutoJoinTeam( );
}
else if ( FStrEq( pTeamName, "spec" ) )
{
iTeam = TEAM_SPECTATOR;
}
else if ( FStrEq( pTeamName, "red" ) )
{
iTeam = TEAM_RED;
}
else if ( FStrEq( pTeamName, "blue" ) )
{
iTeam = TEAM_BLUE;
}
else if ( FStrEq( pTeamName, "yellow" ) )
{
iTeam = TEAM_YELLOW;
}
else if ( FStrEq( pTeamName, "green" ) )
{
iTeam = TEAM_GREEN;
}
else if ( FStrEq( pTeamName, "custom1" ) )
{
iTeam = TEAM_CUSTOM1;
}
else if ( FStrEq( pTeamName, "custom2" ) )
{
iTeam = TEAM_CUSTOM2;
}
else if ( FStrEq( pTeamName, "custom3" ) )
{
iTeam = TEAM_CUSTOM3;
}
else if ( FStrEq( pTeamName, "custom4" ) )
{
iTeam = TEAM_CUSTOM4;
}
else if ( FStrEq( pTeamName, "custom5" ) )
{
iTeam = TEAM_CUSTOM5;
}
else if ( FStrEq( pTeamName, "custom6" ) )
{
iTeam = TEAM_CUSTOM6;
}
else if ( FStrEq( pTeamName, "custom7" ) )
{
iTeam = TEAM_CUSTOM7;
}
else if ( FStrEq( pTeamName, "custom8" ) )
{
iTeam = TEAM_CUSTOM8;
}
else
{
// no known hardcoded team name,
// try to find team by current team names just for the hell of it
for ( int i = 0; i < g_Teams.Count(); ++i )
{
if (!g_Teams[i])
continue;
if ( FStrEq( g_Teams[i]->GetName(), pTeamName ) )
{
iTeam = g_Teams[i]->GetTeamNumber( );
break;
}
}
}
if ( iTeam == TEAM_UNASSIGNED )
{
// TODO: say nothin' found poor sap
if ( iOldTeam == iNewTeam )
return false;
}
// check stupid stuff first
if ( iOldTeam == iTeam )
{
// wants to join same team
return false;
}
CFF_SH_TeamManager *pTeam = GetGlobalFFTeam( iTeam );
if ( !pTeam )
// Make sure this team exists.
CFF_SH_TeamManager *pTeam = GetGlobalFFTeam( iNewTeam );
if( !pTeam )
{
// non active team or something fucked
return false;
}
// make sure isnt full
if ( pTeam->IsTeamFull() )
{
// Make sure this team isn't full.
if( pTeam->IsTeamFull() )
return false;
}
// TODO: Lua player_switchteam predicate here
// refactored this, so each step of the process is seperate chunks,
// since so much per-class state is handled in each
pPlayer.PreChangeTeam( iOldTeam, iTeam );
pPlayer.ChangeTeam( iTeam );
pPlayer.PostChangeTeam( iOldTeam, iTeam );
pPlayer.PreChangeTeam( iOldTeam, iNewTeam );
pPlayer.ChangeTeam( iNewTeam );
pPlayer.PostChangeTeam( iOldTeam, iNewTeam );
return true;
}
@ -357,7 +276,7 @@ int CFF_SH_TeamManager::PickAutoJoinTeam( )
// it is me, the auto picker thingy majig
return TEAM_BLUE;
return FF_TEAM_ONE;
}
bool CFF_SH_TeamManager::IsTeamFull() const
@ -388,7 +307,7 @@ void DebugSetTeamName_f( const CCommand &args )
int teamNum = Q_atoi(args.Arg(1));
const char* newName = args.Arg(2);
if ( teamNum > TEAM_COUNT )
if ( teamNum > FF_TEAM_LAST )
return;
CFF_SH_TeamManager *pTeam = GetGlobalFFTeam( teamNum );

View file

@ -64,7 +64,7 @@ public:
void UpdateClassLimit( int iClassIdx, int conVarVal );
void UpdateAllClassLimits( void );
static bool HandlePlayerTeamCommand( CFF_SV_Player &pPlayer, const char* pTeam );
static bool HandlePlayerTeamCommand( CFF_SV_Player &pPlayer, int iNewTeam );
static int PickAutoJoinTeam( );
bool IsTeamFull() const;