SAGA2: Use Common::HashMap for active items hash

This commit is contained in:
a/ 2021-06-17 16:44:27 +09:00 committed by Eugene Sandulenko
parent f9ecdb80ae
commit f930e14188
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
2 changed files with 4 additions and 12 deletions

View File

@ -2457,8 +2457,7 @@ void WorldMapData::buildInstanceHash(void) {
+ ai->instance.v + (ai->instance.groupID << 2))
% elementsof(instHash);
ai->nextHash = instHash[hashVal];
instHash[hashVal] = ai;
itemHash.setVal(hashVal, ai);
}
}
}
@ -2472,17 +2471,9 @@ ActiveItem *WorldMapData::findHashedInstance(
int16 group) {
int16 hashVal = (((tp.u + tp.z) << 4) + tp.v + (group << 2))
% elementsof(instHash);
ActiveItem *ai;
if (itemHash.contains(hashVal))
return itemHash.getVal(hashVal);
for (ai = instHash[hashVal];
ai;
ai = ai->nextHash) {
if (ai->instance.u == tp.u
&& ai->instance.v == tp.v
&& ai->instance.h == tp.z
&& ai->instance.groupID == group)
return ai;
}
return nullptr;
}

View File

@ -867,6 +867,7 @@ struct WorldMapData {
RipTableIDPtr ripTableIDList; // MetaTile object ripping
ActiveItem *instHash[513]; // ActiveItem hash table
Common::HashMap<int16, ActiveItem*> itemHash;
int16 metaCount, // Number of MetaTiles
activeCount; // Number of ActiveItems