diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/engine.cpp | 19 | ||||
-rw-r--r-- | 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: |