summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-25 10:21:24 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-25 10:21:24 +0000
commit59accfe17512a663d852205dcbe7bc7547400bb3 (patch)
treed00baff7f1413090f07c086977e09d4d08f41c30
parent1c4742e530271e10ae949cf7e85402bee867e298 (diff)
downloadmana-59accfe17512a663d852205dcbe7bc7547400bb3.tar.gz
mana-59accfe17512a663d852205dcbe7bc7547400bb3.tar.bz2
mana-59accfe17512a663d852205dcbe7bc7547400bb3.tar.xz
mana-59accfe17512a663d852205dcbe7bc7547400bb3.zip
Added a logic method to the being manager.
-rw-r--r--ChangeLog7
-rw-r--r--src/beingmanager.cpp20
-rw-r--r--src/beingmanager.h5
-rw-r--r--src/engine.cpp23
-rw-r--r--src/main.h3
-rw-r--r--src/sound.h2
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 <B.Steinbrink@gmx.de>
+2006-02-25 Björn Steinbrink <B.Steinbrink@gmx.de>
+
+ * 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 <B.Steinbrink@gmx.de>
* 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
@@ -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();
}
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 <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