/* ============ Svcmd_TeamMessage_f Sends a Chat Message to a Team from the Console ============ */ void Svcmd_TeamMessage_f( void ) { char teamNum[ 2 ]; const char* prefix; team_t team; if( trap_Argc( ) < 3 ) { G_Printf( "usage: say_team <team> <message>\n" ); return; } trap_Argv( 1, teamNum, sizeof( teamNum ) ); team = G_TeamFromString( teamNum ); if( team == TEAM_NUM_TEAMS ) { G_Printf( "say_team: invalid team \"%s\"\n", teamNum ); return; } prefix = BG_TeamName( team ); prefix = va( "[%c] ", toupper( *prefix ) ); G_TeamCommand( team, va( "tchat \"(console): " S_COLOR_CYAN "%s\"", ConcatArgs( 2 ) ) ); G_LogPrintf( "sayteam: %sconsole: " S_COLOR_CYAN "%s\n", prefix, ConcatArgs( 2 ) ); }
void G_ChangeTeam( gentity_t *ent, team_t newTeam ) { team_t oldTeam = (team_t) ent->client->pers.team; if ( oldTeam == newTeam ) { return; } G_LeaveTeam( ent ); ent->client->pers.teamChangeTime = level.time; ent->client->pers.team = newTeam; ent->client->pers.teamInfo = level.startTime - 1; ent->client->pers.classSelection = PCL_NONE; ClientSpawn( ent, nullptr, nullptr, nullptr ); if ( oldTeam == TEAM_HUMANS && newTeam == TEAM_ALIENS ) { // Convert from human to alien credits ent->client->pers.credit = ( int )( ent->client->pers.credit * ALIEN_MAX_CREDITS / HUMAN_MAX_CREDITS + 0.5f ); } else if ( oldTeam == TEAM_ALIENS && newTeam == TEAM_HUMANS ) { // Convert from alien to human credits ent->client->pers.credit = ( int )( ent->client->pers.credit * HUMAN_MAX_CREDITS / ALIEN_MAX_CREDITS + 0.5f ); } if ( !g_cheats.integer ) { if ( ent->client->noclip ) { ent->client->noclip = false; ent->r.contents = ent->client->cliprcontents; } ent->flags &= ~( FL_GODMODE | FL_NOTARGET ); } // Copy credits to ps for the client ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.credit; // Update PERS_UNLOCKABLES in the same frame as PERS_TEAM to prevent bad status change notifications ent->client->ps.persistant[ PERS_UNLOCKABLES ] = BG_UnlockablesMask( newTeam ); ClientUserinfoChanged( ent->client->ps.clientNum, false ); G_UpdateTeamConfigStrings(); Beacon::PropagateAll( ); G_LogPrintf( "ChangeTeam: %d %s: %s^* switched teams", ( int )( ent - g_entities ), BG_TeamName( newTeam ), ent->client->pers.netname ); G_namelog_update_score( ent->client ); TeamplayInfoMessage( ent ); }
/* ================= G_ChangeTeam ================= */ void G_ChangeTeam( gentity_t *ent, team_t newTeam ) { team_t oldTeam = ent->client->pers.teamSelection; if ( oldTeam == newTeam ) { return; } G_LeaveTeam( ent ); ent->client->pers.teamChangeTime = level.time; ent->client->pers.teamSelection = newTeam; ent->client->pers.classSelection = PCL_NONE; ClientSpawn( ent, NULL, NULL, NULL ); if ( oldTeam == TEAM_HUMANS && newTeam == TEAM_ALIENS ) { // Convert from human to alien credits ent->client->pers.credit = ( int )( ent->client->pers.credit * ALIEN_MAX_CREDITS / HUMAN_MAX_CREDITS + 0.5f ); } else if ( oldTeam == TEAM_ALIENS && newTeam == TEAM_HUMANS ) { // Convert from alien to human credits ent->client->pers.credit = ( int )( ent->client->pers.credit * HUMAN_MAX_CREDITS / ALIEN_MAX_CREDITS + 0.5f ); } if ( !g_cheats.integer ) { if ( ent->client->noclip ) { ent->client->noclip = qfalse; ent->r.contents = ent->client->cliprcontents; } ent->flags &= ~( FL_GODMODE | FL_NOTARGET ); } // Copy credits to ps for the client ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.credit; ClientUserinfoChanged( ent->client->ps.clientNum, qfalse ); G_UpdateTeamConfigStrings(); G_LogPrintf( "ChangeTeam: %d %s: %s" S_COLOR_WHITE " switched teams\n", ( int )( ent - g_entities ), BG_TeamName( newTeam ), ent->client->pers.netname ); G_namelog_update_score( ent->client ); TeamplayInfoMessage( ent ); }
/* ================= CG_Say ================= */ static void CG_Say( const char *name, int clientNum, saymode_t mode, const char *text ) { char prefix[ 21 ] = ""; char *ignore = ""; char *location = ""; char color; char *maybeColon; if ( clientNum >= 0 && clientNum < MAX_CLIENTS ) { clientInfo_t *ci = &cgs.clientinfo[ clientNum ]; char *tcolor = S_COLOR_WHITE; name = ci->name; if ( ci->team == TEAM_ALIENS ) { tcolor = S_COLOR_RED; } else if ( ci->team == TEAM_HUMANS ) { tcolor = S_COLOR_CYAN; } if ( cg_chatTeamPrefix.integer ) { Com_sprintf( prefix, sizeof( prefix ), "[%s%c" S_COLOR_WHITE "] ", tcolor, toupper( * ( BG_TeamName( ci->team ) ) ) ); } if ( Com_ClientListContains( &cgs.ignoreList, clientNum ) ) { ignore = "[skipnotify]"; } if ( ( mode == SAY_TEAM || mode == SAY_AREA ) && cg.snap->ps.pm_type != PM_INTERMISSION ) { int locationNum; if ( clientNum == cg.snap->ps.clientNum ) { centity_t *locent; locent = CG_GetPlayerLocation(); if ( locent ) { locationNum = locent->currentState.generic1; } else { locationNum = 0; } } else { locationNum = ci->location; } if ( locationNum > 0 && locationNum < MAX_LOCATIONS ) { const char *s = CG_ConfigString( CS_LOCATIONS + locationNum ); if ( *s ) { location = va( " (%s" S_COLOR_WHITE ")", s ); } } } } else if ( name ) { Q_strcat( prefix, sizeof( prefix ), "[ADMIN]" ); } else { name = "console"; } // IRC-like /me parsing if ( mode != SAY_RAW && Q_stricmpn( text, "/me ", 4 ) == 0 ) { text += 4; Q_strcat( prefix, sizeof( prefix ), "* " ); maybeColon = ""; } else { maybeColon = ":"; } color = '0' + UI_GetChatColour( mode, cgs.clientinfo[ clientNum ].team ); switch ( mode ) { case SAY_ALL: // might already be ignored but in that case no harm is done if ( cg_teamChatsOnly.integer ) { ignore = "[skipnotify]"; } case SAY_ALL_ADMIN: CG_Printf( "%s%s%s^7%s ^%c%s\n", ignore, prefix, name, maybeColon, color, text ); break; case SAY_TEAM: CG_Printf( "%s%s(%s^7)%s%s ^%c%s\n", ignore, prefix, name, location, maybeColon, color, text ); break; case SAY_ADMINS: case SAY_ADMINS_PUBLIC: CG_Printf( "%s%s%s%s^7%s ^%c%s\n", ignore, prefix, ( mode == SAY_ADMINS ) ? "[ADMIN]" : "[PLAYER]", name, maybeColon, color, text ); break; case SAY_AREA: case SAY_AREA_TEAM: CG_Printf( "%s%s<%s^7>%s%s ^%c%s\n", ignore, prefix, name, location, maybeColon, color, text ); break; case SAY_PRIVMSG: case SAY_TPRIVMSG: CG_Printf( "%s%s[%s^7 -> %s^7]%s ^%c%s\n", ignore, prefix, name, cgs.clientinfo[ cg.clientNum ].name, maybeColon, color, text ); if ( !ignore[ 0 ] ) { CG_CenterPrint( va( "^%cPrivate message from: " S_COLOR_WHITE "%s", color, name ), 200, GIANTCHAR_WIDTH * 4 ); if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) { clientNum = cg.clientNum; } CG_Printf(_( ">> to reply, say: /m %d [your message] <<\n"), clientNum ); } break; case SAY_RAW: CG_Printf( "%s\n", text ); break; case SAY_DEFAULT: default: break; } switch ( mode ) { case SAY_TEAM: case SAY_AREA: case SAY_TPRIVMSG: if ( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) { trap_S_StartLocalSound( cgs.media.alienTalkSound, CHAN_LOCAL_SOUND ); break; } else if ( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) { trap_S_StartLocalSound( cgs.media.humanTalkSound, CHAN_LOCAL_SOUND ); break; } default: trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); } }