Browse Source

* QuestLog Fix.
- mob id no longer stores in sql.
- counts won't increase if you have killed sufficient mobs.
* Fixed Merchant's medalion wrong aspd bonus (bugreport:3554)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14036 54d463be-8e91-2dee-dedb-b68131a5f0ec

Inkfish 15 years ago
parent
commit
6b89176cc9
11 changed files with 65 additions and 56 deletions
  1. 4 0
      Changelog-Trunk.txt
  2. 1 1
      db/item_db.txt
  3. 3 0
      sql-files/upgrade_svn14036.sql
  4. 5 11
      src/char_sql/int_quest.c
  5. 0 2
      src/common/mmo.h
  6. 7 7
      src/map/clif.c
  7. 1 1
      src/map/clif.h
  8. 12 0
      src/map/intif.c
  9. 1 0
      src/map/pc.h
  10. 19 34
      src/map/quest.c
  11. 12 0
      src/map/quest.h

+ 4 - 0
Changelog-Trunk.txt

@@ -3,6 +3,10 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
+09/09/04
+	* QuestLog Fix. [Inkfish]
+	- mob id no longer stores in sql.
+	- counts won't increase if you have killed sufficient mobs.
 09/08/25
 09/08/25
 	* Implemented Progress Bar.(topic:207933) [Inkfish]
 	* Implemented Progress Bar.(topic:207933) [Inkfish]
 09/08/21
 09/08/21

+ 1 - 1
db/item_db.txt

@@ -1533,7 +1533,7 @@
 2722,Medal_Acolyte,Medal of Honor,5,0,,0,,1,,0,0x00008110,7,2,136,,70,0,0,{ bonus bAtkRate,5; bonus bMatkRate,5; bonus bMdef,6; bonus bMaxHP,600; bonus3 bAddEff,Eff_Silence,1000,ATF_SHORT; },{},{}
 2722,Medal_Acolyte,Medal of Honor,5,0,,0,,1,,0,0x00008110,7,2,136,,70,0,0,{ bonus bAtkRate,5; bonus bMatkRate,5; bonus bMdef,6; bonus bMaxHP,600; bonus3 bAddEff,Eff_Silence,1000,ATF_SHORT; },{},{}
 2723,Medal_Mage,Medal of Honor,5,0,,0,,1,,0,0x00810204,7,2,136,,70,0,0,{ bonus bAtkRate,5; bonus bMatkRate,5; bonus bMdef,6; bonus bMaxHP,600; bonus2 bAddEffWhenHit,Eff_Stone,1000; },{},{}
 2723,Medal_Mage,Medal of Honor,5,0,,0,,1,,0,0x00810204,7,2,136,,70,0,0,{ bonus bAtkRate,5; bonus bMatkRate,5; bonus bMdef,6; bonus bMaxHP,600; bonus2 bAddEffWhenHit,Eff_Stone,1000; },{},{}
 2724,Medal_Archer,Medal of Honor,5,0,,0,,1,,0,0x00080808,7,2,136,,70,0,0,{ bonus bAtkRate,5; bonus bMatkRate,5; bonus bCritical,10; bonus bMaxHP,300; bonus bMaxSP,80; bonus3 bAddEff,Eff_Blind,1000,ATF_LONG; },{},{}
 2724,Medal_Archer,Medal of Honor,5,0,,0,,1,,0,0x00080808,7,2,136,,70,0,0,{ bonus bAtkRate,5; bonus bMatkRate,5; bonus bCritical,10; bonus bMaxHP,300; bonus bMaxSP,80; bonus3 bAddEff,Eff_Blind,1000,ATF_LONG; },{},{}
-2725,Medal_Merchant,Medal of Honor,5,0,,0,,1,,0,0x00040420,7,2,136,,70,0,0,{ bonus bAtkRate,5; bonus bMatkRate,5; bonus bAspd,10; bonus bMaxHP,500; bonus bMaxSP,50; bonus3 bAddEff,Eff_Curse,1000,ATF_SHORT; },{},{}
+2725,Medal_Merchant,Medal of Honor,5,0,,0,,1,,0,0x00040420,7,2,136,,70,0,0,{ bonus bAtkRate,5; bonus bMatkRate,5; bonus bAspdRate,10; bonus bMaxHP,500; bonus bMaxSP,50; bonus3 bAddEff,Eff_Curse,1000,ATF_SHORT; },{},{}
 2726,Icarus_Wing,Icarus Wings,5,20,,100,,0,,0,0x00000800,2,2,136,,70,0,0,{ bonus bMaxSP,50; bonus bDex,3; },{},{}
 2726,Icarus_Wing,Icarus Wings,5,20,,100,,0,,0,0x00000800,2,2,136,,70,0,0,{ bonus bMaxSP,50; bonus bDex,3; },{},{}
 2727,Bowman_Scarf,Bowman Scarf,5,20,,200,,0,,0,0x00000800,2,2,136,,0,0,0,{ bonus bMaxSP,50; bonus bDex,3; if (isequipped(2726)) bonus bUseSPrate,-25; },{},{}
 2727,Bowman_Scarf,Bowman Scarf,5,20,,200,,0,,0,0x00000800,2,2,136,,0,0,0,{ bonus bMaxSP,50; bonus bDex,3; if (isequipped(2726)) bonus bUseSPrate,-25; },{},{}
 2728,Cursed_Hand,Cursed Hand,5,0,,50,,0,,1,0xFFFFFFFE,7,2,136,,80,0,0,{ bonus3 bAutoSpell,"NPC_CRITICALWOUND",1,30; bonus bHit,10; bonus bHPrecovRate,20; },{},{}
 2728,Cursed_Hand,Cursed Hand,5,0,,50,,0,,1,0xFFFFFFFE,7,2,136,,80,0,0,{ bonus3 bAutoSpell,"NPC_CRITICALWOUND",1,30; bonus bHit,10; bonus bHPrecovRate,20; },{},{}

+ 3 - 0
sql-files/upgrade_svn14036.sql

@@ -0,0 +1,3 @@
+ALTER TABLE `quest` DROP `mob1`;
+ALTER TABLE `quest` DROP `mob2`;
+ALTER TABLE `quest` DROP `mob3`;

+ 5 - 11
src/char_sql/int_quest.c

@@ -34,25 +34,19 @@ int mapif_quests_fromsql(int char_id, struct quest questlog[])
 
 
 	memset(&tmp_quest, 0, sizeof(struct quest));
 	memset(&tmp_quest, 0, sizeof(struct quest));
 
 
-	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `quest_id`, `state`, `time`, `mob1`, `count1`, `mob2`, `count2`, `mob3`, `count3` FROM `%s` WHERE `char_id`=? LIMIT %d", quest_db, MAX_QUEST_DB)
+	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=? LIMIT %d", quest_db, MAX_QUEST_DB)
 	||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 	||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
 	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,    &tmp_quest.quest_id, 0, NULL, NULL)
 	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,    &tmp_quest.quest_id, 0, NULL, NULL)
 	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT,    &tmp_quest.state, 0, NULL, NULL)
 	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT,    &tmp_quest.state, 0, NULL, NULL)
 	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT,   &tmp_quest.time, 0, NULL, NULL)
 	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT,   &tmp_quest.time, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_INT,    &tmp_quest.mob[0], 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT,    &tmp_quest.count[0], 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_INT,    &tmp_quest.mob[1], 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_INT,    &tmp_quest.count[1], 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_INT,    &tmp_quest.mob[2], 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_INT,    &tmp_quest.count[2], 0, NULL, NULL) )
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_INT,    &tmp_quest.count[0], 0, NULL, NULL)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT,    &tmp_quest.count[1], 0, NULL, NULL)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_INT,    &tmp_quest.count[2], 0, NULL, NULL) )
 		SqlStmt_ShowDebug(stmt);
 		SqlStmt_ShowDebug(stmt);
 
 
 	for( i = 0; i < MAX_QUEST_DB && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
 	for( i = 0; i < MAX_QUEST_DB && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
-	{
 		memcpy(&questlog[i], &tmp_quest, sizeof(tmp_quest));
 		memcpy(&questlog[i], &tmp_quest, sizeof(tmp_quest));
-		questlog[i].num_objectives = (!questlog[i].mob[0] ? 0 : !questlog[i].mob[1] ? 1 : !questlog[i].mob[2] ? 2 : 3);
-	}
 
 
 	SqlStmt_Free(stmt);
 	SqlStmt_Free(stmt);
 	return i;
 	return i;
@@ -76,7 +70,7 @@ bool mapif_quest_add(int char_id, struct quest qd)
 	StringBuf buf;
 	StringBuf buf;
 
 
 	StringBuf_Init(&buf);
 	StringBuf_Init(&buf);
-	StringBuf_Printf(&buf, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`, `mob1`, `count1`, `mob2`, `count2`, `mob3`, `count3`) VALUES ('%d', '%d', '%d','%d', '%d', '%d', '%d', '%d', '%d', '%d')", quest_db, qd.quest_id, char_id, qd.state, qd.time, qd.mob[0], qd.count[0], qd.mob[1], qd.count[1], qd.mob[2], qd.count[2]);
+	StringBuf_Printf(&buf, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`, `count1`, `count2`, `count3`) VALUES ('%d', '%d', '%d','%d', '%d', '%d', '%d')", quest_db, qd.quest_id, char_id, qd.state, qd.time, qd.count[0], qd.count[1], qd.count[2]);
 
 
 	if ( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) 
 	if ( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) 
 	{
 	{

+ 0 - 2
src/common/mmo.h

@@ -132,10 +132,8 @@ typedef enum quest_state { Q_INACTIVE, Q_ACTIVE, Q_COMPLETE } quest_state;
 struct quest {
 struct quest {
 	int quest_id;
 	int quest_id;
 	unsigned int time;
 	unsigned int time;
-	int mob[MAX_QUEST_OBJECTIVES];
 	int count[MAX_QUEST_OBJECTIVES];
 	int count[MAX_QUEST_OBJECTIVES];
 	quest_state state;
 	quest_state state;
-	int num_objectives;
 };
 };
 
 
 struct item {
 struct item {

+ 7 - 7
src/map/clif.c

@@ -12626,12 +12626,12 @@ void clif_send_questlog_info(struct map_session_data * sd)
 	{
 	{
 		WFIFOL(fd, i*104+8) = sd->quest_log[i].quest_id;
 		WFIFOL(fd, i*104+8) = sd->quest_log[i].quest_id;
 		WFIFOL(fd, i*104+16) = sd->quest_log[i].time;
 		WFIFOL(fd, i*104+16) = sd->quest_log[i].time;
-		WFIFOW(fd, i*104+20) = sd->quest_log[i].num_objectives;
+		WFIFOW(fd, i*104+20) = quest_db[sd->quest_index[i]].num_objectives;
 
 
-		for( j = 0 ; j < sd->quest_log[i].num_objectives; j++ )
+		for( j = 0 ; j < quest_db[sd->quest_index[i]].num_objectives; j++ )
 		{
 		{
 			WFIFOW(fd, i*104+26+j*30) = sd->quest_log[i].count[j];
 			WFIFOW(fd, i*104+26+j*30) = sd->quest_log[i].count[j];
-			mob = mob_db(sd->quest_log[i].mob[j]);
+			mob = mob_db(quest_db[sd->quest_index[i]].mob[j]);
 			memcpy(WFIFOP(fd, i*104+28+j*30), mob?mob->jname:"NULL", NAME_LENGTH);
 			memcpy(WFIFOP(fd, i*104+28+j*30), mob?mob->jname:"NULL", NAME_LENGTH);
 		}
 		}
 	}
 	}
@@ -12641,7 +12641,7 @@ void clif_send_questlog_info(struct map_session_data * sd)
 
 
 //Send info when objective info needs an update
 //Send info when objective info needs an update
 //* 02B3 <quest_id>.L <state>.B <ignored>.L <time>.L <num mobs>.W {<ignored>.L <mob count>.W <Mob Name>.24B}.30B[3]
 //* 02B3 <quest_id>.L <state>.B <ignored>.L <time>.L <num mobs>.W {<ignored>.L <mob count>.W <Mob Name>.24B}.30B[3]
-void clif_send_quest_info(struct map_session_data * sd, struct quest * qd)
+void clif_send_quest_info(struct map_session_data * sd, struct quest * qd, int index)
 {
 {
 	int fd = sd->fd;
 	int fd = sd->fd;
 	int i;
 	int i;
@@ -12653,12 +12653,12 @@ void clif_send_quest_info(struct map_session_data * sd, struct quest * qd)
 	WFIFOL(fd, 2) = qd->quest_id;
 	WFIFOL(fd, 2) = qd->quest_id;
 	WFIFOB(fd, 6) = qd->state;
 	WFIFOB(fd, 6) = qd->state;
 	WFIFOL(fd, 11) = qd->time;
 	WFIFOL(fd, 11) = qd->time;
-	WFIFOW(fd, 15) = qd->num_objectives;
+	WFIFOW(fd, 15) = quest_db[index].num_objectives;
 
 
-	for( i = 0; i < qd->num_objectives; i++ )
+	for( i = 0; i < quest_db[index].num_objectives; i++ )
 	{
 	{
 		WFIFOW(fd, i*30+21) = qd->count[i];
 		WFIFOW(fd, i*30+21) = qd->count[i];
-		mob = mob_db(qd->mob[i]);
+		mob = mob_db(quest_db[index].mob[i]);
 		memcpy(WFIFOP(fd, i*30+23), mob?mob->jname:"NULL", NAME_LENGTH);
 		memcpy(WFIFOP(fd, i*30+23), mob?mob->jname:"NULL", NAME_LENGTH);
 	}
 	}
 
 

+ 1 - 1
src/map/clif.h

@@ -434,7 +434,7 @@ void clif_equipcheckbox(struct map_session_data* sd);
 //quest system [Kevin] [Inkfish]
 //quest system [Kevin] [Inkfish]
 void clif_send_questlog(struct map_session_data * sd);
 void clif_send_questlog(struct map_session_data * sd);
 void clif_send_questlog_info(struct map_session_data * sd);
 void clif_send_questlog_info(struct map_session_data * sd);
-void clif_send_quest_info(struct map_session_data * sd, struct quest * qd);
+void clif_send_quest_info(struct map_session_data * sd, struct quest * qd, int index);
 void clif_send_quest_delete(struct map_session_data * sd, int quest_id);
 void clif_send_quest_delete(struct map_session_data * sd, int quest_id);
 void clif_send_quest_status(struct map_session_data * sd, int quest_id, bool active);
 void clif_send_quest_status(struct map_session_data * sd, int quest_id, bool active);
 
 

+ 12 - 0
src/map/intif.c

@@ -1354,6 +1354,18 @@ int intif_parse_questlog(int fd)
 	for( i = 0; i < sd->num_quests; i++ )
 	for( i = 0; i < sd->num_quests; i++ )
 	{
 	{
 		memcpy(&sd->quest_log[i], RFIFOP(fd, i*sizeof(struct quest)+8), sizeof(struct quest));
 		memcpy(&sd->quest_log[i], RFIFOP(fd, i*sizeof(struct quest)+8), sizeof(struct quest));
+
+		sd->quest_index[i] = quest_search_db(sd->quest_log[i].quest_id);
+
+		if( sd->quest_index[i] < 0 )
+		{  
+			ShowError("intif_parse_questlog: quest %d not found in DB.\n",sd->quest_log[i].quest_id);
+			sd->avail_quests--;
+			sd->num_quests--;
+			i--;
+			continue;
+		}
+
 		if( sd->quest_log[i].state == Q_COMPLETE )
 		if( sd->quest_log[i].state == Q_COMPLETE )
 			sd->avail_quests--;
 			sd->avail_quests--;
 	}
 	}

+ 1 - 0
src/map/pc.h

@@ -385,6 +385,7 @@ struct map_session_data {
 	//Quest log system [Kevin] [Inkfish]
 	//Quest log system [Kevin] [Inkfish]
 	int num_quests;
 	int num_quests;
 	int avail_quests;
 	int avail_quests;
+	int quest_index[MAX_QUEST_DB];
 	struct quest quest_log[MAX_QUEST_DB];
 	struct quest quest_log[MAX_QUEST_DB];
 
 
 	// temporary debug [flaviojs]
 	// temporary debug [flaviojs]

+ 19 - 34
src/map/quest.c

@@ -33,15 +33,6 @@
 #include <stdarg.h>
 #include <stdarg.h>
 #include <time.h>
 #include <time.h>
 
 
-struct s_quest_db {
-	int id;
-	unsigned int time;
-	int mob[MAX_QUEST_OBJECTIVES];
-	int count[MAX_QUEST_OBJECTIVES];
-	//char name[NAME_LENGTH];
-};
-struct s_quest_db quest_db[MAX_QUEST_DB];
-
 int quest_search_db(int quest_id)
 int quest_search_db(int quest_id)
 {
 {
 	int i;
 	int i;
@@ -68,7 +59,7 @@ int quest_pc_login(TBL_PC * sd)
 int quest_add(TBL_PC * sd, int quest_id)
 int quest_add(TBL_PC * sd, int quest_id)
 {
 {
 
 
-	int i, j, count;
+	int i, j;
 
 
 	if( sd->num_quests >= MAX_QUEST_DB )
 	if( sd->num_quests >= MAX_QUEST_DB )
 	{
 	{
@@ -96,14 +87,12 @@ int quest_add(TBL_PC * sd, int quest_id)
 	if( quest_db[j].time )
 	if( quest_db[j].time )
 		sd->quest_log[i].time = (unsigned int)(time(NULL) + quest_db[j].time);
 		sd->quest_log[i].time = (unsigned int)(time(NULL) + quest_db[j].time);
 	sd->quest_log[i].state = Q_ACTIVE;
 	sd->quest_log[i].state = Q_ACTIVE;
-	for( count = 0; count < MAX_QUEST_OBJECTIVES && quest_db[j].mob[count]; count++ )
-		sd->quest_log[i].mob[count] = quest_db[j].mob[count];
-	sd->quest_log[i].num_objectives = count;
 
 
+	sd->quest_index[i] = j;
 	sd->num_quests++;
 	sd->num_quests++;
 	sd->avail_quests++;
 	sd->avail_quests++;
 
 
-	clif_send_quest_info(sd, &sd->quest_log[i]);
+	clif_send_quest_info(sd, &sd->quest_log[i], sd->quest_index[i]);
 
 
 	if( save_settings&64 )
 	if( save_settings&64 )
 		chrif_save(sd,0);
 		chrif_save(sd,0);
@@ -114,7 +103,7 @@ int quest_add(TBL_PC * sd, int quest_id)
 int quest_change(TBL_PC * sd, int qid1, int qid2)
 int quest_change(TBL_PC * sd, int qid1, int qid2)
 {
 {
 
 
-	int i, j, count;
+	int i, j;
 
 
 	if( quest_check(sd, qid2, HAVEQUEST) >= 0 )
 	if( quest_check(sd, qid2, HAVEQUEST) >= 0 )
 	{
 	{
@@ -146,12 +135,11 @@ int quest_change(TBL_PC * sd, int qid1, int qid2)
 	if( quest_db[j].time )
 	if( quest_db[j].time )
 		sd->quest_log[i].time = (unsigned int)(time(NULL) + quest_db[j].time);
 		sd->quest_log[i].time = (unsigned int)(time(NULL) + quest_db[j].time);
 	sd->quest_log[i].state = Q_ACTIVE;
 	sd->quest_log[i].state = Q_ACTIVE;
-	for( count = 0; count < MAX_QUEST_OBJECTIVES && quest_db[j].mob[count]; count++ )
-		sd->quest_log[i].mob[count] = quest_db[j].mob[count];
-	sd->quest_log[i].num_objectives = count;
+
+	sd->quest_index[i] = j;
 
 
 	clif_send_quest_delete(sd, qid1);
 	clif_send_quest_delete(sd, qid1);
-	clif_send_quest_info(sd, &sd->quest_log[i]);
+	clif_send_quest_info(sd, &sd->quest_log[i], sd->quest_index[i]);
 
 
 	if( save_settings&64 )
 	if( save_settings&64 )
 		chrif_save(sd,0);
 		chrif_save(sd,0);
@@ -195,7 +183,7 @@ void quest_update_objective(TBL_PC * sd, int mob)
 			continue;
 			continue;
 
 
 		for( j = 0; j < MAX_QUEST_OBJECTIVES; j++ )
 		for( j = 0; j < MAX_QUEST_OBJECTIVES; j++ )
-			if( sd->quest_log[i].mob[j] == mob )
+			if( quest_db[sd->quest_index[i]].mob[j] == mob && sd->quest_log[i].count[j] < quest_db[sd->quest_index[i]].count[j] ) 
 			{
 			{
 				sd->quest_log[i].count[j]++;
 				sd->quest_log[i].count[j]++;
 
 
@@ -259,13 +247,7 @@ int quest_check(TBL_PC * sd, int quest_id, quest_check_type type)
 		return (sd->quest_log[i].time < (unsigned int)time(NULL) ? 2 : sd->quest_log[i].state == Q_COMPLETE ? 1 : 0);
 		return (sd->quest_log[i].time < (unsigned int)time(NULL) ? 2 : sd->quest_log[i].state == Q_COMPLETE ? 1 : 0);
 	case HUNTING:
 	case HUNTING:
 		{
 		{
-			int j = quest_search_db(quest_id);
-
-			if( j < 0 )
-			{
-				ShowError("quest_check_quest: quest %d not found in DB.\n",quest_id);
-				return -1;
-			}
+			int j = sd->quest_index[i];
 
 
 			if( sd->quest_log[i].count[0] < quest_db[j].count[0] || sd->quest_log[i].count[1] < quest_db[j].count[1] || sd->quest_log[i].count[2] < quest_db[j].count[2] )
 			if( sd->quest_log[i].count[0] < quest_db[j].count[0] || sd->quest_log[i].count[1] < quest_db[j].count[1] || sd->quest_log[i].count[2] < quest_db[j].count[2] )
 			{
 			{
@@ -289,7 +271,7 @@ int quest_read_db(void)
 {
 {
 	FILE *fp;
 	FILE *fp;
 	char line[1024];
 	char line[1024];
-	int j,k = 0;
+	int i,j,k = 0;
 	char *str[20],*p,*np;
 	char *str[20],*p,*np;
 
 
 	sprintf(line, "%s/quest_db.txt", db_path);
 	sprintf(line, "%s/quest_db.txt", db_path);
@@ -325,12 +307,15 @@ int quest_read_db(void)
 
 
 		quest_db[k].id = atoi(str[0]);
 		quest_db[k].id = atoi(str[0]);
 		quest_db[k].time = atoi(str[1]);
 		quest_db[k].time = atoi(str[1]);
-		quest_db[k].mob[0] = atoi(str[2]);
-		quest_db[k].count[0] = atoi(str[3]);
-		quest_db[k].mob[1] = atoi(str[4]);
-		quest_db[k].count[1] = atoi(str[5]);
-		quest_db[k].mob[2] = atoi(str[6]);
-		quest_db[k].count[2] = atoi(str[7]);
+		for( i = 0; i < MAX_QUEST_OBJECTIVES; i++ )
+		{
+			quest_db[k].mob[i] = atoi(str[2*i+2]);
+			quest_db[k].count[i] = atoi(str[2*i+3]);
+
+			if( !quest_db[k].mob[i] || !quest_db[k].count[i] )
+				break;
+		}
+		quest_db[k].num_objectives = i;
 		//memcpy(quest_db[k].name, str[8], sizeof(str[8]));
 		//memcpy(quest_db[k].name, str[8], sizeof(str[8]));
 		k++;
 		k++;
 	}
 	}

+ 12 - 0
src/map/quest.h

@@ -4,6 +4,16 @@
 #ifndef _QUEST_H_
 #ifndef _QUEST_H_
 #define _QUEST_H_
 #define _QUEST_H_
 
 
+struct s_quest_db {
+	int id;
+	unsigned int time;
+	int mob[MAX_QUEST_OBJECTIVES];
+	int count[MAX_QUEST_OBJECTIVES];
+	int num_objectives;
+	//char name[NAME_LENGTH];
+};
+struct s_quest_db quest_db[MAX_QUEST_DB];
+
 typedef enum quest_check_type { HAVEQUEST, PLAYTIME, HUNTING } quest_check_type;
 typedef enum quest_check_type { HAVEQUEST, PLAYTIME, HUNTING } quest_check_type;
 
 
 int quest_pc_login(TBL_PC * sd);
 int quest_pc_login(TBL_PC * sd);
@@ -15,6 +25,8 @@ void quest_update_objective(TBL_PC * sd, int mob);
 int quest_update_status(TBL_PC * sd, int quest_id, quest_state status);
 int quest_update_status(TBL_PC * sd, int quest_id, quest_state status);
 int quest_check(TBL_PC * sd, int quest_id, quest_check_type type);
 int quest_check(TBL_PC * sd, int quest_id, quest_check_type type);
 
 
+int quest_search_db(int quest_id);
+
 void do_init_quest();
 void do_init_quest();
 
 
 #endif
 #endif