Cleaned up a little bit of unused code.
This commit is contained in:
parent
2c614f8f2c
commit
146c7485f5
90
src/w_wad.c
90
src/w_wad.c
|
@ -466,6 +466,7 @@ UINT16 W_LoadWadFile(const char *filename)
|
||||||
unsigned int eSize = 0;
|
unsigned int eSize = 0;
|
||||||
unsigned int eCompSize = 0;
|
unsigned int eCompSize = 0;
|
||||||
unsigned int eLocalHeaderOffset = 0;
|
unsigned int eLocalHeaderOffset = 0;
|
||||||
|
int namePos;
|
||||||
|
|
||||||
// We get the compression type indicator value.
|
// We get the compression type indicator value.
|
||||||
fseek(handle, 6, SEEK_CUR);
|
fseek(handle, 6, SEEK_CUR);
|
||||||
|
@ -481,61 +482,54 @@ UINT16 W_LoadWadFile(const char *filename)
|
||||||
fseek(handle, 8, SEEK_CUR);
|
fseek(handle, 8, SEEK_CUR);
|
||||||
fread(&eLocalHeaderOffset, 1, 4, handle); // Get the offset.
|
fread(&eLocalHeaderOffset, 1, 4, handle); // Get the offset.
|
||||||
|
|
||||||
|
if (numlumps == 0) // First lump? Let's allocate the first lumpinfo block.
|
||||||
|
lumpinfo = Z_Malloc(sizeof(*lumpinfo), PU_STATIC, NULL);
|
||||||
|
else // Otherwise, reallocate and increase by 1. Might not be optimal, though...
|
||||||
|
lumpinfo = (lumpinfo_t*) Z_Realloc(lumpinfo, (numlumps + 1)*sizeof(*lumpinfo), PU_STATIC, NULL);
|
||||||
|
|
||||||
eName = malloc(sizeof(char)*(eNameLen + 1));
|
eName = malloc(sizeof(char)*(eNameLen + 1));
|
||||||
fgets(eName, eNameLen + 1, handle);
|
fgets(eName, eNameLen + 1, handle);
|
||||||
if (0)//(eSize == 0) // Is this entry a folder?
|
namePos = eNameLen - 1;
|
||||||
|
lumpinfo[numlumps].position = eLocalHeaderOffset + 30 + eNameLen + eXFieldLen;
|
||||||
|
lumpinfo[numlumps].disksize = eCompSize;
|
||||||
|
lumpinfo[numlumps].size = eSize;
|
||||||
|
CONS_Printf("File %s at: %ld\n", eName, ftell(handle));
|
||||||
|
CONS_Printf("Address: %ld, Full: %ld, Comp: %ld\n", lumpinfo[numlumps].position, lumpinfo[numlumps].size, lumpinfo[numlumps].disksize);
|
||||||
|
// We will trim the file's full name so that only the filename is left.
|
||||||
|
while(namePos--)
|
||||||
{
|
{
|
||||||
CONS_Printf("Folder %s at %ld:\n", eName, ftell(handle));
|
if(eName[namePos] == '/')
|
||||||
}
|
|
||||||
else // If not, then it is a normal file. Let's arrange its lumpinfo structure then!
|
|
||||||
{
|
|
||||||
int namePos = eNameLen - 1;
|
|
||||||
CONS_Printf("File %s at: %ld\n", eName, ftell(handle));
|
|
||||||
if (numlumps == 0) // First lump? Let's allocate the first lumpinfo block.
|
|
||||||
lumpinfo = Z_Malloc(sizeof(*lumpinfo), PU_STATIC, NULL);
|
|
||||||
else // Otherwise, reallocate and increase by 1. Might not be optimal, though...
|
|
||||||
lumpinfo = (lumpinfo_t*) Z_Realloc(lumpinfo, (numlumps + 1)*sizeof(*lumpinfo), PU_STATIC, NULL);
|
|
||||||
|
|
||||||
lumpinfo[numlumps].position = eLocalHeaderOffset + 30 + eNameLen + eXFieldLen;
|
|
||||||
lumpinfo[numlumps].disksize = eCompSize;
|
|
||||||
lumpinfo[numlumps].size = eSize;
|
|
||||||
CONS_Printf("Address: %ld, Full: %ld, Comp: %ld\n", lumpinfo[numlumps].position, lumpinfo[numlumps].size, lumpinfo[numlumps].disksize);
|
|
||||||
// We will trim the file's full name so that only the filename is left.
|
|
||||||
while(namePos--)
|
|
||||||
{
|
{
|
||||||
if(eName[namePos] == '/')
|
namePos++;
|
||||||
{
|
|
||||||
namePos++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memset(lumpinfo[numlumps].name, '\0', 9)
|
|
||||||
strncpy(lumpinfo[numlumps].name, eName + namePos, 8);
|
|
||||||
|
|
||||||
lumpinfo[numlumps].name2 = Z_Malloc((eNameLen+1)*sizeof(char), PU_STATIC, NULL);
|
|
||||||
strncpy(lumpinfo[numlumps].name2, eName, eNameLen);
|
|
||||||
lumpinfo[numlumps].name2[eNameLen] = '\0';
|
|
||||||
|
|
||||||
// We set the compression type from what we're supporting so far.
|
|
||||||
switch(eCompression)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
lumpinfo[numlumps].compression = CM_NONE;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
lumpinfo[numlumps].compression = CM_DEFLATE;
|
|
||||||
break;
|
|
||||||
case 14:
|
|
||||||
lumpinfo[numlumps].compression = CM_LZF;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CONS_Alert(CONS_WARNING, "Lump has an unsupported compression type!\n");
|
|
||||||
lumpinfo[numlumps].compression = CM_NONE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fseek(handle, eXFieldLen + eCommentLen, SEEK_CUR); // We skip to where we expect the next central directory entry or end marker to be.
|
|
||||||
numlumps++;
|
|
||||||
}
|
}
|
||||||
|
memset(lumpinfo[numlumps].name, '\0', 9);
|
||||||
|
strncpy(lumpinfo[numlumps].name, eName + namePos, 8);
|
||||||
|
|
||||||
|
lumpinfo[numlumps].name2 = Z_Malloc((eNameLen+1)*sizeof(char), PU_STATIC, NULL);
|
||||||
|
strncpy(lumpinfo[numlumps].name2, eName, eNameLen);
|
||||||
|
lumpinfo[numlumps].name2[eNameLen] = '\0';
|
||||||
|
|
||||||
|
// We set the compression type from what we're supporting so far.
|
||||||
|
switch(eCompression)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
lumpinfo[numlumps].compression = CM_NONE;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
lumpinfo[numlumps].compression = CM_DEFLATE;
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
lumpinfo[numlumps].compression = CM_LZF;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CONS_Alert(CONS_WARNING, "Lump has an unsupported compression type!\n");
|
||||||
|
lumpinfo[numlumps].compression = CM_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fseek(handle, eXFieldLen + eCommentLen, SEEK_CUR); // We skip to where we expect the next central directory entry or end marker to be.
|
||||||
|
numlumps++;
|
||||||
free(eName);
|
free(eName);
|
||||||
}
|
}
|
||||||
// We found the central directory end signature?
|
// We found the central directory end signature?
|
||||||
|
|
Loading…
Reference in a new issue