summaryrefslogtreecommitdiff
path: root/src/map/map.h
blob: dbd9c0fba3b32defc0be3158291d8ff240bc0179 (plain) (blame)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
/**
 * This file is part of Hercules.
 * http://herc.ws - http://github.com/HerculesWS/Hercules
 *
 * Copyright (C) 2012-2020 Hercules Dev Team
 * Copyright (C) Athena Dev Teams
 *
 * Hercules 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 3 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, see <http://www.gnu.org/licenses/>.
 */
#ifndef MAP_MAP_H
#define MAP_MAP_H

#include "map/atcommand.h"
#include "common/hercules.h"
#include "common/core.h" // CORE_ST_LAST
#include "common/db.h"
#include "common/mapindex.h"
#include "common/mmo.h"

#include <stdio.h>
#include <stdarg.h>

/* Forward Declarations */
struct Sql; // common/sql.h
struct config_t; // common/conf.h
struct mob_data;
struct npc_data;
struct channel_data;
struct hplugin_data_store;

enum E_MAPSERVER_ST {
	MAPSERVER_ST_RUNNING = CORE_ST_LAST,
	MAPSERVER_ST_SHUTDOWN,
	MAPSERVER_ST_LAST
};

//First Jobs
//Note the oddity of the novice:
//Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type.
enum {
	//Novice And 1-1 Jobs
	MAPID_NOVICE = 0,
	MAPID_SWORDMAN,
	MAPID_MAGE,
	MAPID_ARCHER,
	MAPID_ACOLYTE,
	MAPID_MERCHANT,
	MAPID_THIEF,
	MAPID_TAEKWON,
	MAPID_WEDDING,
	MAPID_GUNSLINGER,
	MAPID_NINJA,
	MAPID_XMAS,
	MAPID_SUMMER,
	MAPID_GANGSI,
	MAPID_SUMMONER,
	MAPID_1_1_MAX,

	//2-1 Jobs
	MAPID_SUPER_NOVICE   = JOBL_2_1 | MAPID_NOVICE,
	MAPID_KNIGHT         = JOBL_2_1 | MAPID_SWORDMAN,
	MAPID_WIZARD         = JOBL_2_1 | MAPID_MAGE,
	MAPID_HUNTER         = JOBL_2_1 | MAPID_ARCHER,
	MAPID_PRIEST         = JOBL_2_1 | MAPID_ACOLYTE,
	MAPID_BLACKSMITH     = JOBL_2_1 | MAPID_MERCHANT,
	MAPID_ASSASSIN       = JOBL_2_1 | MAPID_THIEF,
	MAPID_STAR_GLADIATOR = JOBL_2_1 | MAPID_TAEKWON,
	//                   = JOBL_2_1 | MAPID_WEDDING,
	MAPID_REBELLION      = JOBL_2_1 | MAPID_GUNSLINGER,
	MAPID_KAGEROUOBORO   = JOBL_2_1 | MAPID_NINJA,
	//                   = JOBL_2_1 | MAPID_XMAS,
	//                   = JOBL_2_1 | MAPID_SUMMER,
	MAPID_DEATH_KNIGHT   = JOBL_2_1 | MAPID_GANGSI,
	//                   = JOBL_2_1 | MAPID_SUMMONER,

	//2-2 Jobs
	//                   = JOBL_2_1 | MAPID_NOVICE,
	MAPID_CRUSADER       = JOBL_2_2 | MAPID_SWORDMAN,
	MAPID_SAGE           = JOBL_2_2 | MAPID_MAGE,
	MAPID_BARDDANCER     = JOBL_2_2 | MAPID_ARCHER,
	MAPID_MONK           = JOBL_2_2 | MAPID_ACOLYTE,
	MAPID_ALCHEMIST      = JOBL_2_2 | MAPID_MERCHANT,
	MAPID_ROGUE          = JOBL_2_2 | MAPID_THIEF,
	MAPID_SOUL_LINKER    = JOBL_2_2 | MAPID_TAEKWON,
	//                   = JOBL_2_2 | MAPID_WEDDING,
	//                   = JOBL_2_2 | MAPID_GUNSLINGER,
	//                   = JOBL_2_2 | MAPID_NINJA,
	//                   = JOBL_2_2 | MAPID_XMAS,
	//                   = JOBL_2_2 | MAPID_SUMMER,
	MAPID_DARK_COLLECTOR = JOBL_2_2 | MAPID_GANGSI,
	//                   = JOBL_2_2 | MAPID_SUMMONER,

	//Trans Novice And Trans 1-1 Jobs
	MAPID_NOVICE_HIGH   = JOBL_UPPER | MAPID_NOVICE,
	MAPID_SWORDMAN_HIGH = JOBL_UPPER | MAPID_SWORDMAN,
	MAPID_MAGE_HIGH     = JOBL_UPPER | MAPID_MAGE,
	MAPID_ARCHER_HIGH   = JOBL_UPPER | MAPID_ARCHER,
	MAPID_ACOLYTE_HIGH  = JOBL_UPPER | MAPID_ACOLYTE,
	MAPID_MERCHANT_HIGH = JOBL_UPPER | MAPID_MERCHANT,
	MAPID_THIEF_HIGH    = JOBL_UPPER | MAPID_THIEF,
	//                  = JOBL_UPPER | MAPID_TAEKWON,
	//                  = JOBL_UPPER | MAPID_WEDDING,
	//                  = JOBL_UPPER | MAPID_GUNSLINGER,
	//                  = JOBL_UPPER | MAPID_NINJA,
	//                  = JOBL_UPPER | MAPID_XMAS,
	//                  = JOBL_UPPER | MAPID_SUMMER,
	//                  = JOBL_UPPER | MAPID_GANGSI,
	//                  = JOBL_UPPER | MAPID_SUMMONER,

	//Trans 2-1 Jobs
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_NOVICE,
	MAPID_LORD_KNIGHT    = JOBL_UPPER | JOBL_2_1 | MAPID_SWORDMAN,
	MAPID_HIGH_WIZARD    = JOBL_UPPER | JOBL_2_1 | MAPID_MAGE,
	MAPID_SNIPER         = JOBL_UPPER | JOBL_2_1 | MAPID_ARCHER,
	MAPID_HIGH_PRIEST    = JOBL_UPPER | JOBL_2_1 | MAPID_ACOLYTE,
	MAPID_WHITESMITH     = JOBL_UPPER | JOBL_2_1 | MAPID_MERCHANT,
	MAPID_ASSASSIN_CROSS = JOBL_UPPER | JOBL_2_1 | MAPID_THIEF,
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_TAEKWON,
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_WEDDING,
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_GUNSLINGER,
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_NINJA,
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_XMAS,
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_SUMMER,
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_GANGSI,
	//                   = JOBL_UPPER | JOBL_2_1 | MAPID_SUMMONER,

	//Trans 2-2 Jobs
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_NOVICE,
	MAPID_PALADIN    = JOBL_UPPER | JOBL_2_2 | MAPID_SWORDMAN,
	MAPID_PROFESSOR  = JOBL_UPPER | JOBL_2_2 | MAPID_MAGE,
	MAPID_CLOWNGYPSY = JOBL_UPPER | JOBL_2_2 | MAPID_ARCHER,
	MAPID_CHAMPION   = JOBL_UPPER | JOBL_2_2 | MAPID_ACOLYTE,
	MAPID_CREATOR    = JOBL_UPPER | JOBL_2_2 | MAPID_MERCHANT,
	MAPID_STALKER    = JOBL_UPPER | JOBL_2_2 | MAPID_THIEF,
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_TAEKWON,
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_WEDDING,
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_GUNSLINGER,
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_NINJA,
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_XMAS,
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_SUMMER,
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_GANGSI,
	//               = JOBL_UPPER | JOBL_2_2 | MAPID_SUMMONER,

	//Baby Novice And Baby 1-1 Jobs
	MAPID_BABY          = JOBL_BABY | MAPID_NOVICE,
	MAPID_BABY_SWORDMAN = JOBL_BABY | MAPID_SWORDMAN,
	MAPID_BABY_MAGE     = JOBL_BABY | MAPID_MAGE,
	MAPID_BABY_ARCHER   = JOBL_BABY | MAPID_ARCHER,
	MAPID_BABY_ACOLYTE  = JOBL_BABY | MAPID_ACOLYTE,
	MAPID_BABY_MERCHANT = JOBL_BABY | MAPID_MERCHANT,
	MAPID_BABY_THIEF    = JOBL_BABY | MAPID_THIEF,
	//                  = JOBL_BABY | MAPID_TAEKWON,
	//                  = JOBL_BABY | MAPID_WEDDING,
	//                  = JOBL_BABY | MAPID_GUNSLINGER,
	//                  = JOBL_BABY | MAPID_NINJA,
	//                  = JOBL_BABY | MAPID_XMAS,
	//                  = JOBL_BABY | MAPID_SUMMER,
	//                  = JOBL_BABY | MAPID_GANGSI,
	//                  = JOBL_BABY | MAPID_SUMMONER,

	//Baby 2-1 Jobs
	MAPID_SUPER_BABY      = JOBL_BABY | JOBL_2_1 | MAPID_NOVICE,
	MAPID_BABY_KNIGHT     = JOBL_BABY | JOBL_2_1 | MAPID_SWORDMAN,
	MAPID_BABY_WIZARD     = JOBL_BABY | JOBL_2_1 | MAPID_MAGE,
	MAPID_BABY_HUNTER     = JOBL_BABY | JOBL_2_1 | MAPID_ARCHER,
	MAPID_BABY_PRIEST     = JOBL_BABY | JOBL_2_1 | MAPID_ACOLYTE,
	MAPID_BABY_BLACKSMITH = JOBL_BABY | JOBL_2_1 | MAPID_MERCHANT,
	MAPID_BABY_ASSASSIN   = JOBL_BABY | JOBL_2_1 | MAPID_THIEF,
	//                    = JOBL_BABY | JOBL_2_1 | MAPID_TAEKWON,
	//                    = JOBL_BABY | JOBL_2_1 | MAPID_WEDDING,
	//                    = JOBL_BABY | JOBL_2_1 | MAPID_GUNSLINGER,
	//                    = JOBL_BABY | JOBL_2_1 | MAPID_NINJA,
	//                    = JOBL_BABY | JOBL_2_1 | MAPID_XMAS,
	//                    = JOBL_BABY | JOBL_2_1 | MAPID_SUMMER,
	//                    = JOBL_BABY | JOBL_2_1 | MAPID_GANGSI,
	//                    = JOBL_BABY | JOBL_2_1 | MAPID_SUMMONER,

	//Baby 2-2 Jobs
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_NOVICE,
	MAPID_BABY_CRUSADER   = JOBL_BABY | JOBL_2_2 | MAPID_SWORDMAN,
	MAPID_BABY_SAGE       = JOBL_BABY | JOBL_2_2 | MAPID_MAGE,
	MAPID_BABY_BARDDANCER = JOBL_BABY | JOBL_2_2 | MAPID_ARCHER,
	MAPID_BABY_MONK       = JOBL_BABY | JOBL_2_2 | MAPID_ACOLYTE,
	MAPID_BABY_ALCHEMIST  = JOBL_BABY | JOBL_2_2 | MAPID_MERCHANT,
	MAPID_BABY_ROGUE      = JOBL_BABY | JOBL_2_2 | MAPID_THIEF,
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_TAEKWON,
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_WEDDING,
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_GUNSLINGER,
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_NINJA,
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_XMAS,
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_SUMMER,
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_GANGSI,
	//                    = JOBL_BABY | JOBL_2_2 | MAPID_SUMMONER,

	//3-1 Jobs
	MAPID_SUPER_NOVICE_E   = JOBL_THIRD | JOBL_2_1 | MAPID_NOVICE,
	MAPID_RUNE_KNIGHT      = JOBL_THIRD | JOBL_2_1 | MAPID_SWORDMAN,
	MAPID_WARLOCK          = JOBL_THIRD | JOBL_2_1 | MAPID_MAGE,
	MAPID_RANGER           = JOBL_THIRD | JOBL_2_1 | MAPID_ARCHER,
	MAPID_ARCH_BISHOP      = JOBL_THIRD | JOBL_2_1 | MAPID_ACOLYTE,
	MAPID_MECHANIC         = JOBL_THIRD | JOBL_2_1 | MAPID_MERCHANT,
	MAPID_GUILLOTINE_CROSS = JOBL_THIRD | JOBL_2_1 | MAPID_THIEF,
	//                     = JOBL_THIRD | JOBL_2_1 | MAPID_TAEKWON,
	//                     = JOBL_THIRD | JOBL_2_1 | MAPID_WEDDING,
	//                     = JOBL_THIRD | JOBL_2_1 | MAPID_GUNSLINGER,
	//                     = JOBL_THIRD | JOBL_2_1 | MAPID_NINJA,
	//                     = JOBL_THIRD | JOBL_2_1 | MAPID_XMAS,
	//                     = JOBL_THIRD | JOBL_2_1 | MAPID_SUMMER,
	//                     = JOBL_THIRD | JOBL_2_1 | MAPID_GANGSI,
	//                     = JOBL_THIRD | JOBL_2_1 | MAPID_SUMMONER,

	//3-2 Jobs
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_NOVICE,
	MAPID_ROYAL_GUARD      = JOBL_THIRD | JOBL_2_2 | MAPID_SWORDMAN,
	MAPID_SORCERER         = JOBL_THIRD | JOBL_2_2 | MAPID_MAGE,
	MAPID_MINSTRELWANDERER = JOBL_THIRD | JOBL_2_2 | MAPID_ARCHER,
	MAPID_SURA             = JOBL_THIRD | JOBL_2_2 | MAPID_ACOLYTE,
	MAPID_GENETIC          = JOBL_THIRD | JOBL_2_2 | MAPID_MERCHANT,
	MAPID_SHADOW_CHASER    = JOBL_THIRD | JOBL_2_2 | MAPID_THIEF,
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_TAEKWON,
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_WEDDING,
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_GUNSLINGER,
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_NINJA,
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_XMAS,
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_SUMMER,
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_GANGSI,
	//                     = JOBL_THIRD | JOBL_2_2 | MAPID_SUMMONER,

	//Trans 3-1 Jobs
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_NOVICE,
	MAPID_RUNE_KNIGHT_T      = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_SWORDMAN,
	MAPID_WARLOCK_T          = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_MAGE,
	MAPID_RANGER_T           = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_ARCHER,
	MAPID_ARCH_BISHOP_T      = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_ACOLYTE,
	MAPID_MECHANIC_T         = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_MERCHANT,
	MAPID_GUILLOTINE_CROSS_T = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_THIEF,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_TAEKWON,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_WEDDING,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_GUNSLINGER,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_NINJA,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_XMAS,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_SUMMER,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_GANGSI,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_1 | MAPID_SUMMONER,

	//Trans 3-2 Jobs
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_NOVICE,
	MAPID_ROYAL_GUARD_T      = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_SWORDMAN,
	MAPID_SORCERER_T         = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_MAGE,
	MAPID_MINSTRELWANDERER_T = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_ARCHER,
	MAPID_SURA_T             = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_ACOLYTE,
	MAPID_GENETIC_T          = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_MERCHANT,
	MAPID_SHADOW_CHASER_T    = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_THIEF,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_TAEKWON,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_WEDDING,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_GUNSLINGER,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_NINJA,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_XMAS,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_SUMMER,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_GANGSI,
	//                       = JOBL_THIRD | JOBL_UPPER | JOBL_2_2 | MAPID_SUMMONER,

	//Baby 3-1 Jobs
	MAPID_SUPER_BABY_E  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_NOVICE,
	MAPID_BABY_RUNE     = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_SWORDMAN,
	MAPID_BABY_WARLOCK  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_MAGE,
	MAPID_BABY_RANGER   = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_ARCHER,
	MAPID_BABY_BISHOP   = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_ACOLYTE,
	MAPID_BABY_MECHANIC = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_MERCHANT,
	MAPID_BABY_CROSS    = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_THIEF,
	//                  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_TAEKWON,
	//                  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_WEDDING,
	//                  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_GUNSLINGER,
	//                  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_NINJA,
	//                  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_XMAS,
	//                  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_SUMMER,
	//                  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_GANGSI,
	//                  = JOBL_THIRD | JOBL_BABY | JOBL_2_1 | MAPID_SUMMONER,

	//Baby 3-2 Jobs
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_NOVICE,
	MAPID_BABY_GUARD            = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_SWORDMAN,
	MAPID_BABY_SORCERER         = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_MAGE,
	MAPID_BABY_MINSTRELWANDERER = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_ARCHER,
	MAPID_BABY_SURA             = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_ACOLYTE,
	MAPID_BABY_GENETIC          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_MERCHANT,
	MAPID_BABY_CHASER           = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_THIEF,
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_TAEKWON,
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_WEDDING,
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_GUNSLINGER,
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_NINJA,
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_XMAS,
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_SUMMER,
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_GANGSI,
	//                          = JOBL_THIRD | JOBL_BABY | JOBL_2_2 | MAPID_SUMMONER,
};

STATIC_ASSERT(((MAPID_1_1_MAX - 1) | MAPID_BASEMASK) == MAPID_BASEMASK, "First class map IDs do not fit into MAPID_BASEMASK");

//This stackable implementation does not means a BL can be more than one type at a time, but it's
// meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex]
enum bl_type {
	BL_NUL   = 0x000,
	BL_PC    = 0x001,
	BL_MOB   = 0x002,
	BL_PET   = 0x004,
	BL_HOM   = 0x008,
	BL_MER   = 0x010,
	BL_ITEM  = 0x020,
	BL_SKILL = 0x040,
	BL_NPC   = 0x080,
	BL_CHAT  = 0x100,
	BL_ELEM  = 0x200,

	BL_ALL   = 0xFFF,
};

enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP, TOMB };

/**
 * Race type IDs.
 *
 * Mostly used by scripts/bonuses.
 */
enum Race {
	// Base Races
	RC_FORMLESS = 0,  ///< Formless
	RC_UNDEAD,        ///< Undead
	RC_BRUTE,         ///< Beast/Brute
	RC_PLANT,         ///< Plant
	RC_INSECT,        ///< Insect
	RC_FISH,          ///< Fish
	RC_DEMON,         ///< Demon
	RC_DEMIHUMAN,     ///< Demi-Human (not including Player)
	RC_ANGEL,         ///< Angel
	RC_DRAGON,        ///< Dragon
	RC_PLAYER,        ///< Player
	// Boss
	RC_BOSS,          ///< Boss
	RC_NONBOSS,       ///< Non-boss

	RC_MAX,           // Array size delimiter (keep before the combination races)

	// Combination Races
	RC_NONDEMIHUMAN,   ///< Every race except Demi-Human (including Player)
	RC_NONPLAYER,      ///< Every non-player race
	RC_DEMIPLAYER,     ///< Demi-Human (including Player)
	RC_NONDEMIPLAYER,  ///< Every race except Demi-Human (and except Player)
	RC_ALL = 0xFF,     ///< Every race (implemented as equivalent to RC_BOSS and RC_NONBOSS)
};

/**
 * Race type bitmasks.
 *
 * Used by several bonuses internally, to simplify handling of race combinations.
 */
enum RaceMask {
	RCMASK_NONE      = 0,
	RCMASK_FORMLESS  = 1<<RC_FORMLESS,
	RCMASK_UNDEAD    = 1<<RC_UNDEAD,
	RCMASK_BRUTE     = 1<<RC_BRUTE,
	RCMASK_PLANT     = 1<<RC_PLANT,
	RCMASK_INSECT    = 1<<RC_INSECT,
	RCMASK_FISH      = 1<<RC_FISH,
	RCMASK_DEMON     = 1<<RC_DEMON,
	RCMASK_DEMIHUMAN = 1<<RC_DEMIHUMAN,
	RCMASK_ANGEL     = 1<<RC_ANGEL,
	RCMASK_DRAGON    = 1<<RC_DRAGON,
	RCMASK_PLAYER    = 1<<RC_PLAYER,
	RCMASK_BOSS      = 1<<RC_BOSS,
	RCMASK_NONBOSS   = 1<<RC_NONBOSS,
	RCMASK_NONDEMIPLAYER = RCMASK_FORMLESS | RCMASK_UNDEAD | RCMASK_BRUTE | RCMASK_PLANT | RCMASK_INSECT | RCMASK_FISH | RCMASK_DEMON | RCMASK_ANGEL | RCMASK_DRAGON,
	RCMASK_NONDEMIHUMAN = RCMASK_NONDEMIPLAYER | RCMASK_PLAYER,
	RCMASK_NONPLAYER    = RCMASK_NONDEMIPLAYER | RCMASK_DEMIHUMAN,
	RCMASK_DEMIPLAYER   = RCMASK_DEMIHUMAN | RCMASK_PLAYER,
	RCMASK_ALL          = RCMASK_BOSS | RCMASK_NONBOSS,
	RCMASK_ANY          = RCMASK_NONPLAYER | RCMASK_PLAYER,
};

enum {
	RC2_NONE = 0,
	RC2_GOBLIN,
	RC2_KOBOLD,
	RC2_ORC,
	RC2_GOLEM,
	RC2_GUARDIAN,
	RC2_NINJA,
	RC2_SCARABA,
	RC2_TURTLE,
	RC2_MAX
};

enum elements {
	ELE_NEUTRAL=0,
	ELE_WATER,
	ELE_EARTH,
	ELE_FIRE,
	ELE_WIND,
	ELE_POISON,
	ELE_HOLY,
	ELE_DARK,
	ELE_GHOST,
	ELE_UNDEAD,
	ELE_MAX,
	ELE_ALL = 0xFF
};

/**
 * Types of spirit charms.
 *
 * Note: Code assumes that this matches the first entries in enum elements.
 */
enum spirit_charm_types {
	CHARM_TYPE_NONE = 0,
	CHARM_TYPE_WATER,
	CHARM_TYPE_LAND,
	CHARM_TYPE_FIRE,
	CHARM_TYPE_WIND
};

enum auto_trigger_flag {
	ATF_SELF=0x01,
	ATF_TARGET=0x02,
	ATF_SHORT=0x04,
	ATF_LONG=0x08,
	ATF_WEAPON=0x10,
	ATF_MAGIC=0x20,
	ATF_MISC=0x40,
};

struct block_list {
	struct block_list *next,*prev;
	int id;
	int16 m,x,y;
	enum bl_type type;
};

// Mob List Held in memory for Dynamic Mobs [Wizputer]
// Expanded to specify all mob-related spawn data by [Skotlex]
struct spawn_data {
	int class_;                ///< Class, used because a mob can change it's class
	unsigned short m, x, y;      ///< Spawn information (map, point, spawn-area around point)
	signed short xs, ys;
	unsigned short num;          ///< Number of mobs using this structure
	unsigned short active;       ///< Number of mobs that are already spawned (for mob_remove_damaged: no)
	unsigned int delay1, delay2; ///< Spawn delay (fixed base + random variance)
	unsigned int level;
	struct {
		unsigned int size : 2;    ///< Holds if mob has to be tiny/large
		unsigned int ai : 4;      ///< Special AI for summoned monsters.
		//0: Normal mob | 1: Standard summon, attacks mobs
		//2: Alchemist Marine Sphere | 3: Alchemist Summon Flora | 4: Summon Zanzou
		unsigned int dynamic : 1; ///< Whether this data is indexed by a map's dynamic mob list
		uint8 boss;    ///< 0: Non-boss monster | 1: Boss monster | 2: MVP
	} state;
	char name[NAME_LENGTH], eventname[EVENT_NAME_LENGTH]; //Name/event
};

struct flooritem_data {
	struct block_list bl;
	unsigned char subx,suby;
	int cleartimer;
	int first_get_charid,second_get_charid,third_get_charid;
	int64 first_get_tick,second_get_tick,third_get_tick;
	struct item item_data;
	bool showdropeffect;
};

enum status_point_types { //we better clean up this enum and change it name [Hemagx]
	SP_NONE = -1,
	SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7
	SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15
	SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23
	SP_WEIGHT,SP_MAXWEIGHT,SP_1a,SP_1b,SP_1c,SP_1d,SP_1e,SP_1f, // 24-31
	SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_26,SP_27, // 32-39
	SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47
	SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55
	SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-60
	SP_CARTINFO=99, // 99

	SP_BASEJOB=119, // 100+19 - celest
	SP_BASECLASS=120, //Hmm.. why 100+19? I just use the next one... [Skotlex]
	SP_KILLERRID=121,
	SP_KILLEDRID=122,
	SP_SLOTCHANGE=123,
	SP_CHARRENAME=124,
	SP_MOD_EXP=125,
	SP_MOD_DROP=126,
	SP_MOD_DEATH=127,
	SP_BANKVAULT=128,

	// Mercenaries
	SP_MERCFLEE=165, SP_MERCKILLS=189, SP_MERCFAITH=190,

	// original 1000-
	SP_ATTACKRANGE=1000, SP_ATKELE,SP_DEFELE, // 1000-1002
	SP_CASTRATE, SP_MAXHPRATE, SP_MAXSPRATE, SP_SPRATE, // 1003-1006
	SP_ADDELE, SP_ADDRACE, SP_ADDSIZE, SP_SUBELE, SP_SUBRACE, // 1007-1011
	SP_ADDEFF, SP_RESEFF, // 1012-1013
	SP_BASE_ATK,SP_ASPD_RATE,SP_HP_RECOV_RATE,SP_SP_RECOV_RATE,SP_SPEED_RATE, // 1014-1018
	SP_CRITICAL_DEF,SP_NEAR_ATK_DEF,SP_LONG_ATK_DEF, // 1019-1021
	SP_DOUBLE_RATE, SP_DOUBLE_ADD_RATE, SP_SKILL_HEAL, SP_MATK_RATE, // 1022-1025
	SP_IGNORE_DEF_ELE,SP_IGNORE_DEF_RACE, // 1026-1027
	SP_ATK_RATE,SP_SPEED_ADDRATE,SP_SP_REGEN_RATE, // 1028-1030
	SP_MAGIC_ATK_DEF,SP_MISC_ATK_DEF, // 1031-1032
	SP_IGNORE_MDEF_ELE,SP_IGNORE_MDEF_RACE, // 1033-1034
	SP_MAGIC_ADDELE,SP_MAGIC_ADDRACE,SP_MAGIC_ADDSIZE, // 1035-1037
	SP_PERFECT_HIT_RATE,SP_PERFECT_HIT_ADD_RATE,SP_CRITICAL_RATE,SP_GET_ZENY_NUM,SP_ADD_GET_ZENY_NUM, // 1038-1042
	SP_ADD_DAMAGE_CLASS,SP_ADD_MAGIC_DAMAGE_CLASS,SP_ADD_DEF_CLASS,SP_ADD_MDEF_CLASS, // 1043-1046
	SP_ADD_MONSTER_DROP_ITEM,SP_DEF_RATIO_ATK_ELE,SP_DEF_RATIO_ATK_RACE,SP_UNBREAKABLE_GARMENT, // 1047-1050
	SP_HIT_RATE,SP_FLEE_RATE,SP_FLEE2_RATE,SP_DEF_RATE,SP_DEF2_RATE,SP_MDEF_RATE,SP_MDEF2_RATE, // 1051-1057
	SP_SPLASH_RANGE,SP_SPLASH_ADD_RANGE,SP_AUTOSPELL,SP_HP_DRAIN_RATE,SP_SP_DRAIN_RATE, // 1058-1062
	SP_SHORT_WEAPON_DAMAGE_RETURN,SP_LONG_WEAPON_DAMAGE_RETURN,SP_WEAPON_COMA_ELE,SP_WEAPON_COMA_RACE, // 1063-1066
	SP_ADDEFF2,SP_BREAK_WEAPON_RATE,SP_BREAK_ARMOR_RATE,SP_ADD_STEAL_RATE, // 1067-1070
	SP_MAGIC_DAMAGE_RETURN,SP_ALL_STATS=1073,SP_AGI_VIT,SP_AGI_DEX_STR,SP_PERFECT_HIDE, // 1071-1076
	SP_NO_KNOCKBACK,SP_CLASSCHANGE, // 1077-1078
	SP_HP_DRAIN_VALUE,SP_SP_DRAIN_VALUE, // 1079-1080
	SP_WEAPON_ATK,SP_WEAPON_ATK_RATE, // 1081-1082
	SP_DELAYRATE,SP_HP_DRAIN_RATE_RACE,SP_SP_DRAIN_RATE_RACE, // 1083-1085
	SP_IGNORE_MDEF_RATE,SP_IGNORE_DEF_RATE,SP_SKILL_HEAL2,SP_ADDEFF_ONSKILL, //1086-1089
	SP_ADD_HEAL_RATE, SP_ADD_HEAL2_RATE, SP_HP_VANISH_RATE, //1090-1092

	SP_RESTART_FULL_RECOVER=2000,SP_NO_CASTCANCEL,SP_NO_SIZEFIX,SP_NO_MAGIC_DAMAGE,SP_NO_WEAPON_DAMAGE,SP_NO_GEMSTONE, // 2000-2005
	SP_NO_CASTCANCEL2,SP_NO_MISC_DAMAGE,SP_UNBREAKABLE_WEAPON,SP_UNBREAKABLE_ARMOR, SP_UNBREAKABLE_HELM, // 2006-2010
	SP_UNBREAKABLE_SHIELD, SP_LONG_ATK_RATE, // 2011-2012

	SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017
	SP_SKILL_ATK, SP_UNSTRIPABLE, SP_AUTOSPELL_ONSKILL, // 2018-2020
	SP_SP_GAIN_VALUE, SP_HP_REGEN_RATE, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025
	SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030
	SP_SP_GAIN_RACE, SP_SUBRACE2, SP_UNBREAKABLE_SHOES, // 2031-2033
	SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD,  // 2034-2037
	SP_INTRAVISION, SP_ADD_MONSTER_DROP_CHAINITEM, SP_SP_LOSS_RATE, // 2038-2040
	SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE, SP_MAGIC_SP_GAIN_VALUE, SP_MAGIC_HP_GAIN_VALUE, SP_ADD_CLASS_DROP_ITEM, //2041-2045
	SP_EMATK, SP_SP_GAIN_RACE_ATTACK, SP_HP_GAIN_RACE_ATTACK, SP_SKILL_USE_SP_RATE, //2046-2049
	SP_SKILL_COOLDOWN,SP_SKILL_FIXEDCAST, SP_SKILL_VARIABLECAST, SP_FIXCASTRATE, SP_VARCASTRATE, //2050-2054
	SP_SKILL_USE_SP,SP_MAGIC_ATK_ELE, SP_ADD_FIXEDCAST, SP_ADD_VARIABLECAST,  //2055-2058
	SP_SET_DEF_RACE,SP_SET_MDEF_RACE, //2059-2060
	SP_RACE_TOLERANCE,SP_ADDMAXWEIGHT, //2061-2062

	/* must be the last, plugins add bonuses from this value onwards */
	SP_LAST_KNOWN,
};

enum look {
	LOOK_BASE,
	LOOK_HAIR,
	LOOK_WEAPON,
	LOOK_HEAD_BOTTOM,
	LOOK_HEAD_TOP,
	LOOK_HEAD_MID,
	LOOK_HAIR_COLOR,
	LOOK_CLOTHES_COLOR,
	LOOK_SHIELD,
	LOOK_SHOES,
	LOOK_BODY,
	LOOK_FLOOR,
	LOOK_ROBE,
	LOOK_BODY2,

#ifndef LOOK_MAX
	LOOK_MAX
#endif
};

// used by map_setcell()
typedef enum {
	CELL_WALKABLE,
	CELL_SHOOTABLE,
	CELL_WATER,

	CELL_NPC,
	CELL_BASILICA,
	CELL_LANDPROTECTOR,
	CELL_NOVENDING,
	CELL_NOCHAT,
	CELL_ICEWALL,
	CELL_NOICEWALL,

} cell_t;

// used by map->getcell()
typedef enum {
	CELL_GETTYPE,    ///< retrieves a cell's 'gat' type

	CELL_CHKWALL,    ///< wall (gat type 1)
	CELL_CHKWATER,   ///< water (gat type 3)
	CELL_CHKCLIFF,   ///< cliff/gap (gat type 5)

	CELL_CHKPASS,    ///< passable cell (gat type non-1/5)
	CELL_CHKREACH,   ///< Same as PASS, but ignores the cell-stacking mod.
	CELL_CHKNOPASS,  ///< non-passable cell (gat types 1 and 5)
	CELL_CHKNOREACH, ///< Same as NOPASS, but ignores the cell-stacking mod.
	CELL_CHKSTACK,   ///< whether cell is full (reached cell stacking limit)

	CELL_CHKNPC,
	CELL_CHKBASILICA,
	CELL_CHKLANDPROTECTOR,
	CELL_CHKNOVENDING,
	CELL_CHKNOCHAT,
	CELL_CHKICEWALL,
	CELL_CHKNOICEWALL,

} cell_chk;

struct mapcell {
	// terrain flags
	unsigned char
		walkable : 1,
		shootable : 1,
		water : 1;

	// dynamic flags
	unsigned char
		npc : 1,
		basilica : 1,
		landprotector : 1,
		novending : 1,
		nochat : 1,
		icewall : 1,
		noicewall : 1;

#ifdef CELL_NOSTACK
	int cell_bl; //Holds amount of bls in this cell.
#endif
};

struct iwall_data {
	char wall_name[50];
	short m, x, y, size;
	int8 dir;
	bool shootable;
};

struct mapflag_skill_adjust {
	unsigned short skill_id;
	unsigned short modifier;
};

enum map_zone_skill_subtype {
	MZS_NONE  = 0x0,
	MZS_CLONE = 0x01,
	MZS_BOSS  = 0x02,

	MZS_ALL   = 0xFFF
};

struct map_zone_disabled_skill_entry {
	int nameid;
	enum bl_type type;
	enum map_zone_skill_subtype subtype;
};
struct map_zone_disabled_command_entry {
	AtCommandFunc cmd;
	int group_lv;
};

struct map_zone_skill_damage_cap_entry {
	int nameid;
	unsigned int cap;
	enum bl_type type;
	enum map_zone_skill_subtype subtype;
};

enum map_zone_merge_type {
	MZMT_NORMAL = 0, ///< MZMT_MERGEABLE zones can merge *into* MZMT_NORMAL zones (but not the converse).
	MZMT_MERGEABLE,  ///< Can merge with other MZMT_MERGEABLE zones and *into* MZMT_NORMAL zones.
	MZMT_NEVERMERGE, ///< Cannot merge with any zones.
};

struct map_zone_data {
	char name[MAP_ZONE_NAME_LENGTH];/* 20'd */
	enum map_zone_merge_type merge_type;
	struct map_zone_disabled_skill_entry **disabled_skills;
	int disabled_skills_count;
	int *disabled_items;
	int disabled_items_count;
	int *cant_disable_items; /** when a zone wants to ensure such a item is never disabled (i.e. gvg zone enables a item that is restricted everywhere else) **/
	int cant_disable_items_count;
	char **mapflags;
	int mapflags_count;
	struct map_zone_disabled_command_entry **disabled_commands;
	int disabled_commands_count;
	struct map_zone_skill_damage_cap_entry **capped_skills;
	int capped_skills_count;
	struct {
		unsigned int merged : 1;
	} info;
};

struct map_drop_list {
	int drop_id;
	int drop_type;
	int drop_per;
};

struct map_data {
	char name[MAP_NAME_LENGTH];
	uint16 index; // The map index used by the mapindex* functions.
	struct mapcell* cell; // Holds the information of each map cell (NULL if the map is not on this map-server).

	/* 2D Orthogonal Range Search: Grid Implementation
	   "Algorithms in Java, Parts 1-4" 3.18, Robert Sedgewick
	   Map is divided into squares, called blocks (side length = BLOCK_SIZE).
	   For each block there is a linked list of objects in that block (block_list).
	   Array provides capability to access immediately the set of objects close
	   to a given object.
	   The linked lists provide the flexibility to store the objects without
	   knowing ahead how many objects fall into each block.
	*/
	struct block_list **block; // Grid array of block_lists containing only non-BL_MOB objects
	struct block_list **block_mob; // Grid array of block_lists containing only BL_MOB objects

	int16 m;
	int16 xs,ys; // map dimensions (in cells)
	int16 bxs,bys; // map dimensions (in blocks)
	int16 bgscore_lion, bgscore_eagle; // Battleground ScoreBoard
	int npc_num;
	int users;
	int users_pvp;
	int iwall_num; // Total of invisible walls in this map
	struct map_flag {
		unsigned town : 1; // [Suggestion to protect Mail System]
		unsigned autotrade : 1;
		unsigned allowks : 1; // [Kill Steal Protection]
		unsigned nomemo : 1;
		unsigned noteleport : 1;
		unsigned noreturn : 1;
		unsigned monster_noteleport : 1;
		unsigned nosave : 1;
		unsigned nobranch : 1;
		unsigned noexppenalty : 1;
		unsigned pvp : 1;
		unsigned pvp_noparty : 1;
		unsigned pvp_noguild : 1;
		unsigned pvp_nightmaredrop :1;
		unsigned pvp_nocalcrank : 1;
		unsigned gvg_castle : 1;
		unsigned gvg : 1; // Now it identifies gvg versus maps that are active 24/7
		unsigned gvg_dungeon : 1; // Celest
		unsigned gvg_noparty : 1;
		unsigned battleground : 2; // [BattleGround System]
		unsigned cvc : 1;
		unsigned nozenypenalty : 1;
		unsigned notrade : 1;
		unsigned noskill : 1;
		unsigned nowarp : 1;
		unsigned nowarpto : 1;
		unsigned noicewall : 1; // [Valaris]
		unsigned snow : 1; // [Valaris]
		unsigned clouds : 1;
		unsigned clouds2 : 1; // [Valaris]
		unsigned fog : 1; // [Valaris]
		unsigned fireworks : 1;
		unsigned sakura : 1; // [Valaris]
		unsigned leaves : 1; // [Valaris]
		unsigned nobaseexp : 1; // [Lorky] added by Lupus
		unsigned nojobexp : 1; // [Lorky]
		unsigned nomobloot : 1; // [Lorky]
		unsigned nomvploot : 1; // [Lorky]
		unsigned nightenabled :1; //For night display. [Skotlex]
		unsigned nodrop : 1;
		unsigned novending : 1;
		unsigned loadevent : 1;
		unsigned nochat :1;
		unsigned partylock :1;
		unsigned guildlock :1;
		unsigned src4instance : 1; // To flag this map when it's used as a src map for instances
		unsigned reset :1; // [Daegaladh]
		unsigned chsysnolocalaj : 1;
		unsigned noknockback : 1;
		unsigned notomb : 1;
		unsigned nocashshop : 1;
		unsigned noautoloot : 1;
		unsigned pairship_startable : 1;
		unsigned pairship_endable : 1;
		unsigned nostorage : 2;
		unsigned nogstorage : 2;
		uint32 noviewid; ///< noviewid (bitmask - @see enum equip_pos)
	} flag;
	struct point save;
	struct npc_data *npc[MAX_NPC_PER_MAP];
	struct map_drop_list *drop_list;
	unsigned short drop_list_count;

	struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer]
	int mob_delete_timer; // [Skotlex]
	int jexp; // map experience multiplicator
	int bexp; // map experience multiplicator
	int nocommand; //Blocks @/# commands for non-gms. [Skotlex]

	// Instance Variables
	int instance_id;
	int instance_src_map;

	/* adjust_unit_duration mapflag */
	struct mapflag_skill_adjust **units;
	unsigned short unit_count;
	/* adjust_skill_damage mapflag */
	struct mapflag_skill_adjust **skills;
	unsigned short skill_count;

	/* Hercules nocast db overhaul */
	struct map_zone_data *zone;
	char **zone_mf;/* used to store this map's zone mapflags that should be re-applied once zone is removed */
	unsigned short zone_mf_count;
	struct map_zone_data *prev_zone;

	/* Hercules Local Chat */
	struct channel_data *channel;

	/* invincible_time_inc mapflag */
	unsigned int invincible_time_inc;

	/* weapon_damage_rate mapflag */
	unsigned short weapon_damage_rate;
	/* magic_damage_rate mapflag */
	unsigned short magic_damage_rate;
	/* misc_damage_rate mapflag */
	unsigned short misc_damage_rate;
	/* short_damage_rate mapflag */
	unsigned short short_damage_rate;
	/* long_damage_rate mapflag */
	unsigned short long_damage_rate;

	bool custom_name; ///< Whether the instanced map is using a custom name

	/* */
	int (*getcellp)(struct map_data* m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk);
	void (*setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag);
	struct {
		uint8 *data;
		int len;
	} cell_buf;

	/* questinfo entries list */
	VECTOR_DECL(struct npc_data) qi_list;

	/* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */
	unsigned short hpmeter_visible;
	struct hplugin_data_store *hdata; ///< HPM Plugin Data Store
};

/// Stores information about a remote map (for multi-mapserver setups).
/// Beginning of data structure matches 'map_data', to allow typecasting.
struct map_data_other_server {
	char name[MAP_NAME_LENGTH];
	unsigned short index; //Index is the map index used by the mapindex* functions.
	struct mapcell* cell; // If this is NULL, the map is not on this map-server
	uint32 ip;
	uint16 port;
};

#define map_id2index(id) (map->list[(id)].index)

/// Bitfield of flags for the iterator.
enum e_mapitflags {
	MAPIT_NORMAL = 0,
	//MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold authed, active players.
};

struct s_mapiterator;

/* temporary until the map.c "Hercules Renewal Phase One" design is complete. */
struct mapit_interface {
	struct s_mapiterator*   (*alloc) (enum e_mapitflags flags, enum bl_type types);
	void                    (*free) (struct s_mapiterator* iter);
	struct block_list*      (*first) (struct s_mapiterator* iter);
	struct block_list*      (*last) (struct s_mapiterator* iter);
	struct block_list*      (*next) (struct s_mapiterator* iter);
	struct block_list*      (*prev) (struct s_mapiterator* iter);
	bool                    (*exists) (struct s_mapiterator* iter);
};

#define mapit_getallusers() (mapit->alloc(MAPIT_NORMAL,BL_PC))
#define mapit_geteachpc()   (mapit->alloc(MAPIT_NORMAL,BL_PC))
#define mapit_geteachmob()  (mapit->alloc(MAPIT_NORMAL,BL_MOB))
#define mapit_geteachnpc()  (mapit->alloc(MAPIT_NORMAL,BL_NPC))
#define mapit_geteachiddb() (mapit->alloc(MAPIT_NORMAL,BL_ALL))

//Useful typedefs from jA [Skotlex]
typedef struct map_session_data TBL_PC;
typedef struct npc_data         TBL_NPC;
typedef struct mob_data         TBL_MOB;
typedef struct flooritem_data   TBL_ITEM;
typedef struct chat_data        TBL_CHAT;
typedef struct skill_unit       TBL_SKILL;
typedef struct pet_data         TBL_PET;
typedef struct homun_data       TBL_HOM;
typedef struct mercenary_data   TBL_MER;
typedef struct elemental_data   TBL_ELEM;

/**
 * Casts a block list to a specific type.
 *
 * @remark
 *   The `bl` argument may be evaluated more than once.
 *
 * @param type_ The block list type (using symbols from enum bl_type).
 * @param bl    The source block list to cast.
 * @return The block list, cast to the correct type.
 * @retval NULL if bl is the wrong type or NULL.
 */
#define BL_CAST(type_, bl) \
	( ((bl) == (struct block_list *)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) )

/**
 * Casts a const block list to a specific type.
 *
 * @remark
 *   The `bl` argument may be evaluated more than once.
 *
 * @param type_ The block list type (using symbols from enum bl_type).
 * @param bl    The source block list to cast.
 * @return The block list, cast to the correct type.
 * @retval NULL if bl is the wrong type or NULL.
 */
#define BL_CCAST(type_, bl) \
	( ((bl) == (const struct block_list *)NULL || (bl)->type != (type_)) ? (const T ## type_ *)NULL : (const T ## type_ *)(bl) )

/**
 * Helper function for `BL_UCAST`.
 *
 * @warning
 *   This function shouldn't be called on it own.
 *
 * The purpose of this function is to produce a compile-timer error if a non-bl
 * object is passed to BL_UCAST. It's declared as static inline to let the
 * compiler optimize out the function call overhead.
 */
static inline struct block_list *BL_UCAST_(struct block_list *bl) __attribute__((unused));
static inline struct block_list *BL_UCAST_(struct block_list *bl)
{
	return bl;
}

/**
 * Casts a block list to a specific type, without performing any type checks.
 *
 * @remark
 *   The `bl` argument is guaranteed to be evaluated once and only once.
 *
 * @param type_ The block list type (using symbols from enum bl_type).
 * @param bl    The source block list to cast.
 * @return The block list, cast to the correct type.
 */
#define BL_UCAST(type_, bl) \
	((T ## type_ *)BL_UCAST_(bl))

/**
 * Helper function for `BL_UCCAST`.
 *
 * @warning
 *   This function shouldn't be called on it own.
 *
 * The purpose of this function is to produce a compile-timer error if a non-bl
 * object is passed to BL_UCAST. It's declared as static inline to let the
 * compiler optimize out the function call overhead.
 */
static inline const struct block_list *BL_UCCAST_(const struct block_list *bl) __attribute__((unused));
static inline const struct block_list *BL_UCCAST_(const struct block_list *bl)
{
	return bl;
}

/**
 * Casts a const block list to a specific type, without performing any type checks.
 *
 * @remark
 *   The `bl` argument is guaranteed to be evaluated once and only once.
 *
 * @param type_ The block list type (using symbols from enum bl_type).
 * @param bl    The source block list to cast.
 * @return The block list, cast to the correct type.
 */
#define BL_UCCAST(type_, bl) \
	((const T ## type_ *)BL_UCCAST_(bl))

struct charid_request {
	struct charid_request* next;
	int charid;// who want to be notified of the nick
};
struct charid2nick {
	char nick[NAME_LENGTH];
	struct charid_request* requests;// requests of notification on this nick
};

// New mcache file format header
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(push, 1)
#endif // not NetBSD < 6 / Solaris
struct map_cache_header {
	int16 version;
	uint8 md5_checksum[16];
	int16 xs;
	int16 ys;
	int32 len;
} __attribute__((packed));
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(pop)
#endif // not NetBSD < 6 / Solaris

/*=====================================
* Interface : map.h
* Generated by HerculesInterfaceMaker
* created by Susu
*-------------------------------------*/
struct map_interface {

	/* vars */
	bool minimal;     ///< Starts the server in minimal initialization mode.
	bool scriptcheck; ///< Starts the server in script-check mode.

	/** Additional scripts requested through the command-line */
	char **extra_scripts;
	int extra_scripts_count;

	int retval;
	int count;

	int autosave_interval;
	int minsave_interval;
	int save_settings;
	int agit_flag;
	int agit2_flag;
	int night_flag; // 0=day, 1=night [Yor]
	int enable_spy; //Determines if @spy commands are active.
	char db_path[256];

	char help_txt[256];
	char charhelp_txt[256];

	char wisp_server_name[NAME_LENGTH];

	char *INTER_CONF_NAME;
	char *LOG_CONF_NAME;
	char *MAP_CONF_NAME;
	char *BATTLE_CONF_FILENAME;
	char *ATCOMMAND_CONF_FILENAME;
	char *SCRIPT_CONF_NAME;
	char *MSG_CONF_NAME;
	char *GRF_PATH_FILENAME;

	char autotrade_merchants_db[32];
	char autotrade_data_db[32];
	char npc_market_data_db[32];
	char npc_barter_data_db[32];
	char npc_expanded_barter_data_db[32];

	char default_codepage[32];
	char default_lang_str[64];
	uint8 default_lang_id;

	int server_port;
	char server_ip[32];
	char server_id[32];
	char server_pw[100];
	char server_db[32];
	struct Sql *mysql_handle;

	uint16 port;
	int users;
	int enable_grf; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89]
	bool ip_set;
	bool char_ip_set;

	int16 index2mapid[MAX_MAPINDEX];
	/* */
	struct DBMap *id_db;     // int id -> struct block_list*
	struct DBMap *pc_db;     // int id -> struct map_session_data*
	struct DBMap *mobid_db;  // int id -> struct mob_data*
	struct DBMap *bossid_db; // int id -> struct mob_data* (MVP db)
	struct DBMap *map_db;    // unsigned int mapindex -> struct map_data_other_server*
	struct DBMap *nick_db;   // int char_id -> struct charid2nick* (requested names of offline characters)
	struct DBMap *charid_db; // int char_id -> struct map_session_data*
	struct DBMap *regen_db;  // int id -> struct block_list* (status_natural_heal processing)
	struct DBMap *zone_db;   // string => struct map_zone_data
	struct DBMap *iwall_db;
	struct block_list **block_free;
	int block_free_count, block_free_lock, block_free_list_size;
	struct block_list **bl_list;
	int bl_list_count, bl_list_size;
BEGIN_ZEROED_BLOCK; // This block is zeroed in map_defaults()
	struct block_list bl_head;
	struct map_zone_data zone_all;/* used as a base on all maps */
	struct map_zone_data zone_pk;/* used for (pk_mode) */
END_ZEROED_BLOCK;
	/* */
	struct map_session_data *cpsd;
	struct map_data *list;
	/* [Ind/Hercules] */
	struct eri *iterator_ers;
	/* */
	struct eri *flooritem_ers;
	/* */
	int bonus_id;
	/* */
	bool cpsd_active;
	/* funcs */
	void (*zone_init) (void);
	void (*zone_remove) (int m);
	void (*zone_remove_all) (int m);
	void (*zone_apply) (int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath);
	void (*zone_change) (int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath);
	void (*zone_change2) (int m, struct map_zone_data *zone);
	void (*zone_reload) (void);

	int (*getcell) (int16 m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk);
	void (*setgatcell) (int16 m, int16 x, int16 y, int gat);

	void (*cellfromcache) (struct map_data *m);
	// users
	void (*setusers) (int);
	int (*getusers) (void);
	int (*usercount) (void);
	// blocklist lock
	int (*freeblock) (struct block_list *bl);
	int (*freeblock_lock) (void);
	int (*freeblock_unlock) (void);
	// blocklist manipulation
	int (*addblock) (struct block_list* bl);
	int (*delblock) (struct block_list* bl);
	int (*moveblock) (struct block_list *bl, int x1, int y1, int64 tick);
	//blocklist nb in one cell
	int (*count_oncell) (int16 m,int16 x,int16 y,int type,int flag);
	struct skill_unit * (*find_skill_unit_oncell) (struct block_list* target,int16 x,int16 y,uint16 skill_id,struct skill_unit* out_unit, int flag);
	// search and creation
	int (*get_new_object_id) (void);
	int (*search_freecell) (struct block_list *src, int16 m, int16 *x, int16 *y, int16 rx, int16 ry, int flag);
	bool (*closest_freecell) (int16 m, const struct block_list *bl, int16 *x, int16 *y, int type, int flag);
	//
	int (*quit) (struct map_session_data *sd);
	// npc
	bool (*addnpc) (int16 m,struct npc_data *nd);
	// map item
	int (*clearflooritem_timer) (int tid, int64 tick, int id, intptr_t data);
	int (*removemobs_timer) (int tid, int64 tick, int id, intptr_t data);
	void (*clearflooritem) (struct block_list* bl);
	int (*addflooritem) (const struct block_list *bl, struct item *item_data, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, bool showdropeffect);
	// player to map session
	void (*addnickdb) (int charid, const char* nick);
	void (*delnickdb) (int charid, const char* nick);
	void (*reqnickdb) (struct map_session_data* sd,int charid);
	const char* (*charid2nick) (int charid);
	struct map_session_data* (*charid2sd) (int charid);

	void (*vforeachpc) (int (*func)(struct map_session_data* sd, va_list args), va_list args);
	void (*foreachpc) (int (*func)(struct map_session_data* sd, va_list args), ...);
	void (*vforeachmob) (int (*func)(struct mob_data* md, va_list args), va_list args);
	void (*foreachmob) (int (*func)(struct mob_data* md, va_list args), ...);
	void (*vforeachnpc) (int (*func)(struct npc_data* nd, va_list args), va_list args);
	void (*foreachnpc) (int (*func)(struct npc_data* nd, va_list args), ...);
	void (*vforeachregen) (int (*func)(struct block_list* bl, va_list args), va_list args);
	void (*foreachregen) (int (*func)(struct block_list* bl, va_list args), ...);
	void (*vforeachiddb) (int (*func)(struct block_list* bl, va_list args), va_list args);
	void (*foreachiddb) (int (*func)(struct block_list* bl, va_list args), ...);

	int (*vforeachinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, va_list ap);
	int (*foreachinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
	int (*vforeachinshootrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, va_list ap);
	int (*foreachinshootrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
	int (*vforeachinarea) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, va_list ap);
	int (*foreachinarea) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, ...);
	int (*vforcountinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int count, int type, va_list ap);
	int (*forcountinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int count, int type, ...);
	int (*vforcountinarea) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, va_list ap);
	int (*forcountinarea) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, ...);
	int (*vforeachinmovearea) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, va_list ap);
	int (*foreachinmovearea) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, ...);
	int (*vforeachincell) (int (*func)(struct block_list*,va_list), int16 m, int16 x, int16 y, int type, va_list ap);
	int (*foreachincell) (int (*func)(struct block_list*,va_list), int16 m, int16 x, int16 y, int type, ...);
	int (*vforeachinpath) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int type, va_list ap);
	int (*foreachinpath) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int type, ...);
	int (*vforeachinmap) (int (*func)(struct block_list*,va_list), int16 m, int type, va_list args);
	int (*foreachinmap) (int (*func)(struct block_list*,va_list), int16 m, int type, ...);
	int (*forcountinmap) (int (*func)(struct block_list*,va_list), int16 m, int count, int type, ...);
	int (*vforeachininstance)(int (*func)(struct block_list*,va_list), int16 instance_id, int type, va_list ap);
	int (*foreachininstance)(int (*func)(struct block_list*,va_list), int16 instance_id, int type,...);

	struct map_session_data *(*id2sd) (int id);
	struct npc_data *(*id2nd) (int id);
	struct mob_data *(*id2md) (int id);
	struct flooritem_data *(*id2fi) (int id);
	struct chat_data *(*id2cd) (int id);
	struct skill_unit *(*id2su) (int id);
	struct pet_data *(*id2pd) (int id);
	struct homun_data *(*id2hd) (int id);
	struct mercenary_data *(*id2mc) (int id);
	struct elemental_data *(*id2ed) (int id);
	struct block_list *(*id2bl) (int id);
	bool (*blid_exists) (int id);
	int16 (*mapindex2mapid) (unsigned short map_index);
	int16 (*mapname2mapid) (const char* name);
	int (*mapname2ipport) (unsigned short name, uint32* ip, uint16* port);
	int (*setipport) (unsigned short map_index, uint32 ip, uint16 port);
	int (*eraseipport) (unsigned short map_index, uint32 ip, uint16 port);
	int (*eraseallipport) (void);
	void (*addiddb) (struct block_list *bl);
	void (*deliddb) (struct block_list *bl);
	/* */
	struct map_session_data * (*nick2sd) (const char *nick, bool allow_partial);
	struct mob_data * (*getmob_boss) (int16 m);
	struct mob_data * (*id2boss) (int id);
	uint32 (*race_id2mask) (int race);
	// reload config file looking only for npcs
	void (*reloadnpc) (bool clear);

	int (*check_dir) (int s_dir,int t_dir);
	uint8 (*calc_dir) (struct block_list *src,int16 x,int16 y);
	int (*random_dir) (struct block_list *bl, short *x, short *y); // [Skotlex]

	int (*cleanup_sub) (struct block_list *bl, va_list ap);

	int (*delmap) (const char *mapname);
	void (*flags_init) (void);

	bool (*iwall_set) (int16 m, int16 x, int16 y, int size, int8 dir, bool shootable, const char* wall_name);
	void (*iwall_get) (struct map_session_data *sd);
	bool (*iwall_remove) (const char *wall_name);

	int (*addmobtolist) (unsigned short m, struct spawn_data *spawn); // [Wizputer]
	void (*spawnmobs) (int16 m); // [Wizputer]
	void (*removemobs) (int16 m); // [Wizputer]
	//void (*do_reconnect_map) (void); //Invoked on map-char reconnection [Skotlex] Note used but still keeping it, just in case
	void (*addmap2db) (struct map_data *m);
	void (*removemapdb) (struct map_data *m);
	void (*clean) (int i);

	void (*do_shutdown) (void);

	int (*freeblock_timer) (int tid, int64 tick, int id, intptr_t data);
	int (*searchrandfreecell) (int16 m, const struct block_list *bl, int16 *x, int16 *y, int stack);
	int (*count_sub) (struct block_list *bl, va_list ap);
	struct DBData (*create_charid2nick) (union DBKey key, va_list args);
	int (*removemobs_sub) (struct block_list *bl, va_list ap);
	struct mapcell (*gat2cell) (int gat);
	int (*cell2gat) (struct mapcell cell);
	int (*getcellp) (struct map_data *m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk);
	void (*setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag);
	int (*sub_getcellp) (struct map_data *m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk);
	void (*sub_setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag);
	void (*iwall_nextxy) (int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1);
	struct DBData (*create_map_data_other_server) (union DBKey key, va_list args);
	int (*eraseallipport_sub) (union DBKey key, struct DBData *data, va_list va);
	bool (*readfromcache) (struct map_data *m);
	bool (*readfromcache_v1) (FILE *fp, struct map_data *m, unsigned int file_size);
	int (*addmap) (const char *mapname);
	void (*delmapid) (int id);
	void (*zone_db_clear) (void);
	void (*list_final) (void);
	int (*waterheight) (char *mapname);
	int (*readgat) (struct map_data *m);
	int (*readallmaps) (void);
	bool (*config_read) (const char *filename, bool imported);
	bool (*read_npclist) (const char *filename, bool imported);
	bool (*inter_config_read) (const char *filename, bool imported);
	bool (*inter_config_read_database_names) (const char *filename, const struct config_t *config, bool imported);
	bool (*inter_config_read_connection) (const char *filename, const struct config_t *config, bool imported);
	int (*sql_init) (void);
	int (*sql_close) (void);
	bool (*zone_mf_cache) (int m, char *flag, char *params);
	int (*zone_str2itemid) (const char *name);
	unsigned short (*zone_str2skillid) (const char *name);
	enum bl_type (*zone_bl_type) (const char *entry, enum map_zone_skill_subtype *subtype);
	void (*read_zone_db) (void);
	int (*db_final) (union DBKey key, struct DBData *data, va_list ap);
	int (*nick_db_final) (union DBKey key, struct DBData *data, va_list args);
	int (*cleanup_db_sub) (union DBKey key, struct DBData *data, va_list va);
	int (*abort_sub) (struct map_session_data *sd, va_list ap);
	void (*update_cell_bl) (struct block_list *bl, bool increase);
	int (*get_new_bonus_id) (void);
	bool (*add_questinfo) (int m, struct npc_data *nd);
	bool (*remove_questinfo) (int m, struct npc_data *nd);
	struct map_zone_data *(*merge_zone) (struct map_zone_data *main, struct map_zone_data *other);
	void (*zone_clear_single) (struct map_zone_data *zone);
};

#ifdef HERCULES_CORE
void map_defaults(void);
#endif // HERCULES_CORE

HPShared struct mapit_interface *mapit;
HPShared struct map_interface *map;

#endif /* MAP_MAP_H */