- sound code and most of texture code converted to FileRdr.
This allowed to remove a lot of bad pointer voodoo in the music loader, because the new class does not allow duplication of the reader object
This commit is contained in:
parent
26e948357e
commit
5fa63c396d
46 changed files with 333 additions and 307 deletions
|
|
@ -50,11 +50,11 @@ extern "C"
|
|||
|
||||
struct FLumpSourceMgr : public jpeg_source_mgr
|
||||
{
|
||||
FileReader *Lump;
|
||||
FileRdr *Lump;
|
||||
JOCTET Buffer[4096];
|
||||
bool StartOfFile;
|
||||
|
||||
FLumpSourceMgr (FileReader *lump, j_decompress_ptr cinfo);
|
||||
FLumpSourceMgr (FileRdr *lump, j_decompress_ptr cinfo);
|
||||
static void InitSource (j_decompress_ptr cinfo);
|
||||
static boolean FillInputBuffer (j_decompress_ptr cinfo);
|
||||
static void SkipInputData (j_decompress_ptr cinfo, long num_bytes);
|
||||
|
|
@ -82,7 +82,7 @@ void FLumpSourceMgr::InitSource (j_decompress_ptr cinfo)
|
|||
boolean FLumpSourceMgr::FillInputBuffer (j_decompress_ptr cinfo)
|
||||
{
|
||||
FLumpSourceMgr *me = (FLumpSourceMgr *)(cinfo->src);
|
||||
long nbytes = me->Lump->Read (me->Buffer, sizeof(me->Buffer));
|
||||
auto nbytes = me->Lump->Read (me->Buffer, sizeof(me->Buffer));
|
||||
|
||||
if (nbytes <= 0)
|
||||
{
|
||||
|
|
@ -113,7 +113,7 @@ void FLumpSourceMgr::SkipInputData (j_decompress_ptr cinfo, long num_bytes)
|
|||
else
|
||||
{
|
||||
num_bytes -= (long)me->bytes_in_buffer;
|
||||
me->Lump->Seek (num_bytes, SEEK_CUR);
|
||||
me->Lump->Seek (num_bytes, FileRdr::SeekCur);
|
||||
FillInputBuffer (cinfo);
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ void FLumpSourceMgr::TermSource (j_decompress_ptr cinfo)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FLumpSourceMgr::FLumpSourceMgr (FileReader *lump, j_decompress_ptr cinfo)
|
||||
FLumpSourceMgr::FLumpSourceMgr (FileRdr *lump, j_decompress_ptr cinfo)
|
||||
: Lump (lump)
|
||||
{
|
||||
cinfo->src = this;
|
||||
|
|
@ -208,7 +208,7 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum)
|
||||
FTexture *JPEGTexture_TryCreate(FileRdr & data, int lumpnum)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
|
@ -217,7 +217,7 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum)
|
|||
uint8_t b[4];
|
||||
} first4bytes;
|
||||
|
||||
data.Seek(0, SEEK_SET);
|
||||
data.Seek(0, FileRdr::SeekSet);
|
||||
if (data.Read(&first4bytes, 4) < 4) return NULL;
|
||||
|
||||
if (first4bytes.b[0] != 0xFF || first4bytes.b[1] != 0xD8 || first4bytes.b[2] != 0xFF)
|
||||
|
|
@ -231,7 +231,7 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
data.Seek (BigShort(first4bytes.w[0]) - 2, SEEK_CUR);
|
||||
data.Seek (BigShort(first4bytes.w[0]) - 2, FileRdr::SeekCur);
|
||||
if (data.Read (first4bytes.b + 2, 2) != 2 || first4bytes.b[2] != 0xFF)
|
||||
{
|
||||
return NULL;
|
||||
|
|
@ -364,7 +364,7 @@ const uint8_t *FJPEGTexture::GetPixels ()
|
|||
|
||||
void FJPEGTexture::MakeTexture ()
|
||||
{
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||
JSAMPLE *buff = NULL;
|
||||
|
||||
jpeg_decompress_struct cinfo;
|
||||
|
|
@ -468,7 +468,7 @@ int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FC
|
|||
{
|
||||
PalEntry pe[256];
|
||||
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||
JSAMPLE *buff = NULL;
|
||||
|
||||
jpeg_decompress_struct cinfo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue