-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
dd_share.h
1828 lines (1597 loc) · 51.9 KB
/
dd_share.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
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @file dd_share.h
* Shared macros and constants.
*
* Various macros and constants used by the engine and games.
*
* @authors Copyright © 2003-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2012 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program 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 2 of the License, or (at your
* option) any later version. This program 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 this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef LIBDENG_SHARED_H
#define LIBDENG_SHARED_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @def C_DECL
* Calling convention for compare functions. Only for Windows.
*/
#ifndef C_DECL
# if defined(WIN32)
# define C_DECL __cdecl
# elif defined(UNIX)
# define C_DECL
# else
# define C_DECL
# endif
#endif
#include <stdlib.h>
#include <stdarg.h>
#include "dengproject.h"
#include "../portable/include/dd_version.h"
#include "dd_types.h"
#include "dd_maptypes.h"
#include "dd_wad.h"
#include "dd_gl.h"
#include "dd_ui.h"
#include "dd_infine.h"
#include "def_share.h"
#include "thinker.h"
/** @file
* @todo dd_version.h is not officially a public header file!
*/
//------------------------------------------------------------------------
//
// General Definitions and Macros
//
//------------------------------------------------------------------------
/// @defgroup apiFlags Flags
/// Maximum number of players supported by the engine.
#define DDMAXPLAYERS 16
/// Base default paths for data files.
#define DD_BASEPATH_DATA "}data/"
/// Base default paths for definition files.
#define DD_BASEPATH_DEFS "}defs/"
// The case-independent strcmps have different names.
#if WIN32
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
# define strlwr _strlwr
#endif
#if UNIX
# define stricmp strcasecmp
# define strnicmp strncasecmp
/**
* There are manual implementations for these string handling routines:
*/
char* strupr(char *string);
char* strlwr(char *string);
#endif
int dd_snprintf(char* str, size_t size, const char* format, ...);
int dd_vsnprintf(char* str, size_t size, const char* format,
va_list ap);
// Format checking for printf-like functions in GCC2
#if defined(__GNUC__) && __GNUC__ >= 2
# define PRINTF_F(f,v) __attribute__ ((format (printf, f, v)))
#else
# define PRINTF_F(f,v)
#endif
int16_t ShortSwap(int16_t);
int32_t LongSwap(int32_t);
float FloatSwap(float);
#ifdef __BIG_ENDIAN__
#define SHORT(x) ShortSwap(x)
#define LONG(x) LongSwap(x)
#define FLOAT(x) FloatSwap(x)
#define BIGSHORT(x) (x)
#define BIGLONG(x) (x)
#define BIGFLOAT(x) (x)
// In these, x is evaluated multiple times, so increments and decrements
// cannot be used.
#define MACRO_SHORT(x) ((int16_t)(( ((int16_t)(x)) & 0xff ) << 8) | (( ((int16_t)(x)) & 0xff00) >> 8))
#define MACRO_LONG(x) ((int32_t)((( ((int32_t)(x)) & 0xff) << 24) | (( ((int32_t)(x)) & 0xff00) << 8) | \
(( ((int32_t)(x)) & 0xff0000) >> 8) | (( ((int32_t)(x)) & 0xff000000) >> 24) ))
#else
/// Byte order conversion from native to little-endian. @{
#define SHORT(x) (x)
#define LONG(x) (x)
#define FLOAT(x) (x)
///@}
/// Byte order conversion from native to big-endian. @{
#define BIGSHORT(x) ShortSwap(x)
#define BIGLONG(x) LongSwap(x)
#define BIGFLOAT(x) FloatSwap(x)
///@}
#define MACRO_SHORT(x) (x)
#define MACRO_LONG(x) (x)
#endif
/// Byte order conversion from native to little-endian. @{
#define USHORT(x) ((uint16_t) SHORT(x))
#define ULONG(x) ((uint32_t) LONG(x))
///@}
/// Value types.
typedef enum {
DDVT_NONE = -1, ///< Not a read/writeable value type.
DDVT_BOOL,
DDVT_BYTE,
DDVT_SHORT,
DDVT_INT, ///< 32 or 64 bit
DDVT_UINT,
DDVT_FIXED,
DDVT_ANGLE,
DDVT_FLOAT,
DDVT_DOUBLE,
DDVT_LONG,
DDVT_ULONG,
DDVT_PTR,
DDVT_BLENDMODE
} valuetype_t;
/// Integer values for Set/Get
enum {
DD_FIRST_VALUE = -1,
DD_NETGAME,
DD_SERVER,
DD_CLIENT,
DD_ALLOW_FRAMES,
DD_CONSOLEPLAYER,
DD_DISPLAYPLAYER,
DD_MIPMAPPING,
DD_SMOOTH_IMAGES,
DD_DEFAULT_RES_X,
DD_DEFAULT_RES_Y,
DD_UNUSED1,
DD_MOUSE_INVERSE_Y,
DD_FULLBRIGHT, ///< Render everything fullbright?
DD_CCMD_RETURN,
DD_GAME_READY,
DD_DEDICATED,
DD_NOVIDEO,
DD_NUMMOBJTYPES,
DD_GOTFRAME,
DD_PLAYBACK,
DD_NUMSOUNDS,
DD_NUMMUSIC,
DD_NUMLUMPS,
DD_CLIENT_PAUSED,
DD_WEAPON_OFFSET_SCALE_Y, ///< 1000x
DD_MONOCHROME_PATCHES, ///< Convert patch image data to monochrome. 1= linear 2= weighted.
DD_GAME_DATA_FORMAT,
DD_GAME_DRAW_HUD_HINT, ///< Doomsday advises not to draw the HUD.
DD_UPSCALE_AND_SHARPEN_PATCHES,
DD_SYMBOLIC_ECHO,
DD_MAX_TEXTURE_UNITS,
DD_CURRENT_CLIENT_FINALE_ID,
DD_LAST_VALUE
};
/// General constants (not to be used with Get/Set).
enum {
DD_NEW = -2,
DD_SKY = -1,
DD_DISABLE,
DD_ENABLE,
DD_MASK,
DD_YES,
DD_NO,
DD_MATERIAL,
DD_OFFSET,
DD_HEIGHT,
DD_UNUSED2,
DD_UNUSED3,
DD_COLOR_LIMIT,
DD_PRE,
DD_POST,
DD_PLUGIN_VERSION_SHORT,
DD_PLUGIN_VERSION_LONG,
DD_HORIZON,
DD_OLD_GAME_ID,
DD_DEF_MOBJ,
DD_DEF_MOBJ_BY_NAME,
DD_DEF_STATE,
DD_DEF_SPRITE,
DD_DEF_SOUND,
DD_DEF_MUSIC,
DD_DEF_MAP_INFO,
DD_DEF_TEXT,
DD_DEF_VALUE,
DD_DEF_LINE_TYPE,
DD_DEF_SECTOR_TYPE,
DD_PSPRITE_BOB_X,
DD_PSPRITE_BOB_Y,
DD_DEF_FINALE_AFTER,
DD_DEF_FINALE_BEFORE,
DD_DEF_FINALE,
DD_RENDER_RESTART_PRE,
DD_RENDER_RESTART_POST,
DD_DEF_SOUND_BY_NAME,
DD_DEF_SOUND_LUMPNAME,
DD_ID,
DD_LUMP,
DD_CD_TRACK,
DD_SPRITE,
DD_FRAME,
DD_GAME_CONFIG, ///< String: dm/co-op, jumping, etc.
DD_PLUGIN_NAME, ///< (e.g., jdoom, jheretic etc..., suitable for use with filepaths)
DD_PLUGIN_NICENAME, ///< (e.g., jDoom, MyGame:Episode2 etc..., fancy name)
DD_PLUGIN_HOMEURL,
DD_PLUGIN_DOCSURL,
DD_DMU_VERSION, ///< Used in the exchange of DMU API versions.
// Non-integer/special values for Set/Get
DD_TRANSLATIONTABLES_ADDRESS,
DD_TRACE_ADDRESS, ///< obsolete divline 'trace' used by PathTraverse.
DD_SPRITE_REPLACEMENT, ///< Sprite <-> model replacement.
DD_ACTION_LINK, ///< State action routine addresses.
DD_MAP_NAME,
DD_MAP_AUTHOR,
DD_MAP_MUSIC,
DD_MAP_MIN_X,
DD_MAP_MIN_Y,
DD_MAP_MAX_X,
DD_MAP_MAX_Y,
DD_WINDOW_WIDTH,
DD_WINDOW_HEIGHT,
DD_WINDOW_HANDLE,
DD_DYNLIGHT_TEXTURE,
DD_GAME_EXPORTS,
DD_SECTOR_COUNT,
DD_LINE_COUNT,
DD_SIDE_COUNT,
DD_VERTEX_COUNT,
DD_HEDGE_COUNT,
DD_BSPLEAF_COUNT,
DD_BSPNODE_COUNT,
DD_POLYOBJ_COUNT,
DD_XGFUNC_LINK, ///< XG line classes
DD_SHARED_FIXED_TRIGGER_OBSOLETE, ///< obsolete
DD_GAMETIC,
DD_OPENRANGE, ///< obsolete
DD_OPENTOP, ///< obsolete
DD_OPENBOTTOM, ///< obsolete
DD_LOWFLOOR, ///< obsolete
DD_CPLAYER_THRUST_MUL_OBSOLETE, ///< obsolete
DD_GRAVITY,
DD_PSPRITE_OFFSET_X, ///< 10x
DD_PSPRITE_OFFSET_Y, ///< 10x
DD_PSPRITE_LIGHTLEVEL_MULTIPLIER,
DD_TORCH_RED,
DD_TORCH_GREEN,
DD_TORCH_BLUE,
DD_TORCH_ADDITIVE,
DD_TM_FLOOR_Z, ///< output from P_CheckPosition
DD_TM_CEILING_Z ///< output from P_CheckPosition
};
/// Bounding box coordinates.
enum {
BOXTOP = 0,
BOXBOTTOM = 1,
BOXLEFT = 2,
BOXRIGHT = 3,
BOXFLOOR = 4,
BOXCEILING = 5
};
//------------------------------------------------------------------------
//
// Games
//
//------------------------------------------------------------------------
/**
* @defgroup game Game
*/
/**
* Defines the numerous high-level properties of a logical game component.
* Note that this is POD; no construction or destruction is needed.
* @see DD_DefineGame() @ingroup game
*/
typedef struct gamedef_s {
/**
* Unique game mode key/identifier, 16 chars max (e.g., "doom1-ultimate").
* - Used during resource location for mode-specific assets.
* - Sent out in netgames (a client can't connect unless mode strings match).
*/
const char* identityKey;
/// The base directory for all data-class resources.
const char* dataPath;
/// The base directory for all defs-class resources.
const char* defsPath;
/// Name of the config directory.
const char* configDir;
/// Default title. May be overridden later.
const char* defaultTitle;
/// Default author. May be overridden later.
/// Used for (e.g.) the map author name if not specified in a Map Info definition.
const char* defaultAuthor;
} GameDef;
/**
* Extended info about a registered game component.
* @see DD_GameInfo() @ingroup game
*/
typedef struct gameinfo_s {
const char* title;
const char* author;
const char* identityKey;
} GameInfo;
/**
* @defgroup resourceFlags Resource Flags
* @ingroup apiFlags resource
*/
///@{
#define RF_STARTUP 0x1 ///< A required resource needed for and loaded during game start up (can't be a virtual file).
#define RF_FOUND 0x2 ///< Resource has been located.
///@}
/**
* @defgroup math Math Routines
* @ingroup base
*/
///@{
#define FRACBITS 16
#define FRACUNIT (1<<FRACBITS)
#define FRACEPSILON (1.0f/65535.f) // ~ 1.5e-5
#define FLOATEPSILON .000001f
#define MAX_OF(x, y) ((x) > (y)? (x) : (y))
#define MIN_OF(x, y) ((x) < (y)? (x) : (y))
#define MINMAX_OF(a, x, b) ((x) < (a)? (a) : (x) > (b)? (b) : (x))
#define SIGN_OF(x) ((x) > 0? +1 : (x) < 0? -1 : 0)
#define INRANGE_OF(x, y, r) ((x) >= (y) - (r) && (x) <= (y) + (r))
#define FEQUAL(x, y) (INRANGE_OF(x, y, FLOATEPSILON))
#define ROUND(x) ((int) (((x) < 0.0f)? ((x) - 0.5f) : ((x) + 0.5f)))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
/// Ceiling of integer quotient of @a a divided by @a b.
#define CEILING(a, b) ((a) % (b) == 0 ? (a)/(b) : (a)/(b)+1)
/**
* Used to replace /255 as *reciprocal255 is less expensive with CPU cycles.
* Note that this should err on the side of being < 1/255 to prevent result
* exceeding 255 (e.g. 255 * reciprocal255).
*/
#define reciprocal255 0.003921568627f
#define FINEANGLES 8192
#define FINEMASK (FINEANGLES-1)
#define ANGLETOFINESHIFT 19 ///< Shifts 0x100000000 to 0x2000.
#define ANGLE_45 0x20000000
#define ANGLE_90 0x40000000
#define ANGLE_180 0x80000000
#define ANGLE_MAX 0xffffffff
#define ANGLE_1 (ANGLE_45/45)
#define ANGLE_60 (ANGLE_180/3)
#define ANG45 0x20000000
#define ANG90 0x40000000
#define ANG180 0x80000000
#define ANG270 0xc0000000
#define FIX2FLT(x) ( (x) / (float) FRACUNIT )
#define Q_FIX2FLT(x) ( (float)((x)>>FRACBITS) )
#define FLT2FIX(x) ( (fixed_t) ((x)*FRACUNIT) )
#if !defined( DENG_NO_FIXED_ASM ) && !defined( GNU_X86_FIXED_ASM )
__inline fixed_t FixedMul(fixed_t a, fixed_t b) {
__asm {
// The parameters in eax and ebx.
mov eax, a
mov ebx, b
// The multiplying.
imul ebx
shrd eax, edx, 16
// eax should hold the return value.
}
// A value is returned regardless of the compiler warning.
}
__inline fixed_t FixedDiv2(fixed_t a, fixed_t b) {
__asm {
// The parameters.
mov eax, a
mov ebx, b
// The operation.
cdq
shld edx, eax, 16
sal eax, 16
idiv ebx
// And the value returns in eax.
}
// A value is returned regardless of the compiler warning.
}
#else
// Don't use inline assembler in fixed-point calculations.
// (link with plugins/common/m_fixed.c)
fixed_t FixedMul(fixed_t a, fixed_t b);
fixed_t FixedDiv2(fixed_t a, fixed_t b);
#endif
// This one is always in plugins/common/m_fixed.c.
fixed_t FixedDiv(fixed_t a, fixed_t b);
///@}
//------------------------------------------------------------------------
//
// Key Codes
//
//------------------------------------------------------------------------
/// @defgroup input Input
/**
* @defgroup keyConstants Key Constants
* @ingroup input
* Most key data is regular ASCII so key constants correspond to ASCII codes.
*/
///@{
#define DDKEY_ESCAPE 27
#define DDKEY_RETURN 13
#define DDKEY_TAB 9
#define DDKEY_BACKSPACE 127
#define DDKEY_EQUALS 0x3d
#define DDKEY_MINUS 0x2d
#define DDKEY_BACKSLASH 0x5C
// Extended keys (above 127).
enum {
DDKEY_RIGHTARROW = 0x80,
DDKEY_LEFTARROW,
DDKEY_UPARROW,
DDKEY_DOWNARROW,
DDKEY_F1,
DDKEY_F2,
DDKEY_F3,
DDKEY_F4,
DDKEY_F5,
DDKEY_F6,
DDKEY_F7,
DDKEY_F8,
DDKEY_F9,
DDKEY_F10,
DDKEY_F11,
DDKEY_F12,
DDKEY_NUMLOCK,
DDKEY_CAPSLOCK,
DDKEY_SCROLL,
DDKEY_NUMPAD7,
DDKEY_NUMPAD8,
DDKEY_NUMPAD9,
DDKEY_NUMPAD4,
DDKEY_NUMPAD5,
DDKEY_NUMPAD6,
DDKEY_NUMPAD1,
DDKEY_NUMPAD2,
DDKEY_NUMPAD3,
DDKEY_NUMPAD0,
DDKEY_DECIMAL,
DDKEY_PAUSE,
DDKEY_RSHIFT,
DDKEY_LSHIFT = DDKEY_RSHIFT,
DDKEY_RCTRL,
DDKEY_LCTRL = DDKEY_RCTRL,
DDKEY_RALT,
DDKEY_LALT = DDKEY_RALT,
DDKEY_INS,
DDKEY_DEL,
DDKEY_PGUP,
DDKEY_PGDN,
DDKEY_HOME,
DDKEY_END,
DDKEY_SUBTRACT, ///< '-' on numeric keypad.
DDKEY_ADD, ///< '+' on numeric keypad.
DDKEY_PRINT,
DDKEY_ENTER, ///< on the numeric keypad.
DDKEY_DIVIDE, ///< '/' on numeric keypad.
DD_HIGHEST_KEYCODE
};
///@}
//------------------------------------------------------------------------
//
// Events
//
//------------------------------------------------------------------------
/// Event types. @ingroup input
typedef enum {
EV_KEY,
EV_MOUSE_AXIS,
EV_MOUSE_BUTTON,
EV_JOY_AXIS, ///< Joystick main axes (xyz + Rxyz).
EV_JOY_SLIDER, ///< Joystick sliders.
EV_JOY_BUTTON,
EV_POV,
EV_SYMBOLIC, ///< Symbol text pointed to by data1+data2.
NUM_EVENT_TYPES
} evtype_t;
/// Event states. @ingroup input
typedef enum {
EVS_DOWN,
EVS_UP,
EVS_REPEAT,
NUM_EVENT_STATES
} evstate_t;
/// Input event. @ingroup input
typedef struct event_s {
evtype_t type;
evstate_t state; ///< Only used with digital controls.
int data1; ///< Keys/mouse/joystick buttons.
int data2; ///< Mouse/joystick x move.
int data3; ///< Mouse/joystick y move.
int data4;
int data5;
int data6;
} event_t;
/// The mouse wheel is considered two extra mouse buttons.
#define DD_MWHEEL_UP 3
#define DD_MWHEEL_DOWN 4
#define DD_MICKEY_ACCURACY 1000
/*
/// Controller classes. @ingroup input
typedef enum {
CC_AXIS, ///< Axis controller, e.g., a joystick or mouse axis.
CC_TOGGLE, ///< Toggle controller, e.g., a keyboard key.
CC_IMPULSE,
NUM_CONTROL_CLASSES
} ctlclass_t;
*/
//------------------------------------------------------------------------
//
// Purge Levels
//
//------------------------------------------------------------------------
/**
* @defgroup memzone Memory Zone
* @ingroup base
*/
/**
* @defgroup purgeLevels Purge Levels
* @ingroup memzone
*/
///@{
#define PU_APPSTATIC 1 ///< Static entire execution time.
#define PU_GAMESTATIC 40 ///< Static until the game plugin which allocated it is unloaded.
#define PU_MAP 50 ///< Static until map exited (may still be freed during the map, though).
#define PU_MAPSTATIC 52 ///< Not freed until map exited.
#define PU_PURGELEVEL 100 ///< Tags >= 100 are purgable whenever needed.
#define PU_CACHE 101
///@}
//------------------------------------------------------------------------
//
// Map Data
//
//------------------------------------------------------------------------
/// @defgroup map Map Data
/**
* @defgroup dmu Map Update (DMU)
* @ingroup map
*/
///@{
/// Public DMU API version number. Requested by the engine during init. @ingroup dmu
#define DMUAPI_VER 1
/// Map Update constants. @ingroup dmu
enum {
// Do not change the numerical values of the constants!
/// Flag. OR'ed with a DMU property constant. Note: these use only the most
/// significant byte.
/// @{
DMU_FLAG_MASK = 0xff000000,
DMU_SIDEDEF1_OF_LINE = 0x80000000,
DMU_SIDEDEF0_OF_LINE = 0x40000000,
DMU_TOP_OF_SIDEDEF = 0x20000000,
DMU_MIDDLE_OF_SIDEDEF = 0x10000000,
DMU_BOTTOM_OF_SIDEDEF = 0x08000000,
DMU_FLOOR_OF_SECTOR = 0x04000000,
DMU_CEILING_OF_SECTOR = 0x02000000,
// (1 bits left)
///@}
DMU_NONE = 0,
DMU_VERTEX = 1,
DMU_HEDGE,
DMU_LINEDEF,
DMU_SIDEDEF,
DMU_BSPNODE,
DMU_BSPLEAF,
DMU_SECTOR,
DMU_PLANE,
DMU_SURFACE,
DMU_MATERIAL,
DMU_LINEDEF_BY_TAG,
DMU_SECTOR_BY_TAG,
DMU_LINEDEF_BY_ACT_TAG,
DMU_SECTOR_BY_ACT_TAG,
DMU_X,
DMU_Y,
DMU_XY,
DMU_TANGENT_X,
DMU_TANGENT_Y,
DMU_TANGENT_Z,
DMU_TANGENT_XYZ,
DMU_BITANGENT_X,
DMU_BITANGENT_Y,
DMU_BITANGENT_Z,
DMU_BITANGENT_XYZ,
DMU_NORMAL_X,
DMU_NORMAL_Y,
DMU_NORMAL_Z,
DMU_NORMAL_XYZ,
DMU_VERTEX0,
DMU_VERTEX1,
DMU_FRONT_SECTOR,
DMU_BACK_SECTOR,
DMU_SIDEDEF0,
DMU_SIDEDEF1,
DMU_FLAGS,
DMU_DX,
DMU_DY,
DMU_DXY,
DMU_LENGTH,
DMU_SLOPE_TYPE,
DMU_ANGLE,
DMU_OFFSET,
DMU_OFFSET_X,
DMU_OFFSET_Y,
DMU_OFFSET_XY,
DMU_VALID_COUNT,
DMU_LINEDEF_COUNT,
DMU_COLOR, ///< RGB
DMU_COLOR_RED, ///< red component
DMU_COLOR_GREEN, ///< green component
DMU_COLOR_BLUE, ///< blue component
DMU_ALPHA,
DMU_BLENDMODE,
DMU_LIGHT_LEVEL,
DMT_MOBJS, ///< pointer to start of sector mobjList
DMU_BOUNDING_BOX, ///< float[4]
DMU_ORIGIN,
DMU_WIDTH,
DMU_HEIGHT,
DMU_TARGET_HEIGHT,
DMU_SPEED,
DMU_HEDGE_COUNT
};
/**
* @defgroup ldefFlags Linedef Flags
* @ingroup dmu apiFlags
* For use with P_Set/Get(DMU_LINEDEF, n, DMU_FLAGS).
*/
/// @addtogroup ldefFlags
///@{
#define DDLF_BLOCKING 0x0001
#define DDLF_DONTPEGTOP 0x0002
#define DDLF_DONTPEGBOTTOM 0x0004
///@}
/**
* @defgroup sdefFlags Sidedef Flags
* @ingroup dmu apiFlags
* For use with P_Set/Get(DMU_SIDEDEF, n, DMU_FLAGS).
*/
/// @addtogroup sdefFlags
///@{
#define SDF_BLENDTOPTOMID 0x0001
#define SDF_BLENDMIDTOTOP 0x0002
#define SDF_BLENDMIDTOBOTTOM 0x0004
#define SDF_BLENDBOTTOMTOMID 0x0008
#define SDF_MIDDLE_STRETCH 0x0010 ///< Stretch the middle surface to reach from floor to ceiling.
///@}
/**
* @defgroup sufFlags Surface Flags
* @ingroup dmu apiFlags
* For use with P_Set/Get(DMU_SURFACE, n, DMU_FLAGS).
*/
/// @addtogroup sufFlags
///@{
#define DDSUF_MATERIAL_FLIPH 0x00000001 ///< Surface material is flipped horizontally.
#define DDSUF_MATERIAL_FLIPV 0x00000002 ///< Surface material is flipped vertically.
///@}
/// Map Update status code constants. @ingroup dmu
/// Sent to the game when various map update events occur.
enum { /* Do NOT change the numerical values of the constants. */
DMUSC_LINE_FIRSTRENDERED
};
///@}
/// @ingroup mobj
#define DD_BASE_DDMOBJ_ELEMENTS() \
thinker_t thinker; /* thinker node */ \
float pos[3]; /* position [x,y,z] */
/**
* All map think-able objects must use this as a base. Also used for sound
* origin purposes for all of: mobj_t, Polyobj, Sector/Plane
* @ingroup mobj
*/
typedef struct ddmobj_base_s {
DD_BASE_DDMOBJ_ELEMENTS()
} ddmobj_base_t;
/// Fixed-point vertex position. Utility struct for the game, not used by
/// the engine. @ingroup map
typedef struct ddvertex_s {
fixed_t pos[2];
} ddvertex_t;
/// Floating-point vertex position. Utility struct for the game, not used
/// by the engine. @ingroup map
typedef struct ddvertexf_s {
float pos[2];
} ddvertexf_t;
/// R_SetupMap() modes. @ingroup map
enum {
DDSMM_AFTER_LOADING, ///< After loading a savegame...
DDSMM_FINALIZE, ///< After everything else is done.
DDSMM_INITIALIZE, ///< Before anything else if done.
DDSMM_AFTER_BUSY ///< After leaving busy mode, which was used during setup.
};
/// Sector reverb data indices. @ingroup map
enum {
SRD_VOLUME,
SRD_SPACE,
SRD_DECAY,
SRD_DAMPING,
NUM_REVERB_DATA
};
typedef struct {
fixed_t pos[2], dX, dY;
} divline_t;
typedef struct {
float pos[2], dX, dY;
} fdivline_t;
/**
* @defgroup pathTraverseFlags Path Traverse Flags
* @ingroup apiFlags map
*/
///@{
#define PT_ADDLINES 1 ///< Intercept with LineDefs.
#define PT_ADDMOBJS 2 ///< Intercept with Mobjs.
///@}
typedef enum {
ST_HORIZONTAL,
ST_VERTICAL,
ST_POSITIVE,
ST_NEGATIVE
} slopetype_t;
/**
* @defgroup lineSightFlags Line Sight Flags
* Flags used to dictate logic within P_CheckLineSight().
* @ingroup apiFlags map
*/
///@{
#define LS_PASSLEFT 0x1 ///< Ray may cross one-sided linedefs from left to right.
#define LS_PASSOVER 0x2 ///< Ray may cross over sector ceiling height on ray-entry side.
#define LS_PASSUNDER 0x4 ///< Ray may cross under sector floor height on ray-entry side.
///@}
// For (un)linking.
#define DDLINK_SECTOR 0x1
#define DDLINK_BLOCKMAP 0x2
#define DDLINK_NOLINE 0x4
typedef enum intercepttype_e {
ICPT_MOBJ,
ICPT_LINE
} intercepttype_t;
typedef struct intercept_s {
float distance; // Along trace vector as a fraction.
intercepttype_t type;
union {
struct mobj_s* mobj;
struct linedef_s* lineDef;
} d;
} intercept_t;
typedef int (*traverser_t) (const intercept_t* intercept, void* paramaters);
/**
* A simple POD data structure for representing line trace openings.
*/
typedef struct {
/// Top and bottom z of the opening.
float top, bottom;
/// Distance from top to bottom.
float range;
/// Z height of the lowest Plane at the opening on the X|Y axis.
/// @todo Does not belong here?
float lowFloor;
} TraceOpening;
//------------------------------------------------------------------------
//
// Mobjs
//
//------------------------------------------------------------------------
/// @defgroup mobj Map Objects
/// @ingroup map
/**
* Linknodes are used when linking mobjs to lines. Each mobj has a ring
* of linknodes, each node pointing to a line the mobj has been linked to.
* Correspondingly each line has a ring of nodes, with pointers to the
* mobjs that are linked to that particular line. This way it is possible
* that a single mobj is linked simultaneously to multiple lines (which
* is common).
*
* All these rings are maintained by P_MobjLink() and P_MobjUnlink().
* @ingroup mobj
*/
typedef struct linknode_s {
nodeindex_t prev, next;
void* ptr;
int data;
} linknode_t;
/**
* @defgroup stateFlags State Flags
* @ingroup mobj
*/
///@{
#define STF_FULLBRIGHT 0x00000001
#define STF_NOAUTOLIGHT 0x00000002 ///< Don't automatically add light if fullbright.
///@}
/**
* @defgroup mobjFlags Mobj Flags
* @ingroup mobj
*/
///@{
#define DDMF_DONTDRAW 0x00000001
#define DDMF_SHADOW 0x00000002
#define DDMF_ALTSHADOW 0x00000004
#define DDMF_BRIGHTSHADOW 0x00000008
#define DDMF_VIEWALIGN 0x00000010
#define DDMF_FITTOP 0x00000020 ///< Don't let the sprite go into the ceiling.
#define DDMF_NOFITBOTTOM 0x00000040
//#define DDMF_UNUSED1 0x00000080 // Formerly DDMF_NOBLOCKMAP
#define DDMF_LIGHTSCALE 0x00000180 ///< Light scale (0: full, 3: 1/4).
#define DDMF_LIGHTOFFSET 0x0000f000 ///< How to offset light (along Z axis).
//#define DDMF_RESERVED 0x00030000 // Don't touch these!! (translation class).
#define DDMF_BOB 0x00040000 ///< Bob the Z coord up and down.
#define DDMF_LOWGRAVITY 0x00080000 ///< 1/8th gravity (predict).
#define DDMF_MISSILE 0x00100000 ///< Client removes mobj upon impact.
#define DDMF_FLY 0x00200000 ///< Flying object (doesn't matter if airborne).
#define DDMF_NOGRAVITY 0x00400000 ///< Isn't affected by gravity (predict).
#define DDMF_ALWAYSLIT 0x00800000 ///< Always process DL even if hidden.
#define DDMF_SOLID 0x20000000 ///< Solid on client side.
#define DDMF_LOCAL 0x40000000
#define DDMF_REMOTE 0x80000000 ///< This mobj is really on the server.
/// Clear masks (flags the game plugin is not allowed to touch).
#define DDMF_CLEAR_MASK 0xc0000000
#define DDMF_LIGHTSCALESHIFT 7
#define DDMF_LIGHTOFFSETSHIFT 12
///@}
#define DDMOBJ_RADIUS_MAX 32
/// The high byte of the selector is not used for modeldef selecting.
/// 1110 0000 = alpha level (0: opaque => 7: transparent 7/8) @ingroup mobj
#define DDMOBJ_SELECTOR_MASK 0x00ffffff
#define DDMOBJ_SELECTOR_SHIFT 24
#define VISIBLE 1
#define INVISIBLE -1
/// Momentum axis indices. @ingroup mobj
enum { MX, MY, MZ };
/**
* Axis-aligned bounding box with integer precision.
* Handy POD structure for manipulation of bounding boxes. @ingroup map
*/
typedef struct aabox_s {
union {
struct {
int vec4[4];
};
struct {
int arvec2[2][2];
};
struct {
int min[2];
int max[2];
};
struct {
int minX;
int minY;
int maxX;
int maxY;
};
};
} AABox;
/**
* Axis-aligned bounding box with floating-point precision.