+/* $NetBSD: kill.c,v 1.11 2009/05/24 22:55:03 dholland Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-/*static char sccsid[] = "from: @(#)kill.c 5.4 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: kill.c,v 1.2 1993/08/01 18:50:24 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: kill.c,v 1.11 2009/05/24 22:55:03 dholland Exp $");
+#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <limits.h>
+#include "trek.h"
/*
** KILL KILL KILL !!!
** and the game is won if that was the last klingon.
*/
-killk(ix, iy)
-int ix, iy;
+void
+killk(int ix, int iy)
{
- register int i, j;
+ int i;
printf(" *** Klingon at %d,%d destroyed ***\n", ix, iy);
/* find the Klingon in the Klingon list */
for (i = 0; i < Etc.nkling; i++)
- if (ix == Etc.klingon[i].x && iy == Etc.klingon[i].y)
- {
+ if (ix == Etc.klingon[i].x && iy == Etc.klingon[i].y) {
/* purge him from the list */
Etc.nkling -= 1;
for (; i < Etc.nkling; i++)
- bmove(&Etc.klingon[i+1], &Etc.klingon[i], sizeof Etc.klingon[i]);
+ Etc.klingon[i] = Etc.klingon[i+1];
break;
}
** handle a starbase's death
*/
-killb(qx, qy)
-int qx, qy;
+void
+killb(int qx, int qy)
{
- register struct quad *q;
- register struct xy *b;
+ struct quad *q;
+ struct xy *b;
q = &Quad[qx][qy];
if (q->bases <= 0)
return;
- if (!damaged(SSRADIO))
+ if (!damaged(SSRADIO)) {
/* then update starchart */
if (q->scanned < 1000)
q->scanned -= 10;
else
if (q->scanned > 1000)
q->scanned = -1;
+ }
q->bases = 0;
Now.bases -= 1;
for (b = Now.base; ; b++)
if (qx == b->x && qy == b->y)
break;
- bmove(&Now.base[Now.bases], b, sizeof *b);
- if (qx == Ship.quadx && qy == Ship.quady)
- {
+ *b = Now.base[Now.bases];
+ if (qx == Ship.quadx && qy == Ship.quady) {
Sect[Etc.starbase.x][Etc.starbase.y] = EMPTY;
if (Ship.cond == DOCKED)
- undock();
- printf("Starbase at %d,%d destroyed\n", Etc.starbase.x, Etc.starbase.y);
- }
- else
- {
- if (!damaged(SSRADIO))
- {
- printf("Uhura: Starfleet command reports that the starbase in\n");
- printf(" quadrant %d,%d has been destroyed\n", qx, qy);
+ undock(0);
+ printf("Starbase at %d,%d destroyed\n",
+ Etc.starbase.x, Etc.starbase.y);
+ } else {
+ if (!damaged(SSRADIO)) {
+ printf("Uhura: Starfleet command reports that the "
+ "starbase in\n");
+ printf(" quadrant %d,%d has been destroyed\n",
+ qx, qy);
}
else
- schedule(E_KATSB | E_GHOST, 1e50, qx, qy, 0);
+ schedule(E_KATSB | E_GHOST, TOOLARGE, qx, qy, 0);
}
}
/**
** kill an inhabited starsystem
+ **
+ ** x, y are quad coords if f == 0, else sector coords
+ ** f != 0 -- this quad; f < 0 -- Enterprise's fault
**/
-kills(x, y, f)
-int x, y; /* quad coords if f == 0, else sector coords */
-int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */
+void
+kills(int x, int y, int f)
{
- register struct quad *q;
- register struct event *e;
- register char *name;
- char *systemname();
+ struct quad *q;
+ struct event *e;
+ const char *name;
- if (f)
- {
+ if (f) {
/* current quadrant */
q = &Quad[Ship.quadx][Ship.quady];
Sect[x][y] = EMPTY;
name, x, y);
if (f < 0)
Game.killinhab += 1;
- }
- else
- {
+ } else {
/* different quadrant */
q = &Quad[x][y];
}
- if (q->qsystemname & Q_DISTRESSED)
- {
+ if (q->qsystemname & Q_DISTRESSED) {
/* distressed starsystem */
e = &Event[q->qsystemname & Q_SYSTEM];
printf("Distress call for %s invalidated\n",
/**
** "kill" a distress call
+ **
+ ** x, y are quadrant coordinates
+ ** f is set if user is to be informed
**/
-killd(x, y, f)
-int x, y; /* quadrant coordinates */
-int f; /* set if user is to be informed */
+void
+killd(int x, int y, int f)
{
- register struct event *e;
- register int i;
- register struct quad *q;
+ struct event *e;
+ int i;
+ struct quad *q;
q = &Quad[x][y];
- for (i = 0; i < MAXEVENTS; i++)
- {
+ for (i = 0; i < MAXEVENTS; i++) {
e = &Event[i];
if (e->x != x || e->y != y)
continue;
- switch (e->evcode)
- {
+ switch (e->evcode) {
case E_KDESB:
- if (f)
- {
- printf("Distress call for starbase in %d,%d nullified\n",
+ if (f) {
+ printf("Distress call for starbase in "
+ "%d,%d nullified\n",
x, y);
unschedule(e);
}
case E_ENSLV:
case E_REPRO:
- if (f)
- {
- printf("Distress call for %s in quadrant %d,%d nullified\n",
+ if (f) {
+ printf("Distress call for %s in quadrant "
+ "%d,%d nullified\n",
Systemname[e->systemname], x, y);
q->qsystemname = e->systemname;
unschedule(e);
- }
- else
- {
+ } else {
e->evcode |= E_GHOST;
}
}