summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-01 01:13:14 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-01 01:13:14 +0300
commit24902ba328260cb496c62e236a644ebb990e3fd4 (patch)
treefd9ee8f2759566f29076eb63689802b40fe13756
parent2c273a20b2cd3e1628840f2d87df16f0cce9ad33 (diff)
downloadmanaverse-24902ba328260cb496c62e236a644ebb990e3fd4.tar.gz
manaverse-24902ba328260cb496c62e236a644ebb990e3fd4.tar.bz2
manaverse-24902ba328260cb496c62e236a644ebb990e3fd4.tar.xz
manaverse-24902ba328260cb496c62e236a644ebb990e3fd4.zip
Store interacted npc type before buy or talk and send it to buy dialog.
-rw-r--r--src/actions/actions.cpp2
-rw-r--r--src/being/being.cpp2
-rw-r--r--src/gui/windows/buyselldialog.cpp9
-rw-r--r--src/net/eathena/npchandler.cpp16
-rw-r--r--src/net/eathena/npchandler.h4
-rw-r--r--src/net/npchandler.h5
-rw-r--r--src/net/tmwa/npchandler.cpp12
-rw-r--r--src/net/tmwa/npchandler.h4
8 files changed, 37 insertions, 17 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 5deca7e95..7f1e37104 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -727,7 +727,7 @@ impHandler(buy)
if (being->getType() == ActorType::Npc)
{
if (npcHandler)
- npcHandler->buy(being->getId());
+ npcHandler->buy(being);
return true;
}
else if (being->getType() == ActorType::Player)
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 817fcca70..9a86c26cb 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -3517,7 +3517,7 @@ void Being::talkTo() const restrict2
return;
}
- npcHandler->talk(mId);
+ npcHandler->talk(this);
}
void Being::drawPlayer(Graphics *restrict const graphics,
diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp
index 26a8506d2..6969b8fc0 100644
--- a/src/gui/windows/buyselldialog.cpp
+++ b/src/gui/windows/buyselldialog.cpp
@@ -22,6 +22,8 @@
#include "gui/windows/buyselldialog.h"
+#include "actormanager.h"
+
#include "net/buysellhandler.h"
#include "net/npchandler.h"
@@ -129,9 +131,14 @@ void BuySellDialog::action(const ActionEvent &event)
if (eventId == "Buy")
{
if (mNpcId != BeingId_negOne)
- npcHandler->buy(mNpcId);
+ {
+ const Being *const being = actorManager->findBeing(mNpcId);
+ npcHandler->buy(being);
+ }
else
+ {
buySellHandler->requestSellList(mNick);
+ }
}
else if (eventId == "Sell")
{
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index f5b06ff29..f8041940c 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -35,6 +35,8 @@
#include "net/ea/npcrecv.h"
#include "net/eathena/messageout.h"
+#include "net/eathena/npcrecv.h"
+
#include "net/eathena/protocolout.h"
#include "resources/item/shopitem.h"
@@ -52,11 +54,14 @@ NpcHandler::NpcHandler() :
npcHandler = this;
}
-void NpcHandler::talk(const BeingId npcId) const
+void NpcHandler::talk(const Being *const being) const
{
+ if (!being)
+ return;
createOutPacket(CMSG_NPC_TALK);
- outMsg.writeBeingId(npcId, "npc id");
+ outMsg.writeBeingId(being->getId(), "npc id");
outMsg.writeInt8(0, "unused");
+ EAthena::NpcRecv::mNpcTypeId = being->getSubType();
}
void NpcHandler::nextDialog(const BeingId npcId) const
@@ -108,11 +113,14 @@ void NpcHandler::stringInput(const BeingId npcId,
outMsg.writeInt8(0, "null byte");
}
-void NpcHandler::buy(const BeingId beingId) const
+void NpcHandler::buy(const Being *const being) const
{
+ if (!being)
+ return;
createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeBeingId(beingId, "npc id");
+ outMsg.writeBeingId(being->getId(), "npc id");
outMsg.writeInt8(0, "action");
+ EAthena::NpcRecv::mNpcTypeId = being->getSubType();
}
void NpcHandler::sell(const BeingId beingId) const
diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h
index 4c758a7a2..d13d0f0cc 100644
--- a/src/net/eathena/npchandler.h
+++ b/src/net/eathena/npchandler.h
@@ -35,7 +35,7 @@ class NpcHandler final : public Ea::NpcHandler
A_DELETE_COPY(NpcHandler)
- void talk(const BeingId npcId) const override final;
+ void talk(const Being *const being) const override final;
void nextDialog(const BeingId npcId) const override final;
@@ -50,7 +50,7 @@ class NpcHandler final : public Ea::NpcHandler
void stringInput(const BeingId npcId,
const std::string &value) const override final;
- void buy(const BeingId beingId) const override final;
+ void buy(const Being *const being) const override final;
void sell(const BeingId beingId) const override final;
diff --git a/src/net/npchandler.h b/src/net/npchandler.h
index 5ef65d1f6..040b191a9 100644
--- a/src/net/npchandler.h
+++ b/src/net/npchandler.h
@@ -36,6 +36,7 @@
#include "localconsts.h"
+class Being;
class NpcDialog;
class ShopItem;
@@ -58,7 +59,7 @@ class NpcHandler notfinal
virtual BeingId getNpc(Net::MessageIn &msg,
const NpcActionT action) = 0;
- virtual void talk(const BeingId npcId) const = 0;
+ virtual void talk(const Being *const being) const = 0;
virtual void nextDialog(const BeingId npcId) const = 0;
@@ -73,7 +74,7 @@ class NpcHandler notfinal
virtual void stringInput(const BeingId npcId,
const std::string &value) const = 0;
- virtual void buy(const BeingId beingId) const = 0;
+ virtual void buy(const Being *const being) const = 0;
virtual void sell(const BeingId beingId) const = 0;
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 2db9527a3..b892e152a 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -50,10 +50,12 @@ NpcHandler::NpcHandler() :
npcHandler = this;
}
-void NpcHandler::talk(const BeingId npcId) const
+void NpcHandler::talk(const Being *const being) const
{
+ if (!being)
+ return;
createOutPacket(CMSG_NPC_TALK);
- outMsg.writeBeingId(npcId, "npc id");
+ outMsg.writeBeingId(being->getId(), "npc id");
outMsg.writeInt8(0, "unused");
}
@@ -106,10 +108,12 @@ void NpcHandler::stringInput(const BeingId npcId,
outMsg.writeInt8(0, "null byte");
}
-void NpcHandler::buy(const BeingId beingId) const
+void NpcHandler::buy(const Being *const being) const
{
+ if (!being)
+ return;
createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeBeingId(beingId, "npc id");
+ outMsg.writeBeingId(being->getId(), "npc id");
outMsg.writeInt8(0, "action");
}
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index fa635b332..f54c6911d 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -35,7 +35,7 @@ class NpcHandler final : public Ea::NpcHandler
A_DELETE_COPY(NpcHandler)
- void talk(const BeingId npcId) const override final;
+ void talk(const Being *const being) const override final;
void nextDialog(const BeingId npcId) const override final;
@@ -50,7 +50,7 @@ class NpcHandler final : public Ea::NpcHandler
void stringInput(const BeingId npcId,
const std::string &value) const override final;
- void buy(const BeingId beingId) const override final;
+ void buy(const Being *const being) const override final;
void sell(const BeingId beingId) const override final;