mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-17 23:21:22 +00:00
created W_IsLumpWad as a shortcut for the "is the lump a WAD" checking in the code getting map data lumps
This commit is contained in:
parent
19e08584a3
commit
0c89853425
5 changed files with 18 additions and 10 deletions
|
@ -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++)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
13
src/w_wad.c
13
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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue