Make npc_spells_cache a map fixes #705

Should probably add a way to clear the cache, but we didn't do that
before so I didn't bother.
This commit is contained in:
Michael Cook (mackal)
2018-01-29 23:36:05 -05:00
parent 5d9c8c8e27
commit 6716e580f3
3 changed files with 93 additions and 137 deletions
+2 -15
View File
@@ -34,28 +34,15 @@ ZoneDatabase::ZoneDatabase(const char* host, const char* user, const char* passw
void ZoneDatabase::ZDBInitVars() {
memset(door_isopen_array, 0, sizeof(door_isopen_array));
npc_spells_maxid = 0;
npc_spellseffects_maxid = 0;
npc_spells_cache = 0;
npc_spellseffects_cache = 0;
npc_spells_loadtried = 0;
npc_spellseffects_loadtried = 0;
max_faction = 0;
faction_array = nullptr;
}
ZoneDatabase::~ZoneDatabase() {
unsigned int x;
if (npc_spells_cache) {
for (x = 0; x <= npc_spells_maxid; x++) {
safe_delete_array(npc_spells_cache[x]);
}
safe_delete_array(npc_spells_cache);
}
safe_delete_array(npc_spells_loadtried);
if (npc_spellseffects_cache) {
for (x = 0; x <= npc_spellseffects_maxid; x++) {
for (int x = 0; x <= npc_spellseffects_maxid; x++) {
safe_delete_array(npc_spellseffects_cache[x]);
}
safe_delete_array(npc_spellseffects_cache);
@@ -63,7 +50,7 @@ ZoneDatabase::~ZoneDatabase() {
safe_delete_array(npc_spellseffects_loadtried);
if (faction_array != nullptr) {
for (x = 0; x <= max_faction; x++) {
for (int x = 0; x <= max_faction; x++) {
if (faction_array[x] != 0)
safe_delete(faction_array[x]);
}