|
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 c
Length: 4377 (0x1119) Types: TextFile Names: »cs.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Gb/cs.c«
/* * Galactic Bloodshed (Robert Chansky, smq@b) * cs.c -- change scope operand (directory) */ #include "vars.h" #include "ships.h" #include "races.h" cs(APcount, argn,args) int APcount; int argn; char args[MAXARGS][COMMANDSIZE]; { placetype where; planettype *planet; shiptype *s; int cs_shdata,cs_pdata; if (argn==1) { /* chdir to def scope */ Dir.level = Race->deflevel; Dir.snum = Race->defsystem; Dir.pnum = Race->defplanetnum; Dir.shipno = 0; Dir.lastx = Dir.lasty = 0.0; docommand("cs :"); /* trick -- adjust prompt */ return; } else if (argn==2) { /* chdir to specified scope */ where = Getplace(args[1],0); /* do not ignore the fact that you've not explored the place */ if (where.err) { printf("cs: bad scope.\n"); Dir.lastx = Dir.lasty = 0.0; return; } /* fix lastx, lasty coordinates */ switch (Dir.level) { case LEVEL_UNIV: Dir.lastx = Dir.lasty = 0.0; break; case LEVEL_STAR: if (where.level==LEVEL_UNIV) { Dir.lastx = Stars[Dir.snum]->xpos; Dir.lasty = Stars[Dir.snum]->ypos; } else Dir.lastx = Dir.lasty = 0.0; break; case LEVEL_PLAN: openpdata(&cs_pdata); getplanet(cs_pdata,&planet,Stars[Dir.snum]->planetpos[Dir.pnum]); close(cs_pdata); if (where.level==LEVEL_STAR && where.snum==Dir.snum) { Dir.lastx = planet->xpos; Dir.lasty = planet->ypos; } else if (where.level==LEVEL_UNIV) { Dir.lastx = Stars[Dir.snum]->xpos + planet->xpos; Dir.lasty = Stars[Dir.snum]->ypos + planet->ypos; } else Dir.lastx = Dir.lasty = 0.0; free(planet); break; case LEVEL_SHIP: openshdata(&cs_shdata); getship(cs_shdata, &s, Dir.shipno); close(cs_shdata); if (!s->is_docked) { switch (where.level) { case LEVEL_UNIV: Dir.lastx = s->xpos; Dir.lasty = s->ypos; break; case LEVEL_STAR: if (s->whatorbits>=LEVEL_STAR && s->storbits==where.snum) { /* we are going UP from the ship.. change last*/ Dir.lastx = s->xpos - Stars[s->storbits]->xpos; Dir.lasty = s->ypos - Stars[s->storbits]->ypos; } else Dir.lastx = Dir.lasty = 0.0; break; case LEVEL_PLAN: if (s->whatorbits==LEVEL_PLAN && s->storbits==where.snum && s->pnumorbits==where.pnum) { /* same */ openpdata(&cs_pdata); getplanet(cs_pdata,&planet,Stars[s->storbits]->planetpos[s->pnumorbits]); close(cs_pdata); Dir.lastx = s->xpos - Stars[s->storbits]->xpos - planet->xpos; Dir.lasty = s->ypos - Stars[s->storbits]->ypos - planet->ypos; free(planet); } else Dir.lastx = Dir.lasty = 0.0; break; case LEVEL_SHIP: Dir.lastx = Dir.lasty = 0.0; break; default: break; } } else Dir.lastx = Dir.lasty = 0.0; free(s); break; default: break; } Dir.level = where.level; Dir.snum = where.snum; Dir.pnum = where.pnum; Dir.shipno = where.shipno; printf(" csing to st %d, pl %d\n",where.snum,where.pnum); /* fix prompt */ switch (Dir.level) { case LEVEL_UNIV: sprintf(Dir.prompt," [%02d] / >",Sdata.AP[Playernum]); break; case LEVEL_STAR: sprintf(Dir.prompt," / [%02d] %s >", Stars[Dir.snum]->AP[Playernum], Stars[Dir.snum]->name); break; case LEVEL_SHIP: switch (where.shipptr->whatorbits) { /* what orbits around */ case LEVEL_UNIV: sprintf(Dir.prompt," [%02d] / #%d >", Stars[Dir.snum]->AP[Playernum], where.shipno); break; case LEVEL_STAR: sprintf(Dir.prompt," / [%02d] %s / #%d >", Stars[Dir.snum]->AP[Playernum], Stars[Dir.snum]->name, where.shipno); break; case LEVEL_PLAN: sprintf(Dir.prompt," / [%02d] %s / %s / #%d >", Stars[Dir.snum]->AP[Playernum], Stars[Dir.snum]->name, Stars[Dir.snum]->pnames[Dir.pnum], where.shipno); break; } free(where.shipptr); break; case LEVEL_PLAN: sprintf(Dir.prompt," / [%02d] %s / %s >", Stars[Dir.snum]->AP[Playernum], Stars[Dir.snum]->name, Stars[Dir.snum]->pnames[Dir.pnum]); break; default: break; } } else if (argn==3 && args[1][1]=='d') { /* make new def scope */ where = Getplace(args[2],0); if (!where.err) { Race->homelevel = where.level; Race->homesystem = where.snum; Race->homeplanetnum = where.pnum; putrace(Race); docommand("cs"); /* chdir to home scope */ printf("New home system is %s\n",Dispplace(&where)); } else { printf("cs: bad home system.\n"); return; } } }