Definition in file lev_files.c.
#include "lev_files.h"
#include <sys/stat.h>
#include "globals.h"
#include "arr_utils.h"
#include "memfile.h"
#include "obj_column_def.h"
#include "obj_slabs.h"
#include "obj_things.h"
#include "bulcommn.h"
#include "obj_column.h"
#include "lev_data.h"
#include "lev_script.h"
Go to the source code of this file.
Typedefs | |
typedef short(* | mapfile_io_func )(struct LEVEL *lvl, char *fname) |
Level file load/write function type definition. | |
typedef short(* | mapfile_iomsg_func )(struct LEVEL *lvl, struct MEMORY_FILE *mem, char *err_msg) |
Level file load/write function with error message parameter. | |
Functions | |
char * | levfile_error (int errcode) |
Returns load error message for specified error code. | |
short | load_tng (struct LEVEL *lvl, char *fname) |
Reads the TNG file into LEVEL structure. | |
short | load_clm (struct LEVEL *lvl, char *fname) |
Reads the CLM file into LEVEL structure. | |
short | load_apt (struct LEVEL *lvl, char *fname) |
Loads the APT file fname, fills LEVEL apt entries. | |
short | load_inf (struct LEVEL *lvl, char *fname) |
Reads the INF file into LEVEL structure. | |
short | load_vsn (struct LEVEL *lvl, char *fname) |
Reads the VSN file into LEVEL structure. | |
short | load_wib (struct LEVEL *lvl, char *fname) |
Reads the WIB file into LEVEL structure. | |
short | load_slb (struct LEVEL *lvl, char *fname) |
Reads the SLB file into LEVEL structure. | |
short | load_own (struct LEVEL *lvl, char *fname) |
Reads the OWN file into LEVEL structure. | |
short | load_dat (struct LEVEL *lvl, char *fname) |
Reads the DAT file into LEVEL structure. | |
short | load_txt (struct LEVEL *lvl, char *fname) |
Reads the TXT script file into LEVEL structure. | |
short | load_lgt (struct LEVEL *lvl, char *fname) |
Loads the LGT file fname, fills LEVEL light entries. | |
short | load_wlb (struct LEVEL *lvl, char *fname) |
Reads the WLB file into LEVEL structure. | |
short | load_flg (struct LEVEL *lvl, char *fname) |
Loads the FLG file. | |
short | load_lif (struct LEVEL *lvl, char *fname) |
Loads the LIF file. | |
short | script_load_and_execute (struct LEVEL *lvl, struct MEMORY_FILE *mem, char *err_msg) |
Loads ADiKtEd script (.ADI file) from MEMORY_FILE executes all commands. | |
short | script_load_and_execute_file (struct LEVEL *lvl, char *fname, char *err_msg) |
Loads ADiKtEd script (.ADI file) and executes all commands. | |
short | load_text_file (char ***lines, int *lines_count, char *fname) |
Loads any text file as lines. | |
short | write_slb (struct LEVEL *lvl, char *fname) |
Writes the SLB file from LEVEL structure into disk. | |
short | write_own (struct LEVEL *lvl, char *fname) |
Writes the OWN file from LEVEL structure into disk. | |
short | write_dat (struct LEVEL *lvl, char *fname) |
Writes the DAT file from LEVEL structure into disk. | |
short | write_flg (struct LEVEL *lvl, char *fname) |
Writes the FLG file from LEVEL structure into disk. | |
short | write_clm (struct LEVEL *lvl, char *fname) |
Writes the CLM file from LEVEL structure into disk. | |
short | write_wib (struct LEVEL *lvl, char *fname) |
Writes the WIB file from LEVEL structure into disk. | |
short | write_apt (struct LEVEL *lvl, char *fname) |
Writes the APT file from LEVEL structure into disk. | |
short | write_tng (struct LEVEL *lvl, char *fname) |
Writes the TNG file from LEVEL structure into disk. | |
short | write_inf (struct LEVEL *lvl, char *fname) |
Writes the INF file from LEVEL structure into disk. | |
short | write_vsn (struct LEVEL *lvl, char *fname) |
Writes the VSN file from LEVEL structure into disk. | |
short | write_txt (struct LEVEL *lvl, char *fname) |
Writes the TXT script file from LEVEL structure into disk. | |
short | write_lgt (struct LEVEL *lvl, char *fname) |
Writes the LGT file from LEVEL structure into disk. | |
short | write_wlb (struct LEVEL *lvl, char *fname) |
Writes the WLB file from LEVEL structure into disk. | |
short | write_lif (struct LEVEL *lvl, char *fname) |
Writes the LIF file from LEVEL structure into disk. | |
short | write_adi_script (struct LEVEL *lvl, char *fname) |
Writes the ADI script file from LEVEL structure into disk. | |
short | write_nfo (struct LEVEL *lvl, char *fname) |
Writes the NFO level information file into disk. | |
short | write_text_file (char **lines, int lines_count, char *fname) |
Saves any text file. | |
short | save_mapfile (struct LEVEL *lvl, char *mfname, char *fext, mapfile_io_func write_file, int *saved_files, short *result) |
Saves any map file, showing error/warning message if it is required. | |
short | save_dk1_map (struct LEVEL *lvl) |
Saves the whole map. | |
short | save_nfo_file (struct LEVEL *lvl) |
short | save_dke_map (struct LEVEL *lvl) |
Saves the whole DK Extended map. | |
short | user_save_map (struct LEVEL *lvl, short prior_save) |
Saves the whole map. | |
short | load_mapfile (struct LEVEL *lvl, char *fext, mapfile_io_func load_file, int *loaded_files, short *result, short flags) |
Loads any map file, showing error/warning message if it is required. | |
short | load_mapfile_msg (struct LEVEL *lvl, char *fext, mapfile_iomsg_func load_file, int *loaded_files, short *result, short flags) |
Loads map file which loading function uses additional error message parameter. | |
short | load_dk1_map (struct LEVEL *lvl) |
Loads the whole map. | |
short | load_dke_map (struct LEVEL *lvl) |
Loads the whole map. | |
short | user_load_map (struct LEVEL *lvl, short new_on_error) |
Loads the whole map. | |
short | load_map_preview (struct LEVEL *lvl) |
Loads the map preview. | |
short | write_def_clm_source (struct LEVEL *lvl, char *fname) |
Utility function for reverse engineering the CLM format. | |
short | write_def_tng_source (struct LEVEL *lvl, char *fname) |
Utility function for reverse engineering the TNG format. |
typedef short(* mapfile_io_func)(struct LEVEL *lvl, char *fname) |
typedef short(* mapfile_iomsg_func)(struct LEVEL *lvl, struct MEMORY_FILE *mem, char *err_msg) |
Level file load/write function with error message parameter.
Definition at line 42 of file lev_files.c.
char* levfile_error | ( | int | errcode | ) |
Returns load error message for specified error code.
errcode | The integer error code. |
Definition at line 49 of file lev_files.c.
Referenced by load_mapfile(), save_mapfile(), and script_load_and_execute().
short load_apt | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Loads the APT file fname, fills LEVEL apt entries.
This _must_ be called _after_ tng_* are set up.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 261 of file lev_files.c.
Referenced by load_dk1_map().
short load_clm | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the CLM file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 225 of file lev_files.c.
Referenced by load_dk1_map().
short load_dat | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the DAT file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 482 of file lev_files.c.
Referenced by load_dk1_map().
short load_dk1_map | ( | struct LEVEL * | lvl | ) |
Loads the whole map.
Tries to open all files editable in ADiKtEd. Accepts failure for less importand files. Makes no stats update. If you want a complete loading function, use user_load_map() instead.
lvl | Pointer to the LEVEL structure. |
Definition at line 1857 of file lev_files.c.
Referenced by user_load_map().
short load_dke_map | ( | struct LEVEL * | lvl | ) |
Loads the whole map.
Tries to open all files editable in ADiKtEd. Accepts failure for less importand files. Makes no stats update. If you want a complete loading function, use user_load_map() instead. DK Extended map files won't work in standard Dungeon Keeper on DD.
lvl | Pointer to the LEVEL structure. |
Definition at line 1930 of file lev_files.c.
Referenced by user_load_map().
short load_flg | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Loads the FLG file.
These seems to have small priority, but DK loads it when starting a level.
lvl | Pointer to the LEVEL structure. | |
fname | File name to load from. |
Definition at line 685 of file lev_files.c.
Referenced by load_dk1_map().
short load_inf | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the INF file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 315 of file lev_files.c.
Referenced by load_dk1_map().
short load_lgt | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Loads the LGT file fname, fills LEVEL light entries.
This _must_ be called _after_ tng_* are set up.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 596 of file lev_files.c.
Referenced by load_dk1_map().
short load_lif | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Loads the LIF file.
LIFs contain text name of the level (and level number, which is ignored).
lvl | Pointer to the LEVEL structure. | |
fname | File name to load from. |
Definition at line 720 of file lev_files.c.
Referenced by load_dk1_map().
short load_map_preview | ( | struct LEVEL * | lvl | ) |
Loads the map preview.
Tries to open only files needed for Slab mode preview. If you want a complete loading function, use user_load_map() instead.
lvl | Pointer to the LEVEL structure. |
Definition at line 2039 of file lev_files.c.
short load_mapfile | ( | struct LEVEL * | lvl, | |
char * | fext, | |||
mapfile_io_func | load_file, | |||
int * | loaded_files, | |||
short * | result, | |||
short | flags | |||
) |
Loads any map file, showing error/warning message if it is required.
lvl | Pointer to the LEVEL structure. | |
fext | Extension of destination file name. | |
load_file | The loading function. | |
loaded_files | Saved files counter. Incremented if load is successful. | |
result | Result value. Set to error code if error occures, otherwise left unchanged. | |
flags | Load flags. Allows to ignore some errors. |
Definition at line 1682 of file lev_files.c.
Referenced by load_dk1_map(), load_dke_map(), and load_map_preview().
short load_mapfile_msg | ( | struct LEVEL * | lvl, | |
char * | fext, | |||
mapfile_iomsg_func | load_file, | |||
int * | loaded_files, | |||
short * | result, | |||
short | flags | |||
) |
Loads map file which loading function uses additional error message parameter.
Shows error/warning message if it is required.
lvl | Pointer to the LEVEL structure. | |
fext | Extension of destination file name. | |
load_file | The loading function. | |
loaded_files | Saved files counter. Incremented if load is successful. | |
result | Result value. Set to error code if error occures, otherwise left unchanged. | |
flags | Load flags. Allows to ignore some errors. |
Definition at line 1753 of file lev_files.c.
Referenced by load_dk1_map(), and load_dke_map().
short load_own | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the OWN file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 447 of file lev_files.c.
Referenced by load_dk1_map(), and load_map_preview().
short load_slb | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the SLB file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 399 of file lev_files.c.
Referenced by load_dk1_map(), and load_map_preview().
short load_text_file | ( | char *** | lines, | |
int * | lines_count, | |||
char * | fname | |||
) |
Loads any text file as lines.
If input structure is not empty, appends the loaded data at end of it.
lines | Pointer to the text lines array. | |
lines_count | Amount of lines in the array. | |
fname | Source file name. |
Definition at line 850 of file lev_files.c.
Referenced by load_lif().
short load_tng | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the TNG file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 173 of file lev_files.c.
Referenced by load_dk1_map().
short load_txt | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the TXT script file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 519 of file lev_files.c.
Referenced by load_dk1_map().
short load_vsn | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the VSN file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 337 of file lev_files.c.
Referenced by load_dk1_map(), and load_dke_map().
short load_wib | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the WIB file into LEVEL structure.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 364 of file lev_files.c.
Referenced by load_dk1_map().
short load_wlb | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Reads the WLB file into LEVEL structure.
WLB seems to be unused by the game, but are always written by BF editor. DK loads this file when starting a level.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. |
Definition at line 655 of file lev_files.c.
Referenced by load_dk1_map().
short save_dk1_map | ( | struct LEVEL * | lvl | ) |
Saves the whole map.
Includes all files editable in ADiKtEd. On failure, tries to save at least some of the files. Does not perform an update before saving - to do this, use user_save_map() instead.
lvl | Pointer to the LEVEL structure. |
Definition at line 1498 of file lev_files.c.
Referenced by user_save_map().
short save_dke_map | ( | struct LEVEL * | lvl | ) |
Saves the whole DK Extended map.
Includes all files editable in ADiKtEd. On failure, tries to save at least some of the files. DK Extended map files won't load in standard Dungeon Keeper on DD. Does not perform an update before saving - to do this, use user_save_map() instead.
lvl | Pointer to the LEVEL structure. |
Definition at line 1565 of file lev_files.c.
Referenced by user_save_map().
short save_mapfile | ( | struct LEVEL * | lvl, | |
char * | mfname, | |||
char * | fext, | |||
mapfile_io_func | write_file, | |||
int * | saved_files, | |||
short * | result | |||
) |
Saves any map file, showing error/warning message if it is required.
lvl | Pointer to the LEVEL structure. | |
fext | Extension of destination file name. | |
write_file | The writing function. | |
saved_files | Saved files counter. Incremented if save is successful. | |
result | Result value. Set to error code if error occures, otherwise left unchanged. |
Definition at line 1452 of file lev_files.c.
Referenced by save_dk1_map(), save_dke_map(), and save_nfo_file().
short save_nfo_file | ( | struct LEVEL * | lvl | ) |
Definition at line 1546 of file lev_files.c.
short script_load_and_execute | ( | struct LEVEL * | lvl, | |
struct MEMORY_FILE * | mem, | |||
char * | err_msg | |||
) |
Loads ADiKtEd script (.ADI file) from MEMORY_FILE executes all commands.
lvl | Pointer to the LEVEL structure. | |
mem | Source file data. | |
err_msg | Error message text. |
Definition at line 763 of file lev_files.c.
Referenced by load_dk1_map(), load_dke_map(), load_mapfile_msg(), and script_load_and_execute_file().
short script_load_and_execute_file | ( | struct LEVEL * | lvl, | |
char * | fname, | |||
char * | err_msg | |||
) |
Loads ADiKtEd script (.ADI file) and executes all commands.
lvl | Pointer to the LEVEL structure. | |
fname | Source file name. | |
err_msg | Error message text. |
Definition at line 825 of file lev_files.c.
short user_load_map | ( | struct LEVEL * | lvl, | |
short | new_on_error | |||
) |
Loads the whole map.
Tries to open all files editable in Adikted. Accepts failure for less importand files.
lvl | Pointer to the LEVEL structure. | |
new_on_error | If nonzero, the function will automatically start new map on load error. |
Definition at line 2005 of file lev_files.c.
short user_save_map | ( | struct LEVEL * | lvl, | |
short | prior_save | |||
) |
Saves the whole map.
Includes all files editable in ADiKtEd. On failure, tries to save at least some of the files. Makes updates required for saving before it starts. Also, fails if the map verification will return serious error. Should be used instead of save_dk1_map(), as it prepares the map before the saving operation is performed.
lvl | Pointer to the LEVEL structure. | |
prior_save | Informs how to increase level version before saving. Prior saves get greater version increase than minor saves. |
Definition at line 1631 of file lev_files.c.
short write_adi_script | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the ADI script file from LEVEL structure into disk.
Creates the file data first it - is not stored directly in LEVEL.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1291 of file lev_files.c.
Referenced by save_dk1_map(), and save_dke_map().
short write_apt | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the APT file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1072 of file lev_files.c.
Referenced by save_dk1_map().
short write_clm | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the CLM file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1026 of file lev_files.c.
Referenced by save_dk1_map().
short write_dat | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the DAT file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 970 of file lev_files.c.
Referenced by save_dk1_map().
short write_def_clm_source | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Utility function for reverse engineering the CLM format.
Used in rework mode.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 2073 of file lev_files.c.
short write_def_tng_source | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Utility function for reverse engineering the TNG format.
Used in rework mode.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 2160 of file lev_files.c.
short write_flg | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the FLG file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 998 of file lev_files.c.
Referenced by save_dk1_map().
short write_inf | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the INF file from LEVEL structure into disk.
One byte file - the easy one.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1137 of file lev_files.c.
Referenced by save_dk1_map().
short write_lgt | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the LGT file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1203 of file lev_files.c.
Referenced by save_dk1_map().
short write_lif | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the LIF file from LEVEL structure into disk.
LIFs are used to save text name of the level.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1263 of file lev_files.c.
Referenced by save_dk1_map().
short write_nfo | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the NFO level information file into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1312 of file lev_files.c.
Referenced by save_nfo_file().
short write_own | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the OWN file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 943 of file lev_files.c.
Referenced by save_dk1_map().
short write_slb | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the SLB file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 918 of file lev_files.c.
Referenced by save_dk1_map().
short write_text_file | ( | char ** | lines, | |
int | lines_count, | |||
char * | fname | |||
) |
Saves any text file.
lines | Pointer to the lines array. | |
lines_count | Lines count. | |
fname | Destination file name. |
Definition at line 1420 of file lev_files.c.
Referenced by write_adi_script(), write_lif(), write_nfo(), and write_txt().
short write_tng | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the TNG file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1107 of file lev_files.c.
Referenced by save_dk1_map().
short write_txt | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the TXT script file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1191 of file lev_files.c.
Referenced by save_dk1_map().
short write_vsn | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the VSN file from LEVEL structure into disk.
One byte file - the easy one.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1157 of file lev_files.c.
Referenced by save_dk1_map(), and save_dke_map().
short write_wib | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the WIB file from LEVEL structure into disk.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1048 of file lev_files.c.
Referenced by save_dk1_map().
short write_wlb | ( | struct LEVEL * | lvl, | |
char * | fname | |||
) |
Writes the WLB file from LEVEL structure into disk.
Water-Lava Block files are used to define what is under a bridge.
lvl | Pointer to the LEVEL structure. | |
fname | Destination file name. |
Definition at line 1239 of file lev_files.c.
Referenced by save_dk1_map().