summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-06-25 01:00:00 +0200
committerHaru <haru@dotalux.com>2018-06-30 01:51:12 +0200
commit8b68532c0858889fe734b85c46c89a67ba832195 (patch)
tree73be7806b65733879fa80a6046cae42694162ee9
parent7772ec2ad36d01b7a73ab320ac740eb99f7eafbf (diff)
downloadhercules-8b68532c0858889fe734b85c46c89a67ba832195.tar.gz
hercules-8b68532c0858889fe734b85c46c89a67ba832195.tar.bz2
hercules-8b68532c0858889fe734b85c46c89a67ba832195.tar.xz
hercules-8b68532c0858889fe734b85c46c89a67ba832195.zip
Move mapif functions from int_quest.c to mapif.c
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r--src/char/int_quest.c73
-rw-r--r--src/char/mapif.c79
2 files changed, 75 insertions, 77 deletions
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index 7b89ddf01..afd01579e 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -200,15 +200,6 @@ bool inter_quest_update(int char_id, struct quest qd)
return true;
}
-void mapif_quest_save_ack(int fd, int char_id, bool success)
-{
- WFIFOHEAD(fd,7);
- WFIFOW(fd,0) = 0x3861;
- WFIFOL(fd,2) = char_id;
- WFIFOB(fd,6) = success?1:0;
- WFIFOSET(fd,7);
-}
-
bool inter_quest_save(int char_id, const struct quest *new_qd, int new_n)
{
int i, j, k, old_n;
@@ -248,70 +239,6 @@ bool inter_quest_save(int char_id, const struct quest *new_qd, int new_n)
}
/**
- * Handles the save request from mapserver for a character's questlog.
- *
- * Received quests are saved, and an ack is sent back to the map server.
- *
- * @see inter_parse_frommap
- */
-int mapif_parse_quest_save(int fd)
-{
- int num = (RFIFOW(fd, 2) - 8) / sizeof(struct quest);
- int char_id = RFIFOL(fd, 4);
- const struct quest *qd = NULL;
- bool success;
-
- if (num > 0)
- qd = RFIFOP(fd,8);
-
- success = inter_quest->save(char_id, qd, num);
-
- // Send ack
- mapif->quest_save_ack(fd, char_id, success);
-
- return 0;
-}
-
-void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests)
-{
- WFIFOHEAD(fd,num_quests*sizeof(struct quest)+8);
- WFIFOW(fd,0) = 0x3860;
- WFIFOW(fd,2) = num_quests*sizeof(struct quest)+8;
- WFIFOL(fd,4) = char_id;
-
- if (num_quests > 0) {
- nullpo_retv(tmp_questlog);
- memcpy(WFIFOP(fd,8), tmp_questlog, sizeof(struct quest)*num_quests);
- }
-
- WFIFOSET(fd,num_quests*sizeof(struct quest)+8);
-}
-
-/**
- * Sends questlog to the map server
- *
- * Note: Completed quests (state == Q_COMPLETE) are guaranteed to be sent last
- * and the map server relies on this behavior (once the first Q_COMPLETE quest,
- * all of them are considered to be Q_COMPLETE)
- *
- * @see inter_parse_frommap
- */
-int mapif_parse_quest_load(int fd)
-{
- int char_id = RFIFOL(fd,2);
- struct quest *tmp_questlog = NULL;
- int num_quests;
-
- tmp_questlog = inter_quest->fromsql(char_id, &num_quests);
- mapif->send_quests(fd, char_id, tmp_questlog, num_quests);
-
- if (tmp_questlog)
- aFree(tmp_questlog);
-
- return 0;
-}
-
-/**
* Parses questlog related packets from the map server.
*
* @see inter_parse_frommap
diff --git a/src/char/mapif.c b/src/char/mapif.c
index 6eb608204..cb2cb381f 100644
--- a/src/char/mapif.c
+++ b/src/char/mapif.c
@@ -32,9 +32,11 @@
#include "char/int_mercenary.h"
#include "char/int_party.h"
#include "char/int_pet.h"
+#include "char/int_quest.h"
#include "char/int_rodex.h"
#include "char/inter.h"
#include "common/cbasetypes.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/random.h"
@@ -1556,10 +1558,79 @@ int mapif_parse_DeletePet(int fd)
return 0;
}
-void mapif_quest_save_ack(int fd, int char_id, bool success);
-int mapif_parse_quest_save(int fd);
-void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests);
-int mapif_parse_quest_load(int fd);
+void mapif_quest_save_ack(int fd, int char_id, bool success)
+{
+ WFIFOHEAD(fd, 7);
+ WFIFOW(fd, 0) = 0x3861;
+ WFIFOL(fd, 2) = char_id;
+ WFIFOB(fd, 6) = success ? 1 : 0;
+ WFIFOSET(fd, 7);
+}
+
+/**
+ * Handles the save request from mapserver for a character's questlog.
+ *
+ * Received quests are saved, and an ack is sent back to the map server.
+ *
+ * @see inter_parse_frommap
+ */
+int mapif_parse_quest_save(int fd)
+{
+ int num = (RFIFOW(fd, 2) - 8) / sizeof(struct quest);
+ int char_id = RFIFOL(fd, 4);
+ const struct quest *qd = NULL;
+ bool success;
+
+ if (num > 0)
+ qd = RFIFOP(fd,8);
+
+ success = inter_quest->save(char_id, qd, num);
+
+ // Send ack
+ mapif->quest_save_ack(fd, char_id, success);
+
+ return 0;
+}
+
+void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests)
+{
+ WFIFOHEAD(fd,num_quests*sizeof(struct quest) + 8);
+ WFIFOW(fd, 0) = 0x3860;
+ WFIFOW(fd, 2) = num_quests*sizeof(struct quest) + 8;
+ WFIFOL(fd, 4) = char_id;
+
+ if (num_quests > 0) {
+ nullpo_retv(tmp_questlog);
+ memcpy(WFIFOP(fd, 8), tmp_questlog, sizeof(struct quest) * num_quests);
+ }
+
+ WFIFOSET(fd, num_quests * sizeof(struct quest) + 8);
+}
+
+/**
+ * Sends questlog to the map server
+ *
+ * Note: Completed quests (state == Q_COMPLETE) are guaranteed to be sent last
+ * and the map server relies on this behavior (once the first Q_COMPLETE quest,
+ * all of them are considered to be Q_COMPLETE)
+ *
+ * @see inter_parse_frommap
+ */
+int mapif_parse_quest_load(int fd)
+{
+ int char_id = RFIFOL(fd,2);
+ struct quest *tmp_questlog = NULL;
+ int num_quests;
+
+ tmp_questlog = inter_quest->fromsql(char_id, &num_quests);
+ mapif->send_quests(fd, char_id, tmp_questlog, num_quests);
+
+ if (tmp_questlog != NULL)
+ aFree(tmp_questlog);
+
+ return 0;
+}
+
/* RoDEX */
int mapif_parse_rodex_requestinbox(int fd);
void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails);