Continued from the previous entry
Sorry, no pictures for this one!
With the previous patch for equality when checking if an actor was in a sector, I thought the work was completed. Unfortunately, it was pointed out that in the original engine for Grim Fandango, the sector check is done using strstr to check the sector name by substring. Also, with some help from the #ResidualVM IRC channel, I found out that ResidualVM originally DID use equality, but it was changed to a substring check due to a bug in GRIM. Uh oh!
First, I took a look at the problematic scenes in EMI and GRIM to figure out why this bug is happening exactly. Next, the source for EMI needed to be checked to see what its behavior was when running the Lua command IsActorInSector, which is where the broken behavior was. And finally, I needed to resolve the issue for both games.
In the sets themselves, I identified the original problem as returning the incorrect sector when picking the sector by name, with pph_close and pph_closer as the example of two colliding sectors. So, out of curiosity, how often does this happen in EMI? As it turns out, really often! There's cases where different sectors even have the same name! How did I find this? I started by first converting the binary set information to text:
Sorry, no pictures for this one!
With the previous patch for equality when checking if an actor was in a sector, I thought the work was completed. Unfortunately, it was pointed out that in the original engine for Grim Fandango, the sector check is done using strstr to check the sector name by substring. Also, with some help from the #ResidualVM IRC channel, I found out that ResidualVM originally DID use equality, but it was changed to a substring check due to a bug in GRIM. Uh oh!
First, I took a look at the problematic scenes in EMI and GRIM to figure out why this bug is happening exactly. Next, the source for EMI needed to be checked to see what its behavior was when running the Lua command IsActorInSector, which is where the broken behavior was. And finally, I needed to resolve the issue for both games.
In the sets themselves, I identified the original problem as returning the incorrect sector when picking the sector by name, with pph_close and pph_closer as the example of two colliding sectors. So, out of curiosity, how often does this happen in EMI? As it turns out, really often! There's cases where different sectors even have the same name! How did I find this? I started by first converting the binary set information to text:
- mkdir artAll
- cd artAll
- unlab ../artAll.m4b
- mkdir Sets
- cd Sets
- for i in *.setb; do n=$(basename $i | cut -f1 -d.); setb2set $i > $n.set; done
- grep sector *.set | grep -v section: | grep -v numsectors > ../sectorlist && mv ../sectorlist .
- GRIM (3142 total sectors):
- None of the sectors have duplicate names
- 605 of the sectors are substrings of another (including duplicates)
- EMI (2228 total sectors):
- 140 of the sectors have duplicate names
- 506 of the sectors are substrings of another (including duplicates)
- GRIM (384 total setups):
- 1 of the setups has duplicate names
- 2 of the setups are substrings of another (including duplicates)
- EMI (326 total setups):
- 0 of the setups have duplicate names
- 28 of the setups are substrings of another (including duplicates)
- GRIM (210 total camera sectors)
- 0 of the camera sectors are substrings
- EMI (182 total camera sectors)
- 73 of the camera sectors are substrings
So, I've identified that there's really quite a bit of overlap, but not much in GRIM when it comes to camera sectors, while there are a lot of overlaps in EMI's camera sectors which is causing this bug. However, I've shown that the only scene in EMI that this effects is the set pph.
In the next post, I'll discuss the original binaries and the solution to this problem, this post is getting long enough!
No comments:
Post a Comment