summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/intif.c59
-rw-r--r--src/map/intif.h4
-rw-r--r--src/map/quest.c81
-rw-r--r--src/map/quest.h5
4 files changed, 141 insertions, 8 deletions
diff --git a/src/map/intif.c b/src/map/intif.c
index b0013aa52..0ce0aa8c1 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -20,6 +20,7 @@
#include "atcommand.h"
#include "mercenary.h" //albator
#include "mail.h"
+#include "quest.h"
#include <sys/types.h>
#include <stdio.h>
@@ -36,7 +37,7 @@ static const int packet_len_table[]={
10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830
9, 9,-1,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840
-1,-1, 7, 7, 7,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus]
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin]
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
-1,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator]
@@ -1398,7 +1399,58 @@ int intif_parse_DeleteHomunculusOk(int fd)
return 0;
}
+/**************************************
+
+QUESTLOG SYSTEM FUNCTIONS
+
+***************************************/
+
+int intif_parse_questDelete(int fd)
+{
+ quest_delete_ack(RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOB(fd, 10));
+ return 0;
+}
+
+int intif_quest_delete(int char_id, int quest_id)
+{
+ if(CheckForCharServer())
+ return 0;
+
+ WFIFOHEAD(inter_fd, 10);
+ WFIFOW(inter_fd,0) = 0x3062;
+ WFIFOL(inter_fd,2) = char_id;
+ WFIFOL(inter_fd,6) = quest_id;
+ WFIFOSET(inter_fd, 10);
+
+ return 0;
+}
+
+int intif_parse_questAdd(int fd)
+{
+ quest_add_ack(RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOB(fd, 10));
+ return 0;
+}
+
+int intif_quest_add(int char_id, struct quest * qd)
+{
+
+ int sSize = sizeof(struct quest);
+
+ if(CheckForCharServer())
+ return 0;
+
+ WFIFOHEAD(inter_fd, sSize + 8);
+ WFIFOW(inter_fd,0) = 0x3061;
+ WFIFOW(inter_fd,2) = sSize + 8;
+ WFIFOL(inter_fd,4) = char_id;
+ memcpy(WFIFOP(inter_fd,8), qd, sSize);
+ WFIFOSET(inter_fd, sSize + 8);
+
+ return 0;
+}
+
#ifndef TXT_ONLY
+
/*==========================================
* MAIL SYSTEM
* By Zephyrus
@@ -1938,6 +1990,11 @@ int intif_parse(int fd)
case 0x3841: intif_parse_GuildCastleDataSave(fd); break;
case 0x3842: intif_parse_GuildCastleAllDataLoad(fd); break;
case 0x3843: intif_parse_GuildMasterChanged(fd); break;
+
+ //Quest system
+ case 0x3861: intif_parse_questAdd(fd); break;
+ case 0x3862: intif_parse_questDelete(fd); break;
+
#ifndef TXT_ONLY
// Mail System
case 0x3848: intif_parse_Mail_inboxreceived(fd); break;
diff --git a/src/map/intif.h b/src/map/intif.h
index a713be7ea..1827ec00a 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -75,6 +75,10 @@ int intif_homunculus_requestload(int account_id, int homun_id);
int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh);
int intif_homunculus_requestdelete(int homun_id);
+/******QUEST SYTEM*******/
+int intif_quest_delete(int char_id, int quest_id);
+int intif_quest_add(int char_id, struct quest * qd);
+
#ifndef TXT_ONLY
// MAIL SYSTEM
int intif_Mail_requestinbox(int char_id, unsigned char flag);
diff --git a/src/map/quest.c b/src/map/quest.c
index 997ff2abd..25c879105 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -25,6 +25,7 @@
#include "log.h"
#include "clif.h"
#include "quest.h"
+#include "intif.h"
#include <stdio.h>
#include <stdlib.h>
@@ -67,13 +68,46 @@ int quest_add(TBL_PC * sd, struct quest * qd)
memcpy(&sd->quest_log[i], qd, sizeof(struct quest));
sd->num_quests++;
- //Notify client
- clif_send_quest_info(sd, &sd->quest_log[i]);
+ //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)
{
@@ -83,14 +117,47 @@ int quest_delete(TBL_PC * sd, int quest_id)
ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == quest_id);
//Quest not found
- if(i != MAX_QUEST)
+ if(i == MAX_QUEST)
return -1;
- //Zero quest
- memset(&sd->quest_log[i], 0, sizeof(struct quest));
+ intif_quest_delete(sd->status.char_id, quest_id);
- //Notify client
- clif_send_quest_delete(sd, 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;
diff --git a/src/map/quest.h b/src/map/quest.h
index deda985ca..269c58bee 100644
--- a/src/map/quest.h
+++ b/src/map/quest.h
@@ -7,8 +7,13 @@
int quest_pc_login(TBL_PC * sd);
int quest_load_info(TBL_PC * sd, struct mmo_charstatus * st);
int quest_make_savedata(TBL_PC * sd);
+
int quest_add(TBL_PC * sd, struct quest * qd);
+int quest_add_ack(int char_id, int quest_id, int success);
+
int quest_delete(TBL_PC * sd, int quest_id);
+int quest_delete_ack(int char_id, int quest_id, int success);
+
int quest_update_objective(TBL_PC * sd, int quest_id, int objective_num, const char * name, int count);
int quest_update_status(TBL_PC * sd, int quest_id, bool status);