[comp.sources.games.bugs] omega woes

maw@auc.UUCP (Michael A. Walker) (02/02/88)

I have just compiled omega on an AT&T 3b15 running SYS V Rel
2.1.2 of UNIX.  When I tried to play the game, the screen was
filled with CTRL-? in inverse print.  It occurs after the message
of the day screen is displayed.

Please help.
-- 
 _ _ _		 -^-  Michael A. Walker             |^|  ---------------------
' ) ) )   /	 |^|  Systems Programmer/Analyst    -^-  "There is strength in
 / / / o /_  _	 -^-  AUC Computer Center           |^|   diversity."
/ ' (_<_/ <_</_  |^|  UUCP: gatech!gt-cmmsr!auc!maw -^-  ---------------------

meissner@xyzzy.UUCP (Usenet Administration) (02/03/88)

In article <32172@auc.UUCP> maw@auc.UUCP writes:

| I have just compiled omega on an AT&T 3b15 running SYS V Rel
| 2.1.2 of UNIX.  When I tried to play the game, the screen was
| filled with CTRL-? in inverse print.  It occurs after the message
| of the day screen is displayed.

This is a common C portability bug.  The problem is ofile.c uses a char
variable to receive the value getc returns, and tests it against EOF.  On
a machine where char's are unsigned, this will never end the loop.  If
you change line 109 to be an int declaration instead of char it will work.
I also changed the call of printw to print a single character to use the
faster addch.  If you have patch, you can feed this article to patch to
change the file.


*** ofile.c.old	Wed Feb  3 09:41:33 1988
--- ofile.c	Sat Jan 23 22:18:12 1988
***************
*** 106,112
  void showfile(fd)
  FILE *fd;
  {
!   char c,d=' ';
    int x,y;
    clear();
    refresh();

--- 106,112 -----
  void showfile(fd)
  FILE *fd;
  {
!   int c,d=' ';
    int x,y;
    clear();
    refresh();
***************
*** 110,116
    int x,y;
    clear();
    refresh();
!   c = fgetc(fd);
    while ((c != EOF)&&(d != 'q')&&(d!=ESCAPE)) {
      getyx(stdscr,y,x);
      if (y > 20) {

--- 110,116 -----
    int x,y;
    clear();
    refresh();
!   c = getc(fd);
    while ((c != EOF)&&(d != 'q')&&(d!=ESCAPE)) {
      getyx(stdscr,y,x);
      if (y > 20) {
***************
*** 119,126
        d = wgetch(stdscr);
        clear();
      }
!     printw("%c",c);
!     c = fgetc(fd);
    }
    if ((d != 'q')&&(d!=ESCAPE)) {
      printw("\n-Done-");

--- 119,126 -----
        d = wgetch(stdscr);
        clear();
      }
!     addch(c);
!     c = getc(fd);
    }
    if ((d != 'q')&&(d!=ESCAPE)) {
      printw("\n-Done-");

-- 
Michael Meissner, Data General.		Uucp: ...!mcnc!rti!xyzzy!meissner
					Arpa/Csnet:  meissner@dg-rtp.DG.COM