mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-20 15:40:32 +00:00
Address feedback
This commit is contained in:
parent
266a0634eb
commit
ac78b537d2
@ -519,7 +519,7 @@ namespace MWDialogue
|
||||
void DialogueManager::addChoice(std::string_view text, int choice)
|
||||
{
|
||||
mIsInChoice = true;
|
||||
mChoices.emplace_back(std::string{text.begin(), text.end()}, choice);
|
||||
mChoices.emplace_back(text, choice);
|
||||
}
|
||||
|
||||
const std::vector<std::pair<std::string, int> >& DialogueManager::getChoices()
|
||||
|
@ -168,7 +168,7 @@ namespace MWScript
|
||||
if (cellID.empty())
|
||||
return;
|
||||
|
||||
if (!MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search({cellID.begin(), cellID.end()}))
|
||||
if (!MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search(std::string{cellID}))
|
||||
return;
|
||||
|
||||
MWMechanics::AiEscort escortPackage(actorID, cellID, static_cast<int>(duration), x, y, z, repeat);
|
||||
|
@ -58,7 +58,7 @@ namespace MWScript
|
||||
throw std::runtime_error ("animation mode out of range");
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(ptr, {group.begin(), group.end()}, mode, std::numeric_limits<int>::max(), true);
|
||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(ptr, std::string{group}, mode, std::numeric_limits<int>::max(), true);
|
||||
}
|
||||
};
|
||||
|
||||
@ -94,7 +94,7 @@ namespace MWScript
|
||||
throw std::runtime_error ("animation mode out of range");
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(ptr, {group.begin(), group.end()}, mode, loops + 1, true);
|
||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(ptr, std::string{group}, mode, loops + 1, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -87,8 +87,7 @@ namespace MWScript
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
std::string_view cellView = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string cell{cellView.begin(), cellView.end()};
|
||||
std::string cell{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
ESM::Position pos;
|
||||
|
@ -116,7 +116,7 @@ namespace MWScript
|
||||
// Explicit calls to non-unique actors affect the base record
|
||||
if(!R::implicit && ptr.getClass().isActor() && MWBase::Environment::get().getWorld()->getStore().getRefCount(ptr.getCellRef().getRefId()) > 1)
|
||||
{
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), {item.begin(), item.end()}, count);
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), std::string{item}, count);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ namespace MWScript
|
||||
if(ptr.getClass().getType() == ESM::Container::sRecordId && (!ptr.getRefData().getCustomData() ||
|
||||
!ptr.getClass().getContainerStore(ptr).isResolved()))
|
||||
{
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), {item.begin(), item.end()}, count);
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), std::string{item}, count);
|
||||
const ESM::Container* baseRecord = MWBase::Environment::get().getWorld()->getStore().get<ESM::Container>().find(ptr.getCellRef().getRefId());
|
||||
const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId());
|
||||
for(const auto& container : ptrs)
|
||||
@ -229,14 +229,14 @@ namespace MWScript
|
||||
// Explicit calls to non-unique actors affect the base record
|
||||
if(!R::implicit && ptr.getClass().isActor() && MWBase::Environment::get().getWorld()->getStore().getRefCount(ptr.getCellRef().getRefId()) > 1)
|
||||
{
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), {item.begin(), item.end()}, -count);
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), std::string{item}, -count);
|
||||
return;
|
||||
}
|
||||
// Calls to unresolved containers affect the base record instead
|
||||
else if(ptr.getClass().getType() == ESM::Container::sRecordId &&
|
||||
(!ptr.getRefData().getCustomData() || !ptr.getClass().getContainerStore(ptr).isResolved()))
|
||||
{
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), {item.begin(), item.end()}, -count);
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), std::string{item}, -count);
|
||||
const ESM::Container* baseRecord = MWBase::Environment::get().getWorld()->getStore().get<ESM::Container>().find(ptr.getCellRef().getRefId());
|
||||
const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId());
|
||||
for(const auto& container : ptrs)
|
||||
|
@ -34,8 +34,7 @@ namespace MWScript
|
||||
if (ptr.isEmpty())
|
||||
ptr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
|
||||
std::string_view questView = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string quest{questView.begin(), questView.end()};
|
||||
std::string quest{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer index = runtime[0].mInteger;
|
||||
@ -60,13 +59,13 @@ namespace MWScript
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
std::string_view quest = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string quest{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer index = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWBase::Environment::get().getJournal()->setJournalIndex({quest.begin(), quest.end()}, index);
|
||||
MWBase::Environment::get().getJournal()->setJournalIndex (quest, index);
|
||||
}
|
||||
};
|
||||
|
||||
@ -76,10 +75,10 @@ namespace MWScript
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
std::string_view quest = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string quest{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
int index = MWBase::Environment::get().getJournal()->getJournalIndex({quest.begin(), quest.end()});
|
||||
int index = MWBase::Environment::get().getJournal()->getJournalIndex (quest);
|
||||
|
||||
runtime.push (index);
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace
|
||||
}
|
||||
|
||||
ESM::LevelledListBase::LevelItem item;
|
||||
item.mId = {itemId.begin(), itemId.end()};
|
||||
item.mId = std::string{itemId};
|
||||
item.mLevel = level;
|
||||
list->mList.push_back(item);
|
||||
}
|
||||
@ -206,13 +206,13 @@ namespace MWScript
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
std::string_view name = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string name{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
bool allowSkipping = runtime[0].mInteger != 0;
|
||||
runtime.pop();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->playVideo({name.begin(), name.end()}, allowSkipping);
|
||||
MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping);
|
||||
}
|
||||
};
|
||||
|
||||
@ -560,7 +560,7 @@ namespace MWScript
|
||||
char *end;
|
||||
long key = strtol(effect.data(), &end, 10);
|
||||
if(key < 0 || key > 32767 || *end != '\0')
|
||||
key = ESM::MagicEffect::effectStringToId({effect.begin(), effect.end()});
|
||||
key = ESM::MagicEffect::effectStringToId({effect});
|
||||
|
||||
const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
|
||||
|
||||
@ -587,8 +587,7 @@ namespace MWScript
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string_view creatureView = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string creature{creatureView.begin(), creatureView.end()};
|
||||
std::string creature{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
std::string_view gem = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
@ -600,7 +599,7 @@ namespace MWScript
|
||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
store.get<ESM::Creature>().find(creature); // This line throws an exception if it can't find the creature
|
||||
|
||||
MWWorld::Ptr item = *ptr.getClass().getContainerStore(ptr).add({gem.begin(), gem.end()}, 1, ptr);
|
||||
MWWorld::Ptr item = *ptr.getClass().getContainerStore(ptr).add(gem, 1, ptr);
|
||||
|
||||
// Set the soul on just one of the gems, not the whole stack
|
||||
item.getContainerStore()->unstack(item, ptr);
|
||||
@ -1214,16 +1213,16 @@ namespace MWScript
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string_view spellId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string spellId{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
std::string targetId = ::Misc::StringUtils::lowerCase(runtime.getStringLiteral(runtime[0].mInteger));
|
||||
runtime.pop();
|
||||
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search({spellId.begin(), spellId.end()});
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spellId);
|
||||
if (!spell)
|
||||
{
|
||||
runtime.getContext().report("spellcasting failed: cannot find spell \""+std::string{spellId.begin(), spellId.end()}+"\"");
|
||||
runtime.getContext().report("spellcasting failed: cannot find spell \""+spellId+"\"");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1263,13 +1262,13 @@ namespace MWScript
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string_view spellId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string spellId{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search({spellId.begin(), spellId.end()});
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spellId);
|
||||
if (!spell)
|
||||
{
|
||||
runtime.getContext().report("spellcasting failed: cannot find spell \""+std::string{spellId.begin(), spellId.end()}+"\"");
|
||||
runtime.getContext().report("spellcasting failed: cannot find spell \""+spellId+"\"");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1426,14 +1425,14 @@ namespace MWScript
|
||||
public:
|
||||
void execute(Interpreter::Runtime &runtime) override
|
||||
{
|
||||
std::string_view levId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string levId{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
std::string_view creatureId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
int level = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
ESM::CreatureLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get<ESM::CreatureLevList>().find({levId.begin(), levId.end()});
|
||||
ESM::CreatureLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get<ESM::CreatureLevList>().find(levId);
|
||||
addToLevList(&listCopy, creatureId, level);
|
||||
MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy);
|
||||
}
|
||||
@ -1444,14 +1443,14 @@ namespace MWScript
|
||||
public:
|
||||
void execute(Interpreter::Runtime &runtime) override
|
||||
{
|
||||
std::string_view levId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string levId{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
std::string_view creatureId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
int level = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
ESM::CreatureLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get<ESM::CreatureLevList>().find({levId.begin(), levId.end()});
|
||||
ESM::CreatureLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get<ESM::CreatureLevList>().find(levId);
|
||||
removeFromLevList(&listCopy, creatureId, level);
|
||||
MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy);
|
||||
}
|
||||
@ -1462,14 +1461,14 @@ namespace MWScript
|
||||
public:
|
||||
void execute(Interpreter::Runtime &runtime) override
|
||||
{
|
||||
std::string_view levId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string levId{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
std::string_view itemId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
int level = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
ESM::ItemLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get<ESM::ItemLevList>().find({levId.begin(), levId.end()});
|
||||
ESM::ItemLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get<ESM::ItemLevList>().find(levId);
|
||||
addToLevList(&listCopy, itemId, level);
|
||||
MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy);
|
||||
}
|
||||
@ -1480,14 +1479,14 @@ namespace MWScript
|
||||
public:
|
||||
void execute(Interpreter::Runtime &runtime) override
|
||||
{
|
||||
std::string_view levId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string levId{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
std::string_view itemId = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
int level = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
ESM::ItemLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get<ESM::ItemLevList>().find({levId.begin(), levId.end()});
|
||||
ESM::ItemLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get<ESM::ItemLevList>().find(levId);
|
||||
removeFromLevList(&listCopy, itemId, level);
|
||||
MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy);
|
||||
}
|
||||
|
@ -87,8 +87,7 @@ namespace MWScript
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
std::string_view regionView = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string region{regionView.begin(), regionView.end()};
|
||||
std::string region{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer id = runtime[0].mInteger;
|
||||
@ -108,8 +107,7 @@ namespace MWScript
|
||||
|
||||
void execute (Interpreter::Runtime& runtime, unsigned int arg0) override
|
||||
{
|
||||
std::string_view regionView = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string region{regionView.begin(), regionView.end()};
|
||||
std::string region{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
std::vector<char> chances;
|
||||
|
@ -33,16 +33,16 @@ namespace MWScript
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string_view file = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string file{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
std::string_view text = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string text{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->say(ptr, {file.begin(), file.end()});
|
||||
MWBase::Environment::get().getSoundManager()->say (ptr, file);
|
||||
|
||||
if (MWBase::Environment::get().getWindowManager ()->getSubtitlesEnabled())
|
||||
context.messageBox({text.begin(), text.end()});
|
||||
context.messageBox (text);
|
||||
}
|
||||
};
|
||||
|
||||
@ -65,10 +65,10 @@ namespace MWScript
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
std::string_view sound = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string sound{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->streamMusic({sound.begin(), sound.end()});
|
||||
MWBase::Environment::get().getSoundManager()->streamMusic (sound);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -447,10 +447,10 @@ namespace MWScript
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string_view id = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string id{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find({id.begin(), id.end()});
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (id);
|
||||
|
||||
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
|
||||
creatureStats.getSpells().add(spell);
|
||||
@ -474,11 +474,11 @@ namespace MWScript
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string_view id = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string id{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
|
||||
creatureStats.getSpells().remove({id.begin(), id.end()});
|
||||
creatureStats.getSpells().remove (id);
|
||||
|
||||
MWBase::WindowManager *wm = MWBase::Environment::get().getWindowManager();
|
||||
|
||||
@ -532,12 +532,12 @@ namespace MWScript
|
||||
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string_view id = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string id{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer value = 0;
|
||||
|
||||
if (ptr.getClass().isActor() && ptr.getClass().getCreatureStats(ptr).getSpells().hasSpell({id.begin(), id.end()}))
|
||||
if (ptr.getClass().isActor() && ptr.getClass().getCreatureStats(ptr).getSpells().hasSpell(id))
|
||||
value = 1;
|
||||
|
||||
runtime.push (value);
|
||||
@ -748,8 +748,8 @@ namespace MWScript
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
std::string_view id = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
runtime[0].mInteger = MWBase::Environment::get().getMechanicsManager()->countDeaths({id.begin(), id.end()});
|
||||
std::string id{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime[0].mInteger = MWBase::Environment::get().getMechanicsManager()->countDeaths (id);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -74,8 +74,7 @@ namespace MWScript
|
||||
const MWWorld::Ptr to = MWBase::Environment::get().getWorld()->searchPtr(name, false);
|
||||
if (to.isEmpty())
|
||||
{
|
||||
std::string error = "Failed to find an instance of object '";
|
||||
error += name; error += "'";
|
||||
std::string error = "Failed to find an instance of object '" + std::string(name) + "'";
|
||||
runtime.getContext().report(error);
|
||||
Log(Debug::Error) << error;
|
||||
runtime.push(0.f);
|
||||
@ -381,8 +380,7 @@ namespace MWScript
|
||||
runtime.pop();
|
||||
Interpreter::Type_Float zRot = runtime[0].mFloat;
|
||||
runtime.pop();
|
||||
std::string_view cellIDView = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string cellID{cellIDView.begin(), cellIDView.end()};
|
||||
std::string cellID{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
if (ptr.getContainerStore())
|
||||
@ -499,8 +497,7 @@ namespace MWScript
|
||||
{
|
||||
std::string_view itemID = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
std::string_view cellIDView = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
std::string cellID{cellIDView.begin(), cellIDView.end()};
|
||||
std::string cellID{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float x = runtime[0].mFloat;
|
||||
|
@ -278,7 +278,7 @@ bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2)
|
||||
&& cls2.getItemHealth(ptr2) == cls2.getItemMaxHealth(ptr2)));
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add(const std::string &id, int count, const Ptr &actorPtr)
|
||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add(std::string_view id, int count, const Ptr &actorPtr)
|
||||
{
|
||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id, count);
|
||||
return add(ref.getPtr(), count, actorPtr);
|
||||
|
@ -175,7 +175,7 @@ namespace MWWorld
|
||||
///
|
||||
/// @return if stacking happened, return iterator to the item that was stacked against, otherwise iterator to the newly inserted item.
|
||||
|
||||
ContainerStoreIterator add(const std::string& id, int count, const Ptr& actorPtr);
|
||||
ContainerStoreIterator add(std::string_view id, int count, const Ptr& actorPtr);
|
||||
///< Utility to construct a ManualRef and call add(ptr, count, actorPtr, true)
|
||||
|
||||
int remove(std::string_view itemId, int count, const Ptr& actor, bool equipReplacement = 0, bool resolve = true);
|
||||
|
@ -767,8 +767,7 @@ namespace MWWorld
|
||||
Ptr ret = searchPtr(name, activeOnly);
|
||||
if (!ret.isEmpty())
|
||||
return ret;
|
||||
std::string error = "failed to find an instance of object '";
|
||||
error += name; error += "'";
|
||||
std::string error = "failed to find an instance of object '" + std::string(name) + error;
|
||||
if (activeOnly)
|
||||
error += " in active cells";
|
||||
throw std::runtime_error(error);
|
||||
|
@ -128,11 +128,11 @@ namespace
|
||||
|
||||
float getFloat(std::string_view name) const { return getGlobal(name, mFloats); };
|
||||
|
||||
void setShort(std::string_view name, int value) { mShorts[{name.begin(), name.end()}] = value; };
|
||||
void setShort(std::string_view name, int value) { mShorts[std::string(name)] = value; };
|
||||
|
||||
void setLong(std::string_view name, int value) { mLongs[{name.begin(), name.end()}] = value; };
|
||||
void setLong(std::string_view name, int value) { mLongs[std::string(name)] = value; };
|
||||
|
||||
void setFloat(std::string_view name, float value) { mFloats[{name.begin(), name.end()}] = value; };
|
||||
void setFloat(std::string_view name, float value) { mFloats[std::string(name)] = value; };
|
||||
};
|
||||
|
||||
class TestInterpreterContext : public Interpreter::Context
|
||||
@ -224,11 +224,11 @@ namespace
|
||||
return {};
|
||||
};
|
||||
|
||||
void setMemberShort(std::string_view id, std::string_view name, int value, bool global) override { mMembers[{id.begin(), id.end()}].setShort(name, value); };
|
||||
void setMemberShort(std::string_view id, std::string_view name, int value, bool global) override { mMembers[std::string(id)].setShort(name, value); };
|
||||
|
||||
void setMemberLong(std::string_view id, std::string_view name, int value, bool global) override { mMembers[{id.begin(), id.end()}].setLong(name, value); };
|
||||
void setMemberLong(std::string_view id, std::string_view name, int value, bool global) override { mMembers[std::string(id)].setLong(name, value); };
|
||||
|
||||
void setMemberFloat(std::string_view id, std::string_view name, float value, bool global) override { mMembers[{id.begin(), id.end()}].setFloat(name, value); };
|
||||
void setMemberFloat(std::string_view id, std::string_view name, float value, bool global) override { mMembers[std::string(id)].setFloat(name, value); };
|
||||
};
|
||||
|
||||
struct CompiledScript
|
||||
|
@ -533,10 +533,10 @@ const std::string &MagicEffect::effectIdToString(short effectID)
|
||||
}
|
||||
|
||||
class FindSecond {
|
||||
const std::string &mName;
|
||||
std::string_view mName;
|
||||
|
||||
public:
|
||||
FindSecond(const std::string &name) : mName(name) { }
|
||||
FindSecond(std::string_view name) : mName(name) { }
|
||||
|
||||
bool operator()(const std::pair<short,std::string> &item) const
|
||||
{
|
||||
@ -546,13 +546,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
short MagicEffect::effectStringToId(const std::string &effect)
|
||||
short MagicEffect::effectStringToId(std::string_view effect)
|
||||
{
|
||||
std::map<short,std::string>::const_iterator name;
|
||||
|
||||
name = std::find_if(sNames.begin(), sNames.end(), FindSecond(effect));
|
||||
if(name == sNames.end())
|
||||
throw std::runtime_error(std::string("Unimplemented effect ")+effect);
|
||||
throw std::runtime_error("Unimplemented effect " + std::string(effect));
|
||||
|
||||
return name->first;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define OPENMW_ESM_MGEF_H
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <map>
|
||||
|
||||
namespace ESM
|
||||
@ -70,7 +71,7 @@ struct MagicEffect
|
||||
static const std::map<short,std::string> sNames;
|
||||
|
||||
static const std::string &effectIdToString(short effectID);
|
||||
static short effectStringToId(const std::string &effect);
|
||||
static short effectStringToId(std::string_view effect);
|
||||
|
||||
/// Returns the effect that provides resistance against \a effect (or -1 if there's none)
|
||||
static short getResistanceEffect(short effect);
|
||||
|
@ -137,8 +137,7 @@ namespace Interpreter
|
||||
{
|
||||
index = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
std::string_view button = runtime.getStringLiteral(index);
|
||||
buttons.emplace_back(button.begin(), button.end());
|
||||
buttons.emplace_back(runtime.getStringLiteral(index));
|
||||
}
|
||||
|
||||
std::reverse (buttons.begin(), buttons.end());
|
||||
|
Loading…
x
Reference in New Issue
Block a user