1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

Removed mLocked, kept it as "Negative lock level means unlocked"

This commit is contained in:
Thomas 2014-04-23 10:00:18 -04:00
parent 6022ffbd1f
commit 61341d4206
9 changed files with 16 additions and 29 deletions

View file

@ -111,7 +111,7 @@ namespace MWClass
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
bool needKey = ptr.getCellRef().mLocked;
bool needKey = ptr.getCellRef().mLockLevel > 0;
bool hasKey = false;
std::string keyName;
@ -209,7 +209,7 @@ namespace MWClass
info.caption = ref->mBase->mName;
std::string text;
if (ref->mRef.mLocked)
if (ref->mRef.mLockLevel > 0)
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
if (ref->mRef.mTrap != "")
text += "\n#{sTrapped}";
@ -240,14 +240,14 @@ namespace MWClass
void Container::lock (const MWWorld::Ptr& ptr, int lockLevel) const
{
ptr.getCellRef().mLocked = true;
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;
}
void Container::unlock (const MWWorld::Ptr& ptr) const
{
ptr.getCellRef().mLocked= false;
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel negative
}
void Container::changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool doLock) {

View file

@ -76,7 +76,7 @@ namespace MWClass
MWWorld::ContainerStore &invStore = get(actor).getContainerStore(actor);
bool needKey = ptr.getCellRef().mLocked;
bool needKey = ptr.getCellRef().mLockLevel > 0;
bool hasKey = false;
std::string keyName;
@ -158,9 +158,9 @@ namespace MWClass
void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const
{
ptr.getCellRef().mLocked = true;
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;
ptr.getCellRef().mLockLevel = abs(lockLevel);
}
void Door::changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool doLock) const{
@ -173,7 +173,7 @@ namespace MWClass
void Door::unlock (const MWWorld::Ptr& ptr) const
{
ptr.getCellRef().mLocked = false;
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel positive
}
std::string Door::getScript (const MWWorld::Ptr& ptr) const
@ -215,7 +215,7 @@ namespace MWClass
text += "\n" + getDestination(*ref);
}
if (ref->mRef.mLocked == true)
if (ref->mRef.mLockLevel > 0)
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
if (ref->mRef.mTrap != "")
text += "\n#{sTrapped}";

View file

@ -29,7 +29,7 @@ namespace MWMechanics
void Security::pickLock(const MWWorld::Ptr &lock, const MWWorld::Ptr &lockpick,
std::string& resultMessage, std::string& resultSound)
{
if (!lock.getCellRef().mLocked)
if (!(lock.getCellRef().mLockLevel > 0)) //If it's unlocked back out immediately
return;
int lockStrength = lock.getCellRef().mLockLevel;

View file

@ -420,7 +420,7 @@ namespace MWMechanics
{
if (effectId == ESM::MagicEffect::Lock)
{
target.getCellRef().mLocked = true;
target.getCellRef().mLockLevel = abs(target.getCellRef().mLockLevel); //Makes lockLevel positive
if (target.getCellRef().mLockLevel < magnitude)
target.getCellRef().mLockLevel = magnitude;
}
@ -428,12 +428,12 @@ namespace MWMechanics
{
if (target.getCellRef().mLockLevel <= magnitude)
{
if (target.getCellRef().mLocked)
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().mLocked=false;
target.getCellRef().mLockLevel = -abs(target.getCellRef().mLockLevel);
}
else
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);

View file

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

View file

@ -76,7 +76,6 @@ namespace MWWorld
cellRef.mEnchantmentCharge = -1;
cellRef.mTeleport = false;
cellRef.mLockLevel = 0;
cellRef.mLocked = false;
cellRef.mReferenceBlocked = 0;
mPtr.getRefData().setCount(count);
}

View file

@ -2724,7 +2724,7 @@ namespace MWWorld
}
}
}
closestChest.getCellRef().mLocked = true;
closestChest.getCellRef().mLockLevel = abs(closestChest.getCellRef().mLockLevel);
}
void World::goToJail()

View file

@ -55,13 +55,7 @@ void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
mTeleport = false;
mLockLevel = -999; //Set to impossible value to indicate no lock
mLocked = false;
esm.getHNOT (mLockLevel, "FLTV");
if(mLockLevel < 0 && mLockLevel != -999) //Unlocked lock, save lock level properly
mLockLevel*=-1;
else if(mLockLevel != -999){
mLocked = true;
}
mKey = esm.getHNOString ("KNAM");
mTrap = esm.getHNOString ("TNAM");
@ -121,10 +115,7 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory) cons
}
if (mLockLevel != -999 && !inInventory) {
if(mLocked)
esm.writeHNT("FLTV", mLockLevel);
else //If it's not locked we simply flip the locklevel to indicate it's locked
esm.writeHNT("FLTV", -mLockLevel);
}
if (!inInventory)
@ -162,7 +153,6 @@ void ESM::CellRef::blank()
mGoldValue = 0;
mDestCell.clear();
mLockLevel = 0;
mLocked = false;
mKey.clear();
mTrap.clear();
mReferenceBlocked = 0;

View file

@ -71,7 +71,6 @@ namespace ESM
// Lock level for doors and containers
int mLockLevel;
bool mLocked; //Door locked/unlocked
std::string mKey, mTrap; // Key and trap ID names, if any
// This corresponds to the "Reference Blocked" checkbox in the construction set,