From 91097fb48ed4a3a01eb837bc44fd10bccb31b87b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 10 Nov 2017 22:36:37 +0000 Subject: [PATCH 01/14] added RET_SOC and RET_LUA, so we can load SOC/LUA files differently to WADs this also means we can remove a few ancient hacks relating to using the same code used to load SOC/Lua in WADs for loading standalone Lua/SOC files, though I haven't fully done this yet --- src/w_wad.c | 31 ++++++++++++++++++++++--------- src/w_wad.h | 10 ++++++++-- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 75bf40983..dd52a2172 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -224,7 +224,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) { // shameless copy+paste of code from LUA_LoadLump char *name = malloc(strlen(wadfiles[wadnum]->filename)+10); strcpy(name, wadfiles[wadnum]->filename); - if (!fasticmp(&name[strlen(name) - 4], ".soc")) { + /*if (!fasticmp(&name[strlen(name) - 4], ".soc"))*/ { // If it's not a .soc file, copy the lump name in too. name[strlen(wadfiles[wadnum]->filename)] = '|'; M_Memcpy(name+strlen(wadfiles[wadnum]->filename)+1, lump_p->name, 8); @@ -319,7 +319,7 @@ UINT16 W_InitFile(const char *filename) FILE *handle; lumpinfo_t *lumpinfo; wadfile_t *wadfile; - enum restype type; + restype_t type; UINT16 numlumps; size_t i; INT32 compressed = 0; @@ -390,7 +390,7 @@ UINT16 W_InitFile(const char *filename) // This code emulates a wadfile with one lump name "OBJCTCFG" // at position 0 and size of the whole file. // This allows soc files to be like all wads, copied by network and loaded at the console. - type = RET_WAD; + type = RET_SOC; numlumps = 1; lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); @@ -411,7 +411,7 @@ UINT16 W_InitFile(const char *filename) // This code emulates a wadfile with one lump name "LUA_INIT" // at position 0 and size of the whole file. // This allows soc files to be like all wads, copied by network and loaded at the console. - type = RET_WAD; + type = RET_LUA; numlumps = 1; lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); @@ -733,11 +733,24 @@ UINT16 W_InitFile(const char *filename) numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded // TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now. - if (wadfile->type == RET_WAD) - W_LoadDehackedLumps(numwadfiles - 1); - else if (wadfile->type == RET_PK3) - W_LoadDehackedLumpsPK3(numwadfiles - 1); - + switch (wadfile->type) + { + case RET_WAD: + W_LoadDehackedLumps(numwadfiles - 1); + break; + case RET_PK3: + W_LoadDehackedLumpsPK3(numwadfiles - 1); + break; + case RET_SOC: + CONS_Printf(M_GetText("Loading SOC from %s\n"), wadfile->filename); + DEH_LoadDehackedLumpPwad(numwadfiles - 1, 0); + break; + case RET_LUA: + LUA_LoadLump(numwadfiles - 1, 0); + break; + default: + break; + } W_InvalidateLumpnumCache(); diff --git a/src/w_wad.h b/src/w_wad.h index f06725884..26e87f3c2 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -78,12 +78,18 @@ typedef struct #endif // Resource type of the WAD. Yeah, I know this sounds dumb, but I'll leave it like this until I clean up the code further. -enum restype {RET_WAD, RET_PK3}; +typedef enum restype +{ + RET_WAD, + RET_SOC, + RET_LUA, + RET_PK3 +} restype_t; typedef struct wadfile_s { char *filename; - enum restype type; + restype_t type; lumpinfo_t *lumpinfo; lumpcache_t *lumpcache; #ifdef HWRENDER From 75bc76e9b4c5edbf465d2081a240a91d21b208fe Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 7 Dec 2017 18:26:12 +0000 Subject: [PATCH 02/14] Remove all traces of "srb2.wad" support, since it is no longer needed now that srb2.pk3 is the IWAD (...IPK3?). srb2.wad cannot exactly be a pk3 file after all. Additionally, rename any remaining "srb2.srb" to "srb2.pk3" in the main source code files. Not sure whether to bother dealing with srb2.srb/srb2.wad mentions in project files for now. --- src/Makefile | 2 +- src/config.h.in | 4 ++-- src/d_main.c | 29 +++++++++++------------------ src/d_netfil.c | 3 ++- src/sdl/i_system.c | 26 +++++--------------------- 5 files changed, 21 insertions(+), 43 deletions(-) diff --git a/src/Makefile b/src/Makefile index 017bd2442..322e67bfe 100644 --- a/src/Makefile +++ b/src/Makefile @@ -79,7 +79,7 @@ # SRB2 data files D_DIR?=../bin/Resources -D_FILES=$(D_DIR)/srb2.srb \ +D_FILES=$(D_DIR)/srb2.pk3 \ $(D_DIR)/player.dta \ $(D_DIR)/rings.wpn \ $(D_DIR)/drill.dta \ diff --git a/src/config.h.in b/src/config.h.in index 5f06ec45d..7c9ebe6cb 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -11,7 +11,7 @@ #ifdef CMAKECONFIG -#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}" +#define ASSET_HASH_SRB2_PK3 "${SRB2_ASSET_srb2.pk3_HASH}" #define ASSET_HASH_PLAYER_DTA "${SRB2_ASSET_player.dta_HASH}" #define ASSET_HASH_RINGS_DTA "${SRB2_ASSET_rings.dta_HASH}" #define ASSET_HASH_ZONES_DTA "${SRB2_ASSET_zones.dta_HASH}" @@ -31,7 +31,7 @@ /* Manually defined asset hashes for non-CMake builds * Last updated 2015 / 05 / 03 */ -#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7" +#define ASSET_HASH_SRB2_PK3 "c1b9577687f8a795104aef4600720ea7" #define ASSET_HASH_ZONES_DTA "303838c6c534d9540288360fa49cca60" #define ASSET_HASH_PLAYER_DTA "cfca0f1c73023cbbd8f844f45480f799" #define ASSET_HASH_RINGS_DTA "85901ad4bf94637e5753d2ac2c03ea26" diff --git a/src/d_main.c b/src/d_main.c index 45f9d6763..05aa3e675 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -784,7 +784,7 @@ static inline void D_CleanFile(void) static void IdentifyVersion(void) { - char *srb2wad1, *srb2wad2; + char *srb2wad; const char *srb2waddir = NULL; #if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) @@ -813,31 +813,24 @@ static void IdentifyVersion(void) srb2waddir = I_GetWadDir(); #endif // Commercial. - srb2wad1 = malloc(strlen(srb2waddir)+1+8+1); - srb2wad2 = malloc(strlen(srb2waddir)+1+8+1); - if (srb2wad1 == NULL && srb2wad2 == NULL) + srb2wad = malloc(strlen(srb2waddir)+1+8+1); + if (srb2wad == NULL) I_Error("No more free memory to look in %s", srb2waddir); - if (srb2wad1 != NULL) - sprintf(srb2wad1, pandf, srb2waddir, "srb2.pk3"); - if (srb2wad2 != NULL) - sprintf(srb2wad2, pandf, srb2waddir, "srb2.wad"); + else + sprintf(srb2wad, pandf, srb2waddir, "srb2.pk3"); // will be overwritten in case of -cdrom or unix/win home snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2waddir); configfile[sizeof configfile - 1] = '\0'; // Load the IWAD - if (srb2wad2 != NULL && FIL_ReadFileOK(srb2wad2)) - D_AddFile(srb2wad2); - else if (srb2wad1 != NULL && FIL_ReadFileOK(srb2wad1)) - D_AddFile(srb2wad1); + if (srb2wad != NULL && FIL_ReadFileOK(srb2wad)) + D_AddFile(srb2wad); else - I_Error("SRB2.SRB/SRB2.WAD not found! Expected in %s, ss files: %s and %s\n", srb2waddir, srb2wad1, srb2wad2); + I_Error("srb2.pk3 not found! Expected in %s, ss file: %s\n", srb2waddir, srb2wad); - if (srb2wad1) - free(srb2wad1); - if (srb2wad2) - free(srb2wad2); + if (srb2wad) + free(srb2wad); // if you change the ordering of this or add/remove a file, be sure to update the md5 // checking in D_SRB2Main @@ -1132,7 +1125,7 @@ void D_SRB2Main(void) #ifndef DEVELOP // md5s last updated 12/14/14 // Check MD5s of autoloaded files - //W_VerifyFileMD5(0, ASSET_HASH_SRB2_SRB); // srb2.srb/srb2.wad + //W_VerifyFileMD5(0, ASSET_HASH_SRB2_PK3); // srb2.pk3 //W_VerifyFileMD5(1, ASSET_HASH_ZONES_DTA); // zones.dta //W_VerifyFileMD5(2, ASSET_HASH_PLAYER_DTA); // player.dta #ifdef USE_PATCH_DTA diff --git a/src/d_netfil.c b/src/d_netfil.c index 72ac0dd32..c080452ae 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -333,7 +333,7 @@ INT32 CL_CheckFiles(void) // return 1; // the first is the iwad (the main wad file) - // we don't care if it's called srb2.srb or srb2.wad. + // we don't care if it's called srb2.pk3 or not. // Never download the IWAD, just assume it's there and identical fileneeded[0].status = FS_OPEN; @@ -754,6 +754,7 @@ void Got_Filetxpak(void) static INT32 filetime = 0; if (!(strcmp(filename, "srb2.pk3") + && strcmp(filename, "srb2.srb") && strcmp(filename, "srb2.wad") && strcmp(filename, "zones.dta") && strcmp(filename, "player.dta") diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 7d0eabe31..1776ff450 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -124,7 +124,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include "macosx/mac_resources.h" #endif -// Locations for searching the srb2.srb +// Locations for searching the srb2.pk3 #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2" #define DEFAULTWADLOCATION2 "/usr/local/games/SRB2" @@ -143,7 +143,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); /** \brief WAD file to look for */ #define WADKEYWORD1 "srb2.pk3" -#define WADKEYWORD2 "srb2.wad" /** \brief holds wad path */ static char returnWadPath[256]; @@ -2511,14 +2510,6 @@ static boolean isWadPathOk(const char *path) return true; } - sprintf(wad3path, pandf, path, WADKEYWORD2); - - if (FIL_ReadFileOK(wad3path)) - { - free(wad3path); - return true; - } - free(wad3path); return false; } @@ -2536,7 +2527,7 @@ static void pathonly(char *s) } } -/** \brief search for srb2.srb in the given path +/** \brief search for srb2.pk3 in the given path \param searchDir starting path @@ -2557,19 +2548,12 @@ static const char *searchWad(const char *searchDir) return tempsw; } - strcpy(tempsw, WADKEYWORD2); - fstemp = filesearch(tempsw, searchDir, NULL, true, 20); - if (fstemp == FS_FOUND) - { - pathonly(tempsw); - return tempsw; - } return NULL; } -/** \brief go through all possible paths and look for srb2.srb +/** \brief go through all possible paths and look for srb2.pk3 - \return path to srb2.srb if any + \return path to srb2.pk3 if any */ static const char *locateWad(void) { @@ -2698,7 +2682,7 @@ const char *I_LocateWad(void) if (waddir) { - // change to the directory where we found srb2.srb + // change to the directory where we found srb2.pk3 #if defined (_WIN32) SetCurrentDirectoryA(waddir); #else From 6590d97338e44b7788573cc8eec127ea699ace7f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 4 Jan 2018 15:14:53 +0000 Subject: [PATCH 03/14] clean up CM_LZF code in W_ReadLumpHeaderPwad --- src/w_wad.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index c525f673e..2adff1d8a 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1130,30 +1130,30 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); retval = lzf_decompress(rawData, l->disksize, decData, l->size); #ifndef AVOID_ERRNO - if (retval == 0 && errno == E2BIG) // errno is a global var set by the lzf functions when something goes wrong. + if (retval == 0) // If this was returned, check if errno was set { - I_Error("wad %d, lump %d: compressed data too big (bigger than %s)", wad, lump, sizeu1(l->size)); + // errno is a global var set by the lzf functions when something goes wrong. + if (errno == E2BIG) + I_Error("wad %d, lump %d: compressed data too big (bigger than %s)", wad, lump, sizeu1(l->size)); + else if (errno == EINVAL) + I_Error("wad %d, lump %d: invalid compressed data", wad, lump); } - else if (retval == 0 && errno == EINVAL) - I_Error("wad %d, lump %d: invalid compressed data", wad, lump); - else + // Otherwise, fall back on below error (if it was actually correct size then ???) #endif if (retval != l->size) { I_Error("wad %d, lump %d: decompressed to wrong number of bytes (expected %s, got %s)", wad, lump, sizeu1(l->size), sizeu2(retval)); } -#else - (void)wad; - (void)lump; - //I_Error("ZWAD files not supported on this platform."); - return NULL; -#endif if (!decData) // Did we get no data at all? return 0; M_Memcpy(dest, decData + offset, size); Z_Free(rawData); Z_Free(decData); return size; +#else + //I_Error("ZWAD files not supported on this platform."); + return 0; +#endif } case CM_DEFLATE: // Is it compressed via DEFLATE? Very common in ZIPs/PK3s, also what most doom-related editors support. { From 29d605a1041a332372da3d7df2e44ee240a9d14b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 4 Jan 2018 15:17:32 +0000 Subject: [PATCH 04/14] clarify this comment a little better --- src/w_wad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 2adff1d8a..0dea2c352 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1138,7 +1138,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si else if (errno == EINVAL) I_Error("wad %d, lump %d: invalid compressed data", wad, lump); } - // Otherwise, fall back on below error (if it was actually correct size then ???) + // Otherwise, fall back on below error (if zero was actually the correct size then ???) #endif if (retval != l->size) { From b0d0738fb60da32b02bf2fcb59e1899961ee9bed Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 4 Jan 2018 20:15:44 +0000 Subject: [PATCH 05/14] P_AddWadFile: Remove useless firstmapname param, clean up map searching code --- src/d_netcmd.c | 4 ++-- src/d_netfil.c | 2 +- src/p_setup.c | 19 ++++++------------- src/p_setup.h | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b1e3bc9d2..5e3dadf8c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3066,7 +3066,7 @@ static void Command_Addfile(void) // Add file on your client directly if it is trivial, or you aren't in a netgame. if (!(netgame || multiplayer) || musiconly) { - P_AddWadFile(fn, NULL); + P_AddWadFile(fn); return; } @@ -3235,7 +3235,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) ncs = findfile(filename,md5sum,true); - if (ncs != FS_FOUND || !P_AddWadFile(filename, NULL)) + if (ncs != FS_FOUND || !P_AddWadFile(filename)) { Command_ExitGame_f(); if (ncs == FS_FOUND) diff --git a/src/d_netfil.c b/src/d_netfil.c index c080452ae..614d2064e 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -423,7 +423,7 @@ void CL_LoadServerFiles(void) continue; // Already loaded else if (fileneeded[i].status == FS_FOUND) { - P_AddWadFile(fileneeded[i].filename, NULL); + P_AddWadFile(fileneeded[i].filename); G_SetGameModified(true); fileneeded[i].status = FS_OPEN; } diff --git a/src/p_setup.c b/src/p_setup.c index fc0b7273b..4e9cfb61e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3133,7 +3133,7 @@ boolean P_RunSOC(const char *socfilename) lumpnum_t lump; if (strstr(socfilename, ".soc") != NULL) - return P_AddWadFile(socfilename, NULL); + return P_AddWadFile(socfilename); lump = W_CheckNumForName(socfilename); if (lump == LUMPERROR) @@ -3214,13 +3214,13 @@ static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, l // Add a wadfile to the active wad files, // replace sounds, musics, patches, textures, sprites and maps // -boolean P_AddWadFile(const char *wadfilename, char **firstmapname) +boolean P_AddWadFile(const char *wadfilename) { size_t i, j, sreplaces = 0, mreplaces = 0, digmreplaces = 0; UINT16 numlumps, wadnum; - INT16 firstmapreplaced = 0, num; char *name; lumpinfo_t *lumpinfo; + boolean mapsadded = false; boolean replacedcurrentmap = false; // Vars to help us with the position start and amount of each resource type. @@ -3354,10 +3354,9 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname) for (i = 0; i < numlumps; i++, lumpinfo++) { name = lumpinfo->name; - num = firstmapreplaced; - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P') // Ignore the headers { + INT16 num; if (name[5]!='\0') continue; num = (INT16)M_MapNumber(name[3], name[4]); @@ -3367,16 +3366,10 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname) replacedcurrentmap = true; CONS_Printf("%s\n", name); - } - - if (num && (num < firstmapreplaced || !firstmapreplaced)) - { - firstmapreplaced = num; - if (firstmapname) - *firstmapname = name; + mapsadded = true; } } - if (!firstmapreplaced) + if (!mapsadded) CONS_Printf(M_GetText("No maps added\n")); // reload status bar (warning should have valid player!) diff --git a/src/p_setup.h b/src/p_setup.h index de763bed0..a42ac5b76 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -59,7 +59,7 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); #endif void P_LoadThingsOnly(void); boolean P_SetupLevel(boolean skipprecip); -boolean P_AddWadFile(const char *wadfilename, char **firstmapname); +boolean P_AddWadFile(const char *wadfilename); boolean P_RunSOC(const char *socfilename); void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num); void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num); From 0e8db59f4b0abf444ac6c26ddecde460f90bcf2e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 4 Jan 2018 21:06:26 +0000 Subject: [PATCH 06/14] P_AddWadFile: for both WADs and pk3s, if a sound is found to replace an existing sound, don't go on looking for more with the same name (since there shouldn't be any) --- src/p_setup.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4e9cfb61e..bc6e8aeae 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3163,6 +3163,7 @@ void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num) CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", lumpinfo->name); I_FreeSfx(&S_sfx[j]); + break; // there shouldn't be two sounds with the same name, so stop looking } } } @@ -3290,17 +3291,21 @@ boolean P_AddWadFile(const char *wadfilename) name = lumpinfo->name; if (name[0] == 'D') { - if (name[1] == 'S') for (j = 1; j < NUMSFX; j++) + if (name[1] == 'S') { - if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6)) + for (j = 1; j < NUMSFX; j++) { - // the sound will be reloaded when needed, - // since sfx->data will be NULL - CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name); + if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6)) + { + // the sound will be reloaded when needed, + // since sfx->data will be NULL + CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name); - I_FreeSfx(&S_sfx[j]); + I_FreeSfx(&S_sfx[j]); - sreplaces++; + sreplaces++; + break; // there shouldn't be two sounds with the same name, so stop looking + } } } else if (name[1] == '_') From 2d98da3bcb80f18d53f7e1f78de278ff3f445cfa Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 9 Jan 2018 19:43:59 +0000 Subject: [PATCH 07/14] Added support for loading BLOCKMAP lumps from MAPXX.wad maps in /Maps/ in PK3s --- src/p_setup.c | 124 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 97 insertions(+), 27 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index bc6e8aeae..b0dd72996 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1893,6 +1893,30 @@ static void P_CreateBlockMap(void) } } +// Split from P_LoadBlockMap for convenience +// -- Monster Iestyn 08/01/18 +static void P_ReadBlockMapLump(INT16 *wadblockmaplump, size_t count) +{ + size_t i; + blockmaplump = Z_Calloc(sizeof (*blockmaplump) * count, PU_LEVEL, NULL); + + // killough 3/1/98: Expand wad blockmap into larger internal one, + // by treating all offsets except -1 as unsigned and zero-extending + // them. This potentially doubles the size of blockmaps allowed, + // because Doom originally considered the offsets as always signed. + + blockmaplump[0] = SHORT(wadblockmaplump[0]); + blockmaplump[1] = SHORT(wadblockmaplump[1]); + blockmaplump[2] = (INT32)(SHORT(wadblockmaplump[2])) & 0xffff; + blockmaplump[3] = (INT32)(SHORT(wadblockmaplump[3])) & 0xffff; + + for (i = 4; i < count; i++) + { + INT16 t = SHORT(wadblockmaplump[i]); // killough 3/1/98 + blockmaplump[i] = t == -1 ? (INT32)-1 : (INT32) t & 0xffff; + } +} + // // P_LoadBlockMap // @@ -1919,38 +1943,20 @@ static boolean P_LoadBlockMap(lumpnum_t lumpnum) return false; { - size_t i; INT16 *wadblockmaplump = malloc(count); //INT16 *wadblockmaplump = W_CacheLumpNum (lump, PU_LEVEL); - - if (wadblockmaplump) W_ReadLump(lumpnum, wadblockmaplump); - else return false; + if (!wadblockmaplump) + return false; + W_ReadLump(lumpnum, wadblockmaplump); count /= 2; - blockmaplump = Z_Calloc(sizeof (*blockmaplump) * count, PU_LEVEL, 0); - - // killough 3/1/98: Expand wad blockmap into larger internal one, - // by treating all offsets except -1 as unsigned and zero-extending - // them. This potentially doubles the size of blockmaps allowed, - // because Doom originally considered the offsets as always signed. - - blockmaplump[0] = SHORT(wadblockmaplump[0]); - blockmaplump[1] = SHORT(wadblockmaplump[1]); - blockmaplump[2] = (INT32)(SHORT(wadblockmaplump[2])) & 0xffff; - blockmaplump[3] = (INT32)(SHORT(wadblockmaplump[3])) & 0xffff; - - for (i = 4; i < count; i++) - { - INT16 t = SHORT(wadblockmaplump[i]); // killough 3/1/98 - blockmaplump[i] = t == -1 ? (INT32)-1 : (INT32) t & 0xffff; - } - + P_ReadBlockMapLump(wadblockmaplump, count); free(wadblockmaplump); - - bmaporgx = blockmaplump[0]<= 0x20000) + return false; + + CONS_Printf("Reading blockmap lump for pk3..."); + + // no need to malloc anything, assume the data is uncompressed for now + count /= 2; + P_ReadBlockMapLump((INT16 *)data, count); + + bmaporgx = blockmaplump[0]<infotableofs; filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); + UINT32 numlumps = ((wadinfo_t *)wadData)->numlumps; + if (numlumps < ML_REJECT) // at least 9 lumps should be in the wad for a map to be loaded + { + I_Error("Bad WAD file for map %s!\n", maplumpname); + } + + if (numlumps > ML_BLOCKMAP) // enough room for a BLOCKMAP lump at least + { + loadedbm = P_LoadRawBlockMap( + wadData + (fileinfo + ML_BLOCKMAP)->filepos, + (fileinfo + ML_BLOCKMAP)->size, + (fileinfo + ML_BLOCKMAP)->name); + } P_LoadRawVertexes(wadData + (fileinfo + ML_VERTEXES)->filepos, (fileinfo + ML_VERTEXES)->size); P_LoadRawSectors(wadData + (fileinfo + ML_SECTORS)->filepos, (fileinfo + ML_SECTORS)->size); P_LoadRawSideDefs((fileinfo + ML_SIDEDEFS)->size); @@ -2780,6 +2846,10 @@ boolean P_SetupLevel(boolean skipprecip) P_LoadRawSubsectors(wadData + (fileinfo + ML_SSECTORS)->filepos, (fileinfo + ML_SSECTORS)->size); P_LoadRawNodes(wadData + (fileinfo + ML_NODES)->filepos, (fileinfo + ML_NODES)->size); P_LoadRawSegs(wadData + (fileinfo + ML_SEGS)->filepos, (fileinfo + ML_SEGS)->size); + if (numlumps > ML_REJECT) // enough room for a REJECT lump at least + { + // placeholder + } // Important: take care of the ordering of the next functions. if (!loadedbm) From db23cfc91691458d0a33cbb51089c8bfaefde78b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 9 Jan 2018 21:33:10 +0000 Subject: [PATCH 08/14] Same has been done for REJECT now --- src/p_setup.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index b0dd72996..45a5442ff 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2162,6 +2162,30 @@ static void P_LoadReject(lumpnum_t lumpnum) rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL); } +// PK3 version +// -- Monster Iestyn 09/01/18 +static void P_LoadRawReject(UINT8 *data, size_t count, const char *lumpname) +{ + // Check if the lump is named "REJECT" + if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) + { + rejectmatrix = NULL; + CONS_Debug(DBG_SETUP, "P_LoadRawReject: No valid REJECT lump found\n"); + return; + } + + if (!count) // zero length, someone probably used ZDBSP + { + rejectmatrix = NULL; + CONS_Debug(DBG_SETUP, "P_LoadRawReject: REJECT lump has size 0, will not be loaded\n"); + } + else + { + rejectmatrix = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix + M_Memcpy(rejectmatrix, data, count); // copy the data into it + } +} + #if 0 static char *levellumps[] = { @@ -2848,7 +2872,10 @@ boolean P_SetupLevel(boolean skipprecip) P_LoadRawSegs(wadData + (fileinfo + ML_SEGS)->filepos, (fileinfo + ML_SEGS)->size); if (numlumps > ML_REJECT) // enough room for a REJECT lump at least { - // placeholder + P_LoadRawReject( + wadData + (fileinfo + ML_REJECT)->filepos, + (fileinfo + ML_REJECT)->size, + (fileinfo + ML_REJECT)->name); } // Important: take care of the ordering of the next functions. From 9c13cee9f0e49f33b55004a39b0bfe6d153338f7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 9 Jan 2018 22:22:10 +0000 Subject: [PATCH 09/14] Hack up support for pk3s in Custom FOF setup, fix stray ! preventing blockmap from loading --- src/p_setup.c | 6 +++--- src/p_spec.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 45a5442ff..497bba445 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2003,16 +2003,16 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count, const char *lumpname return false; #else // Check if the lump is named "BLOCKMAP" - if (!lumpname || !memcmp(lumpname, "BLOCKMAP", 8) != 0) + if (!lumpname || memcmp(lumpname, "BLOCKMAP", 8) != 0) { - CONS_Printf("No blockmap lump found for pk3!"); + CONS_Printf("No blockmap lump found for pk3!\n"); return false; } if (!count || count >= 0x20000) return false; - CONS_Printf("Reading blockmap lump for pk3..."); + CONS_Printf("Reading blockmap lump for pk3...\n"); // no need to malloc anything, assume the data is uncompressed for now count /= 2; diff --git a/src/p_spec.c b/src/p_spec.c index 797aba049..498ebcf7d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6305,8 +6305,21 @@ void P_SpawnSpecials(INT32 fromnetsave) case 259: // Make-Your-Own FOF! if (lines[i].sidenum[1] != 0xffff) { - UINT8 *data = W_CacheLumpNum(lastloadedmaplumpnum + ML_SIDEDEFS,PU_STATIC); + UINT8 *data; UINT16 b; + char *lumpfullName = (wadfiles[WADFILENUM(lastloadedmaplumpnum)]->lumpinfo + LUMPNUM(lastloadedmaplumpnum))->name2; + + if (!strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4)) // welp it's a map wad in a pk3 + { // HACK: Open wad file rather quickly so we can get the data from the sidedefs lump + UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); + filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); + fileinfo += ML_SIDEDEFS; // we only need the SIDEDEFS lump + data = Z_Malloc(fileinfo->size, PU_STATIC, NULL); + M_Memcpy(data, wadData + fileinfo->filepos, fileinfo->size); // copy data + Z_Free(wadData); // we're done with this now + } + else // phew it's just a WAD + data = W_CacheLumpNum(lastloadedmaplumpnum + ML_SIDEDEFS,PU_STATIC); for (b = 0; b < (INT16)numsides; b++) { From 19e08584a36f8e8cb74c21dcfe21406aa1e767e4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 10 Jan 2018 15:24:24 +0000 Subject: [PATCH 10/14] add support for maps-in-WADs-in-pk3s to P_NetArchiveWorld as well --- src/p_saveg.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index d53869d2e..01711a737 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -497,16 +497,37 @@ static void P_NetArchiveWorld(void) UINT8 *put; // reload the map just to see difference - const mapsector_t *ms; - const mapsidedef_t *msd; - const maplinedef_t *mld; + mapsector_t *ms; + mapsidedef_t *msd; + maplinedef_t *mld; const sector_t *ss = sectors; UINT8 diff, diff2; + char *lumpfullName; WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; - ms = W_CacheLumpNum(lastloadedmaplumpnum+ML_SECTORS, PU_CACHE); + lumpfullName = (wadfiles[WADFILENUM(lastloadedmaplumpnum)]->lumpinfo + LUMPNUM(lastloadedmaplumpnum))->name2; + + if (!strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4)) // welp it's a map wad in a pk3 + { // HACK: Open wad file rather quickly so we can get the data from the relevant lumps + UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); + filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); +#define retrieve_mapdata(d, f)\ + d = Z_Malloc((f)->size, PU_CACHE, NULL); \ + M_Memcpy(d, wadData + (f)->filepos, (f)->size) + retrieve_mapdata(ms, fileinfo + ML_SECTORS); + retrieve_mapdata(mld, fileinfo + ML_LINEDEFS); + retrieve_mapdata(msd, fileinfo + ML_SIDEDEFS); +#undef retrieve_mapdata + Z_Free(wadData); // we're done with this now + } + else // phew it's just a WAD + { + ms = W_CacheLumpNum(lastloadedmaplumpnum+ML_SECTORS, PU_CACHE); + mld = W_CacheLumpNum(lastloadedmaplumpnum+ML_LINEDEFS, PU_CACHE); + msd = W_CacheLumpNum(lastloadedmaplumpnum+ML_SIDEDEFS, PU_CACHE); + } for (i = 0; i < numsectors; i++, ss++, ms++) { @@ -637,8 +658,7 @@ static void P_NetArchiveWorld(void) WRITEUINT16(put, 0xffff); - mld = W_CacheLumpNum(lastloadedmaplumpnum+ML_LINEDEFS, PU_CACHE); - msd = W_CacheLumpNum(lastloadedmaplumpnum+ML_SIDEDEFS, PU_CACHE); + // do lines for (i = 0; i < numlines; i++, mld++, li++) { From 0c898534250db569cf4635822f6d4dfcb7940dfc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 10 Jan 2018 16:51:23 +0000 Subject: [PATCH 11/14] created W_IsLumpWad as a shortcut for the "is the lump a WAD" checking in the code getting map data lumps --- src/p_saveg.c | 6 +----- src/p_setup.c | 4 +--- src/p_spec.c | 3 +-- src/w_wad.c | 13 +++++++++++++ src/w_wad.h | 2 ++ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 01711a737..029df08f4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -502,14 +502,11 @@ static void P_NetArchiveWorld(void) maplinedef_t *mld; const sector_t *ss = sectors; UINT8 diff, diff2; - char *lumpfullName; WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; - lumpfullName = (wadfiles[WADFILENUM(lastloadedmaplumpnum)]->lumpinfo + LUMPNUM(lastloadedmaplumpnum))->name2; - - if (!strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4)) // welp it's a map wad in a pk3 + if (W_IsLumpWad(lastloadedmaplumpnum)) // welp it's a map wad in a pk3 { // HACK: Open wad file rather quickly so we can get the data from the relevant lumps UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); @@ -658,7 +655,6 @@ static void P_NetArchiveWorld(void) WRITEUINT16(put, 0xffff); - // do lines for (i = 0; i < numlines; i++, mld++, li++) { diff --git a/src/p_setup.c b/src/p_setup.c index 497bba445..a9fc57652 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2658,7 +2658,6 @@ boolean P_SetupLevel(boolean skipprecip) // use gamemap to get map number. // 99% of the things already did, so. // Map header should always be in place at this point - char *lumpfullName; INT32 i, loadprecip = 1, ranspecialwipe = 0; INT32 loademblems = 1; INT32 fromnetsave = 0; @@ -2841,8 +2840,7 @@ boolean P_SetupLevel(boolean skipprecip) // As it is implemented right now, we're assuming an uncompressed WAD. // (As in, a normal PWAD, not ZWAD or anything. The lump itself can be compressed.) // We're not accounting for extra lumps and scrambled lump positions. Any additional data will cause an error. - lumpfullName = (wadfiles[WADFILENUM(lastloadedmaplumpnum)]->lumpinfo + LUMPNUM(lastloadedmaplumpnum))->name2; - if (!strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4)) + if (W_IsLumpWad(lastloadedmaplumpnum)) { // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); diff --git a/src/p_spec.c b/src/p_spec.c index 498ebcf7d..0b005baff 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6307,9 +6307,8 @@ void P_SpawnSpecials(INT32 fromnetsave) { UINT8 *data; UINT16 b; - char *lumpfullName = (wadfiles[WADFILENUM(lastloadedmaplumpnum)]->lumpinfo + LUMPNUM(lastloadedmaplumpnum))->name2; - if (!strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4)) // welp it's a map wad in a pk3 + if (W_IsLumpWad(lastloadedmaplumpnum)) // welp it's a map wad in a pk3 { // HACK: Open wad file rather quickly so we can get the data from the sidedefs lump UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); diff --git a/src/w_wad.c b/src/w_wad.c index 0dea2c352..816bbd44f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1051,6 +1051,19 @@ size_t W_LumpLength(lumpnum_t lumpnum) return W_LumpLengthPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); } +// +// W_IsLumpWad +// Is the lump a WAD? (presumably in a PK3) +// +boolean W_IsLumpWad(lumpnum_t lumpnum) +{ + const char *lumpfullName = (wadfiles[WADFILENUM(lumpnum)]->lumpinfo + LUMPNUM(lumpnum))->name2; + + if (strlen(lumpfullName) < 4) + return false; // can't possibly be a wad can it? + return !strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4); +} + /* report a zlib or i/o error */ void zerr(int ret) { diff --git a/src/w_wad.h b/src/w_wad.h index 26e87f3c2..ef4213579 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -139,6 +139,8 @@ UINT8 W_LumpExists(const char *name); // Lua uses this. size_t W_LumpLengthPwad(UINT16 wad, UINT16 lump); size_t W_LumpLength(lumpnum_t lumpnum); +boolean W_IsLumpWad(lumpnum_t lumpnum); // for loading maps from WADs in PK3s + void zerr(int ret); // zlib error checking size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, size_t offset); From ddf82949bf2e65e354003b05f67829cea824bc53 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 10 Jan 2018 19:13:29 +0000 Subject: [PATCH 12/14] W_IsLumpWad: check if the file is a PK3, so it can bail out if it isn't --- src/w_wad.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 816bbd44f..ea0feef6c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1057,11 +1057,16 @@ size_t W_LumpLength(lumpnum_t lumpnum) // boolean W_IsLumpWad(lumpnum_t lumpnum) { - const char *lumpfullName = (wadfiles[WADFILENUM(lumpnum)]->lumpinfo + LUMPNUM(lumpnum))->name2; + if (wadfiles[WADFILENUM(lumpnum)]->type == RET_PK3) + { + const char *lumpfullName = (wadfiles[WADFILENUM(lumpnum)]->lumpinfo + LUMPNUM(lumpnum))->name2; - if (strlen(lumpfullName) < 4) - return false; // can't possibly be a wad can it? - return !strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4); + if (strlen(lumpfullName) < 4) + return false; // can't possibly be a WAD can it? + return !strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4); + } + + return false; // WADs should never be inside non-PK3s as far as SRB2 is concerned } /* report a zlib or i/o error */ From 8556a05668a157d52ced5f9090eb1b487d09a9f3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 9 Feb 2018 22:43:08 +0000 Subject: [PATCH 13/14] Fix SOC/Lua loading messages to display full names or even display at all (for PK3s at least), and otherwise some cleanup of existing code for the messages. Also, I moved lua_lumploading on/offing to LUA_LoadFile. --- src/lua_script.c | 27 ++++++++++++++++++--------- src/w_wad.c | 24 ++++++++++++++++-------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index fdaa12c78..0aebafaee 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -176,11 +176,16 @@ static inline void LUA_LoadFile(MYFILE *f, char *name) LUA_ClearState(); lua_pushinteger(gL, f->wad); lua_setfield(gL, LUA_REGISTRYINDEX, "WAD"); + + lua_lumploading = true; // turn on loading flag + if (luaL_loadbuffer(gL, f->data, f->size, va("@%s",name)) || lua_pcall(gL, 0, 0, 0)) { CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); lua_pop(gL,1); } lua_gc(gL, LUA_GCCOLLECT, 0); + + lua_lumploading = false; // turn off again } // Load a script from a lump @@ -188,24 +193,28 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump) { MYFILE f; char *name; + f.wad = wad; f.size = W_LumpLengthPwad(wad, lump); f.data = Z_Malloc(f.size, PU_LUA, NULL); W_ReadLumpPwad(wad, lump, f.data); f.curpos = f.data; - name = malloc(strlen(wadfiles[wad]->filename)+10); - strcpy(name, wadfiles[wad]->filename); - if (!fasticmp(&name[strlen(name) - 4], ".lua")) { - // If it's not a .lua file, copy the lump name in too. - name[strlen(wadfiles[wad]->filename)] = '|'; - M_Memcpy(name+strlen(wadfiles[wad]->filename)+1, wadfiles[wad]->lumpinfo[lump].name, 8); - name[strlen(wadfiles[wad]->filename)+9] = '\0'; + if (wadfiles[wad]->type == RET_LUA) + { + name = malloc(strlen(wadfiles[wad]->filename)+1); + strcpy(name, wadfiles[wad]->filename); + } + else // If it's not a .lua file, copy the lump name in too. + { + lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump]; + size_t length = strlen(wadfiles[wad]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name + name = malloc(length + 1); + sprintf(name, "%s|%s", wadfiles[wad]->filename, lump_p->name2); + name[length] = '\0'; } - lua_lumploading = true; // turn on loading flag LUA_LoadFile(&f, name); // actually load file! - lua_lumploading = false; // turn off again free(name); Z_Free(f.data); diff --git a/src/w_wad.c b/src/w_wad.c index ea0feef6c..c9330a7eb 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -198,7 +198,17 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) { posEnd = W_CheckNumForFolderEndPK3("SOCs/", wadnum, posStart); for(; posStart < posEnd; posStart++) + { + lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[posStart]; + size_t length = strlen(wadfiles[wadnum]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name + char *name = malloc(length + 1); + sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->name2); + name[length] = '\0'; + + CONS_Printf(M_GetText("Loading SOC from %s\n"), name); DEH_LoadDehackedLumpPwad(wadnum, posStart); + free(name); + } } } @@ -222,16 +232,14 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) if (memcmp(lump_p->name,"SOC_",4)==0) // Check for generic SOC lump { // shameless copy+paste of code from LUA_LoadLump - char *name = malloc(strlen(wadfiles[wadnum]->filename)+10); - strcpy(name, wadfiles[wadnum]->filename); - /*if (!fasticmp(&name[strlen(name) - 4], ".soc"))*/ { - // If it's not a .soc file, copy the lump name in too. - name[strlen(wadfiles[wadnum]->filename)] = '|'; - M_Memcpy(name+strlen(wadfiles[wadnum]->filename)+1, lump_p->name, 8); - name[strlen(wadfiles[wadnum]->filename)+9] = '\0'; - } + size_t length = strlen(wadfiles[wadnum]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name + char *name = malloc(length + 1); + sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->name2); + name[length] = '\0'; + CONS_Printf(M_GetText("Loading SOC from %s\n"), name); DEH_LoadDehackedLumpPwad(wadnum, lump); + free(name); } else if (memcmp(lump_p->name,"MAINCFG",8)==0) // Check for MAINCFG { From 49b8fd6d67e308950f67dda75fa71816f50eb6ce Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 13 Feb 2018 21:12:42 +0000 Subject: [PATCH 14/14] Don't attempt to load the "Lua/" or "SOCs/" folder lumps themselves as Lua/SOC lumps --- src/w_wad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index c9330a7eb..1b0e501a6 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -190,6 +190,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) if (posStart != INT16_MAX) { posEnd = W_CheckNumForFolderEndPK3("Lua/", wadnum, posStart); + posStart++; // first "lump" will be "Lua/" folder itself, so ignore it for (; posStart < posEnd; posStart++) LUA_LoadLump(wadnum, posStart); } @@ -197,6 +198,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) if (posStart != INT16_MAX) { posEnd = W_CheckNumForFolderEndPK3("SOCs/", wadnum, posStart); + posStart++; // first "lump" will be "SOCs/" folder itself, so ignore it for(; posStart < posEnd; posStart++) { lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[posStart];