Skip to content

Commit

Permalink
Fix getting exit parameters from hyperjump
Browse files Browse the repository at this point in the history
The GetBodyForPath function was called (from GetHyperspaceExitParams)
before Game::m_state = State::NORMAL was set, so it returned nullptr.
Therefore, the first non-gravpoint body was always set as the base body
for exit.
This led to the fact that in the multiple system the star "A" was always
chosen, regardless of the player's choice in the sector map.
  • Loading branch information
Gliese852 authored and Webster Sheets committed Feb 1, 2022
1 parent c5b522d commit 26d75cc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ void Game::SwitchToNormalSpace()
// create a new space for the system
m_space.reset(); // HACK: Here because next line will create Frames *before* deleting existing ones
m_space.reset(new Space(this, m_galaxy, m_hyperspaceDest, m_space.get()));
m_state = State::NORMAL;

// put the player in it
m_player->SetFrame(m_space->GetRootFrame());
Expand Down Expand Up @@ -615,8 +616,6 @@ void Game::SwitchToNormalSpace()
// HACK: we call RebuildObjectTrees to make the internal state of CollisionSpace valid
// This is absolutely not our job and CollisionSpace should be redesigned to fix this.
Frame::GetFrame(m_player->GetFrame())->GetCollisionSpace()->RebuildObjectTrees();

m_state = State::NORMAL;
}

const float Game::s_timeAccelRates[] = {
Expand Down

0 comments on commit 26d75cc

Please sign in to comment.