1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
4 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
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/elementalrecv.h" |
23 |
|
|
|
24 |
|
|
#include "being/playerinfo.h" |
25 |
|
|
|
26 |
|
|
#include "net/messagein.h" |
27 |
|
|
|
28 |
|
|
#include "net/eathena/sp.h" |
29 |
|
|
|
30 |
|
|
#include "utils/checkutils.h" |
31 |
|
|
|
32 |
|
|
#include "debug.h" |
33 |
|
|
|
34 |
|
|
namespace EAthena |
35 |
|
|
{ |
36 |
|
|
|
37 |
|
|
#define setElementalStat(sp, stat) \ |
38 |
|
|
case sp: \ |
39 |
|
|
PlayerInfo::setStatBase(stat, \ |
40 |
|
|
val, \ |
41 |
|
|
Notify_true); \ |
42 |
|
|
break |
43 |
|
|
|
44 |
|
|
void ElementalRecv::processElementalUpdateStatus(Net::MessageIn &msg) |
45 |
|
|
{ |
46 |
|
|
const int sp = msg.readInt16("type"); |
47 |
|
|
const int val = msg.readInt32("value"); |
48 |
|
|
switch (sp) |
49 |
|
|
{ |
50 |
|
|
setElementalStat(Sp::HP, Attributes::ELEMENTAL_HP); |
51 |
|
|
setElementalStat(Sp::MAXHP, Attributes::ELEMENTAL_MAX_HP); |
52 |
|
|
setElementalStat(Sp::SP, Attributes::ELEMENTAL_MP); |
53 |
|
|
setElementalStat(Sp::MAXSP, Attributes::ELEMENTAL_MAX_MP); |
54 |
|
|
default: |
55 |
|
|
reportAlways("Unknown elemental stat %d", |
56 |
|
|
sp) |
57 |
|
|
break; |
58 |
|
|
} |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
void ElementalRecv::processElementalInfo(Net::MessageIn &msg) |
62 |
|
|
{ |
63 |
|
|
const BeingId id = msg.readBeingId("elemental id"); |
64 |
|
|
PlayerInfo::setStatBase(Attributes::ELEMENTAL_HP, |
65 |
|
|
msg.readInt32("hp"), |
66 |
|
|
Notify_true); |
67 |
|
|
PlayerInfo::setStatBase(Attributes::ELEMENTAL_MAX_HP, |
68 |
|
|
msg.readInt32("max hp"), |
69 |
|
|
Notify_true); |
70 |
|
|
PlayerInfo::setStatBase(Attributes::ELEMENTAL_MP, |
71 |
|
|
msg.readInt32("sp"), |
72 |
|
|
Notify_true); |
73 |
|
|
PlayerInfo::setStatBase(Attributes::ELEMENTAL_MAX_MP, |
74 |
|
|
msg.readInt32("max sp"), |
75 |
|
|
Notify_true); |
76 |
|
|
PlayerInfo::setElemental(id); |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
} // namespace EAthena |