From 24f7c80ee1df4d248e876e7dd3acb6ebbed50d24 Mon Sep 17 00:00:00 2001 From: Jaka Kranjc Date: Sat, 2 Jul 2016 12:41:51 +0200 Subject: [PATCH] Actor: store also kit indices in the iwd2kits map --- gemrb/core/Scriptable/Actor.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gemrb/core/Scriptable/Actor.cpp b/gemrb/core/Scriptable/Actor.cpp index 7701098f9f..1a7bf508ab 100644 --- a/gemrb/core/Scriptable/Actor.cpp +++ b/gemrb/core/Scriptable/Actor.cpp @@ -198,7 +198,11 @@ static const int levelslotsbg[BGCLASSCNT]={ISFIGHTER, ISMAGE, ISFIGHTER, ISCLERI static unsigned int classesiwd2[ISCLASSES]={5, 11, 9, 1, 2, 3, 4, 6, 7, 8, 10, 12, 13}; // classis -> kits map -static std::map > iwd2kits; +struct ClassKits { + std::vector indices; + std::vector ids; +}; +static std::map iwd2kits; //this map could probably be auto-generated (isClass -> IWD2 book ID) static const int booksiwd2[ISCLASSES]={-1, IE_IWD2_SPELL_WIZARD, -1, -1, @@ -2083,7 +2087,8 @@ static void InitActorTables() if (classcol) { // kit ids are in hex classID = strtoul(tm->QueryField(classname, "ID"), NULL, 16); - iwd2kits[classcol].push_back(classID); + iwd2kits[classcol].indices.push_back(i); + iwd2kits[classcol].ids.push_back(classID); continue; } else if (i >= classcount) { // new class out of order @@ -9150,7 +9155,7 @@ int Actor::CheckUsability(Item *item) const if (Modified[levelslotsiwd2[j]] == 0) continue; if ((1<<(classesiwd2[j] - 1)) & ~itemvalue) continue; - std::vector kits = iwd2kits[classesiwd2[j]]; + std::vector kits = iwd2kits[classesiwd2[j]].ids; std::vector::iterator it = kits.begin(); for ( ; it != kits.end(); it++) { kitignore |= *it;