home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / framework / UsercmdGen.h < prev   
C/C++ Source or Header  |  2005-11-14  |  6KB  |  190 lines

  1. // Copyright (C) 2004 Id Software, Inc.
  2. //
  3.  
  4. #ifndef __USERCMDGEN_H__
  5. #define __USERCMDGEN_H__
  6.  
  7. /*
  8. ===============================================================================
  9.  
  10.     Samples a set of user commands from player input.
  11.  
  12. ===============================================================================
  13. */
  14.  
  15. const int USERCMD_HZ_SP            = 60;            // 60 frames per second
  16. const int USERCMD_MSEC_SP        = 1000 / USERCMD_HZ_SP;
  17.  
  18. //const int USERCMD_HZ_MP            = 30;            // 30 frames per second
  19. //const int USERCMD_MSEC_MP        = 1000 / USERCMD_HZ_MP;
  20.  
  21. const int USERCMD_HZ_MP            = 60;            // 60 frames per second
  22. const int USERCMD_MSEC_MP        = 1000 / USERCMD_HZ_MP;
  23.  
  24. // usercmd_t->button bits
  25. const int BUTTON_ATTACK            = BIT(0);
  26. const int BUTTON_RUN            = BIT(1);
  27. const int BUTTON_ZOOM            = BIT(2);
  28. const int BUTTON_SCORES            = BIT(3);
  29. const int BUTTON_MLOOK            = BIT(4);
  30. // RAVEN BEGIN
  31. // ddynerman: stats
  32. const int BUTTON_INGAMESTATS    = BIT(5);
  33. // jscott: for voicechat
  34. const int BUTTON_VOICECHAT        = BIT(6);
  35. // ddynerman: tourney display
  36. const int BUTTON_TOURNEY        = BIT(7);
  37. // twhitaker: strafe
  38. const int BUTTON_STRAFE            = BIT(8);
  39. // RAVEN END
  40.  
  41.  
  42. // usercmd_t->impulse commands
  43. const int IMPULSE_0                = 0;            // weap 0
  44. const int IMPULSE_1                = 1;            // weap 1
  45. const int IMPULSE_2                = 2;            // weap 2
  46. const int IMPULSE_3                = 3;            // weap 3
  47. const int IMPULSE_4                = 4;            // weap 4
  48. const int IMPULSE_5                = 5;            // weap 5
  49. const int IMPULSE_6                = 6;            // weap 6
  50. const int IMPULSE_7                = 7;            // weap 7
  51. const int IMPULSE_8                = 8;            // weap 8
  52. const int IMPULSE_9                = 9;            // weap 9
  53. const int IMPULSE_10            = 10;            // weap 10
  54. const int IMPULSE_11            = 11;            // weap 11
  55. const int IMPULSE_12            = 12;            // weap 12
  56. const int IMPULSE_13            = 13;            // weap reload
  57. const int IMPULSE_14            = 14;            // weap next
  58. const int IMPULSE_15            = 15;            // weap prev
  59. const int IMPULSE_16            = 16;            // <unused>
  60. const int IMPULSE_17            = 17;            // ready to play ( toggles ui_ready )
  61. const int IMPULSE_18            = 18;            // center view
  62. const int IMPULSE_19            = 19;            // show PDA/INV/MAP
  63. const int IMPULSE_20            = 20;            // toggle team ( toggles ui_team )
  64. const int IMPULSE_21            = 21;            // tourney toggle waiting room/spec
  65. const int IMPULSE_22            = 22;            // spectate
  66. const int IMPULSE_23            = 23;            // <unused>
  67. const int IMPULSE_24            = 24;            // <unused>
  68. const int IMPULSE_25            = 25;            // <unused>
  69. const int IMPULSE_26            = 26;            // <unused>
  70. const int IMPULSE_27            = 27;            // <unused>
  71. const int IMPULSE_28            = 28;            // vote yes
  72. const int IMPULSE_29            = 29;            // vote no
  73. const int IMPULSE_40            = 40;            // repeast last radio chatter
  74.  
  75. // RAVEN BEGIN
  76. // bdube: added flashlight
  77. const int IMPULSE_50            = 50;            // activate flashlight
  78. const int IMPULSE_51            = 51;            // switch to last weapon
  79. // ddynerman: mp stats
  80. const int IMPULSE_52            = 52;            // mp statistics
  81. // RAVEN END
  82.  
  83.  
  84. // RAVEN BEGIN
  85. // asalmon: impulses for weapons combos for xbox
  86. #ifdef _XBOX
  87. const int IMPULSE_70            = 70;            //Weapon switch up
  88. const int IMPULSE_71            = 71;            //Weapon switch down
  89. const int IMPULSE_72            = 72;            //Weapon switch right
  90. const int IMPULSE_73            = 73;            //Weapon Switch left
  91. #endif
  92. //RAVEN END
  93.  
  94. // usercmd_t->flags
  95. const int UCF_IMPULSE_SEQUENCE    = 0x0001;        // toggled every time an impulse command is sent
  96.  
  97. class usercmd_t {
  98. public:
  99.     int            gameFrame;                        // frame number
  100.     int            gameTime;                        // game time
  101.     int            realTime;                        // real game time
  102.     int            duplicateCount;                    // duplication count for networking
  103. // RAVEN BEGIN
  104. // ddynerman: expand buttons to 2 bytes
  105.     short        buttons;                        // buttons
  106. // RAVEN END
  107.     signed char    forwardmove;                    // forward/backward movement
  108.     signed char    rightmove;                        // left/right movement
  109.     signed char    upmove;                            // up/down movement
  110.     short        angles[3];                        // view angles
  111.     short        mx;                                // mouse delta x
  112.     short        my;                                // mouse delta y
  113.     signed char impulse;                        // impulse command
  114.     byte        flags;                            // additional flags
  115.     int            sequence;                        // just for debugging
  116.  
  117. public:
  118.     void        ByteSwap();                        // on big endian systems, byte swap the shorts and ints
  119.     bool        operator==( const usercmd_t &rhs ) const;
  120. };
  121.  
  122. typedef enum {
  123.     INHIBIT_SESSION = 0,
  124.     INHIBIT_ASYNC
  125. } inhibit_t;
  126.  
  127. const int MAX_BUFFERED_USERCMD = 64;
  128.  
  129. class idUsercmdGen {
  130. public:
  131.     virtual                ~idUsercmdGen( void ) {}
  132.  
  133.     // Sets up all the cvars and console commands.
  134.     virtual    void        Init( void ) = 0;
  135.  
  136.     // Prepares for a new map.
  137.     virtual void        InitForNewMap( void ) = 0;
  138.  
  139.     // Shut down.
  140.     virtual void        Shutdown( void ) = 0;
  141.  
  142.     // Clears all key states and face straight.
  143.     virtual    void        Clear( void ) = 0;
  144.  
  145.     // Clears view angles.
  146.     virtual void        ClearAngles( void ) = 0;
  147.  
  148.     // When the console is down or the menu is up, only emit default usercmd, so the player isn't moving around.
  149.     // Each subsystem (session and game) may want an inhibit will OR the requests.
  150.     virtual void        InhibitUsercmd( inhibit_t subsystem, bool inhibit ) = 0;
  151.  
  152.     // Returns a buffered command for the given game tic.
  153.     virtual usercmd_t    TicCmd( int ticNumber ) = 0;
  154.  
  155.     // Called async at regular intervals.
  156.     virtual    void        UsercmdInterrupt( void ) = 0;
  157.  
  158.     // Set a value that can safely be referenced by UsercmdInterrupt() for each key binding.
  159.     virtual    int            CommandStringUsercmdData( const char *cmdString ) = 0;
  160.  
  161.     // Returns the number of user commands.
  162.     virtual int            GetNumUserCommands( void ) = 0;
  163.  
  164.     // Returns the name of a user command via index.
  165.     virtual const char *GetUserCommandName( int index ) = 0;
  166.  
  167.     // Continuously modified, never reset. For full screen guis.
  168.     virtual void        MouseState( int *x, int *y, int *button, bool *down ) = 0;
  169.  
  170.     // Directly sample a usercmd.
  171.     virtual usercmd_t    GetDirectUsercmd( void ) = 0;
  172.  
  173. //RAVEN BEGIN
  174. //asalmon: slow down the joystick movement for aim assist on xenon
  175.     virtual void        SetSlowJoystick(int slow) = 0;
  176.  
  177. // nrausch: Stuff an arbitrary impulse in, which will override any other impulse this cycle
  178.     virtual void        StuffImpulse( int impulse ) = 0;
  179.  
  180. #ifdef _XENON    
  181.     virtual void        GetInputs( int &y, int &p, int &r, int &f ) = 0;
  182. #endif
  183.  
  184. //RAVEN END
  185. };
  186.  
  187. extern idUsercmdGen    *usercmdGen;
  188.  
  189. #endif /* !__USERCMDGEN_H__ */
  190.