lev_files.h File Reference


Detailed Description

Functions for loading and writing levels from/to disk.

Purpose:
Header file. Defines exported routines from lev_files.c.
Comment:
None.
Author:
Jon Skeet, Tomasz Lis
Date:
14 Oct 1997 - 27 Jul 2008
Copying and copyrights:
This program 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 2 of the License, or (at your option) any later version.

Definition in file lev_files.h.

#include "globals.h"

Go to the source code of this file.

Defines

#define ERR_NONE   0
#define ERR_FILE_TOOSMLL   -24
#define ERR_FILE_BADDATA   -25
#define ERR_FILE_BADNAME   -26
#define ERR_CANT_MALLOC   -27
#define ERR_CANT_OPENWR   -28
#define ERR_CANT_WRITE   -29
#define ERR_VERIF   -30
#define ERR_INTERNAL   -31
#define WARN_BAD_COUNT   24
#define LFF_IGNORE_NONE   (0)
#define LFF_IGNORE_ALL   (LFF_IGNORE_INTERNAL|LFF_IGNORE_CANNOT_LOAD)
#define LFF_IGNORE_WITHOUT_WARN   (LFF_IGNORE_INTERNAL|LFF_IGNORE_CANNOT_LOAD|LFF_DONT_EVEN_WARN)

Enumerations

enum  EXTRA_OBJ_LOAD {
  RNC_IGNORE_NONE = 0x0000, RNC_IGNORE_FILE_IS_NOT_RNC = 0x0001, RNC_IGNORE_HUF_DECODE_ERROR = 0x0002, RNC_IGNORE_FILE_SIZE_MISMATCH = 0x0004,
  RNC_IGNORE_PACKED_CRC_ERROR = 0x0008, RNC_IGNORE_UNPACKED_CRC_ERROR = 0x0010, RNC_IGNORE_HEADER_VAL_ERROR = 0x0020, RNC_IGNORE_HUF_EXCEEDS_RANGE = 0x0040,
  EXLD_THING = 0x01, EXLD_ACTNPT = 0x02, EXLD_STLGHT = 0x04
}
 Flags to load extra objects when reading map. More...
enum  LEVEL_FILE_FLAGS { LFF_IGNORE_INTERNAL = 0x0001, LFF_IGNORE_CANNOT_LOAD = 0x0002, LFF_DONT_EVEN_WARN = 0x0004 }
 Flags to ignore errors when loading/saving. More...

Functions

DLLIMPORT short save_dk1_map (struct LEVEL *lvl)
 Saves the whole map.
DLLIMPORT short save_dke_map (struct LEVEL *lvl)
 Saves the whole DK Extended map.
DLLIMPORT short user_save_map (struct LEVEL *lvl, short prior_save)
 Saves the whole map.
DLLIMPORT short load_dk1_map (struct LEVEL *lvl)
 Loads the whole map.
DLLIMPORT short load_dke_map (struct LEVEL *lvl)
 Loads the whole map.
DLLIMPORT short load_map_preview (struct LEVEL *lvl)
 Loads the map preview.
DLLIMPORT short user_load_map (struct LEVEL *lvl, short new_on_error)
 Loads the whole map.
DLLIMPORT 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.
DLLIMPORT short script_load_and_execute_file (struct LEVEL *lvl, char *fname, char *err_msg)
 Loads ADiKtEd script (.ADI file) and executes all commands.
DLLIMPORT short save_nfo_file (struct LEVEL *lvl)
DLLIMPORT short load_text_file (char ***lines, int *lines_count, char *fname)
 Loads any text file as lines.
DLLIMPORT short write_text_file (char **lines, int lines_count, char *fname)
 Saves any text file.
DLLIMPORT short write_def_clm_source (struct LEVEL *lvl, char *fname)
 Utility function for reverse engineering the CLM format.
DLLIMPORT short write_def_tng_source (struct LEVEL *lvl, char *fname)
 Utility function for reverse engineering the TNG format.
DLLIMPORT char * levfile_error (int errcode)
 Returns load error message for specified error code.


Define Documentation

#define ERR_CANT_MALLOC   -27

Definition at line 33 of file lev_files.h.

Referenced by load_apt(), load_lgt(), load_mapfile(), load_mapfile_msg(), and save_mapfile().

#define ERR_CANT_OPENWR   -28

#define ERR_CANT_WRITE   -29

Definition at line 35 of file lev_files.h.

#define ERR_FILE_BADDATA   -25

#define ERR_FILE_BADNAME   -26

Definition at line 32 of file lev_files.h.

Referenced by load_dk1_map(), load_dke_map(), and load_map_preview().

#define ERR_FILE_TOOSMLL   -24

#define ERR_INTERNAL   -31

#define ERR_NONE   0

Definition at line 29 of file lev_files.h.

#define ERR_VERIF   -30

Definition at line 36 of file lev_files.h.

Referenced by user_save_map().

#define LFF_IGNORE_ALL   (LFF_IGNORE_INTERNAL|LFF_IGNORE_CANNOT_LOAD)

Definition at line 59 of file lev_files.h.

Referenced by load_dk1_map(), and load_map_preview().

#define LFF_IGNORE_NONE   (0)

Definition at line 58 of file lev_files.h.

Referenced by load_dk1_map().

#define LFF_IGNORE_WITHOUT_WARN   (LFF_IGNORE_INTERNAL|LFF_IGNORE_CANNOT_LOAD|LFF_DONT_EVEN_WARN)

Definition at line 60 of file lev_files.h.

Referenced by load_dk1_map(), and load_dke_map().

#define WARN_BAD_COUNT   24

Definition at line 38 of file lev_files.h.

Referenced by levfile_error(), load_apt(), load_lgt(), and load_tng().


Enumeration Type Documentation

Flags to load extra objects when reading map.

Enumerator:
RNC_IGNORE_NONE 
RNC_IGNORE_FILE_IS_NOT_RNC 
RNC_IGNORE_HUF_DECODE_ERROR 
RNC_IGNORE_FILE_SIZE_MISMATCH 
RNC_IGNORE_PACKED_CRC_ERROR 
RNC_IGNORE_UNPACKED_CRC_ERROR 
RNC_IGNORE_HEADER_VAL_ERROR 
RNC_IGNORE_HUF_EXCEEDS_RANGE 
EXLD_THING 
EXLD_ACTNPT 
EXLD_STLGHT 

Definition at line 43 of file lev_files.h.

Flags to ignore errors when loading/saving.

Enumerator:
LFF_IGNORE_INTERNAL 
LFF_IGNORE_CANNOT_LOAD 
LFF_DONT_EVEN_WARN 

Definition at line 52 of file lev_files.h.


Function Documentation

DLLIMPORT char* levfile_error ( int  errcode  ) 

Returns load error message for specified error code.

Parameters:
errcode The integer error code.
Returns:
Returns load error message text.

Definition at line 49 of file lev_files.c.

Referenced by load_mapfile(), save_mapfile(), and script_load_and_execute().

DLLIMPORT 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.

See also:
user_load_map
Parameters:
lvl Pointer to the LEVEL structure.
Returns:
Returns ERR_NONE on success, negative error code on error.

Definition at line 1857 of file lev_files.c.

Referenced by user_load_map().

DLLIMPORT 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.

See also:
user_load_map
Parameters:
lvl Pointer to the LEVEL structure.
Returns:
Returns ERR_NONE on success, negative error code on error.

Definition at line 1930 of file lev_files.c.

Referenced by user_load_map().

DLLIMPORT 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.

See also:
user_load_map
Parameters:
lvl Pointer to the LEVEL structure.
Returns:
Returns ERR_NONE on success, or error code on failure. If an error occures, the LEVEL may contain partially loaded data.

Definition at line 2039 of file lev_files.c.

DLLIMPORT 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.

Parameters:
lines Pointer to the text lines array.
lines_count Amount of lines in the array.
fname Source file name.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 850 of file lev_files.c.

Referenced by load_lif().

DLLIMPORT 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.

See also:
user_save_map
Parameters:
lvl Pointer to the LEVEL structure.
Returns:
Returns ERR_NONE on success, last error code on failure.

Definition at line 1498 of file lev_files.c.

Referenced by user_save_map().

DLLIMPORT 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.

See also:
user_save_map

save_dk1_map

Parameters:
lvl Pointer to the LEVEL structure.
Returns:
Returns ERR_NONE on success, last error code on failure.

Definition at line 1565 of file lev_files.c.

Referenced by user_save_map().

DLLIMPORT short save_nfo_file ( struct LEVEL lvl  ) 

Definition at line 1546 of file lev_files.c.

DLLIMPORT 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.

Parameters:
lvl Pointer to the LEVEL structure.
mem Source file data.
err_msg Error message text.
Returns:
Returns ERR_NONE on success, error code on failure.

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().

DLLIMPORT short script_load_and_execute_file ( struct LEVEL lvl,
char *  fname,
char *  err_msg 
)

Loads ADiKtEd script (.ADI file) and executes all commands.

Parameters:
lvl Pointer to the LEVEL structure.
fname Source file name.
err_msg Error message text.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 825 of file lev_files.c.

DLLIMPORT 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.

Parameters:
lvl Pointer to the LEVEL structure.
new_on_error If nonzero, the function will automatically start new map on load error.
Returns:
Returns ERR_NONE on success, on error starts new map and returns negative error code.

Definition at line 2005 of file lev_files.c.

DLLIMPORT 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.

See also:
save_dk1_map
Parameters:
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.
Returns:
Returns ERR_NONE on success, last error code on failure.

Definition at line 1631 of file lev_files.c.

DLLIMPORT short write_def_clm_source ( struct LEVEL lvl,
char *  fname 
)

Utility function for reverse engineering the CLM format.

Used in rework mode.

Parameters:
lvl Pointer to the LEVEL structure.
fname Destination file name.
Returns:
Returns true on success, false otherwise.

Definition at line 2073 of file lev_files.c.

DLLIMPORT short write_def_tng_source ( struct LEVEL lvl,
char *  fname 
)

Utility function for reverse engineering the TNG format.

Used in rework mode.

Parameters:
lvl Pointer to the LEVEL structure.
fname Destination file name.
Returns:
Returns true on success, false otherwise.

Definition at line 2160 of file lev_files.c.

DLLIMPORT short write_text_file ( char **  lines,
int  lines_count,
char *  fname 
)

Saves any text file.

Parameters:
lines Pointer to the lines array.
lines_count Lines count.
fname Destination file name.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 1420 of file lev_files.c.

Referenced by write_adi_script(), write_lif(), write_nfo(), and write_txt().


Generated on Tue Sep 2 18:51:49 2008 for libAdikted by  doxygen 1.5.6