Bug Fix for GF Early Year 3

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
User avatar
Olliebrown
Posts: 9
Joined: Sat Mar 31, 2012 10:19 pm

Bug Fix for GF Early Year 3

Post by Olliebrown »

Was playing through GF with my own compiled version of the code that was built maybe a week ago (so it's not quite the latest dev trunk). I got to the part with the octopus and the perl and had a seg fault. It was very repeatable, like clockwork just after Manny's dialog "I don't like the way he's looking at us".

So, wanting to move on in the game, I recompiled with debug symbols and ran it in GDB to try and find the source of the seg fault. Turns out it was pretty easy to find. There's a bit in Head::lookAt() where it tries to grab the orientation matrix for the parent of joint3Node but it never checks to make sure the parent exists. I'm sure in a perfect would it always would but in this case it was NULL. It tries to memcopy out this member of a null object and boom, seg fault.

I added a check that will use a fresh matrix (presumably identity) if the parent is NULL. Here's the diff for head.cpp that does the trick (just a one-line change). This fixed the crash for me. Just thought I'd offer this up as a possible bug fix.

Ollie

Code: Select all

diff --git a/engines/grim/costume/head.cpp b/engines/grim/costume/head.cpp
index fae1fbb..122ac82 100644
--- a/engines/grim/costume/head.cpp
+++ b/engines/grim/costume/head.cpp
@@ -105,7 +105,7 @@ void Head::lookAt(bool entering, const Math::Vector3d &point, float rate, const
                // the orientation in parent space (as yaw/pitch/roll).
                
                // Get the coordinate frame in which we need to produce the character head yaw/pitch/roll values.
-               Math::Matrix4 parentWorldTM = _joint3Node->_parent->_matrix;
+        Math::Matrix4 parentWorldTM = (_joint3Node->_parent?_joint3Node->_parent->_matrix:Math::Matrix4());
                
                // While we could compute the desired lookat direction directly in the above coordinate frame,
                // it is preferrable to compute the lookat direction with respect to the head orientation in
User avatar
Olliebrown
Posts: 9
Joined: Sat Mar 31, 2012 10:19 pm

Post by Olliebrown »

Awww, nevermind. Just pulled the latest changes and it looks like this already got fixed a week ago. :oops:

Ollie
Post Reply