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

Keep an AiWanderStorage when cloning an actor (bug #5267)

This commit is contained in:
Andrei Kortunov 2020-03-10 10:28:23 +04:00
parent d9f147272c
commit 9f27a0d095
2 changed files with 12 additions and 0 deletions

View file

@ -28,6 +28,10 @@ void AiSequence::copy (const AiSequence& sequence)
for (std::list<AiPackage *>::const_iterator iter (sequence.mPackages.begin());
iter!=sequence.mPackages.end(); ++iter)
mPackages.push_back ((*iter)->clone());
// We need to keep an AiWander storage, if present - it has a state machine.
// Not sure about another temporary storages
sequence.mAiState.copy<AiWanderStorage>(mAiState);
}
AiSequence::AiSequence() : mDone (false), mRepeat(false), mLastAiPackage(-1) {}

View file

@ -38,6 +38,14 @@ namespace MWMechanics
//return a reference to the (new allocated) object
return *result;
}
template< class Derived >
void copy(DerivedClassStorage& destination) const
{
Derived* result = dynamic_cast<Derived*>(mStorage);
if (result != nullptr)
destination.store<Derived>(*result);
}
template< class Derived >
void store( const Derived& payload )