q->planet = NOPLANET;
DESTROY(&game.state.plnets[game.iplnet]);
game.iplnet = 0;
- game.plnet.x = game.plnet.y = 0;
+ invalidate(game.plnet);
game.quad[w.x][w.y] = IHDOT;
if (game.landed) {
/* captain perishes on planet */
q->planet = NOPLANET;
DESTROY(&game.state.plnets[game.iplnet]);
game.iplnet = 0;
- game.plnet.x = game.plnet.y = 0;
+ invalidate(game.plnet);
game.quad[w.x][w.y] = IHDOT;
if (game.landed) {
/* captain perishes on planet */
else if (type == IHQUEST) {
/* Killed a Thingy */
iqhere = iqengry = false;
- thing.x =thing.y = 0;
+ invalidate(thing);
}
else {
/* Some type of a Klingon */
if (i > game.state.remcom || game.state.rembase == 0 ||
!game.state.galaxy[game.battle.x][game.battle.y].starbase) {
/* No action to take after all */
- game.battle.x = game.battle.y = 0;
+ invalidate(game.battle);
break;
}
}
game.battle = hold;
game.isatb = 0;
}
- else {
- game.battle.x = game.battle.y = 0;
- }
+ else
+ invalidate(game.battle);
break;
case FSCMOVE: /* Supercommander moves */
schedule(FSCMOVE, 0.2777);
crmena(true, IHP, sector, scratch);
prout(_(" destroyed."));
DESTROY(&game.state.plnets[game.iplnet]);
- game.iplnet = game.plnet.x = game.plnet.y = 0;
+ game.iplnet = 0;
+ invalidate(game.plnet);
if (game.landed) {
finish(FPNOVA);
return;
break;
game.state.baseq[i] = game.state.baseq[game.state.rembase];
game.state.rembase--;
- game.base.x = game.base.y = 0;
+ invalidate(game.base);
game.state.basekl++;
newcnd();
crmena(true, IHB, sector, scratch);
for (l = 1; l <= maxloop; l++) {
if (same(game.state.kcmdr[l], nq)) {
game.state.kcmdr[l] = game.state.kcmdr[game.state.remcom];
- game.state.kcmdr[game.state.remcom].x = game.state.kcmdr[game.state.remcom].y = 0;
+ invalidate(game.state.kcmdr[game.state.remcom]);
game.state.remcom--;
kldead--;
if (game.state.remcom==0) unschedule(FTBEAM);
for (loop = 1; loop <= maxloop; loop++)
if (same(game.state.baseq[loop], nq)) {
game.state.baseq[loop] = game.state.baseq[game.state.rembase];
- game.state.baseq[game.state.rembase].x = game.state.baseq[game.state.rembase].y = 0;
+ invalidate(game.state.baseq[game.state.rembase]);
game.state.rembase--;
break;
}
prout(_("You must first leave standard orbit."));
return;
}
- if (game.base.x==0 || abs(game.sector.x-game.base.x) > 1 || abs(game.sector.y-game.base.y) > 1) {
+ if (!is_valid(game.base) || abs(game.sector.x-game.base.x) > 1 || abs(game.sector.y-game.base.y) > 1) {
crmshp();
prout(_(" not adjacent to base."));
return;
game.isatb = 0;
unschedule(FCDBAS);
unschedule(FSCDBAS);
- game.battle.x = game.battle.y = 0;
+ invalidate(game.battle);
/* Make sure Galileo is consistant -- Snapshot may have been taken
when on planet, which would give us two Galileos! */
break;
}
}
- if (game.sector.x==0){
+ if (!is_valid(game.sector)){
prout(_("You have been lost in space..."));
finish(FMATERIALIZE);
return;
prout(_("Both warp and impulse engines damaged."));
return;
}
- if (game.plnet.x == 0 || abs(game.sector.x-game.plnet.x) > 1 || abs(game.sector.y-game.plnet.y) > 1) {
+ if (!is_valid(game.plnet) || abs(game.sector.x-game.plnet.x) > 1 || abs(game.sector.y-game.plnet.y) > 1) {
crmshp();
prout(_(" not adjacent to planet."));
skip(1);
for (i=0; i < NDEVICES; i++)
game.damage[i] = 0.0;
// Set up assorted game parameters
- game.battle.x = game.battle.y = 0;
+ invalidate(game.battle);
game.state.date = game.indate = 100.0*(int)(31.0*Rand()+20.0);
game.nkinks = game.nhelp = game.casual = game.abandoned = 0;
game.iscate = game.resting = game.imine = game.icrystl = game.icraft = false;
thing = randplace(GALSIZE);
}
else
- thing.x = thing.y = 0;
+ invalidate(thing);
skip(2);
game.state.snap = false;
struct quadrant *q;
game.justin = true;
- game.base.x = game.base.y = 0;
+ invalidate(game.base);
game.klhere = 0;
game.comhere = false;
- game.plnet.x = game.plnet.y = 0;
+ invalidate(game.plnet);
game.ishere = false;
game.irhere = 0;
game.iplnet = 0;
#define square(i) ((i)*(i))
#define same(c1, c2) ((c1.x == c2.x) && (c1.y == c2.y))
#define distance(c1, c2) sqrt(square(c1.x - c2.x) + square(c1.y - c2.y))
+#define invalidate(w) w.x = w.y = 0
+#define is_valid(w) (w.x == 0 || w.y == 0)
typedef struct {
coord w;