summaryrefslogtreecommitdiff
path: root/src/beingmanager.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-18 11:06:01 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-18 11:06:01 +0000
commit546ae9ed020aefae6ee7470a92dff4901eceb53f (patch)
treee8af17d68d42c2af6a9055ff3d0dc932ff8f6ba0 /src/beingmanager.cpp
parent1e949983c13cab920a4cc445b2ed6429dd9aad5a (diff)
downloadmana-546ae9ed020aefae6ee7470a92dff4901eceb53f.tar.gz
mana-546ae9ed020aefae6ee7470a92dff4901eceb53f.tar.bz2
mana-546ae9ed020aefae6ee7470a92dff4901eceb53f.tar.xz
mana-546ae9ed020aefae6ee7470a92dff4901eceb53f.zip
Removed guess of being type from class number. Factored handler for new beings.
Diffstat (limited to 'src/beingmanager.cpp')
-rw-r--r--src/beingmanager.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index a5be17d2..56865841 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -21,6 +21,8 @@
* $Id$
*/
+#include <cassert>
+
#include "beingmanager.h"
#include "localplayer.h"
@@ -28,6 +30,7 @@
#include "npc.h"
#include "player.h"
+#include "net/protocol.h"
#include "utils/dtor.h"
class FindBeingFunctor
@@ -59,18 +62,24 @@ void BeingManager::setPlayer(LocalPlayer *player)
mBeings.push_back(player);
}
-Being* BeingManager::createBeing(Uint16 id, Uint16 job)
+Being* BeingManager::createBeing(int id, int type, int subtype)
{
Being *being;
- if (job < 10)
- being = new Player(id, job, mMap);
- else if (job >= 100 & job < 200)
- being = new NPC(id, job, mMap);
- else if (job >= 1000 && job < 1200)
- being = new Monster(id, job, mMap);
- else
- being = new Being(id, job, mMap);
+ switch (type)
+ {
+ case OBJECT_PLAYER:
+ being = new Player(id, subtype, mMap);
+ break;
+ case OBJECT_NPC:
+ being = new NPC(id, subtype, mMap);
+ break;
+ case OBJECT_MONSTER:
+ being = new Monster(id, subtype, mMap);
+ break;
+ default:
+ assert(false);
+ }
mBeings.push_back(being);
return being;