[PATCH] qbsp: Complete removal of wadlist_t
Make all WADList functions take a pointer to the first wad_t, rather than embedding it inside the struct wadlist. wadlist_t is no longer needed. Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
parent
39d6337fe3
commit
747631223c
|
|
@ -233,7 +233,7 @@ static void
|
||||||
ProcessFile(void)
|
ProcessFile(void)
|
||||||
{
|
{
|
||||||
char *wadstring;
|
char *wadstring;
|
||||||
wadlist_t wads;
|
wad_t *wads;
|
||||||
int numwads = 0;
|
int numwads = 0;
|
||||||
|
|
||||||
// load brushes and entities
|
// load brushes and entities
|
||||||
|
|
@ -278,10 +278,10 @@ ProcessFile(void)
|
||||||
CreateHulls();
|
CreateHulls();
|
||||||
|
|
||||||
WriteEntitiesToString();
|
WriteEntitiesToString();
|
||||||
WADList_Process(&wads, numwads);
|
WADList_Process(wads, numwads);
|
||||||
FinishBSPFile();
|
FinishBSPFile();
|
||||||
|
|
||||||
WADList_Free(&wads, numwads);
|
WADList_Free(wads, numwads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
48
qbsp/wad.c
48
qbsp/wad.c
|
|
@ -24,8 +24,8 @@
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
||||||
static void WADList_LoadTextures(wadlist_t *w, int numwads, dmiptexlump_t *l);
|
static void WADList_LoadTextures(wad_t *wads, int numwads, dmiptexlump_t *l);
|
||||||
static void WADList_AddAnimatingTextures(wadlist_t *w, int numwads);
|
static void WADList_AddAnimatingTextures(wad_t *wads, int numwads);
|
||||||
static int WAD_LoadLump(wad_t *w, char *name, byte *dest);
|
static int WAD_LoadLump(wad_t *w, char *name, byte *dest);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -52,14 +52,14 @@ WAD_LoadInfo(wad_t *w)
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
WADList_Init(wadlist_t *list, char *wadstring)
|
WADList_Init(wad_t **wads, char *wadstring)
|
||||||
{
|
{
|
||||||
int i, len, numwads;
|
int i, len, numwads;
|
||||||
wad_t *tmp, *w;
|
wad_t *tmp, *w;
|
||||||
char *fname;
|
char *fname;
|
||||||
|
|
||||||
numwads = 0;
|
numwads = 0;
|
||||||
list->wads = NULL;
|
*wads = NULL;
|
||||||
|
|
||||||
if (!wadstring)
|
if (!wadstring)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -94,8 +94,8 @@ WADList_Init(wadlist_t *list, char *wadstring)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Re-allocate just the required amount */
|
/* Re-allocate just the required amount */
|
||||||
list->wads = AllocMem(OTHER, (w - tmp) * sizeof(wad_t), false);
|
*wads = AllocMem(OTHER, (w - tmp) * sizeof(wad_t), false);
|
||||||
memcpy(list->wads, tmp, (w - tmp) * sizeof(wad_t));
|
memcpy(*wads, tmp, (w - tmp) * sizeof(wad_t));
|
||||||
FreeMem(tmp, OTHER, numwads * sizeof(wad_t));
|
FreeMem(tmp, OTHER, numwads * sizeof(wad_t));
|
||||||
numwads = w - tmp;
|
numwads = w - tmp;
|
||||||
|
|
||||||
|
|
@ -104,23 +104,23 @@ WADList_Init(wadlist_t *list, char *wadstring)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WADList_Free(wadlist_t *w, int numwads)
|
WADList_Free(wad_t *wads, int numwads)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (w->wads) {
|
if (wads) {
|
||||||
for (i = 0; i < numwads; i++) {
|
for (i = 0; i < numwads; i++) {
|
||||||
fclose(w->wads[i].file);
|
fclose(wads[i].file);
|
||||||
FreeMem(w->wads[i].lumps, OTHER,
|
FreeMem(wads[i].lumps, OTHER,
|
||||||
sizeof(lumpinfo_t) * w->wads[i].header.numlumps);
|
sizeof(lumpinfo_t) * wads[i].header.numlumps);
|
||||||
}
|
}
|
||||||
FreeMem(w->wads, OTHER, numwads * sizeof(wad_t));
|
FreeMem(wads, OTHER, numwads * sizeof(wad_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WADList_Process(wadlist_t *w, int numwads)
|
WADList_Process(wad_t *wads, int numwads)
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
dmiptexlump_t *l;
|
dmiptexlump_t *l;
|
||||||
|
|
@ -128,20 +128,20 @@ WADList_Process(wadlist_t *w, int numwads)
|
||||||
if (numwads < 1)
|
if (numwads < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WADList_AddAnimatingTextures(w, numwads);
|
WADList_AddAnimatingTextures(wads, numwads);
|
||||||
|
|
||||||
// Count texture size. Slow but saves memory.
|
// Count texture size. Slow but saves memory.
|
||||||
for (i = 0; i < cMiptex; i++)
|
for (i = 0; i < cMiptex; i++)
|
||||||
for (j = 0; j < numwads; j++) {
|
for (j = 0; j < numwads; j++) {
|
||||||
for (k = 0; k < w->wads[j].header.numlumps; k++)
|
for (k = 0; k < wads[j].header.numlumps; k++)
|
||||||
if (!strcasecmp(rgszMiptex[i], w->wads[j].lumps[k].name)) {
|
if (!strcasecmp(rgszMiptex[i], wads[j].lumps[k].name)) {
|
||||||
// Found it. Add in the size and skip to outer loop.
|
// Found it. Add in the size and skip to outer loop.
|
||||||
pWorldEnt->cTexdata += w->wads[j].lumps[k].disksize;
|
pWorldEnt->cTexdata += wads[j].lumps[k].disksize;
|
||||||
j = numwads;
|
j = numwads;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// If we found the texture already, break out to outer loop
|
// If we found the texture already, break out to outer loop
|
||||||
if (k < w->wads[j].header.numlumps)
|
if (k < wads[j].header.numlumps)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,7 +152,7 @@ WADList_Process(wadlist_t *w, int numwads)
|
||||||
l = (dmiptexlump_t *)pWorldEnt->pTexdata;
|
l = (dmiptexlump_t *)pWorldEnt->pTexdata;
|
||||||
l->nummiptex = cMiptex;
|
l->nummiptex = cMiptex;
|
||||||
|
|
||||||
WADList_LoadTextures(w, numwads, l);
|
WADList_LoadTextures(wads, numwads, l);
|
||||||
|
|
||||||
// Last pass, mark unfound textures as such
|
// Last pass, mark unfound textures as such
|
||||||
for (i = 0; i < cMiptex; i++)
|
for (i = 0; i < cMiptex; i++)
|
||||||
|
|
@ -164,7 +164,7 @@ WADList_Process(wadlist_t *w, int numwads)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
WADList_LoadTextures(wadlist_t *w, int numwads, dmiptexlump_t *l)
|
WADList_LoadTextures(wad_t *wads, int numwads, dmiptexlump_t *l)
|
||||||
{
|
{
|
||||||
int i, j, len;
|
int i, j, len;
|
||||||
byte *data;
|
byte *data;
|
||||||
|
|
@ -177,7 +177,7 @@ WADList_LoadTextures(wadlist_t *w, int numwads, dmiptexlump_t *l)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
l->dataofs[j] = data - (byte *)l;
|
l->dataofs[j] = data - (byte *)l;
|
||||||
len = WAD_LoadLump(w->wads + i, rgszMiptex[j], data);
|
len = WAD_LoadLump(wads + i, rgszMiptex[j], data);
|
||||||
if (data + len - pWorldEnt->pTexdata > pWorldEnt->cTexdata)
|
if (data + len - pWorldEnt->pTexdata > pWorldEnt->cTexdata)
|
||||||
Message(msgError, errLowTextureCount);
|
Message(msgError, errLowTextureCount);
|
||||||
|
|
||||||
|
|
@ -211,7 +211,7 @@ WAD_LoadLump(wad_t *w, char *name, byte *dest)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
WADList_AddAnimatingTextures(wadlist_t *w, int numwads)
|
WADList_AddAnimatingTextures(wad_t *wads, int numwads)
|
||||||
{
|
{
|
||||||
int base;
|
int base;
|
||||||
int i, j, k, l;
|
int i, j, k, l;
|
||||||
|
|
@ -233,8 +233,8 @@ WADList_AddAnimatingTextures(wadlist_t *w, int numwads)
|
||||||
|
|
||||||
// see if this name exists in the wadfiles
|
// see if this name exists in the wadfiles
|
||||||
for (l = 0; l < numwads; l++)
|
for (l = 0; l < numwads; l++)
|
||||||
for (k = 0; k < w->wads[l].header.numlumps; k++)
|
for (k = 0; k < wads[l].header.numlumps; k++)
|
||||||
if (!strcasecmp(name, w->wads[l].lumps[k].name)) {
|
if (!strcasecmp(name, wads[l].lumps[k].name)) {
|
||||||
FindMiptex(name); // add to the miptex list
|
FindMiptex(name); // add to the miptex list
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
qbsp/wad.h
10
qbsp/wad.h
|
|
@ -46,12 +46,8 @@ typedef struct {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
} wad_t;
|
} wad_t;
|
||||||
|
|
||||||
typedef struct {
|
int WADList_Init(wad_t **wads, char *wadstring);
|
||||||
wad_t *wads;
|
void WADList_Process(wad_t *wads, int numwads);
|
||||||
} wadlist_t;
|
void WADList_Free(wad_t *wads, int numwads);
|
||||||
|
|
||||||
int WADList_Init(wadlist_t *list, char *wadstring);
|
|
||||||
void WADList_Process(wadlist_t *w, int numwads);
|
|
||||||
void WADList_Free(wadlist_t *w, int numwads);
|
|
||||||
|
|
||||||
#endif /* WAD_H */
|
#endif /* WAD_H */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue