mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-12 22:02:12 +00:00
PK3 stuff again.
-Now can load map WAD files inside Maps/ directory, but they must only contain map data explicitly! Known problems: -There's an issue causing a crash with palettes and colormaps in PK3s. -SS_START and SS_END don't work now. Will check later. -Standalone lumps for maps in the Maps/ folder don't work anymore; perhaps I should keep that functionality? Notes: -It's now a mashup of something dumb that I wanted to do and yet piling hacks again. -A lot of code duplicity with map lump loading functions.
This commit is contained in:
parent
ea2846394e
commit
d4c324eb30
7 changed files with 872 additions and 91 deletions
828
src/p_setup.c
828
src/p_setup.c
|
@ -418,6 +418,31 @@ static inline void P_LoadVertexes(lumpnum_t lumpnum)
|
|||
Z_Free(data);
|
||||
}
|
||||
|
||||
static inline void P_LoadRawVertexes(UINT8 *data, size_t i)
|
||||
{
|
||||
mapvertex_t *ml;
|
||||
vertex_t *li;
|
||||
|
||||
numvertexes = i / sizeof (mapvertex_t);
|
||||
|
||||
if (numvertexes <= 0)
|
||||
I_Error("Level has no vertices"); // instead of crashing
|
||||
|
||||
// Allocate zone memory for buffer.
|
||||
vertexes = Z_Calloc(numvertexes * sizeof (*vertexes), PU_LEVEL, NULL);
|
||||
|
||||
ml = (mapvertex_t *)data;
|
||||
li = vertexes;
|
||||
|
||||
// Copy and convert vertex coordinates, internal representation as fixed.
|
||||
for (i = 0; i < numvertexes; i++, li++, ml++)
|
||||
{
|
||||
li->x = SHORT(ml->x)<<FRACBITS;
|
||||
li->y = SHORT(ml->y)<<FRACBITS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Computes the line length in fracunits, the OpenGL render needs this
|
||||
//
|
||||
|
@ -509,6 +534,54 @@ static void P_LoadSegs(lumpnum_t lumpnum)
|
|||
Z_Free(data);
|
||||
}
|
||||
|
||||
static void P_LoadRawSegs(UINT8 *data, size_t i)
|
||||
{
|
||||
INT32 linedef, side;
|
||||
mapseg_t *ml;
|
||||
seg_t *li;
|
||||
line_t *ldef;
|
||||
|
||||
numsegs = i / sizeof (mapseg_t);
|
||||
if (numsegs <= 0)
|
||||
I_Error("Level has no segs"); // instead of crashing
|
||||
segs = Z_Calloc(numsegs * sizeof (*segs), PU_LEVEL, NULL);
|
||||
|
||||
ml = (mapseg_t *)data;
|
||||
li = segs;
|
||||
for (i = 0; i < numsegs; i++, li++, ml++)
|
||||
{
|
||||
li->v1 = &vertexes[SHORT(ml->v1)];
|
||||
li->v2 = &vertexes[SHORT(ml->v2)];
|
||||
|
||||
#ifdef HWRENDER // not win32 only 19990829 by Kin
|
||||
// used for the hardware render
|
||||
if (rendermode != render_soft && rendermode != render_none)
|
||||
{
|
||||
li->flength = P_SegLengthf(li);
|
||||
//Hurdler: 04/12/2000: for now, only used in hardware mode
|
||||
li->lightmaps = NULL; // list of static lightmap for this seg
|
||||
}
|
||||
#endif
|
||||
|
||||
li->angle = (SHORT(ml->angle))<<FRACBITS;
|
||||
li->offset = (SHORT(ml->offset))<<FRACBITS;
|
||||
linedef = SHORT(ml->linedef);
|
||||
ldef = &lines[linedef];
|
||||
li->linedef = ldef;
|
||||
li->side = side = SHORT(ml->side);
|
||||
li->sidedef = &sides[ldef->sidenum[side]];
|
||||
li->frontsector = sides[ldef->sidenum[side]].sector;
|
||||
if (ldef-> flags & ML_TWOSIDED)
|
||||
li->backsector = sides[ldef->sidenum[side^1]].sector;
|
||||
else
|
||||
li->backsector = 0;
|
||||
|
||||
li->numlights = 0;
|
||||
li->rlights = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Loads the SSECTORS resource from a level.
|
||||
*
|
||||
* \param lump Lump number of the SSECTORS resource.
|
||||
|
@ -543,6 +616,30 @@ static inline void P_LoadSubsectors(lumpnum_t lumpnum)
|
|||
Z_Free(data);
|
||||
}
|
||||
|
||||
static inline void P_LoadRawSubsectors(void *data, size_t i)
|
||||
{
|
||||
mapsubsector_t *ms;
|
||||
subsector_t *ss;
|
||||
|
||||
numsubsectors = i / sizeof (mapsubsector_t);
|
||||
if (numsubsectors <= 0)
|
||||
I_Error("Level has no subsectors (did you forget to run it through a nodesbuilder?)");
|
||||
ss = subsectors = Z_Calloc(numsubsectors * sizeof (*subsectors), PU_LEVEL, NULL);
|
||||
|
||||
ms = (mapsubsector_t *)data;
|
||||
|
||||
for (i = 0; i < numsubsectors; i++, ss++, ms++)
|
||||
{
|
||||
ss->sector = NULL;
|
||||
ss->numlines = SHORT(ms->numsegs);
|
||||
ss->firstline = SHORT(ms->firstseg);
|
||||
#ifdef FLOORSPLATS
|
||||
ss->splats = NULL;
|
||||
#endif
|
||||
ss->validcount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// levelflats
|
||||
//
|
||||
|
@ -780,6 +877,111 @@ static void P_LoadSectors(lumpnum_t lumpnum)
|
|||
P_SetupLevelFlatAnims();
|
||||
}
|
||||
|
||||
static void P_LoadRawSectors(UINT8 *data, size_t i)
|
||||
{
|
||||
mapsector_t *ms;
|
||||
sector_t *ss;
|
||||
levelflat_t *foundflats;
|
||||
|
||||
// We count how many sectors we got.
|
||||
numsectors = i / sizeof (mapsector_t);
|
||||
if (numsectors <= 0)
|
||||
I_Error("Level has no sectors");
|
||||
|
||||
// Allocate as much memory as we need into the global sectors table.
|
||||
sectors = Z_Calloc(numsectors*sizeof (*sectors), PU_LEVEL, NULL);
|
||||
|
||||
// Allocate a big chunk of memory as big as our MAXLEVELFLATS limit.
|
||||
//Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty
|
||||
foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats));
|
||||
if (foundflats == NULL)
|
||||
I_Error("Ran out of memory while loading sectors\n");
|
||||
|
||||
numlevelflats = 0;
|
||||
|
||||
// For each counted sector, copy the sector raw data from our cache pointer ms, to the global table pointer ss.
|
||||
ms = (mapsector_t *)data;
|
||||
ss = sectors;
|
||||
for (i = 0; i < numsectors; i++, ss++, ms++)
|
||||
{
|
||||
ss->floorheight = SHORT(ms->floorheight)<<FRACBITS;
|
||||
ss->ceilingheight = SHORT(ms->ceilingheight)<<FRACBITS;
|
||||
|
||||
ss->floorpic = P_AddLevelFlat(ms->floorpic, foundflats);
|
||||
ss->ceilingpic = P_AddLevelFlat(ms->ceilingpic, foundflats);
|
||||
|
||||
ss->lightlevel = SHORT(ms->lightlevel);
|
||||
ss->special = SHORT(ms->special);
|
||||
ss->tag = SHORT(ms->tag);
|
||||
ss->nexttag = ss->firsttag = -1;
|
||||
ss->spawn_nexttag = ss->spawn_firsttag = -1;
|
||||
|
||||
memset(&ss->soundorg, 0, sizeof(ss->soundorg));
|
||||
ss->validcount = 0;
|
||||
|
||||
ss->thinglist = NULL;
|
||||
ss->touching_thinglist = NULL;
|
||||
ss->preciplist = NULL;
|
||||
ss->touching_preciplist = NULL;
|
||||
|
||||
ss->floordata = NULL;
|
||||
ss->ceilingdata = NULL;
|
||||
ss->lightingdata = NULL;
|
||||
|
||||
ss->linecount = 0;
|
||||
ss->lines = NULL;
|
||||
|
||||
ss->heightsec = -1;
|
||||
ss->camsec = -1;
|
||||
ss->floorlightsec = -1;
|
||||
ss->ceilinglightsec = -1;
|
||||
ss->crumblestate = 0;
|
||||
ss->ffloors = NULL;
|
||||
ss->lightlist = NULL;
|
||||
ss->numlights = 0;
|
||||
ss->attached = NULL;
|
||||
ss->attachedsolid = NULL;
|
||||
ss->numattached = 0;
|
||||
ss->maxattached = 1;
|
||||
ss->moved = true;
|
||||
|
||||
ss->extra_colormap = NULL;
|
||||
|
||||
ss->floor_xoffs = ss->ceiling_xoffs = ss->floor_yoffs = ss->ceiling_yoffs = 0;
|
||||
ss->spawn_flr_xoffs = ss->spawn_ceil_xoffs = ss->spawn_flr_yoffs = ss->spawn_ceil_yoffs = 0;
|
||||
ss->floorpic_angle = ss->ceilingpic_angle = 0;
|
||||
ss->spawn_flrpic_angle = ss->spawn_ceilpic_angle = 0;
|
||||
ss->bottommap = ss->midmap = ss->topmap = -1;
|
||||
ss->gravity = NULL;
|
||||
ss->cullheight = NULL;
|
||||
ss->verticalflip = false;
|
||||
ss->flags = 0;
|
||||
ss->flags |= SF_FLIPSPECIAL_FLOOR;
|
||||
|
||||
ss->floorspeed = 0;
|
||||
ss->ceilspeed = 0;
|
||||
|
||||
#ifdef HWRENDER // ----- for special tricks with HW renderer -----
|
||||
ss->pseudoSector = false;
|
||||
ss->virtualFloor = false;
|
||||
ss->virtualCeiling = false;
|
||||
ss->sectorLines = NULL;
|
||||
ss->stackList = NULL;
|
||||
ss->lineoutLength = -1.0l;
|
||||
#endif // ----- end special tricks -----
|
||||
}
|
||||
|
||||
// set the sky flat num
|
||||
skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats);
|
||||
|
||||
// copy table for global usage
|
||||
levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t));
|
||||
free(foundflats);
|
||||
|
||||
// search for animated flats and set up
|
||||
P_SetupLevelFlatAnims();
|
||||
}
|
||||
|
||||
//
|
||||
// P_LoadNodes
|
||||
//
|
||||
|
@ -817,6 +1019,36 @@ static void P_LoadNodes(lumpnum_t lumpnum)
|
|||
Z_Free(data);
|
||||
}
|
||||
|
||||
static void P_LoadRawNodes(UINT8 *data, size_t i)
|
||||
{
|
||||
UINT8 j, k;
|
||||
mapnode_t *mn;
|
||||
node_t *no;
|
||||
|
||||
numnodes = i / sizeof (mapnode_t);
|
||||
if (numnodes <= 0)
|
||||
I_Error("Level has no nodes");
|
||||
nodes = Z_Calloc(numnodes * sizeof (*nodes), PU_LEVEL, NULL);
|
||||
|
||||
mn = (mapnode_t *)data;
|
||||
no = nodes;
|
||||
|
||||
for (i = 0; i < numnodes; i++, no++, mn++)
|
||||
{
|
||||
no->x = SHORT(mn->x)<<FRACBITS;
|
||||
no->y = SHORT(mn->y)<<FRACBITS;
|
||||
no->dx = SHORT(mn->dx)<<FRACBITS;
|
||||
no->dy = SHORT(mn->dy)<<FRACBITS;
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
no->children[j] = SHORT(mn->children[j]);
|
||||
for (k = 0; k < 4; k++)
|
||||
no->bbox[j][k] = SHORT(mn->bbox[j][k])<<FRACBITS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// P_ReloadRings
|
||||
// Used by NiGHTS, clears all ring/wing/etc items and respawns them
|
||||
|
@ -988,6 +1220,43 @@ static void P_PrepareThings(lumpnum_t lumpnum)
|
|||
|
||||
}
|
||||
|
||||
static void P_PrepareRawThings(UINT8 *data, size_t i)
|
||||
{
|
||||
mapthing_t *mt;
|
||||
UINT8 *datastart;
|
||||
|
||||
nummapthings = i / (5 * sizeof (INT16));
|
||||
mapthings = Z_Calloc(nummapthings * sizeof (*mapthings), PU_LEVEL, NULL);
|
||||
|
||||
// Spawn axis points first so they are
|
||||
// at the front of the list for fast searching.
|
||||
datastart = data;
|
||||
mt = mapthings;
|
||||
for (i = 0; i < nummapthings; i++, mt++)
|
||||
{
|
||||
mt->x = READINT16(data);
|
||||
mt->y = READINT16(data);
|
||||
mt->angle = READINT16(data);
|
||||
mt->type = READUINT16(data);
|
||||
mt->options = READUINT16(data);
|
||||
mt->extrainfo = (UINT8)(mt->type >> 12);
|
||||
|
||||
mt->type &= 4095;
|
||||
|
||||
switch (mt->type)
|
||||
{
|
||||
case 1700: // MT_AXIS
|
||||
case 1701: // MT_AXISTRANSFER
|
||||
case 1702: // MT_AXISTRANSFERLINE
|
||||
mt->mobj = NULL;
|
||||
P_SpawnMapThing(mt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void P_LoadThings(void)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -1287,6 +1556,113 @@ static void P_LoadLineDefs(lumpnum_t lumpnum)
|
|||
Z_Free(data);
|
||||
}
|
||||
|
||||
static void P_LoadRawLineDefs(UINT8 *data, size_t i)
|
||||
{
|
||||
maplinedef_t *mld;
|
||||
line_t *ld;
|
||||
vertex_t *v1, *v2;
|
||||
|
||||
numlines = i / sizeof (maplinedef_t);
|
||||
if (numlines <= 0)
|
||||
I_Error("Level has no linedefs");
|
||||
lines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL);
|
||||
|
||||
mld = (maplinedef_t *)data;
|
||||
ld = lines;
|
||||
for (i = 0; i < numlines; i++, mld++, ld++)
|
||||
{
|
||||
ld->flags = SHORT(mld->flags);
|
||||
ld->special = SHORT(mld->special);
|
||||
ld->tag = SHORT(mld->tag);
|
||||
v1 = ld->v1 = &vertexes[SHORT(mld->v1)];
|
||||
v2 = ld->v2 = &vertexes[SHORT(mld->v2)];
|
||||
ld->dx = v2->x - v1->x;
|
||||
ld->dy = v2->y - v1->y;
|
||||
|
||||
#ifdef WALLSPLATS
|
||||
ld->splats = NULL;
|
||||
#endif
|
||||
|
||||
if (!ld->dx)
|
||||
ld->slopetype = ST_VERTICAL;
|
||||
else if (!ld->dy)
|
||||
ld->slopetype = ST_HORIZONTAL;
|
||||
else if (FixedDiv(ld->dy, ld->dx) > 0)
|
||||
ld->slopetype = ST_POSITIVE;
|
||||
else
|
||||
ld->slopetype = ST_NEGATIVE;
|
||||
|
||||
if (v1->x < v2->x)
|
||||
{
|
||||
ld->bbox[BOXLEFT] = v1->x;
|
||||
ld->bbox[BOXRIGHT] = v2->x;
|
||||
}
|
||||
else
|
||||
{
|
||||
ld->bbox[BOXLEFT] = v2->x;
|
||||
ld->bbox[BOXRIGHT] = v1->x;
|
||||
}
|
||||
|
||||
if (v1->y < v2->y)
|
||||
{
|
||||
ld->bbox[BOXBOTTOM] = v1->y;
|
||||
ld->bbox[BOXTOP] = v2->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ld->bbox[BOXBOTTOM] = v2->y;
|
||||
ld->bbox[BOXTOP] = v1->y;
|
||||
}
|
||||
|
||||
ld->sidenum[0] = SHORT(mld->sidenum[0]);
|
||||
ld->sidenum[1] = SHORT(mld->sidenum[1]);
|
||||
|
||||
{
|
||||
// cph 2006/09/30 - fix sidedef errors right away.
|
||||
// cph 2002/07/20 - these errors are fatal if not fixed, so apply them
|
||||
UINT8 j;
|
||||
|
||||
for (j=0; j < 2; j++)
|
||||
{
|
||||
if (ld->sidenum[j] != 0xffff && ld->sidenum[j] >= (UINT16)numsides)
|
||||
{
|
||||
ld->sidenum[j] = 0xffff;
|
||||
CONS_Debug(DBG_SETUP, "P_LoadLineDefs: linedef %s has out-of-range sidedef number\n", sizeu1(numlines-i-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ld->frontsector = ld->backsector = NULL;
|
||||
ld->validcount = 0;
|
||||
ld->firsttag = ld->nexttag = -1;
|
||||
ld->callcount = 0;
|
||||
// killough 11/98: fix common wad errors (missing sidedefs):
|
||||
|
||||
if (ld->sidenum[0] == 0xffff)
|
||||
{
|
||||
ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side
|
||||
// cph - print a warning about the bug
|
||||
CONS_Debug(DBG_SETUP, "P_LoadLineDefs: linedef %s missing first sidedef\n", sizeu1(numlines-i-1));
|
||||
}
|
||||
|
||||
if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED))
|
||||
{
|
||||
ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side
|
||||
// cph - print a warning about the bug
|
||||
CONS_Debug(DBG_SETUP, "P_LoadLineDefs: linedef %s has two-sided flag set, but no second sidedef\n", sizeu1(numlines-i-1));
|
||||
}
|
||||
|
||||
if (ld->sidenum[0] != 0xffff && ld->special)
|
||||
sides[ld->sidenum[0]].special = ld->special;
|
||||
if (ld->sidenum[1] != 0xffff && ld->special)
|
||||
sides[ld->sidenum[1]].special = ld->special;
|
||||
|
||||
#ifdef POLYOBJECTS
|
||||
ld->polyobj = NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void P_LoadLineDefs2(void)
|
||||
{
|
||||
size_t i = numlines;
|
||||
|
@ -1396,6 +1772,14 @@ static inline void P_LoadSideDefs(lumpnum_t lumpnum)
|
|||
sides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL);
|
||||
}
|
||||
|
||||
static inline void P_LoadRawSideDefs(size_t i)
|
||||
{
|
||||
numsides = i / sizeof (mapsidedef_t);
|
||||
if (numsides <= 0)
|
||||
I_Error("Level has no sidedefs");
|
||||
sides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL);
|
||||
}
|
||||
|
||||
// Delay loading texture names until after loaded linedefs.
|
||||
|
||||
static void P_LoadSideDefs2(lumpnum_t lumpnum)
|
||||
|
@ -1636,6 +2020,244 @@ static void P_LoadSideDefs2(lumpnum_t lumpnum)
|
|||
R_ClearTextureNumCache(true);
|
||||
}
|
||||
|
||||
// I'm sorry about all this duplicity with little change :( -Nev3r
|
||||
static void P_LoadRawSideDefs2(void *data)
|
||||
{
|
||||
UINT16 i;
|
||||
INT32 num;
|
||||
|
||||
for (i = 0; i < numsides; i++)
|
||||
{
|
||||
register mapsidedef_t *msd = (mapsidedef_t *)data + i;
|
||||
register side_t *sd = sides + i;
|
||||
register sector_t *sec;
|
||||
|
||||
sd->textureoffset = SHORT(msd->textureoffset)<<FRACBITS;
|
||||
sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS;
|
||||
|
||||
{ /* cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead */
|
||||
UINT16 sector_num = SHORT(msd->sector);
|
||||
|
||||
if (sector_num >= numsectors)
|
||||
{
|
||||
CONS_Debug(DBG_SETUP, "P_LoadSideDefs2: sidedef %u has out-of-range sector num %u\n", i, sector_num);
|
||||
sector_num = 0;
|
||||
}
|
||||
sd->sector = sec = §ors[sector_num];
|
||||
}
|
||||
|
||||
// refined to allow colormaps to work as wall textures if invalid as colormaps
|
||||
// but valid as textures.
|
||||
|
||||
sd->sector = sec = §ors[SHORT(msd->sector)];
|
||||
|
||||
// Colormaps!
|
||||
switch (sd->special)
|
||||
{
|
||||
case 63: // variable colormap via 242 linedef
|
||||
case 606: //SoM: 4/4/2000: Just colormap transfer
|
||||
// SoM: R_CreateColormap will only create a colormap in software mode...
|
||||
// Perhaps we should just call it instead of doing the calculations here.
|
||||
if (rendermode == render_soft || rendermode == render_none)
|
||||
{
|
||||
if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')
|
||||
{
|
||||
sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture,
|
||||
msd->bottomtexture);
|
||||
sd->toptexture = sd->bottomtexture = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1)
|
||||
sd->toptexture = 0;
|
||||
else
|
||||
sd->toptexture = num;
|
||||
if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1)
|
||||
sd->midtexture = 0;
|
||||
else
|
||||
sd->midtexture = num;
|
||||
if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1)
|
||||
sd->bottomtexture = 0;
|
||||
else
|
||||
sd->bottomtexture = num;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef HWRENDER
|
||||
else
|
||||
{
|
||||
// for now, full support of toptexture only
|
||||
if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6])
|
||||
|| (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]))
|
||||
{
|
||||
char *col;
|
||||
|
||||
sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture,
|
||||
msd->bottomtexture);
|
||||
sd->toptexture = sd->bottomtexture = 0;
|
||||
#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0)
|
||||
#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0)
|
||||
sec->extra_colormap = &extra_colormaps[sec->midmap];
|
||||
|
||||
if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6])
|
||||
{
|
||||
col = msd->toptexture;
|
||||
|
||||
sec->extra_colormap->rgba =
|
||||
(HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) +
|
||||
(HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) +
|
||||
(HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16);
|
||||
|
||||
// alpha
|
||||
if (msd->toptexture[7])
|
||||
sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24);
|
||||
else
|
||||
sec->extra_colormap->rgba += (25 << 24);
|
||||
}
|
||||
else
|
||||
sec->extra_colormap->rgba = 0;
|
||||
|
||||
if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])
|
||||
{
|
||||
col = msd->bottomtexture;
|
||||
|
||||
sec->extra_colormap->fadergba =
|
||||
(HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) +
|
||||
(HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) +
|
||||
(HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16);
|
||||
|
||||
// alpha
|
||||
if (msd->bottomtexture[7])
|
||||
sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24);
|
||||
else
|
||||
sec->extra_colormap->fadergba += (25 << 24);
|
||||
}
|
||||
else
|
||||
sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24)
|
||||
#undef ALPHA2INT
|
||||
#undef HEX2INT
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1)
|
||||
sd->toptexture = 0;
|
||||
else
|
||||
sd->toptexture = num;
|
||||
|
||||
if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1)
|
||||
sd->midtexture = 0;
|
||||
else
|
||||
sd->midtexture = num;
|
||||
|
||||
if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1)
|
||||
sd->bottomtexture = 0;
|
||||
else
|
||||
sd->bottomtexture = num;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case 413: // Change music
|
||||
{
|
||||
char process[8+1];
|
||||
|
||||
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
||||
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
|
||||
{
|
||||
M_Memcpy(process,msd->bottomtexture,8);
|
||||
process[8] = '\0';
|
||||
sd->bottomtexture = get_number(process)-1;
|
||||
}
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
process[8] = '\0';
|
||||
sd->text = Z_Malloc(7, PU_LEVEL, NULL);
|
||||
|
||||
// If they type in O_ or D_ and their music name, just shrug,
|
||||
// then copy the rest instead.
|
||||
if ((process[0] == 'O' || process[0] == 'D') && process[7])
|
||||
M_Memcpy(sd->text, process+2, 6);
|
||||
else // Assume it's a proper music name.
|
||||
M_Memcpy(sd->text, process, 6);
|
||||
sd->text[6] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case 4: // Speed pad parameters
|
||||
case 414: // Play SFX
|
||||
{
|
||||
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
||||
if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0')
|
||||
{
|
||||
char process[8+1];
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
process[8] = '\0';
|
||||
sd->toptexture = get_number(process);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 14: // Bustable block parameters
|
||||
case 15: // Fan particle spawner parameters
|
||||
case 425: // Calls P_SetMobjState on calling mobj
|
||||
case 434: // Custom Power
|
||||
case 442: // Calls P_SetMobjState on mobjs of a given type in the tagged sectors
|
||||
{
|
||||
char process[8*3+1];
|
||||
memset(process,0,8*3+1);
|
||||
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
||||
if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')
|
||||
break;
|
||||
else
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0')
|
||||
M_Memcpy(process+strlen(process), msd->midtexture, 8);
|
||||
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
|
||||
M_Memcpy(process+strlen(process), msd->bottomtexture, 8);
|
||||
sd->toptexture = get_number(process);
|
||||
break;
|
||||
}
|
||||
|
||||
case 443: // Calls a named Lua function
|
||||
{
|
||||
char process[8*3+1];
|
||||
memset(process,0,8*3+1);
|
||||
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
||||
if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')
|
||||
break;
|
||||
else
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0')
|
||||
M_Memcpy(process+strlen(process), msd->midtexture, 8);
|
||||
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
|
||||
M_Memcpy(process+strlen(process), msd->bottomtexture, 8);
|
||||
sd->text = Z_Malloc(strlen(process)+1, PU_LEVEL, NULL);
|
||||
M_Memcpy(sd->text, process, strlen(process)+1);
|
||||
break;
|
||||
}
|
||||
|
||||
default: // normal cases
|
||||
if (msd->toptexture[0] == '#')
|
||||
{
|
||||
char *col = msd->toptexture;
|
||||
sd->toptexture = sd->bottomtexture =
|
||||
((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0') + 1;
|
||||
sd->midtexture = R_TextureNumForName(msd->midtexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
sd->midtexture = R_TextureNumForName(msd->midtexture);
|
||||
sd->toptexture = R_TextureNumForName(msd->toptexture);
|
||||
sd->bottomtexture = R_TextureNumForName(msd->bottomtexture);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
R_ClearTextureNumCache(true);
|
||||
}
|
||||
|
||||
|
||||
static boolean LineInBlock(fixed_t cx1, fixed_t cy1, fixed_t cx2, fixed_t cy2, fixed_t bx1, fixed_t by1)
|
||||
{
|
||||
fixed_t bbox[4];
|
||||
|
@ -2524,6 +3146,7 @@ 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
|
||||
boolean isLumpWad = false; // Is the lump a marker or actually a WAD file of its own? (For PK3s)
|
||||
INT32 i, loadprecip = 1, ranspecialwipe = 0;
|
||||
INT32 loademblems = 1;
|
||||
INT32 fromnetsave = 0;
|
||||
|
@ -2685,7 +3308,54 @@ boolean P_SetupLevel(boolean skipprecip)
|
|||
}
|
||||
|
||||
// internal game map
|
||||
lastloadedmaplumpnum = W_GetNumForName(maplumpname = G_BuildMapName(gamemap));
|
||||
maplumpname = G_BuildMapName(gamemap);
|
||||
lastloadedmaplumpnum = LUMPERROR;
|
||||
|
||||
// Look for valid map data through all added files in descendant order.
|
||||
// Get a map marker for WADs, and a standalone WAD file lump inside PK3s.
|
||||
// TODO: Make it search through cache first, maybe...?
|
||||
// TODO: Also move it to w_wad.c as a function...?
|
||||
for (i = numwadfiles - 1; i >= 0; i--)
|
||||
{
|
||||
if (wadfiles[i]->type == RET_WAD)
|
||||
{
|
||||
UINT16 lumpNum;
|
||||
for (lumpNum = 0; lumpNum < wadfiles[i]->numlumps; lumpNum++)
|
||||
{
|
||||
if (!strncmp(maplumpname, (wadfiles[i]->lumpinfo + lumpNum)->name, 8))
|
||||
{
|
||||
lastloadedmaplumpnum = (i<<16) + lumpNum;
|
||||
CONS_Printf("WAD %s has a map marker named %s.\n", wadfiles[i]->filename, maplumpname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (wadfiles[i]->type == RET_PK3)
|
||||
{
|
||||
// Look for the maps folder.
|
||||
UINT16 lumpNum, end;
|
||||
lumpNum = W_CheckNumForFullNamePK3("maps/", i, 0);
|
||||
if (lumpNum != INT16_MAX)
|
||||
end = W_CheckNumForFolderEndPK3("maps/", i, lumpNum);
|
||||
else
|
||||
continue;
|
||||
|
||||
// Now look for the specified map.
|
||||
for (++lumpNum; lumpNum < end; lumpNum++)
|
||||
if (!strnicmp(maplumpname, (wadfiles[i]->lumpinfo + lumpNum)->name, 5))
|
||||
{
|
||||
isLumpWad = true;
|
||||
lastloadedmaplumpnum = (i<<16) + lumpNum;
|
||||
CONS_Printf("PK3 %s has a map WAD named %s.\n", wadfiles[i]->filename, maplumpname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(lastloadedmaplumpnum == LUMPERROR)) // Stop looking if we found a valid lump.
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastloadedmaplumpnum == INT16_MAX)
|
||||
I_Error("Map %s not found.\n", maplumpname);
|
||||
|
||||
R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette);
|
||||
CON_SetupBackColormap();
|
||||
|
@ -2695,39 +3365,93 @@ boolean P_SetupLevel(boolean skipprecip)
|
|||
|
||||
P_MakeMapMD5(lastloadedmaplumpnum, &mapmd5);
|
||||
|
||||
// note: most of this ordering is important
|
||||
loadedbm = P_LoadBlockMap(lastloadedmaplumpnum + ML_BLOCKMAP);
|
||||
|
||||
P_LoadVertexes(lastloadedmaplumpnum + ML_VERTEXES);
|
||||
P_LoadSectors(lastloadedmaplumpnum + ML_SECTORS);
|
||||
// HACK ALERT: Cache the WAD, get the map data into the table, free memory.
|
||||
// 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.)
|
||||
// Basically this is a nerfed&modified version of W_InitFile from w_wad.
|
||||
if (isLumpWad)
|
||||
{
|
||||
UINT16 i;
|
||||
wadinfo_t *header;
|
||||
filelump_t *fileinfo;
|
||||
UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC);
|
||||
header = (wadinfo_t *)wadData;
|
||||
CONS_Printf("This map WAD contains %lu lumps.\n", header->numlumps);
|
||||
|
||||
P_LoadSideDefs(lastloadedmaplumpnum + ML_SIDEDEFS);
|
||||
fileinfo = wadData + header->infotableofs;
|
||||
for(i = 0; i < header->numlumps; i++, fileinfo++)
|
||||
{
|
||||
char name[9];
|
||||
memcpy(name, fileinfo->name, 8);
|
||||
name[8] = '\0';
|
||||
CONS_Printf("%s, size %lu\n", name, fileinfo->size);
|
||||
}
|
||||
fileinfo = wadData + header->infotableofs;
|
||||
|
||||
P_LoadLineDefs(lastloadedmaplumpnum + ML_LINEDEFS);
|
||||
if (!loadedbm)
|
||||
P_CreateBlockMap(); // Graue 02-29-2004
|
||||
P_LoadSideDefs2(lastloadedmaplumpnum + ML_SIDEDEFS);
|
||||
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);
|
||||
P_LoadRawLineDefs(wadData + (fileinfo + ML_LINEDEFS)->filepos, (fileinfo + ML_LINEDEFS)->size);
|
||||
P_LoadRawSideDefs2(wadData + (fileinfo + ML_SIDEDEFS)->filepos);
|
||||
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);
|
||||
// P_LoadReject(lastloadedmaplumpnum + ML_REJECT);
|
||||
|
||||
R_MakeColormaps();
|
||||
P_LoadLineDefs2();
|
||||
P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS);
|
||||
P_LoadNodes(lastloadedmaplumpnum + ML_NODES);
|
||||
P_LoadSegs(lastloadedmaplumpnum + ML_SEGS);
|
||||
P_LoadReject(lastloadedmaplumpnum + ML_REJECT);
|
||||
P_GroupLines();
|
||||
// Important: take care of the ordering of the next functions.
|
||||
if (!loadedbm)
|
||||
P_CreateBlockMap(); // Graue 02-29-2004
|
||||
R_MakeColormaps();
|
||||
P_LoadLineDefs2();
|
||||
P_GroupLines();
|
||||
numdmstarts = numredctfstarts = numbluectfstarts = 0;
|
||||
|
||||
numdmstarts = numredctfstarts = numbluectfstarts = 0;
|
||||
// reset the player starts
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
playerstarts[i] = NULL;
|
||||
|
||||
// reset the player starts
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
playerstarts[i] = NULL;
|
||||
for (i = 0; i < 2; i++)
|
||||
skyboxmo[i] = NULL;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
skyboxmo[i] = NULL;
|
||||
P_MapStart();
|
||||
|
||||
P_MapStart();
|
||||
P_PrepareRawThings(wadData + (fileinfo + ML_THINGS)->filepos, (fileinfo + ML_THINGS)->size);
|
||||
Z_Free(wadData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Important: take care of the ordering of the next functions.
|
||||
loadedbm = P_LoadBlockMap(lastloadedmaplumpnum + ML_BLOCKMAP);
|
||||
P_LoadVertexes(lastloadedmaplumpnum + ML_VERTEXES);
|
||||
P_LoadSectors(lastloadedmaplumpnum + ML_SECTORS);
|
||||
P_LoadSideDefs(lastloadedmaplumpnum + ML_SIDEDEFS);
|
||||
P_LoadLineDefs(lastloadedmaplumpnum + ML_LINEDEFS);
|
||||
P_LoadSideDefs2(lastloadedmaplumpnum + ML_SIDEDEFS);
|
||||
P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS);
|
||||
P_LoadNodes(lastloadedmaplumpnum + ML_NODES);
|
||||
P_LoadSegs(lastloadedmaplumpnum + ML_SEGS);
|
||||
P_LoadReject(lastloadedmaplumpnum + ML_REJECT);
|
||||
|
||||
P_PrepareThings(lastloadedmaplumpnum + ML_THINGS);
|
||||
// Important: take care of the ordering of the next functions.
|
||||
if (!loadedbm)
|
||||
P_CreateBlockMap(); // Graue 02-29-2004
|
||||
R_MakeColormaps();
|
||||
P_LoadLineDefs2();
|
||||
P_GroupLines();
|
||||
numdmstarts = numredctfstarts = numbluectfstarts = 0;
|
||||
|
||||
// reset the player starts
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
playerstarts[i] = NULL;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
skyboxmo[i] = NULL;
|
||||
|
||||
P_MapStart();
|
||||
|
||||
P_PrepareThings(lastloadedmaplumpnum + ML_THINGS);
|
||||
}
|
||||
|
||||
#ifdef ESLOPE
|
||||
P_ResetDynamicSlopes();
|
||||
|
@ -3079,6 +3803,32 @@ void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num)
|
|||
return;
|
||||
}
|
||||
|
||||
// Auxiliary function for PK3 loading - adds extra lumps
|
||||
// NOTE: does nothing but print debug messages.
|
||||
/*void P_LoadWadMapRange(UINT16 wadnum, UINT16 first, UINT16 num)
|
||||
{
|
||||
lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo + first;
|
||||
CONS_Printf("First %s\n", lumpinfo->name2);
|
||||
for (; num > 0; num--, first++, lumpinfo++)
|
||||
{
|
||||
wadinfo_t header;
|
||||
void* wadCache = Z_Malloc(W_LumpLengthPwad(wadnum, first), PU_STATIC, NULL);
|
||||
W_ReadLumpHeaderPwad(wadnum, first, wadCache, 0, 0);
|
||||
// We put the header info into our header var.
|
||||
memcpy(header, wadCache, sizeof header);
|
||||
|
||||
header.numlumps = LONG(header.numlumps);
|
||||
header.infotableofs = LONG(header.infotableofs);
|
||||
lumpinfo = (lumpinfo_t*) Z_Realloc(lumpinfo, (numlumps + 1)*sizeof(*lumpinfo), PU_STATIC, NULL);
|
||||
|
||||
|
||||
Z_Free(wadCache);
|
||||
CONS_Printf("Decached map WAD stuff.\n");
|
||||
}
|
||||
return;
|
||||
}*/
|
||||
|
||||
|
||||
//
|
||||
// Add a wadfile to the active wad files,
|
||||
// replace sounds, musics, patches, textures, sprites and maps
|
||||
|
@ -3095,16 +3845,17 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
|
|||
// Vars to help us with the position start and amount of each resource type.
|
||||
// Useful for PK3s since they use folders.
|
||||
// WADs use markers for some resources, but others such as sounds are checked lump-by-lump anyway.
|
||||
UINT16 luaPos, luaNum = 0;
|
||||
UINT16 socPos, socNum = 0;
|
||||
// UINT16 luaPos, luaNum = 0;
|
||||
// UINT16 socPos, socNum = 0;
|
||||
UINT16 sfxPos, sfxNum = 0;
|
||||
UINT16 musPos, musNum = 0;
|
||||
UINT16 sprPos, sprNum = 0;
|
||||
UINT16 texPos, texNum = 0;
|
||||
// UINT16 patPos, patNum = 0;
|
||||
// UINT16 flaPos, flaNum = 0;
|
||||
// UINT16 mapPos, mapNum = 0;
|
||||
UINT16 mapPos, mapNum = 0;
|
||||
|
||||
// Init file.
|
||||
if ((numlumps = W_InitFile(wadfilename)) == INT16_MAX)
|
||||
{
|
||||
CONS_Printf(M_GetText("Errors occured while loading %s; not added.\n"), wadfilename);
|
||||
|
@ -3133,7 +3884,6 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
|
|||
}
|
||||
lumpinfo--;
|
||||
*end = i-- - *start;
|
||||
CONS_Printf("Folder %s, first lump %lu, total: %lu.\n", folName, *start, *end);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
@ -3143,35 +3893,35 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
|
|||
lumpinfo = wadfiles[wadnum]->lumpinfo;
|
||||
for (i = 0; i < numlumps; i++, lumpinfo++)
|
||||
{
|
||||
FindFolder("Lua/", &luaPos, &luaNum);
|
||||
FindFolder("Soc/", &socPos, &socNum);
|
||||
// FindFolder("Lua/", &luaPos, &luaNum);
|
||||
// FindFolder("SOCs/", &socPos, &socNum);
|
||||
FindFolder("Sounds/", &sfxPos, &sfxNum);
|
||||
FindFolder("Music/", &musPos, &musNum);
|
||||
FindFolder("Sprites/", &sprPos, &sprNum);
|
||||
FindFolder("Textures/", &texPos, &texNum);
|
||||
// FindFolder("Patches/", &patPos, &patNum);
|
||||
// FindFolder("Flats/", &flaPos, &flaNum);
|
||||
// FindFolder("Maps/", &mapPos, &mapNum);
|
||||
FindFolder("Maps/", &mapPos, &mapNum);
|
||||
}
|
||||
|
||||
// Update the detected resources.
|
||||
// Note: ALWAYS load Lua scripts first, SOCs right after, and the remaining resources afterwards.
|
||||
#ifdef HAVE_BLUA
|
||||
if (luaNum) // Lua scripts.
|
||||
P_LoadLuaScrRange(wadnum, luaPos, luaNum);
|
||||
// if (luaNum) // Lua scripts.
|
||||
// P_LoadLuaScrRange(wadnum, luaPos, luaNum);
|
||||
#endif
|
||||
if (socNum) // SOCs.
|
||||
P_LoadDehackRange(wadnum, socPos, socNum);
|
||||
// if (socNum) // SOCs.
|
||||
// P_LoadDehackRange(wadnum, socPos, socNum);
|
||||
if (sfxNum) // Sounds. TODO: Function currently only updates already existing sounds, the rest is handled somewhere else.
|
||||
P_LoadSoundsRange(wadnum, sfxPos, sfxNum);
|
||||
if (musNum) // Music. TODO: Useless function right now.
|
||||
P_LoadMusicsRange(wadnum, musPos, musNum);
|
||||
if (sprNum) // Sprites.
|
||||
R_LoadSpritsRange(wadnum, sprPos, sprNum);
|
||||
if (texNum) // Textures. TODO: R_LoadTextures() does the folder positioning once again. New function maybe?
|
||||
R_LoadTextures();
|
||||
// if (texNum) // Textures. TODO: R_LoadTextures() does the folder positioning once again. New function maybe?
|
||||
// R_LoadTextures();
|
||||
// if (mapNum) // Maps. TODO: Actually implement the map WAD loading code, lulz.
|
||||
// P_LoadWadMapRange();
|
||||
// P_LoadWadMapRange(wadnum, mapPos, mapNum);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -284,7 +284,10 @@ void P_InitPicAnims(void)
|
|||
}
|
||||
|
||||
// Now find ANIMDEFS
|
||||
animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0);
|
||||
if (wadfiles[w]->type == RET_WAD)
|
||||
animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0);
|
||||
else if (wadfiles[w]->type == RET_PK3)
|
||||
animdefsLumpNum = W_CheckNumForFullNamePK3("ANIMDEFS", w, 0);
|
||||
if (animdefsLumpNum != INT16_MAX)
|
||||
P_ParseANIMDEFSLump(w, animdefsLumpNum);
|
||||
}
|
||||
|
|
29
src/r_data.c
29
src/r_data.c
|
@ -528,8 +528,8 @@ void R_FlushTextureCache(void)
|
|||
}
|
||||
|
||||
// Need these prototypes for later; defining them here instead of r_data.h so they're "private"
|
||||
int R_CountTexturesInTEXTURESLump(UINT16 wadNum);
|
||||
void R_ParseTEXTURESLump(UINT16 wadNum, INT32 *index);
|
||||
int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum);
|
||||
void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *index);
|
||||
|
||||
//
|
||||
// R_LoadTextures
|
||||
|
@ -582,7 +582,7 @@ void R_LoadTextures(void)
|
|||
|
||||
if (texturesLumpPos != INT16_MAX)
|
||||
{
|
||||
numtextures += R_CountTexturesInTEXTURESLump((UINT16)w);
|
||||
numtextures += R_CountTexturesInTEXTURESLump((UINT16)w, (UINT16)texturesLumpPos);
|
||||
}
|
||||
|
||||
// Add all the textures between TX_START and TX_END
|
||||
|
@ -623,16 +623,17 @@ void R_LoadTextures(void)
|
|||
{
|
||||
texstart = W_CheckNumForFullNamePK3("textures/", (UINT16)w, 0) + 1;
|
||||
texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart);
|
||||
texturesLumpPos = W_CheckNumForFullNamePK3("textures", (UINT16)w, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1;
|
||||
texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0);
|
||||
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
|
||||
}
|
||||
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
|
||||
|
||||
if (texturesLumpPos != INT16_MAX)
|
||||
R_ParseTEXTURESLump(w,&i);
|
||||
R_ParseTEXTURESLump(w, texturesLumpPos, &i);
|
||||
|
||||
if (texstart == INT16_MAX || texend == INT16_MAX)
|
||||
continue;
|
||||
|
@ -1041,7 +1042,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
|
|||
}
|
||||
|
||||
// Parses the TEXTURES lump... but just to count the number of textures.
|
||||
int R_CountTexturesInTEXTURESLump(UINT16 wadNum)
|
||||
int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum)
|
||||
{
|
||||
char *texturesLump;
|
||||
size_t texturesLumpLength;
|
||||
|
@ -1052,11 +1053,11 @@ int R_CountTexturesInTEXTURESLump(UINT16 wadNum)
|
|||
// Since lumps AREN'T \0-terminated like I'd assumed they should be, I'll
|
||||
// need to make a space of memory where I can ensure that it will terminate
|
||||
// correctly. Start by loading the relevant data from the WAD.
|
||||
texturesLump = (char *)W_CacheLumpNumPwad(wadNum,W_CheckNumForNamePwad("TEXTURES", wadNum, 0),PU_STATIC);
|
||||
texturesLump = (char *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC);
|
||||
// If that didn't exist, we have nothing to do here.
|
||||
if (texturesLump == NULL) return 0;
|
||||
// If we're still here, then it DOES exist; figure out how long it is, and allot memory accordingly.
|
||||
texturesLumpLength = W_LumpLengthPwad(wadNum,W_CheckNumForNamePwad("TEXTURES",wadNum,0));
|
||||
texturesLumpLength = W_LumpLengthPwad(wadNum, lumpNum);
|
||||
texturesText = (char *)Z_Malloc((texturesLumpLength+1)*sizeof(char),PU_STATIC,NULL);
|
||||
// Now move the contents of the lump into this new location.
|
||||
memmove(texturesText,texturesLump,texturesLumpLength);
|
||||
|
@ -1088,7 +1089,7 @@ int R_CountTexturesInTEXTURESLump(UINT16 wadNum)
|
|||
}
|
||||
|
||||
// Parses the TEXTURES lump... for real, this time.
|
||||
void R_ParseTEXTURESLump(UINT16 wadNum, INT32 *texindex)
|
||||
void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex)
|
||||
{
|
||||
char *texturesLump;
|
||||
size_t texturesLumpLength;
|
||||
|
@ -1101,11 +1102,11 @@ void R_ParseTEXTURESLump(UINT16 wadNum, INT32 *texindex)
|
|||
// Since lumps AREN'T \0-terminated like I'd assumed they should be, I'll
|
||||
// need to make a space of memory where I can ensure that it will terminate
|
||||
// correctly. Start by loading the relevant data from the WAD.
|
||||
texturesLump = (char *)W_CacheLumpNumPwad(wadNum,W_CheckNumForNamePwad("TEXTURES", wadNum, 0),PU_STATIC);
|
||||
texturesLump = (char *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC);
|
||||
// If that didn't exist, we have nothing to do here.
|
||||
if (texturesLump == NULL) return;
|
||||
// If we're still here, then it DOES exist; figure out how long it is, and allot memory accordingly.
|
||||
texturesLumpLength = W_LumpLengthPwad(wadNum,W_CheckNumForNamePwad("TEXTURES",wadNum,0));
|
||||
texturesLumpLength = W_LumpLengthPwad(wadNum, lumpNum);
|
||||
texturesText = (char *)Z_Malloc((texturesLumpLength+1)*sizeof(char),PU_STATIC,NULL);
|
||||
// Now move the contents of the lump into this new location.
|
||||
memmove(texturesText,texturesLump,texturesLumpLength);
|
||||
|
@ -1211,16 +1212,12 @@ lumpnum_t R_GetFlatNumForName(const char *name)
|
|||
{
|
||||
start = W_CheckNumForNamePwad("FF_START", (UINT16)i, 0);
|
||||
if (start == INT16_MAX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = W_CheckNumForNamePwad("FF_END", (UINT16)i, start);
|
||||
if (end == INT16_MAX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1297,7 +1294,7 @@ void R_ReInitColormaps(UINT16 num)
|
|||
{
|
||||
char colormap[9] = "COLORMAP";
|
||||
lumpnum_t lump;
|
||||
|
||||
CONS_Printf("Reinitting colormaps...\n");
|
||||
if (num > 0 && num <= 10000)
|
||||
snprintf(colormap, 8, "CLM%04u", num-1);
|
||||
|
||||
|
|
|
@ -409,31 +409,42 @@ void R_AddSpriteDefs(UINT16 wadnum)
|
|||
UINT16 start, end;
|
||||
char wadname[MAX_WADPATH];
|
||||
|
||||
// find the sprites section in this pwad
|
||||
// we need at least the S_END
|
||||
// (not really, but for speedup)
|
||||
// Find the sprites section in this resource file.
|
||||
if (wadfiles[wadnum]->type == RET_WAD)
|
||||
{
|
||||
start = W_CheckNumForNamePwad("S_START", wadnum, 0);
|
||||
if (start == UINT16_MAX)
|
||||
start = W_CheckNumForNamePwad("SS_START", wadnum, 0); //deutex compatib.
|
||||
}
|
||||
else if (wadfiles[wadnum]->type == RET_PK3)
|
||||
start = W_CheckNumForFullNamePK3("Sprites/", wadnum, 0);
|
||||
|
||||
start = W_CheckNumForNamePwad("S_START", wadnum, 0);
|
||||
if (start == INT16_MAX)
|
||||
start = W_CheckNumForNamePwad("SS_START", wadnum, 0); //deutex compatib.
|
||||
if (start == INT16_MAX)
|
||||
if (start == UINT16_MAX)
|
||||
start = 0; //let say S_START is lump 0
|
||||
else
|
||||
start++; // just after S_START
|
||||
|
||||
|
||||
// ignore skin wads (we don't want skin sprites interfering with vanilla sprites)
|
||||
if (start == 0 && W_CheckNumForNamePwad("S_SKIN", wadnum, 0) != INT16_MAX)
|
||||
if (start == 0 && W_CheckNumForNamePwad("S_SKIN", wadnum, 0) != UINT16_MAX)
|
||||
return;
|
||||
|
||||
end = W_CheckNumForNamePwad("S_END",wadnum,start);
|
||||
if (end == INT16_MAX)
|
||||
end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib.
|
||||
if (end == INT16_MAX)
|
||||
if (wadfiles[wadnum]->type == RET_WAD)
|
||||
{
|
||||
end = W_CheckNumForNamePwad("S_END",wadnum,start);
|
||||
if (end == UINT16_MAX)
|
||||
end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib.
|
||||
}
|
||||
else if (wadfiles[wadnum]->type == RET_PK3)
|
||||
end = W_CheckNumForFolderEndPK3("Sprites/", wadnum, start);
|
||||
|
||||
if (end == UINT16_MAX)
|
||||
{
|
||||
CONS_Debug(DBG_SETUP, "no sprites in pwad %d\n", wadnum);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// scan through lumps, for each sprite, find all the sprite frames
|
||||
//
|
||||
|
|
|
@ -50,7 +50,7 @@ void R_SortVisSprites(void);
|
|||
//faB: find sprites in wadfile, replace existing, add new ones
|
||||
// (only sprites from namelist are added or replaced)
|
||||
void R_AddSpriteDefs(UINT16 wadnum);
|
||||
void R_AddSpriteDefsRange(UINT16 wadnum, UINT16 start, UINT16 end);
|
||||
void R_LoadSpritsRange(UINT16 wadnum, UINT16 first, UINT16 num);
|
||||
|
||||
|
||||
#ifdef DELFILE
|
||||
|
|
54
src/w_wad.c
54
src/w_wad.c
|
@ -70,14 +70,6 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
|
|||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
// a raw entry of the wad directory
|
||||
typedef struct
|
||||
{
|
||||
UINT32 filepos; // file offset of the resource
|
||||
UINT32 size; // size of the resource
|
||||
char name[8]; // name of the resource
|
||||
} ATTRPACK filelump_t;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
@ -179,6 +171,26 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
|
|||
return handle;
|
||||
}
|
||||
|
||||
// Look for all DEHACKED and Lua scripts inside a PK3 archive.
|
||||
static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum)
|
||||
{
|
||||
UINT16 posStart, posEnd;
|
||||
posStart = W_CheckNumForFullNamePK3("Lua/", wadnum, 0);
|
||||
if (posStart != INT16_MAX)
|
||||
{
|
||||
posEnd = W_CheckNumForFolderEndPK3("Lua/", wadnum, posStart);
|
||||
for (++posStart; posStart < posEnd; posStart++)
|
||||
LUA_LoadLump(wadnum, posStart);
|
||||
}
|
||||
posStart = W_CheckNumForFullNamePK3("SOCs/", wadnum, 0);
|
||||
if (posStart != INT16_MAX)
|
||||
{
|
||||
posEnd = W_CheckNumForFolderEndPK3("SOCs/", wadnum, posStart);
|
||||
for(++posStart; posStart < posEnd; posStart++)
|
||||
DEH_LoadDehackedLumpPwad(wadnum, posStart);
|
||||
}
|
||||
}
|
||||
|
||||
// search for all DEHACKED lump in all wads and load it
|
||||
static inline void W_LoadDehackedLumps(UINT16 wadnum)
|
||||
{
|
||||
|
@ -539,6 +551,7 @@ UINT16 W_InitFile(const char *filename)
|
|||
lumpinfo[numlumps].compression = CM_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
CONS_Printf("File %s, Shortname %s, data begins at: %ld\n", eName, lumpinfo[numlumps].name, lumpinfo[numlumps].position);
|
||||
CONS_Debug(DBG_SETUP, "File %s, data begins at: %ld\n", eName, lumpinfo[numlumps].position);
|
||||
fseek(handle, eXFieldLen + eCommentLen, SEEK_CUR); // We skip to where we expect the next central directory entry or end marker to be.
|
||||
numlumps++;
|
||||
|
@ -696,9 +709,12 @@ UINT16 W_InitFile(const char *filename)
|
|||
wadfiles[numwadfiles] = wadfile;
|
||||
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 for WADs. Avoids crash on startup since WADs are loaded using W_InitMultipleFiles.
|
||||
// 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);
|
||||
|
||||
|
||||
W_InvalidateLumpnumCache();
|
||||
|
||||
|
@ -827,10 +843,8 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump)
|
|||
{
|
||||
lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump;
|
||||
for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++)
|
||||
{
|
||||
if (memcmp(lump_p->name,uname,8) == 0)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// not found.
|
||||
|
@ -992,25 +1006,25 @@ size_t W_LumpLength(lumpnum_t lumpnum)
|
|||
/* report a zlib or i/o error */
|
||||
void zerr(int ret)
|
||||
{
|
||||
CONS_Printf("zpipe: ", stderr);
|
||||
CONS_Printf("zpipe: ");
|
||||
switch (ret) {
|
||||
case Z_ERRNO:
|
||||
if (ferror(stdin))
|
||||
CONS_Printf("error reading stdin\n", stderr);
|
||||
CONS_Printf("error reading stdin\n");
|
||||
if (ferror(stdout))
|
||||
CONS_Printf("error writing stdout\n", stderr);
|
||||
CONS_Printf("error writing stdout\n");
|
||||
break;
|
||||
case Z_STREAM_ERROR:
|
||||
CONS_Printf("invalid compression level\n", stderr);
|
||||
CONS_Printf("invalid compression level\n");
|
||||
break;
|
||||
case Z_DATA_ERROR:
|
||||
CONS_Printf("invalid or incomplete deflate data\n", stderr);
|
||||
CONS_Printf("invalid or incomplete deflate data\n");
|
||||
break;
|
||||
case Z_MEM_ERROR:
|
||||
CONS_Printf("out of memory\n", stderr);
|
||||
CONS_Printf("out of memory\n");
|
||||
break;
|
||||
case Z_VERSION_ERROR:
|
||||
CONS_Printf("zlib version mismatch!\n", stderr);
|
||||
CONS_Printf("zlib version mismatch!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1095,8 +1109,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
|||
}
|
||||
case CM_DEFLATE: // Is it compressed via DEFLATE? Very common in ZIPs/PK3s, also what most doom-related editors support.
|
||||
{
|
||||
char *rawData; // The lump's raw data.
|
||||
char *decData; // Lump's decompressed real data.
|
||||
z_const Bytef *rawData; // The lump's raw data.
|
||||
Bytef *decData; // Lump's decompressed real data.
|
||||
|
||||
int zErr; // Helper var.
|
||||
z_stream strm;
|
||||
|
|
10
src/w_wad.h
10
src/w_wad.h
|
@ -34,6 +34,14 @@ typedef struct
|
|||
UINT32 infotableofs; // the 'directory' of resources
|
||||
} wadinfo_t;
|
||||
|
||||
// a raw entry of the wad directory
|
||||
typedef struct
|
||||
{
|
||||
UINT32 filepos; // file offset of the resource
|
||||
UINT32 size; // size of the resource
|
||||
char name[8]; // name of the resource
|
||||
} ATTRPACK filelump_t;
|
||||
|
||||
// Available compression methods for lumps.
|
||||
enum compmethod{CM_NONE, CM_DEFLATE, CM_LZF, CM_UNSUPPORTED};
|
||||
|
||||
|
@ -99,8 +107,6 @@ UINT16 W_InitFile(const char *filename);
|
|||
void W_UnloadWadFile(UINT16 num);
|
||||
#endif
|
||||
|
||||
static inline void W_LoadDehackedLumps(UINT16 wadnum);
|
||||
|
||||
// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise,
|
||||
// so that it stops with a message if a file was not found, but not if all is okay.
|
||||
INT32 W_InitMultipleFiles(char **filenames);
|
||||
|
|
Loading…
Reference in a new issue