mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- Made loading of Build's palette.dat automatic if it's found inside a loaded
group file, but the -bpal parameter remains for now. - Made loading of Build art tiles automatic if they are found inside a group file. Removed the corresponding command-line parameter. - Added support for Ken Silverman's group files. SVN r72 (trunk)
This commit is contained in:
parent
29cd024aba
commit
01a41a6f13
8 changed files with 140 additions and 75 deletions
|
@ -1,3 +1,10 @@
|
|||
May 1, 2006
|
||||
- Made loading of Build's palette.dat automatic if it's found inside a loaded
|
||||
group file, but the -bpal parameter remains for now.
|
||||
- Made loading of Build art tiles automatic if they are found inside a group
|
||||
file. Removed the corresponding command-line parameter.
|
||||
- Added support for Ken Silverman's group files.
|
||||
|
||||
April 30, 2006 (Changes by Graf Zahl)
|
||||
- Removed the DCorpseQueue class. It was no longer used and since
|
||||
the savegames it might have been used in have become incompatible
|
||||
|
|
|
@ -18,6 +18,7 @@ name::MainName::MainName (int next)
|
|||
: NextHash(next)
|
||||
{
|
||||
}
|
||||
|
||||
int name::FindName (const char *text, bool noCreate)
|
||||
{
|
||||
if (!Inited) InitBuckets ();
|
||||
|
|
|
@ -2727,38 +2727,33 @@ void R_InitTextures (void)
|
|||
|
||||
void R_InitBuildTiles ()
|
||||
{
|
||||
const char *artdir;
|
||||
int numartfiles;
|
||||
char artfile[] = "tilesXXX.art";
|
||||
int lumpnum;
|
||||
|
||||
if (NULL != (artdir = Args.CheckValue ("-art")))
|
||||
for (numartfiles = 0; numartfiles < 1000; numartfiles++)
|
||||
{
|
||||
char lastchar = artdir[strlen(artdir)-1];
|
||||
const char *optslash = (lastchar == '/' || lastchar == '\\') ? "" : "/";
|
||||
char artpath[PATH_MAX];
|
||||
|
||||
for (numartfiles = 0; ; numartfiles++)
|
||||
artfile[5] = numartfiles / 100 + '0';
|
||||
artfile[6] = numartfiles / 10 % 10 + '0';
|
||||
artfile[7] = numartfiles % 10 + '0';
|
||||
lumpnum = Wads.CheckNumForFullName (artfile);
|
||||
if (lumpnum < 0)
|
||||
{
|
||||
sprintf (artpath, "%s%stiles%03d.art", artdir, optslash, numartfiles);
|
||||
if (!FileExists (artpath))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
FileReader file (artpath);
|
||||
|
||||
// BADBAD: This memory is never explicitly deleted except when the
|
||||
// version number is wrong.
|
||||
BYTE *art = new BYTE[file.GetLength()];
|
||||
file.Read (art, file.GetLength());
|
||||
|
||||
if (LittleLong(*(DWORD *)art) != 1)
|
||||
{
|
||||
delete[] art;
|
||||
break;
|
||||
}
|
||||
|
||||
TexMan.AddTiles (art);
|
||||
break;
|
||||
}
|
||||
|
||||
// BADBAD: This memory is never explicitly deleted except when the
|
||||
// version number is wrong.
|
||||
BYTE *art = new BYTE[Wads.LumpLength (lumpnum)];
|
||||
Wads.ReadLump (lumpnum, art);
|
||||
|
||||
if (LittleLong(*(DWORD *)art) != 1)
|
||||
{
|
||||
delete[] art;
|
||||
break;
|
||||
}
|
||||
|
||||
TexMan.AddTiles (art);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2782,7 +2777,7 @@ void R_SetDefaultColormap (const char *name)
|
|||
BYTE remap[256];
|
||||
|
||||
// [RH] If using BUILD's palette.dat, generate the colormap
|
||||
if (Args.CheckValue ("-bpal") != NULL)
|
||||
if (Args.CheckParm ("-bpal") || Wads.CheckNumForFullName("palette.dat"))
|
||||
{
|
||||
Printf ("Make colormap\n");
|
||||
FDynamicColormap foo;
|
||||
|
|
|
@ -297,48 +297,67 @@ static int STACK_ARGS sortforremap2 (const void *a, const void *b)
|
|||
}
|
||||
}
|
||||
|
||||
static void FixBuildPalette (BYTE *pal)
|
||||
{
|
||||
int c;
|
||||
|
||||
// Reverse the palette because BUILD used entry 255 as
|
||||
// transparent, but we use 0 as transparent.
|
||||
for (c = 0; c < 768/2; c += 3)
|
||||
{
|
||||
BYTE temp[3] =
|
||||
{
|
||||
(pal[c] << 2) | (pal[c] >> 4),
|
||||
(pal[c+1] << 2) | (pal[c+1] >> 4),
|
||||
(pal[c+2] << 2) | (pal[c+2] >> 4)
|
||||
};
|
||||
pal[c] = (pal[765-c] << 2) | (pal[765-c] >> 4);
|
||||
pal[c+1] = (pal[766-c] << 2) | (pal[766-c] >> 4);
|
||||
pal[c+2] = (pal[767-c] << 2) | (pal[767-c] >> 4);
|
||||
pal[765-c] = temp[0];
|
||||
pal[766-c] = temp[1];
|
||||
pal[767-c] = temp[2];
|
||||
}
|
||||
}
|
||||
|
||||
void InitPalette ()
|
||||
{
|
||||
BYTE pal[768];
|
||||
BYTE *shade;
|
||||
int c;
|
||||
const char *buildPal;
|
||||
bool usingBuild = false;
|
||||
|
||||
buildPal = Args.CheckValue ("-bpal");
|
||||
if (buildPal != NULL)
|
||||
{
|
||||
int f = open (buildPal, O_BINARY | O_RDONLY);
|
||||
if (f >= 0 && read (f, pal, 768) == 768)
|
||||
{
|
||||
// Reverse the palette because BUILD used entry 255 as
|
||||
// transparent, but we use 0 as transparent.
|
||||
for (c = 0; c < 768/2; c += 3)
|
||||
{
|
||||
BYTE temp[3] =
|
||||
{
|
||||
(pal[c] << 2) | (pal[c] >> 4),
|
||||
(pal[c+1] << 2) | (pal[c+1] >> 4),
|
||||
(pal[c+2] << 2) | (pal[c+2] >> 4)
|
||||
};
|
||||
pal[c] = (pal[765-c] << 2) | (pal[765-c] >> 4);
|
||||
pal[c+1] = (pal[766-c] << 2) | (pal[766-c] >> 4);
|
||||
pal[c+2] = (pal[767-c] << 2) | (pal[767-c] >> 4);
|
||||
pal[765-c] = temp[0];
|
||||
pal[766-c] = temp[1];
|
||||
pal[767-c] = temp[2];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buildPal = NULL;
|
||||
}
|
||||
if (f >= 0)
|
||||
{
|
||||
if (read (f, pal, 768) == 768)
|
||||
{
|
||||
FixBuildPalette (pal);
|
||||
usingBuild = true;
|
||||
}
|
||||
close (f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int lump = Wads.CheckNumForFullName ("palette.dat");
|
||||
|
||||
if (buildPal == NULL)
|
||||
if (lump >= 0 && Wads.LumpLength (lump) >= 768)
|
||||
{
|
||||
FWadLump data = Wads.OpenLumpNum (lump);
|
||||
if (data.Read (pal, 768) == 768)
|
||||
{
|
||||
FixBuildPalette (pal);
|
||||
usingBuild = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!usingBuild)
|
||||
{
|
||||
FWadLump palump = Wads.OpenLumpName ("PLAYPAL");
|
||||
palump.Read (pal, 768);
|
||||
|
|
|
@ -46,13 +46,6 @@ struct rffinfo_t
|
|||
DWORD NumLumps;
|
||||
};
|
||||
|
||||
union MergedHeader
|
||||
{
|
||||
DWORD magic;
|
||||
wadinfo_t wad;
|
||||
rffinfo_t rff;
|
||||
};
|
||||
|
||||
struct rfflump_t
|
||||
{
|
||||
BYTE IDontKnow[16];
|
||||
|
@ -65,6 +58,27 @@ struct rfflump_t
|
|||
BYTE WhatIsThis[4];
|
||||
};
|
||||
|
||||
struct grpinfo_t
|
||||
{
|
||||
DWORD Magic[3];
|
||||
DWORD NumLumps;
|
||||
};
|
||||
|
||||
struct grplump_t
|
||||
{
|
||||
char Name[12];
|
||||
DWORD Size;
|
||||
};
|
||||
|
||||
union MergedHeader
|
||||
{
|
||||
DWORD magic[3];
|
||||
wadinfo_t wad;
|
||||
rffinfo_t rff;
|
||||
grpinfo_t grp;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// WADFILE I/O related stuff.
|
||||
//
|
||||
|
@ -341,7 +355,7 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt
|
|||
|
||||
wadinfo->Name = copystring (filename);
|
||||
|
||||
if (header.magic == IWAD_ID || header.magic == PWAD_ID)
|
||||
if (header.magic[0] == IWAD_ID || header.magic[0] == PWAD_ID)
|
||||
{ // This is a WAD file
|
||||
|
||||
header.wad.NumLumps = LittleLong(header.wad.NumLumps);
|
||||
|
@ -352,7 +366,7 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt
|
|||
NumLumps += header.wad.NumLumps;
|
||||
Printf (" (%ld lumps)", header.wad.NumLumps);
|
||||
}
|
||||
else if (header.magic == RFF_ID)
|
||||
else if (header.magic[0] == RFF_ID)
|
||||
{ // This is a Blood RFF file
|
||||
|
||||
rfflump_t *lumps, *rff_p;
|
||||
|
@ -403,7 +417,37 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt
|
|||
LumpInfo = (LumpRecord *)Realloc (LumpInfo, NumLumps*sizeof(LumpRecord));
|
||||
}
|
||||
}
|
||||
else if (header.magic==ZIP_ID)
|
||||
else if (header.magic[0] == GRP_ID_0 && header.magic[1] == GRP_ID_1 && header.magic[2] == GRP_ID_2)
|
||||
{
|
||||
grplump_t *lumps, *grp_p;
|
||||
int pos;
|
||||
|
||||
header.grp.NumLumps = LittleLong(header.grp.NumLumps);
|
||||
lumps = new grplump_t[header.grp.NumLumps];
|
||||
wadinfo->Read (lumps, header.grp.NumLumps * sizeof(grplump_t));
|
||||
pos = sizeof(grpinfo_t) + header.grp.NumLumps * sizeof(grplump_t);
|
||||
|
||||
NumLumps += header.grp.NumLumps;
|
||||
LumpInfo = (LumpRecord *)Realloc (LumpInfo, NumLumps*sizeof(LumpRecord));
|
||||
lump_p = &LumpInfo[startlump];
|
||||
|
||||
for (i = 0, grp_p = lumps; i < header.grp.NumLumps; ++i, ++grp_p)
|
||||
{
|
||||
lump_p->wadnum = (WORD)NumWads;
|
||||
lump_p->position = pos;
|
||||
lump_p->size = LittleLong(grp_p->Size);
|
||||
pos += lump_p->size;
|
||||
grp_p->Name[12] = '\0'; // Be sure filename is null-terminated
|
||||
lump_p->fullname = copystring(grp_p->Name);
|
||||
uppercopy (lump_p->name, grp_p->Name);
|
||||
lump_p->compressedsize = -1;
|
||||
lump_p->flags = 0;
|
||||
lump_p->namespc = ns_global;
|
||||
lump_p++;
|
||||
}
|
||||
Printf (" (%ld files)", header.grp.NumLumps);
|
||||
}
|
||||
else if (header.magic[0] == ZIP_ID)
|
||||
{
|
||||
DWORD centraldir = Zip_FindCentralDir(wadinfo);
|
||||
FZipCentralInfo info;
|
||||
|
@ -567,7 +611,9 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt
|
|||
Printf ("\n");
|
||||
|
||||
// Fill in lumpinfo
|
||||
if (header.magic != RFF_ID && header.magic != ZIP_ID)
|
||||
if (header.magic[0] != RFF_ID &&
|
||||
header.magic[0] != ZIP_ID &&
|
||||
(header.magic[0] != GRP_ID_0 || header.magic[1] != GRP_ID_1 || header.magic[2] != GRP_ID_2))
|
||||
{
|
||||
LumpInfo = (LumpRecord *)Realloc (LumpInfo, NumLumps*sizeof(LumpRecord));
|
||||
lump_p = &LumpInfo[startlump];
|
||||
|
|
19
src/w_wad.h
19
src/w_wad.h
|
@ -24,19 +24,16 @@
|
|||
#define __W_WAD__
|
||||
|
||||
#include "files.h"
|
||||
#include "doomdef.h"
|
||||
|
||||
// [RH] Compare wad header as ints instead of chars
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define IWAD_ID (('I'<<24)|('W'<<16)|('A'<<8)|('D'))
|
||||
#define PWAD_ID (('P'<<24)|('W'<<16)|('A'<<8)|('D'))
|
||||
#define RFF_ID (('R'<<24)|('F'<<16)|('F'<<8)|(0x1a))
|
||||
#define ZIP_ID (('P'<<24)|('K'<<16)|(3<<8)|(4))
|
||||
#else
|
||||
#define IWAD_ID (('I')|('W'<<8)|('A'<<16)|('D'<<24))
|
||||
#define PWAD_ID (('P')|('W'<<8)|('A'<<16)|('D'<<24))
|
||||
#define RFF_ID (('R')|('F'<<8)|('F'<<16)|(0x1a<<24))
|
||||
#define ZIP_ID (('P')|('K'<<8)|(3<<16)|(4<<24))
|
||||
#endif
|
||||
#define IWAD_ID MAKE_ID('I','W','A','D')
|
||||
#define PWAD_ID MAKE_ID('P','W','A','D')
|
||||
#define RFF_ID MAKE_ID('R','F','F',0x1a)
|
||||
#define ZIP_ID MAKE_ID('P','K',3,4)
|
||||
#define GRP_ID_0 MAKE_ID('K','e','n','S')
|
||||
#define GRP_ID_1 MAKE_ID('i','l','v','e')
|
||||
#define GRP_ID_2 MAKE_ID('r','m','a','n')
|
||||
|
||||
// [RH] Remove limit on number of WAD files
|
||||
struct wadlist_t
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue