summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-05-25 15:21:53 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-05-25 15:21:53 +0000
commitb4d6bac9a4d623a9b32188458b26ae424d374bb3 (patch)
tree278b8f86ab39740f7b0dad0e726b10fc4198894a /src/char
parentc842495d17863ebddaf64da006ceb642c70a9ad6 (diff)
downloadhercules-b4d6bac9a4d623a9b32188458b26ae424d374bb3.tar.gz
hercules-b4d6bac9a4d623a9b32188458b26ae424d374bb3.tar.bz2
hercules-b4d6bac9a4d623a9b32188458b26ae424d374bb3.tar.xz
hercules-b4d6bac9a4d623a9b32188458b26ae424d374bb3.zip
Corrected some weird fgets() statements, plus reformatted them
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10616 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char')
-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
8 files changed, 35 insertions, 31 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;