diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-04-06 01:29:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-04-06 01:56:54 +0300 |
commit | f47097a4d585d91852fca51dd347faed92816839 (patch) | |
tree | 9bbde1334cfeff5e6772979a917cf1909b90a36d | |
parent | 3acb4aa3b1248719a3896b419600864a68c65908 (diff) | |
download | manaplus-f47097a4d585d91852fca51dd347faed92816839.tar.gz manaplus-f47097a4d585d91852fca51dd347faed92816839.tar.bz2 manaplus-f47097a4d585d91852fca51dd347faed92816839.tar.xz manaplus-f47097a4d585d91852fca51dd347faed92816839.zip |
eathena: impliment packet SMSG_CHAT_ROOM_SETTINGS.
-rw-r--r-- | src/actormanager.cpp | 23 | ||||
-rw-r--r-- | src/actormanager.h | 4 | ||||
-rw-r--r-- | src/being/being.h | 2 | ||||
-rw-r--r-- | src/net/eathena/chathandler.cpp | 24 |
4 files changed, 46 insertions, 7 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 954fe087f..cabd8fba1 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1832,3 +1832,26 @@ void ActorManager::removeRoom(const int chatId) } } } + +void ActorManager::updateRoom(const ChatObject *const newChat) +{ + if (!newChat) + return; + + for_actors + { + ActorSprite *const actor = *it; + if (actor && actor->getType() != ActorType::Player) + { + Being *const being = static_cast<Being*>(actor); + ChatObject *const chat = being->getChat(); + if (chat && chat->chatId == newChat->chatId) + { + chat->ownerId = newChat->ownerId; + chat->maxUsers = newChat->maxUsers; + chat->type = newChat->type; + chat->title = newChat->title; + } + } + } +} diff --git a/src/actormanager.h b/src/actormanager.h index 2484d3e3a..25b2f6e00 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -36,6 +36,8 @@ class Being; class LocalPlayer; class Map; +struct ChatObject; + typedef std::set<ActorSprite*> ActorSprites; typedef ActorSprites::iterator ActorSpritesIterator; typedef ActorSprites::const_iterator ActorSpritesConstIterator; @@ -319,6 +321,8 @@ class ActorManager final: public ConfigListener void removeRoom(const int chatId); + void updateRoom(const ChatObject *const newChat); + protected: bool validateBeing(const Being *const aroundBeing, Being *const being, diff --git a/src/being/being.h b/src/being/being.h index 1dc44b986..9c7ef3404 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -889,7 +889,7 @@ class Being notfinal : public ActorSprite, void setChat(ChatObject *const obj); - const ChatObject *getChat() const + ChatObject *getChat() const { return mChat; } void setKarma(const int karma) diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index e35fcbc8b..f7ef27cb5 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -974,14 +974,26 @@ void ChatHandler::processChatRoomAddMember(Net::MessageIn &msg) void ChatHandler::processChatRoomSettings(Net::MessageIn &msg) { - UNIMPLIMENTEDPACKET; const int sz = msg.readInt16("len") - 17; - msg.readInt32("owner id"); - msg.readInt32("chat id"); - msg.readInt16("limit"); + const int ownerId = msg.readInt32("owner id"); + const int chatId = msg.readInt32("chat id"); + const int limit = msg.readInt16("limit"); msg.readInt16("users"); - msg.readUInt8("type"); - msg.readString(sz, "title"); + const int type = msg.readUInt8("type"); + const std::string &title = msg.readString(sz, "title"); + ChatObject *const chat = localPlayer->getChat(); + if (chat && chat->chatId == chatId) + { + chat->ownerId = ownerId; + chat->maxUsers = limit; + chat->type = type; + if (chat->title != title) + { + chat->title = title; + actorManager->updateRoom(chat); + chatWindow->joinRoom(true); + } + } } void ChatHandler::processChatRoomRoleChange(Net::MessageIn &msg) |