script blacklist => RefId

Applies changes from review

Fixed clang format

Clang format + review.
iwyu_full
florent.teppe 2 years ago
parent 2c30575b3b
commit 1ef1de974d

@ -253,7 +253,8 @@ void CSMDoc::CollectionReferencesStage::perform(int stage, Messages& messages)
if (record.isModified() || record.mState == CSMWorld::RecordBase::State_Deleted)
{
const ESM::RefId& cellId = record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell;
const ESM::RefId& cellId
= record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell;
std::deque<int>& indices = mState.getSubRecords()[cellId.getRefIdString()];

@ -88,8 +88,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message
}
if (!cellRef.mDestCell.empty() && mCells.searchId(cellRef.mDestCell) == -1)
messages.add(
id, "Destination cell '" + cellRef.mDestCell.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Destination cell '" + cellRef.mDestCell.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
if (cellRef.mScale < 0)
messages.add(id, "Negative scale", "", CSMDoc::Message::Severity_Error);

@ -77,7 +77,6 @@ CSMDoc::OperationHolder* CSMTools::Tools::getVerifier()
connect(&mVerifier, &CSMDoc::OperationHolder::done, this, &Tools::done);
connect(&mVerifier, &CSMDoc::OperationHolder::reportMessage, this, &Tools::verifierMessage);
std::vector<ESM::RefId> mandatoryRefIds;
{
auto mandatoryIds = { "Day", "DaysPassed", "GameHour", "Month", "PCRace" };
@ -85,7 +84,6 @@ CSMDoc::OperationHolder* CSMTools::Tools::getVerifier()
mandatoryRefIds.push_back(ESM::RefId::stringRefId(id));
}
mVerifierOperation->appendStage(new MandatoryIdStage(
mData.getGlobals(), CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Globals), mandatoryRefIds));

@ -9,13 +9,13 @@
#include <osg/Math>
#include <apps/opencs/model/world/cell.hpp>
#include <components/esm/defs.hpp>
#include <components/esm3/loadbody.hpp>
#include <components/esm3/loadinfo.hpp>
#include <components/esm3/loadrace.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/esm3/variant.hpp>
#include <apps/opencs/model/world/cell.hpp>
#include <QString>
#include <QVariant>
@ -334,8 +334,8 @@ namespace CSMWorld
bool isEditable() const override { return true; }
};
template<>
struct NameColumn<CSMWorld::Cell> : public Column < CSMWorld::Cell>
template <>
struct NameColumn<CSMWorld::Cell> : public Column<CSMWorld::Cell>
{
NameColumn(ColumnBase::Display display = ColumnBase::Display_String)
: Column<CSMWorld::Cell>(Columns::ColumnId_Name, display)

@ -790,7 +790,7 @@ void OMW::Engine::prepareEngine()
mScriptContext->setExtensions(&mExtensions);
mScriptManager = std::make_unique<MWScript::ScriptManager>(mWorld->getStore(), *mScriptContext, mWarningsMode,
mScriptBlacklistUse ? mScriptBlacklist : std::vector<std::string>());
mScriptBlacklistUse ? mScriptBlacklist : std::vector<ESM::RefId>());
mEnvironment.setScriptManager(*mScriptManager);
// Create game mechanics system
@ -1003,7 +1003,7 @@ void OMW::Engine::setWarningsMode(int mode)
mWarningsMode = mode;
}
void OMW::Engine::setScriptBlacklist(const std::vector<std::string>& list)
void OMW::Engine::setScriptBlacklist(const std::vector<ESM::RefId>& list)
{
mScriptBlacklist = list;
}

@ -4,10 +4,10 @@
#include <filesystem>
#include <components/compiler/extensions.hpp>
#include <components/esm/refid.hpp>
#include <components/files/collections.hpp>
#include <components/settings/settings.hpp>
#include <components/translation/translation.hpp>
#include <components/esm/refid.hpp>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
@ -179,7 +179,7 @@ namespace OMW
Files::Collections mFileCollections;
bool mFSStrict;
Translation::Storage mTranslationDataStorage;
std::vector<std::string> mScriptBlacklist;
std::vector<ESM::RefId> mScriptBlacklist;
bool mScriptBlacklistUse;
bool mNewGame;
@ -260,7 +260,7 @@ namespace OMW
void setWarningsMode(int mode);
void setScriptBlacklist(const std::vector<std::string>& list);
void setScriptBlacklist(const std::vector<ESM::RefId>& list);
void setScriptBlacklistUse(bool use);

@ -161,7 +161,13 @@ bool parseOptions(int argc, char** argv, OMW::Engine& engine, Files::Configurati
engine.setScriptConsoleMode(variables["script-console"].as<bool>());
engine.setStartupScript(variables["script-run"].as<std::string>());
engine.setWarningsMode(variables["script-warn"].as<int>());
engine.setScriptBlacklist(variables["script-blacklist"].as<StringsVector>());
std::vector<ESM::RefId> scriptBlacklist;
auto& scriptBlacklistString = variables["script-blacklist"].as<StringsVector>();
for (const auto& blacklistString : scriptBlacklistString)
{
scriptBlacklist.push_back(ESM::RefId::stringRefId(blacklistString));
}
engine.setScriptBlacklist(scriptBlacklist);
engine.setScriptBlacklistUse(variables["script-blacklist-use"].as<bool>());
engine.setSaveGameFile(variables["load-savegame"].as<Files::MaybeQuotedPath>().u8string());

@ -367,7 +367,7 @@ namespace MWDialogue
if (dialog.mType == ESM::Dialogue::Topic)
{
const auto* answer = filter.search(dialog, true);
auto topicId = dialog.mId;
const auto& topicId = dialog.mId;
if (answer != nullptr)
{

@ -196,7 +196,8 @@ bool MWDialogue::Filter::testPlayer(const ESM::DialInfo& info) const
if (!info.mCell.empty())
{
// supports partial matches, just like getPcCell
std::string_view playerCell = MWBase::Environment::get().getWorld()->getCellName(player.getCell()).getRefIdString();
std::string_view playerCell
= MWBase::Environment::get().getWorld()->getCellName(player.getCell()).getRefIdString();
if (!Misc::StringUtils::ciStartsWith(playerCell, info.mCell.getRefIdString()))
return false;
}
@ -553,7 +554,8 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
case SelectWrapper::Function_NotCell:
{
std::string_view actorCell = MWBase::Environment::get().getWorld()->getCellName(mActor.getCell()).getRefIdString();
std::string_view actorCell
= MWBase::Environment::get().getWorld()->getCellName(mActor.getCell()).getRefIdString();
return !Misc::StringUtils::ciStartsWith(actorCell, select.getName());
}
case SelectWrapper::Function_SameGender:

@ -330,8 +330,7 @@ namespace MWGui
continue;
if (mGenderIndex != (bodypart.mData.mFlags & ESM::BodyPart::BPF_Female))
continue;
bool firstPerson = (idString.size() >= 3) && idString[idString.size() - 3] == '1'
&& idString[idString.size() - 2] == 's' && idString[idString.size() - 1] == 't';
bool firstPerson = idString.ends_with("1st");
if (firstPerson)
continue;
if (bodypart.mRace == mCurrentRaceId)

@ -804,7 +804,7 @@ namespace MWGui
return mMessageBoxManager->readPressedButton();
}
std::string_view WindowManager::getGameSettingString(const std::string_view id, std::string_view default_)
std::string_view WindowManager::getGameSettingString(std::string_view id, std::string_view default_)
{
const ESM::GameSetting* setting = mStore->get<ESM::GameSetting>().search(id);

@ -283,7 +283,7 @@ namespace MWGui
* @param id Identifier for the GMST setting, e.g. "aName"
* @param default Default value if the GMST setting cannot be used.
*/
std::string_view getGameSettingString(const std::string_view id, std::string_view default_) override;
std::string_view getGameSettingString(std::string_view id, std::string_view default_) override;
void processChangedSettings(const Settings::CategorySettingVector& changed) override;

@ -146,8 +146,8 @@ namespace MWLua
if (esmCell->isExterior())
ai.stack(MWMechanics::AiEscort(refId, gameHoursDuration, dest.x(), dest.y(), dest.z(), false), ptr);
else
ai.stack(MWMechanics::AiEscort(refId, esmCell->mName, gameHoursDuration,
dest.x(), dest.y(), dest.z(), false),
ai.stack(MWMechanics::AiEscort(
refId, esmCell->mName, gameHoursDuration, dest.x(), dest.y(), dest.z(), false),
ptr);
};
selfAPI["_startAiWander"] = [](SelfObject& self, int distance, float duration) {

@ -246,8 +246,8 @@ namespace MWLua
const sol::optional<osg::Vec3f>& optRot) {
MWWorld::Ptr ptr = object.ptr();
osg::Vec3f rot = optRot ? *optRot : ptr.getRefData().getPosition().asRotationVec3();
auto action
= std::make_unique<TeleportAction>(context.mLua, object.id(), ESM::RefId::stringRefId(cell), pos, rot);
auto action = std::make_unique<TeleportAction>(
context.mLua, object.id(), ESM::RefId::stringRefId(cell), pos, rot);
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
context.mLuaManager->addTeleportPlayerAction(std::move(action));
else

@ -1442,7 +1442,7 @@ namespace MWMechanics
if (isWerewolf)
{
const ESM::RefId wolfRun = ESM::RefId::stringRefId("WorldRun");
const ESM::RefId wolfRun = ESM::RefId::stringRefId("WolfRun");
if (isRunning() && !world->isSwimming(mPtr) && mWeaponType == ESM::Weapon::None)
{
if (!sndMgr->getSoundPlaying(mPtr, wolfRun))

@ -85,7 +85,6 @@ namespace
const ESM::RefId& owner = cellref.getOwner();
bool isOwned = !owner.empty() && owner != ESM::RefId::stringRefId("Player");
;
const ESM::RefId& faction = cellref.getFaction();
bool isFactionOwned = false;
@ -866,7 +865,7 @@ namespace MWMechanics
}
// Perform bound item check and assign the Flag_Bound bit if it passes
ESM::RefId tempItemID = item.getCellRef().getRefId();
const ESM::RefId& tempItemID = item.getCellRef().getRefId();
if (boundItemIDCache.count(tempItemID) != 0)
return true;
@ -893,7 +892,7 @@ namespace MWMechanics
// TODO: implement a better check to check if target is owned bed
if (target.getClass().isActivator()
&& target.getClass().getScript(target).getRefIdString().compare(0, 3, "Bed") != 0)
&& target.getClass().getScript(target).getRefIdString().starts_with("Bed") != 0)
return true;
if (target.getClass().isNpc())

@ -25,7 +25,7 @@
namespace MWScript
{
ScriptManager::ScriptManager(const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode,
const std::vector<std::string>& scriptBlacklist)
const std::vector<ESM::RefId>& scriptBlacklist)
: mErrorHandler()
, mStore(store)
, mCompilerContext(compilerContext)
@ -37,8 +37,6 @@ namespace MWScript
mScriptBlacklist.resize(scriptBlacklist.size());
std::transform(scriptBlacklist.begin(), scriptBlacklist.end(), mScriptBlacklist.begin(),
[](const std::string& s) { return Misc::StringUtils::lowerCase(s); });
std::sort(mScriptBlacklist.begin(), mScriptBlacklist.end());
}
@ -112,7 +110,7 @@ namespace MWScript
}
// execute script
auto target = interpreterContext.getTarget();
const auto& target = interpreterContext.getTarget();
if (!iter->second.mByteCode.empty() && iter->second.mInactive.find(target) == iter->second.mInactive.end())
try
{
@ -155,8 +153,7 @@ namespace MWScript
for (auto& script : mStore.get<ESM::Script>())
{
if (!std::binary_search(mScriptBlacklist.begin(), mScriptBlacklist.end(),
Misc::StringUtils::lowerCase(script.mId.getRefIdString())))
if (!std::binary_search(mScriptBlacklist.begin(), mScriptBlacklist.end(), script.mId))
{
++count;
@ -188,8 +185,7 @@ namespace MWScript
{
Compiler::Locals locals;
const Compiler::ContextOverride override(
mErrorHandler, std::string{ name.getRefIdString() } + "[local variables]");
const Compiler::ContextOverride override(mErrorHandler, name.getRefIdString() + "[local variables]");
std::istringstream stream(script->mScriptText);
Compiler::QuickFileParser parser(mErrorHandler, mCompilerContext, locals);

@ -60,11 +60,11 @@ namespace MWScript
std::unordered_map<ESM::RefId, CompiledScript> mScripts;
GlobalScripts mGlobalScripts;
std::unordered_map<ESM::RefId, Compiler::Locals> mOtherLocals;
std::vector<std::string> mScriptBlacklist;
std::vector<ESM::RefId> mScriptBlacklist;
public:
ScriptManager(const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode,
const std::vector<std::string>& scriptBlacklist);
const std::vector<ESM::RefId>& scriptBlacklist);
void clear() override;

@ -973,7 +973,7 @@ namespace MWScript
{
MWWorld::Ptr ptr = R()(runtime);
ESM::RefId factionID = ptr.getClass().getPrimaryFaction(ptr);
const ESM::RefId& factionID = ptr.getClass().getPrimaryFaction(ptr);
if (factionID.empty())
return;
@ -1007,7 +1007,7 @@ namespace MWScript
{
MWWorld::Ptr ptr = R()(runtime);
ESM::RefId factionID = ptr.getClass().getPrimaryFaction(ptr);
const ESM::RefId& factionID = ptr.getClass().getPrimaryFaction(ptr);
if (factionID.empty())
return;

@ -628,7 +628,7 @@ void MWWorld::ContainerStore::addInitialItemImp(
}
else
{
auto itemId = MWMechanics::getLevelledItem(ptr.get<ESM::ItemLevList>()->mBase, false, *prng);
const auto& itemId = MWMechanics::getLevelledItem(ptr.get<ESM::ItemLevList>()->mBase, false, *prng);
if (itemId.empty())
return;
addInitialItem(itemId, owner, count, prng, false);

@ -429,7 +429,6 @@ namespace MWWorld
if (value.mRefID != deletedRefID)
{
ESM::RefId& refId = refIDs[value.mRefID];
// We manually lower case IDs here for the time being to improve performance.
++mRefCount[std::move(refId)];
}
};

@ -50,7 +50,6 @@ namespace MWWorld
ESM::CellRef cellRef;
cellRef.blank();
cellRef.mRefID = ESM::RefId::stringRefId("Player");
;
mPlayer = LiveCellRef<ESM::NPC>(cellRef, player);
ESM::Position playerPos = mPlayer.mData.getPosition();

@ -572,7 +572,8 @@ namespace MWWorld
if (cell)
return cell;
// treat "Wilderness" like an empty string
const ESM::RefId defaultName = ESM::RefId::stringRefId(mStore.get<ESM::GameSetting>().find("sDefaultCellname")->mValue.getString());
const ESM::RefId defaultName
= ESM::RefId::stringRefId(mStore.get<ESM::GameSetting>().find("sDefaultCellname")->mValue.getString());
if (cellName == defaultName)
{
cell = mStore.get<ESM::Cell>().searchExtByName(ESM::RefId::sEmpty);
@ -670,7 +671,7 @@ namespace MWWorld
return cell->mName;
if (const ESM::Region* region = mStore.get<ESM::Region>().search(cell->mRegion))
return ESM::RefId::stringRefId( region->mName);
return ESM::RefId::stringRefId(region->mName);
}
return ESM::RefId::stringRefId(mStore.get<ESM::GameSetting>().find("sDefaultCellname")->mValue.getString());
}

@ -3,10 +3,9 @@
#include "stats.hpp"
#include <components/esm3/loadpgrd.hpp>
#include <components/misc/algorithm.hpp>
#include <components/misc/convert.hpp>
#include <components/misc/coordinateconverter.hpp>
#include <components/misc/algorithm.hpp>
namespace DetourNavigator
{
@ -39,7 +38,8 @@ namespace DetourNavigator
mNavMeshManager.setWorldspace(worldspace, getImpl(guard));
}
void NavigatorImpl::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard) {
void NavigatorImpl::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard)
{
setWorldspace(Misc::StringUtils::lowerCase(worldspace.getRefIdString()), guard);
}

@ -31,7 +31,6 @@ namespace DetourNavigator
void setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard) override;
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard) override;
void addObject(const ObjectId id, const ObjectShapes& shapes, const btTransform& transform,

@ -26,7 +26,6 @@ namespace DetourNavigator
void setWorldspace(std::string_view /*worldspace*/, const UpdateGuard* /*guard*/) override {}
void setWorldspace(const ESM::RefId& /*worldspace*/, const UpdateGuard* /*guard*/) override {}
void addObject(const ObjectId /*id*/, const ObjectShapes& /*shapes*/, const btTransform& /*transform*/,
const UpdateGuard* /*guard*/) override
{

@ -1,8 +1,8 @@
#ifndef OPENMW_ESM_CELLID_H
#define OPENMW_ESM_CELLID_H
#include <string>
#include <components/esm/refid.hpp>
#include <string>
namespace ESM
{

Loading…
Cancel
Save