diff options
-rw-r--r-- | src/map/atcommand.c | 10 | ||||
-rw-r--r-- | src/map/clif.c | 10 | ||||
-rw-r--r-- | src/map/clif.h | 4 | ||||
-rw-r--r-- | src/map/duel.c | 2 | ||||
-rw-r--r-- | src/map/intif.c | 6 | ||||
-rw-r--r-- | src/map/intif.h | 4 | ||||
-rw-r--r-- | src/map/mob.c | 4 | ||||
-rw-r--r-- | src/map/pc.c | 6 | ||||
-rw-r--r-- | src/map/script.c | 39 |
9 files changed, 48 insertions, 37 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 595cb8567..32ca2f384 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1091,9 +1091,9 @@ ACMD(kami) sscanf(message, "%199[^\n]", atcmd_output); if (stristr(info->command, "l") != NULL) - clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); + clif->broadcast(&sd->bl, atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); else - intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(info->command + 4) == 'b' || *(info->command + 4) == 'B') ? BC_BLUE : BC_YELLOW); + intif->broadcast(atcmd_output, (int)strlen(atcmd_output) + 1, (*(info->command + 4) == 'b' || *(info->command + 4) == 'B') ? BC_BLUE : BC_YELLOW); } else { if(!*message || (sscanf(message, "%10u %199[^\n]", &color, atcmd_output) < 2)) { clif->message(fd, msg_fd(fd,981)); // Please enter color and message (usage: @kamic <color> <message>). @@ -1104,7 +1104,7 @@ ACMD(kami) clif->message(fd, msg_fd(fd,982)); // Invalid color. return false; } - intif->broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0); + intif->broadcast2(atcmd_output, (int)strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0); } return true; } @@ -4911,7 +4911,7 @@ ACMD(broadcast) } safesnprintf(atcmd_output, sizeof(atcmd_output), "%s: %s", sd->status.name, message); - intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT); + intif->broadcast(atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT); return true; } @@ -4930,7 +4930,7 @@ ACMD(localbroadcast) safesnprintf(atcmd_output, sizeof(atcmd_output), "%s: %s", sd->status.name, message); - clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); + clif->broadcast(&sd->bl, atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); return true; } diff --git a/src/map/clif.c b/src/map/clif.c index 70a88bfda..11d6076e9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5582,7 +5582,7 @@ void clif_displaymessage_sprintf(const int fd, const char *mes, ...) { } /// Send broadcast message in yellow or blue without font formatting (ZC_BROADCAST). /// 009a <packet len>.W <message>.?B -void clif_broadcast(struct block_list *bl, const char *mes, size_t len, int type, enum send_target target) +void clif_broadcast(struct block_list *bl, const char *mes, int len, int type, enum send_target target) { int lp = (type&BC_COLOR_MASK) ? 4 : 0; unsigned char *buf = NULL; @@ -5631,13 +5631,13 @@ void clif_GlobalMessage(struct block_list *bl, const char *message) /// Send broadcast message with font formatting (ZC_BROADCAST2). /// 01c3 <packet len>.W <fontColor>.L <fontType>.W <fontSize>.W <fontAlign>.W <fontY>.W <message>.?B -void clif_broadcast2(struct block_list* bl, const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target) +void clif_broadcast2(struct block_list *bl, const char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target) { unsigned char *buf; nullpo_retv(mes); - buf = (unsigned char*)aMalloc((16 + len)*sizeof(unsigned char)); + buf = aMalloc((16 + len)*sizeof(unsigned char)); WBUFW(buf,0) = 0x1c3; WBUFW(buf,2) = len + 16; WBUFL(buf,4) = fontColor; @@ -9428,7 +9428,7 @@ void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) { if( map->list[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { char output[128]; sprintf(output, "[ Kill Steal Protection Disabled. KS is allowed in this map ]"); - clif->broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE, SELF); + clif->broadcast(&sd->bl, output, (int)strlen(output) + 1, BC_BLUE, SELF); } map->iwall_get(sd); // Updates Walls Info on this Map to Client @@ -18044,7 +18044,7 @@ void clif_show_modifiers (struct map_session_data *sd) { snprintf(output,128,"Base EXP : %d%% | Base Drop: %d%% | Base Death Penalty: %d%%", sd->status.mod_exp,sd->status.mod_drop,sd->status.mod_death); - clif->broadcast2(&sd->bl,output, strlen(output) + 1, 0xffbc90, 0x190, 12, 0, 0, SELF); + clif->broadcast2(&sd->bl, output, (int)strlen(output) + 1, 0xffbc90, 0x190, 12, 0, 0, SELF); } } diff --git a/src/map/clif.h b/src/map/clif.h index 6d6c368f2..534f04ed7 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -844,8 +844,8 @@ struct clif_interface { void (*wis_message) (int fd, const char* nick, const char* mes, size_t mes_len); void (*wis_end) (int fd, int flag); void (*disp_message) (struct block_list* src, const char* mes, size_t len, enum send_target target); - void (*broadcast) (struct block_list* bl, const char* mes, size_t len, int type, enum send_target target); - void (*broadcast2) (struct block_list* bl, const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target); + void (*broadcast) (struct block_list *bl, const char *mes, int len, int type, enum send_target target); + void (*broadcast2) (struct block_list *bl, const char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target); void (*messagecolor_self) (int fd, uint32 color, const char *msg); void (*messagecolor) (struct block_list* bl, uint32 color, const char* msg); void (*disp_overhead) (struct block_list *bl, const char* mes); diff --git a/src/map/duel.c b/src/map/duel.c index c658ea3e3..86c218acd 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -134,7 +134,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_sd(target_sd,374), sd->status.name); - clif->broadcast(&target_sd->bl, output, strlen(output)+1, BC_BLUE, SELF); + clif->broadcast(&target_sd->bl, output, (int)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 e71f3df48..85270546e 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -150,7 +150,7 @@ int intif_rename(struct map_session_data *sd, int type, const char *name) } // GM Send a message -int intif_broadcast(const char* mes, size_t len, int type) +int intif_broadcast(const char *mes, int len, int type) { int lp = (type&BC_COLOR_MASK) ? 4 : 0; @@ -182,7 +182,7 @@ int intif_broadcast(const char* mes, size_t len, int type) return 0; } -int intif_broadcast2(const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY) +int intif_broadcast2(const char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY) { nullpo_ret(mes); Assert_ret(len < 32000); @@ -222,7 +222,7 @@ int intif_main_message(struct map_session_data* sd, const char* message) snprintf( output, sizeof(output), msg_txt(386), sd->status.name, message ); // send the message using the inter-server broadcast service - intif->broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 ); + intif->broadcast2(output, (int)strlen(output) + 1, 0xFE000000, 0, 0, 0, 0); // log the chat message logs->chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message ); diff --git a/src/map/intif.h b/src/map/intif.h index dccd31d80..11d301ad0 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -59,8 +59,8 @@ struct intif_interface { int (*parse) (int fd); int (*create_pet)(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id, short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name); - int (*broadcast) (const char* mes, size_t len, int type); - int (*broadcast2) (const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY); + int (*broadcast) (const char *mes, int len, int type); + int (*broadcast2) (const char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY); int (*main_message) (struct map_session_data* sd, const char* message); int (*wis_message) (struct map_session_data *sd, const char *nick, const char *mes, size_t mes_len); int (*wis_message_to_gm) (char *Wisp_name, int permission, char *mes); diff --git a/src/map/mob.c b/src/map/mob.c index 6a2fc8304..36901b03b 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2447,7 +2447,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, BC_DEFAULT); + intif->broadcast(message, (int)strlen(message)+1, BC_DEFAULT); } /* heres the thing we got the feature set up however we're still discussing how to best define the ids, @@ -2600,7 +2600,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, rate/100.); //MSG: "'%s' won %s's %s (chance: %0.02f%%)" - intif->broadcast(message, strlen(message)+1, BC_DEFAULT); + intif->broadcast(message, (int)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 1c7c72944..3b436105f 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5341,7 +5341,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, 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, BC_DEFAULT); + intif->broadcast(message, (int)strlen(message)+1, BC_DEFAULT); } return 1; } @@ -10335,7 +10335,7 @@ int map_day_timer(int tid, int64 tick, int id, intptr_t data) { map->night_flag = 0; // 0=day, 1=night [Yor] map->foreachpc(pc->daynight_timer_sub); safestrncpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60), sizeof(tmp_soutput)); // The day has arrived! - intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, BC_DEFAULT); + intif->broadcast(tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT); return 0; } @@ -10355,7 +10355,7 @@ int map_night_timer(int tid, int64 tick, int id, intptr_t data) { map->night_flag = 1; // 0=day, 1=night [Yor] map->foreachpc(pc->daynight_timer_sub); safestrncpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59), sizeof(tmp_soutput)); // The night has fallen... - intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, BC_DEFAULT); + intif->broadcast(tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT); return 0; } diff --git a/src/map/script.c b/src/map/script.c index e76f62f49..f62bfa972 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10507,7 +10507,8 @@ 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; @@ -10515,6 +10516,8 @@ BUILDIN(announce) { int fontSize = script_hasdata(st,6) ? script_getnum(st,6) : 12; // default fontSize 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 + size_t len = strlen(mes); + Assert_retr(false, len < INT_MAX); if( flag&(BC_TARGET_MASK|BC_SOURCE_MASK) ) { // Broadcast source or broadcast region defined @@ -10539,14 +10542,14 @@ BUILDIN(announce) { } if (fontColor) - clif->broadcast2(bl, mes, (int)strlen(mes)+1, (unsigned int)strtoul(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY, target); + clif->broadcast2(bl, mes, (int)len+1, (unsigned int)strtoul(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY, target); else - clif->broadcast(bl, mes, (int)strlen(mes)+1, flag&BC_COLOR_MASK, target); + clif->broadcast(bl, mes, (int)len+1, flag&BC_COLOR_MASK, target); } else { if (fontColor) - intif->broadcast2(mes, (int)strlen(mes)+1, (unsigned int)strtoul(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY); + intif->broadcast2(mes, (int)len+1, (unsigned int)strtoul(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY); else - intif->broadcast(mes, (int)strlen(mes)+1, flag&BC_COLOR_MASK); + intif->broadcast(mes, (int)len+1, flag&BC_COLOR_MASK); } return true; } @@ -10554,10 +10557,10 @@ BUILDIN(announce) { *------------------------------------------*/ int buildin_announce_sub(struct block_list *bl, va_list ap) { - char *mes = va_arg(ap, char *); + const char *mes = va_arg(ap, const char *); int len = va_arg(ap, int); int type = va_arg(ap, int); - char *fontColor = va_arg(ap, char *); + const char *fontColor = va_arg(ap, const char *); short fontType = (short)va_arg(ap, int); short fontSize = (short)va_arg(ap, int); short fontAlign = (short)va_arg(ap, int); @@ -10604,7 +10607,8 @@ BUILDIN(itemeffect) return true; } -BUILDIN(mapannounce) { +BUILDIN(mapannounce) +{ const char *mapname = script_getstr(st,2); const char *mes = script_getstr(st,3); int flag = script_getnum(st,4); @@ -10614,17 +10618,20 @@ BUILDIN(mapannounce) { int fontAlign = script_hasdata(st,8) ? script_getnum(st,8) : 0; // default fontAlign int fontY = script_hasdata(st,9) ? script_getnum(st,9) : 0; // default fontY int16 m; + size_t len = strlen(mes); + Assert_retr(false, len < INT_MAX); if ((m = map->mapname2mapid(mapname)) < 0) return true; map->foreachinmap(script->buildin_announce_sub, m, BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + mes, (int)len+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } /*========================================== *------------------------------------------*/ -BUILDIN(areaannounce) { +BUILDIN(areaannounce) +{ const char *mapname = script_getstr(st,2); int x0 = script_getnum(st,3); int y0 = script_getnum(st,4); @@ -10638,12 +10645,14 @@ BUILDIN(areaannounce) { int fontAlign = script_hasdata(st,12) ? script_getnum(st,12) : 0; // default fontAlign int fontY = script_hasdata(st,13) ? script_getnum(st,13) : 0; // default fontY int16 m; + size_t len = strlen(mes); + Assert_retr(false, len < INT_MAX); if ((m = map->mapname2mapid(mapname)) < 0) return true; map->foreachinarea(script->buildin_announce_sub, m, x0, y0, x1, y1, BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + mes, (int)len+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } @@ -18017,7 +18026,8 @@ BUILDIN(instance_init) { return true; } -BUILDIN(instance_announce) { +BUILDIN(instance_announce) +{ int instance_id = script_getnum(st,2); const char *mes = script_getstr(st,3); int flag = script_getnum(st,4); @@ -18026,8 +18036,9 @@ BUILDIN(instance_announce) { int fontSize = script_hasdata(st,7) ? script_getnum(st,7) : 12; // default fontSize int fontAlign = script_hasdata(st,8) ? script_getnum(st,8) : 0; // default fontAlign int fontY = script_hasdata(st,9) ? script_getnum(st,9) : 0; // default fontY - int i; + size_t len = strlen(mes); + Assert_retr(false, len < INT_MAX); if( instance_id == -1 ) { if( st->instance_id >= 0 ) @@ -18041,7 +18052,7 @@ BUILDIN(instance_announce) { for( i = 0; i < instance->list[instance_id].num_map; i++ ) map->foreachinmap(script->buildin_announce_sub, instance->list[instance_id].map[i], BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + mes, (int)len+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } |