From 85ff05c0b236923b5a5ec599813d60713ddd0513 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Feb 2020 09:41:48 +0100 Subject: [PATCH] - missed these in the last commit. --- src/sound/s_sound.cpp | 6 ++--- src/utility/files.h | 54 +++++++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index 516d6965d3..660925a1a9 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -35,9 +35,6 @@ #include #include -#ifdef _WIN32 -#include -#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 { diff --git a/src/utility/files.h b/src/utility/files.h index a82e5e8e2d..ec4b15223d 100644 --- a/src/utility/files.h +++ b/src/utility/files.h @@ -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 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& 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 ReadPadded(int padding) + { + TArray 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 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& cb) + { + ErrorCallback = cb; + } +}; +