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