diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/supernova/resman.cpp | 22 | ||||
-rw-r--r-- | engines/supernova/resman.h | 14 |
2 files changed, 12 insertions, 24 deletions
diff --git a/engines/supernova/resman.cpp b/engines/supernova/resman.cpp index aed4f18374..1c178846ed 100644 --- a/engines/supernova/resman.cpp +++ b/engines/supernova/resman.cpp @@ -20,10 +20,10 @@ * */ +#include "audio/audiostream.h" #include "audio/decoders/raw.h" #include "audio/mixer.h" #include "audio/mods/protracker.h" -#include "audio/audiostream.h" #include "common/memstream.h" #include "common/system.h" #include "graphics/cursorman.h" @@ -98,13 +98,6 @@ ResourceManager::ResourceManager() initGraphics(); } -ResourceManager::~ResourceManager() { - for (int i = 0; i < kAudioNumSamples; ++i) - delete _soundSamples[i]; - for (int i = 0; i < kNumImageFiles; ++i) - delete _images[i]; -} - void ResourceManager::initSoundFiles() { // Sound // Note: @@ -134,8 +127,8 @@ void ResourceManager::initSoundFiles() { file.close(); byte streamFlag = Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN; - _soundSamples[i] = Audio::makeRawStream(buffer, length, _audioRate, - streamFlag, DisposeAfterUse::YES); + _soundSamples[i].reset(Audio::makeRawStream(buffer, length, _audioRate, + streamFlag, DisposeAfterUse::YES)); } _musicIntroBuffer.reset(convertToMod("msn_data.052")); @@ -171,14 +164,13 @@ void ResourceManager::initCursorGraphics() { void ResourceManager::initImages() { for (int i = 0; i < kNumImageFiles; ++i) { - _images[i] = new MSNImage(); - if (!_images[i]->init(i)) + if (!_images[i].init(i)) error("Failed reading image file msn_data.%03d", i); } } Audio::SeekableAudioStream *ResourceManager::getSoundStream(AudioId index) { - Audio::SeekableAudioStream *stream = _soundSamples[index]; + Audio::SeekableAudioStream *stream = _soundSamples[index].get(); stream->rewind(); return stream; @@ -197,10 +189,10 @@ Audio::AudioStream *ResourceManager::getSoundStream(MusicId index) { } } -MSNImage *ResourceManager::getImage(int filenumber) const { +const MSNImage *ResourceManager::getImage(int filenumber) const { assert(filenumber < kNumImageFiles); - return _images[filenumber]; + return &_images[filenumber]; } const byte *ResourceManager::getImage(CursorId id) const { diff --git a/engines/supernova/resman.h b/engines/supernova/resman.h index 12304abf5e..080ecc5da4 100644 --- a/engines/supernova/resman.h +++ b/engines/supernova/resman.h @@ -23,13 +23,12 @@ #ifndef SUPERNOVA_RESOURCES_H #define SUPERNOVA_RESOURCES_H +#include "audio/audiostream.h" #include "common/ptr.h" +#include "supernova/graphics.h" #include "supernova/sound.h" -namespace Audio { -class SeekableAudioStream; -} namespace Common { class MemoryReadStream; @@ -37,8 +36,6 @@ class MemoryReadStream; namespace Supernova { -class MSNImage; - class ResourceManager { public: enum CursorId { @@ -51,11 +48,10 @@ public: public: ResourceManager(); - ~ResourceManager(); Audio::SeekableAudioStream *getSoundStream(AudioId index); Audio::AudioStream *getSoundStream(MusicId index); - MSNImage *getImage(int filenumber) const; + const MSNImage *getImage(int filenumber) const; const byte *getImage(CursorId id) const; private: @@ -65,13 +61,13 @@ private: void initImages(); private: - Audio::SeekableAudioStream *_soundSamples[kAudioNumSamples]; + Common::ScopedPtr<Audio::SeekableAudioStream> _soundSamples[kAudioNumSamples]; Common::ScopedPtr<Common::MemoryReadStream> _musicIntroBuffer; Common::ScopedPtr<Common::MemoryReadStream> _musicOutroBuffer; Common::ScopedPtr<Audio::AudioStream> _musicIntro; Common::ScopedPtr<Audio::AudioStream> _musicOutro; int _audioRate; - MSNImage *_images[kNumImageFiles]; + MSNImage _images[kNumImageFiles]; byte _cursorNormal[256]; byte _cursorWait[256]; }; |