summaryrefslogtreecommitdiff
path: root/wad.h
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2011-06-09 13:57:32 +0000
committerIan C <ianc@noddybox.co.uk>2011-06-09 13:57:32 +0000
commit0f12083fdb14ae813e419500918b95cb83070586 (patch)
tree93f855836faede895a4c37d12dcc46a8c5fbb835 /wad.h
Added copies of old numbered releases.0.01
Diffstat (limited to 'wad.h')
-rw-r--r--wad.h242
1 files changed, 242 insertions, 0 deletions
diff --git a/wad.h b/wad.h
new file mode 100644
index 0000000..7d9a9f5
--- /dev/null
+++ b/wad.h
@@ -0,0 +1,242 @@
+/*
+
+ 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 _WAD_H
+
+#define _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)
+
+typedef struct Thing
+ {
+ Short x;
+ Short y;
+ Short ang;
+ Short type;
+ Short opt;
+ } 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)
+
+typedef struct
+ {
+ Short from;
+ Short to;
+ Short flags;
+ Short type;
+ Short tag;
+ Short right;
+ Short left;
+ } 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
+ {
+ Map thing;
+ Map vertex;
+ Map linedef;
+ Map sidedef;
+ Map sector;
+ } 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_BROKEN 8 /* Must be last error code */
+
+#define WAD_NOERROR (WAD_BROKEN+1)
+
+
+/* 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);
+
+
+/* Load a MAPxx or ExMy map from the open wads. Returns NULL on error.
+*/
+WadMap *LoadMap(char *name);
+
+
+/* Create a new empty map
+*/
+WadMap *NewMap(void);
+
+
+/* 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);
+
+
+#endif
+
+/* END OF FILE */