ManaPlus
questrecv.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2012-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/questrecv.h"
23 
26 
27 #include "net/messagein.h"
28 
29 #include "const/resources/skill.h"
30 
31 #include "debug.h"
32 
33 namespace EAthena
34 {
35 
37 {
38  const int var = msg.readInt32("quest id");
39  const int val = msg.readUInt8("state");
40  msg.readUInt8("time diff");
41  msg.readInt32("time");
42  const int num = msg.readInt16("objectives count");
43  for (int f = 0; f < num; f ++)
44  {
45  // need use in quests kills list
46  if (msg.getVersion() >= 20181010)
47  {
48  msg.readInt32("hunt ident");
49  msg.readInt32("hunt ident2");
50  msg.readInt32("mob type");
51  }
52  else if (msg.getVersion() >= 20150513)
53  {
54  msg.readInt32("hunt ident");
55  msg.readInt32("mob type");
56  }
57  msg.readInt32("mob id");
58  if (msg.getVersion() >= 20150513)
59  {
60  msg.readInt16("level min");
61  msg.readInt16("level max");
62  }
63  msg.readInt16("hunt count");
64  msg.readInt16("max count");
65  msg.readString(24, "mob name");
66  }
67 
68  msg.skipToEnd("unused");
69 
70  if (questsWindow != nullptr)
71  {
72  questsWindow->updateQuest(var, val, 0, 0, 0);
73  questsWindow->rebuild(true);
74  }
75  if (skillDialog != nullptr)
76  {
77  skillDialog->updateQuest(var, val, 0, 0, 0);
79  }
80 }
81 
83 {
84  const int var = msg.readInt32("quest id");
85  msg.readUInt8("state");
86  const int val1 = msg.readInt32("count1");
87  const int val2 = msg.readInt32("count2");
88  const int val3 = msg.readInt32("count3");
89  const int time = msg.readInt32("time");
90 
91  if (questsWindow != nullptr)
92  {
93  questsWindow->updateQuest(var, val1, val2, val3, time);
94  questsWindow->rebuild(true);
95  }
96  if (skillDialog != nullptr)
97  {
98  skillDialog->updateQuest(var, val1, val2, val3, time);
100  }
101 }
102 
104 {
105  msg.readInt16("len");
106  const int num = msg.readInt32("quests count");
107  for (int f = 0; f < num; f ++)
108  {
109  const int var = msg.readInt32("quest id");
110  const int val = msg.readUInt8("state");
111  if (msg.getVersion() >= 20141022)
112  {
113  msg.readInt32("time diff");
114  msg.readInt32("time");
115  const int cnt = msg.readInt16("objectives count");
116  for (int d = 0; d < cnt; d ++)
117  {
118  if (msg.getVersion() >= 20181010)
119  {
120  msg.readInt32("hunt ident");
121  msg.readInt32("hunt ident2");
122  msg.readInt32("mob type");
123  }
124  else if (msg.getVersion() >= 20150513)
125  {
126  msg.readInt32("hunt ident");
127  msg.readInt32("mob type");
128  }
129  msg.readInt32("mob id");
130  if (msg.getVersion() >= 20150513)
131  {
132  msg.readInt16("level min");
133  msg.readInt16("level max");
134  }
135  msg.readInt16("hunt count");
136  msg.readInt16("max count");
137  msg.readString(24, "mob name");
138  }
139  }
140  if (questsWindow != nullptr)
141  questsWindow->updateQuest(var, val, 0, 0, 0);
142  if (skillDialog != nullptr)
143  skillDialog->updateQuest(var, val, 0, 0, 0);
144  }
145 
146  if (questsWindow != nullptr)
147  questsWindow->rebuild(false);
148 }
149 
151 {
152  msg.readInt16("len");
153  const int num = msg.readInt32("quests count");
154  for (int f = 0; f < num; f ++)
155  {
156  const int var = msg.readInt32("quest id");
157  msg.readUInt8("state");
158  const int val1 = msg.readInt32("count1");
159  const int val2 = msg.readInt32("count2");
160  const int val3 = msg.readInt32("count3");
161  const int time = msg.readInt32("time");
162  if (questsWindow != nullptr)
163  questsWindow->updateQuest(var, val1, val2, val3, time);
164  if (skillDialog != nullptr)
165  skillDialog->updateQuest(var, val1, val2, val3, time);
166  }
167 
168  if (questsWindow != nullptr)
169  questsWindow->rebuild(false);
170 }
171 
173 {
174  msg.readInt16("len");
175  const int quests = msg.readInt32("quests count");
176  for (int f = 0; f < quests; f ++)
177  {
178  msg.readInt32("quest id");
179  msg.readInt32("time diff");
180  msg.readInt32("time");
181  const int num = msg.readInt16("objectives count");
182  for (int d = 0; d < num; d ++)
183  {
184  // need use in quests kills list
185  msg.readInt32("monster id");
186  msg.readInt16("count");
187  msg.readString(24, "monster name");
188  }
189  }
190  msg.skipToEnd("unused");
191 }
192 
194 {
195  // ignored
196  msg.readInt16("len");
197  const int num = msg.readInt16("objectives count");
198  for (int f = 0; f < num; f ++)
199  {
200  msg.readInt32("quest id");
201  if (msg.getVersion() >= 20181010)
202  {
203  msg.readInt32("hunt ident");
204  msg.readInt32("hunt ident2");
205  }
206  else if (msg.getVersion() >= 20150513)
207  {
208  msg.readInt32("hunt ident");
209  }
210  else
211  {
212  msg.readInt32("monster id");
213  }
214  msg.readInt16("count old");
215  msg.readInt16("count new");
216  }
217 }
218 
220 {
221  // ignored
222  const int num = (msg.readInt16("len") - 4) / 12;
223  for (int f = 0; f < num; f ++)
224  {
225  msg.readInt32("quest id");
226  msg.readInt32("monster id");
227  msg.readInt16("max count");
228  msg.readInt16("count");
229  }
230 }
231 
233 {
234  const int var = msg.readInt32("quest id");
235  const int val = -1;
236 
237  // not removing quest, because this is impossible,
238  // but changing status to -1
239  if (questsWindow != nullptr)
240  {
241  questsWindow->updateQuest(var, val, 0, 0, 0);
242  questsWindow->rebuild(true);
243  }
244  if (skillDialog != nullptr)
245  {
246  skillDialog->updateQuest(var, val, 0, 0, 0);
248  }
249 }
250 
252 {
254  // +++ need enable/disable quests depend on this packet
255  msg.readInt32("quest id");
256  msg.readUInt8("activate");
257 }
258 
260 {
262  // this packed mostly useless, because manaplus can show any
263  // kind of effects based on quest states.
264  msg.readInt32("npc id");
265  msg.readInt16("x");
266  msg.readInt16("y");
267  msg.readInt16("state");
268  msg.readInt16("color");
269 }
270 
271 } // namespace EAthena
void updateQuest(const int var, const int val1, const int val2, const int val3, const int time1)
void rebuild(const bool playSound)
void updateQuest(const int var, const int val1, const int val2, const int val3, const int time1)
void playUpdateEffect(const int id) const
#define UNIMPLEMENTEDPACKET
Definition: logger.h:56
bool msg(InputEvent &event)
Definition: chat.cpp:39
void processAddQuestsObjectives(Net::MessageIn &msg)
Definition: questrecv.cpp:172
void processAddQuests(Net::MessageIn &msg)
Definition: questrecv.cpp:103
void processUpdateQuestsObjectives2(Net::MessageIn &msg)
Definition: questrecv.cpp:219
void processActivateQuest(Net::MessageIn &msg)
Definition: questrecv.cpp:251
void processAddQuest(Net::MessageIn &msg)
Definition: questrecv.cpp:36
void processRemoveQuest(Net::MessageIn &msg)
Definition: questrecv.cpp:232
void processAddQuests2(Net::MessageIn &msg)
Definition: questrecv.cpp:150
void processAddQuest2(Net::MessageIn &msg)
Definition: questrecv.cpp:82
void processUpdateQuestsObjectives(Net::MessageIn &msg)
Definition: questrecv.cpp:193
void processNpcQuestEffect(Net::MessageIn &msg)
Definition: questrecv.cpp:259
QuestsWindow * questsWindow
const unsigned int SKILL_VAR_MIN_ID
Definition: skill.h:26
SkillDialog * skillDialog
Definition: skilldialog.cpp:66