home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / MultiplayerGame.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  22KB  |  798 lines

  1. // RAVEN BEGIN
  2. // ddynerman: note that this file is no longer merged with Doom3 updates
  3. //
  4. // MERGE_DATE 09/30/2004
  5.  
  6. #ifndef __MULTIPLAYERGAME_H__
  7. #define    __MULTIPLAYERGAME_H__
  8.  
  9. /*
  10. ===============================================================================
  11.  
  12.     Quake IV multiplayer
  13.  
  14. ===============================================================================
  15. */
  16.  
  17. class idPlayer;
  18. class rvCTF_AssaultPoint;
  19. class rvItemCTFFlag;
  20. typedef enum {
  21.     GAME_SP,
  22.     GAME_DM,
  23.     GAME_TOURNEY,
  24.     GAME_TDM,
  25.     // bdube: added ctf
  26.     GAME_CTF,
  27.     // ddynerman: new gametypes
  28.     GAME_1F_CTF,
  29.     GAME_ARENA_CTF,
  30.     GAME_ARENA_1F_CTF
  31. } gameType_t;
  32.  
  33.  
  34. // ddynerman: teams
  35. typedef enum {
  36.     TEAM_MARINE,
  37.     TEAM_STROGG,
  38.     TEAM_MAX,
  39. } team_t;
  40.  
  41. // shouchard:  server admin command types
  42. typedef enum {
  43.     SERVER_ADMIN_KICK,
  44.     SERVER_ADMIN_BAN,
  45.     SERVER_ADMIN_REMOVE_BAN,
  46.     SERVER_ADMIN_FORCE_SWITCH,
  47. } serverAdmin_t;
  48.  
  49. // shouchard:  vote struct for packing up interface values to be handled later
  50. //             note that we have two mechanisms for dealing with vote data that
  51. //             should be consolidated:  this one that handles the interface and
  52. //             multi-field votes and the one that handles console commands and
  53. //             single line votes.  
  54. struct voteStruct_t {
  55.     int                m_fieldFlags;    // flags for which fields are valid
  56.     int                m_kick;            // id of the player
  57.     idStr            m_map;            // name of the map
  58.     int                m_gameType;        // game type enum
  59.     int                m_timeLimit;
  60.     int                m_fragLimit;
  61.     int                m_tourneyLimit;
  62.     int                m_captureLimit;
  63.     int                m_minPlayers;
  64.     int                m_teamBalance;
  65.     // restart is a flag only
  66.     // nextmap is a flag only but we don't technically support it (but doom had it so it's here)
  67. };
  68.  
  69. typedef enum {
  70.     VOTEFLAG_RESTART        = 0x0001,
  71.     VOTEFLAG_MIN_PLAYERS    = 0x0002,
  72.     VOTEFLAG_TEAMBALANCE    = 0x0004,
  73.     VOTEFLAG_NEXTMAP        = 0x0008,
  74.     VOTEFLAG_KICK            = 0x0010,
  75.     VOTEFLAG_MAP            = 0x0020,
  76.     VOTEFLAG_GAMETYPE        = 0x0040,
  77.     VOTEFLAG_TIMELIMIT        = 0x0080,
  78.     VOTEFLAG_TOURNEYLIMIT    = 0x0100,
  79.     VOTEFLAG_CAPTURELIMIT    = 0x0200,
  80.     VOTEFLAG_FRAGLIMIT        = 0x0400,
  81. } voteFlag_t;
  82.  
  83. // more compact than a chat line
  84. typedef enum {
  85.     MSG_SUICIDE = 0,
  86.     MSG_KILLED,
  87.     MSG_KILLEDTEAM,
  88.     MSG_DIED,
  89.     MSG_VOTE,
  90.     MSG_VOTEPASSED,
  91.     MSG_VOTEFAILED,
  92.     MSG_SUDDENDEATH,
  93.     MSG_FORCEREADY,
  94.     MSG_JOINEDSPEC,
  95.     MSG_TIMELIMIT,
  96.     MSG_FRAGLIMIT,
  97.     MSG_CAPTURELIMIT,
  98.     MSG_TELEFRAGGED,
  99.     MSG_JOINTEAM,
  100.     MSG_HOLYSHIT,
  101.     MSG_COUNT
  102. } msg_evt_t;
  103.  
  104. typedef enum {
  105.     PLAYER_VOTE_NONE,
  106.     PLAYER_VOTE_NO,
  107.     PLAYER_VOTE_YES,
  108.     PLAYER_VOTE_WAIT    // mark a player allowed to vote
  109. } playerVote_t;
  110.  
  111. typedef enum {
  112.     PRM_AUTO,
  113.     PRM_SCORE,
  114.     PRM_TEAM_SCORE,
  115.     PRM_TEAM_SCORE_PLUS_SCORE,
  116.     PRM_WINS
  117. } playerRankMode_t;
  118.  
  119. enum announcerSound_t {
  120.     // General announcements
  121.     AS_GENERAL_ONE,
  122.     AS_GENERAL_TWO,
  123.     AS_GENERAL_THREE,
  124.     AS_GENERAL_YOU_WIN,
  125.     AS_GENERAL_YOU_LOSE,
  126.     AS_GENERAL_FIGHT,
  127.     AS_GENERAL_SUDDEN_DEATH,
  128.     AS_GENERAL_VOTE_FAILED,
  129.     AS_GENERAL_VOTE_PASSED,
  130.     AS_GENERAL_VOTE_NOW,
  131.     AS_GENERAL_ONE_FRAG,
  132.     AS_GENERAL_TWO_FRAGS,
  133.     AS_GENERAL_THREE_FRAGS,
  134.     AS_GENERAL_ONE_MINUTE,
  135.     AS_GENERAL_FIVE_MINUTE,
  136.     AS_GENERAL_PREPARE_TO_FIGHT,
  137.     AS_GENERAL_QUAD_DAMAGE,
  138.     AS_GENERAL_REGENERATION,
  139.     AS_GENERAL_HASTE,
  140.     AS_GENERAL_INVISIBILITY,
  141.     // DM announcements
  142.     AS_DM_YOU_TIED_LEAD,
  143.     AS_DM_YOU_HAVE_TAKEN_LEAD,
  144.     AS_DM_YOU_LOST_LEAD,
  145.     // Team announcements
  146.     AS_TEAM_ENEMY_SCORES,
  147.     AS_TEAM_YOU_SCORE,
  148.     AS_TEAM_TEAMS_TIED,
  149.     AS_TEAM_STROGG_LEAD,
  150.     AS_TEAM_MARINES_LEAD,
  151.     AS_TEAM_JOIN_MARINE,
  152.     AS_TEAM_JOIN_STROGG,
  153.     // CTF announcements
  154.     AS_CTF_YOU_HAVE_FLAG,
  155.     AS_CTF_YOUR_TEAM_HAS_FLAG,
  156.     AS_CTF_ENEMY_HAS_FLAG,
  157.     AS_CTF_YOUR_TEAM_DROPS_FLAG,
  158.     AS_CTF_ENEMY_DROPS_FLAG,
  159.     AS_CTF_YOUR_FLAG_RETURNED,
  160.     AS_CTF_ENEMY_RETURNS_FLAG,
  161.     // Tourney announcements
  162.     AS_TOURNEY_ADVANCE,
  163.     AS_TOURNEY_JOIN_ARENA_ONE,
  164.     AS_TOURNEY_JOIN_ARENA_TWO,
  165.     AS_TOURNEY_JOIN_ARENA_THREE,
  166.     AS_TOURNEY_JOIN_ARENA_FOUR,
  167.     AS_TOURNEY_JOIN_ARENA_FIVE,
  168.     AS_TOURNEY_JOIN_ARENA_SIX,
  169.     AS_TOURNEY_JOIN_ARENA_SEVEN,
  170.     AS_TOURNEY_JOIN_ARENA_EIGHT,
  171.     AS_TOURNEY_JOIN_ARENA_WAITING,
  172.     AS_TOURNEY_DONE,
  173.     AS_TOURNEY_START,
  174.     AS_TOURNEY_ELIMINATED,
  175.     AS_TOURNEY_WON,
  176.     AS_TOURNEY_PRELIMS,
  177.     AS_TOURNEY_QUARTER_FINALS,
  178.     AS_TOURNEY_SEMI_FINALS,
  179.     AS_TOURNEY_FINAL_MATCH,
  180.     AS_NUM_SOUNDS
  181. };
  182.  
  183. typedef struct mpPlayerState_s {
  184.     int                ping;            // player ping
  185.     int                fragCount;        // kills
  186.     int                teamFragCount;    // teamplay awards
  187.     int                wins;
  188.     playerVote_t    vote;            // player's vote
  189.     bool            scoreBoardUp;    // toggle based on player scoreboard button, used to activate de-activate the scoreboard gui
  190.     bool            ingame;
  191. } mpPlayerState_t;
  192.  
  193. const int MAX_INSTANCES = 8;
  194.  
  195. const int NUM_CHAT_NOTIFY    = 5;
  196. const int CHAT_FADE_TIME    = 400;
  197. const int FRAGLIMIT_DELAY    = 2000;
  198. const int CAPTURELIMIT_DELAY = 750;
  199.  
  200. const int MP_PLAYER_MINFRAGS = -100;
  201. const int MP_PLAYER_MAXFRAGS = 999;
  202. const int MP_PLAYER_MAXWINS    = 100;
  203. const int MP_PLAYER_MAXPING    = 999;
  204.  
  205. const int MAX_AP = 5;
  206.  
  207. const int CHAT_HISTORY_SIZE = 2048;
  208. const int RCON_HISTORY_SIZE = 4096;
  209.  
  210. const int KILL_NOTIFICATION_LEN = 256;
  211. //RAVEN BEGIN
  212. //asalmon: update stats for Xenon
  213. #ifdef _XENON
  214. const int XENON_STAT_UPDATE_INTERVAL = 1000;
  215. #endif
  216.  
  217. const int ASYNC_PLAYER_FRAG_BITS = -idMath::BitsForInteger( MP_PLAYER_MAXFRAGS - MP_PLAYER_MINFRAGS );    // player can have negative frags
  218. const int ASYNC_PLAYER_WINS_BITS = idMath::BitsForInteger( MP_PLAYER_MAXWINS );
  219. const int ASYNC_PLAYER_PING_BITS = idMath::BitsForInteger( MP_PLAYER_MAXPING );
  220. const int ASYNC_PLAYER_INSTANCE_BITS = idMath::BitsForInteger( MAX_INSTANCES );
  221. //RAVEN END
  222.  
  223. // ddynerman: game state
  224. #include "mp/GameState.h"
  225.  
  226. typedef struct mpChatLine_s {
  227.     idStr            line;
  228.     short            fade;            // starts high and decreases, line is removed once reached 0
  229. } mpChatLine_t;
  230.  
  231. typedef struct mpBanInfo_s {
  232.     idStr            name;
  233.     char            guid[ CLIENT_GUID_LENGTH ];
  234. //    unsigned char    ip[ 15 ];
  235. } mpBanInfo_t;
  236.  
  237. class idMultiplayerGame {
  238.  
  239.     // rvGameState manages our state
  240.     friend class rvGameState;
  241.  
  242. public:
  243.  
  244.                     idMultiplayerGame();
  245.  
  246.     void            Shutdown( void );
  247.  
  248.     // resets everything and prepares for a match
  249.     void            Reset( void );
  250.  
  251. // RAVEN BEGIN
  252. // mwhitlock: Dynamic memory consolidation
  253.     // Made this public so that level heap can be emptied.
  254.     void            Clear( void );
  255. // RAVEN END
  256.  
  257.     // setup local data for a new player
  258.     void            SpawnPlayer( int clientNum );
  259.  
  260.     // Run the MP Game
  261.     void            Run( void );
  262.  
  263.     // Run the local client
  264.     void            ClientRun( void );
  265.  
  266.     // Run common code (client & server)
  267.     void            CommonRun( void );
  268.  
  269.     // draws mp hud, scoredboard, etc.. 
  270.     bool            Draw( int clientNum );
  271.     
  272.  
  273.     // updates a player vote
  274.     void            PlayerVote( int clientNum, playerVote_t vote );
  275.  
  276.     // updates frag counts and potentially ends the match in sudden death
  277.     void            PlayerDeath( idPlayer *dead, idPlayer *killer, int methodOfDeath );
  278.  
  279.     void            AddChatLine( const char *fmt, ... ) id_attribute((format(printf,2,3)));
  280.  
  281.     void            UpdateMainGui( void );
  282. // RAVEN BEGIN
  283. // bdube: global pickup sounds (powerups, etc)
  284.     // Global item acquire sounds 
  285.     void            PlayGlobalItemAcquireSound ( int entityDefIndex );
  286.  
  287. #ifdef _USE_VOICECHAT
  288. // jscott: game side voice comms
  289.     bool            CanTalk( idPlayer *from, idPlayer *to, bool echo );
  290.     void            XmitVoiceData( void );
  291.     void            ReceiveAndForwardVoiceData( int clientNum, const idBitMsg &inMsg, bool echo );
  292.     void            ReceiveAndPlayVoiceData( const idBitMsg &inMsg );
  293. #endif
  294.  
  295. // jshepard: selects a map at random that will run with the current game type
  296.     bool            PickMap( idStr gameType );
  297.     void            ClearVote( int clientNum = -1 );
  298.     void            ResetRconGuiStatus( void );
  299.  
  300. // RAVEN END
  301.  
  302.     idUserInterface*    StartMenu( void );
  303.     
  304.     void            ClearMenu() { currentMenu = 0; }
  305.  
  306.     const char*        HandleGuiCommands( const char *menuCommand );
  307.  
  308.     void            WriteToSnapshot( idBitMsgDelta &msg ) const;
  309.     void            ReadFromSnapshot( const idBitMsgDelta &msg );
  310.  
  311.     void            ShuffleTeams( void );
  312.     void            SetGameType( void );
  313.     void            SetMatchStartedTime( int time ) { matchStartedTime = time; }
  314.  
  315.     rvGameState*    GetGameState( void );
  316.  
  317.  
  318.     void            PrintMessageEvent( int to, msg_evt_t evt, int parm1 = -1, int parm2 = -1 );
  319.  
  320.     void            DisconnectClient( int clientNum );
  321.     static void        ForceReady_f( const idCmdArgs &args );
  322.     static void        DropWeapon_f( const idCmdArgs &args );
  323.     static void        MessageMode_f( const idCmdArgs &args );
  324.     static void        VoiceChat_f( const idCmdArgs &args );
  325.     static void        VoiceChatTeam_f( const idCmdArgs &args );
  326.  
  327.  
  328. // RAVEN BEGIN
  329. // shouchard:  added console commands to mute/unmute voice chat
  330.     static void        VoiceMute_f( const idCmdArgs &args );
  331.     static void        VoiceUnmute_f( const idCmdArgs &args );
  332.  
  333. // jshepard: command wrappers
  334.     static void        ForceTeamChange_f( const idCmdArgs& args );
  335.     static void        RemoveClientFromBanList_f( const idCmdArgs& args );
  336.  
  337. // activates the admin console when a rcon password challenge returns.
  338.     void            ProcessRconReturn( bool success );
  339. // RAVEN END
  340.  
  341.     typedef enum {
  342.         VOTE_RESTART = 0,
  343.         VOTE_TIMELIMIT,
  344.         VOTE_FRAGLIMIT,
  345.         VOTE_GAMETYPE,
  346.         VOTE_KICK,
  347.         VOTE_MAP,
  348.         VOTE_MIN_PLAYERS,
  349.         VOTE_NEXTMAP,
  350. // RAVEN BEGIN
  351. // shouchard:  added capturelimit, round limit, and autobalance to vote flags
  352.         VOTE_CAPTURELIMIT,
  353.         VOTE_ROUNDLIMIT,
  354.         VOTE_AUTOBALANCE,
  355.         VOTE_MULTIFIELD,    // all the "packed" vote functions
  356. // RAVEN END
  357.         VOTE_COUNT,
  358.         VOTE_NONE
  359.     } vote_flags_t;
  360.  
  361.     typedef enum {
  362.         VOTE_UPDATE,
  363.         VOTE_FAILED,
  364.         VOTE_PASSED,    // passed, but no reset yet
  365.         VOTE_ABORTED,
  366.         VOTE_RESET        // tell clients to reset vote state
  367.     } vote_result_t;
  368.  
  369. // RAVEN BEGIN
  370. // shouchard:  added enum to remove magic numbers
  371.     typedef enum {
  372.         VOTE_GAMETYPE_DM = 0,
  373.         VOTE_GAMETYPE_TOURNEY,
  374.         VOTE_GAMETYPE_TDM,
  375.         VOTE_GAMETYPE_CTF,
  376.         VOTE_GAMETYPE_ARENA_CTF,
  377.         VOTE_GAMETYPE_COUNT
  378.     } vote_gametype_t;
  379. // RAVEN END
  380.  
  381.     static void        Vote_f( const idCmdArgs &args );
  382.     static void        CallVote_f( const idCmdArgs &args );
  383.     void            ClientCallVote( vote_flags_t voteIndex, const char *voteValue );
  384.     void            ServerCallVote( int clientNum, const idBitMsg &msg );
  385.     void            ClientStartVote( int clientNum, const char *voteString );
  386.     void            ServerStartVote( int clientNum, vote_flags_t voteIndex, const char *voteValue );
  387. // RAVEN BEGIN
  388. // shouchard:  multiline vote support
  389.     void            ClientUpdateVote( vote_result_t result, int yesCount, int noCount, const voteStruct_t &voteData );
  390. // RAVEN END
  391.     void            CastVote( int clientNum, bool vote );
  392.     void            ExecuteVote( void );
  393. // RAVEN BEGIN
  394. // shouchard:  multiline vote handlers
  395.     void            ClientCallPackedVote( const voteStruct_t &voteData );
  396.     void            ServerCallPackedVote( int clientNum, const idBitMsg &msg );
  397.     void            ClientStartPackedVote( int clientNum, const voteStruct_t &voteData );
  398.     void            ServerStartPackedVote( int clientNum, const voteStruct_t &voteData );
  399.     void            ExecutePackedVote( void );
  400. // RAVEN END
  401.  
  402.     void            WantKilled( int clientNum );
  403.     int                NumActualClients( bool countSpectators, int *teamcount = NULL );
  404.     void            DropWeapon( int clientNum );
  405.     void            MapRestart( void );
  406.     void            JoinTeam( const char* team );
  407.     // called by idPlayer whenever it detects a team change (init or switch)
  408.     void            SwitchToTeam( int clientNum, int oldteam, int newteam );
  409.     
  410.     bool            IsPureReady( void ) const;
  411.     void            ProcessChatMessage( int clientNum, bool team, const char *name, const char *text, const char *sound );
  412.     void            ProcessVoiceChat( int clientNum, bool team, int index );
  413. // RAVEN BEGIN
  414. // shouchard:  added commands to mute/unmute voice chat
  415.     void            ClientVoiceMute( int clientNum, bool mute );
  416.     int                GetClientNumFromPlayerName( const char *playerName );
  417.     void            ServerHandleVoiceMuting( int clientSrc, int clientDest, bool mute );
  418. // shouchard:  fixing a bug in multiplayer where round timer sounds (5 minute
  419. //             warning, etc.) don't go away at the end of the round.
  420.     void            ClearAnnouncerSounds();
  421. // shouchard:  server admin stuff
  422.     typedef struct 
  423.     {
  424.         bool        restartMap;
  425.         idStr        mapName;
  426.         int            gameType;
  427.         int            captureLimit;
  428.         int            fragLimit;
  429.         int            tourneyLimit;
  430.         int            timeLimit;
  431.         int            minPlayers;
  432.         bool        autoBalance;
  433.     } serverAdminData_t;
  434.  
  435.     void            HandleServerAdminBanPlayer( int clientNum );
  436.     void            HandleServerAdminRemoveBan( const char * info );
  437.     void            HandleServerAdminKickPlayer( int clientNum );
  438.     void            HandleServerAdminForceTeamSwitch( int clientNum );
  439.     bool            HandleServerAdminCommands( serverAdminData_t &data );
  440. // RAVEN END
  441.  
  442.     void            Precache( void );
  443.     
  444.     // throttle UI switch rates
  445.     void            ThrottleUserInfo( void );
  446.     void            ToggleSpectate( void );
  447.     void            ToggleReady( void );
  448.     void            ToggleTeam( void );
  449.  
  450.     void            ClearFrags( int clientNum );
  451.  
  452.     void            EnterGame( int clientNum );
  453.     bool            CanPlay( idPlayer *p );
  454.     bool            IsInGame( int clientNum );
  455.     bool            WantRespawn( idPlayer *p );
  456.  
  457.     void            ServerWriteInitialReliableMessages( int clientNum );
  458.     void            ClientReadStartState( const idBitMsg &msg );
  459.  
  460.     void            ServerClientConnect( int clientNum );
  461.  
  462.     void            PlayerStats( int clientNum, char *data, const int len );
  463.  
  464.     void            AddTeamScore ( int team, int amount );
  465.     void            AddPlayerScore( idPlayer* player, int amount );
  466.     void            AddPlayerTeamScore( idPlayer* player, int amount );
  467.     void            AddPlayerWin( idPlayer* player, int amount );
  468.     void            SetPlayerTeamScore( idPlayer* player, int value );
  469.     void            SetPlayerScore( idPlayer* player, int value );
  470.     void            SetPlayerWin( idPlayer* player, int value );
  471.     void            SetHudOverlay( idUserInterface* overlay, int duration );
  472.  
  473.     void            ClearMap ( void );
  474.  
  475.     void            EnableDamage( bool enable = true );
  476.  
  477.     idPlayer*        GetRankedPlayer( int i );
  478.     int                GetRankedPlayerScore( int i );
  479.     int                GetNumRankedPlayers( void );
  480.     
  481.     idPlayer*        GetUnrankedPlayer( int i );
  482.     int                GetNumUnrankedPlayers( void );
  483.  
  484.     int                GetScore( int i );
  485.     int                GetScore( idPlayer* player );
  486.  
  487.     int                GetTeamScore( int i );
  488.     int                GetTeamScore( idPlayer* player );
  489.  
  490.     int                GetWins( int i );
  491.     int                GetWins( idPlayer* player );
  492.  
  493.     // asalmon: Get the score for a team.
  494.     int                GetScoreForTeam( int i );
  495.     int                GetTeamsTotalFrags( int i );
  496.     int                GetTeamsTotalScore( int i );
  497.  
  498.     int                TeamLeader( void );
  499.  
  500.     int                GetPlayerTime( idPlayer* player );
  501.  
  502.     const char*        GetLongGametypeName( const char* gametype );
  503.     int                GameTypeToVote( const char *gameType );
  504.  
  505.     void            ReceiveRemoteConsoleOutput( const char* output );
  506.  
  507.     void            ClientSetInstance( const idBitMsg& msg );
  508.     void            ServerSetInstance( int instance );
  509.  
  510. //RAVEN BEGIN
  511. //asalmon: Xenon scoreboard update
  512. #ifdef _XENON
  513.     void            UpdateXenonScoreboard( idUserInterface *scoreBoard );
  514. #endif
  515. //RAVEN END
  516.  
  517.     void            ScheduleAnnouncerSound ( announcerSound_t sound, float time, int arena = -1, bool allowOverride = false );
  518.     void            ScheduleTimeAnnouncements( void );
  519. // RAVEN END
  520.  
  521.     void            SendDeathMessage( idPlayer *attacker, idPlayer *victim, int methodOfDeath );
  522.     void            ReceiveDeathMessage( idPlayer *attacker, int attackerScore, idPlayer *victim, int victimScore, int methodOfDeath );
  523.  
  524.     rvCTF_AssaultPoint*        NextAP( int team );
  525.     int                        OpposingTeam( int team );
  526.  
  527.     idList<idEntityPtr<rvCTF_AssaultPoint> > assaultPoints;
  528.  
  529.     idVec3            flagBaseLocation[ TEAM_MAX ];
  530.  
  531.     idUserInterface* statSummary;            // stat summary
  532.     rvTourneyGUI    tourneyGUI;
  533.  
  534.     void            ShowStatSummary( void );
  535.     bool            CanCapture( int team );
  536.     void            FlagCaptured( idPlayer *player );
  537.     
  538.     void            UpdatePlayerRanks( playerRankMode_t rankMode = PRM_AUTO );
  539.     void            UpdateTeamRanks( void );
  540.     void            UpdateHud( idUserInterface* _mphud );
  541.     idPlayer *        FragLimitHit( void );
  542.     idPlayer *        FragLeader( void );
  543.     bool            TimeLimitHit( void );
  544.     int                GetCurrentMenu( void ) { return currentMenu; }
  545.  
  546.     void            WriteClientNetworkInfo( idFile *file, int clientNum );
  547.     void            ReadClientNetworkInfo( idFile* file, int clientNum );
  548.  
  549.     static const char*    teamNames[ TEAM_MAX ];
  550.  
  551. private:
  552.     static const char    *MPGuis[];
  553.     static const char    *ThrottleVars[];
  554.     static const char    *ThrottleVarsInEnglish[];
  555.     static const int    ThrottleDelay[];
  556.  
  557.     char            killNotificationMsg[ KILL_NOTIFICATION_LEN ];
  558.  
  559.     int                pingUpdateTime;            // time to update ping
  560.  
  561.     mpPlayerState_t    playerState[ MAX_CLIENTS ];
  562.  
  563.     // game state
  564.     rvGameState*    gameState;
  565.  
  566.     // vote vars
  567.     vote_flags_t    vote;                    // active vote or VOTE_NONE
  568.     int                voteTimeOut;            // when the current vote expires
  569.     int                voteExecTime;            // delay between vote passed msg and execute
  570.     float            yesVotes;                // counter for yes votes
  571.     float            noVotes;                // and for no votes
  572.     idStr            voteValue;                // the data voted upon ( server )
  573.     idStr            voteString;                // the vote string ( client )
  574.     bool            voted;                    // hide vote box ( client )
  575.     int                kickVoteMap[ MAX_CLIENTS ];
  576. // RAVEN BEGIN
  577. // shouchard:  names for kickVoteMap
  578.     idStr            kickVoteMapNames[ MAX_CLIENTS ];
  579.     voteStruct_t    currentVoteData;        // used for multi-field votes
  580. // RAVEN END
  581.  
  582.     // time related
  583.     int                matchStartedTime;        // time current match started
  584.  
  585.     // guis
  586.     idUserInterface *scoreBoard;            // scoreboard
  587.     idUserInterface *mainGui;                // ready / nick / votes etc.
  588.     idListGUI        *mapList;
  589.     idUserInterface *msgmodeGui;            // message mode
  590.     int                currentMenu;            // 0 - none, 1 - mainGui, 2 - msgmodeGui
  591.     int                nextMenu;                // if 0, will do mainGui
  592.     bool            bCurrentMenuMsg;        // send menu state updates to server
  593.  
  594.  
  595.     enum {
  596.         MPLIGHT_CTF_MARINE,
  597.         MPLIGHT_CTF_STROGG,
  598.         MPLIGHT_QUAD,
  599.         MPLIGHT_HASTE,
  600.         MPLIGHT_REGEN,
  601.         MPLIGHT_MAX
  602.     };
  603.  
  604.     int                lightHandles[ MPLIGHT_MAX ];
  605.     renderLight_t    lights[ MPLIGHT_MAX ];
  606.  
  607.     // chat buffer
  608.     idStr            chatHistory;
  609.  
  610.     // rcon buffer
  611.     idStr            rconHistory;
  612.  
  613. //RAVEN BEGIN
  614. //asalmon: Need to refresh stats periodically if the player is looking at stats
  615.     int currentStatClient;
  616.     int currentStatTeam;
  617. //RAVEN END
  618.  
  619. public:
  620.     // current player rankings
  621.     idList<rvPair<idPlayer*, int> >     rankedPlayers;
  622.     idList<idPlayer*>        unrankedPlayers;
  623.  
  624.     rvPair<int, int>        rankedTeams[ TEAM_MAX ];
  625.  
  626. private:
  627.  
  628.     bool            pureReady;                // defaults to false, set to true once server game is running with pure checksums
  629.     bool            currentSoundOverride;
  630.     int                switchThrottle[ 3 ];
  631.     int                voiceChatThrottle;
  632.  
  633.     // updates the passed gui with current score information
  634.     void            UpdateRankColor( idUserInterface *gui, const char *mask, int i, const idVec3 &vec );    
  635.  
  636.     // bdube: test scoreboard
  637.     void            UpdateTestScoreboard( idUserInterface *scoreBoard );
  638.     
  639.     // ddynerman: gametype specific scoreboard
  640.     void            UpdateScoreboard( idUserInterface *scoreBoard );
  641.  
  642.     void            UpdateDMScoreboard( idUserInterface *scoreBoard );
  643.     void            UpdateTeamScoreboard( idUserInterface *scoreBoard );
  644.     void            UpdateSummaryBoard( idUserInterface *scoreBoard );
  645.  
  646.     int                GetPlayerRank( idPlayer* player, bool& isTied );
  647.     int                GetAdjustedPlayerRank( idPlayer* player, int adjust, bool& isTied );
  648.     char*            GetPlayerRankText( idPlayer* player );
  649.     char*            GetPlayerRankText( int rank, bool tied, int score );
  650.  
  651.     const char*        BuildSummaryListString( idPlayer* player, int rankedScore );
  652.  
  653.     typedef struct announcerSoundNode_s {
  654.         announcerSound_t soundShader;
  655.         float time;
  656.         idLinkList<announcerSoundNode_s> announcerSoundNode;
  657.         int arena;
  658.         bool allowOverride;
  659.     } announcerSoundNode_t;
  660.  
  661.     idLinkList<announcerSoundNode_t> announcerSoundQueue;
  662.  
  663.     static const char* announcerSoundDefs[ AS_NUM_SOUNDS ];
  664.  
  665.     float            announcerPlayTime;
  666.  
  667.     void            PlayAnnouncerSounds ( void );
  668.  
  669.  
  670.     int                teamScore[ TEAM_MAX ];
  671.     void            ClearTeamScores ( void );
  672.  
  673.     void            UpdateLeader( idPlayer* oldLeader );
  674.  
  675.     void            ClearGuis( void );
  676.     void            DrawScoreBoard( idPlayer *player );
  677.     void            CheckVote( void );
  678.     bool            AllPlayersReady( idStr* reason = NULL );
  679.     
  680.     const char *    GameTime( void );
  681.  
  682.     bool            EnoughClientsToPlay( void );
  683.     void            DrawStatSummary( void );
  684.     // go through the clients, and see if they want to be respawned, and if the game allows it
  685.     // called during normal gameplay for death -> respawn cycles
  686.     // and for a spectator who want back in the game (see param)
  687.     void            CheckRespawns( idPlayer *spectator = NULL );
  688.  
  689.     void            FreeLight ( int lightID );
  690.     void            UpdateLight ( int lightID, idPlayer *player );
  691.     void            CheckSpecialLights( void );
  692.     void            ForceReady();
  693.     // when clients disconnect or join spectate during game, check if we need to end the game
  694.     void            CheckAbortGame( void );
  695.     void            MessageMode( const idCmdArgs &args );
  696.     void            DisableMenu( void );
  697.     void            SetMapShot( void );
  698.     // scores in TDM
  699.     void            VoiceChat( const idCmdArgs &args, bool team );
  700.  
  701. // RAVEN BEGIN
  702. // mekberg: added
  703.     void            UpdateMPSettingsModel( idUserInterface* currentGui );
  704. // RAVEN END
  705.  
  706.     void            ServerWriteStartState( int clientNum, idBitMsg &msg, bool withLocalClient );
  707.  
  708. };
  709.  
  710. ID_INLINE bool idMultiplayerGame::IsPureReady( void ) const {
  711.     return pureReady;
  712. }
  713.  
  714. ID_INLINE void idMultiplayerGame::ClearFrags( int clientNum ) {
  715.     playerState[ clientNum ].fragCount = 0;
  716. }
  717.  
  718. ID_INLINE bool idMultiplayerGame::IsInGame( int clientNum ) {
  719.     return playerState[ clientNum ].ingame;
  720. }
  721.  
  722. ID_INLINE int idMultiplayerGame::OpposingTeam( int team ) {
  723.     return (team == TEAM_STROGG ? TEAM_MARINE : TEAM_STROGG);
  724. }
  725.  
  726. ID_INLINE idPlayer* idMultiplayerGame::GetRankedPlayer( int i ) {
  727.     if( i >= 0 && i < rankedPlayers.Num() ) {
  728.         return rankedPlayers[ i ].First();
  729.     } else {
  730.         return NULL;
  731.     }
  732. }
  733.  
  734. ID_INLINE int idMultiplayerGame::GetRankedPlayerScore( int i ) {
  735.     if( i >= 0 && i < rankedPlayers.Num() ) {
  736.         return rankedPlayers[ i ].Second();
  737.     } else {
  738.         return 0;
  739.     }
  740. }
  741.  
  742. ID_INLINE int idMultiplayerGame::GetNumUnrankedPlayers( void ) {
  743.     return unrankedPlayers.Num();
  744. }
  745.  
  746. ID_INLINE idPlayer* idMultiplayerGame::GetUnrankedPlayer( int i ) {
  747.     if( i >= 0 && i < unrankedPlayers.Num() ) {
  748.         return unrankedPlayers[ i ];
  749.     } else {
  750.         return NULL;
  751.     }
  752. }
  753.  
  754. ID_INLINE int idMultiplayerGame::GetNumRankedPlayers( void ) {
  755.     return rankedPlayers.Num();
  756. }
  757.  
  758. ID_INLINE int idMultiplayerGame::GetTeamScore( int i ) {
  759.     return playerState[ i ].teamFragCount;
  760. }
  761.  
  762. ID_INLINE int idMultiplayerGame::GetScore( int i ) {
  763.     return playerState[ i ].fragCount;
  764. }
  765.  
  766. ID_INLINE int idMultiplayerGame::GetWins( int i ) {
  767.     return playerState[ i ].wins;
  768. }
  769.  
  770. ID_INLINE void idMultiplayerGame::ResetRconGuiStatus( void ) {
  771.     if( mainGui) {
  772.         mainGui->SetStateInt( "password_valid", 0 );
  773.     }
  774. }
  775.  
  776. // asalmon: needed access team scores for rich presence
  777. ID_INLINE int idMultiplayerGame::GetScoreForTeam( int i ) {
  778.     if( i < 0 || i > TEAM_MAX ) {
  779.         return 0;
  780.     }
  781.     return teamScore[ i ];
  782. }
  783.  
  784. ID_INLINE int idMultiplayerGame::TeamLeader( void ) {
  785.     if( teamScore[ TEAM_MARINE ] == teamScore[ TEAM_STROGG ] ) {
  786.         return -1;
  787.     } else {
  788.         return ( teamScore[ TEAM_MARINE ] > teamScore[ TEAM_STROGG ] ? TEAM_MARINE : TEAM_STROGG );
  789.     }
  790. }
  791.  
  792. int ComparePlayersByScore( const void* left, const void* right );
  793. int CompareTeamsByScore( const void* left, const void* right );
  794.  
  795. #endif    /* !__MULTIPLAYERGAME_H__ */
  796.  
  797. // RAVEN END
  798.