Fixed various issues caused by late-night coding. Also added "unlock" message to unlocked doors

actorid
Thomas 11 years ago
parent 61341d4206
commit f6deca7c80

@ -211,6 +211,8 @@ namespace MWClass
std::string text;
if (ref->mRef.mLockLevel > 0)
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
else if (ref->mRef.mLockLevel < 0)
text += "\n#{sUnlocked}";
if (ref->mRef.mTrap != "")
text += "\n#{sTrapped}";
@ -240,9 +242,10 @@ namespace MWClass
void Container::lock (const MWWorld::Ptr& ptr, int lockLevel) const
{
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //Makes lockLevel positive
if(lockLevel>=0) //Lock level setting left as most of the code relies on this
ptr.getCellRef().mLockLevel = lockLevel;
if(lockLevel!=0)
ptr.getCellRef().mLockLevel = abs(lockLevel); //Changes lock to locklevel, in positive
else
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //No locklevel given, just flip the oriional one
}
void Container::unlock (const MWWorld::Ptr& ptr) const
@ -250,13 +253,6 @@ namespace MWClass
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel negative
}
void Container::changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool doLock) {
if (lockLevel<0)
lockLevel = 0;
ptr.getCellRef().mLockLevel = lockLevel;
if(doLock) lock(ptr);
}
MWWorld::Ptr
Container::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const

@ -48,15 +48,12 @@ namespace MWClass
///< Returns total weight of objects inside this object (including modifications from magic
/// effects). Throws an exception, if the object can't hold other objects.
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = -999) const;
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = 0) const;
///< Lock object
virtual void unlock (const MWWorld::Ptr& ptr) const;
///< Unlock object
///Changes the lock level of the object
virtual void changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool lock=true);
virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
const;
///< Read additional state from \a state into \a ptr.

@ -158,22 +158,15 @@ namespace MWClass
void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const
{
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //Makes lockLevel positive;
if(lockLevel>=0) //Lock level setting left as most of the code relies on this
ptr.getCellRef().mLockLevel = abs(lockLevel);
}
void Door::changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool doLock) const{
if (lockLevel<0)
lockLevel = 0;
ptr.getCellRef().mLockLevel = lockLevel;
if(doLock) lock(ptr); //A change in lock level almost always nesesitates a lock
if(lockLevel!=0)
ptr.getCellRef().mLockLevel = abs(lockLevel); //Changes lock to locklevel, in positive
else
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //No locklevel given, just flip the origional one
}
void Door::unlock (const MWWorld::Ptr& ptr) const
{
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel positive
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel negative
}
std::string Door::getScript (const MWWorld::Ptr& ptr) const
@ -217,6 +210,8 @@ namespace MWClass
if (ref->mRef.mLockLevel > 0)
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
else if (ref->mRef.mLockLevel < 0)
text += "\n#{sUnlocked}";
if (ref->mRef.mTrap != "")
text += "\n#{sTrapped}";

@ -36,15 +36,12 @@ namespace MWClass
static std::string getDestination (const MWWorld::LiveCellRef<ESM::Door>& door);
///< @return destination cell name or token
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = -999) const;
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = 0) const;
///< Lock object
virtual void unlock (const MWWorld::Ptr& ptr) const;
///< Unlock object
///Change the lock level
virtual void changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool lock=true) const;
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

@ -420,20 +420,20 @@ namespace MWMechanics
{
if (effectId == ESM::MagicEffect::Lock)
{
target.getCellRef().mLockLevel = abs(target.getCellRef().mLockLevel); //Makes lockLevel positive
if (target.getCellRef().mLockLevel < magnitude)
if (target.getCellRef().mLockLevel < magnitude) //If the door is not already locked to a higher value, lock it to spell magnitude
target.getCellRef().mLockLevel = magnitude;
}
else if (effectId == ESM::MagicEffect::Open)
{
if (target.getCellRef().mLockLevel <= magnitude)
{
//Door not already unlocked
if (target.getCellRef().mLockLevel > 0)
{
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock", 1.f, 1.f);
MWBase::Environment::get().getMechanicsManager()->objectOpened(caster, target);
}
target.getCellRef().mLockLevel = -abs(target.getCellRef().mLockLevel);
target.getCellRef().mLockLevel = -abs(target.getCellRef().mLockLevel); //unlocks the door
}
else
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);

@ -132,7 +132,7 @@ namespace MWScript
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer lockLevel = ptr.getCellRef().mLockLevel;
if(lockLevel==-999) { //no lock level was ever set, set to 100 as default
if(lockLevel==0) { //no lock level was ever set, set to 100 as default
lockLevel = 100;
}

@ -137,11 +137,6 @@ namespace MWWorld
throw std::runtime_error ("class does not support locking");
}
void Class::setLockLevel (const Ptr& ptr, int lockLevel) const
{
throw std::runtime_error ("class does not support setting lock level");
}
void Class::unlock (const Ptr& ptr) const
{
throw std::runtime_error ("class does not support unlocking");

@ -165,8 +165,6 @@ namespace MWWorld
virtual void lock (const Ptr& ptr, int lockLevel) const;
///< Lock object (default implementation: throw an exception)
virtual void setLockLevel(const Ptr& ptr, int lockLevel) const;
virtual void unlock (const Ptr& ptr) const;
///< Unlock object (default implementation: throw an exception)

@ -54,7 +54,7 @@ void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
else
mTeleport = false;
mLockLevel = -999; //Set to impossible value to indicate no lock
mLockLevel = 0; //Set to 0 to indicate no lock
esm.getHNOT (mLockLevel, "FLTV");
mKey = esm.getHNOString ("KNAM");
@ -114,7 +114,7 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory) cons
esm.writeHNOCString("DNAM", mDestCell);
}
if (mLockLevel != -999 && !inInventory) {
if (mLockLevel != 0 && !inInventory) {
esm.writeHNT("FLTV", mLockLevel);
}

Loading…
Cancel
Save