From 91097fb48ed4a3a01eb837bc44fd10bccb31b87b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 10 Nov 2017 22:36:37 +0000 Subject: [PATCH] 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