GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/questrecv.cpp Lines: 0 141 0.0 %
Date: 2018-12-09 Branches: 0 58 0.0 %

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