summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-09-09 14:51:14 +0300
committerAndrei Karas <akaras@inbox.ru>2015-09-09 14:51:14 +0300
commit8ac73cce3f9808c8fa48b280635104d9587c9c5a (patch)
tree8bbcce22fb3532c5ac915a3d87eecf41fc3d77bd /src
parentf39df8b1de96c6d6e78d90f2f058318aa7fd998b (diff)
downloadplus-8ac73cce3f9808c8fa48b280635104d9587c9c5a.tar.gz
plus-8ac73cce3f9808c8fa48b280635104d9587c9c5a.tar.bz2
plus-8ac73cce3f9808c8fa48b280635104d9587c9c5a.tar.xz
plus-8ac73cce3f9808c8fa48b280635104d9587c9c5a.zip
Remove virtual method call from MessageOut constructor.
Diffstat (limited to 'src')
-rw-r--r--src/net/eathena/chathandler.cpp9
-rw-r--r--src/net/eathena/messageout.cpp5
-rw-r--r--src/net/eathena/messageout.h3
-rw-r--r--src/net/messageout.h3
-rw-r--r--src/net/tmwa/chathandler.cpp8
-rw-r--r--src/net/tmwa/loginhandler.cpp2
-rw-r--r--src/net/tmwa/messageout.cpp5
-rw-r--r--src/net/tmwa/messageout.h3
8 files changed, 21 insertions, 17 deletions
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index c3f8bf039..da32981dd 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -106,13 +106,18 @@ void ChatHandler::sendRaw(const std::string &args) const
if (pos != std::string::npos)
{
str = line.substr(0, pos);
- outMsg = new MessageOut(static_cast<int16_t>(parseNumber(str)));
+
+ const int16_t id = static_cast<int16_t>(parseNumber(str));
+ outMsg = new MessageOut(id);
+ outMsg->writeInt16(id, "packet id");
line = line.substr(pos + 1);
pos = line.find(" ");
}
else
{
- outMsg = new MessageOut(static_cast<int16_t>(parseNumber(line)));
+ const int16_t id = static_cast<int16_t>(parseNumber(line));
+ outMsg = new MessageOut(id);
+ outMsg->writeInt16(id, "packet id");
delete outMsg;
return;
}
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index 8ecf8e863..0e42bec28 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -35,15 +35,12 @@
namespace EAthena
{
-MessageOut::MessageOut(const int16_t id, const char *const str) :
+MessageOut::MessageOut(const int16_t id) :
Net::MessageOut(id),
mNetwork(EAthena::Network::instance())
{
mNetwork->fixSendBuffer();
mData = mNetwork->mOutBuffer + static_cast<size_t>(mNetwork->mOutSize);
-
- // +++ can be issue. call to virtual member
- writeInt16(id, str);
}
void MessageOut::expand(const size_t bytes)
diff --git a/src/net/eathena/messageout.h b/src/net/eathena/messageout.h
index 4c0074767..8940ccc6a 100644
--- a/src/net/eathena/messageout.h
+++ b/src/net/eathena/messageout.h
@@ -43,8 +43,7 @@ class MessageOut final : public Net::MessageOut
/**
* Constructor.
*/
- explicit MessageOut(const int16_t id,
- const char *const str = "packet id");
+ explicit MessageOut(const int16_t id);
A_DELETE_COPY(MessageOut)
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 048afc70c..fb48ddd6e 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -29,7 +29,8 @@
#include "localconsts.h"
-#define createOutPacket(name) MessageOut outMsg(name, #name)
+#define createOutPacket(name) MessageOut outMsg(name); \
+ outMsg.writeInt16(name, #name)
namespace Net
{
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 165d91422..dc0ecbab2 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -107,13 +107,17 @@ void ChatHandler::sendRaw(const std::string &args) const
if (pos != std::string::npos)
{
str = line.substr(0, pos);
- outMsg = new MessageOut(static_cast<int16_t>(parseNumber(str)));
+ const int16_t id = static_cast<int16_t>(parseNumber(str));
+ outMsg = new MessageOut(id);
+ outMsg->writeInt16(id, "packet id");
line = line.substr(pos + 1);
pos = line.find(" ");
}
else
{
- outMsg = new MessageOut(static_cast<int16_t>(parseNumber(line)));
+ const int16_t id = static_cast<int16_t>(parseNumber(line));
+ outMsg = new MessageOut(id);
+ outMsg->writeInt16(id, "packet id");
delete outMsg;
return;
}
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index d45cd7a09..5a8aaf6c6 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -58,7 +58,9 @@ void LoginHandler::connect()
Network::mInstance->connect(mServer);
if (serverFeatures->haveServerVersion())
+ {
createOutPacket(CMSG_SERVER_VERSION_REQUEST);
+ }
}
bool LoginHandler::isConnected() const
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index c0cc0321d..a38080866 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -35,15 +35,12 @@
namespace TmwAthena
{
-MessageOut::MessageOut(const int16_t id, const char *const str) :
+MessageOut::MessageOut(const int16_t id) :
Net::MessageOut(id),
mNetwork(TmwAthena::Network::instance())
{
mNetwork->fixSendBuffer();
mData = mNetwork->mOutBuffer + static_cast<size_t>(mNetwork->mOutSize);
-
- // +++ can be issue. call to virtual member
- writeInt16(id, str);
}
void MessageOut::expand(const size_t bytes)
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
index c83643c38..a2dcc06f2 100644
--- a/src/net/tmwa/messageout.h
+++ b/src/net/tmwa/messageout.h
@@ -43,8 +43,7 @@ class MessageOut final : public Net::MessageOut
/**
* Constructor.
*/
- explicit MessageOut(const int16_t id,
- const char *const str = "packet id");
+ explicit MessageOut(const int16_t id);
A_DELETE_COPY(MessageOut)