1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-05 06:40:09 +00:00

Windows debug build crash fix.

This commit is contained in:
cc9cii 2014-05-09 20:43:24 +10:00
parent 3dfd239b83
commit cf23721f1b

View File

@ -167,7 +167,7 @@ namespace MWMechanics
mCombatMove = false; mCombatMove = false;
} }
} }
actor.getClass().getMovementSettings(actor) = mMovement; actor.getClass().getMovementSettings(actor) = mMovement;
actor.getClass().getMovementSettings(actor).mRotation[0] = 0; actor.getClass().getMovementSettings(actor).mRotation[0] = 0;
actor.getClass().getMovementSettings(actor).mRotation[2] = 0; actor.getClass().getMovementSettings(actor).mRotation[2] = 0;
@ -176,7 +176,7 @@ namespace MWMechanics
{ {
if(zTurn(actor, Ogre::Degree(mMovement.mRotation[2]))) mMovement.mRotation[2] = 0; if(zTurn(actor, Ogre::Degree(mMovement.mRotation[2]))) mMovement.mRotation[2] = 0;
} }
if(mMovement.mRotation[0] != 0) if(mMovement.mRotation[0] != 0)
{ {
if(smoothTurn(actor, Ogre::Degree(mMovement.mRotation[0]), 0)) mMovement.mRotation[0] = 0; if(smoothTurn(actor, Ogre::Degree(mMovement.mRotation[0]), 0)) mMovement.mRotation[0] = 0;
@ -193,7 +193,7 @@ namespace MWMechanics
} }
//Update with period = tReaction //Update with period = tReaction
mTimerReact = 0; mTimerReact = 0;
bool cellChange = mCell && (actor.getCell() != mCell); bool cellChange = mCell && (actor.getCell() != mCell);
@ -282,7 +282,7 @@ namespace MWMechanics
* *
* - Distance where attack using the actor's weapon is possible: * - Distance where attack using the actor's weapon is possible:
* longer for ranged weapons (obviously?) vs. melee weapons * longer for ranged weapons (obviously?) vs. melee weapons
* - Determined by weapon's reach parameter; hardcoded value * - Determined by weapon's reach parameter; hardcoded value
* for ranged weapon and for creatures * for ranged weapon and for creatures
* - Once within this distance mFollowTarget is triggered * - Once within this distance mFollowTarget is triggered
* *
@ -318,15 +318,15 @@ namespace MWMechanics
rangeAttack = weapRange; rangeAttack = weapRange;
rangeFollow = 300; rangeFollow = 300;
} }
ESM::Position pos = actor.getRefData().getPosition(); ESM::Position pos = actor.getRefData().getPosition();
Ogre::Vector3 vActorPos(pos.pos); Ogre::Vector3 vActorPos(pos.pos);
Ogre::Vector3 vTargetPos(mTarget.getRefData().getPosition().pos); Ogre::Vector3 vTargetPos(mTarget.getRefData().getPosition().pos);
Ogre::Vector3 vDirToTarget = vTargetPos - vActorPos; Ogre::Vector3 vDirToTarget = vTargetPos - vActorPos;
bool isStuck = false; bool isStuck = false;
float speed = 0.0f; float speed = 0.0f;
if(mMovement.mPosition[1] && (Ogre::Vector3(mLastPos.pos) - vActorPos).length() < (speed = actorCls.getSpeed(actor)) / 10.0f) if(mMovement.mPosition[1] && (Ogre::Vector3(mLastPos.pos) - vActorPos).length() < (speed = actorCls.getSpeed(actor)) / 10.0f)
isStuck = true; isStuck = true;
mLastPos = pos; mLastPos = pos;
@ -397,7 +397,7 @@ namespace MWMechanics
if(mReadyToAttack) isStuck = false; if(mReadyToAttack) isStuck = false;
// check if shortcut is available // check if shortcut is available
if(!isStuck if(!isStuck
&& (!mForceNoShortcut && (!mForceNoShortcut
|| (Ogre::Vector3(mShortcutFailPos.pos) - vActorPos).length() >= PATHFIND_SHORTCUT_RETRY_DIST) || (Ogre::Vector3(mShortcutFailPos.pos) - vActorPos).length() >= PATHFIND_SHORTCUT_RETRY_DIST)
&& inLOS) && inLOS)
@ -454,7 +454,7 @@ namespace MWMechanics
{ {
if(!mPathFinder.getPath().empty()) if(!mPathFinder.getPath().empty())
mMovement.mRotation[2] = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]); mMovement.mRotation[2] = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]);
else else
mMovement.mRotation[2] = getZAngleToDir(vDirToTarget, distToTarget); mMovement.mRotation[2] = getZAngleToDir(vDirToTarget, distToTarget);
} }
} }
@ -497,12 +497,12 @@ namespace MWMechanics
// coded at 250ms or 1/4 second // coded at 250ms or 1/4 second
// //
// TODO: Add a parameter to vary DURATION_SAME_SPOT? // TODO: Add a parameter to vary DURATION_SAME_SPOT?
MWWorld::CellStore *cell = actor.getCell();
if((distToTarget > rangeAttack || mFollowTarget) && if((distToTarget > rangeAttack || mFollowTarget) &&
mObstacleCheck.check(actor, tReaction)) // check if evasive action needed mObstacleCheck.check(actor, tReaction)) // check if evasive action needed
{ {
// first check if we're walking into a door // first check if we're walking into a door
mDoorCheckDuration += 1.0f; // add time taken for obstacle check mDoorCheckDuration += 1.0f; // add time taken for obstacle check
MWWorld::CellStore *cell = actor.getCell();
if(mDoorCheckDuration >= DOOR_CHECK_INTERVAL && !cell->getCell()->isExterior()) if(mDoorCheckDuration >= DOOR_CHECK_INTERVAL && !cell->getCell()->isExterior())
{ {
mDoorCheckDuration = 0; mDoorCheckDuration = 0;
@ -542,28 +542,26 @@ namespace MWMechanics
} }
} }
MWWorld::LiveCellRef<ESM::Door>& ref = *mDoorIter; if(!cell->getCell()->isExterior() && !mDoors.mList.empty())
float minSqr = 1.6 * 1.6 * MIN_DIST_TO_DOOR_SQUARED; // for legibility
// TODO: add reaction to checking open doors
if(mBackOffDoor &&
vActorPos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)) < minSqr)
{ {
mMovement.mPosition[1] = -0.2; // back off, but slowly MWWorld::LiveCellRef<ESM::Door>& ref = *mDoorIter;
float minSqr = 1.6 * 1.6 * MIN_DIST_TO_DOOR_SQUARED; // for legibility
// TODO: add reaction to checking open doors
if(mBackOffDoor &&
vActorPos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)) < minSqr)
{
mMovement.mPosition[1] = -0.2; // back off, but slowly
}
else if(mBackOffDoor &&
mDoorIter != mDoors.mList.end() &&
ref.mData.getLocalRotation().rot[2] >= 1)
{
mDoorIter = mDoors.mList.end();
mBackOffDoor = false;
//std::cout<<"open door id \""<<ref.mRef.mRefID<<"\""<<std::endl;
mMovement.mPosition[1] = 1;
}
} }
else if(mBackOffDoor &&
mDoorIter != mDoors.mList.end() &&
ref.mData.getLocalRotation().rot[2] >= 1)
{
mDoorIter = mDoors.mList.end();
mBackOffDoor = false;
//std::cout<<"open door id \""<<ref.mRef.mRefID<<"\""<<std::endl;
mMovement.mPosition[1] = 1;
}
// these lines break ranged combat distance keeping
//else
//{
// mMovement.mPosition[1] = 1; // FIXME: oscillation?
//}
return false; return false;
} }
@ -573,7 +571,7 @@ namespace MWMechanics
Ogre::Vector3 newPathTarget = Ogre::Vector3(mTarget.getRefData().getPosition().pos); Ogre::Vector3 newPathTarget = Ogre::Vector3(mTarget.getRefData().getPosition().pos);
float dist; float dist;
if(!mPathFinder.getPath().empty()) if(!mPathFinder.getPath().empty())
{ {
ESM::Pathgrid::Point lastPt = mPathFinder.getPath().back(); ESM::Pathgrid::Point lastPt = mPathFinder.getPath().back();