Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor summoned creature cleanup fixes #2594

Merged
merged 2 commits into from
Nov 17, 2019

Conversation

Capostrophic
Copy link
Collaborator

  1. Summoned creatures of summoned creatures that recently became possible weren't properly cleared. I added a workaround for that.
  2. I ignored my own good advice and forgot again that I should test the vanilla deaths using the normal damage instead of SetHealth 0. Summoned creatures are still supposed to be removed after the caster's death animation according to my testing. Also this fixes the issue where the despawn VFX are played twice (upon the summoned creature despawn and upon the caster's death animation end) in some situations.
  3. If a summoned creature's despawn is postponed, it didn't trigger the linked spell effects removal from other actors like a normal cleanupSummonedCreature call. But the main purpose of the workaround I've added is to make sure all summoned creatures are removed even if said removal is postponed. There's a plan to expand on that, hm, later, as summoned creature mechanics are not exactly consistent yet.

@akortunov
Copy link
Collaborator

Summoned creatures are still supposed to be removed after the caster's death animation according to my testing.

What about the "safe corpse disposal"? We should remove actor's summons even if death animation was not finished yet.

@akortunov
Copy link
Collaborator

akortunov commented Nov 13, 2019

Basically, seems to work well, but there is in another case in Morrowind when it de-spawns summoned creatures - when the target becomes out of active cell grid for some reason (e.g. it is teleported to inactive cell or just disabled via console).

A suggested approach - cleanup summons in the Actors::removeActor(). At least, it seems to work in this way in the Morrowind. In this case some of your special handling may be not needed.

Something like that:

    // Note: addActor() still should use an old implementation of removeActor()
    void Actors::removeActor (const MWWorld::Ptr& ptr)
    {
        PtrActorMap::iterator iter = mActors.find(ptr);
        if(iter != mActors.end())
        {
            delete iter->second;
            mActors.erase(iter);

            // Recursive summons cleanup
            MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
            std::map<CreatureStats::SummonKey, int>& creatureMap = stats.getSummonedCreatureMap();
            for (const auto& creature : creatureMap)
                cleanupSummonedCreature(stats, creature.second);
            creatureMap.clear();
        }
    }

We should just make sure that the Scene::removeObjectFromScene is not called in loop (but in this case we already would have invalid iterators, though).

Also I do not like that the cleanupSummonedCreature() is called during actors update. It may invalidate iterators as well. Maybe we should introduce a some kind of mToDelete set in Actors, and remove actors from this vector after actors update (even in UI mode).

If you are not going to work on it in this PR, just fill a bugreport.

@Capostrophic
Copy link
Collaborator Author

As I hinted in the first post, I don't plan to work on that here.

Maybe we should introduce a some kind of mToDelete set in Actors, and remove actors from this vector after actors update

That was my idea too. But it's general design issue that doesn't concern summoning specifically.

@akortunov
Copy link
Collaborator

I created a related bugreport to finish the work later.

@akortunov akortunov merged commit 6554130 into OpenMW:master Nov 17, 2019
@Capostrophic Capostrophic deleted the summonsummon branch November 17, 2019 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants