* @(#) Copyright (c) 1980, 1993 The Regents of the University of California. All rights reserved.
* @(#)snake.c 8.2 (Berkeley) 1/7/94
* $FreeBSD: src/games/snake/snake/snake.c,v 1.11.2.1 2000/08/17 06:21:44 jhb Exp $
- * $DragonFly: src/games/snake/snake/snake.c,v 1.3 2006/09/03 23:23:10 pavalos Exp $
+ * $DragonFly: src/games/snake/snake/snake.c,v 1.4 2006/09/03 23:47:56 pavalos Exp $
*/
/*
void win(const struct point *);
void winnings(int);
-main(argc,argv)
-int argc;
-char **argv;
+int
+main(int argc, char **argv)
{
int ch, i;
time_t tv;
}
setgid(getgid());
- (void) time(&tv);
+ time(&tv);
while ((ch = getopt(argc, argv, "l:w:t")) != -1)
switch ((char) ch) {
}
struct point *
-point(ps, x, y)
- struct point *ps;
- int x, y;
+point(struct point *ps, int x, int y)
{
ps->col = x;
ps->line = y;
/* Main command loop */
void
-mainloop()
+mainloop(void)
{
int k;
int repeat = 1;
pchar(&you,' ');
do {
snrand(&money);
- } while (money.col == finish.col && money.line == finish.line ||
- money.col < 5 && money.line == 0 ||
- money.col == you.col && money.line == you.line);
+ } while ((money.col == finish.col && money.line == finish.line) ||
+ (money.col < 5 && money.line == 0) ||
+ (money.col == you.col && money.line == you.line));
pchar(&money,TREASURE);
winnings(cashvalue);
continue;
}
}
-setup(){ /*
+void
+setup(void)
+{ /*
* setup the board
*/
int i;
}
void
-drawbox()
+drawbox(void)
{
int i;
}
}
-snrand(sp)
-struct point *sp;
+void
+snrand(struct point *sp)
{
struct point p;
int i;
*sp = p;
}
-post(iscore, flag)
-int iscore, flag;
+int
+post(int iscore, int flag)
{
short score = iscore;
short uid;
* overshooting. This loses horribly at 9600 baud, but works nicely
* if the terminal gets behind.
*/
-flushi()
+void
+flushi(void)
{
tcflush(0, TCIFLUSH);
}
1, 1.4, 1, 1.4, 1, 1.4, 1, 1.4
};
int oldw=0;
-chase (np, sp)
-struct point *sp, *np;
+
+void
+chase(struct point *np, struct point *sp)
{
/* this algorithm has bugs; otherwise the
snake would get too good */
point(np,sp->col+mx[w],sp->line+my[w]);
}
-spacewarp(w)
-int w;{
+void
+spacewarp(int w)
+{
struct point p;
int j;
const char *str;
winnings(cashvalue);
}
-snap()
+void
+snap(void)
{
-#if 0 /* This code doesn't really make sense. */
- struct point p;
-
- if (you.line < 3) {
- mvaddch(1, you.col + 1, '-');
- }
- if (you.line > lcnt - 4) {
- mvaddch(lcnt, you.col + 1, '_');
- }
- if (you.col < 10) {
- mvaddch(you.line + 1, 1, '(');
- }
- if (you.col > ccnt - 10) {
- mvaddch(you.line + 1, ccnt, ')');
- }
-#endif
if (!stretch(&money))
if (!stretch(&finish)) {
pchar(&you, '?');
delay(10);
pchar(&you, ME);
}
-#if 0
- if (you.line < 3) {
- point(&p, you.col, 0);
- chk(&p);
- }
- if(you.line > lcnt-4){
- point(&p,you.col,lcnt-1);
- chk(&p);
- }
- if(you.col < 10){
- point(&p,0,you.line);
- chk(&p);
- }
- if(you.col > ccnt-10){
- point(&p,ccnt-1,you.line);
- chk(&p);
- }
-#endif
refresh();
}
-stretch(ps)
-const struct point *ps;{
+int
+stretch(const struct point *ps)
+{
struct point p;
point(&p,you.col,you.line);
return(0);
}
-surround(ps)
-struct point *ps;{
+void
+surround(struct point *ps)
+{
int j;
if(ps->col == 0)ps->col++;
delay(6);
}
-win(ps)
-const struct point *ps;
+void
+win(const struct point *ps)
{
struct point x;
int j,k;
}
}
-pushsnake()
+int
+pushsnake(void)
{
int i, bonus;
int issame = 0;
return(0);
}
-chk(sp)
-const struct point *sp;
+int
+chk(const struct point *sp)
{
int j;
pchar(sp,' ');
return(0);
}
-winnings(won)
-int won;
+
+void
+winnings(int won)
{
if (won > 0) {
mvprintw(1, 1, "$%d", won);
}
void
-stop(dummy){
+stop(__unused int dummy)
+{
signal(SIGINT,SIG_IGN);
endwin();
length(moves);
exit(0);
}
-suspend()
+void
+suspend(void)
{
endwin();
kill(getpid(), SIGTSTP);
winnings(cashvalue);
}
-length(num)
-int num;
+void
+length(int num)
{
printf("You made %d moves.\n", num);
}
-logit(msg)
-const char *msg;
+void
+logit(const char *msg)
{
time_t t;