summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/clanhandler.cpp73
-rw-r--r--src/net/eathena/clanhandler.h44
-rw-r--r--src/net/eathena/generalhandler.cpp3
-rw-r--r--src/net/eathena/generalhandler.h2
-rw-r--r--src/net/eathena/packetsout.inc2
5 files changed, 124 insertions, 0 deletions
diff --git a/src/net/eathena/clanhandler.cpp b/src/net/eathena/clanhandler.cpp
new file mode 100644
index 000000000..f35bc9504
--- /dev/null
+++ b/src/net/eathena/clanhandler.cpp
@@ -0,0 +1,73 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2018 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/eathena/clanhandler.h"
+
+#include "being/localplayer.h"
+
+#include "net/eathena/messageout.h"
+#include "net/eathena/protocolout.h"
+
+#include "utils/cast.h"
+
+#include "debug.h"
+
+extern int packetVersion;
+
+namespace EAthena
+{
+
+ClanHandler::ClanHandler() :
+ Net::ClanHandler()
+{
+ clanHandler = this;
+}
+
+ClanHandler::~ClanHandler()
+{
+ clanHandler = nullptr;
+}
+
+void ClanHandler::chat(const std::string &restrict text) const
+{
+ if (localPlayer == nullptr)
+ return;
+
+ if (packetVersion < 20120716)
+ return;
+
+ const std::string mes = std::string(localPlayer->getName()).append(
+ " : ").append(text);
+
+ createOutPacket(CMSG_CLAN_MESSAGE);
+ if (packetVersion >= 20151001)
+ {
+ outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length()), "message");
+ }
+ else
+ {
+ // Added + 1 in order to let eAthena parse admin commands correctly
+ outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
+ }
+}
+
+} // namespace EAthena
diff --git a/src/net/eathena/clanhandler.h b/src/net/eathena/clanhandler.h
new file mode 100644
index 000000000..f1ce56eb6
--- /dev/null
+++ b/src/net/eathena/clanhandler.h
@@ -0,0 +1,44 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2018 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_EATHENA_CLANHANDLER_H
+#define NET_EATHENA_CLANHANDLER_H
+
+#include "net/clanhandler.h"
+
+namespace EAthena
+{
+class MessageOut;
+
+class ClanHandler final : public Net::ClanHandler
+{
+ public:
+ ClanHandler();
+
+ A_DELETE_COPY(ClanHandler)
+
+ ~ClanHandler() override final;
+
+ void chat(const std::string &restrict text) const override final;
+};
+
+} // namespace EAthena
+
+#endif // NET_EATHENA_CLANHANDLER_H
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index ee690e57e..aaf762d3f 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -40,6 +40,7 @@
#include "net/eathena/buysellhandler.h"
#include "net/eathena/cashshophandler.h"
#include "net/eathena/chathandler.h"
+#include "net/eathena/clanhandler.h"
#include "net/eathena/charserverhandler.h"
#include "net/eathena/elementalhandler.h"
#include "net/eathena/familyhandler.h"
@@ -82,6 +83,7 @@ GeneralHandler::GeneralHandler() :
mBuySellHandler(new BuySellHandler),
mCharServerHandler(new CharServerHandler),
mChatHandler(new ChatHandler),
+ mClanHandler(new ClanHandler),
mGameHandler(new GameHandler),
mGuildHandler(new GuildHandler),
mInventoryHandler(new InventoryHandler),
@@ -125,6 +127,7 @@ GeneralHandler::~GeneralHandler()
delete2(mBuySellHandler);
delete2(mCharServerHandler);
delete2(mChatHandler);
+ delete2(mClanHandler);
delete2(mGameHandler);
delete2(mGuildHandler);
delete2(mInventoryHandler);
diff --git a/src/net/eathena/generalhandler.h b/src/net/eathena/generalhandler.h
index 6c6e47979..8f6dc5166 100644
--- a/src/net/eathena/generalhandler.h
+++ b/src/net/eathena/generalhandler.h
@@ -33,6 +33,7 @@ class BeingHandler;
class BuySellHandler;
class CharServerHandler;
class ChatHandler;
+class ClanHandler;
class GameHandler;
class GuildHandler;
class InventoryHandler;
@@ -97,6 +98,7 @@ class GeneralHandler final : public Net::GeneralHandler
BuySellHandler *mBuySellHandler;
CharServerHandler *mCharServerHandler;
ChatHandler *mChatHandler;
+ ClanHandler *mClanHandler;
GameHandler *mGameHandler;
GuildHandler *mGuildHandler;
InventoryHandler *mInventoryHandler;
diff --git a/src/net/eathena/packetsout.inc b/src/net/eathena/packetsout.inc
index 4fda23153..744a90955 100644
--- a/src/net/eathena/packetsout.inc
+++ b/src/net/eathena/packetsout.inc
@@ -330,6 +330,7 @@ packet(CMSG_MAIL2_REFRESH_MAIL_LIST, 0x0000, 0, nullptr);
packet(CMSG_MAIL2_OPEN_MAILBOX, 0x0000, 0, nullptr);
packet(CMSG_MAIL2_CLOSE_MAILBOX, 0x0000, 0, nullptr);
packet(CMSG_MAIL2_CANCEL_WRITE_MAIL, 0x0000, 0, nullptr);
+packet(CMSG_CLAN_MESSAGE, 0x0000, 0, nullptr);
#else
// 20040713
if (packetVersion >= 20040713)
@@ -823,6 +824,7 @@ if (packetVersion >= 20120716)
packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
packet(CMSG_STORAGE_PASSWORD, 0x0819, 36, clif->pStoragePassword);
+ packet(CMSG_CLAN_MESSAGE, 0x098d, -1, clif->pClanMessage);
}
// 20120925