mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
Merge pull request #2981 from akortunov/refactoring
Use more C++11 in the scripting system code
This commit is contained in:
commit
1b3f5d4f0d
3 changed files with 19 additions and 20 deletions
|
@ -225,15 +225,13 @@ namespace MWScript
|
|||
|
||||
std::vector<std::string> InterpreterContext::getGlobals() const
|
||||
{
|
||||
std::vector<std::string> ids;
|
||||
|
||||
const MWWorld::Store<ESM::Global>& globals =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Global>();
|
||||
|
||||
for (MWWorld::Store<ESM::Global>::iterator iter = globals.begin(); iter!=globals.end();
|
||||
++iter)
|
||||
std::vector<std::string> ids;
|
||||
for (auto& globalVariable : globals)
|
||||
{
|
||||
ids.push_back (iter->mId);
|
||||
ids.emplace_back(globalVariable.mId);
|
||||
}
|
||||
|
||||
return ids;
|
||||
|
@ -245,22 +243,22 @@ namespace MWScript
|
|||
return world->getGlobalVariableType(name);
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getActionBinding(const std::string& action) const
|
||||
std::string InterpreterContext::getActionBinding(const std::string& targetAction) const
|
||||
{
|
||||
MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
|
||||
std::vector<int> actions = input->getActionKeySorting ();
|
||||
for (std::vector<int>::const_iterator it = actions.begin(); it != actions.end(); ++it)
|
||||
for (const int action : actions)
|
||||
{
|
||||
std::string desc = input->getActionDescription (*it);
|
||||
std::string desc = input->getActionDescription (action);
|
||||
if(desc == "")
|
||||
continue;
|
||||
|
||||
if(desc == action)
|
||||
if(desc == targetAction)
|
||||
{
|
||||
if(input->joystickLastUsed())
|
||||
return input->getActionControllerBindingName(*it);
|
||||
return input->getActionControllerBindingName(action);
|
||||
else
|
||||
return input->getActionKeyBindingName (*it);
|
||||
return input->getActionKeyBindingName(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ namespace
|
|||
|
||||
void addToLevList(ESM::LevelledListBase* list, const std::string& itemId, int level)
|
||||
{
|
||||
for (std::vector<ESM::LevelledListBase::LevelItem>::iterator it = list->mList.begin(); it != list->mList.end(); ++it)
|
||||
for (auto& levelItem : list->mList)
|
||||
{
|
||||
if (it->mLevel == level && itemId == it->mId)
|
||||
if (levelItem.mLevel == level && itemId == levelItem.mId)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -563,9 +563,9 @@ namespace MWScript
|
|||
effects += store.getMagicEffects();
|
||||
}
|
||||
|
||||
for (MWMechanics::MagicEffects::Collection::const_iterator it = effects.begin(); it != effects.end(); ++it)
|
||||
for (const auto& effect : effects)
|
||||
{
|
||||
if (it->first.mId == key && it->second.getModifier() > 0)
|
||||
if (effect.first.mId == key && effect.second.getModifier() > 0)
|
||||
{
|
||||
runtime.push(1);
|
||||
return;
|
||||
|
|
|
@ -151,16 +151,17 @@ namespace MWScript
|
|||
|
||||
const MWWorld::Store<ESM::Script>& scripts = mStore.get<ESM::Script>();
|
||||
|
||||
for (MWWorld::Store<ESM::Script>::iterator iter = scripts.begin();
|
||||
iter != scripts.end(); ++iter)
|
||||
for (auto& script : mStore.get<ESM::Script>())
|
||||
{
|
||||
if (!std::binary_search (mScriptBlacklist.begin(), mScriptBlacklist.end(),
|
||||
Misc::StringUtils::lowerCase (iter->mId)))
|
||||
Misc::StringUtils::lowerCase(script.mId)))
|
||||
{
|
||||
++count;
|
||||
|
||||
if (compile (iter->mId))
|
||||
if (compile(script.mId))
|
||||
++success;
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair (count, success);
|
||||
}
|
||||
|
@ -195,7 +196,7 @@ namespace MWScript
|
|||
scanner.scan (parser);
|
||||
|
||||
std::map<std::string, Compiler::Locals>::iterator iter =
|
||||
mOtherLocals.insert (std::make_pair (name2, locals)).first;
|
||||
mOtherLocals.emplace(name2, locals).first;
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue