From f1d7cc5777c0a182ae1a69c7277a198085085e11 Mon Sep 17 00:00:00 2001 From: Cydh Ramdh Date: Sun, 15 Feb 2015 10:13:29 +0700 Subject: [PATCH] Homunculus skill tree fix. ~ Thank Philippe Girard Signed-off-by: Cydh Ramdh --- src/map/homunculus.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/map/homunculus.c b/src/map/homunculus.c index be41b87d4cf..5476ecea4a0 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -260,45 +260,47 @@ int hom_delete(struct homun_data *hd, int emote) */ void hom_calc_skilltree(struct homun_data *hd, int flag_evolve) { - int i, skill_id = 0; - int f = 1; + uint8 i; short c = 0; nullpo_retv(hd); /* load previous homunculus form skills first. */ if (hd->homunculus.prev_class != 0 && (c = hom_class2index(hd->homunculus.prev_class)) >= 0) { - for (i = 0; i < MAX_SKILL_TREE && (skill_id = hskill_tree[c][i].id) > 0; i++) { - short idx = hom_skill_get_index(skill_id); - if (idx < 0) + for (i = 0; i < MAX_SKILL_TREE; i++) { + uint16 skill_id; + short idx = -1; + bool fail = false; + if (!(skill_id = hskill_tree[c][i].id) || (idx = hom_skill_get_index(skill_id)) == -1) continue; if (hd->homunculus.hskill[idx].id) continue; //Skill already known. if (!battle_config.skillfree) { - int j; + uint8 j; for (j = 0; j < MAX_HOM_SKILL_REQUIRE; j++) { if (hskill_tree[c][i].need[j].id && hom_checkskill(hd,hskill_tree[c][i].need[j].id) < hskill_tree[c][i].need[j].lv) { - f = 0; + fail = true; break; } } } - if (f) + if (!fail) hd->homunculus.hskill[idx].id = skill_id; } - f = 1; } if ((c = hom_class2index(hd->homunculus.class_)) < 0) return; - for (i = 0; i < MAX_SKILL_TREE && (skill_id = hskill_tree[c][i].id) > 0; i++) { - int intimacy; - short idx = hom_skill_get_index(skill_id); - if (idx < 0) + for (i = 0; i < MAX_SKILL_TREE; i++) { + unsigned int intimacy; + uint16 skill_id; + short idx = -1; + bool fail = false; + if (!(skill_id = hskill_tree[c][i].id) || (idx = hom_skill_get_index(skill_id)) == -1) continue; if (hd->homunculus.hskill[idx].id) continue; //Skill already known. @@ -311,12 +313,12 @@ void hom_calc_skilltree(struct homun_data *hd, int flag_evolve) if (hskill_tree[c][i].need[j].id && hom_checkskill(hd,hskill_tree[c][i].need[j].id) < hskill_tree[c][i].need[j].lv) { - f = 0; + fail = true; break; } } } - if (f) + if (!fail) hd->homunculus.hskill[idx].id = skill_id; } @@ -1468,7 +1470,7 @@ static bool read_homunculus_skilldb_sub(char* split[], int columns, int current) short class_idx, idx = -1; int minJobLevelPresent = 0; - if (columns == 14) + if (columns == 15) minJobLevelPresent = 1; // MinJobLvl has been added // check for bounds [celest] @@ -1506,7 +1508,7 @@ int read_homunculus_skilldb(void) int i; memset(hskill_tree,0,sizeof(hskill_tree)); for(i = 0; i