mirror of
https://github.com/OpenMW/openmw.git
synced 2025-10-14 22:26:41 +00:00
Add and fix -Wshadow
This commit is contained in:
parent
9610be7c8a
commit
3067294f0d
77 changed files with 455 additions and 445 deletions
|
@ -618,7 +618,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT
|
|||
add_compile_options("/WX")
|
||||
endif()
|
||||
else ()
|
||||
add_compile_options("-Wall" "-Wextra" "-Wundef" "-Wextra-semi" "-Wno-unused-parameter" "-pedantic" "-Wno-long-long" "-Wnon-virtual-dtor" "-Wunused")
|
||||
add_compile_options("-Wall" "-Wextra" "-Wundef" "-Wextra-semi" "-Wno-unused-parameter" "-pedantic" "-Wno-long-long" "-Wnon-virtual-dtor" "-Wunused" "-Wshadow")
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT APPLE)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.6 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 3.6)
|
||||
|
|
|
@ -24,8 +24,11 @@ namespace
|
|||
TEST(CorrectSoundPath, corrected_path_does_not_check_existence_in_vfs)
|
||||
{
|
||||
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({});
|
||||
constexpr VFS::Path::NormalizedView path("sound/foo.wav");
|
||||
EXPECT_EQ(correctSoundPath(path, *mVFS), "sound/foo.mp3");
|
||||
|
||||
{
|
||||
constexpr VFS::Path::NormalizedView path("sound/foo.wav");
|
||||
EXPECT_EQ(correctSoundPath(path, *mVFS), "sound/foo.mp3");
|
||||
}
|
||||
|
||||
auto correctESM4SoundPath = [](auto path, auto* vfs) {
|
||||
return Misc::ResourceHelpers::correctResourcePath({ { "sound" } }, path, vfs, ".mp3");
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace
|
|||
bool isNear(const btVector3& lhs, const btVector3& rhs)
|
||||
{
|
||||
return std::equal(static_cast<const btScalar*>(lhs), static_cast<const btScalar*>(lhs) + 3,
|
||||
static_cast<const btScalar*>(rhs), [](btScalar lhs, btScalar rhs) { return isNear(lhs, rhs); });
|
||||
static_cast<const btScalar*>(rhs), [](btScalar l, btScalar r) { return isNear(l, r); });
|
||||
}
|
||||
|
||||
bool isNear(const btMatrix3x3& lhs, const btMatrix3x3& rhs)
|
||||
|
|
|
@ -572,13 +572,13 @@ namespace EsmTool
|
|||
}
|
||||
}
|
||||
|
||||
auto visitorRec = [¶ms](ESM4::Reader& reader) { return readRecord(params, reader); };
|
||||
auto visitorGroup = [¶ms](ESM4::Reader& reader) {
|
||||
auto visitorRec = [¶ms](ESM4::Reader& r) { return readRecord(params, r); };
|
||||
auto visitorGroup = [¶ms](ESM4::Reader& r) {
|
||||
if (params.mQuite)
|
||||
return;
|
||||
auto groupType = static_cast<ESM4::GroupType>(reader.hdr().group.type);
|
||||
std::cout << "\nGroup: " << toString(groupType) << " "
|
||||
<< ESM::NAME(reader.hdr().group.typeId).toStringView() << '\n';
|
||||
auto groupType = static_cast<ESM4::GroupType>(r.hdr().group.type);
|
||||
std::cout << "\nGroup: " << toString(groupType) << " " << ESM::NAME(r.hdr().group.typeId).toStringView()
|
||||
<< '\n';
|
||||
};
|
||||
ESM4::ReaderUtils::readAll(reader, visitorRec, visitorGroup);
|
||||
}
|
||||
|
|
|
@ -245,10 +245,10 @@ CSMWorld::UniversalId::UniversalId(const std::string& universalId)
|
|||
|
||||
std::istringstream stream(universalId.substr(index + 2));
|
||||
|
||||
int index = 0;
|
||||
if (stream >> index)
|
||||
int indexValue = 0;
|
||||
if (stream >> indexValue)
|
||||
{
|
||||
mValue = index;
|
||||
mValue = indexValue;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
#include "../../model/world/data.hpp"
|
||||
#include "../../model/world/idtablebase.hpp"
|
||||
|
||||
CSVFilter::EditWidget::EditWidget(CSMWorld::Data& data, QWidget* parent)
|
||||
CSVFilter::EditWidget::EditWidget(CSMWorld::Data& worldData, QWidget* parent)
|
||||
: QLineEdit(parent)
|
||||
, mParser(data)
|
||||
, mParser(worldData)
|
||||
, mIsEmpty(true)
|
||||
{
|
||||
mPalette = palette();
|
||||
connect(this, &QLineEdit::textChanged, this, &EditWidget::textChanged);
|
||||
|
||||
const CSMWorld::IdTableBase* model
|
||||
= static_cast<const CSMWorld::IdTableBase*>(data.getTableModel(CSMWorld::UniversalId::Type_Filters));
|
||||
= static_cast<const CSMWorld::IdTableBase*>(worldData.getTableModel(CSMWorld::UniversalId::Type_Filters));
|
||||
|
||||
connect(model, &CSMWorld::IdTableBase::dataChanged, this, &EditWidget::filterDataChanged, Qt::QueuedConnection);
|
||||
connect(model, &CSMWorld::IdTableBase::rowsRemoved, this, &EditWidget::filterRowsRemoved, Qt::QueuedConnection);
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace CSVFilter
|
|||
QAction* mHelpAction;
|
||||
|
||||
public:
|
||||
EditWidget(CSMWorld::Data& data, QWidget* parent = nullptr);
|
||||
explicit EditWidget(CSMWorld::Data& worldData, QWidget* parent = nullptr);
|
||||
|
||||
void createFilterRequest(const std::vector<FilterData>& sourceFilter, Qt::DropAction action);
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
#include <apps/opencs/model/world/universalid.hpp>
|
||||
#include <apps/opencs/view/world/dragrecordtable.hpp>
|
||||
|
||||
CSVFilter::FilterBox::FilterBox(CSMWorld::Data& data, QWidget* parent)
|
||||
CSVFilter::FilterBox::FilterBox(CSMWorld::Data& worldData, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
mRecordFilterBox = new RecordFilterBox(data, this);
|
||||
mRecordFilterBox = new RecordFilterBox(worldData, this);
|
||||
|
||||
layout->addWidget(mRecordFilterBox);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace CSVFilter
|
|||
RecordFilterBox* mRecordFilterBox;
|
||||
|
||||
public:
|
||||
FilterBox(CSMWorld::Data& data, QWidget* parent = nullptr);
|
||||
explicit FilterBox(CSMWorld::Data& worldData, QWidget* parent = nullptr);
|
||||
|
||||
void setRecordFilter(const std::string& filter);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "editwidget.hpp"
|
||||
#include "filterdata.hpp"
|
||||
|
||||
CSVFilter::RecordFilterBox::RecordFilterBox(CSMWorld::Data& data, QWidget* parent)
|
||||
CSVFilter::RecordFilterBox::RecordFilterBox(CSMWorld::Data& worldData, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
|
@ -20,7 +20,7 @@ CSVFilter::RecordFilterBox::RecordFilterBox(CSMWorld::Data& data, QWidget* paren
|
|||
label->setIndent(2);
|
||||
layout->addWidget(label);
|
||||
|
||||
mEdit = new EditWidget(data, this);
|
||||
mEdit = new EditWidget(worldData, this);
|
||||
|
||||
layout->addWidget(mEdit);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace CSVFilter
|
|||
EditWidget* mEdit;
|
||||
|
||||
public:
|
||||
RecordFilterBox(CSMWorld::Data& data, QWidget* parent = nullptr);
|
||||
explicit RecordFilterBox(CSMWorld::Data& worldData, QWidget* parent = nullptr);
|
||||
|
||||
void setFilter(const std::string& filter);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace CSVRender
|
|||
PathgridMode::PathgridMode(WorldspaceWidget* worldspaceWidget, QWidget* parent)
|
||||
: EditMode(worldspaceWidget, Misc::ScalableIcon::load(":scenetoolbar/editing-pathgrid"),
|
||||
Mask_Pathgrid | Mask_Terrain | Mask_Reference, getTooltip(), parent)
|
||||
, mDragMode(DragMode_None)
|
||||
, mDragMode(DragMode::None)
|
||||
, mFromNode(0)
|
||||
, mSelectionMode(nullptr)
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ namespace CSVRender
|
|||
|
||||
if (!selection.empty())
|
||||
{
|
||||
mDragMode = DragMode_Move;
|
||||
mDragMode = DragMode::Move;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ namespace CSVRender
|
|||
{
|
||||
if (PathgridTag* tag = dynamic_cast<PathgridTag*>(hit.tag.get()))
|
||||
{
|
||||
mDragMode = DragMode_Edge;
|
||||
mDragMode = DragMode::Edge;
|
||||
mEdgeId = tag->getPathgrid()->getId();
|
||||
mFromNode = SceneUtil::getPathgridNode(hit.index0);
|
||||
|
||||
|
@ -202,7 +202,7 @@ namespace CSVRender
|
|||
|
||||
void PathgridMode::drag(const QPoint& pos, int diffX, int diffY, double speedFactor)
|
||||
{
|
||||
if (mDragMode == DragMode_Move)
|
||||
if (mDragMode == DragMode::Move)
|
||||
{
|
||||
std::vector<osg::ref_ptr<TagBase>> selection = getWorldspaceWidget().getSelection(Mask_Pathgrid);
|
||||
|
||||
|
@ -219,7 +219,7 @@ namespace CSVRender
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (mDragMode == DragMode_Edge)
|
||||
else if (mDragMode == DragMode::Edge)
|
||||
{
|
||||
WorldspaceHitResult hit = getWorldspaceWidget().mousePick(pos, getWorldspaceWidget().getInteractionMask());
|
||||
|
||||
|
@ -243,7 +243,7 @@ namespace CSVRender
|
|||
|
||||
void PathgridMode::dragCompleted(const QPoint& pos)
|
||||
{
|
||||
if (mDragMode == DragMode_Move)
|
||||
if (mDragMode == DragMode::Move)
|
||||
{
|
||||
std::vector<osg::ref_ptr<TagBase>> selection = getWorldspaceWidget().getSelection(Mask_Pathgrid);
|
||||
for (std::vector<osg::ref_ptr<TagBase>>::iterator it = selection.begin(); it != selection.end(); ++it)
|
||||
|
@ -258,7 +258,7 @@ namespace CSVRender
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (mDragMode == DragMode_Edge)
|
||||
else if (mDragMode == DragMode::Edge)
|
||||
{
|
||||
WorldspaceHitResult hit = getWorldspaceWidget().mousePick(pos, getWorldspaceWidget().getInteractionMask());
|
||||
|
||||
|
@ -283,7 +283,7 @@ namespace CSVRender
|
|||
mFromNode = 0;
|
||||
}
|
||||
|
||||
mDragMode = DragMode_None;
|
||||
mDragMode = DragMode::None;
|
||||
getWorldspaceWidget().reset(Mask_Pathgrid);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,11 +50,11 @@ namespace CSVRender
|
|||
void dragAborted() override;
|
||||
|
||||
private:
|
||||
enum DragMode
|
||||
enum class DragMode
|
||||
{
|
||||
DragMode_None,
|
||||
DragMode_Move,
|
||||
DragMode_Edge
|
||||
None,
|
||||
Move,
|
||||
Edge
|
||||
};
|
||||
|
||||
DragMode mDragMode;
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
class QWidget;
|
||||
|
||||
CSVRender::PreviewWidget::PreviewWidget(
|
||||
CSMWorld::Data& data, const std::string& id, bool referenceable, QWidget* parent)
|
||||
: SceneWidget(data.getResourceSystem(), parent)
|
||||
, mData(data)
|
||||
, mObject(data, mRootNode, id, referenceable)
|
||||
CSMWorld::Data& worldData, const std::string& id, bool referenceable, QWidget* parent)
|
||||
: SceneWidget(worldData.getResourceSystem(), parent)
|
||||
, mData(worldData)
|
||||
, mObject(worldData, mRootNode, id, referenceable)
|
||||
{
|
||||
selectNavigationMode("orbit");
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ namespace CSVRender
|
|||
CSVRender::Object mObject;
|
||||
|
||||
public:
|
||||
PreviewWidget(CSMWorld::Data& data, const std::string& id, bool referenceable, QWidget* parent = nullptr);
|
||||
explicit PreviewWidget(
|
||||
CSMWorld::Data& worldData, const std::string& id, bool referenceable, QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
@ -454,7 +454,7 @@ CSVRender::WorldspaceHitResult CSVRender::WorldspaceWidget::mousePick(
|
|||
std::vector<osgUtil::LineSegmentIntersector::Intersection> validIntersections
|
||||
= { intersections.begin(), intersections.end() };
|
||||
|
||||
const auto& removeBackfaces = [direction = direction](const osgUtil::LineSegmentIntersector::Intersection& i) {
|
||||
const auto& removeBackfaces = [direction](const osgUtil::LineSegmentIntersector::Intersection& i) {
|
||||
return direction * i.getWorldIntersectNormal() > 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@ std::string CSVWorld::BodyPartCreator::getId() const
|
|||
return id;
|
||||
}
|
||||
|
||||
CSVWorld::BodyPartCreator::BodyPartCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
CSVWorld::BodyPartCreator::BodyPartCreator(
|
||||
CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(worldData, undoStack, id)
|
||||
{
|
||||
mFirstPerson = new QCheckBox("First Person", this);
|
||||
insertBeforeButtons(mFirstPerson, false);
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace CSVWorld
|
|||
std::string getId() const override;
|
||||
|
||||
public:
|
||||
BodyPartCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
explicit BodyPartCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
|
||||
/// \return Error description for current user input.
|
||||
std::string getErrors() const override;
|
||||
|
|
|
@ -37,8 +37,8 @@ void CSVWorld::CellCreator::configureCreateCommand(CSMWorld::CreateCommand& comm
|
|||
command.addNestedValue(parentIndex, index, mType->currentIndex() == 0);
|
||||
}
|
||||
|
||||
CSVWorld::CellCreator::CellCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
CSVWorld::CellCreator::CellCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(worldData, undoStack, id)
|
||||
{
|
||||
mY = new QSpinBox(this);
|
||||
mY->setVisible(false);
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace CSVWorld
|
|||
void configureCreateCommand(CSMWorld::CreateCommand& command) const override;
|
||||
|
||||
public:
|
||||
CellCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
explicit CellCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
|
||||
void reset() override;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ void CSVWorld::DialogueCreator::configureCreateCommand(CSMWorld::CreateCommand&
|
|||
}
|
||||
|
||||
CSVWorld::DialogueCreator::DialogueCreator(
|
||||
CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, int type)
|
||||
: GenericCreator(data, undoStack, id, true)
|
||||
CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id, int type)
|
||||
: GenericCreator(worldData, undoStack, id, true)
|
||||
, mType(type)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace CSVWorld
|
|||
void configureCreateCommand(CSMWorld::CreateCommand& command) const override;
|
||||
|
||||
public:
|
||||
DialogueCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, int type);
|
||||
explicit DialogueCreator(
|
||||
CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id, int type);
|
||||
};
|
||||
|
||||
class TopicCreatorFactory : public CreatorFactoryBase
|
||||
|
|
|
@ -149,8 +149,8 @@ void CSVWorld::GenericCreator::addScope(const QString& name, CSMWorld::Scope sco
|
|||
}
|
||||
|
||||
CSVWorld::GenericCreator::GenericCreator(
|
||||
CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, bool relaxedIdRules)
|
||||
: mData(data)
|
||||
CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id, bool relaxedIdRules)
|
||||
: mData(worldData)
|
||||
, mUndoStack(undoStack)
|
||||
, mListId(id)
|
||||
, mLocked(false)
|
||||
|
|
|
@ -95,8 +95,8 @@ namespace CSVWorld
|
|||
void addScope(const QString& name, CSMWorld::Scope scope, const QString& tooltip);
|
||||
|
||||
public:
|
||||
GenericCreator(
|
||||
CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, bool relaxedIdRules = false);
|
||||
explicit GenericCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
bool relaxedIdRules = false);
|
||||
|
||||
void setEditLock(bool locked) override;
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ namespace CSVWorld
|
|||
command.addValue(index, type);
|
||||
}
|
||||
|
||||
GlobalCreator::GlobalCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(data, undoStack, id, true)
|
||||
GlobalCreator::GlobalCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(worldData, undoStack, id, true)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace CSVWorld
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GlobalCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
explicit GlobalCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
|
||||
protected:
|
||||
void configureCreateCommand(CSMWorld::CreateCommand& command) const override;
|
||||
|
|
|
@ -81,9 +81,9 @@ void CSVWorld::InfoCreator::configureCreateCommand(CSMWorld::CreateCommand& comm
|
|||
}
|
||||
}
|
||||
|
||||
CSVWorld::InfoCreator::InfoCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
CSVWorld::InfoCreator::InfoCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
CSMWorld::IdCompletionManager& completionManager)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
: GenericCreator(worldData, undoStack, id)
|
||||
{
|
||||
// Determine if we're dealing with topics or journals.
|
||||
CSMWorld::ColumnBase::Display displayType = CSMWorld::ColumnBase::Display_Topic;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace CSVWorld
|
|||
void configureCreateCommand(CSMWorld::CreateCommand& command) const override;
|
||||
|
||||
public:
|
||||
InfoCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
explicit InfoCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
CSMWorld::IdCompletionManager& completionManager);
|
||||
|
||||
void cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type) override;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
namespace CSVWorld
|
||||
{
|
||||
LandCreator::LandCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
LandCreator::LandCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(worldData, undoStack, id)
|
||||
, mXLabel(nullptr)
|
||||
, mYLabel(nullptr)
|
||||
, mX(nullptr)
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace CSVWorld
|
|||
QSpinBox* mY;
|
||||
|
||||
public:
|
||||
LandCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
explicit LandCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
|
||||
void cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type) override;
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ CSMWorld::IdTable& CSVWorld::PathgridCreator::getPathgridsTable() const
|
|||
return dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(getCollectionId()));
|
||||
}
|
||||
|
||||
CSVWorld::PathgridCreator::PathgridCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
CSMWorld::IdCompletionManager& completionManager)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
CSVWorld::PathgridCreator::PathgridCreator(CSMWorld::Data& worldData, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id, CSMWorld::IdCompletionManager& completionManager)
|
||||
: GenericCreator(worldData, undoStack, id)
|
||||
{
|
||||
setManualEditing(false);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace CSVWorld
|
|||
CSMWorld::IdTable& getPathgridsTable() const;
|
||||
|
||||
public:
|
||||
PathgridCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
explicit PathgridCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
CSMWorld::IdCompletionManager& completionManager);
|
||||
|
||||
/// \brief Set cell ID input widget to ID of record to be cloned.
|
||||
|
|
|
@ -25,8 +25,8 @@ void CSVWorld::ReferenceableCreator::configureCreateCommand(CSMWorld::CreateComm
|
|||
}
|
||||
|
||||
CSVWorld::ReferenceableCreator::ReferenceableCreator(
|
||||
CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(worldData, undoStack, id)
|
||||
{
|
||||
QLabel* label = new QLabel("Type", this);
|
||||
insertBeforeButtons(label, false);
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace CSVWorld
|
|||
void configureCreateCommand(CSMWorld::CreateCommand& command) const override;
|
||||
|
||||
public:
|
||||
ReferenceableCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
explicit ReferenceableCreator(
|
||||
CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
|
||||
void reset() override;
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ void CSVWorld::ReferenceCreator::configureCreateCommand(CSMWorld::CreateCommand&
|
|||
command.addValue(cellIdColumn, mCell->text());
|
||||
}
|
||||
|
||||
CSVWorld::ReferenceCreator::ReferenceCreator(CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
CSVWorld::ReferenceCreator::ReferenceCreator(CSMWorld::Data& worldData, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id, CSMWorld::IdCompletionManager& completionManager)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
: GenericCreator(worldData, undoStack, id)
|
||||
{
|
||||
QLabel* label = new QLabel("Cell", this);
|
||||
insertBeforeButtons(label, false);
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace CSVWorld
|
|||
void configureCreateCommand(CSMWorld::CreateCommand& command) const override;
|
||||
|
||||
public:
|
||||
ReferenceCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
explicit ReferenceCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
CSMWorld::IdCompletionManager& completionManager);
|
||||
|
||||
void cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type) override;
|
||||
|
|
|
@ -29,9 +29,9 @@ CSMWorld::IdTable& CSVWorld::StartScriptCreator::getStartScriptsTable() const
|
|||
return dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(getCollectionId()));
|
||||
}
|
||||
|
||||
CSVWorld::StartScriptCreator::StartScriptCreator(CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
CSVWorld::StartScriptCreator::StartScriptCreator(CSMWorld::Data& worldData, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id, CSMWorld::IdCompletionManager& completionManager)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
: GenericCreator(worldData, undoStack, id)
|
||||
{
|
||||
setManualEditing(false);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace CSVWorld
|
|||
CSMWorld::IdTable& getStartScriptsTable() const;
|
||||
|
||||
public:
|
||||
StartScriptCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
explicit StartScriptCreator(CSMWorld::Data& worldData, QUndoStack& undoStack, const CSMWorld::UniversalId& id,
|
||||
CSMWorld::IdCompletionManager& completionManager);
|
||||
|
||||
/// \brief Set script ID input widget to ID of record to be cloned.
|
||||
|
|
|
@ -71,8 +71,8 @@ namespace MWDialogue
|
|||
const ESM::Dialogue* dialogue
|
||||
= MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().find(entry.mTopic);
|
||||
|
||||
auto info = std::find_if(dialogue->mInfo.begin(), dialogue->mInfo.end(),
|
||||
[&](const auto& info) { return info.mId == entry.mInfoId; });
|
||||
auto info = std::find_if(
|
||||
dialogue->mInfo.begin(), dialogue->mInfo.end(), [&](const auto& i) { return i.mId == entry.mInfoId; });
|
||||
|
||||
if (info == dialogue->mInfo.end() || info->mData.mJournalIndex == -1)
|
||||
throw std::runtime_error("unknown journal entry for topic " + mTopic.toDebugString());
|
||||
|
|
|
@ -1122,10 +1122,10 @@ namespace MWGui
|
|||
|
||||
struct CreateActiveFormat
|
||||
{
|
||||
PageDisplay* this_;
|
||||
PageDisplay* mPageDisplay;
|
||||
|
||||
CreateActiveFormat(PageDisplay* this_)
|
||||
: this_(this_)
|
||||
explicit CreateActiveFormat(PageDisplay* pageDisplay)
|
||||
: mPageDisplay(pageDisplay)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1133,15 +1133,15 @@ namespace MWGui
|
|||
{
|
||||
MyGUI::IFont* const font = run.mStyle->mFont;
|
||||
|
||||
ActiveTextFormats::iterator j = this_->mActiveTextFormats.find(font);
|
||||
ActiveTextFormats::iterator j = mPageDisplay->mActiveTextFormats.find(font);
|
||||
|
||||
if (j == this_->mActiveTextFormats.end())
|
||||
if (j == mPageDisplay->mActiveTextFormats.end())
|
||||
{
|
||||
auto textFormat = std::make_unique<TextFormat>(font, this_);
|
||||
auto textFormat = std::make_unique<TextFormat>(font, mPageDisplay);
|
||||
|
||||
textFormat->mTexture = font->getTextureFont();
|
||||
|
||||
j = this_->mActiveTextFormats.insert(std::make_pair(font, std::move(textFormat))).first;
|
||||
j = mPageDisplay->mActiveTextFormats.insert(std::make_pair(font, std::move(textFormat))).first;
|
||||
}
|
||||
|
||||
j->second->mCountVertex += run.mPrintableChars * 6;
|
||||
|
@ -1189,24 +1189,24 @@ namespace MWGui
|
|||
|
||||
struct RenderRun
|
||||
{
|
||||
PageDisplay* this_;
|
||||
GlyphStream& glyphStream;
|
||||
PageDisplay* mPageDisplay;
|
||||
GlyphStream& mGlyphStream;
|
||||
|
||||
RenderRun(PageDisplay* this_, GlyphStream& glyphStream)
|
||||
: this_(this_)
|
||||
, glyphStream(glyphStream)
|
||||
explicit RenderRun(PageDisplay* pageDisplay, GlyphStream& glyphStream)
|
||||
: mPageDisplay(pageDisplay)
|
||||
, mGlyphStream(glyphStream)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(Section const& section, Line const& line, Run const& run) const
|
||||
{
|
||||
bool isActive = run.mStyle->mInteractiveId && (run.mStyle == this_->mFocusItem);
|
||||
bool isActive = run.mStyle->mInteractiveId && (run.mStyle == mPageDisplay->mFocusItem);
|
||||
|
||||
MyGUI::Colour colour = isActive
|
||||
? (this_->mItemActive ? run.mStyle->mActiveColour : run.mStyle->mHotColour)
|
||||
? (mPageDisplay->mItemActive ? run.mStyle->mActiveColour : run.mStyle->mHotColour)
|
||||
: run.mStyle->mNormalColour;
|
||||
|
||||
glyphStream.reset(static_cast<float>(section.mRect.left + line.mRect.left + run.mLeft),
|
||||
mGlyphStream.reset(static_cast<float>(section.mRect.left + line.mRect.left + run.mLeft),
|
||||
static_cast<float>(line.mRect.top), colour);
|
||||
|
||||
Utf8Stream stream(run.mRange);
|
||||
|
@ -1219,9 +1219,9 @@ namespace MWGui
|
|||
continue;
|
||||
|
||||
if (!ucsSpace(codePoint))
|
||||
glyphStream.emitGlyph(codePoint);
|
||||
mGlyphStream.emitGlyph(codePoint);
|
||||
else
|
||||
glyphStream.emitSpace(codePoint);
|
||||
mGlyphStream.emitSpace(codePoint);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -75,11 +75,11 @@ namespace MWGui
|
|||
{
|
||||
typedef t_iterator iterator_t;
|
||||
|
||||
iterator_t itr;
|
||||
iterator_t mItr;
|
||||
JournalViewModelImpl const* mModel;
|
||||
|
||||
BaseEntry(JournalViewModelImpl const* model, iterator_t itr)
|
||||
: itr(itr)
|
||||
: mItr(itr)
|
||||
, mModel(model)
|
||||
, loaded(false)
|
||||
{
|
||||
|
@ -235,7 +235,7 @@ namespace MWGui
|
|||
template <typename iterator_t>
|
||||
struct JournalEntryImpl : BaseEntry<iterator_t, JournalEntry>
|
||||
{
|
||||
using BaseEntry<iterator_t, JournalEntry>::itr;
|
||||
using BaseEntry<iterator_t, JournalEntry>::mItr;
|
||||
|
||||
mutable std::string timestamp_buffer;
|
||||
|
||||
|
@ -244,7 +244,7 @@ namespace MWGui
|
|||
{
|
||||
}
|
||||
|
||||
std::string getText() const override { return itr->getText(); }
|
||||
std::string getText() const override { return mItr->getText(); }
|
||||
|
||||
Utf8Span timestamp() const override
|
||||
{
|
||||
|
@ -254,9 +254,9 @@ namespace MWGui
|
|||
|
||||
std::ostringstream os;
|
||||
|
||||
os << itr->mDayOfMonth << ' '
|
||||
<< MWBase::Environment::get().getWorld()->getTimeManager()->getMonthName(itr->mMonth) << " ("
|
||||
<< dayStr << " " << (itr->mDay) << ')';
|
||||
os << mItr->mDayOfMonth << ' '
|
||||
<< MWBase::Environment::get().getWorld()->getTimeManager()->getMonthName(mItr->mMonth) << " ("
|
||||
<< dayStr << " " << (mItr->mDay) << ')';
|
||||
|
||||
timestamp_buffer = os.str();
|
||||
}
|
||||
|
@ -334,9 +334,9 @@ namespace MWGui
|
|||
{
|
||||
}
|
||||
|
||||
std::string getText() const override { return itr->getText(); }
|
||||
std::string getText() const override { return mItr->getText(); }
|
||||
|
||||
Utf8Span source() const override { return toUtf8Span(itr->mActorName); }
|
||||
Utf8Span source() const override { return toUtf8Span(mItr->mActorName); }
|
||||
};
|
||||
|
||||
void visitTopicEntries(TopicId topicId, std::function<void(TopicEntry const&)> visitor) const override
|
||||
|
|
|
@ -465,11 +465,11 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
auto tryFocus = [this](ListWrapper* widget, const std::string& hint) {
|
||||
auto tryFocus = [this](ListWrapper* widget, const std::string& focusHint) {
|
||||
MyGUI::Widget* oldFocus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||
if (oldFocus == mFilter)
|
||||
return;
|
||||
size_t index = widget->findItemIndexWith(hint);
|
||||
size_t index = widget->findItemIndexWith(focusHint);
|
||||
|
||||
if (index != MyGUI::ITEM_NONE)
|
||||
{
|
||||
|
|
|
@ -626,8 +626,8 @@ namespace MWGui
|
|||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||
|
||||
auto assign = [this](auto type, MWWorld::Ptr item) {
|
||||
if (type == ESM::QuickKeys::Type::Item)
|
||||
auto assign = [this](ESM::QuickKeys::Type keyType, MWWorld::Ptr item) {
|
||||
if (keyType == ESM::QuickKeys::Type::Item)
|
||||
assignItem(item);
|
||||
else // if (quickKey.mType == ESM::QuickKeys::Type::MagicItem)
|
||||
onAssignMagicItem(item);
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace MWLua
|
|||
inputActions[sol::meta_function::index]
|
||||
= [](LuaUtil::InputAction::Registry& registry, std::string_view key) { return registry[key]; };
|
||||
{
|
||||
auto pairs = [](LuaUtil::InputAction::Registry& registry) {
|
||||
auto pairs = [](LuaUtil::InputAction::Registry& self) {
|
||||
auto next = [](LuaUtil::InputAction::Registry& registry, std::string_view key)
|
||||
-> sol::optional<std::tuple<std::string, LuaUtil::InputAction::Info>> {
|
||||
std::optional<std::string> nextKey(registry.nextKey(key));
|
||||
|
@ -93,7 +93,7 @@ namespace MWLua
|
|||
else
|
||||
return std::make_tuple(*nextKey, registry[*nextKey].value());
|
||||
};
|
||||
return std::make_tuple(next, registry, registry.firstKey());
|
||||
return std::make_tuple(next, self, self.firstKey());
|
||||
};
|
||||
inputActions[sol::meta_function::pairs] = pairs;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ namespace MWLua
|
|||
inputTriggers[sol::meta_function::index]
|
||||
= [](LuaUtil::InputTrigger::Registry& registry, std::string_view key) { return registry[key]; };
|
||||
{
|
||||
auto pairs = [](LuaUtil::InputTrigger::Registry& registry) {
|
||||
auto pairs = [](LuaUtil::InputTrigger::Registry& self) {
|
||||
auto next = [](LuaUtil::InputTrigger::Registry& registry, std::string_view key)
|
||||
-> sol::optional<std::tuple<std::string, LuaUtil::InputTrigger::Info>> {
|
||||
std::optional<std::string> nextKey(registry.nextKey(key));
|
||||
|
@ -131,7 +131,7 @@ namespace MWLua
|
|||
else
|
||||
return std::make_tuple(*nextKey, registry[*nextKey].value());
|
||||
};
|
||||
return std::make_tuple(next, registry, registry.firstKey());
|
||||
return std::make_tuple(next, self, self.firstKey());
|
||||
};
|
||||
inputTriggers[sol::meta_function::pairs] = pairs;
|
||||
}
|
||||
|
|
|
@ -214,18 +214,18 @@ namespace MWLua
|
|||
|
||||
sol::table initCoreMagicBindings(const Context& context)
|
||||
{
|
||||
sol::state_view lua = context.sol();
|
||||
sol::table magicApi(lua, sol::create);
|
||||
sol::state_view state = context.sol();
|
||||
sol::table magicApi(state, sol::create);
|
||||
|
||||
// Constants
|
||||
magicApi["RANGE"] = LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, ESM::RangeType>(lua,
|
||||
magicApi["RANGE"] = LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, ESM::RangeType>(state,
|
||||
{
|
||||
{ "Self", ESM::RT_Self },
|
||||
{ "Touch", ESM::RT_Touch },
|
||||
{ "Target", ESM::RT_Target },
|
||||
}));
|
||||
magicApi["SPELL_TYPE"]
|
||||
= LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, ESM::Spell::SpellType>(lua,
|
||||
= LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, ESM::Spell::SpellType>(state,
|
||||
{
|
||||
{ "Spell", ESM::Spell::ST_Spell },
|
||||
{ "Ability", ESM::Spell::ST_Ability },
|
||||
|
@ -235,7 +235,7 @@ namespace MWLua
|
|||
{ "Power", ESM::Spell::ST_Power },
|
||||
}));
|
||||
magicApi["ENCHANTMENT_TYPE"]
|
||||
= LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, ESM::Enchantment::Type>(lua,
|
||||
= LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, ESM::Enchantment::Type>(state,
|
||||
{
|
||||
{ "CastOnce", ESM::Enchantment::Type::CastOnce },
|
||||
{ "CastOnStrike", ESM::Enchantment::Type::WhenStrikes },
|
||||
|
@ -243,7 +243,7 @@ namespace MWLua
|
|||
{ "ConstantEffect", ESM::Enchantment::Type::ConstantEffect },
|
||||
}));
|
||||
|
||||
sol::table effect(lua, sol::create);
|
||||
sol::table effect(state, sol::create);
|
||||
magicApi["EFFECT_TYPE"] = LuaUtil::makeStrictReadOnly(effect);
|
||||
for (const auto& name : ESM::MagicEffect::sIndexNames)
|
||||
{
|
||||
|
@ -251,22 +251,22 @@ namespace MWLua
|
|||
}
|
||||
|
||||
// Spell store
|
||||
sol::table spells(lua, sol::create);
|
||||
sol::table spells(state, sol::create);
|
||||
addRecordFunctionBinding<ESM::Spell>(spells, context);
|
||||
magicApi["spells"] = LuaUtil::makeReadOnly(spells);
|
||||
|
||||
// Enchantment store
|
||||
sol::table enchantments(lua, sol::create);
|
||||
sol::table enchantments(state, sol::create);
|
||||
addRecordFunctionBinding<ESM::Enchantment>(enchantments, context);
|
||||
magicApi["enchantments"] = LuaUtil::makeReadOnly(enchantments);
|
||||
|
||||
// MagicEffect store
|
||||
sol::table magicEffects(lua, sol::create);
|
||||
sol::table magicEffects(state, sol::create);
|
||||
magicApi["effects"] = LuaUtil::makeReadOnly(magicEffects);
|
||||
using MagicEffectStore = MWWorld::Store<ESM::MagicEffect>;
|
||||
const MagicEffectStore* magicEffectStore
|
||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>();
|
||||
auto magicEffectStoreT = lua.new_usertype<MagicEffectStore>("ESM3_MagicEffectStore");
|
||||
auto magicEffectStoreT = state.new_usertype<MagicEffectStore>("ESM3_MagicEffectStore");
|
||||
magicEffectStoreT[sol::meta_function::to_string] = [](const MagicEffectStore& store) {
|
||||
return "ESM3_MagicEffectStore{" + std::to_string(store.getSize()) + " effects}";
|
||||
};
|
||||
|
@ -276,7 +276,7 @@ namespace MWLua
|
|||
int index = ESM::MagicEffect::indexNameToIndex(id);
|
||||
return store.search(index);
|
||||
});
|
||||
auto magicEffectsIter = [magicEffectStore](sol::this_state lua, const sol::object& /*store*/,
|
||||
auto magicEffectsIter = [magicEffectStore](sol::this_state thisState, const sol::object& /*store*/,
|
||||
sol::optional<int> id) -> std::tuple<sol::object, sol::object> {
|
||||
MagicEffectStore::iterator iter;
|
||||
if (id.has_value())
|
||||
|
@ -288,19 +288,20 @@ namespace MWLua
|
|||
else
|
||||
iter = magicEffectStore->begin();
|
||||
if (iter != magicEffectStore->end())
|
||||
return std::make_tuple(sol::make_object(lua, iter->first), sol::make_object(lua, &iter->second));
|
||||
return std::make_tuple(
|
||||
sol::make_object(thisState, iter->first), sol::make_object(thisState, &iter->second));
|
||||
else
|
||||
return std::make_tuple(sol::nil, sol::nil);
|
||||
};
|
||||
magicEffectStoreT[sol::meta_function::pairs]
|
||||
= [iter = sol::make_object(lua, magicEffectsIter)] { return iter; };
|
||||
= [iter = sol::make_object(state, magicEffectsIter)] { return iter; };
|
||||
magicEffectStoreT[sol::meta_function::ipairs]
|
||||
= [iter = sol::make_object(lua, magicEffectsIter)] { return iter; };
|
||||
= [iter = sol::make_object(state, magicEffectsIter)] { return iter; };
|
||||
|
||||
magicEffects["records"] = magicEffectStore;
|
||||
|
||||
// Spell record
|
||||
auto spellT = lua.new_usertype<ESM::Spell>("ESM3_Spell");
|
||||
auto spellT = state.new_usertype<ESM::Spell>("ESM3_Spell");
|
||||
spellT[sol::meta_function::to_string]
|
||||
= [](const ESM::Spell& rec) -> std::string { return "ESM3_Spell[" + rec.mId.toDebugString() + "]"; };
|
||||
spellT["id"] = sol::readonly_property([](const ESM::Spell& rec) { return rec.mId.serializeText(); });
|
||||
|
@ -313,12 +314,12 @@ namespace MWLua
|
|||
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_PCStart); });
|
||||
spellT["autocalcFlag"] = sol::readonly_property(
|
||||
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_Autocalc); });
|
||||
spellT["effects"] = sol::readonly_property([lua = lua.lua_state()](const ESM::Spell& rec) -> sol::table {
|
||||
spellT["effects"] = sol::readonly_property([lua = state.lua_state()](const ESM::Spell& rec) -> sol::table {
|
||||
return effectParamsListToTable(lua, rec.mEffects.mList);
|
||||
});
|
||||
|
||||
// Enchantment record
|
||||
auto enchantT = lua.new_usertype<ESM::Enchantment>("ESM3_Enchantment");
|
||||
auto enchantT = state.new_usertype<ESM::Enchantment>("ESM3_Enchantment");
|
||||
enchantT[sol::meta_function::to_string] = [](const ESM::Enchantment& rec) -> std::string {
|
||||
return "ESM3_Enchantment[" + rec.mId.toDebugString() + "]";
|
||||
};
|
||||
|
@ -330,12 +331,12 @@ namespace MWLua
|
|||
enchantT["charge"]
|
||||
= sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCharge; });
|
||||
enchantT["effects"]
|
||||
= sol::readonly_property([lua = lua.lua_state()](const ESM::Enchantment& rec) -> sol::table {
|
||||
= sol::readonly_property([lua = state.lua_state()](const ESM::Enchantment& rec) -> sol::table {
|
||||
return effectParamsListToTable(lua, rec.mEffects.mList);
|
||||
});
|
||||
|
||||
// Effect params
|
||||
auto effectParamsT = lua.new_usertype<ESM::IndexedENAMstruct>("ESM3_EffectParams");
|
||||
auto effectParamsT = state.new_usertype<ESM::IndexedENAMstruct>("ESM3_EffectParams");
|
||||
effectParamsT[sol::meta_function::to_string] = [magicEffectStore](const ESM::IndexedENAMstruct& params) {
|
||||
const ESM::MagicEffect* const rec = magicEffectStore->find(params.mData.mEffectID);
|
||||
return "ESM3_EffectParams[" + ESM::MagicEffect::indexToGmstString(rec->mIndex) + "]";
|
||||
|
@ -376,7 +377,7 @@ namespace MWLua
|
|||
= sol::readonly_property([](const ESM::IndexedENAMstruct& params) -> int { return params.mIndex; });
|
||||
|
||||
// MagicEffect record
|
||||
auto magicEffectT = lua.new_usertype<ESM::MagicEffect>("ESM3_MagicEffect");
|
||||
auto magicEffectT = state.new_usertype<ESM::MagicEffect>("ESM3_MagicEffect");
|
||||
|
||||
magicEffectT[sol::meta_function::to_string] = [](const ESM::MagicEffect& rec) {
|
||||
return "ESM3_MagicEffect[" + ESM::MagicEffect::indexToGmstString(rec.mIndex) + "]";
|
||||
|
@ -444,78 +445,78 @@ namespace MWLua
|
|||
// magicEffectT["projectileSpeed"]
|
||||
// = sol::readonly_property([](const ESM::MagicEffect& rec) -> float { return rec.mData.mSpeed; });
|
||||
|
||||
auto activeSpellEffectT = lua.new_usertype<ESM::ActiveEffect>("ActiveSpellEffect");
|
||||
activeSpellEffectT[sol::meta_function::to_string] = [](const ESM::ActiveEffect& effect) {
|
||||
return "ActiveSpellEffect[" + ESM::MagicEffect::indexToGmstString(effect.mEffectId) + "]";
|
||||
auto activeSpellEffectT = state.new_usertype<ESM::ActiveEffect>("ActiveSpellEffect");
|
||||
activeSpellEffectT[sol::meta_function::to_string] = [](const ESM::ActiveEffect& self) {
|
||||
return "ActiveSpellEffect[" + ESM::MagicEffect::indexToGmstString(self.mEffectId) + "]";
|
||||
};
|
||||
activeSpellEffectT["id"] = sol::readonly_property([](const ESM::ActiveEffect& effect) -> std::string {
|
||||
auto name = ESM::MagicEffect::indexToName(effect.mEffectId);
|
||||
activeSpellEffectT["id"] = sol::readonly_property([](const ESM::ActiveEffect& self) -> std::string {
|
||||
auto name = ESM::MagicEffect::indexToName(self.mEffectId);
|
||||
return Misc::StringUtils::lowerCase(name);
|
||||
});
|
||||
activeSpellEffectT["index"]
|
||||
= sol::readonly_property([](const ESM::ActiveEffect& effect) -> int { return effect.mEffectIndex; });
|
||||
activeSpellEffectT["name"] = sol::readonly_property([](const ESM::ActiveEffect& effect) -> std::string {
|
||||
return MWMechanics::EffectKey(effect.mEffectId, effect.getSkillOrAttribute()).toString();
|
||||
= sol::readonly_property([](const ESM::ActiveEffect& self) -> int { return self.mEffectIndex; });
|
||||
activeSpellEffectT["name"] = sol::readonly_property([](const ESM::ActiveEffect& self) -> std::string {
|
||||
return MWMechanics::EffectKey(self.mEffectId, self.getSkillOrAttribute()).toString();
|
||||
});
|
||||
activeSpellEffectT["affectedSkill"]
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& effect) -> sol::optional<std::string> {
|
||||
auto* rec = magicEffectStore->find(effect.mEffectId);
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& self) -> sol::optional<std::string> {
|
||||
auto* rec = magicEffectStore->find(self.mEffectId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
||||
return effect.getSkillOrAttribute().serializeText();
|
||||
return self.getSkillOrAttribute().serializeText();
|
||||
else
|
||||
return sol::nullopt;
|
||||
});
|
||||
activeSpellEffectT["affectedAttribute"]
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& effect) -> sol::optional<std::string> {
|
||||
auto* rec = magicEffectStore->find(effect.mEffectId);
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& self) -> sol::optional<std::string> {
|
||||
auto* rec = magicEffectStore->find(self.mEffectId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
return effect.getSkillOrAttribute().serializeText();
|
||||
return self.getSkillOrAttribute().serializeText();
|
||||
else
|
||||
return sol::nullopt;
|
||||
});
|
||||
activeSpellEffectT["magnitudeThisFrame"]
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& effect) -> sol::optional<float> {
|
||||
auto* rec = magicEffectStore->find(effect.mEffectId);
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& self) -> sol::optional<float> {
|
||||
auto* rec = magicEffectStore->find(self.mEffectId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::Flags::NoMagnitude)
|
||||
return sol::nullopt;
|
||||
return effect.mMagnitude;
|
||||
return self.mMagnitude;
|
||||
});
|
||||
activeSpellEffectT["minMagnitude"]
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& effect) -> sol::optional<float> {
|
||||
auto* rec = magicEffectStore->find(effect.mEffectId);
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& self) -> sol::optional<float> {
|
||||
auto* rec = magicEffectStore->find(self.mEffectId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::Flags::NoMagnitude)
|
||||
return sol::nullopt;
|
||||
return effect.mMinMagnitude;
|
||||
return self.mMinMagnitude;
|
||||
});
|
||||
activeSpellEffectT["maxMagnitude"]
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& effect) -> sol::optional<float> {
|
||||
auto* rec = magicEffectStore->find(effect.mEffectId);
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& self) -> sol::optional<float> {
|
||||
auto* rec = magicEffectStore->find(self.mEffectId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::Flags::NoMagnitude)
|
||||
return sol::nullopt;
|
||||
return effect.mMaxMagnitude;
|
||||
return self.mMaxMagnitude;
|
||||
});
|
||||
activeSpellEffectT["durationLeft"]
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& effect) -> sol::optional<float> {
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& self) -> sol::optional<float> {
|
||||
// Permanent/constant effects, abilities, etc. will have a negative duration
|
||||
if (effect.mDuration < 0)
|
||||
if (self.mDuration < 0)
|
||||
return sol::nullopt;
|
||||
auto* rec = magicEffectStore->find(effect.mEffectId);
|
||||
auto* rec = magicEffectStore->find(self.mEffectId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::Flags::NoDuration)
|
||||
return sol::nullopt;
|
||||
return effect.mTimeLeft;
|
||||
return self.mTimeLeft;
|
||||
});
|
||||
activeSpellEffectT["duration"]
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& effect) -> sol::optional<float> {
|
||||
= sol::readonly_property([magicEffectStore](const ESM::ActiveEffect& self) -> sol::optional<float> {
|
||||
// Permanent/constant effects, abilities, etc. will have a negative duration
|
||||
if (effect.mDuration < 0)
|
||||
if (self.mDuration < 0)
|
||||
return sol::nullopt;
|
||||
auto* rec = magicEffectStore->find(effect.mEffectId);
|
||||
auto* rec = magicEffectStore->find(self.mEffectId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::Flags::NoDuration)
|
||||
return sol::nullopt;
|
||||
return effect.mDuration;
|
||||
return self.mDuration;
|
||||
});
|
||||
|
||||
auto activeSpellT = lua.new_usertype<ActiveSpell>("ActiveSpellParams");
|
||||
auto activeSpellT = state.new_usertype<ActiveSpell>("ActiveSpellParams");
|
||||
activeSpellT[sol::meta_function::to_string] = [](const ActiveSpell& activeSpell) {
|
||||
return "ActiveSpellParams[" + activeSpell.mParams.getSourceSpellId().serializeText() + "]";
|
||||
};
|
||||
|
@ -525,7 +526,7 @@ namespace MWLua
|
|||
return activeSpell.mParams.getSourceSpellId().serializeText();
|
||||
});
|
||||
activeSpellT["item"]
|
||||
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::object {
|
||||
= sol::readonly_property([lua = state.lua_state()](const ActiveSpell& activeSpell) -> sol::object {
|
||||
auto item = activeSpell.mParams.getItem();
|
||||
if (!item.isSet())
|
||||
return sol::nil;
|
||||
|
@ -538,7 +539,7 @@ namespace MWLua
|
|||
return sol::make_object(lua, LObject(itemPtr));
|
||||
});
|
||||
activeSpellT["caster"]
|
||||
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::object {
|
||||
= sol::readonly_property([lua = state.lua_state()](const ActiveSpell& activeSpell) -> sol::object {
|
||||
auto caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(
|
||||
activeSpell.mParams.getCasterActorId());
|
||||
if (caster.isEmpty())
|
||||
|
@ -552,14 +553,14 @@ namespace MWLua
|
|||
}
|
||||
});
|
||||
activeSpellT["effects"]
|
||||
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::table {
|
||||
= sol::readonly_property([lua = state.lua_state()](const ActiveSpell& activeSpell) -> sol::table {
|
||||
sol::table res(lua, sol::create);
|
||||
size_t tableIndex = 0;
|
||||
for (const ESM::ActiveEffect& effect : activeSpell.mParams.getEffects())
|
||||
for (const ESM::ActiveEffect& e : activeSpell.mParams.getEffects())
|
||||
{
|
||||
if (!(effect.mFlags & ESM::ActiveEffect::Flag_Applied))
|
||||
if (!(e.mFlags & ESM::ActiveEffect::Flag_Applied))
|
||||
continue;
|
||||
res[++tableIndex] = effect; // ESM::ActiveEffect (effect params)
|
||||
res[++tableIndex] = e; // ESM::ActiveEffect (effect params)
|
||||
}
|
||||
return res;
|
||||
});
|
||||
|
@ -579,39 +580,39 @@ namespace MWLua
|
|||
return activeSpell.mParams.getActiveSpellId().serializeText();
|
||||
});
|
||||
|
||||
auto activeEffectT = lua.new_usertype<ActiveEffect>("ActiveEffect");
|
||||
auto activeEffectT = state.new_usertype<ActiveEffect>("ActiveEffect");
|
||||
|
||||
activeEffectT[sol::meta_function::to_string] = [](const ActiveEffect& effect) {
|
||||
return "ActiveEffect[" + ESM::MagicEffect::indexToGmstString(effect.key.mId) + "]";
|
||||
activeEffectT[sol::meta_function::to_string] = [](const ActiveEffect& self) {
|
||||
return "ActiveEffect[" + ESM::MagicEffect::indexToGmstString(self.key.mId) + "]";
|
||||
};
|
||||
activeEffectT["id"] = sol::readonly_property([](const ActiveEffect& effect) -> std::string {
|
||||
auto name = ESM::MagicEffect::indexToName(effect.key.mId);
|
||||
activeEffectT["id"] = sol::readonly_property([](const ActiveEffect& self) -> std::string {
|
||||
auto name = ESM::MagicEffect::indexToName(self.key.mId);
|
||||
return Misc::StringUtils::lowerCase(name);
|
||||
});
|
||||
activeEffectT["name"]
|
||||
= sol::readonly_property([](const ActiveEffect& effect) -> std::string { return effect.key.toString(); });
|
||||
= sol::readonly_property([](const ActiveEffect& self) -> std::string { return self.key.toString(); });
|
||||
|
||||
activeEffectT["affectedSkill"]
|
||||
= sol::readonly_property([magicEffectStore](const ActiveEffect& effect) -> sol::optional<std::string> {
|
||||
auto* rec = magicEffectStore->find(effect.key.mId);
|
||||
= sol::readonly_property([magicEffectStore](const ActiveEffect& self) -> sol::optional<std::string> {
|
||||
auto* rec = magicEffectStore->find(self.key.mId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
||||
return effect.key.mArg.serializeText();
|
||||
return self.key.mArg.serializeText();
|
||||
return sol::nullopt;
|
||||
});
|
||||
activeEffectT["affectedAttribute"]
|
||||
= sol::readonly_property([magicEffectStore](const ActiveEffect& effect) -> sol::optional<std::string> {
|
||||
auto* rec = magicEffectStore->find(effect.key.mId);
|
||||
= sol::readonly_property([magicEffectStore](const ActiveEffect& self) -> sol::optional<std::string> {
|
||||
auto* rec = magicEffectStore->find(self.key.mId);
|
||||
if (rec->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
return effect.key.mArg.serializeText();
|
||||
return self.key.mArg.serializeText();
|
||||
return sol::nullopt;
|
||||
});
|
||||
|
||||
activeEffectT["magnitude"]
|
||||
= sol::readonly_property([](const ActiveEffect& effect) { return effect.param.getMagnitude(); });
|
||||
= sol::readonly_property([](const ActiveEffect& self) { return self.param.getMagnitude(); });
|
||||
activeEffectT["magnitudeBase"]
|
||||
= sol::readonly_property([](const ActiveEffect& effect) { return effect.param.getBase(); });
|
||||
= sol::readonly_property([](const ActiveEffect& self) { return self.param.getBase(); });
|
||||
activeEffectT["magnitudeModifier"]
|
||||
= sol::readonly_property([](const ActiveEffect& effect) { return effect.param.getModifier(); });
|
||||
= sol::readonly_property([](const ActiveEffect& self) { return self.param.getModifier(); });
|
||||
|
||||
return LuaUtil::makeReadOnly(magicApi);
|
||||
}
|
||||
|
@ -633,10 +634,10 @@ namespace MWLua
|
|||
|
||||
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
|
||||
|
||||
auto getEffectsFromIndexes = [&](const ESM::EffectList& effects) {
|
||||
auto getEffectsFromIndexes = [&](const ESM::EffectList& effectList) {
|
||||
std::vector<ESM::IndexedENAMstruct> enams;
|
||||
for (auto index : effectIndexes)
|
||||
enams.push_back(effects.mList.at(index));
|
||||
enams.push_back(effectList.mList.at(index));
|
||||
return enams;
|
||||
};
|
||||
|
||||
|
@ -690,24 +691,24 @@ namespace MWLua
|
|||
|
||||
void addActorMagicBindings(sol::table& actor, const Context& context)
|
||||
{
|
||||
auto lua = context.sol();
|
||||
sol::state_view state = context.sol();
|
||||
const MWWorld::Store<ESM::Spell>* spellStore
|
||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>();
|
||||
|
||||
// types.Actor.spells(o)
|
||||
actor["spells"] = [](const sol::object& actor) { return ActorSpells{ actor }; };
|
||||
auto spellsT = lua.new_usertype<ActorSpells>("ActorSpells");
|
||||
actor["spells"] = [](const sol::object& object) { return ActorSpells{ object }; };
|
||||
auto spellsT = state.new_usertype<ActorSpells>("ActorSpells");
|
||||
spellsT[sol::meta_function::to_string]
|
||||
= [](const ActorSpells& spells) { return "ActorSpells[" + spells.mActor.object().toString() + "]"; };
|
||||
|
||||
actor["activeSpells"] = [](const sol::object& actor) { return ActorActiveSpells{ actor }; };
|
||||
auto activeSpellsT = lua.new_usertype<ActorActiveSpells>("ActorActiveSpells");
|
||||
actor["activeSpells"] = [](const sol::object& object) { return ActorActiveSpells{ object }; };
|
||||
auto activeSpellsT = state.new_usertype<ActorActiveSpells>("ActorActiveSpells");
|
||||
activeSpellsT[sol::meta_function::to_string] = [](const ActorActiveSpells& spells) {
|
||||
return "ActorActiveSpells[" + spells.mActor.object().toString() + "]";
|
||||
};
|
||||
|
||||
actor["activeEffects"] = [](const sol::object& actor) { return ActorActiveEffects{ actor }; };
|
||||
auto activeEffectsT = lua.new_usertype<ActorActiveEffects>("ActorActiveEffects");
|
||||
actor["activeEffects"] = [](const sol::object& object) { return ActorActiveEffects{ object }; };
|
||||
auto activeEffectsT = state.new_usertype<ActorActiveEffects>("ActorActiveEffects");
|
||||
activeEffectsT[sol::meta_function::to_string] = [](const ActorActiveEffects& effects) {
|
||||
return "ActorActiveEffects[" + effects.mActor.object().toString() + "]";
|
||||
};
|
||||
|
@ -741,15 +742,15 @@ namespace MWLua
|
|||
throw std::runtime_error("Ability or disease can not be casted: " + spellId.toDebugString());
|
||||
}
|
||||
context.mLuaManager->addAction([obj = Object(ptr), spellId]() {
|
||||
const MWWorld::Ptr& ptr = obj.ptr();
|
||||
auto& stats = ptr.getClass().getCreatureStats(ptr);
|
||||
const MWWorld::Ptr& objPtr = obj.ptr();
|
||||
auto& stats = objPtr.getClass().getCreatureStats(objPtr);
|
||||
|
||||
// We need to deselect any enchant items before we can select a spell otherwise the item will be
|
||||
// reselected
|
||||
const auto resetEnchantItem = [&]() {
|
||||
if (ptr.getClass().hasInventoryStore(ptr))
|
||||
if (objPtr.getClass().hasInventoryStore(objPtr))
|
||||
{
|
||||
MWWorld::InventoryStore& inventory = ptr.getClass().getInventoryStore(ptr);
|
||||
MWWorld::InventoryStore& inventory = objPtr.getClass().getInventoryStore(objPtr);
|
||||
inventory.setSelectedEnchantItem(inventory.end());
|
||||
}
|
||||
};
|
||||
|
@ -757,7 +758,7 @@ namespace MWLua
|
|||
if (spellId.empty())
|
||||
{
|
||||
resetEnchantItem();
|
||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
if (objPtr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
||||
else
|
||||
stats.getSpells().setSelectedSpell(ESM::RefId());
|
||||
|
@ -767,9 +768,9 @@ namespace MWLua
|
|||
throw std::runtime_error("Actor doesn't know spell " + spellId.toDebugString());
|
||||
|
||||
resetEnchantItem();
|
||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
if (objPtr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
{
|
||||
int chance = MWMechanics::getSpellSuccessChance(spellId, ptr);
|
||||
int chance = MWMechanics::getSpellSuccessChance(spellId, objPtr);
|
||||
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, chance);
|
||||
}
|
||||
else
|
||||
|
@ -821,10 +822,10 @@ namespace MWLua
|
|||
});
|
||||
|
||||
// pairs(types.Actor.spells(o))
|
||||
spellsT[sol::meta_function::pairs] = lua["ipairsForArray"].template get<sol::function>();
|
||||
spellsT[sol::meta_function::pairs] = state["ipairsForArray"].template get<sol::function>();
|
||||
|
||||
// ipairs(types.Actor.spells(o))
|
||||
spellsT[sol::meta_function::ipairs] = lua["ipairsForArray"].template get<sol::function>();
|
||||
spellsT[sol::meta_function::ipairs] = state["ipairsForArray"].template get<sol::function>();
|
||||
|
||||
// types.Actor.spells(o):add(id)
|
||||
spellsT["add"] = [context](const ActorSpells& spells, const sol::object& spellOrId) {
|
||||
|
|
|
@ -81,16 +81,16 @@ namespace MWLua
|
|||
manager->saveGame(description, slot);
|
||||
};
|
||||
|
||||
auto getSaves = [](sol::state_view lua, const MWState::Character& character) {
|
||||
sol::table saves(lua, sol::create);
|
||||
auto getSaves = [](sol::state_view currentState, const MWState::Character& character) {
|
||||
sol::table saves(currentState, sol::create);
|
||||
for (const MWState::Slot& slot : character)
|
||||
{
|
||||
sol::table slotInfo(lua, sol::create);
|
||||
sol::table slotInfo(currentState, sol::create);
|
||||
slotInfo["description"] = slot.mProfile.mDescription;
|
||||
slotInfo["playerName"] = slot.mProfile.mPlayerName;
|
||||
slotInfo["playerLevel"] = slot.mProfile.mPlayerLevel;
|
||||
slotInfo["timePlayed"] = slot.mProfile.mTimePlayed;
|
||||
sol::table contentFiles(lua, sol::create);
|
||||
sol::table contentFiles(currentState, sol::create);
|
||||
for (size_t i = 0; i < slot.mProfile.mContentFiles.size(); ++i)
|
||||
contentFiles[LuaUtil::toLuaIndex(i)] = Misc::StringUtils::lowerCase(slot.mProfile.mContentFiles[i]);
|
||||
|
||||
|
@ -106,18 +106,18 @@ namespace MWLua
|
|||
return saves;
|
||||
};
|
||||
|
||||
api["getSaves"] = [getSaves](sol::this_state lua, std::string_view dir) -> sol::table {
|
||||
api["getSaves"] = [getSaves](sol::this_state thisState, std::string_view dir) -> sol::table {
|
||||
const MWState::Character* character = findCharacter(dir);
|
||||
if (!character)
|
||||
throw std::runtime_error("Saves not found: " + std::string(dir));
|
||||
return getSaves(lua, *character);
|
||||
return getSaves(thisState, *character);
|
||||
};
|
||||
|
||||
api["getAllSaves"] = [getSaves](sol::this_state lua) -> sol::table {
|
||||
sol::table saves(lua, sol::create);
|
||||
api["getAllSaves"] = [getSaves](sol::this_state thisState) -> sol::table {
|
||||
sol::table saves(thisState, sol::create);
|
||||
MWBase::StateManager* manager = MWBase::Environment::get().getStateManager();
|
||||
for (auto it = manager->characterBegin(); it != manager->characterEnd(); ++it)
|
||||
saves[it->getPath().filename().string()] = getSaves(lua, *it);
|
||||
saves[it->getPath().filename().string()] = getSaves(thisState, *it);
|
||||
return saves;
|
||||
};
|
||||
|
||||
|
|
|
@ -445,16 +445,16 @@ namespace MWLua
|
|||
if (!ptr.getContainerStore() && currentCount > countToRemove)
|
||||
return std::nullopt;
|
||||
// Delayed action to trigger side effects
|
||||
return [signedCountToRemove](MWWorld::Ptr ptr) {
|
||||
return [signedCountToRemove](MWWorld::Ptr p) {
|
||||
// Restore the original count
|
||||
ptr.getCellRef().setCount(ptr.getCellRef().getCount(false) + signedCountToRemove);
|
||||
p.getCellRef().setCount(p.getCellRef().getCount(false) + signedCountToRemove);
|
||||
// And now remove properly
|
||||
if (ptr.getContainerStore())
|
||||
ptr.getContainerStore()->remove(ptr, std::abs(signedCountToRemove), false);
|
||||
if (p.getContainerStore())
|
||||
p.getContainerStore()->remove(p, std::abs(signedCountToRemove), false);
|
||||
else
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->disable(ptr);
|
||||
MWBase::Environment::get().getWorld()->deleteObject(ptr);
|
||||
MWBase::Environment::get().getWorld()->disable(p);
|
||||
MWBase::Environment::get().getWorld()->deleteObject(p);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -110,67 +110,69 @@ namespace MWLua
|
|||
sol::state_view lua = context.sol();
|
||||
sol::table api(lua, sol::create);
|
||||
|
||||
sol::usertype<Shader> shader = lua.new_usertype<Shader>("Shader");
|
||||
shader[sol::meta_function::to_string] = [](const Shader& shader) { return shader.toString(); };
|
||||
{
|
||||
sol::usertype<Shader> shader = lua.new_usertype<Shader>("Shader");
|
||||
shader[sol::meta_function::to_string] = [](const Shader& self) { return self.toString(); };
|
||||
|
||||
shader["enable"] = [context](Shader& shader, sol::optional<int> optPos) {
|
||||
std::optional<int> pos = std::nullopt;
|
||||
if (optPos)
|
||||
pos = optPos.value();
|
||||
shader["enable"] = [context](Shader& self, sol::optional<int> optPos) {
|
||||
std::optional<int> pos = std::nullopt;
|
||||
if (optPos)
|
||||
pos = optPos.value();
|
||||
|
||||
if (shader.mShader && shader.mShader->isValid())
|
||||
shader.mQueuedAction = Shader::Action_Enable;
|
||||
if (self.mShader && self.mShader->isValid())
|
||||
self.mQueuedAction = Shader::Action_Enable;
|
||||
|
||||
context.mLuaManager->addAction([=, &shader] {
|
||||
shader.mQueuedAction = Shader::Action_None;
|
||||
context.mLuaManager->addAction([=, &self] {
|
||||
self.mQueuedAction = Shader::Action_None;
|
||||
|
||||
if (MWBase::Environment::get().getWorld()->getPostProcessor()->enableTechnique(shader.mShader, pos)
|
||||
== MWRender::PostProcessor::Status_Error)
|
||||
throw std::runtime_error("Failed enabling shader '" + shader.mShader->getName() + "'");
|
||||
});
|
||||
};
|
||||
if (MWBase::Environment::get().getWorld()->getPostProcessor()->enableTechnique(self.mShader, pos)
|
||||
== MWRender::PostProcessor::Status_Error)
|
||||
throw std::runtime_error("Failed enabling shader '" + self.mShader->getName() + "'");
|
||||
});
|
||||
};
|
||||
|
||||
shader["disable"] = [context](Shader& shader) {
|
||||
shader.mQueuedAction = Shader::Action_Disable;
|
||||
shader["disable"] = [context](Shader& self) {
|
||||
self.mQueuedAction = Shader::Action_Disable;
|
||||
|
||||
context.mLuaManager->addAction([&] {
|
||||
shader.mQueuedAction = Shader::Action_None;
|
||||
context.mLuaManager->addAction([&] {
|
||||
self.mQueuedAction = Shader::Action_None;
|
||||
|
||||
if (MWBase::Environment::get().getWorld()->getPostProcessor()->disableTechnique(shader.mShader)
|
||||
== MWRender::PostProcessor::Status_Error)
|
||||
throw std::runtime_error("Failed disabling shader '" + shader.mShader->getName() + "'");
|
||||
});
|
||||
};
|
||||
if (MWBase::Environment::get().getWorld()->getPostProcessor()->disableTechnique(self.mShader)
|
||||
== MWRender::PostProcessor::Status_Error)
|
||||
throw std::runtime_error("Failed disabling shader '" + self.mShader->getName() + "'");
|
||||
});
|
||||
};
|
||||
|
||||
shader["isEnabled"] = [](const Shader& shader) {
|
||||
if (shader.mQueuedAction == Shader::Action_Enable)
|
||||
return true;
|
||||
else if (shader.mQueuedAction == Shader::Action_Disable)
|
||||
return false;
|
||||
return MWBase::Environment::get().getWorld()->getPostProcessor()->isTechniqueEnabled(shader.mShader);
|
||||
};
|
||||
shader["isEnabled"] = [](const Shader& self) {
|
||||
if (self.mQueuedAction == Shader::Action_Enable)
|
||||
return true;
|
||||
else if (self.mQueuedAction == Shader::Action_Disable)
|
||||
return false;
|
||||
return MWBase::Environment::get().getWorld()->getPostProcessor()->isTechniqueEnabled(self.mShader);
|
||||
};
|
||||
|
||||
shader["name"] = sol::readonly_property(
|
||||
[](const Shader& shader) { return getLocalizedMyGUIString(shader.mShader->getName()); });
|
||||
shader["author"] = sol::readonly_property(
|
||||
[](const Shader& shader) { return getLocalizedMyGUIString(shader.mShader->getAuthor()); });
|
||||
shader["description"] = sol::readonly_property(
|
||||
[](const Shader& shader) { return getLocalizedMyGUIString(shader.mShader->getDescription()); });
|
||||
shader["version"] = sol::readonly_property(
|
||||
[](const Shader& shader) { return getLocalizedMyGUIString(shader.mShader->getVersion()); });
|
||||
shader["name"] = sol::readonly_property(
|
||||
[](const Shader& self) { return getLocalizedMyGUIString(self.mShader->getName()); });
|
||||
shader["author"] = sol::readonly_property(
|
||||
[](const Shader& self) { return getLocalizedMyGUIString(self.mShader->getAuthor()); });
|
||||
shader["description"] = sol::readonly_property(
|
||||
[](const Shader& self) { return getLocalizedMyGUIString(self.mShader->getDescription()); });
|
||||
shader["version"] = sol::readonly_property(
|
||||
[](const Shader& self) { return getLocalizedMyGUIString(self.mShader->getVersion()); });
|
||||
|
||||
shader["setBool"] = getSetter<bool>(context);
|
||||
shader["setFloat"] = getSetter<float>(context);
|
||||
shader["setInt"] = getSetter<int>(context);
|
||||
shader["setVector2"] = getSetter<osg::Vec2f>(context);
|
||||
shader["setVector3"] = getSetter<osg::Vec3f>(context);
|
||||
shader["setVector4"] = getSetter<osg::Vec4f>(context);
|
||||
shader["setBool"] = getSetter<bool>(context);
|
||||
shader["setFloat"] = getSetter<float>(context);
|
||||
shader["setInt"] = getSetter<int>(context);
|
||||
shader["setVector2"] = getSetter<osg::Vec2f>(context);
|
||||
shader["setVector3"] = getSetter<osg::Vec3f>(context);
|
||||
shader["setVector4"] = getSetter<osg::Vec4f>(context);
|
||||
|
||||
shader["setFloatArray"] = getArraySetter<float>(context);
|
||||
shader["setIntArray"] = getArraySetter<int>(context);
|
||||
shader["setVector2Array"] = getArraySetter<osg::Vec2f>(context);
|
||||
shader["setVector3Array"] = getArraySetter<osg::Vec3f>(context);
|
||||
shader["setVector4Array"] = getArraySetter<osg::Vec4f>(context);
|
||||
shader["setFloatArray"] = getArraySetter<float>(context);
|
||||
shader["setIntArray"] = getArraySetter<int>(context);
|
||||
shader["setVector2Array"] = getArraySetter<osg::Vec2f>(context);
|
||||
shader["setVector3Array"] = getArraySetter<osg::Vec3f>(context);
|
||||
shader["setVector4Array"] = getArraySetter<osg::Vec4f>(context);
|
||||
}
|
||||
|
||||
api["load"] = [](const std::string& name) {
|
||||
Shader shader{ MWBase::Environment::get().getWorld()->getPostProcessor()->loadTechnique(name, false) };
|
||||
|
|
|
@ -47,18 +47,18 @@ namespace MWLua
|
|||
using StoreT = MWWorld::Store<T>;
|
||||
sol::state_view lua = context.sol();
|
||||
sol::usertype<StoreT> storeT = lua.new_usertype<StoreT>(recordName + "WorldStore");
|
||||
storeT[sol::meta_function::to_string] = [recordName](const StoreT& store) {
|
||||
return "{" + std::to_string(store.getSize()) + " " + recordName + " records}";
|
||||
storeT[sol::meta_function::to_string] = [recordName](const StoreT& self) {
|
||||
return "{" + std::to_string(self.getSize()) + " " + recordName + " records}";
|
||||
};
|
||||
storeT[sol::meta_function::length] = [](const StoreT& store) { return store.getSize(); };
|
||||
storeT[sol::meta_function::length] = [](const StoreT& self) { return self.getSize(); };
|
||||
storeT[sol::meta_function::index] = sol::overload(
|
||||
[](const StoreT& store, size_t index) -> const T* {
|
||||
if (index == 0 || index > store.getSize())
|
||||
[](const StoreT& self, size_t index) -> const T* {
|
||||
if (index == 0 || index > self.getSize())
|
||||
return nullptr;
|
||||
return store.at(LuaUtil::fromLuaIndex(index));
|
||||
return self.at(LuaUtil::fromLuaIndex(index));
|
||||
},
|
||||
[](const StoreT& store, std::string_view id) -> const T* {
|
||||
return store.search(ESM::RefId::deserializeText(id));
|
||||
[](const StoreT& self, std::string_view id) -> const T* {
|
||||
return self.search(ESM::RefId::deserializeText(id));
|
||||
});
|
||||
storeT[sol::meta_function::ipairs] = lua["ipairsForArray"].template get<sol::function>();
|
||||
storeT[sol::meta_function::pairs] = lua["ipairsForArray"].template get<sol::function>();
|
||||
|
@ -67,4 +67,5 @@ namespace MWLua
|
|||
table["records"] = &store;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MWLUA_RECORDSTORE_H
|
||||
|
|
|
@ -107,8 +107,7 @@ namespace MWLua
|
|||
|
||||
sol::object get(const Context& context, ESM::StringRefId attributeId) const
|
||||
{
|
||||
const auto& ptr = mObject.ptr();
|
||||
if (!ptr.getClass().isNpc())
|
||||
if (!mObject.ptr().getClass().isNpc())
|
||||
return sol::nil;
|
||||
|
||||
return getValue(context, mObject, &setNpcValue, attributeId, "skillIncreasesForAttribute",
|
||||
|
@ -142,8 +141,7 @@ namespace MWLua
|
|||
|
||||
sol::object get(const Context& context, int specialization) const
|
||||
{
|
||||
const auto& ptr = mObject.ptr();
|
||||
if (!ptr.getClass().isNpc())
|
||||
if (!mObject.ptr().getClass().isNpc())
|
||||
return sol::nil;
|
||||
|
||||
return getValue(context, mObject, &setNpcValue, specialization, "skillIncreasesForSpecialization",
|
||||
|
@ -192,8 +190,7 @@ namespace MWLua
|
|||
|
||||
sol::object getProgress(const Context& context) const
|
||||
{
|
||||
const auto& ptr = mObject.ptr();
|
||||
if (!ptr.getClass().isNpc())
|
||||
if (!mObject.ptr().getClass().isNpc())
|
||||
return sol::nil;
|
||||
|
||||
return getValue(context, mObject, &setNpcValue, std::monostate{}, "progress",
|
||||
|
|
|
@ -248,7 +248,7 @@ namespace MWLua
|
|||
stats.setDrawState(newDrawState);
|
||||
};
|
||||
|
||||
actor["getSelectedEnchantedItem"] = [](sol::this_state lua, const Object& o) -> sol::object {
|
||||
actor["getSelectedEnchantedItem"] = [](sol::this_state thisState, const Object& o) -> sol::object {
|
||||
const MWWorld::Ptr& ptr = o.ptr();
|
||||
if (!ptr.getClass().hasInventoryStore(ptr))
|
||||
return sol::nil;
|
||||
|
@ -258,9 +258,9 @@ namespace MWLua
|
|||
return sol::nil;
|
||||
MWBase::Environment::get().getWorldModel()->registerPtr(*it);
|
||||
if (dynamic_cast<const GObject*>(&o))
|
||||
return sol::make_object(lua, GObject(*it));
|
||||
return sol::make_object(thisState, GObject(*it));
|
||||
else
|
||||
return sol::make_object(lua, LObject(*it));
|
||||
return sol::make_object(thisState, LObject(*it));
|
||||
};
|
||||
actor["setSelectedEnchantedItem"] = [context](const SelfObject& obj, const sol::object& item) {
|
||||
const MWWorld::Ptr& ptr = obj.ptr();
|
||||
|
@ -310,9 +310,9 @@ namespace MWLua
|
|||
|
||||
actor["inventory"] = sol::overload([](const LObject& o) { return Inventory<LObject>{ o }; },
|
||||
[](const GObject& o) { return Inventory<GObject>{ o }; });
|
||||
auto getAllEquipment = [](sol::this_state lua, const Object& o) {
|
||||
auto getAllEquipment = [](sol::this_state thisState, const Object& o) {
|
||||
const MWWorld::Ptr& ptr = o.ptr();
|
||||
sol::table equipment(lua, sol::create);
|
||||
sol::table equipment(thisState, sol::create);
|
||||
if (!ptr.getClass().hasInventoryStore(ptr))
|
||||
return equipment;
|
||||
|
||||
|
@ -324,13 +324,13 @@ namespace MWLua
|
|||
continue;
|
||||
MWBase::Environment::get().getWorldModel()->registerPtr(*it);
|
||||
if (dynamic_cast<const GObject*>(&o))
|
||||
equipment[slot] = sol::make_object(lua, GObject(*it));
|
||||
equipment[slot] = sol::make_object(thisState, GObject(*it));
|
||||
else
|
||||
equipment[slot] = sol::make_object(lua, LObject(*it));
|
||||
equipment[slot] = sol::make_object(thisState, LObject(*it));
|
||||
}
|
||||
return equipment;
|
||||
};
|
||||
auto getEquipmentFromSlot = [](sol::this_state lua, const Object& o, int slot) -> sol::object {
|
||||
auto getEquipmentFromSlot = [](sol::this_state thisState, const Object& o, int slot) -> sol::object {
|
||||
const MWWorld::Ptr& ptr = o.ptr();
|
||||
if (!ptr.getClass().hasInventoryStore(ptr))
|
||||
return sol::nil;
|
||||
|
@ -340,9 +340,9 @@ namespace MWLua
|
|||
return sol::nil;
|
||||
MWBase::Environment::get().getWorldModel()->registerPtr(*it);
|
||||
if (dynamic_cast<const GObject*>(&o))
|
||||
return sol::make_object(lua, GObject(*it));
|
||||
return sol::make_object(thisState, GObject(*it));
|
||||
else
|
||||
return sol::make_object(lua, LObject(*it));
|
||||
return sol::make_object(thisState, LObject(*it));
|
||||
};
|
||||
actor["getEquipment"] = sol::overload(getAllEquipment, getEquipmentFromSlot);
|
||||
actor["equipment"] = actor["getEquipment"]; // for compatibility; should be removed later
|
||||
|
@ -373,10 +373,10 @@ namespace MWLua
|
|||
context.mLuaManager->addAction(
|
||||
[obj = Object(ptr), eqp = std::move(eqp)] { setEquipment(obj.ptr(), eqp); }, "SetEquipmentAction");
|
||||
};
|
||||
actor["getPathfindingAgentBounds"] = [](sol::this_state lua, const LObject& o) {
|
||||
actor["getPathfindingAgentBounds"] = [](sol::this_state thisState, const LObject& o) {
|
||||
const DetourNavigator::AgentBounds agentBounds
|
||||
= MWBase::Environment::get().getWorld()->getPathfindingAgentBounds(o.ptr());
|
||||
sol::table result(lua, sol::create);
|
||||
sol::table result(thisState, sol::create);
|
||||
result["shapeType"] = agentBounds.mShapeType;
|
||||
result["halfExtents"] = agentBounds.mHalfExtents;
|
||||
return result;
|
||||
|
@ -410,13 +410,13 @@ namespace MWLua
|
|||
return target.getClass().getCreatureStats(target).isDeathAnimationFinished();
|
||||
};
|
||||
|
||||
actor["getEncumbrance"] = [](const Object& actor) -> float {
|
||||
const MWWorld::Ptr ptr = actor.ptr();
|
||||
actor["getEncumbrance"] = [](const Object& object) -> float {
|
||||
const MWWorld::Ptr ptr = object.ptr();
|
||||
return ptr.getClass().getEncumbrance(ptr);
|
||||
};
|
||||
|
||||
actor["getCapacity"] = [](const Object& actor) -> float {
|
||||
const MWWorld::Ptr ptr = actor.ptr();
|
||||
actor["getCapacity"] = [](const Object& object) -> float {
|
||||
const MWWorld::Ptr ptr = object.ptr();
|
||||
return ptr.getClass().getCapacity(ptr);
|
||||
};
|
||||
|
||||
|
|
|
@ -120,8 +120,7 @@ namespace MWLua
|
|||
record["enchantCapacity"]
|
||||
= sol::readonly_property([](const ESM::Book& rec) -> float { return rec.mData.mEnchant * 0.1f; });
|
||||
record["skill"] = sol::readonly_property([](const ESM::Book& rec) -> sol::optional<std::string> {
|
||||
ESM::RefId skill = ESM::Skill::indexToRefId(rec.mData.mSkillId);
|
||||
return LuaUtil::serializeRefId(skill);
|
||||
return LuaUtil::serializeRefId(ESM::Skill::indexToRefId(rec.mData.mSkillId));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,20 +51,20 @@ namespace MWLua
|
|||
{ "Closing", MWWorld::DoorState::Closing },
|
||||
}));
|
||||
door["getDoorState"] = [](const Object& o) -> MWWorld::DoorState {
|
||||
const MWWorld::Ptr& door = doorPtr(o);
|
||||
return door.getClass().getDoorState(door);
|
||||
const MWWorld::Ptr& ptr = doorPtr(o);
|
||||
return ptr.getClass().getDoorState(ptr);
|
||||
};
|
||||
door["isOpen"] = [](const Object& o) {
|
||||
const MWWorld::Ptr& door = doorPtr(o);
|
||||
bool doorIsIdle = door.getClass().getDoorState(door) == MWWorld::DoorState::Idle;
|
||||
bool doorIsOpen = door.getRefData().getPosition().rot[2] != door.getCellRef().getPosition().rot[2];
|
||||
const MWWorld::Ptr& ptr = doorPtr(o);
|
||||
bool doorIsIdle = ptr.getClass().getDoorState(ptr) == MWWorld::DoorState::Idle;
|
||||
bool doorIsOpen = ptr.getRefData().getPosition().rot[2] != ptr.getCellRef().getPosition().rot[2];
|
||||
|
||||
return doorIsIdle && doorIsOpen;
|
||||
};
|
||||
door["isClosed"] = [](const Object& o) {
|
||||
const MWWorld::Ptr& door = doorPtr(o);
|
||||
bool doorIsIdle = door.getClass().getDoorState(door) == MWWorld::DoorState::Idle;
|
||||
bool doorIsOpen = door.getRefData().getPosition().rot[2] != door.getCellRef().getPosition().rot[2];
|
||||
const MWWorld::Ptr& ptr = doorPtr(o);
|
||||
bool doorIsIdle = ptr.getClass().getDoorState(ptr) == MWWorld::DoorState::Idle;
|
||||
bool doorIsOpen = ptr.getRefData().getPosition().rot[2] != ptr.getCellRef().getPosition().rot[2];
|
||||
|
||||
return doorIsIdle && !doorIsOpen;
|
||||
};
|
||||
|
@ -74,15 +74,15 @@ namespace MWLua
|
|||
if (!allowChanges)
|
||||
throw std::runtime_error("Can only be used in global scripts or in local scripts on self.");
|
||||
|
||||
const MWWorld::Ptr& door = doorPtr(o);
|
||||
const MWWorld::Ptr& ptr = doorPtr(o);
|
||||
auto world = MWBase::Environment::get().getWorld();
|
||||
|
||||
if (!openState.has_value())
|
||||
world->activateDoor(door);
|
||||
world->activateDoor(ptr);
|
||||
else if (*openState)
|
||||
world->activateDoor(door, MWWorld::DoorState::Opening);
|
||||
world->activateDoor(ptr, MWWorld::DoorState::Opening);
|
||||
else
|
||||
world->activateDoor(door, MWWorld::DoorState::Closing);
|
||||
world->activateDoor(ptr, MWWorld::DoorState::Closing);
|
||||
};
|
||||
door["isTeleport"] = [](const Object& o) { return doorPtr(o).getCellRef().getTeleport(); };
|
||||
door["destPosition"]
|
||||
|
@ -90,15 +90,15 @@ namespace MWLua
|
|||
door["destRotation"] = [](const Object& o) -> LuaUtil::TransformQ {
|
||||
return { Misc::Convert::makeOsgQuat(doorPtr(o).getCellRef().getDoorDest().rot) };
|
||||
};
|
||||
door["destCell"] = [](sol::this_state lua, const Object& o) -> sol::object {
|
||||
door["destCell"] = [](sol::this_state thisState, const Object& o) -> sol::object {
|
||||
const MWWorld::CellRef& cellRef = doorPtr(o).getCellRef();
|
||||
if (!cellRef.getTeleport())
|
||||
return sol::nil;
|
||||
MWWorld::CellStore& cell = MWBase::Environment::get().getWorldModel()->getCell(cellRef.getDestCell());
|
||||
if (dynamic_cast<const GObject*>(&o))
|
||||
return sol::make_object(lua, GCell{ &cell });
|
||||
return sol::make_object(thisState, GCell{ &cell });
|
||||
else
|
||||
return sol::make_object(lua, LCell{ &cell });
|
||||
return sol::make_object(thisState, LCell{ &cell });
|
||||
};
|
||||
|
||||
addRecordFunctionBinding<ESM::Door>(door, context);
|
||||
|
|
|
@ -466,10 +466,10 @@ namespace MWLua
|
|||
ESM::RefId factionId = parseFactionId(faction);
|
||||
return ptr.getClass().getNpcStats(ptr).getExpelled(factionId);
|
||||
};
|
||||
npc["getFactions"] = [](sol::this_state lua, const Object& actor) {
|
||||
npc["getFactions"] = [](sol::this_state thisState, const Object& actor) {
|
||||
const MWWorld::Ptr ptr = actor.ptr();
|
||||
MWMechanics::NpcStats& npcStats = ptr.getClass().getNpcStats(ptr);
|
||||
sol::table res(lua, sol::create);
|
||||
sol::table res(thisState, sol::create);
|
||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
{
|
||||
for (const auto& [factionId, _] : npcStats.getFactionRanks())
|
||||
|
|
|
@ -289,28 +289,28 @@ namespace MWLua
|
|||
sol::state_view lua = context.sol();
|
||||
addJournalEntryBindings(player, lua, journal);
|
||||
|
||||
player["quests"] = [](const Object& player) {
|
||||
verifyPlayer(player);
|
||||
bool allowChanges = dynamic_cast<const GObject*>(&player) != nullptr
|
||||
|| dynamic_cast<const SelfObject*>(&player) != nullptr;
|
||||
player["quests"] = [](const Object& object) {
|
||||
verifyPlayer(object);
|
||||
bool allowChanges = dynamic_cast<const GObject*>(&object) != nullptr
|
||||
|| dynamic_cast<const SelfObject*>(&object) != nullptr;
|
||||
return Quests{ .mMutable = allowChanges };
|
||||
};
|
||||
sol::usertype<Quests> quests = lua.new_usertype<Quests>("Quests");
|
||||
quests[sol::meta_function::to_string] = [](const Quests& quests) { return "Quests"; };
|
||||
quests[sol::meta_function::index] = [](const Quests& quests, std::string_view questId) -> sol::optional<Quest> {
|
||||
quests[sol::meta_function::to_string] = [](const Quests& /*self*/) { return "Quests"; };
|
||||
quests[sol::meta_function::index] = [](const Quests& self, std::string_view questId) -> sol::optional<Quest> {
|
||||
ESM::RefId quest = ESM::RefId::deserializeText(questId);
|
||||
const ESM::Dialogue* dial = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(quest);
|
||||
if (dial == nullptr || dial->mType != ESM::Dialogue::Journal)
|
||||
return sol::nullopt;
|
||||
return Quest{ .mQuestId = quest, .mMutable = quests.mMutable };
|
||||
return Quest{ .mQuestId = quest, .mMutable = self.mMutable };
|
||||
};
|
||||
quests[sol::meta_function::pairs] = [journal](const Quests& quests) {
|
||||
quests[sol::meta_function::pairs] = [journal](const Quests& self) {
|
||||
std::vector<ESM::RefId> ids;
|
||||
for (auto it = journal->questBegin(); it != journal->questEnd(); ++it)
|
||||
ids.push_back(it->first);
|
||||
size_t i = 0;
|
||||
return [ids = std::move(ids), i,
|
||||
allowChanges = quests.mMutable]() mutable -> sol::optional<std::tuple<std::string, Quest>> {
|
||||
allowChanges = self.mMutable]() mutable -> sol::optional<std::tuple<std::string, Quest>> {
|
||||
if (i >= ids.size())
|
||||
return sol::nullopt;
|
||||
const ESM::RefId& id = ids[i++];
|
||||
|
@ -320,19 +320,19 @@ namespace MWLua
|
|||
|
||||
sol::usertype<Quest> quest = lua.new_usertype<Quest>("Quest");
|
||||
quest[sol::meta_function::to_string]
|
||||
= [](const Quest& quest) { return "Quest[" + quest.mQuestId.serializeText() + "]"; };
|
||||
= [](const Quest& self) { return "Quest[" + self.mQuestId.serializeText() + "]"; };
|
||||
|
||||
auto getQuestStage = [journal](const Quest& q) -> int {
|
||||
const MWDialogue::Quest* quest = journal->getQuestOrNull(q.mQuestId);
|
||||
if (quest == nullptr)
|
||||
auto getQuestStage = [journal](const Quest& self) -> int {
|
||||
const MWDialogue::Quest* questPtr = journal->getQuestOrNull(self.mQuestId);
|
||||
if (questPtr == nullptr)
|
||||
return 0;
|
||||
return journal->getJournalIndex(q.mQuestId);
|
||||
return journal->getJournalIndex(self.mQuestId);
|
||||
};
|
||||
auto setQuestStage = [context](const Quest& q, int stage) {
|
||||
if (!q.mMutable)
|
||||
auto setQuestStage = [context](const Quest& self, int stage) {
|
||||
if (!self.mMutable)
|
||||
throw std::runtime_error("Value can only be changed in global or player scripts!");
|
||||
context.mLuaManager->addAction(
|
||||
[q, stage] { MWBase::Environment::get().getJournal()->setJournalIndex(q.mQuestId, stage); },
|
||||
[self, stage] { MWBase::Environment::get().getJournal()->setJournalIndex(self.mQuestId, stage); },
|
||||
"setQuestStageAction");
|
||||
};
|
||||
quest["stage"] = sol::property(getQuestStage, setQuestStage);
|
||||
|
@ -342,10 +342,10 @@ namespace MWLua
|
|||
[journal](const Quest& q) { return journal->getQuestOrNull(q.mQuestId) != nullptr; });
|
||||
quest["finished"] = sol::property(
|
||||
[journal](const Quest& q) -> bool {
|
||||
const MWDialogue::Quest* quest = journal->getQuestOrNull(q.mQuestId);
|
||||
if (quest == nullptr)
|
||||
const MWDialogue::Quest* questPtr = journal->getQuestOrNull(q.mQuestId);
|
||||
if (questPtr == nullptr)
|
||||
return false;
|
||||
return quest->isFinished();
|
||||
return questPtr->isFinished();
|
||||
},
|
||||
[journal, context](const Quest& q, bool finished) {
|
||||
if (!q.mMutable)
|
||||
|
@ -382,28 +382,28 @@ namespace MWLua
|
|||
}));
|
||||
|
||||
MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
|
||||
player["getControlSwitch"] = [input](const Object& player, std::string_view key) {
|
||||
verifyPlayer(player);
|
||||
player["getControlSwitch"] = [input](const Object& object, std::string_view key) {
|
||||
verifyPlayer(object);
|
||||
return input->getControlSwitch(key);
|
||||
};
|
||||
player["setControlSwitch"] = [input](const Object& player, std::string_view key, bool v) {
|
||||
verifyPlayer(player);
|
||||
if (dynamic_cast<const LObject*>(&player) && !dynamic_cast<const SelfObject*>(&player))
|
||||
player["setControlSwitch"] = [input](const Object& object, std::string_view key, bool v) {
|
||||
verifyPlayer(object);
|
||||
if (dynamic_cast<const LObject*>(&object) && !dynamic_cast<const SelfObject*>(&object))
|
||||
throw std::runtime_error("Only player and global scripts can toggle control switches.");
|
||||
input->toggleControlSwitch(key, v);
|
||||
};
|
||||
player["isTeleportingEnabled"] = [](const Object& player) -> bool {
|
||||
verifyPlayer(player);
|
||||
player["isTeleportingEnabled"] = [](const Object& object) -> bool {
|
||||
verifyPlayer(object);
|
||||
return MWBase::Environment::get().getWorld()->isTeleportingEnabled();
|
||||
};
|
||||
player["setTeleportingEnabled"] = [](const Object& player, bool state) {
|
||||
verifyPlayer(player);
|
||||
if (dynamic_cast<const LObject*>(&player) && !dynamic_cast<const SelfObject*>(&player))
|
||||
player["setTeleportingEnabled"] = [](const Object& object, bool state) {
|
||||
verifyPlayer(object);
|
||||
if (dynamic_cast<const LObject*>(&object) && !dynamic_cast<const SelfObject*>(&object))
|
||||
throw std::runtime_error("Only player and global scripts can toggle teleportation.");
|
||||
MWBase::Environment::get().getWorld()->enableTeleporting(state);
|
||||
};
|
||||
player["addTopic"] = [](const Object& player, std::string_view topicId) {
|
||||
verifyPlayer(player);
|
||||
player["addTopic"] = [](const Object& object, std::string_view topicId) {
|
||||
verifyPlayer(object);
|
||||
|
||||
ESM::RefId topic = ESM::RefId::deserializeText(topicId);
|
||||
const ESM::Dialogue* dialogueRecord
|
||||
|
@ -418,8 +418,8 @@ namespace MWLua
|
|||
|
||||
MWBase::Environment::get().getDialogueManager()->addTopic(topic);
|
||||
};
|
||||
player["sendMenuEvent"] = [context](const Object& player, std::string eventName, const sol::object& eventData) {
|
||||
verifyPlayer(player);
|
||||
player["sendMenuEvent"] = [context](const Object& object, std::string eventName, const sol::object& eventData) {
|
||||
verifyPlayer(object);
|
||||
context.mLuaEvents->addMenuEvent({ std::move(eventName), LuaUtil::serialize(eventData) });
|
||||
};
|
||||
|
||||
|
@ -471,13 +471,13 @@ namespace MWLua
|
|||
};
|
||||
|
||||
player["birthSigns"] = initBirthSignRecordBindings(context);
|
||||
player["getBirthSign"] = [](const Object& player) -> std::string {
|
||||
verifyPlayer(player);
|
||||
player["getBirthSign"] = [](const Object& object) -> std::string {
|
||||
verifyPlayer(object);
|
||||
return MWBase::Environment::get().getWorld()->getPlayer().getBirthSign().serializeText();
|
||||
};
|
||||
player["setBirthSign"] = [](const Object& player, const sol::object& recordOrId) {
|
||||
verifyPlayer(player);
|
||||
if (!dynamic_cast<const GObject*>(&player))
|
||||
player["setBirthSign"] = [](const Object& object, const sol::object& recordOrId) {
|
||||
verifyPlayer(object);
|
||||
if (!dynamic_cast<const GObject*>(&object))
|
||||
throw std::runtime_error("Only global scripts can change birth signs");
|
||||
MWBase::Environment::get().getWorld()->getPlayer().setBirthSign(toBirthSignId(recordOrId));
|
||||
};
|
||||
|
|
|
@ -173,18 +173,18 @@ namespace MWLua
|
|||
sol::table types(lua, sol::create);
|
||||
auto addType = [&](std::string_view name, std::vector<ESM::RecNameInts> recTypes,
|
||||
std::optional<std::string_view> base = std::nullopt) -> sol::table {
|
||||
sol::table t(lua, sol::create);
|
||||
sol::table ro = LuaUtil::makeReadOnly(t);
|
||||
sol::table table(lua, sol::create);
|
||||
sol::table ro = LuaUtil::makeReadOnly(table);
|
||||
sol::table meta = ro[sol::metatable_key];
|
||||
meta[sol::meta_function::to_string] = [name]() { return name; };
|
||||
if (base)
|
||||
{
|
||||
t["baseType"] = types[*base];
|
||||
table["baseType"] = types[*base];
|
||||
sol::table baseMeta(lua, sol::create);
|
||||
baseMeta[sol::meta_function::index] = LuaUtil::getMutableFromReadOnly(types[*base]);
|
||||
t[sol::metatable_key] = baseMeta;
|
||||
table[sol::metatable_key] = baseMeta;
|
||||
}
|
||||
t["objectIsInstance"] = [types = recTypes](const Object& o) {
|
||||
table["objectIsInstance"] = [types = recTypes](const Object& o) {
|
||||
unsigned int type = getLiveCellRefType(o.ptr().mRef);
|
||||
for (ESM::RecNameInts t : types)
|
||||
if (t == type)
|
||||
|
@ -192,7 +192,7 @@ namespace MWLua
|
|||
return false;
|
||||
};
|
||||
types[name] = ro;
|
||||
return t;
|
||||
return table;
|
||||
};
|
||||
|
||||
addActorBindings(
|
||||
|
|
|
@ -245,14 +245,14 @@ namespace MWLua
|
|||
|
||||
api["screenSize"] = []() { return osg::Vec2f(Settings::video().mResolutionX, Settings::video().mResolutionY); };
|
||||
|
||||
api["_getAllUiModes"] = [](sol::this_state lua) {
|
||||
sol::table res(lua, sol::create);
|
||||
api["_getAllUiModes"] = [](sol::this_state thisState) {
|
||||
sol::table res(thisState, sol::create);
|
||||
for (const auto& [_, name] : modeToName)
|
||||
res[name] = name;
|
||||
return res;
|
||||
};
|
||||
api["_getUiModeStack"] = [windowManager](sol::this_state lua) {
|
||||
sol::table res(lua, sol::create);
|
||||
api["_getUiModeStack"] = [windowManager](sol::this_state thisState) {
|
||||
sol::table res(thisState, sol::create);
|
||||
int i = 1;
|
||||
for (MWGui::GuiMode m : windowManager->getGuiModeStack())
|
||||
res[i++] = modeToName.at(m);
|
||||
|
@ -283,14 +283,14 @@ namespace MWLua
|
|||
},
|
||||
"Set UI modes");
|
||||
};
|
||||
api["_getAllWindowIds"] = [windowManager](sol::this_state lua) {
|
||||
sol::table res(lua, sol::create);
|
||||
api["_getAllWindowIds"] = [windowManager](sol::this_state thisState) {
|
||||
sol::table res(thisState, sol::create);
|
||||
for (std::string_view name : windowManager->getAllWindowIds())
|
||||
res[name] = name;
|
||||
return res;
|
||||
};
|
||||
api["_getAllowedWindows"] = [windowManager](sol::this_state lua, std::string_view mode) {
|
||||
sol::table res(lua, sol::create);
|
||||
api["_getAllowedWindows"] = [windowManager](sol::this_state thisState, std::string_view mode) {
|
||||
sol::table res(thisState, sol::create);
|
||||
for (std::string_view name : windowManager->getAllowedWindowIds(nameToMode.at(mode)))
|
||||
res[name] = name;
|
||||
return res;
|
||||
|
@ -313,23 +313,23 @@ namespace MWLua
|
|||
{
|
||||
if (context.initializeOnce("openmw_ui_usertypes"))
|
||||
{
|
||||
auto element = context.sol().new_usertype<LuaUi::Element>("UiElement");
|
||||
element[sol::meta_function::to_string] = [](const LuaUi::Element& element) {
|
||||
auto uiElement = context.sol().new_usertype<LuaUi::Element>("UiElement");
|
||||
uiElement[sol::meta_function::to_string] = [](const LuaUi::Element& element) {
|
||||
std::stringstream res;
|
||||
res << "UiElement";
|
||||
if (element.mLayer != "")
|
||||
res << "[" << element.mLayer << "]";
|
||||
return res.str();
|
||||
};
|
||||
element["layout"] = sol::property([](const LuaUi::Element& element) { return element.mLayout; },
|
||||
uiElement["layout"] = sol::property([](const LuaUi::Element& element) { return element.mLayout; },
|
||||
[](LuaUi::Element& element, const sol::main_table& layout) { element.mLayout = layout; });
|
||||
element["update"] = [luaManager = context.mLuaManager](const std::shared_ptr<LuaUi::Element>& element) {
|
||||
uiElement["update"] = [luaManager = context.mLuaManager](const std::shared_ptr<LuaUi::Element>& element) {
|
||||
if (element->mState != LuaUi::Element::Created)
|
||||
return;
|
||||
element->mState = LuaUi::Element::Update;
|
||||
luaManager->addAction([element] { wrapAction(element, [&] { element->update(); }); }, "Update UI");
|
||||
};
|
||||
element["destroy"] = [luaManager = context.mLuaManager](const std::shared_ptr<LuaUi::Element>& element) {
|
||||
uiElement["destroy"] = [luaManager = context.mLuaManager](const std::shared_ptr<LuaUi::Element>& element) {
|
||||
if (element->mState == LuaUi::Element::Destroyed)
|
||||
return;
|
||||
element->mState = LuaUi::Element::Destroy;
|
||||
|
|
|
@ -167,13 +167,13 @@ namespace MWLua
|
|||
|
||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||
|
||||
sol::usertype<FileHandle> handle = context.sol().new_usertype<FileHandle>("FileHandle");
|
||||
handle["fileName"]
|
||||
sol::usertype<FileHandle> fileHandle = context.sol().new_usertype<FileHandle>("FileHandle");
|
||||
fileHandle["fileName"]
|
||||
= sol::readonly_property([](const FileHandle& self) -> std::string_view { return self.mFileName; });
|
||||
handle[sol::meta_function::to_string] = [](const FileHandle& self) {
|
||||
fileHandle[sol::meta_function::to_string] = [](const FileHandle& self) {
|
||||
return "FileHandle{'" + self.mFileName + "'" + (!self.mFilePtr ? ", closed" : "") + "}";
|
||||
};
|
||||
handle["seek"] = sol::overload(
|
||||
fileHandle["seek"] = sol::overload(
|
||||
[](sol::this_state lua, FileHandle& self, std::string_view whence, sol::optional<long> offset) {
|
||||
validateFile(self);
|
||||
|
||||
|
@ -189,7 +189,7 @@ namespace MWLua
|
|||
|
||||
return seek(lua, self, std::ios_base::cur, off);
|
||||
});
|
||||
handle["lines"] = [](sol::this_main_state lua, sol::main_object self) {
|
||||
fileHandle["lines"] = [](sol::this_main_state lua, sol::main_object self) {
|
||||
if (!self.is<FileHandle*>())
|
||||
throw std::runtime_error("self should be a file handle");
|
||||
return sol::as_function([lua, self]() -> sol::object {
|
||||
|
@ -212,7 +212,7 @@ namespace MWLua
|
|||
});
|
||||
};
|
||||
|
||||
handle["close"] = [](sol::this_state lua, FileHandle& self) {
|
||||
fileHandle["close"] = [](sol::this_state lua, FileHandle& self) {
|
||||
sol::variadic_results values;
|
||||
try
|
||||
{
|
||||
|
@ -236,7 +236,7 @@ namespace MWLua
|
|||
return values;
|
||||
};
|
||||
|
||||
handle["read"] = [](sol::this_state lua, FileHandle& self, const sol::variadic_args args) {
|
||||
fileHandle["read"] = [](sol::this_state lua, FileHandle& self, const sol::variadic_args args) {
|
||||
validateFile(self);
|
||||
|
||||
if (args.size() > sMaximumReadArguments)
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace MWMechanics
|
|||
int bonus = 0;
|
||||
int index = ESM::Skill::refIdToIndex(skill.mId);
|
||||
auto bonusIt = std::find_if(race->mData.mBonus.begin(), race->mData.mBonus.end(),
|
||||
[&](const auto& bonus) { return bonus.mSkill == index; });
|
||||
[&](const auto& v) { return v.mSkill == index; });
|
||||
if (bonusIt != race->mData.mBonus.end())
|
||||
bonus = bonusIt->mBonus;
|
||||
|
||||
|
|
|
@ -472,10 +472,10 @@ namespace MWWorld
|
|||
{
|
||||
if (listener != nullptr)
|
||||
listener->setProgressRange(::EsmLoader::fileProgress);
|
||||
auto visitorRec = [this, listener](ESM4::Reader& reader) {
|
||||
bool result = ESMStoreImp::readRecord(reader, *this);
|
||||
auto visitorRec = [this, listener](ESM4::Reader& r) {
|
||||
bool result = ESMStoreImp::readRecord(r, *this);
|
||||
if (listener != nullptr)
|
||||
listener->setProgress(::EsmLoader::fileProgress * reader.getFileOffset() / reader.getFileSize());
|
||||
listener->setProgress(::EsmLoader::fileProgress * r.getFileOffset() / r.getFileSize());
|
||||
return result;
|
||||
};
|
||||
ESM4::ReaderUtils::readAll(reader, visitorRec, [](ESM4::Reader&) {});
|
||||
|
|
|
@ -8,9 +8,9 @@ namespace
|
|||
{
|
||||
|
||||
template <typename T>
|
||||
void create(const MWWorld::Store<T>& list, const ESM::RefId& name, std::any& refValue, MWWorld::Ptr& ptrValue)
|
||||
void create(const MWWorld::Store<T>& store, const ESM::RefId& name, std::any& refValue, MWWorld::Ptr& ptrValue)
|
||||
{
|
||||
const T* base = list.find(name);
|
||||
const T* base = store.find(name);
|
||||
|
||||
ESM::CellRef cellRef;
|
||||
cellRef.blank();
|
||||
|
@ -22,7 +22,7 @@ namespace
|
|||
|
||||
template <typename T>
|
||||
void create(
|
||||
const MWWorld::Store<T>& list, const MWWorld::Ptr& templatePtr, std::any& refValue, MWWorld::Ptr& ptrValue)
|
||||
const MWWorld::Store<T>& /*store*/, const MWWorld::Ptr& templatePtr, std::any& refValue, MWWorld::Ptr& ptrValue)
|
||||
{
|
||||
refValue = *static_cast<MWWorld::LiveCellRef<T>*>(templatePtr.getBase());
|
||||
ptrValue = MWWorld::Ptr(&std::any_cast<MWWorld::LiveCellRef<T>&>(refValue), nullptr);
|
||||
|
@ -92,7 +92,7 @@ namespace
|
|||
|
||||
MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store, const ESM::RefId& name, const int count)
|
||||
{
|
||||
auto cb = [&](const auto& store) { create(store, name, mRef, mPtr); };
|
||||
auto cb = [&](const auto& typedStore) { create(typedStore, name, mRef, mPtr); };
|
||||
visitRefStore(store, name, cb);
|
||||
|
||||
mPtr.getCellRef().setCount(count);
|
||||
|
@ -100,7 +100,7 @@ MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store, const ESM::RefId&
|
|||
|
||||
MWWorld::ManualRef::ManualRef(const ESMStore& store, const Ptr& template_, const int count)
|
||||
{
|
||||
auto cb = [&](const auto& store) { create(store, template_, mRef, mPtr); };
|
||||
auto cb = [&](const auto& typedStore) { create(typedStore, template_, mRef, mPtr); };
|
||||
visitRefStore(store, template_.getCellRef().getRefId(), cb);
|
||||
|
||||
mPtr.getCellRef().setCount(count);
|
||||
|
|
|
@ -401,11 +401,11 @@ namespace MWWorld
|
|||
mNavigator.removeWater(osg::Vec2i(cellX, cellY), navigatorUpdateGuard);
|
||||
|
||||
ESM::visit(ESM::VisitOverload{
|
||||
[&](const ESM::Cell& cell) {
|
||||
if (const auto pathgrid = mWorld.getStore().get<ESM::Pathgrid>().search(cell))
|
||||
[&](const ESM::Cell& c) {
|
||||
if (const auto pathgrid = mWorld.getStore().get<ESM::Pathgrid>().search(c))
|
||||
mNavigator.removePathgrid(*pathgrid);
|
||||
},
|
||||
[&](const ESM4::Cell& cell) {},
|
||||
[&](const ESM4::Cell& /*c*/) {},
|
||||
},
|
||||
*cell->getCell());
|
||||
|
||||
|
@ -482,11 +482,11 @@ namespace MWWorld
|
|||
}
|
||||
|
||||
ESM::visit(ESM::VisitOverload{
|
||||
[&](const ESM::Cell& cell) {
|
||||
if (const auto pathgrid = mWorld.getStore().get<ESM::Pathgrid>().search(cell))
|
||||
mNavigator.addPathgrid(cell, *pathgrid);
|
||||
[&](const ESM::Cell& c) {
|
||||
if (const auto pathgrid = mWorld.getStore().get<ESM::Pathgrid>().search(c))
|
||||
mNavigator.addPathgrid(c, *pathgrid);
|
||||
},
|
||||
[&](const ESM4::Cell& cell) {},
|
||||
[&](const ESM4::Cell& /*c*/) {},
|
||||
},
|
||||
*cell.getCell());
|
||||
|
||||
|
|
|
@ -335,8 +335,7 @@ void Wizard::MainWizard::addInstallation(const QString& path)
|
|||
|
||||
// Add it to the openmw.cfg too
|
||||
const auto& dataDirs = mGameSettings.getDataDirs();
|
||||
if (std::none_of(
|
||||
dataDirs.begin(), dataDirs.end(), [&](const Config::SettingValue& dir) { return dir.value == path; }))
|
||||
if (std::none_of(dataDirs.begin(), dataDirs.end(), [&](const Config::SettingValue& d) { return d.value == path; }))
|
||||
{
|
||||
mGameSettings.setMultiValue(QLatin1String("data"), { path });
|
||||
mGameSettings.addDataDir({ path });
|
||||
|
|
|
@ -361,9 +361,9 @@ bool Wizard::UnshieldWorker::installDirectories(
|
|||
|
||||
QStringList directories(findDirectories(dirName, path, recursive));
|
||||
|
||||
for (const QString& dir : directories)
|
||||
for (const QString& subDir : directories)
|
||||
{
|
||||
QFileInfo info(dir);
|
||||
QFileInfo info(subDir);
|
||||
emit textChanged(tr("Installing: %1 directory").arg(info.fileName()));
|
||||
if (!copyDirectory(info.absoluteFilePath(), getPath() + QDir::separator() + info.fileName(), keepSource))
|
||||
return false;
|
||||
|
@ -769,15 +769,15 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
|
|||
QStringList datafiles(findDirectories(QLatin1String("Data Files"), temp.absolutePath()));
|
||||
datafiles.append(findDirectories(QLatin1String("Data Files"), info.absolutePath()));
|
||||
|
||||
for (const QString& dir : datafiles)
|
||||
for (const QString& dataDir : datafiles)
|
||||
{
|
||||
QFileInfo info(dir);
|
||||
emit textChanged(tr("Installing: %1 directory").arg(info.fileName()));
|
||||
QFileInfo dataDirInfo(dataDir);
|
||||
emit textChanged(tr("Installing: %1 directory").arg(dataDirInfo.fileName()));
|
||||
|
||||
if (!copyDirectory(info.absoluteFilePath(), getPath()))
|
||||
if (!copyDirectory(dataDirInfo.absoluteFilePath(), getPath()))
|
||||
{
|
||||
emit error(tr("Could not install directory!"),
|
||||
tr("Installing %1 to %2 failed.").arg(info.absoluteFilePath(), getPath()));
|
||||
tr("Installing %1 to %2 failed.").arg(dataDirInfo.absoluteFilePath(), getPath()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,6 +324,10 @@ add_component_dir (files
|
|||
istreamptr streamwithbuffer
|
||||
)
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||
set_source_files_properties(files/configfileparser.cpp PROPERTIES COMPILE_FLAGS -Wno-shadow)
|
||||
endif()
|
||||
|
||||
add_component_dir (compiler
|
||||
context controlparser errorhandler exception exprparser extensions fileparser generator
|
||||
lineparser literals locals output parser scanner scriptparser skipparser streamerrorhandler
|
||||
|
|
|
@ -209,7 +209,7 @@ namespace Compiler
|
|||
bool mIgnoreSpecial;
|
||||
|
||||
public:
|
||||
enum keyword
|
||||
enum Keyword
|
||||
{
|
||||
K_begin,
|
||||
K_end,
|
||||
|
@ -228,7 +228,7 @@ namespace Compiler
|
|||
K_to
|
||||
};
|
||||
|
||||
enum special
|
||||
enum Special
|
||||
{
|
||||
S_newline,
|
||||
S_open,
|
||||
|
|
|
@ -316,7 +316,7 @@ namespace DetourNavigator
|
|||
{
|
||||
if (mPushed.emplace(agentBounds, changedTile).second)
|
||||
{
|
||||
const auto processTime = [&, changedTile = changedTile, changeType = changeType] {
|
||||
const std::chrono::steady_clock::time_point processTime = [&] {
|
||||
if (changeType != ChangeType::update)
|
||||
return std::chrono::steady_clock::time_point();
|
||||
const auto lastUpdate = mLastUpdates.find(std::tie(agentBounds, changedTile));
|
||||
|
@ -947,11 +947,11 @@ namespace DetourNavigator
|
|||
mNextTileId = TileId(mDb->getMaxTileId() + 1);
|
||||
Log(Debug::Info) << "Updated navmeshdb tile_id to: " << mNextTileId;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
catch (const std::exception& exception)
|
||||
{
|
||||
mWriteToDb = false;
|
||||
Log(Debug::Warning)
|
||||
<< "Failed to update next tile_id, writes to navmeshdb are disabled: " << e.what();
|
||||
Log(Debug::Warning) << "Failed to update next tile_id, writes to navmeshdb are disabled: "
|
||||
<< exception.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -960,12 +960,12 @@ namespace DetourNavigator
|
|||
|
||||
if (isWritingDbJob(*job))
|
||||
{
|
||||
process([&](JobIt job) { processWritingJob(job); });
|
||||
process([&](JobIt it) { processWritingJob(it); });
|
||||
mUpdater.removeJob(job);
|
||||
return;
|
||||
}
|
||||
|
||||
process([&](JobIt job) { processReadingJob(job); });
|
||||
process([&](JobIt it) { processReadingJob(it); });
|
||||
job->mState = JobState::WithDbResult;
|
||||
mUpdater.enqueueJob(job);
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ namespace DetourNavigator
|
|||
if (itByTilePosition == values->mByTilePosition.end())
|
||||
return result;
|
||||
|
||||
std::for_each(itByTilePosition->second.begin(), itByTilePosition->second.end(), [&](const ObjectId v) {
|
||||
const auto byId = values->mById.equal_range(v);
|
||||
std::for_each(itByTilePosition->second.begin(), itByTilePosition->second.end(), [&](const ObjectId id) {
|
||||
const auto byId = values->mById.equal_range(id);
|
||||
std::for_each(byId.first, byId.second, [&](const auto& v) {
|
||||
if (getTilePosition(mSettings, v.second.mStart) == tilePosition
|
||||
|| getTilePosition(mSettings, v.second.mEnd) == tilePosition)
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace DetourNavigator
|
|||
BulletHelpers::getHeightfieldShift(cellPosition.x(), cellPosition.y(), cellSize, minHeight, maxHeight));
|
||||
const float stepSize = getHeightfieldScale(cellSize, size);
|
||||
const int halfCellSize = cellSize / 2;
|
||||
const auto local = [&](float v, float shift) { return (v - shift + halfCellSize) / stepSize; };
|
||||
const auto local = [&](float v, float offset) { return (v - offset + halfCellSize) / stepSize; };
|
||||
const auto index = [&](float v, int add) { return std::clamp<int>(static_cast<int>(v) + add, 0, size); };
|
||||
const std::size_t minX = index(std::round(local(intersection->mMin.x(), shift.x())), -1);
|
||||
const std::size_t minY = index(std::round(local(intersection->mMin.y(), shift.y())), -1);
|
||||
|
|
|
@ -475,11 +475,11 @@ namespace Files
|
|||
return istream;
|
||||
}
|
||||
|
||||
PathContainer asPathContainer(const MaybeQuotedPathContainer& MaybeQuotedPathContainer)
|
||||
PathContainer asPathContainer(const MaybeQuotedPathContainer& value)
|
||||
{
|
||||
PathContainer res;
|
||||
res.reserve(MaybeQuotedPathContainer.size());
|
||||
for (const auto& maybeQuotedPath : MaybeQuotedPathContainer)
|
||||
res.reserve(value.size());
|
||||
for (const auto& maybeQuotedPath : value)
|
||||
{
|
||||
res.emplace_back(maybeQuotedPath.u8string()); // This call to u8string is redundant, but required to build
|
||||
// on MSVC 14.26 due to implementation bugs.
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Files
|
|||
|
||||
typedef std::vector<MaybeQuotedPath> MaybeQuotedPathContainer;
|
||||
|
||||
PathContainer asPathContainer(const MaybeQuotedPathContainer& MaybeQuotedPathContainer);
|
||||
PathContainer asPathContainer(const MaybeQuotedPathContainer& value);
|
||||
|
||||
} /* namespace Files */
|
||||
|
||||
|
|
|
@ -89,18 +89,18 @@ namespace LuaUtil
|
|||
|
||||
// Pushing to the stack from outside a Lua context crashes the engine if no memory can be allocated to grow the
|
||||
// stack
|
||||
template <class Lambda>
|
||||
[[nodiscard]] int invokeProtectedCall(Lambda&& f) const
|
||||
template <class Function>
|
||||
[[nodiscard]] int invokeProtectedCall(Function&& function) const
|
||||
{
|
||||
if (!lua_checkstack(mSol.lua_state(), 2))
|
||||
return LUA_ERRMEM;
|
||||
lua_pushcfunction(mSol.lua_state(), [](lua_State* L) {
|
||||
void* f = lua_touserdata(L, 1);
|
||||
LuaView view(L);
|
||||
(*static_cast<Lambda*>(f))(view);
|
||||
(*static_cast<Function*>(f))(view);
|
||||
return 0;
|
||||
});
|
||||
lua_pushlightuserdata(mSol.lua_state(), &f);
|
||||
lua_pushlightuserdata(mSol.lua_state(), &function);
|
||||
return lua_pcall(mSol.lua_state(), 1, 0, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -359,10 +359,10 @@ namespace LuaUtil
|
|||
if (it == data.mEventHandlers.end())
|
||||
return;
|
||||
mLua.protectedCall([&](LuaView& view) {
|
||||
sol::object data;
|
||||
sol::object object;
|
||||
try
|
||||
{
|
||||
data = LuaUtil::deserialize(view.sol(), eventData, mSerializer);
|
||||
object = LuaUtil::deserialize(view.sol(), eventData, mSerializer);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
@ -375,7 +375,7 @@ namespace LuaUtil
|
|||
const Handler& h = list[i];
|
||||
try
|
||||
{
|
||||
sol::object res = LuaUtil::call({ this, h.mScriptId }, h.mFn, data);
|
||||
sol::object res = LuaUtil::call({ this, h.mScriptId }, h.mFn, object);
|
||||
if (res.is<bool>() && !res.as<bool>())
|
||||
break; // Skip other handlers if 'false' was returned.
|
||||
}
|
||||
|
|
|
@ -394,12 +394,12 @@ namespace LuaUtil
|
|||
}
|
||||
|
||||
util["loadCode"] = [](const std::string& code, const sol::table& env, sol::this_state s) {
|
||||
sol::state_view lua(s);
|
||||
sol::load_result res = lua.load(code, "", sol::load_mode::text);
|
||||
sol::state_view thisState(s);
|
||||
sol::load_result res = thisState.load(code, "", sol::load_mode::text);
|
||||
if (!res.valid())
|
||||
throw std::runtime_error("Lua error: " + res.get<std::string>());
|
||||
sol::function fn = res;
|
||||
sol::environment newEnv(lua, sol::create, env);
|
||||
sol::environment newEnv(thisState, sol::create, env);
|
||||
newEnv[sol::metatable_key][sol::meta_function::new_index] = env;
|
||||
sol::set_environment(newEnv, fn);
|
||||
return fn;
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Nif
|
|||
union
|
||||
{
|
||||
intptr_t index;
|
||||
X* ptr;
|
||||
X* mPtr;
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -29,7 +29,7 @@ namespace Nif
|
|||
}
|
||||
|
||||
RecordPtrT(X* ptr)
|
||||
: ptr(ptr)
|
||||
: mPtr(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -48,26 +48,26 @@ namespace Nif
|
|||
void post(Reader& nif)
|
||||
{
|
||||
if (index < 0)
|
||||
ptr = nullptr;
|
||||
mPtr = nullptr;
|
||||
else
|
||||
{
|
||||
Record* r = nif.getRecord(index);
|
||||
// And cast it
|
||||
ptr = dynamic_cast<X*>(r);
|
||||
assert(ptr != nullptr);
|
||||
mPtr = dynamic_cast<X*>(r);
|
||||
assert(mPtr != nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
/// Look up the actual object from the index
|
||||
const X* getPtr() const
|
||||
{
|
||||
assert(ptr != nullptr);
|
||||
return ptr;
|
||||
assert(mPtr != nullptr);
|
||||
return mPtr;
|
||||
}
|
||||
X* getPtr()
|
||||
{
|
||||
assert(ptr != nullptr);
|
||||
return ptr;
|
||||
assert(mPtr != nullptr);
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
const X& get() const { return *getPtr(); }
|
||||
|
@ -78,7 +78,7 @@ namespace Nif
|
|||
X* operator->() { return getPtr(); }
|
||||
|
||||
/// Pointers are allowed to be empty
|
||||
bool empty() const { return ptr == nullptr; }
|
||||
bool empty() const { return mPtr == nullptr; }
|
||||
};
|
||||
|
||||
/** A list of references to other records. These are read as a list,
|
||||
|
|
|
@ -375,7 +375,7 @@ namespace NifOsg
|
|||
return true;
|
||||
|
||||
auto iter = std::upper_bound(mData->begin(), mData->end(), time,
|
||||
[](float time, const std::pair<float, bool>& key) { return time < key.first; });
|
||||
[](float t, const std::pair<float, bool>& key) { return t < key.first; });
|
||||
if (iter != mData->begin())
|
||||
--iter;
|
||||
return iter->second;
|
||||
|
|
|
@ -32,18 +32,18 @@ namespace Stereo
|
|||
{
|
||||
public:
|
||||
StereoUpdateCallback(Manager* stereoView)
|
||||
: stereoView(stereoView)
|
||||
: mStereoView(stereoView)
|
||||
{
|
||||
}
|
||||
|
||||
bool run(osg::Object* object, osg::Object* data) override
|
||||
{
|
||||
auto b = traverse(object, data);
|
||||
stereoView->update();
|
||||
mStereoView->update();
|
||||
return b;
|
||||
}
|
||||
|
||||
Manager* stereoView;
|
||||
Manager* mStereoView;
|
||||
};
|
||||
|
||||
// Update states during cull
|
||||
|
|
Loading…
Reference in a new issue