mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-27 22:42:57 +00:00
SVN r191 (trunk)
This commit is contained in:
parent
6e198e034b
commit
d99f5b4b99
7 changed files with 165 additions and 104 deletions
|
@ -1,4 +1,8 @@
|
||||||
June 14, 2006
|
June 14, 2006
|
||||||
|
- Fixed loading of Build/Blood maps.
|
||||||
|
- FWadLump::Read() now handles Blood decryption directly.
|
||||||
|
- Fixed: A fatal error thrown during map loading after the sectors have been
|
||||||
|
counted but before they are allocated crashed in PointerSubstitution().
|
||||||
- Removed my "backwards compatibility fix" for APROP_Speed. It turns out that
|
- Removed my "backwards compatibility fix" for APROP_Speed. It turns out that
|
||||||
in all the public versions where monster speed is not fixed point, you
|
in all the public versions where monster speed is not fixed point, you
|
||||||
couldn't modify the monster's speed due to a bug in P_Move() anyway. So
|
couldn't modify the monster's speed due to a bug in P_Move() anyway. So
|
||||||
|
|
|
@ -499,11 +499,14 @@ void DObject::PointerSubstitution (DObject *old, DObject *notOld)
|
||||||
players[i].FixPointers (old, notOld);
|
players[i].FixPointers (old, notOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (unsigned int)numsectors; ++i)
|
if (sectors != NULL)
|
||||||
{
|
{
|
||||||
if (sectors[i].SoundTarget == old)
|
for (i = 0; i < (unsigned int)numsectors; ++i)
|
||||||
{
|
{
|
||||||
sectors[i].SoundTarget = static_cast<AActor *>(notOld);
|
if (sectors[i].SoundTarget == old)
|
||||||
|
{
|
||||||
|
sectors[i].SoundTarget = static_cast<AActor *>(notOld);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,6 +742,8 @@ static void CalcPlane (SlopeWork &slope, secplane_t &plane)
|
||||||
//
|
//
|
||||||
// Decrypt
|
// Decrypt
|
||||||
//
|
//
|
||||||
|
// Note that this is different from the general RFF encryption.
|
||||||
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void Decrypt (void *to_, const void *from_, int len, int key)
|
static void Decrypt (void *to_, const void *from_, int len, int key)
|
||||||
|
@ -749,13 +751,9 @@ static void Decrypt (void *to_, const void *from_, int len, int key)
|
||||||
BYTE *to = (BYTE *)to_;
|
BYTE *to = (BYTE *)to_;
|
||||||
const BYTE *from = (const BYTE *)from_;
|
const BYTE *from = (const BYTE *)from_;
|
||||||
|
|
||||||
while (len > 0)
|
for (int i = 0; i < len; ++i, ++key)
|
||||||
{
|
{
|
||||||
*to = *from ^ key;
|
to[i] = from[i] ^ key;
|
||||||
to++;
|
|
||||||
from++;
|
|
||||||
key++;
|
|
||||||
len--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,30 +181,33 @@ static void P_SetSideNum (DWORD *sidenum_p, WORD sidenum);
|
||||||
//
|
//
|
||||||
// GetMapIndex
|
// GetMapIndex
|
||||||
//
|
//
|
||||||
// Gets the type of map lump or -1 if invalid
|
// Gets the type of map lump or -1 if invalid or -2 if required and not found.
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
static int GetMapIndex(const char * mapname, int lastindex, const char * lumpname)
|
struct checkstruct
|
||||||
{
|
{
|
||||||
static struct checkstruct
|
char *lumpname;
|
||||||
|
bool required;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int GetMapIndex(const char *mapname, int lastindex, const char *lumpname, bool needrequired)
|
||||||
|
{
|
||||||
|
static const checkstruct check[] =
|
||||||
{
|
{
|
||||||
char * lumpname;
|
{NULL, true},
|
||||||
bool required;
|
{"THINGS", true},
|
||||||
} check[]={
|
|
||||||
{NULL, true},
|
|
||||||
{"THINGS", true},
|
|
||||||
{"LINEDEFS", true},
|
{"LINEDEFS", true},
|
||||||
{"SIDEDEFS", true},
|
{"SIDEDEFS", true},
|
||||||
{"VERTEXES", true},
|
{"VERTEXES", true},
|
||||||
{"SEGS", false},
|
{"SEGS", false},
|
||||||
{"SSECTORS", false},
|
{"SSECTORS", false},
|
||||||
{"NODES", false},
|
{"NODES", false},
|
||||||
{"SECTORS", true},
|
{"SECTORS", true},
|
||||||
{"REJECT", false},
|
{"REJECT", false},
|
||||||
{"BLOCKMAP", false},
|
{"BLOCKMAP", false},
|
||||||
{"BEHAVIOR", false},
|
{"BEHAVIOR", false},
|
||||||
{"SCRIPTS", false},
|
{"SCRIPTS", false},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (lumpname==NULL) lumpname="";
|
if (lumpname==NULL) lumpname="";
|
||||||
|
@ -216,7 +219,11 @@ static int GetMapIndex(const char * mapname, int lastindex, const char * lumpnam
|
||||||
|
|
||||||
if (check[i].required)
|
if (check[i].required)
|
||||||
{
|
{
|
||||||
I_Error("'%s' not found in %s\n", check[i].lumpname, mapname);
|
if (needrequired)
|
||||||
|
{
|
||||||
|
I_Error("'%s' not found in %s\n", check[i].lumpname, mapname);
|
||||||
|
}
|
||||||
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +236,7 @@ static int GetMapIndex(const char * mapname, int lastindex, const char * lumpnam
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
MapData * P_OpenMapData(const char * mapname)
|
MapData *P_OpenMapData(const char * mapname)
|
||||||
{
|
{
|
||||||
MapData * map = new MapData;
|
MapData * map = new MapData;
|
||||||
bool externalfile = !strnicmp(mapname, "file:", 5);
|
bool externalfile = !strnicmp(mapname, "file:", 5);
|
||||||
|
@ -237,7 +244,7 @@ MapData * P_OpenMapData(const char * mapname)
|
||||||
|
|
||||||
if (externalfile)
|
if (externalfile)
|
||||||
{
|
{
|
||||||
mapname+=5;
|
mapname += 5;
|
||||||
if (!FileExists(mapname))
|
if (!FileExists(mapname))
|
||||||
{
|
{
|
||||||
delete map;
|
delete map;
|
||||||
|
@ -269,14 +276,20 @@ MapData * P_OpenMapData(const char * mapname)
|
||||||
|
|
||||||
map->MapLumps[0].FilePos = Wads.GetLumpOffset(lump_name);
|
map->MapLumps[0].FilePos = Wads.GetLumpOffset(lump_name);
|
||||||
map->MapLumps[0].Size = Wads.LumpLength(lump_name);
|
map->MapLumps[0].Size = Wads.LumpLength(lump_name);
|
||||||
|
map->Encrypted = Wads.IsEncryptedFile(lump_name);
|
||||||
|
|
||||||
int index=0;
|
if (map->Encrypted)
|
||||||
for(int i=1;;i++)
|
{ // If it's encrypted, then it's a Blood file, presumably a map.
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for(int i = 1;; i++)
|
||||||
{
|
{
|
||||||
// Since levels must be stored in WADs they can't really have full
|
// Since levels must be stored in WADs they can't really have full
|
||||||
// names and for any valid level lump this always returns the short name.
|
// names and for any valid level lump this always returns the short name.
|
||||||
const char * lumpname = Wads.GetLumpFullName(lump_name + i);
|
const char * lumpname = Wads.GetLumpFullName(lump_name + i);
|
||||||
index = GetMapIndex(mapname, index, lumpname);
|
index = GetMapIndex(mapname, index, lumpname, i != 1 || map->MapLumps[0].Size == 0);
|
||||||
|
|
||||||
// The next lump is not part of this map anymore
|
// The next lump is not part of this map anymore
|
||||||
if (index < 0) break;
|
if (index < 0) break;
|
||||||
|
@ -325,7 +338,7 @@ MapData * P_OpenMapData(const char * mapname)
|
||||||
|
|
||||||
if (i>0)
|
if (i>0)
|
||||||
{
|
{
|
||||||
index = GetMapIndex(maplabel, index, lumpname);
|
index = GetMapIndex(maplabel, index, lumpname, true);
|
||||||
|
|
||||||
// The next lump is not part of this map anymore
|
// The next lump is not part of this map anymore
|
||||||
if (index < 0) break;
|
if (index < 0) break;
|
||||||
|
@ -468,7 +481,6 @@ void P_FloodZones ()
|
||||||
|
|
||||||
void P_LoadVertexes (MapData * map)
|
void P_LoadVertexes (MapData * map)
|
||||||
{
|
{
|
||||||
FWadLump data;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Determine number of vertices:
|
// Determine number of vertices:
|
||||||
|
@ -3362,7 +3374,18 @@ void P_SetupLevel (char *lumpname, int position)
|
||||||
if (map->MapLumps[0].Size > 0)
|
if (map->MapLumps[0].Size > 0)
|
||||||
{
|
{
|
||||||
BYTE *mapdata = new BYTE[map->MapLumps[0].Size];
|
BYTE *mapdata = new BYTE[map->MapLumps[0].Size];
|
||||||
|
map->Seek(0);
|
||||||
map->file->Read(mapdata, map->MapLumps[0].Size);
|
map->file->Read(mapdata, map->MapLumps[0].Size);
|
||||||
|
if (map->Encrypted)
|
||||||
|
{
|
||||||
|
// Why can't the linker find this function? Ugh.
|
||||||
|
//BloodCrypt (mapdata, 0, MIN<int> (map->MapLumps[0].Size, 256));
|
||||||
|
int len = MIN<int> (map->MapLumps[0].Size, 256);
|
||||||
|
for (int i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
mapdata[i] ^= i >> 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
buildmap = P_LoadBuildMap (mapdata, map->MapLumps[0].Size, &buildthings, &numbuildthings);
|
buildmap = P_LoadBuildMap (mapdata, map->MapLumps[0].Size, &buildthings, &numbuildthings);
|
||||||
delete[] mapdata;
|
delete[] mapdata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ struct MapData
|
||||||
wadlump_t MapLumps[ML_BEHAVIOR+1];
|
wadlump_t MapLumps[ML_BEHAVIOR+1];
|
||||||
bool HasBehavior;
|
bool HasBehavior;
|
||||||
bool CloseOnDestruct;
|
bool CloseOnDestruct;
|
||||||
|
bool Encrypted;
|
||||||
int lumpnum;
|
int lumpnum;
|
||||||
FileReader * file;
|
FileReader * file;
|
||||||
|
|
||||||
|
@ -40,9 +41,10 @@ struct MapData
|
||||||
{
|
{
|
||||||
memset(MapLumps, 0, sizeof(MapLumps));
|
memset(MapLumps, 0, sizeof(MapLumps));
|
||||||
file = NULL;
|
file = NULL;
|
||||||
lumpnum=-1;
|
lumpnum = -1;
|
||||||
HasBehavior=false;
|
HasBehavior = false;
|
||||||
CloseOnDestruct=true;
|
CloseOnDestruct = true;
|
||||||
|
Encrypted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
~MapData()
|
~MapData()
|
||||||
|
|
161
src/w_wad.cpp
161
src/w_wad.cpp
|
@ -1603,10 +1603,6 @@ void FWadCollection::ReadLump (int lump, void *dest)
|
||||||
I_Error ("W_ReadLump: only read %ld of %ld on lump %i\n",
|
I_Error ("W_ReadLump: only read %ld of %ld on lump %i\n",
|
||||||
numread, size, lump);
|
numread, size, lump);
|
||||||
}
|
}
|
||||||
if (LumpInfo[lump].flags & LUMPF_BLOODCRYPT)
|
|
||||||
{
|
|
||||||
BloodCrypt (dest, 0, MIN<int> (size, 256));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1629,10 +1625,6 @@ FMemLump FWadCollection::ReadLump (int lump)
|
||||||
I_Error ("W_ReadLump: only read %ld of %ld on lump %i\n",
|
I_Error ("W_ReadLump: only read %ld of %ld on lump %i\n",
|
||||||
numread, size, lump);
|
numread, size, lump);
|
||||||
}
|
}
|
||||||
if (LumpInfo[lump].flags & LUMPF_BLOODCRYPT)
|
|
||||||
{
|
|
||||||
BloodCrypt (dest, 0, MIN<int> (size, 256));
|
|
||||||
}
|
|
||||||
return FMemLump (dest);
|
return FMemLump (dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1657,40 +1649,29 @@ FWadLump FWadCollection::OpenLumpNum (int lump)
|
||||||
|
|
||||||
l = &LumpInfo[lump];
|
l = &LumpInfo[lump];
|
||||||
wad = Wads[l->wadnum];
|
wad = Wads[l->wadnum];
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Blood encryption?
|
|
||||||
if (writeable || l->flags & LUMPF_BLOODCRYPT)
|
|
||||||
{
|
|
||||||
ptr = Malloc (l->size);
|
|
||||||
NonMappedPointers.insert (ptr);
|
|
||||||
W_ReadLump (lump, ptr);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wad->Seek (l->position, SEEK_SET);
|
wad->Seek (l->position, SEEK_SET);
|
||||||
|
|
||||||
if (l->flags & LUMPF_COMPRESSED)
|
if (l->flags & LUMPF_COMPRESSED)
|
||||||
{
|
{
|
||||||
// A compressed entry in a .zip file
|
// A compressed entry in a .zip file
|
||||||
char * buffer = new char[l->size+1]; // the last byte is used as a reference counter
|
char * buffer = new char[l->size+1]; // the last byte is used as a reference counter
|
||||||
|
buffer[l->size] = 0;
|
||||||
FileReaderZ frz(*wad, true);
|
FileReaderZ frz(*wad, true);
|
||||||
frz.Read(buffer, l->size);
|
frz.Read(buffer, l->size);
|
||||||
return FWadLump(buffer, l->size, true);
|
return FWadLump(buffer, l->size, true);
|
||||||
}
|
}
|
||||||
else if (wad->MemoryData!=NULL)
|
else if (wad->MemoryData != NULL)
|
||||||
{
|
{
|
||||||
// A lump from an embedded WAD
|
// A lump from an embedded WAD
|
||||||
// Handling this here creates less overhead than trying
|
// Handling this here creates less overhead than trying
|
||||||
// to do it inside the FWadLump class.
|
// to do it inside the FWadLump class.
|
||||||
|
|
||||||
return FWadLump((char*)wad->MemoryData+l->position, l->size, false);
|
return FWadLump((char*)wad->MemoryData + l->position, l->size, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// An uncompressed lump in a .wad or .zip
|
// An uncompressed lump in a .wad or .zip
|
||||||
return FWadLump (*wad, l->size);
|
return FWadLump (*wad, l->size, !!(l->flags & LUMPF_BLOODCRYPT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1835,6 +1816,23 @@ bool FWadCollection::IsUncompressedFile(int lump) const
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// IsEncryptedFile
|
||||||
|
//
|
||||||
|
// Returns true if the first 256 bytes of the lump are encrypted for Blood.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
bool FWadCollection::IsEncryptedFile(int lump) const
|
||||||
|
{
|
||||||
|
if ((unsigned)lump >= (unsigned)NumLumps)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !!(LumpInfo[lump].flags & LUMPF_BLOODCRYPT);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// W_SkinHack
|
// W_SkinHack
|
||||||
|
@ -1901,7 +1899,7 @@ void FWadCollection::SkinHack (int baselump)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void BloodCrypt (void *data, int key, int len)
|
void BloodCrypt (void *data, int key, int len)
|
||||||
{
|
{
|
||||||
int p = (BYTE)key, i;
|
int p = (BYTE)key, i;
|
||||||
|
|
||||||
|
@ -2013,7 +2011,7 @@ long FWadCollection::WadFileRecord::Read (void *buffer, long len)
|
||||||
// FWadLump -----------------------------------------------------------------
|
// FWadLump -----------------------------------------------------------------
|
||||||
|
|
||||||
FWadLump::FWadLump ()
|
FWadLump::FWadLump ()
|
||||||
: FileReader (), sourceData(NULL)
|
: FileReader(), SourceData(NULL), DestroySource(false), Encrypted(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2021,17 +2019,16 @@ FWadLump::FWadLump (const FWadLump ©)
|
||||||
{
|
{
|
||||||
// This must be defined isn't called.
|
// This must be defined isn't called.
|
||||||
File = copy.File;
|
File = copy.File;
|
||||||
Length=copy.Length;
|
Length = copy.Length;
|
||||||
FilePos=copy.FilePos;
|
FilePos = copy.FilePos;
|
||||||
StartPos=copy.StartPos;
|
StartPos = copy.StartPos;
|
||||||
CloseOnDestruct=false;
|
CloseOnDestruct = false;
|
||||||
if (copy.sourceData!=NULL)
|
SourceData = copy.SourceData;
|
||||||
|
DestroySource = copy.DestroySource;
|
||||||
|
if (SourceData != NULL && DestroySource)
|
||||||
{
|
{
|
||||||
sourceData=copy.sourceData;
|
SourceData[copy.Length]++;
|
||||||
destroySource=copy.destroySource;
|
|
||||||
if (destroySource) sourceData[copy.Length]++;
|
|
||||||
}
|
}
|
||||||
else sourceData=NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -2039,83 +2036,113 @@ FWadLump & FWadLump::operator= (const FWadLump ©)
|
||||||
{
|
{
|
||||||
// Only the debug build actually calls this!
|
// Only the debug build actually calls this!
|
||||||
File = copy.File;
|
File = copy.File;
|
||||||
Length=copy.Length;
|
Length = copy.Length;
|
||||||
FilePos=copy.FilePos;
|
FilePos = copy.FilePos;
|
||||||
StartPos=copy.StartPos;
|
StartPos = copy.StartPos;
|
||||||
CloseOnDestruct=false; // For WAD lumps this is always false!
|
CloseOnDestruct = false; // For WAD lumps this is always false!
|
||||||
if (copy.sourceData!=NULL)
|
SourceData = copy.SourceData;
|
||||||
|
DestroySource = copy.DestroySource;
|
||||||
|
if (SourceData != NULL && DestroySource)
|
||||||
{
|
{
|
||||||
sourceData=copy.sourceData;
|
SourceData[copy.Length]++;
|
||||||
destroySource=copy.destroySource;
|
|
||||||
if (destroySource) sourceData[copy.Length]++;
|
|
||||||
}
|
}
|
||||||
else sourceData=NULL;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FWadLump::FWadLump (const FileReader &other, long length)
|
FWadLump::FWadLump (const FileReader &other, long length, bool encrypted)
|
||||||
: FileReader (other, length), sourceData(NULL)
|
: FileReader(other, length), SourceData(NULL), DestroySource(false), Encrypted(encrypted)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FWadLump::FWadLump (FILE *file, long length)
|
FWadLump::FWadLump (FILE *file, long length)
|
||||||
: FileReader (file, length), sourceData(NULL)
|
: FileReader(file, length), SourceData(NULL), DestroySource(false), Encrypted(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FWadLump::FWadLump (char * data, long length, bool destroy)
|
FWadLump::FWadLump (char *data, long length, bool destroy)
|
||||||
: FileReader (), sourceData(data)
|
: FileReader(), SourceData(data), DestroySource(destroy), Encrypted(false)
|
||||||
{
|
{
|
||||||
FilePos = StartPos = 0;
|
FilePos = StartPos = 0;
|
||||||
Length=length;
|
Length = length;
|
||||||
destroySource=destroy;
|
if (destroy)
|
||||||
if (destroySource) data[length]=0;
|
{
|
||||||
|
data[length] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FWadLump::~FWadLump()
|
FWadLump::~FWadLump()
|
||||||
{
|
{
|
||||||
if (sourceData && destroySource)
|
if (SourceData && DestroySource)
|
||||||
{
|
{
|
||||||
if (sourceData[Length]==0) delete [] sourceData;
|
if (SourceData[Length] == 0)
|
||||||
else sourceData[Length]--;
|
{
|
||||||
|
delete[] SourceData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SourceData[Length]--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long FWadLump::Seek (long offset, int origin)
|
long FWadLump::Seek (long offset, int origin)
|
||||||
{
|
{
|
||||||
if (sourceData)
|
if (SourceData)
|
||||||
{
|
{
|
||||||
switch (origin)
|
switch (origin)
|
||||||
{
|
{
|
||||||
case SEEK_CUR:
|
case SEEK_CUR:
|
||||||
offset+=FilePos;
|
offset += FilePos;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
offset+=Length;
|
offset += Length;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (offset<0) offset=0;
|
FilePos = clamp<long> (offset, 0, Length);
|
||||||
else if (offset>Length) offset=Length;
|
|
||||||
FilePos=offset;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else return FileReader::Seek(offset, origin);
|
return FileReader::Seek(offset, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
long FWadLump::Read (void *buffer, long len)
|
long FWadLump::Read (void *buffer, long len)
|
||||||
{
|
{
|
||||||
if (sourceData)
|
long numread;
|
||||||
|
long startread = FilePos;
|
||||||
|
|
||||||
|
if (SourceData != NULL)
|
||||||
{
|
{
|
||||||
if (FilePos+len>Length) len=Length-FilePos;
|
if (FilePos + len > Length)
|
||||||
memcpy(buffer, sourceData+FilePos, len);
|
{
|
||||||
FilePos+=len;
|
len = Length - FilePos;
|
||||||
return len;
|
}
|
||||||
|
memcpy(buffer, SourceData + FilePos, len);
|
||||||
|
FilePos += len;
|
||||||
|
numread = len;
|
||||||
}
|
}
|
||||||
else return FileReader::Read(buffer, len);
|
else
|
||||||
|
{
|
||||||
|
numread = FileReader::Read(buffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blood, you are so mean to me with your encryption.
|
||||||
|
if (Encrypted && startread - StartPos < 256)
|
||||||
|
{
|
||||||
|
int cryptstart = startread - StartPos;
|
||||||
|
int cryptlen = MIN<int> (FilePos - StartPos, 256);
|
||||||
|
BYTE *data = (BYTE *)buffer - cryptstart;
|
||||||
|
|
||||||
|
for (int i = cryptstart; i < cryptlen; ++i)
|
||||||
|
{
|
||||||
|
data[i] ^= i >> 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return numread;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FMemLump -----------------------------------------------------------------
|
// FMemLump -----------------------------------------------------------------
|
||||||
|
|
12
src/w_wad.h
12
src/w_wad.h
|
@ -79,6 +79,9 @@ typedef enum {
|
||||||
// [RH] Copy an 8-char string and uppercase it.
|
// [RH] Copy an 8-char string and uppercase it.
|
||||||
void uppercopy (char *to, const char *from);
|
void uppercopy (char *to, const char *from);
|
||||||
|
|
||||||
|
// Perform Blood encryption/decryption.
|
||||||
|
void BloodCrypt (void *data, int key, int len);
|
||||||
|
|
||||||
// A very loose reference to a lump on disk. This is really just a wrapper
|
// 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
|
// around the main wad's FILE object with a different length recorded. Since
|
||||||
// the two lumps from the same wad share the same FILE, you cannot read from
|
// the two lumps from the same wad share the same FILE, you cannot read from
|
||||||
|
@ -97,12 +100,13 @@ public:
|
||||||
long Read (void *buffer, long len);
|
long Read (void *buffer, long len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FWadLump (const FileReader &reader, long length);
|
FWadLump (const FileReader &reader, long length, bool encrypted);
|
||||||
FWadLump (FILE *file, long length);
|
FWadLump (FILE *file, long length);
|
||||||
FWadLump (char * data, long length, bool destroy);
|
FWadLump (char * data, long length, bool destroy);
|
||||||
|
|
||||||
char * sourceData;
|
char *SourceData;
|
||||||
bool destroySource;
|
bool DestroySource;
|
||||||
|
bool Encrypted;
|
||||||
|
|
||||||
friend class FWadCollection;
|
friend class FWadCollection;
|
||||||
};
|
};
|
||||||
|
@ -189,7 +193,7 @@ public:
|
||||||
bool CheckLumpName (int lump, const char *name) const; // [RH] Returns true if the names match
|
bool CheckLumpName (int lump, const char *name) const; // [RH] Returns true if the names match
|
||||||
|
|
||||||
bool IsUncompressedFile(int lump) const;
|
bool IsUncompressedFile(int lump) const;
|
||||||
|
bool IsEncryptedFile(int lump) const;
|
||||||
|
|
||||||
int GetNumLumps () const;
|
int GetNumLumps () const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue