Do not initialize map every call

pull/541/head
Andrei Kortunov 6 years ago
parent c280a71b33
commit b0ac0b0b22

@ -138,6 +138,7 @@
Task #4605: Optimize skinning Task #4605: Optimize skinning
Task #4606: Support Rapture3D's OpenAL driver Task #4606: Support Rapture3D's OpenAL driver
Task #4613: Incomplete type errors when compiling with g++ on OSX 10.9 Task #4613: Incomplete type errors when compiling with g++ on OSX 10.9
Task #4621: Optimize combat AI
0.44.0 0.44.0
------ ------

@ -274,7 +274,9 @@ short MagicEffect::getResistanceEffect(short effect)
// Source https://wiki.openmw.org/index.php?title=Research:Magic#Effect_attribute // Source https://wiki.openmw.org/index.php?title=Research:Magic#Effect_attribute
// <Effect, Effect providing resistance against first effect> // <Effect, Effect providing resistance against first effect>
std::map<short, short> effects; static std::map<short, short> effects;
if (effects.empty())
{
effects[DisintegrateArmor] = Sanctuary; effects[DisintegrateArmor] = Sanctuary;
effects[DisintegrateWeapon] = Sanctuary; effects[DisintegrateWeapon] = Sanctuary;
@ -310,6 +312,7 @@ short MagicEffect::getResistanceEffect(short effect)
effects[Corprus] = ResistCorprusDisease; effects[Corprus] = ResistCorprusDisease;
effects[Poison] = ResistPoison; effects[Poison] = ResistPoison;
effects[Paralyze] = ResistParalysis; effects[Paralyze] = ResistParalysis;
}
if (effects.find(effect) != effects.end()) if (effects.find(effect) != effects.end())
return effects[effect]; return effects[effect];
@ -319,8 +322,9 @@ short MagicEffect::getResistanceEffect(short effect)
short MagicEffect::getWeaknessEffect(short effect) short MagicEffect::getWeaknessEffect(short effect)
{ {
std::map<short, short> effects; static std::map<short, short> effects;
if (effects.empty())
{
for (int i=0; i<5; ++i) for (int i=0; i<5; ++i)
effects[DrainAttribute+i] = WeaknessToMagicka; effects[DrainAttribute+i] = WeaknessToMagicka;
for (int i=0; i<5; ++i) for (int i=0; i<5; ++i)
@ -354,6 +358,7 @@ short MagicEffect::getWeaknessEffect(short effect)
effects[Poison] = WeaknessToPoison; effects[Poison] = WeaknessToPoison;
effects[Paralyze] = -1; effects[Paralyze] = -1;
}
if (effects.find(effect) != effects.end()) if (effects.find(effect) != effects.end())
return effects[effect]; return effects[effect];

Loading…
Cancel
Save