mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-21 03:14:50 +00:00
copy in from cvs; cvs2svn fucked up big time
git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
75
sail/dr_3.c
75
sail/dr_3.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $ */
|
||||
/* $NetBSD: dr_3.c,v 1.14 2001/02/05 01:10:09 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,15 +38,23 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $");
|
||||
__RCSID("$NetBSD: dr_3.c,v 1.14 2001/02/05 01:10:09 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "driver.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "extern.h"
|
||||
#include "driver.h"
|
||||
|
||||
static int stillmoving(int);
|
||||
static int is_isolated(struct ship *);
|
||||
static int push(struct ship *, struct ship *);
|
||||
static void step(struct ship *, int, char *);
|
||||
|
||||
/* move all comp ships */
|
||||
void
|
||||
moveall() /* move all comp ships */
|
||||
moveall(void)
|
||||
{
|
||||
struct ship *sp, *sq;
|
||||
int n;
|
||||
@@ -86,10 +94,10 @@ moveall() /* move all comp ships */
|
||||
n = 0;
|
||||
foreachship(sp) {
|
||||
if (snagged(sp))
|
||||
(void) strcpy(sp->file->movebuf, "d");
|
||||
strcpy(sp->file->movebuf, "d");
|
||||
else
|
||||
if (*sp->file->movebuf != 'd')
|
||||
(void) strcat(sp->file->movebuf, "d");
|
||||
strcat(sp->file->movebuf, "d");
|
||||
row[n] = sp->file->row;
|
||||
col[n] = sp->file->col;
|
||||
dir[n] = sp->file->dir;
|
||||
@@ -111,7 +119,7 @@ moveall() /* move all comp ships */
|
||||
if (!sp->file->movebuf[k])
|
||||
sp->file->movebuf[k+1] = '\0';
|
||||
else if (sp->file->dir)
|
||||
step(sp->file->movebuf[k], sp, &moved[n]);
|
||||
step(sp, sp->file->movebuf[k], &moved[n]);
|
||||
n++;
|
||||
}
|
||||
/*
|
||||
@@ -135,11 +143,11 @@ moveall() /* move all comp ships */
|
||||
snap++;
|
||||
if (!range(sp, sq) && !fouled2(sp, sq)) {
|
||||
makesignal(sp, "collision with $$", sq);
|
||||
if (die() < 4) {
|
||||
if (dieroll() < 4) {
|
||||
makesignal(sp, "fouled with $$",
|
||||
sq);
|
||||
Write(W_FOUL, sp, 0, l, 0, 0, 0);
|
||||
Write(W_FOUL, sq, 0, n, 0, 0, 0);
|
||||
Write(W_FOUL, sp, l, 0, 0, 0);
|
||||
Write(W_FOUL, sq, n, 0, 0, 0);
|
||||
}
|
||||
snap++;
|
||||
}
|
||||
@@ -170,21 +178,20 @@ moveall() /* move all comp ships */
|
||||
if (sp->file->dir != 0) {
|
||||
*sp->file->movebuf = 0;
|
||||
if (row[n] != sp->file->row)
|
||||
Write(W_ROW, sp, 0, sp->file->row, 0, 0, 0);
|
||||
Write(W_ROW, sp, sp->file->row, 0, 0, 0);
|
||||
if (col[n] != sp->file->col)
|
||||
Write(W_COL, sp, 0, sp->file->col, 0, 0, 0);
|
||||
Write(W_COL, sp, sp->file->col, 0, 0, 0);
|
||||
if (dir[n] != sp->file->dir)
|
||||
Write(W_DIR, sp, 0, sp->file->dir, 0, 0, 0);
|
||||
Write(W_DIR, sp, sp->file->dir, 0, 0, 0);
|
||||
if (drift[n] != sp->file->drift)
|
||||
Write(W_DRIFT, sp, 0, sp->file->drift, 0, 0, 0);
|
||||
Write(W_DRIFT, sp, sp->file->drift, 0, 0, 0);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
stillmoving(k)
|
||||
int k;
|
||||
static int
|
||||
stillmoving(int k)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
@@ -194,9 +201,8 @@ int k;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
is_isolated(ship)
|
||||
struct ship *ship;
|
||||
static int
|
||||
is_isolated(struct ship *ship)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
@@ -207,9 +213,8 @@ struct ship *ship;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
push(from, to)
|
||||
struct ship *from, *to;
|
||||
static int
|
||||
push(struct ship *from, struct ship *to)
|
||||
{
|
||||
int bs, sb;
|
||||
|
||||
@@ -222,11 +227,8 @@ struct ship *from, *to;
|
||||
return from < to;
|
||||
}
|
||||
|
||||
void
|
||||
step(com, sp, moved)
|
||||
char com;
|
||||
struct ship *sp;
|
||||
char *moved;
|
||||
static void
|
||||
step(struct ship *sp, int com, char *moved)
|
||||
{
|
||||
int dist;
|
||||
|
||||
@@ -266,10 +268,7 @@ char *moved;
|
||||
}
|
||||
|
||||
void
|
||||
sendbp(from, to, sections, isdefense)
|
||||
struct ship *from, *to;
|
||||
int sections;
|
||||
char isdefense;
|
||||
sendbp(struct ship *from, struct ship *to, int sections, int isdefense)
|
||||
{
|
||||
int n;
|
||||
struct BP *bp;
|
||||
@@ -278,7 +277,7 @@ char isdefense;
|
||||
for (n = 0; n < NBP && bp[n].turnsent; n++)
|
||||
;
|
||||
if (n < NBP && sections) {
|
||||
Write(isdefense ? W_DBP : W_OBP, from, 0,
|
||||
Write(isdefense ? W_DBP : W_OBP, from,
|
||||
n, turn, to->file->index, sections);
|
||||
if (isdefense)
|
||||
makemsg(from, "repelling boarders");
|
||||
@@ -288,9 +287,7 @@ char isdefense;
|
||||
}
|
||||
|
||||
int
|
||||
is_toughmelee(ship, to, isdefense, count)
|
||||
struct ship *ship, *to;
|
||||
int isdefense, count;
|
||||
is_toughmelee(struct ship *ship, struct ship *to, int isdefense, int count)
|
||||
{
|
||||
struct BP *bp;
|
||||
int obp = 0;
|
||||
@@ -321,7 +318,7 @@ int isdefense, count;
|
||||
}
|
||||
|
||||
void
|
||||
reload()
|
||||
reload(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
@@ -331,7 +328,7 @@ reload()
|
||||
}
|
||||
|
||||
void
|
||||
checksails()
|
||||
checksails(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
int rig, full;
|
||||
@@ -355,6 +352,6 @@ checksails()
|
||||
} else
|
||||
full = 0;
|
||||
if ((sp->file->FS != 0) != full)
|
||||
Write(W_FS, sp, 0, full, 0, 0, 0);
|
||||
Write(W_FS, sp, full, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user