GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/tmwa/playerrecv.cpp Lines: 1 68 1.5 %
Date: 2017-11-29 Branches: 0 14 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-2017  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/tmwa/playerrecv.h"
24
25
#include "being/localplayer.h"
26
#include "being/playerinfo.h"
27
28
#include "gui/windows/statuswindow.h"
29
30
#include "net/messagein.h"
31
32
#include "debug.h"
33
34
namespace TmwAthena
35
{
36
37
void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
38
{
39
    BLOCK_START("PlayerRecv::processPlayerStatUpdate5")
40
    PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS,
41
        msg.readInt16("char points"));
42
43
    unsigned int val = msg.readUInt8("str");
44
    PlayerInfo::setStatBase(Attributes::PLAYER_STR, val);
45
    if (statusWindow != nullptr)
46
    {
47
        statusWindow->setPointsNeeded(Attributes::PLAYER_STR,
48
            msg.readUInt8("str cost"));
49
    }
50
    else
51
    {
52
        msg.readUInt8("str cost");
53
    }
54
55
    val = msg.readUInt8("agi");
56
    PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val);
57
    if (statusWindow != nullptr)
58
    {
59
        statusWindow->setPointsNeeded(Attributes::PLAYER_AGI,
60
            msg.readUInt8("agi cost"));
61
    }
62
    else
63
    {
64
        msg.readUInt8("agi cost");
65
    }
66
67
    val = msg.readUInt8("vit");
68
    PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val);
69
    if (statusWindow != nullptr)
70
    {
71
        statusWindow->setPointsNeeded(Attributes::PLAYER_VIT,
72
            msg.readUInt8("vit cost"));
73
    }
74
    else
75
    {
76
        msg.readUInt8("vit cost");
77
    }
78
79
    val = msg.readUInt8("int");
80
    PlayerInfo::setStatBase(Attributes::PLAYER_INT, val);
81
    if (statusWindow != nullptr)
82
    {
83
        statusWindow->setPointsNeeded(Attributes::PLAYER_INT,
84
            msg.readUInt8("int cost"));
85
    }
86
    else
87
    {
88
        msg.readUInt8("int cost");
89
    }
90
91
    val = msg.readUInt8("dex");
92
    PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val);
93
    if (statusWindow != nullptr)
94
    {
95
        statusWindow->setPointsNeeded(Attributes::PLAYER_DEX,
96
            msg.readUInt8("dex cost"));
97
    }
98
    else
99
    {
100
        msg.readUInt8("dex cost");
101
    }
102
103
    val = msg.readUInt8("luk");
104
    PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val);
105
    if (statusWindow != nullptr)
106
    {
107
        statusWindow->setPointsNeeded(Attributes::PLAYER_LUK,
108
            msg.readUInt8("luk cost"));
109
    }
110
    else
111
    {
112
        msg.readUInt8("luk cost");
113
    }
114
115
    PlayerInfo::setStatBase(Attributes::PLAYER_ATK,
116
        msg.readInt16("atk"), Notify_false);
117
    PlayerInfo::setStatMod(Attributes::PLAYER_ATK, msg.readInt16("atk+"));
118
    PlayerInfo::updateAttrs();
119
120
    val = msg.readInt16("matk");
121
    PlayerInfo::setStatBase(Attributes::PLAYER_MATK, val, Notify_false);
122
123
    val = msg.readInt16("matk+");
124
    PlayerInfo::setStatMod(Attributes::PLAYER_MATK, val);
125
126
    PlayerInfo::setStatBase(Attributes::PLAYER_DEF,
127
        msg.readInt16("def"), Notify_false);
128
    PlayerInfo::setStatMod(Attributes::PLAYER_DEF, msg.readInt16("def+"));
129
130
    PlayerInfo::setStatBase(Attributes::PLAYER_MDEF,
131
        msg.readInt16("mdef"), Notify_false);
132
    PlayerInfo::setStatMod(Attributes::PLAYER_MDEF, msg.readInt16("mdef+"));
133
134
    PlayerInfo::setStatBase(Attributes::PLAYER_HIT, msg.readInt16("hit"));
135
136
    PlayerInfo::setStatBase(Attributes::PLAYER_FLEE,
137
        msg.readInt16("flee"), Notify_false);
138
    PlayerInfo::setStatMod(Attributes::PLAYER_FLEE, msg.readInt16("flee+"));
139
140
    PlayerInfo::setStatBase(Attributes::PLAYER_CRIT, msg.readInt16("crit"));
141
142
    PlayerInfo::setStatBase(Attributes::PLAYER_MANNER,
143
        msg.readInt16("manner"));
144
    msg.readInt16("unused?");
145
    BLOCK_END("PlayerRecv::processPlayerStatUpdate5")
146
}
147
148
void PlayerRecv::processWalkResponse(Net::MessageIn &msg)
149
{
150
    BLOCK_START("PlayerRecv::processWalkResponse")
151
    /*
152
      * This client assumes that all walk messages succeed,
153
      * and that the server will send a correction notice
154
      * otherwise.
155
      */
156
    uint16_t srcX, srcY, dstX, dstY;
157
    msg.readInt32("tick");
158
    msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
159
    msg.readUInt8("unused");
160
    if (localPlayer != nullptr)
161
        localPlayer->setRealPos(dstX, dstY);
162
    BLOCK_END("PlayerRecv::processWalkResponse")
163
}
164
165
4
}  // namespace TmwAthena