From c204288633cd8f07720a1288a10f3c111de1599c Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Mon, 20 Jun 2005 13:15:07 +0000 Subject: This way BGM should be enabled --- src/game.cpp | 21 +++++++++++++++++---- src/map.h | 4 ++++ 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 9595ec74..820f7dc6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -173,7 +173,7 @@ void do_init() // Try .tmx.gz map file pathDir.insert(pathDir.size(), ".tmx.gz"); Map *tiledMap = MapReader::readMap(pathDir); - + if (!tiledMap) { logger->error("Could not find map file!"); @@ -181,11 +181,15 @@ 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); + } } - // Start playing background music - //sound.startBgm("./data/sound/Mods/somemp.xm", -1); - // Initialize timers tick_time = 0; SDL_AddTimer(10, nextTick, NULL); // Logic counter @@ -1031,6 +1035,7 @@ 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; @@ -1059,6 +1064,14 @@ 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"); diff --git a/src/map.h b/src/map.h index 02bea4a2..19489257 100644 --- a/src/map.h +++ b/src/map.h @@ -176,6 +176,10 @@ class Map * Set a map property. */ void setProperty(const std::string &name, const std::string &value); + + /** + * + */ private: int width, height; -- cgit v1.2.3-70-g09d2