summaryrefslogtreecommitdiff
path: root/src/npc.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-02-25 19:04:39 -0700
committerIra Rice <irarice@gmail.com>2009-02-25 19:04:39 -0700
commit0dde31c3db09113639fa443142995b6efcff6646 (patch)
tree9e91488f812067dae7a91f84393a930ffe31b626 /src/npc.cpp
parent6cd131052c78af04e794409189a0d7e16dcc0c51 (diff)
downloadmana-0dde31c3db09113639fa443142995b6efcff6646.tar.gz
mana-0dde31c3db09113639fa443142995b6efcff6646.tar.bz2
mana-0dde31c3db09113639fa443142995b6efcff6646.tar.xz
mana-0dde31c3db09113639fa443142995b6efcff6646.zip
Fix NPC handling to not need a handle on the NPC
Loosely based on TMW commit f04a8713ffc83db8b3dc4a472b28aad25a2b2bd1 Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/npc.cpp')
-rw-r--r--src/npc.cpp65
1 files changed, 2 insertions, 63 deletions
diff --git a/src/npc.cpp b/src/npc.cpp
index 832e6926..92ef4d82 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -21,6 +21,7 @@
*/
#include "animatedsprite.h"
+#include "beingmanager.h"
#include "npc.h"
#include "particle.h"
#include "text.h"
@@ -32,8 +33,8 @@
#include "resources/npcdb.h"
-NPC *current_npc = 0;
bool NPC::mTalking = false;
+Uint32 current_npc = 0;
static const int NAME_X_OFFSET = 15;
static const int NAME_Y_OFFSET = 30;
@@ -117,68 +118,6 @@ void NPC::talk()
outMsg.writeInt8(0);
}
-void NPC::nextDialog()
-{
- if (!mNetwork)
- return;
-
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_NPC_NEXT_REQUEST);
- outMsg.writeInt32(mId);
-}
-
-void NPC::dialogChoice(char choice)
-{
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_NPC_LIST_CHOICE);
- outMsg.writeInt32(mId);
- outMsg.writeInt8(choice);
-}
-
-void NPC::integerInput(int value)
-{
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_NPC_INT_RESPONSE);
- outMsg.writeInt32(mId);
- outMsg.writeInt32(value);
-}
-
-void NPC::stringInput(const std::string &value)
-{
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_NPC_STR_RESPONSE);
- outMsg.writeInt16(value.length() + 9);
- outMsg.writeInt32(mId);
- outMsg.writeString(value, value.length());
- outMsg.writeInt8(0);
-}
-
-/*
- * TODO Unify the buy() and sell() methods, without sacrificing readability of
- * the code calling the method. buy(bool buySell) would be bad...
- */
-void NPC::buy()
-{
- if (!mNetwork)
- return;
-
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeInt32(mId);
- outMsg.writeInt8(0);
-}
-
-void NPC::sell()
-{
- if (!mNetwork)
- return;
-
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeInt32(mId);
- outMsg.writeInt8(1);
-}
-
void NPC::updateCoords()
{
if (mName)