summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-04-04 15:45:30 +0300
committerAndrei Karas <akaras@inbox.ru>2015-04-04 15:45:30 +0300
commit6f06cd42b8e56aaae2be853a31d73d0115a39c2a (patch)
tree589d5d51b66018b6063bf954f90b96a3244b2e3d
parent13b4a16c46983b786d31f6cf67632a3bd4e14b8f (diff)
downloadplus-6f06cd42b8e56aaae2be853a31d73d0115a39c2a.tar.gz
plus-6f06cd42b8e56aaae2be853a31d73d0115a39c2a.tar.bz2
plus-6f06cd42b8e56aaae2be853a31d73d0115a39c2a.tar.xz
plus-6f06cd42b8e56aaae2be853a31d73d0115a39c2a.zip
Add chat command for create chat room (incomplete).
New chat command: /chatroom NAME
-rw-r--r--src/actions/commands.cpp12
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/gui/windows/chatwindow.cpp6
-rw-r--r--src/gui/windows/chatwindow.h3
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h5
-rw-r--r--src/net/eathena/chathandler.cpp23
-rw-r--r--src/net/eathena/chathandler.h3
-rw-r--r--src/resources/notifications.h8
-rw-r--r--src/resources/notifytypes.h2
10 files changed, 61 insertions, 3 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index a02a97498..76d94886c 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -869,4 +869,16 @@ impHandler(commandHomunEmote)
#endif
}
+impHandler(createPublicChatRoom)
+{
+#ifdef EATHENA_SUPPORT
+ if (event.args.empty())
+ return false;
+ chatHandler->createChatRoom(event.args, "", 100, true);
+ return true;
+#else
+ return false;
+#endif
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index 6417dd32e..f5fa4344b 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -82,6 +82,7 @@ namespace Actions
decHandler(homunTalk);
decHandler(homunEmote);
decHandler(commandHomunEmote);
+ decHandler(createPublicChatRoom);
} // namespace Actions
#undef decHandler
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 748114b10..2c1f580ad 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -1219,6 +1219,12 @@ ChatTab *ChatWindow::addSpecialChannelTab(const std::string &name,
return ret;
}
+ChatTab *ChatWindow::addChatRoomTab(const std::string &name,
+ const bool switchTo)
+{
+ return nullptr;
+}
+
ChatTab *ChatWindow::addChannelTab(const std::string &name,
const bool switchTo)
{
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index 3bbb40e5e..33d6a89bd 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -199,6 +199,9 @@ class ChatWindow final : public Window,
WhisperTab *getWhisperTab(const std::string &nick) const A_WARN_UNUSED;
+ ChatTab *addChatRoomTab(const std::string &name,
+ const bool switchTo = false);
+
ChatTab *addChannelTab(const std::string &name,
const bool switchTo = false);
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index 1fc45b6d1..438075dcf 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -591,6 +591,7 @@ namespace InputAction
HOMUN_EMOTE_48,
KICK_GUILD,
HAT,
+ CREATE_PUBLIC_ROOM,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index d20201c79..78e23d819 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -4436,6 +4436,11 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputCondition::INGAME,
"hat|hats|showhat",
false},
+ {"keyCreatePublicRoom",
+ defaultAction(&Actions::createPublicChatRoom),
+ InputCondition::INGAME,
+ "createroom|createpublicroom",
+ true},
};
#undef defaultAction
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 57d57ca6c..de66468e2 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -55,6 +55,8 @@ extern Net::ChatHandler *chatHandler;
namespace EAthena
{
+std::string ChatHandler::mChatRoom;
+
ChatHandler::ChatHandler() :
MessageHandler(),
Ea::ChatHandler()
@@ -393,11 +395,12 @@ void ChatHandler::createChatRoom(const std::string &title,
{
createOutPacket(CMSG_CREAYE_CHAT_ROOM);
outMsg.writeInt16(static_cast<int16_t>(
- password.size() + title.size() + 5), "len");
+ 7 + 8 + 36), "len");
outMsg.writeInt16(static_cast<int16_t>(limit), "limit");
outMsg.writeInt8(static_cast<int8_t>(isPublic ? 1 : 0), "public");
outMsg.writeString(password, 8, "password");
outMsg.writeString(title, 36, "title");
+ mChatRoom = title;
}
void ChatHandler::battleTalk(const std::string &text) const
@@ -845,8 +848,22 @@ void ChatHandler::talkPet(const std::string &restrict text,
void ChatHandler::processChatRoomCreateAck(Net::MessageIn &msg)
{
- UNIMPLIMENTEDPACKET;
- msg.readUInt8("flag");
+ const int result = msg.readUInt8("flag");
+ switch(result)
+ {
+ case 0:
+ chatWindow->addChatRoomTab(mChatRoom, true);
+ break;
+ case 1:
+ NotifyManager::notify(NotifyTypes::ROOM_LIMIT_EXCEEDED);
+ break;
+ case 2:
+ NotifyManager::notify(NotifyTypes::ROOM_ALREADY_EXISTS);
+ break;
+ default:
+ UNIMPLIMENTEDPACKET;
+ break;
+ }
}
void ChatHandler::processChatRoomDestroy(Net::MessageIn &msg)
diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h
index 879217b41..c0807c37a 100644
--- a/src/net/eathena/chathandler.h
+++ b/src/net/eathena/chathandler.h
@@ -166,6 +166,9 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler
static void processBattleChatMessage(Net::MessageIn &msg);
static void processScriptMessage(Net::MessageIn &msg);
+
+ private:
+ static std::string mChatRoom;
};
} // namespace EAthena
diff --git a/src/resources/notifications.h b/src/resources/notifications.h
index 019879aba..e6d577633 100644
--- a/src/resources/notifications.h
+++ b/src/resources/notifications.h
@@ -511,6 +511,14 @@ namespace NotifyManager
// TRANSLATORS: notification message
N_("You got negative manner points from %s."),
NotifyFlags::STRING},
+ {"chat room limit exceed",
+ // TRANSLATORS: notification message
+ N_("Chat room limit exceeded"),
+ NotifyFlags::EMPTY},
+ {"chat room already exists",
+ // TRANSLATORS: notification message
+ N_("Chat room already exists"),
+ NotifyFlags::EMPTY},
};
} // namespace NotifyManager
#endif // RESOURCES_NOTIFICATIONS_H
diff --git a/src/resources/notifytypes.h b/src/resources/notifytypes.h
index 27bad8673..3269192a3 100644
--- a/src/resources/notifytypes.h
+++ b/src/resources/notifytypes.h
@@ -146,6 +146,8 @@ namespace NotifyTypes
MANNER_CHANGED,
MANNER_POSITIVE_POINTS,
MANNER_NEGATIVE_POINTS,
+ ROOM_LIMIT_EXCEEDED,
+ ROOM_ALREADY_EXISTS,
TYPE_END
};