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/atcommand.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/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index c26daee54..d98ef8d94 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.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 @@ -5364,12 +5364,13 @@ ACMD(displayskill) { * @skilltree by [MouseJstr] * prints the skill tree for a player required to get to a skill *------------------------------------------*/ -ACMD(skilltree) { +ACMD(skilltree) +{ struct map_session_data *pl_sd = NULL; uint16 skill_id; int meets, j, c=0; char target[NAME_LENGTH]; - struct skill_tree_entry *ent; + struct skill_tree_entry *entry; if(!*message || sscanf(message, "%5hu %23[^\r\n]", &skill_id, target) != 2) { clif->message(fd, msg_fd(fd,1167)); // Usage: @skilltree <skill ID> <target> @@ -5387,21 +5388,19 @@ ACMD(skilltree) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1168), pc->job_name(c), pc->checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points). clif->message(fd, atcmd_output); - ARR_FIND( 0, MAX_SKILL_TREE, j, pc->skill_tree[c][j].id == 0 || pc->skill_tree[c][j].id == skill_id ); - if( j == MAX_SKILL_TREE || pc->skill_tree[c][j].id == 0 ) - { + ARR_FIND(0, MAX_SKILL_TREE, j, pc->skill_tree[c][j].id == 0 || pc->skill_tree[c][j].id == skill_id); + if (j == MAX_SKILL_TREE || pc->skill_tree[c][j].id == 0) { clif->message(fd, msg_fd(fd,1169)); // The player cannot use that skill. return false; } - ent = &pc->skill_tree[c][j]; + entry = &pc->skill_tree[c][j]; meets = 1; - for(j=0;j<MAX_PC_SKILL_REQUIRE;j++) - { - if( ent->need[j].id && pc->checkskill(sd,ent->need[j].id) < ent->need[j].lv) - { - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1170), ent->need[j].lv, skill->dbs->db[ent->need[j].id].desc); // Player requires level %d of skill %s. + for (j = 0; j < VECTOR_LENGTH(entry->need); j++) { + struct skill_tree_requirement *req = &VECTOR_INDEX(entry->need, j); + if (pc->checkskill(sd, req->id) < req->lv) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1170), req->lv, skill->dbs->db[req->id].desc); // Player requires level %d of skill %s. clif->message(fd, atcmd_output); meets = 0; } |