Do not initialize map every call

pull/1901/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,42 +274,45 @@ 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;
effects[DisintegrateArmor] = Sanctuary; if (effects.empty())
effects[DisintegrateWeapon] = Sanctuary;
for (int i=0; i<5; ++i)
effects[DrainAttribute+i] = ResistMagicka;
for (int i=0; i<5; ++i)
effects[DamageAttribute+i] = ResistMagicka;
for (int i=0; i<5; ++i)
effects[AbsorbAttribute+i] = ResistMagicka;
for (int i=0; i<10; ++i)
effects[WeaknessToFire+i] = ResistMagicka;
effects[Burden] = ResistMagicka;
effects[Charm] = ResistMagicka;
effects[Silence] = ResistMagicka;
effects[Blind] = ResistMagicka;
effects[Sound] = ResistMagicka;
for (int i=0; i<2; ++i)
{ {
effects[CalmHumanoid+i] = ResistMagicka; effects[DisintegrateArmor] = Sanctuary;
effects[FrenzyHumanoid+i] = ResistMagicka; effects[DisintegrateWeapon] = Sanctuary;
effects[DemoralizeHumanoid+i] = ResistMagicka;
effects[RallyHumanoid+i] = ResistMagicka; for (int i=0; i<5; ++i)
} effects[DrainAttribute+i] = ResistMagicka;
for (int i=0; i<5; ++i)
effects[DamageAttribute+i] = ResistMagicka;
for (int i=0; i<5; ++i)
effects[AbsorbAttribute+i] = ResistMagicka;
for (int i=0; i<10; ++i)
effects[WeaknessToFire+i] = ResistMagicka;
effects[Burden] = ResistMagicka;
effects[Charm] = ResistMagicka;
effects[Silence] = ResistMagicka;
effects[Blind] = ResistMagicka;
effects[Sound] = ResistMagicka;
for (int i=0; i<2; ++i)
{
effects[CalmHumanoid+i] = ResistMagicka;
effects[FrenzyHumanoid+i] = ResistMagicka;
effects[DemoralizeHumanoid+i] = ResistMagicka;
effects[RallyHumanoid+i] = ResistMagicka;
}
effects[TurnUndead] = ResistMagicka; effects[TurnUndead] = ResistMagicka;
effects[FireDamage] = ResistFire; effects[FireDamage] = ResistFire;
effects[FrostDamage] = ResistFrost; effects[FrostDamage] = ResistFrost;
effects[ShockDamage] = ResistShock; effects[ShockDamage] = ResistShock;
effects[Vampirism] = ResistCommonDisease; effects[Vampirism] = ResistCommonDisease;
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,41 +322,43 @@ 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)
effects[DrainAttribute+i] = WeaknessToMagicka;
for (int i=0; i<5; ++i)
effects[DamageAttribute+i] = WeaknessToMagicka;
for (int i=0; i<5; ++i)
effects[AbsorbAttribute+i] = WeaknessToMagicka;
for (int i=0; i<10; ++i)
effects[WeaknessToFire+i] = WeaknessToMagicka;
effects[Burden] = WeaknessToMagicka;
effects[Charm] = WeaknessToMagicka;
effects[Silence] = WeaknessToMagicka;
effects[Blind] = WeaknessToMagicka;
effects[Sound] = WeaknessToMagicka;
for (int i=0; i<2; ++i)
{ {
effects[CalmHumanoid+i] = WeaknessToMagicka; for (int i=0; i<5; ++i)
effects[FrenzyHumanoid+i] = WeaknessToMagicka; effects[DrainAttribute+i] = WeaknessToMagicka;
effects[DemoralizeHumanoid+i] = WeaknessToMagicka; for (int i=0; i<5; ++i)
effects[RallyHumanoid+i] = WeaknessToMagicka; effects[DamageAttribute+i] = WeaknessToMagicka;
} for (int i=0; i<5; ++i)
effects[AbsorbAttribute+i] = WeaknessToMagicka;
for (int i=0; i<10; ++i)
effects[WeaknessToFire+i] = WeaknessToMagicka;
effects[Burden] = WeaknessToMagicka;
effects[Charm] = WeaknessToMagicka;
effects[Silence] = WeaknessToMagicka;
effects[Blind] = WeaknessToMagicka;
effects[Sound] = WeaknessToMagicka;
for (int i=0; i<2; ++i)
{
effects[CalmHumanoid+i] = WeaknessToMagicka;
effects[FrenzyHumanoid+i] = WeaknessToMagicka;
effects[DemoralizeHumanoid+i] = WeaknessToMagicka;
effects[RallyHumanoid+i] = WeaknessToMagicka;
}
effects[TurnUndead] = WeaknessToMagicka; effects[TurnUndead] = WeaknessToMagicka;
effects[FireDamage] = WeaknessToFire; effects[FireDamage] = WeaknessToFire;
effects[FrostDamage] = WeaknessToFrost; effects[FrostDamage] = WeaknessToFrost;
effects[ShockDamage] = WeaknessToShock; effects[ShockDamage] = WeaknessToShock;
effects[Vampirism] = WeaknessToCommonDisease; effects[Vampirism] = WeaknessToCommonDisease;
effects[Corprus] = WeaknessToCorprusDisease; effects[Corprus] = WeaknessToCorprusDisease;
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