mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
- changed lump reader setup for music so that for uncompressed data it opens a new FILE instead of caching the lump.
This reinstates behavior of pre-OpenAL versions but still uses the FileReader interface to keep the simplified code of the OpenAL branch.
This commit is contained in:
parent
4294b94728
commit
13fb76db21
3 changed files with 46 additions and 1 deletions
|
@ -2458,7 +2458,11 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
reader = Wads.ReopenLumpNum(lumpnum);
|
||||
reader = Wads.ReopenLumpNumNewFile(lumpnum);
|
||||
if (reader == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1228,6 +1228,17 @@ FWadLump *FWadCollection::ReopenLumpNum (int lump)
|
|||
return new FWadLump(LumpInfo[lump].lump, true);
|
||||
}
|
||||
|
||||
FWadLump *FWadCollection::ReopenLumpNumNewFile (int lump)
|
||||
{
|
||||
if ((unsigned)lump >= (unsigned)LumpInfo.Size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new FWadLump(lump, LumpInfo[lump].lump);
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// GetFileReader
|
||||
|
@ -1417,6 +1428,34 @@ FWadLump::FWadLump(FResourceLump *lump, bool alwayscache)
|
|||
}
|
||||
}
|
||||
|
||||
FWadLump::FWadLump(int lumpnum, FResourceLump *lump)
|
||||
: FileReader()
|
||||
{
|
||||
FileReader *f = lump->GetReader();
|
||||
|
||||
if (f != NULL && f->GetFile() != NULL)
|
||||
{
|
||||
// Uncompressed lump in a file. For this we will have to open a new FILE, since we need it for streaming
|
||||
int fileno = Wads.GetLumpFile(lumpnum);
|
||||
const char *filename = Wads.GetWadFullName(fileno);
|
||||
File = fopen(filename, "rb");
|
||||
if (File != NULL)
|
||||
{
|
||||
Length = lump->LumpSize;
|
||||
StartPos = FilePos = lump->GetFileOffset();
|
||||
Lump = NULL;
|
||||
CloseOnDestruct = true;
|
||||
Seek(0, SEEK_SET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
File = NULL;
|
||||
Length = lump->LumpSize;
|
||||
StartPos = FilePos = 0;
|
||||
Lump = lump;
|
||||
Lump->CacheLump();
|
||||
}
|
||||
|
||||
FWadLump::~FWadLump()
|
||||
{
|
||||
if (Lump != NULL)
|
||||
|
|
|
@ -112,6 +112,7 @@ public:
|
|||
|
||||
private:
|
||||
FWadLump (FResourceLump *Lump, bool alwayscache = false);
|
||||
FWadLump(int lumpnum, FResourceLump *lump);
|
||||
|
||||
FResourceLump *Lump;
|
||||
|
||||
|
@ -185,6 +186,7 @@ public:
|
|||
FWadLump OpenLumpNum (int lump);
|
||||
FWadLump OpenLumpName (const char *name) { return OpenLumpNum (GetNumForName (name)); }
|
||||
FWadLump *ReopenLumpNum (int lump); // Opens a new, independent FILE
|
||||
FWadLump *ReopenLumpNumNewFile (int lump); // Opens a new, independent FILE
|
||||
|
||||
FileReader * GetFileReader(int wadnum); // Gets a FileReader object to the entire WAD
|
||||
|
||||
|
|
Loading…
Reference in a new issue