mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-08 18:09:45 +01:00
Revert "Add destructor for SoundTrack/MusicTrack (and explicitly define move constructor to prevent double-free)"
This reverts commit 2f760af439
.
This commit is contained in:
parent
098fb77611
commit
d193caac98
3 changed files with 62 additions and 99 deletions
|
@ -9,34 +9,34 @@ void musicclass::init()
|
|||
soundTracks.clear();
|
||||
musicTracks.clear();
|
||||
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/jump.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/jump2.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/hurt.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/souleyeminijingle.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/coin.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/save.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crumble.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/vanish.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/blip.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/preteleport.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/teleport.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crew1.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crew2.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crew3.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crew4.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crew5.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crew6.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/terminal.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/gamesaved.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crashing.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/blip2.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/countdown.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/go.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/crash.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/combine.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/newrecord.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/trophy.wav" )));
|
||||
soundTracks.push_back(move(SoundTrack( "sounds/rescue.wav" )));
|
||||
soundTracks.push_back(SoundTrack( "sounds/jump.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/jump2.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/hurt.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/souleyeminijingle.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/coin.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/save.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crumble.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/vanish.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/blip.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/preteleport.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/teleport.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew1.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew2.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew3.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew4.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew5.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew6.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/terminal.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/gamesaved.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crashing.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/blip2.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/countdown.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/go.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crash.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/combine.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/newrecord.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/trophy.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/rescue.wav" ));
|
||||
|
||||
#ifdef VVV_COMPILEMUSIC
|
||||
binaryBlob musicWriteBlob;
|
||||
|
@ -74,67 +74,67 @@ void musicclass::init()
|
|||
usingmmmmmm = true;
|
||||
int index = musicReadBlob.getIndex("data/music/0levelcomplete.ogg");
|
||||
SDL_RWops *rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/1pushingonwards.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/2positiveforce.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/3potentialforanything.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/4passionforexploring.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/5intermission.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/6presentingvvvvvv.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/7gamecomplete.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/8predestinedfate.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/9positiveforcereversed.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/10popularpotpourri.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/11pipedream.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/12pressurecooker.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/13pacedenergy.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/14piercingthesky.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/predestinedfatefinallevel.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
bool ohCrap = musicReadBlob.unPackBinary("vvvvvvmusic.vvv");
|
||||
SDL_assert(ohCrap && "Music not found!");
|
||||
|
@ -142,67 +142,67 @@ void musicclass::init()
|
|||
|
||||
int index = musicReadBlob.getIndex("data/music/0levelcomplete.ogg");
|
||||
SDL_RWops *rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/1pushingonwards.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/2positiveforce.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/3potentialforanything.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/4passionforexploring.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/5intermission.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/6presentingvvvvvv.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/7gamecomplete.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/8predestinedfate.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/9positiveforcereversed.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/10popularpotpourri.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/11pipedream.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/12pressurecooker.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/13pacedenergy.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/14piercingthesky.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/predestinedfatefinallevel.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(move(MusicTrack( rw )));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
safeToProcessMusic= false;
|
||||
m_doFadeInVol = false;
|
||||
|
|
|
@ -24,15 +24,6 @@ MusicTrack::MusicTrack(SDL_RWops *rw)
|
|||
}
|
||||
}
|
||||
|
||||
MusicTrack::MusicTrack(MusicTrack&& moved) : m_music(move(moved.m_music)), m_isValid(move(moved.m_isValid)) {
|
||||
moved.m_isValid = false;
|
||||
}
|
||||
|
||||
MusicTrack::~MusicTrack() {
|
||||
if (m_isValid) Mix_FreeMusic(m_music);
|
||||
m_isValid = false;
|
||||
}
|
||||
|
||||
SoundTrack::SoundTrack(const char* fileName)
|
||||
{
|
||||
sound = NULL;
|
||||
|
@ -47,22 +38,12 @@ SoundTrack::SoundTrack(const char* fileName)
|
|||
FILESYSTEM_freeMemory(&mem);
|
||||
}
|
||||
|
||||
if (sound == NULL) {
|
||||
if (sound == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to load WAV file: %s\n", Mix_GetError());
|
||||
} else {
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
SoundTrack::SoundTrack(SoundTrack&& moved) : sound(move(moved.sound)), isValid(move(moved.isValid)) {
|
||||
moved.isValid = false;
|
||||
}
|
||||
|
||||
SoundTrack::~SoundTrack() {
|
||||
if (isValid) Mix_FreeChunk(sound);
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
SoundSystem::SoundSystem()
|
||||
{
|
||||
int audio_rate = 44100;
|
||||
|
|
|
@ -8,9 +8,6 @@ class MusicTrack
|
|||
public:
|
||||
MusicTrack(const char* fileName);
|
||||
MusicTrack(SDL_RWops *rw);
|
||||
MusicTrack(MusicTrack&& moved);
|
||||
MusicTrack& operator=(const MusicTrack& other) = default;
|
||||
~MusicTrack();
|
||||
Mix_Music *m_music;
|
||||
bool m_isValid;
|
||||
};
|
||||
|
@ -19,12 +16,7 @@ class SoundTrack
|
|||
{
|
||||
public:
|
||||
SoundTrack(const char* fileName);
|
||||
SoundTrack(SoundTrack&& moved);
|
||||
SoundTrack& operator=(const SoundTrack& other) = default;
|
||||
SoundTrack() = default;
|
||||
~SoundTrack();
|
||||
Mix_Chunk *sound;
|
||||
bool isValid = false;
|
||||
};
|
||||
|
||||
class SoundSystem
|
||||
|
@ -34,14 +26,4 @@ public:
|
|||
void playMusic(MusicTrack* music);
|
||||
};
|
||||
|
||||
// polyfill of std::move
|
||||
template<typename T> struct remove_reference {typedef T type;};
|
||||
template<typename T> struct remove_reference<T&> {typedef T type;};
|
||||
template<typename T> struct remove_reference<T&&> {typedef T type;};
|
||||
|
||||
template<typename T>
|
||||
typename remove_reference<T>::type&& move(T&& t) {
|
||||
return static_cast<typename remove_reference<T>::type&&>(t);
|
||||
}
|
||||
|
||||
#endif /* SOUNDSYSTEM_H */
|
||||
|
|
Loading…
Reference in a new issue