GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/elementalrecv.cpp Lines: 0 21 0.0 %
Date: 2017-11-29 Branches: 0 7 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "net/eathena/elementalrecv.h"
22
23
#include "being/playerinfo.h"
24
25
#include "net/messagein.h"
26
27
#include "net/eathena/sp.h"
28
29
#include "utils/checkutils.h"
30
31
#include "debug.h"
32
33
namespace EAthena
34
{
35
36
#define setElementalStat(sp, stat) \
37
        case sp: \
38
            PlayerInfo::setStatBase(stat, \
39
                val); \
40
            break;
41
42
void ElementalRecv::processElementalUpdateStatus(Net::MessageIn &msg)
43
{
44
    const int sp = msg.readInt16("type");
45
    const int val = msg.readInt32("value");
46
    switch (sp)
47
    {
48
        setElementalStat(Sp::HP, Attributes::ELEMENTAL_HP);
49
        setElementalStat(Sp::MAXHP, Attributes::ELEMENTAL_MAX_HP);
50
        setElementalStat(Sp::SP, Attributes::ELEMENTAL_MP);
51
        setElementalStat(Sp::MAXSP, Attributes::ELEMENTAL_MAX_MP);
52
        default:
53
            reportAlways("Unknown elemental stat %d",
54
                sp);
55
            break;
56
    }
57
}
58
59
void ElementalRecv::processElementalInfo(Net::MessageIn &msg)
60
{
61
    const BeingId id = msg.readBeingId("elemental id");
62
    PlayerInfo::setStatBase(Attributes::ELEMENTAL_HP,
63
        msg.readInt32("hp"));
64
    PlayerInfo::setStatBase(Attributes::ELEMENTAL_MAX_HP,
65
        msg.readInt32("max hp"));
66
    PlayerInfo::setStatBase(Attributes::ELEMENTAL_MP,
67
        msg.readInt32("sp"));
68
    PlayerInfo::setStatBase(Attributes::ELEMENTAL_MAX_MP,
69
        msg.readInt32("max sp"));
70
    PlayerInfo::setElemental(id);
71
}
72
73
}  // namespace EAthena