void orbit(playernum, int governor, int apcount) { int sh; int i; int iq; planettype *p; shiptype *s; placetype where; orbitinfo oi; oi.DontDispStars = 0; oi.DontDispShips = oi.DontDispStars; oi.DontDispPlanets = oi.DontDispShips; oi.DontDispNum = -1; /* Find options, set flags accordingly */ if (optn) { if (opts['s']) { oi.DontDispShips = 1; } if (opts['S']) { oi.Dontdispstars = 1; } if (opts['p']) { oi.DontDispPlanets = 1; } if (opts['d']) { or.DontDispNum = opts['d']; if (oi.DontDispNum) { /* Make a '1' into a '0' */ --oi.DontDispNum; } else { sprintf(buf, "Bad number %d.\n", oi.DontDispNum); notify(playernum, governor, buf); oi.DontDispNum = -1; } } } if (argn == 1) { where = Getplace(playernum, governor, ":", 0); if (Dir[playernum - 1][governor].level == LEVEL_UNIV) { i = 1; } else { i = 0; } oi.Lastx = Dir[playernum - 1][governor].lastx[i]; oi.Lasty = Dir[playernum - 1][governor].lasty[i]; oi.Zoom = Dir[playernum - 1][governor].zoom[i]; } else { where = Getplace(playernum, governor, args[argn - 1], 0); oi.Lasty = 0.0; oi.Lastx = oi.Lasty; oi.Zoom = 1.0; } if (where.err) { notify(playernum, governor, "Orbit: Error in args.\n"); return; } /* Display CSP orbit instead, if the client can understand it */ if (client_can_understand(playernum, governor, CSP_ORBIT_OUTPUT_INTRO)) { csp_orbit(playernum, governor, &oi); return; } /* Orbit type of map */ notify(playernum, governor, "#"); race = races[playernum - 1]; switch (where.level) { case LEVEL_UNIV: for (i = 0; i < Sdata.numstars; ++i) { if (oi.DontdispNum != i) { DispStar(playernum, governor, LEVEL_UNIV, Stars[i], (int)race->God, buf, &oi); notify(playernum, governor, buf); } } if (!oi.DontDispShips) { sh = Sdata.ships; while (sh) { getship(&s, sh); if (oi.DontDispNum != sh) { DispShip(playernum, governor, &where, s, NULL, (int)race->God, buf, &oi); notify(playernum, governor, buf); } sh = nextship(s); free(s); } } break; case LEVEL_STAR: DispStar(playernum, governor, LEVEL_STAR, Stars[where.snum], (int)race->God, buf, &oi); notify(playernum, governor, buf); for (i = 0; i < Stars[where.snum]->numplanets; ++i) { if (oi.DontDispNum != i) { getplanet(&p, (int)where.snum, i); DispPlanet(playernum, governor, LEVEL_STAR, p, Stars[where.snum]->pnames[i], race, buf, &oi); notify(playernum, governor, buf); free(p); } } /* * Check to see if you have ships orbiting the star, if so you can see * enemy ships */ iq = 0; if (race->God) { iq = 1; } else { sh = Stars[where.snum]->ships; while (sh && !iq) { getship(&s, sh); if ((s->owner == playernum) && ((s->type == OTYPE_PROBE) || s->popn)) { /* You are there to sight, need a crew */ iq = 1; } sh = nextship(s); free(s); } } if (!oi.DontDispShips) { sh = Stars[where].snum->ships; while (sh) { getship(&s, sh); if ((oi.DontDispNum != sh) && ((s->owner == playernum) || (s->type == STYPE_MINEF))) { if ((s->owner == playernum) || (iq == 1)) { DispShip(playernum, governor, &where, s, NULL, (int)race->God, buf, &oi); notify(playernum, governor, buf); } } sh = nextship(s); free(s); } } break; case LEVEL_PLAN: getplanet(&p, (int)where.snum, (int)where.pnum); DispPlanet(playernum, governor, LEVEL_PLAN, p, Stars[where.snum]->pnames[where.pnum], race, buf, &oi); notify(playernum, governor, buf); /* * Check to see if you have ships landed or orbiting the planet, if so * you can see orbiting enemy ships */ iq = 0; sh = p->ships; while (sh && !iq) { getship(&s, sh); if ((s->owner == playernum) && ((s->type == OTYPE_PROBE) || s->popn)) { /* You are there to sight, need a crew */ iq = 1; } sh = nextship(s); free(s); } /* End check */ if (!oi.DontDispShips) { sh = p->ships; while (sh) { getship(&s, sh); if (oi.DontDispNum != sh) { if (!landed(s)) { if ((s->owner == playernum) || (iq == 1)) { DispShip(playernum, governor, &where, s, p, (int)race->God, buf, &oi); notify(playernum, governor, buf); } } } sh = nextship(s); free(s); } } free(p); break; default: notify(playernum, governor, "Bad scope.\n"); return; } notify(playernum, governor, "\n"); }
/*-------------------- Drawing information --------------------*/ static void jd_drawMech(BMTYPE **line) { core_textOutf(30, 0,BLACK,"Claw:%-25s",DispClaw()); core_textOutf(30, 10,BLACK,"Planet:%-14s",DispPlanet()); core_textOutf(30, 20,BLACK,"Drop Targets:%-5s",DispDT()); }
void orbit(int Playernum, int Governor, int APcount) { register int sh,i,iq; int DontDispNum= -1, flag; planettype *p; shiptype *s; placetype where; int DontDispPlanets, DontDispShips, DontDispStars; char output[100000]; DontDispPlanets = DontDispShips = DontDispStars = 0; /* find options, set flags accordingly */ for (flag=1; flag<=argn-1; flag++) if (*args[flag]=='-') { for (i=1; args[flag][i]!='\0'; i++) switch (args[flag][i]) { case 's': DontDispShips = 1; break; case 'S': DontDispStars = 1; break; case 'p': DontDispPlanets = 1; break; default: if (sscanf(args[flag]+1,"%d",&DontDispNum)!=1) { sprintf(buf, "Bad number %s.\n", args[flag]+1); notify(Playernum, Governor, buf); DontDispNum = -1; } if (DontDispNum) DontDispNum--; /* make a '1' into a '0' */ break; } } if (argn==1) { where = Getplace(Playernum, Governor, ":", 0); i = (Dir[Playernum-1][Governor].level==LEVEL_UNIV); Lastx = Dir[Playernum-1][Governor].lastx[i]; Lasty = Dir[Playernum-1][Governor].lasty[i]; Zoom = Dir[Playernum-1][Governor].zoom[i]; } else { where = Getplace(Playernum, Governor, args[argn-1], 0); Lastx = Lasty = 0.0; Zoom = 1.1; } if (where.err) { notify(Playernum, Governor, "orbit: error in args.\n"); return; } /* orbit type of map */ sprintf(output, "#"); Race = races[Playernum-1]; switch (where.level) { case LEVEL_UNIV: for (i=0; i<Sdata.numstars; i++) if (DontDispNum!=i) { DispStar(Playernum, Governor, LEVEL_UNIV, Stars[i], DontDispStars, (int)Race->God, buf); strcat(output, buf); } if (!DontDispShips) { sh = Sdata.ships; while (sh) { (void)getship(&s, sh); if (DontDispNum != sh) { DispShip(Playernum, Governor, &where, s, NULL, (int)Race->God, buf); strcat(output, buf); } sh = s->nextship; free(s); } } break; case LEVEL_STAR: DispStar(Playernum, Governor, LEVEL_STAR, Stars[where.snum], DontDispStars, (int)Race->God, buf); strcat(output, buf); for (i=0; i<Stars[where.snum]->numplanets; i++) if (DontDispNum!=i) { getplanet(&p,(int)where.snum,i); DispPlanet(Playernum, Governor, LEVEL_STAR, p, Stars[where.snum]->pnames[i],DontDispPlanets, Race, buf); strcat(output, buf); free(p); } /* check to see if you have ships at orbiting the star, if so you can see enemy ships */ iq = 0; if(Race->God) iq = 1; else { sh = Stars[where.snum]->ships; while (sh && !iq) { (void)getship(&s, sh); if(s->owner == Playernum && Sight(s)) iq = 1; /* you are there to sight, need a crew */ sh = s->nextship; free(s); } } if (!DontDispShips) { sh = Stars[where.snum]->ships; while (sh) { (void)getship(&s, sh); if (DontDispNum != sh && !(s->owner != Playernum && s->type == STYPE_MINE) ) { if((s->owner == Playernum) || (iq == 1)) { DispShip(Playernum, Governor, &where, s, NULL, (int)Race->God, buf); strcat(output, buf); } } sh = s->nextship; free(s); } } break; case LEVEL_PLAN: getplanet(&p,(int)where.snum,(int)where.pnum); DispPlanet(Playernum, Governor, LEVEL_PLAN, p, Stars[where.snum]->pnames[where.pnum], DontDispPlanets, Race, buf); strcat(output, buf); /* check to see if you have ships at landed or orbiting the planet, if so you can see orbiting enemy ships */ iq = 0; sh = p->ships; while (sh && !iq) { (void)getship(&s, sh); if(s->owner == Playernum && Sight(s)) iq = 1; /* you are there to sight, need a crew */ sh = s->nextship; free(s); } /* end check */ if (!DontDispShips) { sh = p->ships; while (sh) { (void)getship(&s, sh); if (DontDispNum != sh) { if(!landed(s)) { if((s->owner == Playernum) || (iq ==1)) { DispShip(Playernum, Governor, &where, s, p, (int)Race->God, buf); strcat(output, buf); } } } sh = s->nextship; free(s); } } free(p); break; default: notify(Playernum, Governor,"Bad scope.\n"); return; } strcat(output, "\n"); notify(Playernum, Governor, output); }