forked from diasurgical/devilutionX
-
Notifications
You must be signed in to change notification settings - Fork 1
/
structs.h
2786 lines (2527 loc) · 86.9 KB
/
structs.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 structs.h
*
* Various global structures.
*/
#ifndef _STRUCTS_H
#define _STRUCTS_H
DEVILUTION_BEGIN_NAMESPACE
#ifndef __AMIGA__
#define static_warning(x, msg) static_assert(x, msg)
#else
#define static_warning(x, msg)
#endif
#if INT_MAX == INT32_MAX && INTPTR_MAX == INT32_MAX
#define X86_32bit_COMP
#define ALIGNMENT(x86, x64) int alignment[x86];
#define ALIGNMENT32(num) int alignment[num];
#define ALIGNMENT64(num)
#define ALIGN { 0 }
#define ALIGN32 { 0 }
#define ALIGN64
#elif INT_MAX == INT32_MAX && INTPTR_MAX == INT64_MAX
#define X86_64bit_COMP
#define ALIGNMENT(x86, x64) int alignment[x64];
#define ALIGNMENT32(num)
#define ALIGNMENT64(num) int alignment[num];
#define ALIGN { 0 }
#define ALIGN32
#define ALIGN64 { 0 }
#else
#define ALIGNMENT(x86, x64)
#define ALIGNMENT32(num)
#define ALIGNMENT64(num)
#define ALIGN
#define ALIGN32
#define ALIGN64
#endif
//////////////////////////////////////////////////
// miniwin
//////////////////////////////////////////////////
typedef int32_t INT;
typedef uint8_t BOOLEAN;
typedef uint32_t DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef uint16_t WORD;
typedef unsigned int UINT;
// typedef int32_t WPARAM;
// typedef int32_t LPARAM;
//
// Handles
//
typedef void* HANDLE;
typedef HANDLE HMODULE, HDC, HINSTANCE;
typedef SDL_Event Dvl_Event;
typedef void (*WNDPROC)(const Dvl_Event*);
// typedef struct tagMSG {
// UINT message;
// WPARAM wParam;
// } MSG, *LPMSG;
//////////////////////////////////////////////////
// control
//////////////////////////////////////////////////
typedef struct POS32 {
int x;
int y;
} POS32;
typedef struct AREA32 {
int w;
int h;
} AREA32;
typedef struct RECT32 {
int x;
int y;
int w;
int h;
} RECT32;
typedef struct RECT_AREA32 {
int x1;
int y1;
int x2;
int y2;
} RECT_AREA32;
typedef struct CelImageBuf {
#if DEBUG_MODE
WORD ciWidth; // number of images before loaded, but overwritten with width when loaded
WORD ciFrameCnt; // number of images before loaded, but overwritten with width when loaded
#else
DWORD ciWidth; // number of images before loaded, but overwritten with width when loaded
#endif
BYTE imageData[32000]; // size does not matter, the struct is allocated dynamically
} CelImageBuf;
typedef struct CampaignMapEntry {
BYTE ceDunType;
BYTE ceIndex;
BYTE ceLevel;
BOOLEAN ceAvailable;
} CampaignMapEntry;
//////////////////////////////////////////////////
// items
//////////////////////////////////////////////////
typedef struct RANGE {
BYTE from;
BYTE to;
} RANGE;
typedef struct AffixData {
BYTE PLPower; // item_effect_type
int PLParam1;
int PLParam2;
RANGE PLRanges[NUM_IARS];
int PLIType; // affix_item_type
BOOLEAN PLDouble;
BOOLEAN PLOk;
int PLMinVal;
int PLMaxVal;
int PLMultVal;
} AffixData;
typedef struct UniqItemData {
const char* UIName;
BYTE UIUniqType; // unique_item_type
BYTE UIMinLvl;
uint16_t UICurs;
int UIValue;
BYTE UIPower1; // item_effect_type
int UIParam1a;
int UIParam1b;
BYTE UIPower2; // item_effect_type
int UIParam2a;
int UIParam2b;
BYTE UIPower3; // item_effect_type
int UIParam3a;
int UIParam3b;
BYTE UIPower4; // item_effect_type
int UIParam4a;
int UIParam4b;
BYTE UIPower5; // item_effect_type
int UIParam5a;
int UIParam5b;
BYTE UIPower6; // item_effect_type
int UIParam6a;
int UIParam6b;
ALIGNMENT(3, 2)
} UniqItemData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(UniqItemData) & (sizeof(UniqItemData) - 1)) == 64, "Align UniqItemData to power of 2 for better performance.");
#endif
typedef struct ItemFileData {
const char* ifName; // Map of item type .cel file names.
int idSFX; // sounds effect of dropping the item on ground (_sfx_id).
int iiSFX; // sounds effect of placing the item in the inventory (_sfx_id).
int iAnimLen; // item drop animation length
ALIGNMENT64(3)
} ItemFileData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(ItemFileData) & (sizeof(ItemFileData) - 1)) == 0, "Align ItemFileData to power of 2 for better performance.");
#endif
typedef struct ItemData {
const char* iName;
BYTE iRnd;
BYTE iMinMLvl;
BYTE iUniqType; // unique_item_type
int iCurs; // item_cursor_graphic
int itype; // item_type
int iMiscId; // item_misc_id
int iSpell; // spell_id
BYTE iClass; // item_class
BYTE iLoc; // item_equip_type
BYTE iDamType; // item_damage_type
BYTE iMinDam;
BYTE iMaxDam;
BYTE iBaseCrit;
BYTE iMinStr;
BYTE iMinMag;
BYTE iMinDex;
BOOLEAN iUsable;
BYTE iMinAC;
BYTE iMaxAC;
BYTE iDurability;
int iValue;
ALIGNMENT(5, 4)
} ItemData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(ItemData) & (sizeof(ItemData) - 1)) == 0, "Align ItemData to power of 2 for better performance.");
#endif
typedef struct ItemStruct {
int32_t _iSeed;
uint16_t _iIdx; // item_indexes
uint16_t _iCreateInfo; // icreateinfo_flag
union {
int _ix;
int _iPHolder; // parent index of a placeholder entry in InvList
};
int _iy;
int _iCurs; // item_cursor_graphic
int _itype; // item_type
int _iMiscId; // item_misc_id
int _iSpell; // spell_id
BYTE _iClass; // item_class enum
BYTE _iLoc; // item_equip_type
BYTE _iDamType; // item_damage_type
BYTE _iMinDam;
BYTE _iMaxDam;
BYTE _iBaseCrit;
BYTE _iMinStr;
BYTE _iMinMag;
BYTE _iMinDex;
BOOLEAN _iUsable; // can be placed in belt, can be consumed/used or stacked (if max durability is not 1)
BYTE _iPrePower; // item_effect_type
BYTE _iSufPower; // item_effect_type
BYTE _iMagical; // item_quality
BYTE _iSelFlag;
BOOLEAN _iFloorFlag;
BOOLEAN _iAnimFlag;
BYTE* _iAnimData; // PSX name -> ItemFrame
unsigned _iAnimFrameLen; // Tick length of each frame in the current animation
unsigned _iAnimCnt; // Increases by one each game tick, counting how close we are to _iAnimFrameLen
unsigned _iAnimLen; // Number of frames in current animation
unsigned _iAnimFrame; // Current frame of animation.
//int _iAnimWidth;
//int _iAnimXOffset;
BOOL _iPostDraw; // should be drawn during the post-phase (magic rock on the stand) -- unused
BOOL _iIdentified;
char _iName[32];
int _ivalue;
int _iIvalue;
int _iAC;
int _iPLFlags; // item_special_effect
int _iCharges;
int _iMaxCharges;
int _iDurability;
int _iMaxDur;
int _iPLDam;
int _iPLToHit;
int _iPLAC;
int _iPLStr;
int _iPLMag;
int _iPLDex;
int _iPLVit;
int _iPLFR;
int _iPLLR;
int _iPLMR;
int _iPLAR;
int _iPLMana;
int _iPLHP;
int _iPLDamMod;
int _iPLGetHit;
int8_t _iPLLight;
int8_t _iPLSkillLevels;
BYTE _iPLSkill;
int8_t _iPLSkillLvl;
BYTE _iPLManaSteal;
BYTE _iPLLifeSteal;
BYTE _iPLCrit;
BOOLEAN _iStatFlag;
int _iUid; // unique_item_indexes
BYTE _iPLFMinDam;
BYTE _iPLFMaxDam;
BYTE _iPLLMinDam;
BYTE _iPLLMaxDam;
BYTE _iPLMMinDam;
BYTE _iPLMMaxDam;
BYTE _iPLAMinDam;
BYTE _iPLAMaxDam;
ALIGNMENT(9, 8)
} ItemStruct;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(ItemStruct) & (sizeof(ItemStruct) - 1)) == 0, "Align ItemStruct closer to power of 2 for better performance.");
#endif
//////////////////////////////////////////////////
// player
//////////////////////////////////////////////////
typedef struct PlrAnimType {
char patTxt[4]; // suffix to select the player animation CL2
int patGfxIdx; // player_graphic_idx
} PlrAnimType;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(PlrAnimType) & (sizeof(PlrAnimType) - 1)) == 0, "Align PlrAnimType closer to power of 2 for better performance.");
#endif
typedef struct PlrAnimStruct {
BYTE* paAnimData[NUM_DIRS];
unsigned paFrames;
int paAnimWidth;
} PlrAnimStruct;
#ifdef X86_32bit_COMP
static_warning((sizeof(PlrAnimStruct) & (sizeof(PlrAnimStruct) - 1)) == 32, "Align PlrAnimStruct closer to power of 2 for better performance.");
#elif defined(X86_64bit_COMP)
static_warning((sizeof(PlrAnimStruct) & (sizeof(PlrAnimStruct) - 1)) == 64, "Align PlrAnimStruct closer to power of 2 for better performance.");
#endif
typedef struct PlayerStruct {
int _pmode; // PLR_MODE
int _pDestAction;
int _pDestParam1;
int _pDestParam2;
int _pDestParam3; // the skill to be used in case of skill based actions
int _pDestParam4; // the level of the skill to be used in case of skill based actions
BOOLEAN _pActive;
BYTE _pInvincible;
BOOLEAN _pLvlChanging; // True when the player is transitioning between levels
BYTE _pDunLevel; // dungeon_level
BYTE _pClass; // plr_class
BYTE _pLevel;
BYTE _pRank;
BYTE _pTeam;
uint16_t _pStatPts;
BYTE _pLightRad;
BYTE _pManaShield;
int16_t _pTimer[NUM_PLRTIMERS];
unsigned _pExperience;
unsigned _pNextExper;
int _px; // Tile X-position where the player should be drawn
int _py; // Tile Y-position where the player should be drawn
int _pfutx; // Future tile X-position where the player will be at the end of its action
int _pfuty; // Future tile Y-position where the player will be at the end of its action
int _poldx; // Most recent tile X-position where the player was at the start of its action
int _poldy; // Most recent tile Y-position where the player was at the start of its action
int _pxoff; // Pixel X-offset from tile position where the player should be drawn
int _pyoff; // Pixel Y-offset from tile position where the player should be drawn
int _pdir; // Direction faced by player (direction enum)
BYTE* _pAnimData;
int _pAnimFrameLen; // Tick length of each frame in the current animation
int _pAnimCnt; // Increases by one each game tick, counting how close we are to _pAnimFrameLen
unsigned _pAnimLen; // Number of frames in current animation
unsigned _pAnimFrame; // Current frame of animation.
int _pAnimWidth;
int _pAnimXOffset;
unsigned _plid; // light id of the player
unsigned _pvid; // vision id of the player
BYTE _pAtkSkill; // the selected attack skill for the primary action
BYTE _pAtkSkillType; // the (RSPLTYPE_)type of the attack skill for the primary action
BYTE _pMoveSkill; // the selected movement skill for the primary action
BYTE _pMoveSkillType; // the (RSPLTYPE_)type of the movement skill for the primary action
BYTE _pAltAtkSkill; // the selected attack skill for the secondary action
BYTE _pAltAtkSkillType; // the (RSPLTYPE_)type of the attack skill for the secondary action
BYTE _pAltMoveSkill; // the selected movement skill for the secondary action
BYTE _pAltMoveSkillType; // the (RSPLTYPE_)type of the movement skill for the secondary action
BYTE _pAtkSkillHotKey[4]; // the attack skill selected by the hotkey
BYTE _pAtkSkillTypeHotKey[4]; // the (RSPLTYPE_)type of the attack skill selected by the hotkey
BYTE _pMoveSkillHotKey[4]; // the movement skill selected by the hotkey
BYTE _pMoveSkillTypeHotKey[4]; // the (RSPLTYPE_)type of the movement skill selected by the hotkey
BYTE _pAltAtkSkillHotKey[4]; // the attack skill selected by the alt-hotkey
BYTE _pAltAtkSkillTypeHotKey[4]; // the (RSPLTYPE_)type of the attack skill selected by the alt-hotkey
BYTE _pAltMoveSkillHotKey[4]; // the movement skill selected by the alt-hotkey
BYTE _pAltMoveSkillTypeHotKey[4]; // the (RSPLTYPE_)type of the movement skill selected by the alt-hotkey
BYTE _pAtkSkillSwapKey[4]; // the attack skill selected by the hotkey after skill-set swap
BYTE _pAtkSkillTypeSwapKey[4]; // the (RSPLTYPE_)type of the attack skill selected by the hotkey after skill-set swap
BYTE _pMoveSkillSwapKey[4]; // the movement skill selected by the hotkey after skill-set swap
BYTE _pMoveSkillTypeSwapKey[4]; // the (RSPLTYPE_)type of the movement skill selected by the hotkey after skill-set swap
BYTE _pAltAtkSkillSwapKey[4]; // the attack skill selected by the alt-hotkey after skill-set swap
BYTE _pAltAtkSkillTypeSwapKey[4]; // the (RSPLTYPE_)type of the attack skill selected by the alt-hotkey after skill-set swap
BYTE _pAltMoveSkillSwapKey[4]; // the movement skill selected by the alt-hotkey after skill-set swap
BYTE _pAltMoveSkillTypeSwapKey[4]; // the (RSPLTYPE_)type of the movement skill selected by the alt-hotkey after skill-set swap
BYTE _pSkillLvlBase[64]; // the skill levels of the player if they would not wear an item
BYTE _pSkillActivity[64];
unsigned _pSkillExp[64];
uint64_t _pMemSkills; // Bitmask of learned skills
uint64_t _pAblSkills; // Bitmask of abilities
uint64_t _pInvSkills; // Bitmask of skills available via items in inventory (scrolls or runes)
char _pName[PLR_NAME_LEN];
uint16_t _pBaseStr;
uint16_t _pBaseMag;
uint16_t _pBaseDex;
uint16_t _pBaseVit;
int _pHPBase; // the hp of the player if they would not wear an item
int _pMaxHPBase; // the maximum hp of the player without items
int _pManaBase; // the mana of the player if they would not wear an item
int _pMaxManaBase; // the maximum mana of the player without items
int _pVar1;
int _pVar2;
int _pVar3;
int _pVar4;
int _pVar5;
int _pVar6;
int _pVar7;
int _pVar8;
int _pGFXLoad; // flags of the loaded gfx('s) (player_graphic_flag)
PlrAnimStruct _pAnims[NUM_PGXS];
unsigned _pAFNum; // action frame number of the attack animation
unsigned _pSFNum; // action frame number of the spell animation
ItemStruct _pHoldItem;
ItemStruct _pInvBody[NUM_INVLOC];
ItemStruct _pSpdList[MAXBELTITEMS];
ItemStruct _pInvList[NUM_INV_GRID_ELEM];
int _pGold;
int _pStrength;
int _pMagic;
int _pDexterity;
int _pVitality;
int _pHitPoints; // the current hp of the player
int _pMaxHP; // the maximum hp of the player
int _pMana; // the current mana of the player
int _pMaxMana; // the maximum mana of the player
BYTE _pSkillLvl[64]; // the skill levels of the player
uint64_t _pISpells; // Bitmask of skills available via equipped items (staff)
BYTE _pSkillFlags; // Bitmask of allowed skill-types (SFLAG_*)
BOOLEAN _pInfraFlag;
BYTE _pgfxnum; // Bitmask indicating what variant of the sprite the player is using. Lower byte define weapon (anim_weapon_id) and higher values define armour (starting with anim_armor_id)
BOOLEAN _pHasUnidItem; // whether the player has an unidentified (magic) item equipped
int _pISlMinDam; // min slash-damage (swords, axes)
int _pISlMaxDam; // max slash-damage (swords, axes)
int _pIBlMinDam; // min blunt-damage (maces, axes)
int _pIBlMaxDam; // max blunt-damage (maces, axes)
int _pIPcMinDam; // min puncture-damage (bows, daggers)
int _pIPcMaxDam; // max puncture-damage (bows, daggers)
int _pIChMinDam; // min charge-damage (shield charge)
int _pIChMaxDam; // max charge-damage (shield charge)
int _pIEvasion;
int _pIAC;
int8_t _pMagResist;
int8_t _pFireResist;
int8_t _pLghtResist;
int8_t _pAcidResist;
int _pIHitChance;
BYTE _pIBaseHitBonus; // indicator whether the base BonusToHit of the items is positive/negative/neutral
BYTE _pICritChance; // 200 == 100%
uint16_t _pIBlockChance;
unsigned _pIFlags; // item_special_effect
BYTE _pIWalkSpeed;
BYTE _pIRecoverySpeed;
BYTE _pIBaseCastSpeed;
BYTE _pAlign_B1;
int _pIGetHit;
BYTE _pIBaseAttackSpeed;
int8_t _pIArrowVelBonus; // _pISplCost in vanilla code
BYTE _pILifeSteal;
BYTE _pIManaSteal;
int _pIFMinDam; // min fire damage (item's added fire damage)
int _pIFMaxDam; // max fire damage (item's added fire damage)
int _pILMinDam; // min lightning damage (item's added lightning damage)
int _pILMaxDam; // max lightning damage (item's added lightning damage)
int _pIMMinDam; // min magic damage (item's added magic damage)
int _pIMMaxDam; // max magic damage (item's added magic damage)
int _pIAMinDam; // min acid damage (item's added acid damage)
int _pIAMaxDam; // max acid damage (item's added acid damage)
BYTE* _pAnimFileData[NUM_PGXS]; // file-pointers of the animations
ALIGNMENT(185, 100)
} PlayerStruct;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(PlayerStruct) & (sizeof(PlayerStruct) - 1)) == 0, "Align PlayerStruct closer to power of 2 for better performance.");
#endif
//////////////////////////////////////////////////
// textdat
//////////////////////////////////////////////////
typedef struct TextData {
const char* txtstr;
BOOLEAN scrlltxt;
BOOLEAN txtsfxset;
int txtspd;
int sfxnr; // _sfx_id or sfx_set if txtsfxset is true
} TextData;
//////////////////////////////////////////////////
// missiles
//////////////////////////////////////////////////
typedef struct MissileData {
int (*mAddProc)(int, int, int, int, int, int, int, int, int);
void (*mProc)(int);
BYTE mdFlags; // missile_flags
BYTE mResist; // missile_resistance
BYTE mFileNum; // missile_gfx_id
BOOLEAN mDrawFlag;
int mlSFX; // sound effect when a missile is launched (_sfx_id)
int miSFX; // sound effect on impact (_sfx_id)
BYTE mlSFXCnt; // number of launch sound effects to choose from
BYTE miSFXCnt; // number of impact sound effects to choose from
ALIGNMENT32(2)
} MissileData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(MissileData) & (sizeof(MissileData) - 1)) == 0, "Align MissileData to power of 2 for better performance.");
#endif
typedef struct MisFileData {
int mfAnimFAmt;
const char* mfName;
const char* mfAnimTrans;
int mfFlags; // missile_anim_flags
BYTE mfAnimFrameLen[16];
BYTE mfAnimLen[16];
int mfAnimWidth;
int mfAnimXOffset; // could be calculated
ALIGNMENT(2, 14)
} MisFileData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(MisFileData) & (sizeof(MisFileData) - 1)) == 0, "Align MisFileData to power of 2 for better performance.");
#endif
typedef struct MissileStruct {
int _miType; // missile_id
BYTE _miFlags; // missile_flags
BYTE _miResist; // missile_resistance
BYTE _miFileNum; // missile_gfx_id
BOOLEAN _miDrawFlag; // should be drawn
int _miUniqTrans; // use unique color-transformation when drawing
BOOLEAN _miDelFlag; // should be deleted
BOOLEAN _miLightFlag; // use light-transformation when drawing
BOOLEAN _miPreFlag; // should be drawn in the pre-phase
BOOLEAN _miAnimFlag;
BYTE* _miAnimData;
int _miAnimFrameLen; // Tick length of each frame in the current animation
int _miAnimLen; // Number of frames in current animation
int _miAnimWidth;
int _miAnimXOffset;
int _miAnimCnt; // Increases by one each game tick, counting how close we are to _miAnimFrameLen
int _miAnimAdd;
int _miAnimFrame; // Current frame of animation.
int _misx; // Initial tile X-position
int _misy; // Initial tile Y-position
int _mix; // Tile X-position where the missile should be drawn
int _miy; // Tile Y-position where the missile should be drawn
int _mixoff; // Pixel X-offset from tile position where the missile should be drawn
int _miyoff; // Pixel Y-offset from tile position where the missile should be drawn
int _mixvel; // Missile tile (X - Y)-velocity while moving. This gets added onto _mitxoff each game tick
int _miyvel; // Missile tile (X + Y)-velocity while moving. This gets added onto _mityoff each game tick
int _mitxoff; // How far the missile has travelled in its lifespan along the (X - Y)-axis. mix/miy/mxoff/myoff get updated every game tick based on this
int _mityoff; // How far the missile has travelled in its lifespan along the (X + Y)-axis. mix/miy/mxoff/myoff get updated every game tick based on this
int _miDir; // The direction of the missile
int _miSpllvl;
int _miSource; // missile_source_type
int _miCaster;
int _miMinDam;
int _miMaxDam;
// int _miRndSeed;
int _miRange;
unsigned _miLid; // light id of the missile
int _miVar1;
int _miVar2;
int _miVar3;
int _miVar4;
int _miVar5;
int _miVar6;
int _miVar7; // distance travelled in case of ARROW missiles
int _miVar8; // last target in case of non-DOT missiles
ALIGNMENT(10, 24)
} MissileStruct;
#ifdef X86_32bit_COMP
static_warning((sizeof(MissileStruct) & (sizeof(MissileStruct) - 1)) == 128, "Align MissileStruct closer to power of 2 for better performance.");
#elif defined(X86_64bit_COMP)
static_warning((sizeof(MissileStruct) & (sizeof(MissileStruct) - 1)) == 0, "Align MissileStruct closer to power of 2 for better performance.");
#endif
//////////////////////////////////////////////////
// effects/sound
//////////////////////////////////////////////////
typedef struct _Mix_Audio Mix_Audio;
typedef struct SoundSample final {
Uint32 nextTc;
Mix_Audio* soundData;
void Release();
bool IsPlaying();
bool IsLoaded() {
return soundData != NULL;
}
void Play(int lVolume, int lPan, int channel);
void SetChunk(BYTE* fileData, size_t dwBytes, bool stream);
//int TrackLength();
} SoundSample;
typedef struct SFXStruct {
BYTE bFlags; // sfx_flag
const char* pszName;
SoundSample pSnd;
} SFXStruct;
//////////////////////////////////////////////////
// monster
//////////////////////////////////////////////////
typedef struct MonAnimStruct {
BYTE* maAnimData[NUM_DIRS];
int maFrames;
int maFrameLen;
} MonAnimStruct;
#ifdef X86_32bit_COMP
static_warning((sizeof(MonAnimStruct) & (sizeof(MonAnimStruct) - 1)) == 32, "Align MonAnimStruct closer to power of 2 for better performance.");
#elif defined(X86_64bit_COMP)
static_warning((sizeof(MonAnimStruct) & (sizeof(MonAnimStruct) - 1)) == 64, "Align MonAnimStruct closer to power of 2 for better performance.");
#endif
typedef struct MonsterAI {
BYTE aiType; // _monster_ai
BYTE aiInt;
BYTE aiParam1;
BYTE aiParam2;
} MonsterAI;
typedef struct MonsterData {
uint16_t moFileNum; // _monster_gfx_id
BYTE mLevel;
BYTE mSelFlag;
const char* mTransFile;
const char* mName;
MonsterAI mAI;
uint16_t mMinHP;
uint16_t mMaxHP;
unsigned mFlags; // _monster_flag
uint16_t mHit; // hit chance (melee+projectile)
BYTE mMinDamage;
BYTE mMaxDamage;
uint16_t mHit2; // hit chance of special melee attacks
BYTE mMinDamage2;
BYTE mMaxDamage2;
BYTE mMagic; // hit chance of magic-projectile
BYTE mMagic2; // unused
BYTE mArmorClass; // AC+evasion: used against physical-hit (melee+projectile)
BYTE mEvasion; // evasion: used against magic-projectile
uint16_t mMagicRes; // resistances in normal and nightmare difficulties (_monster_resistance)
uint16_t mMagicRes2; // resistances in hell difficulty (_monster_resistance)
uint16_t mExp;
ALIGNMENT(5, 2)
} MonsterData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(MonsterData) & (sizeof(MonsterData) - 1)) == 0, "Align MonsterData to power of 2 for better performance.");
#endif
typedef struct MonFileData {
int moImage;
const char* moGfxFile;
const char* moSndFile;
int moAnimFrames[NUM_MON_ANIM];
int moAnimFrameLen[NUM_MON_ANIM];
BYTE moWidth;
BOOLEAN moSndSpecial;
BYTE moAFNum;
BYTE moAFNum2;
} MonFileData;
#ifdef X86_32bit_COMP
static_warning((sizeof(MonFileData) & (sizeof(MonFileData) - 1)) == 0, "Align MonFileData to power of 2 for better performance.");
#elif defined(X86_64bit_COMP)
static_warning((sizeof(MonFileData) & (sizeof(MonFileData) - 1)) == 64, "Align MonFileData to power of 2 for better performance.");
#endif
#pragma pack(push, 1)
typedef struct MapMonData {
int cmType;
BOOL cmPlaceScatter;
SoundSample cmSnds[NUM_MON_SFX][2];
BYTE* cmAnimData[NUM_MON_ANIM];
MonAnimStruct cmAnims[NUM_MON_ANIM];
const char* cmName;
uint16_t cmFileNum;
BYTE cmLevel;
BYTE cmSelFlag;
MonsterAI cmAI;
unsigned cmFlags; // _monster_flag
int cmHit; // hit chance (melee+projectile)
int cmMinDamage;
int cmMaxDamage;
int cmHit2; // hit chance of special melee attacks
int cmMinDamage2;
int cmMaxDamage2;
int cmMagic; // hit chance of magic-projectile
int cmArmorClass; // AC+evasion: used against physical-hit (melee+projectile)
int cmEvasion; // evasion: used against magic-projectile
unsigned cmMagicRes; // resistances of the monster (_monster_resistance)
unsigned cmExp;
int cmWidth;
int cmXOffset;
BYTE cmAFNum;
BYTE cmAFNum2;
uint16_t cmAlign_0; // unused
int cmMinHP;
int cmMaxHP;
ALIGNMENT(24, 17);
} MapMonData;
#ifdef X86_32bit_COMP
static_warning((sizeof(MapMonData) & (sizeof(MapMonData) - 1)) == 0, "Align MapMonData closer to power of 2 for better performance.");
#elif defined(X86_64bit_COMP)
static_warning((sizeof(MapMonData) & (sizeof(MapMonData) - 1)) == 512, "Align MapMonData closer to power of 2 for better performance.");
#endif
#pragma pack(pop)
typedef struct MonsterStruct {
int _mmode; // MON_MODE
unsigned _msquelch;
BYTE _mMTidx;
BYTE _mpathcount; // unused
BYTE _mAlign_1; // unused
BYTE _mgoal;
int _mgoalvar1;
int _mgoalvar2;
int _mgoalvar3;
int _mx; // Tile X-position where the monster should be drawn
int _my; // Tile Y-position where the monster should be drawn
int _mfutx; // Future tile X-position where the monster will be at the end of its action
int _mfuty; // Future tile Y-position where the monster will be at the end of its action
int _moldx; // Most recent tile X-position where the monster was at the start of its action
int _moldy; // Most recent tile Y-position where the monster was at the start of its action
int _mxoff; // Pixel X-offset from tile position where the monster should be drawn
int _myoff; // Pixel Y-offset from tile position where the monster should be drawn
int _mdir; // Direction faced by monster (direction enum)
int _menemy; // The current target of the monster. An index in to either the plr or monster array depending on _mFlags (MFLAG_TARGETS_MONSTER)
BYTE _menemyx; // Future (except for teleporting) tile X-coordinate of the enemy
BYTE _menemyy; // Future (except for teleporting) tile Y-coordinate of the enemy
BYTE _mListener; // the player to whom the monster is talking to (unused)
BOOLEAN _mDelFlag; // unused
BYTE* _mAnimData;
int _mAnimFrameLen; // Tick length of each frame in the current animation
int _mAnimCnt; // Increases by one each game tick, counting how close we are to _mAnimFrameLen
int _mAnimLen; // Number of frames in current animation
int _mAnimFrame; // Current frame of animation.
int _mVar1;
int _mVar2;
int _mVar3; // Used to store the original mode of a stoned monster. Not 'thread' safe -> do not use for anything else!
int _mVar4;
int _mVar5;
int _mVar6;
int _mVar7;
int _mVar8;
int _mmaxhp;
int _mhitpoints;
int _mlastx; // the last known (future) tile X-coordinate of the enemy
int _mlasty; // the last known (future) tile Y-coordinate of the enemy
int32_t _mRndSeed;
int32_t _mAISeed;
BYTE _muniqtype;
BYTE _muniqtrans;
BYTE _mNameColor; // color of the tooltip. white: normal, blue: pack; gold: unique. (text_color)
BYTE _mlid; // light id of the monster
BYTE _mleader; // the leader of the monster
BYTE _mleaderflag; // the status of the monster's leader
BYTE _mpacksize; // the number of 'pack'-monsters close to their leader
BYTE _mvid; // vision id of the monster (for minions only)
const char* _mName;
uint16_t _mFileNum; // _monster_gfx_id
BYTE _mLevel;
BYTE _mSelFlag;
MonsterAI _mAI;
unsigned _mFlags; // _monster_flag
int _mHit; // hit chance (melee+projectile)
int _mMinDamage;
int _mMaxDamage;
int _mHit2; // hit chance of special melee attacks
int _mMinDamage2;
int _mMaxDamage2;
int _mMagic; // hit chance of magic-projectile
int _mArmorClass; // AC+evasion: used against physical-hit (melee+projectile)
int _mEvasion; // evasion: used against magic-projectile
unsigned _mMagicRes; // resistances of the monster (_monster_resistance)
unsigned _mExp;
int _mAnimWidth;
int _mAnimXOffset;
BYTE _mAFNum; // action frame number of the attack animation
BYTE _mAFNum2; // action frame number of the special animation
uint16_t _mAlign_0; // unused
int _mType; // _monster_id
MonAnimStruct* _mAnims;
ALIGNMENT(6, 2)
} MonsterStruct;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(MonsterStruct) & (sizeof(MonsterStruct) - 1)) == 0, "Align MonsterStruct to power of 2 for better performance.");
#endif
typedef struct MonEnemyStruct {
int _meLastDir; // direction
int _meRealDir; // direction
int _meRealDist;
} MonEnemyStruct;
typedef struct UniqMonData {
int mtype; // _monster_id
const char* mName;
const char* mTrnName;
BYTE muLevelIdx; // level-index to place the monster (dungeon_level)
BYTE muLevel; // difficulty level of the monster
uint16_t mmaxhp;
MonsterAI mAI;
BYTE mMinDamage;
BYTE mMaxDamage;
BYTE mMinDamage2;
BYTE mMaxDamage2;
uint16_t mMagicRes; // resistances in normal and nightmare difficulties (_monster_resistance)
uint16_t mMagicRes2; // resistances in hell difficulty (_monster_resistance)
BYTE mUnqFlags;// _uniq_monster_flag
BYTE mUnqHit; // to-hit (melee+projectile) bonus
BYTE mUnqHit2; // to-hit (special melee attacks) bonus
BYTE mUnqMag; // to-hit (magic-projectile) bonus
BYTE mUnqEva; // evasion bonus
BYTE mUnqAC; // armor class bonus
BYTE mQuestId; // quest_id
int mtalkmsg; // _speech_id
ALIGNMENT(6, 2)
} UniqMonData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(UniqMonData) & (sizeof(UniqMonData) - 1)) == 0, "Align UniqMonData to power of 2 for better performance.");
#endif
//////////////////////////////////////////////////
// objects
//////////////////////////////////////////////////
typedef struct ObjectData {
BYTE ofindex; // object_graphic_id
BYTE oLvlTypes; // dungeon_type_mask
BYTE otheme; // theme_id
BYTE oquest; // quest_id
//BYTE oAnimFlag;
BYTE oAnimBaseFrame; // The starting/base frame of (initially) non-animated objects
//int oAnimFrameLen; // Tick length of each frame in the current animation
//int oAnimLen; // Number of frames in current animation
//int oAnimWidth;
//int oSFX;
//BYTE oSFXCnt;
BYTE oLightRadius;
int8_t oLightOffX;
int8_t oLightOffY;
BYTE oProc; // object_proc_func
BYTE oModeFlags; // object_mode_flags
//BOOL oSolidFlag;
//BYTE oBreak;
BOOLEAN oMissFlag;
BYTE oDoorFlag; // object_door_type
BYTE oSelFlag;
BYTE oPreFlag;
BOOLEAN oTrapFlag;
BYTE oAlign[1];
} ObjectData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(ObjectData) & (sizeof(ObjectData) - 1)) == 0, "Align ObjectData closer to power of 2 for better performance.");
#endif
typedef struct ObjFileData {
const char* ofName;
int oSFX; // _sfx_id
BYTE oSFXCnt;
BYTE oAnimFlag; // object_anim_mode
int oAnimFrameLen; // Tick length of each frame in the current animation
int oAnimLen; // Number of frames in current animation
int oAnimWidth;
BOOLEAN oSolidFlag;
BYTE oBreak; // object_break_mode
ALIGNMENT32(1)
} ObjFileData;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(ObjFileData) & (sizeof(ObjFileData) - 1)) == 0, "Align ObjFileData closer to power of 2 for better performance.");
#endif
typedef struct ObjectStruct {
int _otype; // _object_id
int _ox; // Tile X-position of the object
int _oy; // Tile Y-position of the object
int _oSFX; // _sfx_id
BYTE _oSFXCnt;
BYTE _oAnimFlag; // object_anim_mode
BYTE _oProc; // object_proc_func
BYTE _oModeFlags; // object_mode_flags
BYTE* _oAnimData;
int _oAnimFrameLen; // Tick length of each frame in the current animation
int _oAnimCnt; // Increases by one each game tick, counting how close we are to _oAnimFrameLen
int _oAnimLen; // Number of frames in current animation
int _oAnimFrame; // Current frame of animation.
int _oAnimWidth;
int _oAnimXOffset;
//BOOL _oDelFlag;
BOOLEAN _oSolidFlag;
BYTE _oBreak; // object_break_mode
BYTE _oTrapChance;
BYTE _oAlign;
BOOLEAN _oMissFlag;
BYTE _oDoorFlag; // object_door_type
BYTE _oSelFlag;
BOOLEAN _oPreFlag;
unsigned _olid; // light id of the object
int32_t _oRndSeed;
int _oVar1;
int _oVar2;
int _oVar3;
int _oVar4;
int _oVar5;
int _oVar6;
int _oVar7;
int _oVar8;
ALIGNMENT(8, 6)
} ObjectStruct;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(ObjectStruct) & (sizeof(ObjectStruct) - 1)) == 0, "Align ObjectStruct to power of 2 for better performance.");
#endif
//////////////////////////////////////////////////
// portal
//////////////////////////////////////////////////
typedef struct PortalStruct {
int _rlevel; // the destination-level of the portal (dungeon_level). DLV_TOWN if not open.
int _rx;
int _ry;
ALIGNMENT(1, 1)
} PortalStruct;
#if defined(X86_32bit_COMP) || defined(X86_64bit_COMP)
static_warning((sizeof(PortalStruct) & (sizeof(PortalStruct) - 1)) == 0, "Align PortalStruct closer to power of 2 for better performance.");
#endif
//////////////////////////////////////////////////
// endianness
//////////////////////////////////////////////////
typedef struct LE_UINT16 {
uint16_t _value;
void operator=(uint16_t val) {
_value = SwapLE16(val);
};
//void operator=(const LE_UINT16& val) {
// _value = val._value;
//};
template <class T>
void operator=(T) = delete;
bool operator==(const LE_UINT16 & oval) const {
return _value == oval._value;
};
bool operator!=(const LE_UINT16& oval) const {
return _value != oval._value;
};
operator uint16_t() const { return SwapLE16(_value); }
} LE_UINT16;
typedef struct LE_INT16 {
int16_t _value;
void operator=(int16_t val) {
_value = SwapLE16(val);
};
//void operator=(const LE_INT32& val) {
// _value = val._value;
//};
template <class T>
void operator=(T) = delete;
bool operator==(const LE_INT16 & oval) const {
return _value == oval._value;
};
bool operator!=(const LE_INT16& oval) const {
return _value != oval._value;
};
operator int16_t() const { return SwapLE16(_value); }
} LE_INT16;
typedef struct LE_UINT32 {
uint32_t _value;
void operator=(unsigned val) {
_value = SwapLE32(val);
};
void operator=(unsigned long val) {
_value = SwapLE32(val);
};
#if INT_MAX != INT32_MAX
void operator=(uint32_t val) {
_value = SwapLE32(val);
};
#endif
//void operator=(const LE_UINT32& val) {
// _value = val._value;