Merge branch 'i-said-it-was-unlocked-damn-you' into 'master'

Fix(CS): Actually allow unlocking doors ( #7899 )

Closes #7899

See merge request OpenMW/openmw!3982
fix-osga-rotate-wildly
psi29a 9 months ago
commit f7f7502d60

@ -163,6 +163,7 @@
Bug #7872: Region sounds use wrong odds Bug #7872: Region sounds use wrong odds
Bug #7887: Editor: Mismatched reported script data size and actual data size causes a crash during save Bug #7887: Editor: Mismatched reported script data size and actual data size causes a crash during save
Bug #7898: Editor: Invalid reference scales are allowed Bug #7898: Editor: Invalid reference scales are allowed
Bug #7899: Editor: Doors can't be unlocked
Feature #2566: Handle NAM9 records for manual cell references Feature #2566: Handle NAM9 records for manual cell references
Feature #3537: Shader-based water ripples Feature #3537: Shader-based water ripples
Feature #5173: Support for NiFogProperty Feature #5173: Support for NiFogProperty

@ -1182,6 +1182,26 @@ namespace CSMWorld
bool isUserEditable() const override { return true; } bool isUserEditable() const override { return true; }
}; };
template <typename ESXRecordT>
struct IsLockedColumn : public Column<ESXRecordT>
{
IsLockedColumn(int flags)
: Column<ESXRecordT>(Columns::ColumnId_IsLocked, ColumnBase::Display_Boolean, flags)
{
}
QVariant get(const Record<ESXRecordT>& record) const override { return record.get().mIsLocked; }
void set(Record<ESXRecordT>& record, const QVariant& data) override
{
ESXRecordT record2 = record.get();
record2.mIsLocked = data.toBool();
record.setModified(record2);
}
bool isEditable() const override { return true; }
};
template <typename ESXRecordT> template <typename ESXRecordT>
struct LockLevelColumn : public Column<ESXRecordT> struct LockLevelColumn : public Column<ESXRecordT>
{ {
@ -1190,7 +1210,12 @@ namespace CSMWorld
{ {
} }
QVariant get(const Record<ESXRecordT>& record) const override { return record.get().mLockLevel; } QVariant get(const Record<ESXRecordT>& record) const override
{
if (record.get().mIsLocked)
return record.get().mLockLevel;
return QVariant();
}
void set(Record<ESXRecordT>& record, const QVariant& data) override void set(Record<ESXRecordT>& record, const QVariant& data) override
{ {
@ -1212,7 +1237,9 @@ namespace CSMWorld
QVariant get(const Record<ESXRecordT>& record) const override QVariant get(const Record<ESXRecordT>& record) const override
{ {
return QString::fromUtf8(record.get().mKey.getRefIdString().c_str()); if (record.get().mIsLocked)
return QString::fromUtf8(record.get().mKey.getRefIdString().c_str());
return QVariant();
} }
void set(Record<ESXRecordT>& record, const QVariant& data) override void set(Record<ESXRecordT>& record, const QVariant& data) override

@ -59,6 +59,7 @@ namespace CSMWorld
{ ColumnId_StackCount, "Count" }, { ColumnId_StackCount, "Count" },
{ ColumnId_Teleport, "Teleport" }, { ColumnId_Teleport, "Teleport" },
{ ColumnId_TeleportCell, "Teleport Cell" }, { ColumnId_TeleportCell, "Teleport Cell" },
{ ColumnId_IsLocked, "Locked" },
{ ColumnId_LockLevel, "Lock Level" }, { ColumnId_LockLevel, "Lock Level" },
{ ColumnId_Key, "Key" }, { ColumnId_Key, "Key" },
{ ColumnId_Trap, "Trap" }, { ColumnId_Trap, "Trap" },

@ -351,6 +351,8 @@ namespace CSMWorld
ColumnId_SoundProbability = 317, ColumnId_SoundProbability = 317,
ColumnId_IsLocked = 318,
// Allocated to a separate value range, so we don't get a collision should we ever need // Allocated to a separate value range, so we don't get a collision should we ever need
// to extend the number of use values. // to extend the number of use values.
ColumnId_UseValue1 = 0x10000, ColumnId_UseValue1 = 0x10000,

@ -599,6 +599,8 @@ CSMWorld::Data::Data(ToUTF8::FromType encoding, const Files::PathContainer& data
mRefs.addColumn(new RotColumn<CellRef>(&CellRef::mDoorDest, 0, true)); mRefs.addColumn(new RotColumn<CellRef>(&CellRef::mDoorDest, 0, true));
mRefs.addColumn(new RotColumn<CellRef>(&CellRef::mDoorDest, 1, true)); mRefs.addColumn(new RotColumn<CellRef>(&CellRef::mDoorDest, 1, true));
mRefs.addColumn(new RotColumn<CellRef>(&CellRef::mDoorDest, 2, true)); mRefs.addColumn(new RotColumn<CellRef>(&CellRef::mDoorDest, 2, true));
mRefs.addColumn(new IsLockedColumn<CellRef>(
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_Refresh));
mRefs.addColumn(new LockLevelColumn<CellRef>); mRefs.addColumn(new LockLevelColumn<CellRef>);
mRefs.addColumn(new KeyColumn<CellRef>); mRefs.addColumn(new KeyColumn<CellRef>);
mRefs.addColumn(new TrapColumn<CellRef>); mRefs.addColumn(new TrapColumn<CellRef>);

@ -230,12 +230,14 @@ namespace ESM
if (!inInventory) if (!inInventory)
{ {
int lockLevel = mLockLevel; if (mIsLocked)
if (lockLevel == 0 && mIsLocked) {
lockLevel = ZeroLock; int lockLevel = mLockLevel;
if (lockLevel != 0) if (lockLevel == 0)
lockLevel = ZeroLock;
esm.writeHNT("FLTV", lockLevel); esm.writeHNT("FLTV", lockLevel);
esm.writeHNOCRefId("KNAM", mKey); esm.writeHNOCRefId("KNAM", mKey);
}
esm.writeHNOCRefId("TNAM", mTrap); esm.writeHNOCRefId("TNAM", mTrap);
} }

Loading…
Cancel
Save