diff options
author | Haru <haru@dotalux.com> | 2016-01-03 03:45:30 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-01-03 21:46:15 +0100 |
commit | 818acc5866707b9e294a87d2dd902aebb670707f (patch) | |
tree | 1d507deb7d066ab066bdab2cf7bd4f549c471278 /src/map/skill.c | |
parent | 87476b17df574f4c1cb1ef46c3c8e47419ea5a08 (diff) | |
download | hercules-818acc5866707b9e294a87d2dd902aebb670707f.tar.gz hercules-818acc5866707b9e294a87d2dd902aebb670707f.tar.bz2 hercules-818acc5866707b9e294a87d2dd902aebb670707f.tar.xz hercules-818acc5866707b9e294a87d2dd902aebb670707f.zip |
Rewritten skill_tree parser in a more robust way
- Fixes an issue that prevented skills with more than 4 pre-requisites
or more than 3 pre-requisites and a minimum level from being parsed
correctly (and without any warning or error messages).
- Removes the limit on 5 pre-requisites (replaced a fixed size array
with a VECTOR)
- Reduces memory usage of skill_tree from 794kB to 440kB (32 bit) or
523kB (64 bit).
- Fixes an issue that prevented multiple inheritance from working
correctly in rare cases (incorrect definition order), without any
warning or error messages. Now a warning is displayed if a job is
inherited before being defined.
- Fixes an issue that prevented skills inherited from being correctly
merged with the skills defined for the current job.
- Prevents a job from inheriting itself by accident.
- Correctly detects skills defined twice for the same job.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/skill.c')
-rw-r--r-- | src/map/skill.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/map/skill.c b/src/map/skill.c index dc3ebe62e..6795707fd 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -19082,22 +19082,24 @@ void skill_readdb(bool minimal) { sv->readdb(map->db_path, "skill_changematerial_db.txt", ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb); } -void skill_reload (void) { +void skill_reload(void) +{ struct s_mapiterator *iter; struct map_session_data *sd; - int i,c,k; + int i, j, k; skill->read_db(false); //[Ind/Hercules] refresh index cache - for(c = 0; c < CLASS_COUNT; c++) { - for( i = 0; i < MAX_SKILL_TREE; i++ ) { - if( pc->skill_tree[c][i].id ) { - pc->skill_tree[c][i].idx = skill->get_index(pc->skill_tree[c][i].id); - for(k = 0; k < MAX_PC_SKILL_REQUIRE; k++) { - if( pc->skill_tree[c][i].need[k].id ) - pc->skill_tree[c][i].need[k].idx = skill->get_index(pc->skill_tree[c][i].need[k].id); - } + for (j = 0; j < CLASS_COUNT; j++) { + for (i = 0; i < MAX_SKILL_TREE; i++) { + struct skill_tree_entry *entry = &pc->skill_tree[j][i]; + if (entry->id == 0) + continue; + entry->idx = skill->get_index(entry->id); + for (k = 0; k < VECTOR_LENGTH(entry->need); k++) { + struct skill_tree_requirement *req = &VECTOR_INDEX(entry->need, k); + req->idx = skill->get_index(req->id); } } } |