the-infocom-files / zork1

Zork I: The Great Underground Empire
11 stars 3 forks source link

Odd behavior when printing objects on the ground from Up a Tree #28

Open eriktorbjorn opened 5 years ago

eriktorbjorn commented 5 years ago

When you are climbing the tree, objects on the ground are visible. Which is fine:

>LOOK
Up a Tree
You are about 10 feet above the ground nestled among some large branches. The
nearest branch above you is above your reach.
On the ground below you can see:  a jewel-encrusted egg, and a leaflet.
Beside you on the branch is a small bird's nest.

However, because of the way it's implemented in TREE-ROOM they're only visible if there are at least two objects on the ground:

     <COND (<EQUAL? .RARG ,M-LOOK>
        <TELL
"You are about 10 feet above the ground nestled among some large
branches. The nearest branch above you is above your reach." CR>
        <COND (<AND <SET F <FIRST? ,PATH>>
                <NEXT? .F>>
               <TELL "On the ground below you can see:  ">
               <PRINT-CONTENTS ,PATH>
               <TELL "." CR>)>)

The behavior seems to have remained unchanged since the very earliest releases of Zork I. In the MDL version it looked like this:

        <COND (<VERB? "LOOK">
               <TELL ,TREE-DESC>
               <COND (<G? <LENGTH <ROBJS .FORE3>> 1>
                      <TELL "On the ground below you can see:  " 0>
                      <REMOVE-OBJECT <SFIND-OBJ "FTREE">>
                      <MAPR <>
                            <FUNCTION (Y) 
                                    #DECL ((Y) <LIST [REST OBJECT]>)
                                    <PRINC "a ">
                                    <PRINC <ODESC2 <1 .Y>>>
                                    <COND (<G? <LENGTH .Y> 2> <PRINC ", ">)
                                          (<==? <LENGTH .Y> 2>
                                           <PRINC ", and ">)>>
                            <ROBJS .FORE3>>
                      <TELL ".">
                      <INSERT-OBJECT <SFIND-OBJ "FTREE"> .FORE3>)>)

This is what FORE3 and FTREE looked like:

<ROOM "FORE3"
       ,FORTREE
       ,FOREST
       <EXIT "UP" "TREE"  
             "NORTH" "FORE2" "EAST" "CLEAR" "SOUTH" "CLEAR" "WEST" "NHOUS">
       (<GET-OBJ "FTREE">)
       FOREST-ROOM
       <+ ,RLANDBIT ,RLIGHTBIT ,RNWALLBIT ,RSACREDBIT>
       (RGLOBAL <+ ,BIRDBIT ,HOUSEBIT>)>

<OBJECT ["FTREE" "TREE"]
        ["LARGE"]
        "large tree"
        <+ ,OVISON ,NDESCBIT ,CLIMBBIT>>

So, if I understand it correctly, in the mainframe version there was an object in FORE3. Therefore, the objects on the ground were only visible from above if there were at least two objects in FORE3, and FTREE was temporarily removed while the object list was printed.

In Zork I, the tree is a local global object, so it's not actually in PATH. Therefore, it should print the objects if there is at least one, not two.

I.e. it should be something like this:

     <COND (<EQUAL? .RARG ,M-LOOK>
        <TELL
"You are about 10 feet above the ground nestled among some large
branches. The nearest branch above you is above your reach." CR>
        <COND (<FIRST? ,PATH>
               <TELL "On the ground below you can see:  ">
               <PRINT-CONTENTS ,PATH>
               <TELL "." CR>)>)

The local variable F can then be removed.