diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-25 10:21:24 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-25 10:21:24 +0000 |
commit | 59accfe17512a663d852205dcbe7bc7547400bb3 (patch) | |
tree | d00baff7f1413090f07c086977e09d4d08f41c30 /src | |
parent | 1c4742e530271e10ae949cf7e85402bee867e298 (diff) | |
download | mana-59accfe17512a663d852205dcbe7bc7547400bb3.tar.gz mana-59accfe17512a663d852205dcbe7bc7547400bb3.tar.bz2 mana-59accfe17512a663d852205dcbe7bc7547400bb3.tar.xz mana-59accfe17512a663d852205dcbe7bc7547400bb3.zip |
Added a logic method to the being manager.
Diffstat (limited to 'src')
-rw-r--r-- | src/beingmanager.cpp | 20 | ||||
-rw-r--r-- | src/beingmanager.h | 5 | ||||
-rw-r--r-- | src/engine.cpp | 23 | ||||
-rw-r--r-- | src/main.h | 3 | ||||
-rw-r--r-- | src/sound.h | 2 |
5 files changed, 29 insertions, 24 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 311cfa91..c7edc82b 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -121,6 +121,26 @@ Beings* BeingManager::getAll() return &mBeings; } +void BeingManager::logic() +{ + BeingIterator i = mBeings.begin(); + while (i != mBeings.end()) + { + Being *being = (*i); + + being->logic(); + + if (being->action == Being::MONSTER_DEAD && being->mFrame >= 20) + { + delete being; + i = mBeings.erase(i); + } + else { + i++; + } + } +} + void BeingManager::clear() { if (player_node) diff --git a/src/beingmanager.h b/src/beingmanager.h index 2347021c..00670e85 100644 --- a/src/beingmanager.h +++ b/src/beingmanager.h @@ -74,6 +74,11 @@ class BeingManager Beings* getAll(); /** + * Logic. + */ + void logic(); + + /** * Destroys all beings except the local player */ void clear(); diff --git a/src/engine.cpp b/src/engine.cpp index 76ed7ac9..5da8621e 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -33,7 +33,6 @@ #include "graphics.h" #include "localplayer.h" #include "log.h" -#include "main.h" #include "map.h" #include "sound.h" @@ -94,7 +93,7 @@ Engine::~Engine() std::map<int, Spriteset*>::iterator i; for (i = monsterset.begin(); i != monsterset.end(); i++) { - delete (*i).second; + delete i->second; } monsterset.clear(); @@ -165,25 +164,7 @@ void Engine::changeMap(std::string mapPath) void Engine::logic() { - Beings *beings = beingManager->getAll(); - // Update beings - BeingIterator beingIterator = beings->begin(); - while (beingIterator != beings->end()) - { - Being *being = (*beingIterator); - - being->logic(); - - if (being->action == Being::MONSTER_DEAD && being->mFrame >= 20) - { - delete being; - beingIterator = beings->erase(beingIterator); - } - else { - beingIterator++; - } - } - + beingManager->logic(); gui->logic(); } @@ -26,8 +26,6 @@ #include <string> -class Sound; - #if (defined __USE_UNIX98 || defined __FreeBSD__) #include "../config.h" #elif defined WIN32 @@ -70,6 +68,5 @@ enum { extern char n_server, n_character; extern unsigned char state; extern std::string errorMessage; -extern Sound sound; #endif diff --git a/src/sound.h b/src/sound.h index 36185f01..4379754f 100644 --- a/src/sound.h +++ b/src/sound.h @@ -116,4 +116,6 @@ class Sound { Mix_Music *music; }; +extern Sound sound; + #endif |