Fix use of uninitialized memory in AiWander::init

deque
scrawl 11 years ago
parent 061c7813f6
commit 1bb82c710c

@ -35,6 +35,8 @@ namespace MWMechanics
void AiWander::init()
{
// NOTE: mDistance and mDuration must be set already
mCellX = std::numeric_limits<int>::max();
mCellY = std::numeric_limits<int>::max();
mXCell = 0;
@ -47,7 +49,7 @@ namespace MWMechanics
mRotate = false;
mTargetAngle = 0;
mSaidGreeting = Greet_None;
greetingTimer = 0;
mGreetingTimer = 0;
mHasReturnPosition = false;
mReturnPosition = Ogre::Vector3(0,0,0);
@ -430,19 +432,19 @@ namespace MWMechanics
{
if ((playerDistSqr <= helloDistance*helloDistance) && MWBase::Environment::get().getWorld()->getLOS(player, actor)
&& MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, actor))
greetingTimer++;
mGreetingTimer++;
if (greetingTimer >= GREETING_SHOULD_START)
if (mGreetingTimer >= GREETING_SHOULD_START)
{
mSaidGreeting = Greet_InProgress;
MWBase::Environment::get().getDialogueManager()->say(actor, "hello");
greetingTimer = 0;
mGreetingTimer = 0;
}
}
if(mSaidGreeting == Greet_InProgress)
{
greetingTimer++;
mGreetingTimer++;
if(mWalking)
{
@ -470,10 +472,10 @@ namespace MWMechanics
}
}
if (greetingTimer >= GREETING_SHOULD_END)
if (mGreetingTimer >= GREETING_SHOULD_END)
{
mSaidGreeting = Greet_Done;
greetingTimer = 0;
mGreetingTimer = 0;
}
}
@ -680,8 +682,6 @@ namespace MWMechanics
AiWander::AiWander (const ESM::AiSequence::AiWander* wander)
{
init();
mDistance = wander->mData.mDistance;
mDuration = wander->mData.mDuration;
mStartTime = MWWorld::TimeStamp(wander->mStartTime);
@ -690,6 +690,8 @@ namespace MWMechanics
mIdle.push_back(wander->mData.mIdle[i]);
mRepeat = wander->mData.mShouldRepeat;
init();
}
}

@ -36,6 +36,7 @@ namespace MWMechanics
AiWander (const ESM::AiSequence::AiWander* wander);
// NOTE: mDistance and mDuration must be set already
void init();
virtual AiPackage *clone() const;
@ -68,7 +69,7 @@ namespace MWMechanics
Greet_Done
};
GreetingState mSaidGreeting;
int greetingTimer;
int mGreetingTimer;
bool mHasReturnPosition; // NOTE: Could be removed if mReturnPosition was initialized to actor position,
// if we had the actor in the AiWander constructor...

Loading…
Cancel
Save