summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-16 15:50:00 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-16 15:50:00 +0000
commit32badd4b6f843cb74fdc3238fe92119518c8c0ab (patch)
treeade2ace7f5ef62ae9fd14c6409d9c2df43a2348b /src/engine.cpp
parent65ccfccfc1e35a2e65638aea61c46e4e51bd874e (diff)
downloadmana-32badd4b6f843cb74fdc3238fe92119518c8c0ab.tar.gz
mana-32badd4b6f843cb74fdc3238fe92119518c8c0ab.tar.bz2
mana-32badd4b6f843cb74fdc3238fe92119518c8c0ab.tar.xz
mana-32badd4b6f843cb74fdc3238fe92119518c8c0ab.zip
A bunch of cosmetic changes.
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 43d4d0e5..3be152bd 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -82,7 +82,6 @@ Engine::Engine(Network *network):
{
std::stringstream filename;
filename << "graphics/sprites/weapon" << i << ".png";
- printf("hairstyle: %s\n", filename.str().c_str());
Spriteset *tmp = ResourceManager::getInstance()->createSpriteset(
filename.str(), 64, 64);
if (!tmp) {
@@ -117,53 +116,44 @@ Engine::~Engine()
delete itemDb;
}
-void Engine::changeMap(std::string mapPath)
+void Engine::changeMap(const std::string &mapPath)
{
- // Clean up floor items
+ // Clear floor items and beings
floorItemManager->clear();
-
beingManager->clear();
- // Generate full map path
- mapPath = "maps/" + mapPath;
- mapPath = mapPath.substr(0, mapPath.rfind(".")) + ".tmx.gz";
+ std::string oldMusic;
+ // Remove old map
+ if (mCurrentMap) {
+ oldMusic = mCurrentMap->getProperty("music");
+ delete mCurrentMap;
+ }
- // Store in global var
- map_path = mapPath;
+ // Generate full map path
+ map_path = "maps/" + mapPath.substr(0, mapPath.rfind(".")) + ".tmx.gz";
// Attempt to load the new map
- Map *newMap = MapReader::readMap(mapPath);
-
- if (!newMap) {
+ if (!(mCurrentMap = MapReader::readMap(map_path))) {
logger->error("Could not find map file");
}
// Notify the minimap and beingManager about the map change
Image *mapImage = NULL;
- if (newMap->hasProperty("minimap")) {
+ if (mCurrentMap->hasProperty("minimap")) {
ResourceManager *resman = ResourceManager::getInstance();
- mapImage = resman->getImage(newMap->getProperty("minimap"));
+ mapImage = resman->getImage(mCurrentMap->getProperty("minimap"));
}
minimap->setMapImage(mapImage);
- beingManager->setMap(newMap);
+ beingManager->setMap(mCurrentMap);
- // Start playing new music file when necessary
- std::string oldMusic = "";
-
- if (mCurrentMap) {
- oldMusic = mCurrentMap->getProperty("music");
- delete mCurrentMap;
- }
-
- std::string newMusic = newMap->getProperty("music");
+ // Change the music, if necessary
+ std::string newMusic = mCurrentMap->getProperty("music");
if (newMusic != oldMusic) {
- newMusic = std::string(TMW_DATADIR) + "data/music/" + newMusic;
+ newMusic = std::string(TMW_DATADIR "data/music/") + newMusic;
sound.playMusic(newMusic.c_str(), -1);
}
- mCurrentMap = newMap;
-
// Send "map loaded"
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_MAP_LOADED);