|
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 m
Length: 1973 (0x7b5) Types: TextFile Names: »mobiliz.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Gb/mobiliz.c«
/* * Galactic Bloodshed (Robert Chansky, smq@b) * mobilize.c -- persuade people to build military stuff. * Sectors that are mobilized produce Destructive Potential in * proportion to the % they are mobilized. they are also more * damage-resistant. */ #include "vars.h" #include <signal.h> #include <setjmp.h> #include <ctype.h> extern jmp_buf main_jenv; int mobilize_sectdata,mobilize_pdata; mobilize(APcount, argn, args) int APcount, argn; char args[MAXARGS][COMMANDSIZE]; { int owned=0,x,y,sum_mob=0; sectortype *s; planettype *p; int mobilize_handler(); mobilize_pdata = mobilize_sectdata = NEUTRAL_FD; signal(SIGINT, mobilize_handler); if (argn>1) { printf("usage: mobilize\n"); return; } if (Dir.level!=LEVEL_PLAN) { printf("scope must be a planet.\n"); return; } if (!enufAP(Stars[Dir.snum]->AP, APcount)) mobilize_handler(); openpdata(&mobilize_pdata); getplanet(mobilize_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]); opensectdata(&mobilize_sectdata); getsmap(mobilize_sectdata,Smap,p->sectormappos,p->Maxx*p->Maxy); close(mobilize_sectdata); for (y=0; y<p->Maxy; y++) for (x=0; x<p->Maxx; x++) { s = &Sector(*p,x,y); if (s->owner==Playernum) { sum_mob += s->mobilization; owned++; } } p->info[Playernum-1].numsectsowned = owned; printf("(cost:%.3f resource points / 1 mobilization pt.)\n", MOB_COST); printf("Number of sectors owned: %d.\n",owned); printf(" Average mobilization: %.1f.\n",(float)sum_mob / owned); printf(" Old mobilization quota: %u.\n",p->info[Playernum-1].mob_set); printf(" New quota: "); if ( isdigit(x=getchr())) { ungetc(x,stdin); scanf("%d",&sum_mob); getchr(); p->info[Playernum-1].mob_set = sum_mob; putplanet(mobilize_pdata,p,Stars[Dir.snum]->planetpos[Dir.pnum]); } close(mobilize_pdata); free(p); } mobilize_handler(sig, code, scp) int sig,code; struct sigcontext *scp; { close(mobilize_pdata); close(mobilize_sectdata); longjmp(main_jenv,1); }