-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUsercmdGen.h
296 lines (251 loc) · 7.01 KB
/
UsercmdGen.h
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*****************************************************************************
The Dark Mod GPL Source Code
This file is part of the The Dark Mod Source Code, originally based
on the Doom 3 GPL Source Code as published in 2011.
The Dark Mod 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. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#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;
// ButtonState inputs; originally from UsercmdGen.cpp, left out of SDK by accident
// sourced from http://www.doom3world.org/phpbb2/viewtopic.php?f=26&t=18587&p=170143
typedef enum {
UB_NONE,
UB_UP,
UB_DOWN,
UB_LEFT,
UB_RIGHT,
UB_FORWARD,
UB_BACK,
UB_LOOKUP,
UB_LOOKDOWN,
UB_STRAFE,
UB_MOVELEFT,
UB_MOVERIGHT,
UB_BUTTON0,
UB_BUTTON1,
UB_BUTTON2,
UB_BUTTON3,
UB_BUTTON4,
UB_CREEP,
UB_BUTTON6,
UB_BUTTON7,
UB_ATTACK,
UB_SPEED,
UB_PARRY_MANIPULATE,
UB_SHOWSCORES,
UB_MLOOK,
#ifdef QUAKE4
UB_INGAMESTATS,
UB_VOICECHAT,
UB_TOURNEY,
#endif//QUAKE4
UB_WEAPON0,
UB_WEAPON1,
UB_WEAPON2,
UB_WEAPON3,
UB_WEAPON4,
UB_WEAPON5,
UB_WEAPON6,
UB_WEAPON7,
UB_WEAPON8,
UB_WEAPON9,
UB_WEAPON10,
UB_WEAPON11,
UB_WEAPON12,
UB_RELOAD,
UB_WEAPON_NEXT,
UB_WEAPON_PREV,
UB_IMPULSE16,
UB_READY,
UB_CENTER_VIEW,
UB_OBJECTIVES,
UB_IMPULSE20,
UB_IMPULSE21,
UB_IMPULSE22,
UB_CROUCH,
UB_MANTLE,
UB_IMPULSE25,
UB_IMPULSE26,
UB_IMPULSE27,
UB_IMPULSE28,
UB_IMPULSE29,
UB_INVENTORY_GRID,
UB_IMPULSE31,
UB_IMPULSE32,
UB_IMPULSE33,
UB_IMPULSE34,
UB_IMPULSE35,
UB_IMPULSE36,
UB_IMPULSE37,
UB_IMPULSE38,
UB_IMPULSE39,
UB_IMPULSE40,
UB_FROB,
UB_IMPULSE42,
UB_IMPULSE43,
UB_LEAN_FORWARD,
UB_LEAN_LEFT,
UB_LEAN_RIGHT,
UB_INVENTORY_PREV,
UB_INVENTORY_NEXT,
UB_INVENTORY_GROUP_PREV,
UB_INVENTORY_GROUP_NEXT,
UB_INVENTORY_USE,
UB_INVENTORY_DROP,
UB_IMPULSE53,
UB_IMPULSE54,
UB_IMPULSE55,
UB_IMPULSE56,
UB_IMPULSE57,
UB_IMPULSE58,
UB_IMPULSE59,
UB_IMPULSE60,
UB_IMPULSE61,
UB_IMPULSE62,
UB_IMPULSE63,
UB_MAX_BUTTONS
} UserCmdButton;
// 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_CREEP = BIT(5);
const int BUTTON_6 = BIT(6);
const int BUTTON_7 = BIT(7);
// usercmd_t->impulse commands
enum {
IMPULSE_WEAPON0,
IMPULSE_WEAPON1,
IMPULSE_WEAPON2,
IMPULSE_WEAPON3,
IMPULSE_WEAPON4,
IMPULSE_WEAPON5,
IMPULSE_WEAPON6,
IMPULSE_WEAPON7,
IMPULSE_WEAPON8,
IMPULSE_WEAPON9,
IMPULSE_WEAPON10,
IMPULSE_WEAPON11,
IMPULSE_WEAPON12,
IMPULSE_RELOAD,
IMPULSE_WEAPON_NEXT,
IMPULSE_WEAPON_PREV,
IMPULSE_16,
IMPULSE_READY,
IMPULSE_CENTER_VIEW,
IMPULSE_OBJECTIVES,
IMPULSE_20,
IMPULSE_21,
IMPULSE_22,
IMPULSE_CROUCH,
IMPULSE_MANTLE,
IMPULSE_25,
IMPULSE_26,
IMPULSE_27,
IMPULSE_28,
IMPULSE_29,
IMPULSE_INVENTORY_GRID, // #4286
IMPULSE_40 = 40,
IMPULSE_FROB,
IMPULSE_42,
IMPULSE_43,
IMPULSE_LEAN_FORWARD,
IMPULSE_LEAN_LEFT,
IMPULSE_LEAN_RIGHT,
IMPULSE_INVENTORY_PREV,
IMPULSE_INVENTORY_NEXT,
IMPULSE_INVENTORY_GROUP_PREV,
IMPULSE_INVENTORY_GROUP_NEXT,
IMPULSE_INVENTORY_USE,
IMPULSE_INVENTORY_DROP,
IMPULSE_MAX
};
// Darkmod: Added as a baseoffset for the impulse keys, when used with ButtonState.
// This function requires an int as input which defines the key that should be used,
// and it looks as if the first impulse starts with the number 25.
const int IMPULSE_BUTTON_BASE = 25;
#define KEY_FROM_IMPULSE(n) (n + IMPULSE_BUTTON_BASE)
// 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
short jx; // joystick x
short jy; // joystick y
idQuat movementAxis;
idQuat frobAxis;
idVec3 frobPos;
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;
// stgatilov: needed for automation only!!!
// Allows to toggle impulse flag properly.
virtual int& hack_Flags() = 0;
};
extern idUsercmdGen *usercmdGen;
#endif /* !__USERCMDGEN_H__ */