-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstdheader.h
553 lines (490 loc) · 12.9 KB
/
stdheader.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
#pragma once
#pragma comment(lib, "shlwapi.lib")
#pragma comment(lib, "Shell32.lib")
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>
#include <cstdarg>
#include <ShlObj.h>
#include <Shlwapi.h>
#include <ShellAPI.h>
/*Render stuff*/
#define MAX_RENDER_COMMANDS 0x40000
#define SMP_FRAMES 2
#define MAX_DRAWSURFS 0x10000
#define MAX_DLIGHTS 32 // can't be increased, because bit flags are used on surfaces
#define MAX_ENTITIES 1023 // can't be increased without changing drawsurf bit packing
#define DLL_EXPORT __declspec(dllexport)
#define DLL_IMPORT __declspec(dllimport)
extern DWORD gfx_dll_mp;
#define GFX_OFF(x) (gfx_dll_mp + (x - 0x10000000))
#define MOD_NAME "Moto2"
#define MsgBox(x) MessageBoxA(0,x,0,0)
/* dvar->flags */
#define DVAR_ARCHIVE (1 << 0) // 0x0001
#define DVAR_USERINFO (1 << 1) // 0x0002
#define DVAR_SERVERINFO (1 << 2) // 0x0004
#define DVAR_SYSTEMINFO (1 << 3) // 0x0008
#define DVAR_INIT (1 << 4) // 0x0010
#define DVAR_LATCH (1 << 5) // 0x0020
#define DVAR_ROM (1 << 6) // 0x0040
#define DVAR_CHEAT (1 << 7) // 0x0080
#define DVAR_DEVELOPER (1 << 8) // 0x0100
#define DVAR_SAVED (1 << 9) // 0x0200
#define DVAR_NORESTART (1 << 10) // 0x0400
#define DVAR_CHANGEABLE_RESET (1 << 12) // 0x1000
#define DVAR_EXTERNAL (1 << 14) // 0x4000
#define DVAR_AUTOEXEC (1 << 15) // 0x8000
#define CVAR_ARCHIVE 1
#define CVAR_USERINFO 2
#define CVAR_SERVERINFO 4
#define CVAR_SYSTEMINFO 8
#define CVAR_INIT 16
#define CVAR_LATCH 32
#define CVAR_ROM 64
#define CVAR_CHEAT 128
#define CVAR_TEMP 256
#define CVAR_NORESTART 1024
#define CVAR_USER_CREATED 16384
/*INFO STRINGS*/
#define BIG_INFO_STRING 8192 // used for system info key only
#define BIG_INFO_KEY 8192
#define BIG_INFO_VALUE 8192
#define MAX_HOSTNAME_LENGTH 1024
#define Q_COLOR_ESCAPE '^'
#define Q_IsColorString( p ) ( p && *( p ) == Q_COLOR_ESCAPE && *( ( p ) + 1 ) && *( ( p ) + 1 ) != Q_COLOR_ESCAPE )
static float vColorBlack[4] = { 0,0,0,1 };
static float vColorWhite[4] = { 1, 1, 1, 1 };
static float vColorSelected[4] = { 1, 1, 0, 1 };
typedef float vec_t;
typedef vec_t vec2_t[2];
typedef vec_t vec3_t[3];
#pragma pack(push, 4)
struct vec4_t
{
float x, y, z, w;
};
#pragma pack(pop)
typedef vec_t vec5_t[5];
typedef struct {
byte cmds[MAX_RENDER_COMMANDS];
int used;
} renderCommandList_t;
/*Dvars*/
enum dvarType_t
{
DVAR_TYPE_INVALID = 0x0,
DVAR_TYPE_BOOL = 0x1,
DVAR_TYPE_FLOAT = 0x2,
DVAR_TYPE_FLOAT_2 = 0x3,
DVAR_TYPE_FLOAT_3 = 0x4,
DVAR_TYPE_FLOAT_4 = 0x5,
DVAR_TYPE_INT = 0x6,
DVAR_TYPE_ENUM = 0x7,
DVAR_TYPE_STRING = 0x8,
DVAR_TYPE_COLOR = 0x9,
DVAR_TYPE_INT64 = 0xA,
DVAR_TYPE_LINEAR_COLOR_RGB = 0xB,
DVAR_TYPE_COLOR_XYZ = 0xC,
DVAR_TYPE_COUNT = 0xD,
};
union DvarLimits
{
struct {
int stringCount;
const char** strings;
} enumeration;
struct {
int min;
int max;
} integer;
struct {
float min;
float max;
} value, vector;
struct {
__int64 min;
__int64 max;
} integer64;
};
union DvarValue
{
bool enabled;
int integer;
float value;
vec4_t vector;
const char *string;
char color[4];
};
typedef struct dvar_s {
int name;
short flags;
char type;
char modified;
DvarValue current;
int latched;
int reset;
DvarLimits domain;
int next;
int hashNext;
} dvar_t;
typedef struct
{
byte red;
byte green;
byte blue;
byte alpha;
}ucolor_t;
/*Cvars*/
typedef enum {
CVAR_BOOL,
CVAR_FLOAT,
CVAR_VEC2,
CVAR_VEC3,
CVAR_VEC4,
CVAR_INT,
CVAR_ENUM,
CVAR_STRING,
CVAR_COLOR
}cvarType_t;
typedef union
{
float floatval;
int integer;
const char* string;
byte boolean;
vec4_t vec4;
vec3_t vec3;
vec2_t vec2;
ucolor_t color;
}CvarValue_t;
typedef struct {
union {
int imin;
float fmin;
int enumCount;
};
union {
int imax;
float fmax;
const char** enumStrings;
};
}CvarLimits_t;
typedef struct cvar_s
{
char* name;
unsigned short flags;
byte type;
byte modified;
union
{
float floatval;
int integer;
char* string;
byte boolean;
vec2_t vec2;
vec3_t vec3;
vec4_t vec4;
ucolor_t color;
};
union
{
float latchedFloatval;
int latchedInteger;
char* latchedString;
byte latchedBoolean;
vec2_t latchedVec2;
vec3_t latchedVec3;
vec4_t latchedVec4;
ucolor_t latchedColor;
};
union
{
float resetFloatval;
int resetInteger;
char* resetString;
byte resetBoolean;
vec2_t resetVec2;
vec3_t resetVec3;
vec4_t resetVec4;
ucolor_t resetColor;
};
union
{
int imin;
float fmin;
};
union
{
int imax;
float fmax;
const char** enumStr;
};
struct cvar_s* next;
struct cvar_s* hashNext;
} cvar_t;
typedef enum
{
NA_BOT, NA_BAD, NA_LOOPBACK, NA_BROADCAST, NA_IP
} netadrtype_t;
typedef struct
{
netadrtype_t type;
char ip[4];
unsigned short port;
} netadr_t;
typedef enum {
SF_BAD,
SF_SKIP, // ignore
SF_FACE,
SF_GRID,
SF_TRIANGLES,
SF_POLY,
SF_MD3,
SF_MD4,
SF_FLARE,
SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity
SF_DISPLAY_LIST,
SF_NUM_SURFACE_TYPES,
SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int )
} surfaceType_t;
typedef struct dlight_s {
vec3_t origin;
vec3_t color; // range from 0.0 to 1.0, should be color normalized
float radius;
vec3_t transformed; // origin in local coordinate system
int additive; // texture detail is lost tho when the lightmap is dark
} dlight_t;
typedef enum {
RT_MODEL,
RT_POLY,
RT_SPRITE,
RT_BEAM,
RT_RAIL_CORE,
RT_RAIL_RINGS,
RT_LIGHTNING,
RT_PORTALSURFACE, // doesn't draw anything, just info for portals
RT_MAX_REF_ENTITY_TYPE
} refEntityType_t;
typedef struct {
refEntityType_t reType;
int renderfx;
handle_t hModel; // opaque type outside refresh
// most recent data
vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
float shadowPlane; // projection shadows go here, stencils go slightly lower
vec3_t axis[3]; // rotation vectors
boolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale
float origin[3]; // also used as MODEL_BEAM's "from"
int frame; // also used as MODEL_BEAM's diameter
// previous data for frame interpolation
float oldorigin[3]; // also used as MODEL_BEAM's "to"
int oldframe;
float backlerp; // 0.0 = current, 1.0 = old
// texturing
int skinNum; // inline skin index
handle_t customSkin; // NULL for default skin
handle_t customShader; // use one image for the entire thing
// misc
byte shaderRGBA[4]; // colors used by rgbgen entity shaders
float shaderTexCoord[2]; // texture coordinates used by tcMod entity modifiers
float shaderTime; // subtracted from refdef time to control effect start times
// extra sprite information
float radius;
float rotation;
} refEntity_t;
// a trRefEntity_t has all the information passed in by
// the client game, as well as some locally derived info
typedef struct {
refEntity_t e;
float axisLength; // compensate for non-normalized axis
boolean needDlights; // true for bmodels that touch a dlight
boolean lightingCalculated;
vec3_t lightDir; // normalized direction towards light
vec3_t ambientLight; // color normalized to 0-255
int ambientLightInt; // 32 bit rgba packed
vec3_t directedLight;
} trRefEntity_t;
typedef struct drawSurf_s {
unsigned sort; // bit combination for fast compares
surfaceType_t* surface; // any of surface*_t
} drawSurf_t;
typedef struct {
vec3_t xyz;
float st[2];
byte modulate[4];
} polyVert_t;
typedef struct srfPoly_s {
surfaceType_t surfaceType;
handle_t hShader;
int fogIndex;
int numVerts;
polyVert_t* verts;
} srfPoly_t;
// parameters to the main Error routine
typedef enum {
ERR_FATAL, // exit the entire game with a popup window
ERR_DROP, // print to console and disconnect from game
ERR_SERVERDISCONNECT, // don't kill server
ERR_DISCONNECT, // client disconnected from the server
ERR_NEED_CD // pop up the need-cd dialog
} errorParm_t;
typedef enum {
RC_END_OF_LIST,
RC_SET_COLOR,
RC_STRETCH_PIC,
RC_DRAW_SURFS,
RC_DRAW_BUFFER,
RC_SWAP_BUFFERS,
RC_SCREENSHOT
} renderCommand_t;
typedef struct {
int commandId;
float color[4];
} setColorCommand_t;
typedef struct
{
uint64_t _bf0;
}GfxDrawSurfFields;
union GfxDrawSurf
{
GfxDrawSurfFields fields;
uint64_t packed;
};
#pragma pack(push, 8)
typedef struct MaterialInfo
{
const char* name;
char gameFlags;
char sortKey;
char textureAtlasRowCount;
char textureAtlasColumnCount;
union GfxDrawSurf drawSurf;
int surfaceTypeBits;
}MaterialInfo_t;
struct Material
{
MaterialInfo info;
int64_t stateBits;
short textureCount;
short constantCount;
int techniqueSet;
int textures;
int constants;
};
/* 7043 */
#pragma pack(push, 2)
typedef struct
{
uint16_t letter;
char x0;
char y0;
char dx;
char pixelWidth;
char pixelHeight;
char pad;
float s0;
float t0;
float s1;
float t1;
}Glyph;
#pragma pack(pop)
/* 7044 */
typedef struct Font_s
{
const char* fontName;
int pixelHeight;
int glyphCount;
Material* material;
Material* glowMaterial;
Glyph* glyphs;
}Font_t;
extern char* __cdecl va(const char* format, ...);
extern void Dvar_SetString(const char* _dvar, const char* strval);
extern void* R_GetCommandBuffer(int bytes);
extern void RE_SetColor(const float* rgba);
extern int Sys_IsAdmin();
extern int Sys_GetModulePathInfo(HMODULE module, char** path, char** filename, char** extension);
extern bool Sys_ElevateProgram(char* arg3, bool restart);
extern void Q_strncpyz(char* dest, const char* src, int destsize);
extern const char* Info_ValueForKey(const char* s, const char* key);
extern char* Q_CleanStr(char* string, bool colors);
extern char* Com_CleanHostname(char* string, bool colors);
extern char* Com_CleanMapname(char* mapname);
const char* GetStockGametypeName(char* gt);
char* GetTxtGametypeName(char* gt, bool colors);
extern const char* Com_GametypeName(char* gt, bool colors);
typedef struct
{
float scaleVirtualToReal[2];
float scaleVirtualToFull[2];
float scaleRealToVirtual[2];
float virtualViewableMin[2];
float virtualViewableMax[2];
float realViewportSize[2];
float realViewableMin[2];
float realViewableMax[2];
float subScreenLeft;
}ScreenPlacement;
typedef enum
{
CA_DISCONNECTED = 0,
CA_CINEMATIC = 1,
CA_LOGO = 2,
CA_CONNECTING = 3,
CA_CHALLENGING = 4,
CA_CONNECTED = 5,
CA_LOADING = 6,
CA_PRIMED = 7,
CA_ACTIVE = 8
} connstate_t;
typedef dvar_t *(*Dvar_RegisterBool_t)(const char* var_name, bool var_value, unsigned short flags);
extern Dvar_RegisterBool_t Dvar_RegisterBool;
typedef dvar_t *(*Dvar_RegisterFloat_t)(const char* var_name, float var_value, float var_min, float var_max, unsigned short flags);
extern Dvar_RegisterFloat_t Dvar_RegisterFloat;
typedef dvar_t *(*Dvar_RegisterString_t)(const char*, const char*, unsigned short);
extern Dvar_RegisterString_t Dvar_RegisterString;
typedef dvar_t *(*Dvar_SetFromStringByName_t)(const char*, const char*);
extern Dvar_SetFromStringByName_t Dvar_SetFromStringByName;
typedef dvar_t *(*Dvar_Set_t)(const char*, const char*);
extern Dvar_Set_t Dvar_Set;
typedef dvar_t *(*Dvar_SetVariant_t)(cvar_s* dvar, DvarValue value, enum DvarSetSource source);
extern Dvar_SetVariant_t Dvar_SetVariant;
typedef dvar_t *(*Dvar_GetVariantString_t)(const char*);
extern Dvar_GetVariantString_t Dvar_GetVariantString;
typedef void(*Cmd_AddCommand_t)(const char*, void*);
extern Cmd_AddCommand_t Cmd_AddCommand;
typedef void(*Com_PrintMessage_t)(int, const char*);
extern Com_PrintMessage_t Com_PrintMessage;
typedef void(*CL_DrawString_t)(int a1, int a2, const char* a3, int a4, int a5);
extern CL_DrawString_t CL_DrawString;
typedef void(*Com_Error_t)(int a1, const char* Format, ...);
extern Com_Error_t Com_Error;
typedef void(*Cbuf_AddText_t)(const char*);
extern Cbuf_AddText_t Cbuf_AddText;
//typedef void(*CL_DrawText_t)(float* scrPlace, const char* text, int maxChars, float* font, float x, float y, int horzAlign, int vertAlign, float xScale, float yScale, float color, int style);
//extern CL_DrawText_t CL_DrawText;
typedef void(*SV_SendServerCommand_t)(int, const char*, ...);
extern SV_SendServerCommand_t SV_SendServerCommand;
typedef void(*Com_Quit_f_t)();
extern Com_Quit_f_t Com_Quit_f;
typedef int(*Com_Printf_t)(const char* format, ...);
extern Com_Printf_t Com_Printf;
typedef void(*SCR_DrawSmallStringExt_t)(signed int x, signed int y, const char* string, const float* setColor);//__cdecl
extern SCR_DrawSmallStringExt_t SCR_DrawSmallStringExt;
typedef void(*CG_DrawBigDevStringColor_t)(const char*, int, int, int, int, int);
extern CG_DrawBigDevStringColor_t CG_DrawBigDevStringColor;
typedef void(*R_DrawText_t)(float x, float y, int font, float scale, const float* color, const char* text, float spacing, int limit, int flags);
extern R_DrawText_t R_DrawText;
//typedef char* (*Info_ValueForKey_t)(const char * s, const char *key);
//extern Info_ValueForKey_t Info_ValueForKey;
typedef int(*FS_ReadFile_t)(const char* qpath, void** buffer);
extern FS_ReadFile_t FS_ReadFile;
template <typename T, typename ... Ts>
T call(size_t addr, Ts ... ts) {
T(*f)(...);
*(T*)&f = (T)addr;
return f(ts...);
}