Skip to content

Commit

Permalink
🐛 Fixed crash when unloading Train Valley
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Jan 3, 2025
1 parent a8fce37 commit 4adcd90
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions source/main/physics/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,7 @@ void Actor::AddInterActorBeam(beam_t* beam, ActorPtr other, ActorLinkingRequestT
void Actor::RemoveInterActorBeam(beam_t* beam, ActorLinkingRequestType type)
{
ROR_ASSERT(beam->bm_locked_actor);
ROR_ASSERT(beam->bm_locked_actor->ar_state != ActorState::DISPOSED);
ActorPtr other = beam->bm_locked_actor;
beam->bm_locked_actor = nullptr;

Expand All @@ -3315,17 +3316,22 @@ void Actor::RemoveInterActorBeam(beam_t* beam, ActorLinkingRequestType type)
for (ActorPtr& actor : this->ar_linked_actors)
actor->DetermineLinkedActors();

other->DetermineLinkedActors();
for (ActorPtr& actor : other->ar_linked_actors)
actor->DetermineLinkedActors();

// Reset toggled states.
other->ar_physics_paused = false;
other->GetGfxActor()->SetDebugView(DebugViewType::DEBUGVIEW_NONE);
for (ActorPtr& actor : other->ar_linked_actors)
// This should never fail (a disposing actor should disconnect everything first)
// but there seems to be a bug at the moment.
if (other->ar_state != ActorState::DISPOSED)
{
actor->ar_physics_paused = false;
actor->GetGfxActor()->SetDebugView(DebugViewType::DEBUGVIEW_NONE);
other->DetermineLinkedActors();
for (ActorPtr& actor : other->ar_linked_actors)
actor->DetermineLinkedActors();

// Reset toggled states.
other->ar_physics_paused = false;
other->GetGfxActor()->SetDebugView(DebugViewType::DEBUGVIEW_NONE);
for (ActorPtr& actor : other->ar_linked_actors)
{
actor->ar_physics_paused = false;
actor->GetGfxActor()->SetDebugView(DebugViewType::DEBUGVIEW_NONE);
}
}

// Let scripts know.
Expand Down

0 comments on commit 4adcd90

Please sign in to comment.