GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/questrecv.cpp Lines: 0 130 0.0 %
Date: 2018-05-19 03:07:18 Branches: 0 52 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() >= 20150513)
46
        {
47
            msg.readInt32("hunt ident");
48
            msg.readInt32("mob type");
49
        }
50
        msg.readInt32("mob id");
51
        if (msg.getVersion() >= 20150513)
52
        {
53
            msg.readInt16("level min");
54
            msg.readInt16("level max");
55
        }
56
        msg.readInt16("hunt count");
57
        msg.readInt16("max count");
58
        msg.readString(24, "mob name");
59
    }
60
61
    msg.skipToEnd("unused");
62
63
    if (questsWindow != nullptr)
64
    {
65
        questsWindow->updateQuest(var, val, 0, 0, 0);
66
        questsWindow->rebuild(true);
67
    }
68
    if (skillDialog != nullptr)
69
    {
70
        skillDialog->updateQuest(var, val, 0, 0, 0);
71
        skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
72
    }
73
}
74
75
void QuestRecv::processAddQuest2(Net::MessageIn &msg)
76
{
77
    const int var = msg.readInt32("quest id");
78
    msg.readUInt8("state");
79
    const int val1 = msg.readInt32("count1");
80
    const int val2 = msg.readInt32("count2");
81
    const int val3 = msg.readInt32("count3");
82
    const int time = msg.readInt32("time");
83
84
    if (questsWindow != nullptr)
85
    {
86
        questsWindow->updateQuest(var, val1, val2, val3, time);
87
        questsWindow->rebuild(true);
88
    }
89
    if (skillDialog != nullptr)
90
    {
91
        skillDialog->updateQuest(var, val1, val2, val3, time);
92
        skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
93
    }
94
}
95
96
void QuestRecv::processAddQuests(Net::MessageIn &msg)
97
{
98
    msg.readInt16("len");
99
    const int num = msg.readInt32("quests count");
100
    for (int f = 0; f < num; f ++)
101
    {
102
        const int var = msg.readInt32("quest id");
103
        const int val = msg.readUInt8("state");
104
        if (msg.getVersion() >= 20141022)
105
        {
106
            msg.readInt32("time diff");
107
            msg.readInt32("time");
108
            const int cnt = msg.readInt16("objectives count");
109
            for (int d = 0; d < cnt; d ++)
110
            {
111
                if (msg.getVersion() >= 20150513)
112
                {
113
                    msg.readInt32("hunt ident");
114
                    msg.readInt32("mob type");
115
                }
116
                msg.readInt32("mob id");
117
                if (msg.getVersion() >= 20150513)
118
                {
119
                    msg.readInt16("level min");
120
                    msg.readInt16("level max");
121
                }
122
                msg.readInt16("hunt count");
123
                msg.readInt16("max count");
124
                msg.readString(24, "mob name");
125
            }
126
        }
127
        if (questsWindow != nullptr)
128
            questsWindow->updateQuest(var, val, 0, 0, 0);
129
        if (skillDialog != nullptr)
130
            skillDialog->updateQuest(var, val, 0, 0, 0);
131
    }
132
133
    if (questsWindow != nullptr)
134
        questsWindow->rebuild(false);
135
}
136
137
void QuestRecv::processAddQuests2(Net::MessageIn &msg)
138
{
139
    msg.readInt16("len");
140
    const int num = msg.readInt32("quests count");
141
    for (int f = 0; f < num; f ++)
142
    {
143
        const int var = msg.readInt32("quest id");
144
        msg.readUInt8("state");
145
        const int val1 = msg.readInt32("count1");
146
        const int val2 = msg.readInt32("count2");
147
        const int val3 = msg.readInt32("count3");
148
        const int time = msg.readInt32("time");
149
        if (questsWindow != nullptr)
150
            questsWindow->updateQuest(var, val1, val2, val3, time);
151
        if (skillDialog != nullptr)
152
            skillDialog->updateQuest(var, val1, val2, val3, time);
153
    }
154
155
    if (questsWindow != nullptr)
156
        questsWindow->rebuild(false);
157
}
158
159
void QuestRecv::processAddQuestsObjectives(Net::MessageIn &msg)
160
{
161
    msg.readInt16("len");
162
    const int quests = msg.readInt32("quests count");
163
    for (int f = 0; f < quests; f ++)
164
    {
165
        msg.readInt32("quest id");
166
        msg.readInt32("time diff");
167
        msg.readInt32("time");
168
        const int num = msg.readInt16("objectives count");
169
        for (int d = 0; d < num; d ++)
170
        {
171
            // need use in quests kills list
172
            msg.readInt32("monster id");
173
            msg.readInt16("count");
174
            msg.readString(24, "monster name");
175
        }
176
    }
177
    msg.skipToEnd("unused");
178
}
179
180
void QuestRecv::processUpdateQuestsObjectives(Net::MessageIn &msg)
181
{
182
    // ignored
183
    msg.readInt16("len");
184
    const int num = msg.readInt16("objectives count");
185
    for (int f = 0; f < num; f ++)
186
    {
187
        msg.readInt32("quest id");
188
        if (msg.getVersion() >= 20150513)
189
            msg.readInt32("hunt ident");
190
        else
191
            msg.readInt32("monster id");
192
        msg.readInt16("count old");
193
        msg.readInt16("count new");
194
    }
195
}
196
197
void QuestRecv::processUpdateQuestsObjectives2(Net::MessageIn &msg)
198
{
199
    // ignored
200
    const int num = (msg.readInt16("len") - 4) / 12;
201
    for (int f = 0; f < num; f ++)
202
    {
203
        msg.readInt32("quest id");
204
        msg.readInt32("monster id");
205
        msg.readInt16("max count");
206
        msg.readInt16("count");
207
    }
208
}
209
210
void QuestRecv::processRemoveQuest(Net::MessageIn &msg)
211
{
212
    const int var = msg.readInt32("quest id");
213
    const int val = -1;
214
215
    // not removing quest, because this is impossible,
216
    // but changing status to -1
217
    if (questsWindow != nullptr)
218
    {
219
        questsWindow->updateQuest(var, val, 0, 0, 0);
220
        questsWindow->rebuild(true);
221
    }
222
    if (skillDialog != nullptr)
223
    {
224
        skillDialog->updateQuest(var, val, 0, 0, 0);
225
        skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
226
    }
227
}
228
229
void QuestRecv::processActivateQuest(Net::MessageIn &msg)
230
{
231
    UNIMPLEMENTEDPACKET;
232
    // +++ need enable/disable quests depend on this packet
233
    msg.readInt32("quest id");
234
    msg.readUInt8("activate");
235
}
236
237
void QuestRecv::processNpcQuestEffect(Net::MessageIn &msg)
238
{
239
    UNIMPLEMENTEDPACKET;
240
    // this packed mostly useless, because manaplus can show any
241
    // kind of effects based on quest states.
242
    msg.readInt32("npc id");
243
    msg.readInt16("x");
244
    msg.readInt16("y");
245
    msg.readInt16("state");
246
    msg.readInt16("color");
247
}
248
249
}  // namespace EAthena