summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c380
-rw-r--r--src/map/battleground.c4
-rw-r--r--src/map/chrif.c8
-rw-r--r--src/map/clif.c50
-rw-r--r--src/map/guild.c4
-rw-r--r--src/map/homunculus.c8
-rw-r--r--src/map/intif.c6
-rw-r--r--src/map/itemdb.c10
-rw-r--r--src/map/map.c4
-rw-r--r--src/map/mercenary.c4
-rw-r--r--src/map/mob.c22
-rw-r--r--src/map/npc.c10
-rw-r--r--src/map/pc.c40
-rw-r--r--src/map/pet.c2
-rw-r--r--src/map/quest.c2
-rw-r--r--src/map/script.c96
-rw-r--r--src/map/trade.c6
-rw-r--r--src/map/vending.c2
18 files changed, 329 insertions, 329 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 6f008c3af..aa77fcf0e 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -112,7 +112,7 @@ static char* player_title_txt(int level)
: (level >= battle_config.title_lvl2) ? msg_txt(326)
: (level >= battle_config.title_lvl1) ? msg_txt(325)
: "";
- sprintf(atcmd_temp, format, level);
+ snprintf(atcmd_temp, sizeof atcmd_temp, format, level);
return atcmd_temp;
}
@@ -197,7 +197,7 @@ ACMD_FUNC(send)
#define PARSE_ERROR(error,p) \
{\
clif_displaymessage(fd, (error));\
- sprintf(atcmd_output, ">%s", (p));\
+ snprintf(atcmd_output, sizeof atcmd_output, ">%s", (p));\
clif_displaymessage(fd, atcmd_output);\
}
//define PARSE_ERROR
@@ -229,7 +229,7 @@ ACMD_FUNC(send)
if(len)
{// show packet length
- sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
+ snprintf(atcmd_output, sizeof atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -238,7 +238,7 @@ ACMD_FUNC(send)
off=2;
if(len == 0)
{// unknown packet - ERROR
- sprintf(atcmd_output, "Unknown packet: 0x%x", type);
+ snprintf(atcmd_output, sizeof atcmd_output, "Unknown packet: 0x%x", type);
clif_displaymessage(fd, atcmd_output);
return -1;
} else if(len == -1)
@@ -399,7 +399,7 @@ ACMD_FUNC(send)
clif_displaymessage(fd, msg_txt(259)); // Invalid packet
return -1;
}
- sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
clif_displaymessage(fd, atcmd_output);
return 0;
#undef PARSE_ERROR
@@ -536,7 +536,7 @@ ACMD_FUNC(jumpto)
}
pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
- sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
clif_displaymessage(fd, atcmd_output);
return 0;
@@ -573,7 +573,7 @@ ACMD_FUNC(jump)
}
pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
- sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -617,21 +617,21 @@ ACMD_FUNC(who3)
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
- sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
+ snprintf(atcmd_output, sizeof atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
} else {
atcmd_output[0]=0;
}
//Player name
- sprintf(temp0, msg_txt(333), pl_sd->status.name);
+ snprintf(temp0, sizeof temp0, msg_txt(333), pl_sd->status.name);
strcat(atcmd_output,temp0);
//Player title, if exists
if (pl_GM_level > 0) {
- //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
- sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
+ //snprintf(temp0, sizeof temp0, "(%s) ", player_title_txt(pl_GM_level) );
+ snprintf(temp0, sizeof temp0, msg_txt(334), player_title_txt(pl_GM_level) );
strcat(atcmd_output,temp0);
}
//Players Location: map x y
- sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ snprintf(temp0, sizeof temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
strcat(atcmd_output,temp0);
clif_displaymessage(fd, atcmd_output);
@@ -646,7 +646,7 @@ ACMD_FUNC(who3)
else if (count == 1)
clif_displaymessage(fd, msg_txt(29)); // 1 player found.
else {
- sprintf(atcmd_output, msg_txt(30), count); // %d players found.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(30), count); // %d players found.
clif_displaymessage(fd, atcmd_output);
}
@@ -691,17 +691,17 @@ ACMD_FUNC(who2)
player_name[j] = TOLOWER(player_name[j]);
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
//Players Name
- //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
- sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
+ //snprintf(atcmd_output, sizeof atcmd_output, "Name: %s ", pl_sd->status.name);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(333), pl_sd->status.name);
//Player title, if exists
if (pl_GM_level > 0) {
- //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
- sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
+ //snprintf(temp0, sizeof temp0, "(%s) ", player_title_txt(pl_GM_level) );
+ snprintf(temp0, sizeof temp0, msg_txt(334), player_title_txt(pl_GM_level) );
strcat(atcmd_output,temp0);
}
//Players Base Level / Job name
- //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
- sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
+ //snprintf(temp0, sizeof temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
+ snprintf(temp0, sizeof temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
strcat(atcmd_output,temp0);
clif_displaymessage(fd, atcmd_output);
@@ -716,7 +716,7 @@ ACMD_FUNC(who2)
else if (count == 1)
clif_displaymessage(fd, msg_txt(29)); // 1 player found.
else {
- sprintf(atcmd_output, msg_txt(30), count); // %d players found.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(30), count); // %d players found.
clif_displaymessage(fd, atcmd_output);
}
@@ -766,22 +766,22 @@ ACMD_FUNC(who)
g = guild_search(pl_sd->status.guild_id);
p = party_search(pl_sd->status.party_id);
//Players Name
- sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(333), pl_sd->status.name);
//Player title, if exists
if (pl_GM_level > 0) {
- sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
+ snprintf(temp0, sizeof temp0, msg_txt(334), player_title_txt(pl_GM_level) );
strcat(atcmd_output,temp0);
}
//Players Party if exists
if (p != NULL) {
- //sprintf(temp0," | Party: '%s'", p->name);
- sprintf(temp0, msg_txt(335), p->party.name);
+ //snprintf(temp0, sizeof temp0, " | Party: '%s'", p->name);
+ snprintf(temp0, sizeof temp0, msg_txt(335), p->party.name);
strcat(atcmd_output,temp0);
}
//Players Guild if exists
if (g != NULL) {
- //sprintf(temp0," | Guild: '%s'", g->name);
- sprintf(temp0, msg_txt(336), g->name);
+ //snprintf(temp0, sizeof temp0, " | Guild: '%s'", g->name);
+ snprintf(temp0, sizeof temp0, msg_txt(336), g->name);
strcat(atcmd_output,temp0);
}
clif_displaymessage(fd, atcmd_output);
@@ -796,7 +796,7 @@ ACMD_FUNC(who)
else if (count == 1)
clif_displaymessage(fd, msg_txt(29)); // 1 player found.
else {
- sprintf(atcmd_output, msg_txt(30), count); // %d players found.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(30), count); // %d players found.
clif_displaymessage(fd, atcmd_output);
}
@@ -839,20 +839,20 @@ ACMD_FUNC(whomap3)
continue;
if (pl_GM_level > 0)
- sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ snprintf(atcmd_output, sizeof atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
else
- sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ snprintf(atcmd_output, sizeof atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, atcmd_output);
count++;
}
mapit_free(iter);
if (count == 0)
- sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
else if (count == 1)
- sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
else {
- sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
}
clif_displaymessage(fd, atcmd_output);
@@ -897,20 +897,20 @@ ACMD_FUNC(whomap2)
continue;
if (pl_GM_level > 0)
- sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
+ snprintf(atcmd_output, sizeof atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
else
- sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
+ snprintf(atcmd_output, sizeof atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
clif_displaymessage(fd, atcmd_output);
count++;
}
mapit_free(iter);
if (count == 0)
- sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
else if (count == 1)
- sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
else {
- sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
}
clif_displaymessage(fd, atcmd_output);
@@ -962,29 +962,29 @@ ACMD_FUNC(whomap)
g = guild_search(pl_sd->status.guild_id);
if (g == NULL)
- sprintf(temp1, "None");
+ snprintf(temp1, sizeof temp1, "None");
else
- sprintf(temp1, "%s", g->name);
+ snprintf(temp1, sizeof temp1, "%s", g->name);
p = party_search(pl_sd->status.party_id);
if (p == NULL)
- sprintf(temp0, "None");
+ snprintf(temp0, sizeof temp0, "None");
else
- sprintf(temp0, "%s", p->party.name);
+ snprintf(temp0, sizeof temp0, "%s", p->party.name);
if (pl_GM_level > 0)
- sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
+ snprintf(atcmd_output, sizeof atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
else
- sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
+ snprintf(atcmd_output, sizeof atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
clif_displaymessage(fd, atcmd_output);
count++;
}
mapit_free(iter);
if (count == 0)
- sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
else if (count == 1)
- sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
else {
- sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
}
clif_displaymessage(fd, atcmd_output);
@@ -1038,18 +1038,18 @@ ACMD_FUNC(whogm)
if (pl_GM_level > GM_level) {
if (pl_sd->sc.option & OPTION_INVISIBLE)
continue;
- sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
+ snprintf(atcmd_output, sizeof atcmd_output, "Name: %s (GM)", pl_sd->status.name);
clif_displaymessage(fd, atcmd_output);
count++;
continue;
}
- sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
+ snprintf(atcmd_output, sizeof atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
pl_sd->status.name, pl_GM_level,
mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
+ snprintf(atcmd_output, sizeof atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
pl_sd->status.base_level,
job_name(pl_sd->status.class_), pl_sd->status.job_level);
clif_displaymessage(fd, atcmd_output);
@@ -1057,7 +1057,7 @@ ACMD_FUNC(whogm)
p = party_search(pl_sd->status.party_id);
g = guild_search(pl_sd->status.guild_id);
- sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
+ snprintf(atcmd_output, sizeof atcmd_output," Party: '%s' | Guild: '%s'",
p?p->party.name:"None", g?g->name:"None");
clif_displaymessage(fd, atcmd_output);
@@ -1070,7 +1070,7 @@ ACMD_FUNC(whogm)
else if (count == 1)
clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
else {
- sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(152), count); // %d GMs found.
clif_displaymessage(fd, atcmd_output);
}
@@ -1132,7 +1132,7 @@ ACMD_FUNC(speed)
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
- sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
+ snprintf(atcmd_output, sizeof atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -2052,7 +2052,7 @@ ACMD_FUNC(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, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
+ snprintf(atcmd_output, sizeof atcmd_output, "Please, enter at least a 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_displaymessage(fd, atcmd_output);
return -1;
@@ -2084,7 +2084,7 @@ ACMD_FUNC(dye)
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
- sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
+ snprintf(atcmd_output, sizeof atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -2111,7 +2111,7 @@ ACMD_FUNC(hair_style)
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
- sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
+ snprintf(atcmd_output, sizeof atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -2138,7 +2138,7 @@ ACMD_FUNC(hair_color)
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
- sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
+ snprintf(atcmd_output, sizeof atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -2399,7 +2399,7 @@ ACMD_FUNC(monster)
if (number == count)
clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
else {
- sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
clif_displaymessage(fd, atcmd_output);
}
else {
@@ -2635,25 +2635,25 @@ ACMD_FUNC(refine)
if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
- sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Right Hand", EQP_HAND_R);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Garment", EQP_GARMENT);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Left Accessory", EQP_ACC_L);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Body Armor", EQP_ARMOR);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Left Hand", EQP_HAND_L);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Shoes", EQP_SHOES);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Right Accessory", EQP_ACC_R);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
+ snprintf(atcmd_output, sizeof atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -2693,7 +2693,7 @@ ACMD_FUNC(refine)
else if (count == 1)
clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
else {
- sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(168), count); // %d items have been refined.
clif_displaymessage(fd, atcmd_output);
}
@@ -2755,7 +2755,7 @@ ACMD_FUNC(produce)
if ((flag = pc_additem(sd, &tmp_item, 1)))
clif_additem(sd, 0, 0, flag);
} else {
- sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -2780,9 +2780,9 @@ ACMD_FUNC(memo)
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);
+ snprintf(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_txt(171), i); // %d - void
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(171), i); // %d - void
clif_displaymessage(sd->fd, atcmd_output);
}
return 0;
@@ -2790,7 +2790,7 @@ ACMD_FUNC(memo)
if( position < 0 || position >= MAX_MEMOPOINTS )
{
- sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
+ snprintf(atcmd_output, sizeof atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -2810,7 +2810,7 @@ ACMD_FUNC(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",
+ snprintf(atcmd_output, sizeof atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
map[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),
@@ -2989,7 +2989,7 @@ ACMD_FUNC(param)
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
- sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
+ snprintf(atcmd_output, sizeof atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -2997,7 +2997,7 @@ ACMD_FUNC(param)
ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
- sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
+ snprintf(atcmd_output, sizeof atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -3330,7 +3330,7 @@ ACMD_FUNC(recall)
return -1;
}
pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
- sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
clif_displaymessage(fd, atcmd_output);
return 0;
@@ -3940,19 +3940,19 @@ ACMD_FUNC(idsearch)
return -1;
}
- sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
clif_displaymessage(fd, atcmd_output);
match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
if (match > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(269), MAX_SEARCH, match);
clif_displaymessage(fd, atcmd_output);
match = MAX_SEARCH;
}
for(i = 0; i < match; i++) {
- sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
clif_displaymessage(fd, atcmd_output);
}
- sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(79), match); // It is %d affair above.
clif_displaymessage(fd, atcmd_output);
return 0;
@@ -3996,7 +3996,7 @@ ACMD_FUNC(recallall)
clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
if (count) {
- sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
+ snprintf(atcmd_output, sizeof atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
clif_displaymessage(fd, atcmd_output);
}
@@ -4052,10 +4052,10 @@ ACMD_FUNC(guildrecall)
}
mapit_free(iter);
- sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
clif_displaymessage(fd, atcmd_output);
if (count) {
- sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
+ snprintf(atcmd_output, sizeof atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
clif_displaymessage(fd, atcmd_output);
}
@@ -4111,10 +4111,10 @@ ACMD_FUNC(partyrecall)
}
mapit_free(iter);
- sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
clif_displaymessage(fd, atcmd_output);
if (count) {
- sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
+ snprintf(atcmd_output, sizeof atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
clif_displaymessage(fd, atcmd_output);
}
@@ -4322,7 +4322,7 @@ ACMD_FUNC(mapinfo)
chat_num++;
mapit_free(iter);
- sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
+ snprintf(atcmd_output, sizeof atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
clif_displaymessage(fd, atcmd_output);
clif_displaymessage(fd, "------ Map Flags ------");
if (map[m_id].flag.town)
@@ -4377,16 +4377,16 @@ ACMD_FUNC(mapinfo)
strcat(atcmd_output, "NoMemo | ");
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
+ snprintf(atcmd_output, sizeof atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
clif_displaymessage(fd, atcmd_output);
if (map[m_id].flag.nosave) {
if (!map[m_id].save.map)
- sprintf(atcmd_output, "No Save (Return to last Save Point)");
+ snprintf(atcmd_output, sizeof atcmd_output, "No Save (Return to last Save Point)");
else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
- sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
+ snprintf(atcmd_output, sizeof atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
else
- sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
+ snprintf(atcmd_output, sizeof atcmd_output, "No Save, Save Point: %s,%d,%d",
mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
clif_displaymessage(fd, atcmd_output);
}
@@ -4456,7 +4456,7 @@ ACMD_FUNC(mapinfo)
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, "Player '%s' (session #%d) | Location: %d,%d",
+ snprintf(atcmd_output, sizeof atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, atcmd_output);
}
@@ -4480,7 +4480,7 @@ ACMD_FUNC(mapinfo)
case 9: strcpy(direction, "North"); break;
default: strcpy(direction, "Unknown"); break;
}
- sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
+ snprintf(atcmd_output, sizeof atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
clif_displaymessage(fd, atcmd_output);
}
@@ -4494,10 +4494,10 @@ ACMD_FUNC(mapinfo)
pl_sd->mapindex == m_index &&
cd->usersd[0] == pl_sd)
{
- sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
+ snprintf(atcmd_output, sizeof atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
+ snprintf(atcmd_output, sizeof atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
clif_displaymessage(fd, atcmd_output);
}
@@ -4569,11 +4569,11 @@ ACMD_FUNC(guildspy)
(g = guild_search(atoi(message))) != NULL) {
if (sd->guildspy == g->guild_id) {
sd->guildspy = 0;
- sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
clif_displaymessage(fd, atcmd_output);
} else {
sd->guildspy = g->guild_id;
- sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
clif_displaymessage(fd, atcmd_output);
}
} else {
@@ -4611,11 +4611,11 @@ ACMD_FUNC(partyspy)
(p = party_search(atoi(message))) != NULL) {
if (sd->partyspy == p->party.party_id) {
sd->partyspy = 0;
- sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
clif_displaymessage(fd, atcmd_output);
} else {
sd->partyspy = p->party.party_id;
- sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
clif_displaymessage(fd, atcmd_output);
}
} else {
@@ -4838,21 +4838,21 @@ char* txt_time(unsigned int duration)
seconds = duration - (60 * minutes);
if (days < 2)
- sprintf(temp, msg_txt(219), days); // %d day
+ snprintf(temp, sizeof temp, msg_txt(219), days); // %d day
else
- sprintf(temp, msg_txt(220), days); // %d days
+ snprintf(temp, sizeof temp, msg_txt(220), days); // %d days
if (hours < 2)
- sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
+ snprintf(temp1, sizeof temp1, msg_txt(221), temp, hours); // %s %d hour
else
- sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
+ snprintf(temp1, sizeof temp1, msg_txt(222), temp, hours); // %s %d hours
if (minutes < 2)
- sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
+ snprintf(temp, sizeof temp, msg_txt(223), temp1, minutes); // %s %d minute
else
- sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
+ snprintf(temp, sizeof temp, msg_txt(224), temp1, minutes); // %s %d minutes
if (seconds < 2)
- sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
+ snprintf(temp1, sizeof temp1, msg_txt(225), temp, seconds); // %s and %d second
else
- sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
+ snprintf(temp1, sizeof temp1, msg_txt(226), temp, seconds); // %s and %d seconds
return temp1;
}
@@ -4874,7 +4874,7 @@ ACMD_FUNC(servertime)
time(&time_server); // get time in seconds since 1/1/1970
datetime = localtime(&time_server); // convert seconds in structure
- // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
+ // like snprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
clif_displaymessage(fd, temp);
@@ -4886,7 +4886,7 @@ ACMD_FUNC(servertime)
} else if (battle_config.night_duration == 0)
if (night_flag == 1) { // we start with night
timer_data = get_timer(day_timer_tid);
- sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
+ snprintf(temp, sizeof temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
clif_displaymessage(fd, temp);
clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
} else
@@ -4894,7 +4894,7 @@ ACMD_FUNC(servertime)
else if (battle_config.day_duration == 0)
if (night_flag == 0) { // we start with day
timer_data = get_timer(night_timer_tid);
- sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
+ snprintf(temp, sizeof temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
clif_displaymessage(fd, temp);
clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
} else
@@ -4903,26 +4903,26 @@ ACMD_FUNC(servertime)
if (night_flag == 0) {
timer_data = get_timer(night_timer_tid);
timer_data2 = get_timer(day_timer_tid);
- sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
+ snprintf(temp, sizeof temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
clif_displaymessage(fd, temp);
if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
- sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
+ snprintf(temp, sizeof temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
else
- sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
+ snprintf(temp, sizeof temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
clif_displaymessage(fd, temp);
- sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
+ snprintf(temp, sizeof temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
clif_displaymessage(fd, temp);
} else {
timer_data = get_timer(day_timer_tid);
timer_data2 = get_timer(night_timer_tid);
- sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
+ snprintf(temp, sizeof temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
clif_displaymessage(fd, temp);
if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
- sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
+ snprintf(temp, sizeof temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
else
- sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
+ snprintf(temp, sizeof temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
clif_displaymessage(fd, temp);
- sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
+ snprintf(temp, sizeof temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
clif_displaymessage(fd, temp);
}
}
@@ -5136,9 +5136,9 @@ ACMD_FUNC(jailfor)
clif_displaymessage(fd, msg_txt(121)); // Player unjailed
} else {
get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
- sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
+ snprintf(atcmd_output, sizeof atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
clif_displaymessage(pl_sd->fd, atcmd_output);
- sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
+ snprintf(atcmd_output, sizeof atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
clif_displaymessage(fd, atcmd_output);
}
} else if (jailtime < 0) {
@@ -5188,7 +5188,7 @@ ACMD_FUNC(jailtime)
//Get remaining jail time
get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
- sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
+ snprintf(atcmd_output, sizeof atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
clif_displaymessage(fd, atcmd_output);
@@ -5327,7 +5327,7 @@ ACMD_FUNC(exp)
if (nextj)
nextj = sd->status.job_exp*100.0/nextj;
- sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
+ snprintf(output, sizeof output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
clif_displaymessage(fd, output);
return 0;
}
@@ -5347,7 +5347,7 @@ ACMD_FUNC(broadcast)
return -1;
}
- sprintf(atcmd_output, "%s: %s", sd->status.name, message);
+ snprintf(atcmd_output, sizeof atcmd_output, "%s: %s", sd->status.name, message);
intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
return 0;
@@ -5367,7 +5367,7 @@ ACMD_FUNC(localbroadcast)
return -1;
}
- sprintf(atcmd_output, "%s: %s", sd->status.name, message);
+ snprintf(atcmd_output, sizeof atcmd_output, "%s: %s", sd->status.name, message);
clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
@@ -5547,7 +5547,7 @@ ACMD_FUNC(addwarp)
m = mapindex_name2id(mapname);
if( m == 0 )
{
- sprintf(atcmd_output, "Unknown map '%s'.", mapname);
+ snprintf(atcmd_output, sizeof atcmd_output, "Unknown map '%s'.", mapname);
clif_displaymessage(fd, atcmd_output);
return -1;
}
@@ -5556,7 +5556,7 @@ ACMD_FUNC(addwarp)
if( nd == NULL )
return -1;
- sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
+ snprintf(atcmd_output, sizeof atcmd_output, "New warp NPC '%s' created.", nd->exname);
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -5665,7 +5665,7 @@ ACMD_FUNC(skillid)
for (idx = 0; idx < MAX_SKILL_DB; idx++) {
if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
{
- sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
+ snprintf(atcmd_output, sizeof atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
clif_displaymessage(fd, atcmd_output);
}
}
@@ -5772,13 +5772,13 @@ ACMD_FUNC(skilltree)
tbl = job_name(c);
- sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", tbl, pc_checkskill(pl_sd, 1));
+ snprintf(atcmd_output, sizeof atcmd_output, "Player is using %s skill tree (%d basic points)", tbl, pc_checkskill(pl_sd, 1));
clif_displaymessage(fd, atcmd_output);
ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
{
- sprintf(atcmd_output, "I do not believe the player can use that skill");
+ snprintf(atcmd_output, sizeof atcmd_output, "I do not believe the player can use that skill");
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -5790,13 +5790,13 @@ ACMD_FUNC(skilltree)
{
if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
{
- sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
+ snprintf(atcmd_output, sizeof atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
clif_displaymessage(fd, atcmd_output);
meets = 0;
}
}
if (meets == 1) {
- sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
+ snprintf(atcmd_output, sizeof atcmd_output, "I believe the player meets all the requirements for that skill");
clif_displaymessage(fd, atcmd_output);
}
@@ -5845,13 +5845,13 @@ ACMD_FUNC(marry)
}
if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
- sprintf(player2, "Cannot find player '%s' online", player1);
+ snprintf(player2, sizeof player2, "Cannot find player '%s' online", player1);
clif_displaymessage(fd, player2);
return -1;
}
if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
- sprintf(player1, "Cannot find player '%s' online", player2);
+ snprintf(player1, sizeof player1, "Cannot find player '%s' online", player2);
clif_displaymessage(fd, player1);
return -1;
}
@@ -5891,12 +5891,12 @@ ACMD_FUNC(divorce)
}
if (pc_divorce(pl_sd) != 0) {
- sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
+ snprintf(atcmd_output, sizeof atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
clif_displaymessage(fd, atcmd_output);
return -1;
}
- sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
+ snprintf(atcmd_output, sizeof atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -6122,7 +6122,7 @@ ACMD_FUNC(autolootitem)
sd->state.autolootid = item_data->nameid; // Autoloot Activated
- sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
+ snprintf(atcmd_output, sizeof atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
item_data->name, item_data->jname, item_data->nameid);
clif_displaymessage(fd, atcmd_output);
@@ -6540,7 +6540,7 @@ ACMD_FUNC(reset)
{
pc_resetstate(sd);
pc_resetskill(sd,1);
- sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -6946,7 +6946,7 @@ ACMD_FUNC(mobinfo)
}
if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(269), MAX_SEARCH, count);
clif_displaymessage(fd, atcmd_output);
count = MAX_SEARCH;
}
@@ -6955,18 +6955,18 @@ ACMD_FUNC(mobinfo)
// stats
if (mob->mexp)
- sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
+ snprintf(atcmd_output, sizeof atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
else
- sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
+ snprintf(atcmd_output, sizeof atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
+ snprintf(atcmd_output, sizeof atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
+ snprintf(atcmd_output, sizeof atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
+ snprintf(atcmd_output, sizeof atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
mob->range2 , mob->range3, msize[mob->status.size],
mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
@@ -6979,9 +6979,9 @@ ACMD_FUNC(mobinfo)
if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
continue;
if (item_data->slot)
- sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
+ snprintf(atcmd_output2, sizeof atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
else
- sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
+ snprintf(atcmd_output2, sizeof atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
strcat(atcmd_output, atcmd_output2);
if (++j % 3 == 0) {
clif_displaymessage(fd, atcmd_output);
@@ -6994,7 +6994,7 @@ ACMD_FUNC(mobinfo)
clif_displaymessage(fd, atcmd_output);
// mvp
if (mob->mexp) {
- sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
+ snprintf(atcmd_output, sizeof atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
clif_displaymessage(fd, atcmd_output);
strcpy(atcmd_output, " MVP Items:");
j = 0;
@@ -7004,9 +7004,9 @@ ACMD_FUNC(mobinfo)
if (mob->mvpitem[i].p > 0) {
j++;
if (j == 1)
- sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
+ snprintf(atcmd_output2, sizeof atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
else
- sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
+ snprintf(atcmd_output2, sizeof atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
strcat(atcmd_output, atcmd_output2);
}
}
@@ -7406,26 +7406,26 @@ ACMD_FUNC(iteminfo)
}
if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
clif_displaymessage(fd, atcmd_output);
count = MAX_SEARCH;
}
for (i = 0; i < count; i++) {
item_data = item_array[i];
- sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
+ snprintf(atcmd_output, sizeof atcmd_output, "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)? "None" : "With script"
);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
+ snprintf(atcmd_output, sizeof atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
clif_displaymessage(fd, atcmd_output);
if (item_data->maxchance == 10000)
strcpy(atcmd_output, " - Available in the shops only");
else if (item_data->maxchance)
- sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
+ snprintf(atcmd_output, sizeof atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
else
strcpy(atcmd_output, " - Monsters don't drop this item");
clif_displaymessage(fd, atcmd_output);
@@ -7455,25 +7455,25 @@ ACMD_FUNC(whodrops)
}
if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
clif_displaymessage(fd, atcmd_output);
count = MAX_SEARCH;
}
for (i = 0; i < count; i++) {
item_data = item_array[i];
- sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
+ snprintf(atcmd_output, sizeof atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
clif_displaymessage(fd, atcmd_output);
if (item_data->mob[0].chance == 0) {
strcpy(atcmd_output, " - Item is not dropped by mobs.");
clif_displaymessage(fd, atcmd_output);
} else {
- sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
+ snprintf(atcmd_output, sizeof atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
clif_displaymessage(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.);
+ snprintf(atcmd_output, sizeof atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
clif_displaymessage(fd, atcmd_output);
}
}
@@ -7506,7 +7506,7 @@ ACMD_FUNC(whereis)
}
if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(269), MAX_SEARCH, count);
clif_displaymessage(fd, atcmd_output);
count = MAX_SEARCH;
}
@@ -7550,19 +7550,19 @@ ACMD_FUNC(adopt)
ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
- sprintf(output, "Cannot find player %s online", player1);
+ snprintf(output, sizeof output, "Cannot find player %s online", player1);
clif_displaymessage(fd, output);
return -1;
}
if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
- sprintf(output, "Cannot find player %s online", player2);
+ snprintf(output, sizeof output, "Cannot find player %s online", player2);
clif_displaymessage(fd, output);
return -1;
}
if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
- sprintf(output, "Cannot find player %s online", player3);
+ snprintf(output, sizeof output, "Cannot find player %s online", player3);
clif_displaymessage(fd, output);
return -1;
}
@@ -7580,7 +7580,7 @@ ACMD_FUNC(version)
const char * revision;
if ((revision = get_svn_revision()) != 0) {
- sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
+ snprintf(atcmd_output, sizeof atcmd_output,"eAthena Version SVN r%s",revision);
clif_displaymessage(fd,atcmd_output);
} else
clif_displaymessage(fd,"Cannot determine SVN revision");
@@ -7677,7 +7677,7 @@ ACMD_FUNC(me)
return -1;
}
- sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
clif_disp_overhead(sd, atcmd_output);
return 0;
@@ -7858,7 +7858,7 @@ ACMD_FUNC(invite)
if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
{
- sprintf(atcmd_output, msg_txt(364), message);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(364), message);
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -7888,7 +7888,7 @@ ACMD_FUNC(duel)
if(!duel_checktime(sd)) {
// "Duel: You can take part in duel only one time per %d minutes."
- sprintf(output, msg_txt(356), battle_config.duel_time_interval);
+ snprintf(output, sizeof output, msg_txt(356), battle_config.duel_time_interval);
clif_displaymessage(fd, output);
return 0;
}
@@ -7943,7 +7943,7 @@ ACMD_FUNC(accept)
if(!duel_checktime(sd)) {
// "Duel: You can take part in duel only one time per %d minutes."
- sprintf(output, msg_txt(356), battle_config.duel_time_interval);
+ snprintf(output, sizeof output, msg_txt(356), battle_config.duel_time_interval);
clif_displaymessage(fd, output);
return 0;
}
@@ -8111,7 +8111,7 @@ ACMD_FUNC(main)
clif_displaymessage(fd, msg_txt(387));
return -1;
}
- sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(386), sd->status.name, message);
// I use 0xFE000000 color for signalizing that this message is
// main chat message. 0xFE000000 is invalid color, same using
// 0xFF000000 for simple (not colored) GM messages. [LuzZza]
@@ -8160,7 +8160,7 @@ ACMD_FUNC(request)
return -1;
}
- sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(278), message); // (@request): %s
intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
@@ -8201,27 +8201,27 @@ ACMD_FUNC(ksprotection)
if( sd->state.noks ) {
sd->state.noks = 0;
- sprintf(atcmd_output, "[ K.S Protection Inactive ]");
+ snprintf(atcmd_output, sizeof atcmd_output, "[ K.S Protection Inactive ]");
}
else
{
if( !message || !*message || !strcmpi(message, "party") )
{ // Default is Party
sd->state.noks = 2;
- sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
+ snprintf(atcmd_output, sizeof atcmd_output, "[ K.S Protection Active - Option: Party ]");
}
else if( !strcmpi(message, "self") )
{
sd->state.noks = 1;
- sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
+ snprintf(atcmd_output, sizeof atcmd_output, "[ K.S Protection Active - Option: Self ]");
}
else if( !strcmpi(message, "guild") )
{
sd->state.noks = 3;
- sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
+ snprintf(atcmd_output, sizeof atcmd_output, "[ K.S Protection Active - Option: Guild ]");
}
else
- sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
+ snprintf(atcmd_output, sizeof atcmd_output, "Usage: @noks <self|party|guild>");
}
clif_displaymessage(fd, atcmd_output);
@@ -8236,10 +8236,10 @@ ACMD_FUNC(allowks)
if( map[sd->bl.m].flag.allowks ) {
map[sd->bl.m].flag.allowks = 0;
- sprintf(atcmd_output, "[ Map K.S Protection Active ]");
+ snprintf(atcmd_output, sizeof atcmd_output, "[ Map K.S Protection Active ]");
} else {
map[sd->bl.m].flag.allowks = 1;
- sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
+ snprintf(atcmd_output, sizeof atcmd_output, "[ Map K.S Protection Inactive ]");
}
clif_displaymessage(fd, atcmd_output);
@@ -8251,7 +8251,7 @@ ACMD_FUNC(resetstat)
nullpo_retr(-1, sd);
pc_resetstate(sd);
- sprintf(atcmd_output, msg_txt(207), sd->status.name);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(207), sd->status.name);
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -8261,7 +8261,7 @@ ACMD_FUNC(resetskill)
nullpo_retr(-1,sd);
pc_resetskill(sd,1);
- sprintf(atcmd_output, msg_txt(206), sd->status.name);
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(206), sd->status.name);
clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -8480,13 +8480,13 @@ ACMD_FUNC(stats)
output_table[13].value = sd->status.skill_point;
output_table[14].value = sd->change_level;
- sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
- sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
+ snprintf(job_jobname, sizeof job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
+ snprintf(output, sizeof output, msg_txt(53), sd->status.name); // '%s' stats:
clif_displaymessage(fd, output);
for (i = 0; output_table[i].format != NULL; i++) {
- sprintf(output, output_table[i].format, output_table[i].value);
+ snprintf(output, sizeof output, output_table[i].format, output_table[i].value);
clif_displaymessage(fd, output);
}
@@ -8532,12 +8532,12 @@ ACMD_FUNC(delitem)
count++;
item_position = pc_search_inventory(sd, item_id); // for next loop
}
- sprintf(output, msg_txt(113), count); // %d item(s) removed by a GM.
+ snprintf(output, sizeof output, msg_txt(113), count); // %d item(s) removed by a GM.
clif_displaymessage(sd->fd, output);
if (number == count)
- sprintf(output, msg_txt(114), count); // %d item(s) removed from the player.
+ snprintf(output, sizeof output, msg_txt(114), count); // %d item(s) removed from the player.
else
- sprintf(output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
+ snprintf(output, sizeof output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
clif_displaymessage(fd, output);
} else {
clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
@@ -8988,7 +8988,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) )
{
- sprintf(output, "%s failed. Player not found.", command);
+ snprintf(output, sizeof output, "%s failed. Player not found.", command);
clif_displaymessage(fd, output);
return true;
}
@@ -8997,21 +8997,21 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
//can be looked at by the actual command function since most scan to see if the
//right parameters are used.
if ( x > 2 ) {
- sprintf(atcmd_msg, "%s %s", command, params);
+ snprintf(atcmd_msg, sizeof atcmd_msg, "%s %s", command, params);
break;
}
else if ( y > 2 ) {
- sprintf(atcmd_msg, "%s %s", command, params2);
+ snprintf(atcmd_msg, sizeof atcmd_msg, "%s %s", command, params2);
break;
}
//Regardless of what style the #command is used, if it's correct, it will always have
//this value if there is no parameter. Send it as just the #command
else if ( z == 2 ) {
- sprintf(atcmd_msg, "%s", command);
+ snprintf(atcmd_msg, sizeof atcmd_msg, "%s", command);
break;
}
- sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
+ snprintf(output, sizeof output, "Charcommand failed. Usage: #<command> <char name> <params>.");
clif_displaymessage(fd, output);
return true;
}
@@ -9020,7 +9020,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
//atcmd_msg is constructed above differently for charcommands
//it's copied from message if not a charcommand so it can
//pass through the rest of the code compatible with both symbols
- sprintf(atcmd_msg, "%s", message);
+ snprintf(atcmd_msg, sizeof atcmd_msg, "%s", message);
}
//Clearing these to be used once more.
@@ -9035,7 +9035,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
info = get_atcommandinfo_byname(command);
if( info == NULL || info->func == NULL || ( type && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2)) ) )
{
- sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
+ snprintf(output, sizeof output, msg_txt(153), command); // "%s is Unknown Command."
clif_displaymessage(fd, output);
return true;
}
@@ -9044,7 +9044,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
{
- sprintf(output,msg_txt(154), command); // %s failed.
+ snprintf(output, sizeof output, msg_txt(154), command); // %s failed.
clif_displaymessage(fd, output);
}
if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
@@ -9182,7 +9182,7 @@ ACMD_FUNC(commands)
}
clif_displaymessage(fd,line_buff);
- sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(274), count); // "%d commands found."
clif_displaymessage(fd, atcmd_output);
return 0;
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 1c2a90d90..0adacec53 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -127,9 +127,9 @@ int bg_team_leave(struct map_session_data *sd, int flag)
bg->count--;
if( flag )
- sprintf(output, "Server : %s has quit the game...", sd->status.name);
+ snprintf(output, sizeof output, "Server : %s has quit the game...", sd->status.name);
else
- sprintf(output, "Server : %s is leaving the battlefield...", sd->status.name);
+ snprintf(output, sizeof output, "Server : %s is leaving the battlefield...", sd->status.name);
clif_bg_message(bg, "Server", output, strlen(output) + 1);
if( bg->logout_event[0] && flag )
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 40e7ca8d1..04953bdbe 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -806,10 +806,10 @@ static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16
}
switch( answer ) {
- case 0 : sprintf(output, "Login-server has been asked to %s the player '%.*s'.", action, NAME_LENGTH, player_name); break;
- case 1 : sprintf(output, "The player '%.*s' doesn't exist.", NAME_LENGTH, player_name); break;
- case 2 : sprintf(output, "Your GM level don't authorise you to %s the player '%.*s'.", action, NAME_LENGTH, player_name); break;
- case 3 : sprintf(output, "Login-server is offline. Impossible to %s the player '%.*s'.", action, NAME_LENGTH, player_name); break;
+ case 0 : snprintf(output, sizeof output, "Login-server has been asked to %s the player '%.*s'.", action, NAME_LENGTH, player_name); break;
+ case 1 : snprintf(output, sizeof output, "The player '%.*s' doesn't exist.", NAME_LENGTH, player_name); break;
+ case 2 : snprintf(output, sizeof output, "Your GM level don't authorise you to %s the player '%.*s'.", action, NAME_LENGTH, player_name); break;
+ case 3 : snprintf(output, sizeof output, "Login-server is offline. Impossible to %s the player '%.*s'.", action, NAME_LENGTH, player_name); break;
default: output[0] = '\0'; break;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 29064fe31..94b4e91f0 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7843,11 +7843,11 @@ int clif_charnameack (int fd, struct block_list *bl)
char mobhp[50], *str_p = mobhp;
WBUFW(buf, 0) = cmd = 0x195;
if( battle_config.show_mob_info&4 )
- str_p += sprintf(str_p, "Lv. %d | ", md->level);
+ str_p += snprintf(str_p, sizeof str_p, "Lv. %d | ", md->level);
if( battle_config.show_mob_info&1 )
- str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
+ str_p += snprintf(str_p, sizeof str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
if( battle_config.show_mob_info&2 )
- str_p += sprintf(str_p, "HP: %d%% | ", get_percentage(md->status.hp, md->status.max_hp));
+ str_p += snprintf(str_p, sizeof str_p, "HP: %d%% | ", get_percentage(md->status.hp, md->status.max_hp));
//Even thought mobhp ain't a name, we send it as one so the client
//can parse it. [Skotlex]
if( str_p != mobhp )
@@ -8727,7 +8727,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if( map[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) )
{
char output[128];
- sprintf(output, "[ Kill Steal Protection Disable. KS is allowed in this map ]");
+ snprintf(output, sizeof output, "[ Kill Steal Protection Disable. KS is allowed in this map ]");
clif_broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF);
}
@@ -8932,7 +8932,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
pc_isGM(sd) < battle_config.hack_info_GM_level
) {
char gm_msg[256];
- sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id);
+ snprintf(gm_msg, sizeof gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id);
ShowWarning(gm_msg);
// information is sent to all online GMs
intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, gm_msg);
@@ -9005,7 +9005,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
break;
case 1: {
char buf[256];
- sprintf(buf, msg_txt(505), sd->status.name);
+ snprintf(buf, sizeof buf, msg_txt(505), sd->status.name);
if( strstr(message, buf) ) // "My name is %s, and I'm a Super Novice~"
sd->state.snovice_call_flag++;
}
@@ -9049,11 +9049,11 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd)
map_name = (char*)RFIFOP(fd,2);
map_name[MAP_NAME_LENGTH_EXT-1]='\0';
- sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
+ snprintf(output, sizeof output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
atcommand_mapmove(fd, sd, "@mapmove", output);
if( log_config.gm && get_atcommand_level(atcommand_mapmove) >= log_config.gm )
{
- sprintf(message, "/mm %s", output);
+ snprintf(message, sizeof message, "/mm %s", output);
log_atcommand(sd, message);
}
return;
@@ -9326,11 +9326,11 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
for( i = 0; i < 10; ++i )
{
- sprintf(output, "@whispervar%d$", i);
+ snprintf(output, sizeof output, "@whispervar%d$", i);
set_var(sd,output,(char *) split_data[i]);
}
- sprintf(output, "%s::OnWhisperGlobal", npc->name);
+ snprintf(output, sizeof output, "%s::OnWhisperGlobal", npc->name);
npc_event(sd,output,0); // Calls the NPC label
return;
@@ -9390,7 +9390,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if( dstsd->state.autotrade == 1 )
{
char output[256];
- sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name);
+ snprintf(output, sizeof output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name);
clif_wis_message(fd, wisp_server_name, output, strlen(output) + 1);
return;
}
@@ -9402,12 +9402,12 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if(dstsd->away_message[0] != '\0')
{
char output[256];
- sprintf(output, "%s %s", message, msg_txt(543)); // "(Automessage has been sent)"
+ snprintf(output, sizeof output, "%s %s", message, msg_txt(543)); // "(Automessage has been sent)"
clif_wis_message(dstsd->fd, sd->status.name, output, strlen(output) + 1);
if(dstsd->state.autotrade)
- sprintf(output, msg_txt(544), dstsd->away_message); // "Away [AT] - "%s""
+ snprintf(output, sizeof output, msg_txt(544), dstsd->away_message); // "Away [AT] - "%s""
else
- sprintf(output, msg_txt(545), dstsd->away_message); // "Away - "%s""
+ snprintf(output, sizeof output, msg_txt(545), dstsd->away_message); // "Away - "%s""
clif_wis_message(fd, dstsd->status.name, output, strlen(output) + 1);
return;
}
@@ -9438,7 +9438,7 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd)
if(log_config.gm && lv >= log_config.gm) {
char logmsg[CHAT_SIZE_MAX+4];
- sprintf(logmsg, "/b %s", msg);
+ snprintf(logmsg, sizeof logmsg, "/b %s", msg);
log_atcommand(sd, logmsg);
}
}
@@ -10528,7 +10528,7 @@ void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd)
if( log_config.gm && lv >= log_config.gm ) {
char logmsg[CHAT_SIZE_MAX+5];
- sprintf(logmsg, "/lb %s", msg);
+ snprintf(logmsg, sizeof logmsg, "/lb %s", msg);
log_atcommand(sd, logmsg);
}
}
@@ -11443,7 +11443,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
if(log_config.gm && lv >= log_config.gm) {
char message[256];
- sprintf(message, "/kick %s (%d)", tsd->status.name, tsd->status.char_id);
+ snprintf(message, sizeof message, "/kick %s (%d)", tsd->status.name, tsd->status.char_id);
log_atcommand(sd, message);
}
@@ -11461,7 +11461,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
if(log_config.gm && lv >= log_config.gm) {
char message[256];
- sprintf(message, "/kick %s (%d)", status_get_name(target), status_get_class(target));
+ snprintf(message, sizeof message, "/kick %s (%d)", status_get_name(target), status_get_class(target));
log_atcommand(sd, message);
}
@@ -11480,7 +11480,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
if( log_config.gm && lv >= log_config.gm ) {
char message[256];
- sprintf(message, "/kick %s (%d)", status_get_name(target), status_get_class(target));
+ snprintf(message, sizeof message, "/kick %s (%d)", status_get_name(target), status_get_class(target));
log_atcommand(sd, message);
}
@@ -11521,7 +11521,7 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd)
atcommand_jumpto(fd, sd, "@jumpto", player_name); // as @jumpto
if( log_config.gm && lv >= log_config.gm ) {
char message[NAME_LENGTH+7];
- sprintf(message, "/shift %s", player_name);
+ snprintf(message, sizeof message, "/shift %s", player_name);
log_atcommand(sd, message);
}
}
@@ -11545,7 +11545,7 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd)
atcommand_recall(fd, sd, "@recall", player_name); // as @recall
if( log_config.gm && lv >= log_config.gm ) {
char message[NAME_LENGTH+8];
- sprintf(message, "/recall %s", player_name);
+ snprintf(message, sizeof message, "/recall %s", player_name);
log_atcommand(sd, message);
}
}
@@ -11584,7 +11584,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
atcommand_item(fd, sd, "@item", monster_item_name); // as @item
if( log_config.gm && level >= log_config.gm )
{ //Log action. [Skotlex]
- sprintf(message, "@item %s", monster_item_name);
+ snprintf(message, sizeof message, "@item %s", monster_item_name);
log_atcommand(sd, message);
}
}
@@ -11760,7 +11760,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd)
// Bot-check...
if (strcmp(wisp_server_name, nick) == 0)
{ // to find possible bot users who automaticaly ignore people
- sprintf(output, "Character '%s' (account: %d) has tried to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
+ snprintf(output, sizeof output, "Character '%s' (account: %d) has tried to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
WFIFOB(fd,3) = 1; // fail
WFIFOSET(fd, packet_len(0x0d1));
@@ -12566,7 +12566,7 @@ void clif_Mail_refreshinbox(struct map_session_data *sd)
if( md->full )
{
char output[100];
- sprintf(output, "Inbox is full (Max %d). Delete some mails.", MAIL_MAX_INBOX);
+ snprintf(output, sizeof output, "Inbox is full (Max %d). Delete some mails.", MAIL_MAX_INBOX);
clif_disp_onlyself(sd, output, strlen(output));
}
}
@@ -14625,7 +14625,7 @@ static int packetdb_readdb(void)
for( i = 0; i < ARRAYLENGTH(packet_len_table); ++i )
packet_len(i) = packet_len_table[i];
- sprintf(line, "%s/packet_db.txt", db_path);
+ snprintf(line, sizeof line, "%s/packet_db.txt", db_path);
if( (fp=fopen(line,"r"))==NULL ){
ShowFatalError("can't read %s\n", line);
exit(EXIT_FAILURE);
diff --git a/src/map/guild.c b/src/map/guild.c
index f90fc8946..abdc688e9 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -110,7 +110,7 @@ int guild_read_guildskill_tree_db(void)
char line[1024],*p;
memset(guild_skill_tree,0,sizeof(guild_skill_tree));
- sprintf(line, "%s/guild_skill_tree.txt", db_path);
+ snprintf(line, sizeof line, "%s/guild_skill_tree.txt", db_path);
if( (fp=fopen(line,"r"))==NULL){
ShowError("can't read %s\n", line);
return -1;
@@ -176,7 +176,7 @@ static int guild_read_castledb(void)
char *str[32],*p;
struct guild_castle *gc;
- sprintf(line, "%s/castle_db.txt", db_path);
+ snprintf(line, sizeof line, "%s/castle_db.txt", db_path);
if( (fp=fopen(line,"r"))==NULL){
ShowError("can't read %s\n", line);
return -1;
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 0fbd7cbff..c69d397b8 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -259,7 +259,7 @@ int merc_hom_levelup(struct homun_data *hd)
hom->luk += growth_luk;
if ( battle_config.homunculus_show_growth ) {
- sprintf(output,
+ snprintf(output, sizeof output,
"Growth: hp:%d sp:%d str(%.2f) agi(%.2f) vit(%.2f) int(%.2f) dex(%.2f) luk(%.2f) ",
growth_max_hp, growth_max_sp,
growth_str/10.0, growth_agi/10.0, growth_vit/10.0,
@@ -889,7 +889,7 @@ int read_homunculusdb(void)
memset(homunculus_db,0,sizeof(homunculus_db));
for(i = 0; i<2; i++)
{
- sprintf(line, "%s/%s", db_path, filename[i]);
+ snprintf(line, sizeof line, "%s/%s", db_path, filename[i]);
fp = fopen(line,"r");
if(!fp){
if(i != 0)
@@ -1040,7 +1040,7 @@ int read_homunculus_skilldb(void)
char *split[15];
memset(hskill_tree,0,sizeof(hskill_tree));
- sprintf(line, "%s/homun_skill_tree.txt", db_path);
+ snprintf(line, sizeof line, "%s/homun_skill_tree.txt", db_path);
fp=fopen(line,"r");
if(fp==NULL){
ShowError("can't read %s\n", line);
@@ -1108,7 +1108,7 @@ void read_homunculus_expdb(void)
memset(hexptbl,0,sizeof(hexptbl));
for(i=0; i<2; i++){
- sprintf(line, "%s/%s", db_path, filename[i]);
+ snprintf(line, sizeof line, "%s/%s", db_path, filename[i]);
fp=fopen(line,"r");
if(fp == NULL){
if(i != 0)
diff --git a/src/map/intif.c b/src/map/intif.c
index 15d948c59..4ecabac1a 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -262,8 +262,8 @@ int intif_regtostr(char* str, struct global_reg *reg, int qty)
int len =0, i;
for (i = 0; i < qty; i++) {
- len+= sprintf(str+len, "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
- len+= sprintf(str+len, "%s", reg[i].value)+1;
+ len+= snprintf(str+len, sizeof (str+len), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
+ len+= snprintf(str+len, sizeof (str+len), "%s", reg[i].value)+1;
}
return len;
}
@@ -1471,7 +1471,7 @@ int intif_parse_Mail_inboxreceived(int fd)
else
{
char output[128];
- sprintf(output, msg_txt(510), sd->mail.inbox.unchecked, sd->mail.inbox.unread + sd->mail.inbox.unchecked);
+ snprintf(output, sizeof output, msg_txt(510), sd->mail.inbox.unchecked, sd->mail.inbox.unread + sd->mail.inbox.unchecked);
clif_disp_onlyself(sd, output, strlen(output));
}
return 0;
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index ce10f4f39..1f5e13918 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -478,7 +478,7 @@ static int itemdb_read_itemavail (void)
char line[1024], *str[10], *p;
struct item_data *id;
- sprintf(line, "%s/item_avail.txt", db_path);
+ snprintf(line, sizeof line, "%s/item_avail.txt", db_path);
if ((fp = fopen(line,"r")) == NULL) {
ShowError("can't read %s\n", line);
return -1;
@@ -600,7 +600,7 @@ static int itemdb_read_noequip(void)
char *str[32],*p;
struct item_data *id;
- sprintf(line, "%s/item_noequip.txt", db_path);
+ snprintf(line, sizeof line, "%s/item_noequip.txt", db_path);
if( (fp=fopen(line,"r"))==NULL ){
ShowError("can't read %s\n", line);
return -1;
@@ -644,7 +644,7 @@ static int itemdb_read_itemtrade(void)
char line[1024], *str[10], *p;
struct item_data *id;
- sprintf(line, "%s/item_trade.txt", db_path);
+ snprintf(line, sizeof line, "%s/item_trade.txt", db_path);
if ((fp = fopen(line,"r")) == NULL) {
ShowError("can't read %s\n", line);
return -1;
@@ -690,7 +690,7 @@ static int itemdb_read_itemdelay(void)
char line[1024], *str[10], *p;
struct item_data *id;
- sprintf(line, "%s/item_delay.txt", db_path);
+ snprintf(line, sizeof line, "%s/item_delay.txt", db_path);
if ((fp = fopen(line,"r")) == NULL) {
ShowError("can't read %s\n", line);
return -1;
@@ -880,7 +880,7 @@ static int itemdb_readdb(void)
char path[256];
FILE* fp;
- sprintf(path, "%s/%s", db_path, filename[fi]);
+ snprintf(path, sizeof path, "%s/%s", db_path, filename[fi]);
fp = fopen(path, "r");
if( fp == NULL )
{
diff --git a/src/map/map.c b/src/map/map.c
index be2c53526..2bc5b9b97 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2825,7 +2825,7 @@ int map_waterheight(char* mapname)
char *rsw, *found;
//Look up for the rsw
- sprintf(fn, "data\\%s.rsw", mapname);
+ snprintf(fn, sizeof fn, "data\\%s.rsw", mapname);
found = grfio_find_file(fn);
if (found) strcpy(fn, found); // replace with real name
@@ -2852,7 +2852,7 @@ int map_readgat (struct map_data* m)
int water_height;
size_t xy, off, num_cells;
- sprintf(filename, "data\\%s.gat", m->name);
+ snprintf(filename, sizeof filename, "data\\%s.gat", m->name);
gat = (uint8 *) grfio_read(filename);
if (gat == NULL)
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 79bec2da6..189f0793b 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -411,7 +411,7 @@ int read_mercenarydb(void)
struct s_mercenary_db *db;
struct status_data *status;
- sprintf(line, "%s/%s", db_path, "mercenary_db.txt");
+ snprintf(line, sizeof line, "%s/%s", db_path, "mercenary_db.txt");
memset(mercenary_db,0,sizeof(mercenary_db));
fp = fopen(line, "r");
@@ -505,7 +505,7 @@ int read_mercenary_skilldb(void)
int i, j = 0, k = 0, class_;
int skillid, skilllv;
- sprintf(line, "%s/%s", db_path, "mercenary_skill_db.txt");
+ snprintf(line, sizeof line, "%s/%s", db_path, "mercenary_skill_db.txt");
fp = fopen(line, "r");
if( !fp )
{
diff --git a/src/map/mob.c b/src/map/mob.c
index 3c5a611af..879a2c704 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -343,7 +343,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
// Message to KS
if( DIFF_TICK(sd->ks_floodprotect_tick, tick) <= 0 )
{
- sprintf(output, "[KS Warning!! - Owner : %s]", pl_sd->status.name);
+ snprintf(output, sizeof output, "[KS Warning!! - Owner : %s]", pl_sd->status.name);
clif_disp_onlyself(sd, output, strlen(output));
sd->ks_floodprotect_tick = tick + 2000;
@@ -352,7 +352,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
// Message to Owner
if( DIFF_TICK(pl_sd->ks_floodprotect_tick, tick) <= 0 )
{
- sprintf(output, "[Watch out! %s is trying to KS you!]", sd->status.name);
+ snprintf(output, sizeof output, "[Watch out! %s is trying to KS you!]", sd->status.name);
clif_disp_onlyself(pl_sd, output, strlen(output));
pl_sd->ks_floodprotect_tick = tick + 2000;
@@ -2234,7 +2234,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
struct item_data *i_data;
char message[128];
i_data = itemdb_search(ditem->item_data.nameid);
- sprintf (message, msg_txt(541), mvp_sd->status.name, md->name, i_data->jname, (float)drop_rate/100);
+ snprintf (message, sizeof message, msg_txt(541), mvp_sd->status.name, md->name, i_data->jname, (float)drop_rate/100);
//MSG: "'%s' won %s's %s (chance: %0.02f%%)"
intif_broadcast(message,strlen(message)+1,0);
}
@@ -2360,7 +2360,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
struct item_data *i_data;
char message[128];
i_data = itemdb_exists(item.nameid);
- sprintf (message, msg_txt(541), mvp_sd->status.name, md->name, i_data->jname, temp/100.);
+ snprintf (message, sizeof message, msg_txt(541), mvp_sd->status.name, md->name, i_data->jname, temp/100.);
//MSG: "'%s' won %s's %s (chance: %0.02f%%)"
intif_broadcast(message,strlen(message)+1,0);
}
@@ -3354,9 +3354,9 @@ static int mob_makedummymobdb(int class_)
}
//Initialize dummy data.
mob_dummy = (struct mob_db*)aCalloc(1, sizeof(struct mob_db)); //Initializing the dummy mob.
- sprintf(mob_dummy->sprite,"DUMMY");
- sprintf(mob_dummy->name,"Dummy");
- sprintf(mob_dummy->jname,"Dummy");
+ snprintf(mob_dummy->sprite,sizeof mob_dummy->sprite,"DUMMY");
+ snprintf(mob_dummy->name,sizeof mob_dummy->name,"Dummy");
+ snprintf(mob_dummy->jname,sizeof mob_dummy->jname,"Dummy");
mob_dummy->lv=1;
mob_dummy->status.max_hp=1000;
mob_dummy->status.max_sp=1;
@@ -3650,7 +3650,7 @@ static void mob_readdb(void)
if(fi > 0)
{
- sprintf(path, "%s/%s", db_path, filename[fi]);
+ snprintf(path, sizeof path, "%s/%s", db_path, filename[fi]);
if(!exists(path))
{
continue;
@@ -3780,7 +3780,7 @@ static int mob_read_randommonster(void)
for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ )
{
mob_db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one
- sprintf(line, "%s/%s", db_path, mobfile[i]);
+ snprintf(line, sizeof line, "%s/%s", db_path, mobfile[i]);
fp=fopen(line,"r");
if(fp==NULL){
ShowError("can't read %s\n",line);
@@ -3894,7 +3894,7 @@ static void mob_readchatdb(void)
char line[1024], path[256];
int i, tmp=0;
FILE *fp;
- sprintf(path, "%s/%s", db_path, arc);
+ snprintf(path, sizeof path, "%s/%s", db_path, arc);
fp=fopen(path, "r");
if(fp == NULL)
{
@@ -4218,7 +4218,7 @@ static void mob_readskilldb(void)
if(fi > 0)
{
- sprintf(path, "%s/%s", db_path, filename[fi]);
+ snprintf(path, sizeof path, "%s/%s", db_path, filename[fi]);
if(!exists(path))
{
continue;
diff --git a/src/map/npc.c b/src/map/npc.c
index 0b16aa6f9..2764e5cb9 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -368,19 +368,19 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, intptr data)
}
if (t->tm_min != ev_tm_b.tm_min ) {
- sprintf(buf,"OnMinute%02d",t->tm_min);
+ snprintf(buf,sizeof buf,"OnMinute%02d",t->tm_min);
c+=npc_event_doall(buf);
- sprintf(buf,"OnClock%02d%02d",t->tm_hour,t->tm_min);
+ snprintf(buf,sizeof buf,"OnClock%02d%02d",t->tm_hour,t->tm_min);
c+=npc_event_doall(buf);
- sprintf(buf,"On%s%02d%02d",day,t->tm_hour,t->tm_min);
+ snprintf(buf,sizeof buf,"On%s%02d%02d",day,t->tm_hour,t->tm_min);
c+=npc_event_doall(buf);
}
if (t->tm_hour!= ev_tm_b.tm_hour) {
- sprintf(buf,"OnHour%02d",t->tm_hour);
+ snprintf(buf,sizeof buf,"OnHour%02d",t->tm_hour);
c+=npc_event_doall(buf);
}
if (t->tm_mday!= ev_tm_b.tm_mday) {
- sprintf(buf,"OnDay%02d%02d",t->tm_mon+1,t->tm_mday);
+ snprintf(buf,sizeof buf,"OnDay%02d%02d",t->tm_mon+1,t->tm_mday);
c+=npc_event_doall(buf);
}
diff --git a/src/map/pc.c b/src/map/pc.c
index 75097343d..4cb371955 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -939,7 +939,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
if (battle_config.display_version == 1){
char buf[256];
- sprintf(buf, "eAthena SVN version: %s", get_svn_revision());
+ snprintf(buf, sizeof buf, "eAthena SVN version: %s", get_svn_revision());
clif_displaymessage(sd->fd, buf);
}
@@ -3255,7 +3255,7 @@ void pc_paycash(struct map_session_data *sd, int price, int points)
pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints - cash);
pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints - points);
- sprintf(output, "Used %d kafra points and %d cash points. %d kafra and %d cash points remaining.", points, cash, sd->kafraPoints, sd->cashPoints);
+ snprintf(output, sizeof output, "Used %d kafra points and %d cash points. %d kafra and %d cash points remaining.", points, cash, sd->kafraPoints, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
@@ -3268,7 +3268,7 @@ void pc_getcash(struct map_session_data *sd, int cash, int points)
{
pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints + cash);
- sprintf(output, "Gained %d cash points. Total %d points", cash, sd->cashPoints);
+ snprintf(output, sizeof output, "Gained %d cash points. Total %d points", cash, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
@@ -3276,7 +3276,7 @@ void pc_getcash(struct map_session_data *sd, int cash, int points)
{
pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints + points);
- sprintf(output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints);
+ snprintf(output, sizeof output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
}
@@ -3300,7 +3300,7 @@ int pc_getzeny(struct map_session_data *sd,int zeny)
if( zeny > 0 && sd->state.showzeny )
{
char output[255];
- sprintf(output, "Gained %dz.", zeny);
+ snprintf(output, sizeof output, "Gained %dz.", zeny);
clif_disp_onlyself(sd,output,strlen(output));
}
@@ -3922,9 +3922,9 @@ int pc_show_steal(struct block_list *bl,va_list ap)
itemid=va_arg(ap,int);
if((item=itemdb_exists(itemid))==NULL)
- sprintf(output,"%s stole an Unknown Item (id: %i).",sd->status.name, itemid);
+ snprintf(output,sizeof output,"%s stole an Unknown Item (id: %i).",sd->status.name, itemid);
else
- sprintf(output,"%s stole %s.",sd->status.name,item->jname);
+ snprintf(output,sizeof output,"%s stole %s.",sd->status.name,item->jname);
clif_displaymessage( ((struct map_session_data *)bl)->fd, output);
return 0;
@@ -4006,7 +4006,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int lv)
struct item_data *i_data;
char message[128];
i_data = itemdb_search(itemid);
- sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, i_data->jname, (float)md->db->dropitem[i].p/100);
+ snprintf(message, sizeof message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, i_data->jname, (float)md->db->dropitem[i].p/100);
//MSG: "'%s' stole %s's %s (chance: %0.02f%%)"
intif_broadcast(message,strlen(message)+1,0);
}
@@ -4938,7 +4938,7 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int
#endif
if(sd->state.showexp) {
char output[256];
- sprintf(output,
+ snprintf(output, sizeof output,
"Experience Gained Base:%u (%.2f%%) Job:%u (%.2f%%)",base_exp,nextbp*(float)100,job_exp,nextjp*(float)100);
clif_disp_onlyself(sd,output,strlen(output));
}
@@ -7730,7 +7730,7 @@ static int duel_showinfo_sub(struct map_session_data* sd, va_list va)
if (sd->duel_group != ssd->duel_group) return 0;
- sprintf(output, " %d. %s", ++(*p), sd->status.name);
+ snprintf(output, sizeof output, " %d. %s", ++(*p), sd->status.name);
clif_disp_onlyself(ssd, output, strlen(output));
return 1;
}
@@ -7741,13 +7741,13 @@ int duel_showinfo(const unsigned int did, struct map_session_data* sd)
char output[256];
if(duel_list[did].max_players_limit > 0)
- sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
+ snprintf(output, sizeof output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
did, duel_count,
duel_list[did].members_count,
duel_list[did].members_count + duel_list[did].invites_count,
duel_list[did].max_players_limit);
else
- sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
+ snprintf(output, sizeof output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
did, duel_count,
duel_list[did].members_count,
duel_list[did].members_count + duel_list[did].invites_count);
@@ -7784,14 +7784,14 @@ int duel_invite(const unsigned int did, struct map_session_data* sd, struct map_
char output[256];
// " -- Player %s invites %s to duel --"
- sprintf(output, msg_txt(373), sd->status.name, target_sd->status.name);
+ snprintf(output, sizeof output, msg_txt(373), sd->status.name, target_sd->status.name);
clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
target_sd->duel_invite = did;
duel_list[did].invites_count++;
// "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
- sprintf(output, msg_txt(374), sd->status.name);
+ snprintf(output, sizeof output, msg_txt(374), sd->status.name);
clif_broadcast((struct block_list *)target_sd, output, strlen(output)+1, 0x10, SELF);
return 0;
}
@@ -7809,7 +7809,7 @@ int duel_leave(const unsigned int did, struct map_session_data* sd)
char output[256];
// " <- Player %s has left duel --"
- sprintf(output, msg_txt(375), sd->status.name);
+ snprintf(output, sizeof output, msg_txt(375), sd->status.name);
clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
duel_list[did].members_count--;
@@ -7835,7 +7835,7 @@ int duel_accept(const unsigned int did, struct map_session_data* sd)
sd->duel_invite = 0;
// " -> Player %s has accepted duel --"
- sprintf(output, msg_txt(376), sd->status.name);
+ snprintf(output, sizeof output, msg_txt(376), sd->status.name);
clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
clif_set0199(sd, 1);
@@ -7848,7 +7848,7 @@ int duel_reject(const unsigned int did, struct map_session_data* sd)
char output[256];
// " -- Player %s has rejected duel --"
- sprintf(output, msg_txt(377), sd->status.name);
+ snprintf(output, sizeof output, msg_txt(377), sd->status.name);
clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
duel_list[did].invites_count--;
@@ -7977,7 +7977,7 @@ int pc_readdb(void)
// 必要??値?み?み
memset(exp_table,0,sizeof(exp_table));
memset(max_level,0,sizeof(max_level));
- sprintf(line, "%s/exp.txt", db_path);
+ snprintf(line, sizeof line, "%s/exp.txt", db_path);
fp=fopen(line, "r");
if(fp==NULL){
ShowError("can't read %s\n", line);
@@ -8067,7 +8067,7 @@ int pc_readdb(void)
for(k=0;k<ELE_MAX;k++)
attr_fix_table[i][j][k]=100;
- sprintf(line, "%s/attr_fix.txt", db_path);
+ snprintf(line, sizeof line, "%s/attr_fix.txt", db_path);
fp=fopen(line,"r");
if(fp==NULL){
ShowError("can't read %s\n", line);
@@ -8115,7 +8115,7 @@ int pc_readdb(void)
// スキルツリ?
memset(statp,0,sizeof(statp));
i=1;
- sprintf(line, "%s/statpoint.txt", db_path);
+ snprintf(line, sizeof line, "%s/statpoint.txt", db_path);
fp=fopen(line,"r");
if(fp == NULL){
ShowStatus("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line);
diff --git a/src/map/pet.c b/src/map/pet.c
index 843f1cc11..b0bb0bc6a 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -1222,7 +1222,7 @@ int read_petdb()
char line[1024];
int lines;
- sprintf(line, "%s/%s", db_path, filename[i]);
+ snprintf(line, sizeof line, "%s/%s", db_path, filename[i]);
fp=fopen(line,"r");
if( fp == NULL )
{
diff --git a/src/map/quest.c b/src/map/quest.c
index 3e43fcda6..99bf763cf 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -306,7 +306,7 @@ int quest_read_db(void)
int i,j,k = 0;
char *str[20],*p,*np;
- sprintf(line, "%s/quest_db.txt", db_path);
+ snprintf(line, sizeof line, "%s/quest_db.txt", db_path);
if( (fp=fopen(line,"r"))==NULL ){
ShowError("can't read %s\n", line);
return -1;
diff --git a/src/map/script.c b/src/map/script.c
index ed07ac07c..94eb9ccd7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1166,32 +1166,32 @@ const char* parse_curly_close(const char* p)
char label[256];
int l;
// 一時変数を消す
- sprintf(label,"set $@__SW%x_VAL,0;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"set $@__SW%x_VAL,0;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// 無条件で終了ポインタに移動
- sprintf(label,"goto __SW%x_FIN;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __SW%x_FIN;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// 現在地のラベルを付ける
- sprintf(label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
+ snprintf(label,sizeof label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
set_label(l,script_pos, p);
if(syntax.curly[pos].flag) {
// default が存在する
- sprintf(label,"goto __SW%x_DEF;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __SW%x_DEF;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
}
// 終了ラベルを付ける
- sprintf(label,"__SW%x_FIN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__SW%x_FIN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos, p);
linkdb_final(&syntax.curly[pos].case_label); // free the list of case label
@@ -1219,16 +1219,16 @@ const char* parse_syntax(const char* p)
int pos = syntax.curly_count - 1;
while(pos >= 0) {
if(syntax.curly[pos].type == TYPE_DO) {
- sprintf(label,"goto __DO%x_FIN;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __DO%x_FIN;",syntax.curly[pos].index);
break;
} else if(syntax.curly[pos].type == TYPE_FOR) {
- sprintf(label,"goto __FR%x_FIN;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __FR%x_FIN;",syntax.curly[pos].index);
break;
} else if(syntax.curly[pos].type == TYPE_WHILE) {
- sprintf(label,"goto __WL%x_FIN;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __WL%x_FIN;",syntax.curly[pos].index);
break;
} else if(syntax.curly[pos].type == TYPE_SWITCH) {
- sprintf(label,"goto __SW%x_FIN;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __SW%x_FIN;",syntax.curly[pos].index);
break;
}
pos--;
@@ -1262,13 +1262,13 @@ const char* parse_syntax(const char* p)
char *np;
if(syntax.curly[pos].count != 1) {
// FALLTHRU 用のジャンプ
- sprintf(label,"goto __SW%x_%xJ;",syntax.curly[pos].index,syntax.curly[pos].count);
+ snprintf(label,sizeof label,"goto __SW%x_%xJ;",syntax.curly[pos].index,syntax.curly[pos].count);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// 現在地のラベルを付ける
- sprintf(label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
+ snprintf(label,sizeof label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
set_label(l,script_pos, p);
}
@@ -1299,7 +1299,7 @@ const char* parse_syntax(const char* p)
p = skip_space(p);
if(*p != ':')
disp_error_message("parse_syntax: expect ':'",p);
- sprintf(label,"if(%d != $@__SW%x_VAL) goto __SW%x_%x;",
+ snprintf(label,sizeof label,"if(%d != $@__SW%x_VAL) goto __SW%x_%x;",
v,syntax.curly[pos].index,syntax.curly[pos].index,syntax.curly[pos].count+1);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
// 2回parse しないとダメ
@@ -1308,7 +1308,7 @@ const char* parse_syntax(const char* p)
syntax.curly_count--;
if(syntax.curly[pos].count != 1) {
// FALLTHRU 終了後のラベル
- sprintf(label,"__SW%x_%xJ",syntax.curly[pos].index,syntax.curly[pos].count);
+ snprintf(label,sizeof label,"__SW%x_%xJ",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
set_label(l,script_pos,p);
}
@@ -1317,7 +1317,7 @@ const char* parse_syntax(const char* p)
disp_error_message("parse_syntax: dup 'case'",p);
linkdb_insert(&syntax.curly[pos].case_label, (void*)v, (void*)1);
- sprintf(label,"set $@__SW%x_VAL,0;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"set $@__SW%x_VAL,0;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
@@ -1331,14 +1331,14 @@ const char* parse_syntax(const char* p)
int pos = syntax.curly_count - 1;
while(pos >= 0) {
if(syntax.curly[pos].type == TYPE_DO) {
- sprintf(label,"goto __DO%x_NXT;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __DO%x_NXT;",syntax.curly[pos].index);
syntax.curly[pos].flag = 1; // continue 用のリンク張るフラグ
break;
} else if(syntax.curly[pos].type == TYPE_FOR) {
- sprintf(label,"goto __FR%x_NXT;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __FR%x_NXT;",syntax.curly[pos].index);
break;
} else if(syntax.curly[pos].type == TYPE_WHILE) {
- sprintf(label,"goto __WL%x_NXT;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __WL%x_NXT;",syntax.curly[pos].index);
break;
}
pos--;
@@ -1375,18 +1375,18 @@ const char* parse_syntax(const char* p)
if(*p != ':') {
disp_error_message("parse_syntax: need ':'",p);
}
- sprintf(label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
+ snprintf(label,sizeof label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
set_label(l,script_pos,p);
// 無条件で次のリンクに飛ばす
- sprintf(label,"goto __SW%x_%x;",syntax.curly[pos].index,syntax.curly[pos].count+1);
+ snprintf(label,sizeof label,"goto __SW%x_%x;",syntax.curly[pos].index,syntax.curly[pos].count+1);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// default のラベルを付ける
- sprintf(label,"__SW%x_DEF",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__SW%x_DEF",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
@@ -1404,7 +1404,7 @@ const char* parse_syntax(const char* p)
syntax.curly[syntax.curly_count].index = syntax.index++;
syntax.curly[syntax.curly_count].flag = 0;
// 現在地のラベル形成する
- sprintf(label,"__DO%x_BGN",syntax.curly[syntax.curly_count].index);
+ snprintf(label,sizeof label,"__DO%x_BGN",syntax.curly[syntax.curly_count].index);
l=add_str(label);
set_label(l,script_pos,p);
syntax.curly_count++;
@@ -1435,7 +1435,7 @@ const char* parse_syntax(const char* p)
syntax.curly_count--;
// 条件判断開始のラベル形成する
- sprintf(label,"__FR%x_J",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__FR%x_J",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
@@ -1445,7 +1445,7 @@ const char* parse_syntax(const char* p)
;
} else {
// 条件が偽なら終了地点に飛ばす
- sprintf(label,"__FR%x_FIN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__FR%x_FIN",syntax.curly[pos].index);
add_scriptl(add_str("jump_zero"));
add_scriptc(C_ARG);
p=parse_expr(p);
@@ -1458,13 +1458,13 @@ const char* parse_syntax(const char* p)
p++;
// ループ開始に飛ばす
- sprintf(label,"goto __FR%x_BGN;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __FR%x_BGN;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// 次のループへのラベル形成する
- sprintf(label,"__FR%x_NXT",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__FR%x_NXT",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
@@ -1477,13 +1477,13 @@ const char* parse_syntax(const char* p)
parse_syntax_for_flag = 0;
// 条件判定処理に飛ばす
- sprintf(label,"goto __FR%x_J;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __FR%x_J;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// ループ開始のラベル付け
- sprintf(label,"__FR%x_BGN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__FR%x_BGN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
return p;
@@ -1520,7 +1520,7 @@ const char* parse_syntax(const char* p)
++syntax.curly_count;
// Jump over the function code
- sprintf(label, "goto __FN%x_FIN;", syntax.curly[syntax.curly_count-1].index);
+ snprintf(label,sizeof label, "goto __FN%x_FIN;", syntax.curly[syntax.curly_count-1].index);
syntax.curly[syntax.curly_count].type = TYPE_NULL;
++syntax.curly_count;
parse_line(label);
@@ -1554,7 +1554,7 @@ const char* parse_syntax(const char* p)
syntax.curly[syntax.curly_count].count = 1;
syntax.curly[syntax.curly_count].index = syntax.index++;
syntax.curly[syntax.curly_count].flag = 0;
- sprintf(label,"__IF%x_%x",syntax.curly[syntax.curly_count].index,syntax.curly[syntax.curly_count].count);
+ snprintf(label,sizeof label,"__IF%x_%x",syntax.curly[syntax.curly_count].index,syntax.curly[syntax.curly_count].count);
syntax.curly_count++;
add_scriptl(add_str("jump_zero"));
add_scriptc(C_ARG);
@@ -1578,7 +1578,7 @@ const char* parse_syntax(const char* p)
syntax.curly[syntax.curly_count].count = 1;
syntax.curly[syntax.curly_count].index = syntax.index++;
syntax.curly[syntax.curly_count].flag = 0;
- sprintf(label,"$@__SW%x_VAL",syntax.curly[syntax.curly_count].index);
+ snprintf(label,sizeof label,"$@__SW%x_VAL",syntax.curly[syntax.curly_count].index);
syntax.curly_count++;
add_scriptl(add_str("set"));
add_scriptc(C_ARG);
@@ -1606,12 +1606,12 @@ const char* parse_syntax(const char* p)
syntax.curly[syntax.curly_count].index = syntax.index++;
syntax.curly[syntax.curly_count].flag = 0;
// 条件判断開始のラベル形成する
- sprintf(label,"__WL%x_NXT",syntax.curly[syntax.curly_count].index);
+ snprintf(label,sizeof label,"__WL%x_NXT",syntax.curly[syntax.curly_count].index);
l=add_str(label);
set_label(l,script_pos,p);
// 条件が偽なら終了地点に飛ばす
- sprintf(label,"__WL%x_FIN",syntax.curly[syntax.curly_count].index);
+ snprintf(label,sizeof label,"__WL%x_FIN",syntax.curly[syntax.curly_count].index);
syntax.curly_count++;
add_scriptl(add_str("jump_zero"));
add_scriptc(C_ARG);
@@ -1653,13 +1653,13 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
const char *bp = p;
const char *p2;
// if 最終場所へ飛ばす
- sprintf(label,"goto __IF%x_FIN;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __IF%x_FIN;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// 現在地のラベルを付ける
- sprintf(label,"__IF%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
+ snprintf(label,sizeof label,"__IF%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
set_label(l,script_pos,p);
@@ -1676,7 +1676,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
if(*p != '(') {
disp_error_message("need '('",p);
}
- sprintf(label,"__IF%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
+ snprintf(label,sizeof label,"__IF%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
add_scriptl(add_str("jump_zero"));
add_scriptc(C_ARG);
p=parse_expr(p);
@@ -1697,7 +1697,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
// if 閉じ
syntax.curly_count--;
// 最終地のラベルを付ける
- sprintf(label,"__IF%x_FIN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__IF%x_FIN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
if(syntax.curly[pos].flag == 1) {
@@ -1712,7 +1712,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
if(syntax.curly[pos].flag) {
// 現在地のラベル形成する(continue でここに来る)
- sprintf(label,"__DO%x_NXT",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__DO%x_NXT",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
}
@@ -1727,7 +1727,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
if(*p != '(') {
disp_error_message("need '('",p);
}
- sprintf(label,"__DO%x_FIN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__DO%x_FIN",syntax.curly[pos].index);
add_scriptl(add_str("jump_zero"));
add_scriptc(C_ARG);
p=parse_expr(p);
@@ -1736,13 +1736,13 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
add_scriptc(C_FUNC);
// 開始地点に飛ばす
- sprintf(label,"goto __DO%x_BGN;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __DO%x_BGN;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// 条件終了地点のラベル形成する
- sprintf(label,"__DO%x_FIN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__DO%x_FIN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
p = skip_space(p);
@@ -1755,26 +1755,26 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
return p;
} else if(syntax.curly[pos].type == TYPE_FOR) {
// 次のループに飛ばす
- sprintf(label,"goto __FR%x_NXT;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __FR%x_NXT;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// for 終了のラベル付け
- sprintf(label,"__FR%x_FIN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__FR%x_FIN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
syntax.curly_count--;
return p;
} else if(syntax.curly[pos].type == TYPE_WHILE) {
// while 条件判断へ飛ばす
- sprintf(label,"goto __WL%x_NXT;",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"goto __WL%x_NXT;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// while 終了のラベル付け
- sprintf(label,"__WL%x_FIN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__WL%x_FIN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
syntax.curly_count--;
@@ -1784,13 +1784,13 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
char label[256];
int l;
// 戻す
- sprintf(label,"return;");
+ snprintf(label,sizeof label,"return;");
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
syntax.curly_count--;
// 現在地のラベルを付ける
- sprintf(label,"__FN%x_FIN",syntax.curly[pos].index);
+ snprintf(label,sizeof label,"__FN%x_FIN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
syntax.curly_count--;
@@ -1844,7 +1844,7 @@ static void read_constdb(void)
char line[1024],name[1024],val[1024];
int n,type;
- sprintf(line, "%s/const.txt", db_path);
+ snprintf(line, sizeof line, "%s/const.txt", db_path);
fp=fopen(line, "r");
if(fp==NULL){
ShowError("can't read %s\n", line);
@@ -10603,7 +10603,7 @@ BUILDIN_FUNC(getinventorylist)
pc_setreg(sd,add_str("@inventorylist_attribute")+(j<<24),sd->status.inventory[i].attribute);
for (k = 0; k < MAX_SLOTS; k++)
{
- sprintf(card_var, "@inventorylist_card%d",k+1);
+ snprintf(card_var, sizeof card_var, "@inventorylist_card%d",k+1);
pc_setreg(sd,add_str(card_var)+(j<<24),sd->status.inventory[i].card[k]);
}
pc_setreg(sd,add_str("@inventorylist_expire")+(j<<24),sd->status.inventory[i].expire_time);
diff --git a/src/map/trade.c b/src/map/trade.c
index 32c84b508..8dd6600a6 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -194,9 +194,9 @@ int impossible_trade_check(struct map_session_data *sd)
index = sd->deal.item[i].index;
if (inventory[index].amount < sd->deal.item[i].amount)
{ // if more than the player have -> hack
- sprintf(message_to_gm, msg_txt(538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has.
+ snprintf(message_to_gm, sizeof message_to_gm, msg_txt(538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has.
intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- sprintf(message_to_gm, msg_txt(539), inventory[index].amount, inventory[index].nameid, sd->deal.item[i].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them.
+ snprintf(message_to_gm, sizeof message_to_gm, msg_txt(539), inventory[index].amount, inventory[index].nameid, sd->deal.item[i].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them.
intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
// if we block people
if (battle_config.ban_hack_trade < 0) {
@@ -209,7 +209,7 @@ int impossible_trade_check(struct map_session_data *sd)
chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second)
set_eof(sd->fd); // forced to disconnect because of the hack
// message about the ban
- sprintf(message_to_gm, msg_txt(507), battle_config.ban_hack_trade); // This player has been banned for %d minute(s).
+ snprintf(message_to_gm, sizeof message_to_gm, msg_txt(507), battle_config.ban_hack_trade); // This player has been banned for %d minute(s).
} else
// message about the ban
strcpy(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled).
diff --git a/src/map/vending.c b/src/map/vending.c
index 67e5ebf19..687b2ca95 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -180,7 +180,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int cid, const ui
if( battle_config.buyer_name )
{
char temp[256];
- sprintf(temp, msg_txt(265), sd->status.name);
+ snprintf(temp, sizeof temp, msg_txt(265), sd->status.name);
clif_disp_onlyself(vsd,temp,strlen(temp));
}
}