From eb10f355f7e228b59011326a7f84da2e593affea Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 11 Sep 2013 01:28:31 +0200 Subject: Fixed announce script command support for bc_blue and bc_woe - Fixes an issue where it wasn't possible to use bc_blue or bc_woe at the same time as bc_map, bc_area or bc_self. (this partly works around bugreport:7693 - http://hercules.ws/board/tracker/issue-7693-character-with-name ) - Replaced bc_* related values from various places through the sources with constants. Signed-off-by: Haru --- src/map/script.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index 1c67abd4a..3e2347123 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9138,8 +9138,7 @@ BUILDIN(playerattached) /*========================================== *------------------------------------------*/ -BUILDIN(announce) -{ +BUILDIN(announce) { const char *mes = script_getstr(st,2); int flag = script_getnum(st,3); const char *fontColor = script_hasdata(st,4) ? script_getstr(st,4) : NULL; @@ -9148,29 +9147,29 @@ BUILDIN(announce) int fontAlign = script_hasdata(st,7) ? script_getnum(st,7) : 0; // default fontAlign int fontY = script_hasdata(st,8) ? script_getnum(st,8) : 0; // default fontY - if (flag&0x0f) // Broadcast source or broadcast region defined - { + if( flag&(BC_TARGET_MASK|BC_SOURCE_MASK) ) { + // Broadcast source or broadcast region defined send_target target; - struct block_list *bl = (flag&0x08) ? iMap->id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source + struct block_list *bl = (flag&BC_NPC) ? iMap->id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source if (bl == NULL) return true; - flag &= 0x07; - target = (flag == 1) ? ALL_SAMEMAP : - (flag == 2) ? AREA : - (flag == 3) ? SELF : - ALL_CLIENT; + switch( flag&BC_TARGET_MASK ) { + case BC_MAP: target = ALL_SAMEMAP; break; + case BC_AREA: target = AREA; break; + case BC_SELF: target = SELF; break; + default: target = ALL_CLIENT; break; // BC_ALL + } + if (fontColor) clif->broadcast2(bl, mes, (int)strlen(mes)+1, strtol(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY, target); else - clif->broadcast(bl, mes, (int)strlen(mes)+1, flag&0xf0, target); - } - else - { + clif->broadcast(bl, mes, (int)strlen(mes)+1, flag&BC_COLOR_MASK, target); + } else { if (fontColor) intif->broadcast2(mes, (int)strlen(mes)+1, strtol(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY); else - intif->broadcast(mes, (int)strlen(mes)+1, flag&0xf0); + intif->broadcast(mes, (int)strlen(mes)+1, flag&(BC_SOURCE_MASK|BC_TARGET_MASK)); } return true; } @@ -9247,7 +9246,7 @@ BUILDIN(mapannounce) return true; iMap->foreachinmap(buildin_announce_sub, m, BL_PC, - mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY); + mes, strlen(mes)+1, flag&(BC_SOURCE_MASK|BC_TARGET_MASK), fontColor, fontType, fontSize, fontAlign, fontY); return true; } /*========================================== @@ -9272,7 +9271,7 @@ BUILDIN(areaannounce) return true; iMap->foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC, - mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY); + mes, strlen(mes)+1, flag&(BC_SOURCE_MASK|BC_TARGET_MASK), fontColor, fontType, fontSize, fontAlign, fontY); return true; } @@ -16139,7 +16138,7 @@ BUILDIN(instance_announce) { for( i = 0; i < instances[instance_id].num_map; i++ ) iMap->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC, - mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY); + mes, strlen(mes)+1, flag&(BC_SOURCE_MASK|BC_TARGET_MASK), fontColor, fontType, fontSize, fontAlign, fontY); return true; } -- cgit v1.2.3-70-g09d2