From 12371444ef58176bbf7bd5716a223e707a5942e7 Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Mon, 20 Jun 2005 13:51:30 +0000 Subject: Hammerbear suggestion: removing duplicated code --- src/engine.cpp | 6 ++++++ src/game.cpp | 15 --------------- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/engine.cpp b/src/engine.cpp index 76edc0b5..fac158bf 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -270,6 +270,12 @@ void Engine::setCurrentMap(Map *newMap) { 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 820f7dc6..10ec4868 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -181,13 +181,6 @@ void do_init() else { engine->setCurrentMap(tiledMap); - // Start playing background music - std::string musicFile = tiledMap->getProperty("music"); - - if(musicFile!="") { - musicFile = std::string(TMW_DATADIR) + "data/music/" + musicFile; - sound.playMusic(musicFile.c_str(), -1); - } } // Initialize timers @@ -1064,14 +1057,6 @@ void do_parse() WFIFOSET(2); while (out_size > 0) flush(); engine->setCurrentMap(tiledMap); - - std::string musicFile = tiledMap->getProperty("music"); - - if(musicFile!="") { - musicFile = std::string(TMW_DATADIR) + "data/music/" - + musicFile; - sound.playMusic(musicFile.c_str(), -1); - } } else { logger->error("Could not find map file"); -- cgit v1.2.3-70-g09d2