00001
00016
00017
00018 #ifndef ADIKT_LEVDATA_H
00019 #define ADIKT_LEVDATA_H
00020
00021 #include "globals.h"
00022
00023
00024
00025 #define MAP_SIZE_DKSTD_X 85
00026 #define MAP_SIZE_DKSTD_Y 85
00027 #define MAP_SIZE_H 1
00028 #define MAP_SUBNUM_H 8
00029 #define MAP_SUBNUM_X 3
00030 #define MAP_SUBNUM_Y 3
00031 #define COLUMN_ENTRIES 2048
00032
00038 enum MAP_FORMAT_VERSION {
00039 MFV_DKSTD = 0,
00040 MFV_DKGOLD = 1,
00041 MFV_DKXPAND = 2,
00042 MFV_DK2STD = 10,
00043 MFV_DK2OFC = 11,
00044 };
00045
00046 enum OBJECT_TYPE_INDEX {
00047 OBJECT_TYPE_NONE = 0,
00048 OBJECT_TYPE_ACTNPT = 1,
00049 OBJECT_TYPE_THING = 2,
00050 OBJECT_TYPE_STLIGHT = 3,
00051 OBJECT_TYPE_COLUMN = 16,
00052 OBJECT_TYPE_SLAB = 17,
00053 OBJECT_TYPE_DATLST = 18,
00054 };
00055
00056 enum VERIFY_WARN_FLAGS {
00057 VWFLAG_NONE = 0,
00058 VWFLAG_NOWARN_MANYHEART = 1,
00059
00060 };
00061
00062
00063
00064 #define SIZEOF_DK_TNG_REC 21
00065 #define SIZEOF_DK_CLM_REC 24
00066 #define SIZEOF_DK_APT_REC 8
00067 #define SIZEOF_DK_LGT_REC 20
00068
00069 #define SIZEOF_DK_CLM_HEADER 8
00070 #define SIZEOF_DK_APT_HEADER 4
00071 #define SIZEOF_DK_LGT_HEADER 4
00072 #define SIZEOF_DK_TNG_HEADER 2
00073
00078 enum DIRECTION_INDEX {
00079 IDIR_CENTR = 4,
00080 IDIR_NW = 0,
00081 IDIR_NORTH = 1,
00082 IDIR_NE = 2,
00083 IDIR_EAST = 5,
00084 IDIR_SE = 8,
00085 IDIR_SOUTH = 7,
00086 IDIR_SW = 6,
00087 IDIR_WEST = 3,
00088 };
00089
00090
00091
00092
00093
00097 enum GRAFFITI_ORIENT {
00098 ORIENT_NS = 0x00,
00099 ORIENT_WE = 0x01,
00100 ORIENT_SN = 0x02,
00101 ORIENT_EW = 0x03,
00102 ORIENT_TNS = 0x04,
00103 ORIENT_TWE = 0x05,
00104 ORIENT_TSN = 0x06,
00105 ORIENT_TEW = 0x07,
00106 };
00107
00108 extern const int idir_subtl_x[];
00109 extern const int idir_subtl_y[];
00110
00114 enum GRAFFITI_FONT {
00115 GRAFF_FONT_NONE = 0x00,
00116 GRAFF_FONT_ADICLSSC = 0x01,
00117 GRAFF_FONT_ADISIZE8 = 0x02,
00118 };
00119
00123 enum STATS_LINE_TYPE {
00124 STLT_NONE = 0,
00125 STLT_HEADER = 1,
00126 STLT_MAINITEM = 2,
00127 STLT_SUBITEM = 3,
00128 STLT_EMPTY = 4,
00129 };
00130
00134 struct DK_GRAFFITI {
00135 struct IPOINT_2D tile;
00136 char *text;
00137 unsigned short font;
00138 unsigned short orient;
00139 int height;
00140 struct IPOINT_2D fin_tile;
00141 unsigned short cube;
00142 };
00143
00147 struct DK_SCRIPT_PLAYER {
00148 unsigned int max_creatures;
00149 unsigned long start_gold;
00150 int computer_player;
00151 unsigned short *ally;
00152 unsigned short *creature_avail;
00153 int *creature_maxlvl;
00154 unsigned short *room_avail;
00155 unsigned short *spell_avail;
00156 unsigned short *trap_avail;
00157 unsigned short *door_avail;
00158 unsigned int *trap_amount;
00159 unsigned int *door_amount;
00160 };
00161
00166 struct DK_SCRIPT_PARTYMEMBER {
00167 short type;
00168 unsigned short level;
00169 unsigned long gold;
00170 unsigned short objctiv;
00171 unsigned long cntdown;
00172 };
00173
00178 struct DK_SCRIPT_PARTY {
00179 char *name;
00180 struct DK_SCRIPT_PARTYMEMBER *member;
00181 unsigned short count;
00182 };
00183
00188 struct DK_SCRIPT_ADDEVENT {
00189 unsigned short owner;
00190 unsigned short type;
00191 struct DK_SCRIPT_PARTYMEMBER leader;
00192 int actnpt;
00193 char *partyname;
00194 unsigned short num;
00195 };
00196
00202 struct DK_SCRIPT_PARAMETERS {
00203
00204 unsigned long portal_gen_speed;
00205 short dead_return_to_pool;
00206 int end_level;
00207
00208 struct DK_SCRIPT_PLAYER *player;
00209
00210 unsigned int *creature_pool;
00211
00212 struct DK_SCRIPT_ADDEVENT *addevent;
00213 unsigned int addevent_count;
00214 struct DK_SCRIPT_PARTY *party;
00215 unsigned int party_count;
00216
00217
00218 struct DK_SCRIPT_COMMAND **rest;
00219 int rest_count;
00220 };
00221
00226 struct DK_SCRIPT {
00227 struct DK_SCRIPT_COMMAND **list;
00228 struct DK_SCRIPT_PARAMETERS par;
00229 char **txt;
00230 int lines_count;
00231 };
00232
00237 struct LEVSTATS {
00238
00239 int creatures_count;
00240 int effectgenrts_count;
00241 int traps_count;
00242 int doors_count;
00243 int items_count;
00244
00245 int hero_gates_count;
00246 int dn_hearts_count;
00247 int things_count[THING_CATEGR_COUNT];
00248
00249 int room_things_count;
00250
00251 int things_removed;
00252 int things_added;
00253
00254 int saves_count;
00255
00256 int unsaved_changes;
00257 };
00258
00263 struct LEVINFO {
00264
00265 unsigned long usr_cmds_count;
00266 unsigned long usr_mdswtch_count;
00267 unsigned long usr_slbchng_count;
00268 unsigned long usr_creatobj_count;
00269
00270 time_t creat_date;
00271 time_t lastsav_date;
00272
00273 int ver_major;
00274 int ver_minor;
00275 int ver_rel;
00276
00277 char *name_text;
00278 char *desc_text;
00279 char *author_text;
00280 char *editor_text;
00281 };
00282
00288 struct LEVEL {
00289
00290 short format_version;
00291
00292 struct UPOINT_2D tlsize;
00293
00294 struct UPOINT_2D subsize;
00295
00296 char *fname;
00297
00298 char *savfname;
00299
00300 unsigned short **slb;
00301
00302 unsigned char **own;
00303
00304 unsigned char **wib;
00305
00306
00307 unsigned char **wlb;
00308
00309 unsigned short **flg;
00310
00311
00312 unsigned char **clm;
00313
00314 unsigned int *clm_utilize;
00315
00316 unsigned char *clm_hdr;
00317
00318 unsigned char inf;
00319
00320
00321 struct DK_SCRIPT script;
00322
00323
00324
00325 unsigned char ****apt_lookup;
00326 unsigned short **apt_subnums;
00327 unsigned int apt_total_count;
00328
00329 unsigned char ****tng_lookup;
00330 unsigned short **tng_subnums;
00331 unsigned int tng_total_count;
00332
00333
00334 unsigned char ****lgt_lookup;
00335 unsigned short **lgt_subnums;
00336 unsigned int lgt_total_count;
00337
00338 unsigned short **tng_apt_lgt_nums;
00339
00340
00341
00342
00343 unsigned short **dat;
00344
00345
00346
00347 struct LEVSTATS stats;
00348
00349 struct LEVINFO info;
00350
00351 struct LEVOPTIONS optns;
00352
00353
00354
00355 struct DK_CUSTOM_CLM ***cust_clm_lookup;
00356 unsigned int cust_clm_count;
00357 struct DK_GRAFFITI **graffiti;
00358 unsigned int graffiti_count;
00359 };
00360
00361 extern const char default_map_name[];
00362
00363
00364 DLLIMPORT short level_init(struct LEVEL **lvl_ptr,short map_version,struct UPOINT_3D *lvl_size);
00365
00366 DLLIMPORT short level_deinit(struct LEVEL **lvl_ptr);
00367 DLLIMPORT short level_set_options(struct LEVEL *lvl,struct LEVOPTIONS *optns);
00368 DLLIMPORT struct LEVOPTIONS *level_get_options(struct LEVEL *lvl);
00369 DLLIMPORT short level_set_mapdraw_options(struct LEVEL *lvl,struct MAPDRAW_OPTIONS *mdrwopts);
00370 DLLIMPORT struct MAPDRAW_OPTIONS *level_get_mapdraw_options(struct LEVEL *lvl);
00371
00372 DLLIMPORT short level_clear(struct LEVEL *lvl);
00373 short level_clear_tng(struct LEVEL *lvl);
00374 short level_clear_apt(struct LEVEL *lvl);
00375 short level_clear_lgt(struct LEVEL *lvl);
00376 short level_clear_datclm(struct LEVEL *lvl);
00377 short level_clear_other(struct LEVEL *lvl);
00378 short level_clear_stats(struct LEVEL *lvl);
00379 short level_clear_info(struct LEVEL *lvl);
00380 short level_clear_script(struct LEVEL *lvl);
00381 DLLIMPORT short level_clear_script_param(struct DK_SCRIPT_PARAMETERS *par);
00382 DLLIMPORT short level_clear_options(struct LEVOPTIONS *optns);
00383
00384 DLLIMPORT short level_free(struct LEVEL *lvl);
00385 short level_free_tng(struct LEVEL *lvl);
00386 DLLIMPORT short level_free_script_param(struct DK_SCRIPT_PARAMETERS *par);
00387 DLLIMPORT short free_text_file(char ***lines,int *lines_count);
00388
00389 DLLIMPORT short level_verify(struct LEVEL *lvl, char *actn_name,struct IPOINT_2D *errpt);
00390 DLLIMPORT short level_verify_struct(struct LEVEL *lvl, char *err_msg,struct IPOINT_2D *errpt);
00391 short actnpts_verify(struct LEVEL *lvl, char *err_msg,struct IPOINT_2D *errpt);
00392 DLLIMPORT short level_verify_logic(struct LEVEL *lvl, char *err_msg,struct IPOINT_2D *errpt);
00393 DLLIMPORT void start_new_map(struct LEVEL *lvl);
00394 DLLIMPORT void generate_random_map(struct LEVEL *lvl);
00395 DLLIMPORT void generate_slab_bkgnd_default(struct LEVEL *lvl,unsigned short def_slab);
00396 DLLIMPORT void generate_slab_bkgnd_random(struct LEVEL *lvl);
00397 DLLIMPORT short level_generate_random_extension(struct LEVEL *lvl,char *ret_msg);
00398 DLLIMPORT struct DK_SCRIPT_PARAMETERS *level_get_script_param(struct LEVEL *lvl);
00399
00400 DLLIMPORT void free_map(struct LEVEL *lvl);
00401
00402 DLLIMPORT char *get_thing(const struct LEVEL *lvl,unsigned int sx,unsigned int sy,unsigned int num);
00403 DLLIMPORT int thing_add(struct LEVEL *lvl,unsigned char *thing);
00404 DLLIMPORT void thing_del(struct LEVEL *lvl,unsigned int sx,unsigned int sy,unsigned int num);
00405 DLLIMPORT void thing_drop(struct LEVEL *lvl,unsigned int sx, unsigned int sy, unsigned int num);
00406 DLLIMPORT unsigned int get_thing_subnums(const struct LEVEL *lvl,unsigned int sx,unsigned int sy);
00407
00408 DLLIMPORT char *get_actnpt(const struct LEVEL *lvl,unsigned int sx,unsigned int sy,unsigned int num);
00409 DLLIMPORT int actnpt_add(struct LEVEL *lvl,unsigned char *actnpt);
00410 DLLIMPORT void actnpt_del(struct LEVEL *lvl,unsigned int sx,unsigned int sy,unsigned int num);
00411 DLLIMPORT unsigned int get_actnpt_subnums(const struct LEVEL *lvl,unsigned int sx,unsigned int sy);
00412
00413 DLLIMPORT char *get_stlight(const struct LEVEL *lvl,unsigned int sx,unsigned int sy,unsigned int num);
00414 DLLIMPORT int stlight_add(struct LEVEL *lvl,unsigned char *stlight);
00415 DLLIMPORT void stlight_del(struct LEVEL *lvl,unsigned int sx,unsigned int sy,unsigned int num);
00416 DLLIMPORT unsigned int get_stlight_subnums(const struct LEVEL *lvl,unsigned int sx,unsigned int sy);
00417
00418 DLLIMPORT short get_object_type(const struct LEVEL *lvl, unsigned int sx, unsigned int sy, unsigned int z);
00419 DLLIMPORT unsigned char *get_object(const struct LEVEL *lvl,unsigned int sx,unsigned int sy,unsigned int z);
00420 DLLIMPORT void object_del(struct LEVEL *lvl,unsigned int sx,unsigned int sy,unsigned int z);
00421 DLLIMPORT unsigned int get_object_subnums(const struct LEVEL *lvl,unsigned int sx,unsigned int sy);
00422 DLLIMPORT unsigned int get_object_tilnums(const struct LEVEL *lvl,unsigned int tx,unsigned int ty);
00423 DLLIMPORT int get_object_subtl_last(const struct LEVEL *lvl,unsigned int sx,unsigned int sy,short obj_type);
00424 DLLIMPORT void update_object_owners(struct LEVEL *lvl);
00425
00426 DLLIMPORT unsigned int get_lgt_total_count(struct LEVEL *lvl);
00427 DLLIMPORT unsigned int get_apt_total_count(struct LEVEL *lvl);
00428 DLLIMPORT unsigned int get_tng_total_count(struct LEVEL *lvl);
00429 DLLIMPORT short get_datclm_auto_update(struct LEVEL *lvl);
00430 DLLIMPORT short switch_datclm_auto_update(struct LEVEL *lvl);
00431 DLLIMPORT short set_datclm_auto_update(struct LEVEL *lvl,short val);
00432 DLLIMPORT short get_obj_auto_update(struct LEVEL *lvl);
00433 DLLIMPORT short switch_obj_auto_update(struct LEVEL *lvl);
00434 DLLIMPORT short set_obj_auto_update(struct LEVEL *lvl,short val);
00435
00436 DLLIMPORT short get_subtl_wib(struct LEVEL *lvl, unsigned int sx, unsigned int sy);
00437 DLLIMPORT void set_subtl_wib(struct LEVEL *lvl, unsigned int sx, unsigned int sy, short nval);
00438
00439 DLLIMPORT short get_tile_wlb(struct LEVEL *lvl, unsigned int tx, unsigned int ty);
00440 DLLIMPORT void set_tile_wlb(struct LEVEL *lvl, unsigned int tx, unsigned int ty, short nval);
00441
00442 DLLIMPORT unsigned char get_tile_owner(const struct LEVEL *lvl, unsigned int tx, unsigned int ty);
00443 DLLIMPORT void set_tile_owner(struct LEVEL *lvl, unsigned int tx, unsigned int ty, unsigned char nval);
00444 DLLIMPORT unsigned char get_subtl_owner(const struct LEVEL *lvl, unsigned int sx, unsigned int sy);
00445 DLLIMPORT void set_subtl_owner(struct LEVEL *lvl, unsigned int sx, unsigned int sy, unsigned char nval);
00446 DLLIMPORT short user_set_tile_owner(struct LEVEL *lvl, unsigned int tx, unsigned int ty, unsigned short nown);
00447 DLLIMPORT short user_set_owner_rect(struct LEVEL *lvl, unsigned int startx, unsigned int endx,
00448 unsigned int starty, unsigned int endy, unsigned short nown);
00449
00450 DLLIMPORT unsigned short get_tile_slab(const struct LEVEL *lvl, unsigned int tx, unsigned int ty);
00451 DLLIMPORT void set_tile_slab(struct LEVEL *lvl, unsigned int tx, unsigned int ty, unsigned short nval);
00452 DLLIMPORT short user_set_slab(struct LEVEL *lvl, unsigned int tx, unsigned int ty, unsigned short nslab);
00453 DLLIMPORT short user_set_slab_rect(struct LEVEL *lvl, unsigned int startx, unsigned int endx,
00454 unsigned int starty, unsigned int endy, unsigned short nslab);
00455 DLLIMPORT short user_set_slabown_rect(struct LEVEL *lvl, unsigned int startx, unsigned int endx,
00456 unsigned int starty, unsigned int endy, unsigned short nslab,unsigned short nown);
00457
00458 DLLIMPORT unsigned int get_dat_val(const struct LEVEL *lvl, const unsigned int sx, const unsigned int sy);
00459 DLLIMPORT void set_dat_val(struct LEVEL *lvl, int sx, int sy, unsigned int d);
00460
00461 DLLIMPORT unsigned short get_subtl_flg(struct LEVEL *lvl, unsigned int sx, unsigned int sy);
00462 DLLIMPORT void set_subtl_flg(struct LEVEL *lvl, unsigned int sx, unsigned int sy,unsigned short nval);
00463
00464 DLLIMPORT short set_lvl_fname(struct LEVEL *lvl,char *fname);
00465 DLLIMPORT short format_lvl_fname(struct LEVEL *lvl,char *namefmt);
00466 DLLIMPORT char *get_lvl_fname(struct LEVEL *lvl);
00467 DLLIMPORT short set_lvl_savfname(struct LEVEL *lvl,char *fname);
00468 DLLIMPORT short format_lvl_savfname(struct LEVEL *lvl,char *namefmt);
00469 DLLIMPORT char *get_lvl_savfname(struct LEVEL *lvl);
00470 DLLIMPORT short set_levels_path(struct LEVEL *lvl,char *lvpath);
00471 DLLIMPORT char *get_levels_path(struct LEVEL *lvl);
00472 DLLIMPORT short set_data_path(struct LEVEL *lvl,char *datpath);
00473 DLLIMPORT char *get_data_path(struct LEVEL *lvl);
00474
00475 DLLIMPORT char *get_lif_name_text(struct LEVEL *lvl);
00476 DLLIMPORT short set_lif_name_text(struct LEVEL *lvl,char *name);
00477
00478 DLLIMPORT struct DK_SCRIPT *get_lvl_script(struct LEVEL *lvl);
00479 DLLIMPORT struct LEVSTATS *get_lvl_stats(struct LEVEL *lvl);
00480
00481 DLLIMPORT unsigned long inc_info_usr_mdswtch_count(struct LEVEL *lvl);
00482 DLLIMPORT unsigned long inc_info_usr_cmds_count(struct LEVEL *lvl);
00483 DLLIMPORT unsigned long inc_info_usr_slbchng_count(struct LEVEL *lvl);
00484 DLLIMPORT unsigned long inc_info_usr_creatobj_count(struct LEVEL *lvl);
00485
00486 DLLIMPORT unsigned int inc_info_ver_major(struct LEVEL *lvl);
00487 DLLIMPORT unsigned int inc_info_ver_minor(struct LEVEL *lvl);
00488 DLLIMPORT unsigned int inc_info_ver_rel(struct LEVEL *lvl);
00489
00490 DLLIMPORT void update_level_stats(struct LEVEL *lvl);
00491 DLLIMPORT void update_things_stats(struct LEVEL *lvl);
00492 DLLIMPORT void update_thing_stats(struct LEVEL *lvl,const unsigned char *thing,short change);
00493 DLLIMPORT short get_level_objstats_textln(struct LEVEL *lvl,char *stat_buf,const int line_num);
00494
00495 DLLIMPORT unsigned char get_lvl_inf(struct LEVEL *lvl);
00496 DLLIMPORT short set_lvl_inf(struct LEVEL *lvl,unsigned char ninf);
00497 DLLIMPORT short get_lvl_format_version(struct LEVEL *lvl);
00498
00499 #endif // ADIKT_LEVDATA_H