summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authormomacabu <momacabu@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-12-09 02:22:50 +0000
committermomacabu <momacabu@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-12-09 02:22:50 +0000
commitecdcdf7dac66dd3f7404c7851f804bf0c1a60842 (patch)
tree9f5d1baa110085f1f7b2a9961c56cf551bcdb81b /src/char
parentaf7c92046af55175cee59297e4759bd0d3913df7 (diff)
downloadhercules-ecdcdf7dac66dd3f7404c7851f804bf0c1a60842.tar.gz
hercules-ecdcdf7dac66dd3f7404c7851f804bf0c1a60842.tar.bz2
hercules-ecdcdf7dac66dd3f7404c7851f804bf0c1a60842.tar.xz
hercules-ecdcdf7dac66dd3f7404c7851f804bf0c1a60842.zip
* Use sv_readdb to read exp_guild.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@17012 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char')
-rw-r--r--src/char/int_guild.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index b07a1933f..c66f43613 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -599,30 +599,17 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
// Read exp_guild.txt
-int inter_guild_ReadEXP(void)
+static bool exp_guild_parse_row(char* split[], int column, int current)
{
- int i;
- FILE *fp;
- char line[1024];
- for (i=0;i<100;i++) guild_exp[i]=0;
- //this is going to be discussed, temp fix
- sprintf(line, "%s/pre-re/exp_guild.txt", db_path);
- fp=fopen(line,"r");
- if(fp==NULL){
- ShowError("can't read %s\n", line);
- return 1;
- }
- i=0;
- while(fgets(line, sizeof(line), fp) && i < 100)
- {
- if(line[0]=='/' && line[1]=='/')
- continue;
- guild_exp[i]=(unsigned int)atof(line);
- i++;
+ int exp = atoi(split[0]);
+
+ if (exp < 0 || exp >= INT_MAX) {
+ ShowError("exp_guild: Invalid exp %d at line %d\n", exp, current);
+ return false;
}
- fclose(fp);
-
- return 0;
+
+ guild_exp[current] = exp;
+ return true;
}
@@ -738,8 +725,8 @@ int inter_guild_sql_init(void)
guild_db_= idb_alloc(DB_OPT_RELEASE_DATA);
castle_db = idb_alloc(DB_OPT_RELEASE_DATA);
- //Read exp file
- inter_guild_ReadEXP();
+ //Read exp file
+ sv_readdb("db/pre-re", "exp_guild.txt", ',', 1, 1, 100, exp_guild_parse_row);
add_timer_func_list(guild_save_timer, "guild_save_timer");
add_timer(gettick() + 10000, guild_save_timer, 0, 0);