mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
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
This commit is contained in:
parent
7f4424b4a0
commit
91097fb48e
2 changed files with 30 additions and 11 deletions
31
src/w_wad.c
31
src/w_wad.c
|
@ -224,7 +224,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum)
|
||||||
{ // shameless copy+paste of code from LUA_LoadLump
|
{ // shameless copy+paste of code from LUA_LoadLump
|
||||||
char *name = malloc(strlen(wadfiles[wadnum]->filename)+10);
|
char *name = malloc(strlen(wadfiles[wadnum]->filename)+10);
|
||||||
strcpy(name, wadfiles[wadnum]->filename);
|
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.
|
// If it's not a .soc file, copy the lump name in too.
|
||||||
name[strlen(wadfiles[wadnum]->filename)] = '|';
|
name[strlen(wadfiles[wadnum]->filename)] = '|';
|
||||||
M_Memcpy(name+strlen(wadfiles[wadnum]->filename)+1, lump_p->name, 8);
|
M_Memcpy(name+strlen(wadfiles[wadnum]->filename)+1, lump_p->name, 8);
|
||||||
|
@ -319,7 +319,7 @@ UINT16 W_InitFile(const char *filename)
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
lumpinfo_t *lumpinfo;
|
lumpinfo_t *lumpinfo;
|
||||||
wadfile_t *wadfile;
|
wadfile_t *wadfile;
|
||||||
enum restype type;
|
restype_t type;
|
||||||
UINT16 numlumps;
|
UINT16 numlumps;
|
||||||
size_t i;
|
size_t i;
|
||||||
INT32 compressed = 0;
|
INT32 compressed = 0;
|
||||||
|
@ -390,7 +390,7 @@ UINT16 W_InitFile(const char *filename)
|
||||||
// This code emulates a wadfile with one lump name "OBJCTCFG"
|
// This code emulates a wadfile with one lump name "OBJCTCFG"
|
||||||
// at position 0 and size of the whole file.
|
// 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.
|
// 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;
|
numlumps = 1;
|
||||||
lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
|
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"
|
// This code emulates a wadfile with one lump name "LUA_INIT"
|
||||||
// at position 0 and size of the whole file.
|
// 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.
|
// 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;
|
numlumps = 1;
|
||||||
lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
|
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
|
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.
|
// 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)
|
switch (wadfile->type)
|
||||||
W_LoadDehackedLumps(numwadfiles - 1);
|
{
|
||||||
else if (wadfile->type == RET_PK3)
|
case RET_WAD:
|
||||||
W_LoadDehackedLumpsPK3(numwadfiles - 1);
|
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();
|
W_InvalidateLumpnumCache();
|
||||||
|
|
||||||
|
|
10
src/w_wad.h
10
src/w_wad.h
|
@ -78,12 +78,18 @@ typedef struct
|
||||||
#endif
|
#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.
|
// 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
|
typedef struct wadfile_s
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
enum restype type;
|
restype_t type;
|
||||||
lumpinfo_t *lumpinfo;
|
lumpinfo_t *lumpinfo;
|
||||||
lumpcache_t *lumpcache;
|
lumpcache_t *lumpcache;
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
|
|
Loading…
Reference in a new issue