1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __USERCMDGEN_H__
#define __USERCMDGEN_H__
/*
===============================================================================
Samples a set of user commands from player input.
===============================================================================
*/
const int USERCMD_HZ = 60; // 60 frames per second
const int USERCMD_MSEC = 1000 / USERCMD_HZ;
// usercmd_t->button bits
const int BUTTON_ATTACK = BIT(0);
const int BUTTON_RUN = BIT(1);
const int BUTTON_ZOOM = BIT(2);
const int BUTTON_SCORES = BIT(3);
const int BUTTON_MLOOK = BIT(4);
const int BUTTON_5 = BIT(5);
const int BUTTON_6 = BIT(6);
const int BUTTON_7 = BIT(7);
// usercmd_t->impulse commands
const int IMPULSE_0 = 0; // weap 0
const int IMPULSE_1 = 1; // weap 1
const int IMPULSE_2 = 2; // weap 2
const int IMPULSE_3 = 3; // weap 3
const int IMPULSE_4 = 4; // weap 4
const int IMPULSE_5 = 5; // weap 5
const int IMPULSE_6 = 6; // weap 6
const int IMPULSE_7 = 7; // weap 7
const int IMPULSE_8 = 8; // weap 8
const int IMPULSE_9 = 9; // weap 9
const int IMPULSE_10 = 10; // weap 10
const int IMPULSE_11 = 11; // weap 11
const int IMPULSE_12 = 12; // weap 12
const int IMPULSE_13 = 13; // weap reload
const int IMPULSE_14 = 14; // weap next
const int IMPULSE_15 = 15; // weap prev
const int IMPULSE_16 = 16; // <unused>
const int IMPULSE_17 = 17; // ready to play ( toggles ui_ready )
const int IMPULSE_18 = 18; // center view
const int IMPULSE_19 = 19; // show PDA/INV/MAP
const int IMPULSE_20 = 20; // toggle team ( toggles ui_team )
const int IMPULSE_21 = 21; // <unused>
const int IMPULSE_22 = 22; // spectate
const int IMPULSE_23 = 23; // <unused>
const int IMPULSE_24 = 24; // <unused>
const int IMPULSE_25 = 25; // <unused>
const int IMPULSE_26 = 26; // <unused>
const int IMPULSE_27 = 27; // <unused>
const int IMPULSE_28 = 28; // vote yes
const int IMPULSE_29 = 29; // vote no
const int IMPULSE_40 = 40; // use vehicle
// usercmd_t->flags
const int UCF_IMPULSE_SEQUENCE = 0x0001; // toggled every time an impulse command is sent
class usercmd_t {
public:
int gameFrame; // frame number
int gameTime; // game time
int duplicateCount; // duplication count for networking
byte buttons; // buttons
signed char forwardmove; // forward/backward movement
signed char rightmove; // left/right movement
signed char upmove; // up/down movement
short angles[3]; // view angles
short mx; // mouse delta x
short my; // mouse delta y
signed char impulse; // impulse command
byte flags; // additional flags
int sequence; // just for debugging
public:
void ByteSwap(); // on big endian systems, byte swap the shorts and ints
bool operator==( const usercmd_t &rhs ) const;
};
typedef enum {
INHIBIT_SESSION = 0,
INHIBIT_ASYNC
} inhibit_t;
const int MAX_BUFFERED_USERCMD = 64;
class idUsercmdGen {
public:
virtual ~idUsercmdGen( void ) {}
// Sets up all the cvars and console commands.
virtual void Init( void ) = 0;
// Prepares for a new map.
virtual void InitForNewMap( void ) = 0;
// Shut down.
virtual void Shutdown( void ) = 0;
// Clears all key states and face straight.
virtual void Clear( void ) = 0;
// Clears view angles.
virtual void ClearAngles( void ) = 0;
// When the console is down or the menu is up, only emit default usercmd, so the player isn't moving around.
// Each subsystem (session and game) may want an inhibit will OR the requests.
virtual void InhibitUsercmd( inhibit_t subsystem, bool inhibit ) = 0;
// Returns a buffered command for the given game tic.
virtual usercmd_t TicCmd( int ticNumber ) = 0;
// Called async at regular intervals.
virtual void UsercmdInterrupt( void ) = 0;
// Set a value that can safely be referenced by UsercmdInterrupt() for each key binding.
virtual int CommandStringUsercmdData( const char *cmdString ) = 0;
// Returns the number of user commands.
virtual int GetNumUserCommands( void ) = 0;
// Returns the name of a user command via index.
virtual const char *GetUserCommandName( int index ) = 0;
// Continuously modified, never reset. For full screen guis.
virtual void MouseState( int *x, int *y, int *button, bool *down ) = 0;
// Directly sample a button.
virtual int ButtonState( int key ) = 0;
// Directly sample a keystate.
virtual int KeyState( int key ) = 0;
// Directly sample a usercmd.
virtual usercmd_t GetDirectUsercmd( void ) = 0;
};
extern idUsercmdGen *usercmdGen;
#endif /* !__USERCMDGEN_H__ */
|