diff --git a/modules/export_map.lua b/modules/export_map.lua index 1107b1fd8..476917364 100644 --- a/modules/export_map.lua +++ b/modules/export_map.lua @@ -228,9 +228,6 @@ function EXPORT_MAP.begin_level(self, LEVEL) fprintf(file, "{\n") fprintf(file, "\"classname\" \"worldspawn\"\n") fprintf(file, "\"worldtype\" \"0\"\n") -- FIXME - fprintf(file, "\"wad\" \"quake_tex.wad\"\n") - - -- TODO: "message" : LEVEL.description end diff --git a/source_files/obsidian_main/lib_wad.cc b/source_files/obsidian_main/lib_wad.cc index 5fe69894c..636aea475 100644 --- a/source_files/obsidian_main/lib_wad.cc +++ b/source_files/obsidian_main/lib_wad.cc @@ -345,338 +345,5 @@ void WAD_FinishLump(void) { wad_W_directory.push_back(wad_W_lump); } -//------------------------------------------------------------------------ -// WAD2 READING -//------------------------------------------------------------------------ - -#ifdef HAVE_PHYSFS -static PHYSFS_File *wad2_R_fp; -#else -static FILE *wad2_R_fp; -#endif - -static raw_wad2_header_t wad2_R_header; -static raw_wad2_lump_t *wad2_R_dir; - -bool WAD2_OpenRead(const char *filename) { -#ifdef HAVE_PHYSFS - wad2_R_fp = PHYSFS_openRead(filename); -#else - wad2_R_fp = fopen(filename, "rb"); -#endif - - if (!wad2_R_fp) { - LogPrintf("WAD2_OpenRead: no such file: %s\n", filename); - return false; - } - - LogPrintf("Opened WAD2 file: %s\n", filename); - -#ifdef HAVE_PHYSFS - if ((PHYSFS_readBytes(wad2_R_fp, &wad2_R_header, sizeof(wad2_R_header)) / - sizeof(wad2_R_header)) != 1) -#else - if (fread(&wad2_R_header, sizeof(wad2_R_header), 1, wad2_R_fp) != 1) -#endif - { - LogPrintf("WAD2_OpenRead: failed reading header\n"); -#ifdef HAVE_PHYSFS - PHYSFS_close(wad2_R_fp); -#else - fclose(wad2_R_fp); -#endif - return false; - } - - if (memcmp(wad2_R_header.magic, WAD2_MAGIC, 4) != 0) { - LogPrintf("WAD2_OpenRead: not a WAD2 file!\n"); -#ifdef HAVE_PHYSFS - PHYSFS_close(wad2_R_fp); -#else - fclose(wad2_R_fp); -#endif - return false; - } - - wad2_R_header.num_lumps = LE_U32(wad2_R_header.num_lumps); - wad2_R_header.dir_start = LE_U32(wad2_R_header.dir_start); - - /* read directory */ - - if (wad2_R_header.num_lumps >= 5000) // sanity check - { - LogPrintf("WAD2_OpenRead: bad header (%u entries?)\n", - static_cast(wad2_R_header.num_lumps)); -#ifdef HAVE_PHYSFS - PHYSFS_close(wad2_R_fp); -#else - fclose(wad2_R_fp); -#endif - return false; - } - -#ifdef HAVE_PHYSFS - if (!PHYSFS_seek(wad2_R_fp, wad2_R_header.dir_start)) -#else - if (fseek(wad2_R_fp, wad2_R_header.dir_start, SEEK_SET) != 0) -#endif - { - LogPrintf("WAD2_OpenRead: cannot seek to directory (at 0x&u)\n", - static_cast(wad2_R_header.dir_start)); -#ifdef HAVE_PHYSFS - PHYSFS_close(wad2_R_fp); -#else - fclose(wad2_R_fp); -#endif - return false; - } - - wad2_R_dir = new raw_wad2_lump_t[wad2_R_header.num_lumps + 1]; - - for (int i = 0; i < (int)wad2_R_header.num_lumps; i++) { - raw_wad2_lump_t *L = &wad2_R_dir[i]; - -#ifdef HAVE_PHYSFS - size_t res = (PHYSFS_readBytes(wad2_R_fp, L, sizeof(raw_wad2_lump_t)) / - sizeof(raw_wad2_lump_t)); - if (res != 1) -#else - int res = fread(L, sizeof(raw_wad2_lump_t), 1, wad2_R_fp); - if (res == EOF || res != 1 || ferror(wad2_R_fp)) -#endif - { - if (i == 0) { - LogPrintf("WAD2_OpenRead: could not read any dir-entries!\n"); - WAD2_CloseRead(); - return false; - } - - LogPrintf("WAD2_OpenRead: hit EOF reading dir-entry %d\n", i); - - // truncate directory - wad2_R_header.num_lumps = i; - break; - } - - // make sure name is NUL terminated. - L->name[15] = 0; - - L->start = LE_U32(L->start); - L->length = LE_U32(L->length); - L->u_len = LE_U32(L->u_len); - } - - return true; // OK -} - -void WAD2_CloseRead(void) { -#ifdef HAVE_PHYSFS - PHYSFS_close(wad2_R_fp); -#else - fclose(wad2_R_fp); -#endif - - LogPrintf("Closed WAD2 file\n"); - - delete[] wad2_R_dir; - wad2_R_dir = NULL; -} - -int WAD2_NumEntries(void) { return (int)wad2_R_header.num_lumps; } - -int WAD2_FindEntry(const char *name) { - for (unsigned int i = 0; i < wad2_R_header.num_lumps; i++) { - if (StringCaseCmp(name, wad2_R_dir[i].name) == 0) { - return i; - } - } - - return -1; // not found -} - -int WAD2_EntryLen(int entry) { - SYS_ASSERT(entry >= 0 && entry < (int)wad2_R_header.num_lumps); - - return wad2_R_dir[entry].u_len; -} - -const char *WAD2_EntryName(int entry) { - SYS_ASSERT(entry >= 0 && entry < (int)wad2_R_header.num_lumps); - - return wad2_R_dir[entry].name; -} - -int WAD2_EntryType(int entry) { - SYS_ASSERT(entry >= 0 && entry < (int)wad2_R_header.num_lumps); - - if (wad2_R_dir[entry].compression != 0) { - return TYP_COMPRESSED; - } - - return wad2_R_dir[entry].type; -} - -bool WAD2_ReadData(int entry, int offset, int length, void *buffer) { - SYS_ASSERT(entry >= 0 && entry < (int)wad2_R_header.num_lumps); - SYS_ASSERT(offset >= 0); - SYS_ASSERT(length > 0); - - raw_wad2_lump_t *L = &wad2_R_dir[entry]; - - if ((uint32_t)offset + (uint32_t)length > L->length) { // EOF - return false; - } - -#ifdef HAVE_PHYSFS - if (!PHYSFS_seek(wad2_R_fp, L->start + offset)) { - return false; - } - - size_t res = (PHYSFS_readBytes(wad2_R_fp, buffer, length) / length); -#else - if (fseek(wad2_R_fp, L->start + offset, SEEK_SET) != 0) return false; - - int res = fread(buffer, length, 1, wad2_R_fp); -#endif - - return (res == 1); -} - -static char LetterForType(uint8_t type) { - switch (type) { - case TYP_NONE: - return 'x'; - case TYP_LABEL: - return 'L'; - case TYP_PALETTE: - return 'C'; - case TYP_QTEX: - return 'T'; - case TYP_QPIC: - return 'P'; - case TYP_SOUND: - return 'S'; - case TYP_MIPTEX: - return 'M'; - - default: - return '?'; - } -} - -//------------------------------------------------------------------------ -// WAD2 WRITING -//------------------------------------------------------------------------ - -static FILE *wad2_W_fp; - -static std::list wad2_W_directory; - -static raw_wad2_lump_t wad2_W_lump; - -bool WAD2_OpenWrite(const char *filename) { - wad2_W_fp = fopen(filename, "wb"); - - if (!wad2_W_fp) { - LogPrintf("WAD2_OpenWrite: cannot create file: %s\n", filename); - return false; - } - - LogPrintf("Created WAD2 file: %s\n", filename); - - // write out a dummy header - raw_wad2_header_t header; - memset(&header, 0, sizeof(header)); - - fwrite(&header, sizeof(raw_wad2_header_t), 1, wad2_W_fp); - fflush(wad2_W_fp); - - return true; -} - -void WAD2_CloseWrite(void) { - fflush(wad2_W_fp); - - // write the directory - - LogPrintf("Writing WAD2 directory\n"); - - raw_wad2_header_t header; - - memcpy(header.magic, WAD2_MAGIC, 4); - - header.dir_start = (int)ftell(wad2_W_fp); - header.num_lumps = 0; - - std::list::iterator WDI; - - for (WDI = wad2_W_directory.begin(); WDI != wad2_W_directory.end(); WDI++) { - raw_wad2_lump_t *L = &(*WDI); - - fwrite(L, sizeof(raw_wad2_lump_t), 1, wad2_W_fp); - - header.num_lumps++; - } - - fflush(wad2_W_fp); - - // finally write the _real_ WAD2 header - - header.dir_start = LE_U32(header.dir_start); - header.num_lumps = LE_U32(header.num_lumps); - - fseek(wad2_W_fp, 0, SEEK_SET); - - fwrite(&header, sizeof(header), 1, wad2_W_fp); - - fflush(wad2_W_fp); - fclose(wad2_W_fp); - - LogPrintf("Closed WAD2 file\n"); - - wad2_W_directory.clear(); -} - -void WAD2_NewLump(const char *name, int type) { - SYS_ASSERT(strlen(name) <= 15); - - memset(&wad2_W_lump, 0, sizeof(wad2_W_lump)); - - strcpy(wad2_W_lump.name, name); - - wad2_W_lump.type = type; - wad2_W_lump.start = (uint32_t)ftell(wad2_W_fp); -} - -bool WAD2_AppendData(const void *data, int length) { - if (length == 0) { - return true; - } - - SYS_ASSERT(length > 0); - - return (fwrite(data, length, 1, wad2_W_fp) == 1); -} - -void WAD2_FinishLump(void) { - int len = (int)ftell(wad2_W_fp) - (int)wad2_W_lump.start; - - // pad lumps to a multiple of four bytes - int padding = ALIGN_LEN(len) - len; - - if (padding > 0) { - static uint8_t zeros[4] = {0, 0, 0, 0}; - - fwrite(zeros, padding, 1, wad2_W_fp); - } - - // fix endianness - wad2_W_lump.start = LE_U32(wad2_W_lump.start); - wad2_W_lump.length = LE_U32(len); - wad2_W_lump.u_len = LE_U32(len); - - wad2_W_directory.push_back(wad2_W_lump); -} - //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source_files/obsidian_main/lib_wad.h b/source_files/obsidian_main/lib_wad.h index cfaac2c80..f5aa81026 100644 --- a/source_files/obsidian_main/lib_wad.h +++ b/source_files/obsidian_main/lib_wad.h @@ -46,28 +46,6 @@ void WAD_NewLump(std::string name); bool WAD_AppendData(const void *data, int length); void WAD_FinishLump(); -/* WAD2 reading */ - -bool WAD2_OpenRead(const char *filename); -void WAD2_CloseRead(); - -int WAD2_NumEntries(); -int WAD2_FindEntry(const char *name); -int WAD2_EntryLen(int entry); -int WAD2_EntryType(int entry); -const char *WAD2_EntryName(int entry); - -bool WAD2_ReadData(int entry, int offset, int length, void *buffer); - -/* WAD2 writing */ - -bool WAD2_OpenWrite(const char *filename); -void WAD2_CloseWrite(); - -void WAD2_NewLump(const char *name, int type = 0); -bool WAD2_AppendData(const void *data, int length); -void WAD2_FinishLump(); - /* ----- WAD structure (Doom) ---------------------- */ #pragma pack(push, 1) @@ -88,52 +66,6 @@ struct raw_wad_lump_t { }; #pragma pack(pop) -/* ----- WAD2 structures (Quake) ---------------------- */ - -#pragma pack(push, 1) -struct raw_wad2_header_t { - char magic[4]; - - uint32_t num_lumps; - uint32_t dir_start; -}; -#pragma pack(pop) - -constexpr const char *WAD2_MAGIC = "WAD2"; - -#pragma pack(push, 1) -struct raw_wad2_lump_t { - uint32_t start; - uint32_t length; // compressed - uint32_t u_len; // uncompressed - - uint8_t type; - uint8_t compression; - uint8_t _pad[2]; - - char name[16]; // must be null terminated -}; -#pragma pack(pop) - -// compression method (from Quake1 source) -enum { - CMP_NONE, - CMP_LZSS, -}; - -// lump types (from Quake1 source) -enum { - TYP_NONE, - TYP_LABEL, - TYP_PALETTE = 64, - TYP_QTEX, - TYP_QPIC, - TYP_SOUND, - TYP_MIPTEX, - // this value is only returned from WAD2_EntryType() - TYP_COMPRESSED = 256, -}; - #endif //--- editor settings --- diff --git a/source_files/obsidian_main/m_cookie.h b/source_files/obsidian_main/m_cookie.h index 2bfdc54f0..8f5d8dded 100644 --- a/source_files/obsidian_main/m_cookie.h +++ b/source_files/obsidian_main/m_cookie.h @@ -47,7 +47,7 @@ void Recent_Parse(std::string name, std::string value); void Recent_Write(std::ofstream &fp); typedef enum { - RECG_Output = 0, // generated WAD or PAK file + RECG_Output = 0, // generated WAD RECG_Config = 1, // file saved from Config Manager RECG_NUM_GROUPS diff --git a/source_files/obsidian_main/m_manage.cc b/source_files/obsidian_main/m_manage.cc index c97369fc7..31b1d5af3 100644 --- a/source_files/obsidian_main/m_manage.cc +++ b/source_files/obsidian_main/m_manage.cc @@ -422,17 +422,6 @@ class UI_Manage_Config : public Fl_Double_Window { chooser.title(_("Select file to load")); chooser.type(Fl_Native_File_Chooser::BROWSE_FILE); - // These filters (in FLTK's own browser at least) are a choice - // and only one is active at a time. That sucks, since only - // files matching the active filter are shown. -#if 0 - chooser.filter("Text files\t*.txt\n" - "Config files\t*.cfg\n" - "WAD files\t*.wad\n" - "GRP files\t*.grp\n" - "PAK files\t*.pak\n"); -#endif - if (!last_directory.empty()) { chooser.directory(last_directory.generic_u8string().c_str()); } else { diff --git a/source_files/obsidian_main/main.h b/source_files/obsidian_main/main.h index 13533ac18..14aa9312d 100644 --- a/source_files/obsidian_main/main.h +++ b/source_files/obsidian_main/main.h @@ -272,8 +272,7 @@ class game_interface_c { // value is the result from the LUA script, and is false if // an error occurred or the user clicked Abort. // - // For DOOM this will run glBSP node builder, for QUAKE it will - // put all the BSP files into the final PAK file. + // For DOOM this will run the AJBSP node builder. // // Returns false on error. Note that Finish() is never // called if Start() fails. diff --git a/source_files/obsidian_main/q1_structs.h b/source_files/obsidian_main/q1_structs.h deleted file mode 100644 index aeca6a0be..000000000 --- a/source_files/obsidian_main/q1_structs.h +++ /dev/null @@ -1,206 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. - -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. - -*/ - -// -// Modified by Andrew Apted for OBLIGE Level Maker, -// - -#ifndef Q1_STRUCTS_H_ -#define Q1_STRUCTS_H_ - -#include "headers.h" - -// upper design bounds - -constexpr int MAX_MAP_HULLS = 4; - -constexpr int MAX_MAP_MODELS = 256; -constexpr int MAX_MAP_BRUSHED = 4096; -constexpr int MAX_MAP_ENTITIES = 1024; -constexpr int MAX_MAP_ENTSTRING = 65535; - -constexpr int MAX_MAP_PLANES = 65536; -/* negative shorts are contents */ -constexpr int MAX_MAP_NODES = 65530; -/* negative shorts are contents */ -constexpr int MAX_MAP_CLIPNODES = 65530; -constexpr int MAX_MAP_LEAFS = 32768; - -constexpr int MAX_MAP_VERTS = 65535; -constexpr int MAX_MAP_FACES = 65535; -constexpr int MAX_MAP_MARKSURFACES = 65535; -constexpr int MAX_MAP_TEXINFO = 65536; -constexpr int MAX_MAP_TEXTURES = 512; - -constexpr int MAX_MAP_EDGES = 256000; -constexpr int MAX_MAP_SURFEDGES = 512000; -constexpr int MAX_MAP_MIPTEX = 0x200000; -constexpr int MAX_MAP_LIGHTING = 0x100000; -constexpr int MAX_MAP_VISIBILITY = 0x100000; - -constexpr int MAX_MAP_PORTALS = 65535; - -// key / value pair sizes - -constexpr int MAX_KEY = 32; -constexpr int MAX_VALUE = 1024; - -//============================================================================= - -constexpr int BSPVERSION = 29; - -enum { - LUMP_ENTITIES, - LUMP_PLANES, - LUMP_TEXTURES, - LUMP_VERTEXES, - LUMP_VISIBILITY, - LUMP_NODES, - LUMP_TEXINFO, - LUMP_FACES, - LUMP_LIGHTING, - LUMP_CLIPNODES, - LUMP_LEAFS, - LUMP_MARKSURFACES, - LUMP_EDGES, - LUMP_SURFEDGES, - LUMP_MODELS, - HEADER_LUMPS, -}; - -// AJA: moved lump_t and dheader_t to q_common.h - -#pragma pack(push, 1) -struct dmodel_t { - float mins[3], maxs[3]; - float origin[3]; - - int32_t headnode[MAX_MAP_HULLS]; - int32_t numleafs; // not including the solid leaf 0 - int32_t firstface, numfaces; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct dmiptexlump_t { - int32_t num_miptex; - int32_t data_ofs[2]; // [nummiptex] -}; -#pragma pack(pop) - -constexpr int MIP_LEVELS = 4; -#pragma pack(push, 1) -struct miptex_t { - char name[16]; - uint32_t width, height; - uint32_t offsets[MIP_LEVELS]; // four mip maps stored -}; -#pragma pack(pop) - -// AJA: moved dplane_t to q_common.h - -enum { - - CONTENTS_CURRENT_DOWN = -14, - CONTENTS_CURRENT_UP, - CONTENTS_CURRENT_270, - CONTENTS_CURRENT_180, - CONTENTS_CURRENT_90, - CONTENTS_CURRENT_0, - /* changed to contents_solid */ - CONTENTS_CLIP, - /* removed at csg time */ - CONTENTS_ORIGIN, - CONTENTS_SKY, - CONTENTS_LAVA, - CONTENTS_SLIME, - CONTENTS_WATER, - CONTENTS_SOLID, - CONTENTS_EMPTY, -}; - -#pragma pack(push, 1) -struct dnode_t { - int32_t planenum; - int16_t children[2]; // negative numbers are -(leafs+1), not nodes - - int16_t mins[3]; // for sphere culling - int16_t maxs[3]; - - uint16_t firstface; - uint16_t numfaces; // counting both sides -}; -#pragma pack(pop) - -/* - * Note that children are interpreted as unsigned values now, so that we can - * handle > 32k clipnodes. Values > 0xFFF0 can be assumed to be CONTENTS - * values and can be read as the signed value to be compatible with the above - * (i.e. simply subtract 65536). - */ -struct dclipnode_t { - int32_t planenum; - uint16_t children[2]; -}; - -constexpr unsigned int CLIP_SPECIAL = 0xFFF0; - -#pragma pack(push, 1) -struct texinfo_t { - float s[4]; // x/y/z/offset - float t[4]; - - int32_t miptex; - int32_t flags; -}; -#pragma pack(pop) - -// sky or slime: no lightmap, no 256 subdivision -// -AJA- only disables a check on extents, otherwise not used by quake engine -constexpr int TEX_SPECIAL = 1; - -// AJA: dvertex_t and dedge_t moved into q_common.h - -// AJA: dface_t also moved into q_common.h - -// automatic ambient sounds -constexpr int NUM_AMBIENTS = 4; - -// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas -// all other leafs need visibility info -#pragma pack(push, 1) -struct dleaf_t { - int32_t contents; - int32_t visofs; // -1 = no visibility info - - int16_t mins[3]; // for frustum culling - int16_t maxs[3]; - - uint16_t first_marksurf; - uint16_t num_marksurf; - - uint8_t ambient_level[NUM_AMBIENTS]; -}; -#pragma pack(pop) - -#endif - -//--- editor settings --- -// vi:ts=4:sw=4:noexpandtab