2006-02-24 04:48:15 +00: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.
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
// WAD I/O functions.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __W_WAD__
|
|
|
|
#define __W_WAD__
|
|
|
|
|
|
|
|
#include "files.h"
|
2006-05-02 04:38:12 +00:00
|
|
|
#include "doomdef.h"
|
2006-08-17 22:10:50 +00:00
|
|
|
#include "tarray.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-04-23 22:49:38 +00:00
|
|
|
class FResourceFile;
|
|
|
|
struct FResourceLump;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
struct wadinfo_t
|
|
|
|
{
|
|
|
|
// Should be "IWAD" or "PWAD".
|
|
|
|
DWORD Magic;
|
|
|
|
DWORD NumLumps;
|
|
|
|
DWORD InfoTableOfs;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wadlump_t
|
|
|
|
{
|
|
|
|
DWORD FilePos;
|
|
|
|
DWORD Size;
|
|
|
|
char Name[8];
|
|
|
|
};
|
|
|
|
|
2009-04-23 22:49:38 +00:00
|
|
|
#define IWAD_ID MAKE_ID('I','W','A','D')
|
|
|
|
#define PWAD_ID MAKE_ID('P','W','A','D')
|
|
|
|
|
|
|
|
|
|
|
|
// [RH] Remove limit on number of WAD files
|
|
|
|
struct wadlist_t
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
2009-04-23 22:49:38 +00:00
|
|
|
wadlist_t *next;
|
|
|
|
char name[1]; // +size of string
|
2008-01-26 23:20:34 +00:00
|
|
|
};
|
2009-04-23 22:49:38 +00:00
|
|
|
extern wadlist_t *wadfiles;
|
2008-01-26 23:20:34 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Namespaces from BOOM.
|
|
|
|
typedef enum {
|
|
|
|
ns_global = 0,
|
|
|
|
ns_sprites,
|
|
|
|
ns_flats,
|
|
|
|
ns_colormaps,
|
|
|
|
ns_acslibrary,
|
|
|
|
ns_newtextures,
|
|
|
|
ns_bloodraw,
|
|
|
|
ns_bloodsfx,
|
|
|
|
ns_bloodmisc,
|
|
|
|
ns_strifevoices,
|
2006-04-14 16:25:57 +00:00
|
|
|
ns_hires,
|
2006-06-19 15:31:10 +00:00
|
|
|
|
|
|
|
// These namespaces are only used to mark lumps in special subdirectories
|
|
|
|
// so that their contents doesn't interfere with the global namespace.
|
|
|
|
// searching for data in these namespaces works differently for lumps coming
|
|
|
|
// from Zips or other files.
|
|
|
|
ns_specialzipdirectory,
|
|
|
|
ns_sounds,
|
|
|
|
ns_patches,
|
|
|
|
ns_graphics,
|
|
|
|
ns_music,
|
2009-04-23 22:49:38 +00:00
|
|
|
|
|
|
|
ns_firstskin,
|
2006-02-24 04:48:15 +00:00
|
|
|
} namespace_t;
|
|
|
|
|
2009-04-23 22:49:38 +00:00
|
|
|
enum ELumpFlags
|
|
|
|
{
|
|
|
|
LUMPF_MAYBEFLAT=1,
|
|
|
|
LUMPF_ZIPFILE=2,
|
|
|
|
LUMPF_EMBEDDED=4,
|
|
|
|
LUMPF_BLOODCRYPT = 8,
|
|
|
|
};
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-06-15 03:31:19 +00:00
|
|
|
|
2009-04-23 22:49:38 +00:00
|
|
|
// [RH] Copy an 8-char string and uppercase it.
|
|
|
|
void uppercopy (char *to, const char *from);
|
2009-03-22 11:37:56 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// A very loose reference to a lump on disk. This is really just a wrapper
|
|
|
|
// around the main wad's FILE object with a different length recorded. Since
|
2007-12-28 01:54:14 +00:00
|
|
|
// two lumps from the same wad share the same FILE, you cannot read from
|
2006-02-24 04:48:15 +00:00
|
|
|
// both of them independantly.
|
|
|
|
class FWadLump : public FileReader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FWadLump ();
|
|
|
|
FWadLump (const FWadLump ©);
|
2006-04-14 16:25:57 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
FWadLump & operator= (const FWadLump ©);
|
|
|
|
#endif
|
|
|
|
~FWadLump();
|
|
|
|
|
|
|
|
long Seek (long offset, int origin);
|
|
|
|
long Read (void *buffer, long len);
|
2008-04-11 10:16:29 +00:00
|
|
|
char *Gets(char *strbuf, int len);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
private:
|
2009-04-23 22:49:38 +00:00
|
|
|
FWadLump (FResourceLump *Lump, bool alwayscache = false);
|
2006-04-14 16:25:57 +00:00
|
|
|
|
2009-04-23 22:49:38 +00:00
|
|
|
FResourceLump *Lump;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
friend class FWadCollection;
|
|
|
|
};
|
|
|
|
|
2006-04-14 16:25:57 +00:00
|
|
|
|
2007-01-25 04:02:06 +00:00
|
|
|
// A lump in memory.
|
2006-02-24 04:48:15 +00:00
|
|
|
class FMemLump
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FMemLump ();
|
2007-01-25 04:02:06 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
FMemLump (const FMemLump ©);
|
|
|
|
FMemLump &operator= (const FMemLump ©);
|
|
|
|
~FMemLump ();
|
2007-01-28 03:17:02 +00:00
|
|
|
void *GetMem () { return Block.Len() == 0 ? NULL : (void *)Block.GetChars(); }
|
2007-01-28 04:59:04 +00:00
|
|
|
size_t GetSize () { return Block.Len(); }
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
FString GetString () { return Block; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
private:
|
2007-01-25 04:02:06 +00:00
|
|
|
FMemLump (const FString &source);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-01-25 04:02:06 +00:00
|
|
|
FString Block;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
friend class FWadCollection;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FWadCollection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FWadCollection ();
|
2006-04-14 16:25:57 +00:00
|
|
|
~FWadCollection ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// The wadnum for the IWAD
|
|
|
|
enum { IWAD_FILENUM = 1 };
|
|
|
|
|
2009-05-31 10:49:47 +00:00
|
|
|
void InitMultipleFiles (wadlist_t **filenames, const char *loaddir);
|
|
|
|
void AddFile (const char *filename, FileReader *wadinfo = NULL, bool isdir = false);
|
2006-05-03 22:45:01 +00:00
|
|
|
int CheckIfWadLoaded (const char *name);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
const char *GetWadName (int wadnum) const;
|
|
|
|
const char *GetWadFullName (int wadnum) const;
|
|
|
|
|
2009-04-23 22:49:38 +00:00
|
|
|
int GetFirstLump(int wadnum) const;
|
|
|
|
int GetLastLump(int wadnum) const;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
int CheckNumForName (const char *name, int namespc);
|
2008-01-26 23:20:34 +00:00
|
|
|
int CheckNumForName (const char *name, int namespc, int wadfile, bool exact = true);
|
2006-06-19 15:31:10 +00:00
|
|
|
int GetNumForName (const char *name, int namespc);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
inline int CheckNumForName (const BYTE *name) { return CheckNumForName ((const char *)name, ns_global); }
|
2006-02-24 04:48:15 +00:00
|
|
|
inline int CheckNumForName (const char *name) { return CheckNumForName (name, ns_global); }
|
2006-09-14 00:02:31 +00:00
|
|
|
inline int CheckNumForName (const BYTE *name, int ns) { return CheckNumForName ((const char *)name, ns); }
|
2006-06-19 15:31:10 +00:00
|
|
|
inline int GetNumForName (const char *name) { return GetNumForName (name, ns_global); }
|
2006-09-14 00:02:31 +00:00
|
|
|
inline int GetNumForName (const BYTE *name) { return GetNumForName ((const char *)name); }
|
|
|
|
inline int GetNumForName (const BYTE *name, int ns) { return GetNumForName ((const char *)name, ns); }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-29 22:59:41 +00:00
|
|
|
int CheckNumForFullName (const char *name, bool trynormal = false, int namespc = ns_global);
|
2006-04-14 16:25:57 +00:00
|
|
|
int CheckNumForFullName (const char *name, int wadfile);
|
|
|
|
int GetNumForFullName (const char *name);
|
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void ReadLump (int lump, void *dest);
|
|
|
|
FMemLump ReadLump (int lump);
|
|
|
|
FMemLump ReadLump (const char *name) { return ReadLump (GetNumForName (name)); }
|
|
|
|
|
|
|
|
FWadLump OpenLumpNum (int lump);
|
|
|
|
FWadLump OpenLumpName (const char *name) { return OpenLumpNum (GetNumForName (name)); }
|
2006-06-14 15:56:56 +00:00
|
|
|
FWadLump *ReopenLumpNum (int lump); // Opens a new, independent FILE
|
|
|
|
|
|
|
|
FileReader * GetFileReader(int wadnum); // Gets a FileReader object to the entire WAD
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int FindLump (const char *name, int *lastlump, bool anyns=false); // [RH] Find lumps with duplication
|
|
|
|
bool CheckLumpName (int lump, const char *name); // [RH] True if lump's name == name
|
|
|
|
|
|
|
|
static DWORD LumpNameHash (const char *name); // [RH] Create hash key from an 8-char name
|
|
|
|
|
|
|
|
int LumpLength (int lump) const;
|
2007-04-30 08:09:51 +00:00
|
|
|
int GetLumpOffset (int lump); // [RH] Returns offset of lump in the wadfile
|
2008-01-26 23:20:34 +00:00
|
|
|
int GetLumpFlags (int lump); // Return the flags for this lump
|
2006-02-24 04:48:15 +00:00
|
|
|
void GetLumpName (char *to, int lump) const; // [RH] Copies the lump name to to using uppercopy
|
2006-05-03 22:45:01 +00:00
|
|
|
const char *GetLumpFullName (int lump) const; // [RH] Returns the lump's full name
|
2008-04-03 03:19:21 +00:00
|
|
|
FString GetLumpFullPath (int lump) const; // [RH] Returns wad's name + lump's full name
|
2006-02-24 04:48:15 +00:00
|
|
|
int GetLumpFile (int lump) const; // [RH] Returns wadnum for a specified lump
|
|
|
|
int GetLumpNamespace (int lump) const; // [RH] Returns the namespace a lump belongs to
|
|
|
|
bool CheckLumpName (int lump, const char *name) const; // [RH] Returns true if the names match
|
|
|
|
|
2006-04-14 12:58:52 +00:00
|
|
|
bool IsUncompressedFile(int lump) const;
|
2006-06-15 03:31:19 +00:00
|
|
|
bool IsEncryptedFile(int lump) const;
|
2006-04-14 16:25:57 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
int GetNumLumps () const;
|
2008-01-26 23:20:34 +00:00
|
|
|
int GetNumWads () const;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-08-17 22:10:50 +00:00
|
|
|
int AddExternalFile(const char *filename);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
protected:
|
2009-04-23 22:49:38 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
struct LumpRecord;
|
|
|
|
|
2009-04-23 22:49:38 +00:00
|
|
|
TArray<FResourceFile *> Files;
|
|
|
|
TArray<LumpRecord> LumpInfo;
|
|
|
|
|
2009-03-21 09:03:08 +00:00
|
|
|
DWORD *FirstLumpIndex; // [RH] Hashing stuff moved out of lumpinfo structure
|
|
|
|
DWORD *NextLumpIndex;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-03-21 09:03:08 +00:00
|
|
|
DWORD *FirstLumpIndex_FullName; // The same information for fully qualified paths from .zips
|
|
|
|
DWORD *NextLumpIndex_FullName;
|
2006-04-14 16:25:57 +00:00
|
|
|
|
2006-08-17 22:10:50 +00:00
|
|
|
DWORD NumLumps; // Not necessarily the same as LumpInfo.Size()
|
2006-02-24 04:48:15 +00:00
|
|
|
DWORD NumWads;
|
|
|
|
|
|
|
|
void SkinHack (int baselump);
|
|
|
|
void InitHashChains (); // [RH] Set up the lumpinfo hashing
|
|
|
|
|
|
|
|
private:
|
2009-04-30 11:10:38 +00:00
|
|
|
void RenameSprites ();
|
2009-03-21 09:03:08 +00:00
|
|
|
void DeleteAll();
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern FWadCollection Wads;
|
|
|
|
|
|
|
|
#endif
|