diff options
author | Ian C <ianc@noddybox.co.uk> | 2011-06-09 13:46:28 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2011-06-09 13:46:28 +0000 |
commit | a9022b5972dc49d86f617a27940fafe9c4d0e7e7 (patch) | |
tree | 61405aa4ade91ed1057f863ddf118ceb38e14f8e /wad.h |
Initial import of (very old) vidoom sources.
Diffstat (limited to 'wad.h')
-rw-r--r-- | wad.h | 294 |
1 files changed, 294 insertions, 0 deletions
@@ -0,0 +1,294 @@ +/* + + viDOOM - level editor for DOOM + + Copyright (C) 2000 Ian Cowburn (ianc@noddybox.demon.co.uk) + + 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. + + 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, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------- + + WAD file definitions and readers + + These things should be noted about the handling of mutiple entries + from different wad files: + + - Entries in later WADs overwrite earlier loaded WADs. + + - New entries for MAPxy and ExMy automatically overwrite the + following entries from the previous map: + THINGS + LINEDEFS + SIDEDEFS + VERTEXES + SEGS + SSECTORS + NODES + SECTORS + REJECT + BLOCKMAP + + If these entries don't appear in the new map they are + replaced by dummy entries of zero length. + + $Id$ + +*/ + +#ifndef VIDOOM_WAD_H + +#define VIDOOM_WAD_H + +#include "map.h" +#include "list.h" + +/* Basic WAD types +*/ +#define DIRNAME_LEN 8 +typedef char DirName[DIRNAME_LEN+1]; + +/* Directory types +*/ +typedef struct WadDir + { + char *wad; /* WAD the entry is from */ + DirName name; /* Lump name */ + Long off; /* Lump offset */ + Long size; /* Lump size */ + } WadDir; + + +/* Base level types and their sizes in the WAD +*/ +#define THING_SIZE (sizeof(Short)*5) +#define THING_SIZE_HEXEN (sizeof(Short)*6+sizeof(UShort)+6) + +/* Note that the fields are NOT in the order they appear in the WAD +*/ +typedef struct Thing + { + Short x; + Short y; + Short ang; + Short type; + Short flags; + + /* Extra fields for HEXEN things + */ + UShort id; + Byte special; + Short z; + Short args[5]; + } Thing; + +#define VERTEX_SIZE (sizeof(Short)*2) + +typedef struct Vertex + { + Short x; + Short y; + } Vertex; + +#define SIDEDEF_SIZE (sizeof(Short)*3+DIRNAME_LEN*3) + +typedef struct Sidedef + { + Short x; + Short y; + DirName upper; + DirName lower; + DirName middle; + Short sector; + } Sidedef; + +#define LINEDEF_SIZE (sizeof(Short)*7) +#define LINEDEF_SIZE_HEXEN (sizeof(Short)*5+6) + +/* Note that the fields are NOT in the order they appear in the WAD +*/ +typedef struct + { + Short from; + Short to; + Short flags; + Short type; /* In HEXEN mode this is a Byte */ + Short tag; + Short right; + Short left; + + /* Extra fields for HEXEN linedefs + */ + Byte args[5]; + } Linedef; + +#define SECTOR_SIZE (sizeof(Short)*5+DIRNAME_LEN*2) + +typedef struct Sector + { + Short floor; + Short ceiling; + DirName floor_t; + DirName ceiling_t; + Short light; + Short special; + Short tag; + } Sector; + +typedef struct WadMap + { + int hexen; /* TRUE if map in HEXEN/extended format */ + + Map thing; + Map vertex; + Map linedef; + Map sidedef; + Map sector; + + /* ZDOOM/HEXEN lumps and info + */ + int behavior_size; + char *behavior; + int scripts_size; + char *scripts; + char *mapinfo; + } WadMap; + + +/* Error codes +*/ +#define WAD_OK 0 +#define WAD_FILE_NOT_FOUND 1 +#define WAD_NOT_WAD 2 +#define WAD_NOT_IWAD 3 +#define WAD_NOT_PWAD 4 +#define WAD_MAP_NOT_FOUND 5 +#define WAD_LUMP_NOT_FOUND 6 +#define WAD_COULD_NOT_CREATE 7 +#define WAD_MAPINFO_FAILED 8 +#define WAD_MAP_MANGLED 9 +#define WAD_BROKEN 10 /* Must be last error code */ + +#define WAD_NOERROR (WAD_BROKEN+1) + + +/* Returns for WAD file type +*/ +#define FILE_IS_NOT_WAD 0 +#define FILE_IS_IWAD 1 +#define FILE_IS_PWAD 2 + + +/* Add the named IWAD to the list of open WADs. Returns non-zero on error. +*/ +int AddIWAD(char *wad); + + +/* Add the named PWAD to the list of open WADs. Returns non-zero on error. + AddPWAD() and AddIWAD() are by and large identical - they just include + different checking so that the initial loading of IWAD will not allow it + be a PWAD, and also do shareware checking. +*/ +int AddPWAD(char *wad); + + +/* Close a wad from the open list. Removes entries for this wad fom the + global directory, replacing entries from prevous WADs (if any). + + Returns non-zero on error. +*/ +int CloseWad(char *wad); + + +/* Returns a list of open WADS as a string like "<wad>|<wad>|..". The return + must be Release()ed after use. +*/ +char *OpenWads(void); + + +/* If you wish access to the directory of all the open wads, this allows + them to retrieved as a List of WadDir. Returns NULL if none. + + Note the directory is organised with the last loaded WAD files first. + This is the quickest (though hungriest) method for ensuring that later + WAD resources override earlier ones. +*/ +Iterator GetWadDir(void); + +/* No of entries in WadDir list +*/ +int GetWadDirSize(void); + + +/* Retrieves the named lump from the WADs. Return is a pointer to size + bytes. If size is NULL it is not set. + + The pointer must be Release()'ed by the user afterwards. + + NULL indicates the lump could not be found. +*/ +void *GetLump(char *name, Long *size); + + +/* Retrieves the lump pointed to by the WAD directory entry. + Return is a pointer to size bytes. If size is NULL it is not set. + + The pointer must be Release()'ed by the user afterwards. + + NULL indicates the WAD dir entry was invalid. +*/ +void *GetLumpFrom(WadDir *ent, Long *size); + + +/* Load a MAPxx or ExMy map from the open wads. Returns NULL on error. +*/ +WadMap *LoadMap(char *name); + + +/* Create a new empty map. Creates a HEXEN map if hexen is TRUE. +*/ +WadMap *NewMap(int hexen); + + +/* Release the memory for a WadMap +*/ +WadMap *ClearMap(WadMap *map); + + +/* Save the passed WadMap as a MAPxx or ExMy PWAD. Note that this PWAD is + overwritten and the map is the sole object written to the PWAD. Returns + non-zero on error. +*/ +int SaveMap(WadMap *map, char *name, char *wad); + + +/* Return the current error code +*/ +int WadError(void); + + +/* Return a string for the error code +*/ +const char *WadErrorString(void); + + +/* Given a filename returns the type of WAD file it is. + Returns FILE_IS_NOT_WAD if file is not a WAD file, or doesn't exist. +*/ +int WadFileType(char *wad); + + +#endif + +/* END OF FILE */ |