From 57966d67923562c6d3bb10532c09175e8dddf882 Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Sat, 2 Jul 2005 12:22:17 +0000 Subject: Music doesn't restart anymore if it's the same between maps. (I hope Bjorn likes it this way :P) --- src/engine.cpp | 19 +++++++++++++------ src/game.cpp | 7 ++++--- 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: -- cgit v1.2.3-70-g09d2