summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-11-06 16:02:12 +0000
committerDavid Athay <ko2fan@gmail.com>2008-11-06 16:02:12 +0000
commit2e7a4d66bd9ce5077b7a0062aff856d669e05b97 (patch)
treefbe2623101ca6fa849d9a7f739f73b40f34d1abb /src/net
parent222db257d7de12f1077eb43d448d6b357d4642e7 (diff)
downloadmana-2e7a4d66bd9ce5077b7a0062aff856d669e05b97.tar.gz
mana-2e7a4d66bd9ce5077b7a0062aff856d669e05b97.tar.bz2
mana-2e7a4d66bd9ce5077b7a0062aff856d669e05b97.tar.xz
mana-2e7a4d66bd9ce5077b7a0062aff856d669e05b97.zip
Added interface for sending post.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/gameserver/player.cpp8
-rw-r--r--src/net/gameserver/player.h1
-rw-r--r--src/net/npchandler.cpp10
-rw-r--r--src/net/posthandler.cpp80
-rw-r--r--src/net/posthandler.h37
-rw-r--r--src/net/protocol.h9
6 files changed, 14 insertions, 131 deletions
diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp
index 79ada480..cd85447c 100644
--- a/src/net/gameserver/player.cpp
+++ b/src/net/gameserver/player.cpp
@@ -170,18 +170,12 @@ void Net::GameServer::Player::tradeWithNPC(int item, int amount)
void Net::GameServer::Player::sendLetter(const std::string &player,
const std::string &text)
{
- MessageOut msg(PGMSG_SEND_POST);
+ MessageOut msg(PGMSG_NPC_POST_SEND);
msg.writeString(player);
msg.writeString(text);
Net::GameServer::connection->send(msg);
}
-void Net::GameServer::Player::getLetters()
-{
- MessageOut msg(PGMSG_GET_POST);
- Net::GameServer::connection->send(msg);
-}
-
void Net::GameServer::Player::raiseAttribute(int attribute)
{
MessageOut msg(PGMSG_RAISE_ATTRIBUTE);
diff --git a/src/net/gameserver/player.h b/src/net/gameserver/player.h
index 3eba8a13..75e28270 100644
--- a/src/net/gameserver/player.h
+++ b/src/net/gameserver/player.h
@@ -61,7 +61,6 @@ namespace Net
void tradeMoney(int amount);
void tradeWithNPC(int item, int amount);
void sendLetter(const std::string &player, const std::string &text);
- void getLetters();
void raiseAttribute(int attribute);
void lowerAttribute(int attribute);
void respawn();
diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp
index 58c2c9ed..4b08ed8d 100644
--- a/src/net/npchandler.cpp
+++ b/src/net/npchandler.cpp
@@ -30,15 +30,18 @@
#include "../npc.h"
#include "../gui/npclistdialog.h"
+#include "../gui/npcpostdialog.h"
#include "../gui/npc_text.h"
extern NpcListDialog *npcListDialog;
extern NpcTextDialog *npcTextDialog;
+extern NpcPostDialog *npcPostDialog;
NPCHandler::NPCHandler()
{
static const Uint16 _messages[] = {
GPMSG_NPC_CHOICE,
+ GPMSG_NPC_POST,
GPMSG_NPC_MESSAGE,
GPMSG_NPC_ERROR,
0
@@ -67,12 +70,19 @@ void NPCHandler::handleMessage(MessageIn &msg)
npcListDialog->setVisible(true);
break;
+ case GPMSG_NPC_POST:
+ npcTextDialog->setVisible(false);
+ npcPostDialog->clear();
+ npcPostDialog->setVisible(true);
+ break;
+
case GPMSG_NPC_ERROR:
current_npc = NULL;
case GPMSG_NPC_MESSAGE:
npcTextDialog->addText(msg.readString(msg.getUnreadLength()));
npcListDialog->setVisible(false);
npcTextDialog->setVisible(true);
+ npcPostDialog->setVisible(false);
break;
}
}
diff --git a/src/net/posthandler.cpp b/src/net/posthandler.cpp
deleted file mode 100644
index 673d8611..00000000
--- a/src/net/posthandler.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The Mana World
- * Copyright 2009 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include "posthandler.h"
-
-#include <string>
-#include <sstream>
-
-#include "messagein.h"
-#include "protocol.h"
-
-#include "../gui/chat.h"
-
-PostHandler::PostHandler()
-{
- static const Uint16 _messages[] = {
- GPMSG_SEND_POST_RESPONSE,
- GPMSG_GET_POST_RESPONSE,
- 0
- };
- handledMessages = _messages;
-}
-
-void PostHandler::handleMessage(MessageIn &msg)
-{
- switch (msg.getId())
- {
- case GPMSG_SEND_POST_RESPONSE:
- {
- if (msg.readInt8() == ERRMSG_OK)
- {
- chatWindow->chatLog("Post sent successfully");
- }
- else
- {
- chatWindow->chatLog("Unable to send post");
- }
- } break;
-
- case GPMSG_GET_POST_RESPONSE:
- {
- std::stringstream str;
- // get the name of the sender
- std::string sender = msg.readString();
-
- if (sender == "")
- {
- chatWindow->chatLog("No post found");
- break;
- }
-
- // get the message
- std::string letter = msg.readString();
-
- // put message together
- str << "Message from " << sender << " says: " << letter;
- chatWindow->chatLog(str.str());
- } break;
- }
-}
diff --git a/src/net/posthandler.h b/src/net/posthandler.h
deleted file mode 100644
index d46b8bce..00000000
--- a/src/net/posthandler.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * The Mana World
- * Copyright 2009 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#ifndef _TMW_NET_POSTHANDLER_H
-#define _TMW_NET_POSTHANDLER_H
-
-#include "messagehandler.h"
-
-class PostHandler : public MessageHandler
-{
-public:
- PostHandler();
-
- void handleMessage(MessageIn &msg);
-};
-
-#endif
diff --git a/src/net/protocol.h b/src/net/protocol.h
index bbc7d2d2..c0bffb50 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -117,6 +117,9 @@ enum {
GPMSG_NPC_SELL = 0x02B6, // W being id, { W item id, W amount, W cost }*
PGMSG_NPC_BUYSELL = 0x02B7, // W item id, W amount
GPMSG_NPC_ERROR = 0x02B8, // B error
+ GPMSG_NPC_POST = 0x02D0, // W being id
+ PGMSG_NPC_POST_SEND = 0x02D1, // S name, S text, W item id
+ GPMSG_NPC_POST_GET = 0x02D2, // W being id, { S name, S text, W item id }
PGMSG_TRADE_REQUEST = 0x02C0, // W being id
GPMSG_TRADE_REQUEST = 0x02C1, // W being id
GPMSG_TRADE_START = 0x02C2, // -
@@ -184,12 +187,6 @@ enum {
PCMSG_USER_MODE = 0x0465, // W channel id, S name, B mode
PCMSG_KICK_USER = 0x0466, // W channel id, S name
- // Post
- PGMSG_SEND_POST = 0x04A0, // S player, S letter, { W attachment id }
- GPMSG_SEND_POST_RESPONSE = 0x04A1, // B error
- PGMSG_GET_POST = 0x04A2, //
- GPMSG_GET_POST_RESPONSE = 0x04A3, // { S sender name, S letter, { W attachment id } }
-
XXMSG_INVALID = 0x7FFF
};