diff options
author | Smokexyz <sagunkho@hotmail.com> | 2017-12-27 22:31:00 +0800 |
---|---|---|
committer | Asheraf <acheraf1998@gmail.com> | 2018-06-03 02:46:15 +0000 |
commit | 652d34f6570b7eb0361ca471f43c68e274962f0a (patch) | |
tree | b304f6e5b66b21e44fffc6cec9de04e537a263cf /src/map/status.c | |
parent | c81fee18c0d5ed70f8717679ee16cebe5e591c58 (diff) | |
download | hercules-652d34f6570b7eb0361ca471f43c68e274962f0a.tar.gz hercules-652d34f6570b7eb0361ca471f43c68e274962f0a.tar.bz2 hercules-652d34f6570b7eb0361ca471f43c68e274962f0a.tar.xz hercules-652d34f6570b7eb0361ca471f43c68e274962f0a.zip |
Conversion of exp.txt to libconfig
Diffstat (limited to 'src/map/status.c')
-rw-r--r-- | src/map/status.c | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/src/map/status.c b/src/map/status.c index 45a8f86bf..bf48d2301 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -13067,6 +13067,7 @@ void status_read_job_db_sub(int idx, const char *name, struct config_setting_t * { struct config_setting_t *temp = NULL; int i32 = 0; + const char *str = NULL; struct { const char *name; @@ -13101,6 +13102,36 @@ void status_read_job_db_sub(int idx, const char *name, struct config_setting_t * #endif }; + /** + * @field BaseExpGroup must be read before any other that deal with exp tables. + */ + if (libconfig->setting_lookup_string(jdb, "BaseExpGroup", &str) != 0) { + int i = 0; + ARR_FIND(0, VECTOR_LENGTH(pc->class_exp_groups[CLASS_EXP_TABLE_BASE]), i, strcmp(str, VECTOR_INDEX(pc->class_exp_groups[CLASS_EXP_TABLE_BASE], i).name) == 0); + if (i == VECTOR_LENGTH(pc->class_exp_groups[CLASS_EXP_TABLE_BASE])) { + ShowError("status_read_job_db: Unknown Base Exp Group '%s' provided for entry '%s'\n", str, name); + } else { + pc->dbs->class_exp_table[idx][CLASS_EXP_TABLE_BASE] = &VECTOR_INDEX(pc->class_exp_groups[CLASS_EXP_TABLE_BASE], i); + } + } else { + ShowError("status_read_job_db: BaseExpGroup setting not found for entry '%s'\n", name); + } + + /** + * @field JobExpGroup must be read before any other that deal with exp tables. + */ + if (libconfig->setting_lookup_string(jdb, "JobExpGroup", &str) != 0) { + int i = 0; + ARR_FIND(0, VECTOR_LENGTH(pc->class_exp_groups[CLASS_EXP_TABLE_JOB]), i, strcmp(str, VECTOR_INDEX(pc->class_exp_groups[CLASS_EXP_TABLE_JOB], i).name) == 0); + if (i == VECTOR_LENGTH(pc->class_exp_groups[CLASS_EXP_TABLE_JOB])) { + ShowError("status_read_job_db: Unknown Job Exp Group '%s' provided for entry '%s'\n", str, name); + } else { + pc->dbs->class_exp_table[idx][CLASS_EXP_TABLE_JOB] = &VECTOR_INDEX(pc->class_exp_groups[CLASS_EXP_TABLE_JOB], i); + } + } else { + ShowError("status_read_job_db: JobExpGroup setting not found for entry '%s'\n", name); + } + if ((temp = libconfig->setting_get_member(jdb, "Inherit"))) { int nidx = 0; const char *iname; @@ -13125,7 +13156,7 @@ void status_read_job_db_sub(int idx, const char *name, struct config_setting_t * } else { avg_increment = 5; } - for ( ; i <= pc->max_level[idx][0]; i++) { + for ( ; i <= pc->dbs->class_exp_table[idx][CLASS_EXP_TABLE_BASE]->max_level; i++) { status->dbs->HP_table[idx][i] = min(base + avg_increment * i, battle_config.max_hp); } @@ -13140,7 +13171,7 @@ void status_read_job_db_sub(int idx, const char *name, struct config_setting_t * } else { avg_increment = 1; } - for ( ; i <= pc->max_level[idx][0]; i++) { + for ( ; i <= pc->dbs->class_exp_table[idx][CLASS_EXP_TABLE_BASE]->max_level; i++) { status->dbs->SP_table[idx][i] = min(base + avg_increment * i, battle_config.max_sp); } } @@ -13166,7 +13197,7 @@ void status_read_job_db_sub(int idx, const char *name, struct config_setting_t * } else { avg_increment = 5; } - for ( ; i <= pc->max_level[idx][0]; i++) { + for ( ; i <= pc->dbs->class_exp_table[idx][CLASS_EXP_TABLE_BASE]->max_level; i++) { status->dbs->HP_table[idx][i] = min(base + avg_increment * i, battle_config.max_hp); } } @@ -13192,7 +13223,7 @@ void status_read_job_db_sub(int idx, const char *name, struct config_setting_t * } else { avg_increment = 1; } - for ( ; i <= pc->max_level[idx][0]; i++) { + for ( ; i <= pc->dbs->class_exp_table[idx][CLASS_EXP_TABLE_BASE]->max_level; i++) { status->dbs->SP_table[idx][i] = min(base + avg_increment * i, battle_config.max_sp); } } @@ -13234,7 +13265,7 @@ void status_read_job_db_sub(int idx, const char *name, struct config_setting_t * } else { avg_increment = 5; } - for (++level; level <= pc->max_level[idx][0]; ++level) { /* limit only to possible maximum level of the given class */ + for (++level; level <= pc->dbs->class_exp_table[idx][CLASS_EXP_TABLE_BASE]->max_level; ++level) { /* limit only to possible maximum level of the given class */ status->dbs->HP_table[idx][level] = min(base + avg_increment * level, battle_config.max_hp); /* some are still empty? then let's use the average increase */ } } @@ -13254,7 +13285,7 @@ void status_read_job_db_sub(int idx, const char *name, struct config_setting_t * } else { avg_increment = 1; } - for (++level; level <= pc->max_level[idx][0]; level++ ) { + for (++level; level <= pc->dbs->class_exp_table[idx][CLASS_EXP_TABLE_BASE]->max_level; level++) { status->dbs->SP_table[idx][level] = min(base + avg_increment * level, battle_config.max_sp); } } @@ -13281,7 +13312,7 @@ void status_read_job_db(void) /* [malufett/Hercules] */ if (!libconfig->load_file(&job_db_conf, config_filename)) return; - while ( (jdb = libconfig->setting_get_elem(job_db_conf.root, i++)) ) { + while ((jdb = libconfig->setting_get_elem(job_db_conf.root, i++))) { int class, idx; const char *name = config_setting_name(jdb); @@ -13293,6 +13324,7 @@ void status_read_job_db(void) /* [malufett/Hercules] */ idx = pc->class2idx(class); status->read_job_db_sub(idx, name, jdb); } + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, config_filename); libconfig->destroy(&job_db_conf); } @@ -13555,6 +13587,8 @@ int status_readdb(void) sv->readdb(map->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, status->readdb_scconfig); status->read_job_db(); + pc->validate_levels(); + return 0; } |