103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
-
-
+
+
|
#define SW(w, x, y) SWS(w, x, y, ssize)
#define S(x, y) SW(world, x, y) // convenient lookup of a lowest mip cube
#define SMALLEST_FACTOR 6 // determines number of mips there can be
#define DEFAULT_FACTOR 8
#define LARGEST_FACTOR 11 // 10 is already insane
#define SOLID(x) ((x)->type == SOLID)
#define MINBORD 2 // 2 cubes from the edge of the world are always solid
#define OUTBORD(x, y) \
((x) < MINBORD || (y) < MINBORD || (x) >= ssize - MINBORD || \
#define OUTBORD(x, y) \
((x) < MINBORD || (y) < MINBORD || (x) >= ssize - MINBORD || \
(y) >= ssize - MINBORD)
struct block {
int x, y, xs, ys;
};
enum {
|
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
|
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
|
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
|
#define PIXELTAB (VIRTW / 12)
#define PI (3.1415927f)
#define PI2 (2 * PI)
// simplistic vector ops
#define dotprod(u, v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z)
#define vmul(u, f) \
{ \
(u).x *= (f); \
(u).y *= (f); \
(u).z *= (f); \
#define vmul(u, f) \
{ \
(u).x *= (f); \
(u).y *= (f); \
(u).z *= (f); \
}
#define vdiv(u, f) \
{ \
(u).x /= (f); \
(u).y /= (f); \
(u).z /= (f); \
#define vdiv(u, f) \
{ \
(u).x /= (f); \
(u).y /= (f); \
(u).z /= (f); \
}
#define vadd(u, v) \
{ \
(u).x += (v).x; \
(u).y += (v).y; \
(u).z += (v).z; \
#define vadd(u, v) \
{ \
(u).x += (v).x; \
(u).y += (v).y; \
(u).z += (v).z; \
};
#define vsub(u, v) \
{ \
(u).x -= (v).x; \
(u).y -= (v).y; \
(u).z -= (v).z; \
#define vsub(u, v) \
{ \
(u).x -= (v).x; \
(u).y -= (v).y; \
(u).z -= (v).z; \
};
#define vdist(d, v, e, s) \
OFVector3D v = s; \
vsub(v, e); \
#define vdist(d, v, e, s) \
OFVector3D v = s; \
vsub(v, e); \
float d = (float)sqrt(dotprod(v, v));
#define vreject(v, u, max) \
((v).x > (u).x + (max) || (v).x < (u).x - (max) || \
#define vreject(v, u, max) \
((v).x > (u).x + (max) || (v).x < (u).x - (max) || \
(v).y > (u).y + (max) || (v).y < (u).y - (max))
#define vlinterp(v, f, u, g) \
{ \
(v).x = (v).x * f + (u).x * g; \
(v).y = (v).y * f + (u).y * g; \
(v).z = (v).z * f + (u).z * g; \
#define vlinterp(v, f, u, g) \
{ \
(v).x = (v).x * f + (u).x * g; \
(v).y = (v).y * f + (u).y * g; \
(v).z = (v).z * f + (u).z * g; \
}
#define sgetstr() \
{ \
char *t = text; \
do { \
*t = getint(p); \
} while (*t++); \
#define sgetstr() \
{ \
char *t = text; \
do { \
*t = getint(p); \
} while (*t++); \
} // used by networking
#define m_noitems (gamemode >= 4)
#define m_noitemsrail (gamemode <= 5)
#define m_arena (gamemode >= 8)
#define m_tarena (gamemode >= 10)
#define m_teammode (gamemode & 1 && gamemode > 2)
|
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
|
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
|
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
|
ARG_1EST,
ARG_2EST,
ARG_VARI
};
// nasty macros for registering script functions, abuses globals to avoid
// excessive infrastructure
#define COMMANDN(name, fun, nargs) \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
addcommand(@ #name, (void (*)())fun, nargs); \
}); \
#define COMMANDN(name, fun, nargs) \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
addcommand(@ #name, (void (*)())fun, nargs); \
}); \
}
#define COMMAND(name, nargs) COMMANDN(name, name, nargs)
#define VARP(name, min, cur, max) \
int name; \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
name = variable( \
@ #name, min, cur, max, &name, NULL, true); \
}); \
#define VARP(name, min, cur, max) \
int name; \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
name = variable( \
@ #name, min, cur, max, &name, NULL, true); \
}); \
}
#define VAR(name, min, cur, max) \
int name; \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
name = variable( \
@ #name, min, cur, max, &name, NULL, false); \
}); \
#define VAR(name, min, cur, max) \
int name; \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
name = variable( \
@ #name, min, cur, max, &name, NULL, false); \
}); \
}
#define VARF(name, min, cur, max, body) \
void var_##name(); \
static int name; \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
name = variable( \
@ #name, min, cur, max, &name, var_##name, false); \
}); \
} \
void var_##name() { body; }
#define VARFP(name, min, cur, max, body) \
void var_##name(); \
static int name; \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
name = variable( \
@ #name, min, cur, max, &name, var_##name, true); \
}); \
} \
#define VARFP(name, min, cur, max, body) \
void var_##name(); \
static int name; \
OF_CONSTRUCTOR() \
{ \
enqueueInit(^{ \
name = variable( \
@ #name, min, cur, max, &name, var_##name, true); \
}); \
} \
void var_##name() { body; }
#define ATOI(s) strtol(s, NULL, 0) // supports hexadecimal numbers
#ifdef WIN32
# define WIN32_LEAN_AND_MEAN
# include "windows.h"
|