GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/questrecv.cpp Lines: 0 103 0.0 %
Date: 2017-11-29 Branches: 0 38 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2012-2017  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
        msg.readInt32("monster id");
46
        msg.readInt16("count");
47
        msg.readString(24, "monster name");
48
    }
49
50
    msg.skipToEnd("unused");
51
52
    if (questsWindow != nullptr)
53
    {
54
        questsWindow->updateQuest(var, val, 0, 0, 0);
55
        questsWindow->rebuild(true);
56
    }
57
    if (skillDialog != nullptr)
58
    {
59
        skillDialog->updateQuest(var, val, 0, 0, 0);
60
        skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
61
    }
62
}
63
64
void QuestRecv::processAddQuest2(Net::MessageIn &msg)
65
{
66
    const int var = msg.readInt32("quest id");
67
    msg.readUInt8("state");
68
    const int val1 = msg.readInt32("count1");
69
    const int val2 = msg.readInt32("count2");
70
    const int val3 = msg.readInt32("count3");
71
    const int time = msg.readInt32("time");
72
73
    if (questsWindow != nullptr)
74
    {
75
        questsWindow->updateQuest(var, val1, val2, val3, time);
76
        questsWindow->rebuild(true);
77
    }
78
    if (skillDialog != nullptr)
79
    {
80
        skillDialog->updateQuest(var, val1, val2, val3, time);
81
        skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
82
    }
83
}
84
85
void QuestRecv::processAddQuests(Net::MessageIn &msg)
86
{
87
    msg.readInt16("len");
88
    const int num = msg.readInt32("quests count");
89
    for (int f = 0; f < num; f ++)
90
    {
91
        const int var = msg.readInt32("quest id");
92
        const int val = msg.readUInt8("state");
93
        if (msg.getVersion() >= 20141022)
94
        {
95
            msg.readInt32("time diff");
96
            msg.readInt32("time");
97
            msg.readInt16("objectives count");
98
        }
99
        if (questsWindow != nullptr)
100
            questsWindow->updateQuest(var, val, 0, 0, 0);
101
        if (skillDialog != nullptr)
102
            skillDialog->updateQuest(var, val, 0, 0, 0);
103
    }
104
105
    if (questsWindow != nullptr)
106
        questsWindow->rebuild(false);
107
}
108
109
void QuestRecv::processAddQuests2(Net::MessageIn &msg)
110
{
111
    msg.readInt16("len");
112
    const int num = msg.readInt32("quests count");
113
    for (int f = 0; f < num; f ++)
114
    {
115
        const int var = msg.readInt32("quest id");
116
        msg.readUInt8("state");
117
        const int val1 = msg.readInt32("count1");
118
        const int val2 = msg.readInt32("count2");
119
        const int val3 = msg.readInt32("count3");
120
        const int time = msg.readInt32("time");
121
        if (questsWindow != nullptr)
122
            questsWindow->updateQuest(var, val1, val2, val3, time);
123
        if (skillDialog != nullptr)
124
            skillDialog->updateQuest(var, val1, val2, val3, time);
125
    }
126
127
    if (questsWindow != nullptr)
128
        questsWindow->rebuild(false);
129
}
130
131
void QuestRecv::processAddQuestsObjectives(Net::MessageIn &msg)
132
{
133
    msg.readInt16("len");
134
    const int quests = msg.readInt32("quests count");
135
    for (int f = 0; f < quests; f ++)
136
    {
137
        msg.readInt32("quest id");
138
        msg.readInt32("time diff");
139
        msg.readInt32("time");
140
        const int num = msg.readInt16("objectives count");
141
        for (int d = 0; d < num; d ++)
142
        {
143
            // need use in quests kills list
144
            msg.readInt32("monster id");
145
            msg.readInt16("count");
146
            msg.readString(24, "monster name");
147
        }
148
    }
149
    msg.skipToEnd("unused");
150
}
151
152
void QuestRecv::processUpdateQuestsObjectives(Net::MessageIn &msg)
153
{
154
    // ignored
155
    msg.readInt16("len");
156
    const int num = msg.readInt16("objectives count");
157
    for (int f = 0; f < num; f ++)
158
    {
159
        msg.readInt32("quest id");
160
        msg.readInt32("monster id");
161
        msg.readInt16("count old");
162
        msg.readInt16("count new");
163
    }
164
}
165
166
void QuestRecv::processRemoveQuest(Net::MessageIn &msg)
167
{
168
    const int var = msg.readInt32("quest id");
169
    const int val = -1;
170
171
    // not removing quest, because this is impossible,
172
    // but changing status to -1
173
    if (questsWindow != nullptr)
174
    {
175
        questsWindow->updateQuest(var, val, 0, 0, 0);
176
        questsWindow->rebuild(true);
177
    }
178
    if (skillDialog != nullptr)
179
    {
180
        skillDialog->updateQuest(var, val, 0, 0, 0);
181
        skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
182
    }
183
}
184
185
void QuestRecv::processActivateQuest(Net::MessageIn &msg)
186
{
187
    UNIMPLEMENTEDPACKET;
188
    // +++ need enable/disable quests depend on this packet
189
    msg.readInt32("quest id");
190
    msg.readUInt8("activate");
191
}
192
193
void QuestRecv::processNpcQuestEffect(Net::MessageIn &msg)
194
{
195
    UNIMPLEMENTEDPACKET;
196
    // this packed mostly useless, because manaplus can show any
197
    // kind of effects based on quest states.
198
    msg.readInt32("npc id");
199
    msg.readInt16("x");
200
    msg.readInt16("y");
201
    msg.readInt16("state");
202
    msg.readInt16("color");
203
}
204
205
}  // namespace EAthena