diff options
author | Haru <haru@dotalux.com> | 2013-09-11 01:28:31 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2013-09-11 02:26:04 +0200 |
commit | eb10f355f7e228b59011326a7f84da2e593affea (patch) | |
tree | 52c448eeef67c66794e6f8fccee3bfc446893ff3 /src/map | |
parent | c1c3ef1e0b356aaa89d8fba6d63b86130e8aae9c (diff) | |
download | hercules-eb10f355f7e228b59011326a7f84da2e593affea.tar.gz hercules-eb10f355f7e228b59011326a7f84da2e593affea.tar.bz2 hercules-eb10f355f7e228b59011326a7f84da2e593affea.tar.xz hercules-eb10f355f7e228b59011326a7f84da2e593affea.zip |
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 <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 8 | ||||
-rw-r--r-- | src/map/clif.c | 10 | ||||
-rw-r--r-- | src/map/clif.h | 35 | ||||
-rw-r--r-- | src/map/duel.c | 2 | ||||
-rw-r--r-- | src/map/intif.c | 8 | ||||
-rw-r--r-- | src/map/mob.c | 4 | ||||
-rw-r--r-- | src/map/pc.c | 6 | ||||
-rw-r--r-- | src/map/script.c | 35 |
8 files changed, 63 insertions, 45 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4a4487c3b..df97740e1 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1046,9 +1046,9 @@ ACMD(kami) sscanf(message, "%199[^\n]", atcmd_output); if (strstr(command, "l") != NULL) - clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP); + clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); else - intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0); + intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_YELLOW); } else { if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) { clif->message(fd, msg_txt(981)); // Please enter color and message (usage: @kamic <color> <message>). @@ -4960,7 +4960,7 @@ ACMD(broadcast) } sprintf(atcmd_output, "%s: %s", sd->status.name, message); - intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); + intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT); return true; } @@ -4981,7 +4981,7 @@ ACMD(localbroadcast) sprintf(atcmd_output, "%s: %s", sd->status.name, message); - clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP); + clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); return true; } diff --git a/src/map/clif.c b/src/map/clif.c index 081260ddb..8f82141b2 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5718,14 +5718,14 @@ void clif_displaymessage2(const int fd, const char* mes) { /// 009a <packet len>.W <message>.?B void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, enum send_target target) { - int lp = type ? 4 : 0; + int lp = (type&BC_COLOR_MASK) ? 4 : 0; unsigned char *buf = (unsigned char*)aMalloc((4 + lp + len)*sizeof(unsigned char)); WBUFW(buf,0) = 0x9a; WBUFW(buf,2) = 4 + lp + len; - if (type == 0x10) // bc_blue + if( type&BC_BLUE ) WBUFL(buf,4) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow. - else if (type == 0x20) // bc_woe + else if( type&BC_WOE ) WBUFL(buf,4) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'. memcpy(WBUFP(buf, 4 + lp), mes, len); clif->send(buf, WBUFW(buf,2), bl, target); @@ -9580,8 +9580,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if( map[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { char output[128]; - sprintf(output, "[ Kill Steal Protection Disable. KS is allowed in this map ]"); - clif->broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF); + sprintf(output, "[ Kill Steal Protection Disabled. KS is allowed in this map ]"); + clif->broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE, SELF); } iMap->iwall_get(sd); // Updates Walls Info on this Map to Client diff --git a/src/map/clif.h b/src/map/clif.h index f414ecebb..73d3611a2 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -60,13 +60,13 @@ enum {// packet DB typedef enum send_target { ALL_CLIENT, ALL_SAMEMAP, - AREA, // area - AREA_WOS, // area, without self - AREA_WOC, // area, without chatrooms - AREA_WOSC, // area, without own chatroom - AREA_CHAT_WOC, // hearable area, without chatrooms - CHAT, // current chatroom - CHAT_WOS, // current chatroom, without self + AREA, // area + AREA_WOS, // area, without self + AREA_WOC, // area, without chatrooms + AREA_WOSC, // area, without own chatroom + AREA_CHAT_WOC, // hearable area, without chatrooms + CHAT, // current chatroom + CHAT_WOS, // current chatroom, without self PARTY, PARTY_WOS, PARTY_SAMEMAP, @@ -84,7 +84,7 @@ typedef enum send_target { DUEL_WOS, SELF, - BG, // BattleGround System + BG, // BattleGround System BG_WOS, BG_SAMEMAP, BG_SAMEMAP_WOS, @@ -94,6 +94,25 @@ typedef enum send_target { BG_QUEUE, } send_target; +typedef enum broadcast_flags { + BC_ALL = 0, + BC_MAP = 1, + BC_AREA = 2, + BC_SELF = 3, + BC_TARGET_MASK = 0x07, + + BC_PC = 0x00, + BC_NPC = 0x08, + BC_SOURCE_MASK = 0x08, // BC_PC|BC_NPC + + BC_YELLOW = 0x00, + BC_BLUE = 0x10, + BC_WOE = 0x20, + BC_COLOR_MASK = 0x30, // BC_YELLOW|BC_BLUE|BC_WOE + + BC_DEFAULT = BC_ALL|BC_PC|BC_YELLOW +} broadcast_flags; + typedef enum emotion_type { E_GASP = 0, // /! E_WHAT, // /? diff --git a/src/map/duel.c b/src/map/duel.c index 7a4e61fa0..a04ed855b 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -110,7 +110,7 @@ void duel_invite(const unsigned int did, struct map_session_data* sd, struct map // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
sprintf(output, msg_txt(374), sd->status.name);
- clif->broadcast((struct block_list *)target_sd, output, strlen(output)+1, 0x10, SELF);
+ clif->broadcast((struct block_list *)target_sd, output, strlen(output)+1, BC_BLUE, SELF);
}
static int duel_leave_sub(struct map_session_data* sd, va_list va)
diff --git a/src/map/intif.c b/src/map/intif.c index 6461dce8e..1713cb38e 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -139,7 +139,7 @@ int intif_rename(struct map_session_data *sd, int type, char *name) // GM Send a message int intif_broadcast(const char* mes, int len, int type) { - int lp = type ? 4 : 0; + int lp = (type|BC_COLOR_MASK) ? 4 : 0; // Send to the local players clif->broadcast(NULL, mes, len, type, ALL_CLIENT); @@ -158,9 +158,9 @@ int intif_broadcast(const char* mes, int len, int type) WFIFOW(inter_fd,10) = 0; // fontSize not used with standard broadcast WFIFOW(inter_fd,12) = 0; // fontAlign not used with standard broadcast WFIFOW(inter_fd,14) = 0; // fontY not used with standard broadcast - if (type == 0x10) // bc_blue + if( type|BC_BLUE ) WFIFOL(inter_fd,16) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow. - else if (type == 0x20) // bc_woe + else if( type|BC_WOE ) WFIFOL(inter_fd,16) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'. memcpy(WFIFOP(inter_fd,16 + lp), mes, len); WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); @@ -2176,7 +2176,7 @@ int intif_parse(int fd) switch(cmd){ case 0x3800: if (RFIFOL(fd,4) == 0xFF000000) //Normal announce. - clif->broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, 0, ALL_CLIENT); + clif->broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT); else //Color announce. clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); break; diff --git a/src/map/mob.c b/src/map/mob.c index 291f04267..b16c57ef8 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2393,7 +2393,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) char message[128]; sprintf (message, msg_txt(541), mvp_sd->status.name, md->name, it->jname, (float)drop_rate/100); //MSG: "'%s' won %s's %s (chance: %0.02f%%)" - intif->broadcast(message,strlen(message)+1,0); + intif->broadcast(message, strlen(message)+1, BC_DEFAULT); } // Announce first, or else ditem will be freed. [Lance] // By popular demand, use base drop rate for autoloot code. [Skotlex] @@ -2534,7 +2534,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) char message[128]; sprintf (message, msg_txt(541), mvp_sd->status.name, md->name, data->jname, temp/100.); //MSG: "'%s' won %s's %s (chance: %0.02f%%)" - intif->broadcast(message,strlen(message)+1,0); + intif->broadcast(message, strlen(message)+1, BC_DEFAULT); } if((temp = pc->additem(mvp_sd,&item,1,LOG_TYPE_PICKDROP_PLAYER)) != 0) { diff --git a/src/map/pc.c b/src/map/pc.c index d40f747a3..421099ce1 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4753,7 +4753,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil char message[128]; sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, data->jname, (float)md->db->dropitem[i].p/100); //MSG: "'%s' stole %s's %s (chance: %0.02f%%)" - intif->broadcast(message,strlen(message)+1,0); + intif->broadcast(message, strlen(message)+1, BC_DEFAULT); } return 1; } @@ -9368,7 +9368,7 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) iMap->night_flag = 0; // 0=day, 1=night [Yor] iMap->map_foreachpc(pc_daynight_timer_sub); strcpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60)); // The day has arrived! - intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0); + intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, BC_DEFAULT); return 0; } @@ -9389,7 +9389,7 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) iMap->night_flag = 1; // 0=day, 1=night [Yor] iMap->map_foreachpc(pc_daynight_timer_sub); strcpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59)); // The night has fallen... - intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0); + intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, BC_DEFAULT); return 0; } 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; } |