From 2260f6bf4feb62929e32a1bea9cd3f403aa034b1 Mon Sep 17 00:00:00 2001 From: Krzysztof Dermont Date: Fri, 20 Jun 2014 23:41:38 +0200 Subject: Big part of PhysFS support * removed -mod argument * removed -datadir argument * removed -lang argument * removed some dead ui code * added resource manager and file loaders (stream and SDL) * changed interface textures location to match new directory structure * removed CGameData for mod support * added PhysFS support --- src/sound/oalsound/alsound.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/sound/oalsound/alsound.cpp') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 8afbdd2..4d40c3b 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -18,8 +18,6 @@ #include "sound/oalsound/alsound.h" -#include "app/gamedata.h" - #include #include @@ -165,7 +163,7 @@ int ALSound::GetMusicVolume() bool ALSound::Cache(Sound sound, const std::string &filename) { Buffer *buffer = new Buffer(); - if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_SOUND, filename), sound)) + if (buffer->LoadFromFile(filename, sound)) { m_sounds[sound] = buffer; return true; @@ -178,7 +176,7 @@ bool ALSound::CacheMusic(const std::string &filename) if (m_music.find(filename) == m_music.end()) { Buffer *buffer = new Buffer(); - if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename), static_cast(-1))) + if (buffer->LoadFromFile(filename, static_cast(-1))) { m_music[filename] = buffer; return true; @@ -635,21 +633,20 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim return false; } - std::string file = CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename); Buffer *buffer; // check if we have music in cache if (m_music.find(filename) == m_music.end()) { GetLogger()->Debug("Music %s was not cached!\n", filename.c_str()); - if (!boost::filesystem::exists(file)) + if (!boost::filesystem::exists(filename)) { GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str()); return false; } buffer = new Buffer(); - if (!buffer->LoadFromFile(file, static_cast(-1))) + if (!buffer->LoadFromFile(filename, static_cast(-1))) { return false; } -- cgit v1.2.3-1-g7c22 From 754154341dba420e5bfc3190c81deb2859d751ba Mon Sep 17 00:00:00 2001 From: Krzysztof Dermont Date: Sun, 22 Jun 2014 15:01:06 +0200 Subject: More work on PhysFS support * added output stream * fixed music loading --- src/sound/oalsound/alsound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sound/oalsound/alsound.cpp') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 4d40c3b..e9bc116 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -609,7 +609,7 @@ void ALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat) bool ALSound::PlayMusic(int rank, bool bRepeat, float fadeTime) { std::stringstream filename; - filename << "music" << std::setfill('0') << std::setw(3) << rank << ".ogg"; + filename << "music/music" << std::setfill('0') << std::setw(3) << rank << ".ogg"; return PlayMusic(filename.str(), bRepeat, fadeTime); } -- cgit v1.2.3-1-g7c22 From 7b04f673580f0c24aecc103a25c4c4b82da1380f Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 10 Jul 2014 15:38:37 +0200 Subject: Fixed music loading --- src/sound/oalsound/alsound.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/sound/oalsound/alsound.cpp') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index e9bc116..54c94a5 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -173,12 +173,12 @@ bool ALSound::Cache(Sound sound, const std::string &filename) bool ALSound::CacheMusic(const std::string &filename) { - if (m_music.find(filename) == m_music.end()) + if (m_music.find("music/"+filename) == m_music.end()) { Buffer *buffer = new Buffer(); - if (buffer->LoadFromFile(filename, static_cast(-1))) + if (buffer->LoadFromFile("music/"+filename, static_cast(-1))) { - m_music[filename] = buffer; + m_music["music/"+filename] = buffer; return true; } } @@ -609,7 +609,7 @@ void ALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat) bool ALSound::PlayMusic(int rank, bool bRepeat, float fadeTime) { std::stringstream filename; - filename << "music/music" << std::setfill('0') << std::setw(3) << rank << ".ogg"; + filename << "music" << std::setfill('0') << std::setw(3) << rank << ".ogg"; return PlayMusic(filename.str(), bRepeat, fadeTime); } @@ -636,26 +636,26 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim Buffer *buffer; // check if we have music in cache - if (m_music.find(filename) == m_music.end()) + if (m_music.find("music/"+filename) == m_music.end()) { GetLogger()->Debug("Music %s was not cached!\n", filename.c_str()); - if (!boost::filesystem::exists(filename)) + /* TODO: if (!boost::filesystem::exists("music/"+filename)) { GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str()); return false; - } + } */ buffer = new Buffer(); - if (!buffer->LoadFromFile(filename, static_cast(-1))) + if (!buffer->LoadFromFile("music/"+filename, static_cast(-1))) { return false; } - m_music[filename] = buffer; + m_music["music/"+filename] = buffer; } else { GetLogger()->Debug("Music loaded from cache\n"); - buffer = m_music[filename]; + buffer = m_music["music/"+filename]; } if (m_currentMusic) -- cgit v1.2.3-1-g7c22 From ac019c263d7b41742934a9dafd58ac2e6171109c Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 9 Aug 2014 22:45:07 +0200 Subject: Remove unnecessary delete checks (#318) --- src/sound/oalsound/alsound.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/sound/oalsound/alsound.cpp') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 8afbdd2..327bb6f 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -58,20 +58,14 @@ void ALSound::CleanUp() delete channel.second; } - if (m_currentMusic) - { - delete m_currentMusic; - } - + delete m_currentMusic; + for (auto item : m_oldMusic) { delete item.music; } - - if (m_previousMusic.music) - { - delete m_previousMusic.music; - } + + delete m_previousMusic.music; for (auto item : m_sounds) { -- cgit v1.2.3-1-g7c22 From 9fd6cf54492cedd7f6231a0b1d0655120cb1c4d7 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 14 Oct 2014 15:11:37 +0200 Subject: Changed all occurences of PPC in the code to TerranovaTeam --- src/sound/oalsound/alsound.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/sound/oalsound/alsound.cpp') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 327bb6f..72cb557 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -1,19 +1,21 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch -// * Copyright (C) 2012 Polish Portal of Colobot (PPC) -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see http://www.gnu.org/licenses/. +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "sound/oalsound/alsound.h" -- cgit v1.2.3-1-g7c22 From 9ea0b374082b651c9147e609aa4c8e2b8a83966a Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 19 Oct 2014 14:21:55 +0200 Subject: Possible fix for #331 --- src/sound/oalsound/alsound.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sound/oalsound/alsound.cpp') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 72cb557..960faac 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -297,6 +297,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) } delete chn; GetLogger()->Debug("Could not open additional channel to play sound!\n"); + break; } } } -- cgit v1.2.3-1-g7c22 From 6d152d5aeedf8207897f751bfbd179d9994f39cf Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 2 Nov 2014 13:33:37 +0100 Subject: Fixed console spam when music files are not installed Closes #359 --- src/sound/oalsound/alsound.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/sound/oalsound/alsound.cpp') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 0d8fe74..6dd991b 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -181,6 +181,16 @@ bool ALSound::CacheMusic(const std::string &filename) return false; } +bool ALSound::IsCached(Sound sound) +{ + return m_sounds.find(sound) != m_sounds.end(); +} + +bool ALSound::IsCachedMusic(const std::string &filename) +{ + return m_music.find("music/"+filename) != m_music.end(); +} + int ALSound::GetPriority(Sound sound) { if ( sound == SOUND_FLYh || -- cgit v1.2.3-1-g7c22