-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgame.c
16870 lines (14158 loc) · 443 KB
/
game.c
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
// ============================================================================
// Rocks'n'Diamonds - McDuffin Strikes Back!
// ----------------------------------------------------------------------------
// (c) 1995-2014 by Artsoft Entertainment
// Holger Schemel
// http://www.artsoft.org/
// ----------------------------------------------------------------------------
// game.c
// ============================================================================
#include "libgame/libgame.h"
#include "game.h"
#include "init.h"
#include "tools.h"
#include "screens.h"
#include "events.h"
#include "files.h"
#include "tape.h"
#include "network.h"
#include "anim.h"
// ([email protected]) - September 2019
// sprite IDs are used for custom controllers for object tracking
int spriteIDs[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
int spriteIDCounter;
#define MAYBE_UNUSED __attribute__((used))
#ifdef HEADLESS
#define hasStartedNetworkGame() TRUE
#endif
// DEBUG SETTINGS
#define DEBUG_INIT_PLAYER 1
#define DEBUG_PLAYER_ACTIONS 0
// EXPERIMENTAL STUFF
#define USE_NEW_AMOEBA_CODE FALSE
// EXPERIMENTAL STUFF
#define USE_QUICKSAND_BD_ROCK_BUGFIX 0
#define USE_QUICKSAND_IMPACT_BUGFIX 0
#define USE_DELAYED_GFX_REDRAW 0
#define USE_NEW_PLAYER_ASSIGNMENTS 1
#ifndef HEADLESS
#if USE_DELAYED_GFX_REDRAW
#define TEST_DrawLevelField(x, y) \
GfxRedraw[x][y] |= GFX_REDRAW_TILE
#define TEST_DrawLevelFieldCrumbled(x, y) \
GfxRedraw[x][y] |= GFX_REDRAW_TILE_CRUMBLED
#define TEST_DrawLevelFieldCrumbledNeighbours(x, y) \
GfxRedraw[x][y] |= GFX_REDRAW_TILE_CRUMBLED_NEIGHBOURS
#define TEST_DrawTwinkleOnField(x, y) \
GfxRedraw[x][y] |= GFX_REDRAW_TILE_TWINKLED
#else
#define TEST_DrawLevelField(x, y) \
DrawLevelField(x, y)
#define TEST_DrawLevelFieldCrumbled(x, y) \
DrawLevelFieldCrumbled(x, y)
#define TEST_DrawLevelFieldCrumbledNeighbours(x, y) \
DrawLevelFieldCrumbledNeighbours(x, y)
#define TEST_DrawTwinkleOnField(x, y) \
DrawTwinkleOnField(x, y)
#endif
#endif
// for DigField()
#define DF_NO_PUSH 0
#define DF_DIG 1
#define DF_SNAP 2
// for MovePlayer()
#define MP_NO_ACTION 0
#define MP_MOVING 1
#define MP_ACTION 2
#define MP_DONT_RUN_INTO (MP_MOVING | MP_ACTION)
// for ScrollPlayer()
#define SCROLL_INIT 0
#define SCROLL_GO_ON 1
// for Bang()/Explode()
#define EX_PHASE_START 0
#define EX_TYPE_NONE 0
#define EX_TYPE_NORMAL (1 << 0)
#define EX_TYPE_CENTER (1 << 1)
#define EX_TYPE_BORDER (1 << 2)
#define EX_TYPE_CROSS (1 << 3)
#define EX_TYPE_DYNA (1 << 4)
#define EX_TYPE_SINGLE_TILE (EX_TYPE_CENTER | EX_TYPE_BORDER)
#define PANEL_OFF() (game.panel.active == FALSE)
#define PANEL_DEACTIVATED(p) ((p)->x < 0 || (p)->y < 0 || PANEL_OFF())
#define PANEL_XPOS(p) (DX + ALIGNED_TEXT_XPOS(p))
#define PANEL_YPOS(p) (DY + ALIGNED_TEXT_YPOS(p))
// game panel display and control definitions
#define GAME_PANEL_LEVEL_NUMBER 0
#define GAME_PANEL_GEMS 1
#define GAME_PANEL_INVENTORY_COUNT 2
#define GAME_PANEL_INVENTORY_FIRST_1 3
#define GAME_PANEL_INVENTORY_FIRST_2 4
#define GAME_PANEL_INVENTORY_FIRST_3 5
#define GAME_PANEL_INVENTORY_FIRST_4 6
#define GAME_PANEL_INVENTORY_FIRST_5 7
#define GAME_PANEL_INVENTORY_FIRST_6 8
#define GAME_PANEL_INVENTORY_FIRST_7 9
#define GAME_PANEL_INVENTORY_FIRST_8 10
#define GAME_PANEL_INVENTORY_LAST_1 11
#define GAME_PANEL_INVENTORY_LAST_2 12
#define GAME_PANEL_INVENTORY_LAST_3 13
#define GAME_PANEL_INVENTORY_LAST_4 14
#define GAME_PANEL_INVENTORY_LAST_5 15
#define GAME_PANEL_INVENTORY_LAST_6 16
#define GAME_PANEL_INVENTORY_LAST_7 17
#define GAME_PANEL_INVENTORY_LAST_8 18
#define GAME_PANEL_KEY_1 19
#define GAME_PANEL_KEY_2 20
#define GAME_PANEL_KEY_3 21
#define GAME_PANEL_KEY_4 22
#define GAME_PANEL_KEY_5 23
#define GAME_PANEL_KEY_6 24
#define GAME_PANEL_KEY_7 25
#define GAME_PANEL_KEY_8 26
#define GAME_PANEL_KEY_WHITE 27
#define GAME_PANEL_KEY_WHITE_COUNT 28
#define GAME_PANEL_SCORE 29
#define GAME_PANEL_HIGHSCORE 30
#define GAME_PANEL_TIME 31
#define GAME_PANEL_TIME_HH 32
#define GAME_PANEL_TIME_MM 33
#define GAME_PANEL_TIME_SS 34
#define GAME_PANEL_TIME_ANIM 35
#define GAME_PANEL_HEALTH 36
#define GAME_PANEL_HEALTH_ANIM 37
#define GAME_PANEL_FRAME 38
#define GAME_PANEL_SHIELD_NORMAL 39
#define GAME_PANEL_SHIELD_NORMAL_TIME 40
#define GAME_PANEL_SHIELD_DEADLY 41
#define GAME_PANEL_SHIELD_DEADLY_TIME 42
#define GAME_PANEL_EXIT 43
#define GAME_PANEL_EMC_MAGIC_BALL 44
#define GAME_PANEL_EMC_MAGIC_BALL_SWITCH 45
#define GAME_PANEL_LIGHT_SWITCH 46
#define GAME_PANEL_LIGHT_SWITCH_TIME 47
#define GAME_PANEL_TIMEGATE_SWITCH 48
#define GAME_PANEL_TIMEGATE_SWITCH_TIME 49
#define GAME_PANEL_SWITCHGATE_SWITCH 50
#define GAME_PANEL_EMC_LENSES 51
#define GAME_PANEL_EMC_LENSES_TIME 52
#define GAME_PANEL_EMC_MAGNIFIER 53
#define GAME_PANEL_EMC_MAGNIFIER_TIME 54
#define GAME_PANEL_BALLOON_SWITCH 55
#define GAME_PANEL_DYNABOMB_NUMBER 56
#define GAME_PANEL_DYNABOMB_SIZE 57
#define GAME_PANEL_DYNABOMB_POWER 58
#define GAME_PANEL_PENGUINS 59
#define GAME_PANEL_SOKOBAN_OBJECTS 60
#define GAME_PANEL_SOKOBAN_FIELDS 61
#define GAME_PANEL_ROBOT_WHEEL 62
#define GAME_PANEL_CONVEYOR_BELT_1 63
#define GAME_PANEL_CONVEYOR_BELT_2 64
#define GAME_PANEL_CONVEYOR_BELT_3 65
#define GAME_PANEL_CONVEYOR_BELT_4 66
#define GAME_PANEL_CONVEYOR_BELT_1_SWITCH 67
#define GAME_PANEL_CONVEYOR_BELT_2_SWITCH 68
#define GAME_PANEL_CONVEYOR_BELT_3_SWITCH 69
#define GAME_PANEL_CONVEYOR_BELT_4_SWITCH 70
#define GAME_PANEL_MAGIC_WALL 71
#define GAME_PANEL_MAGIC_WALL_TIME 72
#define GAME_PANEL_GRAVITY_STATE 73
#define GAME_PANEL_GRAPHIC_1 74
#define GAME_PANEL_GRAPHIC_2 75
#define GAME_PANEL_GRAPHIC_3 76
#define GAME_PANEL_GRAPHIC_4 77
#define GAME_PANEL_GRAPHIC_5 78
#define GAME_PANEL_GRAPHIC_6 79
#define GAME_PANEL_GRAPHIC_7 80
#define GAME_PANEL_GRAPHIC_8 81
#define GAME_PANEL_ELEMENT_1 82
#define GAME_PANEL_ELEMENT_2 83
#define GAME_PANEL_ELEMENT_3 84
#define GAME_PANEL_ELEMENT_4 85
#define GAME_PANEL_ELEMENT_5 86
#define GAME_PANEL_ELEMENT_6 87
#define GAME_PANEL_ELEMENT_7 88
#define GAME_PANEL_ELEMENT_8 89
#define GAME_PANEL_ELEMENT_COUNT_1 90
#define GAME_PANEL_ELEMENT_COUNT_2 91
#define GAME_PANEL_ELEMENT_COUNT_3 92
#define GAME_PANEL_ELEMENT_COUNT_4 93
#define GAME_PANEL_ELEMENT_COUNT_5 94
#define GAME_PANEL_ELEMENT_COUNT_6 95
#define GAME_PANEL_ELEMENT_COUNT_7 96
#define GAME_PANEL_ELEMENT_COUNT_8 97
#define GAME_PANEL_CE_SCORE_1 98
#define GAME_PANEL_CE_SCORE_2 99
#define GAME_PANEL_CE_SCORE_3 100
#define GAME_PANEL_CE_SCORE_4 101
#define GAME_PANEL_CE_SCORE_5 102
#define GAME_PANEL_CE_SCORE_6 103
#define GAME_PANEL_CE_SCORE_7 104
#define GAME_PANEL_CE_SCORE_8 105
#define GAME_PANEL_CE_SCORE_1_ELEMENT 106
#define GAME_PANEL_CE_SCORE_2_ELEMENT 107
#define GAME_PANEL_CE_SCORE_3_ELEMENT 108
#define GAME_PANEL_CE_SCORE_4_ELEMENT 109
#define GAME_PANEL_CE_SCORE_5_ELEMENT 110
#define GAME_PANEL_CE_SCORE_6_ELEMENT 111
#define GAME_PANEL_CE_SCORE_7_ELEMENT 112
#define GAME_PANEL_CE_SCORE_8_ELEMENT 113
#define GAME_PANEL_PLAYER_NAME 114
#define GAME_PANEL_LEVEL_NAME 115
#define GAME_PANEL_LEVEL_AUTHOR 116
#define NUM_GAME_PANEL_CONTROLS 117
struct GamePanelOrderInfo
{
int nr;
int sort_priority;
};
#ifndef HEADLESS
static struct GamePanelOrderInfo game_panel_order[NUM_GAME_PANEL_CONTROLS];
#endif
struct GamePanelControlInfo
{
int nr;
struct TextPosInfo *pos;
int type;
int graphic, graphic_active;
int value, last_value;
int frame, last_frame;
int gfx_frame;
int gfx_random;
};
static struct GamePanelControlInfo game_panel_controls[] =
{
{
GAME_PANEL_LEVEL_NUMBER,
&game.panel.level_number,
TYPE_INTEGER,
},
{
GAME_PANEL_GEMS,
&game.panel.gems,
TYPE_INTEGER,
},
{
GAME_PANEL_INVENTORY_COUNT,
&game.panel.inventory_count,
TYPE_INTEGER,
},
{
GAME_PANEL_INVENTORY_FIRST_1,
&game.panel.inventory_first[0],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_FIRST_2,
&game.panel.inventory_first[1],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_FIRST_3,
&game.panel.inventory_first[2],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_FIRST_4,
&game.panel.inventory_first[3],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_FIRST_5,
&game.panel.inventory_first[4],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_FIRST_6,
&game.panel.inventory_first[5],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_FIRST_7,
&game.panel.inventory_first[6],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_FIRST_8,
&game.panel.inventory_first[7],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_LAST_1,
&game.panel.inventory_last[0],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_LAST_2,
&game.panel.inventory_last[1],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_LAST_3,
&game.panel.inventory_last[2],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_LAST_4,
&game.panel.inventory_last[3],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_LAST_5,
&game.panel.inventory_last[4],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_LAST_6,
&game.panel.inventory_last[5],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_LAST_7,
&game.panel.inventory_last[6],
TYPE_ELEMENT,
},
{
GAME_PANEL_INVENTORY_LAST_8,
&game.panel.inventory_last[7],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_1,
&game.panel.key[0],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_2,
&game.panel.key[1],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_3,
&game.panel.key[2],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_4,
&game.panel.key[3],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_5,
&game.panel.key[4],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_6,
&game.panel.key[5],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_7,
&game.panel.key[6],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_8,
&game.panel.key[7],
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_WHITE,
&game.panel.key_white,
TYPE_ELEMENT,
},
{
GAME_PANEL_KEY_WHITE_COUNT,
&game.panel.key_white_count,
TYPE_INTEGER,
},
{
GAME_PANEL_SCORE,
&game.panel.score,
TYPE_INTEGER,
},
{
GAME_PANEL_HIGHSCORE,
&game.panel.highscore,
TYPE_INTEGER,
},
{
GAME_PANEL_TIME,
&game.panel.time,
TYPE_INTEGER,
},
{
GAME_PANEL_TIME_HH,
&game.panel.time_hh,
TYPE_INTEGER,
},
{
GAME_PANEL_TIME_MM,
&game.panel.time_mm,
TYPE_INTEGER,
},
{
GAME_PANEL_TIME_SS,
&game.panel.time_ss,
TYPE_INTEGER,
},
{
GAME_PANEL_TIME_ANIM,
&game.panel.time_anim,
TYPE_GRAPHIC,
IMG_GFX_GAME_PANEL_TIME_ANIM,
IMG_GFX_GAME_PANEL_TIME_ANIM_ACTIVE
},
{
GAME_PANEL_HEALTH,
&game.panel.health,
TYPE_INTEGER,
},
{
GAME_PANEL_HEALTH_ANIM,
&game.panel.health_anim,
TYPE_GRAPHIC,
IMG_GFX_GAME_PANEL_HEALTH_ANIM,
IMG_GFX_GAME_PANEL_HEALTH_ANIM_ACTIVE
},
{
GAME_PANEL_FRAME,
&game.panel.frame,
TYPE_INTEGER,
},
{
GAME_PANEL_SHIELD_NORMAL,
&game.panel.shield_normal,
TYPE_ELEMENT,
},
{
GAME_PANEL_SHIELD_NORMAL_TIME,
&game.panel.shield_normal_time,
TYPE_INTEGER,
},
{
GAME_PANEL_SHIELD_DEADLY,
&game.panel.shield_deadly,
TYPE_ELEMENT,
},
{
GAME_PANEL_SHIELD_DEADLY_TIME,
&game.panel.shield_deadly_time,
TYPE_INTEGER,
},
{
GAME_PANEL_EXIT,
&game.panel.exit,
TYPE_ELEMENT,
},
{
GAME_PANEL_EMC_MAGIC_BALL,
&game.panel.emc_magic_ball,
TYPE_ELEMENT,
},
{
GAME_PANEL_EMC_MAGIC_BALL_SWITCH,
&game.panel.emc_magic_ball_switch,
TYPE_ELEMENT,
},
{
GAME_PANEL_LIGHT_SWITCH,
&game.panel.light_switch,
TYPE_ELEMENT,
},
{
GAME_PANEL_LIGHT_SWITCH_TIME,
&game.panel.light_switch_time,
TYPE_INTEGER,
},
{
GAME_PANEL_TIMEGATE_SWITCH,
&game.panel.timegate_switch,
TYPE_ELEMENT,
},
{
GAME_PANEL_TIMEGATE_SWITCH_TIME,
&game.panel.timegate_switch_time,
TYPE_INTEGER,
},
{
GAME_PANEL_SWITCHGATE_SWITCH,
&game.panel.switchgate_switch,
TYPE_ELEMENT,
},
{
GAME_PANEL_EMC_LENSES,
&game.panel.emc_lenses,
TYPE_ELEMENT,
},
{
GAME_PANEL_EMC_LENSES_TIME,
&game.panel.emc_lenses_time,
TYPE_INTEGER,
},
{
GAME_PANEL_EMC_MAGNIFIER,
&game.panel.emc_magnifier,
TYPE_ELEMENT,
},
{
GAME_PANEL_EMC_MAGNIFIER_TIME,
&game.panel.emc_magnifier_time,
TYPE_INTEGER,
},
{
GAME_PANEL_BALLOON_SWITCH,
&game.panel.balloon_switch,
TYPE_ELEMENT,
},
{
GAME_PANEL_DYNABOMB_NUMBER,
&game.panel.dynabomb_number,
TYPE_INTEGER,
},
{
GAME_PANEL_DYNABOMB_SIZE,
&game.panel.dynabomb_size,
TYPE_INTEGER,
},
{
GAME_PANEL_DYNABOMB_POWER,
&game.panel.dynabomb_power,
TYPE_ELEMENT,
},
{
GAME_PANEL_PENGUINS,
&game.panel.penguins,
TYPE_INTEGER,
},
{
GAME_PANEL_SOKOBAN_OBJECTS,
&game.panel.sokoban_objects,
TYPE_INTEGER,
},
{
GAME_PANEL_SOKOBAN_FIELDS,
&game.panel.sokoban_fields,
TYPE_INTEGER,
},
{
GAME_PANEL_ROBOT_WHEEL,
&game.panel.robot_wheel,
TYPE_ELEMENT,
},
{
GAME_PANEL_CONVEYOR_BELT_1,
&game.panel.conveyor_belt[0],
TYPE_ELEMENT,
},
{
GAME_PANEL_CONVEYOR_BELT_2,
&game.panel.conveyor_belt[1],
TYPE_ELEMENT,
},
{
GAME_PANEL_CONVEYOR_BELT_3,
&game.panel.conveyor_belt[2],
TYPE_ELEMENT,
},
{
GAME_PANEL_CONVEYOR_BELT_4,
&game.panel.conveyor_belt[3],
TYPE_ELEMENT,
},
{
GAME_PANEL_CONVEYOR_BELT_1_SWITCH,
&game.panel.conveyor_belt_switch[0],
TYPE_ELEMENT,
},
{
GAME_PANEL_CONVEYOR_BELT_2_SWITCH,
&game.panel.conveyor_belt_switch[1],
TYPE_ELEMENT,
},
{
GAME_PANEL_CONVEYOR_BELT_3_SWITCH,
&game.panel.conveyor_belt_switch[2],
TYPE_ELEMENT,
},
{
GAME_PANEL_CONVEYOR_BELT_4_SWITCH,
&game.panel.conveyor_belt_switch[3],
TYPE_ELEMENT,
},
{
GAME_PANEL_MAGIC_WALL,
&game.panel.magic_wall,
TYPE_ELEMENT,
},
{
GAME_PANEL_MAGIC_WALL_TIME,
&game.panel.magic_wall_time,
TYPE_INTEGER,
},
{
GAME_PANEL_GRAVITY_STATE,
&game.panel.gravity_state,
TYPE_STRING,
},
{
GAME_PANEL_GRAPHIC_1,
&game.panel.graphic[0],
TYPE_ELEMENT,
},
{
GAME_PANEL_GRAPHIC_2,
&game.panel.graphic[1],
TYPE_ELEMENT,
},
{
GAME_PANEL_GRAPHIC_3,
&game.panel.graphic[2],
TYPE_ELEMENT,
},
{
GAME_PANEL_GRAPHIC_4,
&game.panel.graphic[3],
TYPE_ELEMENT,
},
{
GAME_PANEL_GRAPHIC_5,
&game.panel.graphic[4],
TYPE_ELEMENT,
},
{
GAME_PANEL_GRAPHIC_6,
&game.panel.graphic[5],
TYPE_ELEMENT,
},
{
GAME_PANEL_GRAPHIC_7,
&game.panel.graphic[6],
TYPE_ELEMENT,
},
{
GAME_PANEL_GRAPHIC_8,
&game.panel.graphic[7],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_1,
&game.panel.element[0],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_2,
&game.panel.element[1],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_3,
&game.panel.element[2],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_4,
&game.panel.element[3],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_5,
&game.panel.element[4],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_6,
&game.panel.element[5],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_7,
&game.panel.element[6],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_8,
&game.panel.element[7],
TYPE_ELEMENT,
},
{
GAME_PANEL_ELEMENT_COUNT_1,
&game.panel.element_count[0],
TYPE_INTEGER,
},
{
GAME_PANEL_ELEMENT_COUNT_2,
&game.panel.element_count[1],
TYPE_INTEGER,
},
{
GAME_PANEL_ELEMENT_COUNT_3,
&game.panel.element_count[2],
TYPE_INTEGER,
},
{
GAME_PANEL_ELEMENT_COUNT_4,
&game.panel.element_count[3],
TYPE_INTEGER,
},
{
GAME_PANEL_ELEMENT_COUNT_5,
&game.panel.element_count[4],
TYPE_INTEGER,
},
{
GAME_PANEL_ELEMENT_COUNT_6,
&game.panel.element_count[5],
TYPE_INTEGER,
},
{
GAME_PANEL_ELEMENT_COUNT_7,
&game.panel.element_count[6],
TYPE_INTEGER,
},
{
GAME_PANEL_ELEMENT_COUNT_8,
&game.panel.element_count[7],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_1,
&game.panel.ce_score[0],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_2,
&game.panel.ce_score[1],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_3,
&game.panel.ce_score[2],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_4,
&game.panel.ce_score[3],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_5,
&game.panel.ce_score[4],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_6,
&game.panel.ce_score[5],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_7,
&game.panel.ce_score[6],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_8,
&game.panel.ce_score[7],
TYPE_INTEGER,
},
{
GAME_PANEL_CE_SCORE_1_ELEMENT,
&game.panel.ce_score_element[0],
TYPE_ELEMENT,
},
{
GAME_PANEL_CE_SCORE_2_ELEMENT,
&game.panel.ce_score_element[1],
TYPE_ELEMENT,
},
{
GAME_PANEL_CE_SCORE_3_ELEMENT,
&game.panel.ce_score_element[2],
TYPE_ELEMENT,
},
{
GAME_PANEL_CE_SCORE_4_ELEMENT,
&game.panel.ce_score_element[3],
TYPE_ELEMENT,
},
{
GAME_PANEL_CE_SCORE_5_ELEMENT,
&game.panel.ce_score_element[4],
TYPE_ELEMENT,
},
{
GAME_PANEL_CE_SCORE_6_ELEMENT,
&game.panel.ce_score_element[5],
TYPE_ELEMENT,
},
{
GAME_PANEL_CE_SCORE_7_ELEMENT,
&game.panel.ce_score_element[6],
TYPE_ELEMENT,
},
{
GAME_PANEL_CE_SCORE_8_ELEMENT,
&game.panel.ce_score_element[7],
TYPE_ELEMENT,
},
{
GAME_PANEL_PLAYER_NAME,
&game.panel.player_name,
TYPE_STRING,
},
{
GAME_PANEL_LEVEL_NAME,
&game.panel.level_name,
TYPE_STRING,
},
{
GAME_PANEL_LEVEL_AUTHOR,
&game.panel.level_author,
TYPE_STRING,
},
{
-1,
NULL,
-1,
}
};
// values for delayed check of falling and moving elements and for collision
#define CHECK_DELAY_MOVING 3
#define CHECK_DELAY_FALLING CHECK_DELAY_MOVING
#define CHECK_DELAY_COLLISION 2
#define CHECK_DELAY_IMPACT CHECK_DELAY_COLLISION
// values for initial player move delay (initial delay counter value)
#define INITIAL_MOVE_DELAY_OFF -1
#define INITIAL_MOVE_DELAY_ON 0
// values for player movement speed (which is in fact a delay value)
#define MOVE_DELAY_MIN_SPEED 32
#define MOVE_DELAY_NORMAL_SPEED 8
#define MOVE_DELAY_HIGH_SPEED 4
#define MOVE_DELAY_MAX_SPEED 1
#define DOUBLE_MOVE_DELAY(x) (x = (x < MOVE_DELAY_MIN_SPEED ? x * 2 : x))
#define HALVE_MOVE_DELAY(x) (x = (x > MOVE_DELAY_MAX_SPEED ? x / 2 : x))
#define DOUBLE_PLAYER_SPEED(p) (HALVE_MOVE_DELAY( (p)->move_delay_value))
#define HALVE_PLAYER_SPEED(p) (DOUBLE_MOVE_DELAY((p)->move_delay_value))
// values for scroll positions
#define SCROLL_POSITION_X(x) ((x) < SBX_Left + MIDPOSX ? SBX_Left : \
(x) > SBX_Right + MIDPOSX ? SBX_Right :\
(x) - MIDPOSX)
#define SCROLL_POSITION_Y(y) ((y) < SBY_Upper + MIDPOSY ? SBY_Upper :\
(y) > SBY_Lower + MIDPOSY ? SBY_Lower :\
(y) - MIDPOSY)
// values for other actions
#define MOVE_STEPSIZE_NORMAL (TILEX / MOVE_DELAY_NORMAL_SPEED)
#define MOVE_STEPSIZE_MIN (1)
#define MOVE_STEPSIZE_MAX (TILEX)
#define GET_DX_FROM_DIR(d) ((d) == MV_LEFT ? -1 : (d) == MV_RIGHT ? 1 : 0)
#define GET_DY_FROM_DIR(d) ((d) == MV_UP ? -1 : (d) == MV_DOWN ? 1 : 0)
#define INIT_GFX_RANDOM() (GetSimpleRandom(1000000))
#define GET_NEW_PUSH_DELAY(e) ( (element_info[e].push_delay_fixed) + \
RND(element_info[e].push_delay_random))
#define GET_NEW_DROP_DELAY(e) ( (element_info[e].drop_delay_fixed) + \
RND(element_info[e].drop_delay_random))
#define GET_NEW_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \
RND(element_info[e].move_delay_random))
#define GET_MAX_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \
(element_info[e].move_delay_random))
#define GET_NEW_CE_VALUE(e) ( (element_info[e].ce_value_fixed_initial) +\
RND(element_info[e].ce_value_random_initial))
#define GET_CE_SCORE(e) ( (element_info[e].collect_score))
#define GET_CHANGE_DELAY(c) ( ((c)->delay_fixed * (c)->delay_frames) + \
RND((c)->delay_random * (c)->delay_frames))
#define GET_CE_DELAY_VALUE(c) ( ((c)->delay_fixed) + \
RND((c)->delay_random))
#define GET_VALID_RUNTIME_ELEMENT(e) \
((e) >= NUM_RUNTIME_ELEMENTS ? EL_UNKNOWN : (e))
#define RESOLVED_REFERENCE_ELEMENT(be, e) \
((be) + (e) - EL_SELF < EL_CUSTOM_START ? EL_CUSTOM_START : \
(be) + (e) - EL_SELF > EL_CUSTOM_END ? EL_CUSTOM_END : \
(be) + (e) - EL_SELF)
#define GET_PLAYER_FROM_BITS(p) \
(EL_PLAYER_1 + ((p) != PLAYER_BITS_ANY ? log_2(p) : 0))
#define GET_TARGET_ELEMENT(be, e, ch, cv, cs) \
((e) == EL_TRIGGER_PLAYER ? (ch)->actual_trigger_player : \
(e) == EL_TRIGGER_ELEMENT ? (ch)->actual_trigger_element : \
(e) == EL_TRIGGER_CE_VALUE ? (ch)->actual_trigger_ce_value : \
(e) == EL_TRIGGER_CE_SCORE ? (ch)->actual_trigger_ce_score : \
(e) == EL_CURRENT_CE_VALUE ? (cv) : \
(e) == EL_CURRENT_CE_SCORE ? (cs) : \
(e) >= EL_PREV_CE_8 && (e) <= EL_NEXT_CE_8 ? \
RESOLVED_REFERENCE_ELEMENT(be, e) : \
(e))
#define CAN_GROW_INTO(e) \
((e) == EL_SAND || (IS_DIGGABLE(e) && level.grow_into_diggable))
#define ELEMENT_CAN_ENTER_FIELD_BASE_X(x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
(condition)))
#define ELEMENT_CAN_ENTER_FIELD_BASE_2(e, x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
(CAN_MOVE_INTO_ACID(e) && \
Feld[x][y] == EL_ACID) || \
(condition)))
#define ELEMENT_CAN_ENTER_FIELD_BASE_3(e, x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE_OR_PLAYER(x, y) || \
(CAN_MOVE_INTO_ACID(e) && \
Feld[x][y] == EL_ACID) || \
(condition)))
#define ELEMENT_CAN_ENTER_FIELD_BASE_4(e, x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
(condition) || \
(CAN_MOVE_INTO_ACID(e) && \
Feld[x][y] == EL_ACID) || \
(DONT_COLLIDE_WITH(e) && \
IS_PLAYER(x, y) && \
!PLAYER_ENEMY_PROTECTED(x, y))))
#define ELEMENT_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_4(e, x, y, 0)
#define SATELLITE_CAN_ENTER_FIELD(x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_2(EL_SATELLITE, x, y, 0)
#define ANDROID_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_2(e, x, y, Feld[x][y] == EL_EMC_PLANT)
#define ANDROID_CAN_CLONE_FIELD(x, y) \
(IN_LEV_FIELD(x, y) && (CAN_BE_CLONED_BY_ANDROID(Feld[x][y]) || \
CAN_BE_CLONED_BY_ANDROID(EL_TRIGGER_ELEMENT)))
#define ENEMY_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_2(e, x, y, 0)
#define YAMYAM_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_3(e, x, y, Feld[x][y] == EL_DIAMOND)
#define DARK_YAMYAM_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_3(e, x,y, IS_FOOD_DARK_YAMYAM(Feld[x][y]))
#define PACMAN_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_3(e, x, y, IS_AMOEBOID(Feld[x][y]))
#define PIG_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_2(e, x, y, IS_FOOD_PIG(Feld[x][y]))
#define PENGUIN_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_2(e, x, y, (Feld[x][y] == EL_EXIT_OPEN || \
Feld[x][y] == EL_EM_EXIT_OPEN || \
Feld[x][y] == EL_STEEL_EXIT_OPEN || \
Feld[x][y] == EL_EM_STEEL_EXIT_OPEN || \
IS_FOOD_PENGUIN(Feld[x][y])))
#define DRAGON_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_2(e, x, y, 0)
#define MOLE_CAN_ENTER_FIELD(e, x, y, condition) \
ELEMENT_CAN_ENTER_FIELD_BASE_2(e, x, y, (condition))
#define SPRING_CAN_ENTER_FIELD(e, x, y) \
ELEMENT_CAN_ENTER_FIELD_BASE_2(e, x, y, 0)
#define SPRING_CAN_BUMP_FROM_FIELD(x, y) \
(IN_LEV_FIELD(x, y) && (Feld[x][y] == EL_EMC_SPRING_BUMPER || \
Feld[x][y] == EL_EMC_SPRING_BUMPER_ACTIVE))