1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 12:53:51 +00:00

Merge pull request #2718 from akortunov/storage

Keep an AiWanderStorage when cloning an actor
This commit is contained in:
Roman Siromakha 2020-03-11 18:54:22 +01:00 committed by GitHub
commit b1ed7a433e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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()); for (std::list<AiPackage *>::const_iterator iter (sequence.mPackages.begin());
iter!=sequence.mPackages.end(); ++iter) iter!=sequence.mPackages.end(); ++iter)
mPackages.push_back ((*iter)->clone()); 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) {} AiSequence::AiSequence() : mDone (false), mRepeat(false), mLastAiPackage(-1) {}

View file

@ -39,6 +39,14 @@ namespace MWMechanics
return *result; 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 > template< class Derived >
void store( const Derived& payload ) void store( const Derived& payload )
{ {