1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 07:53:53 +00:00

Merge pull request #2114 from Capostrophic/cleanup

Remove some redundant code
This commit is contained in:
Bret Curtis 2019-01-07 14:59:39 +01:00 committed by GitHub
commit 9d1c0d2b22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 5 additions and 42 deletions

View file

@ -1,9 +1,5 @@
#include "ref.hpp" #include "ref.hpp"
#include <cmath>
#include <sstream>
#include "cellcoordinates.hpp" #include "cellcoordinates.hpp"
CSMWorld::CellRef::CellRef() : mNew (true) CSMWorld::CellRef::CellRef() : mNew (true)

View file

@ -1,7 +1,5 @@
#include "aiwander.hpp" #include "aiwander.hpp"
#include <cfloat>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/esm/aisequence.hpp> #include <components/esm/aisequence.hpp>

View file

@ -240,19 +240,6 @@ namespace MWMechanics
return true; return true;
} }
ESM::Skill::SkillEnum mapSchoolToSkill(int school)
{
std::map<int, ESM::Skill::SkillEnum> schoolSkillMap; // maps spell school to skill id
schoolSkillMap[0] = ESM::Skill::Alteration;
schoolSkillMap[1] = ESM::Skill::Conjuration;
schoolSkillMap[3] = ESM::Skill::Illusion;
schoolSkillMap[2] = ESM::Skill::Destruction;
schoolSkillMap[4] = ESM::Skill::Mysticism;
schoolSkillMap[5] = ESM::Skill::Restoration;
assert(schoolSkillMap.find(school) != schoolSkillMap.end());
return schoolSkillMap[school];
}
void calcWeakestSchool (const ESM::Spell* spell, const int* actorSkills, int& effectiveSchool, float& skillTerm) void calcWeakestSchool (const ESM::Spell* spell, const int* actorSkills, int& effectiveSchool, float& skillTerm)
{ {
// Morrowind for some reason uses a formula slightly different from magicka cost calculation // Morrowind for some reason uses a formula slightly different from magicka cost calculation
@ -288,7 +275,7 @@ namespace MWMechanics
if (effect.mRange == ESM::RT_Target) if (effect.mRange == ESM::RT_Target)
x *= 1.5f; x *= 1.5f;
float s = 2.f * actorSkills[mapSchoolToSkill(magicEffect->mData.mSchool)]; float s = 2.f * actorSkills[spellSchoolToSkill(magicEffect->mData.mSchool)];
if (s - x < minChance) if (s - x < minChance)
{ {
minChance = s - x; minChance = s - x;
@ -308,7 +295,7 @@ namespace MWMechanics
float skillTerm = 0; float skillTerm = 0;
if (effectiveSchool != -1) if (effectiveSchool != -1)
skillTerm = 2.f * actorSkills[mapSchoolToSkill(effectiveSchool)]; skillTerm = 2.f * actorSkills[spellSchoolToSkill(effectiveSchool)];
else else
calcWeakestSchool(spell, actorSkills, effectiveSchool, skillTerm); // Note effectiveSchool is unused after this calcWeakestSchool(spell, actorSkills, effectiveSchool, skillTerm); // Note effectiveSchool is unused after this

View file

@ -1,9 +1,6 @@
#ifndef OPENMW_AUTOCALCSPELL_H #ifndef OPENMW_AUTOCALCSPELL_H
#define OPENMW_AUTOCALCSPELL_H #define OPENMW_AUTOCALCSPELL_H
#include <cfloat>
#include <set>
#include <components/esm/loadspel.hpp> #include <components/esm/loadspel.hpp>
#include <components/esm/loadskil.hpp> #include <components/esm/loadskil.hpp>
#include <components/esm/loadrace.hpp> #include <components/esm/loadrace.hpp>
@ -22,8 +19,6 @@ std::vector<std::string> autoCalcPlayerSpells(const int* actorSkills, const int*
bool attrSkillCheck (const ESM::Spell* spell, const int* actorSkills, const int* actorAttributes); bool attrSkillCheck (const ESM::Spell* spell, const int* actorSkills, const int* actorAttributes);
ESM::Skill::SkillEnum mapSchoolToSkill(int school);
void calcWeakestSchool(const ESM::Spell* spell, const int* actorSkills, int& effectiveSchool, float& skillTerm); void calcWeakestSchool(const ESM::Spell* spell, const int* actorSkills, int& effectiveSchool, float& skillTerm);
float calcAutoCastChance(const ESM::Spell* spell, const int* actorSkills, const int* actorAttributes, int effectiveSchool); float calcAutoCastChance(const ESM::Spell* spell, const int* actorSkills, const int* actorAttributes, int effectiveSchool);

View file

@ -60,13 +60,6 @@ void wrap(float& rad)
rad = std::fmod(rad-osg::PI, 2.0f*osg::PI)+osg::PI; rad = std::fmod(rad-osg::PI, 2.0f*osg::PI)+osg::PI;
} }
std::string toString(int num)
{
std::ostringstream stream;
stream << num;
return stream.str();
}
std::string getBestAttack (const ESM::Weapon* weapon) std::string getBestAttack (const ESM::Weapon* weapon)
{ {
int slash = (weapon->mData.mSlash[0] + weapon->mData.mSlash[1])/2; int slash = (weapon->mData.mSlash[0] + weapon->mData.mSlash[1])/2;
@ -235,13 +228,13 @@ public:
std::string CharacterController::chooseRandomGroup (const std::string& prefix, int* num) const std::string CharacterController::chooseRandomGroup (const std::string& prefix, int* num) const
{ {
int numAnims=0; int numAnims=0;
while (mAnimation->hasAnimation(prefix + toString(numAnims+1))) while (mAnimation->hasAnimation(prefix + std::to_string(numAnims+1)))
++numAnims; ++numAnims;
int roll = Misc::Rng::rollDice(numAnims) + 1; // [1, numAnims] int roll = Misc::Rng::rollDice(numAnims) + 1; // [1, numAnims]
if (num) if (num)
*num = roll; *num = roll;
return prefix + toString(roll); return prefix + std::to_string(roll);
} }
void CharacterController::refreshHitRecoilAnims(CharacterState& idle) void CharacterController::refreshHitRecoilAnims(CharacterState& idle)
@ -783,7 +776,7 @@ void CharacterController::playDeath(float startpoint, CharacterState death)
mCurrentDeath = "deathknockout"; mCurrentDeath = "deathknockout";
break; break;
default: default:
mCurrentDeath = "death" + toString(death - CharState_Death1 + 1); mCurrentDeath = "death" + std::to_string(death - CharState_Death1 + 1);
} }
mDeathState = death; mDeathState = death;

View file

@ -1,8 +1,5 @@
#include "mechanicsmanagerimp.hpp" #include "mechanicsmanagerimp.hpp"
#include <limits.h>
#include <set>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/esm/esmwriter.hpp> #include <components/esm/esmwriter.hpp>

View file

@ -1,6 +1,5 @@
#include "spellcasting.hpp" #include "spellcasting.hpp"
#include <cfloat>
#include <limits> #include <limits>
#include <iomanip> #include <iomanip>

View file

@ -1,7 +1,5 @@
#include "objects.hpp" #include "objects.hpp"
#include <cmath>
#include <osg/Group> #include <osg/Group>
#include <osg/UserDataContainer> #include <osg/UserDataContainer>