From b085c09f86f9256c898fc0c629dab3f930ee9624 Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Mon, 30 Nov 2015 13:36:15 +0100 Subject: [PATCH 1/4] Fix windows builds Can't instantiate a container (at least with MSVC) without knowing the exact size of the object being stored, forward-declares only work with pointers. I couldn't see a simple way to remove the forward declare, so pointers and memory management it is. --- apps/openmw/mwsound/soundmanagerimp.cpp | 11 ++++++----- apps/openmw/mwsound/soundmanagerimp.hpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 0f5cee737..71e1c97a8 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -104,9 +104,10 @@ namespace MWSound SoundBufferList::iterator sfxiter = mSoundBuffers.begin(); for(;sfxiter != mSoundBuffers.end();++sfxiter) { - if(sfxiter->mHandle) - mOutput->unloadSound(sfxiter->mHandle); - sfxiter->mHandle = 0; + if((*sfxiter)->mHandle) + mOutput->unloadSound((*sfxiter)->mHandle); + (*sfxiter)->mHandle = 0; + delete (*sfxiter); } mUnusedBuffers.clear(); } @@ -145,8 +146,8 @@ namespace MWSound min = std::max(min, 1.0f); max = std::max(min, max); - Sound_Buffer *sfx = &*mSoundBuffers.insert(mSoundBuffers.end(), - Sound_Buffer("Sound/"+sound->mSound, volume, min, max) + Sound_Buffer *sfx = *mSoundBuffers.insert(mSoundBuffers.end(), + new Sound_Buffer("Sound/"+sound->mSound, volume, min, max) ); mVFS->normalizeFilename(sfx->mResourceName); diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index 8e2df9f1a..196fb28f2 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -56,7 +56,7 @@ namespace MWSound float mVoiceVolume; float mFootstepsVolume; - typedef std::deque SoundBufferList; + typedef std::deque SoundBufferList; // List of sound buffers, grown as needed. New enties are added to the // back, allowing existing Sound_Buffer references/pointers to remain // valid. From a69e751089d5d7c9189b64687560033cf14cda0c Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Mon, 30 Nov 2015 17:38:46 +0100 Subject: [PATCH 2/4] Revert "Fix windows builds" This reverts commit b085c09f86f9256c898fc0c629dab3f930ee9624. --- apps/openmw/mwsound/soundmanagerimp.cpp | 11 +++++------ apps/openmw/mwsound/soundmanagerimp.hpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 71e1c97a8..0f5cee737 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -104,10 +104,9 @@ namespace MWSound SoundBufferList::iterator sfxiter = mSoundBuffers.begin(); for(;sfxiter != mSoundBuffers.end();++sfxiter) { - if((*sfxiter)->mHandle) - mOutput->unloadSound((*sfxiter)->mHandle); - (*sfxiter)->mHandle = 0; - delete (*sfxiter); + if(sfxiter->mHandle) + mOutput->unloadSound(sfxiter->mHandle); + sfxiter->mHandle = 0; } mUnusedBuffers.clear(); } @@ -146,8 +145,8 @@ namespace MWSound min = std::max(min, 1.0f); max = std::max(min, max); - Sound_Buffer *sfx = *mSoundBuffers.insert(mSoundBuffers.end(), - new Sound_Buffer("Sound/"+sound->mSound, volume, min, max) + Sound_Buffer *sfx = &*mSoundBuffers.insert(mSoundBuffers.end(), + Sound_Buffer("Sound/"+sound->mSound, volume, min, max) ); mVFS->normalizeFilename(sfx->mResourceName); diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index 196fb28f2..8e2df9f1a 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -56,7 +56,7 @@ namespace MWSound float mVoiceVolume; float mFootstepsVolume; - typedef std::deque SoundBufferList; + typedef std::deque SoundBufferList; // List of sound buffers, grown as needed. New enties are added to the // back, allowing existing Sound_Buffer references/pointers to remain // valid. From 682329851633b6cb956ca01514a4b0cf26c9844b Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Mon, 30 Nov 2015 17:42:25 +0100 Subject: [PATCH 3/4] Different way to solve the type deduction issue --- apps/openmw/mwsound/soundmanagerimp.cpp | 7 ++++--- apps/openmw/mwsound/soundmanagerimp.hpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 0f5cee737..ceff1a619 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -40,6 +40,7 @@ namespace MWSound , mMusicVolume(1.0f) , mVoiceVolume(1.0f) , mFootstepsVolume(1.0f) + , mSoundBuffers(new SoundBufferList::element_type()) , mBufferCacheSize(0) , mListenerUnderwater(false) , mListenerPos(0,0,0) @@ -101,8 +102,8 @@ namespace MWSound clear(); if(mOutput->isInitialized()) { - SoundBufferList::iterator sfxiter = mSoundBuffers.begin(); - for(;sfxiter != mSoundBuffers.end();++sfxiter) + SoundBufferList::element_type::iterator sfxiter = mSoundBuffers->begin(); + for(;sfxiter != mSoundBuffers->end();++sfxiter) { if(sfxiter->mHandle) mOutput->unloadSound(sfxiter->mHandle); @@ -145,7 +146,7 @@ namespace MWSound min = std::max(min, 1.0f); max = std::max(min, max); - Sound_Buffer *sfx = &*mSoundBuffers.insert(mSoundBuffers.end(), + Sound_Buffer *sfx = &*mSoundBuffers->insert(mSoundBuffers->end(), Sound_Buffer("Sound/"+sound->mSound, volume, min, max) ); mVFS->normalizeFilename(sfx->mResourceName); diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index 8e2df9f1a..424fa712c 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -1,6 +1,7 @@ #ifndef GAME_SOUND_SOUNDMANAGER_H #define GAME_SOUND_SOUNDMANAGER_H +#include #include #include #include @@ -56,7 +57,7 @@ namespace MWSound float mVoiceVolume; float mFootstepsVolume; - typedef std::deque SoundBufferList; + typedef std::auto_ptr> SoundBufferList; // List of sound buffers, grown as needed. New enties are added to the // back, allowing existing Sound_Buffer references/pointers to remain // valid. From 24340bff959fef20cc4277afd2666caa07dcd4de Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Mon, 30 Nov 2015 17:47:36 +0100 Subject: [PATCH 4/4] Add a space --- apps/openmw/mwsound/soundmanagerimp.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index 424fa712c..9c090585b 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -57,7 +57,7 @@ namespace MWSound float mVoiceVolume; float mFootstepsVolume; - typedef std::auto_ptr> SoundBufferList; + typedef std::auto_ptr > SoundBufferList; // List of sound buffers, grown as needed. New enties are added to the // back, allowing existing Sound_Buffer references/pointers to remain // valid.