!-----------------------------------------------------------------------------
! .h file created from example program "scenery.inf" by Joe Mason, Sept. 9/95
!
! * N.B. - Include this file ("scenery1.h") after "parser.h" and "verblib.h",
!          and include "scenery2.h" after "grammar.h"
!
! Original program by Richard Barnett
! Modifications by Joe Mason :
!   - now searches entire scope for sceneDesc properties instead of just the
!     player's location
!-----------------------------------------------------------------------------



! Original header:

!-----------------------------------------------------------------------------
! Scenery non-objects, providing a middle ground between the bare existence
! of a word you can type and receive a "That's not important" message, and
! the trouble of creating a separate scenery object whose only interesting
! feature is that is has a description.
!
! See http://www.cl.cam.ac.uk/users/gdr11/inform/scenery.html for a
! discussion of this code.
!
! Richard Barnett, 18/1/95
!-----------------------------------------------------------------------------

!---------------------------------------!
!     SceneDesc Scenery Non-Objects     !
!---------------------------------------!

Global specWord;

Property sceneDesc NULL;

[ GetScDescAddr loc spWord addr len i j;
    addr = loc.&sceneDesc;
    len = loc.#sceneDesc / 2;
    if (addr-->0 == NULL)
        return 0;
    for (i = 0 : i < len : i = i + addr-->i + 2)
        for (j = i + 1 : j < i + addr-->i + 1: j++)
           if (spWord == addr-->j)
               return addr-->(i + addr-->i + 1);
    return 0;
];

[ AnyWord w;
    w = NextWord();
    if (w ~= -1) {
        specWord = w;
        return 0;
    }
    return -1;
];

[ SceneDescSub addr x;
  ! Scans all objects in scope looking for sceneDesc properties
  ! Modified by Joe Mason
     addr = GetScDescAddr(location, specWord);
     if (addr == 0) {
       objectloop (x near player) {
         addr = GetScDescAddr(x, specWord);
         if (addr ~= 0) {
           print_paddr addr;
           new_line;
           return 0;
         };
       };
       if ((location has visited) && Refers(location, specWord)==1)
         "That's not something you need to refer to in the course of this 
game.";
       "You can't see that.";
     };
     print_paddr addr;
     new_line;
     return 0;
];

[ ParserError eType x;
  ! Scans all objects in scope looking for sceneDesc properties
  ! Modified by Joe Mason
    if (eType == CANTSEE_PE)
      if (GetScDescAddr(location, specWord) ~= 0)
        "That's just scenery.";
      objectloop (x near player)
        if (GetScDescAddr(x, specWord) ~= 0)
          "That's just scenery.";
    return 0;
];
