Fixes skill database reloading (#4669)

* Fixes #4660.
* Resolves an issue with skill database reloading not clearing the previous data first.
* While clearing the YAML cache it will also resize the cache to the previous capacity.
Thanks to @teededung!
This commit is contained in:
Aleos 2020-03-04 13:03:06 -05:00 committed by GitHub
parent 5c35ec7d69
commit 496f362ec9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -147,7 +147,11 @@ public:
void clear() override{
TypesafeYamlDatabase<keytype, datatype>::clear();
// Restore size after clearing
size_t cap = cache.capacity();
cache.clear();
cache.resize(cap, nullptr);
}
std::shared_ptr<datatype> find( keytype key ) override{

View File

@ -21943,7 +21943,7 @@ uint64 SkillDatabase::parseBodyNode(const YAML::Node &node) {
void SkillDatabase::clear() {
TypesafeCachedYamlDatabase::clear();
memset(skilldb_id2idx, 0, sizeof(skilldb_id2idx));
skill_num = 0;
skill_num = 1;
}
SkillDatabase skill_db;
@ -22485,15 +22485,14 @@ static void skill_readdb(void)
}
void skill_reload (void) {
struct s_mapiterator *iter;
struct map_session_data *sd;
skill_db.clear();
skill_readdb();
initChangeTables(); // Re-init Status Change tables
/* lets update all players skill tree : so that if any skill modes were changed they're properly updated */
iter = mapit_getallusers();
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) {
s_mapiterator *iter = mapit_getallusers();
for( map_session_data *sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) {
pc_validate_skill(sd);
clif_skillinfoblock(sd);
}