[comp.sources.games.bugs] mpss, my changes

sin@myab.UUCP (sin) (08/04/88)

Here is most of the changes I have done to mpss. I send it out on the net
before they are finished since I may not have anny more time to work on them.
I have'nt used diff because I've run all sourses through cb (C beautifier)
somtime during the changes. You will have to cope with a cgrep of my comments
in the source ( ~ in a comment usaly means that I'm involved). Look at it and
use the changes if you think it help you.

I have fixed some signaling and i/o polling that did'nt work on sys V.
To use thees changes define USG ('CFLAGS = -DUSG' in the makefile).

There where some problems with short strings to sprintf so it overwrites
other variabels, I increased the size of the strings verry much ;-) but
at least it works.

Some more changes need to be done to let more than one person on the computer
play the game, it hangs if more than one tries. A slight bug there :-).

I have put in some aditional commands:

<space>    stop (same as s)
<esc>      cloak on ,sheeld on
5          change weappon (same as p)
^R, ^L     redraw screen (same as R)

Sorry if my english aint to perfect. 

			    / Olov Torstensson , sin@cd.chalmers.se

Here are the changes:

auto.c:displaybeams(cp)
auto.c:register struct player *cp;
auto.c:{
auto.c:	char str[70]; /*~*/
---------------------------------
consoleplots.c:plotenergy(cp)
consoleplots.c:register struct player *cp;
consoleplots.c:{
consoleplots.c:	char energy[50]; /*~*/
---------------------------------
consoleplots.c:plotbattleenergy(d)
consoleplots.c:struct player *d;
consoleplots.c:{
consoleplots.c:	char energy[50]; /*~*/
---------------------------------
consoleplots.c:plotmaxenergy(cp)
consoleplots.c:register struct player *cp;
consoleplots.c:{
consoleplots.c:	char energy[50]; /*~*/
---------------------------------
consoleplots.c:plotvelocity(cp)
consoleplots.c:register struct player *cp;
consoleplots.c:{
consoleplots.c:	char velocity[140]; /*~*/
---------------------------------
consoleplots.c:plotposition(cp)
consoleplots.c:register struct player *cp;
consoleplots.c:{
consoleplots.c:	char position[140]; /*~*/
---------------------------------
consoleplots.c:plotphaserbanks(cp)
consoleplots.c:register struct player *cp;
consoleplots.c:{
consoleplots.c:	char phaser[50]; /*~*/
---------------------------------
consoleplots.c:plotphotontorpedos(cp)
consoleplots.c:register struct player *cp;
consoleplots.c:{
consoleplots.c:	char photon[50]; /*~*/
---------------------------------
consoleplots.c:plotscore(cp)
consoleplots.c:register struct player *cp;
consoleplots.c:{
consoleplots.c:	char score[80]; /*~*/
---------------------------------
cross.c:	poscurs(cp,20,3);
cross.c:	write(cp->fd,
cross.c:    "y,u,b,n => WARP diagonal move. s,<space> => full stop    ", /*~*/
---------------------------------
cross.c:	poscurs(cp,20,6);
cross.c:	write(cp->fd,
cross.c:    " + => Quit, G => beep on/off, R,^R,^L => Redraw Screen ", /*~*/
cross.c:	    57);
cross.c:	poscurs(cp,20,7);
cross.c:	write(cp->fd,
cross.c:    "d,f => dock/undock, 12346789 => fire, 5,p => weapon sel.", /*~*/
---------------------------------
cross.c:	poscurs(cp,20,9);
cross.c:	write(cp->fd,
cross.c:    " c => cloaking on/off, v => shields on/off ,<esc> both on", /*~*/
---------------------------------
keyscan.c:register struct player *cp;
keyscan.c:long *ptrnoofchars;
keyscan.c:{
keyscan.c:#ifdef USG /*~*/
keyscan.c:	register int no; /*~*/
keyscan.c:	if((no = read(cp->fd,cp->buf,BUFSIZE)) < 1) /*~*/
keyscan.c:		return 0; /*~*/
keyscan.c:	cp->buftop=no; /*~*/
keyscan.c:	cp->bufptr=0; /*~*/
keyscan.c:#else /*~*/
keyscan.c:	if (*ptrnoofchars>0)
---------------------------------
keyscan.c:		cp->buftop=(int)(*ptrnoofchars);
keyscan.c:		cp->bufptr=0;
keyscan.c:	}
keyscan.c:#endif /*~*/
keyscan.c:	return 1; /*~*/
keyscan.c:}
---------------------------------
main.c:checkmasterpidfile()
main.c:{
main.c:	int rpid,masterpid;
main.c:	char string[55]; /*~*/
---------------------------------
main.c:	killcontrol();
main.c:	noofsignals=0;
main.c:	signal(SIGINT,SIG_IGN);
main.c:#ifdef USG /*~*/
main.c:	signal(SIGUSR1,handler); /*~*/
main.c:#else /*~*/
main.c:	signal(29,handler); /*~*/
main.c:#endif /*~*/
main.c:	signal(SIGALRM,checkmasterpidfile);
---------------------------------
newplayer.c:putmasterpidintofile()
newplayer.c:{
newplayer.c:	int masterpid;
newplayer.c:	char string[80]; /*~*/
---------------------------------
newplayer.c:	FILE *f,*fopen();
newplayer.c:	struct player *a,*b;
newplayer.c:	struct torpedo *t;
newplayer.c:	char string[50]; /*~*/
newplayer.c:	int listlength,l,alien;
---------------------------------
processinput.c:	int z;
processinput.c:	unsigned char c;	/* override "char c" in header.h  -- br */
processinput.c:
processinput.c:	if(!getbuf(cp,ptrnoofchars))return; /*~*/
processinput.c:	while ((c=getchr(cp))!='\0')
processinput.c:	{
---------------------------------
processinput.c:				break;
processinput.c:			case 's':
processinput.c:			case ' ': /*~*/
processinput.c:				if (cp->stat>6) {
---------------------------------
processinput.c:				break;
processinput.c:			case '5':  /*~*/
processinput.c:			case 'p': 
processinput.c:				if (cp->weaponselect==0)
---------------------------------
processinput.c:				break;
processinput.c:			case '['-'@': /*~*/
processinput.c:				if (cp->shields) /*~*/
processinput.c:				{ /*~*/
processinput.c:					cp->shields=OFF; /*~*/
processinput.c:					cp->id=(char)(cp->id+32); /*~*/
processinput.c:				} /* !!! Fall through to 'v' case ~*/
processinput.c:			case 'v':  /*~*/
processinput.c:				{ 
processinput.c:				   if (cp->shields)
processinput.c:				   {
.
. unchanged part
.
processinput.c:				   }
processinput.c:				   if (cp->stat<12) cp->chflg=FLAG;
processinput.c:				   plotshields(cp);
processinput.c:				   if(c=='v') break; /*~*/
processinput.c:			/* !!! else Fall through to c case ~*/
processinput.c:				   if (cp->cloakingdevice) /*~*/
processinput.c:					  cp->cloakingdevice=OFF; /*~*/
processinput.c:				} /*~*/
processinput.c:			case 'c': /* c case moved, must come after
					   * the 'v' case ~*/
processinput.c:				{ 
processinput.c:					if (cp->cloakingdevice)
processinput.c:					{
---------------------------------
processinput.c:				break;
processinput.c:			case 'R': 
processinput.c:			case 'R' - '@':  /*~*/
processinput.c:			case 'L' - '@':  /*~*/
processinput.c:				cp->oldstat=cp->stat;
---------------------------------
scan.c:scan(cp,o)
scan.c:register struct player *cp,*o;
scan.c:{
scan.c:	char string[200]; /*~*/
---------------------------------
slave.c:#include <signal.h>
slave.c:#ifdef USG /* sin@myab */
slave.c:#include <termio.h>
slave.c:#else
slave.c:#include <sgtty.h>
slave.c:#endif

slave.c:#define ON 1
---------------------------------
slave.c:int shipnumber,x,y,tty_type;
slave.c:int nointro, termcap;
slave.c:#ifdef USG /* sin@myab */
slave.c:struct termio params;
slave.c:struct termio old_params;
slave.c:#else
slave.c:struct sgttyb params;
slave.c:#endif
slave.c:char masterpidname[45]; /*~*/
slave.c:char *tnam;
---------------------------------
slave.c:readinscores()
slave.c:{
slave.c:	int reason,score,i;
slave.c:	char string[60]; /*~*/
---------------------------------
slave.c:setrawmode()
slave.c:{
slave.c:#ifdef USG /* sin@myab */ /*~*/
slave.c:	ioctl(0,TCGETA,&params); /*get terminal sgttyb structure*/ /*~*/
slave.c:	old_params=params; /*~*/
slave.c:	params.c_lflag &= ~(ICANON|ECHO); /*~*/
slave.c:	params.c_cc[VMIN]=1; /*~*/
slave.c:	params.c_cc[VTIME]=0; /*~*/
slave.c:	ioctl(0,TCSETA,&params); /*write out sgttyb structure*/ /*~*/
slave.c:#else /*~*/
slave.c:	ioctl(0,TIOCGETP,&params); /*get terminal sgttyb structure*/
slave.c:	params.sg_flags |= CBREAK;
slave.c:	params.sg_flags &= ~ECHO;
---------------------------------
slave.c:
slave.c:unsetrawmode()
slave.c:#ifdef USG /* sin@myab */ /*~*/
slave.c:	ioctl(0,TCSETA,&old_params); /*write out sgttyb structure*/ /*~*/
slave.c:#else /*~*/
slave.c:	ioctl(0,TIOCGETP,&params); /*get terminal sgttyb structure*/ /*~*/
slave.c:	params.sg_flags &= ~CBREAK; /*~*/
slave.c:	params.sg_flags |= ECHO; /*~*/
slave.c:	ioctl(0,TIOCSETP,&params); /*write out sgttyb structure*/ /*~*/
slave.c:#endif
slave.c:	signal(SIGINT, SIG_DFL);
slave.c:	signal(SIGHUP, SIG_DFL);
---------------------------------
slave.c:int argc;
slave.c:char *argv[];
slave.c:{
slave.c:	char string[80]; /*~*/
slave.c:	int childpid,i;
slave.c:	char *s;
slave.c:	char c;
---------------------------------
slave.c:		} else
slave.c:		{
slave.c:			char c;
slave.c:#ifdef USG /* sin@myab */ /*~*/
slave.c:			params.c_cc[VMIN]=0; /*~*/
slave.c:			params.c_cc[VTIME]=1; /*~*/
slave.c:			ioctl(0,TCSETA,&params); /*write out sgttyb struct ~*/
slave.c:#endif /*~*/
slave.c:			sprintf(string,"%s#%s#%s#%d#%d#%d#\n",terminalfile,
slave.c:			    cm,
slave.c:			    cl,shipnumber,childpid,tty_type);
---------------------------------
slave.c:	read(0,&c,1);
slave.c:	*/
slave.c:			clrscreenslave(cl,tty_type);
slave.c:#ifdef USG /* sin@myab */ /*~*/
slave.c:			kill(masterpid,SIGUSR1); /*~*/
slave.c:#else  /*~*/
slave.c:			kill(masterpid,29); /*~*/
slave.c:#endif /*~*/
slave.c:			while(1)sleep(1); /*~*/
slave.c:		}
slave.c:	}
slave.c:	while(wait(&status)!=pid);
---------------------------------
torpedo.c:	int hit;
torpedo.c:	struct torpedo *t,*a;
torpedo.c:	struct player *p,*h;
torpedo.c:	char bcstring[157]; /*~*/
torpedo.c:
torpedo.c:	t=tstartlist;
torpedo.c:	while (t!=NULL)

Thats All!

sin@cd.chalmers.se
sin@myab

sin@myab.UUCP (sin) (08/04/88)

I just remembered mpss uses the tty for i/o to the players so if you uses
shell-layers (sxt) mpss getts confused and usaly hangs.

		 sin@cd.chalmers.se
		 sin@myab.se