|
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: 2326 (0x916) Types: TextFile Names: »scrap.c.orig«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Gb/scrap.c.orig«
/* * Galactic Bloodshed (Robert Chansky, smq@ucscb.ucsc.edu) * scrap.c -- turn a ship to junk */ #include "vars.h" #include "ships.h" #include <signal.h> #include <curses.h> #include <setjmp.h> extern jmp_buf main_jenv; extern int Shipdata[NUMSTYPES][NUMABILS]; extern int Ignore_filelocks; int scrap_shdata, scrap_pdata; scrap(APcount, argn,args) int APcount; int argn; char args[MAXARGS][COMMANDSIZE]; { planettype *planet; sectortype *sect; shiptype *s; int i,shfdata,mask,shipno,scrapval; int scrap_handler(); scrap_shdata = scrap_pdata = NEUTRAL_FD; signal(SIGINT, scrap_handler); if (argn<2) { printf("ship #"); scanf("%d",&shipno); getchr(); } else sscanf(args[1] + ((*args[1]=='#') ? 1 : 0), &shipno); openshdata(&scrap_shdata); if (!getship(scrap_shdata,&s,shipno)) { scrap_handler(); } if (s->owner!=Playernum || s->is_dead) { DontOwnErr(shipno); free(s); scrap_handler(); } if ( !(s->is_docked && s->whatdest==LEVEL_PLAN)) { printf("%s #%d is not landed.\n",Shipnames[s->type], shipno); free(s); scrap_handler(); } if (!enufAP(Stars[s->storbits]->AP, APcount)) { printf("Not enough AP's (%d).\n",APcount); return; } openpdata(&scrap_pdata); getplanet(scrap_pdata, &planet, Stars[s->storbits]->planetpos[s->pnumorbits]); scrapval = Shipdata[s->type][ABIL_COST] * .75 + s->resource; tty_on(); printf("%s #%d:original cost: %d\n", Shipnames[s->type], shipno, Shipdata[s->type][ABIL_COST]); printf(" scrap value%s: %d. Junk (y/n)?", s->resource ? "(with stockpile) " : "", scrapval); if (getchr()!='y') { tty_off(); putchr('\n'); scrap_handler(); } deductAPs(APcount, s->storbits, 0); tty_off(); puts("\njunked.\n"); for (i=0; i<MAXPSHIPS; i++) if (planet->shipnums[i] == shipno) { planet->shipnums[i] = 0; planet->numships--; } openshfdata(&shfdata); destroyship(shfdata, shipno); close(shfdata); planet->info[Playernum-1].resource += scrapval; planet->info[Playernum-1].destruct += s->destruct; planet->info[Playernum-1].fuel += s->fuel; putplanet(scrap_pdata, planet, Stars[s->storbits]->planetpos[s->pnumorbits]); close(scrap_pdata); putship(scrap_shdata,s,shipno); close(scrap_shdata); free(s); sigsetmask(mask); /* reset mask */ } scrap_handler() { close(scrap_shdata); close(scrap_pdata); longjmp(main_jenv,1); }