- missed these in the last commit.

This commit is contained in:
Christoph Oelckers 2020-02-15 09:41:48 +01:00
parent dd2d9f4182
commit 85ff05c0b2
2 changed files with 39 additions and 21 deletions

View File

@ -35,9 +35,6 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <io.h>
#endif
#include "s_soundinternal.h"
#include "m_swap.h"
@ -818,6 +815,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_
for (chan = Channels, count = 0; chan != NULL && count < near_limit; chan = chan->NextChan)
{
if (chan->ChanFlags & CHANF_FORGETTABLE) continue;
if (!(chan->ChanFlags & CHANF_EVICTED) && &S_sfx[chan->SoundID] == sfx)
{
FVector3 chanorigin;
@ -1359,7 +1357,7 @@ void SoundEngine::StopChannel(FSoundChan *chan)
chan->Source = NULL;
}
}
GSnd->StopChannel(chan);
if (GSnd) GSnd->StopChannel(chan);
}
else
{

View File

@ -56,8 +56,11 @@ enum
METHOD_PPMD = 98,
METHOD_LZSS = 1337, // not used in Zips - this is for Console Doom compression
METHOD_ZLIB = 1338, // Zlib stream with header, used by compressed nodes.
METHOD_TRANSFEROWNER = 0x8000,
};
class FileReader;
class FileReaderInterface
{
public:
@ -71,22 +74,6 @@ public:
long GetLength () const { return Length; }
};
class DecompressorBase : public FileReaderInterface
{
std::function<void(const char*)> ErrorCallback = nullptr;
public:
// These do not work but need to be defined to satisfy the FileReaderInterface.
// They will just error out when called.
long Tell() const override;
long Seek(long offset, int origin) override;
char *Gets(char *strbuf, int len) override;
void DecompressionError(const char* error, ...) const;
void SetErrorCallback(const std::function<void(const char*)>& cb)
{
ErrorCallback = cb;
}
};
class MemoryReader : public FileReaderInterface
{
protected:
@ -123,12 +110,13 @@ class FileReader
FileReader(const FileReader &r) = delete;
FileReader &operator=(const FileReader &r) = delete;
public:
explicit FileReader(FileReaderInterface *r)
{
mReader = r;
}
public:
enum ESeek
{
SeekSet = SEEK_SET,
@ -217,6 +205,15 @@ public:
return buffer;
}
TArray<uint8_t> ReadPadded(int padding)
{
TArray<uint8_t> buffer(mReader->Length + padding, true);
Size length = mReader->Read(&buffer[0], mReader->Length);
if (length < mReader->Length) buffer.Clear();
else memset(buffer.Data() + mReader->Length, 0, padding);
return buffer;
}
char *Gets(char *strbuf, Size len)
{
return mReader->Gets(strbuf, (int)len);
@ -260,6 +257,13 @@ public:
return LittleShort(v);
}
int16_t ReadInt16BE()
{
uint16_t v = 0;
Read(&v, 2);
return BigShort(v);
}
uint32_t ReadUInt32()
{
uint32_t v = 0;
@ -292,6 +296,22 @@ public:
friend class FWadCollection;
};
class DecompressorBase : public FileReaderInterface
{
std::function<void(const char*)> ErrorCallback = nullptr;
public:
// These do not work but need to be defined to satisfy the FileReaderInterface.
// They will just error out when called.
long Tell() const override;
long Seek(long offset, int origin) override;
char *Gets(char *strbuf, int len) override;
void DecompressionError(const char* error, ...) const;
void SetErrorCallback(const std::function<void(const char*)>& cb)
{
ErrorCallback = cb;
}
};