summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/atcommand.c1028
-rw-r--r--src/map/atcommand.h5
-rw-r--r--src/map/battle.c60
-rw-r--r--src/map/battleground.c22
-rw-r--r--src/map/buyingstore.c16
-rw-r--r--src/map/channel.c19
-rw-r--r--src/map/chat.c10
-rw-r--r--src/map/chrif.c31
-rw-r--r--src/map/clif.c922
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/duel.c12
-rw-r--r--src/map/guild.c2
12 files changed, 1465 insertions, 664 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 105f3304c..190b2179a 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -67,6 +67,7 @@ static char atcmd_player_name[NAME_LENGTH];
struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
int i = 0;
+ nullpo_retr(NULL, name);
if( *name == atcommand->at_symbol || *name == atcommand->char_symbol )
name++; // for backwards compatibility
@@ -76,18 +77,16 @@ struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
}
const char* atcommand_msgsd(struct map_session_data *sd, int msg_number) {
- if( !(msg_number >= 0 && msg_number < MAX_MSG) )
- return "??";
- if( !sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number] )
+ Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG);
+ if (!sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number])
return atcommand->msg_table[0][msg_number];
return atcommand->msg_table[sd->lang_id][msg_number];
}
const char* atcommand_msgfd(int fd, int msg_number) {
struct map_session_data *sd = sockt->session_is_valid(fd) ? sockt->session[fd]->session_data : NULL;
- if( !(msg_number >= 0 && msg_number < MAX_MSG) )
- return "??";
- if( !sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number] )
+ Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG);
+ if (!sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number])
return atcommand->msg_table[0][msg_number];
return atcommand->msg_table[sd->lang_id][msg_number];
}
@@ -96,13 +95,12 @@ const char* atcommand_msgfd(int fd, int msg_number) {
// Return the message string of the specified number by [Yor]
//-----------------------------------------------------------
const char* atcommand_msg(int msg_number) {
- if (msg_number >= 0 && msg_number < MAX_MSG) {
- if(atcommand->msg_table[map->default_lang_id][msg_number] != NULL && atcommand->msg_table[map->default_lang_id][msg_number][0] != '\0')
- return atcommand->msg_table[map->default_lang_id][msg_number];
-
- if(atcommand->msg_table[0][msg_number] != NULL && atcommand->msg_table[0][msg_number][0] != '\0')
- return atcommand->msg_table[0][msg_number];
- }
+ Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG);
+ if (atcommand->msg_table[map->default_lang_id][msg_number] != NULL && atcommand->msg_table[map->default_lang_id][msg_number][0] != '\0')
+ return atcommand->msg_table[map->default_lang_id][msg_number];
+
+ if(atcommand->msg_table[0][msg_number] != NULL && atcommand->msg_table[0][msg_number][0] != '\0')
+ return atcommand->msg_table[0][msg_number];
return "??";
}
@@ -120,6 +118,7 @@ bool msg_config_read(const char *cfg_name, bool allow_override) {
FILE *fp;
static int called = 1;
+ nullpo_retr(false, cfg_name);
if ((fp = fopen(cfg_name, "r")) == NULL) {
ShowError("Messages file not found: %s\n", cfg_name);
return false;
@@ -135,7 +134,7 @@ bool msg_config_read(const char *cfg_name, bool allow_override) {
continue;
if (strcmpi(w1, "import") == 0) {
- msg_config_read(w2, true);
+ atcommand->msg_read(w2, true);
} else {
msg_number = atoi(w1);
if (msg_number >= 0 && msg_number < MAX_MSG) {
@@ -210,7 +209,7 @@ ACMD(send)
long num;
// read message type as hex number (without the 0x)
- if (!message || !*message
+ if (!*message
|| !((sscanf(message, "len %x", &type)==1 && (len=1))
|| sscanf(message, "%x", &type)==1)
) {
@@ -223,7 +222,7 @@ ACMD(send)
#define PARSE_ERROR(error,p) do {\
clif->message(fd, (error));\
- sprintf(atcmd_output, ">%s", (p));\
+ safesnprintf(atcmd_output, sizeof(atcmd_output), ">%s", (p));\
clif->message(fd, atcmd_output);\
} while(0) //define PARSE_ERROR
@@ -250,7 +249,7 @@ ACMD(send)
int off = 2;
if (len) {
// show packet length
- sprintf(atcmd_output, msg_fd(fd,904), type, packet_db[type].len); // Packet 0x%x length: %d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, packet_db[type].len); // Packet 0x%x length: %d
clif->message(fd, atcmd_output);
return true;
}
@@ -258,7 +257,7 @@ ACMD(send)
len=packet_db[type].len;
if (len == 0) {
// unknown packet - ERROR
- sprintf(atcmd_output, msg_fd(fd,905), type); // Unknown packet: 0x%x
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,905), type); // Unknown packet: 0x%x
clif->message(fd, atcmd_output);
return false;
} else if (len == -1) {
@@ -438,9 +437,9 @@ ACMD(mapmove) {
memset(map_name, '\0', sizeof(map_name));
- if (!message || !*message ||
- (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
- sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
+ if (!*message ||
+ (sscanf(message, "%15s %5hd %5hd", map_name, &x, &y) < 3 &&
+ sscanf(message, "%15[^,],%5hd,%5hd", map_name, &x, &y) < 1)) {
clif->message(fd, msg_fd(fd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
return false;
}
@@ -490,7 +489,7 @@ ACMD(where) {
memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_fd(fd,910)); // Please enter a player name (usage: @where <char name>).
return false;
}
@@ -516,7 +515,7 @@ ACMD(where) {
ACMD(jumpto) {
struct map_session_data *pl_sd = NULL;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
return false;
}
@@ -547,7 +546,7 @@ ACMD(jumpto) {
}
pc->setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
- sprintf(atcmd_output, msg_fd(fd,4), pl_sd->status.name); // Jumped to %s
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,4), pl_sd->status.name); // Jumped to %s
clif->message(fd, atcmd_output);
return true;
@@ -562,7 +561,7 @@ ACMD(jump)
memset(atcmd_output, '\0', sizeof(atcmd_output));
- sscanf(message, "%hd %hd", &x, &y);
+ sscanf(message, "%5hd %5hd", &x, &y);
if (map->list[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_fd(fd,248)); // You are not authorized to warp from your current map.
@@ -581,13 +580,13 @@ ACMD(jump)
x = y = 0; //Invalid cell, use random spot.
}
- if( x && y && sd->bl.x == x && sd->bl.y == y ) {
+ if (x && y && sd->bl.x == x && sd->bl.y == y) {
clif->message(fd, msg_fd(fd,253)); // You already are at your destination!
return false;
}
pc->setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
- sprintf(atcmd_output, msg_fd(fd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
clif->message(fd, atcmd_output);
return true;
}
@@ -735,18 +734,18 @@ ACMD(whogm)
if (pl_level > level) {
if (pc_isinvisible(pl_sd))
continue;
- sprintf(atcmd_output, msg_fd(fd,913), pl_sd->status.name); // Name: %s (GM)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,913), pl_sd->status.name); // Name: %s (GM)
clif->message(fd, atcmd_output);
count++;
continue;
}
- sprintf(atcmd_output, msg_fd(fd,914), // Name: %s (GM:%d) | Location: %s %d %d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,914), // Name: %s (GM:%d) | Location: %s %d %d
pl_sd->status.name, pl_level,
mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,915), // BLvl: %d | Job: %s (Lvl: %d)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,915), // BLvl: %d | Job: %s (Lvl: %d)
pl_sd->status.base_level,
pc->job_name(pl_sd->status.class_), pl_sd->status.job_level);
clif->message(fd, atcmd_output);
@@ -754,7 +753,7 @@ ACMD(whogm)
p = party->search(pl_sd->status.party_id);
g = pl_sd->guild;
- sprintf(atcmd_output,msg_fd(fd,916), // Party: '%s' | Guild: '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,916), // Party: '%s' | Guild: '%s'
p?p->party.name:msg_fd(fd,917), g?g->name:msg_fd(fd,917)); // None.
clif->message(fd, atcmd_output);
@@ -767,7 +766,7 @@ ACMD(whogm)
else if (count == 1)
clif->message(fd, msg_fd(fd,151)); // 1 GM found.
else {
- sprintf(atcmd_output, msg_fd(fd,152), count); // %d GMs found.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,152), count); // %d GMs found.
clif->message(fd, atcmd_output);
}
@@ -821,8 +820,8 @@ ACMD(speed)
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
- sprintf(atcmd_output, msg_fd(fd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
+ if (!*message || sscanf(message, "%12d", &speed) < 1) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
clif->message(fd, atcmd_output);
return false;
}
@@ -903,7 +902,7 @@ ACMD(option)
{
int param1 = 0, param2 = 0, param3 = 0;
- if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
+ if (!*message || sscanf(message, "%12d %12d %12d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
{// failed to match the parameters so inform the user of the options
const char* text;
@@ -976,7 +975,7 @@ ACMD(jobchange) {
int job = 0, upper = 0;
const char* text;
- if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
+ if (!*message || sscanf(message, "%12d %12d", &job, &upper) < 1) {
upper = 0;
if( message ) {
@@ -1070,7 +1069,7 @@ ACMD(kami)
memset(atcmd_output, '\0', sizeof(atcmd_output));
if(*(info->command + 4) != 'c' && *(info->command + 4) != 'C') {
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,980)); // Please enter a message (usage: @kami <message>).
return false;
}
@@ -1081,7 +1080,7 @@ ACMD(kami)
else
intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(info->command + 4) == 'b' || *(info->command + 4) == 'B') ? BC_BLUE : BC_YELLOW);
} else {
- if(!message || !*message || (sscanf(message, "%u %199[^\n]", &color, atcmd_output) < 2)) {
+ 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>).
return false;
}
@@ -1102,7 +1101,7 @@ ACMD(heal)
{
int hp = 0, sp = 0; // [Valaris] thanks to fov
- sscanf(message, "%d %d", &hp, &sp);
+ sscanf(message, "%12d %12d", &hp, &sp);
// some overflow checks
if( hp == INT_MIN ) hp++;
@@ -1166,15 +1165,15 @@ ACMD(item)
memset(item_name, '\0', sizeof(item_name));
- if (!strcmpi(info->command,"itembound") && (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 2 &&
- sscanf(message, "%99s %d %d", item_name, &number, &bound) < 2
+ if (!strcmpi(info->command,"itembound") && (!*message || (
+ sscanf(message, "\"%99[^\"]\" %12d %12d", item_name, &number, &bound) < 2 &&
+ sscanf(message, "%99s %12d %12d", item_name, &number, &bound) < 2
))) {
clif->message(fd, msg_fd(fd,295)); // Please enter an item name or ID (usage: @itembound <item name/ID> <quantity> <bound_type>).
return false;
- } else if (!message || !*message
- || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1
- && sscanf(message, "%99s %d", item_name, &number) < 1
+ } else if (!*message
+ || ( sscanf(message, "\"%99[^\"]\" %12d", item_name, &number) < 1
+ && sscanf(message, "%99s %12d", item_name, &number) < 1
)) {
clif->message(fd, msg_fd(fd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
return false;
@@ -1257,15 +1256,15 @@ ACMD(item2)
memset(item_name, '\0', sizeof(item_name));
- if (!strcmpi(info->command,"itembound2") && (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
- sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) {
+ if (!strcmpi(info->command,"itembound2") && (!*message || (
+ sscanf(message, "\"%99[^\"]\" %12d %12d %12d %12d %12d %12d %12d %12d %12d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
+ sscanf(message, "%99s %12d %12d %12d %12d %12d %12d %12d %12d %12d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) {
clif->message(fd, msg_fd(fd,296)); // Please enter all parameters (usage: @itembound2 <item name/ID> <quantity>
clif->message(fd, msg_fd(fd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
return false;
- } else if ( !message || !*message
- || ( sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
- && sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
+ } else if (!*message
+ || ( sscanf(message, "\"%99[^\"]\" %12d %12d %12d %12d %12d %12d %12d %12d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
+ && sscanf(message, "%99s %12d %12d %12d %12d %12d %12d %12d %12d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
)) {
clif->message(fd, msg_fd(fd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
clif->message(fd, msg_fd(fd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
@@ -1361,7 +1360,7 @@ ACMD(baselevelup)
{
int level=0, i=0, status_point=0;
- if (!message || !*message || !(level = atoi(message))) {
+ if (!*message || !(level = atoi(message))) {
clif->message(fd, msg_fd(fd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
return false;
}
@@ -1420,7 +1419,7 @@ ACMD(joblevelup)
{
int level=0;
- if (!message || !*message || !(level = atoi(message))) {
+ if (!*message || !(level = atoi(message))) {
clif->message(fd, msg_fd(fd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
return false;
}
@@ -1470,7 +1469,7 @@ ACMD(help) {
char *default_command = "help";
AtCommandInfo *tinfo = NULL;
- if (!message || !*message) {
+ if (!*message) {
command_name = default_command; // If no command_name specified, display help for @help.
} else {
if (*message == atcommand->at_symbol || *message == atcommand->char_symbol)
@@ -1479,7 +1478,7 @@ ACMD(help) {
}
if (!atcommand->can_use2(sd, command_name, COMMAND_ATCOMMAND)) {
- sprintf(atcmd_output, msg_fd(fd,153), message); // "%s is Unknown Command"
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,153), message); // "%s is Unknown Command"
clif->message(fd, atcmd_output);
atcommand->get_suggestions(sd, command_name, true);
return false;
@@ -1488,13 +1487,13 @@ ACMD(help) {
tinfo = atcommand->get_info_byname(atcommand->check_alias(command_name));
if ( !tinfo || tinfo->help == NULL ) {
- sprintf(atcmd_output, msg_fd(fd,988), atcommand->at_symbol, command_name); // There is no help for %c%s.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,988), atcommand->at_symbol, command_name); // There is no help for %c%s.
clif->message(fd, atcmd_output);
atcommand->get_suggestions(sd, command_name, true);
return false;
}
- sprintf(atcmd_output, msg_fd(fd,989), atcommand->at_symbol, command_name); // Help for command %c%s:
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,989), atcommand->at_symbol, command_name); // Help for command %c%s:
clif->message(fd, atcmd_output);
{ // Display aliases
@@ -1530,6 +1529,7 @@ ACMD(help) {
int atcommand_stopattack(struct block_list *bl,va_list ap)
{
struct unit_data *ud = unit->bl2ud(bl);
+ nullpo_ret(bl);
int id = va_arg(ap, int);
if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
{
@@ -1538,12 +1538,14 @@ int atcommand_stopattack(struct block_list *bl,va_list ap)
}
return 0;
}
+
/*==========================================
*
*------------------------------------------*/
int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
{
TBL_PC* sd = (TBL_PC*)bl;
+ nullpo_ret(bl);
clif->pvpset(sd, 0, 0, 2);
if (sd->pvp_timer != INVALID_TIMER) {
timer->delete(sd->pvp_timer, pc->calc_pvprank_timer);
@@ -1578,6 +1580,7 @@ ACMD(pvpoff)
int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
{
TBL_PC* sd = (TBL_PC*)bl;
+ nullpo_ret(bl);
if (sd->pvp_timer == INVALID_TIMER) {
sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0);
sd->pvp_rank = 0;
@@ -1658,8 +1661,8 @@ ACMD(model)
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
- sprintf(atcmd_output, msg_fd(fd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
+ if (!*message || sscanf(message, "%12d %12d %12d", &hair_style, &hair_color, &cloth_color) < 1) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
clif->message(fd, atcmd_output);
return false;
@@ -1689,8 +1692,8 @@ ACMD(dye)
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
- sprintf(atcmd_output, msg_fd(fd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
+ if (!*message || sscanf(message, "%12d", &cloth_color) < 1) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
clif->message(fd, atcmd_output);
return false;
}
@@ -1715,8 +1718,8 @@ ACMD(hair_style)
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
- sprintf(atcmd_output, msg_fd(fd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
+ if (!*message || sscanf(message, "%12d", &hair_style) < 1) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
clif->message(fd, atcmd_output);
return false;
}
@@ -1741,8 +1744,8 @@ ACMD(hair_color)
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
- sprintf(atcmd_output, msg_fd(fd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
+ if (!*message || sscanf(message, "%12d", &hair_color) < 1) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
clif->message(fd, atcmd_output);
return false;
}
@@ -1815,7 +1818,7 @@ ACMD(go) {
memset(map_name, '\0', sizeof(map_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%11s", map_name) < 1) {
+ if (!*message || sscanf(message, "%11s", map_name) < 1) {
// no value matched so send the list of locations
const char* text;
@@ -1824,7 +1827,7 @@ ACMD(go) {
clif->message(fd, msg_fd(fd,38)); // Invalid location number, or name.
- if( text ) {// send the text to the client
+ if (text) { // send the text to the client
clif->messageln( fd, text );
}
@@ -1915,18 +1918,18 @@ ACMD(monster)
memset(monster, '\0', sizeof(monster));
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,80)); // Please specify a display name or monster name/id.
return false;
}
- if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
- sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
+ if (sscanf(message, "\"%23[^\"]\" %23s %12d", name, monster, &number) > 1 ||
+ sscanf(message, "%23s \"%23[^\"]\" %12d", monster, name, &number) > 1) {
//All data can be left as it is.
- } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
+ } else if ((count=sscanf(message, "%23s %12d %23s", monster, &number, name)) > 1) {
//Here, it is possible name was not given and we are using monster for it.
if (count < 3) //Blank mob's name.
name[0] = '\0';
- } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
+ } else if (sscanf(message, "%23s %23s %12d", name, monster, &number) > 1) {
//All data can be left as it is.
} else if (sscanf(message, "%23s", monster) > 0) {
//As before, name may be already filled.
@@ -1947,7 +1950,7 @@ ACMD(monster)
if (number <= 0)
number = 1;
- if( !name[0] )
+ if (!name[0])
strcpy(name, "--ja--");
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
@@ -1977,7 +1980,7 @@ ACMD(monster)
if (number == count)
clif->message(fd, msg_fd(fd,39)); // All monster summoned!
else {
- sprintf(atcmd_output, msg_fd(fd,240), count); // %d monster(s) summoned!
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,240), count); // %d monster(s) summoned!
clif->message(fd, atcmd_output);
}
else {
@@ -1993,12 +1996,10 @@ ACMD(monster)
*------------------------------------------*/
int atkillmonster_sub(struct block_list *bl, va_list ap)
{
- struct mob_data *md;
- int flag;
-
- nullpo_ret(md=(struct mob_data *)bl);
- flag = va_arg(ap, int);
+ struct mob_data *md = (struct mob_data *)bl;
+ int flag = va_arg(ap, int);
+ nullpo_ret(bl);
if (md->guardian_data)
return 0; //Do not touch WoE mobs!
@@ -2015,9 +2016,9 @@ ACMD(killmonster) {
memset(map_name, '\0', sizeof(map_name));
- if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
+ if (!*message || sscanf(message, "%15s", map_name) < 1) {
map_id = sd->bl.m;
- else {
+ } else {
if ((map_id = map->mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
@@ -2041,27 +2042,27 @@ ACMD(refine)
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
+ if (!*message || sscanf(message, "%12d %12d", &position, &refine) < 2) {
clif->message(fd, msg_fd(fd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
- sprintf(atcmd_output, msg_fd(fd,997), EQP_HEAD_LOW); // %d: Lower Headgear
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,997), EQP_HEAD_LOW); // %d: Lower Headgear
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,998), EQP_HAND_R); // %d: Right Hand
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,998), EQP_HAND_R); // %d: Right Hand
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,999), EQP_GARMENT); // %d: Garment
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,999), EQP_GARMENT); // %d: Garment
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1000), EQP_ACC_L); // %d: Left Accessory
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1000), EQP_ACC_L); // %d: Left Accessory
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1001), EQP_ARMOR); // %d: Body Armor
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1001), EQP_ARMOR); // %d: Body Armor
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1002), EQP_HAND_L); // %d: Left Hand
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1002), EQP_HAND_L); // %d: Left Hand
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1003), EQP_SHOES); // %d: Shoes
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1003), EQP_SHOES); // %d: Shoes
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1004), EQP_ACC_R); // %d: Right Accessory
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1004), EQP_ACC_R); // %d: Right Accessory
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1005), EQP_HEAD_TOP); // %d: Top Headgear
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1005), EQP_HEAD_TOP); // %d: Top Headgear
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1006), EQP_HEAD_MID); // %d: Mid Headgear
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1006), EQP_HEAD_MID); // %d: Mid Headgear
clif->message(fd, atcmd_output);
return false;
}
@@ -2103,7 +2104,7 @@ ACMD(refine)
else if (count == 1)
clif->message(fd, msg_fd(fd,167)); // 1 item has been refined.
else {
- sprintf(atcmd_output, msg_fd(fd,168), count); // %d items have been refined.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,168), count); // %d items have been refined.
clif->message(fd, atcmd_output);
}
@@ -2123,9 +2124,9 @@ ACMD(produce)
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(item_name, '\0', sizeof(item_name));
- if (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
- sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
+ if (!*message || (
+ sscanf(message, "\"%99[^\"]\" %12d %12d", item_name, &attribute, &star) < 1 &&
+ sscanf(message, "%99s %12d %12d", item_name, &attribute, &star) < 1
)) {
clif->message(fd, msg_fd(fd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
return false;
@@ -2160,7 +2161,7 @@ ACMD(produce)
if ((flag = pc->additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
} else {
- sprintf(atcmd_output, msg_fd(fd,169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
clif->message(fd, atcmd_output);
return false;
}
@@ -2177,16 +2178,16 @@ ACMD(memo)
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if( !message || !*message || sscanf(message, "%d", &position) < 1 )
+ if (!*message || sscanf(message, "%d", &position) < 1)
{
int i;
clif->message(sd->fd, msg_fd(fd,868)); // "Your current memo positions are:"
for( i = 0; i < MAX_MEMOPOINTS; i++ )
{
if( sd->status.memo_point[i].map )
- sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
else
- sprintf(atcmd_output, msg_fd(fd,171), i); // %d - void
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,171), i); // %d - void
clif->message(sd->fd, atcmd_output);
}
return true;
@@ -2194,7 +2195,7 @@ ACMD(memo)
if( position < 0 || position >= MAX_MEMOPOINTS )
{
- sprintf(atcmd_output, msg_fd(fd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
clif->message(fd, atcmd_output);
return false;
}
@@ -2212,7 +2213,7 @@ ACMD(gat) {
memset(atcmd_output, '\0', sizeof(atcmd_output));
for (y = 2; y >= -2; y--) {
- sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
+ safesnprintf(atcmd_output, sizeof(atcmd_output), "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
map->list[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
map->getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
map->getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
@@ -2233,7 +2234,7 @@ ACMD(displaystatus)
{
int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
- if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
+ if (!*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
clif->message(fd, msg_fd(fd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
return false;
}
@@ -2256,7 +2257,7 @@ ACMD(statuspoint)
int point;
unsigned int new_status_point;
- if (!message || !*message || (point = atoi(message)) == 0) {
+ if (!*message || (point = atoi(message)) == 0) {
clif->message(fd, msg_fd(fd,1010)); // Please enter a number (usage: @stpoint <number of points>).
return false;
}
@@ -2304,7 +2305,7 @@ ACMD(skillpoint)
int point;
unsigned int new_skill_point;
- if (!message || !*message || (point = atoi(message)) == 0) {
+ if (!*message || (point = atoi(message)) == 0) {
clif->message(fd, msg_fd(fd,1011)); // Please enter a number (usage: @skpoint <number of points>).
return false;
}
@@ -2351,12 +2352,12 @@ ACMD(zeny)
{
int zeny=0, ret=-1;
- if (!message || !*message || (zeny = atoi(message)) == 0) {
+ if (!*message || (zeny = atoi(message)) == 0) {
clif->message(fd, msg_fd(fd,1012)); // Please enter an amount (usage: @zeny <amount>).
return false;
}
- if(zeny > 0){
+ if(zeny > 0) {
if((ret=pc->getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
clif->message(fd, msg_fd(fd,149)); // Unable to increase the number/value.
}
@@ -2384,7 +2385,7 @@ ACMD(param) {
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
+ if (!*message || sscanf(message, "%d", &value) < 1 || value == 0) {
clif->message(fd, msg_fd(fd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
return false;
}
@@ -2448,7 +2449,7 @@ ACMD(stat_all) {
stats[4] = &sd->status.dex;
stats[5] = &sd->status.luk;
- if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
+ if (!*message || sscanf(message, "%d", &value) < 1 || value == 0) {
value = pc_maxparameter(sd);
max = pc_maxparameter(sd);
} else {
@@ -2497,7 +2498,7 @@ ACMD(guildlevelup) {
int16 added_level;
struct guild *guild_info;
- if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
+ if (!*message || sscanf(message, "%d", &level) < 1 || level == 0) {
clif->message(fd, msg_fd(fd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
return false;
}
@@ -2538,7 +2539,7 @@ ACMD(makeegg)
struct item_data *item_data;
int id, pet_id;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
return false;
}
@@ -2592,7 +2593,7 @@ ACMD(petfriendly)
int friendly;
struct pet_data *pd;
- if (!message || !*message || (friendly = atoi(message)) < 0) {
+ if (!*message || (friendly = atoi(message)) < 0) {
clif->message(fd, msg_fd(fd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
return false;
}
@@ -2628,7 +2629,7 @@ ACMD(pethungry)
int hungry;
struct pet_data *pd;
- if (!message || !*message || (hungry = atoi(message)) < 0) {
+ if (!*message || (hungry = atoi(message)) < 0) {
clif->message(fd, msg_fd(fd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
return false;
}
@@ -2684,7 +2685,7 @@ ACMD(petrename)
ACMD(recall) {
struct map_session_data *pl_sd = NULL;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
return false;
}
@@ -2712,7 +2713,7 @@ ACMD(recall) {
return false;
}
pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
- sprintf(atcmd_output, msg_fd(fd,46), pl_sd->status.name); // %s recalled!
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,46), pl_sd->status.name); // %s recalled!
clif->message(fd, atcmd_output);
return true;
@@ -2727,7 +2728,7 @@ ACMD(char_block)
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_fd(fd,1021)); // Please enter a player name (usage: @block <char name>).
return false;
}
@@ -2763,7 +2764,7 @@ ACMD(char_ban)
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
+ if (!*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
clif->message(fd, msg_fd(fd,1022)); // Please enter ban time and a player name (usage: @ban <time> <char name>).
return false;
}
@@ -2842,7 +2843,7 @@ ACMD(char_unblock)
{
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_fd(fd,1024)); // Please enter a player name (usage: @unblock <char name>).
return false;
}
@@ -2861,7 +2862,7 @@ ACMD(char_unban)
{
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_fd(fd,1025)); // Please enter a player name (usage: @unban <char name>).
return false;
}
@@ -2959,6 +2960,7 @@ ACMD(doommap)
*------------------------------------------*/
void atcommand_raise_sub(struct map_session_data* sd)
{
+ nullpo_retv(sd);
status->revive(&sd->bl, 100, 100);
clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
@@ -3012,7 +3014,7 @@ ACMD(kick)
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
return false;
}
@@ -3022,7 +3024,7 @@ ACMD(kick)
return false;
}
- if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
+ if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
{
clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorize you to do this action on this player.
return false;
@@ -3042,7 +3044,7 @@ ACMD(kickall)
struct s_mapiterator* iter;
iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
+ for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter))
{
if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
if (sd->status.account_id != pl_sd->status.account_id)
@@ -3076,8 +3078,8 @@ ACMD(questskill)
{
uint16 skill_id, index;
- if (!message || !*message || (skill_id = atoi(message)) <= 0)
- {// also send a list of skills applicable to this command
+ if (!*message || (skill_id = atoi(message)) <= 0)
+ { // also send a list of skills applicable to this command
const char* text;
// attempt to find the text corresponding to this command
@@ -3118,8 +3120,8 @@ ACMD(lostskill)
{
uint16 skill_id, index;
- if (!message || !*message || (skill_id = atoi(message)) <= 0)
- {// also send a list of skills applicable to this command
+ if (!*message || (skill_id = atoi(message)) <= 0)
+ { // also send a list of skills applicable to this command
const char* text;
// attempt to find the text corresponding to this command
@@ -3134,7 +3136,7 @@ ACMD(lostskill)
return false;
}
- if ( !( index = skill->get_index(skill_id) ) ) {
+ if (!( index = skill->get_index(skill_id))) {
clif->message(fd, msg_fd(fd,198)); // This skill number doesn't exist.
return false;
}
@@ -3165,7 +3167,7 @@ ACMD(spiritball)
max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
- if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
+ if (!*message || (number = atoi(message)) < 0 || number > max_spiritballs)
{
char msg[CHAT_SIZE_MAX];
safesnprintf(msg, sizeof(msg), msg_fd(fd,1028), max_spiritballs); // Please enter an amount (usage: @spiritball <number: 0-%d>).
@@ -3191,7 +3193,7 @@ ACMD(party)
memset(party_name, '\0', sizeof(party_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_fd(fd,1029)); // Please enter a party name (usage: @party <party_name>).
return false;
}
@@ -3211,7 +3213,7 @@ ACMD(guild)
memset(guild_name, '\0', sizeof(guild_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_fd(fd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
return false;
}
@@ -3227,8 +3229,7 @@ ACMD(guild)
ACMD(breakguild)
{
if (sd->status.guild_id) { // Check if the player has a guild
- struct guild *g;
- g = sd->guild; // Search the guild
+ struct guild *g = sd->guild; // Search the guild
if (g) { // Check if guild was found
if (sd->state.gmaster_flag) { // Check if player is guild master
int ret = 0;
@@ -3337,24 +3338,24 @@ ACMD(idsearch)
memset(item_name, '\0', sizeof(item_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
+ if (!*message || sscanf(message, "%99s", item_name) < 0) {
clif->message(fd, msg_fd(fd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
return false;
}
- sprintf(atcmd_output, msg_fd(fd,77), item_name); // Search results for '%s' (name: id):
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,77), item_name); // Search results for '%s' (name: id):
clif->message(fd, atcmd_output);
match = itemdb->search_name_array(item_array, MAX_SEARCH, item_name, 0);
if (match > MAX_SEARCH) {
- sprintf(atcmd_output, msg_fd(fd,269), MAX_SEARCH, match);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, match);
clif->message(fd, atcmd_output);
match = MAX_SEARCH;
}
for(i = 0; i < match; i++) {
- sprintf(atcmd_output, msg_fd(fd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
clif->message(fd, atcmd_output);
}
- sprintf(atcmd_output, msg_fd(fd,79), match); // %d results found.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,79), match); // %d results found.
clif->message(fd, atcmd_output);
return true;
@@ -3378,7 +3379,7 @@ ACMD(recallall)
count = 0;
iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
+ for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) {
if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) {
if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
continue; // Don't waste time warping the character to the same place.
@@ -3397,7 +3398,7 @@ ACMD(recallall)
clif->message(fd, msg_fd(fd,92)); // All characters recalled!
if (count) {
- sprintf(atcmd_output, msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
@@ -3418,7 +3419,7 @@ ACMD(guildrecall)
memset(guild_name, '\0', sizeof(guild_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_fd(fd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
return false;
}
@@ -3438,7 +3439,7 @@ ACMD(guildrecall)
count = 0;
iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
+ for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter))
{
if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) {
if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
@@ -3451,10 +3452,10 @@ ACMD(guildrecall)
}
mapit->free(iter);
- sprintf(atcmd_output, msg_fd(fd,93), g->name); // All online characters of the %s guild have been recalled to your position.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,93), g->name); // All online characters of the %s guild have been recalled to your position.
clif->message(fd, atcmd_output);
if (count) {
- sprintf(atcmd_output, msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
@@ -3475,7 +3476,7 @@ ACMD(partyrecall)
memset(party_name, '\0', sizeof(party_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_fd(fd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
return false;
}
@@ -3507,10 +3508,10 @@ ACMD(partyrecall)
}
mapit->free(iter);
- sprintf(atcmd_output, msg_fd(fd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
clif->message(fd, atcmd_output);
if (count) {
- sprintf(atcmd_output, msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
clif->message(fd, atcmd_output);
}
@@ -3658,7 +3659,7 @@ ACMD(reloadscript) {
//atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
+ for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) {
if (pl_sd->npc_id || pl_sd->npc_shopid) {
if (pl_sd->state.using_fake_npc) {
clif->clearunit_single(pl_sd->npc_id, CLR_OUTSIGHT, pl_sd->fd);
@@ -3709,7 +3710,7 @@ ACMD(mapinfo) {
memset(mapname, '\0', sizeof(mapname));
memset(direction, '\0', sizeof(direction));
- sscanf(message, "%d %23[^\n]", &list, mapname);
+ sscanf(message, "%12d %23[^\n]", &list, mapname);
if (list < 0 || list > 3) {
clif->message(fd, msg_fd(fd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
@@ -3744,7 +3745,7 @@ ACMD(mapinfo) {
}
mapit->free(iter);
- sprintf(atcmd_output, msg_fd(fd,1040), mapname, map->list[m_id].zone->name, map->list[m_id].users, map->list[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1040), mapname, map->list[m_id].zone->name, map->list[m_id].users, map->list[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1041)); // ------ Map Flags ------
if (map->list[m_id].flag.town)
@@ -3797,7 +3798,7 @@ ACMD(mapinfo) {
strcat(atcmd_output, msg_fd(fd,1064)); // NoMemo |
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
(map->list[m_id].flag.noexppenalty) ? msg_fd(fd,1066) : msg_fd(fd,1067),
(map->list[m_id].flag.nozenypenalty) ? msg_fd(fd,1066) : msg_fd(fd,1067)); // On / Off
clif->message(fd, atcmd_output);
@@ -3806,10 +3807,10 @@ ACMD(mapinfo) {
if (!map->list[m_id].save.map)
clif->message(fd, msg_fd(fd,1068)); // No Save (Return to last Save Point)
else if (map->list[m_id].save.x == -1 || map->list[m_id].save.y == -1 ) {
- sprintf(atcmd_output, msg_fd(fd,1069), mapindex_id2name(map->list[m_id].save.map)); // No Save, Save Point: %s,Random
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1069), mapindex_id2name(map->list[m_id].save.map)); // No Save, Save Point: %s,Random
clif->message(fd, atcmd_output);
} else {
- sprintf(atcmd_output, msg_fd(fd,1070), // No Save, Save Point: %s,%d,%d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1070), // No Save, Save Point: %s,%d,%d
mapindex_id2name(map->list[m_id].save.map),map->list[m_id].save.x,map->list[m_id].save.y);
clif->message(fd, atcmd_output);
}
@@ -3877,10 +3878,10 @@ ACMD(mapinfo) {
case 1:
clif->message(fd, msg_fd(fd,1098)); // ----- Players in Map -----
iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
+ for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter))
{
if (pl_sd->mapindex == m_index) {
- sprintf(atcmd_output, msg_fd(fd,1099), // Player '%s' (session #%d) | Location: %d,%d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1099), // Player '%s' (session #%d) | Location: %d,%d
pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
clif->message(fd, atcmd_output);
}
@@ -3904,27 +3905,27 @@ ACMD(mapinfo) {
default: strcpy(direction, msg_fd(fd,1110)); break; // Unknown
}
if(strcmp(nd->name,nd->exname) == 0)
- sprintf(atcmd_output, msg_fd(fd,1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
- ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
+ ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
else
- sprintf(atcmd_output, msg_fd(fd,1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
- ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
+ ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
clif->message(fd, atcmd_output);
}
break;
case 3:
clif->message(fd, msg_fd(fd,1113)); // ----- Chats in Map -----
iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
+ for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter))
{
if ((cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL &&
pl_sd->mapindex == m_index &&
cd->usersd[0] == pl_sd)
{
- sprintf(atcmd_output, msg_fd(fd,1114), // Chat: %s | Player: %s | Location: %d %d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1114), // Chat: %s | Player: %s | Location: %d %d
cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1115), // Users: %d/%d | Password: %s | Public: %s
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1115), // Users: %d/%d | Password: %s | Public: %s
cd->users, cd->limit, cd->pass, (cd->pub) ? msg_fd(fd,1116) : msg_fd(fd,1117)); // Yes / No
clif->message(fd, atcmd_output);
}
@@ -3949,14 +3950,14 @@ ACMD(mount_peco)
return false;
}
- if( sd->sc.data[SC_ALL_RIDING] ) {
+ if (sd->sc.data[SC_ALL_RIDING]) {
clif->message(fd, msg_fd(fd,1476)); // You are already mounting something else
return false;
}
- if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT ) {
- if( !pc->checkskill(sd,RK_DRAGONTRAINING) ) {
- sprintf(atcmd_output, msg_fd(fd,213), skill->get_desc(RK_DRAGONTRAINING)); // You need %s to mount!
+ if ((sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) {
+ if (!pc->checkskill(sd,RK_DRAGONTRAINING)) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(RK_DRAGONTRAINING)); // You need %s to mount!
clif->message(fd, atcmd_output);
return false;
}
@@ -3969,13 +3970,13 @@ ACMD(mount_peco)
}
return true;
}
- if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER ) {
- if( !pc->checkskill(sd,RA_WUGRIDER) ) {
- sprintf(atcmd_output, msg_fd(fd,213), skill->get_desc(RA_WUGRIDER)); // You need %s to mount!
+ if ((sd->class_&MAPID_THIRDMASK) == MAPID_RANGER) {
+ if (!pc->checkskill(sd,RA_WUGRIDER)) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(RA_WUGRIDER)); // You need %s to mount!
clif->message(fd, atcmd_output);
return false;
}
- if( !pc_isridingwug(sd) ) {
+ if (!pc_isridingwug(sd)) {
clif->message(sd->fd,msg_fd(fd,1121)); // You have mounted your Warg.
pc->setridingwug(sd, true);
} else {
@@ -3984,8 +3985,8 @@ ACMD(mount_peco)
}
return true;
}
- if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
- if( !pc_ismadogear(sd) ) {
+ if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) {
+ if (!pc_ismadogear(sd)) {
clif->message(sd->fd,msg_fd(fd,1123)); // You have mounted your Mado Gear.
pc->setmadogear(sd, true);
} else {
@@ -3994,10 +3995,10 @@ ACMD(mount_peco)
}
return true;
}
- if( sd->class_&MAPID_SWORDMAN && sd->class_&JOBL_2 ) {
+ if (sd->class_&MAPID_SWORDMAN && sd->class_&JOBL_2) {
if (!pc_isridingpeco(sd)) { // if actually no peco
if (!pc->checkskill(sd, KN_RIDING)) {
- sprintf(atcmd_output, msg_fd(fd,213), skill->get_desc(KN_RIDING)); // You need %s to mount!
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(KN_RIDING)); // You need %s to mount!
clif->message(fd, atcmd_output);
return false;
}
@@ -4028,7 +4029,7 @@ ACMD(guildspy) {
clif->message(fd, msg_fd(fd,1125)); // The mapserver has spy command support disabled.
return false;
}
- if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_fd(fd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
return false;
}
@@ -4037,11 +4038,11 @@ ACMD(guildspy) {
(g = guild->search(atoi(message))) != NULL) {
if (sd->guildspy == g->guild_id) {
sd->guildspy = 0;
- sprintf(atcmd_output, msg_fd(fd,103), g->name); // No longer spying on the %s guild.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,103), g->name); // No longer spying on the %s guild.
clif->message(fd, atcmd_output);
} else {
sd->guildspy = g->guild_id;
- sprintf(atcmd_output, msg_fd(fd,104), g->name); // Spying on the %s guild.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,104), g->name); // Spying on the %s guild.
clif->message(fd, atcmd_output);
}
} else {
@@ -4068,7 +4069,7 @@ ACMD(partyspy) {
return false;
}
- if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_fd(fd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
return false;
}
@@ -4077,11 +4078,11 @@ ACMD(partyspy) {
(p = party->search(atoi(message))) != NULL) {
if (sd->partyspy == p->party.party_id) {
sd->partyspy = 0;
- sprintf(atcmd_output, msg_fd(fd,105), p->party.name); // No longer spying on the %s party.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,105), p->party.name); // No longer spying on the %s party.
clif->message(fd, atcmd_output);
} else {
sd->partyspy = p->party.party_id;
- sprintf(atcmd_output, msg_fd(fd,106), p->party.name); // Spying on the %s party.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,106), p->party.name); // Spying on the %s party.
clif->message(fd, atcmd_output);
}
} else {
@@ -4128,7 +4129,7 @@ ACMD(nuke) {
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_fd(fd,1128)); // Please enter a player name (usage: @nuke <char name>).
return false;
}
@@ -4158,7 +4159,7 @@ ACMD(tonpc) {
memset(npcname, 0, sizeof(npcname));
- if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", npcname) < 1) {
clif->message(fd, msg_fd(fd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
return false;
}
@@ -4185,7 +4186,7 @@ ACMD(shownpc)
memset(NPCname, '\0', sizeof(NPCname));
- if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
clif->message(fd, msg_fd(fd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
return false;
}
@@ -4229,7 +4230,7 @@ ACMD(loadnpc)
{
FILE *fp;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
return false;
}
@@ -4258,7 +4259,7 @@ ACMD(unloadnpc)
memset(NPCname, '\0', sizeof(NPCname));
- if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
+ if (!*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
clif->message(fd, msg_fd(fd,1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
return false;
}
@@ -4378,6 +4379,11 @@ void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int
const int factor_day = 1440; //24*60 = 1440
const int factor_hour = 60;
+ nullpo_retv(year);
+ nullpo_retv(month);
+ nullpo_retv(day);
+ nullpo_retv(hour);
+ nullpo_retv(minute);
*year = jailtime/factor_year;
jailtime -= *year*factor_year;
*month = jailtime/factor_month;
@@ -4407,7 +4413,7 @@ ACMD(jail) {
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_fd(fd,1134)); // Please enter a player name (usage: @jail <char_name>).
return false;
}
@@ -4458,7 +4464,7 @@ ACMD(unjail) {
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif->message(fd, msg_fd(fd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
return false;
}
@@ -4494,7 +4500,7 @@ ACMD(jailfor) {
int jailtime = 0,x,y;
short m_index = 0;
- if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
+ if (!*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
clif->message(fd, msg_fd(fd,400)); //Usage: @jailfor <time> <character name>
return false;
}
@@ -4568,9 +4574,9 @@ ACMD(jailfor) {
clif->message(fd, msg_fd(fd,121)); // Player unjailed
} else {
atcommand->get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
- sprintf(atcmd_output,msg_fd(fd,402),msg_fd(fd,1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,402),msg_fd(fd,1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
clif->message(pl_sd->fd, atcmd_output);
- sprintf(atcmd_output,msg_fd(fd,402),msg_fd(fd,1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,402),msg_fd(fd,1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
clif->message(fd, atcmd_output);
}
} else if (jailtime < 0) {
@@ -4618,7 +4624,7 @@ ACMD(jailtime)
//Get remaining jail time
atcommand->get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
- sprintf(atcmd_output,msg_fd(fd,402),msg_fd(fd,1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,402),msg_fd(fd,1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
clif->message(fd, atcmd_output);
@@ -4632,7 +4638,7 @@ ACMD(disguise)
{
int id = 0;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
return false;
}
@@ -4683,7 +4689,7 @@ ACMD(disguiseall)
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
return false;
}
@@ -4799,17 +4805,17 @@ ACMD(undisguiseguild)
memset(guild_name, '\0', sizeof(guild_name));
- if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
+ if (!*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif->message(fd, msg_fd(fd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
return false;
}
- if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(message))) == NULL ) {
+ if ((g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,94)); // Incorrect name/ID, or no one from the guild is online.
return false;
}
- for(i = 0; i < g->max_member; i++) {
+ for (i = 0; i < g->max_member; i++) {
struct map_session_data *pl_sd = g->member[i].sd;
if (pl_sd && pl_sd->disguise != -1)
pc->disguise(pl_sd, -1);
@@ -4851,12 +4857,12 @@ ACMD(broadcast)
{
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1149)); // Please enter a message (usage: @broadcast <message>).
return false;
}
- sprintf(atcmd_output, "%s: %s", sd->status.name, message);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), "%s: %s", sd->status.name, message);
intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
return true;
@@ -4869,12 +4875,12 @@ ACMD(localbroadcast)
{
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1150)); // Please enter a message (usage: @localbroadcast <message>).
return false;
}
- sprintf(atcmd_output, "%s: %s", sd->status.name, message);
+ 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);
@@ -4892,7 +4898,7 @@ ACMD(email)
memset(actual_email, '\0', sizeof(actual_email));
memset(new_email, '\0', sizeof(new_email));
- if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
+ if (!*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
clif->message(fd, msg_fd(fd,1151)); // Please enter two e-mail addresses (usage: @email <current@email> <new@email>).
return false;
}
@@ -4923,7 +4929,7 @@ ACMD(effect)
{
int type = 0, flag = 0;
- if (!message || !*message || sscanf(message, "%d", &type) < 1) {
+ if (!*message || sscanf(message, "%d", &type) < 1) {
clif->message(fd, msg_fd(fd,1152)); // Please enter an effect number (usage: @effect <effect number>).
return false;
}
@@ -4941,7 +4947,7 @@ ACMD(killer)
{
sd->state.killer = !sd->state.killer;
- if(sd->state.killer)
+ if (sd->state.killer)
clif->message(fd, msg_fd(fd,241));
else {
clif->message(fd, msg_fd(fd,292));
@@ -4957,9 +4963,9 @@ ACMD(killer)
ACMD(killable) {
sd->state.killable = !sd->state.killable;
- if(sd->state.killable)
+ if (sd->state.killable) {
clif->message(fd, msg_fd(fd,242));
- else {
+ } else {
clif->message(fd, msg_fd(fd,288));
map->foreachinrange(atcommand->stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
}
@@ -4996,7 +5002,7 @@ ACMD(npcmove) {
memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
- if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
+ if (!*message || sscanf(message, "%12d %12d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
clif->message(fd, msg_fd(fd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
return false;
}
@@ -5034,7 +5040,7 @@ ACMD(addwarp)
memset(warpname, '\0', sizeof(warpname));
- if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
+ if (!*message || sscanf(message, "%31s %12d %12d %23[^\n]", mapname, &x, &y, warpname) < 4) {
clif->message(fd, msg_fd(fd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
return false;
}
@@ -5042,7 +5048,7 @@ ACMD(addwarp)
m = mapindex->name2id(mapname);
if( m == 0 )
{
- sprintf(atcmd_output, msg_fd(fd,1157), mapname); // Unknown map '%s'.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1157), mapname); // Unknown map '%s'.
clif->message(fd, atcmd_output);
return false;
}
@@ -5051,7 +5057,7 @@ ACMD(addwarp)
if( nd == NULL )
return false;
- sprintf(atcmd_output, msg_fd(fd,1158), nd->exname); // New warp NPC '%s' created.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1158), nd->exname); // New warp NPC '%s' created.
clif->message(fd, atcmd_output);
return true;
}
@@ -5063,7 +5069,7 @@ ACMD(addwarp)
ACMD(follow) {
struct map_session_data *pl_sd = NULL;
- if (!message || !*message) {
+ if (!*message) {
if (sd->followtarget == -1)
return false;
pc->stop_following (sd);
@@ -5071,7 +5077,7 @@ ACMD(follow) {
return true;
}
- if ( (pl_sd = map->nick2sd((char *)message)) == NULL )
+ if ((pl_sd = map->nick2sd((char *)message)) == NULL)
{
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
@@ -5117,7 +5123,7 @@ ACMD(storeall)
if (sd->state.storage_flag != STORAGE_FLAG_NORMAL) {
//Open storage.
- if( storage->open(sd) == 1 ) {
+ if (storage->open(sd) == 1) {
clif->message(fd, msg_fd(fd,1161)); // You currently cannot open your storage.
return false;
}
@@ -5234,7 +5240,7 @@ ACMD(skillid) {
DBData *data;
char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
return false;
}
@@ -5246,7 +5252,7 @@ ACMD(skillid) {
for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) {
int idx = skill->get_index(DB->data2i(data));
if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->dbs->db[idx].desc, message, skillen) == 0) {
- sprintf(atcmd_output, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); // skill %d: %s (%s)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); // skill %d: %s (%s)
clif->message(fd, atcmd_output);
} else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->dbs->db[idx].desc,message) ) ) {
snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str);
@@ -5257,7 +5263,7 @@ ACMD(skillid) {
dbi_destroy(iter);
if( found ) {
- sprintf(atcmd_output, msg_fd(fd,1398), found); // -- Displaying first %d partial matches
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1398), found); // -- Displaying first %d partial matches
clif->message(fd, atcmd_output);
}
@@ -5279,19 +5285,19 @@ ACMD(useskill) {
uint16 skill_lv;
char target[100];
- if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
+ if (!*message || sscanf(message, "%5hu %5hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
clif->message(fd, msg_fd(fd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
return false;
}
- if(!strcmp(target,"self"))
+ if (!strcmp(target,"self"))
pl_sd = sd; //quick keyword
- else if ( (pl_sd = map->nick2sd(target)) == NULL ) {
+ else if ((pl_sd = map->nick2sd(target)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
- if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
+ if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
{
clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorized you to do this action on this player.
return false;
@@ -5324,7 +5330,7 @@ ACMD(displayskill) {
uint16 skill_id;
uint16 skill_lv = 1;
- if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1) {
+ if (!*message || sscanf(message, "%5hu %5hu", &skill_id, &skill_lv) < 1) {
clif->message(fd, msg_fd(fd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
return false;
}
@@ -5347,7 +5353,7 @@ ACMD(skilltree) {
char target[NAME_LENGTH];
struct skill_tree_entry *ent;
- if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
+ if(!*message || sscanf(message, "%5hu %23[^\r\n]", &skill_id, target) != 2) {
clif->message(fd, msg_fd(fd,1167)); // Usage: @skilltree <skill ID> <target>
return false;
}
@@ -5360,7 +5366,7 @@ ACMD(skilltree) {
c = pc->calc_skilltree_normalize_job(pl_sd);
c = pc->mapid2jobid(c, pl_sd->status.sex);
- sprintf(atcmd_output, msg_fd(fd,1168), pc->job_name(c), pc->checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1168), pc->job_name(c), pc->checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
clif->message(fd, atcmd_output);
ARR_FIND( 0, MAX_SKILL_TREE, j, pc->skill_tree[c][j].id == 0 || pc->skill_tree[c][j].id == skill_id );
@@ -5377,7 +5383,7 @@ ACMD(skilltree) {
{
if( ent->need[j].id && pc->checkskill(sd,ent->need[j].id) < ent->need[j].lv)
{
- sprintf(atcmd_output, msg_fd(fd,1170), ent->need[j].lv, skill->dbs->db[ent->need[j].id].desc); // Player requires level %d of skill %s.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1170), ent->need[j].lv, skill->dbs->db[ent->need[j].id].desc); // Player requires level %d of skill %s.
clif->message(fd, atcmd_output);
meets = 0;
}
@@ -5390,9 +5396,10 @@ ACMD(skilltree) {
}
// Hand a ring with partners name on it to this char
-void getring(struct map_session_data* sd) {
+void atcommand_getring(struct map_session_data* sd) {
int flag, item_id;
struct item item_tmp;
+ nullpo_retv(sd);
item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
memset(&item_tmp, 0, sizeof(item_tmp));
@@ -5416,7 +5423,7 @@ ACMD(marry) {
struct map_session_data *pl_sd = NULL;
char player_name[NAME_LENGTH] = "";
- if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
+ if (!*message || sscanf(message, "%23s", player_name) != 1) {
clif->message(fd, msg_fd(fd,1172)); // Usage: @marry <char name>
return false;
}
@@ -5429,8 +5436,8 @@ ACMD(marry) {
if (pc->marriage(sd, pl_sd) == 0) {
clif->message(fd, msg_fd(fd,1173)); // They are married... wish them well.
clif->wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
- getring(sd); // Auto-give named rings (Aru)
- getring(pl_sd);
+ atcommand->getring(sd); // Auto-give named rings (Aru)
+ atcommand->getring(pl_sd);
return true;
}
@@ -5445,12 +5452,12 @@ ACMD(marry) {
ACMD(divorce)
{
if (pc->divorce(sd) != 0) {
- sprintf(atcmd_output, msg_fd(fd,1175), sd->status.name); // '%s' is not married.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1175), sd->status.name); // '%s' is not married.
clif->message(fd, atcmd_output);
return false;
}
- sprintf(atcmd_output, msg_fd(fd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
clif->message(fd, atcmd_output);
return true;
}
@@ -5463,7 +5470,7 @@ ACMD(changelook)
int i, j = 0, k = 0;
int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
- if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
+ if((i = sscanf(message, "%12d %12d", &j, &k)) < 1) {
clif->message(fd, msg_fd(fd,1177)); // Usage: @changelook {<position>} <view id>
clif->message(fd, msg_fd(fd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
return false;
@@ -5540,17 +5547,17 @@ ACMD(changegm) {
return false;
}
- if( map->list[sd->bl.m].flag.guildlock || map->list[sd->bl.m].flag.gvg_castle ) {
+ if (map->list[sd->bl.m].flag.guildlock || map->list[sd->bl.m].flag.gvg_castle) {
clif->message(fd, msg_fd(fd,1182)); // You cannot change guild leaders in this map.
return false;
}
- if( !message[0] ) {
+ if (!message[0]) {
clif->message(fd, msg_fd(fd,1183)); // Usage: @changegm <guild_member_name>
return false;
}
- if((pl_sd=map->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
+ if ((pl_sd=map->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
clif->message(fd, msg_fd(fd,1184)); // Target character must be online and be a guild member.
return false;
}
@@ -5565,7 +5572,7 @@ ACMD(changegm) {
*------------------------------------------*/
ACMD(changeleader) {
- if( !message[0] ) {
+ if (!message[0]) {
clif->message(fd, msg_fd(fd,1185)); // Usage: @changeleader <party_member_name>
return false;
}
@@ -5591,7 +5598,7 @@ ACMD(partyoption)
return false;
}
- ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
+ ARR_FIND(0, MAX_PARTY, mi, p->data[mi].sd == sd);
if (mi == MAX_PARTY)
return false; //Shouldn't happen
@@ -5601,7 +5608,7 @@ ACMD(partyoption)
return false;
}
- if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
+ if (!*message || sscanf(message, "%15s %15s", w1, w2) < 2)
{
clif->message(fd, msg_fd(fd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
return false;
@@ -5627,7 +5634,7 @@ ACMD(autoloot)
int rate;
// autoloot command without value
- if(!message || !*message)
+ if (!*message)
{
if (sd->state.autoloot)
rate = 0;
@@ -5660,7 +5667,7 @@ ACMD(autolootitem)
int i;
int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
- if (message && *message) {
+ if (*message) {
if (message[0] == '+') {
message++;
action = 1;
@@ -5684,7 +5691,7 @@ ACMD(autolootitem)
}
}
- switch(action) {
+ switch (action) {
case 1:
ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
if (i != AUTOLOOTITEM_SIZE) {
@@ -5697,7 +5704,7 @@ ACMD(autolootitem)
return false;
}
sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
- sprintf(atcmd_output, msg_fd(fd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
clif->message(fd, atcmd_output);
sd->state.autolooting = 1;
break;
@@ -5708,7 +5715,7 @@ ACMD(autolootitem)
return false;
}
sd->state.autolootid[i] = 0;
- sprintf(atcmd_output, msg_fd(fd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
clif->message(fd, atcmd_output);
ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
if (i == AUTOLOOTITEM_SIZE) {
@@ -5716,7 +5723,7 @@ ACMD(autolootitem)
}
break;
case 3:
- sprintf(atcmd_output, msg_fd(fd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
clif->message(fd, msg_fd(fd,1197)); // "@alootid reset" will clear your autolootitem list.
@@ -5733,7 +5740,7 @@ ACMD(autolootitem)
ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
continue;
}
- sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
clif->message(fd, atcmd_output);
}
}
@@ -5757,7 +5764,7 @@ ACMD(autoloottype) {
enum item_types type = -1;
int ITEM_NONE = 0;
- if (message && *message) {
+ if (*message) {
if (message[0] == '+') {
message++;
action = 1;
@@ -5802,7 +5809,7 @@ ACMD(autoloottype) {
return false;
}
sd->state.autoloottype |= (1<<type); // Stores the type
- sprintf(atcmd_output, msg_fd(fd,1492), itemdb->typename(type)); // Autolooting item type: '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1492), itemdb->typename(type)); // Autolooting item type: '%s'
clif->message(fd, atcmd_output);
break;
case 2:
@@ -5811,7 +5818,7 @@ ACMD(autoloottype) {
return false;
}
sd->state.autoloottype &= ~(1<<type);
- sprintf(atcmd_output, msg_fd(fd,1494), itemdb->typename(type)); // Removed item type: '%s' from your autoloottype list.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1494), itemdb->typename(type)); // Removed item type: '%s' from your autoloottype list.
clif->message(fd, atcmd_output);
break;
case 3:
@@ -5830,7 +5837,7 @@ ACMD(autoloottype) {
clif->message(fd, msg_fd(fd,1496)); // Item types on your autoloottype list:
for(i=0; i < IT_MAX; i++) {
if (sd->state.autoloottype&(1<<i)) {
- sprintf(atcmd_output, " '%s'", itemdb->typename(i));
+ safesnprintf(atcmd_output, sizeof(atcmd_output), " '%s'", itemdb->typename(i));
clif->message(fd, atcmd_output);
}
}
@@ -5995,7 +6002,7 @@ ACMD(sound)
memset(sound_file, '\0', sizeof(sound_file));
- if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
+ if(!*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
clif->message(fd, msg_fd(fd,1217)); // Please enter a sound filename (usage: @sound <filename>).
return false;
}
@@ -6018,7 +6025,7 @@ ACMD(mobsearch)
int number = 0;
struct s_mapiterator* it;
- if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
+ if (!*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
clif->message(fd, msg_fd(fd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
return false;
}
@@ -6110,13 +6117,13 @@ ACMD(npctalk)
return false;
if(!ifcolor) {
- if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
+ if (!*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
clif->message(fd, msg_fd(fd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
return false;
}
}
else {
- if (!message || !*message || sscanf(message, "%u %23[^,], %99[^\n]", &color, name, mes) < 3) {
+ if (!*message || sscanf(message, "%12u %23[^,], %99[^\n]", &color, name, mes) < 3) {
clif->message(fd, msg_fd(fd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
return false;
}
@@ -6141,13 +6148,13 @@ ACMD(pettalk)
char mes[100],temp[100];
struct pet_data *pd;
- if ( battle_config.min_chat_delay ) {
+ if (battle_config.min_chat_delay) {
if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 )
return true;
sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
}
- if(!sd->status.pet_id || !(pd=sd->pd))
+ if (!sd->status.pet_id || !(pd=sd->pd))
{
clif->message(fd, msg_fd(fd,184));
return false;
@@ -6164,7 +6171,7 @@ ACMD(pettalk)
}
if (message[0] == '/')
- {// pet emotion processing
+ { // pet emotion processing
const char* emo[] = {
"/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
"/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
@@ -6251,7 +6258,7 @@ ACMD(users)
ACMD(reset) {
pc->resetstate(sd);
pc->resetskill(sd, PCRESETSKILL_RESYNC);
- sprintf(atcmd_output, msg_fd(fd,208), sd->status.name); // '%s' skill and stats points reseted!
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,208), sd->status.name); // '%s' skill and stats points reseted!
clif->message(fd, atcmd_output);
return true;
}
@@ -6267,7 +6274,7 @@ ACMD(summon)
struct mob_data *md;
int64 tick=timer->gettick();
- if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
+ if (!*message || sscanf(message, "%23s %12d", name, &duration) < 1)
{
clif->message(fd, msg_fd(fd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
return false;
@@ -6312,7 +6319,7 @@ ACMD(adjgroup)
{
int new_group = 0;
- if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
+ if (!*message || sscanf(message, "%12d", &new_group) != 1) {
clif->message(fd, msg_fd(fd,1226)); // Usage: @adjgroup <group_id>
return false;
}
@@ -6334,7 +6341,7 @@ ACMD(adjgroup)
ACMD(trade) {
struct map_session_data *pl_sd = NULL;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1230)); // Please enter a player name (usage: @trade <char name>).
return false;
}
@@ -6356,7 +6363,7 @@ ACMD(setbattleflag)
{
char flag[128], value[128];
- if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
+ if (!*message || sscanf(message, "%127s %127s", flag, value) != 2) {
clif->message(fd, msg_fd(fd,1231)); // Usage: @setbattleflag <flag> <value>
return false;
}
@@ -6377,18 +6384,18 @@ ACMD(setbattleflag)
ACMD(unmute) {
struct map_session_data *pl_sd = NULL;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1234)); // Please enter a player name (usage: @unmute <char name>).
return false;
}
- if ( (pl_sd = map->nick2sd((char *)message)) == NULL )
+ if ((pl_sd = map->nick2sd((char *)message)) == NULL)
{
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
- if(!pl_sd->sc.data[SC_NOCHAT]) {
+ if (!pl_sd->sc.data[SC_NOCHAT]) {
clif->message(sd->fd,msg_fd(fd,1235)); // Player is not muted.
return false;
}
@@ -6431,8 +6438,8 @@ ACMD(changesex) {
pc->resetskill(sd, PCRESETSKILL_CHSEX);
// to avoid any problem with equipment and invalid sex, equipment is unequipped.
- for( i=0; i<EQI_MAX; i++ )
- if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
+ for (i=0; i<EQI_MAX; i++)
+ if (sd->equip_index[i] >= 0) pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
chrif->changesex(sd, true);
return true;
}
@@ -6444,17 +6451,17 @@ ACMD(mute) {
struct map_session_data *pl_sd = NULL;
int manner;
- if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
+ if (!*message || sscanf(message, "%12d %23[^\n]", &manner, atcmd_player_name) < 1) {
clif->message(fd, msg_fd(fd,1237)); // Usage: @mute <time> <char name>
return false;
}
- if ( (pl_sd = map->nick2sd(atcmd_player_name)) == NULL ) {
+ if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
- if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
+ if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
{
clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorize you to do this action on this player.
return false;
@@ -6463,7 +6470,7 @@ ACMD(mute) {
clif->manner_message(sd, 0);
clif->manner_message(pl_sd, 5);
- if( pl_sd->status.manner < manner ) {
+ if (pl_sd->status.manner < manner) {
pl_sd->status.manner -= manner;
sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
} else {
@@ -6505,7 +6512,7 @@ ACMD(identify)
{
int i,num;
- for(i=num=0;i<MAX_INVENTORY;i++){
+ for (i=num=0;i<MAX_INVENTORY;i++) {
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
num++;
}
@@ -6521,9 +6528,9 @@ ACMD(identify)
ACMD(misceffect) {
int effect = 0;
- if (!message || !*message)
+ if (!*message)
return false;
- if (sscanf(message, "%d", &effect) < 1)
+ if (sscanf(message, "%12d", &effect) < 1)
return false;
clif->misceffect(&sd->bl,effect);
@@ -6557,7 +6564,7 @@ ACMD(mobinfo)
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(atcmd_output2, '\0', sizeof(atcmd_output2));
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
return false;
}
@@ -6575,7 +6582,7 @@ ACMD(mobinfo)
}
if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_fd(fd,269), MAX_SEARCH, count);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, count);
clif->message(fd, atcmd_output);
count = MAX_SEARCH;
}
@@ -6598,27 +6605,27 @@ ACMD(mobinfo)
// stats
if (monster->mexp)
- sprintf(atcmd_output, msg_fd(fd,1240), monster->name, monster->jname, monster->sprite, monster->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1240), monster->name, monster->jname, monster->sprite, monster->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
else
- sprintf(atcmd_output, msg_fd(fd,1241), monster->name, monster->jname, monster->sprite, monster->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1241), monster->name, monster->jname, monster->sprite, monster->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1242), monster->lv, monster->status.max_hp, base_exp, job_exp, MOB_HIT(monster), MOB_FLEE(monster)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1242), monster->lv, monster->status.max_hp, base_exp, job_exp, MOB_HIT(monster), MOB_FLEE(monster)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
monster->status.def, monster->status.mdef, monster->status.str, monster->status.agi,
monster->status.vit, monster->status.int_, monster->status.dex, monster->status.luk);
clif->message(fd, atcmd_output);
#ifdef RENEWAL
- sprintf(atcmd_output, msg_fd(fd,1291), // ATK : %d~%d MATK : %d~%d Range : %d~%d~%d Size : %s Race : %s Element : %s(Lv : %d)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1291), // ATK : %d~%d MATK : %d~%d Range : %d~%d~%d Size : %s Race : %s Element : %s(Lv : %d)
MOB_ATK1(monster), MOB_ATK2(monster), MOB_MATK1(monster), MOB_MATK2(monster), monster->status.rhw.range,
monster->range2 , monster->range3, msize[monster->status.size],
mrace[monster->status.race], melement[monster->status.def_ele], monster->status.ele_lv);
#else
- sprintf(atcmd_output, msg_fd(fd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
monster->status.rhw.atk, monster->status.rhw.atk2, monster->status.rhw.range,
monster->range2 , monster->range3, msize[monster->status.size],
mrace[monster->status.race], melement[monster->status.def_ele], monster->status.ele_lv);
@@ -6665,7 +6672,7 @@ ACMD(mobinfo)
clif->message(fd, atcmd_output);
// mvp
if (monster->mexp) {
- sprintf(atcmd_output, msg_fd(fd,1247), monster->mexp); // MVP Bonus EXP:%u
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1247), monster->mexp); // MVP Bonus EXP:%u
clif->message(fd, atcmd_output);
safestrncpy(atcmd_output, msg_fd(fd,1248), sizeof(atcmd_output)); // MVP Items:
@@ -6702,7 +6709,7 @@ ACMD(showmobs)
int number = 0;
struct s_mapiterator* it;
- if( sscanf(message, "%99[^\n]", mob_name) < 0 ) {
+ if (sscanf(message, "%99[^\n]", mob_name) < 0) {
clif->message(fd, msg_fd(fd,546)); // Please enter a mob name/id (usage: @showmobs <mob name/id>)
return false;
}
@@ -6768,19 +6775,19 @@ ACMD(homlevel) {
int level = 0;
enum homun_type htype;
- if( !message || !*message || ( level = atoi(message) ) < 1 ) {
+ if (!*message || ( level = atoi(message) ) < 1) {
clif->message(fd, msg_fd(fd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
return false;
}
- if( !homun_alive(sd->hd) ) {
+ if (!homun_alive(sd->hd)) {
clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
return false;
}
hd = sd->hd;
- if( (htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID ) {
+ if ((htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID) {
ShowError("atcommand_homlevel: invalid homun class %d (player %s)\n", hd->homunculus.class_,sd->status.name);
return false;
}
@@ -6838,12 +6845,12 @@ ACMD(hommutate) {
int homun_id;
enum homun_type m_class, m_id;
- if( !homun_alive(sd->hd) ) {
+ if (!homun_alive(sd->hd)) {
clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
return false;
}
- if( !message || !*message ) {
+ if (!*message) {
homun_id = 6048 + (rnd() % 4);
} else {
homun_id = atoi(message);
@@ -6866,15 +6873,15 @@ ACMD(hommutate) {
ACMD(makehomun) {
int homunid;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
return false;
}
homunid = atoi(message);
- if( homunid == -1 && sd->status.hom_id && !(sd->hd && homun_alive(sd->hd)) ) {
- if( !sd->hd )
+ if (homunid == -1 && sd->status.hom_id && !(sd->hd && homun_alive(sd->hd))) {
+ if (!sd->hd)
homun->call(sd);
else if( sd->hd->homunculus.vaporize )
homun->ressurect(sd, 100, sd->bl.x, sd->bl.y);
@@ -6883,12 +6890,12 @@ ACMD(makehomun) {
return true;
}
- if ( sd->status.hom_id ) {
+ if (sd->status.hom_id) {
clif->message(fd, msg_fd(fd,450));
return false;
}
- if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
+ if (homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1)
{
clif->message(fd, msg_fd(fd,1257)); // Invalid Homunculus ID.
return false;
@@ -6905,7 +6912,7 @@ ACMD(homfriendly)
{
int friendly = 0;
- if ( !homun_alive(sd->hd) ) {
+ if (!homun_alive(sd->hd)) {
clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
return false;
}
@@ -6930,12 +6937,12 @@ ACMD(homhungry)
{
int hungry = 0;
- if ( !homun_alive(sd->hd) ) {
+ if (!homun_alive(sd->hd)) {
clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
return false;
}
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
return false;
}
@@ -6955,8 +6962,8 @@ ACMD(homtalk)
{
char mes[100],temp[100];
- if ( battle_config.min_chat_delay ) {
- if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 )
+ if (battle_config.min_chat_delay) {
+ if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0)
return true;
sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
}
@@ -6966,12 +6973,12 @@ ACMD(homtalk)
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
- if ( !homun_alive(sd->hd) ) {
+ if (!homun_alive(sd->hd)) {
clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
return false;
}
- if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
+ if (!*message || sscanf(message, "%99[^\n]", mes) < 1) {
clif->message(fd, msg_fd(fd,1260)); // Please enter a message (usage: @homtalk <message>).
return false;
}
@@ -6989,7 +6996,7 @@ ACMD(hominfo) {
struct homun_data *hd;
struct status_data *st;
- if ( !homun_alive(sd->hd) ) {
+ if (!homun_alive(sd->hd)) {
clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
return false;
}
@@ -7026,7 +7033,7 @@ ACMD(homstats)
struct s_homunculus *hom;
int lv, min, max, evo;
- if ( !homun_alive(sd->hd) ) {
+ if (!homun_alive(sd->hd)) {
clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
return false;
}
@@ -7088,10 +7095,10 @@ ACMD(homstats)
ACMD(homshuffle)
{
- if(!sd->hd)
+ if (!sd->hd)
return false; // nothing to do
- if(!homun->shuffle(sd->hd))
+ if (!homun->shuffle(sd->hd))
return false;
clif->message(sd->fd, msg_fd(fd,1275)); // Homunculus stats altered.
@@ -7108,7 +7115,7 @@ ACMD(iteminfo)
struct item_data *item_array[MAX_SEARCH];
int i, count = 1;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
return false;
}
@@ -7121,27 +7128,27 @@ ACMD(iteminfo)
}
if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_fd(fd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
clif->message(fd, atcmd_output);
count = MAX_SEARCH;
}
for (i = 0; i < count; i++) {
struct item_data *item_data = item_array[i];
- sprintf(atcmd_output, msg_fd(fd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
item_data->name,item_data->jname,item_data->slot,item_data->nameid,
itemdb->typename(item_data->type),
(item_data->script==NULL)? msg_fd(fd,1278) : msg_fd(fd,1279) // None / With script
);
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
clif->message(fd, atcmd_output);
if (item_data->maxchance == -1)
safestrncpy(atcmd_output, msg_fd(fd,1281), sizeof(atcmd_output)); // - Available in the shops only.
else if ( !battle_config.atcommand_mobinfo_type ) {
if( item_data->maxchance )
- sprintf(atcmd_output, msg_fd(fd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
else
safestrncpy(atcmd_output, msg_fd(fd,1283), sizeof(atcmd_output)); // - Monsters don't drop this item.
}
@@ -7159,7 +7166,7 @@ ACMD(whodrops)
struct item_data *item_array[MAX_SEARCH];
int i,j, count = 1;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
return false;
}
@@ -7172,25 +7179,25 @@ ACMD(whodrops)
}
if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_fd(fd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
clif->message(fd, atcmd_output);
count = MAX_SEARCH;
}
for (i = 0; i < count; i++) {
struct item_data *item_data = item_array[i];
- sprintf(atcmd_output, msg_fd(fd,1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
clif->message(fd, atcmd_output);
if (item_data->mob[0].chance == 0) {
safestrncpy(atcmd_output, msg_fd(fd,1286), sizeof(atcmd_output)); // - Item is not dropped by mobs.
clif->message(fd, atcmd_output);
} else {
- sprintf(atcmd_output, msg_fd(fd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
clif->message(fd, atcmd_output);
for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
{
- sprintf(atcmd_output, "- %s (%02.02f%%)", mob->db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), "- %s (%02.02f%%)", mob->db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
clif->message(fd, atcmd_output);
}
}
@@ -7204,7 +7211,7 @@ ACMD(whereis)
int count;
int i, j, k;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
return false;
}
@@ -7223,7 +7230,7 @@ ACMD(whereis)
}
if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_fd(fd,269), MAX_SEARCH, count);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, count);
clif->message(fd, atcmd_output);
count = MAX_SEARCH;
}
@@ -7246,9 +7253,9 @@ ACMD(whereis)
}
ACMD(version) {
- sprintf(atcmd_output, msg_fd(fd,1296), sysinfo->is64bit() ? 64 : 32, sysinfo->platform()); // Hercules %d-bit for %s
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1296), sysinfo->is64bit() ? 64 : 32, sysinfo->platform()); // Hercules %d-bit for %s
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_fd(fd,1295), sysinfo->vcstype(), sysinfo->vcsrevision_src(), sysinfo->vcsrevision_scripts()); // %s revision '%s' (src) / '%s' (scripts)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1295), sysinfo->vcstype(), sysinfo->vcsrevision_src(), sysinfo->vcsrevision_scripts()); // %s revision '%s' (src) / '%s' (scripts)
clif->message(fd, atcmd_output);
return true;
@@ -7257,7 +7264,7 @@ ACMD(version) {
/*==========================================
* @mutearea by MouseJstr
*------------------------------------------*/
-int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
+int atcommand_mutearea_sub(struct block_list *bl, va_list ap)
{ // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way
int time, id;
@@ -7281,7 +7288,7 @@ int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
ACMD(mutearea) {
int time;
- if (!message || !*message) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
return false;
}
@@ -7302,16 +7309,16 @@ ACMD(rates)
memset(buf, '\0', sizeof(buf));
- snprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1298), // Experience rates: Base %.2fx / Job %.2fx
+ safesnprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1298), // Experience rates: Base %.2fx / Job %.2fx
battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
clif->message(fd, buf);
- snprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
+ safesnprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
clif->message(fd, buf);
- snprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
+ safesnprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
clif->message(fd, buf);
- snprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
+ safesnprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
clif->message(fd, buf);
@@ -7339,7 +7346,7 @@ ACMD(me)
return false;
}
- sprintf(atcmd_output, msg_fd(fd,270), sd->status.name, tempmes); // *%s %s*
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,270), sd->status.name, tempmes); // *%s %s*
clif->disp_overhead(&sd->bl, atcmd_output);
return true;
@@ -7380,17 +7387,17 @@ ACMD(sizeall)
size = cap_value(size,0,2);
iter = mapit_getallusers();
- for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
- if( pl_sd->state.size != size ) {
- if( pl_sd->state.size ) {
+ for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) {
+ if (pl_sd->state.size != size) {
+ if (pl_sd->state.size) {
pl_sd->state.size = SZ_SMALL;
pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
pl_sd->state.size = size;
- if( size == SZ_MEDIUM )
+ if (size == SZ_MEDIUM)
clif->specialeffect(&pl_sd->bl,420,AREA);
- else if( size == SZ_BIG )
+ else if (size == SZ_BIG)
clif->specialeffect(&pl_sd->bl,422,AREA);
}
}
@@ -7409,20 +7416,20 @@ ACMD(sizeguild)
memset(guild_name, '\0', sizeof(guild_name));
- if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild_name) < 2 ) {
+ if (!*message || sscanf(message, "%d %23[^\n]", &size, guild_name) < 2) {
clif->message(fd, msg_fd(fd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
return false;
}
- if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(guild_name))) == NULL ) {
+ if ((g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(guild_name))) == NULL) {
clif->message(fd, msg_fd(fd,94)); // Incorrect name/ID, or no one from the guild is online.
return false;
}
size = cap_value(size,SZ_SMALL,SZ_BIG);
- for( i = 0; i < g->max_member; i++ ) {
- if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
+ for (i = 0; i < g->max_member; i++) {
+ if ((pl_sd = g->member[i].sd) && pl_sd->state.size != size) {
if( pl_sd->state.size ) {
pl_sd->state.size = SZ_SMALL;
pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
@@ -7462,9 +7469,9 @@ ACMD(monsterignore)
*------------------------------------------*/
ACMD(fakename)
{
- if( !message || !*message )
+ if (!*message)
{
- if( sd->fakename[0] )
+ if (sd->fakename[0])
{
sd->fakename[0] = '\0';
clif->charnameack(0, &sd->bl);
@@ -7478,7 +7485,7 @@ ACMD(fakename)
return false;
}
- if( strlen(message) < 2 )
+ if (strlen(message) < 2)
{
clif->message(sd->fd, msg_fd(fd,1309)); // Fake name must be at least two characters.
return false;
@@ -7486,7 +7493,7 @@ ACMD(fakename)
safestrncpy(sd->fakename, message, sizeof(sd->fakename));
clif->charnameack(0, &sd->bl);
- if( sd->disguise ) // Another packet should be sent so the client updates the name for sd
+ if (sd->disguise) // Another packet should be sent so the client updates the name for sd
clif->charnameack(sd->fd, &sd->bl);
clif->message(sd->fd, msg_fd(fd,1310)); // Fake name enabled.
@@ -7497,11 +7504,11 @@ ACMD(fakename)
* Ragnarok Resources
*------------------------------------------*/
ACMD(mapflag) {
-#define CHECKFLAG( cmd ) do { if ( map->list[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd); } while(0)
+#define CHECKFLAG( cmd ) do { if (map->list[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd);} while(0)
#define SETFLAG( cmd ) do { \
- if ( strcmp( flag_name , #cmd ) == 0 ) { \
+ if (strcmp( flag_name , #cmd ) == 0) { \
map->list[ sd->bl.m ].flag.cmd = flag; \
- sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag); \
+ safesnprintf(atcmd_output, sizeof(atcmd_output),"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag); \
clif->message(sd->fd,atcmd_output); \
return true; \
} \
@@ -7512,7 +7519,7 @@ ACMD(mapflag) {
memset(flag_name, '\0', sizeof(flag_name));
- if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
+ if (!*message || (sscanf(message, "%99s %5hd", flag_name, &flag) < 1)) {
clif->message(sd->fd,msg_fd(fd,1311)); // Enabled Mapflags in this map:
clif->message(sd->fd,"----------------------------------");
CHECKFLAG(autotrade); CHECKFLAG(allowks); CHECKFLAG(nomemo); CHECKFLAG(noteleport);
@@ -7535,18 +7542,18 @@ ACMD(mapflag) {
}
for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase
- if ( strcmp( flag_name , "gvg" ) == 0 ) {
+ if (strcmp( flag_name , "gvg" ) == 0) {
if( flag && !map->list[sd->bl.m].flag.gvg )
map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME));
else if ( !flag && map->list[sd->bl.m].flag.gvg )
map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
} else if ( strcmp( flag_name , "pvp" ) == 0 ) {
- if( flag && !map->list[sd->bl.m].flag.pvp )
+ if ( flag && !map->list[sd->bl.m].flag.pvp )
map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME));
else if ( !flag && map->list[sd->bl.m].flag.pvp )
map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
} else if ( strcmp( flag_name , "battleground" ) == 0 ) {
- if( flag && !map->list[sd->bl.m].flag.battleground )
+ if ( flag && !map->list[sd->bl.m].flag.battleground )
map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_BG_NAME));
else if ( !flag && map->list[sd->bl.m].flag.battleground )
map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
@@ -7638,36 +7645,36 @@ ACMD(invite) {
unsigned int did = sd->duel_group;
struct map_session_data *target_sd = map->nick2sd((char *)message);
- if(did == 0)
+ if (did == 0)
{
// "Duel: @invite without @duel."
clif->message(fd, msg_fd(fd,350));
return false;
}
- if(duel->list[did].max_players_limit > 0 &&
- duel->list[did].members_count >= duel->list[did].max_players_limit) {
+ if (duel->list[did].max_players_limit > 0 &&
+ duel->list[did].members_count >= duel->list[did].max_players_limit) {
// "Duel: Limit of players is reached."
clif->message(fd, msg_fd(fd,351));
return false;
}
- if(target_sd == NULL) {
+ if (target_sd == NULL) {
// "Duel: Player not found."
clif->message(fd, msg_fd(fd,352));
return false;
}
- if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
+ if (target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
// "Duel: Player already in duel."
clif->message(fd, msg_fd(fd,353));
return false;
}
- if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
+ if (battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
{
// "Duel: You can't invite %s because he/she isn't in the same map."
- sprintf(atcmd_output, msg_fd(fd,364), message);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,364), message);
clif->message(fd, atcmd_output);
return false;
}
@@ -7681,18 +7688,18 @@ ACMD(invite) {
ACMD(duel) {
unsigned int maxpl = 0;
- if(sd->duel_group > 0) {
+ if (sd->duel_group > 0) {
duel->showinfo(sd->duel_group, sd);
return true;
}
- if(sd->duel_invite > 0) {
+ if (sd->duel_invite > 0) {
// "Duel: @duel without @reject."
clif->message(fd, msg_fd(fd,355));
return false;
}
- if(!duel->checktime(sd)) {
+ if (!duel->checktime(sd)) {
char output[CHAT_SIZE_MAX];
// "Duel: You can take part in duel only one time per %d minutes."
sprintf(output, msg_fd(fd,356), battle_config.duel_time_interval);
@@ -7700,9 +7707,9 @@ ACMD(duel) {
return false;
}
- if( message[0] ) {
- if(sscanf(message, "%u", &maxpl) >= 1) {
- if(maxpl < 2 || maxpl > 65535) {
+ if (message[0]) {
+ if (sscanf(message, "%12u", &maxpl) >= 1) {
+ if (maxpl < 2 || maxpl > 65535) {
clif->message(fd, msg_fd(fd,357)); // "Duel: Invalid value."
return false;
}
@@ -7710,10 +7717,10 @@ ACMD(duel) {
} else {
struct map_session_data *target_sd;
target_sd = map->nick2sd((char *)message);
- if(target_sd != NULL) {
+ if (target_sd != NULL) {
unsigned int newduel;
- if((newduel = duel->create(sd, 2)) != -1) {
- if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
+ if ((newduel = duel->create(sd, 2)) != -1) {
+ if (target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
clif->message(fd, msg_fd(fd,353)); // "Duel: Player already in duel."
return false;
}
@@ -7734,7 +7741,7 @@ ACMD(duel) {
ACMD(leave) {
- if(sd->duel_group <= 0) {
+ if (sd->duel_group <= 0) {
// "Duel: @leave without @duel."
clif->message(fd, msg_fd(fd,358));
return false;
@@ -7745,7 +7752,7 @@ ACMD(leave) {
}
ACMD(accept) {
- if(!duel->checktime(sd)) {
+ if (!duel->checktime(sd)) {
char output[CHAT_SIZE_MAX];
// "Duel: You can take part in duel only one time per %d minutes."
sprintf(output, msg_fd(fd,356), battle_config.duel_time_interval);
@@ -7753,14 +7760,14 @@ ACMD(accept) {
return false;
}
- if(sd->duel_invite <= 0) {
+ if (sd->duel_invite <= 0) {
// "Duel: @accept without invitation."
clif->message(fd, msg_fd(fd,360));
return false;
}
- if( duel->list[sd->duel_invite].max_players_limit > 0
- && duel->list[sd->duel_invite].members_count >= duel->list[sd->duel_invite].max_players_limit ) {
+ if (duel->list[sd->duel_invite].max_players_limit > 0
+ && duel->list[sd->duel_invite].members_count >= duel->list[sd->duel_invite].max_players_limit) {
// "Duel: Limit of players is reached."
clif->message(fd, msg_fd(fd,351));
return false;
@@ -7773,7 +7780,7 @@ ACMD(accept) {
}
ACMD(reject) {
- if(sd->duel_invite <= 0) {
+ if (sd->duel_invite <= 0) {
// "Duel: @reject without invitation."
clif->message(fd, msg_fd(fd,362));
return false;
@@ -7794,12 +7801,12 @@ ACMD(cash)
int value;
int ret=0;
- if( !message || !*message || (value = atoi(message)) == 0 ) {
+ if (!*message || (value = atoi(message)) == 0) {
clif->message(fd, msg_fd(fd,1322)); // Please enter an amount.
return false;
}
- if( !strcmpi(info->command,"cash") ) {
+ if (!strcmpi(info->command,"cash")) {
if( value > 0 ) {
if( (ret=pc->getcash(sd, value, 0)) >= 0){
// If this option is set, the message is already sent by pc function
@@ -7847,17 +7854,17 @@ ACMD(clone) {
int x=0,y=0,flag=0,master=0,i=0;
struct map_session_data *pl_sd=NULL;
- if (!message || !*message) {
+ if (!*message) {
clif->message(sd->fd,msg_fd(fd,1323)); // You must enter a player name or ID.
return false;
}
- if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
+ if ((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
- if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
+ if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
clif->message(fd, msg_fd(fd,126)); // Cannot clone a player of higher GM level than yourself.
return false;
}
@@ -7866,7 +7873,7 @@ ACMD(clone) {
flag = 1;
else if (strcmpi(info->command, "slaveclone") == 0) {
flag = 2;
- if(pc_isdead(sd)){
+ if (pc_isdead(sd)){
//"Unable to spawn slave clone."
clif->message(fd, msg_fd(fd,129+flag*2));
return false;
@@ -7889,7 +7896,7 @@ ACMD(clone) {
y = sd->bl.y;
}
- if((x = mob->clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
+ if ((x = mob->clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
clif->message(fd, msg_fd(fd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
return true;
}
@@ -7903,7 +7910,7 @@ ACMD(clone) {
*-------------------------------------*/
ACMD(noask)
{
- if(sd->state.noask) {
+ if (sd->state.noask) {
clif->message(fd, msg_fd(fd,391)); // Autorejecting is deactivated.
sd->state.noask = 0;
} else {
@@ -7920,12 +7927,12 @@ ACMD(noask)
*-------------------------------------*/
ACMD(request)
{
- if (!message || !*message) {
+ if (!*message) {
clif->message(sd->fd,msg_fd(fd,277)); // Usage: @request <petition/message to online GMs>.
return false;
}
- sprintf(atcmd_output, msg_fd(fd,278), message); // (@request): %s
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,278), message); // (@request): %s
intif->wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
clif->message(sd->fd,msg_fd(fd,279)); // @request sent.
@@ -7998,7 +8005,7 @@ ACMD(allowks)
ACMD(resetstat)
{
pc->resetstate(sd);
- sprintf(atcmd_output, msg_fd(fd,207), sd->status.name);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,207), sd->status.name);
clif->message(fd, atcmd_output);
return true;
}
@@ -8006,7 +8013,7 @@ ACMD(resetstat)
ACMD(resetskill)
{
pc->resetskill(sd, PCRESETSKILL_RESYNC);
- sprintf(atcmd_output, msg_fd(fd,206), sd->status.name);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,206), sd->status.name);
clif->message(fd, atcmd_output);
return true;
}
@@ -8226,13 +8233,13 @@ ACMD(delitem) {
int nameid, amount = 0, total, idx;
struct item_data* id;
- if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
+ if (!*message || (sscanf(message, "\"%99[^\"]\" %12d", item_name, &amount) < 2 && sscanf(message, "%99s %12d", item_name, &amount) < 2) || amount < 1)
{
clif->message(fd, msg_fd(fd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
return false;
}
- if( ( id = itemdb->search_name(item_name) ) != NULL || ( id = itemdb->exists(atoi(item_name)) ) != NULL )
+ if ((id = itemdb->search_name(item_name)) != NULL || (id = itemdb->exists(atoi(item_name))) != NULL)
{
nameid = id->nameid;
}
@@ -8258,7 +8265,7 @@ ACMD(delitem) {
}
// notify target
- sprintf(atcmd_output, msg_fd(fd,113), total-amount); // %d item(s) removed by a GM.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,113), total-amount); // %d item(s) removed by a GM.
clif->message(sd->fd, atcmd_output);
// notify source
@@ -8268,12 +8275,12 @@ ACMD(delitem) {
}
else if( amount )
{
- sprintf(atcmd_output, msg_fd(fd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
clif->message(fd, atcmd_output);
}
else
{
- sprintf(atcmd_output, msg_fd(fd,114), total); // %d item(s) removed from the player.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,114), total); // %d item(s) removed from the player.
clif->message(fd, atcmd_output);
}
return true;
@@ -8365,7 +8372,7 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand
dbi_destroy(iter);
clif->message(fd,line_buff);
- sprintf(atcmd_output, msg_fd(fd,274), count); // "%d commands found."
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,274), count); // "%d commands found."
clif->message(fd, atcmd_output);
return;
@@ -8410,7 +8417,7 @@ ACMD(cashmount)
ACMD(accinfo) {
char query[NAME_LENGTH];
- if (!message || !*message || strlen(message) > NAME_LENGTH ) {
+ if (!*message || strlen(message) > NAME_LENGTH ) {
clif->message(fd, msg_fd(fd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
clif->message(fd, msg_fd(fd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
return false;
@@ -8431,7 +8438,7 @@ ACMD(set) {
bool is_str = false;
size_t len;
- if( !message || !*message || (toset = sscanf(message, "%31s %127[^\n]s", reg, val)) < 1 ) {
+ if (!*message || (toset = sscanf(message, "%31s %127[^\n]s", reg, val)) < 1) {
clif->message(fd, msg_fd(fd,1367)); // Usage: @set <variable name> <value>
clif->message(fd, msg_fd(fd,1368)); // Usage: ex. "@set PoringCharVar 50"
clif->message(fd, msg_fd(fd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
@@ -8514,16 +8521,16 @@ ACMD(set) {
switch( data->type ) {
case C_INT:
- sprintf(atcmd_output,msg_fd(fd,1373),reg,data->u.num); // %s value is now :%d
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1373),reg,data->u.num); // %s value is now :%d
break;
case C_STR:
- sprintf(atcmd_output,msg_fd(fd,1374),reg,data->u.str); // %s value is now :%s
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1374),reg,data->u.str); // %s value is now :%s
break;
case C_CONSTSTR:
- sprintf(atcmd_output,msg_fd(fd,1375),reg); // %s is empty
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1375),reg); // %s is empty
break;
default:
- sprintf(atcmd_output,msg_fd(fd,1376),reg,data->type); // %s data type is not supported :%u
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1376),reg,data->type); // %s data type is not supported :%u
break;
}
clif->message(fd, atcmd_output);
@@ -8541,12 +8548,12 @@ ACMD(addperm) {
bool add = (strcmpi(info->command, "addperm") == 0) ? true : false;
int i;
- if( !message || !*message ) {
- sprintf(atcmd_output, msg_fd(fd,1378),command); // Usage: %s <permission_name>
+ if (!*message) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1378),command); // Usage: %s <permission_name>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1379)); // -- Permission List
for( i = 0; i < perm_size; i++ ) {
- sprintf(atcmd_output,"- %s",pcg->permissions[i].name);
+ safesnprintf(atcmd_output, sizeof(atcmd_output),"- %s",pcg->permissions[i].name);
clif->message(fd, atcmd_output);
}
return false;
@@ -8554,28 +8561,28 @@ ACMD(addperm) {
ARR_FIND(0, perm_size, i, strcmpi(pcg->permissions[i].name, message) == 0);
if( i == perm_size ) {
- sprintf(atcmd_output,msg_fd(fd,1380),message); // '%s' is not a known permission.
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1380),message); // '%s' is not a known permission.
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1379)); // -- Permission List
for( i = 0; i < perm_size; i++ ) {
- sprintf(atcmd_output,"- %s",pcg->permissions[i].name);
+ safesnprintf(atcmd_output, sizeof(atcmd_output),"- %s",pcg->permissions[i].name);
clif->message(fd, atcmd_output);
}
return false;
}
if( add && (sd->extra_temp_permissions&pcg->permissions[i].permission) ) {
- sprintf(atcmd_output, msg_fd(fd,1381),sd->status.name,pcg->permissions[i].name); // User '%s' already possesses the '%s' permission.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1381),sd->status.name,pcg->permissions[i].name); // User '%s' already possesses the '%s' permission.
clif->message(fd, atcmd_output);
return false;
} else if ( !add && !(sd->extra_temp_permissions&pcg->permissions[i].permission) ) {
- sprintf(atcmd_output, msg_fd(fd,1382),sd->status.name,pcg->permissions[i].name); // User '%s' doesn't possess the '%s' permission.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1382),sd->status.name,pcg->permissions[i].name); // User '%s' doesn't possess the '%s' permission.
clif->message(fd, atcmd_output);
- sprintf(atcmd_output,msg_fd(fd,1383),sd->status.name); // -- User '%s' Permissions
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1383),sd->status.name); // -- User '%s' Permissions
clif->message(fd, atcmd_output);
for( i = 0; i < perm_size; i++ ) {
if( sd->extra_temp_permissions&pcg->permissions[i].permission ) {
- sprintf(atcmd_output,"- %s",pcg->permissions[i].name);
+ safesnprintf(atcmd_output, sizeof(atcmd_output),"- %s",pcg->permissions[i].name);
clif->message(fd, atcmd_output);
}
}
@@ -8587,21 +8594,21 @@ ACMD(addperm) {
else
sd->extra_temp_permissions &=~ pcg->permissions[i].permission;
- sprintf(atcmd_output, msg_fd(fd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
clif->message(fd, atcmd_output);
return true;
}
ACMD(unloadnpcfile)
{
- if( !message || !*message ) {
+ if (!*message) {
clif->message(fd, msg_fd(fd,1385)); // Usage: @unloadnpcfile <file name>
return false;
}
- if( npc->unloadfile(message) )
+ if (npc->unloadfile(message)) {
clif->message(fd, msg_fd(fd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
- else {
+ } else {
clif->message(fd, msg_fd(fd,1387)); // File not found.
return false;
}
@@ -8614,14 +8621,12 @@ ACMD(cart) {
sd->status.skill[idx].flag = (x)?1:0; \
} while(0)
- int val;
+ int val = atoi(message);
bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true;
unsigned int index = skill->get_index(MC_PUSHCART);
- if (message)
- val = atoi(message);
- if( !message || !*message || val < 0 || val > MAX_CARTS ) {
- sprintf(atcmd_output, msg_fd(fd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
+ if (!*message || val < 0 || val > MAX_CARTS) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
clif->message(fd, atcmd_output);
return false;
}
@@ -8658,16 +8663,16 @@ ACMD(join)
char name[HCS_NAME_LENGTH], pass[HCS_NAME_LENGTH];
enum channel_operation_status ret = HCS_STATUS_OK;
- if (!message || !*message || sscanf(message, "%19s %19s", name, pass) < 1) {
- sprintf(atcmd_output, msg_fd(fd,1399),command); // Unknown Channel (usage: %s <#channel_name>)
+ if (!*message || sscanf(message, "%19s %19s", name, pass) < 1) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1399),command); // Unknown Channel (usage: %s <#channel_name>)
clif->message(fd, atcmd_output);
return false;
}
chan = channel->search(name, sd);
- if(!chan) {
- sprintf(atcmd_output, msg_fd(fd,1400),name,command); // Unknown Channel '%s' (usage: %s <#channel_name>)
+ if (!chan) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1400),name,command); // Unknown Channel '%s' (usage: %s <#channel_name>)
clif->message(fd, atcmd_output);
return false;
}
@@ -8675,19 +8680,19 @@ ACMD(join)
ret = channel->join(chan, sd, pass, false);
if (ret == HCS_STATUS_ALREADY) {
- sprintf(atcmd_output, msg_fd(fd,1436),name); // You're already in the '%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1436),name); // You're already in the '%s' channel
clif->message(fd, atcmd_output);
return false;
}
if (ret == HCS_STATUS_NOPERM) {
- sprintf(atcmd_output, msg_fd(fd,1401),name,command); // '%s' Channel is password protected (usage: %s <#channel_name> <password>)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1401),name,command); // '%s' Channel is password protected (usage: %s <#channel_name> <password>)
clif->message(fd, atcmd_output);
return false;
}
if (ret == HCS_STATUS_BANNED) {
- sprintf(atcmd_output, msg_fd(fd,1438),name); // You cannot join the '%s' channel because you've been banned from it
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1438),name); // You cannot join the '%s' channel because you've been banned from it
clif->message(fd, atcmd_output);
return false;
}
@@ -8695,51 +8700,52 @@ ACMD(join)
return true;
}
/* [Ind/Hercules] */
-static inline void atcmd_channel_help(int fd, const char *command, bool can_create) {
- sprintf(atcmd_output, msg_fd(fd,1404),command); // %s failed.
+void atcommand_channel_help(int fd, const char *command, bool can_create) {
+ nullpo_retv(command);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1404),command); // %s failed.
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1414));// --- Available options:
if( can_create ) {
- sprintf(atcmd_output, msg_fd(fd,1415),command);// -- %s create <channel name> <channel password>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1415),command);// -- %s create <channel name> <channel password>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1416));// - creates a new channel
}
- sprintf(atcmd_output, msg_fd(fd,1417),command);// -- %s list
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1417),command);// -- %s list
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1418));// - lists public channels
if( can_create ) {
- sprintf(atcmd_output, msg_fd(fd,1419),command);// -- %s list colors
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1419),command);// -- %s list colors
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1420));// - lists colors available to select for custom channels
- sprintf(atcmd_output, msg_fd(fd,1421),command);// -- %s setcolor <channel name> <color name>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1421),command);// -- %s setcolor <channel name> <color name>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1422));// - changes <channel name> color to <color name>
}
- sprintf(atcmd_output, msg_fd(fd,1423),command);// -- %s leave <channel name>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1423),command);// -- %s leave <channel name>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1424));// - leaves <channel name>
- sprintf(atcmd_output, msg_fd(fd,1427),command);// -- %s bindto <channel name>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1427),command);// -- %s bindto <channel name>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1428));// - binds global chat to <channel name>, making anything you type in global be sent to the channel
- sprintf(atcmd_output, msg_fd(fd,1429),command);// -- %s unbind
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1429),command);// -- %s unbind
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1430));// - unbinds your global chat from its attached channel (if binded)
- sprintf(atcmd_output, msg_fd(fd,1429),command);// -- %s unbind
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1429),command);// -- %s unbind
clif->message(fd, atcmd_output);
if( can_create ) {
- sprintf(atcmd_output, msg_fd(fd,1456),command);// -- %s ban <channel name> <character name>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1456),command);// -- %s ban <channel name> <character name>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1457));// - bans <character name> from <channel name> channel
- sprintf(atcmd_output, msg_fd(fd,1458),command);// -- %s banlist <channel name>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1458),command);// -- %s banlist <channel name>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1459));// - lists all banned characters from <channel name> channel
- sprintf(atcmd_output, msg_fd(fd,1460),command);// -- %s unban <channel name> <character name>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1460),command);// -- %s unban <channel name> <character name>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1461));// - unbans <character name> from <channel name> channel
- sprintf(atcmd_output, msg_fd(fd,1467),command);// -- %s unbanall <channel name>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1467),command);// -- %s unbanall <channel name>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1468));// - unbans everyone from <channel name>
- sprintf(atcmd_output, msg_fd(fd,1462),command);// -- %s setopt <channel name> <option name> <option value>
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1462),command);// -- %s setopt <channel name> <option name> <option value>
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1463));// - adds or removes <option name> with <option value> to <channel name> channel
}
@@ -8751,20 +8757,20 @@ ACMD(channel) {
unsigned char k = 0;
sub1[0] = sub2[0] = sub3[0] = '\0';
- if (!message || !*message || sscanf(message, "%19s %19s %19s %19s", subcmd, sub1, sub2, sub3) < 1) {
- atcmd_channel_help(fd,command, (channel->config->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)));
+ if (!*message || sscanf(message, "%19s %19s %19s %19s", subcmd, sub1, sub2, sub3) < 1) {
+ atcommand->channel_help(fd,command, (channel->config->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)));
return true;
}
if (strcmpi(subcmd,"create") == 0 && (channel->config->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN))) {
// sub1 = channel name; sub2 = password; sub3 = unused
size_t len = strlen(sub1);
- const char *pass = *sub2 ? sub2 : NULL;
+ const char *pass = *sub2 ? sub2 : "";
if (sub1[0] != '#') {
clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
return false;
} else if (len < 3 || len > HCS_NAME_LENGTH) {
- sprintf(atcmd_output, msg_fd(fd,1406), HCS_NAME_LENGTH);// Channel length must be between 3 and %d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1406), HCS_NAME_LENGTH);// Channel length must be between 3 and %d
clif->message(fd, atcmd_output);
return false;
} else if (sub3[0] != '\0') {
@@ -8772,7 +8778,7 @@ ACMD(channel) {
return false;
}
if (strcmpi(sub1 + 1, channel->config->local_name) == 0 || strcmpi(sub1 + 1, channel->config->ally_name) == 0 || strdb_exists(channel->db, sub1 + 1)) {
- sprintf(atcmd_output, msg_fd(fd,1407), sub1);// Channel '%s' is not available
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
@@ -8786,7 +8792,7 @@ ACMD(channel) {
// sub1 = list type; sub2 = unused; sub3 = unused
if (sub1[0] != '\0' && strcmpi(sub1,"colors") == 0) {
for (k = 0; k < channel->config->colors_count; k++) {
- sprintf(atcmd_output, "[ %s list colors ] : %s", command, channel->config->colors_name[k]);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), "[ %s list colors ] : %s", command, channel->config->colors_name[k]);
clif->messagecolor_self(fd, channel->config->colors[k], atcmd_output);
}
@@ -8795,18 +8801,18 @@ ACMD(channel) {
bool show_all = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false;
clif->message(fd, msg_fd(fd,1410)); // -- Public Channels
if (channel->config->local) {
- sprintf(atcmd_output, msg_fd(fd,1409), channel->config->local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users )
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1409), channel->config->local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
if (channel->config->ally && sd->status.guild_id) {
struct guild *g = sd->guild;
if( !g ) { dbi_destroy(iter); return false; }
- sprintf(atcmd_output, msg_fd(fd,1409), channel->config->ally_name, db_size(g->channel->users));// - #%s ( %d users )
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1409), channel->config->ally_name, db_size(g->channel->users));// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
for (chan = dbi_first(iter); dbi_exists(iter); chan = dbi_next(iter)) {
if (show_all || chan->type == HCS_TYPE_PUBLIC || chan->type == HCS_TYPE_IRC) {
- sprintf(atcmd_output, msg_fd(fd,1409), chan->name, db_size(chan->users));// - #%s ( %d users )
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1409), chan->name, db_size(chan->users));// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
}
@@ -8820,13 +8826,13 @@ ACMD(channel) {
}
if (!(chan = channel->search(sub1, sd))) {
- sprintf(atcmd_output, msg_fd(fd,1407), sub1);// Channel '%s' is not available
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
if (chan->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
- sprintf(atcmd_output, msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
@@ -8836,12 +8842,12 @@ ACMD(channel) {
break;
}
if (k == channel->config->colors_count) {
- sprintf(atcmd_output, msg_fd(fd,1411), sub2);// Unknown color '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1411), sub2);// Unknown color '%s'
clif->message(fd, atcmd_output);
return false;
}
chan->color = k;
- sprintf(atcmd_output, msg_fd(fd,1413), sub1, channel->config->colors_name[k]);// '%s' channel color updated to '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1413), sub1, channel->config->colors_name[k]);// '%s' channel color updated to '%s'
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"leave") == 0) {
// sub1 = channel name; sub2 = unused; sub3 = unused
@@ -8854,7 +8860,7 @@ ACMD(channel) {
break;
}
if (k == sd->channel_count) {
- sprintf(atcmd_output, msg_fd(fd,1425),sub1);// You're not part of the '%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1425),sub1);// You're not part of the '%s' channel
clif->message(fd, atcmd_output);
return false;
}
@@ -8870,7 +8876,7 @@ ACMD(channel) {
} else {
channel->leave(sd->channels[k],sd);
}
- sprintf(atcmd_output, msg_fd(fd,1426),sub1); // You've left the '%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1426),sub1); // You've left the '%s' channel
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"bindto") == 0) {
// sub1 = channel name; sub2 = unused; sub3 = unused
@@ -8884,13 +8890,13 @@ ACMD(channel) {
break;
}
if (k == sd->channel_count) {
- sprintf(atcmd_output, msg_fd(fd,1425),sub1);// You're not part of the '%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1425),sub1);// You're not part of the '%s' channel
clif->message(fd, atcmd_output);
return false;
}
sd->gcbind = sd->channels[k];
- sprintf(atcmd_output, msg_fd(fd,1431),sub1); // Your global chat is now bound to the '%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1431),sub1); // Your global chat is now bound to the '%s' channel
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"unbind") == 0) {
// sub1 = unused; sub2 = unused; sub3 = unused
@@ -8899,7 +8905,7 @@ ACMD(channel) {
return false;
}
- sprintf(atcmd_output, msg_fd(fd,1433),sd->gcbind->name); // Your global chat is no longer bound to the '#%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1433),sd->gcbind->name); // Your global chat is no longer bound to the '#%s' channel
clif->message(fd, atcmd_output);
sd->gcbind = NULL;
@@ -8915,19 +8921,19 @@ ACMD(channel) {
}
if (!(chan = channel->search(sub1, sd))) {
- sprintf(atcmd_output, msg_fd(fd,1407), sub1);// Channel '%s' is not available
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) {
- sprintf(atcmd_output, msg_fd(fd,1434), sub4);// Player '%s' was not found
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
}
if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) {
- sprintf(atcmd_output, msg_fd(fd,1434), sub4);// Player '%s' was not found
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
}
@@ -8935,13 +8941,13 @@ ACMD(channel) {
ret = channel->ban(chan, sd, pl_sd);
if (ret == HCS_STATUS_NOPERM) {
- sprintf(atcmd_output, msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
if (ret == HCS_STATUS_ALREADY) {
- sprintf(atcmd_output, msg_fd(fd,1465), pl_sd->status.name);// Player '%s' is already banned from this channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1465), pl_sd->status.name);// Player '%s' is already banned from this channel
clif->message(fd, atcmd_output);
return false;
}
@@ -8951,7 +8957,7 @@ ACMD(channel) {
return false;
}
- sprintf(atcmd_output, msg_fd(fd,1437),pl_sd->status.name,sub1); // Player '%s' has now been banned from '%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1437),pl_sd->status.name,sub1); // Player '%s' has now been banned from '%s' channel
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"unban") == 0) {
// sub1 = channel name; sub2 = unused; sub3 = unused
@@ -8964,34 +8970,34 @@ ACMD(channel) {
return false;
}
if (!(chan = channel->search(sub1, sd))) {
- sprintf(atcmd_output, msg_fd(fd,1407), sub1);// Channel '%s' is not available
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) {
- sprintf(atcmd_output, msg_fd(fd,1434), sub4);// Player '%s' was not found
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
}
if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) {
- sprintf(atcmd_output, msg_fd(fd,1434), sub4);// Player '%s' was not found
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
}
ret = channel->unban(chan, sd, pl_sd);
if (ret == HCS_STATUS_NOPERM) {
- sprintf(atcmd_output, msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
if (ret == HCS_STATUS_ALREADY) {
- sprintf(atcmd_output, msg_fd(fd,1440), pl_sd->status.name);// Player '%s' is not banned from this channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1440), pl_sd->status.name);// Player '%s' is not banned from this channel
clif->message(fd, atcmd_output);
return false;
}
- sprintf(atcmd_output, msg_fd(fd,1441),pl_sd->status.name,sub1); // Player '%s' has now been unbanned from the '%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1441),pl_sd->status.name,sub1); // Player '%s' has now been unbanned from the '%s' channel
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"unbanall") == 0) {
enum channel_operation_status ret = HCS_STATUS_OK;
@@ -9001,23 +9007,23 @@ ACMD(channel) {
return false;
}
if (!(chan = channel->search(sub1, sd))) {
- sprintf(atcmd_output, msg_fd(fd,1407), sub1);// Channel '%s' is not available
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
ret = channel->unban(chan, sd, NULL);
if (ret == HCS_STATUS_NOPERM) {
- sprintf(atcmd_output, msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
if (ret == HCS_STATUS_ALREADY) {
- sprintf(atcmd_output, msg_fd(fd,1439), sub1);// Channel '%s' has no banned players
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1439), sub1);// Channel '%s' has no banned players
clif->message(fd, atcmd_output);
return false;
}
- sprintf(atcmd_output, msg_fd(fd,1442),sub1); // Removed all bans from '%s' channel
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1442),sub1); // Removed all bans from '%s' channel
clif->message(fd, atcmd_output);
} else if (strcmpi(subcmd,"banlist") == 0) {
// sub1 = channel name; sub2 = unused; sub3 = unused
@@ -9030,21 +9036,21 @@ ACMD(channel) {
return false;
}
if (!(chan = channel->search(sub1, sd))) {
- sprintf(atcmd_output, msg_fd(fd,1407), sub1);// Channel '%s' is not available
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
if (chan->owner != sd->status.char_id && !isA) {
- sprintf(atcmd_output, msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
if (!chan->banned) {
- sprintf(atcmd_output, msg_fd(fd,1439), sub1);// Channel '%s' has no banned players
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1439), sub1);// Channel '%s' has no banned players
clif->message(fd, atcmd_output);
return false;
}
- sprintf(atcmd_output, msg_fd(fd,1443), chan->name);// -- '%s' ban list
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1443), chan->name);// -- '%s' ban list
clif->message(fd, atcmd_output);
iter = db_iterator(chan->banned);
@@ -9052,9 +9058,9 @@ ACMD(channel) {
struct channel_ban_entry *entry = DB->data2ptr(data);
if (!isA)
- sprintf(atcmd_output, msg_fd(fd,1444), entry->name);// - %s %s
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1444), entry->name);// - %s %s
else
- sprintf(atcmd_output, msg_fd(fd,1445), entry->name, key.i);// - %s (%d)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1445), entry->name, key.i);// - %s (%d)
clif->message(fd, atcmd_output);
}
@@ -9071,12 +9077,12 @@ ACMD(channel) {
return false;
}
if (!(chan = channel->search(sub1, sd))) {
- sprintf(atcmd_output, msg_fd(fd,1407), sub1);// Channel '%s' is not available
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
if (chan->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
- sprintf(atcmd_output, msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
@@ -9089,27 +9095,27 @@ ACMD(channel) {
break;
}
if (k == 3) {
- sprintf(atcmd_output, msg_fd(fd,1447), sub2);// '%s' is not a known channel option
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1447), sub2);// '%s' is not a known channel option
clif->message(fd, atcmd_output);
clif->message(fd, msg_fd(fd,1448)); // -- Available options
for (k = 1; k < 3; k++) {
- sprintf(atcmd_output, msg_fd(fd,1444), opt_str[k]);// - '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1444), opt_str[k]);// - '%s'
clif->message(fd, atcmd_output);
}
return false;
}
if (sub3[0] == '\0') {
if (k == HCS_OPT_MSG_DELAY) {
- sprintf(atcmd_output, msg_fd(fd,1466), opt_str[k]);// For '%s' you need the amount of seconds (from 0 to 10)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1466), opt_str[k]);// For '%s' you need the amount of seconds (from 0 to 10)
clif->message(fd, atcmd_output);
return false;
} else if (chan->options & k) {
- sprintf(atcmd_output, msg_fd(fd,1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel setopt %s 0'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel setopt %s 0'
clif->message(fd, atcmd_output);
return false;
} else {
channel->set_options(chan, chan->options | k);
- sprintf(atcmd_output, msg_fd(fd,1450), opt_str[k],chan->name);//option '%s' is now enabled for channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1450), opt_str[k],chan->name);//option '%s' is now enabled for channel '%s'
clif->message(fd, atcmd_output);
return true;
}
@@ -9117,42 +9123,42 @@ ACMD(channel) {
int v = atoi(sub3);
if (k == HCS_OPT_MSG_DELAY) {
if (v < 0 || v > 10) {
- sprintf(atcmd_output, msg_fd(fd,1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10)
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10)
clif->message(fd, atcmd_output);
return false;
}
if (v == 0) {
channel->set_options(chan, chan->options&~k);
chan->msg_delay = 0;
- sprintf(atcmd_output, msg_fd(fd,1453), opt_str[k],chan->name,v);// option '%s' is now disabled for channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1453), opt_str[k],chan->name,v);// option '%s' is now disabled for channel '%s'
clif->message(fd, atcmd_output);
return true;
} else {
channel->set_options(chan, chan->options | k);
chan->msg_delay = v;
- sprintf(atcmd_output, msg_fd(fd,1452), opt_str[k],chan->name,v);// option '%s' is now enabled for channel '%s' with %d seconds
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1452), opt_str[k],chan->name,v);// option '%s' is now enabled for channel '%s' with %d seconds
clif->message(fd, atcmd_output);
return true;
}
} else {
if (v) {
if (chan->options & k) {
- sprintf(atcmd_output, msg_fd(fd,1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel opt %s 0'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel opt %s 0'
clif->message(fd, atcmd_output);
return false;
} else {
channel->set_options(chan, chan->options | k);
- sprintf(atcmd_output, msg_fd(fd,1450), opt_str[k],chan->name);//option '%s' is now enabled for channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1450), opt_str[k],chan->name);//option '%s' is now enabled for channel '%s'
clif->message(fd, atcmd_output);
}
} else {
if (!(chan->options & k)) {
- sprintf(atcmd_output, msg_fd(fd,1454), opt_str[k],chan->name); // option '%s' is not enabled on channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1454), opt_str[k],chan->name); // option '%s' is not enabled on channel '%s'
clif->message(fd, atcmd_output);
return false;
} else {
channel->set_options(chan, chan->options&~k);
- sprintf(atcmd_output, msg_fd(fd,1453), opt_str[k],chan->name);// option '%s' is now disabled for channel '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1453), opt_str[k],chan->name);// option '%s' is now disabled for channel '%s'
clif->message(fd, atcmd_output);
return true;
}
@@ -9160,7 +9166,7 @@ ACMD(channel) {
}
}
} else {
- atcmd_channel_help(fd, command, (channel->config->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)));
+ atcommand->channel_help(fd, command, (channel->config->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)));
}
return true;
}
@@ -9168,9 +9174,9 @@ ACMD(channel) {
ACMD(fontcolor) {
unsigned char k;
- if (!message || !*message) {
+ if (!*message) {
for (k = 0; k < channel->config->colors_count; k++) {
- sprintf(atcmd_output, "[ %s ] : %s", command, channel->config->colors_name[k]);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), "[ %s ] : %s", command, channel->config->colors_name[k]);
clif->messagecolor_self(fd, channel->config->colors[k], atcmd_output);
}
return false;
@@ -9186,13 +9192,13 @@ ACMD(fontcolor) {
break;
}
if( k == channel->config->colors_count ) {
- sprintf(atcmd_output, msg_fd(fd,1411), message);// Unknown color '%s'
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1411), message);// Unknown color '%s'
clif->message(fd, atcmd_output);
return false;
}
sd->fontcolor = k + 1;
- sprintf(atcmd_output, "Color changed to '%s'", channel->config->colors_name[k]);
+ safesnprintf(atcmd_output, sizeof(atcmd_output), "Color changed to '%s'", channel->config->colors_name[k]);
clif->messagecolor_self(fd, channel->config->colors[k], atcmd_output);
return true;
@@ -9200,7 +9206,7 @@ ACMD(fontcolor) {
ACMD(searchstore){
int val = atoi(message);
- switch( val ) {
+ switch (val) {
case 0://EFFECTTYPE_NORMAL
case 1://EFFECTTYPE_CASH
break;
@@ -9233,10 +9239,10 @@ ACMD(costume){
};
unsigned short k = 0, len = ARRAYLENGTH(names);
- if( !message || !*message ) {
+ if (!*message) {
for( k = 0; k < len; k++ ) {
if( sd->sc.data[name2id[k]] ) {
- sprintf(atcmd_output,msg_fd(fd,1473),names[k]);//Costume '%s' removed.
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1473),names[k]);//Costume '%s' removed.
clif->message(sd->fd,atcmd_output);
status_change_end(&sd->bl,name2id[k],INVALID_TIMER);
return true;
@@ -9244,7 +9250,7 @@ ACMD(costume){
}
clif->message(sd->fd,msg_fd(fd,1472));
for( k = 0; k < len; k++ ) {
- sprintf(atcmd_output,msg_fd(fd,1471),names[k]);//-- %s
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1471),names[k]);//-- %s
clif->message(sd->fd,atcmd_output);
}
return false;
@@ -9252,7 +9258,7 @@ ACMD(costume){
for( k = 0; k < len; k++ ) {
if( sd->sc.data[name2id[k]] ) {
- sprintf(atcmd_output,msg_fd(fd,1470),names[k]);// You're already with a '%s' costume, type '@costume' to remove it.
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1470),names[k]);// You're already with a '%s' costume, type '@costume' to remove it.
clif->message(sd->fd,atcmd_output);
return false;
}
@@ -9263,7 +9269,7 @@ ACMD(costume){
break;
}
if( k == len ) {
- sprintf(atcmd_output,msg_fd(fd,1469),message);// '%s' is not a known costume
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1469),message);// '%s' is not a known costume
clif->message(sd->fd,atcmd_output);
return false;
}
@@ -9275,13 +9281,13 @@ ACMD(costume){
/* for debugging purposes (so users can easily provide us with debug info) */
/* should be trashed as soon as its no longer necessary */
ACMD(skdebug) {
- sprintf(atcmd_output,"second: %u; third: %u", sd->sktree.second, sd->sktree.third);
+ safesnprintf(atcmd_output, sizeof(atcmd_output),"second: %u; third: %u", sd->sktree.second, sd->sktree.third);
clif->message(fd,atcmd_output);
- sprintf(atcmd_output,"pc_calc_skilltree_normalize_job: %d",pc->calc_skilltree_normalize_job(sd));
+ safesnprintf(atcmd_output, sizeof(atcmd_output),"pc_calc_skilltree_normalize_job: %d",pc->calc_skilltree_normalize_job(sd));
clif->message(fd,atcmd_output);
- sprintf(atcmd_output,"change_lv_2nd/3rd: %d/%d",sd->change_level_2nd,sd->change_level_3rd);
+ safesnprintf(atcmd_output, sizeof(atcmd_output),"change_lv_2nd/3rd: %d/%d",sd->change_level_2nd,sd->change_level_3rd);
clif->message(fd,atcmd_output);
- sprintf(atcmd_output,"pc_calc_skillpoint:%d",pc->calc_skillpoint(sd));
+ safesnprintf(atcmd_output, sizeof(atcmd_output),"pc_calc_skillpoint:%d",pc->calc_skillpoint(sd));
clif->message(fd,atcmd_output);
return true;
}
@@ -9292,7 +9298,7 @@ ACMD(cddebug) {
int i;
struct skill_cd* cd = NULL;
- if( !(cd = idb_get(skill->cd_db,sd->status.char_id)) ) {
+ if (!(cd = idb_get(skill->cd_db,sd->status.char_id))) {
clif->message(fd,"No cool down list found");
} else {
clif->messages(fd,"Found %d registered cooldowns",cd->cursor);
@@ -9308,7 +9314,7 @@ ACMD(cddebug) {
}
}
- if( !cd || (message && *message && !strcmpi(message,"reset")) ) {
+ if (!cd || (*message && !strcmpi(message,"reset"))) {
for(i = 0; i < MAX_SKILL; i++) {
if( sd->blockskill[i] ) {
clif->messages(fd,"Found skill '%s', unblocking...",skill->dbs->db[i].name);
@@ -9336,7 +9342,7 @@ ACMD(cddebug) {
ACMD(lang) {
uint8 i;
- if( !message || !*message ) {
+ if (!*message) {
clif->messages(fd,"Usage: @%s <Language>",info->command);
clif->messages(fd,"There are %d languages available:",script->max_lang_id);
for(i = 0; i < script->max_lang_id; i++)
@@ -9654,9 +9660,10 @@ void atcommand_basecommands(void) {
#undef ACMD_DEF
#undef ACMD_DEF2
-bool atcommand_add(char *name,AtCommandFunc func, bool replace) {
+bool atcommand_add(char *name, AtCommandFunc func, bool replace) {
AtCommandInfo* cmd;
+ nullpo_retr(false, name);
if( (cmd = atcommand->exists(name)) ) { //caller will handle/display on false
if( !replace )
return false;
@@ -9979,6 +9986,7 @@ void atcommand_config_read(const char* config_filename) {
const char *symbol = NULL;
int num_aliases = 0;
+ nullpo_retv(config_filename);
if (libconfig->read_file(&atcommand_config, config_filename))
return;
@@ -10101,7 +10109,11 @@ void atcommand_config_read(const char* config_filename) {
* COMMAND_ATCOMMAND (1) being index 0, COMMAND_CHARCOMMAND (2) being index 1.
* @private
*/
-static inline int AtCommandType2idx(AtCommandType type) { return (type-1); }
+static inline int atcommand_command_type2idx(AtCommandType type)
+{
+ Assert_retr(0, type > 0);
+ return (type-1);
+}
/**
* Loads permissions for groups to use commands.
@@ -10112,6 +10124,8 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
DBIterator *iter = db_iterator(atcommand->db);
AtCommandInfo *atcmd;
+ nullpo_retv(groups);
+ nullpo_retv(commands_);
for (atcmd = dbi_first(iter); dbi_exists(iter); atcmd = dbi_next(iter)) {
int i;
CREATE(atcmd->at_groups, char, sz);
@@ -10151,10 +10165,10 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
config_setting_is_aggregate(cmd) &&
config_setting_length(cmd) == 2
) {
- if (config_setting_get_bool_elem(cmd, AtCommandType2idx(COMMAND_ATCOMMAND))) {
+ if (config_setting_get_bool_elem(cmd, atcommand_command_type2idx(COMMAND_ATCOMMAND))) {
atcmd->at_groups[idx] = 1;
}
- if (config_setting_get_bool_elem(cmd, AtCommandType2idx(COMMAND_CHARCOMMAND))) {
+ if (config_setting_get_bool_elem(cmd, atcommand_command_type2idx(COMMAND_CHARCOMMAND))) {
atcmd->char_groups[idx] = 1;
}
}
@@ -10168,6 +10182,8 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
bool atcommand_can_use(struct map_session_data *sd, const char *command) {
AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command + 1));
+ nullpo_retr(false, sd);
+ nullpo_retr(false, command);
if (info == NULL)
return false;
@@ -10181,6 +10197,8 @@ bool atcommand_can_use(struct map_session_data *sd, const char *command) {
bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) {
AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command));
+ nullpo_retr(false, sd);
+ nullpo_retr(false, command);
if (info == NULL)
return false;
@@ -10287,6 +10305,8 @@ void atcommand_defaults(void) {
atcommand->cleanfloor_sub = atcommand_cleanfloor_sub;
atcommand->mutearea_sub = atcommand_mutearea_sub;
atcommand->commands_sub = atcommand_commands_sub;
+ atcommand->getring = atcommand_getring;
+ atcommand->channel_help = atcommand_channel_help;
atcommand->cmd_db_clear = atcommand_db_clear;
atcommand->cmd_db_clear_sub = atcommand_db_clear_sub;
atcommand->doload = atcommand_doload;
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index ccc7d3725..6c8dbf9ef 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -114,6 +114,8 @@ struct atcommand_interface {
void (*get_jail_time) (int jailtime, int* year, int* month, int* day, int* hour, int* minute);
int (*cleanfloor_sub) (struct block_list *bl, va_list ap);
int (*mutearea_sub) (struct block_list *bl,va_list ap);
+ void (*getring) (struct map_session_data* sd);
+ void (*channel_help) (int fd, const char *command, bool can_create);
/* */
void (*commands_sub) (struct map_session_data* sd, const int fd, AtCommandType type);
void (*cmd_db_clear) (void);
@@ -134,6 +136,7 @@ void atcommand_defaults(void);
HPShared struct atcommand_interface *atcommand;
/* stay here */
-#define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info)
+#define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) __attribute__((nonnull (2, 3, 4, 5))); \
+ static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info)
#endif /* MAP_ATCOMMAND_H */
diff --git a/src/map/battle.c b/src/map/battle.c
index 6a6924aa3..d4f789d34 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -48,7 +48,8 @@ struct battle_interface *battle;
int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last skill in use by this bl.
struct unit_data *ud;
- if( bl->type == BL_SKILL ) {
+ nullpo_ret(bl);
+ if (bl->type == BL_SKILL) {
struct skill_unit * su = (struct skill_unit*)bl;
return su->group?su->group->skill_id:0;
}
@@ -67,6 +68,7 @@ int battle_gettargeted_sub(struct block_list *bl, va_list ap) {
int target_id;
int *c;
+ nullpo_ret(bl);
bl_list = va_arg(ap, struct block_list **);
c = va_arg(ap, int *);
target_id = va_arg(ap, int);
@@ -77,7 +79,7 @@ int battle_gettargeted_sub(struct block_list *bl, va_list ap) {
if (*c >= 24)
return 0;
- if ( !(ud = unit->bl2ud(bl)) )
+ if (!(ud = unit->bl2ud(bl)))
return 0;
if (ud->target == target_id || ud->skilltarget == target_id) {
@@ -106,6 +108,7 @@ struct block_list* battle_gettargeted(struct block_list *target) {
//Returns the id of the current targeted character of the passed bl. [Skotlex]
int battle_gettarget(struct block_list* bl) {
+ nullpo_ret(bl);
switch (bl->type) {
case BL_PC: return ((struct map_session_data*)bl)->ud.target;
case BL_MOB: return ((struct mob_data*)bl)->target_id;
@@ -123,6 +126,7 @@ int battle_getenemy_sub(struct block_list *bl, va_list ap) {
struct block_list *target;
int *c;
+ nullpo_ret(bl);
bl_list = va_arg(ap, struct block_list **);
c = va_arg(ap, int *);
target = va_arg(ap, struct block_list *);
@@ -149,6 +153,7 @@ struct block_list* battle_getenemy(struct block_list *target, int type, int rang
struct block_list *bl_list[24];
int c = 0;
+ nullpo_retr(NULL, target);
memset(bl_list, 0, sizeof(bl_list));
map->foreachinrange(battle->get_enemy_sub, target, range, type, bl_list, &c, target);
@@ -164,8 +169,11 @@ int battle_getenemyarea_sub(struct block_list *bl, va_list ap) {
struct block_list **bl_list, *src;
int *c, ignore_id;
+ nullpo_ret(bl);
bl_list = va_arg(ap, struct block_list **);
+ nullpo_ret(bl_list);
c = va_arg(ap, int *);
+ nullpo_ret(c);
src = va_arg(ap, struct block_list *);
ignore_id = va_arg(ap, int);
@@ -191,6 +199,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int
struct block_list *bl_list[24];
int c = 0;
+ nullpo_retr(NULL, src);
memset(bl_list, 0, sizeof(bl_list));
map->foreachinarea(battle->get_enemy_area_sub, src->m, x - range, y - range, x + range, y + range, type, bl_list, &c, src, ignore_id);
@@ -300,7 +309,6 @@ int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct
}
int battle_attr_ratio(int atk_elem,int def_type, int def_lv)
{
-
if (atk_elem < ELE_NEUTRAL || atk_elem >= ELE_MAX)
return 100;
@@ -501,7 +509,8 @@ int64 battle_calc_base_damage(struct block_list *src, struct block_list *bl, uin
int64 damage;
struct status_data *st = status->get_status_data(src);
struct status_change *sc = status->get_sc(src);
-
+
+ nullpo_retr(0, src);
if ( !skill_id ) {
s_ele = st->rhw.ele;
s_ele_ = st->lhw.ele;
@@ -536,6 +545,8 @@ int64 battle_calc_base_damage2(struct status_data *st, struct weapon_atk *wa, st
short type = 0;
int64 damage = 0;
+ nullpo_retr(damage, st);
+ nullpo_retr(damage, wa);
if (!sd) { //Mobs/Pets
if(flag&4) {
atkmin = st->matk_min;
@@ -612,6 +623,7 @@ int64 battle_calc_base_damage2(struct status_data *st, struct weapon_atk *wa, st
int64 battle_calc_sizefix(struct map_session_data *sd, int64 damage, int type, int size, bool ignore){
//SizeFix only for players
+ nullpo_retr(damage, sd);
if (!(sd->special_state.no_sizefix || (ignore)))
damage = damage * ( type == EQI_HAND_L ? sd->left_weapon.atkmods[size] : sd->right_weapon.atkmods[size] ) / 100;
return damage;
@@ -627,8 +639,8 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in
int weapon, skill_lv;
damage = dmg;
- nullpo_ret(sd);
-
+ nullpo_retr(damage, sd);
+ nullpo_retr(damage, target);
if((skill_lv = pc->checkskill(sd,AL_DEMONBANE)) > 0 &&
target->type == BL_MOB && //This bonus doesn't work against players.
(battle->check_undead(st->race,st->def_ele) || st->race==RC_DEMON) )
@@ -2688,9 +2700,12 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
struct map_session_data *sd = NULL;
struct status_change *sc, *tsc;
struct status_change_entry *sce;
- int div_ = d->div_, flag = d->flag;
+ int div_, flag;
nullpo_ret(bl);
+ nullpo_ret(d);
+ div_ = d->div_;
+ flag = d->flag;
// need check src for null pointer?
@@ -3286,6 +3301,7 @@ int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64
if( !damage )
return 0;
+ nullpo_retr(damage, bl);
if( bl->type == BL_MOB ) {
struct mob_data* md = BL_CAST(BL_MOB, bl);
@@ -3306,6 +3322,8 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64
if (!damage) //No reductions to make.
return 0;
+ nullpo_retr(damage, src);
+ nullpo_retr(damage, bl);
if(md && md->guardian_data) {
if(class_ == MOBID_EMPERIUM && flag&BF_SKILL) {
@@ -3373,6 +3391,8 @@ int battle_calc_drain(int64 damage, int rate, int per) {
*------------------------------------------*/
void battle_consume_ammo(TBL_PC*sd, int skill_id, int lv) {
int qty=1;
+
+ nullpo_retv(sd);
if (!battle_config.arrow_decrement)
return;
@@ -3386,8 +3406,12 @@ void battle_consume_ammo(TBL_PC*sd, int skill_id, int lv) {
sd->state.arrow_atk = 0;
}
+
//Skill Range Criteria
int battle_range_type(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv) {
+ nullpo_retr(BF_SHORT, src);
+ nullpo_retr(BF_SHORT, target);
+
if (battle_config.skillrange_by_distance &&
(src->type&battle_config.skillrange_by_distance)
) { //based on distance between src/target [Skotlex]
@@ -3420,8 +3444,10 @@ int battle_adjust_skill_damage(int m, unsigned short skill_id) {
return 0;
}
+
int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) {
int i;
+ nullpo_ret(sd);
if (!sd->skillblown[0].id)
return 0;
//Apply the bonus blow count. [Skotlex]
@@ -5576,6 +5602,7 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl
break;
}
+ nullpo_retr(d, target);
#ifdef HMAP_ZONE_DAMAGE_CAP_TYPE
if( target && skill_id ) {
int i;
@@ -5613,9 +5640,10 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl
}
return d;
}
+
//Performs reflect damage (magic (maya) is performed over skill.c).
void battle_reflect_damage(struct block_list *target, struct block_list *src, struct Damage *wd,uint16 skill_id) {
- int64 damage = wd->damage + wd->damage2, rdamage = 0, trdamage = 0;
+ int64 damage, rdamage = 0, trdamage = 0;
struct map_session_data *sd, *tsd;
struct status_change *sc;
int64 tick = timer->gettick();
@@ -5626,6 +5654,10 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
max_reflect_damage = max(status_get_max_hp(target), status_get_max_hp(target) * status->get_lv(target) / 100);
#endif
+ damage = wd->damage + wd->damage2;
+
+ nullpo_retv(wd);
+
sd = BL_CAST(BL_PC, src);
tsd = BL_CAST(BL_PC, target);
@@ -5806,11 +5838,14 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st
return;
#undef NORMALIZE_RDAMAGE
}
+
void battle_drain(TBL_PC *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss)
{
struct weapon_data *wd;
int type, thp = 0, tsp = 0, rhp = 0, rsp = 0, hp, sp, i;
int64 *damage;
+
+ nullpo_retv(sd);
for (i = 0; i < 4; i++) {
//First two iterations: Right hand
if (i < 2) { wd = &sd->right_weapon; damage = &rdamage; }
@@ -5873,6 +5908,7 @@ int battle_damage_area(struct block_list *bl, va_list ap) {
if( bl->type == BL_MOB && ((TBL_MOB*)bl)->class_ == MOBID_EMPERIUM )
return 0;
if( bl != src && battle->check_target(src,bl,BCT_ENEMY) > 0 ) {
+ nullpo_ret(src);
map->freeblock_lock();
if( src->type == BL_PC )
battle->drain((TBL_PC*)src, bl, damage, damage, status_get_race(bl), is_boss(bl));
@@ -6273,6 +6309,7 @@ bool battle_check_undead(int race,int element)
//Returns the upmost level master starting with the given object
struct block_list* battle_get_master(struct block_list *src) {
struct block_list *prev; //Used for infinite loop check (master of yourself?)
+ nullpo_retr(NULL, src);
do {
prev = src;
switch (src->type) {
@@ -7270,8 +7307,10 @@ static int Hercules_report_timer(int tid, int64 tick, int id, intptr_t data) {
int battle_set_value(const char* w1, const char* w2)
{
int val = config_switch(w2);
-
int i;
+
+ nullpo_retr(1, w1);
+ nullpo_retr(1, w2);
ARR_FIND(0, ARRAYLENGTH(battle_data), i, strcmpi(w1, battle_data[i].str) == 0);
if (i == ARRAYLENGTH(battle_data)) {
if( HPM->parseConf(w1,w2,HPCT_BATTLE) ) /* if plugin-owned, succeed */
@@ -7292,6 +7331,7 @@ int battle_set_value(const char* w1, const char* w2)
int battle_get_value(const char* w1)
{
int i;
+ nullpo_retr(1, w1);
ARR_FIND(0, ARRAYLENGTH(battle_data), i, strcmpi(w1, battle_data[i].str) == 0);
if (i == ARRAYLENGTH(battle_data))
return 0; // not found
@@ -7374,6 +7414,8 @@ int battle_config_read(const char* cfgName)
FILE* fp;
static int count = 0;
+ nullpo_ret(cfgName);
+
if (count == 0)
battle->config_set_defaults();
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 19360cd97..e825025a9 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -236,6 +236,7 @@ bool bg_send_message(struct map_session_data *sd, const char *mes, int len) {
struct battleground_data *bgd;
nullpo_ret(sd);
+ nullpo_ret(mes);
if( sd->bg_id == 0 || (bgd = bg->team_search(sd->bg_id)) == NULL )
return false; // Couldn't send message
clif->bg_message(bgd, sd->bl.id, sd->status.name, mes, len);
@@ -271,6 +272,7 @@ enum bg_queue_types bg_str2teamtype (const char *str) {
char temp[200], *parse;
enum bg_queue_types type = BGQT_INVALID;
+ nullpo_retr(type, str);
safestrncpy(temp, str, 200);
parse = strtok(temp,"|");
@@ -462,6 +464,7 @@ void bg_config_read(void) {
}
struct bg_arena *bg_name2arena (char *name) {
int i;
+ nullpo_retr(NULL, name);
for(i = 0; i < bg->arenas; i++) {
if( strcmpi(bg->arena[i]->name,name) == 0 )
return bg->arena[i];
@@ -484,6 +487,8 @@ int bg_id2pos ( int queue_id, int account_id ) {
return 0;
}
void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bool response) {
+ nullpo_retv(arena);
+ nullpo_retv(sd);
if( arena->begin_timer == INVALID_TIMER || !sd->bg_queue.arena || sd->bg_queue.arena != arena ) {
bg->queue_pc_cleanup(sd);
return;
@@ -511,6 +516,7 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo
}
void bg_queue_player_cleanup(struct map_session_data *sd) {
+ nullpo_retv(sd);
if ( sd->bg_queue.client_has_bg_data ) {
if( sd->bg_queue.arena )
clif->bgqueue_notice_delete(sd,BGQND_CLOSEWINDOW,sd->bg_queue.arena->name);
@@ -528,6 +534,7 @@ void bg_match_over(struct bg_arena *arena, bool canceled) {
struct hQueue *queue = &script->hq[arena->queue_id];
int i;
+ nullpo_retv(arena);
if( !arena->ongoing )
return;
arena->ongoing = false;
@@ -556,6 +563,7 @@ void bg_begin(struct bg_arena *arena) {
struct hQueue *queue = &script->hq[arena->queue_id];
int i, count = 0;
+ nullpo_retv(arena);
for( i = 0; i < queue->size; i++ ) {
struct map_session_data * sd = NULL;
@@ -637,9 +645,11 @@ int bg_afk_timer(int tid, int64 tick, int id, intptr_t data) {
}
void bg_queue_pregame(struct bg_arena *arena) {
- struct hQueue *queue = &script->hq[arena->queue_id];
+ struct hQueue *queue;
int i;
+ nullpo_retv(arena);
+ queue = &script->hq[arena->queue_id];
for( i = 0; i < queue->size; i++ ) {
struct map_session_data * sd = NULL;
@@ -656,7 +666,10 @@ int bg_fillup_timer(int tid, int64 tick, int id, intptr_t data) {
}
void bg_queue_check(struct bg_arena *arena) {
- int count = script->hq[arena->queue_id].items;
+ int count;
+
+ nullpo_retv(arena);
+ count = script->hq[arena->queue_id].items;
if( count == arena->max_players ) {
if( arena->fillup_timer != INVALID_TIMER ) {
timer->delete(arena->fillup_timer,bg->fillup_timer);
@@ -672,6 +685,8 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q
struct hQueue *queue;
int i, count = 0;
+ nullpo_retv(sd);
+ nullpo_retv(arena);
if( arena->begin_timer != INVALID_TIMER || arena->ongoing ) {
clif->bgqueue_ack(sd,BGQA_FAIL_QUEUING_FINISHED,arena->id);
return;
@@ -750,6 +765,8 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
int tick;
unsigned int tsec;
+ nullpo_retr(BGQA_FAIL_TYPE_INVALID, sd);
+ nullpo_retr(BGQA_FAIL_TYPE_INVALID, arena);
if( !(arena->allowed_types & type) )
return BGQA_FAIL_TYPE_INVALID;
@@ -864,6 +881,7 @@ void do_init_battleground(bool minimal) {
int bg_team_db_final(DBKey key, DBData *data, va_list ap) {
struct battleground_data* bgd = DB->data2ptr(data);
int i;
+ nullpo_ret(bgd);
for(i = 0; i < bgd->hdatac; i++ ) {
if( bgd->hdata[i]->flag.free ) {
aFree(bgd->hdata[i]->data);
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index a1b6e9e65..e01b8a1d8 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -14,6 +14,7 @@
#include "map/pc.h" // struct map_session_data
#include "common/cbasetypes.h"
#include "common/db.h" // ARR_FIND
+#include "common/nullpo.h" // nullpo_*
#include "common/showmsg.h" // ShowWarning
#include "common/socket.h" // RBUF*
#include "common/strlib.h" // safestrncpy
@@ -28,6 +29,7 @@ unsigned int buyingstore_getuid(void) {
bool buyingstore_setup(struct map_session_data* sd, unsigned char slots)
{
+ nullpo_retr(false, sd);
if( !battle_config.feature_buying_store || sd->state.vending || sd->state.buyingstore || sd->state.trading || slots == 0 )
{
return false;
@@ -62,11 +64,11 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots)
return true;
}
-
void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count)
{
unsigned int i, weight, listidx;
+ nullpo_retv(sd);
if (!result || count == 0) {
// canceled, or no items
return;
@@ -178,10 +180,10 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
clif->buyingstore_entry(sd);
}
-
void buyingstore_close(struct map_session_data* sd)
{
- if( sd->state.buyingstore )
+ nullpo_retv(sd);
+ if (sd->state.buyingstore)
{
// invalidate data
sd->state.buyingstore = false;
@@ -192,11 +194,11 @@ void buyingstore_close(struct map_session_data* sd)
}
}
-
void buyingstore_open(struct map_session_data* sd, int account_id)
{
struct map_session_data* pl_sd;
+ nullpo_retv(sd);
if( !battle_config.feature_buying_store || pc_istrading(sd) )
{// not allowed to sell
return;
@@ -229,6 +231,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
unsigned int i, weight, listidx, k;
struct map_session_data* pl_sd;
+ nullpo_retv(sd);
if( count == 0 )
{// nothing to do
return;
@@ -402,7 +405,8 @@ bool buyingstore_search(struct map_session_data* sd, unsigned short nameid)
{
unsigned int i;
- if( !sd->state.buyingstore )
+ nullpo_retr(false, sd);
+ if (!sd->state.buyingstore)
{// not buying
return false;
}
@@ -424,6 +428,8 @@ bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_st
unsigned int i, idx;
struct s_buyingstore_item* it;
+ nullpo_retr(true, sd);
+
if( !sd->state.buyingstore )
{// not buying
return true;
diff --git a/src/map/channel.c b/src/map/channel.c
index 6e15d072e..529d3155e 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -255,6 +255,7 @@ void channel_send(struct channel_data *chan, struct map_session_data *sd, const
{
char message[150];
nullpo_retv(chan);
+ nullpo_retv(msg);
if (sd && chan->msg_delay != 0
&& DIFF_TICK(sd->hchsysch_tick + chan->msg_delay*1000, timer->gettick()) > 0
@@ -262,14 +263,14 @@ void channel_send(struct channel_data *chan, struct map_session_data *sd, const
clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1455));
return;
} else if (sd) {
- snprintf(message, 150, "[ #%s ] %s : %s",chan->name,sd->status.name, msg);
+ safesnprintf(message, 150, "[ #%s ] %s : %s", chan->name, sd->status.name, msg);
clif->channel_msg(chan,sd,message);
if (chan->type == HCS_TYPE_IRC)
ircbot->relay(sd->status.name,msg);
if (chan->msg_delay != 0)
sd->hchsysch_tick = timer->gettick();
} else {
- snprintf(message, 150, "[ #%s ] %s",chan->name, msg);
+ safesnprintf(message, 150, "[ #%s ] %s", chan->name, msg);
clif->channel_msg2(chan, message);
if (chan->type == HCS_TYPE_IRC)
ircbot->relay(NULL, msg);
@@ -329,6 +330,7 @@ enum channel_operation_status channel_join(struct channel_data *chan, struct map
nullpo_retr(HCS_STATUS_FAIL, chan);
nullpo_retr(HCS_STATUS_FAIL, sd);
+ nullpo_retr(HCS_STATUS_FAIL, password);
if (idb_exists(chan->users, sd->status.char_id)) {
return HCS_STATUS_ALREADY;
@@ -445,6 +447,7 @@ void channel_leave(struct channel_data *chan, struct map_session_data *sd)
*/
void channel_quit(struct map_session_data *sd)
{
+ nullpo_retv(sd);
while (sd->channel_count > 0) {
// Loop downward to avoid unnecessary array compactions by channel_leave
struct channel_data *chan = sd->channels[sd->channel_count-1];
@@ -461,10 +464,11 @@ void channel_quit(struct map_session_data *sd)
/**
* Joins the local map channel.
*
- * @param sd The target character
+ * @param sd The target character (sd must be non null)
*/
void channel_map_join(struct map_session_data *sd)
{
+ nullpo_retv(sd);
if (sd->state.autotrade || sd->state.standalone)
return;
if (!map->list[sd->bl.m].channel) {
@@ -475,18 +479,20 @@ void channel_map_join(struct map_session_data *sd)
map->list[sd->bl.m].channel->m = sd->bl.m;
}
- channel->join(map->list[sd->bl.m].channel, sd, NULL, false);
+ channel->join(map->list[sd->bl.m].channel, sd, "", false);
}
void channel_irc_join(struct map_session_data *sd)
{
struct channel_data *chan = ircbot->channel;
+
+ nullpo_retv(sd);
if (sd->state.autotrade || sd->state.standalone)
return;
if (channel->config->irc_name[0] == '\0')
return;
if (chan)
- channel->join(chan, sd, NULL, false);
+ channel->join(chan, sd, "", false);
}
/**
@@ -548,12 +554,13 @@ void channel_guild_leave_alliance(const struct guild *g_source, const struct gui
/**
* Makes a character quit all guild-related channels.
*
- * @param sd The character
+ * @param sd The character (must be non null)
*/
void channel_quit_guild(struct map_session_data *sd)
{
unsigned char i;
+ nullpo_retv(sd);
for (i = 0; i < sd->channel_count; i++) {
struct channel_data *chan = sd->channels[i];
diff --git a/src/map/chat.c b/src/map/chat.c
index ed9d9c598..c53d23889 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -32,6 +32,9 @@ struct chat_data* chat_createchat(struct block_list* bl, const char* title, cons
{
struct chat_data* cd;
nullpo_retr(NULL, bl);
+ nullpo_retr(NULL, title);
+ nullpo_retr(NULL, pass);
+ nullpo_retr(NULL, ev);
/* Given the overhead and the numerous instances (npc allocated or otherwise) wouldn't it be beneficial to have it use ERS? [Ind] */
cd = (struct chat_data *) aMalloc(sizeof(struct chat_data));
@@ -75,6 +78,8 @@ struct chat_data* chat_createchat(struct block_list* bl, const char* title, cons
bool chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) {
struct chat_data* cd;
nullpo_ret(sd);
+ nullpo_ret(title);
+ nullpo_ret(pass);
if( sd->chatID )
return false; //Prevent people abusing the chat system by creating multiple chats, as pointed out by End of Exam. [Skotlex]
@@ -118,6 +123,7 @@ bool chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) {
struct chat_data* cd;
nullpo_ret(sd);
+ nullpo_ret(pass);
cd = (struct chat_data*)map->id2bl(chatid);
if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit )
@@ -255,6 +261,7 @@ bool chat_changechatowner(struct map_session_data* sd, const char* nextownername
int i;
nullpo_ret(sd);
+ nullpo_ret(nextownername);
cd = (struct chat_data*)map->id2bl(sd->chatID);
if( cd == NULL || (struct block_list*) sd != cd->owner )
@@ -298,6 +305,8 @@ bool chat_changechatstatus(struct map_session_data* sd, const char* title, const
struct chat_data* cd;
nullpo_ret(sd);
+ nullpo_ret(title);
+ nullpo_ret(pass);
cd = (struct chat_data*)map->id2bl(sd->chatID);
if( cd==NULL || (struct block_list *)sd != cd->owner )
@@ -325,6 +334,7 @@ bool chat_kickchat(struct map_session_data* sd, const char* kickusername) {
int i;
nullpo_ret(sd);
+ nullpo_ret(kickusername);
cd = (struct chat_data *)map->id2bl(sd->chatID);
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 65c042533..2df7e19b8 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -150,6 +150,7 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
struct auth_node *node;
+ nullpo_retr(false, sd);
if ( chrif->search(sd->status.account_id) )
return false; //Already exists?
@@ -176,6 +177,7 @@ bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
bool chrif_auth_logout(TBL_PC* sd, enum sd_state state)
{
+ nullpo_retr(false, sd);
if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex]
//fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player.
if ( sockt->session[sd->fd] )
@@ -187,8 +189,10 @@ bool chrif_auth_logout(TBL_PC* sd, enum sd_state state)
}
bool chrif_auth_finished(TBL_PC* sd) {
- struct auth_node *node= chrif->search(sd->status.account_id);
+ struct auth_node *node;
+ nullpo_retr(false, sd);
+ node = chrif->search(sd->status.account_id);
if ( node && node->sd == sd && node->state == ST_LOGIN ) {
node->sd = NULL;
@@ -197,13 +201,16 @@ bool chrif_auth_finished(TBL_PC* sd) {
return false;
}
+
// sets char-server's user id
void chrif_setuserid(char *id) {
+ nullpo_retv(id);
memcpy(chrif->userid, id, NAME_LENGTH);
}
// sets char-server's password
void chrif_setpasswd(char *pwd) {
+ nullpo_retv(pwd);
memcpy(chrif->passwd, pwd, NAME_LENGTH);
}
@@ -220,6 +227,7 @@ void chrif_checkdefaultlogin(void) {
bool chrif_setip(const char* ip) {
char ip_str[16];
+ nullpo_retr(false, ip);
if (!(chrif->ip = sockt->host2ip(ip))) {
ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip);
return false;
@@ -446,6 +454,7 @@ void chrif_connectack(int fd) {
int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
+ nullpo_ret(node);
switch (node->state) {
case ST_LOGIN:
if ( node->sd ) {//Since there is no way to request the char auth, make it fail.
@@ -542,6 +551,7 @@ bool chrif_scdata_request(int account_id, int char_id)
void chrif_authreq(struct map_session_data *sd, bool hstandalone) {
struct auth_node *node= chrif->search(sd->bl.id);
+ nullpo_retv(sd);
if( node != NULL || !chrif->isconnected() ) {
sockt->eof(sd->fd);
return;
@@ -657,6 +667,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
+ nullpo_retr(1, node);
if(DIFF_TICK(timer->gettick(),node->node_created)>60000) {
const char* states[] = { "Login", "Logout", "Map change" };
switch (node->state) {
@@ -732,6 +743,8 @@ bool chrif_changeemail(int id, const char *actual_email, const char *new_email)
if (battle_config.etc_log)
ShowInfo("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email);
+ nullpo_retr(false, actual_email);
+ nullpo_retr(false, new_email);
chrif_check(false);
WFIFOHEAD(chrif->fd,86);
@@ -760,6 +773,7 @@ bool chrif_changeemail(int id, const char *actual_email, const char *new_email)
*------------------------------------------*/
bool chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second)
{
+ nullpo_retr(false, character_name);
chrif_check(false);
WFIFOHEAD(chrif->fd,44);
@@ -790,6 +804,7 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope
*/
bool chrif_changesex(struct map_session_data *sd, bool change_account)
{
+ nullpo_retr(false, sd);
chrif_check(false);
WFIFOHEAD(chrif->fd,44);
@@ -822,6 +837,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
char output[256];
bool charsrv = ( type == CHAR_ASK_NAME_CHARBAN || type == CHAR_ASK_NAME_CHARUNBAN ) ? true : false;
+ nullpo_retr(false, player_name);
sd = map->id2sd(acc);
if( acc < 0 || sd == NULL ) {
@@ -1025,6 +1041,7 @@ int chrif_disconnectplayer(int fd) {
int chrif_updatefamelist(struct map_session_data* sd) {
char type;
+ nullpo_retr(0, sd);
chrif_check(-1);
switch(sd->class_ & MAPID_UPPERMASK) {
@@ -1115,9 +1132,11 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th
int i, count=0;
int64 tick;
struct status_change_data data;
- struct status_change *sc = &sd->sc;
+ struct status_change *sc;
const struct TimerData *td;
+ nullpo_retr(false, sd);
+ sc = &sd->sc;
chrif_check(false);
tick = timer->gettick();
@@ -1254,11 +1273,12 @@ bool chrif_char_reset_offline(void) {
}
/*=========================================
- * Tell char-server character is online [Wizputer]
+ * Tell char-server character is online [Wizputer]. Look like unused.
*-----------------------------------------*/
bool chrif_char_online(struct map_session_data *sd) {
chrif_check(false);
+ nullpo_retr(false, sd);
WFIFOHEAD(chrif->fd,10);
WFIFOW(chrif->fd,0) = 0x2b19;
WFIFOL(chrif->fd,2) = sd->status.char_id;
@@ -1523,6 +1543,7 @@ bool chrif_removefriend(int char_id, int friend_id)
void chrif_send_report(char* buf, int len) {
#ifndef STATS_OPT_OUT
if( chrif->fd > 0 ) {
+ nullpo_retv(buf);
WFIFOHEAD(chrif->fd,len + 2);
WFIFOW(chrif->fd,0) = 0x3008;
@@ -1543,6 +1564,7 @@ void chrif_save_scdata_single(int account_id, int char_id, short type, struct st
if( !chrif->isconnected() )
return;
+ nullpo_retv(sce);
WFIFOHEAD(chrif->fd, 28);
WFIFOW(chrif->fd, 0) = 0x2740;
@@ -1582,6 +1604,7 @@ void chrif_del_scdata_single(int account_id, int char_id, short type)
int auth_db_final(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
+ nullpo_ret(node);
if (node->sd) {
if( node->sd->regs.vars )
node->sd->regs.vars->destroy(node->sd->regs.vars, script->reg_destroy);
@@ -1706,7 +1729,7 @@ void chrif_defaults(void) {
chrif->char_offline_nsd = chrif_char_offline_nsd;
chrif->char_reset_offline = chrif_char_reset_offline;
chrif->send_users_tochar = send_users_tochar;
- chrif->char_online = chrif_char_online;
+ chrif->char_online = chrif_char_online; // look like unused
chrif->changesex = chrif_changesex;
//chrif->chardisconnect = chrif_chardisconnect;
chrif->divorce = chrif_divorce;
diff --git a/src/map/clif.c b/src/map/clif.c
index 9c172a2ee..f61bc7055 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -180,9 +180,14 @@ static inline bool disguised(struct block_list* bl) {
return (bool)( bl->type == BL_PC && ((TBL_PC*)bl)->disguise != -1 );
}
-
//Guarantees that the given string does not exceeds the allowed size, as well as making sure it's null terminated. [Skotlex]
static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned int max) {
+ nullpo_retr(0, mes);
+ if (len <= 0)
+ {
+ mes[0] = '\0';
+ Assert_retr(0, len > 0);
+ }
if( len > max )
len = max;
@@ -196,6 +201,7 @@ static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned i
*------------------------------------------*/
bool clif_setip(const char* ip) {
char ip_str[16];
+ nullpo_retr(false, ip);
clif->map_ip = sockt->host2ip(ip);
if ( !clif->map_ip ) {
ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
@@ -208,6 +214,7 @@ bool clif_setip(const char* ip) {
}
bool clif_setbindip(const char* ip) {
+ nullpo_retr(false, ip);
clif->bind_ip = sockt->host2ip(ip);
if ( clif->bind_ip ) {
char ip_str[16];
@@ -258,6 +265,7 @@ uint32 clif_refresh_ip(void)
#if PACKETVER >= 20071106
static inline unsigned char clif_bl_type(struct block_list *bl) {
+ nullpo_retr(0x1, bl);
switch (bl->type) {
case BL_PC: return (disguised(bl) && !pc->db_checkid(status->get_viewdata(bl)->class_))? 0x1:0x0; //PC_TYPE
case BL_ITEM: return 0x2; //ITEM_TYPE
@@ -342,6 +350,7 @@ int clif_send_sub(struct block_list *bl, va_list ap) {
int clif_send_actual(int fd, void *buf, int len)
{
+ nullpo_retr(0, buf);
WFIFOHEAD(fd, len);
if (WFIFOP(fd,0) == buf) {
ShowError("WARNING: Invalid use of clif->send function\n");
@@ -391,8 +400,8 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target
case ALL_SAMEMAP: //All players on the same map
iter = mapit_getallusers();
- while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) {
- if( bl->m == tsd->bl.m ) {
+ while ((tsd = (TBL_PC*)mapit->next(iter)) != NULL) {
+ if (bl && bl->m == tsd->bl.m) {
WFIFOHEAD(tsd->fd, len);
memcpy(WFIFOP(tsd->fd,0), buf, len);
WFIFOSET(tsd->fd,len);
@@ -408,16 +417,19 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target
/* Fall through */
case AREA_WOC:
case AREA_WOS:
+ nullpo_retr(true, bl);
map->foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
BL_PC, buf, len, bl, type);
break;
case AREA_CHAT_WOC:
+ nullpo_retr(true, bl);
map->foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5),
bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC);
break;
case CHAT:
case CHAT_WOS:
+ nullpo_retr(true, bl);
{
struct chat_data *cd;
if (sd) {
@@ -441,6 +453,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target
case PARTY_AREA:
case PARTY_AREA_WOS:
+ nullpo_retr(true, bl);
x0 = bl->x - AREA_SIZE;
y0 = bl->y - AREA_SIZE;
x1 = bl->x + AREA_SIZE;
@@ -517,6 +530,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target
// New definitions for guilds [Valaris] - Cleaned up and reorganized by [Skotlex]
case GUILD_AREA:
case GUILD_AREA_WOS:
+ nullpo_retr(true, bl);
x0 = bl->x - AREA_SIZE;
y0 = bl->y - AREA_SIZE;
x1 = bl->x + AREA_SIZE;
@@ -569,6 +583,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target
case BG_AREA:
case BG_AREA_WOS:
+ nullpo_retr(true, bl);
x0 = bl->x - AREA_SIZE;
y0 = bl->y - AREA_SIZE;
x1 = bl->x + AREA_SIZE;
@@ -626,6 +641,7 @@ void clif_authok(struct map_session_data *sd)
{
struct packet_authok p;
+ nullpo_retv(sd);
p.PacketType = authokType;
p.startTime = (unsigned int)timer->gettick();
WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */
@@ -830,7 +846,10 @@ int clif_clearunit_delayed_sub(int tid, int64 tick, int id, intptr_t data) {
}
void clif_clearunit_delayed(struct block_list* bl, clr_type type, int64 tick) {
- struct block_list *tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list);
+ struct block_list *tbl;
+
+ nullpo_retv(bl);
+ tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list);
memcpy (tbl, bl, sizeof (struct block_list));
timer->add(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl);
}
@@ -838,6 +857,9 @@ void clif_clearunit_delayed(struct block_list* bl, clr_type type, int64 tick) {
/// Gets weapon view info from sd's inventory_data and points (*rhand,*lhand)
void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand)
{
+ nullpo_retv(sd);
+ nullpo_retv(rhand);
+ nullpo_retv(lhand);
if(sd->sc.option&OPTION_COSTUME) {
*rhand = *lhand = 0;
return;
@@ -887,6 +909,7 @@ static int clif_setlevel_sub(int lv) {
static int clif_setlevel(struct block_list* bl) {
int lv = status->get_lv(bl);
+ nullpo_retr(0, bl);
if( battle_config.client_limit_unit_lv&bl->type )
return clif_setlevel_sub(lv);
switch( bl->type ) {
@@ -906,6 +929,7 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en
struct packet_idle_unit2 p;
int g_id = status->get_guild_id(bl);
+ nullpo_retv(bl);
sd = BL_CAST(BL_PC, bl);
p.PacketType = idle_unit2Type;
@@ -1046,6 +1070,7 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) {
struct packet_spawn_unit2 p;
int g_id = status->get_guild_id(bl);
+ nullpo_retv(bl);
sd = BL_CAST(BL_PC, bl);
p.PacketType = spawn_unit2Type;
@@ -1180,6 +1205,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
int g_id = status->get_guild_id(bl);
nullpo_retv(bl);
+ nullpo_retv(ud);
sd = BL_CAST(BL_PC, bl);
@@ -1252,7 +1278,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
/// 01b0 <id>.L <type>.B <value>.L
/// type:
/// unused
-void clif_class_change(struct block_list *bl,int class_,int type)
+void clif_class_change(struct block_list *bl, int class_, int type)
{
nullpo_retv(bl);
@@ -1272,6 +1298,7 @@ void clif_class_change(struct block_list *bl,int class_,int type)
/// 01d0 <id>.L <amount>.W (ZC_SPIRITS)
/// 01e1 <id>.L <amount>.W (ZC_SPIRITS2)
void clif_spiritball_single(int fd, struct map_session_data *sd) {
+ nullpo_retv(sd);
WFIFOHEAD(fd, packet_len(0x1e1));
WFIFOW(fd,0)=0x1e1;
WFIFOL(fd,2)=sd->bl.id;
@@ -1284,6 +1311,7 @@ void clif_spiritball_single(int fd, struct map_session_data *sd) {
*------------------------------------------*/
void clif_charm_single(int fd, struct map_session_data *sd)
{
+ nullpo_retv(sd);
WFIFOHEAD(fd, packet_len(0x08cf));
WFIFOW(fd,0) = 0x08cf;
WFIFOL(fd,2) = sd->bl.id;
@@ -1297,9 +1325,12 @@ void clif_charm_single(int fd, struct map_session_data *sd)
* Tells its client to display all weather settings being used by this map
*------------------------------------------*/
void clif_weather_check(struct map_session_data *sd) {
- int16 m = sd->bl.m;
- int fd = sd->fd;
+ int16 m;
+ int fd;
+ nullpo_retv(sd);
+ m = sd->bl.m;
+ fd = sd->fd;
if (map->list[m].flag.snow)
clif->specialeffect_single(&sd->bl, 162, fd);
if (map->list[m].flag.clouds)
@@ -1341,6 +1372,7 @@ bool clif_spawn(struct block_list *bl)
{
struct view_data *vd;
+ nullpo_retr(false, bl);
vd = status->get_viewdata(bl);
if( !vd )
return false;
@@ -1413,6 +1445,7 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
unsigned char buf[128];
enum homun_type htype;
+ nullpo_retv(sd);
nullpo_retv(hd);
hstatus = &hd->battle_status;
@@ -1492,8 +1525,12 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
/// ? = ignored
void clif_send_homdata(struct map_session_data *sd, int state, int param)
{
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ nullpo_retv(sd->hd);
+ fd = sd->fd;
if ( (state == SP_INTIMATE) && (param >= 910) && (sd->hd->homunculus.class_ == sd->hd->homunculusDB->evo_class) )
homun->calc_skilltree(sd->hd, 0);
@@ -1553,6 +1590,7 @@ void clif_homskillup(struct map_session_data *sd, uint16 skill_id) { //[orn]
struct homun_data *hd;
int fd, idx;
nullpo_retv(sd);
+ nullpo_retv(sd->hd);
idx = skill_id - HM_SKILLBASE;
fd=sd->fd;
@@ -1588,8 +1626,10 @@ void clif_hom_food(struct map_session_data *sd,int foodid,int fail)
/// 0087 <walk start time>.L <walk data>.6B
void clif_walkok(struct map_session_data *sd)
{
- int fd=sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x87));
WFIFOW(fd,0)=0x87;
WFIFOL(fd,2)=(unsigned int)timer->gettick();
@@ -1597,14 +1637,20 @@ void clif_walkok(struct map_session_data *sd)
WFIFOSET(fd,packet_len(0x87));
}
-
void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *ud) {
#ifdef ANTI_MAYAP_CHEAT
struct status_change *sc = NULL;
+#endif
+
+ nullpo_retv(bl);
+ nullpo_retv(vd);
+ nullpo_retv(ud);
+#ifdef ANTI_MAYAP_CHEAT
if( (sc = status->get_sc(bl)) && sc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE|OPTION_CHASEWALK) )
clif->ally_only = true;
#endif
+
clif->set_unit_walking(bl,NULL,ud,AREA_WOS);
if(vd->cloth_color)
@@ -1640,7 +1686,6 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u
#endif
}
-
/// Notifies clients in an area, that an other visible object is walking (ZC_NOTIFY_PLAYERMOVE).
/// 0086 <id>.L <walk data>.6B <walk start time>.L
/// Note: unit must not be self
@@ -1648,10 +1693,14 @@ void clif_move(struct unit_data *ud)
{
unsigned char buf[16];
struct view_data *vd;
- struct block_list *bl = ud->bl;
+ struct block_list *bl;
#ifdef ANTI_MAYAP_CHEAT
struct status_change *sc = NULL;
#endif
+
+ nullpo_retv(ud);
+ bl = ud->bl;
+ nullpo_retv(bl);
vd = status->get_viewdata(bl);
if (!vd || vd->class_ == INVISIBLE_CLASS)
return; //This performance check is needed to keep GM-hidden objects from being notified to bots.
@@ -1706,7 +1755,8 @@ int clif_delayquit(int tid, int64 tick, int id, intptr_t data) {
/*==========================================
*
*------------------------------------------*/
-void clif_quitsave(int fd,struct map_session_data *sd) {
+void clif_quitsave(int fd, struct map_session_data *sd) {
+ nullpo_retv(sd);
if (!battle_config.prevent_logout ||
DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout)
map->quit(sd);
@@ -1756,6 +1806,7 @@ void clif_changemapserver(struct map_session_data* sd, unsigned short map_index,
void clif_blown(struct block_list *bl)
{
//Aegis packets says fixpos, but it's unsure whether slide works better or not.
+ nullpo_retv(bl);
clif->fixpos(bl);
clif->slide(bl, bl->x, bl->y);
}
@@ -1889,7 +1940,11 @@ void clif_selllist(struct map_session_data *sd)
/// - append this text
void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) {
int fd = sd->fd;
- size_t slen = strlen(mes) + 9;
+ size_t slen;
+
+ nullpo_retv(sd);
+ nullpo_retv(mes);
+ slen = strlen(mes) + 9;
sd->state.dialog = 1;
@@ -1912,7 +1967,7 @@ void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) {
/// - 00B9 <npcid of dialog window>.L
/// - set to clear on next mes
/// - remove 'next' button
-void clif_scriptnext(struct map_session_data *sd,int npcid)
+void clif_scriptnext(struct map_session_data *sd, int npcid)
{
int fd;
@@ -1959,9 +2014,11 @@ void clif_scriptclose(struct map_session_data *sd, int npcid)
*------------------------------------------*/
void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
unsigned char *buf;
- int fd = sd->fd;
- sd->state.using_fake_npc = 1;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
+ sd->state.using_fake_npc = 1;
WFIFOHEAD(fd, packet_len(0x78));
buf = WFIFOP(fd,0);
memset(WBUFP(buf,0), 0, packet_len(0x78));
@@ -2000,10 +2057,14 @@ void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
/// Which suggests their have intertwined behavior. (probably the mouse targeting)
/// TODO investigate behavior of other windows [FlavioJS]
void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) {
- int fd = sd->fd;
- size_t slen = strlen(mes) + 9;
+ int fd;
+ size_t slen;
struct block_list *bl = NULL;
+ nullpo_retv(sd);
+ nullpo_retv(mes);
+ fd = sd->fd;
+ slen = strlen(mes) + 9;
if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
@@ -2135,6 +2196,7 @@ void clif_cutin(struct map_session_data* sd, const char* image, int type)
*------------------------------------------*/
void clif_addcards(unsigned char* buf, struct item* item) {
int i=0,j;
+ nullpo_retv(buf);
if( item == NULL ) { //Blank data
WBUFW(buf,0) = 0;
WBUFW(buf,2) = 0;
@@ -2184,6 +2246,7 @@ void clif_addcards(unsigned char* buf, struct item* item) {
void clif_addcards2(unsigned short *cards, struct item* item) {
int i=0,j;
+ nullpo_retv(cards);
if( item == NULL ) { //Blank data
cards[0] = 0;
cards[1] = 0;
@@ -2243,6 +2306,7 @@ void clif_addcards2(unsigned short *cards, struct item* item) {
void clif_add_random_options(unsigned char* buf, struct item* item)
{
int i;
+ nullpo_retv(buf);
for (i = 0; i < 5; i++){
WBUFW(buf,i*5+0) = 0; // OptIndex
WBUFW(buf,i*5+2) = 0; // Value
@@ -2356,6 +2420,7 @@ void clif_delitem(struct map_session_data *sd,int n,int amount, short reason)
// Simplifies inventory/cart/storage packets by handling the packet section relevant to items. [Skotlex]
// Equip is >= 0 for equippable items (holds the equip-point, is 0 for pet
// armor/egg) -1 for stackable items, -2 for stackable items where arrows must send in the equip-point.
+// look like unused, not adding checks
void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *id, int equip) {
if (id->view_id > 0)
WBUFW(buf,n)=id->view_id;
@@ -2377,10 +2442,14 @@ void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *
}
}
+
void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct item_data *id, int eqp_pos) {
#if PACKETVER >= 20150226
int j;
#endif
+ nullpo_retv(p);
+ nullpo_retv(i);
+ nullpo_retv(id);
p->index = idx;
if (id->view_id > 0)
@@ -2432,7 +2501,12 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct
}
#endif
}
+
void clif_item_normal(short idx, struct NORMALITEM_INFO *p, struct item *i, struct item_data *id) {
+ nullpo_retv(p);
+ nullpo_retv(i);
+ nullpo_retv(id);
+
p->index = idx;
if (id->view_id > 0)
@@ -2463,17 +2537,19 @@ void clif_item_normal(short idx, struct NORMALITEM_INFO *p, struct item *i, stru
p->Flag.SpareBits = 0;
#endif
}
+
void clif_inventorylist(struct map_session_data *sd) {
int i, normal = 0, equip = 0;
+ nullpo_retv(sd);
for( i = 0; i < MAX_INVENTORY; i++ ) {
if( sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL )
continue;
if( !itemdb->isstackable2(sd->inventory_data[i]) ) //Non-stackable (Equippable)
- clif_item_equip(i+2,&itemlist_equip.list[equip++],&sd->status.inventory[i],sd->inventory_data[i],pc->equippoint(sd,i));
+ clif->item_equip(i+2,&itemlist_equip.list[equip++],&sd->status.inventory[i],sd->inventory_data[i],pc->equippoint(sd,i));
else //Stackable (Normal)
- clif_item_normal(i+2,&itemlist_normal.list[normal++],&sd->status.inventory[i],sd->inventory_data[i]);
+ clif->item_normal(i+2,&itemlist_normal.list[normal++],&sd->status.inventory[i],sd->inventory_data[i]);
}
if( normal ) {
@@ -2508,12 +2584,13 @@ void clif_inventorylist(struct map_session_data *sd) {
void clif_equiplist(struct map_session_data *sd) {
int i, equip = 0;
+ nullpo_retv(sd);
for( i = 0; i < MAX_INVENTORY; i++ ) {
if( sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL )
continue;
if( !itemdb->isstackable2(sd->inventory_data[i]) ) //Non-stackable (Equippable)
- clif_item_equip(i+2,&itemlist_equip.list[equip++],&sd->status.inventory[i],sd->inventory_data[i],pc->equippoint(sd,i));
+ clif->item_equip(i+2,&itemlist_equip.list[equip++],&sd->status.inventory[i],sd->inventory_data[i],pc->equippoint(sd,i));
}
if( equip ) {
@@ -2539,6 +2616,8 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
int i = 0;
struct item_data *id;
+ nullpo_retv(sd);
+ nullpo_retv(items);
do {
int normal = 0, equip = 0, k = 0;
@@ -2550,9 +2629,9 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
id = itemdb->search(items[i].nameid);
if( !itemdb->isstackable2(id) ) //Non-stackable (Equippable)
- clif_item_equip(i+1,&storelist_equip.list[equip++],&items[i],id,id->equip);
+ clif->item_equip(i+1,&storelist_equip.list[equip++],&items[i],id,id->equip);
else //Stackable (Normal)
- clif_item_normal(i+1,&storelist_normal.list[normal++],&items[i],id);
+ clif->item_normal(i+1,&storelist_normal.list[normal++],&items[i],id);
}
if( normal ) {
@@ -2585,17 +2664,17 @@ void clif_cartlist(struct map_session_data *sd) {
int i, normal = 0, equip = 0;
struct item_data *id;
+ nullpo_retv(sd);
for( i = 0; i < MAX_CART; i++ ) {
if( sd->status.cart[i].nameid <= 0 )
continue;
id = itemdb->search(sd->status.cart[i].nameid);
-
if( !itemdb->isstackable2(id) ) //Non-stackable (Equippable)
- clif_item_equip(i+2,&itemlist_equip.list[equip++],&sd->status.cart[i],id,id->equip);
+ clif->item_equip(i+2,&itemlist_equip.list[equip++],&sd->status.cart[i],id,id->equip);
else //Stackable (Normal)
- clif_item_normal(i+2,&itemlist_normal.list[normal++],&sd->status.cart[i],id);
+ clif->item_normal(i+2,&itemlist_normal.list[normal++],&sd->status.cart[i],id);
}
if( normal ) {
@@ -2651,6 +2730,7 @@ void clif_guild_xy_single(int fd, struct map_session_data *sd)
if( sd->bg_id )
return;
+ nullpo_retv(sd);
WFIFOHEAD(fd,packet_len(0x1eb));
WFIFOW(fd,0)=0x1eb;
WFIFOL(fd,2)=sd->status.account_id;
@@ -3437,6 +3517,7 @@ void clif_changeoption2(struct block_list* bl) {
unsigned char buf[20];
struct status_change *sc;
+ nullpo_retv(bl);
if ( !(sc = status->get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc?
WBUFW(buf,0) = 0x28a;
@@ -3741,6 +3822,8 @@ void clif_leavechat(struct chat_data* cd, struct map_session_data* sd, bool flag
void clif_traderequest(struct map_session_data* sd, const char* name) {
int fd = sd->fd;
+ nullpo_retv(sd);
+ nullpo_retv(name);
#if PACKETVER < 6
WFIFOHEAD(fd,packet_len(0xe5));
WFIFOW(fd,0) = 0xe5;
@@ -3771,7 +3854,10 @@ void clif_traderequest(struct map_session_data* sd, const char* name) {
/// 4 = Cancel
/// 5 = Busy
void clif_tradestart(struct map_session_data* sd, uint8 type) {
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
#if PACKETVER >= 6
struct map_session_data* tsd = map->id2sd(sd->trade_partner);
if( tsd ) {
@@ -3931,10 +4017,13 @@ void clif_tradecompleted(struct map_session_data* sd, int fail)
/// 00f1
/// NOTE: Unknown purpose. Items are not removed until the window is
/// refreshed (ex. by putting another item in there).
+/// unused
void clif_tradeundo(struct map_session_data* sd)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0xf1));
WFIFOW(fd,0) = 0xf1;
WFIFOSET(fd,packet_len(0xf1));
@@ -4030,6 +4119,8 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
struct block_list *d_bl;
int i;
+ nullpo_retv(sd);
+ nullpo_retv(dstsd);
if( dstsd->chatID ) {
struct chat_data *cd = NULL;
if( (cd = (struct chat_data*)map->id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd)
@@ -4068,6 +4159,9 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
struct unit_data *ud;
struct view_data *vd;
+ nullpo_retv(sd);
+ nullpo_retv(bl);
+
vd = status->get_viewdata(bl);
if (!vd || vd->class_ == INVISIBLE_CLASS)
return;
@@ -4156,6 +4250,7 @@ int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, i
if (type == 4 || type == 9 || damage <=0)
return 0;
+ nullpo_retr(delay, bl);
if (bl->type == BL_PC) {
if (battle_config.pc_walk_delay_rate != 100)
delay = delay*battle_config.pc_walk_delay_rate/100;
@@ -4335,6 +4430,9 @@ void clif_changemapcell(int fd, int16 m, int x, int y, int type, enum send_targe
/// 009d <id>.L <name id>.W <identified>.B <x>.W <y>.W <amount>.W <subX>.B <subY>.B
void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem) {
int view,fd;
+
+ nullpo_retv(sd);
+ nullpo_retv(fitem);
fd=sd->fd;
WFIFOHEAD(fd,packet_len(0x9d));
@@ -4356,6 +4454,9 @@ void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fi
void clif_graffiti_entry(struct block_list *bl, struct skill_unit *su, enum send_target target) {
struct packet_graffiti_entry p;
+ nullpo_retv(bl);
+ nullpo_retv(su);
+ nullpo_retv(su->group);
p.PacketType = graffiti_entryType;
p.AID = su->bl.id;
p.creatorAID = su->group->src_id;
@@ -4737,7 +4838,12 @@ void clif_skillinfo(struct map_session_data *sd,int skill_id, int inf)
{
const int fd = sd->fd;
int idx = skill->get_index(skill_id);
- int skill_lv = sd->status.skill[idx].lv;
+ int skill_lv;
+
+ nullpo_retv(sd);
+ Assert_retv(idx >= 0 && idx < MAX_SKILL);
+
+ skill_lv = sd->status.skill[idx].lv;
WFIFOHEAD(fd,packet_len(0x7e1));
WFIFOW(fd,0) = 0x7e1;
@@ -5105,6 +5211,7 @@ void clif_skill_poseffect(struct block_list *src, uint16 skill_id, int val, int
void clif_skill_warppoint(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv, unsigned short map1, unsigned short map2, unsigned short map3, unsigned short map4)
{
int fd;
+
nullpo_retv(sd);
fd = sd->fd;
@@ -5404,8 +5511,8 @@ void clif_displaymessage(const int fd, const char* mes) {
#endif
}
}
+
void clif_displaymessage2(const int fd, const char* mes) {
- // invalid pointer?
nullpo_retv(mes);
//Scrapped, as these are shared by disconnected players =X [Skotlex]
@@ -5442,6 +5549,7 @@ void clif_displaymessage_sprintf(const int fd, const char *mes, ...) __attribute
void clif_displaymessage_sprintf(const int fd, const char *mes, ...) {
va_list ap;
+ nullpo_retv(mes);
if (map->cpsd_active && fd == 0) {
ShowInfo("HCP: ");
va_start(ap,mes);
@@ -5474,6 +5582,7 @@ void clif_displaymessage_sprintf(const int fd, const char *mes, ...) {
/// 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)
{
+ nullpo_retv(mes);
int lp = (type&BC_COLOR_MASK) ? 4 : 0;
unsigned char *buf = (unsigned char*)aMalloc((4 + lp + len)*sizeof(unsigned char));
@@ -5520,8 +5629,11 @@ void clif_GlobalMessage(struct block_list* bl, const char* message) {
/// 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)
{
- unsigned char *buf = (unsigned char*)aMalloc((16 + len)*sizeof(unsigned char));
+ unsigned char *buf;
+ nullpo_retv(mes);
+
+ buf = (unsigned char*)aMalloc((16 + len)*sizeof(unsigned char));
WBUFW(buf,0) = 0x1c3;
WBUFW(buf,2) = len + 16;
WBUFL(buf,4) = fontColor;
@@ -5613,6 +5725,8 @@ void clif_map_type(struct map_session_data* sd, enum map_type type) {
// FIXME: missing documentation for the 'type' parameter
void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
{
+ nullpo_retv(sd);
+
if(type == 2) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x19a));
@@ -5695,6 +5809,8 @@ void clif_upgrademessage(int fd, int result, int item_id)
/// 0097 <packet len>.W <nick>.24B <message>.?B
/// 0097 <packet len>.W <nick>.24B <isAdmin>.L <message>.?B (PACKETVER >= 20091104)
void clif_wis_message(int fd, const char* nick, const char* mes, size_t mes_len) {
+ nullpo_retv(nick);
+ nullpo_retv(mes);
#if PACKETVER < 20091104
WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4);
WFIFOW(fd,0) = 0x97;
@@ -5744,6 +5860,7 @@ void clif_wis_end(int fd, int flag) {
/// 0194 <char id>.L <name>.24B
void clif_solved_charname(int fd, int charid, const char* name)
{
+ nullpo_retv(name);
WFIFOHEAD(fd,packet_len(0x194));
WFIFOW(fd,0)=0x194;
WFIFOL(fd,2)=charid;
@@ -5913,7 +6030,10 @@ void clif_item_repaireffect(struct map_session_data *sd,int idx,int flag)
/// 02bb <equip location>.W <account id>.L
void clif_item_damaged(struct map_session_data* sd, unsigned short position)
{
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x2bb));
WFIFOW(fd,0) = 0x2bb;
@@ -6195,6 +6315,7 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven
#endif
nullpo_retv(sd);
+ nullpo_retv(vending_items);
fd = sd->fd;
count = sd->vend_num;
@@ -6284,6 +6405,8 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
unsigned char buf[81];
int i;
+ nullpo_retv(p);
+ nullpo_retv(sd);
if (!sd) { //Pick any party member (this call is used when changing item share rules)
ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd != 0 );
} else {
@@ -6412,6 +6535,7 @@ void clif_party_inviteack(struct map_session_data* sd, const char* nick, int res
{
int fd;
nullpo_retv(sd);
+ nullpo_retv(nick);
fd=sd->fd;
#if PACKETVER < 20070904
@@ -6491,6 +6615,8 @@ void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int
unsigned char buf[64];
nullpo_retv(p);
+ nullpo_retv(sd);
+ nullpo_retv(name);
if(!sd && (flag&0xf0)==0)
{
@@ -6522,6 +6648,7 @@ void clif_party_message(struct party_data* p, int account_id, const char* mes, i
int i;
nullpo_retv(p);
+ nullpo_retv(mes);
for(i=0; i < MAX_PARTY && !p->data[i].sd;i++);
if(i < MAX_PARTY){
@@ -6564,6 +6691,7 @@ void clif_party_xy(struct map_session_data *sd)
*------------------------------------------*/
void clif_party_xy_single(int fd, struct map_session_data *sd)
{
+ nullpo_retv(sd);
WFIFOHEAD(fd,packet_len(0x107));
WFIFOW(fd,0)=0x107;
WFIFOL(fd,2)=sd->status.account_id;
@@ -7580,6 +7708,8 @@ void clif_guild_expulsion(struct map_session_data* sd, const char* name, const c
#endif
nullpo_retv(sd);
+ nullpo_retv(name);
+ nullpo_retv(mes);
WBUFW(buf,0) = cmd;
safestrncpy((char*)WBUFP(buf,2), name, NAME_LENGTH);
@@ -7641,6 +7771,7 @@ void clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
struct map_session_data *sd;
uint8 buf[256];
+ nullpo_retv(mes);
if (len == 0)
return;
@@ -7664,6 +7795,7 @@ void clif_guild_reqalliance(struct map_session_data *sd,int account_id,const cha
int fd;
nullpo_retv(sd);
+ nullpo_retv(name);
fd=sd->fd;
WFIFOHEAD(fd,packet_len(0x171));
@@ -7797,6 +7929,7 @@ void clif_talkiebox(struct block_list* bl, const char* talkie)
{
unsigned char buf[MESSAGE_SIZE+6];
nullpo_retv(bl);
+ nullpo_retv(talkie);
WBUFW(buf,0) = 0x191;
WBUFL(buf,2) = bl->id;
@@ -7903,6 +8036,9 @@ void clif_disp_message(struct block_list* src, const char* mes, size_t len, enum
if (len == 0)
return;
+ nullpo_retv(src);
+ nullpo_retv(mes);
+
if (len > sizeof(buf)-5) {
ShowWarning("clif_disp_message: Truncated message '%s' (len=%"PRIuS", max=%"PRIuS", aid=%d).\n", mes, len, sizeof(buf)-5, src->id);
len = sizeof(buf)-5;
@@ -7936,14 +8072,17 @@ void clif_GM_kickack(struct map_session_data *sd, int result)
void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) {
- int fd = tsd->fd;
+ int fd;
+
+ nullpo_retv(tsd);
+ fd = tsd->fd;
- if( fd > 0 )
+ if (fd > 0)
clif->authfail_fd(fd, 15);
else
map->quit(tsd);
- if( sd )
+ if (sd)
clif->GM_kickack(sd, 1);
}
@@ -8069,6 +8208,7 @@ void clif_soundeffect(struct map_session_data* sd, struct block_list* bl, const
nullpo_retv(sd);
nullpo_retv(bl);
+ nullpo_retv(name);
fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x1d3));
@@ -8085,6 +8225,7 @@ void clif_soundeffectall(struct block_list* bl, const char* name, int type, enum
unsigned char buf[40];
nullpo_retv(bl);
+ nullpo_retv(name);
WBUFW(buf,0) = 0x1d3;
safestrncpy((char*)WBUFP(buf,2), name, NAME_LENGTH);
@@ -8120,6 +8261,7 @@ void clif_specialeffect(struct block_list* bl, int type, enum send_target target
}
void clif_specialeffect_single(struct block_list* bl, int type, int fd) {
+ nullpo_retv(bl);
WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x1f3;
WFIFOL(fd,2) = bl->id;
@@ -8162,7 +8304,10 @@ void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, sen
*/
void clif_messagecolor_self(int fd, uint32 color, const char *msg)
{
- size_t msg_len = strlen(msg) + 1;
+ size_t msg_len;
+
+ nullpo_retv(msg);
+ msg_len = strlen(msg) + 1;
WFIFOHEAD(fd,msg_len + 12);
WFIFOW(fd,0) = 0x2C1;
@@ -8188,6 +8333,7 @@ void clif_messagecolor(struct block_list* bl, uint32 color, const char *msg)
uint8 buf[256];
nullpo_retv(bl);
+ nullpo_retv(msg);
if (msg_len > sizeof(buf)-12) {
ShowWarning("clif_messagecolor: Truncating too long message '%s' (len=%"PRIuS").\n", msg, msg_len);
@@ -8211,6 +8357,7 @@ void clif_messagecolor(struct block_list* bl, uint32 color, const char *msg)
**/
void clif_refresh_storagewindow(struct map_session_data *sd)
{
+ nullpo_retv(sd);
// Notify the client that the storage is open
if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
storage->sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
@@ -8519,7 +8666,11 @@ void clif_slide(struct block_list *bl, int x, int y)
void clif_disp_overhead(struct block_list *bl, const char* mes)
{
unsigned char buf[256]; //This should be more than sufficient, the theoretical max is CHAT_SIZE + 8 (pads and extra inserted crap)
- size_t len_mes = strlen(mes)+1; //Account for \0
+ size_t len_mes;
+
+ nullpo_retv(bl);
+ nullpo_retv(mes);
+ len_mes = strlen(mes)+1; //Account for \0
if (len_mes > sizeof(buf)-8) {
ShowError("clif_disp_overhead: Message too long (length %"PRIuS")\n", len_mes);
@@ -8575,7 +8726,10 @@ void clif_party_xy_remove(struct map_session_data *sd)
/// ? = nothing
void clif_gospel_info(struct map_session_data *sd, int type)
{
- int fd=sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x215));
WFIFOW(fd,0)=0x215;
WFIFOL(fd,2)=type;
@@ -8614,7 +8768,11 @@ void clif_gospel_info(struct map_session_data *sd, int type)
/// 40 = Target HP : <monster_id used as HP>
void clif_starskill(struct map_session_data* sd, const char* mapname, int monster_id, unsigned char star, unsigned char result)
{
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ nullpo_retv(mapname);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x20e));
WFIFOW(fd,0) = 0x20e;
@@ -8633,6 +8791,8 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig
{
char mapname[MAP_NAME_LENGTH_EXT];
+ nullpo_retv(sd);
+ Assert_retv(feel_level < MAX_PC_FEELHATE);
mapindex->getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), mapname);
clif->starskill(sd, mapname, 0, feel_level, type ? 1 : 0);
}
@@ -8725,7 +8885,7 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts
if (tsd->status.inventory[k].nameid <= 0 || tsd->inventory_data[k] == NULL) // Item doesn't exist
continue;
- clif_item_equip(k+2,&viewequip_list.list[equip++],&tsd->status.inventory[k],tsd->inventory_data[k],pc->equippoint(tsd,k));
+ clif->item_equip(k+2,&viewequip_list.list[equip++],&tsd->status.inventory[k],tsd->inventory_data[k],pc->equippoint(tsd,k));
}
}
@@ -8808,7 +8968,10 @@ void clif_msgtable_num(struct map_session_data *sd, unsigned short msg_id, int v
*/
void clif_msgtable_skill(struct map_session_data* sd, uint16 skill_id, int msg_id)
{
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x7e6));
WFIFOW(fd,0) = 0x7e6;
@@ -8827,6 +8990,12 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_,
size_t namelen, messagelen;
int fd = sd->fd;
+ nullpo_retr(false, sd);
+ nullpo_retr(false, name_);
+ nullpo_retr(false, namelen_);
+ nullpo_retr(false, message_);
+ nullpo_retr(false, messagelen_);
+
*name_ = NULL;
*namelen_ = 0;
*message_ = NULL;
@@ -8914,10 +9083,17 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_,
void clif_channel_msg(struct channel_data *chan, struct map_session_data *sd, char *msg)
{
- DBIterator *iter = db_iterator(chan->users);
+ DBIterator *iter;
struct map_session_data *user;
- unsigned short msg_len = strlen(msg) + 1;
- uint32 color = channel->config->colors[chan->color];
+ unsigned short msg_len;
+ uint32 color;
+
+ nullpo_retv(chan);
+ nullpo_retv(sd);
+ nullpo_retv(msg);
+ iter = db_iterator(chan->users);
+ msg_len = strlen(msg) + 1;
+ color = channel->config->colors[chan->color];
WFIFOHEAD(sd->fd,msg_len + 12);
WFIFOW(sd->fd,0) = 0x2C1;
@@ -8941,11 +9117,17 @@ void clif_channel_msg(struct channel_data *chan, struct map_session_data *sd, ch
void clif_channel_msg2(struct channel_data *chan, char *msg)
{
- DBIterator *iter = db_iterator(chan->users);
+ DBIterator *iter;
struct map_session_data *user;
unsigned char buf[210];
- unsigned short msg_len = strlen(msg) + 1;
- uint32 color = channel->config->colors[chan->color];
+ unsigned short msg_len;
+ uint32 color;
+
+ nullpo_retv(chan);
+ nullpo_retv(msg);
+ iter = db_iterator(chan->users);
+ msg_len = strlen(msg) + 1;
+ color = channel->config->colors[chan->color];
WBUFW(buf,0) = 0x2C1;
WBUFW(buf,2) = msg_len + 12;
@@ -9043,9 +9225,10 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
chrif->authreq(sd,false);
}
+void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Notification from the client, that it has finished map loading and is about to display player's character (CZ_NOTIFY_ACTORINIT).
/// 007d
-void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
+void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) {
bool first_time = false;
if(sd->bl.prev != NULL)
@@ -9405,7 +9588,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
/// Server's tick (ZC_NOTIFY_TIME).
/// 007f <time>.L
void clif_notify_time(struct map_session_data* sd, int64 time) {
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x7f));
WFIFOW(fd,0) = 0x7f;
@@ -9414,6 +9600,7 @@ void clif_notify_time(struct map_session_data* sd, int64 time) {
}
+void clif_parse_TickSend(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request for server's tick.
/// 007e <client tick>.L (CZ_REQUEST_TIME)
/// 0360 <client tick>.L (CZ_REQUEST_TIME2)
@@ -9435,6 +9622,7 @@ void clif_hotkeys_send(struct map_session_data *sd) {
#ifdef HOTKEY_SAVING
struct packet_hotkey p;
int i;
+ nullpo_retv(sd);
p.PacketType = hotkeyType;
#if PACKETVER >= 20141022
p.Rotate = sd->status.hotkey_rowshift;
@@ -9448,12 +9636,14 @@ void clif_hotkeys_send(struct map_session_data *sd) {
#endif
}
+void clif_parse_HotkeyRowShift(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_HotkeyRowShift(int fd, struct map_session_data *sd)
{
int cmd = RFIFOW(fd, 0);
sd->status.hotkey_rowshift = RFIFOB(fd, packet_db[cmd].pos[0]);
}
+void clif_parse_Hotkey(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to update a position on the hotkey bar (CZ_SHORTCUT_KEY_CHANGE).
/// 02ba <index>.W <is skill>.B <id>.L <count>.W
void clif_parse_Hotkey(int fd, struct map_session_data *sd) {
@@ -9477,7 +9667,10 @@ void clif_parse_Hotkey(int fd, struct map_session_data *sd) {
/* TODO ZC_PROGRESS_ACTOR <account_id>.L */
void clif_progressbar(struct map_session_data * sd, unsigned int color, unsigned int second)
{
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x2f0));
WFIFOW(fd,0) = 0x2f0;
@@ -9491,7 +9684,10 @@ void clif_progressbar(struct map_session_data * sd, unsigned int color, unsigned
/// 02f2
void clif_progressbar_abort(struct map_session_data * sd)
{
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x2f2));
WFIFOW(fd,0) = 0x2f2;
@@ -9499,6 +9695,7 @@ void clif_progressbar_abort(struct map_session_data * sd)
}
+void clif_parse_progressbar(int fd, struct map_session_data * sd) __attribute__((nonnull (2)));
/// Notification from the client, that the progress bar has reached 100% (CZ_PROGRESS).
/// 02f1
void clif_parse_progressbar(int fd, struct map_session_data * sd)
@@ -9513,6 +9710,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd)
}
+void clif_parse_WalkToXY(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to walk to a certain position on the current map.
/// 0085 <dest>.3B (CZ_REQUEST_MOVE)
/// 035f <dest>.3B (CZ_REQUEST_MOVE2)
@@ -9556,7 +9754,10 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd)
/// ? = ignored
void clif_disconnect_ack(struct map_session_data* sd, short result)
{
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x18b));
WFIFOW(fd,0) = 0x18b;
@@ -9565,6 +9766,7 @@ void clif_disconnect_ack(struct map_session_data* sd, short result)
}
+void clif_parse_QuitGame(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to disconnect from server (CZ_REQ_DISCONNECT).
/// 018a <type>.W
/// type:
@@ -9584,6 +9786,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd)
}
+void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Requesting unit's name.
/// 0094 <id>.L (CZ_REQNAME)
/// 0368 <id>.L (CZ_REQNAME2)
@@ -9631,6 +9834,7 @@ int clif_undisguise_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
+void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Validates and processes global messages
/// 008c <packet len>.W <text>.?B (<name> : <message>) 00 (CZ_REQUEST_CHAT)
/// There are various variants of this packet.
@@ -9773,6 +9977,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
}
+void clif_parse_MapMove(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /mm /mapmove (as @rura GM command) (CZ_MOVETO_MAP).
/// Request to warp to a map on given coordinates.
/// 0140 <map name>.16B <x>.W <y>.W
@@ -9807,6 +10012,7 @@ void clif_changed_dir(struct block_list *bl, enum send_target target)
{
unsigned char buf[64];
+ nullpo_retv(bl);
WBUFW(buf,0) = 0x9c;
WBUFL(buf,2) = bl->id;
WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0;
@@ -9822,6 +10028,7 @@ void clif_changed_dir(struct block_list *bl, enum send_target target)
}
+void clif_parse_ChangeDir(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to change own body and head direction.
/// 009b <head dir>.W <dir>.B (CZ_CHANGE_DIRECTION)
/// 0361 <head dir>.W <dir>.B (CZ_CHANGE_DIRECTION2)
@@ -9838,6 +10045,7 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd)
}
+void clif_parse_Emotion(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to show an emotion (CZ_REQ_EMOTION).
/// 00bf <type>.B
/// type:
@@ -9875,7 +10083,10 @@ void clif_parse_Emotion(int fd, struct map_session_data *sd)
/// Amount of currently online players, reply to /w /who (ZC_USER_COUNT).
/// 00c2 <count>.L
void clif_user_count(struct map_session_data* sd, int count) {
- int fd = sd->fd;
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0xc2));
WFIFOW(fd,0) = 0xc2;
@@ -9884,6 +10095,7 @@ void clif_user_count(struct map_session_data* sd, int count) {
}
+void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /w /who (CZ_REQ_USER_COUNT).
/// Request to display amount of currently connected players.
/// 00c1
@@ -9895,6 +10107,7 @@ void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) {
void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, int64 tick) {
struct block_list *target = NULL;
+ nullpo_retv(sd);
if (pc_isdead(sd)) {
clif->clearunit_area(&sd->bl, CLR_DEAD);
return;
@@ -9990,6 +10203,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
}
}
+void clif_parse_ActionRequest(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request for an action.
/// 0089 <target id>.L <action>.B (CZ_REQUEST_ACT)
/// 0437 <target id>.L <action>.B (CZ_REQUEST_ACT2)
@@ -10011,6 +10225,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd)
}
+void clif_parse_Restart(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Response to the death/system menu (CZ_RESTART).
/// 00b2 <type>.B
/// type:
@@ -10037,6 +10252,7 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) {
}
+void clif_parse_WisMessage(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Validates and processes whispered messages (CZ_WHISPER).
/// 0096 <packet len>.W <nick>.24B <message>.?B
void clif_parse_WisMessage(int fd, struct map_session_data* sd)
@@ -10116,7 +10332,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if (chan) {
int k;
ARR_FIND(0, sd->channel_count, k, sd->channels[k] == chan);
- if (k < sd->channel_count || channel->join(chan, sd, NULL, true) == HCS_STATUS_OK) {
+ if (k < sd->channel_count || channel->join(chan, sd, "", true) == HCS_STATUS_OK) {
channel->send(chan,sd,message);
} else {
clif->message(fd, msg_fd(fd,1402));
@@ -10172,6 +10388,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
}
+void clif_parse_Broadcast(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// /b /nb (CZ_BROADCAST).
/// Request to broadcast a message on whole server.
/// 0099 <packet len>.W <text>.?B 00
@@ -10188,6 +10405,7 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd) {
}
+void clif_parse_TakeItem(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to pick up an item.
/// 009f <id>.L (CZ_ITEM_PICKUP)
/// 0362 <id>.L (CZ_ITEM_PICKUP2)
@@ -10232,6 +10450,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd) {
}
+void clif_parse_DropItem(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to drop an item.
/// 00a2 <index>.W <amount>.W (CZ_ITEM_THROW)
/// 0363 <index>.W <amount>.W (CZ_ITEM_THROW2)
@@ -10265,10 +10484,11 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd)
}
//Because the client does not like being ignored.
- clif->dropitem(sd, item_index,0);
+ clif->dropitem(sd, item_index, 0);
}
+void clif_parse_UseItem(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to use an item.
/// 00a7 <index>.W <account id>.L (CZ_USE_ITEM)
/// 0439 <index>.W <account id>.L (CZ_USE_ITEM2)
@@ -10290,13 +10510,14 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd)
sd->idletime = sockt->last_tick;
n = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-2;
- if(n <0 || n >= MAX_INVENTORY)
+ if (n < 0 || n >= MAX_INVENTORY)
return;
if (!pc->useitem(sd,n))
clif->useitemack(sd,n,0,false); //Send an empty ack packet or the client gets stuck.
}
+void clif_parse_EquipItem(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to equip an item (CZ_REQ_WEAR_EQUIP).
/// 00a9 <index>.W <position>.W
/// 0998 <index>.W <position>.L
@@ -10343,6 +10564,7 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd) {
pc->equipitem(sd,p->index,p->wearLocation);
}
+void clif_parse_UnequipItem(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to take off an equip (CZ_REQ_TAKEOFF_EQUIP).
/// 00ab <index>.W
void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
@@ -10371,6 +10593,7 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
}
+void clif_parse_NpcClicked(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to start a conversation with an NPC (CZ_CONTACTNPC).
/// 0090 <id>.L <type>.B
/// type:
@@ -10411,16 +10634,17 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
}
+void clif_parse_NpcBuySellSelected(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Selection between buy/sell was made (CZ_ACK_SELECT_DEALTYPE).
/// 00c5 <id>.L <type>.B
/// type:
/// 0 = buy
/// 1 = sell
-void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
+void clif_parse_NpcBuySellSelected(int fd, struct map_session_data *sd)
{
if (sd->state.trading)
return;
- npc->buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
+ npc->buysellsel(sd, RFIFOL(fd,2), RFIFOB(fd,6));
}
@@ -10432,8 +10656,10 @@ void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
/// 2 = "You are over your Weight Limit."
/// 3 = "Out of the maximum capacity, you have too many items."
void clif_npc_buy_result(struct map_session_data* sd, unsigned char result) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0xca));
WFIFOW(fd,0) = 0xca;
WFIFOB(fd,2) = result;
@@ -10441,6 +10667,7 @@ void clif_npc_buy_result(struct map_session_data* sd, unsigned char result) {
}
+void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to buy chosen items from npc shop (CZ_PC_PURCHASE_ITEMLIST).
/// 00c8 <packet len>.W { <amount>.W <name id>.W }*
void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd)
@@ -10466,8 +10693,10 @@ void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd)
/// 0 = "The deal has successfully completed."
/// 1 = "The deal has failed."
void clif_npc_sell_result(struct map_session_data* sd, unsigned char result) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0xcb));
WFIFOW(fd,0) = 0xcb;
WFIFOB(fd,2) = result;
@@ -10475,6 +10704,7 @@ void clif_npc_sell_result(struct map_session_data* sd, unsigned char result) {
}
+void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to sell chosen items to npc shop (CZ_PC_SELL_ITEMLIST).
/// 00c9 <packet len>.W { <index>.W <amount>.W }*
void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
@@ -10496,6 +10726,7 @@ void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
}
+void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Chatroom creation request (CZ_CREATE_CHATROOM).
/// 00d5 <packet len>.W <limit>.W <type>.B <passwd>.8B <title>.?B
/// type:
@@ -10536,6 +10767,7 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd)
}
+void clif_parse_ChatAddMember(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Chatroom join request (CZ_REQ_ENTER_ROOM).
/// 00d9 <chat ID>.L <passwd>.8B
void clif_parse_ChatAddMember(int fd, struct map_session_data* sd)
@@ -10547,6 +10779,7 @@ void clif_parse_ChatAddMember(int fd, struct map_session_data* sd)
}
+void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Chatroom properties adjustment request (CZ_CHANGE_CHATROOM).
/// 00de <packet len>.W <limit>.W <type>.B <passwd>.8B <title>.?B
/// type:
@@ -10572,6 +10805,7 @@ void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd)
}
+void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to change the chat room ownership (CZ_REQ_ROLE_CHANGE).
/// 00e0 <role>.L <nick>.24B
/// role:
@@ -10583,6 +10817,7 @@ void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd)
}
+void clif_parse_KickFromChat(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to expel a player from chat room (CZ_REQ_EXPEL_MEMBER).
/// 00e2 <name>.24B
void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
@@ -10591,6 +10826,7 @@ void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
}
+void clif_parse_ChatLeave(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to leave the current chatroom (CZ_EXIT_ROOM).
/// 00e3
void clif_parse_ChatLeave(int fd, struct map_session_data* sd)
@@ -10605,6 +10841,7 @@ void clif_parse_ChatLeave(int fd, struct map_session_data* sd)
void clif_noask_sub(struct map_session_data *src, struct map_session_data *target, int type) {
const char* msg;
char output[256];
+ nullpo_retv(src);
// Your request has been rejected by autoreject option.
msg = msg_sd(src,392);
clif_disp_onlyself(src, msg, strlen(msg));
@@ -10614,6 +10851,7 @@ void clif_noask_sub(struct map_session_data *src, struct map_session_data *targe
}
+void clif_parse_TradeRequest(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to begin a trade (CZ_REQ_EXCHANGE_ITEM).
/// 00e4 <account id>.L
void clif_parse_TradeRequest(int fd,struct map_session_data *sd) {
@@ -10639,6 +10877,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd) {
}
+void clif_parse_TradeAck(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to a trade request (CZ_ACK_EXCHANGE_ITEM).
/// 00e6 <result>.B
/// result:
@@ -10650,6 +10889,7 @@ void clif_parse_TradeAck(int fd,struct map_session_data *sd)
}
+void clif_parse_TradeAddItem(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to add an item to current trade (CZ_ADD_EXCHANGE_ITEM).
/// 00e8 <index>.W <amount>.L
void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
@@ -10664,6 +10904,7 @@ void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
}
+void clif_parse_TradeOk(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to lock items in current trade (CZ_CONCLUDE_EXCHANGE_ITEM).
/// 00eb
void clif_parse_TradeOk(int fd,struct map_session_data *sd)
@@ -10672,6 +10913,7 @@ void clif_parse_TradeOk(int fd,struct map_session_data *sd)
}
+void clif_parse_TradeCancel(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to cancel current trade (CZ_CANCEL_EXCHANGE_ITEM).
/// 00ed
void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
@@ -10680,6 +10922,7 @@ void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
}
+void clif_parse_TradeCommit(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to commit current trade (CZ_EXEC_EXCHANGE_ITEM).
/// 00ef
void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
@@ -10688,6 +10931,7 @@ void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
}
+void clif_parse_StopAttack(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to stop chasing/attacking an unit (CZ_CANCEL_LOCKON).
/// 0118
void clif_parse_StopAttack(int fd,struct map_session_data *sd)
@@ -10696,6 +10940,7 @@ void clif_parse_StopAttack(int fd,struct map_session_data *sd)
}
+void clif_parse_PutItemToCart(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to move an item from inventory to cart (CZ_MOVE_ITEM_FROM_BODY_TO_CART).
/// 0126 <index>.W <amount>.L
void clif_parse_PutItemToCart(int fd,struct map_session_data *sd) {
@@ -10711,6 +10956,7 @@ void clif_parse_PutItemToCart(int fd,struct map_session_data *sd) {
}
+void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to move an item from cart to inventory (CZ_MOVE_ITEM_FROM_CART_TO_BODY).
/// 0127 <index>.W <amount>.L
void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
@@ -10721,6 +10967,7 @@ void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
}
+void clif_parse_RemoveOption(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to remove cart/falcon/peco/dragon (CZ_REQ_CARTOFF).
/// 012a
void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
@@ -10739,13 +10986,13 @@ void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
}
+void clif_parse_ChangeCart(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to change cart's visual look (CZ_REQ_CHANGECART).
/// 01af <num>.W
void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
{// TODO: State tracking?
int type;
- nullpo_retv(sd);
if( pc->checkskill(sd, MC_CHANGECART) < 1 )
return;
@@ -10779,6 +11026,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
}
+void clif_parse_StatusUp(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to increase status (CZ_STATUS_CHANGE).
/// 00bb <status id>.W <amount>.B
/// status id:
@@ -10799,6 +11047,7 @@ void clif_parse_StatusUp(int fd,struct map_session_data *sd) {
}
+void clif_parse_SkillUp(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to increase level of a skill (CZ_UPGRADE_SKILLLEVEL).
/// 0112 <skill id>.W
void clif_parse_SkillUp(int fd,struct map_session_data *sd)
@@ -10809,6 +11058,7 @@ void clif_parse_SkillUp(int fd,struct map_session_data *sd)
void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, int target_id) {
int lv;
+ nullpo_retv(sd);
if( !hd )
return;
if (skill->not_ok_hom(skill_id, hd)){
@@ -10837,6 +11087,7 @@ void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_dat
void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) {
int lv;
+ nullpo_retv(sd);
if( !hd )
return;
if (skill->not_ok_hom(skill_id, hd)){
@@ -10865,6 +11116,7 @@ void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_da
void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, int target_id) {
int lv;
+ nullpo_retv(sd);
if( !md )
return;
if( skill->not_ok_mercenary(skill_id, md) )
@@ -10885,6 +11137,7 @@ void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_ses
void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) {
int lv;
+ nullpo_retv(sd);
if( !md )
return;
if( skill->not_ok_mercenary(skill_id, md) )
@@ -10906,6 +11159,7 @@ void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_se
}
+void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to use a targeted skill.
/// 0113 <skill lv>.W <skill id>.W <target id>.L (CZ_USE_SKILL)
/// 0438 <skill lv>.W <skill id>.W <target id>.L (CZ_USE_SKILL2)
@@ -11023,6 +11277,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski
{
int64 tick = timer->gettick();
+ nullpo_retv(sd);
if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) )
return; //Using a target skill on the ground? WRONG.
@@ -11099,6 +11354,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski
}
+void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to use a ground skill.
/// 0116 <skill lv>.W <skill id>.W <x>.W <y>.W (CZ_USE_SKILL_TOGROUND)
/// 0366 <skill lv>.W <skill id>.W <x>.W <y>.W (CZ_USE_SKILL_TOGROUND2)
@@ -11120,6 +11376,7 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd)
}
+void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to use a ground skill with text.
/// 0190 <skill lv>.W <skill id>.W <x>.W <y>.W <contents>.80B (CZ_USE_SKILL_TOGROUND_WITHTALKBOX)
/// 0367 <skill lv>.W <skill id>.W <x>.W <y>.W <contents>.80B (CZ_USE_SKILL_TOGROUND_WITHTALKBOX2)
@@ -11141,6 +11398,7 @@ void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd)
}
+void clif_parse_UseSkillMap(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Answer to map selection dialog (CZ_SELECT_WARPPOINT).
/// 011b <skill id>.W <map name>.16B
void clif_parse_UseSkillMap(int fd, struct map_session_data* sd)
@@ -11165,6 +11423,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd)
}
+void clif_parse_RequestMemo(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to set a memo on current map (CZ_REMEMBER_WARPPOINT).
/// 011d
void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
@@ -11174,6 +11433,7 @@ void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
}
+void clif_parse_ProduceMix(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to pharmacy item selection dialog (CZ_REQMAKINGITEM).
/// 018e <name id>.W { <material id>.W }*3
void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
@@ -11199,6 +11459,7 @@ void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
}
+void clif_parse_Cooking(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to mixing item selection dialog (CZ_REQ_MAKINGITEM).
/// 025b <mk type>.W <name id>.W
/// mk type:
@@ -11227,6 +11488,7 @@ void clif_parse_Cooking(int fd,struct map_session_data *sd) {
}
+void clif_parse_RepairItem(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to repair weapon item selection dialog (CZ_REQ_ITEMREPAIR).
/// 01fd <index>.W <name id>.W <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W
void clif_parse_RepairItem(int fd, struct map_session_data *sd)
@@ -11244,6 +11506,7 @@ void clif_parse_RepairItem(int fd, struct map_session_data *sd)
}
+void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to refine weapon item selection dialog (CZ_REQ_WEAPONREFINE).
/// 0222 <index>.L
void clif_parse_WeaponRefine(int fd, struct map_session_data *sd)
@@ -11266,6 +11529,7 @@ void clif_parse_WeaponRefine(int fd, struct map_session_data *sd)
}
+void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to script menu dialog (CZ_CHOOSE_MENU).
/// 00b8 <npc id>.L <choice>.B
/// choice:
@@ -11296,6 +11560,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
}
+void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// NPC dialog 'next' click (CZ_REQ_NEXT_SCRIPT).
/// 00b9 <npc id>.L
void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
@@ -11304,6 +11569,7 @@ void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
}
+void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// NPC numeric input dialog value (CZ_INPUT_EDITDLG).
/// 0143 <npc id>.L <value>.L
void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
@@ -11311,11 +11577,15 @@ void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
int npcid = RFIFOL(fd,2);
int amount = (int)RFIFOL(fd,6);
- sd->npc_amount = amount;
+ if (amount >= 0)
+ sd->npc_amount = amount;
+ else
+ sd->npc_amount = 0;
npc->scriptcont(sd, npcid, false);
}
+void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// NPC text input dialog value (CZ_INPUT_EDITDLGSTR).
/// 01d5 <packet len>.W <npc id>.L <string>.?B
void clif_parse_NpcStringInput(int fd, struct map_session_data* sd)
@@ -11332,6 +11602,7 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd)
}
+void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// NPC dialog 'close' click (CZ_CLOSE_DIALOG).
/// 0146 <npc id>.L
void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
@@ -11343,6 +11614,7 @@ void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
}
+void clif_parse_ItemIdentify(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to identify item selection dialog (CZ_REQ_ITEMIDENTIFY).
/// 0178 <index>.W
/// index:
@@ -11364,6 +11636,7 @@ void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
}
+void clif_parse_SelectArrow(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to arrow crafting item selection dialog (CZ_REQ_MAKINGARROW).
/// 01ae <name id>.W
void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
@@ -11396,6 +11669,7 @@ void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
}
+void clif_parse_AutoSpell(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to SA_AUTOSPELL skill selection dialog (CZ_SELECTAUTOSPELL).
/// 01ce <skill id>.L
void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
@@ -11415,6 +11689,7 @@ void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
}
+void clif_parse_UseCard(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to display item carding/composition list (CZ_REQ_ITEMCOMPOSITION_LIST).
/// 017a <card index>.W
void clif_parse_UseCard(int fd,struct map_session_data *sd)
@@ -11423,6 +11698,7 @@ void clif_parse_UseCard(int fd,struct map_session_data *sd)
}
+void clif_parse_InsertCard(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to carding/composing item selection dialog (CZ_REQ_ITEMCOMPOSITION).
/// 017c <card index>.W <equip index>.W
void clif_parse_InsertCard(int fd,struct map_session_data *sd)
@@ -11431,6 +11707,7 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd)
}
+void clif_parse_SolveCharName(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request of character's name by char ID.
/// 0193 <char id>.L (CZ_REQNAME_BYGID)
/// 0369 <char id>.L (CZ_REQNAME_BYGID2)
@@ -11443,6 +11720,7 @@ void clif_parse_SolveCharName(int fd, struct map_session_data *sd) {
}
+void clif_parse_ResetChar(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /resetskill /resetstate (CZ_RESET).
/// Request to reset stats or skills.
/// 0197 <type>.W
@@ -11461,6 +11739,7 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
}
+void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// /lb /nlb (CZ_LOCALBROADCAST).
/// Request to broadcast a message on current map.
/// 019c <packet len>.W <text>.?B
@@ -11478,6 +11757,7 @@ void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd)
}
+void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to move an item from inventory to storage.
/// 00f3 <index>.W <amount>.L (CZ_MOVE_ITEM_FROM_BODY_TO_STORE)
/// 0364 <index>.W <amount>.L (CZ_MOVE_ITEM_FROM_BODY_TO_STORE2)
@@ -11501,6 +11781,7 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
}
+void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to move an item from storage to inventory.
/// 00f5 <index>.W <amount>.L (CZ_MOVE_ITEM_FROM_STORE_TO_BODY)
/// 0365 <index>.W <amount>.L (CZ_MOVE_ITEM_FROM_STORE_TO_BODY2)
@@ -11519,6 +11800,7 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd)
}
+void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to move an item from cart to storage (CZ_MOVE_ITEM_FROM_CART_TO_STORE).
/// 0129 <index>.W <amount>.L
void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd)
@@ -11535,6 +11817,7 @@ void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd)
}
+void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to move an item from storage to cart (CZ_MOVE_ITEM_FROM_STORE_TO_CART).
/// 0128 <index>.W <amount>.L
void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
@@ -11551,6 +11834,7 @@ void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
}
+void clif_parse_CloseKafra(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to close storage (CZ_CLOSE_STORE).
/// 00f7
void clif_parse_CloseKafra(int fd, struct map_session_data *sd)
@@ -11572,8 +11856,10 @@ void clif_parse_CloseKafra(int fd, struct map_session_data *sd)
/// NOTE: This packet is only available on certain non-kRO clients.
void clif_storagepassword(struct map_session_data* sd, short info)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x23a));
WFIFOW(fd,0) = 0x23a;
WFIFOW(fd,2) = info;
@@ -11581,6 +11867,7 @@ void clif_storagepassword(struct map_session_data* sd, short info)
}
+void clif_parse_StoragePassword(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to the kafra storage password dialog (CZ_ACK_STORE_PASSWORD).
/// 023b <type>.W <password>.16B <new password>.16B
/// type:
@@ -11605,8 +11892,10 @@ void clif_parse_StoragePassword(int fd, struct map_session_data *sd)
/// NOTE: This packet is only available on certain non-kRO clients.
void clif_storagepassword_result(struct map_session_data* sd, short result, short error_count)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x23c));
WFIFOW(fd,0) = 0x23c;
WFIFOW(fd,2) = result;
@@ -11615,6 +11904,7 @@ void clif_storagepassword_result(struct map_session_data* sd, short result, shor
}
+void clif_parse_CreateParty(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Party creation request
/// 00f9 <party name>.24B (CZ_MAKE_GROUP)
/// 01e8 <party name>.24B <item pickup rule>.B <item share rule>.B (CZ_MAKE_GROUP2)
@@ -11635,6 +11925,7 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) {
party->create(sd,name,0,0);
}
+void clif_parse_CreateParty2(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_CreateParty2(int fd, struct map_session_data *sd) {
char* name = (char*)RFIFOP(fd,2);
int item1 = RFIFOB(fd,26);
@@ -11655,6 +11946,7 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) {
}
+void clif_parse_PartyInvite(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Party invitation request
/// 00fc <account id>.L (CZ_REQ_JOIN_GROUP)
/// 02c4 <char name>.24B (CZ_PARTY_JOIN_REQ)
@@ -11677,6 +11969,7 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) {
party->invite(sd, t_sd);
}
+void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) {
struct map_session_data *t_sd;
char *name = (char*)RFIFOP(fd,2);
@@ -11699,6 +11992,7 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) {
}
+void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Party invitation reply
/// 00ff <party id>.L <flag>.L (CZ_JOIN_GROUP)
/// 02c7 <party id>.L <flag>.B (CZ_PARTY_JOIN_REQ_ACK)
@@ -11710,12 +12004,14 @@ void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd)
party->reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
}
+void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd)
{
party->reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
}
+void clif_parse_LeaveParty(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to leave party (CZ_REQ_LEAVE_GROUP).
/// 0100
void clif_parse_LeaveParty(int fd, struct map_session_data *sd) {
@@ -11728,6 +12024,7 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd) {
}
+void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to expel a party member (CZ_REQ_EXPEL_GROUP_MEMBER).
/// 0103 <account id>.L <char name>.24B
void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) {
@@ -11740,6 +12037,7 @@ void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) {
}
+void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to change party options.
/// 0102 <exp share rule>.L (CZ_CHANGE_GROUPEXPOPTION)
/// 07d7 <exp share rule>.L <item pickup rule>.B <item share rule>.B (CZ_GROUPINFO_CHANGE_V2)
@@ -11771,6 +12069,7 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd)
}
+void clif_parse_PartyMessage(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Validates and processes party messages (CZ_REQUEST_CHAT_PARTY).
/// 0108 <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
@@ -11804,12 +12103,14 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
}
+void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Changes Party Leader (CZ_CHANGE_GROUP_MASTER).
/// 07da <account id>.L
void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) {
party->changeleader(sd, map->id2sd(RFIFOL(fd,2)));
}
-
+
+void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Party Booking in KRO [Spiria]
///
@@ -11842,8 +12143,10 @@ void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd)
void clif_PartyBookingRegisterAck(struct map_session_data *sd, int flag)
{
#ifndef PARTY_RECRUIT
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x803));
WFIFOW(fd,0) = 0x803;
WFIFOW(fd,2) = flag;
@@ -11854,6 +12157,7 @@ void clif_PartyBookingRegisterAck(struct map_session_data *sd, int flag)
}
+void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to search for party booking advertisement (CZ_PARTY_BOOKING_REQ_SEARCH).
/// 0804 <level>.W <map id>.W <job>.W <last index>.L <result count>.W
void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd)
@@ -11883,6 +12187,7 @@ void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results,
int i, j;
int size = sizeof(struct party_booking_ad_info); // structure size (48)
struct party_booking_ad_info *pb_ad;
+ nullpo_retv(results);
WFIFOHEAD(fd,size*count + 5);
WFIFOW(fd,0) = 0x805;
WFIFOW(fd,2) = size*count + 5;
@@ -11905,6 +12210,7 @@ void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results,
}
+void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to delete own party booking advertisement (CZ_PARTY_BOOKING_REQ_DELETE).
/// 0806
void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd)
@@ -11928,8 +12234,10 @@ void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd)
void clif_PartyBookingDeleteAck(struct map_session_data* sd, int flag)
{
#ifndef PARTY_RECRUIT
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x807));
WFIFOW(fd,0) = 0x807;
WFIFOW(fd,2) = flag;
@@ -11940,6 +12248,7 @@ void clif_PartyBookingDeleteAck(struct map_session_data* sd, int flag)
}
+void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to update party booking advertisement (CZ_PARTY_BOOKING_REQ_UPDATE).
/// 0808 { <job>.W }*6
void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data* sd)
@@ -11966,6 +12275,7 @@ void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_boo
int i;
uint8 buf[38+PARTY_BOOKING_JOBS*2];
+ nullpo_retv(sd);
if(pb_ad == NULL) return;
WBUFW(buf,0) = 0x809;
@@ -11992,6 +12302,7 @@ void clif_PartyBookingUpdateNotify(struct map_session_data* sd, struct party_boo
int i;
uint8 buf[6+PARTY_BOOKING_JOBS*2];
+ nullpo_retv(sd);
if(pb_ad == NULL) return;
WBUFW(buf,0) = 0x80a;
@@ -12012,6 +12323,7 @@ void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index)
#ifndef PARTY_RECRUIT
uint8 buf[6];
+ nullpo_retv(sd);
WBUFW(buf,0) = 0x80b;
WBUFL(buf,2) = index;
@@ -12021,6 +12333,7 @@ void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index)
#endif
}
+void clif_parse_PartyRecruitRegisterReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Modified version of Party Booking System for 2012-04-10 or 2012-04-18 (RagexeRE).
/// Code written by mkbu95, Spiria, Yommy and Ind
@@ -12050,6 +12363,7 @@ void clif_PartyRecruitSearchAck(int fd, struct party_booking_ad_info** results,
int size = sizeof(struct party_booking_ad_info);
struct party_booking_ad_info *pb_ad;
+ nullpo_retv(results);
WFIFOHEAD(fd, (size * count) + 5);
WFIFOW(fd, 0) = 0x8e8;
WFIFOW(fd, 2) = (size * count) + 5;
@@ -12080,8 +12394,10 @@ void clif_PartyRecruitSearchAck(int fd, struct party_booking_ad_info** results,
void clif_PartyRecruitRegisterAck(struct map_session_data *sd, int flag)
{
#ifdef PARTY_RECRUIT
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x8e6));
WFIFOW(fd, 0) = 0x8e6;
WFIFOW(fd, 2) = flag;
@@ -12091,6 +12407,7 @@ void clif_PartyRecruitRegisterAck(struct map_session_data *sd, int flag)
#endif
}
+void clif_parse_PartyRecruitSearchReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to search for party booking advertisement (CZ_PARTY_RECRUIT_REQ_SEARCH).
/// 08e7 <level>.W <map id>.W <last index>.L <result count>.W
void clif_parse_PartyRecruitSearchReq(int fd, struct map_session_data* sd)
@@ -12107,6 +12424,7 @@ void clif_parse_PartyRecruitSearchReq(int fd, struct map_session_data* sd)
#endif
}
+void clif_parse_PartyRecruitDeleteReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to delete own party booking advertisement (CZ_PARTY_RECRUIT_REQ_DELETE).
/// 08e9
void clif_parse_PartyRecruitDeleteReq(int fd, struct map_session_data* sd)
@@ -12129,8 +12447,10 @@ void clif_parse_PartyRecruitDeleteReq(int fd, struct map_session_data* sd)
void clif_PartyRecruitDeleteAck(struct map_session_data* sd, int flag)
{
#ifdef PARTY_RECRUIT
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x8ea));
WFIFOW(fd, 0) = 0x8ea;
WFIFOW(fd, 2) = flag;
@@ -12140,6 +12460,7 @@ void clif_PartyRecruitDeleteAck(struct map_session_data* sd, int flag)
#endif
}
+void clif_parse_PartyRecruitUpdateReq(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to update party booking advertisement (CZ_PARTY_RECRUIT_REQ_UPDATE).
/// 08eb <notice>.37B
void clif_parse_PartyRecruitUpdateReq(int fd, struct map_session_data *sd)
@@ -12162,6 +12483,7 @@ void clif_PartyRecruitInsertNotify(struct map_session_data* sd, struct party_boo
#ifdef PARTY_RECRUIT
unsigned char buf[2+6+6+24+4+37+1];
+ nullpo_retv(sd);
if (pb_ad == NULL)
return;
@@ -12184,6 +12506,8 @@ void clif_PartyRecruitUpdateNotify(struct map_session_data *sd, struct party_boo
#ifdef PARTY_RECRUIT
unsigned char buf[2+6+37+1];
+ nullpo_retv(sd);
+ nullpo_retv(pb_ad);
WBUFW(buf, 0) = 0x8ed;
WBUFL(buf, 2) = pb_ad->index;
memcpy(WBUFP(buf, 6), pb_ad->p_detail.notice, PB_NOTICE_LENGTH);
@@ -12201,6 +12525,7 @@ void clif_PartyRecruitDeleteNotify(struct map_session_data* sd, int index)
#ifdef PARTY_RECRUIT
unsigned char buf[2+6+1];
+ nullpo_retv(sd);
WBUFW(buf, 0) = 0x8ee;
WBUFL(buf, 2) = index;
@@ -12210,6 +12535,7 @@ void clif_PartyRecruitDeleteNotify(struct map_session_data* sd, int index)
#endif
}
+void clif_parse_PartyBookingAddFilteringList(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to add to filtering list (PARTY_RECRUIT_ADD_FILTERLINGLIST).
/// 08ef <index>.L
void clif_parse_PartyBookingAddFilteringList(int fd, struct map_session_data *sd)
@@ -12223,6 +12549,7 @@ void clif_parse_PartyBookingAddFilteringList(int fd, struct map_session_data *sd
#endif
}
+void clif_parse_PartyBookingSubFilteringList(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to remove from filtering list (PARTY_RECRUIT_SUB_FILTERLINGLIST).
/// 08f0 <GID>.L
void clif_parse_PartyBookingSubFilteringList(int fd, struct map_session_data *sd)
@@ -12236,6 +12563,7 @@ void clif_parse_PartyBookingSubFilteringList(int fd, struct map_session_data *sd
#endif
}
+void clif_parse_PartyBookingReqVolunteer(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to recruit volunteer (PARTY_RECRUIT_REQ_VOLUNTEER).
/// 08f1 <index>.L
void clif_parse_PartyBookingReqVolunteer(int fd, struct map_session_data *sd)
@@ -12256,6 +12584,7 @@ void clif_PartyBookingVolunteerInfo(int index, struct map_session_data *sd)
#ifdef PARTY_RECRUIT
unsigned char buf[2+4+4+2+24+1];
+ nullpo_retv(sd);
WBUFW(buf, 0) = 0x8f2;
WBUFL(buf, 2) = sd->status.account_id;
WBUFL(buf, 6) = sd->status.class_;
@@ -12274,21 +12603,25 @@ void clif_PartyBookingPersonalSetting(int fd, struct map_session_data *sd)
{
}
+void clif_parse_PartyBookingShowEquipment(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// 08f4 <target GID>.L
void clif_parse_PartyBookingShowEquipment(int fd, struct map_session_data *sd)
{
}
+void clif_parse_PartyBookingReqRecall(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// 08f5 <packet len>.W
void clif_parse_PartyBookingReqRecall(int fd, struct map_session_data *sd)
{
}
+void clif_PartyBookingRecallCost(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// 08f6 <money>.L <map name>.16B
void clif_PartyBookingRecallCost(int fd, struct map_session_data *sd)
{
}
+void clif_parse_PartyBookingAckRecall(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// 08f7 <result>.B
void clif_parse_PartyBookingAckRecall(int fd, struct map_session_data *sd)
{
@@ -12301,11 +12634,13 @@ void clif_parse_PartyBookingAckRecall(int fd, struct map_session_data *sd)
/// REASON_REFUSE = 0x2
/// REASON_NOT_PARTY_MEMBER = 0x3
/// REASON_ETC = 0x4
+void clif_PartyBookingFailedRecall(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_PartyBookingFailedRecall(int fd, struct map_session_data *sd)
{
}
#endif //if 0
+void clif_parse_PartyBookingRefuseVolunteer(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// 08f9 <refuse AID>.L
void clif_parse_PartyBookingRefuseVolunteer(int fd, struct map_session_data *sd)
{
@@ -12318,6 +12653,7 @@ void clif_parse_PartyBookingRefuseVolunteer(int fd, struct map_session_data *sd)
#endif
}
+void clif_PartyBookingRefuseVolunteer(unsigned int aid, struct map_session_data *sd) __attribute__((nonnull (2)));
/// 08fa <index>.L
void clif_PartyBookingRefuseVolunteer(unsigned int aid, struct map_session_data *sd)
{
@@ -12333,6 +12669,7 @@ void clif_PartyBookingRefuseVolunteer(unsigned int aid, struct map_session_data
#endif
}
+void clif_parse_PartyBookingCancelVolunteer(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// 08fb <index>.L
void clif_parse_PartyBookingCancelVolunteer(int fd, struct map_session_data *sd)
{
@@ -12351,6 +12688,7 @@ void clif_PartyBookingCancelVolunteer(int index, struct map_session_data *sd)
#ifdef PARTY_RECRUIT
unsigned char buf[2+6+1];
+ nullpo_retv(sd);
WBUFW(buf, 0) = 0x909;
WBUFL(buf, 2) = index;
@@ -12366,6 +12704,7 @@ void clif_PartyBookingAddFilteringList(int index, struct map_session_data *sd)
#ifdef PARTY_RECRUIT
unsigned char buf[2+6+24+1];
+ nullpo_retv(sd);
WBUFW(buf, 0) = 0x90b;
WBUFL(buf, 2) = sd->bl.id;
memcpy(WBUFP(buf, 6), sd->status.name, NAME_LENGTH);
@@ -12382,6 +12721,7 @@ void clif_PartyBookingSubFilteringList(int gid, struct map_session_data *sd)
#ifdef PARTY_RECRUIT
unsigned char buf[2+6+24+1];
+ nullpo_retv(sd);
WBUFW(buf, 0) = 0x90c;
WBUFL(buf, 2) = gid;
memcpy(WBUFP(buf, 6), sd->status.name, NAME_LENGTH);
@@ -12404,6 +12744,7 @@ void clif_PartyBookingRefuseVolunteerToPM(struct map_session_data *sd)
}
#endif //if 0
+void clif_parse_CloseVending(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to close own vending (CZ_REQ_CLOSESTORE).
/// 012e
void clif_parse_CloseVending(int fd, struct map_session_data* sd)
@@ -12412,6 +12753,7 @@ void clif_parse_CloseVending(int fd, struct map_session_data* sd)
}
+void clif_parse_VendingListReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to open a vending shop (CZ_REQ_BUY_FROMMC).
/// 0130 <account id>.L
void clif_parse_VendingListReq(int fd, struct map_session_data* sd)
@@ -12423,6 +12765,7 @@ void clif_parse_VendingListReq(int fd, struct map_session_data* sd)
}
+void clif_parse_PurchaseReq(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Shop item(s) purchase request (CZ_PC_PURCHASE_ITEMLIST_FROMMC).
/// 0134 <packet len>.W <account id>.L { <amount>.W <index>.W }*
void clif_parse_PurchaseReq(int fd, struct map_session_data* sd)
@@ -12438,6 +12781,7 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data* sd)
}
+void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Shop item(s) purchase request (CZ_PC_PURCHASE_ITEMLIST_FROMMC2).
/// 0801 <packet len>.W <account id>.L <unique id>.L { <amount>.W <index>.W }*
void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd)
@@ -12454,6 +12798,7 @@ void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd)
}
+void clif_parse_OpenVending(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Confirm or cancel the shop preparation window.
/// 012f <packet len>.W <shop name>.80B { <index>.W <amount>.W <price>.L }* (CZ_REQ_OPENSTORE)
/// 01b2 <packet len>.W <shop name>.80B <result>.B { <index>.W <amount>.W <price>.L }* (CZ_REQ_OPENSTORE2)
@@ -12486,6 +12831,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) {
vending->open(sd, message, data, len/8);
}
+void clif_parse_CreateGuild(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Guild creation request (CZ_REQ_MAKE_GUILD).
/// 0165 <char id>.L <guild name>.24B
void clif_parse_CreateGuild(int fd,struct map_session_data *sd) {
@@ -12502,6 +12848,7 @@ void clif_parse_CreateGuild(int fd,struct map_session_data *sd) {
}
+void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request for guild window interface permissions (CZ_REQ_GUILD_MENUINTERFACE).
/// 014d
void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd)
@@ -12510,6 +12857,7 @@ void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd)
}
+void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request for guild window information (CZ_REQ_GUILD_MENU).
/// 014f <type>.L
/// type:
@@ -12551,6 +12899,7 @@ void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd)
}
+void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to update guild positions (CZ_REG_CHANGE_GUILD_POSITIONINFO).
/// 0161 <packet len>.W { <position id>.L <mode>.L <ranking>.L <pay rate>.L <name>.24B }*
void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd)
@@ -12566,6 +12915,7 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd)
}
+void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to update the position of guild members (CZ_REQ_CHANGE_MEMBERPOS).
/// 0155 <packet len>.W { <account id>.L <char id>.L <position id>.L }*
void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd)
@@ -12582,6 +12932,7 @@ void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd)
}
+void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request for guild emblem data (CZ_REQ_GUILD_EMBLEM_IMG).
/// 0151 <guild id>.L
void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd)
@@ -12619,6 +12970,7 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) {
unsigned long buf_len = sizeof(buf);
int header = 0, bitmap = 0, offbits = 0, palettesize = 0;
+ nullpo_retr(false, emblem);
if( decode_zip(buf, &buf_len, emblem, emblem_len) != 0 || buf_len < BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE
|| RBUFW(buf,0) != 0x4d42 // BITMAPFILEHEADER.bfType (signature)
|| RBUFL(buf,2) != buf_len // BITMAPFILEHEADER.bfSize (file size)
@@ -12717,6 +13069,7 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) {
}
+void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to update the guild emblem (CZ_REGISTER_GUILD_EMBLEM_IMG).
/// 0153 <packet len>.W <emblem data>.?B
void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
@@ -12737,6 +13090,7 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
}
+void clif_parse_GuildChangeNotice(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Guild notice update request (CZ_GUILD_NOTICE).
/// 016e <guild id>.L <msg1>.60B <msg2>.120B
void clif_parse_GuildChangeNotice(int fd, struct map_session_data* sd)
@@ -12761,6 +13115,8 @@ bool clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_sessi
if ( t_sd == NULL )// not online or does not exist
return false;
+ nullpo_retr(false, sd);
+ nullpo_retr(false, t_sd);
if ( map->list[sd->bl.m].flag.guildlock ) {
//Guild locked.
clif->message(fd, msg_fd(fd,228));
@@ -12776,6 +13132,7 @@ bool clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_sessi
return true;
}
+void clif_parse_GuildInvite(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Guild invite request (CZ_REQ_JOIN_GUILD).
/// 0168 <account id>.L <inviter account id>.L <inviter char id>.L
void clif_parse_GuildInvite(int fd,struct map_session_data *sd) {
@@ -12785,15 +13142,20 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd) {
return;
}
+void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Guild invite request (/guildinvite) (CZ_REQ_JOIN_GUILD2).
/// 0916 <char name>.24B
void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) {
- struct map_session_data *t_sd = map->nick2sd((char *)RFIFOP(fd, 2));
+ char *nick = (char*)RFIFOP(fd, 2);
+
+ nick[NAME_LENGTH - 1] = '\0';
+ struct map_session_data *t_sd = map->nick2sd(nick);
if (!clif_sub_guild_invite(fd, sd, t_sd))
return;
}
+void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to guild invitation (CZ_JOIN_GUILD).
/// 016b <guild id>.L <answer>.L
/// answer:
@@ -12805,6 +13167,7 @@ void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd)
}
+void clif_parse_GuildLeave(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to leave guild (CZ_REQ_LEAVE_GUILD).
/// 0159 <guild id>.L <account id>.L <char id>.L <reason>.40B
void clif_parse_GuildLeave(int fd,struct map_session_data *sd) {
@@ -12822,6 +13185,7 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd) {
}
+void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to expel a member of a guild (CZ_REQ_BAN_GUILD).
/// 015b <guild id>.L <account id>.L <char id>.L <reason>.40B
void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) {
@@ -12834,6 +13198,7 @@ void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) {
}
+void clif_parse_GuildMessage(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Validates and processes guild messages (CZ_GUILD_CHAT).
/// 017e <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
@@ -12870,6 +13235,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
}
+void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Guild alliance request (CZ_REQ_ALLY_GUILD).
/// 0170 <account id>.L <inviter account id>.L <inviter char id>.L
void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) {
@@ -12896,6 +13262,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) {
}
+void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to a guild alliance request (CZ_ALLY_GUILD).
/// 0172 <inviter account id>.L <answer>.L
/// answer:
@@ -12907,6 +13274,7 @@ void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd)
}
+void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to delete a guild alliance or opposition (CZ_REQ_DELETE_RELATED_GUILD).
/// 0183 <opponent guild id>.L <relation>.L
/// relation:
@@ -12925,6 +13293,7 @@ void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) {
}
+void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to set a guild as opposition (CZ_REQ_HOSTILE_GUILD).
/// 0180 <account id>.L
void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) {
@@ -12951,6 +13320,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) {
}
+void clif_parse_GuildBreak(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to delete own guild (CZ_REQ_DISORGANIZE_GUILD).
/// 015d <key>.40B
/// key:
@@ -12969,6 +13339,7 @@ void clif_parse_GuildBreak(int fd, struct map_session_data *sd) {
/// Pet
///
+void clif_parse_PetMenu(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to invoke a pet menu action (CZ_COMMAND_PET).
/// 01a1 <type>.B
/// type:
@@ -12983,6 +13354,7 @@ void clif_parse_PetMenu(int fd, struct map_session_data *sd)
}
+void clif_parse_CatchPet(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Attempt to tame a monster (CZ_TRYCAPTURE_MONSTER).
/// 019f <id>.L
void clif_parse_CatchPet(int fd, struct map_session_data *sd)
@@ -12991,6 +13363,7 @@ void clif_parse_CatchPet(int fd, struct map_session_data *sd)
}
+void clif_parse_SelectEgg(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to pet incubator egg selection dialog (CZ_SELECT_PETEGG).
/// 01a7 <index>.W
void clif_parse_SelectEgg(int fd, struct map_session_data *sd)
@@ -13003,6 +13376,7 @@ void clif_parse_SelectEgg(int fd, struct map_session_data *sd)
}
+void clif_parse_SendEmotion(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to display pet's emotion/talk (CZ_PET_ACT).
/// 01a9 <data>.L
/// data:
@@ -13034,6 +13408,7 @@ void clif_parse_SendEmotion(int fd, struct map_session_data *sd)
}
+void clif_parse_ChangePetName(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to change pet's name (CZ_RENAME_PET).
/// 01a5 <name>.24B
void clif_parse_ChangePetName(int fd, struct map_session_data *sd)
@@ -13042,6 +13417,7 @@ void clif_parse_ChangePetName(int fd, struct map_session_data *sd)
}
+void clif_parse_GMKick(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /kill (CZ_DISCONNECT_CHARACTER).
/// Request to disconnect a character.
/// 00cc <account id>.L
@@ -13101,6 +13477,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) {
}
+void clif_parse_GMKickAll(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// /killall (CZ_DISCONNECT_ALL_CHARACTER).
/// Request to disconnect all characters.
/// 00ce
@@ -13111,6 +13488,7 @@ void clif_parse_GMKickAll(int fd, struct map_session_data* sd) {
}
+void clif_parse_GMShift(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /remove (CZ_REMOVE_AID).
/// Request to warp to a character with given login ID.
/// 01ba <account name>.24B
@@ -13131,6 +13509,7 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd)
}
+void clif_parse_GMRemove2(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// /remove (CZ_REMOVE_AID_SSO).
/// Request to warp to a character with given account ID.
/// 0843 <account id>.L
@@ -13147,6 +13526,7 @@ void clif_parse_GMRemove2(int fd, struct map_session_data* sd) {
}
+void clif_parse_GMRecall(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /recall (CZ_RECALL).
/// Request to summon a player with given login ID to own position.
/// 01bc <account name>.24B
@@ -13167,6 +13547,7 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd)
}
+void clif_parse_GMRecall2(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// /recall (CZ_RECALL_SSO).
/// Request to summon a player with given account ID to own position.
/// 0842 <account id>.L
@@ -13183,6 +13564,7 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd) {
}
+void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /item /monster (CZ_ITEM_CREATE).
/// Request to execute GM commands.
/// usage:
@@ -13253,6 +13635,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
}
+void clif_parse_GMHide(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /hide (CZ_CHANGE_EFFECTSTATE).
/// 019d <effect state>.L
/// effect state:
@@ -13266,6 +13649,7 @@ void clif_parse_GMHide(int fd, struct map_session_data *sd) {
}
+void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to adjust player's manner points (CZ_REQ_GIVE_MANNER_POINT).
/// 0149 <account id>.L <type>.B <value>.W
/// type:
@@ -13320,6 +13704,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) {
}
+void clif_parse_GMRc(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// /rc (CZ_REQ_GIVE_MANNER_BYNAME).
/// GM adjustment of a player's manner value by -60.
/// 0212 <char name>.24B
@@ -13337,8 +13722,10 @@ void clif_parse_GMRc(int fd, struct map_session_data* sd)
/// Result of request to resolve account name (ZC_ACK_ACCOUNTNAME).
/// 01e0 <account id>.L <account name>.24B
void clif_account_name(struct map_session_data* sd, int account_id, const char* accname) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x1e0));
WFIFOW(fd,0) = 0x1e0;
WFIFOL(fd,2) = account_id;
@@ -13347,6 +13734,7 @@ void clif_account_name(struct map_session_data* sd, int account_id, const char*
}
+void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// GM requesting account name (for right-click gm menu) (CZ_REQ_ACCOUNTNAME).
/// 01df <account id>.L
void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd)
@@ -13358,6 +13746,7 @@ void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd)
}
+void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /changemaptype <x> <y> <type> (CZ_CHANGE_MAPTYPE).
/// GM single cell type change request.
/// 0198 <x>.W <y>.W <type>.W
@@ -13380,6 +13769,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) {
}
+void clif_parse_PMIgnore(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// /in /ex (CZ_SETTING_WHISPER_PC).
/// Request to allow/deny whispers from a nick.
/// 00cf <nick>.24B <type>.B
@@ -13433,6 +13823,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd) {
}
+void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /inall /exall (CZ_SETTING_WHISPER_STATE).
/// Request to allow/deny all whispers.
/// 00d0 <type>.B
@@ -13472,8 +13863,10 @@ void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd)
/// Whisper ignore list (ZC_WHISPER_LIST).
/// 00d4 <packet len>.W { <char name>.24B }*
void clif_PMIgnoreList(struct map_session_data* sd) {
- int i, fd = sd->fd;
+ int i, fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,4+ARRAYLENGTH(sd->ignore)*NAME_LENGTH);
WFIFOW(fd,0) = 0xd4;
@@ -13486,6 +13879,7 @@ void clif_PMIgnoreList(struct map_session_data* sd) {
}
+void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Whisper ignore list request (CZ_REQ_WHISPER_LIST).
/// 00d3
void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
@@ -13494,6 +13888,7 @@ void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
}
+void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to invoke the /doridori recovery bonus (CZ_DORIDORI).
/// 01e7
void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd)
@@ -13513,6 +13908,7 @@ void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd)
}
+void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to invoke the effect of super novice's guardian angel prayer (CZ_CHOPOKGI).
/// 01ed
/// Note: This packet is caused by 7 lines of any text, followed by
@@ -13551,8 +13947,10 @@ void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd)
/// 0 = online
/// 1 = offline
void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int char_id, int online) {
- int i, fd = sd->fd;
+ int i, fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
//Seek friend.
for (i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id &&
(sd->status.friends[i].char_id != char_id || sd->status.friends[i].account_id != account_id); i++);
@@ -13587,6 +13985,7 @@ void clif_friendslist_send(struct map_session_data *sd)
{
int i = 0, n, fd = sd->fd;
+ nullpo_retv(sd);
// Send friends list
WFIFOHEAD(fd, MAX_FRIENDS * 32 + 4);
WFIFOW(fd, 0) = 0x201;
@@ -13636,8 +14035,10 @@ void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_dat
/// Asks a player for permission to be added as friend (ZC_REQ_ADD_FRIENDS).
/// 0207 <req account id>.L <req char id>.L <req char name>.24B
void clif_friendlist_req(struct map_session_data* sd, int account_id, int char_id, const char* name) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x207));
WFIFOW(fd,0) = 0x207;
WFIFOL(fd,2) = account_id;
@@ -13647,13 +14048,16 @@ void clif_friendlist_req(struct map_session_data* sd, int account_id, int char_i
}
+void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to add a player as friend (CZ_ADD_FRIENDS).
/// 0202 <name>.24B
void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) {
struct map_session_data *f_sd;
int i;
+ char *nick = (char*)RFIFOP(fd,2);
- f_sd = map->nick2sd((char*)RFIFOP(fd,2));
+ nick[NAME_LENGTH - 1] = '\0';
+ f_sd = map->nick2sd(nick);
// ensure that the request player's friend list is not full
ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0);
@@ -13694,6 +14098,7 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) {
}
+void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to a friend add request (CZ_ACK_REQ_ADD_FRIENDS).
/// 0208 <inviter account id>.L <inviter char id>.L <result>.B
/// 0208 <inviter account id>.L <inviter char id>.L <result>.L (PACKETVER >= 6)
@@ -13762,6 +14167,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd)
}
+void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to delete a friend (CZ_DELETE_FRIENDS).
/// 0203 <account id>.L <char id>.L
void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
@@ -13829,8 +14235,10 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
/// /pvpinfo list (ZC_ACK_PVPPOINT).
/// 0210 <char id>.L <account id>.L <win point>.L <lose point>.L <point>.L
void clif_PVPInfo(struct map_session_data* sd) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x210));
WFIFOW(fd,0) = 0x210;
WFIFOL(fd,2) = sd->status.char_id;
@@ -13842,6 +14250,7 @@ void clif_PVPInfo(struct map_session_data* sd) {
}
+void clif_parse_PVPInfo(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// /pvpinfo (CZ_REQ_PVPPOINT).
/// 020f <char id>.L <account id>.L
void clif_parse_PVPInfo(int fd,struct map_session_data *sd)
@@ -13858,6 +14267,7 @@ void clif_ranklist_sub(unsigned char *buf, enum fame_list_type type) {
struct fame_list* list;
int i;
+ nullpo_retv(buf);
switch( type ) {
case RANKTYPE_BLACKSMITH: list = pc->smith_fame_list; break;
case RANKTYPE_ALCHEMIST: list = pc->chemist_fame_list; break;
@@ -13886,10 +14296,13 @@ void clif_ranklist_sub(unsigned char *buf, enum fame_list_type type) {
/// 097d <RankingType>.W {<CharName>.24B <point>L}*10 <mypoint>L (ZC_ACK_RANKING)
void clif_ranklist(struct map_session_data *sd, enum fame_list_type type) {
- int fd = sd->fd;
+ int fd;
int mypoint = 0;
- int upperMask = sd->class_&MAPID_UPPERMASK;
+ int upperMask;
+ nullpo_retv(sd);
+ fd = sd->fd;
+ upperMask = sd->class_&MAPID_UPPERMASK;
WFIFOHEAD(fd, 288);
WFIFOW(fd, 0) = 0x97d;
WFIFOW(fd, 2) = type;
@@ -13908,6 +14321,7 @@ void clif_ranklist(struct map_session_data *sd, enum fame_list_type type) {
WFIFOSET(fd, 288);
}
+void clif_parse_ranklist(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/*
* 097c <type> (CZ_REQ_RANKING)
* */
@@ -13932,7 +14346,11 @@ void clif_update_rankingpoint(struct map_session_data *sd, enum fame_list_type t
case RANKTYPE_TAEKWON: clif->fame_taekwon(sd,points); break;
}
#else
- int fd = sd->fd;
+
+ int fd;
+
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd, 12);
WFIFOW(fd, 0) = 0x97e;
WFIFOW(fd, 2) = type;
@@ -13945,14 +14363,17 @@ void clif_update_rankingpoint(struct map_session_data *sd, enum fame_list_type t
/// /blacksmith list (ZC_BLACKSMITH_RANK).
/// 0219 { <name>.24B }*10 { <point>.L }*10
void clif_blacksmith(struct map_session_data* sd) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x219));
WFIFOW(fd,0) = 0x219;
clif_ranklist_sub(WFIFOP(fd, 2), RANKTYPE_BLACKSMITH);
WFIFOSET(fd, packet_len(0x219));
}
+void clif_parse_Blacksmith(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// /blacksmith (CZ_BLACKSMITH_RANK).
/// 0217
void clif_parse_Blacksmith(int fd,struct map_session_data *sd) {
@@ -13962,8 +14383,10 @@ void clif_parse_Blacksmith(int fd,struct map_session_data *sd) {
/// Notification about backsmith points (ZC_BLACKSMITH_POINT).
/// 021b <points>.L <total points>.L
void clif_fame_blacksmith(struct map_session_data *sd, int points) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x21b));
WFIFOW(fd,0) = 0x21b;
WFIFOL(fd,2) = points;
@@ -13974,14 +14397,17 @@ void clif_fame_blacksmith(struct map_session_data *sd, int points) {
/// /alchemist list (ZC_ALCHEMIST_RANK).
/// 021a { <name>.24B }*10 { <point>.L }*10
void clif_alchemist(struct map_session_data* sd) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x21a));
WFIFOW(fd,0) = 0x21a;
clif_ranklist_sub(WFIFOP(fd,2), RANKTYPE_ALCHEMIST);
WFIFOSET(fd, packet_len(0x21a));
}
+void clif_parse_Alchemist(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// /alchemist (CZ_ALCHEMIST_RANK).
/// 0218
void clif_parse_Alchemist(int fd,struct map_session_data *sd) {
@@ -13991,8 +14417,10 @@ void clif_parse_Alchemist(int fd,struct map_session_data *sd) {
/// Notification about alchemist points (ZC_ALCHEMIST_POINT).
/// 021c <points>.L <total points>.L
void clif_fame_alchemist(struct map_session_data *sd, int points) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x21c));
WFIFOW(fd,0) = 0x21c;
WFIFOL(fd,2) = points;
@@ -14003,14 +14431,17 @@ void clif_fame_alchemist(struct map_session_data *sd, int points) {
/// /taekwon list (ZC_TAEKWON_RANK).
/// 0226 { <name>.24B }*10 { <point>.L }*10
void clif_taekwon(struct map_session_data* sd) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x226));
WFIFOW(fd,0) = 0x226;
clif_ranklist_sub(WFIFOP(fd,2), RANKTYPE_TAEKWON);
WFIFOSET(fd, packet_len(0x226));
}
+void clif_parse_Taekwon(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// /taekwon (CZ_TAEKWON_RANK).
/// 0225
void clif_parse_Taekwon(int fd,struct map_session_data *sd) {
@@ -14020,8 +14451,10 @@ void clif_parse_Taekwon(int fd,struct map_session_data *sd) {
/// Notification about taekwon points (ZC_TAEKWON_POINT).
/// 0224 <points>.L <total points>.L
void clif_fame_taekwon(struct map_session_data *sd, int points) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x224));
WFIFOW(fd,0) = 0x224;
WFIFOL(fd,2) = points;
@@ -14032,8 +14465,10 @@ void clif_fame_taekwon(struct map_session_data *sd, int points) {
/// /pk list (ZC_KILLER_RANK).
/// 0238 { <name>.24B }*10 { <point>.L }*10
void clif_ranking_pk(struct map_session_data* sd) {
- int i, fd = sd->fd;
+ int i, fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x238));
WFIFOW(fd,0) = 0x238;
for (i = 0; i < 10;i ++) {
@@ -14044,6 +14479,7 @@ void clif_ranking_pk(struct map_session_data* sd) {
}
+void clif_parse_RankingPk(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// /pk (CZ_KILLER_RANK).
/// 0237
void clif_parse_RankingPk(int fd,struct map_session_data *sd) {
@@ -14051,6 +14487,7 @@ void clif_parse_RankingPk(int fd,struct map_session_data *sd) {
}
+void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// SG Feel save OK [Komurka] (CZ_AGREE_STARPLACE).
/// 0254 <which>.B
/// which:
@@ -14086,6 +14523,7 @@ void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd)
/// 2 = star
void clif_feel_req(int fd, struct map_session_data *sd, uint16 skill_lv)
{
+ nullpo_retv(sd);
WFIFOHEAD(fd,packet_len(0x253));
WFIFOW(fd,0)=0x253;
WFIFOB(fd,2)=TOB(skill_lv-1);
@@ -14095,6 +14533,7 @@ void clif_feel_req(int fd, struct map_session_data *sd, uint16 skill_lv)
}
+void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to change homunculus' name (CZ_RENAME_MER).
/// 0231 <name>.24B
void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) {
@@ -14102,6 +14541,7 @@ void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) {
}
+void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to warp/move homunculus/mercenary to it's owner (CZ_REQUEST_MOVETOOWNER).
/// 0234 <id>.L
void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd)
@@ -14110,9 +14550,9 @@ void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd)
struct block_list *bl = NULL;
struct unit_data *ud = NULL;
- if( sd->md && sd->md->bl.id == id )
+ if (sd->md && sd->md->bl.id == id)
bl = &sd->md->bl;
- else if( homun_alive(sd->hd) && sd->hd->bl.id == id )
+ else if (homun_alive(sd->hd) && sd->hd->bl.id == id)
bl = &sd->hd->bl; // Moving Homunculus
else
return;
@@ -14123,6 +14563,7 @@ void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd)
}
+void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to move homunculus/mercenary (CZ_REQUEST_MOVENPC).
/// 0232 <id>.L <position data>.3B
void clif_parse_HomMoveTo(int fd, struct map_session_data *sd)
@@ -14144,6 +14585,7 @@ void clif_parse_HomMoveTo(int fd, struct map_session_data *sd)
}
+void clif_parse_HomAttack(int fd,struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to do an action with homunculus/mercenary (CZ_REQUEST_ACTNPC).
/// 0233 <id>.L <target id>.L <action>.B
/// action:
@@ -14166,6 +14608,7 @@ void clif_parse_HomAttack(int fd,struct map_session_data *sd)
}
+void clif_parse_HomMenu(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to invoke a homunculus menu action (CZ_COMMAND_MER).
/// 022d <type>.W <command>.B
/// type:
@@ -14186,6 +14629,7 @@ void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn]
}
+void clif_parse_AutoRevive(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to resurrect oneself using Token of Siegfried (CZ_STANDING_RESURRECTION).
/// 0292
void clif_parse_AutoRevive(int fd, struct map_session_data *sd) {
@@ -14222,6 +14666,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd) {
/// <hitSuccessValue>.W <avoidSuccessValue>.W <plusAvoidSuccessValue>.W
/// <criticalSuccessValue>.W <ASPD>.W <plusASPD>.W
void clif_check(int fd, struct map_session_data* pl_sd) {
+ nullpo_retv(pl_sd);
WFIFOHEAD(fd,packet_len(0x214));
WFIFOW(fd, 0) = 0x214;
WFIFOB(fd, 2) = min(pl_sd->status.str, UINT8_MAX);
@@ -14254,6 +14699,7 @@ void clif_check(int fd, struct map_session_data* pl_sd) {
}
+void clif_parse_Check(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// /check (CZ_REQ_STATUS_GM).
/// Request character's status values.
/// 0213 <char name>.24B
@@ -14358,6 +14804,8 @@ void clif_Mail_return(int fd, int mail_id, short fail)
/// 024a <mail id>.L <title>.40B <sender>.24B
void clif_Mail_new(int fd, int mail_id, const char *sender, const char *title)
{
+ nullpo_retv(sender);
+ nullpo_retv(title);
WFIFOHEAD(fd,packet_len(0x24a));
WFIFOW(fd,0) = 0x24a;
WFIFOL(fd,2) = mail_id;
@@ -14389,10 +14837,12 @@ void clif_Mail_window(int fd, int flag)
void clif_Mail_refreshinbox(struct map_session_data *sd)
{
int fd = sd->fd;
- struct mail_data *md = &sd->mail.inbox;
+ struct mail_data *md;
struct mail_message *msg;
int len, i, j;
+ nullpo_retv(sd);
+ md = &sd->mail.inbox;
len = 8 + (73 * md->amount);
WFIFOHEAD(fd,len);
@@ -14422,6 +14872,7 @@ void clif_Mail_refreshinbox(struct map_session_data *sd)
}
+void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Mail inbox list request (CZ_MAIL_GET_LIST).
/// 023f
void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd)
@@ -14446,6 +14897,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
{
int i, fd = sd->fd;
+ nullpo_retv(sd);
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
if( i == MAIL_MAX_INBOX ) {
clif->mail_return(sd->fd, mail_id, 1); // Mail doesn't exist
@@ -14500,6 +14952,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
}
+void clif_parse_Mail_read(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to open a mail (CZ_MAIL_OPEN).
/// 0241 <mail id>.L
void clif_parse_Mail_read(int fd, struct map_session_data *sd)
@@ -14515,6 +14968,7 @@ void clif_parse_Mail_read(int fd, struct map_session_data *sd)
}
+void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to receive mail's attachment (CZ_MAIL_GET_ITEM).
/// 0244 <mail id>.L
void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
@@ -14583,6 +15037,7 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
}
+void clif_parse_Mail_delete(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to delete a mail (CZ_MAIL_DELETE).
/// 0243 <mail id>.L
void clif_parse_Mail_delete(int fd, struct map_session_data *sd)
@@ -14614,6 +15069,7 @@ void clif_parse_Mail_delete(int fd, struct map_session_data *sd)
}
+void clif_parse_Mail_return(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to return a mail (CZ_REQ_MAIL_RETURN).
/// 0273 <mail id>.L <receive name>.24B
void clif_parse_Mail_return(int fd, struct map_session_data *sd)
@@ -14638,6 +15094,7 @@ void clif_parse_Mail_return(int fd, struct map_session_data *sd)
}
+void clif_parse_Mail_setattach(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to add an item or Zeny to mail (CZ_MAIL_ADD_ITEM).
/// 0247 <index>.W <amount>.L
void clif_parse_Mail_setattach(int fd, struct map_session_data *sd)
@@ -14656,6 +15113,7 @@ void clif_parse_Mail_setattach(int fd, struct map_session_data *sd)
}
+void clif_parse_Mail_winopen(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to reset mail item and/or Zeny (CZ_MAIL_RESET_ITEM).
/// 0246 <type>.W
/// type:
@@ -14673,6 +15131,7 @@ void clif_parse_Mail_winopen(int fd, struct map_session_data *sd)
}
+void clif_parse_Mail_send(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to send mail (CZ_MAIL_SEND).
/// 0248 <packet len>.W <recipient>.24B <title>.40B <body len>.B <body>.?B
void clif_parse_Mail_send(int fd, struct map_session_data *sd)
@@ -14744,8 +15203,10 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
/// 1 = close
void clif_Auction_openwindow(struct map_session_data *sd)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->state.vending || sd->state.buyingstore || sd->state.trading)
return;
@@ -14763,10 +15224,12 @@ void clif_Auction_openwindow(struct map_session_data *sd)
/// 0252 <packet len>.W <pages>.L <count>.L { <auction id>.L <seller name>.24B <name id>.W <type>.L <amount>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <now price>.L <max price>.L <buyer name>.24B <delete time>.L }*
void clif_Auction_results(struct map_session_data *sd, short count, short pages, uint8 *buf)
{
- int i, fd = sd->fd, len = sizeof(struct auction_data);
+ int i, fd, len = sizeof(struct auction_data);
struct auction_data auction;
struct item_data *item;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,12 + (count * 83));
WFIFOW(fd,0) = 0x252;
WFIFOW(fd,2) = 12 + (count * 83);
@@ -14817,6 +15280,7 @@ void clif_Auction_setitem(int fd, int index, bool fail) {
}
+void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to initialize 'new auction' data (CZ_AUCTION_CREATE).
/// 024b <type>.W
/// type:
@@ -14832,6 +15296,7 @@ void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd)
}
+void clif_parse_Auction_setitem(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to add an item to the action (CZ_AUCTION_ADD_ITEM).
/// 024c <index>.W <count>.L
void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
@@ -14912,6 +15377,7 @@ void clif_Auction_close(int fd, unsigned char flag)
}
+void clif_parse_Auction_register(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to add an auction (CZ_AUCTION_ADD).
/// 024d <now money>.L <max money>.L <delete hour>.W
void clif_parse_Auction_register(int fd, struct map_session_data *sd)
@@ -14922,12 +15388,19 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
if (!battle_config.feature_auction)
return;
+ Assert_retv(sd->auction.index >= 0 && sd->auction.index < MAX_INVENTORY);
+
memset(&auction, 0, sizeof(auction));
auction.price = RFIFOL(fd,2);
auction.buynow = RFIFOL(fd,6);
auction.hours = RFIFOW(fd,10);
// Invalid Situations...
+ if (auction.price <= 0 || auction.buynow <= 0) {
+ ShowWarning("Character %s trying to register auction wit wrong price.\n", sd->status.name);
+ return;
+ }
+
if( sd->auction.amount < 1 ) {
ShowWarning("Character %s trying to register auction without item.\n", sd->status.name);
return;
@@ -15000,6 +15473,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
}
+void clif_parse_Auction_cancel(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Cancels an auction (CZ_AUCTION_ADD_CANCEL).
/// 024e <auction id>.L
void clif_parse_Auction_cancel(int fd, struct map_session_data *sd)
@@ -15010,6 +15484,7 @@ void clif_parse_Auction_cancel(int fd, struct map_session_data *sd)
}
+void clif_parse_Auction_close(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Closes an auction (CZ_AUCTION_REQ_MY_SELL_STOP).
/// 025d <auction id>.L
void clif_parse_Auction_close(int fd, struct map_session_data *sd)
@@ -15020,6 +15495,7 @@ void clif_parse_Auction_close(int fd, struct map_session_data *sd)
}
+void clif_parse_Auction_bid(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Places a bid on an auction (CZ_AUCTION_BUY).
/// 024f <auction id>.L <money>.L
void clif_parse_Auction_bid(int fd, struct map_session_data *sd)
@@ -15045,6 +15521,7 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd)
}
+void clif_parse_Auction_search(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Auction Search (CZ_AUCTION_ITEM_SEARCH).
/// 0251 <search type>.W <auction id>.L <search text>.24B <page number>.W
/// search type:
@@ -15070,6 +15547,7 @@ void clif_parse_Auction_search(int fd, struct map_session_data* sd)
}
+void clif_parse_Auction_buysell(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Requests list of own currently active bids or auctions (CZ_AUCTION_REQ_MY_INFO).
/// 025c <type>.W
/// type:
@@ -15154,9 +15632,11 @@ void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd) {
/// For error return codes see enum cashshop_error@clif.h
void clif_cashshop_ack(struct map_session_data* sd, int error) {
struct npc_data *nd;
- int fd = sd->fd;
+ int fd;
int currency[2] = { 0,0 };
+ nullpo_retv(sd);
+ fd = sd->fd;
if( (nd = map->id2nd(sd->npc_shopid)) && nd->subtype == SCRIPT ) {
npc->trader_count_funds(nd,sd);
currency[0] = npc->trader_funds[0];
@@ -15179,6 +15659,7 @@ void clif_cashshop_ack(struct map_session_data* sd, int error) {
}
+void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to buy item(s) from cash shop (CZ_PC_BUY_CASH_POINT_ITEM).
/// 0288 <name id>.W <amount>.W
/// 0288 <name id>.W <amount>.W <kafra points>.L (PACKETVER >= 20070711)
@@ -15186,7 +15667,6 @@ void clif_cashshop_ack(struct map_session_data* sd, int error) {
void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
{
int fail = 0;
- nullpo_retv(sd);
if( sd->state.trading || !sd->npc_shopid || pc_has_permission(sd,PC_PERM_DISABLE_STORE) )
fail = 1;
@@ -15226,8 +15706,10 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
/// 2 = "You cannot adopt a married person."
void clif_Adopt_reply(struct map_session_data *sd, int type)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,6);
WFIFOW(fd,0) = 0x216;
WFIFOL(fd,2) = type;
@@ -15238,8 +15720,11 @@ void clif_Adopt_reply(struct map_session_data *sd, int type)
/// Adoption confirmation (ZC_REQ_BABY).
/// 01f6 <account id>.L <char id>.L <name>.B
void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *src, int p_id) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ nullpo_retv(src);
+ fd = sd->fd;
WFIFOHEAD(fd,34);
WFIFOW(fd,0) = 0x1f6;
WFIFOL(fd,2) = src->status.account_id;
@@ -15249,6 +15734,7 @@ void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *sr
}
+void clif_parse_Adopt_request(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to adopt a player (CZ_REQ_JOIN_BABY).
/// 01f9 <account id>.L
void clif_parse_Adopt_request(int fd, struct map_session_data *sd) {
@@ -15261,6 +15747,7 @@ void clif_parse_Adopt_request(int fd, struct map_session_data *sd) {
}
+void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Answer to adopt confirmation (CZ_JOIN_BABY).
/// 01f7 <account id>.L <char id>.L <answer>.L
/// answer:
@@ -15331,6 +15818,7 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag)
}
+void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Requesting equip of a player (CZ_EQUIPWIN_MICROSCOPE).
/// 02d6 <account id>.L
void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) {
@@ -15347,6 +15835,7 @@ void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) {
}
+void clif_parse_EquipTick(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to change equip window tick (CZ_CONFIG).
/// 02d8 <type>.L <value>.L
/// type:
@@ -15361,6 +15850,7 @@ void clif_parse_EquipTick(int fd, struct map_session_data* sd)
clif->equiptickack(sd, flag);
}
+void clif_parse_PartyTick(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to change party invitation tick.
/// value:
/// 0 = disabled
@@ -15383,12 +15873,16 @@ void clif_quest_send_list(struct map_session_data *sd)
int i;
#if PACKETVER >= 20141022
int info_len = 15;
- int len = sd->avail_quests*info_len+8;
+ int len;
+ nullpo_retv(sd);
+ len = sd->avail_quests*info_len+8;
WFIFOHEAD(fd,len);
WFIFOW(fd, 0) = 0x97a;
#else
int info_len = 5;
- int len = sd->avail_quests*info_len+8;
+ int len;
+ nullpo_retv(sd);
+ len = sd->avail_quests*info_len+8;
WFIFOHEAD(fd,len);
WFIFOW(fd, 0) = 0x2b1;
#endif
@@ -15418,9 +15912,11 @@ void clif_quest_send_mission(struct map_session_data *sd)
{
int fd = sd->fd;
int i, j;
- int len = sd->avail_quests*104+8;
+ int len;
struct mob_db *monster;
+ nullpo_retv(sd);
+ len = sd->avail_quests*104+8;
WFIFOHEAD(fd, len);
WFIFOW(fd, 0) = 0x2b2;
WFIFOW(fd, 2) = len;
@@ -15449,10 +15945,14 @@ void clif_quest_send_mission(struct map_session_data *sd)
/// 02b3 <quest id>.L <active>.B <start time>.L <expire time>.L <mobs>.W { <mob id>.L <mob count>.W <mob name>.24B }*3
void clif_quest_add(struct map_session_data *sd, struct quest *qd)
{
- int fd = sd->fd;
+ int fd;
int i;
- struct quest_db *qi = quest->db(qd->quest_id);
+ struct quest_db *qi;
+ nullpo_retv(sd);
+ nullpo_retv(qd);
+ fd = sd->fd;
+ qi = quest->db(qd->quest_id);
WFIFOHEAD(fd, packet_len(0x2b3));
WFIFOW(fd, 0) = 0x2b3;
WFIFOL(fd, 2) = qd->quest_id;
@@ -15476,8 +15976,10 @@ void clif_quest_add(struct map_session_data *sd, struct quest *qd)
/// Notification about a quest being removed (ZC_DEL_QUEST).
/// 02b4 <quest id>.L
void clif_quest_delete(struct map_session_data *sd, int quest_id) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x2b4));
WFIFOW(fd, 0) = 0x2b4;
WFIFOL(fd, 2) = quest_id;
@@ -15489,10 +15991,16 @@ void clif_quest_delete(struct map_session_data *sd, int quest_id) {
/// 02b5 <packet len>.W <mobs>.W { <quest id>.L <mob id>.L <total count>.W <current count>.W }*3
void clif_quest_update_objective(struct map_session_data *sd, struct quest *qd)
{
- int fd = sd->fd;
+ int fd;
int i;
- struct quest_db *qi = quest->db(qd->quest_id);
- int len = qi->objectives_count*12+6;
+ struct quest_db *qi;
+ int len;
+
+ nullpo_retv(sd);
+ nullpo_retv(qd);
+ fd = sd->fd;
+ qi = quest->db(qd->quest_id);
+ len = qi->objectives_count * 12 + 6;
WFIFOHEAD(fd, len);
WFIFOW(fd, 0) = 0x2b5;
@@ -15510,6 +16018,7 @@ void clif_quest_update_objective(struct map_session_data *sd, struct quest *qd)
}
+void clif_parse_questStateAck(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Request to change the state of a quest (CZ_ACTIVE_QUEST).
/// 02b6 <quest id>.L <active>.B
void clif_parse_questStateAck(int fd, struct map_session_data *sd) {
@@ -15520,8 +16029,10 @@ void clif_parse_questStateAck(int fd, struct map_session_data *sd) {
/// Notification about the change of a quest state (ZC_ACTIVE_QUEST).
/// 02b7 <quest id>.L <active>.B
void clif_quest_update_status(struct map_session_data *sd, int quest_id, bool active) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x2b7));
WFIFOW(fd, 0) = 0x2b7;
WFIFOL(fd, 2) = quest_id;
@@ -15544,8 +16055,11 @@ void clif_quest_update_status(struct map_session_data *sd, int quest_id, bool ac
void clif_quest_show_event(struct map_session_data *sd, struct block_list *bl, short state, short color)
{
#if PACKETVER >= 20090218
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ nullpo_retv(bl);
+ fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x446));
WFIFOW(fd, 0) = 0x446;
WFIFOL(fd, 2) = bl->id;
@@ -15723,6 +16237,7 @@ void clif_mercenary_skillblock(struct map_session_data *sd)
}
+void clif_parse_mercenary_action(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to invoke a mercenary menu action (CZ_MER_COMMAND).
/// 029f <command>.B
/// 1 = mercenary information
@@ -15856,6 +16371,9 @@ void clif_bg_message(struct battleground_data *bgd, int src_id, const char *name
struct map_session_data *sd;
unsigned char *buf;
+ nullpo_retv(bgd);
+ nullpo_retv(name);
+ nullpo_retv(mes);
if( !bgd->count || (sd = bg->getavailablesd(bgd)) == NULL )
return;
@@ -15872,6 +16390,7 @@ void clif_bg_message(struct battleground_data *bgd, int src_id, const char *name
}
+void clif_parse_BattleChat(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Validates and processes battlechat messages [pakpil] (CZ_BATTLEFIELD_CHAT).
/// 0x2db <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_BattleChat(int fd, struct map_session_data* sd)
@@ -16089,8 +16608,11 @@ void clif_party_show_picker(struct map_session_data * sd, struct item * item_dat
{
#if PACKETVER >= 20071002
unsigned char buf[22];
- struct item_data* id = itemdb->search(item_data->nameid);
+ struct item_data* id;
+ nullpo_retv(sd);
+ nullpo_retv(item_data);
+ id = itemdb->search(item_data->nameid);
WBUFW(buf,0) = 0x2b8;
WBUFL(buf,2) = sd->status.account_id;
WBUFW(buf,6) = item_data->nameid;
@@ -16139,6 +16661,7 @@ void clif_displayexp(struct map_session_data *sd, unsigned int exp, char type, b
/// Except for type 3 it is interpreted as seconds for displaying as DD:HH:MM:SS, HH:MM:SS, MM:SS or SS (leftmost '00' is not displayed).
void clif_showdigit(struct map_session_data* sd, unsigned char type, int value)
{
+ nullpo_retv(sd);
WFIFOHEAD(sd->fd, packet_len(0x1b1));
WFIFOW(sd->fd,0) = 0x1b1;
WFIFOB(sd->fd,2) = type;
@@ -16147,6 +16670,7 @@ void clif_showdigit(struct map_session_data* sd, unsigned char type, int value)
}
+void clif_parse_LessEffect(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Notification of the state of client command /effect (CZ_LESSEFFECT).
/// 021d <state>.L
/// state:
@@ -16166,6 +16690,7 @@ void clif_parse_LessEffect(int fd, struct map_session_data* sd)
sd->state.lesseffect = ( isLess != 0 );
}
+void clif_parse_ItemListWindowSelected(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// S 07e4 <length>.w <option>.l <val>.l {<index>.w <amount>.w).4b*
void clif_parse_ItemListWindowSelected(int fd, struct map_session_data* sd) {
int n = (RFIFOW(fd,2)-12) / 4;
@@ -16262,8 +16787,10 @@ void clif_elemental_info(struct map_session_data *sd) {
/// 0810 <slots>.B
void clif_buyingstore_open(struct map_session_data* sd)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x810));
WFIFOW(fd,0) = 0x810;
WFIFOB(fd,2) = sd->buyingstore.slots;
@@ -16271,6 +16798,7 @@ void clif_buyingstore_open(struct map_session_data* sd)
}
+void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to create a buying store (CZ_REQ_OPEN_BUYING_STORE).
/// 0811 <packet len>.W <limit zeny>.L <result>.B <store name>.80B { <name id>.W <amount>.W <price>.L }*
/// result:
@@ -16322,8 +16850,10 @@ void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd) {
/// ? = nothing
void clif_buyingstore_open_failed(struct map_session_data* sd, unsigned short result, unsigned int weight)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x812));
WFIFOW(fd,0) = 0x812;
WFIFOW(fd,2) = result;
@@ -16336,9 +16866,11 @@ void clif_buyingstore_open_failed(struct map_session_data* sd, unsigned short re
/// 0813 <packet len>.W <account id>.L <limit zeny>.L { <price>.L <count>.W <type>.B <name id>.W }*
void clif_buyingstore_myitemlist(struct map_session_data* sd)
{
- int fd = sd->fd;
+ int fd;
unsigned int i;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,12+sd->buyingstore.slots*9);
WFIFOW(fd,0) = 0x813;
WFIFOW(fd,2) = 12+sd->buyingstore.slots*9;
@@ -16363,6 +16895,7 @@ void clif_buyingstore_entry(struct map_session_data* sd)
{
uint8 buf[86];
+ nullpo_retv(sd);
WBUFW(buf,0) = 0x814;
WBUFL(buf,2) = sd->bl.id;
memcpy(WBUFP(buf,6), sd->message, MESSAGE_SIZE);
@@ -16371,8 +16904,10 @@ void clif_buyingstore_entry(struct map_session_data* sd)
}
void clif_buyingstore_entry_single(struct map_session_data* sd, struct map_session_data* pl_sd)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x814));
WFIFOW(fd,0) = 0x814;
WFIFOL(fd,2) = pl_sd->bl.id;
@@ -16381,6 +16916,7 @@ void clif_buyingstore_entry_single(struct map_session_data* sd, struct map_sessi
}
+void clif_parse_ReqCloseBuyingStore(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to close own buying store (CZ_REQ_CLOSE_BUYING_STORE).
/// 0815
void clif_parse_ReqCloseBuyingStore(int fd, struct map_session_data* sd) {
@@ -16394,6 +16930,7 @@ void clif_buyingstore_disappear_entry(struct map_session_data* sd)
{
uint8 buf[6];
+ nullpo_retv(sd);
WBUFW(buf,0) = 0x816;
WBUFL(buf,2) = sd->bl.id;
@@ -16401,8 +16938,11 @@ void clif_buyingstore_disappear_entry(struct map_session_data* sd)
}
void clif_buyingstore_disappear_entry_single(struct map_session_data* sd, struct map_session_data* pl_sd)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ nullpo_retv(pl_sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x816));
WFIFOW(fd,0) = 0x816;
WFIFOL(fd,2) = pl_sd->bl.id;
@@ -16426,9 +16966,12 @@ void clif_parse_ReqClickBuyingStore(int fd, struct map_session_data* sd)
/// 0818 <packet len>.W <account id>.L <store id>.L <limit zeny>.L { <price>.L <amount>.W <type>.B <name id>.W }*
void clif_buyingstore_itemlist(struct map_session_data* sd, struct map_session_data* pl_sd)
{
- int fd = sd->fd;
+ int fd;
unsigned int i;
+ nullpo_retv(sd);
+ nullpo_retv(pl_sd);
+ fd = sd->fd;
WFIFOHEAD(fd,16+pl_sd->buyingstore.slots*9);
WFIFOW(fd,0) = 0x818;
WFIFOW(fd,2) = 16+pl_sd->buyingstore.slots*9;
@@ -16448,6 +16991,7 @@ void clif_buyingstore_itemlist(struct map_session_data* sd, struct map_session_d
}
+void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to sell items to a buying store (CZ_REQ_TRADE_BUYING_STORE).
/// 0819 <packet len>.W <account id>.L <store id>.L { <index>.W <name id>.W <amount>.W }*
void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd) {
@@ -16491,8 +17035,10 @@ void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd) {
/// ? = nothing
void clif_buyingstore_trade_failed_buyer(struct map_session_data* sd, short result)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x81a));
WFIFOW(fd,0) = 0x81a;
WFIFOW(fd,2) = result;
@@ -16504,8 +17050,10 @@ void clif_buyingstore_trade_failed_buyer(struct map_session_data* sd, short resu
/// 081b <name id>.W <amount>.W <limit zeny>.L
void clif_buyingstore_update_item(struct map_session_data* sd, unsigned short nameid, unsigned short amount)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x81b));
WFIFOW(fd,0) = 0x81b;
WFIFOW(fd,2) = nameid;
@@ -16523,8 +17071,10 @@ void clif_buyingstore_update_item(struct map_session_data* sd, unsigned short na
/// NOTE: This function has to be called _instead_ of clif_delitem/clif_dropitem.
void clif_buyingstore_delete_item(struct map_session_data* sd, short index, unsigned short amount, int price)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x81c));
WFIFOW(fd,0) = 0x81c;
WFIFOW(fd,2) = index+2;
@@ -16543,8 +17093,10 @@ void clif_buyingstore_delete_item(struct map_session_data* sd, short index, unsi
/// ? = nothing
void clif_buyingstore_trade_failed_seller(struct map_session_data* sd, short result, unsigned short nameid)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x824));
WFIFOW(fd,0) = 0x824;
WFIFOW(fd,2) = result;
@@ -16553,6 +17105,7 @@ void clif_buyingstore_trade_failed_seller(struct map_session_data* sd, short res
}
+void clif_parse_SearchStoreInfo(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Search Store Info System
///
@@ -16620,9 +17173,11 @@ void clif_parse_SearchStoreInfo(int fd, struct map_session_data* sd) {
void clif_search_store_info_ack(struct map_session_data* sd)
{
const unsigned int blocksize = MESSAGE_SIZE+26;
- int fd = sd->fd;
+ int fd;
unsigned int i, start, end;
+ nullpo_retv(sd);
+ fd = sd->fd;
start = sd->searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE;
end = min(sd->searchstore.count, start+SEARCHSTORE_RESULTS_PER_PAGE);
@@ -16669,8 +17224,10 @@ void clif_search_store_info_ack(struct map_session_data* sd)
/// 4 = "No sale (purchase) information available." (0x705)
void clif_search_store_info_failed(struct map_session_data* sd, unsigned char reason)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x837));
WFIFOW(fd,0) = 0x837;
WFIFOB(fd,2) = reason;
@@ -16678,6 +17235,7 @@ void clif_search_store_info_failed(struct map_session_data* sd, unsigned char re
}
+void clif_parse_SearchStoreInfoNextPage(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to display next page of results (CZ_SEARCH_STORE_INFO_NEXT_PAGE).
/// 0838
void clif_parse_SearchStoreInfoNextPage(int fd, struct map_session_data* sd)
@@ -16693,8 +17251,10 @@ void clif_parse_SearchStoreInfoNextPage(int fd, struct map_session_data* sd)
/// 1 = Search Stores (Cash), asks for confirmation, when clicking a store
void clif_open_search_store_info(struct map_session_data* sd)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x83a));
WFIFOW(fd,0) = 0x83a;
WFIFOW(fd,2) = sd->searchstore.effect;
@@ -16705,6 +17265,7 @@ void clif_open_search_store_info(struct map_session_data* sd)
}
+void clif_parse_CloseSearchStoreInfo(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to close the store search window (CZ_CLOSE_SEARCH_STORE_INFO).
/// 083b
void clif_parse_CloseSearchStoreInfo(int fd, struct map_session_data* sd)
@@ -16713,6 +17274,7 @@ void clif_parse_CloseSearchStoreInfo(int fd, struct map_session_data* sd)
}
+void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/// Request to invoke catalog effect on a store from search results (CZ_SSILIST_ITEM_CLICK).
/// 083c <account id>.L <store id>.L <nameid>.W
void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_data* sd)
@@ -16733,8 +17295,10 @@ void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_data* sd
/// 083d <xPos>.W <yPos>.W
void clif_search_store_info_click_ack(struct map_session_data* sd, short x, short y)
{
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x83d));
WFIFOW(fd,0) = 0x83d;
WFIFOW(fd,2) = x;
@@ -16773,7 +17337,6 @@ int clif_elementalconverter_list(struct map_session_data *sd) {
nullpo_ret(sd);
-
/// Main client packet processing function
fd=sd->fd;
WFIFOHEAD(fd, MAX_SKILL_PRODUCE_DB *2+4);
@@ -16804,6 +17367,7 @@ void clif_millenniumshield(struct block_list *bl, short shields ) {
#if PACKETVER >= 20081217
unsigned char buf[10];
+ nullpo_retv(bl);
WBUFW(buf,0) = 0x440;
WBUFL(buf,2) = bl->id;
WBUFW(buf,6) = shields;
@@ -16982,6 +17546,8 @@ int clif_skill_itemlistwindow( struct map_session_data *sd, uint16 skill_id, uin
return 1;
}
+
+void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/*==========================================
* used by SC_AUTOSHADOWSPELL
* RFIFOL(fd,2) - flag (currently not used)
@@ -17001,6 +17567,7 @@ void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd) {
clif_menuskill_clear(sd);
}
+
/*==========================================
* Kagerou/Oboro amulet spirit
*------------------------------------------*/
@@ -17016,6 +17583,8 @@ void clif_charm(struct map_session_data *sd)
WBUFW(buf,8) = sd->charm_count;
clif->send(buf,packet_len(0x08cf),&sd->bl,AREA);
}
+
+void clif_parse_MoveItem(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/// Move Item from or to Personal Tab (CZ_WHATSOEVER) [FE]
/// 0907 <index>.W
///
@@ -17047,6 +17616,7 @@ void clif_parse_MoveItem(int fd, struct map_session_data *sd) {
clif->favorite_item(sd, index);
#endif
}
+
/* [Ind/Hercules] */
void clif_cashshop_db(void) {
config_t cashshop_conf;
@@ -17116,8 +17686,10 @@ void clif_cashshop_db(void) {
/// Items that are in favorite tab of inventory (ZC_ITEM_FAVORITE).
/// 0900 <index>.W <favorite>.B
void clif_favorite_item(struct map_session_data* sd, unsigned short index) {
- int fd = sd->fd;
+ int fd;
+ nullpo_retv(sd);
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x908));
WFIFOW(fd,0) = 0x908;
WFIFOW(fd,2) = index+2;
@@ -17128,6 +17700,7 @@ void clif_favorite_item(struct map_session_data* sd, unsigned short index) {
void clif_snap( struct block_list *bl, short x, short y ) {
unsigned char buf[10];
+ nullpo_retv(bl);
WBUFW(buf,0) = 0x8d2;
WBUFL(buf,2) = bl->id;
WBUFW(buf,6) = x;
@@ -17139,6 +17712,8 @@ void clif_snap( struct block_list *bl, short x, short y ) {
void clif_monster_hp_bar( struct mob_data* md, struct map_session_data *sd ) {
struct packet_monster_hp p;
+ nullpo_retv(md);
+ nullpo_retv(sd);
p.PacketType = monsterhpType;
p.GID = md->bl.id;
p.HP = md->status.hp;
@@ -17146,10 +17721,13 @@ void clif_monster_hp_bar( struct mob_data* md, struct map_session_data *sd ) {
clif->send(&p,sizeof(p),&sd->bl,SELF);
}
+
/* [Ind/Hercules] placeholder for unsupported incoming packets (avoids server disconnecting client) */
void __attribute__ ((unused)) clif_parse_dull(int fd,struct map_session_data *sd) {
return;
}
+
+void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) {
if (map->list[sd->bl.m].flag.nocashshop) {
@@ -17164,10 +17742,12 @@ void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) {
WFIFOSET(fd, 10);
}
+void clif_parse_CashShopClose(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_CashShopClose(int fd, struct map_session_data *sd) {
/* TODO apply some state tracking */
}
+void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) {
int i, j = 0;
@@ -17189,6 +17769,8 @@ void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) {
WFIFOSET(fd, 8 + ( clif->cs.item_count[i] * 6 ));
}
}
+
+void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
unsigned short limit = RFIFOW(fd, 4), i, j;
unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash currently for us, confusing)
@@ -17276,6 +17858,8 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
}
}
+
+void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/* [Ind/Hercules] */
void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd) {
short tab = RFIFOW(fd, 2);
@@ -17341,6 +17925,7 @@ void clif_status_change2(struct block_list *bl, int tid, enum send_target target
}
void clif_partytickack(struct map_session_data* sd, bool flag) {
+ nullpo_retv(sd);
WFIFOHEAD(sd->fd, packet_len(0x2c9));
WFIFOW(sd->fd, 0) = 0x2c9;
@@ -17373,6 +17958,8 @@ void clif_ShowScript(struct block_list* bl, const char* message) {
void clif_status_change_end(struct block_list *bl, int tid, enum send_target target, int type) {
struct packet_status_change_end p;
+ nullpo_retv(bl);
+
if( bl->type == BL_PC && !((TBL_PC*)bl)->state.active )
return;
@@ -17393,6 +17980,7 @@ void clif_bgqueue_ack(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_ACK
default: {
struct packet_bgqueue_ack p;
+ nullpo_retv(sd);
p.PacketType = bgqueue_ackType;
p.type = response;
safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name));
@@ -17407,6 +17995,7 @@ void clif_bgqueue_ack(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_ACK
void clif_bgqueue_notice_delete(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_NOTICE_DELETED response, char *name) {
struct packet_bgqueue_notice_delete p;
+ nullpo_retv(sd);
p.PacketType = bgqueue_notice_deleteType;
p.type = response;
safestrncpy(p.bg_name, name, sizeof(p.bg_name));
@@ -17414,6 +18003,7 @@ void clif_bgqueue_notice_delete(struct map_session_data *sd, enum BATTLEGROUNDS_
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) {
struct packet_bgqueue_register *p = P2PTR(fd);
struct bg_arena *arena = NULL;
@@ -17440,6 +18030,8 @@ void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) {
void clif_bgqueue_update_info(struct map_session_data *sd, unsigned char arena_id, int position) {
struct packet_bgqueue_update_info p;
+ nullpo_retv(sd);
+ Assert_retv(arena_id < bg->arenas);
p.PacketType = bgqueue_updateinfoType;
safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name));
p.position = position;
@@ -17449,15 +18041,18 @@ void clif_bgqueue_update_info(struct map_session_data *sd, unsigned char arena_i
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd) {
struct packet_bgqueue_checkstate *p = P2PTR(fd);
+ nullpo_retv(sd);
if ( sd->bg_queue.arena && sd->bg_queue.type ) {
clif->bgqueue_update_info(sd,sd->bg_queue.arena->id,bg->id2pos(sd->bg_queue.arena->queue_id,sd->status.account_id));
} else
clif->bgqueue_notice_delete(sd, BGQND_FAIL_NOT_QUEUING,p->bg_name);
}
+void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd) {
struct packet_bgqueue_revoke_req *p = P2PTR(fd);
@@ -17467,6 +18062,7 @@ void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd) {
clif->bgqueue_notice_delete(sd, BGQND_FAIL_NOT_QUEUING,p->bg_name);
}
+void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) {
struct packet_bgqueue_battlebegin_ack *p = P2PTR(fd);
struct bg_arena *arena;
@@ -17483,6 +18079,7 @@ void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) {
void clif_bgqueue_joined(struct map_session_data *sd, int pos) {
struct packet_bgqueue_notify_entry p;
+ nullpo_retv(sd);
p.PacketType = bgqueue_notify_entryType;
safestrncpy(p.name,sd->status.name,sizeof(p.name));
p.position = pos;
@@ -17499,6 +18096,8 @@ void clif_bgqueue_pcleft(struct map_session_data *sd) {
void clif_bgqueue_battlebegins(struct map_session_data *sd, unsigned char arena_id, enum send_target target) {
struct packet_bgqueue_battlebegins p;
+ nullpo_retv(sd);
+ Assert_retv(arena_id < bg->arenas);
p.PacketType = bgqueue_battlebeginsType;
safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name));
safestrncpy(p.game_name, bg->arena[arena_id]->name, sizeof(p.game_name));
@@ -17509,15 +18108,18 @@ void clif_bgqueue_battlebegins(struct map_session_data *sd, unsigned char arena_
void clif_scriptclear(struct map_session_data *sd, int npcid) {
struct packet_script_clear p;
+ nullpo_retv(sd);
p.PacketType = script_clearType;
p.NpcID = npcid;
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+
/* Made Possible Thanks to Yommy! */
void clif_package_item_announce(struct map_session_data *sd, unsigned short nameid, unsigned short containerid) {
struct packet_package_item_announce p;
+ nullpo_retv(sd);
p.PacketType = package_item_announceType;
p.PacketLength = 11+NAME_LENGTH;
p.type = 0x0;
@@ -17529,10 +18131,12 @@ void clif_package_item_announce(struct map_session_data *sd, unsigned short name
clif->send(&p,sizeof(p), &sd->bl, ALL_CLIENT);
}
+
/* Made Possible Thanks to Yommy! */
void clif_item_drop_announce(struct map_session_data *sd, unsigned short nameid, char *monsterName) {
struct packet_item_drop_announce p;
+ nullpo_retv(sd);
p.PacketType = item_drop_announceType;
p.PacketLength = sizeof(p);
p.type = 0x1;
@@ -17544,6 +18148,7 @@ void clif_item_drop_announce(struct map_session_data *sd, unsigned short nameid,
clif->send(&p,sizeof(p), &sd->bl, ALL_CLIENT);
}
+
/* [Ind/Hercules] special thanks to Yommy~! */
void clif_skill_cooldown_list(int fd, struct skill_cd* cd) {
#if PACKETVER >= 20120604
@@ -17553,6 +18158,8 @@ void clif_skill_cooldown_list(int fd, struct skill_cd* cd) {
#endif
int i, count = 0;
+ nullpo_retv(cd);
+
WFIFOHEAD(fd,4+(offset*cd->cursor));
#if PACKETVER >= 20120604
@@ -17578,6 +18185,7 @@ void clif_skill_cooldown_list(int fd, struct skill_cd* cd) {
WFIFOSET(fd,4+(offset*count));
}
+
/* [Ind/Hercules] - Data Thanks to Yommy
* - ADDITEM_TO_CART_FAIL_WEIGHT = 0x0
* - ADDITEM_TO_CART_FAIL_COUNT = 0x1
@@ -17585,11 +18193,14 @@ void clif_skill_cooldown_list(int fd, struct skill_cd* cd) {
void clif_cart_additem_ack(struct map_session_data *sd, int flag) {
struct packet_cart_additem_ack p;
+ nullpo_retv(sd);
p.PacketType = cart_additem_ackType;
p.result = (char)flag;
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+
+void clif_parse_BankDeposit(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/* Bank System [Yommy/Hercules] */
void clif_parse_BankDeposit(int fd, struct map_session_data* sd) {
struct packet_banking_deposit_req *p = P2PTR(fd);
@@ -17605,6 +18216,7 @@ void clif_parse_BankDeposit(int fd, struct map_session_data* sd) {
pc->bank_deposit(sd,money);
}
+void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) {
struct packet_banking_withdraw_req *p = P2PTR(fd);
int money;
@@ -17619,6 +18231,7 @@ void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) {
pc->bank_withdraw(sd,money);
}
+void clif_parse_BankCheck(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
void clif_parse_BankCheck(int fd, struct map_session_data* sd) {
struct packet_banking_check p;
@@ -17634,10 +18247,12 @@ void clif_parse_BankCheck(int fd, struct map_session_data* sd) {
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+void clif_parse_BankOpen(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
void clif_parse_BankOpen(int fd, struct map_session_data* sd) {
return;
}
+void clif_parse_BankClose(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
void clif_parse_BankClose(int fd, struct map_session_data* sd) {
return;
}
@@ -17645,6 +18260,7 @@ void clif_parse_BankClose(int fd, struct map_session_data* sd) {
void clif_bank_deposit(struct map_session_data *sd, enum e_BANKING_DEPOSIT_ACK reason) {
struct packet_banking_deposit_ack p;
+ nullpo_retv(sd);
p.PacketType = banking_deposit_ackType;
p.Balance = sd->status.zeny;/* how much zeny char has after operation */
p.Money = (int64)sd->status.bank_vault;/* money in the bank */
@@ -17652,9 +18268,11 @@ void clif_bank_deposit(struct map_session_data *sd, enum e_BANKING_DEPOSIT_ACK r
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+
void clif_bank_withdraw(struct map_session_data *sd,enum e_BANKING_WITHDRAW_ACK reason) {
struct packet_banking_withdraw_ack p;
+ nullpo_retv(sd);
p.PacketType = banking_withdraw_ackType;
p.Balance = sd->status.zeny;/* how much zeny char has after operation */
p.Money = (int64)sd->status.bank_vault;/* money in the bank */
@@ -17662,9 +18280,11 @@ void clif_bank_withdraw(struct map_session_data *sd,enum e_BANKING_WITHDRAW_ACK
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+
/* TODO: official response packet (tried 0x8cb/0x97b but the display was quite screwed up.) */
/* currently mimicing */
void clif_show_modifiers (struct map_session_data *sd) {
+ nullpo_retv(sd);
if( sd->status.mod_exp != 100 || sd->status.mod_drop != 100 || sd->status.mod_death != 100 ) {
char output[128];
@@ -17679,12 +18299,14 @@ void clif_show_modifiers (struct map_session_data *sd) {
void clif_notify_bounditem(struct map_session_data *sd, unsigned short index) {
struct packet_notify_bounditem p;
+ nullpo_retv(sd);
p.PacketType = notify_bounditemType;
p.index = index+2;
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+void clif_parse_GMFullStrip(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/**
* Parses the (GM) right click option 'remove all equipment'
**/
@@ -17701,6 +18323,7 @@ void clif_parse_GMFullStrip(int fd, struct map_session_data *sd) {
pc->unequipitem(tsd, tsd->equip_index[i], PCUNEQUIPITEM_FORCE);
}
}
+
/**
* clif_delay_damage timer, sends the stored data and clears the memory afterwards
**/
@@ -17713,6 +18336,7 @@ int clif_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
+
/**
* Delays sending a damage packet in order to avoid the visual display to overlap
*
@@ -17785,17 +18409,24 @@ int clif_delay_damage(int64 tick, struct block_list *src, struct block_list *dst
return clif->calc_walkdelay(dst,ddelay,type,damage,div);
}
+
+void clif_parse_NPCShopClosed(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
/* Thanks to Yommy */
void clif_parse_NPCShopClosed(int fd, struct map_session_data *sd) {
/* TODO track the state <3~ */
sd->npc_shopid = 0;
}
+
/* NPC Market (by Ind after an extensive debugging of the packet, only possible thanks to Yommy <3) */
void clif_npc_market_open(struct map_session_data *sd, struct npc_data *nd) {
#if PACKETVER >= 20131223
- struct npc_item_list *shop = nd->u.scr.shop->item;
- unsigned short shop_size = nd->u.scr.shop->items, i, c;
+ struct npc_item_list *shop;
+ unsigned short shop_size, i, c;
+ nullpo_retv(sd);
+ nullpo_retv(nd);
+ shop = nd->u.scr.shop->item;
+ shop_size = nd->u.scr.shop->items;
npcmarket_open.PacketType = npcmarketopenType;
for(i = 0, c = 0; i < shop_size; i++) {
@@ -17815,14 +18446,19 @@ void clif_npc_market_open(struct map_session_data *sd, struct npc_data *nd) {
clif->send(&npcmarket_open,npcmarket_open.PacketLength,&sd->bl,SELF);
#endif
}
+
+void clif_parse_NPCMarketClosed(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_NPCMarketClosed(int fd, struct map_session_data *sd) {
/* TODO track the state <3~ */
sd->npc_shopid = 0;
}
+
void clif_npc_market_purchase_ack(struct map_session_data *sd, struct packet_npc_market_purchase *req, unsigned char response) {
#if PACKETVER >= 20131223
unsigned short c = 0;
+ nullpo_retv(sd);
+ nullpo_retv(req);
npcmarket_result.PacketType = npcmarketresultackType;
npcmarket_result.result = response == 0 ? 1 : 0;/* find other values */
@@ -17855,6 +18491,8 @@ void clif_npc_market_purchase_ack(struct map_session_data *sd, struct packet_npc
clif->send(&npcmarket_result,npcmarket_result.PacketLength,&sd->bl,SELF);
#endif
}
+
+void clif_parse_NPCMarketPurchase(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
void clif_parse_NPCMarketPurchase(int fd, struct map_session_data *sd) {
#if PACKETVER >= 20131223
struct packet_npc_market_purchase *p = P2PTR(fd);
@@ -17862,18 +18500,20 @@ void clif_parse_NPCMarketPurchase(int fd, struct map_session_data *sd) {
clif->npc_market_purchase_ack(sd,p,npc->market_buylist(sd,(p->PacketLength - 4) / sizeof(p->list[0]),p));
#endif
}
-
+
void clif_PartyLeaderChanged(struct map_session_data *sd, int prev_leader_aid, int new_leader_aid) {
struct packet_party_leader_changed p;
-
+
+ nullpo_retv(sd);
p.PacketType = partyleaderchangedType;
-
+
p.prev_leader_aid = prev_leader_aid;
p.new_leader_aid = new_leader_aid;
clif->send(&p,sizeof(p),&sd->bl,PARTY);
}
+void clif_parse_RouletteOpen(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/* Roulette System [Yommy/Hercules] */
void clif_parse_RouletteOpen(int fd, struct map_session_data* sd) {
struct packet_roulette_open_ack p;
@@ -17895,6 +18535,8 @@ void clif_parse_RouletteOpen(int fd, struct map_session_data* sd) {
clif->send(&p,sizeof(p), &sd->bl, SELF);
}
+
+void clif_parse_RouletteInfo(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
void clif_parse_RouletteInfo(int fd, struct map_session_data* sd) {
struct packet_roulette_info_ack p;
unsigned short i, j, count = 0;
@@ -17921,6 +18563,8 @@ void clif_parse_RouletteInfo(int fd, struct map_session_data* sd) {
clif->send(&p,sizeof(p), &sd->bl, SELF);
return;
}
+
+void clif_parse_RouletteClose(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
void clif_parse_RouletteClose(int fd, struct map_session_data* sd) {
if( !battle_config.feature_roulette ) {
@@ -17935,6 +18579,8 @@ void clif_parse_RouletteClose(int fd, struct map_session_data* sd) {
return;
}
+
+void clif_parse_RouletteGenerate(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
void clif_parse_RouletteGenerate(int fd, struct map_session_data* sd) {
unsigned char result = GENERATE_ROULETTE_SUCCESS;
short stage = sd->roulette.stage;
@@ -17989,6 +18635,8 @@ void clif_parse_RouletteGenerate(int fd, struct map_session_data* sd) {
if( result == GENERATE_ROULETTE_SUCCESS )
sd->roulette.stage++;
}
+
+void clif_parse_RouletteRecvItem(int fd, struct map_session_data* sd) __attribute__((nonnull (2)));
/**
* Request to cash in!
**/
@@ -18140,6 +18788,7 @@ bool clif_parse_roulette_db(void) {
void clif_roulette_generate_ack(struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, short bonusItemID) {
struct packet_roulette_generate_ack p;
+ nullpo_retv(sd);
p.PacketType = roulettgenerateackType;
p.Result = result;
p.Step = stage;
@@ -18161,6 +18810,7 @@ void clif_openmergeitem(int fd, struct map_session_data *sd)
struct merge_item merge_items[MAX_INVENTORY];
struct merge_item *merge_items_[MAX_INVENTORY] = {0};
+ nullpo_retv(sd);
memset(&merge_items,'\0',sizeof(merge_items));
for (i = 0; i < MAX_INVENTORY; i++) {
@@ -18207,8 +18857,10 @@ int clif_comparemergeitem(const void *a, const void *b)
const struct merge_item *a_ = a;
const struct merge_item *b_ = b;
+ nullpo_ret(a);
+ nullpo_ret(b);
if (a_->nameid == b_->nameid)
- return 0;
+ return 0;
return a_->nameid > b_->nameid ? -1 : 1;
}
@@ -18218,6 +18870,7 @@ void clif_ackmergeitems(int fd, struct map_session_data *sd)
int16 nameid = 0, indexes[MAX_INVENTORY] = {0}, amounts[MAX_INVENTORY] = {0};
struct item item_data;
+ nullpo_retv(sd);
length = (RFIFOW(fd,2) - 4)/2;
if (length >= MAX_INVENTORY || length < 2) {
@@ -18310,11 +18963,13 @@ unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) {
}
return (cmd ^ (((( clif->cryptKey[0] * clif->cryptKey[1] ) + clif->cryptKey[2]) >> 16) & 0x7FFF));
}
+
unsigned short clif_parse_cmd_normal( int fd, struct map_session_data *sd ) {
unsigned short cmd = RFIFOW(fd,0);
return cmd;
}
+
unsigned short clif_parse_cmd_decrypt( int fd, struct map_session_data *sd ) {
unsigned short cmd = RFIFOW(fd,0);
@@ -18322,6 +18977,7 @@ unsigned short clif_parse_cmd_decrypt( int fd, struct map_session_data *sd ) {
return cmd;
}
+
unsigned short clif_parse_cmd_optional( int fd, struct map_session_data *sd ) {
unsigned short cmd = RFIFOW(fd,0);
@@ -18631,6 +19287,8 @@ void clif_defaults(void) {
clif->dropitem = clif_dropitem;
clif->delitem = clif_delitem;
clif->takeitem = clif_takeitem;
+ clif->item_equip = clif_item_equip;
+ clif->item_normal = clif_item_normal;
clif->arrowequip = clif_arrowequip;
clif->arrow_fail = clif_arrow_fail;
clif->use_card = clif_use_card;
@@ -18641,7 +19299,7 @@ void clif_defaults(void) {
clif->useitemack = clif_useitemack;
clif->addcards = clif_addcards;
clif->addcards2 = clif_addcards2;
- clif->item_sub = clif_item_sub;
+ clif->item_sub = clif_item_sub; // look like unused
clif->getareachar_item = clif_getareachar_item;
clif->cart_additem_ack = clif_cart_additem_ack;
clif->cashshop_load = clif_cashshop_db;
@@ -18875,7 +19533,7 @@ void clif_defaults(void) {
clif->tradedeal_lock = clif_tradedeal_lock;
clif->tradecancelled = clif_tradecancelled;
clif->tradecompleted = clif_tradecompleted;
- clif->tradeundo = clif_tradeundo;
+ clif->tradeundo = clif_tradeundo; // unused
/* vending handling */
clif->openvendingreq = clif_openvendingreq;
clif->showvendingboard = clif_showvendingboard;
diff --git a/src/map/clif.h b/src/map/clif.h
index fdcc929e3..f6f0d4fe7 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -611,6 +611,8 @@ struct clif_interface {
void (*dropitem) (struct map_session_data *sd,int n,int amount);
void (*delitem) (struct map_session_data *sd,int n,int amount, short reason);
void (*takeitem) (struct block_list* src, struct block_list* dst);
+ void (*item_equip) (short idx, struct EQUIPITEM_INFO *p, struct item *i, struct item_data *id, int eqp_pos);
+ void (*item_normal) (short idx, struct NORMALITEM_INFO *p, struct item *i, struct item_data *id);
void (*arrowequip) (struct map_session_data *sd,int val);
void (*arrow_fail) (struct map_session_data *sd,int type);
void (*use_card) (struct map_session_data *sd,int idx);
diff --git a/src/map/duel.c b/src/map/duel.c
index 762745b75..21f5c0c93 100644
--- a/src/map/duel.c
+++ b/src/map/duel.c
@@ -10,6 +10,7 @@
#include "map/clif.h"
#include "map/pc.h"
#include "common/cbasetypes.h"
+#include "common/nullpo.h"
#include <stdio.h>
#include <stdlib.h>
@@ -44,12 +45,15 @@ int duel_checktime(struct map_session_data* sd) {
return !(diff >= 0 && diff < battle_config.duel_time_interval);
}
+
static int duel_showinfo_sub(struct map_session_data* sd, va_list va)
{
struct map_session_data *ssd = va_arg(va, struct map_session_data*);
int *p = va_arg(va, int*);
char output[256];
+ nullpo_retr(1, sd);
+ nullpo_retr(1, ssd);
if (sd->duel_group != ssd->duel_group) return 0;
sprintf(output, " %d. %s", ++(*p), sd->status.name);
@@ -81,6 +85,8 @@ int duel_create(struct map_session_data* sd, const unsigned int maxpl) {
int i=1;
char output[256];
+ nullpo_ret(sd);
+
while(i < MAX_DUEL && duel->list[i].members_count > 0) i++;
if(i == MAX_DUEL) return 0;
@@ -101,6 +107,8 @@ int duel_create(struct map_session_data* sd, const unsigned int maxpl) {
void duel_invite(const unsigned int did, struct map_session_data* sd, struct map_session_data* target_sd) {
char output[256];
+ nullpo_retv(sd);
+ nullpo_retv(target_sd);
// " -- Player %s invites %s to duel --"
sprintf(output, msg_sd(sd,373), sd->status.name, target_sd->status.name);
clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
@@ -116,6 +124,7 @@ void duel_invite(const unsigned int did, struct map_session_data* sd, struct map
static int duel_leave_sub(struct map_session_data* sd, va_list va)
{
int did = va_arg(va, int);
+ nullpo_ret(sd);
if (sd->duel_invite == did)
sd->duel_invite = 0;
return 0;
@@ -124,6 +133,7 @@ static int duel_leave_sub(struct map_session_data* sd, va_list va)
void duel_leave(const unsigned int did, struct map_session_data* sd) {
char output[256];
+ nullpo_retv(sd);
// " <- Player %s has left duel --"
sprintf(output, msg_sd(sd,375), sd->status.name);
clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
@@ -144,6 +154,7 @@ void duel_leave(const unsigned int did, struct map_session_data* sd) {
void duel_accept(const unsigned int did, struct map_session_data* sd) {
char output[256];
+ nullpo_retv(sd);
duel->list[did].members_count++;
sd->duel_group = sd->duel_invite;
duel->list[did].invites_count--;
@@ -160,6 +171,7 @@ void duel_accept(const unsigned int did, struct map_session_data* sd) {
void duel_reject(const unsigned int did, struct map_session_data* sd) {
char output[256];
+ nullpo_retv(sd);
// " -- Player %s has rejected duel --"
sprintf(output, msg_sd(sd,377), sd->status.name);
clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
diff --git a/src/map/guild.c b/src/map/guild.c
index 15c65ec98..ac9322b6b 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -740,7 +740,7 @@ void guild_member_joined(struct map_session_data *sd)
sd->guild = g;
if (channel->config->ally && channel->config->ally_autojoin) {
- channel->join(g->channel, sd, NULL, true);
+ channel->join(g->channel, sd, "", true);
}
}