2007-01-28 05:53:06 +03:00
|
|
|
// Emacs style mode select -*- C++ -*-
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id:$
|
|
|
|
//
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
//
|
|
|
|
// This source is available for distribution and/or modification
|
|
|
|
// only under the terms of the DOOM Source Code License as
|
|
|
|
// published by id Software. All rights reserved.
|
|
|
|
//
|
|
|
|
// The source is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
// $Log:$
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
2007-02-09 01:53:29 +03:00
|
|
|
// Handles WAD file header, directory, lump I/O.
|
2007-01-28 05:53:06 +03:00
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
static const char
|
|
|
|
rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $";
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "m_swap.h"
|
|
|
|
#include "doomtype.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "z_zone.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
|
|
|
|
#include <malloc.h>
|
|
|
|
|
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
//
|
|
|
|
// GLOBALS
|
|
|
|
//
|
|
|
|
|
|
|
|
// Location of each lump on disk.
|
2007-02-09 01:53:29 +03:00
|
|
|
lumpinfo_t* lumpinfo;
|
|
|
|
int numlumps;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
void** lumpcache;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
ExtractFileBase
|
2007-02-09 01:53:29 +03:00
|
|
|
( char* path,
|
|
|
|
char* dest )
|
2007-01-28 05:53:06 +03:00
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
char* src;
|
|
|
|
int length;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
src = path + strlen(path) - 1;
|
|
|
|
|
|
|
|
// back up until a \ or the start
|
|
|
|
while (src != path
|
2007-02-09 01:53:29 +03:00
|
|
|
&& *(src-1) != '\\'
|
|
|
|
&& *(src-1) != '/')
|
2007-01-28 05:53:06 +03:00
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
src--;
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// copy up to eight characters
|
|
|
|
memset (dest,0,8);
|
|
|
|
length = 0;
|
|
|
|
|
|
|
|
while (*src && *src != '.')
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
if (++length == 9)
|
|
|
|
I_Error ("Filename base of %s >8 chars",path);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
*dest++ = toupper((int)*src++);
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// LUMP BASED ROUTINES.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_AddFile
|
|
|
|
// All files are optional, but at least one file must be
|
|
|
|
// found (PWAD, if all required lumps are present).
|
|
|
|
// Files with a .wad extension are wadlink files
|
|
|
|
// with multiple lumps.
|
|
|
|
// Other files are single lumps with the base filename
|
|
|
|
// for the lump name.
|
|
|
|
//
|
|
|
|
// If filename starts with a tilde, the file is handled
|
|
|
|
// specially to allow map reloads.
|
|
|
|
// But: the reload feature is a fragile hack...
|
|
|
|
|
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
int reloadlump;
|
|
|
|
char* reloadname;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
void W_AddFile (char *filename)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
wadinfo_t header;
|
|
|
|
lumpinfo_t* lump_p;
|
|
|
|
unsigned i;
|
|
|
|
FILE *handle;
|
|
|
|
int length;
|
|
|
|
int startlump;
|
|
|
|
filelump_t* fileinfo;
|
|
|
|
filelump_t singleinfo;
|
|
|
|
int storehandle;
|
|
|
|
int err;
|
|
|
|
size_t bytes;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
// open the file and add to directory
|
|
|
|
|
|
|
|
// handle reload indicator.
|
|
|
|
if (filename[0] == '~')
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
filename++;
|
|
|
|
reloadname = filename;
|
|
|
|
reloadlump = numlumps;
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
2007-02-13 07:00:47 +03:00
|
|
|
|
|
|
|
printf("open file %s\n\r",filename);
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
if ( (handle = fopen (filename,"rb")) == NULL)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
printf (" couldn't open %s\n",filename);
|
|
|
|
return;
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
printf (" adding %s\n\r",filename);
|
2007-01-28 05:53:06 +03:00
|
|
|
startlump = numlumps;
|
2007-02-09 01:53:29 +03:00
|
|
|
|
|
|
|
if (strnicmp (filename+strlen(filename)-3 , "wad", 3 ) )
|
2007-01-28 05:53:06 +03:00
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
// single lump file
|
|
|
|
fileinfo = &singleinfo;
|
|
|
|
singleinfo.filepos = 0;
|
|
|
|
singleinfo.size = FileSize(handle);
|
|
|
|
ExtractFileBase (filename, singleinfo.name);
|
|
|
|
numlumps++;
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
//WAD file
|
|
|
|
fread (&header, 1, sizeof(header), handle);
|
|
|
|
|
|
|
|
if (strncmp(header.identification,"IWAD",4))
|
|
|
|
{
|
|
|
|
printf("No IWAD id\n");
|
|
|
|
// Homebrew levels?
|
|
|
|
if (strncmp(header.identification,"PWAD",4))
|
|
|
|
{
|
|
|
|
I_Error ("Wad file %s doesn't have IWAD "
|
|
|
|
"or PWAD id\n", filename);
|
|
|
|
}
|
|
|
|
printf("WAD magic OK\n");
|
|
|
|
// ???modifiedgame = true;
|
|
|
|
}
|
|
|
|
header.numlumps = LONG(header.numlumps);
|
|
|
|
|
|
|
|
header.infotableofs = LONG(header.infotableofs);
|
|
|
|
|
|
|
|
length = header.numlumps*sizeof(filelump_t);
|
|
|
|
|
|
|
|
fileinfo = alloca(length);
|
|
|
|
|
|
|
|
fseek (handle, header.infotableofs, SEEK_SET);
|
|
|
|
fread (fileinfo, 1, length, handle);
|
|
|
|
numlumps += header.numlumps;
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Fill in lumpinfo
|
|
|
|
lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t));
|
|
|
|
|
|
|
|
if (!lumpinfo)
|
2007-02-09 01:53:29 +03:00
|
|
|
I_Error ("Couldn't realloc lumpinfo");
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
lump_p = &lumpinfo[startlump];
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
storehandle = reloadname ? -1 : (int)handle;
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
lump_p->handle = storehandle;
|
|
|
|
lump_p->position = LONG(fileinfo->filepos);
|
|
|
|
lump_p->size = LONG(fileinfo->size);
|
|
|
|
strncpy (lump_p->name, fileinfo->name, 8);
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
if (reloadname)
|
2007-02-09 01:53:29 +03:00
|
|
|
fclose (handle);
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_Reload
|
|
|
|
// Flushes any of the reloadable lumps in memory
|
|
|
|
// and reloads the directory.
|
|
|
|
//
|
|
|
|
void W_Reload (void)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
wadinfo_t header;
|
|
|
|
int lumpcount;
|
|
|
|
lumpinfo_t* lump_p;
|
|
|
|
unsigned i;
|
|
|
|
FILE *handle;
|
|
|
|
int length;
|
|
|
|
filelump_t* fileinfo;
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
if (!reloadname)
|
2007-02-09 01:53:29 +03:00
|
|
|
return;
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
if ( (handle = fopen (reloadname,"rb")) == NULL)
|
2007-02-09 01:53:29 +03:00
|
|
|
I_Error ("W_Reload: couldn't open %s",reloadname);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
fread (&header, 1, sizeof(header), handle);
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
lumpcount = LONG(header.numlumps);
|
|
|
|
header.infotableofs = LONG(header.infotableofs);
|
|
|
|
length = lumpcount*sizeof(filelump_t);
|
|
|
|
fileinfo = malloc (length);
|
|
|
|
fseek (handle, header.infotableofs, SEEK_SET);
|
|
|
|
fread (fileinfo, 1, length, handle);
|
|
|
|
|
|
|
|
// Fill in lumpinfo
|
|
|
|
lump_p = &lumpinfo[reloadlump];
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
for (i=reloadlump ;
|
2007-02-09 01:53:29 +03:00
|
|
|
i<reloadlump+lumpcount ;
|
|
|
|
i++,lump_p++, fileinfo++)
|
2007-01-28 05:53:06 +03:00
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
if (lumpcache[i])
|
|
|
|
Z_Free (lumpcache[i]);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
lump_p->position = LONG(fileinfo->filepos);
|
|
|
|
lump_p->size = LONG(fileinfo->size);
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
fclose (handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_InitMultipleFiles
|
|
|
|
// Pass a null terminated list of files to use.
|
|
|
|
// All files are optional, but at least one file
|
|
|
|
// must be found.
|
|
|
|
// Files with a .wad extension are idlink files
|
|
|
|
// with multiple lumps.
|
|
|
|
// Other files are single lumps with the base filename
|
|
|
|
// for the lump name.
|
|
|
|
// Lump names can appear multiple times.
|
|
|
|
// The name searcher looks backwards, so a later file
|
|
|
|
// does override all earlier ones.
|
|
|
|
//
|
|
|
|
void W_InitMultipleFiles (char** filenames)
|
2007-02-09 01:53:29 +03:00
|
|
|
{
|
|
|
|
int size;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
// open all the files, load headers, and count lumps
|
|
|
|
numlumps = 0;
|
|
|
|
|
|
|
|
// will be realloced as lumps are added
|
2007-02-09 01:53:29 +03:00
|
|
|
lumpinfo = malloc(16384);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
for ( ; *filenames ; filenames++)
|
2007-02-09 01:53:29 +03:00
|
|
|
W_AddFile (*filenames);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
if (!numlumps)
|
2007-02-09 01:53:29 +03:00
|
|
|
I_Error ("W_InitFiles: no files found");
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
// set up caching
|
|
|
|
size = numlumps * sizeof(*lumpcache);
|
|
|
|
lumpcache = malloc (size);
|
|
|
|
|
|
|
|
if (!lumpcache)
|
2007-02-09 01:53:29 +03:00
|
|
|
I_Error ("Couldn't allocate lumpcache");
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
memset (lumpcache,0, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_InitFile
|
|
|
|
// Just initialize from a single file.
|
|
|
|
//
|
|
|
|
void W_InitFile (char* filename)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
char* names[2];
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
names[0] = filename;
|
|
|
|
names[1] = NULL;
|
|
|
|
W_InitMultipleFiles (names);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_NumLumps
|
|
|
|
//
|
|
|
|
int W_NumLumps (void)
|
|
|
|
{
|
|
|
|
return numlumps;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_CheckNumForName
|
|
|
|
// Returns -1 if name not found.
|
|
|
|
//
|
|
|
|
|
|
|
|
int W_CheckNumForName (char* name)
|
|
|
|
{
|
|
|
|
union {
|
2007-02-09 01:53:29 +03:00
|
|
|
char s[9];
|
|
|
|
int x[2];
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
} name8;
|
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
int v1;
|
|
|
|
int v2;
|
|
|
|
lumpinfo_t* lump_p;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
// make the name into two integers for easy compares
|
|
|
|
strncpy (name8.s,name,8);
|
|
|
|
|
|
|
|
// in case the name was a fill 8 chars
|
|
|
|
name8.s[8] = 0;
|
|
|
|
|
|
|
|
// case insensitive
|
2007-02-09 01:53:29 +03:00
|
|
|
strupr (name8.s);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
v1 = name8.x[0];
|
|
|
|
v2 = name8.x[1];
|
|
|
|
|
|
|
|
|
|
|
|
// scan backwards so patch lump files take precedence
|
|
|
|
lump_p = lumpinfo + numlumps;
|
|
|
|
|
|
|
|
while (lump_p-- != lumpinfo)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
if ( *(int *)lump_p->name == v1
|
|
|
|
&& *(int *)&lump_p->name[4] == v2)
|
|
|
|
{
|
|
|
|
return lump_p - lumpinfo;
|
|
|
|
}
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// TFB. Not found.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_GetNumForName
|
|
|
|
// Calls W_CheckNumForName, but bombs out if not found.
|
|
|
|
//
|
|
|
|
int W_GetNumForName (char* name)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
int i;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
i = W_CheckNumForName (name);
|
|
|
|
|
|
|
|
if (i == -1)
|
|
|
|
I_Error ("W_GetNumForName: %s not found!", name);
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_LumpLength
|
|
|
|
// Returns the buffer size needed to load the given lump.
|
|
|
|
//
|
|
|
|
int W_LumpLength (int lump)
|
|
|
|
{
|
|
|
|
if (lump >= numlumps)
|
2007-02-09 01:53:29 +03:00
|
|
|
I_Error ("W_LumpLength: %i >= numlumps",lump);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
return lumpinfo[lump].size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_ReadLump
|
|
|
|
// Loads the lump into the given buffer,
|
|
|
|
// which must be >= W_LumpLength().
|
|
|
|
//
|
|
|
|
void
|
|
|
|
W_ReadLump
|
2007-02-09 01:53:29 +03:00
|
|
|
( int lump,
|
|
|
|
void* dest )
|
2007-01-28 05:53:06 +03:00
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
int c;
|
|
|
|
lumpinfo_t* l;
|
|
|
|
FILE *handle;
|
|
|
|
size_t bytes;
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
if (lump >= numlumps)
|
2007-02-09 01:53:29 +03:00
|
|
|
I_Error ("W_ReadLump: %i >= numlumps",lump);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
l = lumpinfo+lump;
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
// ??? I_BeginRead ();
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
if (l->handle == -1)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
// reloadable file, so use open / read / close
|
|
|
|
if ( (handle = fopen (reloadname,"rb")) == NULL)
|
|
|
|
I_Error ("W_ReadLump: couldn't open %s",reloadname);
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
else
|
2007-02-09 01:53:29 +03:00
|
|
|
handle = (FILE *)l->handle;
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
fseek (handle, l->position, SEEK_SET);
|
|
|
|
c = fread (dest, 1, l->size, handle);
|
|
|
|
if (c < l->size)
|
2007-02-09 01:53:29 +03:00
|
|
|
I_Error ("W_ReadLump: only read %i of %i on lump %i",
|
|
|
|
c,l->size,lump);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
if (l->handle == -1)
|
2007-02-09 01:53:29 +03:00
|
|
|
fclose (handle);
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
// ??? I_EndRead ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_CacheLumpNum
|
|
|
|
//
|
|
|
|
void*
|
|
|
|
W_CacheLumpNum
|
2007-02-09 01:53:29 +03:00
|
|
|
( int lump,
|
|
|
|
int tag )
|
2007-01-28 05:53:06 +03:00
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
byte* ptr;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
if ((unsigned)lump >= (unsigned)numlumps)
|
|
|
|
I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
if (!lumpcache[lump])
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
// read the lump in
|
|
|
|
|
|
|
|
//printf ("cache miss on lump %i\n",lump);
|
|
|
|
ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]);
|
|
|
|
W_ReadLump (lump, lumpcache[lump]);
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
//printf ("cache hit on lump %i\n",lump);
|
|
|
|
Z_ChangeTag (lumpcache[lump],tag);
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
return lumpcache[lump];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// W_CacheLumpName
|
|
|
|
//
|
|
|
|
void*
|
|
|
|
W_CacheLumpName
|
2007-02-09 01:53:29 +03:00
|
|
|
( char* name,
|
|
|
|
int tag )
|
2007-01-28 05:53:06 +03:00
|
|
|
{
|
|
|
|
return W_CacheLumpNum (W_GetNumForName(name), tag);
|
|
|
|
}
|
|
|
|
|
2007-01-29 23:02:19 +03:00
|
|
|
#if 0
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// W_Profile
|
|
|
|
//
|
2007-02-09 01:53:29 +03:00
|
|
|
int info[2500][10];
|
|
|
|
int profilecount;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
|
|
|
void W_Profile (void)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
int i;
|
|
|
|
memblock_t* block;
|
|
|
|
void* ptr;
|
|
|
|
char ch;
|
|
|
|
FILE* f;
|
|
|
|
int j;
|
|
|
|
char name[9];
|
|
|
|
|
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
for (i=0 ; i<numlumps ; i++)
|
2007-02-09 01:53:29 +03:00
|
|
|
{
|
|
|
|
ptr = lumpcache[i];
|
|
|
|
if (!ptr)
|
|
|
|
{
|
|
|
|
ch = ' ';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
|
|
|
|
if (block->tag < PU_PURGELEVEL)
|
|
|
|
ch = 'S';
|
|
|
|
else
|
|
|
|
ch = 'P';
|
|
|
|
}
|
|
|
|
info[i][profilecount] = ch;
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
profilecount++;
|
2007-02-09 01:53:29 +03:00
|
|
|
|
2007-01-28 05:53:06 +03:00
|
|
|
f = fopen ("waddump.txt","w");
|
|
|
|
name[8] = 0;
|
|
|
|
|
|
|
|
for (i=0 ; i<numlumps ; i++)
|
|
|
|
{
|
2007-02-09 01:53:29 +03:00
|
|
|
memcpy (name,lumpinfo[i].name,8);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
for (j=0 ; j<8 ; j++)
|
|
|
|
if (!name[j])
|
|
|
|
break;
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
for ( ; j<8 ; j++)
|
|
|
|
name[j] = ' ';
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
//printf ("%s ",name);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
for (j=0 ; j<profilecount ; j++)
|
|
|
|
fprintf (f," %c",info[i][j]);
|
2007-01-28 05:53:06 +03:00
|
|
|
|
2007-02-09 01:53:29 +03:00
|
|
|
//printf ("\n");
|
2007-01-28 05:53:06 +03:00
|
|
|
}
|
|
|
|
fclose (f);
|
|
|
|
}
|
|
|
|
|
2007-01-29 23:02:19 +03:00
|
|
|
#endif
|
2007-02-09 01:53:29 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|