|
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 l
Length: 3757 (0xead) Types: TextFile Names: »launch.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Gb/launch.c«
/* * Galactic Bloodshed (Robert Chansky, smq@b) * launch.c -- launch or undock a ship */ #include "vars.h" #include "ships.h" #include <setjmp.h> extern jmp_buf main_jenv; #include <signal.h> int launch_shdata,launch_pdata; extern int Ignore_filelocks; launch(APcount, argn,args) int APcount; int argn; char args[MAXARGS][COMMANDSIZE]; { int launch_handler(); shiptype *s,*s2; planettype *p; bool planet=0; int shipno,o; float fuel; launch_shdata = launch_pdata = NEUTRAL_FD; signal(SIGINT, launch_handler); if (argn!=2) { printf("Launch what ship #"); scanf("%d",&shipno); getchr(); } else { o = (args[1][0]=='#'); sscanf(args[1]+o,"%d",&shipno); } openshdata(&launch_shdata); if (!getship(launch_shdata, &s, shipno)) { launch_handler(); } if (s->owner!=Playernum) { DontOwnErr(shipno); launch_handler(); } if (!can_move(s)) { printf("That cannot be launched.\n"); launch_handler(); } if (s->rad) { printf("%s irradiated and inactive.\n", Shipnames[s->type]); launch_handler(); } if (!s->is_docked) { printf("Ship #%d is not landed or docked.\n",shipno); launch_handler(); } if (s->whatdest==LEVEL_SHIP) { if (s->whatorbits==LEVEL_UNIV) if (!enufAP(Sdata.AP, APcount)) launch_handler(); else deductAPs(APcount, 0, 1); else if (!enufAP(Stars[s->storbits]->AP, APcount)) launch_handler(); else deductAPs(APcount, s->storbits, 0); Ignore_filelocks = 1; (void)getship(launch_shdata, &s2, s->destshipno); Ignore_filelocks = 0; s->is_docked = 0; s->whatdest = LEVEL_UNIV; /* no destination */ putship(launch_shdata, s, shipno); s2->is_docked = 0; s2->whatdest = LEVEL_UNIV; putship(launch_shdata, s2, s->destshipno); close(launch_shdata); free(s); free(s2); printf("%s #%d undocked from ship #%d", Shipnames[s->type], shipno, s->destshipno); } else { if (!enufAP(Stars[s->storbits]->AP, APcount)) launch_handler(); else deductAPs(APcount, s->storbits, 0); s->is_docked = 0; s->whatdest = LEVEL_UNIV; /* no destination */ /* adjust x,ypos to absolute coords */ openpdata(&launch_pdata); getplanet(launch_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]); if (p->is_explored) /* no alteration of the planet unless this.. */ close(launch_pdata); printf("Planet /%s/%s has gravity field of %.2f\n", Stars[s->storbits]->name, Stars[s->storbits]->pnames[s->pnumorbits], gravity(p)); /* alter sector location of ship x,y to stellar coords x,y */ s->xpos = Stars[s->storbits]->xpos + p->xpos + (float)int_rand((int)(-DIST_TO_LAND),(int)(DIST_TO_LAND)); s->ypos = Stars[s->storbits]->ypos + p->ypos + (float)int_rand((int)(-DIST_TO_LAND),(int)(DIST_TO_LAND)); /* subtract fuel from ship */ fuel = gravity(p) * s->mass * LAUNCH_GRAV_MASS_FACTOR; if (s->fuel < fuel) { printf("Ship #%d does not have enough fuel! (%.1f)\n",shipno, fuel); launch_handler(); } s->fuel -= fuel; s->mass -= fuel * MASS_FUEL; deductAPs(APcount, s->storbits, 0); if (s->type == OTYPE_CANIST) s->orders.object.number = 20; /* canister dissapates after 20 turns */ putship(launch_shdata, s, shipno); close(launch_shdata); if (!p->is_explored) { /* not yet explored by owner; space exploration causes the player to see a whole map */ p->is_explored = 1; putplanet(launch_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]); close(launch_pdata); } free(p); printf("%s #%d launched from planet,", Shipnames[s->type], shipno); printf(" using %.1f fuel.\n",fuel); if (s->type == OTYPE_CANIST) printf("A thick cloud of dust envelops your planet.\n"); free(s); } } launch_handler() { Ignore_filelocks = 0; close(launch_pdata); close(launch_shdata); longjmp(main_jenv,1); }