Fix for glued cockpit#5631
Conversation
|
If there is now no codepath that calls |
|
Makes sense with a type-checking before casting. I will change this back to |
|
I have no intentions to further improve ShipCockpit.cpp. It is the last file in the codebase from the Paragon/Jumpdrive codebase (as indicated by the Meteoric Games copyright header), has many significant deficiencies/bugs, and is pending a complete replacement with a "clean-room" implementation of ship cockpit view that's being developed in my clickable cockpits branch. You are welcome to make any changes to it that you deem necessary to improve performance or reduce unnecessary computation - however given that it will be completely gone in 1-2 releases I'm not going to ask you to spend any further time on it if you don't want to. Were this another part of the code that isn't in "pending removal" state, I'd say go for it. 😄 |
Fixes issue when cockpit becomes "glued" on random occasions.
81951d4 to
a128b00
Compare
|
Changed |
|
Looks good! I'll test this in a few days in the same batch as your other PRs and (most likely) merge all three at once. |
|
@Max5377 Please let us know if you want to be in AUTHORS.txt (and what to put there). Also: good work with the bug fixes! |
|
@impaktor Yes, you can add me in AUTHORS.txt. I write later what to add here, need to think about it. You are welcome. |
Fixes #5621
This happened, because there was no check in this statement in
void ShipCockpit::Update(const Player *player, float timeStep):if (m_icc == nullptr),if current
CameraControlleris reallyInternalCameraController. Because of that, this statement ininline void ShipCockpit::resetInternalCameraController():m_icc = static_cast<InternalCameraController *>(Pi::game->GetWorldView()->shipView->GetCameraController());,would cast current
CameraControllerto invalid type if it was notInternalCameraController, which is undefined behaviour.Added check at the start of
Updateif current view is exterior to ensure that currentCameraControlleris reallyInternalCameraController.