ManaPlus
npcrecv.cpp
Go to the documentation of this file.
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 
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 {
44 } // namespace NpcRecv
45 
47 {
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 
62 {
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 
77 {
80  // +++ probably need show progress bar in npc dialog
81  msg.readInt32("color");
82  msg.readInt32("seconds");
83 }
84 
86 {
89  msg.readBeingId("account id");
90  msg.readInt32("color");
91  msg.readInt32("time");
92 }
93 
95 {
98  // this packet send after npc closed by timeout.
99  msg.readInt32("npc id");
100 }
101 
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 
117 {
119 
120  msg.readUInt8("type");
121  msg.readInt32("value");
122 }
123 
125 {
127 }
128 
130 {
131  const int len = msg.readInt16("len");
133  if (Ea::NpcRecv::mDialog != nullptr)
134  {
135  const std::string skin = msg.readString(len - 8, "skin");
137  }
138  else
139  {
140  msg.readString(len - 8, "skin");
141  }
142 }
143 
145 {
147  msg.readUInt32("flag");
148 }
149 
150 } // namespace EAthena
ActorManager * actorManager
int BeingTypeId
Definition: beingtypeid.h:30
const BeingTypeId BeingTypeId_zero
Definition: beingtypeid.h:30
Being * findBeing(const BeingId id) const
Definition: being.h:96
void setAreaSize(const int areaSize)
Definition: being.h:1052
void show(const std::string &name, const CutInT cutin)
Definition: cutinwindow.cpp:77
virtual BeingId getNpc(Net::MessageIn &msg, const NpcActionT action)=0
void setSkin(const std::string &skin)
Definition: npcdialog.cpp:1251
CutIn ::T CutInT
Definition: cutin.h:35
CutInWindow * cutInWindow
Definition: cutinwindow.cpp:37
#define UNIMPLEMENTEDPACKET
Definition: logger.h:56
bool msg(InputEvent &event)
Definition: chat.cpp:39
void processNpcCutin(Net::MessageIn &msg)
Definition: npcrecv.cpp:46
void processShowDigit(Net::MessageIn &msg)
Definition: npcrecv.cpp:116
void processNpcShowProgressBar(Net::MessageIn &msg)
Definition: npcrecv.cpp:76
void processNpcCloseTimeout(Net::MessageIn &msg)
Definition: npcrecv.cpp:94
void processProgressBarAbort(Net::MessageIn &msg)
Definition: npcrecv.cpp:124
void processArea(Net::MessageIn &msg)
Definition: npcrecv.cpp:102
void processNpcViewPoint(Net::MessageIn &msg)
Definition: npcrecv.cpp:61
void processNpcSkin(Net::MessageIn &msg)
Definition: npcrecv.cpp:129
void processShowProgressBarFree(Net::MessageIn &msg)
Definition: npcrecv.cpp:85
BeingTypeId mNpcTypeId
Definition: npcrecv.cpp:43
void processPrivateAirShipResponse(Net::MessageIn &msg)
Definition: npcrecv.cpp:144
NpcDialog * mDialog
Definition: npcrecv.cpp:42
bool mRequestLang
Definition: npcrecv.cpp:43
Net::NpcHandler * npcHandler
Definition: net.cpp:93