From 7928947b09b3e7b7f317379d16f9b47299d26cee Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Thu, 22 Jan 2009 09:37:47 +0000 Subject: * Changed val4 of SC_BLADESTOP from a block_list pointer to an id. (64bit portability issue and potential dangling pointer crash) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13471 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ src/map/battle.c | 6 +++--- src/map/clif.c | 10 +++------- src/map/clif.h | 2 +- src/map/status.c | 10 ++++++---- src/map/unit.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index b29d1fc9d..0d1d1fb1e 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. +2009/01/22 + * Changed val4 of SC_BLADESTOP from a block_list pointer to an id. [FlavioJS] 2009/01/21 * Added a limit of 1MB of pending data in the write fifo for non-server sockets. Connections that go over the limit are closed. diff --git a/src/map/battle.c b/src/map/battle.c index 1ac70f77b..4450c3258 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2903,11 +2903,11 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t int skilllv = tsc->data[SC_BLADESTOP_WAIT]->val1; int duration = skill_get_time2(MO_BLADESTOP,skilllv); status_change_end(target, SC_BLADESTOP_WAIT, -1); - if(sc_start4(src, SC_BLADESTOP, 100, sd?pc_checkskill(sd, MO_BLADESTOP):5, 0, 0, (int)target, duration)) + if(sc_start4(src, SC_BLADESTOP, 100, sd?pc_checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration)) { //Target locked. clif_damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS. - clif_bladestop(target,src,1); - sc_start4(target, SC_BLADESTOP, 100, skilllv, 0, 0,(int)src, duration); + clif_bladestop(target, src->id, 1); + sc_start4(target, SC_BLADESTOP, 100, skilllv, 0, 0, src->id, duration); return ATK_NONE; } } diff --git a/src/map/clif.c b/src/map/clif.c index 6038a4947..662cfb580 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5957,22 +5957,18 @@ int clif_combo_delay(struct block_list *bl,int wait) /*========================================== *n *------------------------------------------*/ -int clif_bladestop(struct block_list *src,struct block_list *dst, - int _bool) +void clif_bladestop(struct block_list *src, int dst_id, int active) { unsigned char buf[32]; nullpo_retr(0, src); - nullpo_retr(0, dst); WBUFW(buf,0)=0x1d1; WBUFL(buf,2)=src->id; - WBUFL(buf,6)=dst->id; - WBUFL(buf,10)=_bool; + WBUFL(buf,6)=dst_id; + WBUFL(buf,10)=active; clif_send(buf,packet_len(0x1d1),src,AREA); - - return 0; } /*========================================== diff --git a/src/map/clif.h b/src/map/clif.h index e0e100852..b64d94b48 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -236,7 +236,7 @@ int clif_autospell(struct map_session_data *sd,int skilllv); void clif_devotion(struct block_list *src, struct map_session_data *tsd); int clif_spiritball(struct map_session_data *sd); int clif_combo_delay(struct block_list *src,int wait); -int clif_bladestop(struct block_list *src,struct block_list *dst,int bool_); +void clif_bladestop(struct block_list* src, int dst_id, int active); void clif_changemapcell(int fd, int m, int x, int y, int type, enum send_target target); int clif_status_load(struct block_list *bl,int type, int flag); diff --git a/src/map/status.c b/src/map/status.c index 5b38fd17a..e8da71bcc 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4549,9 +4549,10 @@ void status_set_viewdata(struct block_list *bl, int class_) vd->cloth_color = 0; } +/// Returns the status_change data of bl or NULL if it doesn't exist. struct status_change *status_get_sc(struct block_list *bl) { - nullpo_retr(NULL, bl); + if( bl ) switch (bl->type) { case BL_PC: return &((TBL_PC*)bl)->sc; case BL_MOB: return &((TBL_MOB*)bl)->sc; @@ -6582,15 +6583,16 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid) case SC_BLADESTOP: if(sce->val4) { - struct block_list *tbl = (struct block_list *)sce->val4; + int tid = sce->val4; + struct block_list *tbl = map_id2bl(tid); struct status_change *tsc = status_get_sc(tbl); sce->val4 = 0; - if(tsc && tsc->data[SC_BLADESTOP]) + if(tbl && tsc && tsc->data[SC_BLADESTOP]) { tsc->data[SC_BLADESTOP]->val4 = 0; status_change_end(tbl,SC_BLADESTOP,-1); } - clif_bladestop(bl,tbl,0); + clif_bladestop(bl, tid, 0); } break; case SC_DANCING: diff --git a/src/map/unit.c b/src/map/unit.c index 787b25765..f79a16664 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -855,7 +855,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh { //Check for skills that auto-select target case MO_CHAINCOMBO: if (sc && sc->data[SC_BLADESTOP]){ - if ((target=(struct block_list *)sc->data[SC_BLADESTOP]->val4) == NULL) + if ((target=map_id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL) return 0; } break; -- cgit v1.2.3-60-g2f50