Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Browse files Browse the repository at this point in the history
  • Loading branch information
shennetsind committed Sep 14, 2013
2 parents 0fd46a8 + eb10f35 commit f1a594d
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 45 deletions.
8 changes: 4 additions & 4 deletions src/map/atcommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>).
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
35 changes: 27 additions & 8 deletions src/map/clif.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -84,7 +84,7 @@ typedef enum send_target {
DUEL_WOS,
SELF,

BG, // BattleGround System
BG, // BattleGround System
BG_WOS,
BG_SAMEMAP,
BG_SAMEMAP_WOS,
Expand All @@ -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, // /?
Expand Down
2 changes: 1 addition & 1 deletion src/map/duel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/map/intif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/map/mob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/map/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
35 changes: 17 additions & 18 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -9139,8 +9139,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;
Expand All @@ -9149,29 +9148,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;
}
Expand Down Expand Up @@ -9248,7 +9247,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;
}
/*==========================================
Expand All @@ -9273,7 +9272,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;
}

Expand Down Expand Up @@ -16140,7 +16139,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;
}
Expand Down

0 comments on commit f1a594d

Please sign in to comment.