home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume10 / gb3 / part03 < prev    next >
Internet Message Format  |  1990-06-08  |  56KB

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v10i003:  gb3 - Galactic Bloodshed, an empire-like war game [Ver. 2.0], Part03/14
  5. Message-ID: <5694@tekred.CNA.TEK.COM>
  6. Date: 1 Jun 90 19:05:44 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 1853
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: VANCLEEF@mps.ohio-state.edu
  12. Posting-number: Volume 10, Issue 3
  13. Archive-name: gb3/Part03
  14. Supersedes: GB2: Volume 7, Issue 44-51
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 3 (of 14)."
  25. # Contents:  Docs/vessels.doc server/doplanet.c server/order.c
  26. #   server/ships.h
  27. # Wrapped by billr@saab on Fri Jun  1 11:53:32 1990
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'Docs/vessels.doc' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'Docs/vessels.doc'\"
  31. else
  32. echo shar: Extracting \"'Docs/vessels.doc'\" \(369 characters\)
  33. sed "s/^X//" >'Docs/vessels.doc' <<'END_OF_FILE'
  34. XVESSELS            Galactic Bloodshed            VESSELS
  35. X
  36. X
  37. XNAME
  38. X  [0] vessels -- describe the various ships that players may
  39. X          build during the game.
  40. X
  41. XSYNTAX
  42. X    vessels
  43. X
  44. XDESCRIPTION
  45. X   This command allows users to examine the various types
  46. Xof ships that can be built during the game. This enters the same
  47. Xhelp facility used with the 'build' command.
  48. X
  49. X
  50. XSEE ALSO
  51. X   build, examine
  52. X   
  53. X   
  54. END_OF_FILE
  55. if test 369 -ne `wc -c <'Docs/vessels.doc'`; then
  56.     echo shar: \"'Docs/vessels.doc'\" unpacked with wrong size!
  57. fi
  58. # end of 'Docs/vessels.doc'
  59. fi
  60. if test -f 'server/doplanet.c' -a "${1}" != "-c" ; then 
  61.   echo shar: Will not clobber existing file \"'server/doplanet.c'\"
  62. else
  63. echo shar: Extracting \"'server/doplanet.c'\" \(21893 characters\)
  64. sed "s/^X//" >'server/doplanet.c' <<'END_OF_FILE'
  65. Xint Sectormappos;
  66. X/*
  67. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  68. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  69. X * Restrictions in GB_copyright.h.
  70. X *  doplanet.c -- do one turn on a planet.
  71. X */ 
  72. X
  73. X#include "GB_copyright.h"
  74. X#define EXTERN extern
  75. X#include "vars.h"
  76. X#include "ships.h"
  77. X#include "races.h"
  78. X#include "doturn.h"
  79. X#include "power.h"
  80. X#include "buffers.h"
  81. X#include <math.h>
  82. X
  83. Xextern float compatibility();
  84. X
  85. X    /* types of accidents that can occur on a toxic planet. */
  86. Xchar *Accidents_uninhab[] = {
  87. X     /* on water sectors */
  88. X    "Widespread waste spill",
  89. X    "Ecological instability",
  90. X     /* on land sectors */
  91. X    "Massive volcanic eruptions",
  92. X    "Ecological instability",
  93. X     /* on mountain sectors */
  94. X    "Massive volcanic eruptions",
  95. X    "Ecological instability",
  96. X     /* gas sectors */
  97. X    "Lethal toxin concentration",
  98. X    "Ecological instability",
  99. X     /* ice */
  100. X    "Leak in isolated chemical plant",
  101. X    "Continental warming cause glacial melting",
  102. X     /* plate */
  103. X    "Nuclear accident",
  104. X    "Untended nuclear plant explodes"
  105. X};
  106. X
  107. Xchar *Accidents_inhab[] = {
  108. X    "Nuclear accident",
  109. X    "Terrorists trigger nuclear weapon",
  110. X    "Release of toxic waste",
  111. X    "Weapons dump explosion",
  112. X    "Massive starvation",
  113. X    "Virus epidemic",
  114. X    "famine",
  115. X    "starvation",
  116. X    "Widespread cultist suicide",
  117. X    "Atomic experiment gone wrong",
  118. X    "Great Hrung collapse"
  119. X};
  120. X
  121. X
  122. Xint doplanet(starnum,planet, planetnum)
  123. Xint starnum;
  124. Xplanettype *planet;
  125. Xint planetnum;
  126. X{
  127. Xint shipno,x,y,nukex,nukey;
  128. Xint o=0,j;
  129. Xchar *nukem;
  130. Xreg int i;
  131. Xsectortype *p;
  132. Xshiptype *ship;
  133. Xfloat madd,fadd;
  134. Xint sectdata,timer=20;
  135. Xint oldplanetpopn, oldplanetmaxpopn;
  136. Xboolean allmod=0,allexp=0;
  137. Xchar buf[200]; 
  138. X
  139. XSectormappos = planet->sectormappos;
  140. Xcheck(planet,0);
  141. Xif (!StarsInhab[starnum])
  142. X    return 0;    /* no one's here now */
  143. X
  144. Xif (Stinfo[starnum][planetnum].inhab) {
  145. X/*    printf(" getting sectmap pos %d\n",planet->sectormappos); */
  146. X    opensectdata(§data);
  147. X    getsmap(sectdata,Smap,planet);
  148. X    close_file(sectdata);
  149. X
  150. X    PermuteSects(planet);
  151. X    bzero((char *)Sectinfo, sizeof(Sectinfo) );
  152. X}
  153. X
  154. X
  155. X
  156. Xcheck(planet,1);
  157. X  shipno = planet->ships;
  158. X
  159. X  while (shipno) {
  160. X
  161. X    if ( ((ship = ships[shipno])!=NULL) && ship->is_alive && !ship->rad) {
  162. X
  163. X       if ( !(ship->is_docked && ship->whatdest==LEVEL_PLAN)) {
  164. X         /* add fuel to ships orbiting gas giants */
  165. X        if (planet->type == TYPE_GASGIANT) {
  166. X         if (ship->type == STYPE_TANKER) {
  167. X            fadd = FUEL_GAS_ADD_TANKER;
  168. X            madd = FUEL_GAS_ADD_TANKER*MASS_FUEL;
  169. X         } else if (ship->type == STYPE_HABITAT) {
  170. X            fadd = FUEL_GAS_ADD_HABITAT;
  171. X            madd = FUEL_GAS_ADD_HABITAT*MASS_FUEL;
  172. X         } else {
  173. X            fadd = FUEL_GAS_ADD;
  174. X            madd = FUEL_GAS_ADD*MASS_FUEL;
  175. X         }
  176. X         if (ship->fuel + fadd > Max_fuel(ship)) {
  177. X            madd -= (Max_fuel(ship) - (ship->fuel+fadd))*MASS_FUEL;
  178. X            fadd = Max_fuel(ship)-(ship->fuel+fadd);
  179. X         }
  180. X         ship->fuel += fadd;
  181. X         ship->mass += madd;
  182. X        }
  183. X       }
  184. X
  185. X        if (ship->type == OTYPE_VN || (ship->type==OTYPE_BERS && !ship->destruct)) {         
  186. X                                        /* Von Neumann machine/unarmed Berserker */
  187. X             planet_doVN(ship,shipno,planet);
  188. X        } else if (ship->type == OTYPE_TERRA) {     /* terraforming device. */
  189. X
  190. X         if (ship->fuel >= (float)FUEL_COST_TERRA) { 
  191. X
  192. X        if (ship->on && 
  193. X            ((ship->whatdest == LEVEL_PLAN) && ship->is_docked)) {
  194. X
  195. X           /* move, and then terraform. */
  196. X
  197. X         if (ship->xpos >= (planet->Maxx-1) && ship->object.number > 0)
  198. X           ship->xpos = 0.0;
  199. X         else if (ship->xpos <= 0.0 && ship->object.number < 0)
  200. X           ship->xpos = (planet->Maxx-1);
  201. X         else
  202. X           ship->xpos += ship->object.number;
  203. X
  204. X         if (ship->ypos <= 0.0 && ship->object.number2 < 0)
  205. X            ship->object.number2 = -ship->object.number2;
  206. X         else if (ship->ypos >= (planet->Maxy-1) && ship->object.number2 > 0)
  207. X            ship->object.number2 = -ship->object.number2;
  208. X         
  209. X        ship->ypos += ship->object.number2;
  210. X
  211. X           {
  212. X            sectortype *s;
  213. X            s = &Sector(*planet,(int)ship->xpos,(int)ship->ypos);
  214. X            if (s->des != DES_GAS && 
  215. X            (int_rand(1,100) <= (((100-ship->damage) * 
  216. X                  ship->popn)/Max_crew(ship)))) {
  217. X              /* gas sectors can't be terraformed. */
  218. X             s->des = races[ship->owner-1]->likesbest;
  219. X             s->eff *= 0.5;
  220. X             s->mobilization *= 0.5;
  221. X             s->resource *= 0.7;
  222. X             /*s->popn *= 0.5;*/    /* ?? not sure bout this */
  223. X            s->popn = 0;
  224. X            s->owner = 0;/* i AM sure about this :) */
  225. X             ship->fuel -= (float)FUEL_COST_TERRA;
  226. X             ship->mass -= FUEL_COST_TERRA*MASS_FUEL;
  227. X            if (planet->conditions[TOXIC]<100)
  228. X                planet->conditions[TOXIC] += random()&01;
  229. X              }
  230. X         } 
  231. X
  232. X           }
  233. X          } else if (!ship->notified) {  
  234. X        char teleg2_buf[1000];
  235. X            ship->notified = 1;
  236. X        msg_OOF(ship, shipno, teleg2_buf);
  237. X          }
  238. X
  239. X     } else if (ship->type==OTYPE_BERS && ship->destruct) {
  240. X        if (ship->bombard && ship->whatorbits==LEVEL_PLAN &&
  241. X         ship->whatdest==LEVEL_PLAN &&
  242. X         ship->storbits==ship->deststar &&
  243. X         ship->pnumorbits==ship->destpnum &&
  244. X         !ship->is_docked)
  245. X        if (!Bombard(ship, shipno, planets[ship->storbits][ship->pnumorbits],
  246. X                races[ship->owner-1])) {
  247. X            /* we killed everyone here; go somewhere else */
  248. X           ship->destpnum = int_rand(0,Stars[ship->storbits]->numplanets);
  249. X        } else {
  250. X            /* exact revenge */
  251. X           if (Sdata.VN_hitlist[ship->object.number-1]>0)
  252. X               Sdata.VN_hitlist[ship->object.number-1]--;
  253. X        }
  254. X     } else if (can_bombard(ship) && ship->bombard &&
  255. X         ship->whatorbits==LEVEL_PLAN &&
  256. X         ship->whatdest==LEVEL_PLAN &&
  257. X         ship->storbits==ship->deststar &&
  258. X         ship->pnumorbits==ship->destpnum &&
  259. X         !ship->is_docked)
  260. X        Bombard(ship, shipno, planets[ship->storbits][ship->pnumorbits], races[ship->owner-1]);
  261. X
  262. X
  263. X    }
  264. X      shipno = ship->nextship;
  265. Xcheck(planet,2);
  266. X  }
  267. X
  268. X
  269. X if (!Stinfo[starnum][planetnum].inhab && 
  270. X     !Stinfo[starnum][planetnum].Thing_add)
  271. X    return 0;    /* (no one's explored the planet) */
  272. X
  273. X
  274. X    /* check for space mirrors (among other things) warming the planet */
  275. X    /* if a change in any artificial warming/cooling trends */
  276. X if (Stinfo[starnum][planetnum].temp_add != 0) {
  277. X    int final_temp;
  278. X
  279. X    final_temp = planet->conditions[RTEMP] +
  280. X             Stinfo[starnum][planetnum].temp_add + int_rand(-5,5);
  281. X
  282. X    planet->conditions[TEMP] = final_temp;
  283. X }
  284. X else planet->conditions[TEMP] = planet->conditions[RTEMP] + int_rand(-5,5);
  285. X
  286. X if (planet->slaved_to)
  287. X    planet->is_sheep = 1;    /* this is set to 0 at the end of ea. turn */
  288. X
  289. X check(planet,3);
  290. X
  291. X if (Stinfo[starnum][planetnum].Thing_add>0) {
  292. X     /* start a meso colony */
  293. X    int p;
  294. X/*    printf(" getting sectmap pos %d\n",planet->sectormappos); */
  295. X    opensectdata(§data);
  296. X    getsmap(sectdata,Smap,planet);
  297. X    close_file(sectdata);
  298. X
  299. X    PermuteSects(planet);
  300. X    bzero((char *)Sectinfo, sizeof(Sectinfo) );
  301. X    x = int_rand(0,planet->Maxx-1);
  302. X    y = int_rand(0,planet->Maxy-1);
  303. X    p = Stinfo[starnum][planetnum].Thing_add;
  304. X/*    printf("spore landed st %d, plan %d, play %d.\n", starnum,planetnum,p);*/
  305. X    planet->info[p-1].numsectsowned = 1;
  306. X
  307. X    planet->info[p-1].explored = 1;
  308. X    Sector(*planet,x,y).popn = 1;
  309. X    Sector(*planet,x,y).owner = p;
  310. X    Sector(*planet,x,y).is_wasted = 0;
  311. X}
  312. X
  313. Xbzero((char *)avg_mob, sizeof(avg_mob) );
  314. Xbzero((char *)sects_gained, sizeof(sects_gained) );
  315. Xbzero((char *)sects_lost, sizeof(sects_lost) );
  316. Xbzero((char *)populations, sizeof(populations) );
  317. Xbzero((char *)prod_res, sizeof(prod_res) );
  318. Xbzero((char *)prod_fuel, sizeof(prod_fuel) );
  319. Xbzero((char *)prod_destruct, sizeof(prod_destruct) );
  320. X
  321. Xtot_resdep = prod_eff= prod_mob = tot_captured = 0;
  322. XClaims = 0;
  323. X
  324. Xoldplanetmaxpopn = planet->maxpopn;
  325. Xplanet->maxpopn = 0; 
  326. X
  327. Xoldplanetpopn = planet->popn;
  328. Xplanet->popn = 0;    /* initialize population for recount */ 
  329. X
  330. X/* reset global variables */
  331. Xfor (i=1; i<=Num_races; i++) {
  332. X    Compat[i-1] = compatibility(planet, races[i-1]);
  333. X    planet->info[i-1].numsectsowned = 0;
  334. X    populations[i-1] = 0;
  335. X    prod_fuel[i-1] = 0;
  336. X    prod_destruct[i-1] = 0;
  337. X    prod_res[i-1] = 0;
  338. X    avg_mob[i-1] = 0.0;
  339. X}
  340. X
  341. XGetxysect(planet, &x, &y, 1);
  342. X/*printf(" while %d\n",Getxysect(planet, &x, &y, 1));    /* reset */
  343. X
  344. Xcheck(planet,4);
  345. Xwhile (Getxysect(planet, &x, &y, 0)) {
  346. X       p = &Sector(*planet,x,y);
  347. X     if (p->owner) {
  348. X        /* (all modified; sectors belonging to that player modified) */
  349. X        allmod = 1;    
  350. X        if (p->popn == 0) {
  351. X          p->owner=0;    /* make wasted/unowned sects go to player 0 */
  352. X        } else {
  353. X          if (!Stars[starnum]->nova_stage) {
  354. X                   /* spread excess popn to surrounding sects */
  355. X                  produce(planet,p);    /* >produce stuff there */
  356. X                  spread(planet,p,x,y);    
  357. X          } else {
  358. X            /* damage sector from supernova */
  359. X            p->resource++;
  360. X            p->fert *= 0.95;
  361. X            if (Stars[starnum]->nova_stage == 14)
  362. X                p->popn = p->owner = 0;
  363. X            else
  364. X                p->popn = round_rand((float)p->popn * .50);
  365. X          }
  366. X
  367. X        }
  368. X
  369. X          Sectinfo[x][y].done = 1;
  370. X
  371. X      }
  372. X
  373. X
  374. X           if (p->owner) {
  375. X          planet->info[p->owner-1].numsectsowned++;
  376. X          planet->popn += p->popn;
  377. X          Power[p->owner-1].popn += p->popn;
  378. X          Power[p->owner-1].sum_eff += p->eff;
  379. X               Power[p->owner-1].sum_mob += p->mobilization;
  380. X          starpopns[starnum][p->owner-1] += populations[p->owner-1] += p->popn;
  381. X          planet->maxpopn += maxsupport(races[p->owner-1],p,
  382. X                  Compat[p->owner-1],planet->conditions[TOXIC]);
  383. X    }
  384. X
  385. X
  386. X
  387. X         if (p->is_wasted) {
  388. X         if (x>1 && x<planet->Maxx-2) {
  389. X            if (p->des==DES_SEA || p->des==DES_GAS) {
  390. X                /* don't reclaim pole sectors */
  391. X                  if ( y>1 && y<planet->Maxy-2 && 
  392. X                    (!(p-1)->is_wasted || !(p+1)->is_wasted)
  393. X                    && !random()%5)
  394. X                    p->is_wasted = 0;
  395. X                  } else if (p->des==DES_LAND || p->des==DES_MOUNT || p->des==DES_ICE) {
  396. X                if ( y>1 && y<planet->Maxy-2 && 
  397. X                   ((p-1)->popn || (p+1)->popn)
  398. X                   && !random()%10)
  399. X                    p->is_wasted = 0;
  400. X                  }
  401. X        }
  402. X         }
  403. X
  404. X     /* evaporate the oceans on novae */
  405. X     if (Stars[starnum]->nova_stage) {
  406. X       if (p->des==DES_ICE)
  407. X       p->des = DES_LAND;
  408. X       else if (p->des==DES_SEA)
  409. X
  410. X      if ( (x>0 && (p-1)->des==DES_LAND) ||
  411. X         (x<planet->Maxx-1 && (p+1)->des==DES_LAND) || 
  412. X         (y>0 && (p-planet->Maxx)->des==DES_LAND) ||
  413. X         (y<planet->Maxy-1 && (p+planet->Maxx)->des==DES_LAND ) ) {
  414. X           p->des = DES_LAND;
  415. X           p->popn = p->owner = 0;
  416. X           p->resource += 3;
  417. X           p->fert = int_rand(1,4);
  418. X/*           printf("sect %d,%d evaporated.\n",x,y); */
  419. X    }
  420. X     }
  421. X
  422. X}
  423. Xcheck(planet,5);
  424. X
  425. Xif (allmod) {    /* ( >= 1 inhabited sector on the planet) */
  426. X
  427. Xcheck(planet,51);
  428. X     if (planet->expltimer >= 1)
  429. X        planet->expltimer--;
  430. X     if (!Stars[starnum]->nova_stage && !planet->expltimer) {
  431. X      if (!planet->expltimer)
  432. X        planet->expltimer = 5;
  433. X       for (i=1; !Claims && !allexp && i<=Num_races; i++) {
  434. Xcheck(planet,6);
  435. X         /* sectors have been modified for this player*/
  436. X
  437. X         if (planet->info[i-1].numsectsowned)
  438. X          while (!Claims && !allexp && timer>0) {
  439. X        timer -= 1;
  440. X        o = 1;
  441. X        Getxysect(planet, &x, &y, 1);
  442. X        while (!Claims && Getxysect(planet, &x, &y, 0)) {
  443. X              /* find out if all sectors have been explored */
  444. X            o &= Sectinfo[x][y].explored;
  445. X            p = &Sector(*planet,x,y);
  446. X            if (( (Sectinfo[x][y].explored==i) && !(random()&02) ) 
  447. X                && (!p->owner && !p->is_wasted && p->des==races[i-1]->likesbest) ) {
  448. X                 /*  explorations have found an island */
  449. X/*                printf("found island @ %d,%d\n",x,y);*/
  450. X                Claims = i;
  451. X                 /* give them some free people there */
  452. X                p->popn = races[i-1]->number_sexes;
  453. X                p->owner = i;
  454. X                tot_captured = 1;
  455. X            } else {
  456. X
  457. X                explore(planet, p, x, y, i);
  458. X                check(planet,63);
  459. X                }
  460. X        }
  461. X        allexp |= o;    /* all sectors explored for this player */
  462. X
  463. X           }
  464. X           }
  465. X     }
  466. X    if (allexp)
  467. X        planet->expltimer = 5;
  468. X
  469. Xcheck(planet,7);
  470. X        /* environment nukes a random sector */
  471. X   if (planet->conditions[TOXIC] > ENVIR_DAMAGE_TOX) {
  472. X    nukex = int_rand(0,planet->Maxx-1);
  473. X    nukey = int_rand(0,planet->Maxy-1);
  474. X    p = &Sector(*planet,nukex,nukey);
  475. X    if (p->owner)
  476. X        planet->info[p->owner-1].numsectsowned--;
  477. X    p->is_wasted = 1;
  478. X        /* index into accident type array */
  479. X    nukem = p->popn ? 
  480. X            /* random disaster */
  481. X        Accidents_inhab[int_rand(0,sizeof(Accidents_inhab)/sizeof(char *))]
  482. X                /* random of two disasters for that sec type*/
  483. X        : Accidents_uninhab[p->des * 2 + (random()&01)];
  484. X    p->popn = p->owner = 0;
  485. X   }
  486. X
  487. X    for (i=1; i<=Num_races; i++)
  488. X      if (sects_gained[i-1] || sects_lost[i-1]) {
  489. X      sprintf(telegram_buf,"****** Report: Planet /%s/%s ******\n", 
  490. X        Stars[starnum]->name, Stars[starnum]->pnames[planetnum] );
  491. X          sprintf(buf," \nWAR STATUS: %d sectors gained, %d sectors lost.\n", sects_gained[i-1],sects_lost[i-1]);
  492. X    str_cat(telegram_buf, buf);
  493. X    push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
  494. X      }
  495. X
  496. X    for (i=1; i<=Num_races; i++)
  497. X     if (planet->info[i-1].autorep) {
  498. X
  499. Xcheck(planet,8);
  500. X/*      planet->info[i-1].autorep = planet->info[i-1].autorep - 1; */
  501. Xcheck(planet,85);
  502. X      sprintf(telegram_buf,"\nFrom /%s/%s\n", 
  503. X        Stars[starnum]->name, Stars[starnum]->pnames[planetnum] );
  504. X      if (Stinfo[starnum][planetnum].temp_add) {
  505. X        sprintf(buf,"Temp: %d to %d\n", 
  506. X            Temp(planet->conditions[RTEMP]), Temp(planet->conditions[TEMP]));
  507. X        str_cat(telegram_buf, buf);
  508. X      }
  509. X      sprintf(buf, "Total      Prod: %dr %df %dd\n", prod_res[i-1], prod_fuel[i-1],
  510. X            prod_destruct[i-1]);
  511. X    str_cat(telegram_buf, buf);
  512. X
  513. X    if(tot_captured) {
  514. X      sprintf(buf,"%d sectors captured\n", tot_captured);
  515. X    str_cat(telegram_buf, buf);
  516. X        }
  517. X
  518. X      if (Stars[starnum]->nova_stage) {
  519. X        sprintf(buf,"This planet's primary is in a Stage %d nova.\n", 
  520. X            Stars[starnum]->nova_stage);
  521. X        str_cat(telegram_buf, buf);
  522. X      }
  523. X
  524. X        /* remind the player that he should clean up the environment. */
  525. X      if (planet->conditions[TOXIC] > ENVIR_DAMAGE_TOX) {
  526. X        sprintf(buf,"Environmental damage on sector %d,%d\n", nukex, nukey);
  527. X        str_cat(telegram_buf, buf);
  528. X      }
  529. X
  530. X      if (planet->slaved_to) {
  531. X        sprintf(buf, "ENSLAVED to player %d\n", planet->slaved_to);
  532. X        str_cat(telegram_buf, buf);
  533. X      }
  534. X
  535. X push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
  536. X
  537. X    }
  538. Xcheck(planet,9);
  539. X
  540. X       /* find out who is on this planet, for nova notification */
  541. X    if (Stars[starnum]->nova_stage == 1) {
  542. X         sprintf(telegram_buf,"BULLETIN from /%s/%s\n", Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
  543. X         sprintf(buf,"\nStar %s is undergoing nova.\n", Stars[starnum]->name);
  544. X    str_cat(telegram_buf, buf);
  545. X         if (planet->type==TYPE_EARTH) {
  546. X        sprintf(buf,"Seas and rivers are boiling!\n",telegram_buf,0);
  547. X        str_cat(telegram_buf, buf);
  548. X        }
  549. X         sprintf(buf, "This planet must be evacuated immediately!\n%c", TELEG_DELIM);
  550. X        str_cat(telegram_buf, buf);
  551. X              for (i=1; i<=Num_races; i++)
  552. X        if (planet->info[i-1].numsectsowned) {
  553. X        push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
  554. X        }
  555. X     }
  556. X
  557. X
  558. Xcheck(planet,10);
  559. X   for (i=1; i<=Num_races; i++) {
  560. X
  561. X/* check to see if your guys steal all alien resources on the planet,
  562. X    this requires that you be the only one inhabiting the planet */
  563. X
  564. X    if (planet->info[i-1].numsectsowned > 0) {
  565. X        int aliensects=0,stolenres=0,stolendes=0,stolenfuel=0;
  566. X        int stuff=0;
  567. X
  568. X
  569. X        for (j=2; j<=Num_races; j++)  
  570. X            if(j!=i)
  571. X            {
  572. X            aliensects += planet->info[j-1].numsectsowned;
  573. X            if(planet->info[j-1].resource >0 ||
  574. X               planet->info[j-1].destruct >0 ||
  575. X               planet->info[j-1].fuel > 0.0) stuff=1;
  576. X            }
  577. X
  578. X        if(!aliensects && stuff)
  579. X            {
  580. X        for (j=1; j<=Num_races; j++)
  581. X            if(j!=i)
  582. X            {
  583. X              stolenres += planet->info[j-1].resource;
  584. X              stolendes += planet->info[j-1].destruct;
  585. X              stolenfuel += planet->info[j-1].fuel;
  586. X              planet->info[j-1].resource = 0;
  587. X              planet->info[j-1].destruct = 0;
  588. X              planet->info[j-1].fuel = 0;
  589. X            }
  590. X        planet->info[i-1].resource += stolenres;
  591. X        planet->info[i-1].destruct += stolendes;
  592. X        planet->info[i-1].fuel += stolenfuel;
  593. X/* notify player of recovered stockpiles */
  594. X      sprintf(telegram_buf,"****** Report: Planet /%s/%s ******\n\n", 
  595. X        Stars[starnum]->name, Stars[starnum]->pnames[planetnum] );
  596. X      sprintf(buf," %d resources \n %d destruct \n %d fuel recovered from alien stock piles",stolenres,stolendes,stolenfuel);
  597. X    str_cat(telegram_buf, buf);
  598. X    push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
  599. X            } /*aliensect==0*/
  600. X        }
  601. X
  602. X    if (planet->info[i-1].numsectsowned) {
  603. X      /* combat readiness naturally moves towards the avg mobilization */
  604. X        avg_mob[i-1] /= planet->info[i-1].numsectsowned;
  605. X        planet->info[i-1].comread += 
  606. X                sgn(avg_mob[i-1] - planet->info[i-1].comread);
  607. X     }
  608. X   }
  609. X
  610. X    if (planet->maxpopn > 0 && planet->conditions[TOXIC]<100)
  611. X        planet->conditions[TOXIC] += 
  612. X/*              round_rand(MIN((float)(planet->popn / 
  613. X                    (float)planet->maxpopn),2.0)); */
  614. X                    planet->popn/planet->maxpopn;
  615. X                     /* Rob, this is a better idea, or toxic go wild
  616. X                other effects can make this happen
  617. X                keeps waste containers down too -
  618. X                playtesting has proved this to us at OSU */
  619. X
  620. X    if (planet->conditions[TOXIC] > 100)
  621. X       planet->conditions[TOXIC] = 100;
  622. X    else if (planet->conditions[TOXIC] < 0)
  623. X       planet->conditions[TOXIC] = 0;
  624. X
  625. X    /* deal with enslaved planets */
  626. X   if (planet->slaved_to) {
  627. X    if (populations[planet->slaved_to-1] >= planet->popn * 0.001 ||
  628. X        (Stinfo[starnum][planetnum].intimidated && random()&01) ) {
  629. X/*         printf("enslaved!\n"); */
  630. X        for (i=1; i<=Num_races; i++)
  631. X            /* add production to slave holder of planet */
  632. X          if (planet->info[i-1].numsectsowned) {
  633. X            planet->info[planet->slaved_to-1].resource += 
  634. X                    prod_res[i-1];
  635. X            prod_res[i-1] = 0;
  636. X            planet->info[planet->slaved_to-1].fuel += 
  637. X                    prod_fuel[i-1];
  638. X            prod_fuel[i-1] = 0;
  639. X            planet->info[planet->slaved_to-1].destruct += 
  640. X                    prod_destruct[i-1];
  641. X            prod_destruct[i-1] = 0;
  642. X          }
  643. X    } else {
  644. X         /* slave revolt! */
  645. X/*    printf("slave revolt!\n"); */
  646. X         /* first nuke some random sectors from the revolt */
  647. X        i = planet->popn / 1000 + 1;
  648. X/*    printf("i %d  Maxx %d  Maxy %d\n",i,planet->Maxx,planet->Maxy); */
  649. X        while (--i) {
  650. X            p = &Sector(*planet,int_rand(0,planet->Maxx-1),
  651. X                    int_rand(0,planet->Maxy-1));
  652. X            if (p->popn) {
  653. X                p->owner = p->popn = 0;
  654. X                p->is_wasted = 1;
  655. X            }
  656. X        }
  657. X         /* now nuke all sectors belonging to former master */
  658. X        Getxysect(planet, &x, &y, 1);
  659. X        while (Getxysect(planet, &x, &y, 0)) {
  660. X            if (Stinfo[starnum][planetnum].intimidated && random()&01) {
  661. X               p =  &Sector(*planet,x,y);
  662. X               if (p->owner==planet->slaved_to) {
  663. X                p->owner = 0;
  664. X                p->popn = 0;
  665. X                p->is_wasted = 1;
  666. X               }
  667. X            }
  668. X        }
  669. X        sprintf(telegram_buf,"NOTICE from planet /%s/%s!\n",
  670. X                Stars[starnum]->name,
  671. X                Stars[starnum]->pnames[planetnum]);
  672. X        sprintf(buf,"\nThere has been a SLAVE REVOLT on this planet!\n");
  673. X            str_cat(telegram_buf, buf);
  674. X        sprintf(buf,"All population belonging to player #%d on the planet have been killed!\n",planet->slaved_to);
  675. X            str_cat(telegram_buf, buf);
  676. X        sprintf(buf,"Productions now go to their rightful owners.\n");
  677. X            str_cat(telegram_buf, buf);
  678. X        for (i=1; i<=Num_races; i++)
  679. X          if (planet->info[i-1].numsectsowned && i!=planet->slaved_to) {
  680. X            push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
  681. X            }
  682. X         /* send to previous slave holder */
  683. X    push_message(TELEG_PLAYER_AUTO, planet->slaved_to, telegram_buf);
  684. X
  685. X        planet->slaved_to = 0;
  686. X        planet->is_sheep = 0;
  687. X    }
  688. X
  689. X   } else {
  690. X     /* add production to all people here */
  691. X    for (i=1; i<=Num_races; i++) {
  692. X
  693. X      if (planet->info[i-1].numsectsowned) {
  694. X
  695. X         if (planet->info[i-1].fuel + prod_fuel[i-1] > 100000)
  696. X          planet->info[i-1].fuel = 100000;
  697. X        else
  698. X          planet->info[i-1].fuel += prod_fuel[i-1];
  699. X
  700. X         if (planet->info[i-1].resource + prod_res[i-1] > 100000)
  701. X          planet->info[i-1].resource = 100000;
  702. X        else
  703. X          planet->info[i-1].resource += prod_res[i-1];
  704. X
  705. X         if (planet->info[i-1].destruct + prod_destruct[i-1] > 100000)
  706. X          planet->info[i-1].destruct = 100000;
  707. X        else
  708. X          planet->info[i-1].destruct += prod_destruct[i-1];
  709. X
  710. X        /* do tech investments */
  711. X       if (planet->info[i-1].resource >= planet->info[i-1].tech_invest) {
  712. X         races[i-1]->tech += 
  713. X            log10(1.0+(double)planet->info[i-1].tech_invest) * TECH_INVEST;
  714. X         planet->info[i-1].resource -= planet->info[i-1].tech_invest;
  715. X       }
  716. X
  717. X       /* build wc's if it's been ordered */
  718. X      if (planet->info[i-1].tox_thresh>0 &&
  719. X          planet->conditions[TOXIC] >= planet->info[i-1].tox_thresh &&
  720. X          planet->info[i-1].resource >= Shipdata[OTYPE_TOXWC][ABIL_COST]) {
  721. X              shiptype *s2; reg int t;
  722. X        ++Num_ships;
  723. X        ships = (shiptype **)realloc(ships, (unsigned)((Num_ships+1)*sizeof(shiptype*)));
  724. X        s2 = ships[Num_ships] = Malloc(shiptype);
  725. X/*        printf("planet /%s/%s made Tox wc #%d.\n",Stars[starnum]->name,
  726. X            Stars[starnum]->pnames[planetnum],Num_ships); */
  727. X        bzero((char *)s2,sizeof(shiptype));
  728. X        s2->type = OTYPE_TOXWC;
  729. X
  730. X        s2->armor = Shipdata[OTYPE_TOXWC][ABIL_ARMOR];
  731. X        s2->guns = Shipdata[OTYPE_TOXWC][ABIL_GUNS];
  732. X        s2->size = Shipdata[OTYPE_TOXWC][ABIL_TARGET];
  733. X        s2->max_crew = Shipdata[OTYPE_TOXWC][ABIL_MAXCREW];
  734. X        s2->max_resource = Shipdata[OTYPE_TOXWC][ABIL_CARGO];
  735. X        s2->max_fuel = Shipdata[OTYPE_TOXWC][ABIL_FUELCAP];
  736. X        s2->max_destruct = Shipdata[OTYPE_TOXWC][ABIL_DESTCAP];
  737. X        s2->max_speed = Shipdata[OTYPE_TOXWC][ABIL_SPEED];
  738. X        s2->base_mass = getmass(s2);
  739. X        s2->mass = s2->base_mass;
  740. X         s2->is_alive = 1;
  741. X        sprintf(s2->name,"Scum%04d",Num_ships);
  742. X
  743. X        insert_sh_plan(planet,s2,Num_ships);
  744. X
  745. X        s2->whatorbits = LEVEL_PLAN;
  746. X        s2->storbits = starnum;
  747. X        s2->pnumorbits = planetnum;
  748. X        s2->is_docked = 1;
  749. X        s2->xpos = int_rand(0,planet->Maxx-1);
  750. X        s2->ypos = int_rand(0,planet->Maxy-1);
  751. X        s2->whatdest = LEVEL_PLAN;
  752. X        s2->deststar = starnum;
  753. X        s2->destpnum = planetnum;
  754. X        s2->owner = i;
  755. X        t = MIN(TOXMAX,planet->conditions[TOXIC]);    /* amt of tox */
  756. X        planet->conditions[TOXIC] -= t;
  757. X        s2->object.number = t;
  758. X    }
  759. X     }     /* (if numsectsowned[i]) */
  760. X
  761. X   } /* (for i=1 to Num_races) */
  762. X
  763. X  }  /* (else (if slaved_to)) */
  764. X
  765. X
  766. X   planet->is_sheep = 0;
  767. X
  768. X }
  769. X
  770. X for (i=1; i<=Num_races; i++) {
  771. X    Power[i-1].resource += planet->info[i-1].resource;
  772. X    Power[i-1].destruct += planet->info[i-1].destruct;
  773. X    Power[i-1].fuel += planet->info[i-1].fuel;
  774. X    Power[i-1].planets_owned += !!planet->info[i-1].numsectsowned;
  775. X    Power[i-1].sectors_owned += planet->info[i-1].numsectsowned;
  776. X/*    Power[i-1].sum_mob += avg_mob[i-1]; */
  777. X }
  778. X
  779. Xcheck(planet,12);
  780. X return allmod;
  781. X}
  782. X
  783. X
  784. Xcheck(p,n)
  785. Xplanettype *p;
  786. Xint n;
  787. X{
  788. X if (p->sectormappos != Sectormappos)
  789. X    fprintf(stderr," WHOA! sectormappos %d != %d (%d)\n",
  790. X        p->sectormappos, Sectormappos, n);
  791. X /*else
  792. X    fprintf(stderr, "OK (%d)\n",n);*/
  793. X}
  794. END_OF_FILE
  795. if test 21893 -ne `wc -c <'server/doplanet.c'`; then
  796.     echo shar: \"'server/doplanet.c'\" unpacked with wrong size!
  797. fi
  798. # end of 'server/doplanet.c'
  799. fi
  800. if test -f 'server/order.c' -a "${1}" != "-c" ; then 
  801.   echo shar: Will not clobber existing file \"'server/order.c'\"
  802. else
  803. echo shar: Extracting \"'server/order.c'\" \(21412 characters\)
  804. sed "s/^X//" >'server/order.c' <<'END_OF_FILE'
  805. X/*
  806. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  807. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  808. X * Restrictions in GB_copyright.h.
  809. X *
  810. X *  order.c -- give orders to ship
  811. X */
  812. X
  813. X#include "GB_copyright.h"
  814. X#define EXTERN extern
  815. X#include "vars.h"
  816. X#include "ships.h"
  817. X#include "races.h"
  818. X#include "buffers.h"
  819. X#include <curses.h>
  820. X#include <ctype.h>
  821. X#include <signal.h>
  822. X#include <math.h>
  823. X
  824. Xchar *prin_aimed_at(), *prin_ship_dest();
  825. X
  826. Xint order_shdata,order_pdata,order_stardata;
  827. Xint n_ships;
  828. Xstatic boolean first,prerror,was_obj = 0;
  829. Xboolean Order_types[NUMSTYPES];
  830. X
  831. Xorder(Playernum, APcount, argn,args)
  832. Xint Playernum;
  833. Xint APcount;
  834. Xint argn;
  835. Xchar args[MAXARGS][COMMANDSIZE];
  836. X{
  837. Xint shipno, i;
  838. Xint order_shdata = NEUTRAL_FD;
  839. Xint sh, pdata;
  840. Xplanettype *p; 
  841. X
  842. Xfor (i=0; i<NUMSTYPES; i++) Order_types[i]=0;
  843. X
  844. Xif(argn==1) {    /* display all ship orders */
  845. X        switch(Dir[Playernum-1].level) {
  846. X            case LEVEL_UNIV:
  847. X                      sh = Sdata.ships;
  848. X                    DispOrdersHeader(Playernum);
  849. X                           while (sh)
  850. X                        DispOrders(Playernum, sh, &sh, 0);
  851. X                break;
  852. X            case LEVEL_STAR:
  853. X                      sh = Stars[Dir[Playernum-1].snum]->ships;
  854. X                    DispOrdersHeader(Playernum);
  855. X                           while (sh)
  856. X                        DispOrders(Playernum, sh, &sh, 0);
  857. X                break;
  858. X            case LEVEL_PLAN:
  859. X                 openpdata(&pdata);
  860. X                 getplanet(pdata,&p,
  861. X                    Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
  862. X                 close_file(pdata);
  863. X                sh = p->ships;
  864. X                    DispOrdersHeader(Playernum);
  865. X                           while (sh)
  866. X                        DispOrders(Playernum, sh, &sh, 0);
  867. X                free(p);
  868. X                break;
  869. X            case LEVEL_SHIP:
  870. X                sh = Dir[Playernum-1].shipno;
  871. X                    DispOrdersHeader(Playernum);
  872. X                    DispOrders(Playernum, sh, &sh, 0);
  873. X                break;
  874. X            default:
  875. X                notify(Playernum, "Bad scope.\n");
  876. X                break;
  877. X        }
  878. X                
  879. X} else if (argn>=2) {        /* display one ship's orders (if argn==2), otherwise assigne orders */
  880. X
  881. X    if(*args[1] == '#' || isdigit(*args[1])) {
  882. X    sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
  883. X
  884. X openshdata(&order_shdata);
  885. X n_ships = Numships(order_shdata);
  886. Xclose_file(order_shdata);
  887. X
  888. X    if(shipno <=0 || shipno >  n_ships) {
  889. X        sprintf(buf, "Illegal ship number %d.\n", shipno);
  890. X        notify(Playernum, buf);
  891. X        return;        
  892. X        }
  893. X
  894. X    if(argn > 2)
  895. X           give_orders(Playernum, APcount, argn, args, shipno, 0);
  896. X
  897. X/* display the orders anyway */
  898. X    DispOrdersHeader(Playernum);
  899. X    DispOrders(Playernum, shipno, &sh, 0);
  900. X    } else {        /* you want to order all types on this level */
  901. X        int l;
  902. X        l = strlen(args[1]);
  903. X
  904. X        while (l--) {
  905. X               i = NUMSTYPES;
  906. X               while (--i && Shipltrs[i]!=args[1][l]);
  907. X           if (Shipltrs[i]!=args[1][l]) {
  908. X            sprintf(buf,"'%c' -- no such ship letter\n",args[1][l]);
  909. X            notify(Playernum, buf);
  910. X           } else
  911. X            Order_types[i] = 1;
  912. X    }
  913. X        
  914. X
  915. Xswitch(Dir[Playernum-1].level) { 
  916. X  case LEVEL_PLAN:
  917. X     openpdata(&pdata);
  918. X     getplanet(pdata,&p,
  919. X    Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
  920. X     close_file(pdata);
  921. X          shipno = p->ships;
  922. X          break; 
  923. X   case LEVEL_STAR:
  924. X          shipno = Stars[Dir[Playernum-1].snum]->ships;
  925. X          break; 
  926. X   default:
  927. X    notify(Playernum, "You can't do multiple orders from this level. Must be planet of star.\n");
  928. X        return;        
  929. X        }
  930. X
  931. X    DispOrdersHeader(Playernum);
  932. X           while (shipno) {
  933. X        if(argn > 2)
  934. X        give_orders(Playernum, APcount, argn, args, shipno, 1);
  935. X        DispOrders(Playernum, shipno, &shipno, 1);
  936. X                    }
  937. X
  938. X
  939. X       }
  940. X    } else
  941. X        notify(Playernum, "I don't understand what you mean.\n");
  942. X        
  943. X}
  944. X
  945. X
  946. Xint give_orders(Playernum, APcount, argn, args, shipno, check)
  947. Xint Playernum;
  948. Xint APcount;
  949. Xint argn;
  950. Xchar args[MAXARGS][COMMANDSIZE];
  951. Xint shipno;
  952. Xint check;
  953. X{
  954. X boolean Mod=0,q=0,redraw=1;
  955. X placetype where,pl;
  956. X int i = 0, j=0, in_list=0;
  957. X shiptype *ship, *oldship, ship2;
  958. X char c,s[PLACENAMESIZE];
  959. X planettype *planet;
  960. X
  961. X openshdata(&order_shdata);
  962. X if (!getship(order_shdata,&ship,shipno)) {
  963. X    notify(Playernum, "order:error in getship.\n");
  964. X    return;
  965. X }
  966. Xclose_file(order_shdata);
  967. Xif(ship->type == OTYPE_CANIST)
  968. X  i=1;
  969. X
  970. Xif(check) {
  971. X    in_list = 0;
  972. X    for(j=0; j<NUMSTYPES; j++) {
  973. X        if(Order_types[j] && ship->type==j) in_list = 1;
  974. X        }
  975. X    if(!in_list) {
  976. X            free(ship);
  977. X            return;
  978. X            }
  979. X        }
  980. X
  981. X if (ship->owner==Playernum) {
  982. X    if (!ship->is_alive) {
  983. X    sprintf(buf, "%s #%d has been destroyed.\n", Shipnames[ship->type], shipno);
  984. X    notify(Playernum, buf);
  985. X    free(ship);
  986. X    return;
  987. X    } else {
  988. X
  989. X      if (!ship->active) {
  990. X    sprintf(buf, "%s #%d is irradiated (%d); it cannot be give orders.\n", 
  991. X            Shipnames[ship->type], shipno,ship->rad);
  992. X    notify(Playernum, buf);
  993. X    free(ship);
  994. X    return;
  995. X      }
  996. X      if (ship->type != OTYPE_TRANSDEV && !ship->popn && 
  997. X      Max_crew(ship)) {
  998. X    sprintf(buf, "%s #%d has no crew and is not a robotic ship.\n",
  999. X        Shipnames[ship->type], shipno);
  1000. X    notify(Playernum, buf);
  1001. X    free(ship);
  1002. X    return;
  1003. X      }
  1004. X
  1005. X    }
  1006. X
  1007. X    i=strlen(args[2]);
  1008. X
  1009. X       if (!strncmp(args[2],"defense",i)) {
  1010. X        if (can_bombard(ship) || ship->type == OTYPE_GR) {
  1011. X            if(!strncmp(args[3],"off", strlen(args[3]))) {
  1012. X                ship->protect.planet = 0;
  1013. X                notify(Playernum, "Planetary defense canceled.\n");
  1014. X            } else {
  1015. X                ship->protect.planet = 1;
  1016. X                notify(Playernum, "Ship assigned to planetary defense.\n");
  1017. X            }
  1018. X        } else {
  1019. X                notify(Playernum, "That ship cannot be assigned those orders.\n");
  1020. X                free(ship);
  1021. X                return;
  1022. X        }
  1023. X         } else if (!strncmp(args[2],"jump",i)) {
  1024. X        if(Shipdata[ship->type][ABIL_JUMP]) {
  1025. X            if(!strncmp(args[3],"off", strlen(args[3]))) {
  1026. X                ship->hyper_drive.on = 0;
  1027. X                notify(Playernum, "Hyper drive turned off.\n");
  1028. X                } else {
  1029. X                if(ship->whatdest != LEVEL_STAR) {
  1030. X                notify(Playernum, "Destination must be star.\n");
  1031. X                free(ship);
  1032. X                return;
  1033. X                        }
  1034. X                ship->hyper_drive.on = 1;
  1035. X                ship->navigate.on = 0;
  1036. X                notify(Playernum, "Hyper drive engine's activated.\n");
  1037. X/* estimate how much fuel it will cost for this ship to get there */
  1038. X                }
  1039. X            } else {
  1040. X        notify(Playernum, "This ship does not have hyper drive capability.\n");
  1041. X        free(ship);
  1042. X        return;
  1043. X            }
  1044. X
  1045. X         } else if (!strncmp(args[2],"protect",i)) {
  1046. X
  1047. X    sscanf(args[3]+(args[3][0]=='#'),"%d",&j);
  1048. X
  1049. X        if(j < 0 || j > n_ships || j==shipno) {
  1050. X                notify(Playernum, "You can't protect that!\n");
  1051. X                free(ship);
  1052. X                return;
  1053. X            }
  1054. X          if (can_bombard(ship) || ship->type==OTYPE_GR) {
  1055. X                if(!j) {
  1056. X                    ship->protect.on = 0;
  1057. X                    notify(Playernum, "Protection orders halted.\n");
  1058. X                } else {
  1059. X                    ship->protect.on = 1;
  1060. X                    ship->protect.ship = j;
  1061. X                    sprintf(buf, "Protecting ship #%d.\n", j);
  1062. X                    notify(Playernum, buf);
  1063. X                    }
  1064. X
  1065. X            } else {
  1066. X                notify(Playernum, "That ship cannot protect.\n");
  1067. X                free(ship);
  1068. X                return;
  1069. X            }
  1070. X       } else if (!strncmp(args[2],"navigate",i)) {
  1071. X        if(argn >= 5) {
  1072. X            ship->navigate.on = 1;
  1073. X            ship->navigate.bearing = atoi(args[3]);
  1074. X            ship->navigate.turns = atoi(args[4]);
  1075. X            sprintf(buf, "Navigating %d degrees for %d turns.\n",
  1076. X                ship->navigate.bearing, ship->navigate.turns);
  1077. X            notify(Playernum, buf);
  1078. X        } else {
  1079. X            ship->navigate.on = 0;        
  1080. X            }
  1081. X        if(ship->hyper_drive.on) {
  1082. X            ship->hyper_drive.on = 0;
  1083. X            notify(Playernum, "Hyper drive turned off.\n");
  1084. X            }
  1085. X       } else if (!strncmp(args[2],"switch",i)) {
  1086. X        if(has_switch(ship)) {
  1087. X            ship->on = !ship->on;
  1088. X        } else {
  1089. X            sprintf(buf, "That ship does not have an on/off setting.\n");
  1090. X            notify(Playernum, buf);
  1091. X            free(ship);
  1092. X            return;
  1093. X            }
  1094. X        if(ship->on) {
  1095. X            notify(Playernum, "Turned on.\n");
  1096. X                  switch (ship->type) {
  1097. X                case STYPE_MINE:
  1098. X                    notify(Playernum, "Mine armed and ready.\n");
  1099. X                    break;
  1100. X                case OTYPE_TRANSDEV:
  1101. X                    notify(Playernum, "Transporter ready to receive.\n");
  1102. X                    break;
  1103. X                default: break;
  1104. X                  }
  1105. X        } else {
  1106. X            notify(Playernum, "Turned off.\n");
  1107. X                  switch (ship->type) {
  1108. X                case STYPE_MINE:
  1109. X                    notify(Playernum, "Mine disarmed.\n");
  1110. X                    break;
  1111. X                case OTYPE_TRANSDEV:
  1112. X                    notify(Playernum, "No longer receiving.\n");
  1113. X                    break;
  1114. X                default: break;
  1115. X                  }
  1116. X        }
  1117. X       } else if (!strncmp(args[2],"destination",i)) {
  1118. X            if (speed_rating(ship)) {
  1119. X                  if (ship->is_docked) {
  1120. X                notify(Playernum, "That ship is docked; use undock or launch first.\n");
  1121. X            free(ship);
  1122. X            return;
  1123. X                  } 
  1124. X            where = Getplace(Playernum, args[3], 1);
  1125. X              if (!where.err) {
  1126. X            if (where.level==LEVEL_SHIP) {
  1127. X                    ship->destshipno = where.shipno;
  1128. X                ship->whatdest = LEVEL_SHIP;
  1129. X            } else {
  1130. X                ship->whatdest = where.level;
  1131. X                ship->deststar = where.snum;
  1132. X                ship->destpnum = where.pnum;
  1133. X            }
  1134. X              } else {
  1135. X            notify(Playernum, "Illegal destination.\n");
  1136. X            free(ship);
  1137. X            return;            
  1138. X            }
  1139. X
  1140. X             sprintf(buf, "Ship's destination set to %*s\n", -PLACENAMESIZE, 
  1141. X            prin_ship_dest(Playernum, ship) );
  1142. X            notify(Playernum, buf);            
  1143. X
  1144. X            } else {
  1145. X                notify(Playernum, "That ship cannot be launched.\n");
  1146. X                free(ship);
  1147. X                return;
  1148. X            }
  1149. X       } else if (!strncmp(args[2],"evade",i)) {
  1150. X            if (Max_crew(ship) && Max_speed(ship)) {
  1151. X        if(!strlen(args[3],"on",strlen(args[3]))) {
  1152. X            ship->protect.evade = 1;
  1153. X            notify(Playernum, "Ship is undergoing evasive maneuvers.\n");
  1154. X        } else {
  1155. X            ship->protect.evade = 0;
  1156. X            notify(Playernum, "Ship no longer undergoing evasive maneuvers.\n");
  1157. X        }
  1158. X        } else {
  1159. X            notify(Playernum, "You can't make this type of ship do this.\n");
  1160. X            free(ship);
  1161. X            return;
  1162. X            }
  1163. X
  1164. X       } else if (!strncmp(args[2],"bombard",i)) {
  1165. X        if (ship->type!=OTYPE_OMCL) {
  1166. X            if (can_bombard(ship)) {
  1167. X            if(!strncmp(args[3],"off",strlen(args[3]))) {
  1168. X                ship->bombard = 0;
  1169. X                notify(Playernum, "Bombardment option turned off.\n");                
  1170. X            } else {
  1171. X                ship->bombard = 1;
  1172. X                notify(Playernum, "Ship will bombard upon reaching its destination.\n");
  1173. X            }
  1174. X
  1175. X            } else {
  1176. X            notify(Playernum, "This type of ship cannot be set to retaliate.\n");
  1177. X            }
  1178. X        }
  1179. X       } else if (!strncmp(args[2],"retaliate",i)) {
  1180. X        if (ship->type!=OTYPE_OMCL) {
  1181. X            if (can_bombard(ship) || ship->type==OTYPE_GR) {
  1182. X            if(!strncmp(args[3],"off",strlen(args[3]))) {
  1183. X                ship->protect.self = 0;
  1184. X                notify(Playernum, "Retaliation option turned off.\n");                
  1185. X            } else {
  1186. X                ship->protect.self = 1;
  1187. X                notify(Playernum, "Ship will retaliate if attacked and damaged.\n");
  1188. X            }
  1189. X
  1190. X            } else {
  1191. X            notify(Playernum, "This type of ship cannot be set to retaliate.\n");
  1192. X            }
  1193. X        }
  1194. X       } else if (!strncmp(args[2],"speed",i)) {
  1195. X        if (speed_rating(ship)) {
  1196. X            j = atoi(args[3]);            
  1197. X            if(j < 0) {
  1198. X                notify(Playernum, "Specify a positive speed.\n");
  1199. X                free(ship);
  1200. X                return;
  1201. X            } else {
  1202. X                if(j > speed_rating(ship)) j = speed_rating(ship);
  1203. X                ship->speed = j;
  1204. X                sprintf(buf, "Ship speed set to %d.\n", j);
  1205. X                notify(Playernum, buf);
  1206. X            }
  1207. X
  1208. X        } else {
  1209. X            notify(Playernum, "This ship does not have a speed rating.\n");
  1210. X            free(ship);
  1211. X            return;
  1212. X        }
  1213. X
  1214. X      } else if(!strncmp(args[2], "explosive", i)) {
  1215. X        if(ship->type==STYPE_MINE) {
  1216. X            ship->mine.mode = 1;
  1217. X            notify(Playernum, "This mine is set for explosive mode.\n");
  1218. X        } else {
  1219. X            notify(Playernum, "This ship cannot be set for this.\n");
  1220. X            free(ship);
  1221. X            return;
  1222. X        }
  1223. X      } else if(!strncmp(args[2], "radiative", i)) {
  1224. X        if(ship->type==STYPE_MINE) {
  1225. X            ship->mine.mode = 0;
  1226. X            notify(Playernum, "This mine is set for radiation mode.\n");
  1227. X        } else {
  1228. X            notify(Playernum, "This ship cannot be set for this.\n");
  1229. X            free(ship);
  1230. X            return;
  1231. X        }
  1232. X      } else if(!strncmp(args[2], "move", i)) {
  1233. X        if (ship->type==OTYPE_TERRA) {
  1234. X            ship->object.number = atoi(args[3]);
  1235. X            ship->object.number2 = atoi(args[4]);
  1236. X            if(ship->object.number != 0)
  1237. X                ship->object.number = sgn(ship->object.number);
  1238. X            if(ship->object.number2 != 0)
  1239. X                ship->object.number2 = sgn(ship->object.number2); 
  1240. X            sprintf(buf, "Terraformer moving in direction %d,%d\n",
  1241. X                ship->object.number,ship->object.number2);
  1242. X            notify(Playernum, buf);
  1243. X            } else {
  1244. X            notify(Playernum, "That ship is not a terraformer.\n");
  1245. X            free(ship);
  1246. X            return;
  1247. X        }
  1248. X      } else if(!strncmp(args[2], "trigger", i)) {
  1249. X            if (ship->type==STYPE_MINE) {
  1250. X                ship->object.number = atoi(args[3]);
  1251. X            if (ship->object.number < 0)
  1252. X                ship->object.number = 0;
  1253. X            sprintf(buf, "Trigger radius set to %3d\n",ship->object.number); 
  1254. X            notify(Playernum, buf);
  1255. X            } else {
  1256. X            notify(Playernum, "This ship cannot be assigned a trigger radius.\n");
  1257. X            free(ship);
  1258. X            return;
  1259. X            }
  1260. X      } else if(!strncmp(args[2], "transport", i)) {
  1261. X         if (ship->type==OTYPE_TRANSDEV) {
  1262. X            ship->object.number = atoi(args[3]);
  1263. X            if(ship->object.number < 0 || ship->object.number > n_ships)
  1264. X                ship->object.number = 0;
  1265. X            sprintf(buf, "Target ship is %d.\n",ship->object.number);
  1266. X            notify(Playernum, buf);
  1267. X            } else {
  1268. X            notify(Playernum, "This ship is not a transporter.\n");
  1269. X            free(ship);
  1270. X            return;
  1271. X            }
  1272. X      } else if(!strncmp(args[2], "aim", i)) {
  1273. X            if (can_aim(ship)) {
  1274. X              if (ship->type==OTYPE_GTELE || ship->type==OTYPE_TRACT 
  1275. X                  || ship->fuel>=FUEL_MANEUVER) {
  1276. X                  if (ship->type==STYPE_MIRROR && ship->is_docked) {
  1277. X                sprintf(buf, "docked; use undock or launch first.\n");
  1278. X                notify(Playernum, buf);
  1279. X                free(ship);
  1280. X                return;
  1281. X                  }
  1282. X              pl = Getplace(Playernum, args[3],1);
  1283. X              if (pl.err) {
  1284. X                notify(Playernum, "Error in destination.\n");
  1285. X                free(ship);
  1286. X                return;
  1287. X              } else {
  1288. X                ship->aimed_at.level = pl.level;
  1289. X                ship->aimed_at.pnum = pl.pnum;
  1290. X                ship->aimed_at.snum = pl.snum;
  1291. X                ship->aimed_at.shipno = pl.shipno;
  1292. X                if (ship->type!=OTYPE_TRACT && 
  1293. X                        ship->type!=OTYPE_GTELE)
  1294. X                    ship->fuel -= FUEL_MANEUVER;
  1295. X                if (ship->type==OTYPE_GTELE || 
  1296. X                        ship->type==OTYPE_STELE)
  1297. X                    mk_expl_aimed_at(Playernum, ship);
  1298. X                sprintf(buf, "Aimed at %s\n", prin_aimed_at(Playernum, ship) );
  1299. X            notify(Playernum, buf);
  1300. X            }
  1301. X              } else {
  1302. X            sprintf(buf, "Not enough maneuvering fuel (%.2f).\n",FUEL_MANEUVER);
  1303. X            notify(Playernum, buf);
  1304. X            free(ship);
  1305. X            return;
  1306. X              }
  1307. X
  1308. X
  1309. X            } else {
  1310. X            notify(Playernum, "You can't aim that kind of ship.\n");
  1311. X            free(ship);
  1312. X            return;
  1313. X            }
  1314. X     } else if(!strncmp(args[2], "intensity", i)) {
  1315. X            if (ship->type==STYPE_MIRROR) { 
  1316. X                  ship->aimed_at.intensity = atoi(args[3]);
  1317. X                  if (ship->aimed_at.intensity>100)
  1318. X                  ship->aimed_at.intensity=100;
  1319. X                  else if (ship->aimed_at.intensity<0)
  1320. X                  ship->aimed_at.intensity=0;
  1321. X                sprintf(buf, "Mirror intensisty set to %3d\n",ship->aimed_at.intensity); 
  1322. X                notify(Playernum, buf);
  1323. X            } else {
  1324. X                notify(Playernum, "You can't do that with this kind of ship.\n");
  1325. X            }
  1326. X } else if(!strncmp(args[2], "on", i)) {
  1327. X
  1328. X     if(ship->type==OTYPE_FACTORY) {
  1329. X     if(ship->on) {
  1330. X     notify(Playernum, "It's already online.\n");
  1331. X     free(ship);
  1332. X     return;
  1333. X             }
  1334. X/* check to see if player has enough resources to activate the factory */
  1335. X             openpdata(&order_pdata);
  1336. X             getplanet(order_pdata,&planet, Stars[ship->deststar]->planetpos[ship->destpnum]);
  1337. X        close_file(order_pdata);
  1338. X
  1339. X    if(planet->info[Playernum-1].resource < 2*ship->build_cost) {
  1340. X        sprintf(buf, "You don't have %s resources on the planet to activate this factory.\n",
  1341. X                2*ship->build_cost);
  1342. X        notify(Playernum, buf);
  1343. X        free(ship);
  1344. X        free(planet);
  1345. X        return;
  1346. X            } else {
  1347. X        planet->info[Playernum-1].resource -= 2*ship->build_cost;
  1348. X
  1349. X             openpdata(&order_pdata);
  1350. X        putplanet(order_pdata, planet, Stars[ship->deststar]->planetpos[ship->destpnum]);
  1351. X        close_file(order_pdata);
  1352. X        free(planet);
  1353. X        sprintf(buf, "Factory activated at a cost of %d resources.\n",
  1354. X            2*ship->build_cost);
  1355. X        notify(Playernum, buf);
  1356. X            }
  1357. X
  1358. X    }     
  1359. X                ship->on = 1;
  1360. X        notify(Playernum, "Activated.\n");
  1361. X } else if(!strncmp(args[2], "off", i)) {
  1362. X
  1363. X     if(ship->type==OTYPE_FACTORY && ship->on) {
  1364. X     notify(Playernum, "You can't deactivate a factory once it's online. Consider using 'scrap'.\n");
  1365. X     free(ship);
  1366. X     return;
  1367. X     }
  1368. X     
  1369. X                ship->on = 0;
  1370. X        notify(Playernum, "Deactivated.\n");
  1371. X} else {
  1372. X        notify(Playernum, "I don't understand what you mean.\n");
  1373. X }
  1374. X
  1375. X           ship->notified = 0;
  1376. X    openshdata(&order_shdata);
  1377. X    putship(order_shdata, ship, shipno);
  1378. X    close_file(order_shdata);
  1379. X } else {
  1380. X    notify(Playernum, "You don't own that ship!\n");
  1381. X    }
  1382. X
  1383. X free(ship);
  1384. X}
  1385. X
  1386. X
  1387. X
  1388. X/* 
  1389. X * return what the ship is aimed at, if it's a mirror 
  1390. X */
  1391. Xchar *prin_aimed_at(Playernum, ship)
  1392. Xint Playernum;
  1393. Xshiptype *ship;
  1394. X{
  1395. X placetype targ;
  1396. X
  1397. X  targ.level = ship->aimed_at.level;
  1398. X  targ.snum = ship->aimed_at.snum;
  1399. X  targ.pnum = ship->aimed_at.pnum;
  1400. X  targ.shipno = ship->aimed_at.shipno;
  1401. X  return Dispplace(Playernum, &targ);
  1402. X}
  1403. X
  1404. Xchar *prin_ship_dest(Playernum, ship)
  1405. Xint Playernum;
  1406. Xshiptype *ship;
  1407. X{
  1408. X placetype dest;
  1409. X
  1410. X  dest.level = ship->whatdest;
  1411. X  dest.snum = ship->deststar;
  1412. X  dest.pnum = ship->destpnum;
  1413. X  dest.shipno = ship->destshipno;
  1414. X  return Dispplace(Playernum, &dest);
  1415. X}
  1416. X
  1417. X
  1418. X/* 
  1419. X * mark wherever the ship is aimed at, as explored by the owning player.
  1420. X */
  1421. Xmk_expl_aimed_at(Playernum, s)
  1422. Xint Playernum;
  1423. Xshiptype *s;
  1424. X{
  1425. Xdouble dist;
  1426. Xstartype *str;
  1427. Xplanettype *p;
  1428. Xint sdata,pdata;
  1429. Xfloat xf,yf;
  1430. X
  1431. X str = Stars[s->aimed_at.snum];
  1432. X
  1433. X if (s->is_docked && s->whatdest==LEVEL_PLAN) {
  1434. X    openpdata(&pdata);
  1435. X    getplanet(pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
  1436. X    close_file(pdata);
  1437. X    xf = Stars[s->storbits]->xpos + p->xpos + s->xpos;
  1438. X    yf = Stars[s->storbits]->ypos + p->ypos + s->ypos;
  1439. X    free(p);
  1440. X } else {
  1441. X    xf = s->xpos;
  1442. X    yf = s->ypos;
  1443. X }
  1444. X
  1445. X switch (s->aimed_at.level) {
  1446. X    case LEVEL_UNIV:
  1447. X        sprintf(buf, "There is nothing out here to aim at.");
  1448. X        notify(Playernum, buf);
  1449. X        break;
  1450. X    case LEVEL_STAR:
  1451. X        sprintf(buf, "Star %s ", prin_aimed_at(Playernum, s));
  1452. X        notify(Playernum, buf);
  1453. X        if ((dist=sqrt(Distsq(xf, yf, str->xpos, str->ypos))) <= tele_range(s->type, s->tech) ) {
  1454. X            openstardata(&sdata);
  1455. X            getstar(sdata, &str, s->aimed_at.snum);
  1456. X             setbit(str->explored,Playernum);
  1457. X            putstar(sdata, str, s->aimed_at.snum);
  1458. X            close_file(sdata);    /* don't need to care about Stars */
  1459. X            sprintf(buf, "Surveyed, distance %g.\n",dist);
  1460. X            notify(Playernum, buf);
  1461. X        } else {
  1462. X            sprintf(buf, "Too far to see (%g, max %g).\n", 
  1463. X                        dist, tele_range(s->type, s->tech) );
  1464. X            notify(Playernum, buf);
  1465. X        }
  1466. X        break;
  1467. X    case LEVEL_PLAN:
  1468. X        sprintf(buf, "Planet %s ", prin_aimed_at(Playernum, s));
  1469. X        notify(Playernum, buf);
  1470. X        openpdata(&pdata);
  1471. X        getplanet(pdata, &p, str->planetpos[s->aimed_at.pnum]);
  1472. X        close_file(pdata);
  1473. X        if ((dist=sqrt(Distsq(xf, yf, str->xpos+p->xpos, str->ypos+p->ypos))) <= tele_range(s->type,s->tech) ) {
  1474. X            setbit(str->explored,Playernum);
  1475. X            p->info[Playernum-1].explored = 1;
  1476. X            openpdata(&pdata);
  1477. X            putplanet(pdata, p, str->planetpos[s->aimed_at.pnum]);
  1478. X        close_file(pdata);
  1479. X            free(p);
  1480. X            sprintf(buf, "Surveyed, distance %g.\n", dist);
  1481. X            notify(Playernum, buf);
  1482. X        } else {
  1483. X            sprintf(buf, "Too far to see (%g, max %g).\n", 
  1484. X                        dist, tele_range(s->type, s->tech) );
  1485. X            notify(Playernum, buf);
  1486. X        }
  1487. X        break;
  1488. X    case LEVEL_SHIP:
  1489. X        sprintf(buf, "You can't see anything of use there.\n");
  1490. X        notify(Playernum, buf);
  1491. X        break;
  1492. X }
  1493. X}
  1494. X
  1495. XDispOrdersHeader(Playernum)
  1496. Xint Playernum;
  1497. X{
  1498. Xnotify(Playernum, "            name          destination     orbits     spd   options\n"); 
  1499. X}
  1500. X
  1501. XDispOrders(Playernum, sh, next, check)
  1502. Xint Playernum;
  1503. Xint sh;
  1504. Xint *next;
  1505. Xint check;
  1506. X{
  1507. Xint order_shdata, in_list;
  1508. Xshiptype *ship;
  1509. Xchar temp[128];
  1510. X
  1511. Xopenshdata(&order_shdata);
  1512. X if (!getship(order_shdata,&ship, sh)) {
  1513. X    sprintf(buf, "order:error in getship.\n");
  1514. X    notify(Playernum, buf);
  1515. X    *next = 0;
  1516. X    return; 
  1517. X}
  1518. Xclose_file(order_shdata);
  1519. X
  1520. X*next = ship->nextship;
  1521. X
  1522. Xif(ship->owner != Playernum || !ship->is_alive) { /* cant look at other ships */
  1523. X    free(ship);
  1524. X    return;
  1525. X    }
  1526. X
  1527. Xif(check) {
  1528. X    int j;
  1529. X    in_list = 0;
  1530. X    for(j=0; j<NUMSTYPES; j++)
  1531. X        if(Order_types[j] && ship->type==j) in_list = 1;
  1532. X    if(!in_list) {
  1533. X        free(ship);
  1534. X        return;
  1535. X        }
  1536. X        }
  1537. X
  1538. X    sprintf(buf, "%4d %c %14s %15s %15s %1d ", sh, Shipltrs[ship->type], ship->name, 
  1539. X        prin_ship_dest(Playernum, ship), prin_ship_orbits(ship),  ship->speed);
  1540. X
  1541. Xif(ship->hyper_drive.on) {
  1542. X    sprintf(temp, "/jump %s %d", (ship->hyper_drive.ready ? "ready" : "charging"),
  1543. X        ship->hyper_drive.charge);
  1544. X    strcat(buf, temp);
  1545. X    }
  1546. Xif(ship->protect.self) strcat(buf, "/retal");
  1547. Xif(ship->protect.planet) strcat(buf, "/defense");
  1548. Xif(ship->protect.on) {
  1549. X        sprintf(temp, "/prot %d", ship->protect.ship);
  1550. X        strcat(buf, temp);
  1551. X        }
  1552. Xif(ship->navigate.on) {
  1553. X    sprintf(temp, "/nav %d (%d)", ship->navigate.bearing, ship->navigate.turns);
  1554. X    strcat(buf, temp);
  1555. X    }
  1556. Xif(has_switch(ship)) {
  1557. X    if(ship->on) strcat(buf, "/on");
  1558. X    else strcat(buf, "/off");
  1559. X    }
  1560. Xif(ship->protect.evade) strcat(buf, "/evade");
  1561. Xif(ship->bombard) strcat(buf, "/bomb");
  1562. Xif(ship->type==STYPE_MINE) {
  1563. X    if(ship->mine.mode) strcat(buf, "/explode");
  1564. X    else strcat(buf, "/radiate");
  1565. X    }
  1566. Xif(ship->type==OTYPE_TERRA) {
  1567. X    sprintf(temp, "/(%d, %d)", ship->object.number, ship->object.number2);
  1568. X    strcat(buf, temp);
  1569. X    }
  1570. Xif(ship->type==STYPE_MINE) {
  1571. X    sprintf(temp, "/trigger %d", ship->object.number);
  1572. X    strcat(buf, temp);
  1573. X    }
  1574. Xif(ship->type==OTYPE_TRANSDEV) {
  1575. X    sprintf(temp, "/target %d", ship->object.number);
  1576. X    strcat(buf, temp);
  1577. X    }
  1578. Xif(ship->type == STYPE_MIRROR) {
  1579. X    sprintf(temp, "/aim %s/int %d", prin_aimed_at(Playernum, ship), ship->aimed_at.intensity);
  1580. X    strcat(buf, temp);
  1581. X    }
  1582. X
  1583. Xstrcat(buf, "\n");
  1584. Xnotify(Playernum, buf);
  1585. X/* if hyper space is on estimate how much fuel it will cost to get to the destination */
  1586. X    if(ship->hyper_drive.on) {
  1587. X    double dist, fuse;
  1588. X
  1589. X     dist = sqrt( Distsq(ship->xpos, ship->ypos, Stars[ship->deststar]->xpos, 
  1590. X                Stars[ship->deststar]->ypos));
  1591. X     fuse = HYPER_DRIVE_FUEL_USE * ship->mass 
  1592. X            * (dist/HYPER_DIST_FACTOR) * (dist/HYPER_DIST_FACTOR);
  1593. X            sprintf(buf, "    *** jump will cost %.1ff ***\n", fuse);
  1594. X            notify(Playernum, buf);
  1595. X    if(ship->max_fuel < fuse)
  1596. X            notify(Playernum, "Your ship cannot carry enough fuel to do this jump.\n");
  1597. X        }
  1598. X
  1599. Xfree(ship);
  1600. X}
  1601. X
  1602. X
  1603. END_OF_FILE
  1604. if test 21412 -ne `wc -c <'server/order.c'`; then
  1605.     echo shar: \"'server/order.c'\" unpacked with wrong size!
  1606. fi
  1607. # end of 'server/order.c'
  1608. fi
  1609. if test -f 'server/ships.h' -a "${1}" != "-c" ; then 
  1610.   echo shar: Will not clobber existing file \"'server/ships.h'\"
  1611. else
  1612. echo shar: Extracting \"'server/ships.h'\" \(7417 characters\)
  1613. sed "s/^X//" >'server/ships.h' <<'END_OF_FILE'
  1614. X/*
  1615. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  1616. X * smq@ucscb.ucsc.edu, mods by people in GB.c, enroll.dat.
  1617. X * Restrictions in GB.c.
  1618. X */
  1619. X
  1620. X
  1621. X#define STYPE_POD    0
  1622. X#define STYPE_SHUTTLE     1
  1623. X#define STYPE_CARRIER   2
  1624. X#define STYPE_DREADNT    3
  1625. X#define STYPE_BATTLE     4
  1626. X#define STYPE_INTCPT    5
  1627. X#define STYPE_CRUISER    6
  1628. X#define STYPE_DESTROYER 7
  1629. X#define STYPE_FIGHTER     8
  1630. X#define STYPE_EXPLORER     9
  1631. X#define STYPE_HABITAT     10
  1632. X#define STYPE_STATION    11
  1633. X#define STYPE_ASS    12
  1634. X#define STYPE_CARGO     13
  1635. X#define STYPE_TANKER     14
  1636. X#define STYPE_GOD    15
  1637. X#define STYPE_MINE    16
  1638. X#define STYPE_MIRROR    17
  1639. X
  1640. X#define OTYPE_STELE    18
  1641. X#define OTYPE_GTELE    19
  1642. X#define OTYPE_TRACT    20
  1643. X#define OTYPE_AP    21
  1644. X#define OTYPE_CANIST    22
  1645. X#define OTYPE_VN    23
  1646. X#define OTYPE_BERS    24
  1647. X#define OTYPE_GOV    25
  1648. X#define OTYPE_OMCL    26
  1649. X#define OTYPE_TOXWC    27
  1650. X#define OTYPE_PROBE    28
  1651. X#define OTYPE_GR    29
  1652. X#define OTYPE_FACTORY    30
  1653. X#define OTYPE_TERRA    31
  1654. X#define OTYPE_BERSCTLC    32
  1655. X#define OTYPE_AUTOFAC    33
  1656. X#define OTYPE_TRANSDEV    34
  1657. X#define OTYPE_REPAIR    35
  1658. X#define OTYPE_PLANDEF    36
  1659. X
  1660. X#define ABIL_CARGO     0
  1661. X#define ABIL_DESTCAP     1
  1662. X#define ABIL_GUNS     2
  1663. X#define ABIL_FUELCAP     3
  1664. X#define ABIL_TECH     4
  1665. X#define ABIL_MAXCREW     5
  1666. X#define ABIL_ARMOR     6
  1667. X#define ABIL_TARGET    7
  1668. X#define ABIL_COST     8
  1669. X#define ABIL_JUMP     9
  1670. X#define ABIL_CANLAND    10
  1671. X#define ABIL_HASSWITCH    11
  1672. X#define ABIL_SPEED    12
  1673. X#define ABIL_DAMAGE    13
  1674. X#define ABIL_BUILD    14
  1675. X#define ABIL_CONSTRUCT    15
  1676. X#define ABIL_SIGHT    16
  1677. X#define ABIL_PROGRAMMED 17
  1678. X
  1679. X#define NUMSTYPES     (OTYPE_PLANDEF+1)
  1680. X#define NUMABILS     (ABIL_PROGRAMMED+1)
  1681. X
  1682. X#define SHIP_NAMESIZE    18
  1683. X
  1684. X
  1685. X
  1686. Xtypedef struct ship shiptype;
  1687. Xtypedef struct ship_new shiptype_new;
  1688. Xtypedef struct place placetype;
  1689. X
  1690. X
  1691. Xstruct ship {
  1692. X    float xpos,ypos;
  1693. X    float fuel,mass;
  1694. X    char name[SHIP_NAMESIZE];        /* name of ship (optional) */
  1695. X    char class[SHIP_NAMESIZE];        /* class of ship - designated by players */
  1696. X    percent morale;            /* morale of the crew */
  1697. X    unsigned short command;        /* captain+staff leadership value */
  1698. X
  1699. X    unsigned short destshipno;        /* destination ship # */
  1700. X    unsigned short nextship;        /* next ship in linked list */
  1701. X
  1702. X    unsigned bombard : 1;    /* bombard planet we're orbiting */
  1703. X
  1704. X    percent armor;
  1705. X    percent guns;
  1706. X    percent size;
  1707. X
  1708. X    unsigned short max_crew;
  1709. X    unsigned short max_resource;
  1710. X    unsigned short max_destruct;
  1711. X    unsigned short max_fuel;
  1712. X    unsigned short max_speed;
  1713. X    unsigned short build_type;    /* for factories - type of ship it makes */
  1714. X    unsigned short build_cost; /* how much it cost to build the ship - into VPs too? */
  1715. X
  1716. X    float base_mass;
  1717. X    float tech;        /* technology rating */
  1718. X
  1719. X    struct a {        /* if the ship is a Space Mirror */
  1720. X        unsigned short shipno;    /* aimed at what ship */
  1721. X        char snum;        /* aimed at what star */
  1722. X        percent intensity;        /* intensity of aiming */
  1723. X        unsigned pnum : BITS_MAXPLANETS;  /* aimed at what planet */
  1724. X        unsigned level : 2;    /* aimed at what level */
  1725. X    } aimed_at;
  1726. X    
  1727. X    struct o2 {
  1728. X        short number;    /* for misc functions */
  1729. X        short number2;    /* again */
  1730. X        short number3;
  1731. X        short number4;  /* again */
  1732. X    } object;
  1733. X    
  1734. X    struct m {
  1735. X        unsigned mode : 1; /* 0 for radiation, 1 for damage */
  1736. X    } mine;
  1737. X    
  1738. X    struct nv {
  1739. X        unsigned on : 1;    /* toggles navigate mode */
  1740. X        unsigned speed : 3; /* speed for navigate command */
  1741. X        unsigned turns : 16;/* number turns left in maneuver */
  1742. X        unsigned bearing : 9; /* course */
  1743. X    } navigate;
  1744. X    
  1745. X    struct prot {
  1746. X        float maxrng;           /* maximum range for autoshoot */
  1747. X        unsigned on     :  1; /* toggle on/off */
  1748. X        unsigned planet  :  1; /* planet defender */
  1749. X         unsigned self     :  1; /* retaliate if attacked */
  1750. X         unsigned evade     :  1; /* evasive action */
  1751. X         unsigned ship     : 14; /* ship it is protecting */
  1752. X    } protect;
  1753. X
  1754. X    struct hd {
  1755. X    unsigned char charge;
  1756. X    unsigned ready : 1;
  1757. X    unsigned on : 1;
  1758. X    unsigned dummy : 6;  /* dummy bits for development */
  1759. X    } hyper_drive;
  1760. X
  1761. X    char storbits;        /* what star # orbits */
  1762. X    char deststar;        /* destination star */
  1763. X    unsigned destpnum : BITS_MAXPLANETS;    /* destination planet */
  1764. X    unsigned pnumorbits : BITS_MAXPLANETS;    /* # of planet if orbiting */
  1765. X    unsigned damage : 7;        /* amt of damage */
  1766. X    unsigned rad : 7;            /* radiation level */
  1767. X    unsigned active: 1;            /* tells whether the ship is active */
  1768. X    unsigned short destruct;         /* stuff it's carrying */
  1769. X    unsigned short resource;
  1770. X    unsigned short popn;            /* crew */
  1771. X    unsigned owner : BITS_MAXPLAYERS;    /* owner of ship */
  1772. X    unsigned speed : 4;        /* what speed to travel at 0-9 */
  1773. X    unsigned whatdest : 2;    /* where going (same as Dir) */
  1774. X    unsigned whatorbits : 2;    /* where orbited (same as Dir) */
  1775. X    unsigned type : 6;        /* what type ship is */
  1776. X    unsigned is_cloaked : 1;    /* 1 bit: is cloaked ship */
  1777. X    unsigned is_sheep : 1;    /* 1 bit: is under influence of mind control */
  1778. X    unsigned is_docked : 1;    /* 1 bit: is landed on a planet or docked */
  1779. X    unsigned notified : 1;     /* 1bit: has been notified of something */
  1780. X    unsigned is_alive : 1;    /* 1 bit: ship is alive */
  1781. X    unsigned is_examined : 1;    /* 1 bit: has been examined */
  1782. X    unsigned on : 1;        /* on or off */
  1783. X};
  1784. X
  1785. X
  1786. Xstruct place {        /* used in function return for finding place */
  1787. X    char snum;
  1788. X    char pnum;
  1789. X    short shipno;
  1790. X    shiptype *shipptr;
  1791. X    unsigned level : 2;    /* .level: same as Dir */
  1792. X    unsigned err : 1;        /* if error */
  1793. X};
  1794. X
  1795. X /* whether ship is an object or not */
  1796. X#define is_object(s) ((s)->type > STYPE_MIRROR)
  1797. X
  1798. X /* can takeoff & land, is mobile, etc. */
  1799. X#define speed_rating(s) (Shipdata[(s)->type][ABIL_SPEED])
  1800. X
  1801. X /* has an on/off switch */
  1802. X#define has_switch(s) (Shipdata[(s)->type][ABIL_HASSWITCH])
  1803. X
  1804. X /* can bombard planets */
  1805. X#define can_bombard(s) \
  1806. X    (Shipdata[(s)->type][ABIL_GUNS] && ((s)->type != STYPE_MINE))
  1807. X
  1808. X/* can navigate */
  1809. X#define can_navigate(s) (Shipdata[(s)->type][ABIL_SPEED] > 0 && (s)->type != OTYPE_TERRA && (s)->type != OTYPE_VN)
  1810. X
  1811. X /* can aim at things. */
  1812. X#define can_aim(s) ((s)->type>=STYPE_MIRROR && (s)->type<=OTYPE_TRACT)
  1813. X
  1814. X /* macro for killing a ship.  !notified means we have not yet written it
  1815. X    to the dead_ship file.  */
  1816. X#define kill_ship(s) ((s)->is_alive = 0, (s)->damage = 100, (s)->notified = 0)
  1817. X
  1818. X/* macros to get ship stats */
  1819. X#define Armor(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_ARMOR] : (s)->armor)
  1820. X#define Guns(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_GUNS] : (s)->guns)
  1821. X#define Size(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_TARGET] : (s)->size)
  1822. X#define Max_crew(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_MAXCREW] : (s)->max_crew)
  1823. X#define Max_resource(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_CARGO] : (s)->max_resource)
  1824. X#define Max_fuel(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_FUELCAP] : (s)->max_fuel)
  1825. X#define Max_destruct(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_DESTCAP] : (s)->max_destruct)
  1826. X#define Max_speed(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_SPEED] : (s)->max_speed)
  1827. X#define Cost(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_COST ] : (s)->build_cost)
  1828. X#define Mass(s) ( ((s)->type==OTYPE_FACTORY) ? (s)->mass : (s)->base_mass)
  1829. X
  1830. Xextern placetype Getplace();
  1831. Xextern char *Dispplace(),*Dispshiporbits(),*prin_ship_orbits(),
  1832. X    *prin_aimed_at(), *prin_ship_dest();
  1833. Xextern int Shipdata[NUMSTYPES][NUMABILS];
  1834. Xextern char Shipltrs[];
  1835. Xextern char *Shipnames[];
  1836. Xextern float tele_range(), gun_range();
  1837. X
  1838. XEXTERN shiptype **ships;
  1839. XEXTERN shiptype *shipptr;
  1840. END_OF_FILE
  1841. if test 7417 -ne `wc -c <'server/ships.h'`; then
  1842.     echo shar: \"'server/ships.h'\" unpacked with wrong size!
  1843. fi
  1844. # end of 'server/ships.h'
  1845. fi
  1846. echo shar: End of archive 3 \(of 14\).
  1847. cp /dev/null ark3isdone
  1848. MISSING=""
  1849. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1850.     if test ! -f ark${I}isdone ; then
  1851.     MISSING="${MISSING} ${I}"
  1852.     fi
  1853. done
  1854. if test "${MISSING}" = "" ; then
  1855.     echo You have unpacked all 14 archives.
  1856.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1857. else
  1858.     echo You still need to unpack the following archives:
  1859.     echo "        " ${MISSING}
  1860. fi
  1861. ##  End of shell archive.
  1862. exit 0
  1863.