summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-07-02 12:22:17 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-07-02 12:22:17 +0000
commit57966d67923562c6d3bb10532c09175e8dddf882 (patch)
treec1162364b5f8de6f75acad591efdd23e93285ec9 /src
parent76afaa810068cad82efa05cbac71c92f9531dd09 (diff)
downloadmana-57966d67923562c6d3bb10532c09175e8dddf882.tar.gz
mana-57966d67923562c6d3bb10532c09175e8dddf882.tar.bz2
mana-57966d67923562c6d3bb10532c09175e8dddf882.tar.xz
mana-57966d67923562c6d3bb10532c09175e8dddf882.zip
Music doesn't restart anymore if it's the same between maps.
(I hope Bjorn likes it this way :P)
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp19
-rw-r--r--src/game.cpp7
2 files changed, 17 insertions, 9 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 3d18f8ad..1743bcc1 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -268,14 +268,21 @@ Map *Engine::getCurrentMap()
void Engine::setCurrentMap(Map *newMap)
{
+ std::string oldMusic = "";
+ if (mCurrentMap) {
+ oldMusic = mCurrentMap->getProperty("music");
+ logger->log("old: %s",oldMusic.c_str());
+ }
+ std::string newMusic = newMap->getProperty("music");
+ logger->log("new: %s",newMusic.c_str());
+ if(newMusic!=oldMusic) {
+ logger->log("new: %s",newMusic.c_str());
+ newMusic = std::string(TMW_DATADIR) + "data/music/" + newMusic;
+ sound.playMusic(newMusic.c_str(), -1);
+ }
+
mCurrentMap = newMap;
minimap->setMap(mCurrentMap);
- std::string musicFile = newMap->getProperty("music");
-
- if(musicFile!="") {
- musicFile = std::string(TMW_DATADIR) + "data/music/" + musicFile;
- sound.playMusic(musicFile.c_str(), -1);
- }
}
void Engine::logic()
diff --git a/src/game.cpp b/src/game.cpp
index 45ef2ccc..e834410f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1073,10 +1073,10 @@ void do_parse()
strncat(map_path, RFIFOP(2), 497 - strlen(map_path));
logger->log("Warping to %s (%d, %d)",
map_path, RFIFOW(18), RFIFOW(20));
- sound.stopMusic();
strcpy(strrchr(map_path, '.') + 1, "tmx.gz");
-
- if (tiledMap) delete tiledMap;
+
+ Map *oldMap;
+ oldMap = tiledMap;
tiledMap = MapReader::readMap(map_path);
if (tiledMap)
@@ -1110,6 +1110,7 @@ void do_parse()
{
logger->error("Could not find map file");
}
+ if (oldMap) delete oldMap;
break;
// Skill ...
case 0x011a: