From 6f55c00e72ca6db130a84fe92218f73a777428f4 Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 27 Nov 2013 03:21:45 +0100 Subject: Questlog fixes - Improved memory usage of the quest log system. (saves up to 75kB per online character). Fixes issue #133. - Fixed various issues with quest entries disappearing from characters without an apparent reason, or monster kill counters getting stuck - the issues were caused by a de-synchronization between the two parallel questlog arrays in map_session_data. - Added some code documentation. - Thanks to Ind. Signed-off-by: Haru --- src/map/script.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index 853f0c44f..79d2ac969 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15889,20 +15889,20 @@ BUILDIN(questinfo) return true; } -BUILDIN(setquest) -{ +BUILDIN(setquest) { struct map_session_data *sd = script->rid2sd(st); unsigned short i; - - if (!sd) - return false; + int quest_id; + nullpo_retr(false,sd); - quest->add(sd, script_getnum(st, 2)); + quest_id = script_getnum(st, 2); + + quest->add(sd, quest_id); // If questinfo is set, remove quest bubble once quest is set. for(i = 0; i < map->list[sd->bl.m].qi_count; i++) { struct questinfo *qi = &map->list[sd->bl.m].qi_data[i]; - if( qi->quest_id == script_getnum(st, 2) ) { + if( qi->quest_id == quest_id ) { #if PACKETVER >= 20120410 clif->quest_show_event(sd, &qi->nd->bl, 9999, 0); #else @@ -15914,8 +15914,7 @@ BUILDIN(setquest) return true; } -BUILDIN(erasequest) -{ +BUILDIN(erasequest) { struct map_session_data *sd = script->rid2sd(st); nullpo_retr(false,sd); @@ -15923,8 +15922,7 @@ BUILDIN(erasequest) return true; } -BUILDIN(completequest) -{ +BUILDIN(completequest) { struct map_session_data *sd = script->rid2sd(st); nullpo_retr(false,sd); @@ -15932,8 +15930,7 @@ BUILDIN(completequest) return true; } -BUILDIN(changequest) -{ +BUILDIN(changequest) { struct map_session_data *sd = script->rid2sd(st); nullpo_retr(false,sd); @@ -15941,15 +15938,14 @@ BUILDIN(changequest) return true; } -BUILDIN(checkquest) -{ +BUILDIN(checkquest) { struct map_session_data *sd = script->rid2sd(st); - quest_check_type type = HAVEQUEST; + enum quest_check_type type = HAVEQUEST; nullpo_retr(false,sd); if( script_hasdata(st, 3) ) - type = (quest_check_type)script_getnum(st, 3); + type = (enum quest_check_type)script_getnum(st, 3); script_pushint(st, quest->check(sd, script_getnum(st, 2), type)); -- cgit v1.2.3-70-g09d2