GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/chatrecv.cpp Lines: 2 380 0.5 %
Date: 2018-09-20 Branches: 2 373 0.5 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2004-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2018  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#include "net/eathena/chatrecv.h"
24
25
#include "actormanager.h"
26
#include "notifymanager.h"
27
28
#include "being/localplayer.h"
29
#include "being/playerinfo.h"
30
#include "being/playerrelation.h"
31
#include "being/playerrelations.h"
32
33
#include "const/gui/chat.h"
34
35
#include "enums/resources/notifytypes.h"
36
37
#include "gui/windows/chatwindow.h"
38
39
#include "gui/widgets/tabs/chat/chattab.h"
40
41
#include "net/messagein.h"
42
43
#include "net/ea/chatrecv.h"
44
45
#include "net/eathena/mercenaryrecv.h"
46
47
#include "resources/chatobject.h"
48
#include "utils/gettext.h"
49
#include "utils/stringutils.h"
50
51
#include "debug.h"
52
53
namespace EAthena
54
{
55
56
namespace ChatRecv
57
{
58
1
    std::string mChatRoom;
59
}  // namespace ChatRecv
60
61
void ChatRecv::processIgnoreNickAck(Net::MessageIn &msg)
62
{
63
    const int type = msg.readUInt8("type");
64
    const int flag = msg.readUInt8("flag");
65
    switch (type)
66
    {
67
        case 0:
68
            switch (flag)
69
            {
70
                case 0:
71
                    NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_SUCCESS);
72
                    break;
73
                case 1:
74
                    NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_FAILURE);
75
                    break;
76
                case 2:
77
                    NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_TOO_MANY);
78
                    break;
79
                default:
80
                    NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_UNKNOWN);
81
                    break;
82
            }
83
            break;
84
        case 1:
85
            switch (flag)
86
            {
87
                case 0:
88
                    NotifyManager::notify(
89
                        NotifyTypes::UNIGNORE_PLAYER_SUCCESS);
90
                    break;
91
                case 1:
92
                    NotifyManager::notify(
93
                        NotifyTypes::UNIGNORE_PLAYER_FAILURE);
94
                    break;
95
                default:
96
                    NotifyManager::notify(
97
                        NotifyTypes::UNIGNORE_PLAYER_UNKNOWN);
98
                    break;
99
            }
100
            break;
101
102
        default:
103
            NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_TYPE_UNKNOWN);
104
            break;
105
    }
106
}
107
108
void ChatRecv::processChat(Net::MessageIn &msg)
109
{
110
    BLOCK_START("ChatRecv::processChat")
111
    const int chatMsgLength = msg.readInt16("len") - 4;
112
    if (chatMsgLength <= 0)
113
    {
114
        BLOCK_END("ChatRecv::processChat")
115
        return;
116
    }
117
118
    processChatContinue(msg.readRawString(chatMsgLength, "message"),
119
        ChatMsgType::BY_PLAYER);
120
}
121
122
void ChatRecv::processFormatMessage(Net::MessageIn &msg)
123
{
124
    const int msgId = msg.readInt16("msg id");
125
    // +++ here need load message from configuration file
126
    std::string chatMsg;
127
    if (msgId >= 1266 && msgId <= 1269)
128
    {
129
        MercenaryRecv::handleMercenaryMessage(msgId - 1266);
130
        return;
131
    }
132
    switch (msgId)
133
    {
134
        case 1334:
135
            // TRANSLATORS: error message
136
            chatMsg = _("Can't cast skill in this area.");
137
            break;
138
        case 1335:
139
            // TRANSLATORS: error message
140
            chatMsg = _("Can't use item in this area.");
141
            break;
142
        case 1773:
143
            // TRANSLATORS: error message
144
            chatMsg = _("Can't equip. Wrong level.");
145
            break;
146
        case 1774:
147
            // TRANSLATORS: error message
148
            chatMsg = _("Can't use. Wrong level.");
149
            break;
150
        case 1923:
151
            // TRANSLATORS: error message
152
            chatMsg = _("Work in progress.");  // busy with npc
153
            break;
154
        default:
155
            chatMsg = strprintf("Message #%d", msgId);
156
            break;
157
    }
158
    processChatContinue(chatMsg, ChatMsgType::BY_SERVER);
159
}
160
161
void ChatRecv::processFormatMessageNumber(Net::MessageIn &msg)
162
{
163
    const int msgId = msg.readInt16("msg id");
164
    const int value = msg.readInt32("value");
165
    if (msgId == 1862)
166
    {
167
        NotifyManager::notify(NotifyTypes::USE_ITEM_WAIT, value);
168
        return;
169
    }
170
    // +++ here need load message from configuration file
171
    const std::string chatMsg = strprintf(
172
        "Message #%d, value: %d", msgId, value);
173
    processChatContinue(chatMsg, ChatMsgType::BY_SERVER);
174
}
175
176
void ChatRecv::processFormatColor(Net::MessageIn &msg)
177
{
178
    const int msgId = msg.readInt16("msg id");
179
    msg.readInt32("color");
180
    // +++ here need load message from configuration file
181
    const std::string chatMsg = strprintf(
182
        "Message #%d", msgId);
183
    processChatContinue(chatMsg, ChatMsgType::BY_SERVER);
184
}
185
186
void ChatRecv::processFormatMessageString(Net::MessageIn &msg)
187
{
188
    const int strLen = msg.readInt16("len") - 6;
189
    const int msgId = msg.readInt16("msg id");
190
    const std::string message = msg.readString(strLen, "value");
191
    // +++ here need load message from configuration file
192
    const std::string chatMsg = strprintf(
193
        "Message #%d, value: %s", msgId, message.c_str());
194
    processChatContinue(chatMsg, ChatMsgType::BY_SERVER);
195
}
196
197
void ChatRecv::processFormatMessageSkill(Net::MessageIn &msg)
198
{
199
    const int skillId = msg.readInt16("skill id");
200
    const int msgId = msg.readInt32("msg id");
201
    // +++ here need load message from configuration file
202
    const std::string chatMsg = strprintf(
203
        "Message #%d, skill: %d", msgId, skillId);
204
    processChatContinue(chatMsg, ChatMsgType::BY_SERVER);
205
}
206
207
void ChatRecv::processColorChat(Net::MessageIn &msg)
208
{
209
    BLOCK_START("ChatRecv::processChat")
210
    int chatMsgLength = msg.readInt16("len") - 4;
211
    msg.readInt32("unused");
212
    msg.readInt32("chat color");
213
    chatMsgLength -= 8;
214
    if (chatMsgLength <= 0)
215
    {
216
        BLOCK_END("ChatRecv::processChat")
217
        return;
218
    }
219
220
    std::string message = msg.readRawString(chatMsgLength, "message");
221
    std::string msg2 = message;
222
    if (findCutFirst(msg2, "You're now in the '#") && findCutLast(msg2, "'"))
223
    {
224
        const size_t idx = msg2.find("' channel for '");
225
        if (idx != std::string::npos && (chatWindow != nullptr))
226
        {
227
            chatWindow->addChannelTab(std::string("#").append(
228
                msg2.substr(0, idx)), false);
229
            return;
230
        }
231
    }
232
    else
233
    {
234
        const std::string nick = Ea::ChatRecv::getLastWhisperNick();
235
        if (nick.size() > 1 && nick[0] == '#')
236
        {
237
            if (message == strprintf("[ %s ] %s : \302\202\302",
238
                nick.c_str(), localPlayer->getName().c_str()))
239
            {
240
                Ea::ChatRecv::mSentWhispers.pop();
241
            }
242
        }
243
    }
244
    processChatContinue(message, ChatMsgType::BY_UNKNOWN);
245
}
246
247
std::string ChatRecv::extractChannelFromMessage(std::string &chatMsg)
248
{
249
    std::string msg = chatMsg;
250
    std::string channel(GENERAL_CHANNEL);
251
    if (findCutFirst(msg, "[ #"))
252
    {   // found channel message
253
        const size_t idx = msg.find(" ] ");
254
        if (idx != std::string::npos)
255
        {
256
            channel = std::string("#").append(msg.substr(0, idx));
257
            chatMsg = msg.substr(idx + 3);
258
        }
259
    }
260
    return channel;
261
}
262
263
void ChatRecv::processChatContinue(std::string chatMsg,
264
                                   const ChatMsgTypeT own)
265
{
266
    const std::string channel = extractChannelFromMessage(chatMsg);
267
    bool allow(true);
268
    if (chatWindow != nullptr)
269
    {
270
        allow = chatWindow->resortChatLog(chatMsg,
271
            own,
272
            channel,
273
            IgnoreRecord_false,
274
            TryRemoveColors_true);
275
    }
276
277
    const size_t pos = chatMsg.find(" : ", 0);
278
    if (pos != std::string::npos)
279
        chatMsg.erase(0, pos + 3);
280
281
    trim(chatMsg);
282
283
    if (localPlayer != nullptr)
284
    {
285
        if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow)
286
            localPlayer->setSpeech(chatMsg);
287
    }
288
    BLOCK_END("ChatRecv::processChat")
289
}
290
291
void ChatRecv::processGmChat(Net::MessageIn &msg)
292
{
293
    BLOCK_START("ChatRecv::processChat")
294
    const int chatMsgLength = msg.readInt16("len") - 4;
295
    if (chatMsgLength <= 0)
296
    {
297
        BLOCK_END("ChatRecv::processChat")
298
        return;
299
    }
300
301
    std::string chatMsg = msg.readRawString(chatMsgLength, "message");
302
    // remove non persistend "colors" from server.
303
    if (!findCutFirst(chatMsg, "ssss"))
304
        findCutFirst(chatMsg, "eulb");
305
306
    if (chatWindow != nullptr)
307
        chatWindow->addGlobalMessage(chatMsg);
308
    BLOCK_END("ChatRecv::processChat")
309
}
310
311
void ChatRecv::processGmChat2(Net::MessageIn &msg)
312
{
313
    const int chatMsgLength = msg.readInt16("len") - 16;
314
    msg.readInt32("font color");
315
    msg.readInt16("font type");
316
    msg.readInt16("font size");
317
    msg.readInt16("font align");
318
    msg.readInt16("font y");
319
    if (chatWindow != nullptr)
320
    {
321
        const std::string chatMsg = msg.readRawString(chatMsgLength,
322
            "message");
323
        chatWindow->addGlobalMessage(chatMsg);
324
    }
325
    else
326
    {
327
        msg.readRawString(chatMsgLength, "message");
328
    }
329
}
330
331
void ChatRecv::processWhisper(Net::MessageIn &msg)
332
{
333
    BLOCK_START("ChatRecv::processWhisper")
334
    int packetLen = 28;
335
    if (msg.getVersion() >= 20091104)
336
        packetLen += 4;
337
    const int chatMsgLength = msg.readInt16("len") - packetLen;
338
    std::string nick = msg.readString(24, "nick");
339
    if (msg.getVersion() >= 20091104)
340
        msg.readInt32("admin flag");
341
342
    if (chatMsgLength <= 0)
343
    {
344
        BLOCK_END("ChatRecv::processWhisper")
345
        return;
346
    }
347
348
    processWhisperContinue(nick, msg.readString(chatMsgLength, "message"));
349
}
350
351
void ChatRecv::processWhisperResponse(Net::MessageIn &msg)
352
{
353
    BLOCK_START("ChatRecv::processWhisperResponse")
354
355
    const uint8_t type = msg.readUInt8("response");
356
    if (msg.getVersion() >= 20131223)
357
        msg.readInt32("unknown");
358
    if (type == 1 && (chatWindow != nullptr))
359
    {
360
        const std::string nick = Ea::ChatRecv::getLastWhisperNick();
361
        if (nick.size() > 1 && nick[0] == '#')
362
        {
363
            chatWindow->channelChatLog(nick,
364
                // TRANSLATORS: chat message
365
                strprintf(_("Message could not be sent, channel "
366
                "%s is not exists."), nick.c_str()),
367
                ChatMsgType::BY_SERVER,
368
                IgnoreRecord_false,
369
                TryRemoveColors_false);
370
            if (!Ea::ChatRecv::mSentWhispers.empty())
371
                Ea::ChatRecv::mSentWhispers.pop();
372
            return;
373
        }
374
    }
375
    Ea::ChatRecv::processWhisperResponseContinue(msg, type);
376
}
377
378
void ChatRecv::processChatIgnoreList(Net::MessageIn &msg)
379
{
380
    UNIMPLEMENTEDPACKET;
381
    // +++ need put it in some object or window
382
    const int count = (msg.readInt16("len") - 4) / 24;
383
    for (int f = 0; f < count; f ++)
384
        msg.readString(24, "nick");
385
}
386
387
void ChatRecv::processChatDisplay(Net::MessageIn &msg)
388
{
389
    if (actorManager == nullptr)
390
        return;
391
    const int len = msg.readInt16("len") - 17;
392
    ChatObject *const obj = new ChatObject;
393
    obj->ownerId = msg.readBeingId("owner account id");
394
    obj->chatId = msg.readInt32("chat id");
395
    obj->maxUsers = msg.readInt16("max users");
396
    obj->currentUsers = msg.readInt16("current users");
397
    obj->type = msg.readUInt8("type");
398
    obj->title = msg.readString(len, "title");
399
    obj->update();
400
401
    Being *const dstBeing = actorManager->findBeing(obj->ownerId);
402
    if (dstBeing != nullptr)
403
        dstBeing->setChat(obj);
404
}
405
406
void ChatRecv::processChatRoomJoinAck(Net::MessageIn &msg)
407
{
408
    const int count = (msg.readInt16("len") - 8) / 28;
409
    const int id = msg.readInt32("chat id");
410
411
    // +++ ignore chat members for now
412
    for (int f = 0; f < count; f ++)
413
    {
414
        msg.readInt32("role");
415
        msg.readString(24, "name");
416
    }
417
418
    const ChatObject *const oldChat = ChatObject::findById(id);
419
420
    if (oldChat != nullptr)
421
        PlayerInfo::setRoomName(oldChat->title);
422
    else
423
        PlayerInfo::setRoomName(std::string());
424
    chatWindow->joinRoom(true);
425
    ChatObject *const obj = new ChatObject;
426
    if (oldChat != nullptr)
427
    {
428
        obj->ownerId = oldChat->ownerId;
429
        obj->chatId = oldChat->chatId;
430
        obj->maxUsers = oldChat->maxUsers;
431
        obj->currentUsers = oldChat->currentUsers;
432
        obj->type = oldChat->type;
433
        obj->title = oldChat->title;
434
//        obj->update();
435
    }
436
    localPlayer->setChat(obj);
437
}
438
439
void ChatRecv::processChatRoomLeave(Net::MessageIn &msg)
440
{
441
    if (actorManager == nullptr)
442
        return;
443
    msg.readInt16("users");
444
    const std::string name = msg.readString(24, "name");
445
    const int status = msg.readUInt8("flag");  // 0 - left, 1 - kicked
446
    switch (status)
447
    {
448
        case 0:
449
            NotifyManager::notify(NotifyTypes::ROOM_LEAVE, name);
450
            break;
451
        case 1:
452
            NotifyManager::notify(NotifyTypes::ROOM_KICKED, name);
453
            break;
454
        default:
455
            UNIMPLEMENTEDPACKETFIELD(status);
456
            break;
457
    }
458
    if ((localPlayer != nullptr) && name == localPlayer->getName())
459
    {
460
        if (chatWindow != nullptr)
461
            chatWindow->joinRoom(false);
462
        PlayerInfo::setRoomName(std::string());
463
        if (localPlayer != nullptr)
464
            localPlayer->setChat(nullptr);
465
    }
466
    else
467
    {
468
        Being *const being = actorManager->findBeingByName(
469
            name, ActorType::Player);
470
        if (being != nullptr)
471
            being->setChat(nullptr);
472
    }
473
}
474
475
void ChatRecv::processJoinChannel(Net::MessageIn &msg)
476
{
477
    if (chatWindow == nullptr)
478
        return;
479
480
    const std::string channel = msg.readString(24, "channel name");
481
    const int flag = msg.readUInt8("flag");
482
483
    if (channel.size() < 2)
484
        return;
485
    switch (flag)
486
    {
487
        case 0:
488
        default:
489
            chatWindow->channelChatLog(channel,
490
                // TRANSLATORS: chat message
491
                strprintf(_("Can't open channel. Channel "
492
                "%s is not exists."), channel.c_str()),
493
                ChatMsgType::BY_SERVER,
494
                IgnoreRecord_false,
495
                TryRemoveColors_false);
496
            break;
497
498
        case 1:
499
        case 2:
500
            chatWindow->addChannelTab(std::string("#").append(
501
                channel.substr(1)), false);
502
            break;
503
    }
504
}
505
506
void ChatRecv::processWhisperContinue(const std::string &nick,
507
                                      std::string chatMsg)
508
{
509
    // ignoring future whisper messages
510
    if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0)
511
    {
512
        BLOCK_END("ChatRecv::processWhisper")
513
        return;
514
    }
515
    // remove first unicode space if this is may be whisper command.
516
    if (chatMsg.find("\302\202!") == 0)
517
        chatMsg = chatMsg.substr(2);
518
519
    if (nick != "Server")
520
    {
521
        if (playerRelations.hasPermission(nick, PlayerRelation::WHISPER))
522
        {
523
            chatWindow->addWhisper(nick,
524
                chatMsg,
525
                ChatMsgType::BY_OTHER);
526
        }
527
    }
528
    else if (localChatTab != nullptr)
529
    {
530
        localChatTab->chatLog(chatMsg,
531
            ChatMsgType::BY_SERVER,
532
            IgnoreRecord_false,
533
            TryRemoveColors_true);
534
    }
535
    BLOCK_END("ChatRecv::processWhisper")
536
}
537
538
void ChatRecv::processBeingChat(Net::MessageIn &msg)
539
{
540
    if (actorManager == nullptr)
541
        return;
542
543
    BLOCK_START("ChatRecv::processBeingChat")
544
    const int chatMsgLength = msg.readInt16("len") - 8;
545
    Being *const being = actorManager->findBeing(msg.readBeingId("being id"));
546
547
    if (chatMsgLength <= 0)
548
    {
549
        BLOCK_END("ChatRecv::processBeingChat")
550
        return;
551
    }
552
553
    std::string chatMsg = msg.readRawString(chatMsgLength, "message");
554
555
    if ((being != nullptr) && being->getType() == ActorType::Player)
556
        being->setTalkTime();
557
558
    const size_t pos = chatMsg.find(" : ", 0);
559
    std::string sender_name = ((pos == std::string::npos)
560
        ? "" : chatMsg.substr(0, pos));
561
562
    if ((being != nullptr) && sender_name != being->getName()
563
        && being->getType() == ActorType::Player)
564
    {
565
        if (!being->getName().empty())
566
            sender_name = being->getName();
567
    }
568
    else
569
    {
570
        chatMsg.erase(0, pos + 3);
571
    }
572
573
    trim(chatMsg);
574
575
    bool allow(true);
576
    // We use getIgnorePlayer instead of ignoringPlayer here
577
    // because ignorePlayer' side effects are triggered
578
    // right below for Being::IGNORE_SPEECH_FLOAT.
579
    if ((playerRelations.checkPermissionSilently(sender_name,
580
        PlayerRelation::SPEECH_LOG) != 0u) && (chatWindow != nullptr))
581
    {
582
        allow = chatWindow->resortChatLog(
583
            removeColors(sender_name).append(" : ").append(chatMsg),
584
            ChatMsgType::BY_OTHER,
585
            GENERAL_CHANNEL,
586
            IgnoreRecord_false,
587
            TryRemoveColors_true);
588
    }
589
590
    if (allow &&
591
        being != nullptr &&
592
        playerRelations.hasPermission(sender_name,
593
        PlayerRelation::SPEECH_FLOAT))
594
    {
595
        being->setSpeech(chatMsg);
596
    }
597
    BLOCK_END("ChatRecv::processBeingChat")
598
}
599
600
void ChatRecv::processChatRoomCreateAck(Net::MessageIn &msg)
601
{
602
    const int result = msg.readUInt8("flag");
603
    switch (result)
604
    {
605
        case 0:
606
        {
607
            PlayerInfo::setRoomName(mChatRoom);
608
            chatWindow->joinRoom(true);
609
            ChatObject *const obj = new ChatObject;
610
            obj->ownerId = localPlayer->getId();
611
            obj->chatId = 0;
612
            obj->maxUsers = 1000;
613
            obj->currentUsers = 1;
614
            obj->type = 1;
615
            obj->title = mChatRoom;
616
            obj->update();
617
            localPlayer->setChat(obj);
618
            break;
619
        }
620
        case 1:
621
            NotifyManager::notify(NotifyTypes::ROOM_LIMIT_EXCEEDED);
622
            break;
623
        case 2:
624
            NotifyManager::notify(NotifyTypes::ROOM_ALREADY_EXISTS);
625
            break;
626
        default:
627
            UNIMPLEMENTEDPACKETFIELD(result);
628
            break;
629
    }
630
    mChatRoom.clear();
631
}
632
633
void ChatRecv::processChatRoomDestroy(Net::MessageIn &msg)
634
{
635
    const int chatId = msg.readInt32("chat id");
636
    if (actorManager == nullptr)
637
        return;
638
    actorManager->removeRoom(chatId);
639
}
640
641
void ChatRecv::processChatRoomJoinFailed(Net::MessageIn &msg)
642
{
643
    const int result = msg.readUInt8("flag");
644
    switch (result)
645
    {
646
        case 0:
647
            NotifyManager::notify(NotifyTypes::ROOM_ERROR_FULL);
648
            break;
649
        case 1:
650
            NotifyManager::notify(NotifyTypes::ROOM_ERROR_WRONG_PASSWORD);
651
            break;
652
        case 2:
653
            NotifyManager::notify(NotifyTypes::ROOM_ERROR_KICKED);
654
            break;
655
        case 3:
656
            break;
657
        case 4:
658
            NotifyManager::notify(NotifyTypes::ROOM_ERROR_ZENY);
659
            break;
660
        case 5:
661
            NotifyManager::notify(NotifyTypes::ROOM_ERROR_LOW_LEVEL);
662
            break;
663
        case 6:
664
            NotifyManager::notify(NotifyTypes::ROOM_ERROR_HIGH_LEVEL);
665
            break;
666
        case 7:
667
            NotifyManager::notify(NotifyTypes::ROOM_ERROR_RACE);
668
            break;
669
        default:
670
            UNIMPLEMENTEDPACKETFIELD(result);
671
            break;
672
    }
673
}
674
675
void ChatRecv::processChatRoomAddMember(Net::MessageIn &msg)
676
{
677
    msg.readInt16("users");
678
    const std::string name = msg.readString(24, "name");
679
    if (localChatTab == nullptr)
680
        return;
681
    NotifyManager::notify(NotifyTypes::ROOM_JOINED, name);
682
}
683
684
void ChatRecv::processChatRoomSettings(Net::MessageIn &msg)
685
{
686
    const int sz = msg.readInt16("len") - 17;
687
    const BeingId ownerId = msg.readBeingId("owner id");
688
    const int chatId = msg.readInt32("chat id");
689
    const uint16_t limit = msg.readInt16("limit");
690
    msg.readInt16("users");
691
    const uint8_t type = msg.readUInt8("type");
692
    const std::string &title = msg.readString(sz, "title");
693
    ChatObject *const chat = localPlayer->getChat();
694
    if ((chat != nullptr) && chat->chatId == chatId)
695
    {
696
        chat->ownerId = ownerId;
697
        chat->maxUsers = limit;
698
        chat->type = type;
699
        if (chat->title != title)
700
        {
701
            chat->title = title;
702
            if (actorManager != nullptr)
703
                actorManager->updateRoom(chat);
704
            if (chatWindow != nullptr)
705
                chatWindow->joinRoom(true);
706
        }
707
    }
708
}
709
710
void ChatRecv::processChatRoomRoleChange(Net::MessageIn &msg)
711
{
712
    const int role = msg.readInt32("role");
713
    const std::string name = msg.readString(24, "name");
714
    switch (role)
715
    {
716
        case 0:
717
            NotifyManager::notify(NotifyTypes::ROOM_ROLE_OWNER, name);
718
            break;
719
        case 1:
720
            // dont show normal role
721
            break;
722
        default:
723
            UNIMPLEMENTEDPACKETFIELD(role);
724
            break;
725
    }
726
}
727
728
void ChatRecv::processMVPItem(Net::MessageIn &msg)
729
{
730
    UNIMPLEMENTEDPACKET;
731
    msg.readItemId("item id");
732
}
733
734
void ChatRecv::processMVPExp(Net::MessageIn &msg)
735
{
736
    UNIMPLEMENTEDPACKET;
737
    msg.readInt32("exp");
738
}
739
740
void ChatRecv::processMVPNoItem(Net::MessageIn &msg)
741
{
742
    UNIMPLEMENTEDPACKET;
743
}
744
745
void ChatRecv::processMannerMessage(Net::MessageIn &msg)
746
{
747
    const int result = msg.readInt32("type");
748
    switch (result)
749
    {
750
        case 0:
751
            NotifyManager::notify(NotifyTypes::MANNER_CHANGED);
752
            break;
753
        case 5:
754
            break;
755
        default:
756
            UNIMPLEMENTEDPACKETFIELD(result);
757
            break;
758
    }
759
}
760
761
void ChatRecv::processChatSilence(Net::MessageIn &msg)
762
{
763
    const int result = msg.readUInt8("type");
764
    const std::string name = msg.readString(24, "gm name");
765
766
    switch (result)
767
    {
768
        case 0:
769
            NotifyManager::notify(NotifyTypes::MANNER_POSITIVE_POINTS, name);
770
            break;
771
        case 1:
772
            NotifyManager::notify(NotifyTypes::MANNER_NEGATIVE_POINTS, name);
773
            break;
774
        default:
775
            UNIMPLEMENTEDPACKETFIELD(result);
776
            break;
777
    }
778
}
779
780
void ChatRecv::processChatTalkieBox(Net::MessageIn &msg)
781
{
782
    msg.readBeingId("being id");
783
    const std::string message = msg.readString(80, "message");
784
    localChatTab->chatLog(message,
785
        ChatMsgType::BY_SERVER,
786
        IgnoreRecord_false,
787
        TryRemoveColors_true);
788
}
789
790
void ChatRecv::processBattleChatMessage(Net::MessageIn &msg)
791
{
792
    UNIMPLEMENTEDPACKET;
793
    const int sz = msg.readInt16("len") - 24 - 8;
794
    msg.readBeingId("account id");
795
    msg.readString(24, "nick");
796
    msg.readString(sz, "message");
797
}
798
799
void ChatRecv::processScriptMessage(Net::MessageIn &msg)
800
{
801
    const int sz = msg.readInt16("len") - 8;
802
    msg.readBeingId("being id");
803
    const std::string message = msg.readString(sz, "message");
804
    localChatTab->chatLog(message,
805
        ChatMsgType::BY_SERVER,
806
        IgnoreRecord_false,
807
        TryRemoveColors_true);
808
}
809
810

3
}  // namespace EAthena