Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue L61113     [previous patch]

Size of upper window not restored properly on UNDO
Submitted by: Magnus Olsson     Appeared in: Library 6/11 or before     Fixed in: -
Problem

Compile and run a trivial game with Nitfol. When the game begins, type WAIT and then UNDO. Nitfol displays the message [ERROR: output]: illegal line for set_cursor (1) 46968 (1,1) This happens in DrawStatusLine() and the reason is that the upper window has height 0, but the Library tries to position the cursor at (1,1).

DrawStatusLine() calls the routine StatusLineHeight() to ensure that the upper window is big enough. This routine contains an optimization to avoid unnecessary calls to split_window (all the following applies to v5 Z-code only):

  [ StatusLineHeight height;
      if (gg_statuswin_cursize ~= height) @split_window height;
      gg_statuswin_cursize = height;
  ];

The Library keeps track of the current size of the upper window in the global variable gg_statuswin_cursize. The problem is that after an UNDO, gg_statuswin_cursize will be restored to its previous value, in my case 1, but this will not reflect the actual size of the window, which Nitfol resets to zero. So when DrawStatusLine() calls StatusLineHeight(1), it just returns rather than doing a split_window.

Solution

Set gg_statuswin_cursize to -1 at the beginning of RestoreColours() (which is called after an UNDO):

  [ RestoreColours;
      gg_statuswin_cursize = -1;
      if (clr_on) { ! check colour has been used
          SetColour(clr_fg, clr_bg, 2); ! make sure both sets of variables are restored
          SetColour(clr_fgstatus, clr_bgstatus, 1, true);
          ClearScreen();
      }
      #Ifdef TARGET_ZCODE;
      #Iftrue (#version_number == 6); ! request screen update
      (0-->8) = (0-->8) | $$00000100;
      #Endif;
      #Endif;
  ];

This ensures that the next DrawStatusLine will in fact restore the status line.

As far as I can see, RestoreColours() is only called in two places: after an UNDO and after a RESTORE. This means that a) the fix only affects performance in those cases; the optimization in StatusLineHeight remains effective otherwise. b) any possible problems after a RESTORE should be taken care of by the same fix.


Last updated 17 April 2013. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.