SCCS-vsn: games/larn/create.c 5.2
SCCS-vsn: games/larn/display.c 5.2
SCCS-vsn: games/larn/fortune.c 5.3
SCCS-vsn: games/larn/main.c 5.5
SCCS-vsn: games/larn/monster.c 5.2
SCCS-vsn: games/larn/moreobj.c 5.2
SCCS-vsn: games/larn/signal.c 5.2
SCCS-vsn: games/larn/store.c 5.3
SCCS-vsn: games/mille/mille.c 5.5
SCCS-vsn: games/monop/execute.c 5.5
SCCS-vsn: games/monop/getinp.c 5.4
SCCS-vsn: games/monop/misc.c 5.5
SCCS-vsn: games/morse/morse.c 5.3
SCCS-vsn: games/number/number.c 5.1
SCCS-vsn: games/pom/pom.c 5.3
SCCS-vsn: games/quiz/quiz.c 4.7
SCCS-vsn: games/rain/rain.c 5.6
SCCS-vsn: games/robots/main.c 5.5
SCCS-vsn: games/robots/move_robs.c 5.5
SCCS-vsn: games/robots/robots.h 5.6
SCCS-vsn: games/rogue/init.c 5.4
SCCS-vsn: games/rogue/machdep.c 5.7
SCCS-vsn: games/rogue/rogue.h 5.6
SCCS-vsn: games/sail/lo_main.c 5.7
SCCS-vsn: games/sail/pl_1.c 5.5
SCCS-vsn: games/sail/pl_7.c 5.7
SCCS-vsn: games/sail/pl_main.c 5.5
SCCS-vsn: games/snake/snake/move.c 5.8
SCCS-vsn: games/snake/snake/snake.c 5.9
29 files changed:
playerx=tp1; playery=tp2;
}
\f
playerx=tp1; playery=tp2;
}
\f
+static void fillroom();
+
/*
***********
MAKE_OBJECT
/*
***********
MAKE_OBJECT
subroutine to put an object into an empty room
* uses a random walk
*/
subroutine to put an object into an empty room
* uses a random walk
*/
-static fillroom(what,arg)
+static void
+fillroom(what,arg)
if (bot3f) { bot3f=0; bot_spellx(); }
}
if (bot3f) { bot3f=0; bot_spellx(); }
}
bot_linex()
{
register int i;
bot_linex()
{
register int i;
+static void
+botsub(idx,str)
register int idx;
char *str;
{
register int idx;
char *str;
{
/* fortune.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/types.h>
#include <sys/stat.h>
/* fortune.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/types.h>
#include <sys/stat.h>
-#else
-#define O_RDONLY 0
-#endif
register int i,j;
int hard;
char *ptr=0,*ttype;
register int i,j;
int hard;
char *ptr=0,*ttype;
- struct passwd *pwe,*getpwuid();
/*
* first task is to identify the player
/*
* first task is to identify the player
/*
* speldamage(x) Function to perform spell functions cast by the player
* int x;
/*
* speldamage(x) Function to perform spell functions cast by the player
* int x;
* Enter with the origination coordinates in (x,y).
* Returns index into diroffx[] (0-8).
*/
* Enter with the origination coordinates in (x,y).
* Returns index into diroffx[] (0-8).
*/
int *x,*y;
{
register int i;
int *x,*y;
{
register int i;
/*
function to cast a +3 protection on the player
*/
/*
function to cast a +3 protection on the player
*/
{
lprcat("\nYou have been heard!");
if (c[ALTPRO]==0) c[MOREDEFENSES]+=3;
{
lprcat("\nYou have been heard!");
if (c[ALTPRO]==0) c[MOREDEFENSES]+=3;
+/*
+ ***
+ FCH
+ ***
+
+ subroutine to process an up/down of a character attribute for ofountain
+ */
+static void
+fch(how,x)
+ int how;
+ long *x;
+ {
+ if (how < 0) { lprcat(" went down by one!"); --(*x); }
+ else { lprcat(" went up by one!"); (*x)++; }
+ bottomline();
+ }
+
/*
a subroutine to raise or lower character levels
if x > 0 they are raised if x < 0 they are lowered
/*
a subroutine to raise or lower character levels
if x > 0 they are raised if x < 0 they are lowered
-
-/*
- ***
- FCH
- ***
-
- subroutine to process an up/down of a character attribute for ofountain
- */
-static fch(how,x)
- int how;
- long *x;
- {
- if (how < 0) { lprcat(" went down by one!"); --(*x); }
- else { lprcat(" went up by one!"); (*x)++; }
- bottomline();
- }
lprcat(" to continue: "); lflush();
}
lprcat(" to continue: "); lflush();
}
-static cntlc() /* what to do for a ^C */
+static void
+cntlc() /* what to do for a ^C */
{
if (nosignal) return; /* don't do anything if inhibited */
signal(SIGQUIT,SIG_IGN); signal(SIGINT,SIG_IGN);
{
if (nosignal) return; /* don't do anything if inhibited */
signal(SIGQUIT,SIG_IGN); signal(SIGINT,SIG_IGN);
/*
* subroutine to save the game if a hangup signal
*/
/*
* subroutine to save the game if a hangup signal
*/
{
savegame(savefilename); wizard=1; died(-257); /* hangup signal */
}
#ifdef SIGTSTP
{
savegame(savefilename); wizard=1; died(-257); /* hangup signal */
}
#ifdef SIGTSTP
-static tstop() /* control Y */
+static void
+tstop() /* control Y */
{
if (nosignal) return; /* nothing if inhibited */
lcreat((char*)0); clearvt100(); lflush(); signal(SIGTSTP,SIG_DFL);
{
if (nosignal) return; /* nothing if inhibited */
lcreat((char*)0); clearvt100(); lflush(); signal(SIGTSTP,SIG_DFL);
/*
* subroutine to issue the needed signal traps called from main()
*/
/*
* subroutine to issue the needed signal traps called from main()
*/
-static sigill() { sigpanic(SIGILL); } static sigtrap() { sigpanic(SIGTRAP); }
-static sigiot() { sigpanic(SIGIOT); } static sigemt() { sigpanic(SIGEMT); }
-static sigfpe() { sigpanic(SIGFPE); } static sigbus() { sigpanic(SIGBUS); }
-static sigsegv() { sigpanic(SIGSEGV); } static sigsys() { sigpanic(SIGSYS); }
-static sigpipe() { sigpanic(SIGPIPE); } static sigterm() { sigpanic(SIGTERM); }
+static void sigpanic();
+static void sigill() { sigpanic(SIGILL); }
+static void sigtrap() { sigpanic(SIGTRAP); }
+static void sigiot() { sigpanic(SIGIOT); }
+static void sigemt() { sigpanic(SIGEMT); }
+static void sigfpe() { sigpanic(SIGFPE); }
+static void sigbus() { sigpanic(SIGBUS); }
+static void sigsegv() { sigpanic(SIGSEGV); }
+static void sigsys() { sigpanic(SIGSYS); }
+static void sigpipe() { sigpanic(SIGPIPE); }
+static void sigterm() { sigpanic(SIGTERM); }
sigsetup()
{
signal(SIGQUIT, cntlc); signal(SIGINT, cntlc);
sigsetup()
{
signal(SIGQUIT, cntlc); signal(SIGINT, cntlc);
/*
* routine to process a fatal error signal
*/
/*
* routine to process a fatal error signal
*/
+static void
+sigpanic(sig)
int sig;
{
char buf[128];
int sig;
{
char buf[128];
-static char sccsid[] = "@(#)store.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)store.c 5.3 (Berkeley) %G%";
#endif /* not lint */
/* store.c Larn is copyrighted 1986 by Noah Morgan. */
#endif /* not lint */
/* store.c Larn is copyrighted 1986 by Noah Morgan. */
lprcat("Also be advised, if you break 'em, you pay for 'em.");
}
lprcat("Also be advised, if you break 'em, you pay for 'em.");
}
+static void dnditem();
+
dnd_hed()
{
register int i;
dnd_hed()
{
register int i;
cursor(50,18); lprcat("You have ");
}
cursor(50,18); lprcat("You have ");
}
+static void
+handsfull()
+{
+ lprcat("\nYou can't carry anything more!");
+ lflush();
+ nap(2200);
+}
+
+static void
+outofstock()
+{
+ lprcat("\nSorry, but we are out of that item.");
+ lflush();
+ nap(2200);
+}
+
+static void nogold()
+{
+ lprcat("\nYou don't have enough gold to pay for that!");
+ lflush();
+ nap(2200);
+}
+
dndstore()
{
register int i;
dndstore()
{
register int i;
-/*
- function for the players hands are full
- */
-static handsfull()
- { lprcat("\nYou can't carry anything more!"); lflush(); nap(2200); }
-static outofstock()
- { lprcat("\nSorry, but we are out of that item."); lflush(); nap(2200); }
-static nogold()
- { lprcat("\nYou don't have enough gold to pay for that!"); lflush(); nap(2200); }
-
/*
dnditem(index)
to print the item list; used in dndstore() enter with the index into itm
*/
/*
dnditem(index)
to print the item list; used in dndstore() enter with the index into itm
*/
register int i;
{
register int j,k;
register int i;
{
register int j,k;
* for the first national bank of Larn
*/
int lasttime=0; /* last time he was in bank */
* for the first national bank of Larn
*/
int lasttime=0; /* last time he was in bank */
+static void banktitle();
+
obank()
{
banktitle(" Welcome to the First National Bank of Larn.");
obank()
{
banktitle(" Welcome to the First National Bank of Larn.");
{
banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
}
{
banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
}
+static void
+banktitle(str)
char *str;
{
nosignal = 1; /* disable signals */
char *str;
{
nosignal = 1; /* disable signals */
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)mille.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)mille.c 5.5 (Berkeley) %G%";
#endif /* not lint */
# include "mille.h"
#endif /* not lint */
# include "mille.h"
* @(#)mille.c 1.3 (Berkeley) 5/10/83
*/
* @(#)mille.c 1.3 (Berkeley) 5/10/83
*/
* Routine to trap rubouts, and make sure they really want to
* quit.
*/
* Routine to trap rubouts, and make sure they really want to
* quit.
*/
rub() {
(void)signal(SIGINT, SIG_IGN);
rub() {
(void)signal(SIGINT, SIG_IGN);
-static char sccsid[] = "@(#)execute.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)execute.c 5.5 (Berkeley) %G%";
#endif /* not lint */
# include "monop.ext"
#endif /* not lint */
# include "monop.ext"
reg char *sp;
reg int outf, num;
reg char *sp;
reg int outf, num;
- TIME tme, *tp;
- int *dat_end, junk[18];
+ time_t t;
+ int *dat_end;
+ struct stat sb;
printf("Which file do you wish to save it in? ");
sp = buf;
while ((*sp++=getchar()) != '\n')
printf("Which file do you wish to save it in? ");
sp = buf;
while ((*sp++=getchar()) != '\n')
* check for existing files, and confirm overwrite if needed
*/
* check for existing files, and confirm overwrite if needed
*/
- if (stat(buf, junk) > -1
+ if (stat(buf, &sb) > -1
&& getyn("File exists. Do you wish to overwrite? ", yn_only) > 0)
return;
&& getyn("File exists. Do you wish to overwrite? ", yn_only) > 0)
return;
return;
}
printf("\"%s\" ", buf);
return;
}
printf("\"%s\" ", buf);
- time(tp); /* get current time */
- strcpy(buf, ctime(tp));
+ time(&t); /* get current time */
+ strcpy(buf, ctime(&t));
for (sp = buf; *sp != '\n'; sp++)
continue;
*sp = '\0';
for (sp = buf; *sp != '\n'; sp++)
continue;
*sp = '\0';
start += num;
}
close(inf);
start += num;
}
close(inf);
- strcpy(buf, ctime(sbuf.st_mtime));
+ strcpy(buf, ctime(&sbuf.st_mtime));
for (sp = buf; *sp != '\n'; sp++)
continue;
*sp = '\0';
for (sp = buf; *sp != '\n'; sp++)
continue;
*sp = '\0';
-static char sccsid[] = "@(#)getinp.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)getinp.c 5.4 (Berkeley) %G%";
#endif /* not lint */
# include <stdio.h>
#endif /* not lint */
# include <stdio.h>
reg int i, n_match, match;
char *sp;
int plen;
reg int i, n_match, match;
char *sp;
int plen;
-static char sccsid[] = "@(#)misc.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)misc.c 5.5 (Berkeley) %G%";
#endif /* not lint */
# include "monop.ext"
#endif /* not lint */
# include "monop.ext"
/*
* This routine gives the players a chance before it exits.
*/
/*
* This routine gives the players a chance before it exits.
*/
quit() {
putchar('\n');
if (getyn("Do you all really want to quit? ", yn) == 0)
exit(0);
quit() {
putchar('\n');
if (getyn("Do you all really want to quit? ", yn) == 0)
exit(0);
}
/*
* This routine copies one structure to another
}
/*
* This routine copies one structure to another
printline();
if (shell == NULL)
shell = shell_in();
printline();
if (shell == NULL)
shell = shell_in();
if (!fork()) {
signal(SIGINT, SIG_DFL);
execsh(shell);
if (!fork()) {
signal(SIGINT, SIG_DFL);
execsh(shell);
# include <sys/types.h>
# include <pwd.h>
# include <sys/types.h>
# include <pwd.h>
-struct passwd *getpwuid();
-
for (i = 0; i < NSIG; i++)
signal(i, SIG_DFL);
for (i = 0; i < NSIG; i++)
signal(i, SIG_DFL);
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)morse.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)morse.c 5.3 (Berkeley) %G%";
#endif /* not lint */
#include <stdio.h>
#endif /* not lint */
#include <stdio.h>
morse(c)
register int c;
{
morse(c)
register int c;
{
show(s)
register char *s;
{
show(s)
register char *s;
{
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)number.c 4.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)number.c 5.1 (Berkeley) %G%";
#endif /* not lint */
#include <stdio.h>
#endif /* not lint */
#include <stdio.h>
convert(line)
char *line;
{
convert(line)
char *line;
{
unit(len,C)
register int len;
register char *C;
unit(len,C)
register int len;
register char *C;
number(C,len)
register char *C;
int len;
number(C,len)
register char *C;
int len;
pfract(len)
register int len;
{
pfract(len)
register int len;
{
usage(toobig)
int toobig;
{
usage(toobig)
int toobig;
{
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)pom.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)pom.c 5.3 (Berkeley) %G%";
#define Pzero 192.917585 /* lunar mean long of perigee at EPOCH */
#define Nzero 55.204723 /* lunar mean long of node at EPOCH */
#define Pzero 192.917585 /* lunar mean long of perigee at EPOCH */
#define Nzero 55.204723 /* lunar mean long of node at EPOCH */
+double dtor(), potm(), adj360();
+
main()
{
extern int errno;
struct timeval tp;
struct timezone tzp;
struct tm *GMT, *gmtime();
main()
{
extern int errno;
struct timeval tp;
struct timezone tzp;
struct tm *GMT, *gmtime();
- double days, today, tomorrow, dtor(), adj360(), potm();
+ double days, today, tomorrow;
int cnt;
char *strerror();
int cnt;
char *strerror();
-static char sccsid[] = " quiz.c 4.6 91/02/04 ";
+static char sccsid[] = " quiz.c 4.7 91/02/28 ";
#include <stdio.h>
#include <signal.h>
#include <stdio.h>
#include <signal.h>
main(argc,argv)
char *argv[];
{
main(argc,argv)
char *argv[];
{
char *info;
int tvec[2];
char *t;
char *info;
int tvec[2];
char *t;
int count;
info = _PATH_INDEX;
time(tvec);
int count;
info = _PATH_INDEX;
time(tvec);
done()
{
if (rights + wrongs) {
done()
{
if (rights + wrongs) {
exit(0);
}
instruct(info)
exit(0);
}
instruct(info)
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)rain.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)rain.c 5.6 (Berkeley) %G%";
char *TI, *tcp, *mp, tcb[100],
*malloc(), *getenv(), *strcpy(), *tgetstr();
long cols, lines, random();
char *TI, *tcp, *mp, tcb[100],
*malloc(), *getenv(), *strcpy(), *tgetstr();
long cols, lines, random();
- int xpos[5], ypos[5], onsig();
+ int xpos[5], ypos[5];
+ static void onsig();
if (!(term = getenv("TERM"))) {
fprintf(stderr, "%s: TERM: parameter not set\n", *argv);
if (!(term = getenv("TERM"))) {
fprintf(stderr, "%s: TERM: parameter not set\n", *argv);
onsig()
{
tputs(LL, 1, fputchar);
onsig()
{
tputs(LL, 1, fputchar);
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 5.5 (Berkeley) %G%";
#endif /* not lint */
# include "robots.h"
#endif /* not lint */
# include "robots.h"
register bool show_only;
extern char *Scorefile;
extern int Max_per_uid;
register bool show_only;
extern char *Scorefile;
extern int Max_per_uid;
show_only = FALSE;
if (ac > 1) {
show_only = FALSE;
if (ac > 1) {
if (LINES != Y_SIZE || COLS != X_SIZE) {
if (LINES < Y_SIZE || COLS < X_SIZE) {
endwin();
if (LINES != Y_SIZE || COLS != X_SIZE) {
if (LINES < Y_SIZE || COLS < X_SIZE) {
endwin();
- printf("Need at least a %dx%d screen\n", Y_SIZE, X_SIZE);
+ printf("Need at least a %dx%d screen\n",
+ Y_SIZE, X_SIZE);
exit(1);
}
delwin(stdscr);
exit(1);
}
delwin(stdscr);
* quit:
* Leave the program elegantly.
*/
* quit:
* Leave the program elegantly.
*/
quit()
{
extern int _putchar();
quit()
{
extern int _putchar();
-static char sccsid[] = "@(#)move_robs.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)move_robs.c 5.5 (Berkeley) %G%";
#endif /* not lint */
# include "robots.h"
#endif /* not lint */
# include "robots.h"
* move_robots:
* Move the robots around
*/
* move_robots:
* Move the robots around
*/
move_robots(was_sig)
bool was_sig;
{
move_robots(was_sig)
bool was_sig;
{
if (was_sig) {
refresh();
if (Dead || Num_robots <= 0)
if (was_sig) {
refresh();
if (Dead || Num_robots <= 0)
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)robots.h 5.5 (Berkeley) %G%
+ * @(#)robots.h 5.6 (Berkeley) %G%
-int quit(), cmp_sc(), move_robots();
+int cmp_sc();
+void move_robots();
-static char sccsid[] = "@(#)init.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)init.c 5.4 (Berkeley) %G%";
byebye()
{
md_ignore_signals();
byebye()
{
md_ignore_signals();
onintr()
{
md_ignore_signals();
onintr()
{
md_ignore_signals();
error_save()
{
save_is_interactive = 0;
error_save()
{
save_is_interactive = 0;
-static char sccsid[] = "@(#)machdep.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)machdep.c 5.7 (Berkeley) %G%";
- struct passwd *p, *getpwuid();
if (!(p = getpwuid(getuid())))
return((char *)NULL);
if (!(p = getpwuid(getuid())))
return((char *)NULL);
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)rogue.h 5.5 (Berkeley) %G%
+ * @(#)rogue.h 5.6 (Berkeley) %G%
long rrandom();
long lget_number();
long xxx();
long rrandom();
long lget_number();
long xxx();
-int byebye(), onintr(), error_save();
+void byebye(), onintr(), error_save();
struct rogue_time {
short year; /* >= 1987 */
struct rogue_time {
short year; /* >= 1987 */
-static char sccsid[] = "@(#)lo_main.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)lo_main.c 5.7 (Berkeley) %G%";
FILE *fp;
char sbuf[32];
int n = 0, people;
FILE *fp;
char sbuf[32];
int n = 0, people;
- struct passwd *getpwuid(), *pass;
struct logs log;
struct ship *ship;
struct logs log;
struct ship *ship;
-static char sccsid[] = "@(#)pl_1.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)pl_1.c 5.5 (Berkeley) %G%";
#endif /* not lint */
#include "player.h"
#endif /* not lint */
#include "player.h"
choke()
{
leave(LEAVE_QUIT);
}
choke()
{
leave(LEAVE_QUIT);
}
child()
{
union wait status;
child()
{
union wait status;
(void) signal(SIGCHLD, SIG_IGN);
do {
(void) signal(SIGCHLD, SIG_IGN);
do {
- pid = wait3(&status, WNOHANG, (struct rusage *)0);
+ pid = wait3((int *)&status, WNOHANG, (struct rusage *)0);
if (pid < 0 || pid > 0 && !WIFSTOPPED(status))
hasdriver = 0;
} while (pid > 0);
if (pid < 0 || pid > 0 && !WIFSTOPPED(status))
hasdriver = 0;
} while (pid > 0);
-static char sccsid[] = "@(#)pl_7.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)pl_7.c 5.7 (Berkeley) %G%";
#endif /* not lint */
#include "player.h"
#endif /* not lint */
#include "player.h"
(void) leaveok(turn_w, 1);
#ifdef SIGTSTP
{
(void) leaveok(turn_w, 1);
#ifdef SIGTSTP
{
(void) signal(SIGTSTP, susp);
}
#endif
(void) signal(SIGTSTP, susp);
}
#endif
newturn()
{
repaired = loaded = fired = changed = 0;
newturn()
{
repaired = loaded = fired = changed = 0;
-static char sccsid[] = "@(#)pl_main.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)pl_main.c 5.5 (Berkeley) %G%";
#endif /* not lint */
#include "player.h"
#include <sys/types.h>
#include <sys/wait.h>
#endif /* not lint */
#include "player.h"
#include <sys/types.h>
#include <sys/wait.h>
-static char sccsid[] = "@(#)move.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)move.c 5.8 (Berkeley) %G%";
#endif /* not lint */
/*************************************************************************
#endif /* not lint */
/*************************************************************************
* home() home.
* ll() move to lower left corner of screen.
* cr() carriage return (no line feed).
* home() home.
* ll() move to lower left corner of screen.
* cr() carriage return (no line feed).
- * printf() just like standard printf, but keeps track
+ * pr() just like standard printf, but keeps track
* of cursor position. (Uses pstring).
* of cursor position. (Uses pstring).
- * aprintf() same as printf, but first argument is &point.
+ * apr() same as printf, but first argument is &point.
* (Uses pstring).
* pstring(s) output the string of printing characters.
* However, '\r' is interpreted to mean return
* (Uses pstring).
* pstring(s) output the string of printing characters.
* However, '\r' is interpreted to mean return
*
******************************************************************************/
*
******************************************************************************/
#include "snake.h"
int CMlength;
#include "snake.h"
int CMlength;
struct point z;
if (sp->line <0 || sp->col <0 || sp->col > COLUMNS){
struct point z;
if (sp->line <0 || sp->col <0 || sp->col > COLUMNS){
- printf("move to [%d,%d]?",sp->line,sp->col);
+ pr("move to [%d,%d]?",sp->line,sp->col);
return;
}
if (sp->line >= LINES){
return;
}
if (sp->line >= LINES){
distance = sp->col - cursor.col;
distance = distance > 0 ?
distance*NDlength : -distance * BSlength;
distance = sp->col - cursor.col;
distance = distance > 0 ?
distance*NDlength : -distance * BSlength;
-if(distance < 0)printf("ERROR: distance is negative: %d",distance);
+ if (distance < 0)
+ pr("ERROR: distance is negative: %d",distance);
distance += abs(sp->line - cursor.line);
if(distance >= CMlength){
putpad(cmstr);
distance += abs(sp->line - cursor.line);
if(distance >= CMlength){
putpad(cmstr);
if (cursor.line > LINES || cursor.line <0 ||
cursor.col <0 || cursor.col > COLUMNS)
if (cursor.line > LINES || cursor.line <0 ||
cursor.col <0 || cursor.col > COLUMNS)
- printf("ERROR: cursor is at %d,%d\n",
+ pr("ERROR: cursor is at %d,%d\n",
cursor.line,cursor.col);
if (sp->line > LINES || sp->line <0 ||
sp->col <0 || sp->col > COLUMNS)
cursor.line,cursor.col);
if (sp->line > LINES || sp->line <0 ||
sp->col <0 || sp->col > COLUMNS)
- printf("ERROR: target is %d,%d\n",sp->line,sp->col);
+ pr("ERROR: target is %d,%d\n",sp->line,sp->col);
tfield = (sp->col) >> 3;
if (sp->line == cursor.line){
if (sp->col > cursor.col)right(sp);
tfield = (sp->col) >> 3;
if (sp->line == cursor.line){
if (sp->col > cursor.col)right(sp);
int tabcol,strlength;
if (sp->col < cursor.col)
int tabcol,strlength;
if (sp->col < cursor.col)
- printf("ERROR:right() can't move left\n");
+ pr("ERROR:right() can't move left\n");
if(TA){ /* If No Tabs: can't send tabs because ttydrive
* loses count with control characters.
*/
if(TA){ /* If No Tabs: can't send tabs because ttydrive
* loses count with control characters.
*/
-aprintf(ps,st,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9)
-struct point *ps;
-char *st;
-int v0,v1,v2,v3,v4,v5,v6,v7,v8,v9;
-
+apr(ps, fmt)
+ struct point *ps;
+ char *fmt;
p.line = ps->line+1; p.col = ps->col+1;
move(&p);
p.line = ps->line+1; p.col = ps->col+1;
move(&p);
- (void)sprintf(str,st,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9);
+ va_start(ap, fmt);
+ (void)vsprintf(str, fmt, ap);
+ va_end(ap);
-printf(st,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9)
-char *st;
-int v0,v1,v2,v3,v4,v5,v6,v7,v8,v9;
- (void)sprintf(str,st,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9);
+ va_list ap;
+
+ va_start(ap, fmt);
+ (void)vsprintf(str, fmt, ap);
+ va_end(ap);
char *term;
char *xPC;
struct point z;
char *term;
char *xPC;
struct point z;
term = getenv("TERM");
if (term==0) {
term = getenv("TERM");
if (term==0) {
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)snake.c 5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)snake.c 5.9 (Berkeley) %G%";
int ch, i, j, k;
time_t time();
long atol();
int ch, i, j, k;
time_t time();
long atol();
(void)time(&tv);
srandom((int)tv);
(void)time(&tv);
srandom((int)tv);
i = MIN(lcnt, ccnt);
if (i < 4) {
cook();
i = MIN(lcnt, ccnt);
if (i < 4) {
cook();
- printf("snake: screen too small for a fair game.\n");
+ pr("snake: screen too small for a fair game.\n");
win(&finish);
ll();
cook();
win(&finish);
ll();
cook();
- printf("You have won with $%d.\n",cashvalue);
+ pr("You have won with $%d.\n",cashvalue);
fflush(stdout);
logit("won");
post(cashvalue,0);
fflush(stdout);
logit("won");
post(cashvalue,0);
short uid;
short oldbest=0;
short allbwho=0, allbscore=0;
short uid;
short oldbest=0;
short allbwho=0, allbscore=0;
- struct passwd *p, *getpwuid();
/*
* Neg uid, 0, and 1 cannot have scores recorded.
/*
* Neg uid, 0, and 1 cannot have scores recorded.
if (score > oldbest) {
lseek(rawscores, ((long)uid)*sizeof(short), 0);
write(rawscores, &score, sizeof(short));
if (score > oldbest) {
lseek(rawscores, ((long)uid)*sizeof(short), 0);
write(rawscores, &score, sizeof(short));
- printf("You bettered your previous best of $%d\n", oldbest);
+ pr("You bettered your previous best of $%d\n", oldbest);
- printf("Your best to date is $%d\n", oldbest);
+ pr("Your best to date is $%d\n", oldbest);
/* See if we have a new champ */
p = getpwuid(allbwho);
/* See if we have a new champ */
p = getpwuid(allbwho);
write(rawscores, &score, sizeof(short));
write(rawscores, &uid, sizeof(short));
if (p != NULL)
write(rawscores, &score, sizeof(short));
write(rawscores, &uid, sizeof(short));
if (p != NULL)
- printf("You beat %s's old record of $%d!\n", p->pw_name, allbscore);
+ pr("You beat %s's old record of $%d!\n",
+ p->pw_name, allbscore);
- printf("You set a new record!\n");
+ pr("You set a new record!\n");
- printf("The highest is %s with $%d\n", p->pw_name, allbscore);
+ pr("The highest is %s with $%d\n",
+ p->pw_name, allbscore);
close(rawscores);
} else
if (!flag)
close(rawscores);
} else
if (!flag)
- printf("Unable to post score.\n");
+ pr("Unable to post score.\n");
else
vp -= wt[i];
if (i==8) {
else
vp -= wt[i];
if (i==8) {
i=0;
while (wt[i]==0) i++;
}
i=0;
while (wt[i]==0) i++;
}
for(j=0;j<3;j++){
clear();
delay(5);
for(j=0;j<3;j++){
clear();
delay(5);
if (! stretch(&money)) if (! stretch(&finish)) delay(10);
if(you.line < 3){
point(&p,you.col,0);
if (! stretch(&money)) if (! stretch(&finish)) delay(10);
if(you.line < 3){
point(&p,you.col,0);
}
if(you.line > lcnt-4){
point(&p,you.col,lcnt-1);
}
if(you.line > lcnt-4){
point(&p,you.col,lcnt-1);
}
if(you.col < 10){
point(&p,0,you.line);
}
if(you.col < 10){
point(&p,0,you.line);
}
if(you.col > ccnt-10){
point(&p,ccnt-1,you.line);
}
if(you.col > ccnt-10){
point(&p,ccnt-1,you.line);
pchar(&p,'v');
delay(10);
for (;p.line > you.line;p.line--)
pchar(&p,'v');
delay(10);
for (;p.line > you.line;p.line--)
} else {
for (p.line = you.line-1;p.line >= ps->line;p.line--)
pchar(&p,'^');
delay(10);
for (;p.line < you.line;p.line++)
} else {
for (p.line = you.line-1;p.line >= ps->line;p.line--)
pchar(&p,'^');
delay(10);
for (;p.line < you.line;p.line++)
}
return(1);
} else if(abs(ps->line-you.line) < 3){
}
return(1);
} else if(abs(ps->line-you.line) < 3){
pchar(&p,'>');
delay(10);
for (;p.col > you.col;p.col--)
pchar(&p,'>');
delay(10);
for (;p.col > you.col;p.col--)
} else {
for (p.col = you.col-1;p.col >= ps->col;p.col--)
pchar(&p,'<');
delay(10);
for (;p.col < you.col;p.col++)
} else {
for (p.col = you.col-1;p.col >= ps->col;p.col--)
pchar(&p,'<');
delay(10);
for (;p.col < you.col;p.col++)
if(ps->line == 0)ps->line++;
if(ps->line == LINES -1)ps->line--;
if(ps->col == COLUMNS -1)ps->col--;
if(ps->line == 0)ps->line++;
if(ps->line == LINES -1)ps->line--;
if(ps->col == COLUMNS -1)ps->col--;
- aprintf(point(&x,ps->col-1,ps->line-1),"/*\\\r* *\r\\*/");
+ apr(point(&x,ps->col-1,ps->line-1),"/*\\\r* *\r\\*/");
for (j=0;j<20;j++){
pchar(ps,'@');
delay(1);
for (j=0;j<20;j++){
pchar(ps,'@');
delay(1);
delay(1);
}
if (post(cashvalue,1)) {
delay(1);
}
if (post(cashvalue,1)) {
- aprintf(point(&x,ps->col-1,ps->line-1)," \ro.o\r\\_/");
+ apr(point(&x,ps->col-1,ps->line-1)," \ro.o\r\\_/");
- aprintf(point(&x,ps->col-1,ps->line-1)," \ro.-\r\\_/");
+ apr(point(&x,ps->col-1,ps->line-1)," \ro.-\r\\_/");
- aprintf(point(&x,ps->col-1,ps->line-1)," \ro.o\r\\_/");
+ apr(point(&x,ps->col-1,ps->line-1)," \ro.o\r\\_/");
}
win(ps)
struct point *ps;
}
win(ps)
struct point *ps;
i = (cashvalue) % 10;
bonus = ((rand()>>8) & 0377)% 10;
ll();
i = (cashvalue) % 10;
bonus = ((rand()>>8) & 0377)% 10;
ll();
delay(30);
if (bonus == i) {
spacewarp(1);
delay(30);
if (bonus == i) {
spacewarp(1);
return(1);
}
if ( loot >= penalty ){
return(1);
}
if ( loot >= penalty ){
- printf("You and your $%d have been eaten\n",cashvalue);
+ pr("You and your $%d have been eaten\n",
+ cashvalue);
- printf("The snake ate you. You owe $%d.\n",-cashvalue);
+ pr("The snake ate you. You owe $%d.\n",
+ -cashvalue);
}
logit("eaten");
length(moves);
}
logit("eaten");
length(moves);
struct point *sp;
{
int j;
struct point *sp;
{
int j;
p.line = p.col = 1;
if(won>0){
move(&p);
p.line = p.col = 1;
if(won>0){
move(&p);
+ signal(SIGINT,SIG_IGN);
ll();
length(moves);
done();
ll();
length(moves);
done();
- printf("You made %d moves.\n",num);
+ pr("You made %d moves.\n",num);
if ((logfile=fopen(_PATH_LOGFILE, "a")) != NULL) {
time(&t);
if ((logfile=fopen(_PATH_LOGFILE, "a")) != NULL) {
time(&t);
- fprintf(logfile, "%s $%d %dx%d %s %s", getlogin(), cashvalue, lcnt, ccnt, msg, ctime(&t));
+ fprintf(logfile, "%s $%d %dx%d %s %s",
+ getlogin(), cashvalue, lcnt, ccnt, msg, ctime(&t));