1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "../common/cbasetypes.h"
#include "../common/socket.h"
#include "../common/timer.h"
#include "../common/malloc.h"
#include "../common/version.h"
#include "../common/nullpo.h"
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/utils.h"
#include "map.h"
#include "chrif.h"
#include "pc.h"
#include "npc.h"
#include "itemdb.h"
#include "script.h"
#include "intif.h"
#include "battle.h"
#include "mob.h"
#include "party.h"
#include "unit.h"
#include "log.h"
#include "clif.h"
#include "quest.h"
#include "intif.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
//Send quest info on login
int quest_pc_login(TBL_PC * sd)
{
if(sd->num_quests == 0)
return 1;
clif_send_questlog(sd);
clif_send_questlog_info(sd);
return 0;
}
int quest_add(TBL_PC * sd, struct quest * qd)
{
int i;
//Search to see if this quest exists
ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == qd->quest_id);
//Already have this quest
if(i!=MAX_QUEST)
return 1;
//Find empty quest log spot
ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == 0);
//Quest log is full
if(i == MAX_QUEST)
return -1;
//Copy over quest data
memcpy(&sd->quest_log[i], qd, sizeof(struct quest));
sd->num_quests++;
//Notify inter server
intif_quest_add(sd->status.char_id, qd);
return 0;
}
int quest_add_ack(int char_id, int quest_id, int success)
{
int i;
TBL_PC * sd = map_charid2sd(char_id);
///Player no longer on map
if(!sd)
return -1;
//Search for quest
ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == quest_id);
//Quest not found, shouldn't happen?
if(i == MAX_QUEST)
return -1;
if(success)
{
//Notify client
clif_send_quest_info(sd, &sd->quest_log[i]);
}
else
{
ShowError("Quest %d for character %d could not be added!\n", quest_id, char_id);
//Zero quest
memset(&sd->quest_log[i], 0, sizeof(struct quest));
sd->num_quests--;
}
return 0;
}
int quest_delete(TBL_PC * sd, int quest_id)
{
int i;
//Search for quest
ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == quest_id);
//Quest not found
if(i == MAX_QUEST)
return -1;
intif_quest_delete(sd->status.char_id, quest_id);
return 0;
}
int quest_delete_ack(int char_id, int quest_id, int success)
{
int i;
TBL_PC * sd = map_charid2sd(char_id);
///Player no longer on map
if(!sd)
return -1;
//Search for quest
ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == quest_id);
//Quest not found
if(i == MAX_QUEST)
return -1;
if(success)
{
//Zero quest
memset(&sd->quest_log[i], 0, sizeof(struct quest));
sd->num_quests--;
//Notify client
clif_send_quest_delete(sd, quest_id);
return 1;
}
else
ShowError("Quest %d for character %d could not be deleted!\n", quest_id, char_id);
return 0;
}
int quest_update_objective(TBL_PC * sd, int quest_id, int objective_num, const char * name, int count)
{
int i;
//Search for quest
ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == quest_id);
//Quest not found
if(i == MAX_QUEST)
return -1;
memcpy(&sd->quest_log[i].objectives[objective_num].name, name, NAME_LENGTH);
sd->quest_log[i].objectives[objective_num].count = count;
//Notify client
clif_send_quest_info(sd, &sd->quest_log[i]);
return 0;
}
bool quest_has_quest(TBL_PC * sd, int quest_id)
{
int i;
ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == quest_id);
return (i != MAX_QUEST);
}
int quest_update_status(TBL_PC * sd, int quest_id, bool status)
{
return 0;
}
|