From 11cd2c81ac4b0adab851902d9a0adb7b6c596a96 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Tue, 30 Nov 2010 12:40:36 +0000 Subject: * Made job_db1.txt, job_db2.txt, size_fix.txt and refine_db.txt reading use sv_readdb. - NOTE: Any MAX_LEVEL (map.h) increase requires at least same increase of SV_READDB_MAX_FIELDS as well. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14526 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/status.c | 224 ++++++++++++++++++++++++------------------------------- 1 file changed, 98 insertions(+), 126 deletions(-) (limited to 'src/map') diff --git a/src/map/status.c b/src/map/status.c index 2d30e6df8..7d9a804e5 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -8,6 +8,7 @@ #include "../common/malloc.h" #include "../common/utils.h" #include "../common/ers.h" +#include "../common/strlib.h" #include "map.h" #include "path.h" @@ -7683,146 +7684,117 @@ static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr * size_fix.txt - size adjustment table for weapons * refine_db.txt - refining data table *------------------------------------------*/ -int status_readdb(void) -{ - int i,j,class_; - FILE *fp; - char line[1024], path[1024],*p; - - sprintf(path, "%s/job_db1.txt", db_path); - fp=fopen(path,"r"); // Job-specific values (weight, HP, SP, ASPD) - if(fp==NULL){ - ShowError("can't read %s\n", path); - return 1; +static bool status_readdb_job1(char* fields[], int columns, int current) +{// Job-specific values (weight, HP, SP, ASPD) + int idx, class_; + unsigned int i; + + class_ = atoi(fields[0]); + + if(!pcdb_checkid(class_)) + { + ShowWarning("status_readdb_job1: Invalid job class %d specified.\n", class_); + return false; } - i = 0; - while(fgets(line, sizeof(line), fp)) + idx = pc_class2idx(class_); + + max_weight_base[idx] = atoi(fields[1]); + hp_coefficient[idx] = atoi(fields[2]); + hp_coefficient2[idx] = atoi(fields[3]); + sp_coefficient[idx] = atoi(fields[4]); + + for(i = 0; i < MAX_WEAPON_TYPE; i++) { - //NOTE: entry MAX_WEAPON_TYPE is not counted - char* split[5 + MAX_WEAPON_TYPE]; - i++; - if(line[0]=='/' && line[1]=='/') - continue; - for(j=0,p=line; j < 5 + MAX_WEAPON_TYPE && p; j++){ - split[j]=p; - p=strchr(p,','); - if(p) *p++=0; - } - if(j < 5 + MAX_WEAPON_TYPE) - { //Weapon #.MAX_WEAPON_TYPE is constantly not load. Fix to that: replace < with <= [blackhole89] - ShowDebug("%s: Not enough columns at line %d\n", path, i); - continue; - } - class_ = atoi(split[0]); - if(!pcdb_checkid(class_)) - continue; - class_ = pc_class2idx(class_); - max_weight_base[class_]=atoi(split[1]); - hp_coefficient[class_]=atoi(split[2]); - hp_coefficient2[class_]=atoi(split[3]); - sp_coefficient[class_]=atoi(split[4]); - for(j=0;j