GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/tmwa/playerrecv.cpp Lines: 1 87 1.1 %
Date: 2018-09-09 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-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/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
        Notify_true);
43
44
    unsigned int val = msg.readUInt8("str");
45
    PlayerInfo::setStatBase(Attributes::PLAYER_STR, val, Notify_true);
46
    if (statusWindow != nullptr)
47
    {
48
        statusWindow->setPointsNeeded(Attributes::PLAYER_STR,
49
            msg.readUInt8("str cost"));
50
    }
51
    else
52
    {
53
        msg.readUInt8("str cost");
54
    }
55
56
    val = msg.readUInt8("agi");
57
    PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val, Notify_true);
58
    if (statusWindow != nullptr)
59
    {
60
        statusWindow->setPointsNeeded(Attributes::PLAYER_AGI,
61
            msg.readUInt8("agi cost"));
62
    }
63
    else
64
    {
65
        msg.readUInt8("agi cost");
66
    }
67
68
    val = msg.readUInt8("vit");
69
    PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val, Notify_true);
70
    if (statusWindow != nullptr)
71
    {
72
        statusWindow->setPointsNeeded(Attributes::PLAYER_VIT,
73
            msg.readUInt8("vit cost"));
74
    }
75
    else
76
    {
77
        msg.readUInt8("vit cost");
78
    }
79
80
    val = msg.readUInt8("int");
81
    PlayerInfo::setStatBase(Attributes::PLAYER_INT, val, Notify_true);
82
    if (statusWindow != nullptr)
83
    {
84
        statusWindow->setPointsNeeded(Attributes::PLAYER_INT,
85
            msg.readUInt8("int cost"));
86
    }
87
    else
88
    {
89
        msg.readUInt8("int cost");
90
    }
91
92
    val = msg.readUInt8("dex");
93
    PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val, Notify_true);
94
    if (statusWindow != nullptr)
95
    {
96
        statusWindow->setPointsNeeded(Attributes::PLAYER_DEX,
97
            msg.readUInt8("dex cost"));
98
    }
99
    else
100
    {
101
        msg.readUInt8("dex cost");
102
    }
103
104
    val = msg.readUInt8("luk");
105
    PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val, Notify_true);
106
    if (statusWindow != nullptr)
107
    {
108
        statusWindow->setPointsNeeded(Attributes::PLAYER_LUK,
109
            msg.readUInt8("luk cost"));
110
    }
111
    else
112
    {
113
        msg.readUInt8("luk cost");
114
    }
115
116
    PlayerInfo::setStatBase(Attributes::PLAYER_ATK,
117
        msg.readInt16("atk"),
118
        Notify_false);
119
    PlayerInfo::setStatMod(Attributes::PLAYER_ATK,
120
        msg.readInt16("atk+"),
121
        Notify_true);
122
    PlayerInfo::updateAttrs();
123
124
    val = msg.readInt16("matk");
125
    PlayerInfo::setStatBase(Attributes::PLAYER_MATK, val, Notify_false);
126
127
    val = msg.readInt16("matk+");
128
    PlayerInfo::setStatMod(Attributes::PLAYER_MATK,
129
        val,
130
        Notify_true);
131
132
    PlayerInfo::setStatBase(Attributes::PLAYER_DEF,
133
        msg.readInt16("def"),
134
        Notify_false);
135
    PlayerInfo::setStatMod(Attributes::PLAYER_DEF,
136
        msg.readInt16("def+"),
137
        Notify_true);
138
139
    PlayerInfo::setStatBase(Attributes::PLAYER_MDEF,
140
        msg.readInt16("mdef"),
141
        Notify_false);
142
    PlayerInfo::setStatMod(Attributes::PLAYER_MDEF,
143
        msg.readInt16("mdef+"),
144
        Notify_true);
145
146
    PlayerInfo::setStatBase(Attributes::PLAYER_HIT,
147
        msg.readInt16("hit"),
148
        Notify_true);
149
150
    PlayerInfo::setStatBase(Attributes::PLAYER_FLEE,
151
        msg.readInt16("flee"),
152
        Notify_false);
153
    PlayerInfo::setStatMod(Attributes::PLAYER_FLEE,
154
        msg.readInt16("flee+"),
155
        Notify_true);
156
157
    PlayerInfo::setStatBase(Attributes::PLAYER_CRIT,
158
        msg.readInt16("crit"),
159
        Notify_true);
160
161
    PlayerInfo::setStatBase(Attributes::PLAYER_MANNER,
162
        msg.readInt16("manner"),
163
        Notify_true);
164
    msg.readInt16("unused?");
165
    BLOCK_END("PlayerRecv::processPlayerStatUpdate5")
166
}
167
168
void PlayerRecv::processWalkResponse(Net::MessageIn &msg)
169
{
170
    BLOCK_START("PlayerRecv::processWalkResponse")
171
    /*
172
      * This client assumes that all walk messages succeed,
173
      * and that the server will send a correction notice
174
      * otherwise.
175
      */
176
    uint16_t srcX, srcY, dstX, dstY;
177
    msg.readInt32("tick");
178
    msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
179
    msg.readUInt8("unused");
180
    if (localPlayer != nullptr)
181
        localPlayer->setRealPos(dstX, dstY);
182
    BLOCK_END("PlayerRecv::processWalkResponse")
183
}
184
185
2
}  // namespace TmwAthena