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

  1.  
  2. #ifndef __GAME_LOCAL_H__
  3. #define    __GAME_LOCAL_H__
  4. // RAVEN BEGIN
  5. // jsinger: attempt to eliminate cross-DLL allocation issues
  6. #ifdef RV_UNIFIED_ALLOCATOR
  7. inline void *operator new( size_t s ) { return Memory::Allocate(s); }
  8. inline void operator delete( void *p ) { Memory::Free(p); }
  9. inline void *operator new[]( size_t s ) { return Memory::Allocate(s); }
  10. inline void operator delete[]( void *p ) { Memory::Free(p); }
  11. #endif
  12. // RAVEN END
  13.  
  14. /*
  15. ===============================================================================
  16.  
  17.     Local implementation of the public game interface.
  18.  
  19. ===============================================================================
  20. */
  21.  
  22. #define LAGO_IMG_WIDTH 64
  23. #define LAGO_IMG_HEIGHT 64
  24. #define LAGO_WIDTH    64
  25. #define LAGO_HEIGHT    44
  26. #define LAGO_MATERIAL    "textures/mptextures/lagometer"
  27. #define LAGO_IMAGE        "textures/mptextures/lagometer.tga"
  28.  
  29. // if set to 1 the server sends the client PVS with snapshots and the client compares against what it sees
  30. #ifndef ASYNC_WRITE_PVS
  31.     #define ASYNC_WRITE_PVS 0
  32. #endif
  33.  
  34. extern idRenderWorld *                gameRenderWorld;
  35.  
  36. // the "gameversion" client command will print this plus compile date
  37. #define    GAME_VERSION        "baseQUAKE4-1"
  38.  
  39. // classes used by idGameLocal
  40. class idEntity;
  41. class idActor;
  42. class idPlayer;
  43. class idCamera;
  44. class idWorldspawn;
  45. class idTestModel;
  46. class idAAS;
  47. class idAI;
  48. // RAVEN BEGIN
  49. // bdube: not using id effects
  50. //class idSmokeParticles;
  51. //class idEntityFx;
  52. // bdube: client side entities
  53. class rvInstance;
  54. class rvClientEntity;
  55. class rvClientModel;
  56. class rvCTFAssaultPlayerStart;
  57. class idPlayerStart;
  58. // RAVEN END
  59. class idTypeInfo;
  60. class idProgram;
  61. class idThread;
  62. class idEditEntities;
  63. class idLocationEntity;
  64.  
  65. // RAVEN BEGIN
  66. // dluetscher: reduced max clients for memory usage
  67. #ifdef _XENON
  68. #define    MAX_CLIENTS                16
  69. #else
  70. // RAVEN END
  71. #define    MAX_CLIENTS                32
  72. #endif
  73.  
  74. #define    GENTITYNUM_BITS            12
  75. #define    MAX_GENTITIES            (1<<GENTITYNUM_BITS)
  76. #define    ENTITYNUM_NONE            (MAX_GENTITIES-1)
  77. #define    ENTITYNUM_WORLD            (MAX_GENTITIES-2)
  78. // RAVEN BEGIN
  79. // bdube: dummy entity for client side physics
  80. #define ENTITYNUM_CLIENT        (MAX_GENTITIES-3)
  81. #define    ENTITYNUM_MAX_NORMAL    (MAX_GENTITIES-3)
  82. // RAVEN END
  83.  
  84. // RAVEN BEGIN
  85. // bdube: client entities
  86. #define    CENTITYNUM_BITS            12
  87. #define    MAX_CENTITIES            (1<<CENTITYNUM_BITS)
  88. // shouchard:  for ban lists and because I hate magic numbers
  89. #define CLIENT_GUID_LENGTH        12
  90. // RAVEN END
  91.  
  92. // RAVEN BEGIN
  93. // abahr: helper macros
  94. #define SAFE_DELETE_PTR(p) if(p) { delete (p); (p) = NULL; }
  95. #define SAFE_REMOVE(p) if(p) { (p)->PostEventMS(&EV_Remove, 0); (p) = NULL; }
  96. // RAVEN END
  97.  
  98. //============================================================================
  99.  
  100. #include "gamesys/Event.h"
  101. // RAVEN BEGIN
  102. // bdube: added
  103. #include "gamesys/State.h"
  104. // RAVEN END
  105. #include "gamesys/Class.h"
  106. #include "gamesys/SysCvar.h"
  107. #include "gamesys/SysCmds.h"
  108. #include "gamesys/SaveGame.h"
  109. #include "gamesys/DebugGraph.h"
  110.  
  111. #include "script/Script_Program.h"
  112.  
  113. #include "anim/Anim.h"
  114.  
  115. #include "ai/AAS.h"
  116.  
  117. #include "physics/Clip.h"
  118. #include "physics/Push.h"
  119.  
  120. #include "Pvs.h"
  121.  
  122. //============================================================================
  123.  
  124. const int MAX_GAME_MESSAGE_SIZE        = 8192;
  125. const int MAX_ENTITY_STATE_SIZE        = 512;
  126. const int ENTITY_PVS_SIZE            = ((MAX_GENTITIES+31)>>5);
  127. // RAVEN BEGIN
  128. // abahr: changed to NUM_PORTAL_ATTRIBUTES to take into account gravity
  129. const int NUM_RENDER_PORTAL_BITS    = NUM_PORTAL_ATTRIBUTES;
  130. // RAVEN END
  131.  
  132. typedef struct entityState_s {
  133.     int                        entityNumber;
  134.     idBitMsg                state;
  135.     byte                    stateBuf[MAX_ENTITY_STATE_SIZE];
  136.     struct entityState_s *    next;
  137. } entityState_t;
  138.  
  139. typedef struct snapshot_s {
  140.     int                        sequence;
  141.     entityState_t *            firstEntityState;
  142.     int                        pvs[ENTITY_PVS_SIZE];
  143.     struct snapshot_s *        next;
  144. } snapshot_t;
  145.  
  146. const int MAX_EVENT_PARAM_SIZE        = 128;
  147.  
  148. typedef struct entityNetEvent_s {
  149.     int                        spawnId;
  150.     int                        event;
  151.     int                        time;
  152.     int                        paramsSize;
  153.     byte                    paramsBuf[MAX_EVENT_PARAM_SIZE];
  154.     struct entityNetEvent_s    *next;
  155.     struct entityNetEvent_s *prev;
  156. } entityNetEvent_t;
  157.  
  158. enum {
  159.     GAME_RELIABLE_MESSAGE_SPAWN_PLAYER,
  160.     GAME_RELIABLE_MESSAGE_DELETE_ENT,
  161.     GAME_RELIABLE_MESSAGE_CHAT,
  162.     GAME_RELIABLE_MESSAGE_TCHAT,
  163.     GAME_RELIABLE_MESSAGE_DB,
  164.     GAME_RELIABLE_MESSAGE_KILL,
  165.     GAME_RELIABLE_MESSAGE_DROPWEAPON,
  166.     GAME_RELIABLE_MESSAGE_RESTART,
  167.     GAME_RELIABLE_MESSAGE_SERVERINFO,
  168.     GAME_RELIABLE_MESSAGE_CALLVOTE,
  169.     GAME_RELIABLE_MESSAGE_CASTVOTE,
  170.     GAME_RELIABLE_MESSAGE_STARTVOTE,
  171.     GAME_RELIABLE_MESSAGE_UPDATEVOTE,
  172.     GAME_RELIABLE_MESSAGE_PORTALSTATES,
  173.     GAME_RELIABLE_MESSAGE_PORTAL,
  174.     GAME_RELIABLE_MESSAGE_VCHAT,
  175.     GAME_RELIABLE_MESSAGE_STARTSTATE,
  176.     GAME_RELIABLE_MESSAGE_MENU,
  177.     GAME_RELIABLE_MESSAGE_EVENT,
  178. // RAVEN BEGIN
  179. // bdube: effect
  180.     GAME_RELIABLE_MESSAGE_ITEMACQUIRESOUND,
  181. // ddynerman: death messages
  182.     GAME_RELIABLE_MESSAGE_DEATH,
  183. // ddynerman: game state
  184.     GAME_RELIABLE_MESSAGE_GAMESTATE,
  185. // ddynerman: game stat
  186.     GAME_RELIABLE_MESSAGE_STAT,
  187. // asalmon: game stats for xenon
  188.     GAME_RELIABLE_MESSAGE_ALL_STATS,
  189. // ddynerman: ingame awards
  190.     GAME_RELIABLE_MESSAGE_INGAMEAWARD,
  191. #ifdef _USE_VOICECHAT
  192. // jscott: for voice comms
  193.     GAME_RELIABLE_MESSAGE_VOICEDATA_CLIENT,
  194.     GAME_RELIABLE_MESSAGE_VOICEDATA_CLIENT_ECHO,
  195. #endif
  196. // ddynerman: instances
  197.     GAME_RELIABLE_MESSAGE_SET_INSTANCE,
  198. // shouchard:  for voicechat
  199.     GAME_RELIABLE_MESSAGE_VOICECHAT_MUTING,
  200. // shouchard:  for server admin
  201.     GAME_RELIABLE_MESSAGE_SERVER_ADMIN,
  202. // shouchard:  for voting
  203.     GAME_RELIABLE_MESSAGE_CALLPACKEDVOTE,
  204.     GAME_RELIABLE_MESSAGE_STARTPACKEDVOTE,
  205. // mekberg: get ban list for server
  206.     GAME_RELIABLE_MESSAGE_GETADMINBANLIST,
  207. // RAVEN END    
  208. };
  209.  
  210. enum {
  211.     GAME_UNRELIABLE_MESSAGE_EVENT,
  212.     GAME_UNRELIABLE_MESSAGE_EFFECT,
  213.     GAME_UNRELIABLE_MESSAGE_HITSCAN,
  214. #ifdef _USE_VOICECHAT
  215.     GAME_UNRELIABLE_MESSAGE_VOICEDATA_SERVER
  216. #endif
  217. };
  218.  
  219. typedef enum {
  220.     GAMESTATE_UNINITIALIZED,        // prior to Init being called
  221.     GAMESTATE_NOMAP,                // no map loaded
  222.     GAMESTATE_STARTUP,                // inside InitFromNewMap().  spawning map entities.
  223.     GAMESTATE_RESTART,                // spawning map entities from an instance restart, but not fully restarting
  224.     GAMESTATE_ACTIVE,                // normal gameplay
  225.     GAMESTATE_SHUTDOWN                // inside MapShutdown().  clearing memory.
  226. } gameState_t;
  227.  
  228. typedef struct {
  229.     idEntity    *ent;
  230.     int            dist;
  231. } spawnSpot_t;
  232.  
  233. //============================================================================
  234. class idEventQueue {
  235. public:
  236.     typedef enum {
  237.         OUTOFORDER_IGNORE,
  238.         OUTOFORDER_DROP,
  239.         OUTOFORDER_SORT
  240.     } outOfOrderBehaviour_t;
  241.  
  242.                             idEventQueue() : start( NULL ), end( NULL ) {}
  243.  
  244.     entityNetEvent_t *        Alloc();
  245.     void                    Free( entityNetEvent_t *event );
  246.     void                    Shutdown();
  247.  
  248.     void                    Init();
  249.     void                    Enqueue( entityNetEvent_t* event, outOfOrderBehaviour_t oooBehaviour );
  250.     entityNetEvent_t *        Dequeue( void );
  251.     entityNetEvent_t *        RemoveLast( void );
  252.  
  253.     entityNetEvent_t *        Start( void ) { return start; }
  254.  
  255. private:
  256.     entityNetEvent_t *                    start;
  257.     entityNetEvent_t *                    end;
  258. // RAVEN BEGIN
  259. // jnewquist: Mark memory tags for idBlockAlloc
  260.     idBlockAlloc<entityNetEvent_t,32,MA_EVENT>    eventAllocator;
  261. // RAVEN END
  262. };
  263.  
  264. //============================================================================
  265.  
  266. template< class type >
  267. class idEntityPtr {
  268. public:
  269.                             idEntityPtr();
  270.  
  271.     // save games
  272.     void                    Save( idSaveGame *savefile ) const;                    // archives object for save game file
  273.     void                    Restore( idRestoreGame *savefile );                    // unarchives object from save game file
  274.  
  275.     idEntityPtr<type> &        operator=( type *ent );
  276.  
  277.     // synchronize entity pointers over the network
  278.     int                        GetSpawnId( void ) const { return spawnId; }
  279.     bool                    SetSpawnId( int id );
  280.     bool                    UpdateSpawnId( void );
  281.  
  282.     bool                    IsValid( void ) const;
  283.     type *                    GetEntity( void ) const;
  284.     int                        GetEntityNum( void ) const;
  285.  
  286. // RAVEN BEGIN
  287. // bdube: overloaded operators
  288.                             idEntityPtr( type* ent ) { *this = ent; }
  289.     idEntityPtr<type>&        operator=( idEntityPtr<type>& ent ) { *this = ent.GetEntity(); return *this; }
  290.     type *                    operator->( void ) const;                
  291.     operator                type *( void ) const;
  292. // RAVEN END
  293.  
  294. private:
  295.     int                        spawnId;
  296. };
  297.  
  298. template< class type >
  299. ID_INLINE idEntityPtr<type>::idEntityPtr() {
  300.     spawnId = 0;
  301. }
  302.  
  303. template< class type >
  304. ID_INLINE void idEntityPtr<type>::Save( idSaveGame *savefile ) const {
  305.     savefile->WriteInt( spawnId );
  306. }
  307.  
  308. template< class type >
  309. ID_INLINE void idEntityPtr<type>::Restore( idRestoreGame *savefile ) {
  310.     savefile->ReadInt( spawnId );
  311. }
  312.  
  313. template< class type >
  314. ID_INLINE idEntityPtr<type> &idEntityPtr<type>::operator=( type *ent ) {
  315.     if ( ent == NULL ) {
  316.         spawnId = 0;
  317.     } else {
  318.         spawnId = ( gameLocal.spawnIds[ent->entityNumber] << GENTITYNUM_BITS ) | ent->entityNumber;
  319.     }
  320.     return *this;
  321. }
  322.  
  323. template< class type >
  324. ID_INLINE bool idEntityPtr<type>::SetSpawnId( int id ) {
  325.     if ( id == spawnId ) {
  326.         return false;
  327.     }
  328.     if ( ( id >> GENTITYNUM_BITS ) == gameLocal.spawnIds[ id & ( ( 1 << GENTITYNUM_BITS ) - 1 ) ] ) {
  329.         spawnId = id;
  330.         return true;
  331.     }
  332.     return false;
  333. }
  334.  
  335. template< class type >
  336. ID_INLINE bool idEntityPtr<type>::IsValid( void ) const {
  337.     return ( gameLocal.spawnIds[ spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ) ] == ( spawnId >> GENTITYNUM_BITS ) );
  338. }
  339.  
  340. template< class type >
  341. ID_INLINE type *idEntityPtr<type>::GetEntity( void ) const {
  342.     int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 );
  343.     if ( ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) ) {
  344.         return static_cast<type *>( gameLocal.entities[ entityNum ] );
  345.     }
  346.     return NULL;
  347. }
  348.  
  349. template< class type >
  350. ID_INLINE int idEntityPtr<type>::GetEntityNum( void ) const {
  351.     return ( spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ) );
  352. }
  353.  
  354. // RAVEN BEGIN
  355. // bdube: overloaded operator
  356. template< class type >
  357. ID_INLINE type * idEntityPtr<type>::operator->( void ) const {
  358.     return GetEntity ( );
  359. }
  360.  
  361. template< class type >
  362. ID_INLINE idEntityPtr<type>::operator type * ( void ) const { 
  363.     return GetEntity(); 
  364. }
  365. // RAVEN END
  366.  
  367. // RAVEN BEGIN
  368. // abahr: forward declaration
  369. class rvGravityArea;
  370. // RAVEN END
  371.  
  372. //============================================================================
  373. // ddynerman: moved MultiplayerGame.h down here, so it can use more stuff in Game_local (idEntityPtr)
  374. #include "MultiplayerGame.h"
  375.  
  376. //============================================================================
  377.  
  378. class idGameLocal : public idGame {
  379. public:
  380.     idDict                    serverInfo;                // all the tunable parameters, like numclients, etc
  381.     int                        numClients;                // pulled from serverInfo and verified
  382.     idDict                    userInfo[MAX_CLIENTS];    // client specific settings
  383.     const usercmd_t            *usercmds;                // client input commands
  384.     idDict                    persistentPlayerInfo[MAX_CLIENTS];
  385.     idEntity *                entities[MAX_GENTITIES];// index to entities
  386.     int                        spawnIds[MAX_GENTITIES];// for use in idEntityPtr
  387.     int                        firstFreeIndex;            // first free index in the entities array
  388.     int                        num_entities;            // current number <= MAX_GENTITIES
  389.     idHashIndex                entityHash;                // hash table to quickly find entities by name
  390.     idWorldspawn *            world;                    // world entity
  391.     idLinkList<idEntity>    spawnedEntities;        // all spawned entities
  392.     idLinkList<idEntity>    activeEntities;            // all thinking entities (idEntity::thinkFlags != 0)
  393.     int                        numEntitiesToDeactivate;// number of entities that became inactive in current frame
  394.     bool                    sortPushers;            // true if active lists needs to be reordered to place pushers at the front
  395.     bool                    sortTeamMasters;        // true if active lists needs to be reordered to place physics team masters before their slaves
  396.     idDict                    persistentLevelInfo;    // contains args that are kept around between levels
  397.  
  398. // RAVEN BEGIN
  399. // bdube: client entities
  400.     rvClientEntity *            clientEntities[MAX_CENTITIES];    // index to client entities
  401.     int                            clientSpawnIds[MAX_CENTITIES];    // for use in idClientEntityPtr
  402.     idLinkList<rvClientEntity>    clientSpawnedEntities;            // all client side entities
  403.     int                            num_clientEntities;                // current number of client entities
  404.     int                            firstFreeClientIndex;            // first free index in the client entities array
  405.     
  406.     int                            entityRegisterTime;
  407. // RAVEN END
  408.  
  409.     // can be used to automatically effect every material in the world that references globalParms
  410.     float                    globalShaderParms[ MAX_GLOBAL_SHADER_PARMS ];    
  411.  
  412.     idRandom                random;                    // random number generator used throughout the game
  413.  
  414.     idProgram                program;                // currently loaded script and data space
  415.     idThread *                frameCommandThread;
  416.  
  417.     idPush                    push;                    // geometric pushing
  418.     idPVS                    pvs;                    // potential visible set
  419.     pvsHandle_t                clientsPVS[MAX_CLIENTS];// PVS of multiplayer clients updated every frame
  420.  
  421.     idTestModel *            testmodel;                // for development testing of models
  422. // RAVEN BEGIN
  423. // bdube: not using id effects
  424. //    idEntityFx *            testFx;                    // for development testing of fx
  425. // RAVEN END
  426.  
  427.     // only set when an end level is activated, which will take over camera positioning
  428.     // and draw end-level guis, then 
  429.  
  430.     idStr                    sessionCommand;            // a target_sessionCommand can set this to return something to the session 
  431.  
  432.     idMultiplayerGame        mpGame;                    // handles rules for standard dm
  433.  
  434. // RAVEN BEGIN
  435. // bdube: not using smoke particles
  436. //    idSmokeParticles *        smokeParticles;            // global smoke trails
  437. // RAVEN END
  438.     idEditEntities *        editEntities;            // in game editing
  439.  
  440.     int                        cinematicSkipTime;        // don't allow skipping cinemetics until this time has passed so player doesn't skip out accidently from a firefight
  441.     int                        cinematicStopTime;        // cinematics have several camera changes, so keep track of when we stop them so that we don't reset cinematicSkipTime unnecessarily
  442.     int                        cinematicMaxSkipTime;    // time to end cinematic when skipping.  there's a possibility of an infinite loop if the map isn't set up right.
  443.     bool                    inCinematic;            // game is playing cinematic (player controls frozen)
  444.     bool                    skipCinematic;
  445.  
  446.                                                     // are kept up to date with changes to serverInfo
  447.     int                        framenum;
  448.     int                        previousTime;            // time in msec of last frame
  449.     int                        time;                    // in msec
  450.     int                        msec;                    // time since last update in milliseconds
  451.     int                        mHz;                    // hertz
  452.  
  453.     int                        vacuumAreaNum;            // -1 if level doesn't have any outside areas
  454.  
  455. // RAVEN BEGIN
  456. // abahr:
  457.     idList<rvGravityArea*>    gravityInfo;            // area num for each gravity zone
  458.     idList< idEntityPtr<idEntity> > scriptObjectProxies;
  459. // RAVEN END
  460.  
  461.     gameType_t                gameType;
  462.     bool                    isMultiplayer;            // set if the game is run in multiplayer mode
  463.     bool                    isServer;                // set if the game is run for a dedicated or listen server
  464.     bool                    isClient;                // set if the game is run for a client
  465.                                                     // discriminates between the RunFrame path and the ClientPrediction path
  466.                                                     // NOTE: on a listen server, isClient is false
  467. // RAVEN BEGIN
  468. // ddynerman: set if we're a server and not dedicated
  469.     bool                    isListenServer;            
  470. // RAVEN END
  471.     int                        localClientNum;            // number of the local client. MP: -1 on a dedicated
  472.     idLinkList<idEntity>    snapshotEntities;        // entities from the last snapshot
  473.     int                        realClientTime;            // real client time
  474.     bool                    isNewFrame;                // true if this is a new game frame, not a rerun due to prediction
  475.     int                        entityDefBits;            // bits required to store an entity def number
  476.  
  477.     static const char *        sufaceTypeNames[ MAX_SURFACE_TYPES ];    // text names for surface types
  478.  
  479.     idEntityPtr<idEntity>    lastGUIEnt;                // last entity with a GUI, used by Cmd_NextGUI_f
  480.     int                        lastGUI;                // last GUI on the lastGUIEnt
  481.  
  482. // RAVEN BEGIN
  483. // bdube: added
  484.     int                        editors;                // Mirrored editors flags from common determine which editors are running
  485.     bool                    isLastPredictFrame;        // on an MP server or in SP game this means 'last catchup frame' rather than predict
  486. // RAVEN END
  487.  
  488. // RAVEN BEGIN
  489. // rjohnson: entity usage stats
  490.     idStr                    mapFileNameStripped;        // name of the map, empty string if no map loaded, with path and extension removed.  If entity filter, that is appended
  491.     idList<idDict>            entityUsageList;
  492. // ddynerman: the entity currently thinking, used to play effects/etc only in the appropriate instance
  493.     idEntity*                currentThinkingEntity;
  494.  
  495.     const static int        INITIAL_SPAWN_COUNT = 1;
  496.  
  497.     bool                    pendingDisconnect;            // true if we need to disconnect in the next update
  498.     void                    SetPendingDisconnect() { pendingDisconnect = true; }
  499.  
  500. // RAVEN END
  501.  
  502.     // ---------------------- Public idGame Interface -------------------
  503.  
  504.                             idGameLocal();
  505.  
  506. // RAVEN BEGIN
  507. // jsinger: attempt to eliminate cross-DLL allocation issues
  508. #ifdef RV_UNIFIED_ALLOCATOR
  509.     virtual void            Init( void *(*allocator)( size_t size ), void (*deallocator)( void *ptr ), size_t (*msize)( void *ptr ) );
  510. #else
  511.     virtual void            Init( void );
  512. #endif
  513. // RAVEN END
  514.     virtual void            Shutdown( void );
  515.     virtual void            SetLocalClient( int clientNum );
  516.     virtual void            ThrottleUserInfo( void );
  517.     virtual const idDict *    SetUserInfo( int clientNum, const idDict &userInfo, bool isClient );
  518.     virtual const idDict *    GetUserInfo( int clientNum );
  519.     virtual void            SetServerInfo( const idDict &serverInfo );
  520.  
  521.     virtual const idDict &    GetPersistentPlayerInfo( int clientNum );
  522.     virtual void            SetPersistentPlayerInfo( int clientNum, const idDict &playerInfo );
  523.     virtual void            InitFromNewMap( const char *mapName, idRenderWorld *renderWorld, bool isServer, bool isClient, int randSeed );
  524.     virtual bool            InitFromSaveGame( const char *mapName, idRenderWorld *renderWorld, idFile *saveGameFile );
  525. // RAVEN BEGIN
  526. // mekberg: added saveTypes
  527.     virtual void            SaveGame( idFile *saveGameFile, saveType_t saveType = ST_REGULAR );
  528. // RAVEN END
  529.     virtual void            MapShutdown( void );
  530.     virtual void            CacheDictionaryMedia( const idDict *dict );
  531.     virtual void            SpawnPlayer( int clientNum );
  532. // RAVEN BEGIN
  533.     virtual gameReturn_t    RunFrame( const usercmd_t *clientCmds, int activeEditors, bool lastCatchupFrame );
  534.     virtual    void            MenuFrame( void );
  535. // RAVEN END
  536.     virtual bool            Draw( int clientNum );
  537.     virtual escReply_t        HandleESC( idUserInterface **gui );
  538.     virtual idUserInterface    *StartMenu( void );
  539.     virtual const char *    HandleGuiCommands( const char *menuCommand );
  540.     virtual void            HandleMainMenuCommands( const char *menuCommand, idUserInterface *gui );
  541.     virtual allowReply_t    ServerAllowClient( int numClients, const char *IP, const char *guid, const char *password, char reason[MAX_STRING_CHARS] );
  542.     virtual void            ServerClientConnect( int clientNum );
  543.     virtual void            ServerClientBegin( int clientNum );
  544.     virtual void            ServerClientDisconnect( int clientNum );
  545.     virtual void            ServerWriteInitialReliableMessages( int clientNum );
  546. // RAVEN BEGIN
  547. // jnewquist: Use dword array to match pvs array so we don't have endianness problems.
  548.     virtual void            ServerWriteSnapshot( int clientNum, int sequence, idBitMsg &msg, dword *clientInPVS, int numPVSClients );
  549. // RAVEN END
  550.     virtual bool            ServerApplySnapshot( int clientNum, int sequence );
  551.     virtual void            ServerProcessReliableMessage( int clientNum, const idBitMsg &msg );
  552.     virtual void            ClientReadSnapshot( int clientNum, int sequence, const int gameFrame, const int gameTime, const int dupeUsercmds, const int aheadOfServer, const idBitMsg &msg );
  553.     virtual bool            ClientApplySnapshot( int clientNum, int sequence );
  554.     virtual void            ClientProcessReliableMessage( int clientNum, const idBitMsg &msg );
  555.     virtual gameReturn_t    ClientPrediction( int clientNum, const usercmd_t *clientCmds, bool lastPredictFrame = true, ClientStats_t *cs = NULL );
  556. // RAVEN BEGIN
  557. // ddynerman: client game frame
  558.     virtual void            ClientRun( void );
  559.  
  560. // jshepard: rcon password check
  561.     virtual void            ProcessRconReturn( bool success );
  562.     virtual void            ResetRconGuiStatus( void );
  563. // RAVEN END
  564.     
  565.     virtual void            GetClientStats( int clientNum, char *data, const int len );
  566.     virtual void            SwitchTeam( int clientNum, int team );
  567.  
  568.     virtual bool            DownloadRequest( const char *IP, const char *guid, const char *paks, char urls[ MAX_STRING_CHARS ] );
  569.  
  570. // RAVEN BEGIN
  571. // bdube: client hitscan
  572.     virtual void            ClientHitScan( const idBitMsg &msg );
  573. // jscott: for effects system
  574.     virtual void            StartViewEffect( int type, float time, float scale );
  575.     virtual void            GetPlayerView( idVec3 &origin, idMat3 &axis );
  576.     virtual void            Translation( trace_t &trace, idVec3 &source, idVec3 &dest, idTraceModel *trm, int clipMask );
  577.     virtual void            SpawnClientMoveable ( const char* name, int lifetime, const idVec3& origin, const idMat3& axis, const idVec3& velocity, const idVec3& angular_velocity );
  578. // bdube: added debug methods
  579.     virtual void            DebugSetString ( const char* name, const char* value );
  580.     virtual void            DebugSetFloat ( const char* name, float value );
  581.     virtual void            DebugSetInt ( const char* name, int value );
  582.     virtual const char*        DebugGetStatString ( const char* name );
  583.     virtual int                DebugGetStatInt ( const char* name );
  584.     virtual float            DebugGetStatFloat ( const char* name );
  585.     virtual bool            IsDebugHudActive ( void ) const;
  586. // rjohnson: for new note taking mechanism
  587.     virtual bool            GetPlayerInfo( idVec3 &origin, idMat3 &axis, int PlayerNum = -1, idAngles *deltaViewAngles = NULL, int reqClientNum = -1 );
  588.     virtual void            SetPlayerInfo( idVec3 &origin, idMat3 &axis, int PlayerNum = -1 );
  589.     virtual    bool            PlayerChatDisabled( int clientNum );
  590.     virtual void            SetViewComments( const char *text = 0 );
  591. // ddynerman: utility functions
  592.     virtual void            GetPlayerName( int clientNum, char* name );
  593.     virtual void            GetPlayerClan( int clientNum, char* clan );
  594.     virtual void            SetFriend( int clientNum, bool isFriend );
  595.     static  void            Cmd_PrintMapEntityNumbers_f( const idCmdArgs& args );
  596.     static  void            Cmd_PrintSpawnIds_f( const idCmdArgs& args );
  597. // abahr:
  598.     virtual int                GetNumGravityAreas() const;
  599.     virtual const rvGravityArea* GetGravityInfo( int index ) const;
  600.     virtual void            SetGravityInfo( int index, rvGravityArea* info );
  601.     virtual void            AddUniqueGravityInfo( rvGravityArea* info );
  602.  
  603.     virtual int                GetCurrentGravityInfoIndex( const idVec3& origin ) const;
  604.     virtual bool            InGravityArea( idEntity* entity ) const;
  605.     virtual int                GetCurrentGravityInfoIndex( idEntity* entity ) const;
  606.     virtual const idVec3    GetCurrentGravity( idEntity* entity ) const;
  607.  
  608.     virtual const idVec3    GetCurrentGravity( const idVec3& origin, const idMat3& axis ) const;
  609.  
  610.     virtual bool            InGravityArea( rvClientEntity* entity ) const;
  611.     virtual int                GetCurrentGravityInfoIndex( rvClientEntity* entity ) const;
  612.     virtual const idVec3    GetCurrentGravity( rvClientEntity* entity ) const;
  613.     virtual idEntity*        ReferenceScriptObjectProxy( const char* scriptObjectName );
  614.     virtual void            ReleaseScriptObjectProxy( const char* proxyName );
  615.  
  616. // rjohnson: entity usage stats
  617.     virtual void            ListEntityStats( const idCmdArgs &args );
  618. // RAVEN END
  619.  
  620.     virtual void            SetDemoState( demoState_t state );
  621.     virtual void            WriteClientNetworkInfo( idFile* file, int clientNum );
  622.     virtual void            ReadClientNetworkInfo( int gameTime, idFile* file, int clientNum );
  623.     virtual bool            ValidateDemoProtocol( int minor_ref, int minor );
  624.  
  625.     // ---------------------- Public idGameLocal Interface -------------------
  626.  
  627.     void                    Printf( const char *fmt, ... ) const;
  628.     void                    DPrintf( const char *fmt, ... ) const;
  629.     void                    Warning( const char *fmt, ... ) const;
  630.     void                    DWarning( const char *fmt, ... ) const;
  631.     void                    Error( const char *fmt, ... ) const;
  632.  
  633.                             // Initializes all map variables common to both save games and spawned games
  634.     void                    LoadMap( const char *mapName, int randseed );
  635.  
  636.     void                    LocalMapRestart( int instance = -1 );
  637.     void                    MapRestart( int instance = -1 );
  638.     static void                VerifyServerSettings_f( const idCmdArgs &args );
  639.     static void                MapRestart_f( const idCmdArgs &args );
  640.     bool                    NextMap( void );    // returns wether serverinfo settings have been modified
  641.     static void                NextMap_f( const idCmdArgs &args );
  642.  
  643.     idMapFile *                GetLevelMap( void );
  644.     const char *            GetMapName( void ) const;
  645.  
  646.     int                        NumAAS( void ) const;
  647.     idAAS *                    GetAAS( int num ) const;
  648.     idAAS *                    GetAAS( const char *name ) const;
  649. // RAVEN BEGIN
  650. // jscott: added accessor for memory tracking
  651.     int                        GetNumAAS( void ) const { return( aasList.Num() ); }
  652. // RAVEN END
  653.     void                    SetAASAreaState( const idBounds &bounds, const int areaContents, bool closed );
  654.     aasHandle_t                AddAASObstacle( const idBounds &bounds );
  655.     void                    RemoveAASObstacle( const aasHandle_t handle );
  656.     void                    RemoveAllAASObstacles( void );
  657. // RAVEN BEGIN
  658. // mwhitlock: added entity memory usage stuff.
  659.     size_t                    GetEntityMemoryUsage ( void ) const;
  660. // RAVEN END
  661.     bool                    CheatsOk( bool requirePlayer = true );
  662.     void                    SetSkill( int value );
  663.     gameState_t                GameState( void ) const;
  664.     void                    SetGameState( gameState_t newState ) { gamestate = newState; }
  665.     idEntity *                SpawnEntityType( const idTypeInfo &classdef, const idDict *args = NULL, bool bIsClientReadSnapshot = false );
  666.     bool                    SpawnEntityDef( const idDict &args, idEntity **ent = NULL, bool setDefaults = true );
  667. // abahr:
  668.     idEntity*                SpawnEntityDef( const char* entityDefName, const idDict* additionalArgs = NULL );
  669.     template< class type >
  670.     type*                    SpawnSafeEntityDef( const char* entityDefName, const idDict* additionalArgs = NULL );
  671.     int                        GetPreviousTime() const { return previousTime; }
  672. // RAVEN END
  673.     int                        GetSpawnId( const idEntity *ent ) const;
  674.  
  675.     const idDeclEntityDef *    FindEntityDef( const char *name, bool makeDefault = true ) const;
  676.     const idDict *            FindEntityDefDict( const char *name, bool makeDefault = true ) const;
  677.  
  678.     void                    RegisterEntity( idEntity *ent );
  679.     void                    UnregisterEntity( idEntity *ent );
  680.  
  681.     bool                    RequirementMet( idEntity *activator, const idStr &requires, int removeItem );
  682.  
  683. // RAVEN BEGIN
  684. // bdube: client entities
  685.     void                    RegisterClientEntity( rvClientEntity *cent );
  686.     void                    UnregisterClientEntity( rvClientEntity *cent );
  687. // RAVEN END
  688.  
  689.     void                    AlertAI( idEntity *ent );
  690. // RAVEN BEGIN
  691. // bdube: added get alert actor
  692.     idActor *                GetAlertActor( void );
  693.     idEntity *                GetAlertEntity( void );
  694. // RAVEN END
  695.  
  696.  
  697.     bool                    InPlayerPVS( idEntity *ent ) const;
  698.     bool                    InPlayerConnectedArea( idEntity *ent ) const;
  699.  
  700.     void                    SetCamera( idCamera *cam );
  701.     idCamera *                GetCamera( void ) const;
  702.     bool                    SkipCinematic( void );
  703.  
  704. // RAVEN BEGIN
  705. // jscott: for portal skies
  706.     idCamera                *GetPortalSky( void ) const;
  707.     void                    SetPortalSky( idCamera *cam );
  708. // RAVEN END
  709.  
  710.     void                    CalcFov( float base_fov, float &fov_x, float &fov_y ) const;
  711.  
  712.     void                    AddEntityToHash( const char *name, idEntity *ent );
  713.     bool                    RemoveEntityFromHash( const char *name, idEntity *ent );
  714.     int                        GetTargets( const idDict &args, idList< idEntityPtr<idEntity> > &list, const char *ref ) const;
  715.  
  716.                             // returns the master entity of a trace.  for example, if the trace entity is the player's head, it will return the player.
  717.     idEntity *                GetTraceEntity( const trace_t &trace ) const;
  718.  
  719.     static void                ArgCompletion_EntityName( const idCmdArgs &args, void(*callback)( const char *s ) );
  720.     idEntity *                FindTraceEntity( idVec3 start, idVec3 end, const idTypeInfo &c, const idEntity *skip ) const;
  721.     static void                ArgCompletion_AIName( const idCmdArgs &args, void(*callback)( const char *s ) );
  722.  
  723. //RAVEN BEGIN
  724. // bgeisler: added, I don't want to have to do this work myself every single time I have an entityNumber
  725.     idEntity *                FindEntity( int entityNumber )    { return ((entityNumber >= 0 && entityNumber < MAX_GENTITIES) ? entities[entityNumber] : NULL); }
  726. //RAVEN BEGIN
  727.  
  728.     idEntity *                FindEntity( const char *name ) const;
  729.     idEntity *                FindEntityUsingDef( idEntity *from, const char *match ) const;
  730.     int                        EntitiesWithinRadius( const idVec3 org, float radius, idEntity **entityList, int maxCount ) const;
  731.  
  732.     void                    KillBox( idEntity *ent, bool catch_teleport = false );
  733.     void                    RadiusPush( const idVec3 &origin, const float radius, const float push, const idEntity *inflictor, const idEntity *ignore, float inflictorScale, const bool quake );
  734. // RAVEN BEGIN
  735. // ddynerman: return number of people damaged
  736.     void                    RadiusDamage( const idVec3 &origin, idEntity *inflictor, idEntity *attacker, idEntity *ignoreDamage, idEntity *ignorePush, const char *damageDefName, float dmgPower = 1.0f, int* hitCount = NULL );
  737. // bdube: inflictor
  738.     void                    RadiusPushClipModel( idEntity* inflictor, const idVec3 &origin, const float push, const idClipModel *clipModel );
  739. // RAVEN END
  740.  
  741.     void                    ProjectDecal( const idVec3 &origin, const idVec3 &dir, float depth, bool parallel, float size, const char *material, float angle = 0 );
  742. // RAVEN BEGIN
  743. // ddynerman: multiple collision worlds
  744.     void                    BloodSplat( const idEntity* ent, const idVec3 &origin, const idVec3 &dir, float size, const char *material );
  745. // RAVEN END
  746.  
  747.     void                    CallFrameCommand( idEntity *ent, const function_t *frameCommand );
  748. // RAVEN BEGIN
  749. // bdube: added script object frame commands
  750.     void                    CallFrameCommand( idScriptObject* obj, const function_t* frameCommand );
  751.     void                    CallFrameCommand( idEntity* ent, const char* frameCommand );
  752. // RAVEN END    
  753.  
  754.     void                    CallObjectFrameCommand( idEntity *ent, const char *frameCommand );
  755.  
  756.     const idVec3 &            GetGravity( void ) const;
  757.  
  758.     // added the following to assist licensees with merge issues
  759.     int                        GetFrameNum() const { return framenum; }
  760.     int                        GetTime() const { return time; }
  761.     int                        GetMSec() const { return msec; }
  762.     int                        GetMHz() const { return mHz; }
  763.  
  764.     int                        GetNextClientNum( int current ) const;
  765.     idPlayer *                GetClientByNum( int current ) const;
  766.     idPlayer *                GetClientByName( const char *name ) const;
  767.     idPlayer *                GetClientByCmdArgs( const idCmdArgs &args ) const;
  768.     int                        GetClientNumByName( const char *name ) const;
  769.  
  770.     idPlayer *                GetLocalPlayer() const;
  771.     
  772. // RAVEN BEGIN
  773. // jshepard: update player data after main menu close
  774.     void                    UpdatePlayerPostMainMenu();
  775.  
  776. // bdube: added
  777.     int                        GetSpawnCount ( void ) const;
  778.     void                    SetSpawnCount ( int newSpawnCount ) { spawnCount = newSpawnCount; }
  779. // ddynerman: team type
  780.     bool                    IsTeamGame ( void ) const;
  781. // RAVEN END    
  782.     
  783.     void                    SpreadLocations();
  784.     idLocationEntity *        LocationForPoint( const idVec3 &point );    // May return NULL
  785. // RAVEN BEGIN
  786. // bdube: added
  787.     idLocationEntity*        AddLocation                ( const idVec3& point, const char* name );
  788. // ddynerman: new gametype specific spawn code
  789.     idEntity*                SelectSpawnPoint( idPlayer* player );
  790.     void                    UpdateForwardSpawns( rvCTFAssaultPlayerStart* point, int team );
  791.     void                    ClearForwardSpawns( void );
  792. // RAVEN END
  793.  
  794.     void                    SetPortalState( qhandle_t portal, int blockingBits );
  795.     void                    ServerSendChatMessage( int to, const char *name, const char *text, const char *parm = "" );
  796.  
  797.     void                    SetGlobalMaterial( const idMaterial *mat );
  798.     const idMaterial *        GetGlobalMaterial();
  799.  
  800.     void                    SetGibTime( int _time ) { nextGibTime = _time; }
  801.     int                        GetGibTime() { return nextGibTime; }
  802.  
  803.     bool                    NeedRestart();
  804.  
  805. // RAVEN BEGIN
  806. // jshepard: update end of level on player hud
  807.     void                    UpdateEndLevel();
  808. // MCG: added whizz-by sound
  809.     void                    CheckPlayerWhizzBy    ( idVec3 start, idVec3 end, idEntity* hitEnt, idEntity *attacker );
  810. // bdube: added hitscan
  811. // twhitaker: added additionalIgnore parameter
  812.     idEntity*                HitScan                ( const idDict& hitscanDef, const idVec3& origin, const idVec3& dir, const idVec3& fxOrigin, idEntity* owner = NULL, bool noFX = false, float damageScale = 1.0f, idEntity * additionalIgnore = NULL, int *areas = NULL );
  813. // bdube: added effect calls
  814.     virtual rvClientEffect*    PlayEffect            ( const idDecl *effect, const idVec3& origin, const idMat3& axis, bool loop = false, const idVec3& endOrigin = vec3_origin, bool broadcast = false, effectCategory_t category = EC_IGNORE, const idVec4& effectTint = vec4_one );
  815.     rvClientEffect*            PlayEffect            ( const idDict& args, const char* effectName, const idVec3& origin, const idMat3& axis, bool loop = false, const idVec3& endOrigin = vec3_origin, bool broadcast = false, effectCategory_t category = EC_IGNORE, const idVec4& effectTint = vec4_one );
  816.     const idDecl            *GetEffect            ( const idDict& args, const char* effectName, const rvDeclMatType* materialType = NULL );
  817.  
  818.     idList<idEntity*>        ambientLights; // lights that cast ambient
  819.  
  820. // ddynerman:    multiple collision world - game collision wrapper functions to
  821. //                use the correct idClip
  822. //                ---------------------------------------------------------------
  823. //                These are wrapper functions around idClip collision detection 
  824. //                functions.  They expose the collision detection engine to the 
  825. //                game code, but do collision world determination in one spot.
  826. //              'ent' refers to the entity we want collision information about
  827.     bool                    Translation    ( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity, const idEntity *passEntity2 = 0 );
  828.     bool                    Rotation    ( const idEntity* ent, trace_t &results, const idVec3 &start, const idRotation &rotation, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity );
  829.     bool                    Motion        ( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idRotation &rotation, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity );
  830.     int                        Contacts    ( const idEntity* ent, contactInfo_t *contacts, const int maxContacts, const idVec3 &start, const idVec6 &dir, const float depth, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity );
  831.     int                        Contents    ( const idEntity* ent, const idVec3 &start, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity, idEntity **touchedEntity = NULL );
  832.     // special case translations versus the rest of the world
  833.     bool                    TracePoint    ( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, int contentMask, const idEntity *passEntity );
  834.     bool                    TraceBounds    ( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idBounds &bounds, int contentMask, const idEntity *passEntity );
  835.     // clip versus a specific model
  836.     void                    TranslationModel( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, idCollisionModel *model, const idVec3 &modelOrigin, const idMat3 &modelAxis );
  837.     void                    RotationModel    ( const idEntity* ent, trace_t &results, const idVec3 &start, const idRotation &rotation, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, idCollisionModel *model, const idVec3 &modelOrigin, const idMat3 &modelAxis );
  838.     int                        ContactsModel    ( const idEntity* ent, contactInfo_t *contacts, const int maxContacts, const idVec3 &start, const idVec6 &dir, const float depth, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, idCollisionModel *model, const idVec3 &modelOrigin, const idMat3 &modelAxis );
  839.     int                        ContentsModel    ( const idEntity* ent, const idVec3 &start, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, idCollisionModel *model, const idVec3 &modelOrigin, const idMat3 &modelAxis );
  840.     // clip versus all entities but not the world
  841.     void                    TranslationEntities( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity, const idEntity *passEntity2 = 0 );
  842.     // get a contact feature
  843.     bool                    GetModelContactFeature( const idEntity* ent, const contactInfo_t &contact, const idClipModel *clipModel, idFixedWinding &winding ) const;
  844.     // get entities/clip models within or touching the given bounds
  845.     int                        EntitiesTouchingBounds    ( const idEntity* ent, const idBounds &bounds, int contentMask, idEntity **entityList, int maxCount ) const;
  846.     int                        ClipModelsTouchingBounds( const idEntity* ent, const idBounds &bounds, int contentMask, idClipModel **clipModelList, int maxCount ) const;
  847.     int                        PlayersTouchingBounds    ( const idEntity* ent, const idBounds &bounds, int contentMask, idPlayer **entityList, int maxCount ) const;
  848.     const idBounds &        GetWorldBounds( const idEntity* ent ) const;
  849.  
  850.     void                    Link( idClipModel* clip, idEntity *ent, int newId, const idVec3 &newOrigin, const idMat3 &newAxis, int renderModelHandle = -1 );
  851.  
  852.     idClip*                    GetEntityClipWorld( const idEntity* ent );
  853.     const idClip*            GetEntityClipWorld( const idEntity* ent ) const;
  854.     int                        GetNumMapEntities( void ) const;
  855.  
  856.     int                        AddClipWorld( int id );
  857.     void                    RemoveClipWorld( int id );
  858.     int                        AddInstance( int id = -1, bool deferPopulate = false );
  859.     void                    RemoveInstance( int id );
  860.     rvInstance*                GetInstance( int id );
  861.     int                        GetNumInstances( void );
  862. // ddynerman: multiple game instances
  863.     void                    SpawnMapEntities( int instance = 0, unsigned short* entityNumIn = NULL, unsigned short* entityNumOut = NULL, int* startSpawnCount = NULL );
  864.     void                    InstanceClear( int instance );
  865. // ddynerman: utility function
  866.     virtual const char*        GetLongGametypeName( const char* gametype );
  867.     virtual void            ReceiveRemoteConsoleOutput( const char* output );
  868.     bool                    IsFlagGameType( void ) { return (gameType == GAME_CTF || gameType == GAME_1F_CTF || gameType == GAME_ARENA_CTF || gameType == GAME_ARENA_1F_CTF); }
  869.  
  870.     // twhitaker: needed this for difficulty settings
  871.     float                    GetDifficultyModifier( void ) { const static float difficulty[] = { -0.3f, 0.0f, 0.4f, 0.8f }; return difficulty[ idMath::ClampInt( 0, 3, g_skill.GetInteger() ) ]; }
  872.  
  873.     bool                    IsMultiplayer( void ) { return isMultiplayer; }
  874.  
  875. // mekberg: added
  876.     bool                    InCinematic( void ) { return inCinematic; }
  877.  
  878.     // mekberg: so ban list can be populated outside of multiplayer game
  879.     void                    PopulateBanList( idUserInterface* hud );
  880. // RAVEN END
  881.  
  882. // RAVEN BEGIN
  883. // mwhitlock: Dynamic memory consolidation
  884. #if defined(_RV_MEM_SYS_SUPPORT)
  885.     virtual void            FlushBeforelevelLoad( void );
  886. #endif
  887. // RAVEN END
  888.  
  889.     void                    ServerSendInstanceReliableMessageExcluding( const idEntity* owner, int excludeClient, const idBitMsg& msg );
  890.     void                    ServerSendInstanceReliableMessage( const idEntity* owner, int clientNum, const idBitMsg& msg );    
  891.  
  892.     void                    SendUnreliableMessage( const idBitMsg &msg, const int clientNum );
  893.     // note: local client on dedicated server is always excluded
  894.     void                    SendUnreliableMessagePVS( const idBitMsg &msg, const idEntity *instanceEnt, int area1 = -1, int area2 = -1 );
  895.  
  896.     demoState_t                GetDemoState( void ) const { return demoState; }
  897.  
  898.     /*
  899.     do not synchronize implicit decls over the network
  900.     implicit decls are created when loading sounds and materials that don't have an explicit entry in the def files
  901.     clients and server may load those in different orders in a same map, or even join in with different orders because of different map histories before this game
  902.     in D3 we maintain remap tables, but it's much better to have tighter multiplayer assets so we have no need at all
  903.     still, you want to catch when bad things happen, so indexes should ALL be read and written through these functions
  904.     */
  905.     static void                WriteDecl( idBitMsg &msg, const idDecl *decl );
  906.     static const idDecl*    ReadDecl( const idBitMsg &msg, declType_t type );
  907.     static void                WriteDecl( idBitMsgDelta &msg, const idDecl *decl );
  908.     static const idDecl*    ReadDecl( const idBitMsgDelta &msg, declType_t type );
  909.  
  910. private:
  911. // RAVEN BEGIN
  912. // ddynerman: multiple instance for MP
  913.     idList<idClip*>            clip;                    // collision detection
  914.     idList<rvInstance*>        instances;
  915. // RAVEN END
  916.  
  917.     idStr                    mapFileName;            // name of the map, empty string if no map loaded
  918.     idMapFile *                mapFile;                // will be NULL during the game unless in-game editing is used
  919.     bool                    mapCycleLoaded;
  920.  
  921.     int                        spawnCount;
  922.     bool                    isMapEntity[ MAX_GENTITIES ]; // it's handy to know which entities are part of the map
  923. // RAVEN BEGIN
  924. // bdube: client entities    
  925.     int                        clientSpawnCount;
  926. // RAVEN END
  927.  
  928.     idLocationEntity **        locationEntities;        // for location names, etc
  929.  
  930.     idCamera *                camera;
  931.     const idMaterial *        globalMaterial;            // for overriding everything
  932.  
  933. // RAVEN BEGIN
  934. // jscott: for portal skies
  935.     idCamera                *portalSky;
  936.     bool                    portalSkyVisible;
  937. // RAVEN END
  938.  
  939.     idList<idAAS *>            aasList;                // area system
  940.     idStrList                aasNames;
  941.  
  942. // RAVEN BEGIN
  943. // bdube: GetAlertActor
  944.     idEntityPtr<idActor>    lastAIAlertActor;
  945.     int                        lastAIAlertActorTime;
  946.     idEntityPtr<idEntity>    lastAIAlertEntity;
  947.     int                        lastAIAlertEntityTime;
  948. // RAVEN END
  949.  
  950.     idDict                    spawnArgs;                // spawn args used during entity spawning  FIXME: shouldn't be necessary anymore
  951. // RAVEN BEGIN
  952. // nmckenzie:
  953.     const idDeclEntityDef *    spawnOverrides;
  954. // RAVEN END
  955.  
  956.     pvsHandle_t                playerPVS;                // merged pvs of all players
  957.     bool                    freePlayerPVS;            // tracks if playerPVS needs to be released
  958.     pvsHandle_t                playerConnectedAreas;    // all areas connected to any player area
  959.  
  960.     idVec3                    gravity;                // global gravity vector
  961.     gameState_t                gamestate;                // keeps track of whether we're spawning, shutting down, or normal gameplay
  962.     bool                    influenceActive;        // true when a phantasm is happening
  963.     int                        nextGibTime;
  964.  
  965.     entityState_t *            clientEntityStates[MAX_CLIENTS][MAX_GENTITIES];
  966.     int                        clientPVS[MAX_CLIENTS][ENTITY_PVS_SIZE];
  967.     snapshot_t *            clientSnapshots[MAX_CLIENTS];
  968. // RAVEN BEGIN
  969. // jnewquist: Mark memory tags for idBlockAlloc
  970.     idBlockAlloc<entityState_t,256,MA_ENTITY> entityStateAllocator;
  971.     idBlockAlloc<snapshot_t,64,MA_ENTITY> snapshotAllocator;
  972. // RAVEN END
  973.  
  974.     idEventQueue            eventQueue;
  975.  
  976.     idList<idPlayerStart*> spawnSpots;
  977. // RAVEN BEGIN
  978. // ddynerman: two lists to hold team spawn points for team based games
  979.     idList<idPlayerStart*> teamSpawnSpots[TEAM_MAX];    
  980.     idList<idPlayerStart*> teamForwardSpawnSpots[TEAM_MAX]; // forward spawn positions, used in CTF
  981. // RAVEN END
  982.  
  983.     idDict                    newInfo;
  984.  
  985.     idStrList                shakeSounds;
  986.  
  987.     byte                    lagometer[ LAGO_IMG_HEIGHT ][ LAGO_IMG_WIDTH ][ 4 ];
  988.  
  989.     idMsgQueue                unreliableMessages[ MAX_CLIENTS ];
  990.  
  991.     demoState_t                demoState;
  992.  
  993.     void                    Clear( void );
  994.                             // returns true if the entity shouldn't be spawned at all in this game type or difficulty level
  995.     bool                    InhibitEntitySpawn( idDict &spawnArgs );
  996.                             // spawn entities from the map file
  997.                             // commons used by init, shutdown, and restart
  998.     void                    MapPopulate( int instance = -1 );
  999.     void                    MapClear( bool clearClients, int instance = -1 );
  1000.  
  1001. // RAVEN BEGIN
  1002. // jscott: made public
  1003. public:
  1004.     pvsHandle_t                GetClientPVS( idPlayer *player, pvsType_t type );
  1005.  
  1006. private:
  1007.     bool                    SetupPortalSkyPVS( idPlayer *player );
  1008. // RAVEN END
  1009.     void                    SetupPlayerPVS( void );
  1010.     void                    FreePlayerPVS( void );
  1011.     void                    UpdateGravity( void );
  1012.     void                    SortActiveEntityList( void );
  1013.     void                    ShowTargets( void );
  1014.     void                    RunDebugInfo( void );
  1015.  
  1016.     void                    InitScriptForMap( void );
  1017.     void                    InitConsoleCommands( void );
  1018.     void                    ShutdownConsoleCommands( void );
  1019.  
  1020.     void                    InitAsyncNetwork( void );
  1021.     void                    ShutdownAsyncNetwork( void );
  1022.     void                    InitLocalClient( int clientNum );
  1023.     void                    FreeSnapshotsOlderThanSequence( int clientNum, int sequence );
  1024.     bool                    ApplySnapshot( int clientNum, int sequence );
  1025.     void                    WriteGameStateToSnapshot( idBitMsgDelta &msg ) const;
  1026.     void                    ReadGameStateFromSnapshot( const idBitMsgDelta &msg );
  1027.     void                    NetworkEventWarning( const entityNetEvent_t *event, const char *fmt, ... ) id_attribute((format(printf,3,4)));
  1028.     void                    ServerProcessEntityNetworkEventQueue( void );
  1029.     void                    ClientProcessEntityNetworkEventQueue( void );
  1030.     void                    ClientShowSnapshot( int clientNum ) const;
  1031.     void                    SetGameType( void );
  1032. // RAVEN BEGIN
  1033. // ddynerman: gametype specific spawn code
  1034.     void                    InitializeSpawns( void );
  1035.     idList<spawnSpot_t>        WeightSpawnSpots( idPlayer* player );
  1036.     idEntity*                SpawnInRange( idList<spawnSpot_t>& spawns, idEntity* player, int lowIndex, int highIndex, int maxIndex );
  1037. // RAVEN END
  1038.     static int                sortSpawnPoints( const void *ptr1, const void *ptr2 );
  1039.  
  1040.     void                    DumpOggSounds( void );
  1041.     void                    GetShakeSounds( const idDict *dict );
  1042.     idStr                    GetBestGameType( const char* map, const char* gametype );
  1043.  
  1044.     void                    Tokenize( idStrList &out, const char *in );
  1045.  
  1046. // RAVEN BEGIN
  1047. // ddynerman: multiple clip worlds
  1048.     void                    ShutdownInstances( void );
  1049. // shouchard:  ban list support (lives in game_network.cpp)
  1050.  
  1051.     void                    UpdateLagometer( int aheadOfServer, int dupeUsercmds );
  1052.  
  1053.     void                    ClientReadUnreliableMessages( const idBitMsg &msg );
  1054.     void                    ProcessUnreliableMessage( const idBitMsg &msg );
  1055.  
  1056.     void                    UpdateClientsPVS( void );
  1057.  
  1058. public:
  1059.     void                    LoadBanList();
  1060.     void                    SaveBanList();
  1061.     void                    FlushBanList();
  1062.     bool                    IsPlayerBanned( const char *name );
  1063.     bool                    IsGuidBanned( const char *guid );
  1064.     void                    AddGuidToBanList( const char *guid );
  1065.     void                    RemoveGuidFromBanList( const char *guid );
  1066.     virtual void            RegisterClientGuid( int clientNum, const char *guid );
  1067.  
  1068.     int                        GetBanListCount();
  1069.     const mpBanInfo_t*        GetBanListEntry( int entry );    // returns client name
  1070.     const char*                GetGuidByClientNum( int clientNum );    // returns GUID
  1071.     int                        GetClientNumByGuid( const char* );        // returns clientNum
  1072.  
  1073. // mekberg: get and send ban list
  1074.     void                    ServerSendBanList( int clientNum );
  1075.  
  1076. protected:
  1077.     char                    clientGuids[ MAX_CLIENTS ][ CLIENT_GUID_LENGTH ];
  1078.     idList<mpBanInfo_t>        banList;
  1079.     bool                    banListLoaded;
  1080.     bool                    banListChanged;
  1081. // RAVEN END
  1082. };
  1083.  
  1084. // RAVEN BEGIN
  1085. // bdube: inlines
  1086. ID_INLINE rvClientEffect* idGameLocal::PlayEffect ( const idDict& args, const char* effectName, const idVec3& origin, const idMat3& axis, bool loop, const idVec3& endOrigin, bool broadcast, effectCategory_t category, const idVec4& effectTint ) {
  1087.     return PlayEffect ( GetEffect ( args, effectName ), origin, axis, loop, endOrigin, broadcast, category, effectTint );
  1088. }
  1089.  
  1090. ID_INLINE bool idGameLocal::IsTeamGame ( void ) const {
  1091.     return ( isMultiplayer && ( gameType == GAME_CTF || gameType == GAME_TDM || gameType == GAME_1F_CTF || gameType == GAME_ARENA_CTF ) );
  1092. }
  1093.  
  1094. ID_INLINE int idGameLocal::GetNumMapEntities( void ) const {
  1095.     if( mapFile == NULL ) {
  1096.         return -1;
  1097.     } else {
  1098.         return mapFile->GetNumEntities();
  1099.     }
  1100. }
  1101.  
  1102. ID_INLINE rvInstance* idGameLocal::GetInstance( int id ) {
  1103.     return instances[ id ];
  1104. }
  1105.  
  1106. ID_INLINE int idGameLocal::GetNumInstances( void ) {
  1107.     return instances.Num();
  1108. }
  1109.  
  1110. ID_INLINE void idGameLocal::ReceiveRemoteConsoleOutput( const char* output ) {
  1111.     if( isMultiplayer ) {
  1112.         mpGame.ReceiveRemoteConsoleOutput( output );
  1113.     }
  1114. }
  1115.  
  1116. // abahr:
  1117. template< class type >
  1118. type* idGameLocal::SpawnSafeEntityDef( const char* entityDefName, const idDict* additionalArgs ) {
  1119.     idEntity* entity = SpawnEntityDef( entityDefName, additionalArgs );
  1120.     if( !entity ) {
  1121.         return NULL;
  1122.     }
  1123.  
  1124.     if( !entity->IsType(type::GetClassType()) ) {
  1125.         entity->PostEventMS( &EV_Remove, 0 );
  1126.         return NULL;
  1127.     }
  1128.  
  1129.     return static_cast<type*>( entity );
  1130. }
  1131. // RAVEN END
  1132.  
  1133. //============================================================================
  1134.  
  1135. extern idGameLocal            gameLocal;
  1136. // RAVEN BEGIN
  1137. // jsinger: animationLib changed to a pointer to prevent it from allocating memory
  1138. //          before the unified allocator is initialized
  1139. extern idAnimManager        *animationLib;
  1140. // RAVEN END
  1141.  
  1142. //============================================================================
  1143.  
  1144. ID_INLINE void idGameLocal::WriteDecl( idBitMsg &msg, const idDecl *decl ) {
  1145.     assert( decl );
  1146.     if ( decl->IsImplicit() ) {
  1147.         gameLocal.Error( "WriteDecl: %s decl %s ( index %d ) is implicit", declManager->GetDeclNameFromType( decl->GetType() ), decl->GetName(), decl->Index() );
  1148.     }
  1149.     msg.WriteLong( decl->Index() );
  1150. }
  1151.  
  1152. ID_INLINE const idDecl* idGameLocal::ReadDecl( const idBitMsg &msg, declType_t type ) {
  1153.     int index = msg.ReadLong();
  1154.     const idDecl *decl = declManager->DeclByIndex( type, index );
  1155.     if ( !decl ) {
  1156.         gameLocal.Error( "ReadDecl: NULL %s decl at index %d", declManager->GetDeclNameFromType( type ), index );
  1157.     }
  1158.     if ( decl->IsImplicit() ) {
  1159.         gameLocal.Error( "ReadDecl: %s decl %s ( index %d ) is implicit", declManager->GetDeclNameFromType( type ), decl->GetName(), decl->Index() );
  1160.     }
  1161.     return decl;
  1162. }
  1163.  
  1164. ID_INLINE void idGameLocal::WriteDecl( idBitMsgDelta &msg, const idDecl *decl ) {
  1165.     assert( decl );
  1166.     if ( decl->IsImplicit() ) {
  1167.         gameLocal.Error( "WriteDecl: %s decl %s ( index %d ) is implicit", declManager->GetDeclNameFromType( decl->GetType() ), decl->GetName(), decl->Index() );
  1168.     }
  1169.     msg.WriteLong( decl->Index() );
  1170. }
  1171.  
  1172. ID_INLINE const idDecl* idGameLocal::ReadDecl( const idBitMsgDelta &msg, declType_t type ) {
  1173.     int index = msg.ReadLong();
  1174.     const idDecl *decl = declManager->DeclByIndex( type, index );
  1175.     if ( !decl ) {
  1176.         gameLocal.Error( "ReadDecl: NULL %s decl at index %d", declManager->GetDeclNameFromType( type ), index );
  1177.     }
  1178.     if ( decl->IsImplicit() ) {
  1179.         gameLocal.Error( "ReadDecl: %s decl %s ( index %d ) is implicit", declManager->GetDeclNameFromType( type ), decl->GetName(), decl->Index() );
  1180.     }
  1181.     return decl;
  1182. }
  1183.  
  1184. //============================================================================
  1185.  
  1186. class idGameError : public idException {
  1187. public:
  1188.     idGameError( const char *text ) : idException( text ) {}
  1189. };
  1190.  
  1191. //============================================================================
  1192.  
  1193.  
  1194. //
  1195. // these defines work for all startsounds from all entity types
  1196. // make sure to change script/doom_defs.script if you add any channels, or change their order
  1197. //
  1198. typedef enum {
  1199.     SND_CHANNEL_ANY = SCHANNEL_ANY,
  1200.     SND_CHANNEL_VOICE = SCHANNEL_ONE,
  1201.     SND_CHANNEL_VOICE2,
  1202.     SND_CHANNEL_BODY,
  1203.     SND_CHANNEL_BODY2,
  1204.     SND_CHANNEL_BODY3,
  1205.     SND_CHANNEL_WEAPON,
  1206.     SND_CHANNEL_ITEM,
  1207.     SND_CHANNEL_HEART,
  1208.     SND_CHANNEL_DEMONIC,
  1209.     SND_CHANNEL_RADIO,
  1210.  
  1211.     // internal use only.  not exposed to script or framecommands.
  1212.     SND_CHANNEL_AMBIENT,
  1213.     SND_CHANNEL_DAMAGE
  1214.  
  1215. // RAVEN BEGIN
  1216. // bdube: added custom to tell us where the end of the predefined list is
  1217.     ,
  1218.     SND_CHANNEL_POWERUP,
  1219.     SND_CHANNEL_POWERUP_IDLE,
  1220.     SND_CHANNEL_MP_ANNOUNCER,
  1221.     SND_CHANNEL_CUSTOM
  1222. // RAVEN END
  1223. } gameSoundChannel_t;
  1224.  
  1225. // content masks
  1226. #define    MASK_ALL                    (-1)
  1227. #define    MASK_SOLID                    (CONTENTS_SOLID)
  1228. #define    MASK_MONSTERSOLID            (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_BODY)
  1229. #define    MASK_PLAYERSOLID            (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY)
  1230. #define    MASK_DEADSOLID                (CONTENTS_SOLID|CONTENTS_PLAYERCLIP)
  1231. #define    MASK_WATER                    (CONTENTS_WATER)
  1232. #define    MASK_OPAQUE                    (CONTENTS_OPAQUE|CONTENTS_SIGHTCLIP)
  1233. #define    MASK_SHOT_RENDERMODEL        (CONTENTS_SOLID|CONTENTS_RENDERMODEL)
  1234. #define    MASK_SHOT_BOUNDINGBOX        (CONTENTS_SOLID|CONTENTS_BODY)
  1235. #define MASK_LARGESHOT_RENDERMODEL    (CONTENTS_SOLID|CONTENTS_RENDERMODEL|CONTENTS_LARGESHOTCLIP)
  1236. #define MASK_LARGESHOT_BOUNDINGBOX    (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_LARGESHOTCLIP)
  1237. #define MASK_DMGSOLID                (CONTENTS_SOLID|CONTENTS_LARGESHOTCLIP)
  1238.  
  1239. // RAVEN BEGIN
  1240. // creed: added monster clip
  1241. #define    MASK_MONSTERCLIP            (CONTENTS_SOLID|CONTENTS_MONSTERCLIP)
  1242. // RAVEN END
  1243.  
  1244. const float DEFAULT_GRAVITY            = 1066.0f;
  1245. const float DEFAULT_GRAVITY_MP        = 800.0f;
  1246.  
  1247. #define DEFAULT_GRAVITY_STRING        "1066"
  1248. #define DEFAULT_MP_GRAVITY_STRING    "800"
  1249. const idVec3 DEFAULT_GRAVITY_VEC3( 0, 0, -DEFAULT_GRAVITY );
  1250.  
  1251. const int    CINEMATIC_SKIP_DELAY    = SEC2MS( 2.0f );
  1252.  
  1253. //============================================================================
  1254.  
  1255. #include "physics/Force.h"
  1256. #include "physics/Force_Constant.h"
  1257. #include "physics/Force_Drag.h"
  1258. #include "physics/Force_Field.h"
  1259. #include "physics/Force_Spring.h"
  1260. #include "physics/Physics.h"
  1261. #include "physics/Physics_Static.h"
  1262. #include "physics/Physics_StaticMulti.h"
  1263. #include "physics/Physics_Base.h"
  1264. #include "physics/Physics_Actor.h"
  1265. #include "physics/Physics_Monster.h"
  1266. #include "physics/Physics_Player.h"
  1267. #include "physics/Physics_Parametric.h"
  1268. #include "physics/Physics_RigidBody.h"
  1269. #include "physics/Physics_AF.h"
  1270. #include "physics/Physics_Particle.h"
  1271. #include "physics/Physics_VehicleMonster.h"
  1272. // RAVEN BEGIN
  1273. // bdube: vehicle include needed for actor
  1274. #include "vehicle/VehicleController.h"
  1275.  
  1276. // bdube: client entities
  1277. #include "Entity.h"
  1278. #include "client/ClientEntity.h"
  1279. #include "client/ClientEffect.h"
  1280. #include "client/ClientMoveable.h"
  1281. #include "client/ClientModel.h"
  1282. //#include "SmokeParticles.h"
  1283. #include "Game_Debug.h"
  1284. // ddynerman: icons
  1285. #include "IconManager.h"
  1286. // RAVEN END
  1287. #include "GameEdit.h"
  1288. #include "AF.h"
  1289. #include "IK.h"
  1290. #include "AFEntity.h"
  1291. #include "Misc.h"
  1292. #include "Actor.h"
  1293.  
  1294. // RAVEN BEGIN
  1295. // bdube: included only where needed now
  1296. //#include "Projectile.h"
  1297. #include "Weapon.h"
  1298. // RAVEN END
  1299.  
  1300. // RAVEN BEGIN
  1301. // abahr
  1302. #include "script/ScriptFuncUtility.h"
  1303. // RAVEN END
  1304.  
  1305. #include "Light.h"
  1306. #include "WorldSpawn.h"
  1307. #include "Item.h"
  1308. #include "PlayerView.h"
  1309. // TTimo: moved AI.h up, can't do template instanciation on forward declared-classes
  1310. #include "ai/AI.h"
  1311. #include "Player.h"
  1312. #include "Mover.h"
  1313. // RAVEN BEGIN
  1314. // abahr:
  1315. #include "vehicle/VehicleParts.h"
  1316. #include "vehicle/Vehicle.h"
  1317. #include "SplineMover.h"
  1318. #include "TramGate.h"
  1319. #include "vehicle/VehicleDriver.h"
  1320. // RAVEN END
  1321. #include "Camera.h"
  1322. #include "Moveable.h"
  1323. #include "Target.h"
  1324. #include "Trigger.h"
  1325. #include "Sound.h"
  1326. #include "SecurityCamera.h"
  1327. #include "BrittleFracture.h"
  1328.  
  1329. // RAVEN BEGIN
  1330. // nmckenzie: Reduce dependencies.
  1331. #include "mp/CTF.h"
  1332. #include "mp/stats/StatManager.h"
  1333. #include "mp/Tourney.h"
  1334. #include "Instance.h"
  1335. // RAVEN END
  1336. #include "anim/Anim_Testmodel.h"
  1337.  
  1338. // RAVEN BEGIN
  1339. // jscott: for lip syncing
  1340. #include "LipSync.h"
  1341. // RAVEN END
  1342.  
  1343. #include "script/Script_Compiler.h"
  1344. #include "script/Script_Interpreter.h"
  1345. #include "script/Script_Thread.h"
  1346.  
  1347. #ifdef _XENON
  1348. #define PACIFIER_UPDATE session->PacifierUpdate()
  1349. #else
  1350. #define PACIFIER_UPDATE
  1351. #endif
  1352.  
  1353. #endif    /* !__GAME_LOCAL_H__ */
  1354.