diff options
author | Kevin <Kevin@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-04-13 22:19:02 +0000 |
---|---|---|
committer | Kevin <Kevin@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-04-13 22:19:02 +0000 |
commit | e5242b4b3842fc94a60ad2f66284162948baefeb (patch) | |
tree | 8023e522ce29b67adb11c5db33dc0e71c27d04b1 /src/char_sql | |
parent | 40a44f83fc8c640412af6e4f227106eea9c17003 (diff) | |
download | hercules-e5242b4b3842fc94a60ad2f66284162948baefeb.tar.gz hercules-e5242b4b3842fc94a60ad2f66284162948baefeb.tar.bz2 hercules-e5242b4b3842fc94a60ad2f66284162948baefeb.tar.xz hercules-e5242b4b3842fc94a60ad2f66284162948baefeb.zip |
Major updates to the quest system.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12581 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r-- | src/char_sql/Makefile.in | 4 | ||||
-rw-r--r-- | src/char_sql/char.c | 72 | ||||
-rw-r--r-- | src/char_sql/char.h | 2 | ||||
-rw-r--r-- | src/char_sql/int_quest.c | 112 | ||||
-rw-r--r-- | src/char_sql/int_quest.h | 12 | ||||
-rw-r--r-- | src/char_sql/inter.c | 4 |
6 files changed, 132 insertions, 74 deletions
diff --git a/src/char_sql/Makefile.in b/src/char_sql/Makefile.in index ddc160e3f..63a53e9af 100644 --- a/src/char_sql/Makefile.in +++ b/src/char_sql/Makefile.in @@ -14,8 +14,8 @@ COMMON_SQL_OBJ = ../common/obj_sql/sql.o COMMON_H = ../common/sql.h CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \ - obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o -CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h + obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o +CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 9afd6b59d..2eca9b929 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -431,7 +431,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p) int diff = 0; char save_status[128]; //For displaying save information. [Skotlex] struct mmo_charstatus *cp; - StringBuf buf, buf2; + StringBuf buf; if (char_id!=p->char_id) return 0; @@ -644,76 +644,6 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p) strcat(save_status, " friends"); } - StringBuf_Clear(&buf); - StringBuf_Printf(&buf, "REPLACE INTO `%s` (`char_id`, `quest_id`, `state`) VALUES ", quest_db); - for(i=0; i<MAX_QUEST; i++) - { - - if(p->quest_log[i].quest_id) - { - if(diff) - StringBuf_AppendStr(&buf, ","); - StringBuf_Printf(&buf, "('%d', '%d', '%d')", p->char_id, p->quest_log[i].quest_id, p->quest_log[i].state); - diff = 1; - } - - } - - if(diff) { - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - Sql_ShowDebug(sql_handle); - else - strcat(save_status, " hotkeys"); - } - - //save quests - StringBuf_Init(&buf2); - StringBuf_Clear(&buf); - StringBuf_Clear(&buf2); - diff = 0; - StringBuf_Printf(&buf, "REPLACE INTO `%s` (`char_id`, `quest_id`, `state`) VALUES ", quest_db); - for(i=0; i<MAX_QUEST; i++) - { - - if(p->quest_log[i].quest_id) - { - if(diff) - StringBuf_AppendStr(&buf, ","); - StringBuf_Printf(&buf, "('%d', '%d', '%d')", p->char_id, p->quest_log[i].quest_id, p->quest_log[i].state); - diff = 1; - - StringBuf_Printf(&buf2, "REPLACE INTO `%s` (`quest_id`, `num`, `name`, `count`) VALUES ", quest_obj_db); - count = 0; - for(j=0; j<p->quest_log[i].num_objectives; j++) - { - - if(p->quest_log[i].objectives[j].name) - { - - if(count) - StringBuf_AppendStr(&buf2, ","); - StringBuf_Printf(&buf2, "('%d', '%d', '%s', '%d')", p->quest_log[i].quest_id, j, p->quest_log[i].objectives[j].name, p->quest_log[i].objectives[j].count); - count = 1; - - } - } - - if(count) { - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf2)) ) - Sql_ShowDebug(sql_handle); - } - } - } - - if(diff) { - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - Sql_ShowDebug(sql_handle); - else - strcat(save_status, " quests"); - } - - StringBuf_Destroy(&buf2); - #ifdef HOTKEY_SAVING // hotkeys StringBuf_Clear(&buf); diff --git a/src/char_sql/char.h b/src/char_sql/char.h index f44c40bea..19c6fcba5 100644 --- a/src/char_sql/char.h +++ b/src/char_sql/char.h @@ -59,6 +59,8 @@ extern char party_db[256]; extern char pet_db[256]; extern char mail_db[256]; extern char auction_db[256]; +extern char quest_db[256]; +extern char quest_obj_db[256]; extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris] diff --git a/src/char_sql/int_quest.c b/src/char_sql/int_quest.c new file mode 100644 index 000000000..49fb1533b --- /dev/null +++ b/src/char_sql/int_quest.c @@ -0,0 +1,112 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sql.h" +#include "../common/timer.h" + +#include "char.h" +#include "inter.h" +#include "int_quest.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + + +int mapif_parse_quest_delete(int fd) +{ + + bool success = true; + int char_id = RFIFOL(fd,2); + int quest_id = RFIFOL(fd,6); + + if ( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id) ) + { + Sql_ShowDebug(sql_handle); + success = false; + } + + if ( success && SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_obj_db, quest_id, char_id) ) + { + Sql_ShowDebug(sql_handle); + success = false; + } + + WFIFOHEAD(fd,11); + WFIFOW(fd,0) = 0x3862; + WFIFOL(fd,2) = char_id; + WFIFOL(fd,6) = quest_id; + WFIFOB(fd,10) = success?1:0; + WFIFOSET(fd,11); + + return 0; + +} + + +int mapif_parse_quest_add(int fd) +{ + + StringBuf buf; + bool success = true; + int char_id = RFIFOL(fd,4); + struct quest qd; + int i; + + memcpy(&qd, RFIFOP(fd,8), RFIFOW(fd,2)-8); + + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`) VALUES ('%d', '%d', '%d')", quest_db, qd.quest_id, char_id, qd.state); + + + if ( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + { + Sql_ShowDebug(sql_handle); + success = false; + } + + for(i=0; i<qd.num_objectives && success; i++) + { + + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s`(`quest_id`, `char_id`, `num`, `name`, `count`) VALUES ('%d', '%d', '%d', '%s', '%d')", + quest_obj_db, qd.quest_id, char_id, i, qd.objectives[i].name, qd.objectives[i].count); + + if ( success && SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + { + Sql_ShowDebug(sql_handle); + success = false; + } + } + + WFIFOHEAD(fd,11); + WFIFOW(fd,0) = 0x3861; + WFIFOL(fd,2) = char_id; + WFIFOL(fd,6) = qd.quest_id; + WFIFOB(fd,10) = success?1:0; + WFIFOSET(fd,11); + + StringBuf_Destroy(&buf); + + return 0; + +} + +int inter_quest_parse_frommap(int fd) +{ + + switch(RFIFOW(fd,0)) + { + case 0x3061: mapif_parse_quest_add(fd); break; + case 0x3062: mapif_parse_quest_delete(fd); break; + default: + return 0; + } + return 1; + +} diff --git a/src/char_sql/int_quest.h b/src/char_sql/int_quest.h new file mode 100644 index 000000000..2b7df67dd --- /dev/null +++ b/src/char_sql/int_quest.h @@ -0,0 +1,12 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _QUEST_H_ +#define _QUEST_H_ + +/*questlog system*/ +struct quest; + +int inter_quest_parse_frommap(int fd); + +#endif
\ No newline at end of file diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 72c88a3f2..8e1c466a4 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -17,6 +17,7 @@ #include "int_homun.h" #include "int_mail.h" #include "int_auction.h" +#include "int_quest.h" #include <stdio.h> #include <string.h> @@ -56,7 +57,7 @@ int inter_recv_packet_length[] = { -1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 14,19,186,-1, // 3030- 5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040- -1,-1,10,10, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus] - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- + -1,-1,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- Quest system [Kevin] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070- 48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3080- -1,10,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator] @@ -843,6 +844,7 @@ int inter_parse_frommap(int fd) || inter_homunculus_parse_frommap(fd) || inter_mail_parse_frommap(fd) || inter_auction_parse_frommap(fd) + || inter_quest_parse_frommap(fd) ) break; else |