GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/guildrecv.cpp Lines: 1 425 0.2 %
Date: 2019-03-24 Branches: 0 392 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009-2010  The Mana Developers
4
 *  Copyright (C) 2011-2019  The ManaPlus Developers
5
 *
6
 *  This file is part of The ManaPlus Client.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#include "net/eathena/guildrecv.h"
23
24
#include "actormanager.h"
25
#include "configuration.h"
26
#include "notifymanager.h"
27
28
#include "being/localplayer.h"
29
#include "being/playerinfo.h"
30
31
#include "enums/resources/notifytypes.h"
32
33
#include "gui/windows/chatwindow.h"
34
#include "gui/windows/skilldialog.h"
35
#include "gui/windows/socialwindow.h"
36
37
#include "gui/widgets/tabs/chat/guildtab.h"
38
39
#include "net/beinghandler.h"
40
#include "net/messagein.h"
41
42
#include "net/eathena/guildhandler.h"
43
44
#include "utils/delete2.h"
45
#include "utils/checkutils.h"
46
#include "utils/gettext.h"
47
48
#include "debug.h"
49
50
namespace EAthena
51
{
52
53
Guild *taGuild = nullptr;
54
55
namespace GuildRecv
56
{
57
    bool showBasicInfo = false;
58
}  // namespace GuildRecv
59
60
void GuildRecv::processGuildCreateResponse(Net::MessageIn &msg)
61
{
62
    const uint8_t flag = msg.readUInt8("flag");
63
64
    switch (flag)
65
    {
66
        case 0:
67
            // Success
68
            NotifyManager::notify(NotifyTypes::GUILD_CREATED);
69
            break;
70
71
        case 1:
72
            // Already in a guild
73
            NotifyManager::notify(NotifyTypes::GUILD_ALREADY);
74
            break;
75
76
        case 2:
77
            // Unable to make (likely name already in use)
78
            NotifyManager::notify(NotifyTypes::GUILD_ALREADY);
79
            break;
80
81
        case 3:
82
            // Emperium check failed
83
            NotifyManager::notify(NotifyTypes::GUILD_EMPERIUM_CHECK_FAILED);
84
            break;
85
86
        default:
87
            // Unknown response
88
            NotifyManager::notify(NotifyTypes::GUILD_ERROR);
89
            break;
90
    }
91
}
92
93
void GuildRecv::processGuildMasterOrMember(Net::MessageIn &msg)
94
{
95
    msg.readInt32("type");  // Type (0x57 for member, 0xd7 for master)
96
}
97
98
void GuildRecv::processGuildBasicInfo(Net::MessageIn &msg)
99
{
100
    const int guildId = msg.readInt32("guild id");
101
    const int level = msg.readInt32("guild level");
102
    const int members = msg.readInt32("connect member");
103
    const int maxMembers = msg.readInt32("max member");
104
    const int avgLevel = msg.readInt32("average level");
105
    const int exp = msg.readInt32("exp");
106
    const int nextExp = msg.readInt32("next exp");
107
    msg.skip(12, "unused");
108
    const int emblem = msg.readInt32("emblem id");
109
    std::string name = msg.readString(24, "guild name");
110
    std::string castle;
111
    std::string master;
112
    if (msg.getVersion() >= 20160622)
113
    {
114
        castle = msg.readString(16, "castles");
115
        msg.readInt32("money, unused");
116
        msg.readBeingId("leader char id");
117
    }
118
    else
119
    {
120
        master = msg.readString(24, "master name");
121
        castle = msg.readString(16, "castles");
122
        msg.readInt32("money, unused");
123
    }
124
125
    if (guildTab != nullptr &&
126
        showBasicInfo)
127
    {
128
        showBasicInfo = false;
129
        // TRANSLATORS: guild info message
130
        guildTab->chatLog(strprintf(_("Guild name: %s"),
131
            name.c_str()),
132
            ChatMsgType::BY_SERVER,
133
            IgnoreRecord_false,
134
            TryRemoveColors_true);
135
        if (!master.empty())
136
        {
137
            // TRANSLATORS: guild info message
138
            guildTab->chatLog(strprintf(_("Guild master: %s"),
139
                master.c_str()),
140
                ChatMsgType::BY_SERVER,
141
                IgnoreRecord_false,
142
                TryRemoveColors_true);
143
        }
144
        // TRANSLATORS: guild info message
145
        guildTab->chatLog(strprintf(_("Guild level: %d"), level),
146
            ChatMsgType::BY_SERVER,
147
            IgnoreRecord_false,
148
            TryRemoveColors_true);
149
        // TRANSLATORS: guild info message
150
        guildTab->chatLog(strprintf(_("Online members: %d"), members),
151
            ChatMsgType::BY_SERVER,
152
            IgnoreRecord_false,
153
            TryRemoveColors_true);
154
        // TRANSLATORS: guild info message
155
        guildTab->chatLog(strprintf(_("Max members: %d"), maxMembers),
156
            ChatMsgType::BY_SERVER,
157
            IgnoreRecord_false,
158
            TryRemoveColors_true);
159
        // TRANSLATORS: guild info message
160
        guildTab->chatLog(strprintf(_("Average level: %d"), avgLevel),
161
            ChatMsgType::BY_SERVER,
162
            IgnoreRecord_false,
163
            TryRemoveColors_true);
164
        // TRANSLATORS: guild info message
165
        guildTab->chatLog(strprintf(_("Guild exp: %d"), exp),
166
            ChatMsgType::BY_SERVER,
167
            IgnoreRecord_false,
168
            TryRemoveColors_true);
169
        // TRANSLATORS: guild info message
170
        guildTab->chatLog(strprintf(_("Guild next exp: %d"), nextExp),
171
            ChatMsgType::BY_SERVER,
172
            IgnoreRecord_false,
173
            TryRemoveColors_true);
174
        // TRANSLATORS: guild info message
175
        guildTab->chatLog(strprintf(_("Guild castle: %s"), castle.c_str()),
176
            ChatMsgType::BY_SERVER,
177
            IgnoreRecord_false,
178
            TryRemoveColors_true);
179
    }
180
181
    Guild *const g = Guild::getGuild(CAST_S16(guildId));
182
    if (g == nullptr)
183
        return;
184
    g->setName(name);
185
    g->setEmblemId(emblem);
186
}
187
188
void GuildRecv::processGuildAlianceInfo(Net::MessageIn &msg)
189
{
190
    const int length = msg.readInt16("len");
191
    if (length < 4)
192
        return;
193
    const int count = (length - 4) / 32;
194
195
    for (int i = 0; i < count; i++)
196
    {
197
        msg.readInt32("opposition");
198
        msg.readInt32("guild id");
199
        msg.readString(24, "guild name");
200
    }
201
}
202
203
void GuildRecv::processGuildMemberList(Net::MessageIn &msg)
204
{
205
    if (actorManager == nullptr)
206
        return;
207
208
    const int length = msg.readInt16("len");
209
    if (length < 4)
210
        return;
211
    int guildSize = 0;
212
    if (msg.getVersion() >= 20161026)
213
    {
214
        guildSize = 34;
215
    }
216
    else
217
    {
218
        guildSize = 104;
219
    }
220
221
    const int count = (length - 4) / guildSize;
222
    if (taGuild == nullptr)
223
    {
224
        logger->log1("!taGuild");
225
        return;
226
    }
227
228
    taGuild->clearMembers();
229
230
    int onlineNum = 0;
231
    int totalNum = 0;
232
    for (int i = 0; i < count; i++)
233
    {
234
        const BeingId id = msg.readBeingId("account id");
235
        const int charId = msg.readInt32("char id");
236
        msg.readInt16("hair");
237
        msg.readInt16("hair color");
238
        const int gender = msg.readInt16("gender");
239
        const int race = msg.readInt16("class");
240
        const int level = msg.readInt16("level");
241
        const int exp = msg.readInt32("exp");
242
        const int online = msg.readInt32("online");
243
        const int pos = msg.readInt32("position");
244
        std::string name;
245
        if (msg.getVersion() < 20161026)
246
        {
247
            msg.skip(50, "unused");
248
            name = msg.readString(24, "name");
249
        }
250
        else
251
        {
252
            msg.readInt32("last login");  // for now unused
253
            name = actorManager->findCharById(charId);
254
            if (name.empty())
255
            {
256
                beingHandler->requestNameByCharId(charId);
257
            }
258
        }
259
260
        GuildMember *const m = taGuild->addMember(id, charId, name);
261
        if (m != nullptr)
262
        {
263
            m->setOnline(online != 0);
264
            m->setID(id);
265
            m->setCharId(charId);
266
            m->setGender(Being::intToGender(CAST_U8(gender)));
267
            m->setLevel(level);
268
            m->setExp(exp);
269
            m->setPos(pos);
270
            m->setRace(race);
271
            Being *const being = actorManager->findBeingByName(
272
                name, ActorType::Player);
273
            if (being != nullptr)
274
            {
275
                being->setGuildName(taGuild->getName());
276
                if (being->getLevel() != level)
277
                {
278
                    being->setLevel(level);
279
                    being->updateName();
280
                }
281
            }
282
            if (online != 0)
283
                onlineNum ++;
284
            totalNum ++;
285
        }
286
    }
287
    taGuild->sort();
288
    actorManager->updatePlayerGuild();
289
    actorManager->updatePlayerColors();
290
    if (socialWindow != nullptr)
291
        socialWindow->updateGuildCounter(onlineNum, totalNum);
292
}
293
294
void GuildRecv::processGuildPosNameList(Net::MessageIn &msg)
295
{
296
    if (taGuild == nullptr)
297
    {
298
        logger->log1("!taGuild");
299
        return;
300
    }
301
302
    const int length = msg.readInt16("len");
303
    if (length < 4)
304
        return;
305
    const int count = (length - 4) / 28;
306
307
    for (int i = 0; i < count; i++)
308
    {
309
        const int id = msg.readInt32("position id");
310
        const std::string name = msg.readString(24, "position name");
311
        taGuild->addPos(id, name);
312
    }
313
}
314
315
void GuildRecv::processGuildPosInfoList(Net::MessageIn &msg)
316
{
317
    const int length = msg.readInt16("len");
318
    if (length < 4)
319
        return;
320
    const int count = (length - 4) / 16;
321
322
    for (int i = 0; i < count; i++)
323
    {
324
        msg.readInt32("id");
325
        msg.readInt32("mode");
326
        msg.readInt32("same id");
327
        msg.readInt32("exp mode");
328
    }
329
}
330
331
void GuildRecv::processGuildPositionChanged(Net::MessageIn &msg)
332
{
333
    UNIMPLEMENTEDPACKET;
334
    msg.readInt16("len");
335
    msg.readInt32("id");
336
    msg.readInt32("mode");
337
    msg.readInt32("same ip");
338
    msg.readInt32("exp mode");
339
    msg.readString(24, "name");
340
}
341
342
void GuildRecv::processGuildMemberPosChange(Net::MessageIn &msg)
343
{
344
    msg.readInt16("len");
345
    const BeingId accountId = msg.readBeingId("account id");
346
    const int charId = msg.readInt32("char id");
347
    const int pos = msg.readInt32("position");
348
    if (taGuild != nullptr)
349
    {
350
        GuildMember *const m = taGuild->getMember(accountId, charId);
351
        if (m != nullptr)
352
            m->setPos(pos);
353
    }
354
}
355
356
void GuildRecv::processGuildEmblemData(Net::MessageIn &msg)
357
{
358
    UNIMPLEMENTEDPACKET;
359
    const int length = msg.readInt16("len");
360
361
    msg.readInt32("guild id");
362
    msg.readInt32("emblem id");
363
    if (length < 12)
364
        return;
365
    msg.skip(length - 12, "emblem data");
366
}
367
368
void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg)
369
{
370
    const int count = (msg.readInt16("len") - 6) / 37;
371
    msg.readInt16("skill points");
372
373
    if (skillDialog != nullptr)
374
        skillDialog->hideSkills(SkillOwner::Guild);
375
    for (int i = 0; i < count; i++)
376
    {
377
        const int skillId = msg.readInt16("skill id");
378
        const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
379
            msg.readInt32("inf"));
380
        const int level = msg.readInt16("skill level");
381
        const int sp = msg.readInt16("sp");
382
        const int range = msg.readInt16("range");
383
        const std::string name = msg.readString(24, "skill name");
384
        const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
385
        PlayerInfo::setSkillLevel(skillId, level);
386
        if (skillDialog != nullptr)
387
        {
388
            if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
389
            {
390
                skillDialog->addSkill(SkillOwner::Guild,
391
                    skillId, name, level, range, up, inf, sp);
392
            }
393
        }
394
    }
395
    if (skillDialog != nullptr)
396
        skillDialog->updateModels();
397
}
398
399
void GuildRecv::processGuildNotice(Net::MessageIn &msg)
400
{
401
    if (guildTab != nullptr)
402
    {
403
        const std::string msg1 = msg.readString(60, "msg1");
404
        const std::string msg2 = msg.readString(120, "msg2");
405
        guildTab->chatLog(msg1,
406
            ChatMsgType::BY_SERVER,
407
            IgnoreRecord_false,
408
            TryRemoveColors_true);
409
        guildTab->chatLog(msg2,
410
            ChatMsgType::BY_SERVER,
411
            IgnoreRecord_false,
412
            TryRemoveColors_true);
413
    }
414
    else
415
    {
416
        msg.readString(60, "msg1");
417
        msg.readString(120, "msg2");
418
    }
419
}
420
421
void GuildRecv::processGuildInvite(Net::MessageIn &msg)
422
{
423
    const int guildId = msg.readInt32("guild id");
424
425
    if (socialWindow != nullptr)
426
    {
427
        const std::string guildName = msg.readString(24, "guild name");
428
        socialWindow->showGuildInvite(guildName, guildId, "");
429
    }
430
    else
431
    {
432
        msg.readString(24, "guild name");
433
    }
434
}
435
436
void GuildRecv::processGuildInviteAck(Net::MessageIn &msg)
437
{
438
    const uint8_t flag = msg.readUInt8("flag");
439
    if (guildTab == nullptr)
440
        return;
441
442
    switch (flag)
443
    {
444
        case 0:
445
            NotifyManager::notify(NotifyTypes::GUILD_INVITE_FAILED);
446
            break;
447
448
        case 1:
449
            NotifyManager::notify(NotifyTypes::GUILD_INVITE_REJECTED);
450
            break;
451
452
        case 2:
453
            NotifyManager::notify(NotifyTypes::GUILD_INVITE_JOINED);
454
            break;
455
456
        case 3:
457
            NotifyManager::notify(NotifyTypes::GUILD_INVITE_FULL);
458
            break;
459
460
        default:
461
            NotifyManager::notify(NotifyTypes::GUILD_INVITE_ERROR);
462
            break;
463
    }
464
}
465
466
void GuildRecv::processGuildLeave(Net::MessageIn &msg)
467
{
468
    const std::string nick = msg.readString(24, "nick");
469
    msg.readString(40, "message");
470
471
    if (taGuild != nullptr)
472
        taGuild->removeMember(nick);
473
474
    if (localPlayer == nullptr)
475
        return;
476
477
    if (nick == localPlayer->getName())
478
    {
479
        if (taGuild != nullptr)
480
        {
481
            taGuild->removeFromMembers();
482
            taGuild->clearMembers();
483
            localPlayer->removeGuild(taGuild->getId());
484
        }
485
        NotifyManager::notify(NotifyTypes::GUILD_LEFT);
486
        delete2(guildTab)
487
488
        if ((socialWindow != nullptr) && (taGuild != nullptr))
489
            socialWindow->removeTab(taGuild);
490
        if (actorManager != nullptr)
491
            actorManager->updatePlayerColors();
492
    }
493
    else
494
    {
495
        NotifyManager::notify(NotifyTypes::GUILD_USER_LEFT, nick);
496
        if (actorManager != nullptr)
497
        {
498
            Being *const b = actorManager->findBeingByName(
499
                nick, ActorType::Player);
500
501
            if (b != nullptr)
502
                b->clearGuilds();
503
            if (taGuild != nullptr)
504
                taGuild->removeMember(nick);
505
        }
506
    }
507
}
508
509
void GuildRecv::processGuildLeave2(Net::MessageIn &msg)
510
{
511
    const int charId = msg.readInt32("char id");
512
    msg.readString(40, "message");
513
    std::string nick;
514
515
    if (taGuild != nullptr)
516
    {
517
        const GuildMember *const member = taGuild->getMemberByCharId(charId);
518
        if (member != nullptr)
519
        {
520
            nick = member->getName();
521
            taGuild->removeMember(member);
522
        }
523
    }
524
525
    if (localPlayer == nullptr)
526
        return;
527
528
    if (charId == PlayerInfo::getCharId())
529
    {
530
        if (taGuild != nullptr)
531
        {
532
            taGuild->removeFromMembers();
533
            taGuild->clearMembers();
534
            localPlayer->removeGuild(taGuild->getId());
535
        }
536
        NotifyManager::notify(NotifyTypes::GUILD_LEFT);
537
        delete2(guildTab)
538
539
        if ((socialWindow != nullptr) && (taGuild != nullptr))
540
            socialWindow->removeTab(taGuild);
541
        if (actorManager != nullptr)
542
            actorManager->updatePlayerColors();
543
    }
544
    else
545
    {
546
        NotifyManager::notify(NotifyTypes::GUILD_USER_LEFT, nick);
547
        if (actorManager != nullptr)
548
        {
549
            Being *const b = actorManager->findBeingByName(
550
                nick, ActorType::Player);
551
552
            if (b != nullptr)
553
                b->clearGuilds();
554
            if (taGuild != nullptr)
555
                taGuild->removeMember(nick);
556
        }
557
    }
558
}
559
560
void GuildRecv::processGuildMessage(Net::MessageIn &msg)
561
{
562
    const int msgLength = msg.readInt16("len") - 4;
563
564
    if (msgLength <= 0)
565
        return;
566
    if (guildTab != nullptr)
567
    {
568
        std::string chatMsg = msg.readString(msgLength, "message");
569
        const size_t pos = chatMsg.find(" : ", 0);
570
        if (pos != std::string::npos)
571
        {
572
            const std::string sender_name = chatMsg.substr(0, pos);
573
            chatMsg.erase(0, pos + 3);
574
            trim(chatMsg);
575
            guildTab->chatLog(sender_name, chatMsg);
576
        }
577
        else
578
        {
579
            guildTab->chatLog(chatMsg,
580
                ChatMsgType::BY_SERVER,
581
                IgnoreRecord_false,
582
                TryRemoveColors_true);
583
        }
584
    }
585
    else
586
    {
587
        DEBUGLOGSTR("invisible guild?");
588
        msg.readString(msgLength, "message");
589
    }
590
}
591
592
void GuildRecv::processGuildReqAlliance(Net::MessageIn &msg)
593
{
594
    UNIMPLEMENTEDPACKET;
595
    msg.readInt32("id");
596
    msg.readString(24, "name");
597
}
598
599
void GuildRecv::processGuildReqAllianceAck(Net::MessageIn &msg)
600
{
601
    UNIMPLEMENTEDPACKET;
602
    msg.readInt32("flag");
603
}
604
605
void GuildRecv::processGuildDelAlliance(Net::MessageIn &msg)
606
{
607
    UNIMPLEMENTEDPACKET;
608
    msg.readInt32("guild id");
609
    msg.readInt32("flag");
610
}
611
612
void GuildRecv::processGuildOppositionAck(Net::MessageIn &msg)
613
{
614
    UNIMPLEMENTEDPACKET;
615
    msg.readUInt8("flag");
616
}
617
618
void GuildRecv::processGuildBroken(Net::MessageIn &msg)
619
{
620
    UNIMPLEMENTEDPACKET;
621
    msg.readInt32("flag");
622
}
623
624
void GuildRecv::processGuildExpulsionContinue(const std::string &nick)
625
{
626
    if (taGuild != nullptr)
627
        taGuild->removeMember(nick);
628
629
    if (localPlayer == nullptr)
630
        return;
631
632
    if (nick == localPlayer->getName())
633
    {
634
        if (taGuild != nullptr)
635
        {
636
            taGuild->removeFromMembers();
637
            taGuild->clearMembers();
638
        }
639
        NotifyManager::notify(NotifyTypes::GUILD_KICKED);
640
        delete2(guildTab)
641
642
        if ((socialWindow != nullptr) && (taGuild != nullptr))
643
            socialWindow->removeTab(taGuild);
644
        if (actorManager != nullptr)
645
            actorManager->updatePlayerColors();
646
    }
647
    else
648
    {
649
        NotifyManager::notify(NotifyTypes::GUILD_USER_KICKED, nick);
650
        if (actorManager != nullptr)
651
        {
652
            Being *const b = actorManager->findBeingByName(
653
                nick, ActorType::Player);
654
655
            if (b != nullptr)
656
                b->clearGuilds();
657
            if (taGuild != nullptr)
658
                taGuild->removeMember(nick);
659
        }
660
    }
661
}
662
663
void GuildRecv::processGuildUpdateCoords(Net::MessageIn &msg)
664
{
665
    const BeingId id = msg.readBeingId("account id");
666
    const int x = msg.readInt16("x");
667
    const int y = msg.readInt16("y");
668
    if (taGuild != nullptr)
669
    {
670
        GuildMember *const m = taGuild->getMember(id);
671
        if (m != nullptr)
672
        {
673
            m->setX(x);
674
            m->setY(y);
675
        }
676
    }
677
}
678
679
void GuildRecv::processGuildPositionInfo(Net::MessageIn &msg)
680
{
681
    const int guildId =  msg.readInt32("guild id");
682
    const int emblem =  msg.readInt32("elblem id");
683
    PlayerInfo::setGuildPositionFlags(
684
        static_cast<GuildPositionFlags::Type>(msg.readInt32("mode")));
685
    msg.readUInt8("guild master");
686
    msg.readInt32("unused");
687
    std::string guildName = msg.readString(24, "guild name");
688
689
    Guild *const g = Guild::getGuild(CAST_S16(guildId));
690
    if (g == nullptr)
691
        return;
692
693
    g->setName(guildName);
694
    g->setEmblemId(emblem);
695
    if (taGuild == nullptr)
696
        taGuild = g;
697
    if ((guildTab == nullptr) && (chatWindow != nullptr))
698
    {
699
        guildTab = new GuildTab(chatWindow);
700
        if (config.getBoolValue("showChatHistory"))
701
            guildTab->loadFromLogFile("#Guild");
702
        if (localPlayer != nullptr)
703
            localPlayer->addGuild(taGuild);
704
        guildHandler->memberList();
705
    }
706
707
    if (localPlayer != nullptr)
708
    {
709
        localPlayer->setGuild(g);
710
        localPlayer->setGuildName(g->getName());
711
    }
712
}
713
714
void GuildRecv::processGuildMemberLogin(Net::MessageIn &msg)
715
{
716
    const BeingId accountId = msg.readBeingId("account id");
717
    const int charId = msg.readInt32("char id");
718
    const int online = msg.readInt32("flag");
719
    const GenderT gender = Being::intToGender(CAST_U8(
720
        msg.readInt16("sex")));
721
    msg.readInt16("hair");
722
    msg.readInt16("hair color");
723
    if (taGuild != nullptr)
724
    {
725
        GuildMember *const m = taGuild->getMember(accountId, charId);
726
        if (m != nullptr)
727
        {
728
            m->setOnline(online != 0);
729
            if (online != 0)
730
                m->setGender(gender);
731
            if (guildTab != nullptr)
732
                guildTab->showOnline(m->getName(), fromBool(online, Online));
733
            if (socialWindow != nullptr)
734
                socialWindow->updateGuildCounter(0, 0);
735
        }
736
    }
737
}
738
739
void GuildRecv::processGuildExpulsion(Net::MessageIn &msg)
740
{
741
    const std::string nick = msg.readString(24, "name");
742
    msg.readString(40, "message");
743
744
    GuildRecv::processGuildExpulsionContinue(nick);
745
}
746
747
void GuildRecv::processGuildExpulsion2(Net::MessageIn &msg)
748
{
749
    msg.readString(40, "message");
750
    const int charId = msg.readInt32("char id");
751
752
    std::string nick;
753
754
    if (taGuild != nullptr)
755
    {
756
        const GuildMember *const member = taGuild->getMemberByCharId(charId);
757
        if (member != nullptr)
758
        {
759
            nick = member->getName();
760
            GuildRecv::processGuildExpulsionContinue(nick);
761
        }
762
    }
763
}
764
765
void GuildRecv::processGuildExpulsionList(Net::MessageIn &msg)
766
{
767
    const int length = msg.readInt16("len");
768
    if (length < 4)
769
        return;
770
771
    int count;
772
    if (msg.getVersion() < 20100803)
773
    {
774
        count = (length - 4) / 64;
775
        for (int i = 0; i < count; i++)
776
        {
777
            msg.readString(24, "name");
778
            msg.readString(40, "message");
779
        }
780
    }
781
    else
782
    {
783
        count = (length - 4) / 40;
784
        for (int i = 0; i < count; i++)
785
            msg.readString(40, "message");
786
    }
787
}
788
789
void GuildRecv::processGuildEmblem(Net::MessageIn &msg)
790
{
791
    UNIMPLEMENTEDPACKET;
792
    msg.readBeingId("being id");
793
    msg.readInt32("guild id");
794
    msg.readInt16("emblem id");
795
}
796
797
void GuildRecv::processOnlineInfo(Net::MessageIn &msg)
798
{
799
    // look like unused packet
800
    UNIMPLEMENTEDPACKET;
801
    msg.readBeingId("being id");
802
    msg.readInt32("char id");
803
    msg.readInt32("online");
804
}
805
806
void GuildRecv::processGuildSetPosition(Net::MessageIn &msg)
807
{
808
    const int positionLen = msg.readInt16("len") - 8;
809
    const BeingId beingId = msg.readBeingId("being id");
810
    std::string position;
811
    if (positionLen > 0)
812
    {
813
        position = msg.readString(positionLen, "position");
814
    }
815
    Being *const dstBeing = actorManager->findBeing(beingId);
816
    if (dstBeing != nullptr)
817
    {
818
        dstBeing->setGuildPos(position);
819
        dstBeing->addToCache();
820
    }
821
}
822
823
2
}  // namespace EAthena