40,6 → 40,27 |
#include <malloc.h> |
|
|
extern char *main_file; |
|
#ifdef DLHEAP |
|
void* _cdecl dlmalloc(size_t); |
void _cdecl dlfree(void*); |
void _cdecl mf_init(); |
|
#define malloc dlmalloc |
#define free dlfree |
#define realloc dlrealloc |
|
#endif |
|
size_t FileSize(FILE *handle); |
|
int _stdcall read_file (char *name, void *buff, |
size_t offset, size_t count, size_t *reads); |
|
|
|
// |
// GLOBALS |
// |
50,19 → 71,6 |
|
void** lumpcache; |
|
|
int filelength (FILE *handle) |
{ |
unsigned long pos, size; |
|
pos = ftell(handle); |
fseek(handle, 0, SEEK_END); |
size = ftell(handle); |
fseek(handle, pos, SEEK_SET); |
return (int)size; |
} |
|
|
void |
ExtractFileBase |
( char* path, |
115,13 → 123,6 |
// specially to allow map reloads. |
// But: the reload feature is a fragile hack... |
|
#ifdef __BEOS__ |
#ifdef __GNUC__ |
extern void *alloca(int); |
#else |
#include <alloca.h> |
#endif |
#endif /* __BEOS__ */ |
|
int reloadlump; |
char* reloadname; |
138,6 → 139,8 |
filelump_t* fileinfo; |
filelump_t singleinfo; |
int storehandle; |
int err; |
size_t bytes; |
|
// open the file and add to directory |
|
155,15 → 158,15 |
return; |
} |
|
printf (" adding %s\n",filename); |
printf (" adding %s\n\r",filename); |
startlump = numlumps; |
|
if (I_strncasecmp (filename+strlen(filename)-3 , "wad", 3 ) ) |
if (strnicmp (filename+strlen(filename)-3 , "wad", 3 ) ) |
{ |
// single lump file |
fileinfo = &singleinfo; |
singleinfo.filepos = 0; |
singleinfo.size = LONG(filelength(handle)); |
singleinfo.size = FileSize(handle); |
ExtractFileBase (filename, singleinfo.name); |
numlumps++; |
} |
170,9 → 173,8 |
else |
{ |
//WAD file |
printf("f1 at %x,%u\n",&header,handle); |
fread (&header, 1, sizeof(header), handle); |
printf("f2\n"); |
|
if (strncmp(header.identification,"IWAD",4)) |
{ |
printf("No IWAD id\n"); |
182,23 → 184,19 |
I_Error ("Wad file %s doesn't have IWAD " |
"or PWAD id\n", filename); |
} |
// printf("WAD magic OK\n"); |
printf("WAD magic OK\n"); |
// ???modifiedgame = true; |
} |
printf("after checking hdr\n"); |
header.numlumps = LONG(header.numlumps); |
printf("%u lumps in WAD\n",header.numlumps); |
|
header.infotableofs = LONG(header.infotableofs); |
printf("infor table at %x\n",header.infotableofs); |
|
length = header.numlumps*sizeof(filelump_t); |
printf("length %u\n",length); |
|
fileinfo = alloca(length); |
|
printf("seeking to info table\n"); |
fseek (handle, header.infotableofs, SEEK_SET); |
printf("f3\n"); |
fread (fileinfo, 1, length, handle); |
printf("f4\n"); |
numlumps += header.numlumps; |
} |
|
249,17 → 247,14 |
if ( (handle = fopen (reloadname,"rb")) == NULL) |
I_Error ("W_Reload: couldn't open %s",reloadname); |
|
printf("f5\n"); |
fread (&header, 1, sizeof(header), handle); |
printf("f6\n"); |
|
lumpcount = LONG(header.numlumps); |
header.infotableofs = LONG(header.infotableofs); |
length = lumpcount*sizeof(filelump_t); |
fileinfo = malloc (length); |
fseek (handle, header.infotableofs, SEEK_SET); |
printf("f7\n"); |
fread (fileinfo, 1, length, handle); |
printf("f8\n"); |
|
// Fill in lumpinfo |
lump_p = &lumpinfo[reloadlump]; |
278,8 → 273,6 |
fclose (handle); |
} |
|
|
|
// |
// W_InitMultipleFiles |
// Pass a null terminated list of files to use. |
301,7 → 294,7 |
numlumps = 0; |
|
// will be realloced as lumps are added |
lumpinfo = malloc(1); |
lumpinfo = malloc(16384); |
|
for ( ; *filenames ; filenames++) |
W_AddFile (*filenames); |
440,6 → 433,7 |
int c; |
lumpinfo_t* l; |
FILE *handle; |
size_t bytes; |
|
if (lump >= numlumps) |
I_Error ("W_ReadLump: %i >= numlumps",lump); |
482,7 → 476,7 |
{ |
byte* ptr; |
|
if ((unsigned)lump >= numlumps) |
if ((unsigned)lump >= (unsigned)numlumps) |
I_Error ("W_CacheLumpNum: %i >= numlumps",lump); |
|
if (!lumpcache[lump]) |
568,14 → 562,21 |
for ( ; j<8 ; j++) |
name[j] = ' '; |
|
printf ("%s ",name); |
//printf ("%s ",name); |
|
for (j=0 ; j<profilecount ; j++) |
fprintf (f," %c",info[i][j]); |
|
printf ("\n"); |
//printf ("\n"); |
} |
fclose (f); |
} |
|
#endif |
|
|
|
|
|
|
|