summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.c32
-rw-r--r--src/char/int_guild.c30
-rw-r--r--src/char/int_homun.c4
-rw-r--r--src/char/int_party.c4
-rw-r--r--src/char/int_pet.c2
-rw-r--r--src/char/int_status.c4
-rw-r--r--src/char/int_storage.c16
-rw-r--r--src/char/inter.c4
8 files changed, 48 insertions, 48 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 91ad7d33d..927e0e8fa 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -358,7 +358,7 @@ int char_log(char *fmt, ...)
else {
time(&raw_time);
strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", localtime(&raw_time));
- sprintf(tmpstr + 19, ": %s", fmt);
+ snprintf(tmpstr + 19, sizeof (tmpstr + 19), ": %s", fmt);
vfprintf(logfp, tmpstr, ap);
}
fclose(logfp);
@@ -440,11 +440,11 @@ int mmo_friends_list_data_str(char *str, struct mmo_charstatus *p)
{
int i;
char *str_p = str;
- str_p += sprintf(str_p, "%d", p->char_id);
+ str_p += snprintf(str_p, sizeof str_p, "%d", p->char_id);
for (i=0;i<MAX_FRIENDS;i++){
if (p->friends[i].account_id > 0 && p->friends[i].char_id > 0 && p->friends[i].name[0])
- str_p += sprintf(str_p, ",%d,%d,%s", p->friends[i].account_id, p->friends[i].char_id, p->friends[i].name);
+ str_p += snprintf(str_p, sizeof str_p, ",%d,%d,%s", p->friends[i].account_id, p->friends[i].char_id, p->friends[i].name);
}
str_p += '\0';
@@ -460,9 +460,9 @@ int mmo_hotkeys_tostr(char *str, struct mmo_charstatus *p)
#ifdef HOTKEY_SAVING
int i;
char *str_p = str;
- str_p += sprintf(str_p, "%d", p->char_id);
+ str_p += snprintf(str_p, sizeof str_p, "%d", p->char_id);
for (i=0;i<MAX_HOTKEYS;i++)
- str_p += sprintf(str_p, ",%d,%d,%d", p->hotkeys[i].type, p->hotkeys[i].id, p->hotkeys[i].lv);
+ str_p += snprintf(str_p, sizeof str_p, ",%d,%d,%d", p->hotkeys[i].type, p->hotkeys[i].id, p->hotkeys[i].lv);
str_p += '\0';
#endif
@@ -477,7 +477,7 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg,
int i,j;
char *str_p = str;
- str_p += sprintf(str_p,
+ str_p += snprintf(str_p, sizeof str_p,
"%d\t%d,%d\t%s\t%d,%d,%d\t%u,%u,%d" //Up to Zeny field
"\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" //Up to Skill Point
"\t%d,%d,%d\t%d,%d,%d,%d" //Up to hom id
@@ -499,41 +499,41 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg,
p->partner_id,p->father,p->mother,p->child,p->fame);
for(i = 0; i < MAX_MEMOPOINTS; i++)
if (p->memo_point[i].map) {
- str_p += sprintf(str_p, "%d,%d,%d ", p->memo_point[i].map, p->memo_point[i].x, p->memo_point[i].y);
+ str_p += snprintf(str_p, sizeof str_p, "%d,%d,%d ", p->memo_point[i].map, p->memo_point[i].x, p->memo_point[i].y);
}
*(str_p++) = '\t';
for(i = 0; i < MAX_INVENTORY; i++)
if (p->inventory[i].nameid) {
- str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d",
+ str_p += snprintf(str_p,sizeof str_p,"%d,%d,%d,%d,%d,%d,%d",
p->inventory[i].id,p->inventory[i].nameid,p->inventory[i].amount,p->inventory[i].equip,
p->inventory[i].identify,p->inventory[i].refine,p->inventory[i].attribute);
for(j=0; j<MAX_SLOTS; j++)
- str_p += sprintf(str_p,",%d",p->inventory[i].card[j]);
- str_p += sprintf(str_p," ");
+ str_p += snprintf(str_p,sizeof str_p,",%d",p->inventory[i].card[j]);
+ str_p += snprintf(str_p,sizeof str_p," ");
}
*(str_p++) = '\t';
for(i = 0; i < MAX_CART; i++)
if (p->cart[i].nameid) {
- str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d",
+ str_p += snprintf(str_p,sizeof str_p,"%d,%d,%d,%d,%d,%d,%d",
p->cart[i].id,p->cart[i].nameid,p->cart[i].amount,p->cart[i].equip,
p->cart[i].identify,p->cart[i].refine,p->cart[i].attribute);
for(j=0; j<MAX_SLOTS; j++)
- str_p += sprintf(str_p,",%d",p->cart[i].card[j]);
- str_p += sprintf(str_p," ");
+ str_p += snprintf(str_p,sizeof str_p,",%d",p->cart[i].card[j]);
+ str_p += snprintf(str_p,sizeof str_p," ");
}
*(str_p++) = '\t';
for(i = 0; i < MAX_SKILL; i++)
if (p->skill[i].id && p->skill[i].flag != 1) {
- str_p += sprintf(str_p, "%d,%d ", p->skill[i].id, (p->skill[i].flag == 0) ? p->skill[i].lv : p->skill[i].flag-2);
+ str_p += snprintf(str_p, sizeof str_p, "%d,%d ", p->skill[i].id, (p->skill[i].flag == 0) ? p->skill[i].lv : p->skill[i].flag-2);
}
*(str_p++) = '\t';
for(i = 0; i < reg_num; i++)
if (reg[i].str[0])
- str_p += sprintf(str_p, "%s,%s ", reg[i].str, reg[i].value);
+ str_p += snprintf(str_p, sizeof str_p, "%s,%s ", reg[i].str, reg[i].value);
*(str_p++) = '\t';
*str_p = '\0';
@@ -1496,7 +1496,7 @@ void create_online_files(void)
// get time
time(&time_server); // get time in seconds since 1/1/1970
datetime = localtime(&time_server); // convert seconds in structure
- strftime(temp, sizeof(temp), "%d %b %Y %X", datetime); // like sprintf, but only for date/time (05 dec 2003 15:12:52)
+ strftime(temp, sizeof(temp), "%d %b %Y %X", datetime); // like snprintf, but only for date/time (05 dec 2003 15:12:52)
// write heading
fprintf(fp2, "<HTML>\n");
fprintf(fp2, " <META http-equiv=\"Refresh\" content=\"%d\">\n", online_refresh_html); // update on client explorer every x seconds
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 31cceeff0..27bfcedc3 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -42,14 +42,14 @@ int inter_guild_tostr(char* str, struct guild* g)
int i, c, len;
// save guild base info
- len = sprintf(str, "%d\t%s\t%s\t%d,%d,%"PRIu64",%d,%d\t%s#\t%s#\t",
+ len = snprintf(str, sizeof str, "%d\t%s\t%s\t%d,%d,%"PRIu64",%d,%d\t%s#\t%s#\t",
g->guild_id, g->name, g->master, g->guild_lv, g->max_member, g->exp, g->skill_point, 0, g->mes1, g->mes2);
// save guild member info
for(i = 0; i < g->max_member; i++)
{
struct guild_member *m = &g->member[i];
- len += sprintf(str + len, "%d,%d,%d,%d,%d,%d,%d,%"PRIu64",%d,%d\t%s\t",
+ len += snprintf(str + len, sizeof (str + len), "%d,%d,%d,%d,%d,%d,%d,%"PRIu64",%d,%d\t%s\t",
m->account_id, m->char_id,
m->hair, m->hair_color, m->gender,
m->class_, m->lv, m->exp, m->exp_payper, m->position,
@@ -59,26 +59,26 @@ int inter_guild_tostr(char* str, struct guild* g)
// save guild position info
for(i = 0; i < MAX_GUILDPOSITION; i++) {
struct guild_position *p = &g->position[i];
- len += sprintf(str + len, "%d,%d\t%s#\t", p->mode, p->exp_mode, p->name);
+ len += snprintf(str + len, sizeof (str + len), "%d,%d\t%s#\t", p->mode, p->exp_mode, p->name);
}
// save guild emblem
- len += sprintf(str + len, "%d,%d,", g->emblem_len, g->emblem_id);
+ len += snprintf(str + len, sizeof (str + len), "%d,%d,", g->emblem_len, g->emblem_id);
for(i = 0; i < g->emblem_len; i++) {
- len += sprintf(str + len, "%02x", (unsigned char)(g->emblem_data[i]));
+ len += snprintf(str + len, sizeof (str + len), "%02x", (unsigned char)(g->emblem_data[i]));
}
- len += sprintf(str + len, "$\t");
+ len += snprintf(str + len, sizeof (str + len), "$\t");
// save guild alliance info
c = 0;
for(i = 0; i < MAX_GUILDALLIANCE; i++)
if (g->alliance[i].guild_id > 0)
c++;
- len += sprintf(str + len, "%d\t", c);
+ len += snprintf(str + len, sizeof (str + len), "%d\t", c);
for(i = 0; i < MAX_GUILDALLIANCE; i++) {
struct guild_alliance *a = &g->alliance[i];
if (a->guild_id > 0)
- len += sprintf(str + len, "%d,%d\t%s\t", a->guild_id, a->opposition, a->name);
+ len += snprintf(str + len, sizeof (str + len), "%d,%d\t%s\t", a->guild_id, a->opposition, a->name);
}
// save guild expulsion info
@@ -86,19 +86,19 @@ int inter_guild_tostr(char* str, struct guild* g)
for(i = 0; i < MAX_GUILDEXPULSION; i++)
if (g->expulsion[i].account_id > 0)
c++;
- len += sprintf(str + len, "%d\t", c);
+ len += snprintf(str + len, sizeof (str + len), "%d\t", c);
for(i = 0; i < MAX_GUILDEXPULSION; i++) {
struct guild_expulsion *e = &g->expulsion[i];
if (e->account_id > 0)
- len += sprintf(str + len, "%d,%d,%d,%d\t%s\t%s\t%s#\t",
+ len += snprintf(str + len, sizeof (str + len), "%d,%d,%d,%d\t%s\t%s\t%s#\t",
e->account_id, 0, 0, 0, e->name, "#", e->mes );
}
// save guild skill info
for(i = 0; i < MAX_GUILDSKILL; i++) {
- len += sprintf(str + len, "%d,%d ", g->skill[i].id, g->skill[i].lv);
+ len += snprintf(str + len, sizeof (str + len), "%d,%d ", g->skill[i].id, g->skill[i].lv);
}
- len += sprintf(str + len, "\t");
+ len += snprintf(str + len, sizeof (str + len), "\t");
return 0;
}
@@ -309,7 +309,7 @@ int inter_guildcastle_tostr(char *str, struct guild_castle *gc)
{
int len;
- len = sprintf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
+ len = snprintf(str, sizeof str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE,
gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC,
gc->guardian[0].visible, gc->guardian[1].visible, gc->guardian[2].visible, gc->guardian[3].visible,
@@ -369,7 +369,7 @@ int inter_guild_readdb(void)
char line[1024];
char path[1024];
- sprintf(path, "%s%s", db_path, "/exp_guild.txt");
+ snprintf(path, sizeof path, "%s%s", db_path, "/exp_guild.txt");
fp = fopen(path, "r");
if (fp == NULL) {
ShowError("can't read db/exp_guild.txt\n");
@@ -999,7 +999,7 @@ int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_mem
strcpy(g->position[ 0].name, "GuildMaster");
strcpy(g->position[MAX_GUILDPOSITION-1].name, "Newbie");
for(i = 1; i < MAX_GUILDPOSITION-1; i++)
- sprintf(g->position[i].name, "Position %d", i + 1);
+ snprintf(g->position[i].name, sizeof g->position[i].name, "Position %d", i + 1);
// ここでギルド情報計算が必要と思われる
g->max_member = 16;
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index d547b60f7..d36150c4d 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -24,7 +24,7 @@ int inter_homun_tostr(char *str,struct s_homunculus *p)
{
int i;
- str+=sprintf(str,"%d,%d\t%s\t%d,%d,%d,%d,%d,"
+ str+=snprintf(str, sizeof str, "%d,%d\t%s\t%d,%d,%d,%d,%d,"
"%u,%d,%d,%d,"
"%u,%d,%d,"
"%d,%d,%d,%d,%d,%d\t",
@@ -37,7 +37,7 @@ int inter_homun_tostr(char *str,struct s_homunculus *p)
for (i = 0; i < MAX_HOMUNSKILL; i++)
{
if (p->hskill[i].id && !p->hskill[i].flag)
- str+=sprintf(str,"%d,%d,", p->hskill[i].id, p->hskill[i].lv);
+ str+=snprintf(str, sizeof str, "%d,%d,", p->hskill[i].id, p->hskill[i].lv);
}
return 0;
diff --git a/src/char/int_party.c b/src/char/int_party.c
index 04d638049..3a43bc5ae 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -107,10 +107,10 @@ static void int_party_calc_state(struct party_data *p)
int inter_party_tostr(char *str, struct party *p) {
int i, len;
- len = sprintf(str, "%d\t%s\t%d,%d\t", p->party_id, p->name, p->exp, p->item);
+ len = snprintf(str, sizeof str, "%d\t%s\t%d,%d\t", p->party_id, p->name, p->exp, p->item);
for(i = 0; i < MAX_PARTY; i++) {
struct party_member *m = &p->member[i];
- len += sprintf(str + len, "%d,%d,%d\t", m->account_id, m->char_id, m->leader);
+ len += snprintf(str + len, sizeof (str + len), "%d,%d,%d\t", m->account_id, m->char_id, m->leader);
}
return 0;
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 41d61fbc3..0be33e9c4 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -34,7 +34,7 @@ int inter_pet_tostr(char *str,struct s_pet *p)
else if(p->intimate > 1000)
p->intimate = 1000;
- len=sprintf(str,"%d,%d,%s\t%d,%d,%d,%d,%d,%d,%d,%d,%d",
+ len=snprintf(str,sizeof str,"%d,%d,%s\t%d,%d,%d,%d,%d,%d,%d,%d,%d",
p->pet_id,p->class_,p->name,p->account_id,p->char_id,p->level,p->egg_id,
p->equip,p->intimate,p->hungry,p->rename_flag,p->incuvate);
diff --git a/src/char/int_status.c b/src/char/int_status.c
index 52b14ebbe..59779dc83 100644
--- a/src/char/int_status.c
+++ b/src/char/int_status.c
@@ -52,9 +52,9 @@ static void inter_status_tostr(char* line, struct scdata *sc_data)
{
int i, len;
- len = sprintf(line, "%d,%d,%d\t", sc_data->account_id, sc_data->char_id, sc_data->count);
+ len = snprintf(line, sizeof line, "%d,%d,%d\t", sc_data->account_id, sc_data->char_id, sc_data->count);
for(i = 0; i < sc_data->count; i++) {
- len += sprintf(line + len, "%d,%ld,%ld,%ld,%ld,%ld\t", sc_data->data[i].type, sc_data->data[i].tick,
+ len += snprintf(line + len, sizeof (line + len), "%d,%ld,%ld,%ld,%ld,%ld\t", sc_data->data[i].type, sc_data->data[i].tick,
sc_data->data[i].val1, sc_data->data[i].val2, sc_data->data[i].val3, sc_data->data[i].val4);
}
return;
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index bae72fcf4..ff682da87 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -31,17 +31,17 @@ bool storage_tostr(char* str, int account_id, struct storage_data* p)
{
int i,j;
char *str_p = str;
- str_p += sprintf(str_p, "%d,%d\t", account_id, p->storage_amount);
+ str_p += snprintf(str_p, sizeof str_p, "%d,%d\t", account_id, p->storage_amount);
for( i = 0; i < MAX_STORAGE; i++ )
if( p->items[i].nameid > 0 && p->items[i].amount > 0 )
{
- str_p += sprintf(str_p, "%d,%d,%d,%d,%d,%d,%d",
+ str_p += snprintf(str_p, sizeof str_p, "%d,%d,%d,%d,%d,%d,%d",
p->items[i].id,p->items[i].nameid,p->items[i].amount,p->items[i].equip,
p->items[i].identify,p->items[i].refine,p->items[i].attribute);
for(j=0; j<MAX_SLOTS; j++)
- str_p += sprintf(str_p,",%d",p->items[i].card[j]);
- str_p += sprintf(str_p," ");
+ str_p += snprintf(str_p,sizeof str_p,",%d",p->items[i].card[j]);
+ str_p += snprintf(str_p,sizeof str_p," ");
}
*(str_p++)='\t';
@@ -98,16 +98,16 @@ int guild_storage_tostr(char *str,struct guild_storage *p)
{
int i,j,f=0;
char *str_p = str;
- str_p+=sprintf(str,"%d,%d\t",p->guild_id,p->storage_amount);
+ str_p+=snprintf(str,sizeof str,"%d,%d\t",p->guild_id,p->storage_amount);
for(i=0;i<MAX_GUILD_STORAGE;i++)
if( (p->storage_[i].nameid) && (p->storage_[i].amount) ){
- str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d",
+ str_p += snprintf(str_p,sizeof str_p,"%d,%d,%d,%d,%d,%d,%d",
p->storage_[i].id,p->storage_[i].nameid,p->storage_[i].amount,p->storage_[i].equip,
p->storage_[i].identify,p->storage_[i].refine,p->storage_[i].attribute);
for(j=0; j<MAX_SLOTS; j++)
- str_p += sprintf(str_p,",%d",p->storage_[i].card[j]);
- str_p += sprintf(str_p," ");
+ str_p += snprintf(str_p,sizeof str_p,",%d",p->storage_[i].card[j]);
+ str_p += snprintf(str_p,sizeof str_p," ");
f++;
}
diff --git a/src/char/inter.c b/src/char/inter.c
index 8d9cac99f..1c6dceb5c 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -78,9 +78,9 @@ int inter_accreg_tostr(char *str, struct accreg *reg) {
int j;
char *p = str;
- p += sprintf(p, "%d\t", reg->account_id);
+ p += snprintf(p, sizeof p, "%d\t", reg->account_id);
for(j = 0; j < reg->reg_num; j++) {
- p += sprintf(p,"%s,%s ", reg->reg[j].str, reg->reg[j].value);
+ p += snprintf(p, sizeof p, "%s,%s ", reg->reg[j].str, reg->reg[j].value);
}
return 0;