the-infocom-files / seastalker

Seastalker
3 stars 3 forks source link

Bug in DEPTH-CONTROL-F when comparing your desired depth to the current depth in the endgame #75

Open eriktorbjorn opened 4 years ago

eriktorbjorn commented 4 years ago

This can happen once you encounter Thorpe and the Snark at the end of the game:

>EXAMINE DEPTH FINDER
You're now at a depth of 145 meters, 5 meters above the bottom of the sea.

>SET DEPTH CONTROL TO 30 METERS
The SCIMITAR noses upward. You're now rising at a speed of 5 meters per sea
square.

>SET DEPTH CONTROL TO 25 METERS
If you go above the Snark, Thorpe will shoot you!

The Snark is big, all right, but that big? I don't think so. The problem is probably this in DEPTH-CONTROL-F:

          (<AND ,SUB-IN-BATTLE  ;<NOT <FSET? ,THORPE-SUB ,INVISIBLE>>
            <G? ,SUB-DEPTH .DEP>>
           <TELL
"If you go above the Snark, Thorpe will shoot you!" CR>

At this point, .DEP is ,P-NUMBER, which is probably the desired depth in meters. But the submarine's depth in meters is <* 5 ,SUB-DEPTH>, so SUB-DEPTH is probably 29, i.e. the same as AIRLOCK-DEPTH.

Actually, as I was writing the bug report I realized that the game doesn't just allow you to specify depth in meters, you can also specify it in "sea squares":

>SET DEPTH TO 29 SEA SQUARES
You are already at that depth!

>SET DEPTH TO 28 SEA SQUARES
If you go above the Snark, Thorpe will shoot you!

So the check is correct if you use sea squares, but not if you use meters. I guess the test has to be moved to after that conversion is done, but before actually setting TARGET-DEPTH, i.e. in here somewhere:

          (<IOBJ? METER>
           <SET DEP </ <+ 2 .DEP> 5>>
           <COND (<NOT <==? ,P-NUMBER <* 5 .DEP>>>
              <TELL
"(That rounds off to " N <* 5 .DEP> " meters.)" CR>)>)>
    <SETG TARGET-DEPTH .DEP>

This is unlikely to actually affect players, because the game turns off the depth finder for you (you have to turn it on again to use the depth control), and gives you no reason to to change depth once you're in battle.