[comp.sources.games.bugs] Spacewar Gngngngnnnn!!!

kus3@sphinx.uchicago.edu (Bob Kusumoto) (06/10/88)

In article <3461@enea.se> pesv@enea.se (Peter Svenson) writes:
>First off it took some time until I understood that it was the program with
>the obvious name "rsw" and not "sw" that was supposed to start the game.
>When running this program it prompts me for my name and then just sits there.
>My educated guess is that the author has mixed up some tty modes. My guessing
>isn't educated anough to guess which, though. Then the program resolutely
>refuses to see my -DDEBUG in the Makefile. 

edit psw.sh and run this program (I'm not too sure but you might need to 
setuid on this program as well.

-- 
	Bob Kusumoto                         |           Follow me!
Internet: kus3@sphinx.uchicago.edu           | I'll play the game you want me,
BITNET:   kus3@sphinx.uchicago.bitnet        |  Until I find a way back home.
UUCP:    {ihnp4!gargoyle,oddjob}!sphinx!kus3 | --- Genesis, "One for the Vine"

allbery@ncoast.UUCP (Brandon S. Allbery) (06/18/88)

As quoted from <4362@sphinx.uchicago.edu> by kus3@sphinx.uchicago.edu (Bob Kusumoto):
+---------------
| In article <3461@enea.se> pesv@enea.se (Peter Svenson) writes:
| >First off it took some time until I understood that it was the program with
| >the obvious name "rsw" and not "sw" that was supposed to start the game.
+---------------

Nope.  "psw", run by "psw.sh", starts the program.  "rsw" is run by the
daemon to communicate with the user.

+---------------
| >isn't educated anough to guess which, though. Then the program resolutely
| >refuses to see my -DDEBUG in the Makefile. 
+---------------

To use debug mode you must start the server manually:

		/usr/games/lib/sw/sw <debuglevel> &

where <debuglevel> is a number.  I used 127 and got fairly complete
diagnostic information.

+---------------
| edit psw.sh and run this program (I'm not too sure but you might need to 
| setuid on this program as well.
+---------------

The programs must all be setuid.  Note that you need all of the following:

		dmpdbm	psw	rsw	sw	upddbm

psw is the user runtime, sw is the daemon, rsw does terminal reads and
passes them to sw, and dmpdbm and upddbm are used with the ship-building
code.

All that notwithstanding, I still can't get it to stop doing constant screen
redraws.
-- 
Brandon S. Allbery			  | "Given its constituency, the only
uunet!marque,sun!mandrill}!ncoast!allbery | thing I expect to be "open" about
Delphi: ALLBERY	       MCI Mail: BALLBERY | [the Open Software Foundation] is
comp.sources.misc: ncoast!sources-misc    | its mouth."  --John Gilmore

bob@turnkey.TCC.COM (Robert Best) (06/21/88)

Spacewar patch for Xenix 386 (286?)
from Bob Best (bob@dhw68k.cts.com)

The following patches can be used as input to Larry Wall's patch program
to revise the following files:
	update.c
	cmd.c
	play.c
All patches involve manipulation of alarm(2) system calls that were causing
spacewar to fail during execution.  Since these patches are timing related,
no guaranty can be made regarding their success on varying systems.  These
patches have only been tested on Xenix 386 2.2.2.

To generate the patches, enter 'patch <patchfile' at shell prompt, where
this file is 'patchfile'.  This must be done from directory containing source.
Next, run 'make', install binaries in directory specified in spacewar.h and
then, hopefully, type 'psw.sh' and TAKE OFF!

*** /usr/tmp/sw/org/update.c
--- update.c
**************
*** 4,10
   * Copyright 1985 obo Systems, Inc.
   * Copyright 1985 Dan Rosenblatt
   */
- 
  #include "spacewar.h"
  #ifndef VMS
  #include <sys/types.h>
--- 4,9 -----
   * Copyright 1985 obo Systems, Inc.
   * Copyright 1985 Dan Rosenblatt
   */
  #include "spacewar.h"
  #ifndef VMS
  #include <sys/types.h>
**************
*** 30,35
  	char *s,*lckmsg();
  	extern int numpling;
  
  #ifdef DEBUG
  	DBG("update()\n");
  #endif
--- 29,35 -----
  	char *s,*lckmsg();
  	extern int numpling;
  
+ 	alarm(0);/*RSB - alarm off during update*/
  #ifdef DEBUG
  	DBG("update()\n");
  #endif
**************
*** 60,65
  	    }
  	}
  
  	/* movement of objects */
  	updobjs();
  	updmov();
--- 60,66 -----
  	    }
  	}
  
+ 	if (gametime%10L == 0) { /*RSB - do update on every 10th call*/
  	/* movement of objects */
  	updobjs();
  	updmov();
**************
*** 76,82
  
  	/* direction, sensors, homing */
  	upddsh();
! 
  	/* player's screens */
  	for (plogin=loginlst;plogin < loginlst+MAXLOGIN;++plogin) {
  	    if (!plogin->ln_tty || !(puniv=plogin->ln_play.ip_ptr)) continue;
--- 77,83 -----
  
  	/* direction, sensors, homing */
  	upddsh();
! 	}
  	/* player's screens */
  	for (plogin=loginlst;plogin < loginlst+MAXLOGIN;++plogin) {
  	    if (!plogin->ln_tty || !(puniv=plogin->ln_play.ip_ptr)) continue;
**************
*** 85,91
  	    output(plogin,0,0,0);
  	    pcrft->cr_time += 1;
  	}
- 
  #ifdef DEBUG
  	VDBG("update return\n");
  #endif
--- 86,91 -----
  	    output(plogin,0,0,0);
  	    pcrft->cr_time += 1;
  	}
  #ifdef DEBUG
  	VDBG("update return\n");
  #endif
**************
*** 89,92
  #ifdef DEBUG
  	VDBG("update return\n");
  #endif
  }
--- 89,93 -----
  #ifdef DEBUG
  	VDBG("update return\n");
  #endif
+         alarm(1);/*RSB - alarm on*/
  }

*** /usr/tmp/sw/org/cmd.c
--- cmd.c
**************
*** 357,363
  	struct uio2 inp2;
  #endif /* VMS */
  #endif /* BSD */
- 
  #ifdef DEBUG
  	DBG("getinp()\n");
  #endif /* DEBUG */
--- 357,362 -----
  	struct uio2 inp2;
  #endif /* VMS */
  #endif /* BSD */
  #ifdef DEBUG
  	DBG("getinp()\n");
  #endif /* DEBUG */
**************
*** 372,377
  #ifdef DEBUG
  			VDBG("getinp return\n");
  #endif
  			return(NULL);
  		}
  		doproctrap = 1;
--- 371,377 -----
  #ifdef DEBUG
  			VDBG("getinp return\n");
  #endif
+ 			alarm(1);/*RSB*/
  			return(NULL);
  		}
  		doproctrap = 1;
**************
*** 394,399
  			continue;
  		}
  #endif /* VMS BSD SYSIII SYSV */
  		doproctrap = 0;
  #ifdef DEBUG
  #ifndef BSD
--- 394,400 -----
  			continue;
  		}
  #endif /* VMS BSD SYSIII SYSV */
+ 		alarm(0);/*RSB*/
  		doproctrap = 0;
  #ifdef DEBUG
  #ifndef BSD
**************
*** 457,462
  #ifdef DEBUG
  			    VDBG("getinp return\n");
  #endif /* DEBUG */
  			    return(inp.uio_lgn);
  
  			case '\025':	/* control-U */
--- 458,464 -----
  #ifdef DEBUG
  			    VDBG("getinp return\n");
  #endif /* DEBUG */
+ 			alarm(1);/*RSB*/
  			    return(inp.uio_lgn);
  
  			case '\025':	/* control-U */
**************
*** 495,500
  #ifdef DEBUG
  			VDBG("getinp return\n");
  #endif /* DEBUG */
  			return(inp.uio_lgn);
  		    }
  
--- 497,503 -----
  #ifdef DEBUG
  			VDBG("getinp return\n");
  #endif /* DEBUG */
+ 			alarm(1);/*RSB*/
  			return(inp.uio_lgn);
  		    }
  

*** /usr/tmp/sw/org/play.c
--- play.c
**************
*** 58,63
  	char ucargs[9][20+1],inuc=0;
  	dsplcmnt tmpdspl;
  
  #ifdef DEBUG
  	DBG("play(#%d/%s)\n",plogin-loginlst,plogin->ln_name);
  #endif
--- 58,64 -----
  	char ucargs[9][20+1],inuc=0;
  	dsplcmnt tmpdspl;
  
+ 	alarm(0);/*RSB*/
  #ifdef DEBUG
  	DBG("play(#%d/%s)\n",plogin-loginlst,plogin->ln_name);
  #endif
**************
*** 65,70
  	/* if not yet placed into the universe, try doing so */
  	if (!plogin->ln_play.ip_ptr) {
  	    if (plinit(plogin)) {
  		pcrft = plogin->ln_play.ip_ptr->uv_ptr.uv_crft;
  		sprintf(plogin->ln_input,"Wlcm abrd the %s captain %s",
  		plogin->ln_crft,plogin->ln_name);
--- 66,72 -----
  	/* if not yet placed into the universe, try doing so */
  	if (!plogin->ln_play.ip_ptr) {
  	    if (plinit(plogin)) {
+                 alarm(0);/*RSB*/
  		pcrft = plogin->ln_play.ip_ptr->uv_ptr.uv_crft;
  		sprintf(plogin->ln_input,"Wlcm abrd the %s captain %s",
  		plogin->ln_crft,plogin->ln_name);
**************
*** 74,79
  #ifdef DEBUG
  	    VDBG("play return\n");
  #endif
  	    return;
  	}
  	pcrft = plogin->ln_play.ip_ptr->uv_ptr.uv_crft;
--- 76,82 -----
  #ifdef DEBUG
  	    VDBG("play return\n");
  #endif
+ 	    alarm(1);/*RSB*/
  	    return;
  	}
  	pcrft = plogin->ln_play.ip_ptr->uv_ptr.uv_crft;
**************
*** 527,532
  		    output(plogin,'E',0,0);
  		    output(plogin,'C',0,PROMPT);
  		    output(plogin,0,0,0);
  		    return;
  		}
  		sprintf(buf,"%.14s - not docked and BAD != 0",plogin->ln_input);
--- 530,536 -----
  		    output(plogin,'E',0,0);
  		    output(plogin,'C',0,PROMPT);
  		    output(plogin,0,0,0);
+ 		    alarm(1);/*RSB*/
  		    return;
  		}
  		sprintf(buf,"%.14s - not docked and BAD != 0",plogin->ln_input);
**************
*** 1149,1154
  #ifdef DEBUG
  	VDBG("play return\n");
  #endif
  	return;
  }
  
--- 1153,1159 -----
  #ifdef DEBUG
  	VDBG("play return\n");
  #endif
+ 	alarm(1);/*RSB*/
  	return;
  }