|
|
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 s
Length: 3300 (0xce4)
Types: TextFile
Names: »shlmisc.c.orig«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Gb/shlmisc.c.orig«
/*
* Galactic Bloodshed (Robert Chansky, smq@b)
* miscellaneous stuff included in the shell
*/
#include "vars.h"
#include "races.h"
#include <signal.h>
#include <ctype.h>
#include <stdio.h>
DontOwnErr(shipno)
register int shipno;
{
printf("You don't own ship #%d.\n",shipno);
}
int enufAP(AP, x)
char *AP;
register int x;
{
register int blah;
if (blah = (AP[Playernum] < x) ) {
printf("You don't have %d action points there.\n", x);
}
return (!blah);
}
int Getracenum(login)
char *login;
{
register int i = 0;
char s[LOGIN_NAME_SIZE];
FILE *fd;
fd = fopen(PLAYERDATAFL, "r");
s[0] = '\0';
while (!feof(fd) && strcmp(s,login) ) {
i++;
fscanf(fd,"%s",s);
}
fclose(fd);
return( (strcmp(s,login)) ? 0 : i );
}
/* returns player # from string containing that players name or #. */
GetPlayer(name, rnum, race)
char *name;
int *rnum;
racetype **race;
{
int numraces;
register int i,l;
numraces = Numraces();
*rnum = 0;
if (isdigit(*name)) {
if ( (*rnum = atoi(name)) < 1 || *rnum > numraces) {
*rnum = -1;
return;
} else {
printf(" player %d\n",*rnum);
getrace(race, *rnum);
return;
}
} else {
l = strlen(name);
for (i=1; !(*rnum) && i<=numraces; i++) {
getrace(race, i);
if (!strncmp(name, (*race)->name, l)) {
printf(" player %d\n",i);
*rnum = i;
return;
} else
free(*race);
}
}
}
int deductAPs(n, snum, sdata)
int n, snum;
int sdata; /* whether or not sdata is involved */
{
int deductAPs_stardata, mask;
if (n) {
mask = sigblock(SIGINT|SIGQUIT|SIGSTOP);
/* keep people from cheating */
openstardata(&deductAPs_stardata);
if (!sdata) {
free(Stars[snum]);
getstar(deductAPs_stardata, &Stars[snum], snum);
if (Stars[snum]->AP[Playernum] >= n)
Stars[snum]->AP[Playernum] -= n;
else {
Stars[snum]->AP[Playernum] = 0;
printf("WHOA! You cheater! Oooohh! OOOOH!\n I'm tellllllllliiiiiiinnnnnnnnnggggggggg!!!!!!!\n");
exit(-1);
}
putstar(deductAPs_stardata, Stars[snum], snum);
if (Dir.level!=LEVEL_UNIV && Dir.snum == snum) {
/* fix the prompt */
sprintf(Dir.prompt + 4, "%02d", Stars[snum]->AP[Playernum]);
Dir.prompt[6] = ']'; /* fix bracket (made '\0' by sprintf)*/
}
} else {
getsdata(deductAPs_stardata,&Sdata);
Sdata.AP[Playernum] -= n;
if (Sdata.AP[Playernum] < 0)
Sdata.AP[Playernum] = 0;
putsdata(deductAPs_stardata,&Sdata);
if (Dir.level==LEVEL_UNIV) {
sprintf(Dir.prompt + 2, "%02d", Sdata.AP[Playernum]);
Dir.prompt[3] = ']';
}
}
close(deductAPs_stardata);
sigsetmask(mask);
}
}
GetMapSector(pl, x, y)
planettype *pl;
int *x, *y;
{
char c;
*x = -1;
do {
printf(" what sector (0-%d,0-%d,'?' for map): ",pl->Maxx-1,pl->Maxy-1);
while ( !(isdigit(c=getchr()) || c=='?' || c=='-') )
;
/*if (isdigit(c) || c=='-')
ungetc(c,stdin);*/
if (c=='?') {
getchr(); /* get \n */
show_map(pl,0); /* don't show extraneous data */
} else if (isdigit(c) || c=='-') {
ungetc(c,stdin);
scanf("%d,%d", x, y);
getchr();
}
} while ((*x)<0 || (*x)>=pl->Maxx || (*y)<0 || (*y)>=pl->Maxy);
}
void dots(i)
register int i;
{
register int j;
for (j=0; j<i; j++)
putchar('.');
for (j=0; j<i; j++)
putchar('\010');
}