GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/playerhandler.cpp Lines: 8 447 1.8 %
Date: 2018-12-09 Branches: 0 633 0.0 %

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/playerhandler.h"
24
25
#include "notifymanager.h"
26
#include "party.h"
27
28
#include "being/localplayer.h"
29
#include "being/playerinfo.h"
30
31
#include "const/net/nostat.h"
32
33
#include "enums/resources/notifytypes.h"
34
35
#include "gui/windows/skilldialog.h"
36
#include "gui/windows/statuswindow.h"
37
38
#include "net/ea/inventoryhandler.h"
39
40
#include "net/eathena/messageout.h"
41
#include "net/eathena/protocolout.h"
42
#include "net/eathena/sp.h"
43
44
#include "resources/db/unitsdb.h"
45
46
#include "debug.h"
47
48
extern int packetVersion;
49
extern int packetVersionMain;
50
extern int packetVersionRe;
51
extern int packetVersionZero;
52
extern int serverVersion;
53
54
namespace EAthena
55
{
56
57
77
PlayerHandler::PlayerHandler() :
58
77
    Ea::PlayerHandler()
59
{
60
77
    playerHandler = this;
61
77
}
62
63
231
PlayerHandler::~PlayerHandler()
64
{
65
77
    playerHandler = nullptr;
66
77
}
67
68
void PlayerHandler::attack(const BeingId id,
69
                           const Keep keep) const
70
{
71
    createOutPacket(CMSG_PLAYER_CHANGE_ACT);
72
    outMsg.writeBeingId(id, "target id");
73
    if (keep == Keep_true)
74
        outMsg.writeInt8(7, "action");
75
    else
76
        outMsg.writeInt8(0, "action");
77
}
78
79
void PlayerHandler::stopAttack() const
80
{
81
    createOutPacket(CMSG_PLAYER_STOP_ATTACK);
82
}
83
84
void PlayerHandler::emote(const uint8_t emoteId) const
85
{
86
    createOutPacket(CMSG_PLAYER_EMOTE);
87
    outMsg.writeInt8(emoteId, "emote id");
88
}
89
90
void PlayerHandler::increaseAttribute(const AttributesT attr,
91
                                      const int amount) const
92
{
93
    if (attr >= Attributes::PLAYER_STR && attr <= Attributes::PLAYER_LUK)
94
    {
95
        createOutPacket(CMSG_STAT_UPDATE_REQUEST);
96
        outMsg.writeInt16(CAST_S16(attr), "attribute id");
97
        outMsg.writeInt8(CAST_S8(amount), "increase");
98
    }
99
}
100
101
void PlayerHandler::increaseSkill(const uint16_t skillId) const
102
{
103
    if (PlayerInfo::getAttribute(Attributes::PLAYER_SKILL_POINTS) <= 0)
104
        return;
105
106
    createOutPacket(CMSG_SKILL_LEVELUP_REQUEST);
107
    outMsg.writeInt16(skillId, "skill id");
108
}
109
110
void PlayerHandler::pickUp(const FloorItem *const floorItem) const
111
{
112
    if (floorItem == nullptr)
113
        return;
114
115
    createOutPacket(CMSG_ITEM_PICKUP);
116
    const BeingId id = floorItem->getId();
117
    if (packetVersion >= 20101124)
118
    {
119
        outMsg.writeBeingId(id, "object id");
120
    }
121
    else if (packetVersion >= 20080827)
122
    {
123
        outMsg.writeInt32(0, "unused");
124
        outMsg.writeInt8(0, "unused");
125
        outMsg.writeBeingId(id, "object id");
126
    }
127
    else if (packetVersion >= 20070212)
128
    {
129
        outMsg.writeInt32(0, "unused");
130
        outMsg.writeBeingId(id, "object id");
131
    }
132
    else if (packetVersion >= 20070108)
133
    {
134
        outMsg.writeInt32(0, "unused");
135
        outMsg.writeInt8(0, "unused");
136
        outMsg.writeBeingId(id, "object id");
137
    }
138
    else if (packetVersion >= 20050719)
139
    {
140
        outMsg.writeInt32(0, "unused");
141
        outMsg.writeInt16(0, "unused");
142
        outMsg.writeInt8(0, "unused");
143
        outMsg.writeBeingId(id, "object id");
144
    }
145
    else if (packetVersion >= 20050718)
146
    {
147
        outMsg.writeInt8(0, "unused");
148
        outMsg.writeBeingId(id, "object id");
149
    }
150
    else if (packetVersion >= 20050628)
151
    {
152
        outMsg.writeInt32(0, "unused");
153
        outMsg.writeInt8(0, "unused");
154
        outMsg.writeBeingId(id, "object id");
155
    }
156
    else if (packetVersion >= 20050509)
157
    {
158
        outMsg.writeInt16(0, "unused");
159
        outMsg.writeBeingId(id, "object id");
160
    }
161
    else if (packetVersion >= 20050110)
162
    {
163
        outMsg.writeInt16(0, "unused");
164
        outMsg.writeInt8(0, "unused");
165
        outMsg.writeBeingId(id, "object id");
166
    }
167
    else if (packetVersion >= 20041129)
168
    {
169
        outMsg.writeInt8(0, "unused");
170
        outMsg.writeBeingId(id, "object id");
171
    }
172
    else if (packetVersion >= 20041025)
173
    {
174
        outMsg.writeInt16(0, "unused");
175
        outMsg.writeInt8(0, "unused");
176
        outMsg.writeBeingId(id, "object id");
177
    }
178
    else if (packetVersion >= 20041005)
179
    {
180
        outMsg.writeInt32(0, "unused");
181
        outMsg.writeBeingId(id, "object id");
182
    }
183
    else if (packetVersion >= 20040920)
184
    {
185
        outMsg.writeInt32(0, "unused");
186
        outMsg.writeInt32(0, "unused");
187
        outMsg.writeBeingId(id, "object id");
188
    }
189
    else if (packetVersion >= 20040906)
190
    {
191
        outMsg.writeInt32(0, "unused");
192
        outMsg.writeInt8(0, "unused");
193
        outMsg.writeBeingId(id, "object id");
194
    }
195
    else if (packetVersion >= 20040809)
196
    {
197
        outMsg.writeInt32(0, "unused");
198
        outMsg.writeInt16(0, "unused");
199
        outMsg.writeInt8(0, "unused");
200
        outMsg.writeBeingId(id, "object id");
201
    }
202
    else if (packetVersion >= 20040713)
203
    {
204
        outMsg.writeInt32(0, "unused");
205
        outMsg.writeBeingId(id, "object id");
206
    }
207
    else
208
    {
209
        outMsg.writeBeingId(id, "object id");
210
    }
211
212
    Ea::InventoryHandler::pushPickup(floorItem->getId());
213
}
214
215
void PlayerHandler::setDirection(const unsigned char direction) const
216
{
217
    createOutPacket(CMSG_PLAYER_CHANGE_DIR);
218
    if (packetVersion >= 20101124)
219
    {
220
        outMsg.writeInt8(0, "head direction");
221
        outMsg.writeInt8(0, "unused");
222
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
223
            "player direction");
224
    }
225
    else if (packetVersion >= 20080827)
226
    {
227
        outMsg.writeInt16(0, "unused");
228
        outMsg.writeInt8(0, "head direction");
229
        outMsg.writeInt32(0, "unused");
230
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
231
            "player direction");
232
    }
233
    else if (packetVersion >= 20070212)
234
    {
235
        outMsg.writeInt32(0, "unused");
236
        outMsg.writeInt16(0, "unused");
237
        outMsg.writeInt8(0, "head direction");
238
        outMsg.writeInt16(0, "unused");
239
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
240
            "player direction");
241
    }
242
    else if (packetVersion >= 20070108)
243
    {
244
        outMsg.writeInt32(0, "unused");
245
        outMsg.writeInt32(0, "unused");
246
        outMsg.writeInt8(0, "head direction");
247
        outMsg.writeInt16(0, "unused");
248
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
249
            "player direction");
250
    }
251
    else if (packetVersion >= 20060327)
252
    {
253
        outMsg.writeInt32(0, "unused");
254
        outMsg.writeInt8(0, "unused");
255
        outMsg.writeInt8(0, "head direction");
256
        outMsg.writeInt8(0, "unused");
257
        outMsg.writeInt16(0, "unused");
258
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
259
            "player direction");
260
    }
261
    else if (packetVersion >= 20050719)
262
    {
263
        outMsg.writeInt32(0, "unused");
264
        outMsg.writeInt16(0, "unused");
265
        outMsg.writeInt8(0, "head direction");
266
        outMsg.writeInt8(0, "unused");
267
        outMsg.writeInt32(0, "unused");
268
        outMsg.writeInt16(0, "unused");
269
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
270
            "player direction");
271
    }
272
    else if (packetVersion >= 20050718)
273
    {
274
        outMsg.writeInt32(0, "unused");
275
        outMsg.writeInt8(0, "head direction");
276
        outMsg.writeInt8(0, "unused");
277
        outMsg.writeInt16(0, "unused");
278
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
279
            "player direction");
280
    }
281
    else if (packetVersion >= 20050628)
282
    {
283
        outMsg.writeInt32(0, "unused");
284
        outMsg.writeInt16(0, "unused");
285
        outMsg.writeInt8(0, "head direction");
286
        outMsg.writeInt8(0, "unused");
287
        outMsg.writeInt32(0, "unused");
288
        outMsg.writeInt16(0, "unused");
289
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
290
            "player direction");
291
    }
292
    else if (packetVersion >= 20050509)
293
    {
294
        outMsg.writeInt8(0, "unused");
295
        outMsg.writeInt32(0, "unused");
296
        outMsg.writeInt16(0, "unused");
297
        outMsg.writeInt8(0, "head direction");
298
        outMsg.writeInt8(0, "unused");
299
        outMsg.writeInt16(0, "unused");
300
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
301
            "player direction");
302
    }
303
    else if (packetVersion >= 20050110)
304
    {
305
        outMsg.writeInt32(0, "unused");
306
        outMsg.writeInt32(0, "unused");
307
        outMsg.writeInt16(0, "unused");
308
        outMsg.writeInt8(0, "head direction");
309
        outMsg.writeInt8(0, "unused");
310
        outMsg.writeInt32(0, "unused");
311
        outMsg.writeInt32(0, "unused");
312
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
313
            "player direction");
314
    }
315
    else if (packetVersion >= 20041129)
316
    {
317
        outMsg.writeInt8(0, "unused");
318
        outMsg.writeInt8(0, "head direction");
319
        outMsg.writeInt8(0, "unused");
320
        outMsg.writeInt16(0, "unused");
321
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
322
            "player direction");
323
    }
324
    else if (packetVersion >= 20041025)
325
    {
326
        outMsg.writeInt32(0, "unused");
327
        outMsg.writeInt8(0, "head direction");
328
        outMsg.writeInt8(0, "unused");
329
        outMsg.writeInt32(0, "unused");
330
        outMsg.writeInt16(0, "unused");
331
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
332
            "player direction");
333
    }
334
    else if (packetVersion >= 20041005)
335
    {
336
        outMsg.writeInt16(0, "unused");
337
        outMsg.writeInt8(0, "unused");
338
        outMsg.writeInt8(0, "head direction");
339
        outMsg.writeInt32(0, "unused");
340
        outMsg.writeInt16(0, "unused");
341
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
342
            "player direction");
343
    }
344
    else if (packetVersion >= 20040920)
345
    {
346
        outMsg.writeInt32(0, "unused");
347
        outMsg.writeInt16(0, "unused");
348
        outMsg.writeInt8(0, "head direction");
349
        outMsg.writeInt32(0, "unused");
350
        outMsg.writeInt32(0, "unused");
351
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
352
            "player direction");
353
    }
354
    else if (packetVersion >= 20040906)
355
    {
356
        outMsg.writeInt16(0, "unused");
357
        outMsg.writeInt8(0, "head direction");
358
        outMsg.writeInt16(0, "unused");
359
        outMsg.writeInt16(0, "unused");
360
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
361
            "player direction");
362
    }
363
    else if (packetVersion >= 20040809)
364
    {
365
        outMsg.writeInt16(0, "unused");
366
        outMsg.writeInt16(0, "unused");
367
        outMsg.writeInt8(0, "unused");
368
        outMsg.writeInt8(0, "head direction");
369
        outMsg.writeInt16(0, "unused");
370
        outMsg.writeInt8(0, "unused");
371
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
372
            "player direction");
373
    }
374
    else if (packetVersion >= 20040713)
375
    {
376
        outMsg.writeInt8(0, "unused");
377
        outMsg.writeInt8(0, "unused");
378
        outMsg.writeInt8(0, "unused");
379
        outMsg.writeInt8(0, "head direction");
380
        outMsg.writeInt16(0, "unused");
381
        outMsg.writeInt16(0, "unused");
382
        outMsg.writeInt16(0, "unused");
383
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
384
            "player direction");
385
    }
386
    else
387
    {
388
        outMsg.writeInt8(0, "head direction");
389
        outMsg.writeInt8(0, "unused");
390
        outMsg.writeInt8(MessageOut::toServerDirection(direction),
391
            "player direction");
392
    }
393
}
394
395
void PlayerHandler::setDestination(const int x, const int y,
396
                                   const int direction) const
397
{
398
    createOutPacket(CMSG_PLAYER_CHANGE_DEST);
399
    if (packetVersion >= 20080827 && packetVersion < 20101124)
400
        outMsg.writeInt32(0, "unused");
401
    outMsg.writeCoordinates(CAST_U16(x),
402
        CAST_U16(y),
403
        CAST_U8(direction), "destination");
404
}
405
406
void PlayerHandler::changeAction(const BeingActionT &action) const
407
{
408
    unsigned char type;
409
    switch (action)
410
    {
411
        case BeingAction::SIT:
412
            type = 2;
413
            break;
414
        case BeingAction::STAND:
415
        case BeingAction::PRESTAND:
416
            type = 3;
417
            break;
418
        default:
419
        case BeingAction::MOVE:
420
        case BeingAction::ATTACK:
421
        case BeingAction::DEAD:
422
        case BeingAction::HURT:
423
        case BeingAction::SPAWN:
424
        case BeingAction::CAST:
425
            return;
426
    }
427
428
    createOutPacket(CMSG_PLAYER_CHANGE_ACT);
429
    outMsg.writeInt32(0, "unused");
430
    outMsg.writeInt8(type, "action");
431
}
432
433
void PlayerHandler::respawn() const
434
{
435
    createOutPacket(CMSG_PLAYER_RESTART);
436
    outMsg.writeInt8(0, "action");
437
}
438
439
void PlayerHandler::requestOnlineList() const
440
{
441
    createOutPacket(CMSG_ONLINE_LIST);
442
}
443
444
void PlayerHandler::updateStatus(const uint8_t status) const
445
{
446
    createOutPacket(CMSG_SET_STATUS);
447
    outMsg.writeInt8(status, "status");
448
    outMsg.writeInt8(0, "unused");
449
}
450
451
void PlayerHandler::setShortcut(const int idx,
452
                                const uint8_t type,
453
                                const int id,
454
                                const int level) const
455
{
456
    createOutPacket(CMSG_SET_SHORTCUTS);
457
    outMsg.writeInt16(CAST_S16(idx), "index");
458
    outMsg.writeInt8(CAST_S8(type), "type");
459
    outMsg.writeInt32(id, "id");
460
    outMsg.writeInt16(CAST_S16(level), "level");
461
}
462
463
void PlayerHandler::shortcutShiftRow(const int row) const
464
{
465
    if (packetVersion < 20140129)
466
        return;
467
    createOutPacket(CMSG_SHORTCUTS_ROW_SHIFT);
468
    outMsg.writeInt8(CAST_S8(row), "row");
469
}
470
471
void PlayerHandler::removeOption() const
472
{
473
    createOutPacket(CMSG_REMOVE_OPTION);
474
}
475
476
void PlayerHandler::changeCart(const int type) const
477
{
478
    createOutPacket(CMSG_CHANGE_CART);
479
    outMsg.writeInt16(CAST_S16(type), "type");
480
}
481
482
void PlayerHandler::setMemo() const
483
{
484
    createOutPacket(CMSG_PLAYER_SET_MEMO);
485
}
486
487
void PlayerHandler::doriDori() const
488
{
489
    createOutPacket(CMSG_DORI_DORI);
490
}
491
492
void PlayerHandler::explosionSpirits() const
493
{
494
    createOutPacket(CMSG_EXPLOSION_SPIRITS);
495
}
496
497
void PlayerHandler::requestPvpInfo() const
498
{
499
    createOutPacket(CMSG_PVP_INFO);
500
    outMsg.writeInt32(0, "char id");
501
    outMsg.writeInt32(0, "account id");
502
}
503
504
void PlayerHandler::revive() const
505
{
506
    createOutPacket(CMSG_PLAYER_AUTO_REVIVE);
507
}
508
509
void PlayerHandler::setConfigOption(const int id,
510
                                    const int data) const
511
{
512
    createOutPacket(CMSG_SET_CONFIG_OPTION);
513
    outMsg.writeInt32(id, "config option");
514
    outMsg.writeInt32(data, "config data");
515
}
516
517
#define setStatComplex(stat) \
518
    PlayerInfo::setStatBase(stat, CAST_S32(base), notify); \
519
    if (mod != NoStat) \
520
        PlayerInfo::setStatMod(stat, mod, Notify_true)
521
522
void PlayerHandler::setStat(Net::MessageIn &msg,
523
                            const int type,
524
                            const int64_t base,
525
                            const int mod,
526
                            const Notify notify) const
527
{
528
    switch (type)
529
    {
530
        case Sp::SPEED:
531
            localPlayer->setWalkSpeed(CAST_S32(base));
532
            PlayerInfo::setStatBase(Attributes::PLAYER_WALK_SPEED,
533
                CAST_S32(base),
534
                Notify_true);
535
            PlayerInfo::setStatMod(Attributes::PLAYER_WALK_SPEED,
536
                0,
537
                Notify_true);
538
            break;
539
        case Sp::BASEEXP:
540
            PlayerInfo::setAttribute(Attributes::PLAYER_EXP,
541
                base,
542
                Notify_true);
543
            break;
544
        case Sp::JOBEXP:
545
            PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP,
546
                base,
547
                Notify_true);
548
            break;
549
        case Sp::KARMA:
550
            PlayerInfo::setStatBase(Attributes::PLAYER_KARMA,
551
                CAST_S32(base),
552
                Notify_true);
553
            PlayerInfo::setStatMod(Attributes::PLAYER_KARMA,
554
                0,
555
                Notify_true);
556
            break;
557
        case Sp::MANNER:
558
            PlayerInfo::setStatBase(Attributes::PLAYER_MANNER,
559
                CAST_S32(base),
560
                Notify_true);
561
            PlayerInfo::setStatMod(Attributes::PLAYER_MANNER,
562
                0,
563
                Notify_true);
564
            break;
565
        case Sp::HP:
566
            PlayerInfo::setAttribute(Attributes::PLAYER_HP,
567
                base,
568
                Notify_true);
569
            if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
570
            {
571
                PartyMember *const m = Party::getParty(1)
572
                    ->getMember(localPlayer->getId());
573
                if (m != nullptr)
574
                {
575
                    m->setHp(CAST_S32(base));
576
                    m->setMaxHp(PlayerInfo::getAttribute(
577
                        Attributes::PLAYER_MAX_HP));
578
                }
579
            }
580
            break;
581
        case Sp::MAXHP:
582
            PlayerInfo::setAttribute(Attributes::PLAYER_MAX_HP,
583
                base,
584
                Notify_true);
585
586
            if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
587
            {
588
                PartyMember *const m = Party::getParty(1)->getMember(
589
                    localPlayer->getId());
590
                if (m != nullptr)
591
                {
592
                    m->setHp(PlayerInfo::getAttribute(Attributes::PLAYER_HP));
593
                    m->setMaxHp(CAST_S32(base));
594
                }
595
            }
596
            break;
597
        case Sp::SP:
598
            PlayerInfo::setAttribute(Attributes::PLAYER_MP,
599
                base,
600
                Notify_true);
601
            break;
602
        case Sp::MAXSP:
603
            PlayerInfo::setAttribute(Attributes::PLAYER_MAX_MP,
604
                base,
605
                Notify_true);
606
            break;
607
        case Sp::STATUSPOINT:
608
            PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS,
609
                base,
610
                Notify_true);
611
            break;
612
        case Sp::BASELEVEL:
613
            PlayerInfo::setAttribute(Attributes::PLAYER_BASE_LEVEL,
614
                base,
615
                Notify_true);
616
            if (localPlayer != nullptr)
617
            {
618
                localPlayer->setLevel(CAST_S32(base));
619
                localPlayer->updateName();
620
            }
621
            break;
622
        case Sp::SKILLPOINT:
623
            PlayerInfo::setAttribute(Attributes::PLAYER_SKILL_POINTS,
624
                base,
625
                Notify_true);
626
            if (skillDialog != nullptr)
627
                skillDialog->update();
628
            break;
629
        case Sp::STR:
630
            setStatComplex(Attributes::PLAYER_STR);
631
            break;
632
        case Sp::AGI:
633
            setStatComplex(Attributes::PLAYER_AGI);
634
            break;
635
        case Sp::VIT:
636
            setStatComplex(Attributes::PLAYER_VIT);
637
            break;
638
        case Sp::INT:
639
            setStatComplex(Attributes::PLAYER_INT);
640
            break;
641
        case Sp::DEX:
642
            setStatComplex(Attributes::PLAYER_DEX);
643
            break;
644
        case Sp::LUK:
645
            setStatComplex(Attributes::PLAYER_LUK);
646
            break;
647
        case Sp::ZENY:
648
        {
649
            const int oldMoney = PlayerInfo::getAttribute(Attributes::MONEY);
650
            const int newMoney = CAST_S32(base);
651
            if (newMoney > oldMoney)
652
            {
653
                NotifyManager::notify(NotifyTypes::MONEY_GET,
654
                    UnitsDb::formatCurrency(newMoney - oldMoney));
655
            }
656
            else if (newMoney < oldMoney)
657
            {
658
                NotifyManager::notify(NotifyTypes::MONEY_SPENT,
659
                    UnitsDb::formatCurrency(oldMoney - newMoney).c_str());
660
            }
661
662
            PlayerInfo::setAttribute(Attributes::MONEY,
663
                newMoney,
664
                Notify_true);
665
            break;
666
        }
667
        case Sp::NEXTBASEEXP:
668
            PlayerInfo::setAttribute(Attributes::PLAYER_EXP_NEEDED,
669
                base,
670
                Notify_true);
671
            break;
672
        case Sp::NEXTJOBEXP:
673
            PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP_NEEDED,
674
                base,
675
                Notify_true);
676
            break;
677
        case Sp::WEIGHT:
678
            PlayerInfo::setAttribute(Attributes::TOTAL_WEIGHT,
679
                base,
680
                Notify_true);
681
            break;
682
        case Sp::MAXWEIGHT:
683
            PlayerInfo::setAttribute(Attributes::MAX_WEIGHT,
684
                base,
685
                Notify_true);
686
            break;
687
        case Sp::USTR:
688
            statusWindow->setPointsNeeded(Attributes::PLAYER_STR,
689
                CAST_S32(base));
690
            break;
691
        case Sp::UAGI:
692
            statusWindow->setPointsNeeded(Attributes::PLAYER_AGI,
693
                CAST_S32(base));
694
            break;
695
        case Sp::UVIT:
696
            statusWindow->setPointsNeeded(Attributes::PLAYER_VIT,
697
                CAST_S32(base));
698
            break;
699
        case Sp::UINT:
700
            statusWindow->setPointsNeeded(Attributes::PLAYER_INT,
701
                CAST_S32(base));
702
            break;
703
        case Sp::UDEX:
704
            statusWindow->setPointsNeeded(Attributes::PLAYER_DEX,
705
                CAST_S32(base));
706
            break;
707
        case Sp::ULUK:
708
            statusWindow->setPointsNeeded(Attributes::PLAYER_LUK,
709
                CAST_S32(base));
710
            break;
711
712
        case Sp::ATK1:
713
            PlayerInfo::setStatBase(Attributes::PLAYER_ATK,
714
                CAST_S32(base),
715
                Notify_true);
716
            PlayerInfo::updateAttrs();
717
            break;
718
        case Sp::ATK2:
719
            PlayerInfo::setStatMod(Attributes::PLAYER_ATK,
720
                CAST_S32(base),
721
                Notify_true);
722
            PlayerInfo::updateAttrs();
723
            break;
724
        case Sp::MATK1:
725
            PlayerInfo::setStatBase(Attributes::PLAYER_MATK,
726
                CAST_S32(base),
727
                Notify_true);
728
            break;
729
        case Sp::MATK2:
730
            PlayerInfo::setStatMod(Attributes::PLAYER_MATK,
731
                CAST_S32(base),
732
                Notify_true);
733
            break;
734
        case Sp::DEF1:
735
            PlayerInfo::setStatBase(Attributes::PLAYER_DEF,
736
                CAST_S32(base),
737
                Notify_true);
738
            break;
739
        case Sp::DEF2:
740
            PlayerInfo::setStatMod(Attributes::PLAYER_DEF,
741
                CAST_S32(base),
742
                Notify_true);
743
            break;
744
        case Sp::MDEF1:
745
            PlayerInfo::setStatBase(Attributes::PLAYER_MDEF,
746
                CAST_S32(base),
747
                Notify_true);
748
            break;
749
        case Sp::MDEF2:
750
            PlayerInfo::setStatMod(Attributes::PLAYER_MDEF,
751
                CAST_S32(base),
752
                Notify_true);
753
            break;
754
        case Sp::HIT:
755
            PlayerInfo::setStatBase(Attributes::PLAYER_HIT,
756
                CAST_S32(base),
757
                Notify_true);
758
            break;
759
        case Sp::FLEE1:
760
            PlayerInfo::setStatBase(Attributes::PLAYER_FLEE,
761
                CAST_S32(base),
762
                Notify_true);
763
            break;
764
        case Sp::FLEE2:
765
            PlayerInfo::setStatMod(Attributes::PLAYER_FLEE,
766
                CAST_S32(base),
767
                Notify_true);
768
            break;
769
        case Sp::CRITICAL:
770
            PlayerInfo::setStatBase(Attributes::PLAYER_CRIT,
771
                CAST_S32(base),
772
                Notify_true);
773
            break;
774
        case Sp::ASPD:
775
            localPlayer->setAttackSpeed(CAST_S32(base));
776
            PlayerInfo::setStatBase(Attributes::PLAYER_ATTACK_DELAY,
777
                CAST_S32(base),
778
                Notify_true);
779
            PlayerInfo::setStatMod(Attributes::PLAYER_ATTACK_DELAY,
780
                0,
781
                Notify_true);
782
            PlayerInfo::updateAttrs();
783
            break;
784
        case Sp::JOBLEVEL:
785
            PlayerInfo::setAttribute(Attributes::PLAYER_JOB_LEVEL,
786
                base,
787
                Notify_true);
788
            break;
789
790
        default:
791
            UNIMPLEMENTEDPACKETFIELD(type);
792
            break;
793
    }
794
}
795
796
void PlayerHandler::selectStyle(const int headColor,
797
                                const int headStyle,
798
                                const int bodyColor,
799
                                const int topStyle,
800
                                const int middleStyle,
801
                                const int bottomStyle,
802
                                const int bodyStyle) const
803
{
804
    if (packetVersion < 20151104)
805
        return;
806
    if (packetVersionMain >= 20180516 ||
807
        packetVersionRe >= 20180516 ||
808
        packetVersionZero >= 20180523)
809
    {
810
        createOutPacket(CMSG_PLAYER_SELECT_STYLE2);
811
        outMsg.writeInt16(CAST_S16(headColor), "head color");
812
        outMsg.writeInt16(CAST_S16(headStyle), "head style");
813
        outMsg.writeInt16(CAST_S16(bodyColor), "body color");
814
        outMsg.writeInt16(CAST_S16(topStyle), "top style");
815
        outMsg.writeInt16(CAST_S16(middleStyle), "middle style");
816
        outMsg.writeInt16(CAST_S16(bottomStyle), "bottom style");
817
        outMsg.writeInt16(CAST_S16(bodyStyle), "body style");
818
    }
819
    else
820
    {
821
        createOutPacket(CMSG_PLAYER_SELECT_STYLE);
822
        outMsg.writeInt16(CAST_S16(headColor), "head color");
823
        outMsg.writeInt16(CAST_S16(headStyle), "head style");
824
        outMsg.writeInt16(CAST_S16(bodyColor), "body color");
825
        outMsg.writeInt16(CAST_S16(topStyle), "top style");
826
        outMsg.writeInt16(CAST_S16(middleStyle), "middle style");
827
        outMsg.writeInt16(CAST_S16(bottomStyle), "bottom style");
828
    }
829
}
830
831
void PlayerHandler::setTitle(const int titleId) const
832
{
833
    if (packetVersion < 20140903)
834
        return;
835
    createOutPacket(CMSG_PLAYER_SET_TITLE);
836
    outMsg.writeInt32(titleId, "title");
837
}
838
839
#undef setStatComplex
840
841
2
}  // namespace EAthena