bool CTeam::ReadSpecialData(void) { // Grab the "name" char szTemp[MAX_TEAM_NAME]; if (GetCustomDataString("name", szTemp, MAX_TEAM_NAME, true)) { SetTeamName(szTemp); } else { CLogger::ErrorPrintf("Bad/missing name' attribute in <team> (line %u)\n", m_uiLine); return false; } // Grab the "color" data int iTemp; if (GetCustomDataString("color", szTemp, MAX_TEAM_NAME, true)) { // Convert it to RGBA unsigned char ucAlpha; if (!XMLColorToInt(szTemp, m_ucRed, m_ucGreen, m_ucBlue, ucAlpha)) { CLogger::ErrorPrintf("Bad 'color' value specified in <team> (line %u)\n", m_uiLine); return false; } } else { if (GetCustomDataInt("colorR", iTemp, true)) m_ucRed = static_cast<unsigned char>(iTemp); else m_ucRed = 255; if (GetCustomDataInt("colorG", iTemp, true)) m_ucGreen = static_cast<unsigned char>(iTemp); else m_ucGreen = 255; if (GetCustomDataInt("colorB", iTemp, true)) m_ucBlue = static_cast<unsigned char>(iTemp); else m_ucBlue = 255; } if (!GetCustomDataBool("friendlyfire", m_bFriendlyFire, true)) { m_bFriendlyFire = true; } if (GetCustomDataInt("dimension", iTemp, true)) m_usDimension = static_cast<unsigned short>(iTemp); return true; }
CTeam::CTeam(CTeamManager* pTeamManager, CElement* pParent, CXMLNode* pNode, const char* szName, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue) : CElement(pParent, pNode) { m_pTeamManager = pTeamManager; m_iType = CElement::TEAM; SetTypeName("team"); SetTeamName(szName); SetColor(ucRed, ucGreen, ucBlue); SetFriendlyFire(true); m_pTeamManager->AddToList(this); }
int TeamFortress_TeamSet( int tno ) { int tc; if ( teamplay < 1 ) { G_sprint( self, 2, "Teamplay is not On, so FortressTeams are inactive.\n" ); return 0; } if ( tno > number_of_teams && number_of_teams ) { G_sprint( self, 2, "There can be only %d teams on this map.\nTry again\n", number_of_teams ); return 0; } if ( self->team_no > 0 ) { G_sprint( self, 2, "You're already in Team No %d.\n", self->team_no ); return 0; } tc = TeamFortress_TeamGetNoPlayers( tno ); if ( tc >= TeamFortress_TeamGetMaxPlayers( tno ) ) { G_sprint( self, 2, "That team is full. Pick another.\n" ); return 0; } if ( !TeamFortress_TeamGetColor( tno ) ) { //TeamFortress_TeamSetColor( tno ); if ( !TeamFortress_TeamGetColor( tno ) ) { G_sprint( self, 2, "You can't start a new team with your color, since another " ); G_sprint( self, 2, "already using that color. Change your pants color, then try again.\n" ); return 0; } G_bprint( 2, "%s has started Team No %d.\n", self->s.v.netname, tno ); self->immune_to_check = g_globalvars.time + 10; if ( ( tf_data.toggleflags & TFLAG_TEAMFRAGS ) || ( tf_data.toggleflags & TFLAG_FULLTEAMSCORE ) ) self->s.v.frags = TeamFortress_TeamGetScore( tno ); TeamFortress_SetColor( self, TeamFortress_TeamGetTopColor( tno ), TeamFortress_TeamGetColor( tno ) - 1 ); self->team_no = tno; self->lives = TeamFortress_TeamGetLives( tno ); SetTeamName( self ); if ( !self->playerclass ) { if ( TeamFortress_TeamIsCivilian( self->team_no ) ) { self->s.v.impulse = 1; TeamFortress_ChangeClass( ); } } return 1; } G_bprint( 2, "%s has joined Team No %d.\n", self->s.v.netname, tno ); TeamFortress_SetColor( self, TeamFortress_TeamGetTopColor( tno ), TeamFortress_TeamGetColor( tno ) - 1 ); self->team_no = tno; self->immune_to_check = g_globalvars.time + 10; self->lives = TeamFortress_TeamGetLives( tno ); if ( ( tf_data.toggleflags & TFLAG_TEAMFRAGS ) || ( tf_data.toggleflags & TFLAG_FULLTEAMSCORE ) ) self->s.v.frags = TeamFortress_TeamGetScore( tno ); TeamFortress_TeamShowMemberClasses( self ); SetTeamName( self ); if ( !self->playerclass ) { if ( TeamFortress_TeamIsCivilian( self->team_no ) ) { self->s.v.impulse = 1; TeamFortress_ChangeClass( ); } } return 1; }
void TeamFortress_CheckTeamCheats( ) { char st[20]; const char *sk; int tc; if ( self->immune_to_check > g_globalvars.time ) return; if ( self->s.v.deadflag ) return; if ( !( self->s.v.netname[0] ) ) KickCheater( self ); else { if ( self->playerclass && !self->team_no && teamplay > 0 ) KickCheater( self ); } if ( self->team_no > 0 && teamplay > 0 ) { tc = GetInfokeyInt( self, "bottomcolor", NULL, 0 ); if ( self->playerclass == PC_SPY && self->undercover_team ) { if ( TeamFortress_TeamGetColor( self->undercover_team ) - 1 != tc ) { TeamFortress_SetColor( self, TeamFortress_TeamGetTopColor( self->undercover_team ), TeamFortress_TeamGetColor( self->undercover_team ) - 1 ); G_bprint( 1, "%s has been kicked for changing color.\n", self->s.v.netname ); G_sprint( self, 2, "You have been kicked for changing your pants color. Don't do it.\n" ); KickCheater( self ); return; } } else { if ( tc != TeamFortress_TeamGetColor( self->team_no ) - 1 ) { TeamFortress_SetColor( self, TeamFortress_TeamGetTopColor( self->team_no ), TeamFortress_TeamGetColor( self->team_no ) - 1 ); G_bprint( 1, "%s has been kicked for changing color.\n", self->s.v.netname ); G_sprint( self, 2, "You have been kicked for changing your pants color. Don't do it.\n" ); KickCheater( self ); return; } } if ( tf_data.topcolor_check ) { tc = GetInfokeyInt( self, "topcolor", NULL, 0 ); if ( self->playerclass == PC_SPY && self->undercover_team ) { if ( TeamFortress_TeamGetTopColor( self->undercover_team ) != tc ) { TeamFortress_SetColor( self, TeamFortress_TeamGetTopColor( self->undercover_team ), TeamFortress_TeamGetColor( self->undercover_team ) - 1 ); G_bprint( 1, "%s has been kicked for changing color.\n", self->s.v.netname ); G_sprint( self, 2, "You have been kicked for changing your top color. Don't do it.\n" ); KickCheater( self ); return; } } else { if ( tc != TeamFortress_TeamGetTopColor( self->team_no ) ) { TeamFortress_SetColor( self, TeamFortress_TeamGetTopColor( self->undercover_team ), TeamFortress_TeamGetColor( self->undercover_team ) - 1 ); G_bprint( 1, "%s has been kicked for changing color.\n", self->s.v.netname ); G_sprint( self, 2, "You have been kicked for changing your top color. Don't do it.\n" ); KickCheater( self ); return; } } } if ( self->playerclass ) { GetInfokeyString( self, "skin", NULL, st, sizeof( st ), "" ); tc = 0; sk = TeamFortress_GetSkin( self ); if ( strneq( st, sk ) ) { TeamFortress_SetSkin( self ); G_bprint( 1, "%s has been kicked for changing skin.\n", self->s.v.netname ); G_sprint( self, 2, "You have been kicked for changing your skin. Don't do it.\n" ); KickCheater( self ); } if ( tc == 8 ) self->playerclass = 8; } sk = GetTeamName( self->team_no ); GetInfokeyString( self, "team", NULL, st, sizeof( st ), "" ); if ( strneq( st, sk ) ) { SetTeamName( self ); G_bprint( 1, " has been kicked for changing team.\n", self->s.v.netname ); G_sprint( self, 2, "You have been kicked for changing your team. Don't do it.\n" ); KickCheater( self ); return; } } }
qboolean ClientUserInfoChanged( ) { char key[1024]; char value[1024]; const char *sk; int color; self = PROG_TO_EDICT( g_globalvars.self ); trap_CmdArgv( 1, key, sizeof( key ) ); trap_CmdArgv( 2, value, sizeof( value ) ); if ( !strcmp( key, "team" ) ) { if ( !self->team_no ) return 0; sk = GetTeamName( self->team_no ); if ( strneq( value, sk ) ) { SetTeamName( self ); G_sprint( self, 2, "you cannot change your team setinfo\n" ); return 1; } return 0; } if ( !strcmp( key, "skin" ) ) { if ( !self->playerclass || !self->team_no ) return 0; sk = TeamFortress_GetSkin( self ); if ( strneq( value, sk ) ) { G_sprint( self, 2, "you cannot change your skin setinfo\n" ); TeamFortress_SetSkin( self ); return 1; } return 0; } if ( ( !strcmp( key, "topcolor" ) ) && tf_data.topcolor_check ) { if ( !self->team_no ) return 0; color = atoi( value ); if ( self->playerclass == PC_SPY && self->undercover_team ) { if ( TeamFortress_TeamGetTopColor( self->undercover_team ) != color ) { G_sprint( self, 2, "you cannot change your topcolor setinfo\n" ); return 1; } } else { if ( TeamFortress_TeamGetTopColor( self->team_no ) != color ) { G_sprint( self, 2, "you cannot change your topcolor setinfo\n" ); return 1; } } return 0; } if ( ( !strcmp( key, "bottomcolor" ) ) ) { if ( !self->team_no ) return 0; color = atoi( value ); if ( self->playerclass == PC_SPY && self->undercover_team ) { if ( TeamFortress_TeamGetColor( self->undercover_team ) - 1 != color ) { G_sprint( self, 2, "you cannot change your bottomcolor setinfo\n" ); return 1; } } else { if ( TeamFortress_TeamGetColor( self->team_no ) - 1 != color ) { G_sprint( self, 2, "you cannot change your bottomcolor setinfo\n" ); return 1; } } return 0; } SetClientSetting( self, Q_strlwr( key ), value); return 0; }