Continued from the previous entry
In the previous entry, we found that the sector being selected for positioning the camera was incorrect in ResidualVM in the case of the set pph. Specifically, the setup pph_closer was incorrectly using the sector information for the setup pph_close. When the camera view is changed, the actor is asked for the CAMERA type sector the actor is in by calling the Lua engine function GetActorSector.
In GetActorSector, we get the actor’s world coordinates, then use the findPointSector method to get the current Sector, filtered by the desired sector type. This function simply iterates through the sectors in the set to find the one containing the actor’s coordinates. I tested with gdb and found that the correct sector was being identified. A bit puzzled, I went back to ResidualVM and ran the Lua script that updated the camera position:
- pph:force_camerachange()
This correctly put guybrush into the right setup and updated the camera. I tried again with the only caller for this code, which is called from TrackGuybrush:
- pph:cameraman()
I found that the camera wasn’t being updated when called this way, so I went through each of the variables that might prevent a camera update, ultimately finding that the IsActorInSector method was using the substring of the setup name to identify the setup. Unfortunately, this won’t work for the set pph because we have one setup that is a substring of the other: pph_close and pph_closer. Changing this check to an equality test fixes the issue, and Guybrush can now enter and leave the scene properly! The fix for this issue can be found in this PR.