summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-28 11:22:46 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-28 11:22:46 -0600
commitdf095c66fdf7af74849454dbf8c4c2284616ecd7 (patch)
treed078ea9ecffd75ab1b526993c5e18846bf501867
parent42a095de15649f0f00ef6c681268d6623205900c (diff)
downloadmana-client-df095c66fdf7af74849454dbf8c4c2284616ecd7.tar.gz
mana-client-df095c66fdf7af74849454dbf8c4c2284616ecd7.tar.bz2
mana-client-df095c66fdf7af74849454dbf8c4c2284616ecd7.tar.xz
mana-client-df095c66fdf7af74849454dbf8c4c2284616ecd7.zip
Remove #ifdefs related to Being creation
Also move the Monster type offset handling into the eAthena netcode.
-rw-r--r--src/beingmanager.cpp33
-rw-r--r--src/beingmanager.h6
-rw-r--r--src/monster.cpp4
-rw-r--r--src/net/ea/beinghandler.cpp43
-rw-r--r--src/net/tmwserv/beinghandler.cpp5
5 files changed, 49 insertions, 42 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 9c671808..8c07aaab 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -81,46 +81,27 @@ void BeingManager::setPlayer(LocalPlayer *player)
mBeings.push_back(player);
}
-#ifdef TMWSERV_SUPPORT
-Being *BeingManager::createBeing(int id, int type, int subtype)
-#else
-Being *BeingManager::createBeing(int id, Uint16 job)
-#endif
+Being *BeingManager::createBeing(int id, Being::Type type, int subtype)
{
Being *being;
-#ifdef TMWSERV_SUPPORT
switch (type)
{
- case OBJECT_PLAYER:
+ case Being::PLAYER:
being = new Player(id, subtype, mMap);
break;
- case OBJECT_NPC:
+ case Being::NPC:
being = new NPC(id, subtype, mMap);
break;
- case OBJECT_MONSTER:
+ case Being::MONSTER:
being = new Monster(id, subtype, mMap);
break;
+ case Being::UNKNOWN:
+ being = new Being(id, subtype, mMap);
+ break;
default:
assert(false);
}
-#else
- if (job <= 25 || (job >= 4001 && job <= 4049))
- being = new Player(id, job, mMap);
- else if (job >= 46 && job <= 1000)
- being = new NPC(id, job, mMap);
- else if (job > 1000 && job <= 2000)
- being = new Monster(id, job, mMap);
- else
- being = new Being(id, job, mMap);
-
- // Player or NPC
- if (job <= 1000 || (job >= 4001 && job <= 4049))
- {
- MessageOut outMsg(0x0094);
- outMsg.writeInt32(id);//readLong(2));
- }
-#endif
mBeings.push_back(being);
return being;
diff --git a/src/beingmanager.h b/src/beingmanager.h
index 891a8ccb..727918a8 100644
--- a/src/beingmanager.h
+++ b/src/beingmanager.h
@@ -50,11 +50,7 @@ class BeingManager
/**
* Create a being and add it to the list of beings.
*/
-#ifdef TMWSERV_SUPPORT
- Being *createBeing(int id, int type, int subtype);
-#else
- Being *createBeing(int id, Uint16 job);
-#endif
+ Being *createBeing(int id, Being::Type type, int subtype);
/**
* Remove a Being.
diff --git a/src/monster.cpp b/src/monster.cpp
index c2632028..08a614ea 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -201,11 +201,7 @@ Being::TargetCursorSize Monster::getTargetCursorSize() const
const MonsterInfo &Monster::getInfo() const
{
-#ifdef TMWSERV_SUPPORT
return MonsterDB::get(mJob);
-#else
- return MonsterDB::get(mJob - 1002);
-#endif
}
void Monster::setShowName(bool show)
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 237c9f1f..0ad15d7d 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -24,6 +24,7 @@
#include "net/ea/protocol.h"
#include "net/messagein.h"
+#include "net/messageout.h"
#include "being.h"
#include "beingmanager.h"
@@ -37,7 +38,6 @@
#include "gui/npc_text.h"
#include <iostream>
-#include <SDL_types.h>
extern NpcTextDialog *npcTextDialog;
@@ -69,10 +69,34 @@ BeingHandler::BeingHandler(bool enableSync):
handledMessages = _messages;
}
+Being *createBeing(int id, short job)
+{
+ Being::Type type = Being::UNKNOWN;
+ if (job <= 25 || (job >= 4001 && job <= 4049))
+ type = Being::PLAYER;
+ else if (job >= 46 && job <= 1000)
+ type = Being::NPC;
+ else if (job > 1000 && job <= 2000)
+ {
+ type = Being::MONSTER;
+ job -= 1002;
+ }
+
+ Being *being = beingManager->createBeing(id, type, job);
+
+ if (type == Being::PLAYER || type == Being::NPC)
+ {
+ MessageOut outMsg(0x0094);
+ outMsg.writeInt32(id);//readLong(2));
+ }
+
+ return being;
+}
+
void BeingHandler::handleMessage(MessageIn &msg)
{
int id;
- Uint16 job, speed;
+ short job, speed;
Uint16 headTop, headMid, headBottom;
Uint16 shoes, gloves;
Uint16 weapon, shield;
@@ -108,9 +132,14 @@ void BeingHandler::handleMessage(MessageIn &msg)
break;
}
- dstBeing = beingManager->createBeing(id, job);
+ dstBeing = createBeing(id, job);
}
- else if (msg.getId() == 0x0078)
+ else if (dstBeing->getType() == Being::MONSTER)
+ {
+ job -= 1002;
+ }
+
+ if (msg.getId() == 0x0078)
{
dstBeing->clearPath();
dstBeing->mFrame = 0;
@@ -399,7 +428,11 @@ void BeingHandler::handleMessage(MessageIn &msg)
if (!dstBeing)
{
- dstBeing = beingManager->createBeing(id, job);
+ dstBeing = createBeing(id, job);
+ }
+ else if (dstBeing->getType() == Being::MONSTER)
+ {
+ job -= 1002;
}
dstBeing->setWalkSpeed(speed);
diff --git a/src/net/tmwserv/beinghandler.cpp b/src/net/tmwserv/beinghandler.cpp
index 1a1744cc..08847d7d 100644
--- a/src/net/tmwserv/beinghandler.cpp
+++ b/src/net/tmwserv/beinghandler.cpp
@@ -139,7 +139,7 @@ void BeingHandler::handleBeingEnterMessage(MessageIn &msg)
}
else
{
- being = beingManager->createBeing(id, type, 0);
+ being = beingManager->createBeing(id, Being::PLAYER, 0);
being->setName(name);
}
Player *p = static_cast< Player * >(being);
@@ -154,7 +154,8 @@ void BeingHandler::handleBeingEnterMessage(MessageIn &msg)
case OBJECT_NPC:
{
int subtype = msg.readInt16();
- being = beingManager->createBeing(id, type, subtype);
+ being = beingManager->createBeing(id, type == OBJECT_MONSTER ?
+ Being::MONSTER : Being::NPC, subtype);
std::string name = msg.readString();
if (name.length() > 0) being->setName(name);
} break;