summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/char/char.c30
-rw-r--r--src/char/int_guild.c9
-rw-r--r--src/char/int_homun.c3
-rw-r--r--src/char/int_party.c3
-rw-r--r--src/char/int_pet.c3
-rw-r--r--src/char/int_status.c3
-rw-r--r--src/char/int_storage.c6
-rw-r--r--src/char/inter.c9
-rw-r--r--src/char_sql/char.c12
-rw-r--r--src/char_sql/int_guild.c3
-rw-r--r--src/char_sql/inter.c6
-rw-r--r--src/char_sql/itemdb.c3
-rw-r--r--src/common/core.c8
-rw-r--r--src/common/grfio.c6
-rw-r--r--src/common/mapindex.c3
-rw-r--r--src/common/plugins.c3
-rw-r--r--src/common/socket.c2
-rw-r--r--src/ladmin/ladmin.c7
-rw-r--r--src/login/login.c30
-rw-r--r--src/login_sql/login.c9
-rw-r--r--src/map/atcommand.c19
-rw-r--r--src/map/battle.c3
-rw-r--r--src/map/charcommand.c6
-rw-r--r--src/map/chrif.c3
-rw-r--r--src/map/clif.c2
-rw-r--r--src/map/guild.c6
-rw-r--r--src/map/irc.c3
-rw-r--r--src/map/itemdb.c15
-rw-r--r--src/map/log.c3
-rw-r--r--src/map/map.c6
-rw-r--r--src/map/mercenary.c6
-rw-r--r--src/map/mob.c14
-rw-r--r--src/map/npc.c9
-rw-r--r--src/map/pc.c14
-rw-r--r--src/map/pet.c4
-rw-r--r--src/map/script.c9
-rw-r--r--src/map/skill.c31
-rw-r--r--src/map/status.c14
-rw-r--r--src/plugins/console.c2
-rw-r--r--src/plugins/gui.c5
-rw-r--r--src/tool/adduser.c3
-rw-r--r--src/tool/convert.c3
-rw-r--r--src/tool/grfio.c6
-rw-r--r--src/tool/mapcache.c4
-rw-r--r--src/txt-converter/char-converter.c38
-rw-r--r--src/txt-converter/login-converter.c10
46 files changed, 229 insertions, 167 deletions
diff --git a/src/char/char.c b/src/char/char.c
index d5b4bbb37..a6db79ebb 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -830,10 +830,10 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg
return 1;
}
+
//---------------------------------
// Function to read friend list
//---------------------------------
-
int parse_friend_txt(struct mmo_charstatus *p)
{
char line[1024], temp[1024];
@@ -847,8 +847,8 @@ int parse_friend_txt(struct mmo_charstatus *p)
if(fp == NULL)
return -1;
- while(fgets(line, sizeof(line)-1, fp)) {
-
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0] == '/' && line[1] == '/')
continue;
if (sscanf(line, "%d%n",&i, &pos) < 1 || i != p->char_id)
@@ -888,6 +888,7 @@ int parse_friend_txt(struct mmo_charstatus *p)
fclose(fp);
return count;
}
+
#ifndef TXT_SQL_CONVERT
//---------------------------------
// Function to read characters file
@@ -896,15 +897,11 @@ int mmo_char_init(void)
{
char line[65536];
int ret, line_count;
- FILE *fp;
+ FILE* fp;
- char_max = 256;
- char_dat = (struct character_data*)aCalloc(sizeof(struct character_data) * 256, 1);
- if (!char_dat) {
- ShowFatalError("out of memory: mmo_char_init (calloc of char_dat).\n");
- exit(1);
- }
char_num = 0;
+ char_max = 0;
+ char_dat = NULL;
fp = fopen(char_txt, "r");
@@ -916,13 +913,13 @@ int mmo_char_init(void)
}
line_count = 0;
- while(fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
int i, j;
line_count++;
if (line[0] == '/' && line[1] == '/')
continue;
- line[sizeof(line)-1] = '\0';
j = 0;
if (sscanf(line, "%d\t%%newid%%%n", &i, &j) == 1 && j > 0) {
@@ -3978,13 +3975,12 @@ int char_lan_config_read(const char *lancfgName)
ShowInfo("Reading the configuration file %s...\n", lancfgName);
- while(fgets(line, sizeof(line)-1, fp)) {
-
+ while(fgets(line, sizeof(line), fp))
+ {
line_num++;
if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n')
continue;
- line[sizeof(line)-1] = '\0';
if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) {
ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
@@ -4029,11 +4025,11 @@ int char_config_read(const char *cfgName)
}
ShowInfo("Reading configuration file %s...\n", cfgName);
- while(fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
- line[sizeof(line)-1] = '\0';
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
continue;
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 2cf8b8b91..d347d847e 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -353,7 +353,8 @@ int inter_guild_readdb(void) {
return 1;
}
i = 0;
- while(fgets(line, sizeof(line)-1, fp) && i < 100){
+ while(fgets(line, sizeof(line), fp) && i < 100)
+ {
if (line[0] == '/' && line[1] == '/')
continue;
guild_exp[i] = (unsigned int)atof(line);
@@ -379,7 +380,8 @@ int inter_guild_init() {
if ((fp = fopen(guild_txt,"r")) == NULL)
return 1;
- while(fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
j = 0;
if (sscanf(line, "%d\t%%newid%%\n%n", &i, &j) == 1 && j > 0 && guild_newid <= i) {
guild_newid = i;
@@ -413,7 +415,8 @@ int inter_guild_init() {
return 1;
}
- while(fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
gc = (struct guild_castle *) aCalloc(sizeof(struct guild_castle), 1);
if(gc == NULL){
ShowFatalError("int_guild: out of memory!\n");
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index 43d56359d..bccefa428 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -122,7 +122,8 @@ int inter_homun_init()
if( (fp=fopen(homun_txt,"r"))==NULL )
return 1;
- while(fgets(line,sizeof(line),fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
p = (struct s_homunculus*)aCalloc(sizeof(struct s_homunculus), 1);
if(p==NULL){
ShowFatalError("int_homun: out of memory!\n");
diff --git a/src/char/int_party.c b/src/char/int_party.c
index 2c18f29ab..6d2562668 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -183,7 +183,8 @@ int inter_party_init() {
if ((fp = fopen(party_txt, "r")) == NULL)
return 1;
- while(fgets(line, sizeof(line) - 1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
j = 0;
if (sscanf(line, "%d\t%%newid%%\n%n", &i, &j) == 1 && j > 0 && party_newid <= i) {
party_newid = i;
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 4eb3f5b49..06c962e11 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -92,7 +92,8 @@ int inter_pet_init()
if( (fp=fopen(pet_txt,"r"))==NULL )
return 1;
- while(fgets(line,sizeof(line),fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
p = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1);
if(p==NULL){
ShowFatalError("int_pet: out of memory!\n");
diff --git a/src/char/int_status.c b/src/char/int_status.c
index ccab32431..d03797e1d 100644
--- a/src/char/int_status.c
+++ b/src/char/int_status.c
@@ -98,7 +98,8 @@ void status_load_scdata(const char* filename)
return;
}
- while(fgets(line, sizeof(line) - 1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
sc = (struct scdata*)aCalloc(1, sizeof(struct scdata));
if (inter_scdata_fromstr(line, sc)) {
sd_count++;
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index e19268508..8c9a6faa7 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -204,7 +204,8 @@ int inter_storage_init()
ShowError("can't read : %s\n",storage_txt);
return 1;
}
- while(fgets(line,65535,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
sscanf(line,"%d",&tmp_int);
s = (struct storage*)aCalloc(sizeof(struct storage), 1);
if(s==NULL){
@@ -232,7 +233,8 @@ int inter_storage_init()
ShowError("can't read : %s\n",guild_storage_txt);
return 1;
}
- while(fgets(line,65535,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
sscanf(line,"%d",&tmp_int);
gs = (struct guild_storage*)aCalloc(sizeof(struct guild_storage), 1);
if(gs==NULL){
diff --git a/src/char/inter.c b/src/char/inter.c
index e8051f40c..8dae4766b 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -114,9 +114,8 @@ int inter_accreg_init(void) {
if( (fp = fopen(accreg_txt, "r")) == NULL)
return 1;
- while(fgets(line, sizeof(line)-1, fp)){
- line[sizeof(line)-1] = '\0';
-
+ while(fgets(line, sizeof(line), fp))
+ {
reg = (struct accreg*)aCalloc(sizeof(struct accreg), 1);
if (reg == NULL) {
ShowFatalError("inter: accreg: out of memory!\n");
@@ -181,10 +180,10 @@ static int inter_config_read(const char *cfgName) {
ShowError("file not found: %s\n", cfgName);
return 1;
}
- while(fgets(line, sizeof(line) - 1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
- line[sizeof(line)-1] = '\0';
if (sscanf(line,"%[^:]: %[^\r\n]", w1, w2) != 2)
continue;
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index a1fdc8835..ce09c43dd 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -3674,13 +3674,12 @@ int char_lan_config_read(const char *lancfgName)
ShowInfo("Reading the configuration file %s...\n", lancfgName);
- while(fgets(line, sizeof(line)-1, fp)) {
-
+ while(fgets(line, sizeof(line), fp))
+ {
line_num++;
if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n')
continue;
- line[sizeof(line)-1] = '\0';
if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) {
ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
@@ -3726,7 +3725,8 @@ void sql_config_read(const char *cfgName)
exit(1);
}
- while(fgets(line, sizeof(line)-1, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0] == '/' && line[1] == '/')
continue;
@@ -3826,11 +3826,11 @@ int char_config_read(const char *cfgName)
}
ShowInfo("Reading configuration file %s...\n", cfgName);
- while(fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
- line[sizeof(line)-1] = '\0';
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
continue;
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index 3ecaec839..e516da9e6 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -719,7 +719,8 @@ int inter_guild_ReadEXP(void)
return 1;
}
i=0;
- while(fgets(line,256,fp) && i<100){
+ while(fgets(line, sizeof(line), fp) && i < 100)
+ {
if(line[0]=='/' && line[1]=='/')
continue;
guild_exp[i]=(unsigned int)atof(line);
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c
index 0702ed3e7..8f2386a91 100644
--- a/src/char_sql/inter.c
+++ b/src/char_sql/inter.c
@@ -1,9 +1,6 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-// original code from athena
-// SQL conversion by Jioh L. Jung
-
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -204,7 +201,8 @@ static int inter_config_read(const char *cfgName)
ShowInfo("reading file %s...\n",cfgName);
- while(fgets(line, 1020, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2);
if(i!=2)
continue;
diff --git a/src/char_sql/itemdb.c b/src/char_sql/itemdb.c
index a5c2aa8f0..b03d76bfe 100644
--- a/src/char_sql/itemdb.c
+++ b/src/char_sql/itemdb.c
@@ -92,7 +92,8 @@ static int itemdb_readdb(void)
}
lines=0;
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
lines++;
if(line[0]=='/' && line[1]=='/')
continue;
diff --git a/src/common/core.c b/src/common/core.c
index deac7a514..3cde639f6 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -139,7 +139,7 @@ const char* get_svn_revision(void)
char line[1024];
int rev;
// Check the version
- if (fgets(line,sizeof(line),fp))
+ if (fgets(line, sizeof(line), fp))
{
if(!ISDIGIT(line[0]))
{
@@ -153,9 +153,9 @@ const char* get_svn_revision(void)
else
{
// Bin File format
- fgets(line,sizeof(line),fp); // Get the name
- fgets(line,sizeof(line),fp); // Get the entries kind
- if(fgets(line,sizeof(line),fp)) // Get the rev numver
+ fgets(line, sizeof(line), fp); // Get the name
+ fgets(line, sizeof(line), fp); // Get the entries kind
+ if(fgets(line, sizeof(line), fp)) // Get the rev numver
{
snprintf(eA_svn_version, sizeof(eA_svn_version), "%d", atoi(line));
}
diff --git a/src/common/grfio.c b/src/common/grfio.c
index f5de9fbdb..4b68ea9fc 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -700,7 +700,8 @@ static void grfio_resourcecheck(void)
fp = fopen(restable, "rb");
if (fp) {
- while (fgets(line, sizeof(line) - 1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (sscanf(line, "%[^#]#%[^#]#", w1, w2) == 2 &&
// we only need the maps' GAT and RSW files
(strstr(w2, ".gat") || strstr(w2, ".rsw")))
@@ -807,7 +808,8 @@ void grfio_init(char* fname)
data_conf = fopen(fname, "r");
// It will read, if there is grf-files.txt.
if (data_conf) {
- while(fgets(line, sizeof(line) - 1, data_conf)) {
+ while(fgets(line, sizeof(line), data_conf))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index 36bd32cb5..e60287a38 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -115,7 +115,8 @@ void mapindex_init(void)
ShowFatalError("Unable to read mapindex config file %s!\n", mapindex_cfgfile);
exit(1); //Server can't really run without this file.
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0] == '/' && line[1] == '/')
continue;
diff --git a/src/common/plugins.c b/src/common/plugins.c
index 5a55e84e4..76dfc5956 100644
--- a/src/common/plugins.c
+++ b/src/common/plugins.c
@@ -303,7 +303,8 @@ static int plugins_config_read(const char *cfgName)
ShowError("File not found: %s\n", cfgName);
return 1;
}
- while( fgets(line, 1020, fp) ){
+ while( fgets(line, sizeof(line), fp) )
+ {
if( line[0] == '/' && line[1] == '/' )
continue;
if( sscanf(line,"%[^:]: %[^\r\n]",w1,w2) != 2 )
diff --git a/src/common/socket.c b/src/common/socket.c
index 3d00ed8ce..11b273d61 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -898,7 +898,7 @@ int socket_config_read(const char* cfgName)
return 1;
}
- while(fgets(line,1020,fp))
+ while(fgets(line, sizeof(line), fp))
{
if(line[0] == '/' && line[1] == '/')
continue;
diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c
index 9027d7e07..7d8815eb2 100644
--- a/src/ladmin/ladmin.c
+++ b/src/ladmin/ladmin.c
@@ -3053,8 +3053,7 @@ int prompt(void)
// get command and parameter
memset(buf, '\0', sizeof(buf));
fflush(stdin);
- fgets(buf, 1023, stdin);
- buf[1023] = '\0';
+ fgets(buf, sizeof(buf), stdin);
ShowMessage("\033[0m");
fflush(stdout);
@@ -4256,11 +4255,11 @@ int ladmin_config_read(const char *cfgName)
} else {
ShowMessage("\033[0m---Start reading of Ladmin configuration file (%s)\n", cfgName);
}
- while(fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
- line[sizeof(line)-1] = '\0';
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
remove_control_chars(w1);
remove_control_chars(w2);
diff --git a/src/login/login.c b/src/login/login.c
index c507cc2cc..6b432a87f 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -321,8 +321,8 @@ int read_gm_account(void)
int start_range = 0, end_range = 0, is_range = 0, current_id = 0;
if(gm_account_db) aFree(gm_account_db);
- GM_num = 0;
gm_account_db = (struct gm_account*)aCalloc(GM_max, sizeof(struct gm_account));
+ GM_num = 0;
// get last modify time/date
if (stat(GM_account_filename, &file_stat))
@@ -341,7 +341,8 @@ int read_gm_account(void)
line_counter = 0;
// limited to 4000, because we send information to char-servers (more than 4000 GM accounts???)
// int (id) + int (level) = 8 bytes * 4000 = 32k (limit of packets in windows)
- while(fgets(line, sizeof(line)-1, fp) && GM_num < 4000) {
+ while(fgets(line, sizeof(line), fp) && GM_num < 4000)
+ {
line_counter++;
if ((line[0] == '/' && line[1] == '/') || line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
continue;
@@ -572,13 +573,11 @@ int mmo_auth_init(void)
return 0;
}
- while(fgets(line, sizeof(line)-1, fp) != NULL) {
+ while(fgets(line, sizeof(line), fp) != NULL)
+ {
if (line[0] == '/' && line[1] == '/')
continue;
- line[sizeof(line)-1] = '\0';
- // remove carriage return if exist
- while(line[0] != '\0' && (line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r'))
- line[strlen(line)-1] = '\0';
+
p = line;
memset(userid, 0, sizeof(userid));
@@ -2394,9 +2393,10 @@ int parse_admin(int fd)
strftime(tmpstr, 23, date_format, localtime(&raw_time));
modify_flag = 0;
// read/write GM file
- while(fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
while(line[0] != '\0' && (line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r'))
- line[strlen(line)-1] = '\0';
+ line[strlen(line)-1] = '\0'; // TODO: remove this
if ((line[0] == '/' && line[1] == '/') || line[0] == '\0')
fprintf(fp2, "%s" RETCODE, line);
else {
@@ -3421,15 +3421,14 @@ int login_lan_config_read(const char *lancfgName)
ShowInfo("Reading the configuration file %s...\n", lancfgName);
- while(fgets(line, sizeof(line)-1, fp)) {
-
+ while(fgets(line, sizeof(line), fp))
+ {
line_num++;
if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n')
continue;
- line[sizeof(line)-1] = '\0';
- if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) {
-
+ if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4)
+ {
ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
continue;
}
@@ -3472,12 +3471,11 @@ int login_config_read(const char* cfgName)
return 1;
}
ShowInfo("Reading configuration file %s...\n", cfgName);
- while (fgets(line, sizeof(line)-1, fp))
+ while(fgets(line, sizeof(line), fp))
{
if (line[0] == '/' && line[1] == '/')
continue;
- line[sizeof(line)-1] = '\0';
memset(w2, 0, sizeof(w2));
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2)
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index f42eb681a..aabb3611d 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -1743,13 +1743,12 @@ int login_lan_config_read(const char *lancfgName)
ShowInfo("Reading the configuration file %s...\n", lancfgName);
- while(fgets(line, sizeof(line)-1, fp)) {
-
+ while(fgets(line, sizeof(line), fp))
+ {
line_num++;
if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n')
continue;
- line[sizeof(line)-1] = '\0';
if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) {
ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
@@ -1807,7 +1806,7 @@ int login_config_read(const char* cfgName)
return 1;
}
ShowInfo("Reading configuration file %s...\n", cfgName);
- while (fgets(line, sizeof(line)-1, fp))
+ while(fgets(line, sizeof(line), fp))
{
if (line[0] == '/' && line[1] == '/')
continue;
@@ -1894,7 +1893,7 @@ void sql_config_read(const char* cfgName)
exit(1);
}
ShowInfo("reading configuration file %s...\n", cfgName);
- while (fgets(line, sizeof(line)-1, fp))
+ while(fgets(line, sizeof(line), fp))
{
if (line[0] == '/' && line[1] == '/')
continue;
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 642a1f97e..87bf2a4d5 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -822,7 +822,8 @@ int msg_config_read(const char *cfgName)
if ((--called) == 0)
memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
- while(fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
@@ -884,7 +885,8 @@ int atcommand_config_read(const char *cfgName)
return 1;
}
- while (fgets(line, sizeof(line)-1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
@@ -2713,7 +2715,7 @@ int atcommand_help(const int fd, struct map_session_data* sd, const char* comman
if ((fp = fopen(help_txt, "r")) != NULL) {
clif_displaymessage(fd, msg_txt(26)); // Help commands:
gm_level = pc_isGM(sd);
- while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
+ while(fgets(buf, sizeof(buf), fp) != NULL) {
if (buf[0] == '/' && buf[1] == '/')
continue;
for (i = 0; buf[i] != '\0'; i++) {
@@ -2751,7 +2753,7 @@ int atcommand_help2(const int fd, struct map_session_data* sd, const char* comma
if ((fp = fopen(help2_txt, "r")) != NULL) {
clif_displaymessage(fd, msg_txt(26)); // Help commands:
gm_level = pc_isGM(sd);
- while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
+ while(fgets(buf, sizeof(buf), fp) != NULL) {
if (buf[0] == '/' && buf[1] == '/')
continue;
for (i = 0; buf[i] != '\0'; i++) {
@@ -7778,13 +7780,14 @@ int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* comma
char buf[256];
FILE *fp;
nullpo_retr(-1, sd);
- if( (fp = fopen(motd_txt, "r"))!=NULL){
- while (fgets(buf, 250, fp) != NULL){
+ if((fp = fopen(motd_txt, "r"))!=NULL){
+ while(fgets(buf, sizeof(buf), fp) != NULL)
+ {
int i;
if (buf[0] == '/' && buf[1] == '/')
continue;
- for( i=0; buf[i]; i++){
- if( buf[i]=='\r' || buf[i]=='\n'){
+ for(i=0; buf[i]; i++){
+ if(buf[i]=='\r' || buf[i]=='\n'){
buf[i]=0;
break;
}
diff --git a/src/map/battle.c b/src/map/battle.c
index cee92d515..06329b3bb 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -4304,7 +4304,8 @@ int battle_config_read(const char *cfgName)
ShowError("File not found: %s\n", cfgName);
return 1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
if (sscanf(line, "%[^:]:%s", w1, w2) != 2)
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index 7d4151b64..7f0f9b089 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -379,7 +379,8 @@ int charcommand_config_read(const char *cfgName)
return 1;
}
- while (fgets(line, sizeof(line)-1, fp)) {
+ while (fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
@@ -1852,7 +1853,8 @@ int charcommand_help(const int fd, struct map_session_data* sd, const char* comm
if ((fp = fopen(charhelp_txt, "r")) != NULL) {
clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
gm_level = pc_isGM(sd);
- while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
+ while(fgets(buf, sizeof(buf), fp) != NULL)
+ {
if (buf[0] == '/' && buf[1] == '/')
continue;
for (i = 0; buf[i] != '\0'; i++) {
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 1adee71a9..4b5dde218 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1246,7 +1246,8 @@ int chrif_load_scdata(int fd)
WFIFOW(char_fd,6) = drop_rate;
if ((fp = fopen(motd_txt, "r")) != NULL) {
- if (fgets(buf, 250, fp) != NULL) {
+ if (fgets(buf, sizeof(buf), fp) != NULL)
+ {
for(i = 0; buf[i]; i++) {
if (buf[i] == '\r' || buf[i] == '\n') {
buf[i] = 0;
diff --git a/src/map/clif.c b/src/map/clif.c
index a4ffc3b6b..4cc6da374 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11924,7 +11924,7 @@ static int packetdb_readdb(void)
clif_config.packet_db_ver = MAX_PACKET_VER;
packet_ver = MAX_PACKET_VER; // read into packet_db's version by default
- while( fgets(line,sizeof(line),fp) )
+ while( fgets(line, sizeof(line), fp) )
{
ln++;
if(line[0]=='/' && line[1]=='/')
diff --git a/src/map/guild.c b/src/map/guild.c
index 857eeffb0..c6dbe7515 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -99,7 +99,8 @@ int guild_read_guildskill_tree_db(void)
ShowError("can't read %s\n", line);
return -1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[50];
if(line[0]=='/' && line[1]=='/')
continue;
@@ -165,7 +166,8 @@ static int guild_read_castledb(void)
return -1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0]=='/' && line[1]=='/')
continue;
memset(str,0,sizeof(str));
diff --git a/src/map/irc.c b/src/map/irc.c
index e74b89efa..c9ca87202 100644
--- a/src/map/irc.c
+++ b/src/map/irc.c
@@ -515,7 +515,8 @@ int irc_read_conf(char *file)
return 0;
}
- while(fgets(row,1023,fp)!=NULL) {
+ while(fgets(row, sizeof(row), fp) != NULL)
+ {
if(row[0]=='/'&&row[1]=='/')
continue;
sscanf(row,"%[^:]: %255[^\r\n]",w1,w2);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 7e450fe4d..bf23c5280 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -404,7 +404,8 @@ static int itemdb_read_itemavail (void)
return -1;
}
- while (fgets(line, sizeof(line) - 1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
memset(str, 0, sizeof(str));
@@ -449,7 +450,8 @@ static void itemdb_read_itemgroup_sub(const char* filename)
return;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
ln++;
if(line[0]=='/' && line[1]=='/')
continue;
@@ -523,7 +525,8 @@ static int itemdb_read_noequip(void)
ShowError("can't read %s\n", line);
return -1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0]=='/' && line[1]=='/')
continue;
memset(str,0,sizeof(str));
@@ -567,7 +570,8 @@ static int itemdb_read_itemtrade(void)
return -1;
}
- while (fgets(line, sizeof(line) - 1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
memset(str, 0, sizeof(str));
@@ -819,7 +823,8 @@ static int itemdb_readdb(void)
}
lines=0;
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
lines++;
if(line[0]=='/' && line[1]=='/')
continue;
diff --git a/src/map/log.c b/src/map/log.c
index 5ee1a2d83..97726bb6e 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -1,7 +1,6 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-// Logging functions by Azndragon & Codemaster
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -419,7 +418,7 @@ int log_config_read(char *cfgName)
return 1;
}
- while(fgets(line, sizeof(line) -1, fp))
+ while(fgets(line, sizeof(line), fp))
{
if(line[0] == '/' && line[1] == '/')
continue;
diff --git a/src/map/map.c b/src/map/map.c
index 6df33fe26..1acee0c9b 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2777,7 +2777,8 @@ int map_config_read(char *cfgName)
ShowFatalError("Map configuration file not found at: %s\n", cfgName);
exit(1);
}
- while(fgets(line, sizeof(line) -1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
@@ -2877,7 +2878,8 @@ int inter_config_read(char *cfgName)
ShowError("File not found: '%s'.\n",cfgName);
return 1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0] == '/' && line[1] == '/')
continue;
i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2);
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 899764ec8..4f39607b1 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -823,7 +823,7 @@ int read_homunculusdb(void)
return -1;
}
- while(fgets(line,sizeof(line)-1,fp) && j < MAX_HOMUNCULUS_CLASS)
+ while(fgets(line, sizeof(line), fp) && j < MAX_HOMUNCULUS_CLASS)
{
if(line[0] == '/' && line[1] == '/')
continue;
@@ -924,7 +924,7 @@ int read_homunculus_skilldb(void)
return 1;
}
- while(fgets(line, sizeof(line)-1, fp))
+ while(fgets(line, sizeof(line), fp))
{
int minJobLevelPresent = 0;
@@ -993,7 +993,7 @@ void read_homunculus_expdb(void)
ShowError("can't read %s\n",line);
return;
}
- while(fgets(line,sizeof(line)-1,fp) && j < MAX_LEVEL)
+ while(fgets(line, sizeof(line), fp) && j < MAX_LEVEL)
{
if(line[0] == '/' && line[1] == '/')
continue;
diff --git a/src/map/mob.c b/src/map/mob.c
index 79ae84435..74c658109 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -3427,7 +3427,7 @@ static int mob_readdb(void)
return -1;
}
- while(fgets(line, 1020, fp))
+ while(fgets(line, sizeof(line), fp))
{
char *str[38+2*MAX_MOB_DROP], *p, *np;
@@ -3511,7 +3511,8 @@ static int mob_readdb_mobavail(void)
return -1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0]=='/' && line[1]=='/')
continue;
memset(str,0,sizeof(str));
@@ -3589,7 +3590,8 @@ static int mob_read_randommonster(void)
ShowError("can't read %s\n",line);
return -1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
int class_,per;
if(line[0] == '/' && line[1] == '/')
continue;
@@ -3708,7 +3710,8 @@ static int mob_readskilldb(void)
ShowError("can't read %s\n",line);
continue;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *sp[20],*p;
int mob_id;
struct mob_skill *ms, gms;
@@ -3919,7 +3922,8 @@ static int mob_readdb_race(void)
return -1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0]=='/' && line[1]=='/')
continue;
memset(str,0,sizeof(str));
diff --git a/src/map/npc.c b/src/map/npc.c
index 61a8ef093..eca640b1f 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1900,7 +1900,7 @@ static int npc_skip_script (char *w1,char *w2,char *w3,char *w4,char *first_line
srcbuf[0] = 0;
npc_parse_script_line(srcbuf,&curly_count,*lines);
while (curly_count > 0) {
- fgets ((char *)line, 1020, fp);
+ fgets ((char *)line, sizeof(line), fp);
(*lines)++;
npc_parse_script_line(line,&curly_count,*lines);
if (feof(fp))
@@ -1964,7 +1964,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
srcbuf[0] = 0;
npc_parse_script_line(srcbuf,&curly_count,*lines);
while (curly_count > 0) {
- fgets ((char *)line, 1020, fp);
+ fgets((char *)line, sizeof(line), fp);
(*lines)++;
npc_parse_script_line(line,&curly_count,*lines);
if (feof(fp))
@@ -2272,7 +2272,7 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
npc_parse_script_line(srcbuf,&curly_count,*lines);
while (curly_count > 0) {
- fgets(line, sizeof(line) - 1, fp);
+ fgets(line, sizeof(line), fp);
(*lines)++;
npc_parse_script_line(line,&curly_count,*lines);
if (feof(fp))
@@ -2780,7 +2780,8 @@ void npc_parsesrcfile(const char* name)
}
current_file = name;
- while (fgets(line, sizeof(line) - 1, fp)) {
+ while (fgets(line, sizeof(line), fp))
+ {
char w1[2048], w2[2048], w3[2048], w4[2048], mapname[2048];
int i, w4pos, count;
lines++;
diff --git a/src/map/pc.c b/src/map/pc.c
index 22dad96f0..8692599f1 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -7344,7 +7344,8 @@ int pc_readdb(void)
ShowError("can't read %s\n", line);
return 1;
}
- while(fgets(line, sizeof(line)-1, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
int jobs[MAX_PC_CLASS], job_count, job;
int type;
unsigned int ui,maxlv;
@@ -7422,7 +7423,8 @@ int pc_readdb(void)
return 1;
}
- while(fgets(line, sizeof(line)-1, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[50];
int f=0, m=3;
if(line[0]=='/' && line[1]=='/')
@@ -7472,7 +7474,8 @@ int pc_readdb(void)
ShowError("can't read %s\n", line);
return 1;
}
- while(fgets(line, sizeof(line)-1, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[10];
int lv,n;
if(line[0]=='/' && line[1]=='/')
@@ -7486,7 +7489,7 @@ int pc_readdb(void)
n=atoi(split[1]);
for(i=0;i<n && i<ELE_MAX;){
- if( !fgets(line, sizeof(line)-1, fp) )
+ if( !fgets(line, sizeof(line), fp) )
break;
if(line[0]=='/' && line[1]=='/')
continue;
@@ -7517,7 +7520,8 @@ int pc_readdb(void)
ShowStatus("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line);
//return 1;
} else {
- while(fgets(line, sizeof(line)-1, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0]=='/' && line[1]=='/')
continue;
if ((j=atoi(line))<0)
diff --git a/src/map/pet.c b/src/map/pet.c
index 82168ac48..866d8ca67 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -1299,8 +1299,8 @@ int read_petdb()
return -1;
}
lines = 0;
- while(fgets(line,1020,fp) && j < MAX_PET_DB){
-
+ while(fgets(line, sizeof(line), fp) && j < MAX_PET_DB)
+ {
lines++;
if(line[0] == '/' && line[1] == '/')
diff --git a/src/map/script.c b/src/map/script.c
index 46042f085..56e8174ae 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1680,7 +1680,8 @@ static void read_constdb(void)
ShowError("can't read %s\n", line);
return ;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0]=='/' && line[1]=='/')
continue;
type=0;
@@ -3079,7 +3080,8 @@ static int script_load_mapreg(void)
if( (fp=fopen(mapreg_txt,"rt"))==NULL )
return -1;
- while(fgets(line,sizeof(line),fp)){
+ while(fgets(line,sizeof(line),fp))
+ {
char buf1[256],buf2[1024],*p;
int n,v,s,i;
if( sscanf(line,"%255[^,],%d\t%n",buf1,&i,&n)!=2 &&
@@ -3273,7 +3275,8 @@ int script_config_read_sub(char *cfgName)
ShowError("file not found: [%s]\n", cfgName);
return 1;
}
- while(fgets(line,sizeof(line)-1,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0] == '/' && line[1] == '/')
continue;
i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2);
diff --git a/src/map/skill.c b/src/map/skill.c
index 0fff9ba0c..efadefe9c 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -859,7 +859,7 @@ int skillnotok (int skillid, struct map_session_data *sd)
return 1;
if (battle_config.gm_skilluncond && pc_isGM(sd) >= battle_config.gm_skilluncond)
- return 0; // gm's can do anything damn thing they want
+ return 0; // GMs can do any damn thing they want
if (sd->blockskill[i] > 0)
return 1;
@@ -8726,7 +8726,7 @@ int skill_castfix_sc (struct block_list *bl, int time)
}
/*==========================================
- * Does delay reductions based on dex,
+ * Does delay reductions based on dex, sc data, item bonuses, ...
*------------------------------------------*/
int skill_delayfix (struct block_list *bl, int skill_id, int skill_lv)
{
@@ -11186,7 +11186,8 @@ int skill_readdb (void)
ShowError("can't read %s\n", path);
return 1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[50];
if(line[0]=='/' && line[1]=='/')
continue;
@@ -11248,7 +11249,8 @@ int skill_readdb (void)
ShowError("can't read %s\n", path);
return 1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[50];
if(line[0]=='/' && line[1]=='/')
continue;
@@ -11335,7 +11337,8 @@ int skill_readdb (void)
}
l=0;
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[50];
l++;
memset(split,0,sizeof(split)); // [Valaris] thanks to fov
@@ -11373,7 +11376,8 @@ int skill_readdb (void)
return 1;
}
k = 0;
- while (fgets(line,1020,fp)) {
+ while (fgets(line, sizeof(line), fp))
+ {
char *split[50];
if (line[0]=='/' && line[1]=='/')
continue;
@@ -11434,7 +11438,8 @@ int skill_readdb (void)
ShowError("can't read %s\n",path);
return 1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[7 + MAX_PRODUCE_RESOURCE * 2];
int x,y;
if(line[0]=='/' && line[1]=='/')
@@ -11475,7 +11480,8 @@ int skill_readdb (void)
return 1;
}
k=0;
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[16];
int x,y;
if(line[0]=='/' && line[1]=='/')
@@ -11509,7 +11515,8 @@ int skill_readdb (void)
return 1;
}
k=0;
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[16];
if(line[0]=='/' && line[1]=='/')
continue;
@@ -11537,7 +11544,8 @@ int skill_readdb (void)
ShowError("can't read %s\n", path);
return 1;
}
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[50];
if(line[0]=='/' && line[1]=='/')
continue;
@@ -11566,7 +11574,8 @@ int skill_readdb (void)
return 1;
}
k=0;
- while(fgets(line,1020,fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[16];
if(line[0]=='/' && line[1]=='/')
continue;
diff --git a/src/map/status.c b/src/map/status.c
index 54b6db02e..27b18fbbc 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -7282,7 +7282,8 @@ int status_readdb(void)
return 1;
}
i = 0;
- while(fgets(line, sizeof(line)-1, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[MAX_WEAPON_TYPE + 5];
i++;
if(line[0]=='/' && line[1]=='/')
@@ -7317,8 +7318,9 @@ int status_readdb(void)
ShowError("can't read %s\n", path);
return 1;
}
- while(fgets(line, sizeof(line)-1, fp)){
- char *split[MAX_LEVEL+1]; //Job Level is limited to MAX_LEVEL, so the bonuses should likewise be limited to it. [Skotlex]
+ while(fgets(line, sizeof(line), fp))
+ {
+ char *split[MAX_LEVEL+1]; //Job Level is limited to MAX_LEVEL, so the bonuses should likewise be limited to it. [Skotlex]
if(line[0]=='/' && line[1]=='/')
continue;
for(j=0,p=line;j<MAX_LEVEL+1 && p;j++){
@@ -7345,7 +7347,8 @@ int status_readdb(void)
return 1;
}
i=0;
- while(fgets(line, sizeof(line)-1, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[MAX_WEAPON_TYPE];
if(line[0]=='/' && line[1]=='/')
continue;
@@ -7380,7 +7383,8 @@ int status_readdb(void)
return 1;
}
i=0;
- while(fgets(line, sizeof(line)-1, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
char *split[MAX_REFINE+4];
if(line[0]=='/' && line[1]=='/')
continue;
diff --git a/src/plugins/console.c b/src/plugins/console.c
index f5f512dcb..5374d784f 100644
--- a/src/plugins/console.c
+++ b/src/plugins/console.c
@@ -406,7 +406,7 @@ WORKER_FUNC_START(getinput)
{// get input
input_setstate(INPUT_READING);
buf.arr[0] = '\0';
- fgets(buf.arr, INPUT_BUFSIZE-1, stdin);
+ fgets(buf.arr, INPUT_BUFSIZE, stdin);
buf.len = strlen(buf.arr);
input_setstate(INPUT_READY);
}
diff --git a/src/plugins/gui.c b/src/plugins/gui.c
index 84b61dab1..ecbfd3b97 100644
--- a/src/plugins/gui.c
+++ b/src/plugins/gui.c
@@ -1,3 +1,5 @@
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
#include <stdio.h>
#include <string.h>
@@ -70,7 +72,8 @@ void gui_init ()
if (fp == NULL)
break;
- while(fgets(line, sizeof(line) -1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
diff --git a/src/tool/adduser.c b/src/tool/adduser.c
index 592729df6..1140bd6ff 100644
--- a/src/tool/adduser.c
+++ b/src/tool/adduser.c
@@ -50,7 +50,8 @@ int main(int argc, char *argv[])
}
next_id = 2000000;
- while(fgets(line, sizeof(line)-1, FPaccin)) {
+ while(fgets(line, sizeof(line), FPaccin))
+ {
if (line[0] == '/' && line[1] == '/') { continue; }
if (sscanf(line, "%d\t%%newid%%\n", &id) == 1) {
if (next_id < id) {
diff --git a/src/tool/convert.c b/src/tool/convert.c
index 5cb096fdb..2959eb826 100644
--- a/src/tool/convert.c
+++ b/src/tool/convert.c
@@ -276,7 +276,8 @@ int mmo_char_convert(char *fname1,char *fname2)
printf("file open error %s\n",fname2);
return 0;
}
- while(fgets(line,65535,ifp)){
+ while(fgets(line, sizeof(line), ifp))
+ {
memset(&char_dat,0,sizeof(struct mmo_charstatus));
ret=mmo_char_fromstr(line,&char_dat);
if(ret){
diff --git a/src/tool/grfio.c b/src/tool/grfio.c
index 2961dc0ec..b9c03cbc5 100644
--- a/src/tool/grfio.c
+++ b/src/tool/grfio.c
@@ -703,7 +703,8 @@ static void grfio_resourcecheck(void)
fp = fopen(restable, "rb");
if (fp) {
- while (fgets(line, sizeof(line) - 1, fp)) {
+ while(fgets(line, sizeof(line), fp))
+ {
if (sscanf(line, "%[^#]#%[^#]#", w1, w2) == 2 &&
// we only need the maps' GAT and RSW files
(strstr(w2, ".gat") || strstr(w2, ".rsw")))
@@ -806,7 +807,8 @@ void grfio_init(char* fname)
data_conf = fopen(fname, "r");
// It will read, if there is grf-files.txt.
if (data_conf) {
- while(fgets(line, sizeof(line) - 1, data_conf)) {
+ while(fgets(line, sizeof(line), data_conf))
+ {
if (line[0] == '/' && line[1] == '/')
continue;
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c
index 5db46c123..095245da4 100644
--- a/src/tool/mapcache.c
+++ b/src/tool/mapcache.c
@@ -296,8 +296,8 @@ int main(int argc, char *argv[])
}
// Read and process the map list
- while(fgets(line, 1020, list)){
-
+ while(fgets(line, sizeof(line), list))
+ {
if(line[0] == '/' && line[1] == '/')
continue;
diff --git a/src/txt-converter/char-converter.c b/src/txt-converter/char-converter.c
index b1aae0ca5..9dd677938 100644
--- a/src/txt-converter/char-converter.c
+++ b/src/txt-converter/char-converter.c
@@ -55,7 +55,8 @@ int convert_init(void)
return 0;
}
lineno = count = 0;
- while(fgets(line, 65535, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
lineno++;
memset(&char_dat, 0, sizeof(char_dat));
ret=mmo_char_fromstr(line, &char_dat.status, char_dat.global, &char_dat.global_num);
@@ -82,8 +83,9 @@ int convert_init(void)
ShowError("Unable to open file %s!", accreg_txt);
return 1;
}
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
+ lineno = count = 0;
+ while(fgets(line, sizeof(line), fp))
+ {
lineno++;
memset (&reg, 0, sizeof(struct accreg));
if(inter_accreg_fromstr(line, &reg) == 0 && reg.account_id > 0) {
@@ -110,8 +112,9 @@ int convert_init(void)
ShowError("can't read : %s\n",storage_txt);
return 0;
}
- lineno=count=0;
- while(fgets(line,65535,fp)){
+ lineno = count = 0;
+ while(fgets(line, sizeof(line), fp))
+ {
lineno++;
set=sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]);
if(set==2) {
@@ -142,8 +145,9 @@ int convert_init(void)
ShowError("Unable to open file %s!", pet_txt);
return 1;
}
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
+ lineno = count = 0;
+ while(fgets(line, sizeof(line), fp))
+ {
lineno++;
memset (&p, 0, sizeof(struct s_pet));
if(inter_pet_fromstr(line, &p)==0 && p.pet_id>0){
@@ -170,8 +174,9 @@ int convert_init(void)
ShowError("Unable to open file %s!", party_txt);
return 1;
}
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
+ lineno = count = 0;
+ while(fgets(line, sizeof(line), fp))
+ {
lineno++;
memset (&p, 0, sizeof(struct party));
if(inter_party_fromstr(line, &p) == 0 &&
@@ -200,8 +205,9 @@ int convert_init(void)
ShowError("Unable to open file %s!", guild_txt);
return 1;
}
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
+ lineno = count = 0;
+ while(fgets(line, sizeof(line), fp))
+ {
lineno++;
memset (&g, 0, sizeof(struct guild));
if (inter_guild_fromstr(line, &g) == 0 &&
@@ -219,8 +225,9 @@ int convert_init(void)
ShowError("Unable to open file %s!", castle_txt);
return 1;
}
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
+ lineno = count = 0;
+ while(fgets(line, sizeof(line), fp))
+ {
lineno++;
memset (&gc, 0, sizeof(struct guild_castle));
if (inter_guildcastle_fromstr(line, &gc) == 0) {
@@ -247,8 +254,9 @@ int convert_init(void)
ShowError("can't read : %s\n",guild_storage_txt);
return 0;
}
- lineno=count=0;
- while(fgets(line,65535,fp)){
+ lineno = count = 0;
+ while(fgets(line, sizeof(line), fp))
+ {
lineno++;
memset(&storage_, 0, sizeof(struct guild_storage));
if (sscanf(line,"%d",&storage_.guild_id) == 1 &&
diff --git a/src/txt-converter/login-converter.c b/src/txt-converter/login-converter.c
index 020fd8008..687689dad 100644
--- a/src/txt-converter/login-converter.c
+++ b/src/txt-converter/login-converter.c
@@ -67,7 +67,8 @@ int read_gm_account()
if( (fp=fopen("conf/GM_account.txt","r"))==NULL )
return 1;
- while(fgets(line,sizeof(line),fp)){
+ while(fgets(line,sizeof(line),fp))
+ {
if(line[0] == '/' || line[1] == '/' || line[2] == '/')
continue;
@@ -124,8 +125,8 @@ int mmo_auth_init(void)
auth_dat = (struct auth_dat_*)malloc(sizeof(auth_dat[0])*256);
if(fp==NULL)
return 0;
- while(fgets(line,1023,fp)!=NULL){
-
+ while(fgets(line,1023,fp)!=NULL)
+ {
if(line[0]=='/' && line[1]=='/')
continue;
@@ -175,7 +176,8 @@ int login_config_read(const char *cfgName)
return 1;
}
- while(fgets(line, 1020, fp)){
+ while(fgets(line, sizeof(line), fp))
+ {
if(line[0] == '/' && line[1] == '/')
continue;