Fix p_spec.c and r_things.h, get the compiler to shut up

This compiles with no errors or warnings, but hasn't been tested yet. Please review/test when you can.
This commit is contained in:
wolfy852 2017-10-07 17:18:25 -05:00
parent 93584f6811
commit b298c7a541
8 changed files with 67 additions and 192 deletions

View File

@ -2796,7 +2796,8 @@ boolean P_SetupLevel(boolean skipprecip)
{
// 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);
filelump_t *fileinfo = wadData + ((wadinfo_t *)wadData)->infotableofs;
//filelump_t *fileinfo = wadData + ((wadinfo_t *)wadData)->infotableofs;
filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs);
P_LoadRawVertexes(wadData + (fileinfo + ML_VERTEXES)->filepos, (fileinfo + ML_VERTEXES)->size);
P_LoadRawSectors(wadData + (fileinfo + ML_SECTORS)->filepos, (fileinfo + ML_SECTORS)->size);
@ -3233,7 +3234,7 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
// UINT16 socPos, socNum = 0;
UINT16 sfxPos, sfxNum = 0;
UINT16 musPos, musNum = 0;
UINT16 sprPos, sprNum = 0;
// UINT16 sprPos, sprNum = 0;
UINT16 texPos, texNum = 0;
// UINT16 patPos, patNum = 0;
// UINT16 flaPos, flaNum = 0;
@ -3254,7 +3255,7 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
case RET_PK3:
{
// Auxiliary function - input a folder name and gives us the resource markers positions.
void FindFolder(char *folName, UINT16 *start, UINT16 *end)
void FindFolder(const char *folName, UINT16 *start, UINT16 *end)
{
if (!stricmp(lumpinfo->name2, folName))
{

View File

@ -61,6 +61,8 @@ void P_LoadThingsOnly(void);
boolean P_SetupLevel(boolean skipprecip);
boolean P_AddWadFile(const char *wadfilename, char **firstmapname);
boolean P_RunSOC(const char *socfilename);
void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num);
void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num);
void P_WriteThings(lumpnum_t lump);
size_t P_PrecacheLevelFlats(void);
void P_AllocMapHeader(INT16 i);

View File

@ -74,7 +74,7 @@ typedef struct
#endif
/** Animated texture definition.
* Used for ::harddefs and for loading an ANIMATED lump from a wad.
* Used for loading an ANIMDEFS lump from a wad.
*
* Animations are defined by the first and last frame (i.e., flat or texture).
* The animation sequence uses all flats between the start and end entry, in
@ -121,104 +121,6 @@ static anim_t *lastanim;
static anim_t *anims = NULL; /// \todo free leak
static size_t maxanims;
//
// P_InitPicAnims
//
/** Hardcoded animation sequences.
* Used if no ANIMATED lump is found in a loaded wad.
*/
static animdef_t harddefs[] =
{
// flat animations.
{false, "LITEY3", "LITEY1", 4},
{false, "FWATER16", "FWATER1", 4},
{false, "BWATER16", "BWATER01", 4},
{false, "LWATER16", "LWATER1", 4},
{false, "WATER7", "WATER0", 4},
{false, "LAVA4", "LAVA1", 8},
{false, "DLAVA4", "DLAVA1", 8},
{false, "RLAVA8", "RLAVA1", 8},
{false, "LITER3", "LITER1", 8},
{false, "SURF08", "SURF01", 4},
{false, "CHEMG16", "CHEMG01", 4}, // THZ Chemical gunk
{false, "GOOP16", "GOOP01", 4}, // Green chemical gunk
{false, "OIL16", "OIL01", 4}, // Oil
{false, "THZBOXF4", "THZBOXF1", 2}, // Moved up with the flats
{false, "ALTBOXF4", "ALTBOXF1", 2},
{false, "LITEB3", "LITEB1", 4},
{false, "LITEN3", "LITEN1", 4},
{false, "ACZRFL1H", "ACZRFL1A", 4},
{false, "ACZRFL2H", "ACZRFL2A", 4},
{false, "EGRIDF3", "EGRIDF1", 4},
{false, "ERZFAN4", "ERZFAN1", 1},
{false, "ERZFANR4", "ERZFANR1", 1},
{false, "DISCO4", "DISCO1", 15},
// animated textures
{true, "GFALL4", "GFALL1", 2}, // Short waterfall
{true, "CFALL4", "CFALL1", 2}, // Long waterfall
{true, "TFALL4", "TFALL1", 2}, // THZ Chemical fall
{true, "AFALL4", "AFALL1", 2}, // Green Chemical fall
{true, "QFALL4", "QFALL1", 2}, // Quicksand fall
{true, "Q2FALL4", "Q2FALL1", 2},
{true, "Q3FALL4", "Q3FALL1", 2},
{true, "Q4FALL4", "Q4FALL1", 2},
{true, "Q5FALL4", "Q5FALL1", 2},
{true, "Q6FALL4", "Q6FALL1", 2},
{true, "Q7FALL4", "Q7FALL1", 2},
{true, "LFALL4", "LFALL1", 2},
{true, "MFALL4", "MFALL1", 2},
{true, "OFALL4", "OFALL1", 2},
{true, "DLAVA4", "DLAVA1", 8},
{true, "ERZLASA2", "ERZLASA1", 1},
{true, "ERZLASB4", "ERZLASB1", 1},
{true, "ERZLASC4", "ERZLASC1", 1},
{true, "THZBOX04", "THZBOX01", 2},
{true, "ALTBOX04", "ALTBOX01", 2},
{true, "SFALL4", "SFALL1", 4}, // Lava fall
{true, "RVZFALL8", "RVZFALL1", 4},
{true, "BFALL4", "BFALL1", 2}, // HPZ waterfall
{true, "GREYW3", "GREYW1", 4},
{true, "BLUEW3", "BLUEW1", 4},
{true, "COMP6", "COMP4", 4},
{true, "RED3", "RED1", 4},
{true, "YEL3", "YEL1", 4},
{true, "ACWRFL1D", "ACWRFL1A", 1},
{true, "ACWRFL2D", "ACWRFL2A", 1},
{true, "ACWRFL3D", "ACWRFL3A", 1},
{true, "ACWRFL4D", "ACWRFL4A", 1},
{true, "ACWRP1D", "ACWRP1A", 1},
{true, "ACWRP2D", "ACWRP2A", 1},
{true, "ACZRP1D", "ACZRP1A", 1},
{true, "ACZRP2D", "ACZRP2A", 1},
{true, "OILFALL4", "OILFALL1", 2},
{true, "SOLFALL4", "SOLFALL1", 2},
{true, "DOWN1C", "DOWN1A", 4},
{true, "DOWN2C", "DOWN2A", 4},
{true, "DOWN3D", "DOWN3A", 4},
{true, "DOWN4C", "DOWN4A", 4},
{true, "DOWN5C", "DOWN5A", 4},
{true, "UP1C", "UP1A", 4},
{true, "UP2C", "UP2A", 4},
{true, "UP3D", "UP3A", 4},
{true, "UP4C", "UP4A", 4},
{true, "UP5C", "UP5A", 4},
{true, "EGRID3", "EGRID1", 4},
{true, "ERFANW4", "ERFANW1", 1},
{true, "ERFANX4", "ERFANX1", 1},
{true, "DISCOD4", "DISCOD1", 15},
{true, "DANCE4", "DANCE1", 8},
{true, "SKY135", "SKY132", 2},
{true, "APPLMS4", "APPLMS1", 2},
{true, "APBOXW3", "APBOXW1", 2},
{true, "ERZLAZC4", "ERZLAZC1", 4},
// End of line
{ -1, "", "", 0},
};
// Animating line specials
// Init animated textures
@ -232,7 +134,7 @@ void P_ParseAnimationDefintion(SINT8 istexture);
/** Sets up texture and flat animations.
*
* Converts an ::animdef_t array loaded from ::harddefs or a lump into
* Converts an ::animdef_t array loaded from a lump into
* ::anim_t format.
*
* Issues an error if any animation cycles are invalid.
@ -244,73 +146,41 @@ void P_InitPicAnims(void)
{
// Init animation
INT32 w; // WAD
UINT8 *animatedLump;
UINT8 *currentPos;
size_t i;
I_Assert(animdefs == NULL);
maxanims = 0;
if (W_CheckNumForName("ANIMATED") != LUMPERROR || W_CheckNumForName("ANIMDEFS") != LUMPERROR)
if (W_CheckNumForName("ANIMDEFS") != LUMPERROR)
{
for (w = numwadfiles-1, maxanims = 0; w >= 0; w--)
for (w = numwadfiles-1; w >= 0; w--)
{
UINT16 animatedLumpNum;
UINT16 animdefsLumpNum;
// Find ANIMATED lump in the WAD
animatedLumpNum = W_CheckNumForNamePwad("ANIMATED", w, 0);
if (animatedLumpNum != INT16_MAX)
{
animatedLump = (UINT8 *)W_CacheLumpNumPwad(w, animatedLumpNum, PU_STATIC);
// Get the number of animations in the file
i = maxanims;
for (currentPos = animatedLump; *currentPos != UINT8_MAX; maxanims++, currentPos+=23);
// Resize animdefs (or if it hasn't been created, create it)
animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL);
// Sanity check it
if (!animdefs)
I_Error("Not enough free memory for ANIMATED data");
// Populate the new array
for (currentPos = animatedLump; *currentPos != UINT8_MAX; i++, currentPos+=23)
{
M_Memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte
M_Memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes
M_Memcpy(animdefs[i].startname, (currentPos + 10), 9); // startname, 9 bytes
M_Memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes
}
Z_Free(animatedLump);
}
// Now find ANIMDEFS
if (wadfiles[w]->type == RET_WAD)
animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0);
else if (wadfiles[w]->type == RET_PK3)
// Find ANIMDEFS lump in the WAD
if (wadfiles[w]->type == RET_PK3)
animdefsLumpNum = W_CheckNumForFullNamePK3("ANIMDEFS", w, 0);
else
animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0);
if (animdefsLumpNum != INT16_MAX)
P_ParseANIMDEFSLump(w, animdefsLumpNum);
}
// Define the last one
animdefs[maxanims].istexture = -1;
strncpy(animdefs[maxanims].endname, "", 9);
strncpy(animdefs[maxanims].startname, "", 9);
animdefs[maxanims].speed = 0;
}
else
{
animdefs = harddefs;
for (maxanims = 0; animdefs[maxanims].istexture != -1; maxanims++);
}
// Define the last one
animdefs[maxanims].istexture = -1;
strncpy(animdefs[maxanims].endname, "", 9);
strncpy(animdefs[maxanims].startname, "", 9);
animdefs[maxanims].speed = 0;
if (anims)
free(anims);
anims = (anim_t *)malloc(sizeof (*anims)*(maxanims + 1));
if (!anims)
I_Error("Not enough free memory for ANIMATED data");
I_Error("Not enough free memory for ANIMDEFS data");
lastanim = anims;
for (i = 0; animdefs[i].istexture != -1; i++)
@ -342,10 +212,7 @@ void P_InitPicAnims(void)
animdefs[i].startname, animdefs[i].endname);
}
if (animdefs == harddefs)
lastanim->speed = animdefs[i].speed;
else
lastanim->speed = LONG(animdefs[i].speed);
lastanim->speed = LONG(animdefs[i].speed);
lastanim++;
}
lastanim->istexture = -1;
@ -353,8 +220,7 @@ void P_InitPicAnims(void)
// Clear animdefs now that we're done with it.
// We'll only be using anims from now on.
if (animdefs != harddefs)
Z_Free(animdefs);
Z_Free(animdefs);
animdefs = NULL;
}

View File

@ -1198,8 +1198,17 @@ lumpnum_t R_GetFlatNumForName(const char *name)
// Scan wad files backwards so patched flats take preference.
for (i = numwadfiles - 1; i >= 0; i--)
{
// WAD type? use markers.
if (wadfiles[i]->type == RET_WAD)
if (wadfiles[i]->type == RET_PK3)
{
start = W_CheckNumForFolderStartPK3("Flats/", i, 0);
if (start == INT16_MAX)
continue;
end = W_CheckNumForFolderEndPK3("Flats/", i, start);
if (end == INT16_MAX)
continue;
}
else // WAD type? use markers.
{
// Find the ranges to work with.
start = W_CheckNumForNamePwad("F_START", (UINT16)i, 0);
@ -1222,15 +1231,6 @@ lumpnum_t R_GetFlatNumForName(const char *name)
continue;
}
}
else if (wadfiles[i]->type == RET_PK3)
{
start = W_CheckNumForFolderStartPK3("Flats/", i, 0);
if (start == INT16_MAX)
continue;
end = W_CheckNumForFolderEndPK3("Flats/", i, start);
if (end == INT16_MAX)
continue;
}
// Now find lump with specified name in that range.
lump = W_CheckNumForNamePwad(name, (UINT16)i, start);
if (lump < end)

View File

@ -380,7 +380,9 @@ void R_AddSpriteDefs(UINT16 wadnum)
char wadname[MAX_WADPATH];
// Find the sprites section in this resource file.
if (wadfiles[wadnum]->type == RET_WAD)
if (wadfiles[wadnum]->type == RET_PK3)
start = W_CheckNumForFolderStartPK3("Sprites/", wadnum, 0);
else
{
start = W_CheckNumForNamePwad("S_START", wadnum, 0);
if (start == UINT16_MAX)
@ -390,21 +392,19 @@ void R_AddSpriteDefs(UINT16 wadnum)
else
start++; // just after S_START
}
else if (wadfiles[wadnum]->type == RET_PK3)
start = W_CheckNumForFolderStartPK3("Sprites/", wadnum, 0);
// ignore skin wads (we don't want skin sprites interfering with vanilla sprites)
if (start == 0 && W_CheckNumForNamePwad("S_SKIN", wadnum, 0) != UINT16_MAX)
return;
if (wadfiles[wadnum]->type == RET_WAD)
if (wadfiles[wadnum]->type == RET_PK3)
end = W_CheckNumForFolderEndPK3("Sprites/", wadnum, start);
else
{
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)
{

View File

@ -51,11 +51,6 @@ void R_SortVisSprites(void);
// (only sprites from namelist are added or replaced)
void R_AddSpriteDefs(UINT16 wadnum);
#ifdef DELFILE
void R_DelSpriteDefs(UINT16 wadnum);
#endif
//SoM: 6/5/2000: Light sprites correctly!
void R_AddSprites(sector_t *sec, INT32 lightlevel);
void R_InitSprites(void);
@ -217,11 +212,10 @@ void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002
boolean R_SkinUsable(INT32 playernum, INT32 skinnum);
UINT32 R_GetSkinAvailabilities(void);
INT32 R_SkinAvailable(const char *name);
void R_PatchSkins(UINT16 wadnum);
void R_AddSkins(UINT16 wadnum);
#ifdef DELFILE
void R_DelSkins(UINT16 wadnum);
#endif
UINT8 P_GetSkinSprite2(skin_t *skin, UINT8 spr2, player_t *player);
void R_InitDrawNodes(void);
@ -236,7 +230,7 @@ char *GetPlayerFacePic(INT32 skinnum);
// Future: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@ ]]
FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame)
{
#if 0 // 2.1 compat
#if 1 // 2.1 compat
return 'A' + frame;
#else
if (frame < 26) return 'A' + frame;
@ -250,7 +244,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame)
FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn)
{
#if 0 // 2.1 compat
#if 1 // 2.1 compat
return cn - 'A';
#else
if (cn >= 'A' && cn <= 'Z') return cn - 'A';

View File

@ -25,6 +25,19 @@
#endif
#include "lzf.h"
#endif
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 0
#endif
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
#ifndef _LFS64_LARGEFILE
#define _LFS64_LARGEFILE
#endif
//#ifdef HAVE_ZLIB
#include "zlib.h"
//#endif // HAVE_ZLIB
@ -181,14 +194,14 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum)
if (posStart != INT16_MAX)
{
posEnd = W_CheckNumForFolderEndPK3("Lua/", wadnum, posStart);
for (posStart; posStart < posEnd; posStart++)
for (; posStart < posEnd; posStart++)
LUA_LoadLump(wadnum, posStart);
}
posStart = W_CheckNumForFolderStartPK3("SOCs/", wadnum, 0);
if (posStart != INT16_MAX)
{
posEnd = W_CheckNumForFolderEndPK3("SOCs/", wadnum, posStart);
for(posStart; posStart < posEnd; posStart++)
for(; posStart < posEnd; posStart++)
DEH_LoadDehackedLumpPwad(wadnum, posStart);
}
}
@ -604,12 +617,12 @@ UINT16 W_InitFile(const char *filename)
// assume wad file
else
{
type = RET_WAD;
wadinfo_t header;
lumpinfo_t *lump_p;
filelump_t *fileinfo;
void *fileinfov;
type = RET_WAD;
// read the header
if (fread(&header, 1, sizeof header, handle) < sizeof header)
@ -925,7 +938,7 @@ lumpnum_t W_CheckNumForMap(const char *name)
{
UINT16 lumpNum, end;
UINT32 i;
for (i = numwadfiles - 1; i >= 0; i--)
for (i = numwadfiles - 1; i < numwadfiles; i--)
{
if (wadfiles[i]->type == RET_WAD)
{

View File

@ -110,9 +110,6 @@ void W_Shutdown(void);
FILE *W_OpenWadFile(const char **filename, boolean useerrors);
// Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
UINT16 W_InitFile(const char *filename);
#ifdef DELFILE
void W_UnloadWadFile(UINT16 num);
#endif
// 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.
@ -136,6 +133,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);
void zerr(int ret); // zlib error checking
size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, size_t offset);
size_t W_ReadLumpHeader(lumpnum_t lump, void *dest, size_t size, size_t offest); // read all or a part of a lump
void W_ReadLumpPwad(UINT16 wad, UINT16 lump, void *dest);