Address feedback

fix/shrink_builds
Evil Eye 3 years ago
parent 266a0634eb
commit ac78b537d2

@ -519,7 +519,7 @@ namespace MWDialogue
void DialogueManager::addChoice(std::string_view text, int choice) void DialogueManager::addChoice(std::string_view text, int choice)
{ {
mIsInChoice = true; 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() const std::vector<std::pair<std::string, int> >& DialogueManager::getChoices()

@ -168,7 +168,7 @@ namespace MWScript
if (cellID.empty()) if (cellID.empty())
return; 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; return;
MWMechanics::AiEscort escortPackage(actorID, cellID, static_cast<int>(duration), x, y, z, repeat); 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"); 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"); 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 void execute (Interpreter::Runtime& runtime) override
{ {
std::string_view cellView = runtime.getStringLiteral(runtime[0].mInteger); std::string cell{runtime.getStringLiteral(runtime[0].mInteger)};
std::string cell{cellView.begin(), cellView.end()};
runtime.pop(); runtime.pop();
ESM::Position pos; ESM::Position pos;

@ -116,7 +116,7 @@ namespace MWScript
// Explicit calls to non-unique actors affect the base record // 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) 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; return;
} }
@ -124,7 +124,7 @@ namespace MWScript
if(ptr.getClass().getType() == ESM::Container::sRecordId && (!ptr.getRefData().getCustomData() || if(ptr.getClass().getType() == ESM::Container::sRecordId && (!ptr.getRefData().getCustomData() ||
!ptr.getClass().getContainerStore(ptr).isResolved())) !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 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()); const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId());
for(const auto& container : ptrs) for(const auto& container : ptrs)
@ -229,14 +229,14 @@ namespace MWScript
// Explicit calls to non-unique actors affect the base record // 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) 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; return;
} }
// Calls to unresolved containers affect the base record instead // Calls to unresolved containers affect the base record instead
else if(ptr.getClass().getType() == ESM::Container::sRecordId && else if(ptr.getClass().getType() == ESM::Container::sRecordId &&
(!ptr.getRefData().getCustomData() || !ptr.getClass().getContainerStore(ptr).isResolved())) (!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 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()); const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId());
for(const auto& container : ptrs) for(const auto& container : ptrs)

@ -34,8 +34,7 @@ namespace MWScript
if (ptr.isEmpty()) if (ptr.isEmpty())
ptr = MWBase::Environment::get().getWorld()->getPlayerPtr(); ptr = MWBase::Environment::get().getWorld()->getPlayerPtr();
std::string_view questView = runtime.getStringLiteral(runtime[0].mInteger); std::string quest{runtime.getStringLiteral(runtime[0].mInteger)};
std::string quest{questView.begin(), questView.end()};
runtime.pop(); runtime.pop();
Interpreter::Type_Integer index = runtime[0].mInteger; Interpreter::Type_Integer index = runtime[0].mInteger;
@ -60,13 +59,13 @@ namespace MWScript
void execute (Interpreter::Runtime& runtime) override 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(); runtime.pop();
Interpreter::Type_Integer index = runtime[0].mInteger; Interpreter::Type_Integer index = runtime[0].mInteger;
runtime.pop(); 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 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(); runtime.pop();
int index = MWBase::Environment::get().getJournal()->getJournalIndex({quest.begin(), quest.end()}); int index = MWBase::Environment::get().getJournal()->getJournalIndex (quest);
runtime.push (index); runtime.push (index);

@ -60,7 +60,7 @@ namespace
} }
ESM::LevelledListBase::LevelItem item; ESM::LevelledListBase::LevelItem item;
item.mId = {itemId.begin(), itemId.end()}; item.mId = std::string{itemId};
item.mLevel = level; item.mLevel = level;
list->mList.push_back(item); list->mList.push_back(item);
} }
@ -206,13 +206,13 @@ namespace MWScript
void execute (Interpreter::Runtime& runtime) override 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(); runtime.pop();
bool allowSkipping = runtime[0].mInteger != 0; bool allowSkipping = runtime[0].mInteger != 0;
runtime.pop(); 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; char *end;
long key = strtol(effect.data(), &end, 10); long key = strtol(effect.data(), &end, 10);
if(key < 0 || key > 32767 || *end != '\0') 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); const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
@ -587,8 +587,7 @@ namespace MWScript
{ {
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
std::string_view creatureView = runtime.getStringLiteral(runtime[0].mInteger); std::string creature{runtime.getStringLiteral(runtime[0].mInteger)};
std::string creature{creatureView.begin(), creatureView.end()};
runtime.pop(); runtime.pop();
std::string_view gem = runtime.getStringLiteral(runtime[0].mInteger); std::string_view gem = runtime.getStringLiteral(runtime[0].mInteger);
@ -600,7 +599,7 @@ namespace MWScript
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); 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 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 // Set the soul on just one of the gems, not the whole stack
item.getContainerStore()->unstack(item, ptr); item.getContainerStore()->unstack(item, ptr);
@ -1214,16 +1213,16 @@ namespace MWScript
{ {
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
std::string_view spellId = runtime.getStringLiteral(runtime[0].mInteger); std::string spellId{runtime.getStringLiteral(runtime[0].mInteger)};
runtime.pop(); runtime.pop();
std::string targetId = ::Misc::StringUtils::lowerCase(runtime.getStringLiteral(runtime[0].mInteger)); std::string targetId = ::Misc::StringUtils::lowerCase(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop(); 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) 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; return;
} }
@ -1263,13 +1262,13 @@ namespace MWScript
{ {
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
std::string_view spellId = runtime.getStringLiteral(runtime[0].mInteger); std::string spellId{runtime.getStringLiteral(runtime[0].mInteger)};
runtime.pop(); 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) 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; return;
} }
@ -1426,14 +1425,14 @@ namespace MWScript
public: public:
void execute(Interpreter::Runtime &runtime) override 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(); runtime.pop();
std::string_view creatureId = runtime.getStringLiteral(runtime[0].mInteger); std::string_view creatureId = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop(); runtime.pop();
int level = runtime[0].mInteger; int level = runtime[0].mInteger;
runtime.pop(); 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); addToLevList(&listCopy, creatureId, level);
MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy); MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy);
} }
@ -1444,14 +1443,14 @@ namespace MWScript
public: public:
void execute(Interpreter::Runtime &runtime) override 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(); runtime.pop();
std::string_view creatureId = runtime.getStringLiteral(runtime[0].mInteger); std::string_view creatureId = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop(); runtime.pop();
int level = runtime[0].mInteger; int level = runtime[0].mInteger;
runtime.pop(); 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); removeFromLevList(&listCopy, creatureId, level);
MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy); MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy);
} }
@ -1462,14 +1461,14 @@ namespace MWScript
public: public:
void execute(Interpreter::Runtime &runtime) override 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(); runtime.pop();
std::string_view itemId = runtime.getStringLiteral(runtime[0].mInteger); std::string_view itemId = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop(); runtime.pop();
int level = runtime[0].mInteger; int level = runtime[0].mInteger;
runtime.pop(); 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); addToLevList(&listCopy, itemId, level);
MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy); MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy);
} }
@ -1480,14 +1479,14 @@ namespace MWScript
public: public:
void execute(Interpreter::Runtime &runtime) override 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(); runtime.pop();
std::string_view itemId = runtime.getStringLiteral(runtime[0].mInteger); std::string_view itemId = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop(); runtime.pop();
int level = runtime[0].mInteger; int level = runtime[0].mInteger;
runtime.pop(); 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); removeFromLevList(&listCopy, itemId, level);
MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy); MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy);
} }

@ -87,8 +87,7 @@ namespace MWScript
void execute (Interpreter::Runtime& runtime) override void execute (Interpreter::Runtime& runtime) override
{ {
std::string_view regionView = runtime.getStringLiteral(runtime[0].mInteger); std::string region{runtime.getStringLiteral(runtime[0].mInteger)};
std::string region{regionView.begin(), regionView.end()};
runtime.pop(); runtime.pop();
Interpreter::Type_Integer id = runtime[0].mInteger; Interpreter::Type_Integer id = runtime[0].mInteger;
@ -108,8 +107,7 @@ namespace MWScript
void execute (Interpreter::Runtime& runtime, unsigned int arg0) override void execute (Interpreter::Runtime& runtime, unsigned int arg0) override
{ {
std::string_view regionView = runtime.getStringLiteral(runtime[0].mInteger); std::string region{runtime.getStringLiteral(runtime[0].mInteger)};
std::string region{regionView.begin(), regionView.end()};
runtime.pop(); runtime.pop();
std::vector<char> chances; std::vector<char> chances;

@ -33,16 +33,16 @@ namespace MWScript
MWScript::InterpreterContext& context MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext()); = 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(); runtime.pop();
std::string_view text = runtime.getStringLiteral(runtime[0].mInteger); std::string text{runtime.getStringLiteral(runtime[0].mInteger)};
runtime.pop(); 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()) 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 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(); 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); MWWorld::Ptr ptr = R()(runtime);
std::string_view id = runtime.getStringLiteral(runtime[0].mInteger); std::string id{runtime.getStringLiteral(runtime[0].mInteger)};
runtime.pop(); 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); MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
creatureStats.getSpells().add(spell); creatureStats.getSpells().add(spell);
@ -474,11 +474,11 @@ namespace MWScript
{ {
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
std::string_view id = runtime.getStringLiteral(runtime[0].mInteger); std::string id{runtime.getStringLiteral(runtime[0].mInteger)};
runtime.pop(); runtime.pop();
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr); 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(); MWBase::WindowManager *wm = MWBase::Environment::get().getWindowManager();
@ -532,12 +532,12 @@ namespace MWScript
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
std::string_view id = runtime.getStringLiteral(runtime[0].mInteger); std::string id{runtime.getStringLiteral(runtime[0].mInteger)};
runtime.pop(); runtime.pop();
Interpreter::Type_Integer value = 0; 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; value = 1;
runtime.push (value); runtime.push (value);
@ -748,8 +748,8 @@ namespace MWScript
void execute (Interpreter::Runtime& runtime) override void execute (Interpreter::Runtime& runtime) override
{ {
std::string_view id = runtime.getStringLiteral(runtime[0].mInteger); std::string id{runtime.getStringLiteral(runtime[0].mInteger)};
runtime[0].mInteger = MWBase::Environment::get().getMechanicsManager()->countDeaths({id.begin(), id.end()}); 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); const MWWorld::Ptr to = MWBase::Environment::get().getWorld()->searchPtr(name, false);
if (to.isEmpty()) if (to.isEmpty())
{ {
std::string error = "Failed to find an instance of object '"; std::string error = "Failed to find an instance of object '" + std::string(name) + "'";
error += name; error += "'";
runtime.getContext().report(error); runtime.getContext().report(error);
Log(Debug::Error) << error; Log(Debug::Error) << error;
runtime.push(0.f); runtime.push(0.f);
@ -381,8 +380,7 @@ namespace MWScript
runtime.pop(); runtime.pop();
Interpreter::Type_Float zRot = runtime[0].mFloat; Interpreter::Type_Float zRot = runtime[0].mFloat;
runtime.pop(); runtime.pop();
std::string_view cellIDView = runtime.getStringLiteral(runtime[0].mInteger); std::string cellID{runtime.getStringLiteral(runtime[0].mInteger)};
std::string cellID{cellIDView.begin(), cellIDView.end()};
runtime.pop(); runtime.pop();
if (ptr.getContainerStore()) if (ptr.getContainerStore())
@ -499,8 +497,7 @@ namespace MWScript
{ {
std::string_view itemID = runtime.getStringLiteral(runtime[0].mInteger); std::string_view itemID = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop(); runtime.pop();
std::string_view cellIDView = runtime.getStringLiteral(runtime[0].mInteger); std::string cellID{runtime.getStringLiteral(runtime[0].mInteger)};
std::string cellID{cellIDView.begin(), cellIDView.end()};
runtime.pop(); runtime.pop();
Interpreter::Type_Float x = runtime[0].mFloat; 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))); && 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); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id, count);
return add(ref.getPtr(), count, actorPtr); 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. /// @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) ///< 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); 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); Ptr ret = searchPtr(name, activeOnly);
if (!ret.isEmpty()) if (!ret.isEmpty())
return ret; return ret;
std::string error = "failed to find an instance of object '"; std::string error = "failed to find an instance of object '" + std::string(name) + error;
error += name; error += "'";
if (activeOnly) if (activeOnly)
error += " in active cells"; error += " in active cells";
throw std::runtime_error(error); throw std::runtime_error(error);

@ -128,11 +128,11 @@ namespace
float getFloat(std::string_view name) const { return getGlobal(name, mFloats); }; 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 class TestInterpreterContext : public Interpreter::Context
@ -224,11 +224,11 @@ namespace
return {}; 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 struct CompiledScript

@ -533,10 +533,10 @@ const std::string &MagicEffect::effectIdToString(short effectID)
} }
class FindSecond { class FindSecond {
const std::string &mName; std::string_view mName;
public: 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 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; std::map<short,std::string>::const_iterator name;
name = std::find_if(sNames.begin(), sNames.end(), FindSecond(effect)); name = std::find_if(sNames.begin(), sNames.end(), FindSecond(effect));
if(name == sNames.end()) 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; return name->first;
} }

@ -2,6 +2,7 @@
#define OPENMW_ESM_MGEF_H #define OPENMW_ESM_MGEF_H
#include <string> #include <string>
#include <string_view>
#include <map> #include <map>
namespace ESM namespace ESM
@ -70,7 +71,7 @@ struct MagicEffect
static const std::map<short,std::string> sNames; static const std::map<short,std::string> sNames;
static const std::string &effectIdToString(short effectID); 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) /// Returns the effect that provides resistance against \a effect (or -1 if there's none)
static short getResistanceEffect(short effect); static short getResistanceEffect(short effect);

@ -137,8 +137,7 @@ namespace Interpreter
{ {
index = runtime[0].mInteger; index = runtime[0].mInteger;
runtime.pop(); runtime.pop();
std::string_view button = runtime.getStringLiteral(index); buttons.emplace_back(runtime.getStringLiteral(index));
buttons.emplace_back(button.begin(), button.end());
} }
std::reverse (buttons.begin(), buttons.end()); std::reverse (buttons.begin(), buttons.end());

Loading…
Cancel
Save