mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- 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
|
@ -1224,7 +1224,7 @@ CCMD(secret)
|
|||
int lumpno=Wads.CheckNumForName("SECRETS");
|
||||
if (lumpno < 0) return;
|
||||
|
||||
FWadLump lump = Wads.OpenLumpNum(lumpno);
|
||||
auto lump = Wads.OpenLumpReader(lumpno);
|
||||
FString maphdr;
|
||||
maphdr.Format("[%s]", mapname);
|
||||
|
||||
|
|
|
@ -563,10 +563,13 @@ char *MemoryReader::Gets(char *strbuf, int len)
|
|||
|
||||
MemoryArrayReader::MemoryArrayReader (const char *buffer, long length)
|
||||
{
|
||||
buf.Resize(length);
|
||||
memcpy(&buf[0], buffer, length);
|
||||
Length=length;
|
||||
FilePos=0;
|
||||
if (length > 0)
|
||||
{
|
||||
buf.Resize(length);
|
||||
memcpy(&buf[0], buffer, length);
|
||||
}
|
||||
Length = length;
|
||||
FilePos=0;
|
||||
}
|
||||
|
||||
MemoryArrayReader::~MemoryArrayReader ()
|
||||
|
@ -696,22 +699,42 @@ size_t BufferWriter::Write(const void *buffer, size_t len)
|
|||
|
||||
bool FileRdr::OpenFile(const char *filename)
|
||||
{
|
||||
mReader = new FileReader;
|
||||
if (mReader->Open(filename)) return true;
|
||||
delete mReader;
|
||||
mReader = nullptr;
|
||||
return false;
|
||||
auto reader = new FileReader;
|
||||
if (!reader->Open(filename)) return false;
|
||||
Close();
|
||||
mReader = reader;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileRdr::OpenMemory(const void *mem, FileRdr::Size length)
|
||||
{
|
||||
Close();
|
||||
mReader = new MemoryReader((const char *)mem, (long)length);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileRdr::OpenMemoryArray(const void *mem, FileRdr::Size length)
|
||||
{
|
||||
Close();
|
||||
mReader = new MemoryArrayReader((const char *)mem, (long)length);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileRdr::OpenMemoryArray(std::function<bool(TArray<uint8_t>&)> getter)
|
||||
{
|
||||
auto reader = new MemoryArrayReader(nullptr, 0);
|
||||
if (getter(reader->GetArray()))
|
||||
{
|
||||
Close();
|
||||
reader->UpdateLength();
|
||||
mReader = reader;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This will keep the old
|
||||
delete reader;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
27
src/files.h
27
src/files.h
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <zlib.h>
|
||||
#include <functional>
|
||||
#include "bzlib.h"
|
||||
#include "doomtype.h"
|
||||
#include "m_swap.h"
|
||||
|
@ -498,8 +499,8 @@ class FileRdr // this is just a temporary name, until the old FileReader hierarc
|
|||
{
|
||||
FileReader *mReader = nullptr;
|
||||
|
||||
FileRdr() {}
|
||||
FileRdr(const FileRdr &r) = delete;
|
||||
FileRdr &operator=(const FileRdr &r) = delete;
|
||||
public:
|
||||
enum ESeek
|
||||
{
|
||||
|
@ -510,10 +511,19 @@ public:
|
|||
|
||||
typedef ptrdiff_t Size; // let's not use 'long' here.
|
||||
|
||||
FileRdr() {}
|
||||
|
||||
// These two functions are only needed as long as the FileReader has not been fully replaced throughout the code.
|
||||
FileRdr(FileReader *r)
|
||||
{
|
||||
mReader = r;
|
||||
}
|
||||
FileReader *Reader()
|
||||
{
|
||||
auto r = mReader;
|
||||
mReader = nullptr;
|
||||
return r;
|
||||
}
|
||||
|
||||
FileRdr(FileRdr &&r)
|
||||
{
|
||||
|
@ -521,7 +531,21 @@ public:
|
|||
r.mReader = nullptr;
|
||||
}
|
||||
|
||||
FileRdr& operator =(FileRdr &&r)
|
||||
{
|
||||
Close();
|
||||
mReader = r.mReader;
|
||||
r.mReader = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
~FileRdr()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
if (mReader != nullptr) delete mReader;
|
||||
mReader = nullptr;
|
||||
|
@ -531,6 +555,7 @@ public:
|
|||
bool OpenFilePart(FileReader *parent, Size start, Size length); // later
|
||||
bool OpenMemory(const void *mem, Size length); // read directly from the buffer
|
||||
bool OpenMemoryArray(const void *mem, Size length); // read from a copy of the buffer.
|
||||
bool OpenMemoryArray(std::function<bool(TArray<uint8_t>&)> getter); // read contents to a buffer and return a reader to it
|
||||
|
||||
Size Tell() const
|
||||
{
|
||||
|
|
|
@ -2500,17 +2500,17 @@ static void P_LoopSidedefs (bool firstloop)
|
|||
|
||||
int P_DetermineTranslucency (int lumpnum)
|
||||
{
|
||||
FWadLump tranmap = Wads.OpenLumpNum (lumpnum);
|
||||
auto tranmap = Wads.OpenLumpReader (lumpnum);
|
||||
uint8_t index;
|
||||
PalEntry newcolor;
|
||||
PalEntry newcolor2;
|
||||
|
||||
tranmap.Seek (GPalette.BlackIndex * 256 + GPalette.WhiteIndex, SEEK_SET);
|
||||
tranmap.Seek (GPalette.BlackIndex * 256 + GPalette.WhiteIndex, FileRdr::SeekSet);
|
||||
tranmap.Read (&index, 1);
|
||||
|
||||
newcolor = GPalette.BaseColors[GPalette.Remap[index]];
|
||||
|
||||
tranmap.Seek (GPalette.WhiteIndex * 256 + GPalette.BlackIndex, SEEK_SET);
|
||||
tranmap.Seek (GPalette.WhiteIndex * 256 + GPalette.BlackIndex, FileRdr::SeekSet);
|
||||
tranmap.Read (&index, 1);
|
||||
newcolor2 = GPalette.BaseColors[GPalette.Remap[index]];
|
||||
if (newcolor2.r == 255) // if black on white results in white it's either
|
||||
|
|
|
@ -232,7 +232,7 @@ void R_InitColormaps ()
|
|||
if (Wads.LumpLength (fakecmaps[j].lump) >= 256)
|
||||
{
|
||||
int k, r, g, b;
|
||||
FWadLump lump = Wads.OpenLumpNum (fakecmaps[j].lump);
|
||||
auto lump = Wads.OpenLumpReader (fakecmaps[j].lump);
|
||||
lump.Read(map, 256);
|
||||
r = g = b = 0;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ bool FPlayList::ChangeList (const char *path)
|
|||
{
|
||||
FString playlistdir;
|
||||
FString song;
|
||||
FileReader fr;
|
||||
FileRdr fr;
|
||||
bool first;
|
||||
bool pls;
|
||||
int i;
|
||||
|
@ -62,7 +62,7 @@ bool FPlayList::ChangeList (const char *path)
|
|||
Songs.Clear();
|
||||
Position = 0;
|
||||
|
||||
if (!fr.Open(path))
|
||||
if (!fr.OpenFile(path))
|
||||
{
|
||||
Printf ("Could not open " TEXTCOLOR_BOLD "%s" TEXTCOLOR_NORMAL ": %s\n", path, strerror(errno));
|
||||
return false;
|
||||
|
@ -71,7 +71,7 @@ bool FPlayList::ChangeList (const char *path)
|
|||
first = true;
|
||||
pls = false;
|
||||
playlistdir = ExtractFilePath(path);
|
||||
while ((song = NextLine(&fr)).IsNotEmpty())
|
||||
while ((song = NextLine(fr)).IsNotEmpty())
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
|
@ -133,14 +133,14 @@ bool FPlayList::ChangeList (const char *path)
|
|||
return Songs.Size() != 0;
|
||||
}
|
||||
|
||||
FString FPlayList::NextLine (FileReader *file)
|
||||
FString FPlayList::NextLine (FileRdr &file)
|
||||
{
|
||||
char buffer[512];
|
||||
char *skipper;
|
||||
|
||||
do
|
||||
{
|
||||
if (NULL == file->Gets (buffer, countof(buffer)))
|
||||
if (nullptr == file.Gets (buffer, countof(buffer)))
|
||||
return "";
|
||||
|
||||
for (skipper = buffer; *skipper != 0 && *skipper <= ' '; skipper++)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef __S_PLAYLIST_H__
|
||||
#define __S_PLAYLIST_H__
|
||||
|
||||
class FileReader;
|
||||
class FileRdr;
|
||||
|
||||
class FPlayList
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
const char *GetSong (int position) const;
|
||||
|
||||
private:
|
||||
static FString NextLine (FileReader *file);
|
||||
static FString NextLine (FileRdr &file);
|
||||
|
||||
unsigned int Position;
|
||||
TArray<FString> Songs;
|
||||
|
|
|
@ -1430,7 +1430,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer)
|
|||
int size = Wads.LumpLength(sfx->lumpnum);
|
||||
if (size > 0)
|
||||
{
|
||||
FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum);
|
||||
auto wlump = Wads.OpenLumpReader(sfx->lumpnum);
|
||||
uint8_t *sfxdata = new uint8_t[size];
|
||||
wlump.Read(sfxdata, size);
|
||||
int32_t dmxlen = LittleLong(((int32_t *)sfxdata)[1]);
|
||||
|
@ -1498,7 +1498,7 @@ static void S_LoadSound3D(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer)
|
|||
int size = Wads.LumpLength(sfx->lumpnum);
|
||||
if (size <= 0) return;
|
||||
|
||||
FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum);
|
||||
auto wlump = Wads.OpenLumpReader(sfx->lumpnum);
|
||||
uint8_t *sfxdata = new uint8_t[size];
|
||||
wlump.Read(sfxdata, size);
|
||||
int32_t dmxlen = LittleLong(((int32_t *)sfxdata)[1]);
|
||||
|
@ -2609,7 +2609,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
musicname += 7;
|
||||
}
|
||||
|
||||
FileReader *reader = NULL;
|
||||
FileRdr reader;
|
||||
if (!FileExists (musicname))
|
||||
{
|
||||
if ((lumpnum = Wads.CheckNumForFullName (musicname, true, ns_music)) == -1)
|
||||
|
@ -2623,17 +2623,16 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
reader = Wads.ReopenLumpNumNewFile(lumpnum);
|
||||
if (reader == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
reader = Wads.ReopenLumpReader(lumpnum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load an external file.
|
||||
reader = new FileReader(musicname);
|
||||
if (!reader.OpenFile(musicname))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// shutdown old music
|
||||
|
@ -2646,7 +2645,6 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
mus_playing.name = musicname;
|
||||
mus_playing.baseorder = order;
|
||||
LastSong = musicname;
|
||||
delete reader;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2654,7 +2652,6 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
if (handle != NULL)
|
||||
{
|
||||
mus_playing.handle = handle;
|
||||
delete reader;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -398,7 +398,7 @@ static EMIDIType IdentifyMIDIType(uint32_t *id, int size)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
||||
MusInfo *I_RegisterSong (FileRdr &reader, MidiDeviceSetting *device)
|
||||
{
|
||||
MusInfo *info = nullptr;
|
||||
const char *fmt;
|
||||
|
@ -406,14 +406,12 @@ MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
|||
|
||||
if (nomusic)
|
||||
{
|
||||
delete reader;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(reader->Read(id, 32) != 32 || reader->Seek(-32, SEEK_CUR) != 0)
|
||||
if(reader.Read(id, 32) != 32 || reader.Seek(-32, FileRdr::SeekCur) != 0)
|
||||
{
|
||||
delete reader;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Check for gzip compression. Some formats are expected to have players
|
||||
|
@ -421,47 +419,38 @@ MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
|||
// gzippable.
|
||||
if ((id[0] & MAKE_ID(255, 255, 255, 0)) == GZIP_ID)
|
||||
{
|
||||
int len = reader->GetLength();
|
||||
uint8_t *gzipped = new uint8_t[len];
|
||||
if (reader->Read(gzipped, len) != len)
|
||||
|
||||
if (!reader.OpenMemoryArray([&reader](TArray<uint8_t> &array)
|
||||
{
|
||||
bool res = false;
|
||||
auto len = reader.GetLength();
|
||||
uint8_t *gzipped = new uint8_t[len];
|
||||
if (reader.Read(gzipped, len) == len)
|
||||
{
|
||||
res = ungzip(gzipped, (int)len, array);
|
||||
}
|
||||
delete[] gzipped;
|
||||
delete reader;
|
||||
return res;
|
||||
}))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
delete reader;
|
||||
|
||||
MemoryArrayReader *memreader = new MemoryArrayReader(nullptr, 0);
|
||||
if (!ungzip(gzipped, len, memreader->GetArray()))
|
||||
if (reader.Read(id, 32) != 32 || reader.Seek(-32, FileRdr::SeekCur) != 0)
|
||||
{
|
||||
delete[] gzipped;
|
||||
delete memreader;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
delete[] gzipped;
|
||||
memreader->UpdateLength();
|
||||
|
||||
if (memreader->Read(id, 32) != 32 || memreader->Seek(-32, SEEK_CUR) != 0)
|
||||
{
|
||||
delete memreader;
|
||||
return 0;
|
||||
}
|
||||
reader = memreader;
|
||||
}
|
||||
|
||||
EMIDIType miditype = IdentifyMIDIType(id, sizeof(id));
|
||||
if (miditype != MIDI_NOTMIDI)
|
||||
{
|
||||
// temporary hack so we can test before converting more.
|
||||
FileRdr rdr(reader);
|
||||
reader = nullptr;
|
||||
|
||||
auto source = CreateMIDISource(rdr, miditype);
|
||||
if (source == nullptr) return 0;
|
||||
auto source = CreateMIDISource(reader, miditype);
|
||||
if (source == nullptr) return nullptr;
|
||||
if (!source->isValid())
|
||||
{
|
||||
delete source;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EMidiDevice devtype = device == nullptr? MDEV_DEFAULT : (EMidiDevice)device->device;
|
||||
|
@ -474,9 +463,8 @@ MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
|||
MIDIStreamer *streamer = CreateMIDIStreamer(devtype, device != nullptr? device->args.GetChars() : "");
|
||||
if (streamer == nullptr)
|
||||
{
|
||||
delete reader;
|
||||
delete source;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
streamer->SetMIDISource(source);
|
||||
info = streamer;
|
||||
|
@ -488,22 +476,21 @@ MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
|||
(id[0] == MAKE_ID('D','B','R','A') && id[1] == MAKE_ID('W','O','P','L')) || // DosBox Raw OPL
|
||||
(id[0] == MAKE_ID('A','D','L','I') && *((uint8_t *)id + 4) == 'B')) // Martin Fernandez's modified IMF
|
||||
{
|
||||
info = new OPLMUSSong (*reader, device != nullptr? device->args.GetChars() : "");
|
||||
info = new OPLMUSSong (reader, device != nullptr? device->args.GetChars() : "");
|
||||
}
|
||||
// Check for game music
|
||||
else if ((fmt = GME_CheckFormat(id[0])) != nullptr && fmt[0] != '\0')
|
||||
{
|
||||
info = GME_OpenSong(*reader, fmt);
|
||||
info = GME_OpenSong(reader, fmt);
|
||||
}
|
||||
// Check for module formats
|
||||
else
|
||||
{
|
||||
info = MOD_OpenSong(*reader);
|
||||
info = MOD_OpenSong(reader);
|
||||
}
|
||||
if (info == nullptr)
|
||||
{
|
||||
info = SndFile_OpenSong(*reader);
|
||||
if (info != nullptr) reader = nullptr;
|
||||
info = SndFile_OpenSong(reader);
|
||||
}
|
||||
|
||||
if (info == nullptr)
|
||||
|
@ -513,24 +500,21 @@ MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
|||
{
|
||||
uint32_t subid;
|
||||
|
||||
reader->Seek(8, SEEK_CUR);
|
||||
if (reader->Read (&subid, 4) != 4)
|
||||
reader.Seek(8, FileRdr::SeekCur);
|
||||
if (reader.Read (&subid, 4) != 4)
|
||||
{
|
||||
delete reader;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
reader->Seek(-12, SEEK_CUR);
|
||||
reader.Seek(-12, FileRdr::SeekCur);
|
||||
|
||||
if (subid == (('C')|(('D')<<8)|(('D')<<16)|(('A')<<24)))
|
||||
{
|
||||
// This is a CDDA file
|
||||
info = new CDDAFile (*reader);
|
||||
info = new CDDAFile (reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (reader != nullptr) delete reader;
|
||||
|
||||
if (info && !info->IsValid ())
|
||||
{
|
||||
delete info;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "doomdef.h"
|
||||
#include "i_soundinternal.h"
|
||||
|
||||
class FileReader;
|
||||
class FileRdr;
|
||||
struct FOptionValues;
|
||||
|
||||
//
|
||||
|
@ -55,7 +55,7 @@ void I_SetMusicVolume (float volume);
|
|||
// Registers a song handle to song data.
|
||||
class MusInfo;
|
||||
struct MidiDeviceSetting;
|
||||
MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device);
|
||||
MusInfo *I_RegisterSong (FileRdr &reader, MidiDeviceSetting *device);
|
||||
MusInfo *I_RegisterCDSong (int track, int cdid = 0);
|
||||
|
||||
// The base music class. Everything is derived from this --------------------
|
||||
|
|
|
@ -408,7 +408,7 @@ protected:
|
|||
class StreamSong : public MusInfo
|
||||
{
|
||||
public:
|
||||
StreamSong (FileReader *reader);
|
||||
StreamSong (FileRdr &reader);
|
||||
~StreamSong ();
|
||||
void Play (bool looping, int subsong);
|
||||
void Pause ();
|
||||
|
@ -431,7 +431,7 @@ protected:
|
|||
class OPLMUSSong : public StreamSong
|
||||
{
|
||||
public:
|
||||
OPLMUSSong (FileReader &reader, const char *args);
|
||||
OPLMUSSong (FileRdr &reader, const char *args);
|
||||
~OPLMUSSong ();
|
||||
void Play (bool looping, int subsong);
|
||||
bool IsPlaying ();
|
||||
|
@ -480,18 +480,18 @@ protected:
|
|||
class CDDAFile : public CDSong
|
||||
{
|
||||
public:
|
||||
CDDAFile (FileReader &reader);
|
||||
CDDAFile (FileRdr &reader);
|
||||
};
|
||||
|
||||
// Module played via foo_dumb -----------------------------------------------
|
||||
|
||||
MusInfo *MOD_OpenSong(FileReader &reader);
|
||||
MusInfo *MOD_OpenSong(FileRdr &reader);
|
||||
|
||||
// Music played via Game Music Emu ------------------------------------------
|
||||
|
||||
const char *GME_CheckFormat(uint32_t header);
|
||||
MusInfo *GME_OpenSong(FileReader &reader, const char *fmt);
|
||||
MusInfo *SndFile_OpenSong(FileReader &fr);
|
||||
MusInfo *GME_OpenSong(FileRdr &reader, const char *fmt);
|
||||
MusInfo *SndFile_OpenSong(FileRdr &fr);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -159,9 +159,8 @@ public:
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
SoundStream *OpenStream (FileReader *reader, int flags)
|
||||
SoundStream *OpenStream (FileRdr &reader, int flags)
|
||||
{
|
||||
delete reader;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -371,13 +370,15 @@ FString SoundRenderer::GatherStats ()
|
|||
|
||||
short *SoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType ctype)
|
||||
{
|
||||
MemoryReader reader((const char*)coded, sizebytes);
|
||||
FileRdr reader;
|
||||
short *samples = (short*)calloc(1, outlen);
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
int srate;
|
||||
|
||||
SoundDecoder *decoder = CreateDecoder(&reader);
|
||||
reader.OpenMemory(coded, sizebytes);
|
||||
|
||||
SoundDecoder *decoder = CreateDecoder(reader);
|
||||
if(!decoder) return samples;
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
|
@ -577,16 +578,16 @@ std::pair<SoundHandle, bool> SoundRenderer::LoadSoundBuffered(FSoundLoadBuffer *
|
|||
return std::make_pair(retval, true);
|
||||
}
|
||||
|
||||
SoundDecoder *SoundRenderer::CreateDecoder(FileReader *reader)
|
||||
SoundDecoder *SoundRenderer::CreateDecoder(FileRdr &reader)
|
||||
{
|
||||
SoundDecoder *decoder = NULL;
|
||||
int pos = reader->Tell();
|
||||
auto pos = reader.Tell();
|
||||
|
||||
#ifdef HAVE_SNDFILE
|
||||
decoder = new SndFileDecoder;
|
||||
if (decoder->open(reader))
|
||||
return decoder;
|
||||
reader->Seek(pos, SEEK_SET);
|
||||
reader.Seek(pos, FileRdr::SeekSet);
|
||||
|
||||
delete decoder;
|
||||
decoder = NULL;
|
||||
|
@ -595,7 +596,7 @@ SoundDecoder *SoundRenderer::CreateDecoder(FileReader *reader)
|
|||
decoder = new MPG123Decoder;
|
||||
if (decoder->open(reader))
|
||||
return decoder;
|
||||
reader->Seek(pos, SEEK_SET);
|
||||
reader.Seek(pos, FileRdr::SeekSet);
|
||||
|
||||
delete decoder;
|
||||
decoder = NULL;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "doomtype.h"
|
||||
#include "i_soundinternal.h"
|
||||
|
||||
class FileReader;
|
||||
class FileRdr;
|
||||
|
||||
enum ECodecType
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ public:
|
|||
|
||||
// Streaming sounds.
|
||||
virtual SoundStream *CreateStream (SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata) = 0;
|
||||
virtual SoundStream *OpenStream (FileReader *reader, int flags) = 0;
|
||||
virtual SoundStream *OpenStream (FileRdr &reader, int flags) = 0;
|
||||
|
||||
// Starts a sound.
|
||||
virtual FISoundChannel *StartSound (SoundHandle sfx, float vol, int pitch, int chanflags, FISoundChannel *reuse_chan) = 0;
|
||||
|
@ -168,7 +168,7 @@ public:
|
|||
|
||||
virtual void DrawWaveDebug(int mode);
|
||||
|
||||
static SoundDecoder *CreateDecoder(FileReader *reader);
|
||||
static SoundDecoder *CreateDecoder(FileRdr &reader);
|
||||
};
|
||||
|
||||
extern SoundRenderer *GSnd;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "vectors.h"
|
||||
#include "tarray.h"
|
||||
|
||||
class FileReader;
|
||||
class FileRdr;
|
||||
|
||||
// For convenience, this structure matches FMOD_REVERB_PROPERTIES.
|
||||
// Since I can't very well #include system-specific stuff in the
|
||||
|
@ -112,7 +112,7 @@ struct FISoundChannel
|
|||
};
|
||||
|
||||
|
||||
void FindLoopTags(FileReader *fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass);
|
||||
void FindLoopTags(FileRdr &fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass);
|
||||
|
||||
|
||||
enum SampleType
|
||||
|
@ -143,7 +143,7 @@ struct SoundDecoder
|
|||
virtual ~SoundDecoder() { }
|
||||
|
||||
protected:
|
||||
virtual bool open(FileReader *reader) = 0;
|
||||
virtual bool open(FileRdr &reader) = 0;
|
||||
friend class SoundRenderer;
|
||||
|
||||
private:
|
||||
|
|
|
@ -128,7 +128,7 @@ struct HMISong::TrackInfo
|
|||
|
||||
HMISong::HMISong (FileRdr &reader)
|
||||
{
|
||||
auto len = reader.GetLength();
|
||||
int len = (int)reader.GetLength();
|
||||
if (len < 0x100)
|
||||
{ // Way too small to be HMI.
|
||||
return;
|
||||
|
|
|
@ -74,28 +74,28 @@ static bool inited = false;
|
|||
|
||||
off_t MPG123Decoder::file_lseek(void *handle, off_t offset, int whence)
|
||||
{
|
||||
FileReader *reader = reinterpret_cast<MPG123Decoder*>(handle)->Reader;
|
||||
auto &reader = reinterpret_cast<MPG123Decoder*>(handle)->Reader;
|
||||
|
||||
if(whence == SEEK_CUR)
|
||||
{
|
||||
if(offset < 0 && reader->Tell()+offset < 0)
|
||||
if(offset < 0 && reader.Tell()+offset < 0)
|
||||
return -1;
|
||||
}
|
||||
else if(whence == SEEK_END)
|
||||
{
|
||||
if(offset < 0 && reader->GetLength()+offset < 0)
|
||||
if(offset < 0 && reader.GetLength()+offset < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(reader->Seek(offset, whence) != 0)
|
||||
if(reader.Seek(offset, (FileRdr::ESeek)whence) != 0)
|
||||
return -1;
|
||||
return reader->Tell();
|
||||
return (off_t)reader.Tell();
|
||||
}
|
||||
|
||||
ssize_t MPG123Decoder::file_read(void *handle, void *buffer, size_t bytes)
|
||||
{
|
||||
FileReader *reader = reinterpret_cast<MPG123Decoder*>(handle)->Reader;
|
||||
return (ssize_t)reader->Read(buffer, (long)bytes);
|
||||
auto &reader = reinterpret_cast<MPG123Decoder*>(handle)->Reader;
|
||||
return (ssize_t)reader.Read(buffer, (long)bytes);
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,7 +109,7 @@ MPG123Decoder::~MPG123Decoder()
|
|||
}
|
||||
}
|
||||
|
||||
bool MPG123Decoder::open(FileReader *reader)
|
||||
bool MPG123Decoder::open(FileRdr &reader)
|
||||
{
|
||||
if(!inited)
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ bool MPG123Decoder::open(FileReader *reader)
|
|||
inited = true;
|
||||
}
|
||||
|
||||
Reader = reader;
|
||||
Reader = std::move(reader);
|
||||
|
||||
{
|
||||
MPG123 = mpg123_new(NULL, NULL);
|
||||
|
@ -214,8 +214,10 @@ bool MPG123Decoder::seek(size_t ms_offset, bool ms, bool mayrestart)
|
|||
mpg123_delete(MPG123);
|
||||
MPG123 = 0;
|
||||
}
|
||||
Reader->Seek(0, SEEK_SET);
|
||||
return open(Reader);
|
||||
Reader.Seek(0, FileRdr::SeekSet);
|
||||
// Do not call open with our own reader variable, that would be catastrophic.
|
||||
auto reader = std::move(Reader);
|
||||
return open(reader);
|
||||
}
|
||||
}
|
||||
size_t MPG123Decoder::getSampleOffset()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define MPG123_DECODER_H
|
||||
|
||||
#include "i_soundinternal.h"
|
||||
#include "files.h"
|
||||
|
||||
#ifdef HAVE_MPG123
|
||||
|
||||
|
@ -29,13 +30,13 @@ struct MPG123Decoder : public SoundDecoder
|
|||
virtual ~MPG123Decoder();
|
||||
|
||||
protected:
|
||||
virtual bool open(FileReader *reader);
|
||||
virtual bool open(FileRdr &reader);
|
||||
|
||||
private:
|
||||
mpg123_handle *MPG123;
|
||||
bool Done;
|
||||
|
||||
FileReader *Reader;
|
||||
FileRdr Reader;
|
||||
static off_t file_lseek(void *handle, off_t offset, int whence);
|
||||
static ssize_t file_read(void *handle, void *buffer, size_t bytes);
|
||||
|
||||
|
|
|
@ -112,17 +112,17 @@ bool CDSong::IsPlaying ()
|
|||
return m_Status != STATE_Stopped;
|
||||
}
|
||||
|
||||
CDDAFile::CDDAFile (FileReader &reader)
|
||||
CDDAFile::CDDAFile (FileRdr &reader)
|
||||
: CDSong ()
|
||||
{
|
||||
uint32_t chunk;
|
||||
uint16_t track;
|
||||
uint32_t discid;
|
||||
long endpos = reader.Tell() + reader.GetLength() - 8;
|
||||
auto endpos = reader.Tell() + reader.GetLength() - 8;
|
||||
|
||||
// I_RegisterSong already identified this as a CDDA file, so we
|
||||
// just need to check the contents we're interested in.
|
||||
reader.Seek(12, SEEK_CUR);
|
||||
reader.Seek(12, FileRdr::SeekCur);
|
||||
|
||||
while (reader.Tell() < endpos)
|
||||
{
|
||||
|
@ -130,11 +130,11 @@ CDDAFile::CDDAFile (FileReader &reader)
|
|||
if (chunk != (('f')|(('m')<<8)|(('t')<<16)|((' ')<<24)))
|
||||
{
|
||||
reader.Read(&chunk, 4);
|
||||
reader.Seek(chunk, SEEK_CUR);
|
||||
reader.Seek(chunk, FileRdr::SeekCur);
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Seek(6, SEEK_CUR);
|
||||
reader.Seek(6, FileRdr::SeekCur);
|
||||
reader.Read(&track, 2);
|
||||
reader.Read(&discid, 4);
|
||||
|
||||
|
|
|
@ -550,7 +550,7 @@ static DUMBFILE_SYSTEM mem_dfs = {
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
DUMBFILE *dumb_read_allfile(dumbfile_mem_status *filestate, uint8_t *start, FileReader &reader, int lenhave, int lenfull)
|
||||
DUMBFILE *dumb_read_allfile(dumbfile_mem_status *filestate, uint8_t *start, FileRdr &reader, int lenhave, int lenfull)
|
||||
{
|
||||
filestate->size = lenfull;
|
||||
filestate->offset = 0;
|
||||
|
@ -765,7 +765,7 @@ static void MOD_SetAutoChip(DUH *duh)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
MusInfo *MOD_OpenSong(FileReader &reader)
|
||||
MusInfo *MOD_OpenSong(FileRdr &reader)
|
||||
{
|
||||
DUH *duh = 0;
|
||||
int headsize;
|
||||
|
@ -776,7 +776,6 @@ MusInfo *MOD_OpenSong(FileReader &reader)
|
|||
};
|
||||
dumbfile_mem_status filestate;
|
||||
DUMBFILE *f = NULL;
|
||||
long fpos = 0;
|
||||
input_mod *state = NULL;
|
||||
|
||||
bool is_it = false;
|
||||
|
@ -784,8 +783,8 @@ MusInfo *MOD_OpenSong(FileReader &reader)
|
|||
|
||||
atterm(dumb_exit);
|
||||
|
||||
int size = reader.GetLength();
|
||||
fpos = reader.Tell();
|
||||
int size = (int)reader.GetLength();
|
||||
auto fpos = reader.Tell();
|
||||
|
||||
filestate.ptr = start;
|
||||
filestate.offset = 0;
|
||||
|
@ -903,7 +902,7 @@ MusInfo *MOD_OpenSong(FileReader &reader)
|
|||
{
|
||||
if (!(f = dumb_read_allfile(&filestate, start, reader, headsize, size)))
|
||||
{
|
||||
reader.Seek(fpos, SEEK_SET);
|
||||
reader.Seek(fpos, FileRdr::SeekSet);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -944,7 +943,7 @@ MusInfo *MOD_OpenSong(FileReader &reader)
|
|||
else
|
||||
{
|
||||
// Reposition file pointer for other codecs to do their checks.
|
||||
reader.Seek(fpos, SEEK_SET);
|
||||
reader.Seek(fpos, FileRdr::SeekSet);
|
||||
}
|
||||
if (filestate.ptr != (uint8_t *)start)
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ const char *GME_CheckFormat(uint32_t id)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
MusInfo *GME_OpenSong(FileReader &reader, const char *fmt)
|
||||
MusInfo *GME_OpenSong(FileRdr &reader, const char *fmt)
|
||||
{
|
||||
gme_type_t type;
|
||||
gme_err_t err;
|
||||
|
@ -128,31 +128,31 @@ MusInfo *GME_OpenSong(FileReader &reader, const char *fmt)
|
|||
}
|
||||
sample_rate = (int)GSnd->GetOutputRate();
|
||||
emu = gme_new_emu(type, sample_rate);
|
||||
if (emu == NULL)
|
||||
if (emu == nullptr)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int fpos = reader.Tell();
|
||||
int len = reader.GetLength();
|
||||
auto fpos = reader.Tell();
|
||||
auto len = reader.GetLength();
|
||||
song = new uint8_t[len];
|
||||
if (reader.Read(song, len) != len)
|
||||
{
|
||||
delete[] song;
|
||||
gme_delete(emu);
|
||||
reader.Seek(fpos, SEEK_SET);
|
||||
return NULL;
|
||||
reader.Seek(fpos, FileRdr::SeekSet);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
err = gme_load_data(emu, song, len);
|
||||
err = gme_load_data(emu, song, (long)len);
|
||||
delete[] song;
|
||||
|
||||
if (err != NULL)
|
||||
if (err != nullptr)
|
||||
{
|
||||
Printf("Failed loading song: %s\n", err);
|
||||
gme_delete(emu);
|
||||
reader.Seek(fpos, SEEK_SET);
|
||||
return NULL;
|
||||
reader.Seek(fpos, FileRdr::SeekSet);
|
||||
return nullptr;
|
||||
}
|
||||
gme_set_stereo_depth(emu, clamp(*gme_stereodepth, 0.f, 1.f));
|
||||
return new GMESong(emu, sample_rate);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
class SndFileSong : public StreamSong
|
||||
{
|
||||
public:
|
||||
SndFileSong(FileReader *reader, SoundDecoder *decoder, uint32_t loop_start, uint32_t loop_end, bool startass, bool endass);
|
||||
SndFileSong(FileRdr &reader, SoundDecoder *decoder, uint32_t loop_start, uint32_t loop_end, bool startass, bool endass);
|
||||
~SndFileSong();
|
||||
bool SetSubsong(int subsong);
|
||||
void Play(bool looping, int subsong);
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
protected:
|
||||
FCriticalSection CritSec;
|
||||
FileReader *Reader;
|
||||
FileRdr Reader;
|
||||
SoundDecoder *Decoder;
|
||||
int Channels;
|
||||
int SampleRate;
|
||||
|
@ -105,23 +105,23 @@ CUSTOM_CVAR(Int, snd_streambuffersize, 64, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void ParseVorbisComments(FileReader *fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass)
|
||||
static void ParseVorbisComments(FileRdr &fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass)
|
||||
{
|
||||
uint8_t vc_data[4];
|
||||
|
||||
// The VC block starts with a 32LE integer for the vendor string length,
|
||||
// followed by the vendor string
|
||||
if(fr->Read(vc_data, 4) != 4)
|
||||
if(fr.Read(vc_data, 4) != 4)
|
||||
return;
|
||||
uint32_t vndr_len = vc_data[0] | (vc_data[1]<<8) | (vc_data[2]<<16) | (vc_data[3]<<24);
|
||||
|
||||
// Skip vendor string
|
||||
if(fr->Seek(vndr_len, SEEK_CUR) == -1)
|
||||
if(fr.Seek(vndr_len, FileRdr::SeekCur) == -1)
|
||||
return;
|
||||
|
||||
// Following the vendor string is a 32LE integer for the number of
|
||||
// comments, followed by each comment.
|
||||
if(fr->Read(vc_data, 4) != 4)
|
||||
if(fr.Read(vc_data, 4) != 4)
|
||||
return;
|
||||
size_t count = vc_data[0] | (vc_data[1]<<8) | (vc_data[2]<<16) | (vc_data[3]<<24);
|
||||
|
||||
|
@ -129,20 +129,20 @@ static void ParseVorbisComments(FileReader *fr, uint32_t *start, bool *startass,
|
|||
{
|
||||
// Each comment is a 32LE integer for the comment length, followed by
|
||||
// the comment text (not null terminated!)
|
||||
if(fr->Read(vc_data, 4) != 4)
|
||||
if(fr.Read(vc_data, 4) != 4)
|
||||
return;
|
||||
uint32_t length = vc_data[0] | (vc_data[1]<<8) | (vc_data[2]<<16) | (vc_data[3]<<24);
|
||||
|
||||
if(length >= 128)
|
||||
{
|
||||
// If the comment is "big", skip it
|
||||
if(fr->Seek(length, SEEK_CUR) == -1)
|
||||
if(fr.Seek(length, FileRdr::SeekCur) == -1)
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
char strdat[128];
|
||||
if(fr->Read(strdat, length) != (long)length)
|
||||
if(fr.Read(strdat, length) != (long)length)
|
||||
return;
|
||||
strdat[length] = 0;
|
||||
|
||||
|
@ -153,13 +153,13 @@ static void ParseVorbisComments(FileReader *fr, uint32_t *start, bool *startass,
|
|||
}
|
||||
}
|
||||
|
||||
static void FindFlacComments(FileReader *fr, uint32_t *loop_start, bool *startass, uint32_t *loop_end, bool *endass)
|
||||
static void FindFlacComments(FileRdr &fr, uint32_t *loop_start, bool *startass, uint32_t *loop_end, bool *endass)
|
||||
{
|
||||
// Already verified the fLaC marker, so we're 4 bytes into the file
|
||||
bool lastblock = false;
|
||||
uint8_t header[4];
|
||||
|
||||
while(!lastblock && fr->Read(header, 4) == 4)
|
||||
while(!lastblock && fr.Read(header, 4) == 4)
|
||||
{
|
||||
// The first byte of the block header contains the type and a flag
|
||||
// indicating the last metadata block
|
||||
|
@ -175,18 +175,18 @@ static void FindFlacComments(FileReader *fr, uint32_t *loop_start, bool *startas
|
|||
return;
|
||||
}
|
||||
|
||||
if(fr->Seek(blocksize, SEEK_CUR) == -1)
|
||||
if(fr.Seek(blocksize, FileRdr::SeekCur) == -1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void FindOggComments(FileReader *fr, uint32_t *loop_start, bool *startass, uint32_t *loop_end, bool *endass)
|
||||
static void FindOggComments(FileRdr &fr, uint32_t *loop_start, bool *startass, uint32_t *loop_end, bool *endass)
|
||||
{
|
||||
uint8_t ogghead[27];
|
||||
|
||||
// We already read and verified the OggS marker, so skip the first 4 bytes
|
||||
// of the Ogg page header.
|
||||
while(fr->Read(ogghead+4, 23) == 23)
|
||||
while(fr.Read(ogghead+4, 23) == 23)
|
||||
{
|
||||
// The 19th byte of the Ogg header is a 32LE integer for the page
|
||||
// number, and the 27th is a uint8 for the number of segments in the
|
||||
|
@ -199,7 +199,7 @@ static void FindOggComments(FileReader *fr, uint32_t *loop_start, bool *startass
|
|||
// each segment in the page. The page segment data follows contiguously
|
||||
// after.
|
||||
uint8_t segsizes[256];
|
||||
if(fr->Read(segsizes, ogg_segments) != ogg_segments)
|
||||
if(fr.Read(segsizes, ogg_segments) != ogg_segments)
|
||||
break;
|
||||
|
||||
// Find the segment with the Vorbis Comment packet (type 3)
|
||||
|
@ -210,7 +210,7 @@ static void FindOggComments(FileReader *fr, uint32_t *loop_start, bool *startass
|
|||
if(segsize > 16)
|
||||
{
|
||||
uint8_t vorbhead[7];
|
||||
if(fr->Read(vorbhead, 7) != 7)
|
||||
if(fr.Read(vorbhead, 7) != 7)
|
||||
return;
|
||||
|
||||
if(vorbhead[0] == 3 && memcmp(vorbhead+1, "vorbis", 6) == 0)
|
||||
|
@ -237,7 +237,7 @@ static void FindOggComments(FileReader *fr, uint32_t *loop_start, bool *startass
|
|||
|
||||
segsize -= 7;
|
||||
}
|
||||
if(fr->Seek(segsize, SEEK_CUR) == -1)
|
||||
if(fr.Seek(segsize, FileRdr::SeekCur) == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -245,16 +245,16 @@ static void FindOggComments(FileReader *fr, uint32_t *loop_start, bool *startass
|
|||
if(ogg_pagenum >= 2)
|
||||
break;
|
||||
|
||||
if(fr->Read(ogghead, 4) != 4 || memcmp(ogghead, "OggS", 4) != 0)
|
||||
if(fr.Read(ogghead, 4) != 4 || memcmp(ogghead, "OggS", 4) != 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FindLoopTags(FileReader *fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass)
|
||||
void FindLoopTags(FileRdr &fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass)
|
||||
{
|
||||
uint8_t signature[4];
|
||||
|
||||
fr->Read(signature, 4);
|
||||
fr.Read(signature, 4);
|
||||
if(memcmp(signature, "fLaC", 4) == 0)
|
||||
FindFlacComments(fr, start, startass, end, endass);
|
||||
else if(memcmp(signature, "OggS", 4) == 0)
|
||||
|
@ -268,18 +268,18 @@ void FindLoopTags(FileReader *fr, uint32_t *start, bool *startass, uint32_t *end
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
MusInfo *SndFile_OpenSong(FileReader &fr)
|
||||
MusInfo *SndFile_OpenSong(FileRdr &fr)
|
||||
{
|
||||
fr.Seek(0, SEEK_SET);
|
||||
fr.Seek(0, FileRdr::SeekSet);
|
||||
|
||||
uint32_t loop_start = 0, loop_end = ~0u;
|
||||
bool startass = false, endass = false;
|
||||
FindLoopTags(&fr, &loop_start, &startass, &loop_end, &endass);
|
||||
FindLoopTags(fr, &loop_start, &startass, &loop_end, &endass);
|
||||
|
||||
fr.Seek(0, SEEK_SET);
|
||||
auto decoder = SoundRenderer::CreateDecoder(&fr);
|
||||
fr.Seek(0, FileRdr::SeekSet);
|
||||
auto decoder = SoundRenderer::CreateDecoder(fr);
|
||||
if (decoder == nullptr) return nullptr;
|
||||
return new SndFileSong(&fr, decoder, loop_start, loop_end, startass, endass);
|
||||
return new SndFileSong(fr, decoder, loop_start, loop_end, startass, endass);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -288,7 +288,7 @@ MusInfo *SndFile_OpenSong(FileReader &fr)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
SndFileSong::SndFileSong(FileReader *reader, SoundDecoder *decoder, uint32_t loop_start, uint32_t loop_end, bool startass, bool endass)
|
||||
SndFileSong::SndFileSong(FileRdr &reader, SoundDecoder *decoder, uint32_t loop_start, uint32_t loop_end, bool startass, bool endass)
|
||||
{
|
||||
ChannelConfig iChannels;
|
||||
SampleType Type;
|
||||
|
@ -300,7 +300,7 @@ SndFileSong::SndFileSong(FileReader *reader, SoundDecoder *decoder, uint32_t loo
|
|||
|
||||
Loop_Start = loop_start;
|
||||
Loop_End = clamp<uint32_t>(loop_end, 0, (uint32_t)decoder->getSampleLength());
|
||||
Reader = reader;
|
||||
Reader = std::move(reader);
|
||||
Decoder = decoder;
|
||||
Channels = iChannels == ChannelConfig_Stereo? 2:1;
|
||||
m_Stream = GSnd->CreateStream(Read, snd_streambuffersize * 1024, iChannels == ChannelConfig_Stereo? 0 : SoundStream::Mono, SampleRate, this);
|
||||
|
@ -324,10 +324,6 @@ SndFileSong::~SndFileSong()
|
|||
{
|
||||
delete Decoder;
|
||||
}
|
||||
if (Reader != nullptr)
|
||||
{
|
||||
delete Reader;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,12 +69,12 @@ void OPL_SetCore(const char *args)
|
|||
if (args != NULL && *args >= '0' && *args < '4') current_opl_core = *args - '0';
|
||||
}
|
||||
|
||||
OPLMUSSong::OPLMUSSong (FileReader &reader, const char *args)
|
||||
OPLMUSSong::OPLMUSSong (FileRdr &reader, const char *args)
|
||||
{
|
||||
int samples = int(OPL_SAMPLE_RATE / 14);
|
||||
|
||||
OPL_SetCore(args);
|
||||
Music = new OPLmusicFile (&reader);
|
||||
Music = new OPLmusicFile (reader);
|
||||
|
||||
m_Stream = GSnd->CreateStream (FillStream, samples*4,
|
||||
(current_opl_core == 0 ? SoundStream::Mono : 0) | SoundStream::Float, int(OPL_SAMPLE_RATE), this);
|
||||
|
|
|
@ -85,7 +85,7 @@ StreamSong::~StreamSong ()
|
|||
}
|
||||
}
|
||||
|
||||
StreamSong::StreamSong (FileReader *reader)
|
||||
StreamSong::StreamSong (FileRdr &reader)
|
||||
{
|
||||
m_Stream = GSnd->OpenStream (reader, SoundStream::Loop);
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ class OpenALSoundStream : public SoundStream
|
|||
ALfloat Volume;
|
||||
|
||||
|
||||
FileReader *Reader;
|
||||
FileRdr Reader;
|
||||
SoundDecoder *Decoder;
|
||||
static bool DecoderCallback(SoundStream *_sstream, void *ptr, int length, void *user)
|
||||
{
|
||||
|
@ -317,7 +317,6 @@ public:
|
|||
getALError();
|
||||
|
||||
delete Decoder;
|
||||
delete Reader;
|
||||
}
|
||||
|
||||
|
||||
|
@ -604,17 +603,15 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Init(FileReader *reader, bool loop)
|
||||
bool Init(FileRdr &reader, bool loop)
|
||||
{
|
||||
if(!SetupSource())
|
||||
{
|
||||
delete reader;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Decoder) delete Decoder;
|
||||
if(Reader) delete Reader;
|
||||
Reader = reader;
|
||||
Reader = std::move(reader);
|
||||
Decoder = Renderer->CreateDecoder(Reader);
|
||||
if(!Decoder) return false;
|
||||
|
||||
|
@ -1279,7 +1276,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSoundRaw(uint8_t *sfxdata,
|
|||
std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length, bool monoize, FSoundLoadBuffer *pBuffer)
|
||||
{
|
||||
SoundHandle retval = { NULL };
|
||||
MemoryReader reader((const char*)sfxdata, length);
|
||||
FileRdr reader;
|
||||
ALenum format = AL_NONE;
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
|
@ -1290,10 +1287,12 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int
|
|||
/* Only downmix to mono if we can't spatialize multi-channel sounds. */
|
||||
monoize = monoize && !AL.SOFT_source_spatialize;
|
||||
|
||||
FindLoopTags(&reader, &loop_start, &startass, &loop_end, &endass);
|
||||
reader.OpenMemory(sfxdata, length);
|
||||
|
||||
reader.Seek(0, SEEK_SET);
|
||||
std::unique_ptr<SoundDecoder> decoder(CreateDecoder(&reader));
|
||||
FindLoopTags(reader, &loop_start, &startass, &loop_end, &endass);
|
||||
|
||||
reader.Seek(0, FileRdr::SeekSet);
|
||||
std::unique_ptr<SoundDecoder> decoder(CreateDecoder(reader));
|
||||
if (!decoder) return std::make_pair(retval, true);
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
|
@ -1530,7 +1529,7 @@ SoundStream *OpenALSoundRenderer::CreateStream(SoundStreamCallback callback, int
|
|||
return stream;
|
||||
}
|
||||
|
||||
SoundStream *OpenALSoundRenderer::OpenStream(FileReader *reader, int flags)
|
||||
SoundStream *OpenALSoundRenderer::OpenStream(FileRdr &reader, int flags)
|
||||
{
|
||||
if(StreamThread.get_id() == std::thread::id())
|
||||
StreamThread = std::thread(std::mem_fn(&OpenALSoundRenderer::BackgroundProc), this);
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
|
||||
// Streaming sounds.
|
||||
virtual SoundStream *CreateStream(SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata);
|
||||
virtual SoundStream *OpenStream(FileReader *reader, int flags);
|
||||
virtual SoundStream *OpenStream(FileRdr &reader, int flags);
|
||||
|
||||
// Starts a sound.
|
||||
virtual FISoundChannel *StartSound(SoundHandle sfx, float vol, int pitch, int chanflags, FISoundChannel *reuse_chan);
|
||||
|
|
|
@ -84,8 +84,8 @@ void OPLmusicBlock::Restart()
|
|||
LastOffset = 0;
|
||||
}
|
||||
|
||||
OPLmusicFile::OPLmusicFile (FileReader *reader)
|
||||
: ScoreLen (reader->GetLength())
|
||||
OPLmusicFile::OPLmusicFile (FileRdr &reader)
|
||||
: ScoreLen ((int)reader.GetLength())
|
||||
{
|
||||
if (io == NULL)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ OPLmusicFile::OPLmusicFile (FileReader *reader)
|
|||
|
||||
scoredata = new uint8_t[ScoreLen];
|
||||
|
||||
if (reader->Read(scoredata, ScoreLen) != ScoreLen)
|
||||
if (reader.Read(scoredata, ScoreLen) != ScoreLen)
|
||||
{
|
||||
fail: delete[] scoredata;
|
||||
scoredata = NULL;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "critsec.h"
|
||||
#include "musicblock.h"
|
||||
|
||||
class FileReader;
|
||||
class FileRdr;
|
||||
|
||||
class OPLmusicBlock : public musicBlock
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ protected:
|
|||
class OPLmusicFile : public OPLmusicBlock
|
||||
{
|
||||
public:
|
||||
OPLmusicFile(FileReader *reader);
|
||||
OPLmusicFile(FileRdr &reader);
|
||||
OPLmusicFile(const OPLmusicFile *source, const char *filename);
|
||||
virtual ~OPLmusicFile();
|
||||
|
||||
|
|
|
@ -72,23 +72,23 @@ bool IsSndFilePresent()
|
|||
|
||||
sf_count_t SndFileDecoder::file_get_filelen(void *user_data)
|
||||
{
|
||||
FileReader *reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
|
||||
return reader->GetLength();
|
||||
auto &reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
|
||||
return reader.GetLength();
|
||||
}
|
||||
|
||||
sf_count_t SndFileDecoder::file_seek(sf_count_t offset, int whence, void *user_data)
|
||||
{
|
||||
FileReader *reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
|
||||
auto &reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
|
||||
|
||||
if(reader->Seek((long)offset, whence) != 0)
|
||||
if(reader.Seek((long)offset, (FileRdr::ESeek)whence) != 0)
|
||||
return -1;
|
||||
return reader->Tell();
|
||||
return reader.Tell();
|
||||
}
|
||||
|
||||
sf_count_t SndFileDecoder::file_read(void *ptr, sf_count_t count, void *user_data)
|
||||
{
|
||||
FileReader *reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
|
||||
return reader->Read(ptr, (long)count);
|
||||
auto &reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
|
||||
return reader.Read(ptr, (long)count);
|
||||
}
|
||||
|
||||
sf_count_t SndFileDecoder::file_write(const void *ptr, sf_count_t count, void *user_data)
|
||||
|
@ -98,8 +98,8 @@ sf_count_t SndFileDecoder::file_write(const void *ptr, sf_count_t count, void *u
|
|||
|
||||
sf_count_t SndFileDecoder::file_tell(void *user_data)
|
||||
{
|
||||
FileReader *reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
|
||||
return reader->Tell();
|
||||
auto &reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
|
||||
return reader.Tell();
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,13 +110,13 @@ SndFileDecoder::~SndFileDecoder()
|
|||
SndFile = 0;
|
||||
}
|
||||
|
||||
bool SndFileDecoder::open(FileReader *reader)
|
||||
bool SndFileDecoder::open(FileRdr &reader)
|
||||
{
|
||||
if (!IsSndFilePresent()) return false;
|
||||
|
||||
SF_VIRTUAL_IO sfio = { file_get_filelen, file_seek, file_read, file_write, file_tell };
|
||||
|
||||
Reader = reader;
|
||||
Reader = std::move(reader);
|
||||
SndInfo.format = 0;
|
||||
SndFile = sf_open_virtual(&sfio, SFM_READ, &SndInfo, this);
|
||||
if (SndFile)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define SNDFILE_DECODER_H
|
||||
|
||||
#include "i_soundinternal.h"
|
||||
#include "files.h"
|
||||
|
||||
#ifdef HAVE_SNDFILE
|
||||
|
||||
|
@ -25,13 +26,13 @@ struct SndFileDecoder : public SoundDecoder
|
|||
virtual ~SndFileDecoder();
|
||||
|
||||
protected:
|
||||
virtual bool open(FileReader *reader);
|
||||
virtual bool open(FileRdr &reader);
|
||||
|
||||
private:
|
||||
SNDFILE *SndFile;
|
||||
SF_INFO SndInfo;
|
||||
|
||||
FileReader *Reader;
|
||||
FileRdr Reader;
|
||||
static sf_count_t file_get_filelen(void *user_data);
|
||||
static sf_count_t file_seek(sf_count_t offset, int whence, void *user_data);
|
||||
static sf_count_t file_read(void *ptr, sf_count_t count, void *user_data);
|
||||
|
|
|
@ -366,7 +366,7 @@ void SetDefaultColormap (const char *name)
|
|||
}
|
||||
else
|
||||
{
|
||||
FWadLump lumpr = Wads.OpenLumpNum (lump);
|
||||
auto lumpr = Wads.OpenLumpReader (lump);
|
||||
|
||||
// [RH] The colormap may not have been designed for the specific
|
||||
// palette we are using, so remap it to match the current palette.
|
||||
|
@ -427,7 +427,7 @@ static void InitBoomColormaps ()
|
|||
if (Wads.LumpLength (fakecmaps[j].lump) >= (NUMCOLORMAPS+1)*256)
|
||||
{
|
||||
int k, r;
|
||||
FWadLump lump = Wads.OpenLumpNum (fakecmaps[j].lump);
|
||||
auto lump = Wads.OpenLumpReader (fakecmaps[j].lump);
|
||||
uint8_t *const map = realcolormaps.Maps + NUMCOLORMAPS*256*j;
|
||||
|
||||
for (k = 0; k < NUMCOLORMAPS; ++k)
|
||||
|
|
|
@ -72,7 +72,7 @@ private:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *AutomapTexture_TryCreate(FileReader &data, int lumpnum)
|
||||
FTexture *AutomapTexture_TryCreate(FileRdr &data, int lumpnum)
|
||||
{
|
||||
if (data.GetLength() < 320) return NULL;
|
||||
if (!Wads.CheckLumpName(lumpnum, "AUTOPAGE")) return NULL;
|
||||
|
|
|
@ -156,7 +156,7 @@ struct DDSFileHeader
|
|||
class FDDSTexture : public FTexture
|
||||
{
|
||||
public:
|
||||
FDDSTexture (FileReader &lump, int lumpnum, void *surfdesc);
|
||||
FDDSTexture (FileRdr &lump, int lumpnum, void *surfdesc);
|
||||
~FDDSTexture ();
|
||||
|
||||
const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
|
||||
|
@ -181,10 +181,10 @@ protected:
|
|||
static void CalcBitShift (uint32_t mask, uint8_t *lshift, uint8_t *rshift);
|
||||
|
||||
void MakeTexture ();
|
||||
void ReadRGB (FWadLump &lump, uint8_t *tcbuf = NULL);
|
||||
void DecompressDXT1 (FWadLump &lump, uint8_t *tcbuf = NULL);
|
||||
void DecompressDXT3 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf = NULL);
|
||||
void DecompressDXT5 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf = NULL);
|
||||
void ReadRGB (FileRdr &lump, uint8_t *tcbuf = NULL);
|
||||
void DecompressDXT1 (FileRdr &lump, uint8_t *tcbuf = NULL);
|
||||
void DecompressDXT3 (FileRdr &lump, bool premultiplied, uint8_t *tcbuf = NULL);
|
||||
void DecompressDXT5 (FileRdr &lump, bool premultiplied, uint8_t *tcbuf = NULL);
|
||||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
|
@ -199,11 +199,11 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool CheckDDS (FileReader &file)
|
||||
static bool CheckDDS (FileRdr &file)
|
||||
{
|
||||
DDSFileHeader Header;
|
||||
|
||||
file.Seek (0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
if (file.Read (&Header, sizeof(Header)) != sizeof(Header))
|
||||
{
|
||||
return false;
|
||||
|
@ -222,7 +222,7 @@ static bool CheckDDS (FileReader &file)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
|
||||
FTexture *DDSTexture_TryCreate (FileRdr &data, int lumpnum)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
|
|||
|
||||
if (!CheckDDS(data)) return NULL;
|
||||
|
||||
data.Seek (4, SEEK_SET);
|
||||
data.Seek(4, FileRdr::SeekSet);
|
||||
data.Read (&surfdesc, sizeof(surfdesc));
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
|
@ -286,7 +286,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc)
|
||||
FDDSTexture::FDDSTexture (FileRdr &lump, int lumpnum, void *vsurfdesc)
|
||||
: FTexture(NULL, lumpnum), Pixels(0), Spans(0)
|
||||
{
|
||||
DDSURFACEDESC2 *surf = (DDSURFACEDESC2 *)vsurfdesc;
|
||||
|
@ -488,11 +488,11 @@ const uint8_t *FDDSTexture::GetPixels ()
|
|||
|
||||
void FDDSTexture::MakeTexture ()
|
||||
{
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||
|
||||
Pixels = new uint8_t[Width*Height];
|
||||
|
||||
lump.Seek (sizeof(DDSURFACEDESC2) + 4, SEEK_SET);
|
||||
lump.Seek (sizeof(DDSURFACEDESC2) + 4, FileRdr::SeekSet);
|
||||
|
||||
if (Format >= 1 && Format <= 4) // RGB: Format is # of bytes per pixel
|
||||
{
|
||||
|
@ -518,7 +518,7 @@ void FDDSTexture::MakeTexture ()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::ReadRGB (FWadLump &lump, uint8_t *tcbuf)
|
||||
void FDDSTexture::ReadRGB (FileRdr &lump, uint8_t *tcbuf)
|
||||
{
|
||||
uint32_t x, y;
|
||||
uint32_t amask = AMask == 0 ? 0 : 0x80000000 >> AShiftL;
|
||||
|
@ -587,7 +587,7 @@ void FDDSTexture::ReadRGB (FWadLump &lump, uint8_t *tcbuf)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::DecompressDXT1 (FWadLump &lump, uint8_t *tcbuf)
|
||||
void FDDSTexture::DecompressDXT1 (FileRdr &lump, uint8_t *tcbuf)
|
||||
{
|
||||
const long blocklinelen = ((Width + 3) >> 2) << 3;
|
||||
uint8_t *blockbuff = new uint8_t[blocklinelen];
|
||||
|
@ -685,7 +685,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, uint8_t *tcbuf)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf)
|
||||
void FDDSTexture::DecompressDXT3 (FileRdr &lump, bool premultiplied, uint8_t *tcbuf)
|
||||
{
|
||||
const long blocklinelen = ((Width + 3) >> 2) << 4;
|
||||
uint8_t *blockbuff = new uint8_t[blocklinelen];
|
||||
|
@ -767,7 +767,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, uint8_t *t
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf)
|
||||
void FDDSTexture::DecompressDXT5 (FileRdr &lump, bool premultiplied, uint8_t *tcbuf)
|
||||
{
|
||||
const long blocklinelen = ((Width + 3) >> 2) << 4;
|
||||
uint8_t *blockbuff = new uint8_t[blocklinelen];
|
||||
|
@ -881,11 +881,11 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, uint8_t *t
|
|||
|
||||
int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||
|
||||
uint8_t *TexBuffer = new uint8_t[4*Width*Height];
|
||||
|
||||
lump.Seek (sizeof(DDSURFACEDESC2) + 4, SEEK_SET);
|
||||
lump.Seek (sizeof(DDSURFACEDESC2) + 4, FileRdr::SeekSet);
|
||||
|
||||
if (Format >= 1 && Format <= 4) // RGB: Format is # of bytes per pixel
|
||||
{
|
||||
|
|
|
@ -68,11 +68,11 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *EmptyTexture_TryCreate(FileReader & file, int lumpnum)
|
||||
FTexture *EmptyTexture_TryCreate(FileRdr & file, int lumpnum)
|
||||
{
|
||||
char check[8];
|
||||
if (file.GetLength() != 8) return NULL;
|
||||
file.Seek(0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
if (file.Read(check, 8) != 8) return NULL;
|
||||
if (memcmp(check, "\0\0\0\0\0\0\0\0", 8)) return NULL;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *FlatTexture_TryCreate(FileReader & file, int lumpnum)
|
||||
FTexture *FlatTexture_TryCreate(FileRdr & file, int lumpnum)
|
||||
{
|
||||
return new FFlatTexture(lumpnum);
|
||||
}
|
||||
|
@ -194,9 +194,9 @@ const uint8_t *FFlatTexture::GetPixels ()
|
|||
|
||||
void FFlatTexture::MakeTexture ()
|
||||
{
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||
Pixels = new uint8_t[Width*Height];
|
||||
long numread = lump.Read (Pixels, Width*Height);
|
||||
auto numread = lump.Read (Pixels, Width*Height);
|
||||
if (numread < Width*Height)
|
||||
{
|
||||
memset (Pixels + numread, 0xBB, Width*Height - numread);
|
||||
|
|
|
@ -83,13 +83,13 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum)
|
||||
FTexture *IMGZTexture_TryCreate(FileRdr & file, int lumpnum)
|
||||
{
|
||||
uint32_t magic = 0;
|
||||
uint16_t w, h;
|
||||
int16_t l, t;
|
||||
|
||||
file.Seek(0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
if (file.Read(&magic, 4) != 4) return NULL;
|
||||
if (magic != MAKE_ID('I','M','G','Z')) return NULL;
|
||||
file >> w >> h >> l >> t;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -814,7 +814,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
|
|||
}
|
||||
|
||||
{
|
||||
FWadLump pnames = Wads.OpenLumpNum (patcheslump);
|
||||
auto pnames = Wads.OpenLumpReader (patcheslump);
|
||||
|
||||
pnames >> numpatches;
|
||||
|
||||
|
|
|
@ -81,12 +81,12 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool CheckIfPatch(FileReader & file)
|
||||
static bool CheckIfPatch(FileRdr & file)
|
||||
{
|
||||
if (file.GetLength() < 13) return false; // minimum length of a valid Doom patch
|
||||
|
||||
uint8_t *data = new uint8_t[file.GetLength()];
|
||||
file.Seek(0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
file.Read(data, file.GetLength());
|
||||
|
||||
const patch_t *foo = (const patch_t *)data;
|
||||
|
@ -129,12 +129,12 @@ static bool CheckIfPatch(FileReader & file)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *PatchTexture_TryCreate(FileReader & file, int lumpnum)
|
||||
FTexture *PatchTexture_TryCreate(FileRdr & file, int lumpnum)
|
||||
{
|
||||
patch_t header;
|
||||
|
||||
if (!CheckIfPatch(file)) return NULL;
|
||||
file.Seek(0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
file >> header.width >> header.height >> header.leftoffset >> header.topoffset;
|
||||
return new FPatchTexture(lumpnum, &header);
|
||||
}
|
||||
|
|
|
@ -99,10 +99,10 @@ protected:
|
|||
uint8_t *Pixels;
|
||||
Span DummySpans[2];
|
||||
|
||||
void ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
||||
void ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
||||
void ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
||||
void ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes);
|
||||
void ReadPCX1bit (uint8_t *dst, FileRdr & lump, PCXHeader *hdr);
|
||||
void ReadPCX4bits (uint8_t *dst, FileRdr & lump, PCXHeader *hdr);
|
||||
void ReadPCX8bits (uint8_t *dst, FileRdr & lump, PCXHeader *hdr);
|
||||
void ReadPCX24bits (uint8_t *dst, FileRdr & lump, PCXHeader *hdr, int planes);
|
||||
|
||||
virtual void MakeTexture ();
|
||||
|
||||
|
@ -116,11 +116,11 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum)
|
||||
FTexture * PCXTexture_TryCreate(FileRdr & file, int lumpnum)
|
||||
{
|
||||
PCXHeader hdr;
|
||||
|
||||
file.Seek(0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
if (file.Read(&hdr, sizeof(hdr)) != sizeof(hdr))
|
||||
{
|
||||
return NULL;
|
||||
|
@ -141,7 +141,7 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum)
|
|||
if (hdr.padding[i] != 0) return NULL;
|
||||
}
|
||||
|
||||
file.Seek(0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
file.Read(&hdr, sizeof(hdr));
|
||||
|
||||
return new FPCXTexture(lumpnum, hdr);
|
||||
|
@ -256,7 +256,7 @@ const uint8_t *FPCXTexture::GetPixels ()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FPCXTexture::ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||
void FPCXTexture::ReadPCX1bit (uint8_t *dst, FileRdr & lump, PCXHeader *hdr)
|
||||
{
|
||||
int y, i, bytes;
|
||||
int rle_count = 0;
|
||||
|
@ -304,7 +304,7 @@ void FPCXTexture::ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||
void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileRdr & lump, PCXHeader *hdr)
|
||||
{
|
||||
int rle_count = 0, rle_value = 0;
|
||||
int x, y, c;
|
||||
|
@ -367,7 +367,7 @@ void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FPCXTexture::ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||
void FPCXTexture::ReadPCX8bits (uint8_t *dst, FileRdr & lump, PCXHeader *hdr)
|
||||
{
|
||||
int rle_count = 0, rle_value = 0;
|
||||
int y, bytes;
|
||||
|
@ -409,7 +409,7 @@ void FPCXTexture::ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FPCXTexture::ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes)
|
||||
void FPCXTexture::ReadPCX24bits (uint8_t *dst, FileRdr & lump, PCXHeader *hdr, int planes)
|
||||
{
|
||||
int rle_count = 0, rle_value = 0;
|
||||
int y, c;
|
||||
|
@ -463,7 +463,7 @@ void FPCXTexture::MakeTexture()
|
|||
PCXHeader header;
|
||||
int bitcount;
|
||||
|
||||
FWadLump lump = Wads.OpenLumpNum(SourceLump);
|
||||
auto lump = Wads.OpenLumpReader(SourceLump);
|
||||
|
||||
lump.Read(&header, sizeof(header));
|
||||
|
||||
|
@ -494,7 +494,7 @@ void FPCXTexture::MakeTexture()
|
|||
else if (bitcount == 8)
|
||||
{
|
||||
uint8_t c;
|
||||
lump.Seek(-769, SEEK_END);
|
||||
lump.Seek(-769, FileRdr::SeekEnd);
|
||||
lump >> c;
|
||||
//if (c !=0x0c) memcpy(PaletteMap, GrayMap, 256); // Fallback for files without palette
|
||||
//else
|
||||
|
@ -504,7 +504,7 @@ void FPCXTexture::MakeTexture()
|
|||
lump >> r >> g >> b;
|
||||
PaletteMap[i] = ColorMatcher.Pick(r,g,b);
|
||||
}
|
||||
lump.Seek(sizeof(header), SEEK_SET);
|
||||
lump.Seek(sizeof(header), FileRdr::SeekSet);
|
||||
ReadPCX8bits (Pixels, lump, &header);
|
||||
}
|
||||
if (Width == Height)
|
||||
|
@ -552,7 +552,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
|
|||
int bitcount;
|
||||
uint8_t * Pixels;
|
||||
|
||||
FWadLump lump = Wads.OpenLumpNum(SourceLump);
|
||||
auto lump = Wads.OpenLumpReader(SourceLump);
|
||||
|
||||
lump.Read(&header, sizeof(header));
|
||||
|
||||
|
@ -583,7 +583,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
|
|||
else if (bitcount == 8)
|
||||
{
|
||||
uint8_t c;
|
||||
lump.Seek(-769, SEEK_END);
|
||||
lump.Seek(-769, FileRdr::SeekEnd);
|
||||
lump >> c;
|
||||
c=0x0c; // Apparently there's many non-compliant PCXs out there...
|
||||
if (c !=0x0c)
|
||||
|
@ -596,7 +596,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
|
|||
lump >> r >> g >> b;
|
||||
pe[i] = PalEntry(255, r,g,b);
|
||||
}
|
||||
lump.Seek(sizeof(header), SEEK_SET);
|
||||
lump.Seek(sizeof(header), FileRdr::SeekSet);
|
||||
ReadPCX8bits (Pixels, lump, &header);
|
||||
}
|
||||
bmp->CopyPixelData(x, y, Pixels, Width, Height, 1, Width, rotate, pe, inf);
|
||||
|
|
|
@ -90,7 +90,7 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
|
||||
FTexture *PNGTexture_TryCreate(FileRdr & data, int lumpnum)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
|
|||
// first 4 bytes match, but later bytes don't, we assume it's
|
||||
// a corrupt PNG.)
|
||||
|
||||
data.Seek(0, SEEK_SET);
|
||||
data.Seek(0, FileRdr::SeekSet);
|
||||
if (data.Read (first4bytes.b, 4) != 4) return NULL;
|
||||
if (first4bytes.dw != MAKE_ID(137,'P','N','G')) return NULL;
|
||||
if (data.Read (first4bytes.b, 4) != 4) return NULL;
|
||||
|
@ -136,7 +136,7 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
|
|||
}
|
||||
|
||||
// Just for completeness, make sure the PNG has something more than an IHDR.
|
||||
data.Seek (4, SEEK_CUR);
|
||||
data.Seek (4, FileRdr::SeekSet);
|
||||
data.Read (first4bytes.b, 4);
|
||||
if (first4bytes.dw == 0)
|
||||
{
|
||||
|
@ -147,7 +147,7 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
|
|||
}
|
||||
}
|
||||
|
||||
return new FPNGTexture (data, lumpnum, FString(), BigLong((int)width), BigLong((int)height),
|
||||
return new FPNGTexture (*data.Reader(), lumpnum, FString(), BigLong((int)width), BigLong((int)height),
|
||||
bitdepth, colortype, interlace);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool CheckIfRaw(FileReader & data)
|
||||
static bool CheckIfRaw(FileRdr & data)
|
||||
{
|
||||
if (data.GetLength() != 64000) return false;
|
||||
|
||||
|
@ -80,7 +80,7 @@ static bool CheckIfRaw(FileReader & data)
|
|||
int width;
|
||||
|
||||
foo = (patch_t *)M_Malloc (data.GetLength());
|
||||
data.Seek (0, SEEK_SET);
|
||||
data.Seek (0, FileRdr::SeekSet);
|
||||
data.Read (foo, data.GetLength());
|
||||
|
||||
height = LittleShort(foo->height);
|
||||
|
@ -148,7 +148,7 @@ static bool CheckIfRaw(FileReader & data)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *RawPageTexture_TryCreate(FileReader & file, int lumpnum)
|
||||
FTexture *RawPageTexture_TryCreate(FileRdr & file, int lumpnum)
|
||||
{
|
||||
if (!CheckIfRaw(file)) return NULL;
|
||||
return new FRawPageTexture(lumpnum);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "v_palette.h"
|
||||
|
||||
typedef bool (*CheckFunc)(FileReader & file);
|
||||
typedef FTexture * (*CreateFunc)(FileReader & file, int lumpnum);
|
||||
typedef FTexture * (*CreateFunc)(FileRdr & file, int lumpnum);
|
||||
|
||||
struct TexCreateInfo
|
||||
{
|
||||
|
@ -66,17 +66,17 @@ void FTexture::InitGrayMap()
|
|||
}
|
||||
}
|
||||
|
||||
FTexture *IMGZTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *PNGTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *JPEGTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *DDSTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *PCXTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *TGATexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *RawPageTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *FlatTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *PatchTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *EmptyTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *AutomapTexture_TryCreate(FileReader &, int lumpnum);
|
||||
FTexture *IMGZTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *PNGTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *JPEGTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *DDSTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *PCXTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *TGATexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *RawPageTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *FlatTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *PatchTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *EmptyTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
FTexture *AutomapTexture_TryCreate(FileRdr &, int lumpnum);
|
||||
|
||||
|
||||
// Examines the lump contents to decide what type of texture to create,
|
||||
|
@ -99,7 +99,7 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype)
|
|||
|
||||
if (lumpnum == -1) return NULL;
|
||||
|
||||
FWadLump data = Wads.OpenLumpNum (lumpnum);
|
||||
auto data = Wads.OpenLumpReader (lumpnum);
|
||||
|
||||
for(size_t i = 0; i < countof(CreateInfo); i++)
|
||||
{
|
||||
|
|
|
@ -764,16 +764,16 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
|
|||
|
||||
void FTextureManager::AddPatches (int lumpnum)
|
||||
{
|
||||
FWadLump *file = Wads.ReopenLumpNum (lumpnum);
|
||||
auto file = Wads.ReopenLumpReader (lumpnum, true);
|
||||
uint32_t numpatches, i;
|
||||
char name[9];
|
||||
|
||||
*file >> numpatches;
|
||||
file >> numpatches;
|
||||
name[8] = '\0';
|
||||
|
||||
for (i = 0; i < numpatches; ++i)
|
||||
{
|
||||
file->Read (name, 8);
|
||||
file.Read (name, 8);
|
||||
|
||||
if (CheckForTexture (name, FTexture::TEX_WallPatch, 0) == -1)
|
||||
{
|
||||
|
@ -781,8 +781,6 @@ void FTextureManager::AddPatches (int lumpnum)
|
|||
}
|
||||
StartScreen->Progress();
|
||||
}
|
||||
|
||||
delete file;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1187,7 +1185,7 @@ int FTextureManager::CountLumpTextures (int lumpnum)
|
|||
{
|
||||
if (lumpnum >= 0)
|
||||
{
|
||||
FWadLump file = Wads.OpenLumpNum (lumpnum);
|
||||
auto file = Wads.OpenLumpReader (lumpnum);
|
||||
uint32_t numtex;
|
||||
|
||||
file >> numtex;
|
||||
|
|
|
@ -94,7 +94,7 @@ protected:
|
|||
uint8_t *Pixels;
|
||||
Span **Spans;
|
||||
|
||||
void ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel);
|
||||
void ReadCompressed(FileRdr &lump, uint8_t * buffer, int bytesperpixel);
|
||||
|
||||
virtual void MakeTexture ();
|
||||
|
||||
|
@ -107,13 +107,13 @@ protected:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum)
|
||||
FTexture *TGATexture_TryCreate(FileRdr & file, int lumpnum)
|
||||
{
|
||||
TGAHeader hdr;
|
||||
|
||||
if (file.GetLength() < (long)sizeof(hdr)) return NULL;
|
||||
|
||||
file.Seek(0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
file.Read(&hdr, sizeof(hdr));
|
||||
hdr.width = LittleShort(hdr.width);
|
||||
hdr.height = LittleShort(hdr.height);
|
||||
|
@ -127,7 +127,7 @@ FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum)
|
|||
if (hdr.img_type >=4 && hdr.img_type <= 8) return NULL;
|
||||
if ((hdr.img_desc & 16) != 0) return NULL;
|
||||
|
||||
file.Seek(0, SEEK_SET);
|
||||
file.Seek(0, FileRdr::SeekSet);
|
||||
file.Read(&hdr, sizeof(hdr));
|
||||
hdr.width = LittleShort(hdr.width);
|
||||
hdr.height = LittleShort(hdr.height);
|
||||
|
@ -250,7 +250,7 @@ const uint8_t *FTGATexture::GetPixels ()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel)
|
||||
void FTGATexture::ReadCompressed(FileRdr &lump, uint8_t * buffer, int bytesperpixel)
|
||||
{
|
||||
uint8_t b;
|
||||
uint8_t data[4];
|
||||
|
@ -290,7 +290,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe
|
|||
void FTGATexture::MakeTexture ()
|
||||
{
|
||||
uint8_t PaletteMap[256];
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||
TGAHeader hdr;
|
||||
uint16_t w;
|
||||
uint8_t r,g,b,a;
|
||||
|
@ -298,7 +298,7 @@ void FTGATexture::MakeTexture ()
|
|||
|
||||
Pixels = new uint8_t[Width*Height];
|
||||
lump.Read(&hdr, sizeof(hdr));
|
||||
lump.Seek(hdr.id_len, SEEK_CUR);
|
||||
lump.Seek(hdr.id_len, FileRdr::SeekCur);
|
||||
|
||||
hdr.width = LittleShort(hdr.width);
|
||||
hdr.height = LittleShort(hdr.height);
|
||||
|
@ -491,7 +491,7 @@ void FTGATexture::MakeTexture ()
|
|||
int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||
TGAHeader hdr;
|
||||
uint16_t w;
|
||||
uint8_t r,g,b,a;
|
||||
|
@ -499,7 +499,7 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
|
|||
int transval = 0;
|
||||
|
||||
lump.Read(&hdr, sizeof(hdr));
|
||||
lump.Seek(hdr.id_len, SEEK_CUR);
|
||||
lump.Seek(hdr.id_len, FileRdr::SeekCur);
|
||||
|
||||
hdr.width = LittleShort(hdr.width);
|
||||
hdr.height = LittleShort(hdr.height);
|
||||
|
|
|
@ -321,7 +321,7 @@ FFont *V_GetFont(const char *name)
|
|||
{
|
||||
uint32_t head;
|
||||
{
|
||||
FWadLump lumpy = Wads.OpenLumpNum (lump);
|
||||
auto lumpy = Wads.OpenLumpReader (lump);
|
||||
lumpy.Read (&head, 4);
|
||||
}
|
||||
if ((head & MAKE_ID(255,255,255,0)) == MAKE_ID('F','O','N',0) ||
|
||||
|
@ -1855,7 +1855,7 @@ void FFontChar2::SetSourceRemap(const uint8_t *sourceremap)
|
|||
|
||||
void FFontChar2::MakeTexture ()
|
||||
{
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||
int destSize = Width * Height;
|
||||
uint8_t max = 255;
|
||||
bool rle = true;
|
||||
|
@ -1868,18 +1868,18 @@ void FFontChar2::MakeTexture ()
|
|||
{
|
||||
lump.Read (buff, 7);
|
||||
max = buff[6];
|
||||
lump.Seek (SourcePos - 11, SEEK_CUR);
|
||||
lump.Seek (SourcePos - 11, FileRdr::SeekCur);
|
||||
}
|
||||
else if (buff[3] == 0x1A)
|
||||
{
|
||||
lump.Read(buff, 13);
|
||||
max = buff[12] - 1;
|
||||
lump.Seek (SourcePos - 17, SEEK_CUR);
|
||||
lump.Seek (SourcePos - 17, FileRdr::SeekCur);
|
||||
rle = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
lump.Seek (SourcePos - 4, SEEK_CUR);
|
||||
lump.Seek (SourcePos - 4, FileRdr::SeekCur);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -966,8 +966,8 @@ FStrifeStartupScreen::FStrifeStartupScreen(int max_progress, HRESULT &hr)
|
|||
|
||||
// Fill bitmap with the startup image.
|
||||
memset (ST_Util_BitsForBitmap(StartupBitmap), 0xF0, 64000);
|
||||
FWadLump lumpr = Wads.OpenLumpNum (startup_lump);
|
||||
lumpr.Seek (57 * 320, SEEK_SET);
|
||||
auto lumpr = Wads.OpenLumpReader (startup_lump);
|
||||
lumpr.Seek (57 * 320, FileRdr::SeekSet);
|
||||
lumpr.Read (ST_Util_BitsForBitmap(StartupBitmap) + 41 * 320, 95 * 320);
|
||||
|
||||
// Load the animated overlays.
|
||||
|
@ -978,7 +978,7 @@ FStrifeStartupScreen::FStrifeStartupScreen(int max_progress, HRESULT &hr)
|
|||
|
||||
if (lumpnum >= 0 && (lumplen = Wads.LumpLength (lumpnum)) == StrifeStartupPicSizes[i])
|
||||
{
|
||||
FWadLump lumpr = Wads.OpenLumpNum (lumpnum);
|
||||
auto lumpr = Wads.OpenLumpReader (lumpnum);
|
||||
StartupPics[i] = new uint8_t[lumplen];
|
||||
lumpr.Read (StartupPics[i], lumplen);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue