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

No more crashes when hyperjumping #4907

Merged
merged 3 commits into from
Sep 9, 2020

Conversation

Gliese852
Copy link
Contributor

@Gliese852 Gliese852 commented Jul 6, 2020

Commits

Notify the camera when the ship changes the frame

Since the camera is not tied to the ship, but to the frame of the ship, when the frame changes, the information in the camera becomes irrelevant. If the worldview is active, it is quickly updated, but if the worldview is not active, an accident occurs.
This patch fixes a crash when hyper jumping with an open info screen.

Rename CameraContext vars to cameraContext (optional)

Many variables of type CameraContext are called camera, and this seems to be confusing because there is also a type Camera, and variables of this type, also called "camera" or something like that.

The problem with info screens was resolved in #4941

Fix crashes when hyperjump with a map opened

ezgif-2-f0135cd12af1
Fixes #4901

System map: add a check to see if we are in hyperspace

Sector map:

  • move the drawing of the player's indicator from DrawNearSector up to Draw3D
  • calculate the interpolated position of the player's indicator during a hyperjump
  • don't display current system during hyperjump (lua-side)
  • fix selected system indicator (green circle), it pointed not to the the selected system, but to the current system

Also:

  • add easing function into utils.cpp to smooth the movement of the player indicator
  • move fuel reduction from the start of the hyperjump to the end
  • force handling of lua events immediately after entering system

Indent hyperjump-planner.lua

TODO:

  • Fix crash in the system map.
  • Fix crash in the sector map.
  • Show player movement between systems in the sector map

@Gliese852
Copy link
Contributor Author

Apparently, this PR should wait for #4908 to merge.

@sturnclaw
Copy link
Member

Not necessarily, but I'd much prefer seeing: a) the frame-switching logic moved to ShipViewController instead of duplicating it in the (soon-to-be-deprecated) CameraController subclasses, and b) the logic related to reacting to a change in frames attached to the Player ship or, more efficiently, in the ShipViewController (a simple check once per frame to compare FrameIds is literally a single cycle, something we can well afford compared to adding 16+ bytes and an irrelevant signal handler call to every single ship's datum in the world.)

If we have another impending use-case for an onChangeFrame signal attached to all ship objects I stand corrected on the latter point, but I'd rather keep fixes like this well contained and work on removing methods and logic from the monolithic object hierarchy we have now.

@Gliese852
Copy link
Contributor Author

Gliese852 commented Jul 13, 2020

@Web-eWorks I touched the frames in this PR, because there was a crash in hyperspace, as a result of calling function Pi::game->GetWorldView()->BeginCameraFrame();. Since it will be deleted in #4908, existing commits (and signals) will most likely not be needed.

@Gliese852 Gliese852 changed the title WIP: No more crashes when hyperjumping No more crashes when hyperjumping Sep 6, 2020
@Gliese852 Gliese852 marked this pull request as ready for review September 6, 2020 09:52
Fixes pioneerspacesim#4901

System map: add a check to see if we are in hyperspace

Sector map:
 - move the drawing of the player's indicator from DrawNearSector up to
Draw3D
 - calculate the interpolated position of the player's indicator during
a hyperjump
 - don't display current system during hyperjump (lua-side)
 - fix selected system indicator (green circle), it pointed not to
the the selected system, but to the current system

Also:
 - add easing function into utils.cpp to smooth the movement of the
player indicator
 - move fuel reduction from the start of the hyperjump to the end
 - force handling of lua events immediately after entering system
@sturnclaw sturnclaw merged commit ca6d23a into pioneerspacesim:master Sep 9, 2020
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.

Game crashes when hyper jumping while having any ship screen open
2 participants