From 752030de0bf089cb360cd8ccffeb7db278e2504c Mon Sep 17 00:00:00 2001 From: Inkfish Date: Sat, 7 Nov 2009 15:29:24 +0000 Subject: Added a flag to indicate if the script of an autobonus was parsed for the sake of resource saving. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14129 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ src/map/pc.c | 15 ++++++++++++--- src/map/pc.h | 3 ++- src/map/script.c | 8 +++++++- src/map/status.c | 1 + 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 12ffac1f4..09a00c80a 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,8 @@ Date Added 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. +09/11/08 + * Added a flag to indicate if the script of an autobonus was parsed for the sake of resourse saving. [Inkfish] 09/11/04 * All Songs/Dances now create a 3 second delay before Adaption can be used. [Inkfish] * Fixed unit still not being able to move when fiberlock is removed by Magnetic Earth. [Inkfish] diff --git a/src/map/pc.c b/src/map/pc.c index 48a17907d..72663a5b0 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1665,7 +1665,7 @@ int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,c for( i = 0; i < max; i++ ) { - if( autobonus[i].active != INVALID_TIMER && ( !restore || (autobonus[i].pos && !(sd->state.autobonus&autobonus[i].pos)) ) ) + if( autobonus[i].active != INVALID_TIMER && !(restore && sd->state.autobonus&autobonus[i].pos) ) { // Logout / Unequipped an item with an activated bonus delete_timer(autobonus[i].active,pc_endautobonus); autobonus[i].active = INVALID_TIMER; @@ -1681,6 +1681,9 @@ int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,c if( sd->state.autocast ) continue; + if( autobonus[i].pos&sd->state.script_parsed && restore ) + continue; + if( autobonus[i].bonus_script ) script_free_code(autobonus[i].bonus_script); if( autobonus[i].other_script ) @@ -6999,6 +7002,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) * 0 - only unequip * 1 - calculate status after unequipping * 2 - force unequip + * 4 - ignore autobonus flags *------------------------------------------*/ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { @@ -7071,8 +7075,13 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) status_change_end(&sd->bl, SC_ARMOR_RESIST, -1); } - if( sd->state.autobonus&sd->status.inventory[n].equip ) - sd->state.autobonus &= ~sd->status.inventory[n].equip; //Check for activated autobonus [Inkfish] + if( !(flag&4) ) + { + if( sd->state.script_parsed&sd->status.inventory[n].equip ) + sd->state.script_parsed &= ~sd->status.inventory[n].equip; + if( sd->state.autobonus&sd->status.inventory[n].equip ) + sd->state.autobonus &= ~sd->status.inventory[n].equip; //Check for activated autobonus [Inkfish] + } sd->status.inventory[n].equip=0; diff --git a/src/map/pc.h b/src/map/pc.h index 02fab8882..19db45465 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -130,7 +130,8 @@ struct map_session_data { unsigned int bg_id; unsigned skillonskill : 1; unsigned short user_font; - unsigned short autobonus; + unsigned short script_parsed; //flag to indicate if the script of an autobonus is parsed. [Inkfish] + unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish] } state; struct { unsigned char no_weapon_damage, no_magic_damage, no_misc_damage; diff --git a/src/map/script.c b/src/map/script.c index 135b200b0..70b049fd1 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6436,7 +6436,7 @@ BUILDIN_FUNC(successrefitem) log_pick_pc(sd, "N", sd->status.inventory[i].nameid, -1, &sd->status.inventory[i]); sd->status.inventory[i].refine++; - pc_unequipitem(sd,i,2); // status calc will happen in pc_equipitem() below + pc_unequipitem(sd,i,2|4); // status calc will happen in pc_equipitem() below clif_refine(sd->fd,0,i,sd->status.inventory[i].refine); clif_delitem(sd,i,1); @@ -6638,6 +6638,8 @@ BUILDIN_FUNC(autobonus) return 0; if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip ) return 0; + if( sd->state.script_parsed&sd->status.inventory[current_equip_item_index].equip ) + return 0; bonus_script = parse_script(script_getstr(st,2), "autobonus bonus", 0, 0); rate = script_getnum(st,3); @@ -6678,6 +6680,8 @@ BUILDIN_FUNC(autobonus2) return 0; if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip ) return 0; + if( sd->state.script_parsed&sd->status.inventory[current_equip_item_index].equip ) + return 0; bonus_script = parse_script(script_getstr(st,2), "autobonus bonus", 0, 0); rate = script_getnum(st,3); @@ -6717,6 +6721,8 @@ BUILDIN_FUNC(autobonus3) return 0; if( sd->state.autobonus&sd->status.inventory[current_equip_item_index].equip ) return 0; + if( sd->state.script_parsed&sd->status.inventory[current_equip_item_index].equip ) + return 0; bonus_script = parse_script(script_getstr(st,2), "autobonus bonus", 0, 0); rate = script_getnum(st,3); diff --git a/src/map/status.c b/src/map/status.c index 6d5733397..de87bb98a 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1856,6 +1856,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) if(first && sd->inventory_data[index]->equip_script) { //Execute equip-script on login run_script(sd->inventory_data[index]->equip_script,0,sd->bl.id,0); + sd->state.script_parsed |= sd->status.inventory[index].equip; if (!calculating) return 1; } -- cgit v1.2.3-70-g09d2