|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 1756 (0x6dc)
Types: TextFile
Names: »coup.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/X/Xtrek/coup.c«
static char sccsid[] = "@(#)coup.c 1.1";
/*
Copyright (c) 1986 Chris Guthrie
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation. No representations are made about the
suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
*/
#include <X11/Xlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "defs.h"
#include "data.h"
/* throw a coup */
coup(p)
register struct player *p;
{
register int i;
register struct planet *l;
if (p->p_kills < 1.0) {
warning(p, "You must have one kill to throw a coup");
return;
}
if (!(p->p_flags & PFORBIT)) {
warning(p, "You must orbit your home planet to throw a coup");
return;
}
for (i = 0, l = &planets[0]; i < MAXPLANETS; i++, l++) {
if ((l->pl_owner == p->p_team) && (l->pl_armies > 0)) {
warning(p, "You already own a planet!!!");
return;
}
}
l = &planets[p->p_planet];
if ((!(l->pl_flags & PLHOME)) || ((l->pl_flags & ALLTEAM) != p->p_team)) {
warning(p, "You must orbit your home planet to throw a coup");
return;
}
if (l->pl_armies > 4) {
warning(p, "Too many armies on planet to throw a coup");
return;
}
if (l->pl_couptime > 0) {
warning(p, "Planet not yet ready for a coup");
return;
}
if (l->pl_flags & PLCOUP) { /* Avoid race conditions */
return;
}
/* the cases are now met. We can have a coup. */
l->pl_flags |= PLCOUP;
p->p_stats.st_coups++;
}