projects
/
super-star-trek.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b3d872b
)
FDISTR/FENSLV/FREPRO sequence looks like it's working.
author
Eric S. Raymond
<esr@thyrsus.com>
Tue, 19 Sep 2006 08:56:52 +0000
(08:56 +0000)
committer
Eric S. Raymond
<esr@thyrsus.com>
Tue, 19 Sep 2006 08:56:52 +0000
(08:56 +0000)
src/events.c
patch
|
blob
|
history
diff --git
a/src/events.c
b/src/events.c
index b6a168796e2c8e6e3fec74801943e1ebb99bc41e..6f2cac95e9df814c0c607c192a738e90d0079524 100644
(file)
--- a/
src/events.c
+++ b/
src/events.c
@@
-1,3
+1,11
@@
+/*
+ * events.c -- event-queue handling
+ *
+ * This isn't a real event queue a la BSD Trek yet -- you can only have one
+ * event of each type active at any given time. Mostly these means we can
+ * only have one FDISTR/FENSLV/FREPRO sequence going at any given time;
+ * BSD Trek, from which we swiped the idea, can have up to 5.
+ */
#include "sst.h"
#include <math.h>
#include "sst.h"
#include <math.h>
@@
-55,7
+63,7
@@
void events(void)
int radio_was_broken;
struct quadrant *pdest, *q;
coord w, hold;
int radio_was_broken;
struct quadrant *pdest, *q;
coord w, hold;
- event *ev;
+ event *ev
, *ev2
;
if (idebug) {
prout("=== EVENTS from %.2f to %.2f:", game.state.date, fintim);
if (idebug) {
prout("=== EVENTS from %.2f to %.2f:", game.state.date, fintim);
@@
-438,13
+446,14
@@
void events(void)
/* tell the captain about it if we can */
if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)
{
/* tell the captain about it if we can */
if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)
{
- prout("Uhura: Captain, starsystem %s in quadrant %d - %d is under attack.",
- systemname(q->planet), w.x, w.y);
+ prout("Uhura- Captain, starsystem %s in quadrant %s",
+ systemname(q->planet), cramlc(quadrant, w));
+ prout("is under attack.");
if (cancelrest())
return;
}
break;
if (cancelrest())
return;
}
break;
-
case FENSLV:
/* starsystem is enslaved */
+
case FENSLV:
/* starsystem is enslaved */
ev = unschedule(FENSLV);
/* see if current distress call still active */
q = &game.state.galaxy[ev->quadrant.x][ev->quadrant.y];
ev = unschedule(FENSLV);
/* see if current distress call still active */
q = &game.state.galaxy[ev->quadrant.x][ev->quadrant.y];
@@
-455,17
+464,22
@@
void events(void)
q->status = enslaved;
/* play stork and schedule the first baby */
q->status = enslaved;
/* play stork and schedule the first baby */
- ev = schedule(FREPRO, expran(2.0 * game.intime));
+ ev2 = schedule(FREPRO, expran(2.0 * game.intime));
+ ev2->quadrant = ev->quadrant;
/* report the disaster if we can */
if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)
{
/* report the disaster if we can */
if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)
{
- prout("
\nUhura: We've lost contact with starsystem %s\n
",
+ prout("
Uhura- We've lost contact with starsystem %s
",
systemname(q->planet));
systemname(q->planet));
- prout("
in quadrant %d,%d.\n", ev->quadrant.x,ev->quadrant.y
);
+ prout("
in quadrant %s.\n", cramlc(quadrant, ev->quadrant)
);
}
break;
}
break;
- case FREPRO: /* Klingon reproduces */
+ case FREPRO: /* Klingon reproduces */
+ /*
+ * If we ever switch to a real event queue, we'll need to
+ * explicitly retrieve and restore the x and y.
+ */
ev = schedule(FREPRO, expran(1.0 * game.intime));
/* see if current distress call still active */
q = &game.state.galaxy[ev->quadrant.x][ev->quadrant.y];
ev = schedule(FREPRO, expran(1.0 * game.intime));
/* see if current distress call still active */
q = &game.state.galaxy[ev->quadrant.x][ev->quadrant.y];
@@
-892,11
+906,9
@@
void snova(int insx, int insy)
game.state.nplankl += npdead;
}
/* mark supernova in galaxy and in star chart */
game.state.nplankl += npdead;
}
/* mark supernova in galaxy and in star chart */
- if ((game.quadrant.x == nq.x && game.quadrant.y == nq.y) ||
- game.damage[DRADIO] == 0 ||
- game.condit == IHDOCKED)
+ if (same(game.quadrant, nq) || game.damage[DRADIO] == 0 || game.condit == IHDOCKED)
game.state.galaxy[nq.x][nq.y].supernova = true;
game.state.galaxy[nq.x][nq.y].supernova = true;
- /* If supernova destroys last
k
lingons give special message */
+ /* If supernova destroys last
K
lingons give special message */
if (KLINGREM==0 && (nq.x != game.quadrant.x || nq.y != game.quadrant.y)) {
skip(2);
if (insx == 0) prout(_("Lucky you!"));
if (KLINGREM==0 && (nq.x != game.quadrant.x || nq.y != game.quadrant.y)) {
skip(2);
if (insx == 0) prout(_("Lucky you!"));