GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/npcrecv.cpp Lines: 1 50 2.0 %
Date: 2017-11-29 Branches: 0 16 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/npcrecv.h"
22
23
#include "actormanager.h"
24
25
#include "being/being.h"
26
27
#include "gui/windows/cutinwindow.h"
28
#include "gui/windows/npcdialog.h"
29
30
#include "net/messagein.h"
31
#include "net/npchandler.h"
32
33
#include "net/ea/npcrecv.h"
34
35
#include "debug.h"
36
37
namespace EAthena
38
{
39
40
namespace NpcRecv
41
{
42
    BeingTypeId mNpcTypeId = BeingTypeId_zero;
43
}  // namespace NpcRecv
44
45
void NpcRecv::processNpcCutin(Net::MessageIn &msg)
46
{
47
    Ea::NpcRecv::mRequestLang = false;
48
    if (cutInWindow == nullptr)
49
    {
50
        msg.readString(64, "image name");
51
        msg.readUInt8("type");
52
        return;
53
    }
54
    const std::string image = msg.readString(64, "image name");
55
    const CutInT cutin = static_cast<CutInT>(msg.readUInt8("type"));
56
    if (cutInWindow != nullptr)
57
        cutInWindow->show(image, cutin);
58
}
59
60
void NpcRecv::processNpcViewPoint(Net::MessageIn &msg)
61
{
62
    UNIMPLEMENTEDPACKET;
63
    Ea::NpcRecv::mRequestLang = false;
64
    // +++ probably need add nav point and start moving to it
65
    msg.readInt32("npc id");
66
    msg.readInt32("type");  // 0 display for 15 sec,
67
                            // 1 display until teleport,
68
                            // 2 remove
69
    msg.readInt32("x");
70
    msg.readInt32("y");
71
    msg.readUInt8("number");  // can be used for scripts
72
    msg.readInt32("color");
73
}
74
75
void NpcRecv::processNpcShowProgressBar(Net::MessageIn &msg)
76
{
77
    UNIMPLEMENTEDPACKET;
78
    Ea::NpcRecv::mRequestLang = false;
79
    // +++ probably need show progress bar in npc dialog
80
    msg.readInt32("color");
81
    msg.readInt32("seconds");
82
}
83
84
void NpcRecv::processNpcCloseTimeout(Net::MessageIn &msg)
85
{
86
    UNIMPLEMENTEDPACKET;
87
    Ea::NpcRecv::mRequestLang = false;
88
    // this packet send after npc closed by timeout.
89
    msg.readInt32("npc id");
90
}
91
92
void NpcRecv::processArea(Net::MessageIn &msg)
93
{
94
    const int len = msg.readInt16("len");
95
    if (len < 12)
96
        return;
97
    Being *const dstBeing = actorManager->findBeing(
98
        msg.readBeingId("npc id"));
99
    const int area = msg.readInt32("area size");
100
    if (dstBeing != nullptr)
101
        dstBeing->setAreaSize(area);
102
}
103
104
void NpcRecv::processShowDigit(Net::MessageIn &msg)
105
{
106
    UNIMPLEMENTEDPACKET;
107
108
    msg.readUInt8("type");
109
    msg.readInt32("value");
110
}
111
112
void NpcRecv::processProgressBarAbort(Net::MessageIn &msg)
113
{
114
    UNIMPLEMENTEDPACKET;
115
}
116
117
void NpcRecv::processNpcSkin(Net::MessageIn &msg)
118
{
119
    const int len = msg.readInt16("len");
120
    npcHandler->getNpc(msg, NpcAction::Other);
121
    if (Ea::NpcRecv::mDialog != nullptr)
122
    {
123
        const std::string skin = msg.readString(len - 8, "skin");
124
        Ea::NpcRecv::mDialog->setSkin(skin);
125
    }
126
    else
127
    {
128
        msg.readString(len - 8, "skin");
129
    }
130
}
131
132
4
}  // namespace EAthena