|
|
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 n
Length: 3488 (0xda0)
Types: TextFile
Names: »name.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Gb/name.c«
/*
* Galactic Bloodshed (Robert Chansky, smq@b)
* name.c -- rename something to something else
*/
#include "vars.h"
#include "races.h"
#include "ships.h"
#include <ctype.h>
#include <signal.h>
#include <setjmp.h>
#include <strings.h>
extern jmp_buf main_jenv;
int name_shdata,name_stardata;
name(APcount, argn,args)
int APcount;
int argn;
char args[MAXARGS][COMMANDSIZE];
{
planettype *p;
placetype where;
char st[COMMANDSIZE],*ch;
register int i;
bool check=0;
int name_handler();
name_stardata = NEUTRAL_FD;
signal(SIGINT, name_handler);
if (argn==1) { /* no args */
printf("Rename: ");
scanf("%[^\n]",st);
getchr();
} else sscanf(args[1],"%s",st);
if (!strcmp(st,"race")) {
if (!enufAP(Sdata.AP, APcount));
/*free(Race);
getrace(&Race, Race->Playernum);*/
printf("Change racial name %s to:",Race->name);
dots(RNAMESIZE);
scanf("%[^\n]",Race->name);
getchr();
putrace(Race);
deductAPs(APcount, 0, 1);
return;
}
where = Getplace(st,0);
if (where.err) {
printf("Not found.\n");
return;
} else if (where.level==LEVEL_SHIP) {
printf("You cannot name a ship.\n");
return;
}
printf("Rename %s%s to:", (where.level==LEVEL_SHIP) ?
"ship " : "" , Dispplace(&where) );
dots(NAMESIZE); /* make a bunch of dots */
scanf("%20[^\n]",st); /* change "20" if NAMESIZE altered */
getchr();
ch = st;
while (*ch!='\0')
check |= (iscntrl(*ch) || (*(ch++)=='/') );
/* make sure there are no ^'s or '/' in name */
if (strlen(st) < 1 || check) {
printf("Illegal name %s.\n", check ? "form" : "length" );
name_handler();
}
switch (where.level) {
case LEVEL_STAR:
openstardata(&name_stardata);
free(Stars[where.snum]);
getstar(name_stardata, &Stars[where.snum], where.snum);
if (!enufAP(Stars[where.snum]->AP, APcount))
name_handler();
/* can't name the place if you don't have the most AP's */
if (!MostAPs(Stars[where.snum])) {
printf("You don't have the most AP's in that system.\n");
name_handler();
}
strncpy(Stars[where.snum]->name,st,NAMESIZE-1);
putstar(name_stardata, Stars[where.snum], where.snum);
close(name_stardata);
deductAPs(APcount, where.snum, 0);
break;
case LEVEL_PLAN:
openstardata(&name_stardata);
free(Stars[where.snum]);
getstar(name_stardata, &Stars[where.snum], where.snum);
if (!MostAPs(Stars[where.snum])) {
printf("You don't have the most AP's in that system.\n");
name_handler();
}
strncpy(Stars[where.snum]->pnames[where.pnum],st,NAMESIZE-1);
putstar(name_stardata, Stars[where.snum], where.snum);
close(name_stardata);
deductAPs(APcount, where.snum, 0);
break;
/*case LEVEL_SHIP:
/* shipptr already gotten */
/*if (where.shipptr->owner!=Playernum || where.err) {
printf("Name: bad ship #.\n");
DontOwnErr(where.shipno);
name_handler();
}
strncpy(where.shipptr->name,st,NAMESIZE-1);
openshdata(&name_shdata);
putship(name_shdata, where.shipptr, where.shipno);
close(name_shdata);
if (where.shipptr->whatorbits==LEVEL_UNIV)
deductAPs(APcount, 0, 1);
else
deductAPs(APcount, where.shipptr->storbits, 0);
break;*/
case LEVEL_UNIV:
default:
printf("You can't do that.\n");
return;
}
docommand("cs :"); /* trick */
}
int MostAPs(s)
startype *s;
{
register int i,t = 0;
for (i=0; i<MAXPLAYERS; i++)
if (s->AP[i] > s->AP[t])
t = i;
return (t == Playernum);
}
name_handler(sig, code, scp)
int sig,code;
struct sigcontext *scp;
{
close(name_stardata);
close(name_shdata);
longjmp(main_jenv,1);
}