From 59accfe17512a663d852205dcbe7bc7547400bb3 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sat, 25 Feb 2006 10:21:24 +0000 Subject: Added a logic method to the being manager. --- ChangeLog | 7 ++++++- src/beingmanager.cpp | 20 ++++++++++++++++++++ src/beingmanager.h | 5 +++++ src/engine.cpp | 23 ++--------------------- src/main.h | 3 --- src/sound.h | 2 ++ 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98d4dff3..b293e089 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2006-03-24 Björn Steinbrink +2006-02-25 Björn Steinbrink + + * src/beingmanager.cpp, src/beingmanager.h, src/engine.cpp, + src/main.h, src/sound.h: Added a logic method to the being manager. + +2006-02-24 Björn Steinbrink * src/being.cpp, src/being.h, src/configuration.cpp, src/configuration.h, src/engine.cpp, src/map.cpp, src/map.h, 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 @@ -73,6 +73,11 @@ class BeingManager */ Beings* getAll(); + /** + * Logic. + */ + void logic(); + /** * Destroys all beings except the local player */ 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::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(); } diff --git a/src/main.h b/src/main.h index 5506bbb1..f8bfb4d9 100644 --- a/src/main.h +++ b/src/main.h @@ -26,8 +26,6 @@ #include -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 -- cgit v1.2.3-70-g09d2