home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume17 / gbp / part14 < prev    next >
Encoding:
Internet Message Format  |  1993-03-20  |  54.6 KB

  1. Path: uunet!news.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v17i026:  gbp - Galactic Bloodshed+, an empire-like war game, Part14/21
  5. Message-ID: <4554@master.CNA.TEK.COM>
  6. Date: 12 Feb 93 17:32:13 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1798
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1705
  11.  
  12. Submitted-by: deragon@harpo.cs.nyu.edu (Seeker)
  13. Posting-number: Volume 17, Issue 26
  14. Archive-name: gbp/Part14
  15. Supersedes: gb3: Volume 10, Issue 1-14
  16. Environment: sockets, curses
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 14 (of 21)."
  27. # Contents:  user/capture.c user/explore.c user/orbit.c user/prof.c
  28. #   utils/Makelist.c
  29. # Wrapped by billr@saab on Fri Feb 12 09:14:28 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'user/capture.c' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'user/capture.c'\"
  33. else
  34. echo shar: Extracting \"'user/capture.c'\" \(10740 characters\)
  35. sed "s/^X//" >'user/capture.c' <<'END_OF_FILE'
  36. X#ident  "@(#)capture.c    1.5 2/1/93 "
  37. X/*
  38. X * * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, *
  39. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. * Restrictions in
  40. X * GB_copyright.h. *
  41. X * 
  42. X *  capture.c -- capture a ship on the ground *
  43. X * 
  44. X */
  45. X
  46. X#include "GB_copyright.h"
  47. X#define EXTERN extern
  48. X#include "vars.h"
  49. X#include "ships.h"
  50. X#include "races.h"
  51. X#include "power.h"
  52. X#include "buffers.h"
  53. X#include <math.h>
  54. X#include <signal.h>
  55. X#include <strings.h>
  56. X
  57. Xextern int      Defensedata[];
  58. X
  59. Xvoid            capture(int, int, int);
  60. Xvoid            capture_stuff(shiptype *);
  61. X#include "proto.h"
  62. X
  63. Xvoid 
  64. Xcapture(int Playernum, int Governor, int APcount)
  65. X{
  66. X    shiptype       *ship, s;
  67. X    planettype     *p;
  68. X    sectortype     *sect;
  69. X    int             boarders, olddpopn, oldapopn, oldowner, oldgov,
  70. X                    shipdam = 0, booby = 0;
  71. X    int             shipno, nextshipno, x = -1, y = -1, what, olddtroops,
  72. X                    i;
  73. X    int             casualties = 0, casualties1 = 0, casualties2 = 0,
  74. X                    casualty_scale = 0;
  75. X    double          astrength, dstrength;
  76. X    racetype       *Race, *alien;
  77. X    int             snum, pnum;
  78. X
  79. X    if (argn < 2) {
  80. X        notify(Playernum, Governor, "Capture what?\n");
  81. X        return;
  82. X    }
  83. X    snum = Dir[Playernum - 1][Governor].snum;
  84. X    pnum = Dir[Playernum - 1][Governor].pnum;
  85. X    if (Governor && Stars[snum]->governor[Playernum - 1] != Governor) {
  86. X        notify(Playernum, Governor, "You are not authorized in this system.\n");
  87. X        return;
  88. X    }
  89. X    nextshipno = start_shiplist(Playernum, Governor, args[1]);
  90. X    while (shipno = do_shiplist(&ship, &nextshipno))
  91. X        if (ship->owner != Playernum &&
  92. X            in_list((int) ship->owner, args[1], ship, &nextshipno)) {
  93. X            if (!landed(ship)) {
  94. X                sprintf(buf, "%s #%d is not landed on a planet.\n",
  95. X                    Shipnames[ship->type], shipno);
  96. X                notify(Playernum, Governor, buf);
  97. X                free(ship);
  98. X                continue;
  99. X            }
  100. X            if (!enufAP(Playernum, Governor, Stars[ship->storbits]->AP[Playernum - 1], APcount)) {
  101. X                free(ship);
  102. X                continue;
  103. X            }
  104. X            x = ship->land_x;
  105. X            y = ship->land_y;
  106. X
  107. X            getplanet(&p, (int) ship->storbits, (int) ship->pnumorbits);
  108. X            getsector(§, p, x, y);
  109. X
  110. X            if (sect->owner != Playernum) {
  111. X                sprintf(buf, "You don't own the sector where the ship is landed [%d].\n",
  112. X                    sect->owner);
  113. X                notify(Playernum, Governor, buf);
  114. X                free(sect);
  115. X                free(p);
  116. X                free(ship);
  117. X                continue;
  118. X            }
  119. X            if (argn < 4)
  120. X                what = CIV;
  121. X            else if (match(args[3], "civilians"))
  122. X                what = CIV;
  123. X            else if (match(args[3], "military"))
  124. X                what = MIL;
  125. X            else {
  126. X                notify(Playernum, Governor, "Capture with what?\n");
  127. X                free(sect);
  128. X                free(p);
  129. X                free(ship);
  130. X                continue;
  131. X            }
  132. X
  133. X            if (argn < 3) {
  134. X                if (what == CIV)
  135. X                    boarders = sect->popn;
  136. X                else if (what == MIL)
  137. X                    boarders = sect->troops;
  138. X            } else
  139. X                boarders = atoi(args[2]);
  140. X
  141. X            if (boarders <= 0) {
  142. X                sprintf(buf, "Illegal number of boarders %d.\n", boarders);
  143. X                notify(Playernum, Governor, buf);
  144. X                free(ship);
  145. X                free(sect);
  146. X                free(p);
  147. X                continue;
  148. X            }
  149. X            if ((boarders > sect->popn) && what == CIV)
  150. X                boarders = sect->popn;
  151. X            else if ((boarders > sect->troops) && what == MIL)
  152. X                boarders = sect->troops;
  153. X
  154. X            Race = races[Playernum - 1];
  155. X            alien = races[ship->owner - 1];
  156. X
  157. X            if (isset(Race->allied, (int) (ship->owner))) {
  158. X                sprintf(buf, "Boarding the ship of your ally, %s\n", alien->name);
  159. X                notify(Playernum, Governor, buf);
  160. X            }
  161. X            oldapopn = boarders;
  162. X            olddpopn = ship->popn;
  163. X            olddtroops = ship->troops;
  164. X            oldowner = ship->owner;
  165. X            oldgov = ship->governor;
  166. X            bcopy(ship, &s, sizeof(shiptype));
  167. X
  168. X            shipdam = 0;
  169. X            casualties = 0;
  170. X            casualties1 = 0;
  171. X            casualties2 = 0;
  172. X
  173. X            if (what == CIV)
  174. X                sect->popn -= boarders;
  175. X            else if (what == MIL)
  176. X                sect->troops -= boarders;
  177. X
  178. X            if (olddpopn + olddtroops) {
  179. X                sprintf(buf, "Attack strength: %.2f     Defense strength: %.2f\n",
  180. X                    astrength = (double) boarders
  181. X                    * (what == MIL ? (double) Race->fighters * 10.0 : 1.0)
  182. X                    * .01 * Race->tech
  183. X                     * (Race->likes[sect->condition] + 0.01)
  184. X                    * ((double) Defensedata[sect->condition] + 1.0)
  185. X                    * morale_factor((double) (Race->morale - alien->morale)),
  186. X
  187. X                    dstrength = ((double) ship->popn + (double) ship->troops * 10.0
  188. X                         * (double) alien->fighters)
  189. X                    * .01 * alien->tech
  190. X                    * ((double) (Armor(ship)) + 0.01)
  191. X                     * .01 * (100.0 - (double) ship->damage)
  192. X                    * morale_factor((double) (alien->morale - Race->morale))
  193. X                    );
  194. X                notify(Playernum, Governor, buf);
  195. X                casualty_scale = MIN(boarders, ship->popn + ship->troops);
  196. X                if (astrength > 0.0)
  197. X                    casualties = int_rand(0, round_rand((double) casualty_scale * (dstrength + 1.0) /
  198. X                            (astrength + 1.0)));
  199. X
  200. X                if (dstrength > 0.0) {
  201. X                    casualties1 = int_rand(0, round_rand((double) casualty_scale * (astrength + 1.0) /
  202. X                            (dstrength + 1.0)));
  203. X                    casualties2 = int_rand(0, round_rand((double) casualty_scale * (astrength + 1.0) /
  204. X                            (dstrength + 1.0)));
  205. X                    shipdam = int_rand(0, round_rand(25. * (astrength + 1.0) / (dstrength + 1.0)));
  206. X                    ship->damage = MIN(100, ship->damage + shipdam);
  207. X                }
  208. X                casualties = MIN(boarders, casualties);
  209. X                boarders -= casualties;
  210. X
  211. X                casualties1 = MIN(olddpopn, casualties1);
  212. X                ship->popn -= casualties1;
  213. X                ship->mass -= casualties1 * alien->mass;
  214. X
  215. X                casualties2 = MIN(olddtroops, casualties2);
  216. X                ship->troops -= casualties2;
  217. X                ship->mass -= casualties2 * alien->mass;
  218. X
  219. X            } else if (ship->destruct) {    /* booby trapped robot
  220. X                             * ships */
  221. X                booby = int_rand(0, 10 * (int) ship->destruct);
  222. X                booby = MIN(100, booby);
  223. X                casualties = casualties2 = 0;
  224. X                for (i = 0; i < boarders; i++)
  225. X                    casualties += (int_rand(1, 100) < booby);
  226. X                boarders -= casualties;
  227. X                shipdam += booby;
  228. X                ship->damage += booby;
  229. X            }
  230. X            shipdam = MIN(100, shipdam);
  231. X            if (ship->damage >= 100)
  232. X                kill_ship(Playernum, ship);
  233. X
  234. X            if (!(ship->popn + ship->troops) && ship->alive) {
  235. X                /* we got 'em */
  236. X                ship->owner = Playernum;
  237. X                ship->governor = Governor;
  238. X                if (what == CIV) {
  239. X                    ship->popn = MIN(boarders, Max_crew(ship));
  240. X                    sect->popn += boarders - ship->popn;
  241. X                    ship->mass += ship->popn * Race->mass;
  242. X                } else if (what == MIL) {
  243. X                    ship->troops = MIN(boarders, Max_mil(ship));
  244. X                    sect->troops += boarders - ship->troops;
  245. X                    ship->mass += ship->troops * Race->mass;
  246. X                }
  247. X                if (olddpopn + olddtroops && ship->type != OTYPE_FACTORY)
  248. X                    adjust_morale(Race, alien, (int) ship->build_cost);
  249. X                /* unoccupied ships and factories don't count */
  250. X            } else {/* retreat */
  251. X                if (what == CIV)
  252. X                    sect->popn += boarders;
  253. X                else if (what == MIL)
  254. X                    sect->troops += boarders;
  255. X            }
  256. X
  257. X            if (!(sect->popn + sect->troops))
  258. X                sect->owner = 0;
  259. X
  260. X            sprintf(buf, "BULLETIN from %s/%s!!\n",
  261. X                Stars[ship->storbits]->name, Stars[ship->storbits]->pnames[ship->pnumorbits]);
  262. X            strcpy(telegram_buf, buf);
  263. X            sprintf(buf, "You are being attacked by%s Player #%d (%s)!!!\n",
  264. X               (isset(alien->allied, Playernum) ? " your ally" :
  265. X                (isset(alien->atwar, Playernum) ? " your enemy" : " neutral")),
  266. X                Playernum, Race->name);
  267. X            strcat(telegram_buf, buf);
  268. X            sprintf(buf, "%s at sector %d,%d [owner %d] !\n",
  269. X                Ship(ship), x, y, sect->owner);
  270. X            strcat(telegram_buf, buf);
  271. X
  272. X            if (booby) {
  273. X                sprintf(buf, "Booby trap triggered causing %d%% damage.\n", booby);
  274. X                strcat(telegram_buf, buf);
  275. X                notify(Playernum, Governor, buf);
  276. X            }
  277. X            if (shipdam) {
  278. X                sprintf(buf, "Total damage: %d%% (now %d%%)\n", shipdam, ship->damage);
  279. X                strcat(telegram_buf, buf);
  280. X                sprintf(buf, "Damage inflicted:  Them: %d%% (now %d%%)\n",
  281. X                    shipdam, ship->damage);
  282. X                notify(Playernum, Governor, buf);
  283. X            }
  284. X            if (!ship->alive) {
  285. X                sprintf(buf, "              YOUR SHIP WAS DESTROYED!!!\n");
  286. X                strcat(telegram_buf, buf);
  287. X                sprintf(buf, "              Their ship DESTROYED!!!\n");
  288. X                notify(Playernum, Governor, buf);
  289. X                sprintf(short_buf, "%s: %s [%d] DESTROYED %s\n",
  290. X                    Dispshiploc(ship), Race->name, Playernum, Ship(&s));
  291. X            }
  292. X            if (ship->owner == Playernum) {
  293. X                sprintf(buf, "%s CAPTURED!\n", Ship(&s));
  294. X                notify(oldowner, oldgov, buf);
  295. X                sprintf(buf, "VICTORY! The ship is yours!\n");
  296. X                notify(Playernum, Governor, buf);
  297. X                if (what == CIV)
  298. X                    sprintf(buf, "%d boarders move in.\n", MIN(boarders, ship->popn));
  299. X                else if (what == MIL)
  300. X                    sprintf(buf, "%d troops move in.\n", MIN(boarders, ship->troops));
  301. X                notify(Playernum, Governor, buf);
  302. X                capture_stuff(ship);
  303. X                sprintf(short_buf, "%s: %s [%d] CAPTURED %s\n",
  304. X                    Dispshiploc(ship), Race->name, Playernum, Ship(&s));
  305. X            } else if (ship->popn + ship->troops) {
  306. X                sprintf(buf, "You fought them off!\n");
  307. X                notify(oldowner, oldgov, buf);
  308. X                sprintf(buf, "The boarding was repulsed; try again.\n");
  309. X                notify(Playernum, Governor, buf);
  310. X                sprintf(short_buf, "%s: %s [%d] assaults %s\n",
  311. X                    Dispshiploc(ship), Race->name, Playernum, Ship(&s));
  312. X            }
  313. X            if (ship->alive) {
  314. X                if (sect->popn + sect->troops + boarders) {
  315. X                    sprintf(buf, "You killed all the aliens in this sector!\n");
  316. X                    strcat(telegram_buf, buf);
  317. X                    p->info[Playernum - 1].mob_points -= sect->mobilization;
  318. X                }
  319. X                if (!boarders) {
  320. X                    sprintf(buf, "Oh no! They killed your party to the last man!\n");
  321. X                    notify(Playernum, Governor, buf);
  322. X                }
  323. X            } else {
  324. X                sprintf(buf, "Your ship was weakened too much!\n");
  325. X                strcat(telegram_buf, buf);
  326. X                sprintf(buf, "The assault weakened their ship too much!\n");
  327. X                notify(Playernum, Governor, buf);
  328. X            }
  329. X
  330. X            if (casualties || casualties1 || casualties2) {
  331. X                sprintf(buf, "Casualties: Yours: %d civ/%d mil, Theirs: %d %s\n",
  332. X                    casualties1, casualties2, casualties, what == CIV ? "civ" : "mil");
  333. X                strcat(telegram_buf, buf);
  334. X                sprintf(buf, "Casualties: Yours: %d %s, Theirs: %d civ/%d mil\n",
  335. X                    casualties, what == CIV ? "civ" : "mil", casualties1, casualties2);
  336. X                notify(Playernum, Governor, buf);
  337. X            }
  338. X            warn(oldowner, oldgov, telegram_buf);
  339. X            if (ship->owner != oldowner || !ship->alive)
  340. X                post(short_buf, COMBAT);
  341. X            notify_star(Playernum, Governor, oldowner,
  342. X                    (int) ship->storbits, short_buf);
  343. X            putship(ship);
  344. X            putsector(sect, p, x, y);
  345. X            putplanet(p, snum, pnum);
  346. X            putrace(Race);
  347. X            putrace(alien);
  348. X            deductAPs(Playernum, Governor, APcount, (int) ship->storbits, 0);
  349. X            free(p);
  350. X            free(ship);
  351. X            free(sect);
  352. X        } else
  353. X            free(ship);
  354. X
  355. X}
  356. X
  357. Xvoid 
  358. Xcapture_stuff(shiptype * ship)
  359. X{
  360. X    int             sh;
  361. X    shiptype       *s;
  362. X
  363. X    sh = ship->ships;
  364. X    while (sh) {
  365. X        (void) getship(&s, sh);
  366. X        capture_stuff(s);    /* recursive call */
  367. X        s->owner = ship->owner;    /* make sure he gets all of the ships
  368. X                     * landed on it */
  369. X        s->governor = ship->governor;
  370. X        putship(s);
  371. X        sprintf(buf, "%s CAPTURED!\n", Ship(s));
  372. X        notify((int) s->owner, (int) s->governor, buf);
  373. X        sh = s->nextship;
  374. X        free(s);
  375. X    }
  376. X}
  377. END_OF_FILE
  378. if test 10740 -ne `wc -c <'user/capture.c'`; then
  379.     echo shar: \"'user/capture.c'\" unpacked with wrong size!
  380. fi
  381. # end of 'user/capture.c'
  382. fi
  383. if test -f 'user/explore.c' -a "${1}" != "-c" ; then 
  384.   echo shar: Will not clobber existing file \"'user/explore.c'\"
  385. else
  386. echo shar: Extracting \"'user/explore.c'\" \(12697 characters\)
  387. sed "s/^X//" >'user/explore.c' <<'END_OF_FILE'
  388. X/*
  389. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  390. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  391. X * GB_copyright.h. explore.c -- display systems/worlds explored (this command
  392. X * written by Dan Corrin, dan@geomech.engrg.uwo.ca)
  393. X * 
  394. X * Thu Apr 11 02:19:44 MDT 1991 Made mods to this prior, but forgot the header.
  395. X * :) Evan Koffler
  396. X */
  397. X#include <math.h>
  398. X#include <strings.h>
  399. X#include "GB_copyright.h"
  400. X#define EXTERN extern
  401. X#include "vars.h"
  402. X#include "ships.h"
  403. X#include "races.h"
  404. X#include "power.h"
  405. X#include "buffers.h"
  406. Xextern char     Psymbol[], *Planet_types[];
  407. X
  408. Xvoid            colonies_at_star(int, int, racetype *, int, int);
  409. Xvoid            colonies(int, int, int, int);
  410. Xvoid            distance(int, int, int);
  411. Xvoid            star_locations(int, int, int);
  412. Xvoid            exploration(int, int, int);
  413. Xvoid            tech_status(int, int, int);
  414. Xvoid            tech_report_star(int, int, startype *, int, int *, double *, double *);
  415. X#include "proto.h"
  416. X
  417. Xvoid 
  418. Xcolonies_at_star(int Playernum, int Governor, racetype * Race, int star, int mode)
  419. X{
  420. X    int             i, j;
  421. X    planettype     *pl;
  422. X
  423. X    getstar(&(Stars[star]), star);
  424. X    if (!isset(Stars[star]->explored, Playernum))
  425. X        return;
  426. X
  427. X    for (i = 0; i < Stars[star]->numplanets; i++) {
  428. X        getplanet(&pl, star, i);
  429. X
  430. X        if (pl->info[Playernum - 1].explored &&
  431. X            pl->info[Playernum - 1].numsectsowned &&
  432. X            (!Governor || Stars[star]->governor[Playernum - 1] == Governor)) {
  433. X            switch (mode) {
  434. X            case -1:    /* combined report */
  435. X            case 0:/* colonies */
  436. X                sprintf(buf,
  437. X                    " %c %4.4s/%-4.4s%c%4d%3d%5d%8d%3d%6d%5d%6d %3d/%-3d%3.0f/%-3d%3d/%-3d",
  438. X                    Psymbol[pl->type],
  439. X                    Stars[star]->name,
  440. X                    Stars[star]->pnames[i],
  441. X                    (pl->info[Playernum - 1].autorep ? '*' : ' '),
  442. X                    Stars[star]->governor[Playernum - 1],
  443. X                      pl->info[Playernum - 1].numsectsowned,
  444. X                    pl->info[Playernum - 1].tech_invest,
  445. X                    pl->info[Playernum - 1].popn,
  446. X                    pl->info[Playernum - 1].crystals,
  447. X                    pl->info[Playernum - 1].resource,
  448. X                    pl->info[Playernum - 1].destruct,
  449. X                    pl->info[Playernum - 1].fuel,
  450. X                    pl->info[Playernum - 1].tax,
  451. X                    pl->info[Playernum - 1].newtax,
  452. X                    compatibility(pl, Race),
  453. X                    pl->conditions[TOXIC],
  454. X                    pl->info[Playernum - 1].comread,
  455. X                    pl->info[Playernum - 1].mob_set);
  456. X                notify(Playernum, Governor, buf);
  457. X                for (j = 1; j <= Num_races; j++)
  458. X                    if ((j != Playernum) && (pl->info[j - 1].numsectsowned > 0)) {
  459. X                        sprintf(buf, " %d", j);
  460. X                        notify(Playernum, Governor, buf);
  461. X                    }
  462. X                notify(Playernum, Governor, "\n");
  463. X                if (mode == 0)
  464. X                    break;
  465. X                /* Fall through if (mode == -1) */
  466. X            case 1:/* production */
  467. X                sprintf(buf,
  468. X                    " %c %4.4s/%-4.4s%c%3d%8.4f%8d%3d%6d%5d%6d %6d   %3d%8.2f\n",
  469. X                    Psymbol[pl->type],
  470. X                  Stars[star]->name, Stars[star]->pnames[i],
  471. X                    (pl->info[Playernum - 1].autorep ? '*' : ' '),
  472. X                    Stars[star]->governor[Playernum - 1],
  473. X                    pl->info[Playernum - 1].prod_tech,
  474. X                    pl->total_resources,
  475. X                      pl->info[Playernum - 1].prod_crystals,
  476. X                    pl->info[Playernum - 1].prod_res,
  477. X                    pl->info[Playernum - 1].prod_dest,
  478. X                    pl->info[Playernum - 1].prod_fuel,
  479. X                    pl->info[Playernum - 1].prod_money,
  480. X                    pl->info[Playernum - 1].tox_thresh,
  481. X                    pl->info[Playernum - 1].est_production);
  482. X                notify(Playernum, Governor, buf);
  483. X                break;
  484. X            default:
  485. X                break;
  486. X            }
  487. X        }
  488. X        free(pl);
  489. X    }
  490. X}
  491. X
  492. Xvoid 
  493. Xcolonies(int Playernum, int Governor, int APcount, int mode)
  494. X{
  495. X    int             i, star;
  496. X    racetype       *Race;
  497. X    placetype       where;
  498. X
  499. X    switch (mode) {
  500. X    case -1:
  501. X        notify(Playernum, Governor, "          ========= Colonies Prod Report ==========\n");
  502. X        notify(Playernum, Governor, "  Planet     gov sec tech    popn  x   res  des  fuel  tax  cmpt/tox mob   Aliens\n");
  503. X        notify(Playernum, Governor, "               tox  deposit\n");
  504. X        break;
  505. X    case 0:
  506. X        notify(Playernum, Governor, "          ========== Colonization Report ==========\n");
  507. X        notify(Playernum, Governor, "  Planet     gov sec tech    popn  x   res  des  fuel  tax  cmpt/tox mob  Aliens\n");
  508. X        break;
  509. X    case 1:
  510. X        notify(Playernum, Governor, "          ============ Production Report ==========\n");
  511. X        notify(Playernum, Governor, "  Planet     gov    tech deposit  x   res  des  fuel    tax   tox  est prod\n");
  512. X        break;
  513. X    default:
  514. X        notify(Playernum, Governor, "          =============== Unknown Report ==========\n");
  515. X        return;
  516. X    }
  517. X
  518. X    Race = races[Playernum - 1];
  519. X    getsdata(&Sdata);
  520. X
  521. X    if (argn < 2)
  522. X        for (star = 0; star < Sdata.numstars; star++)
  523. X            colonies_at_star(Playernum, Governor, Race, star, mode);
  524. X    else
  525. X        for (i = 1; i < argn; i++) {
  526. X            where = Getplace(Playernum, Governor, args[i], 0);
  527. X            if (where.err || (where.level == LEVEL_UNIV) || (where.level == LEVEL_SHIP)) {
  528. X                sprintf(buf, "Bad location `%s'.\n", args[i]);
  529. X                notify(Playernum, Governor, buf);
  530. X                continue;
  531. X            } else    /* ok, a proper location */
  532. X                colonies_at_star(Playernum, Governor, Race, where.snum, mode);
  533. X        }
  534. X    notify(Playernum, Governor, "\n");
  535. X}
  536. X
  537. X
  538. Xvoid 
  539. Xdistance(int Playernum, int Governor, int APcount)
  540. X{
  541. X    placetype       from, to;
  542. X    planettype     *p;
  543. X    double          x0, y0, x1, y1, dist;
  544. X    shiptype       *ship;
  545. X
  546. X    if (argn < 3) {
  547. X        notify(Playernum, Governor, "Syntax: 'distance <from> <to>'.\n");
  548. X        return;
  549. X    }
  550. X    from = Getplace(Playernum, Governor, args[1], 1);
  551. X    if (from.err) {
  552. X        sprintf(buf, "Bad scope '%s'.\n", args[1]);
  553. X        notify(Playernum, Governor, buf);
  554. X        return;
  555. X    }
  556. X    to = Getplace(Playernum, Governor, args[2], 1);
  557. X    if (to.err) {
  558. X        sprintf(buf, "Bad scope '%s'.\n", args[2]);
  559. X        notify(Playernum, Governor, buf);
  560. X    }
  561. X    x0 = 0.0;
  562. X    y0 = 0.0;
  563. X    x1 = 0.0;
  564. X    y1 = 0.0;
  565. X    /* get position in absolute units */
  566. X    if (from.level == LEVEL_SHIP) {
  567. X        (void) getship(&ship, from.shipno);
  568. X        if (ship->owner != Playernum) {
  569. X            notify(Playernum, Governor, "Nice try.\n");
  570. X            free(ship);
  571. X            return;
  572. X        }
  573. X        x0 = ship->xpos;
  574. X        y0 = ship->ypos;
  575. X        free(ship);
  576. X    } else if (from.level == LEVEL_PLAN) {
  577. X        getplanet(&p, (int) from.snum, (int) from.pnum);
  578. X        x0 = p->xpos + Stars[from.snum]->xpos;
  579. X        y0 = p->ypos + Stars[from.snum]->ypos;
  580. X        free(p);
  581. X    } else if (from.level == LEVEL_STAR) {
  582. X        x0 = Stars[from.snum]->xpos;
  583. X        y0 = Stars[from.snum]->ypos;
  584. X    }
  585. X    if (to.level == LEVEL_SHIP) {
  586. X        (void) getship(&ship, to.shipno);
  587. X        if (ship->owner != Playernum) {
  588. X            notify(Playernum, Governor, "Nice try.\n");
  589. X            free(ship);
  590. X            return;
  591. X        }
  592. X        x1 = ship->xpos;
  593. X        y1 = ship->ypos;
  594. X        free(ship);
  595. X    } else if (to.level == LEVEL_PLAN) {
  596. X        getplanet(&p, (int) to.snum, (int) to.pnum);
  597. X        x1 = p->xpos + Stars[to.snum]->xpos;
  598. X        y1 = p->ypos + Stars[to.snum]->ypos;
  599. X        free(p);
  600. X    } else if (to.level == LEVEL_STAR) {
  601. X        x1 = Stars[to.snum]->xpos;
  602. X        y1 = Stars[to.snum]->ypos;
  603. X    }
  604. X    /* compute the distance */
  605. X    dist = sqrt(Distsq(x0, y0, x1, y1));
  606. X    sprintf(buf, "Distance = %f\n", dist);
  607. X    notify(Playernum, Governor, buf);
  608. X}
  609. X
  610. Xvoid 
  611. Xstar_locations(int Playernum, int Governor, int APcount)
  612. X{
  613. X    reg int         i;
  614. X    double          dist, x, y;
  615. X    int             max;
  616. X
  617. X    x = Dir[Playernum - 1][Governor].lastx[1];
  618. X    y = Dir[Playernum - 1][Governor].lasty[1];
  619. X
  620. X    if (argn > 1)
  621. X        max = atoi(args[1]);
  622. X    else
  623. X        max = 999999;
  624. X
  625. X    for (i = 0; i < Sdata.numstars; i++) {
  626. X        dist = sqrt(Distsq(Stars[i]->xpos, Stars[i]->ypos, x, y));
  627. X        if ((int) dist <= max) {
  628. X            sprintf(buf, "(%2d) %20.20s (%8.0f,%8.0f) %7.0f\n", i,
  629. X                Stars[i]->name, Stars[i]->xpos, Stars[i]->ypos, dist);
  630. X            notify(Playernum, Governor, buf);
  631. X        }
  632. X    }
  633. X}
  634. X
  635. Xvoid 
  636. Xexploration(int Playernum, int Governor, int APcount)
  637. X{
  638. X    int             star, starq, i, j;
  639. X    planettype     *pl;
  640. X    placetype       where;
  641. X    racetype       *Race;
  642. X
  643. X    starq = -1;
  644. X
  645. X    if (argn == 2) {
  646. X        where = Getplace(Playernum, Governor, args[1], 0);
  647. X        if (where.err) {
  648. X            sprintf(buf, "explore: bad scope.\n");
  649. X            notify(Playernum, Governor, buf);
  650. X            return;
  651. X        } else if (where.level == LEVEL_SHIP || where.level == LEVEL_UNIV) {
  652. X            sprintf(buf, "Bad scope '%s'.\n", args[1]);
  653. X            notify(Playernum, Governor, buf);
  654. X            return;
  655. X        }
  656. X        starq = where.snum;
  657. X    }
  658. X    Race = races[Playernum - 1];
  659. X
  660. X    getsdata(&Sdata);
  661. X    sprintf(buf, "         ========== Exploration Report ==========\n");
  662. X    notify(Playernum, Governor, buf);
  663. X    sprintf(buf, " Global action points : [%2d]\n", Sdata.AP[Playernum - 1]);
  664. X    notify(Playernum, Governor, buf);
  665. X    sprintf(buf, " Star  (stability)[AP]   #  Planet [Attributes] Type (Compatibility)\n");
  666. X    notify(Playernum, Governor, buf);
  667. X    for (star = 0; star < Sdata.numstars; star++)
  668. X        if ((starq == -1) || (starq == star)) {
  669. X            getstar(&(Stars[star]), star);
  670. X            if (isset(Stars[star]->explored, Playernum))
  671. X                for (i = 0; i < Stars[star]->numplanets; i++) {
  672. X                    getplanet(&pl, star, i);
  673. X                    if (i == 0)
  674. X                        if (Race->tech >= TECH_SEE_STABILITY) {
  675. X                            sprintf(buf, "\n%13s (%2d)[%2d]\n", Stars[star]->name, Stars[star]->stability,
  676. X                                Stars[star]->AP[Playernum - 1]);
  677. X                            notify(Playernum, Governor, buf);
  678. X                        } else {
  679. X                            sprintf(buf, "\n%13s (/?/?)[%2d]\n", Stars[star]->name,
  680. X                                Stars[star]->AP[Playernum - 1]);
  681. X                            notify(Playernum, Governor, buf);
  682. X                        }
  683. X
  684. X
  685. X                    sprintf(buf, "  #%d. %-15s [ ", i + 1, Stars[star]->pnames[i]);
  686. X                    notify(Playernum, Governor, buf);
  687. X                    if (pl->info[Playernum - 1].explored) {
  688. X                        sprintf(buf, "Ex ");
  689. X                        notify(Playernum, Governor, buf);
  690. X                        if (pl->info[Playernum - 1].autorep) {
  691. X                            sprintf(buf, "Rep ");
  692. X                            notify(Playernum, Governor, buf);
  693. X                        }
  694. X                        if (pl->info[Playernum - 1].numsectsowned) {
  695. X                            sprintf(buf, "Inhab ");
  696. X                            notify(Playernum, Governor, buf);
  697. X                        }
  698. X                        if (pl->slaved_to) {
  699. X                            sprintf(buf, "SLAVED ");
  700. X                            notify(Playernum, Governor, buf);
  701. X                        }
  702. X                        for (j = 1; j <= Num_races; j++)
  703. X                            if (j != Playernum && pl->info[j - 1].numsectsowned) {
  704. X                                sprintf(buf, "%d ", j);
  705. X                                notify(Playernum, Governor, buf);
  706. X                            }
  707. X                        if (pl->conditions[TOXIC] > 70) {
  708. X                            sprintf(buf, "TOXIC ");
  709. X                            notify(Playernum, Governor, buf);
  710. X                        }
  711. X                        sprintf(buf, "] %s %2.0f%%\n", Planet_types[pl->type],
  712. X                           compatibility(pl, Race));
  713. X                        notify(Playernum, Governor, buf);
  714. X                    } else {
  715. X                        sprintf(buf, "No Data ]\n");
  716. X                        notify(Playernum, Governor, buf);
  717. X                    }
  718. X                    free(pl);
  719. X                }
  720. X        }
  721. X}
  722. X
  723. Xvoid 
  724. Xtech_status(int Playernum, int Governor, int APcount)
  725. X{
  726. X    int             star, k;
  727. X    placetype       where;
  728. X    double          total_gain = 0.0;
  729. X    double          total_max_gain = 0.0;
  730. X    int             total_invest = 0;
  731. X
  732. X    getsdata(&Sdata);
  733. X
  734. X    sprintf(buf, "             ========== Technology Report ==========\n\n");
  735. X    notify(Playernum, Governor, buf);
  736. X
  737. X    sprintf(buf, "       Planet          popn    invest    gain   ^gain\n");
  738. X    notify(Playernum, Governor, buf);
  739. X
  740. X    if (argn == 1) {
  741. X        for (star = 0; star < Sdata.numstars; star++) {
  742. X            getstar(&(Stars[star]), star);
  743. X            tech_report_star(Playernum, Governor, Stars[star], star,
  744. X                   &total_invest, &total_gain, &total_max_gain);
  745. X        }
  746. X    } else {        /* Several arguments */
  747. X        for (k = 1; k < argn; k++) {
  748. X            where = Getplace(Playernum, Governor, args[k], 0);
  749. X            if (where.err || where.level == LEVEL_UNIV || where.level == LEVEL_SHIP) {
  750. X                sprintf(buf, "Bad location `%s'.\n", args[k]);
  751. X                notify(Playernum, Governor, buf);
  752. X                continue;
  753. X            } else {/* ok, a proper location */
  754. X                star = where.snum;
  755. X                getstar(&Stars[star], star);
  756. X                tech_report_star(Playernum, Governor, Stars[star], star,
  757. X                &total_invest, &total_gain, &total_max_gain);
  758. X            }
  759. X        }
  760. X    }
  761. X    sprintf(buf, "       Total Popn:  %7ld\n", Power[Playernum - 1].popn);
  762. X    notify(Playernum, Governor, buf);
  763. X    sprintf(buf, "Tech: %31d%8.3lf%8.3lf\n",
  764. X        total_invest, total_gain, total_max_gain);
  765. X    notify(Playernum, Governor, buf);
  766. X}
  767. X
  768. X
  769. Xvoid 
  770. Xtech_report_star(int Playernum, int Governor, startype * star, int snum,
  771. X         int *t_invest, double *t_gain, double *t_max_gain)
  772. X{
  773. X    int             i;
  774. X    planettype     *pl;
  775. X    char            str[200];
  776. X    double          gain, max_gain;
  777. X
  778. X    if (isset(star->explored, Playernum) &&
  779. X        (!Governor || star->governor[Playernum - 1] == Governor)) {
  780. X        for (i = 0; i < star->numplanets; i++) {
  781. X            getplanet(&pl, snum, i);
  782. X            if (pl->info[Playernum - 1].explored
  783. X                && pl->info[Playernum - 1].numsectsowned) {
  784. X                sprintf(str, "%s/%s%s", star->name, star->pnames[i],
  785. X                    (pl->info[Playernum - 1].autorep ? "*" : ""));
  786. X                sprintf(buf, "%16.16s %10d%10d%8.3lf%8.3lf\n", str,
  787. X                    pl->info[Playernum - 1].popn,
  788. X                    pl->info[Playernum - 1].tech_invest,
  789. X                    gain = tech_prod((int) pl->info[Playernum - 1].tech_invest,
  790. X                    (int) pl->info[Playernum - 1].popn),
  791. X                    max_gain = tech_prod((int) pl->info[Playernum - 1].prod_res,
  792. X                       (int) pl->info[Playernum - 1].popn));
  793. X                notify(Playernum, Governor, buf);
  794. X                *t_invest += pl->info[Playernum - 1].tech_invest;
  795. X                *t_gain += gain;
  796. X                *t_max_gain += max_gain;
  797. X            }
  798. X            free(pl);
  799. X        }
  800. X    }
  801. X}
  802. END_OF_FILE
  803. if test 12697 -ne `wc -c <'user/explore.c'`; then
  804.     echo shar: \"'user/explore.c'\" unpacked with wrong size!
  805. fi
  806. # end of 'user/explore.c'
  807. fi
  808. if test -f 'user/orbit.c' -a "${1}" != "-c" ; then 
  809.   echo shar: Will not clobber existing file \"'user/orbit.c'\"
  810. else
  811. echo shar: Extracting \"'user/orbit.c'\" \(12472 characters\)
  812. sed "s/^X//" >'user/orbit.c' <<'END_OF_FILE'
  813. X/*
  814. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  815. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  816. X * GB_copyright.h.
  817. X * 
  818. X * orbit.c -- display orbits of planets (graphic representation)
  819. X * 
  820. X * OPTIONS -p : If this option is set, ``orbit'' will not display planet names.
  821. X * 
  822. X * -S : Do not display star names.
  823. X * 
  824. X * -s : Do not display ships.
  825. X * 
  826. X * -(number) : Do not display that #'d ship or planet (in case it obstructs the
  827. X * view of another object)
  828. X */
  829. X
  830. X#include "GB_copyright.h"
  831. X#define EXTERN extern
  832. X#include "vars.h"
  833. X#include "ships.h"
  834. X#include "races.h"
  835. X#include "power.h"
  836. X#include "buffers.h"
  837. X#include <curses.h>
  838. X#include <stdio.h>
  839. Xextern char     Shipltrs[];
  840. Xdouble          Lastx, Lasty, Zoom;
  841. Xint             SCALE = 100;
  842. X
  843. Xracetype       *Race;
  844. X
  845. Xchar            Psymbol[] = {'@', 'o', 'O', '#', '~', '.', ')', '-'};
  846. Xchar           *Planet_types[] = {"Class M", "Asteroid", "Airless", "Iceball",
  847. X"Jovian", "Waterball", "Forest", "Desert"};
  848. X
  849. Xvoid            orbit(int, int, int);
  850. Xvoid            DispStar(int, int, int, startype *, int, int, char *);
  851. Xvoid            DispPlanet(int, int, int, planettype *, char *, int, racetype *, char *);
  852. Xvoid            DispShip(int, int, placetype *, shiptype *, planettype *, int, char *);
  853. X#include "proto.h"
  854. X
  855. Xvoid 
  856. Xorbit(int Playernum, int Governor, int APcount)
  857. X{
  858. X    register int    sh, i, iq;
  859. X    int             DontDispNum = -1, flag;
  860. X    planettype     *p;
  861. X    shiptype       *s;
  862. X    placetype       where;
  863. X    int             DontDispPlanets, DontDispShips, DontDispStars;
  864. X    char            output[100000];
  865. X
  866. X    DontDispPlanets = DontDispShips = DontDispStars = 0;
  867. X
  868. X    /* find options, set flags accordingly */
  869. X    for (flag = 1; flag <= argn - 1; flag++)
  870. X        if (*args[flag] == '-') {
  871. X            for (i = 1; args[flag][i] != '\0'; i++)
  872. X                switch (args[flag][i]) {
  873. X                case 's':
  874. X                    DontDispShips = 1;
  875. X                    break;
  876. X                case 'S':
  877. X                    DontDispStars = 1;
  878. X                    break;
  879. X                case 'p':
  880. X                    DontDispPlanets = 1;
  881. X                    break;
  882. X                default:
  883. X                    if (sscanf(args[flag] + 1, "%d", &DontDispNum) != 1) {
  884. X                        sprintf(buf, "Bad number %s.\n", args[flag] + 1);
  885. X                        notify(Playernum, Governor, buf);
  886. X                        DontDispNum = -1;
  887. X                    }
  888. X                    if (DontDispNum)
  889. X                        DontDispNum--;    /* make a '1' into a '0' */
  890. X                    break;
  891. X                }
  892. X        }
  893. X    if (argn == 1) {
  894. X        where = Getplace(Playernum, Governor, ":", 0);
  895. X        i = (Dir[Playernum - 1][Governor].level == LEVEL_UNIV);
  896. X        Lastx = Dir[Playernum - 1][Governor].lastx[i];
  897. X        Lasty = Dir[Playernum - 1][Governor].lasty[i];
  898. X        Zoom = Dir[Playernum - 1][Governor].zoom[i];
  899. X    } else {
  900. X        where = Getplace(Playernum, Governor, args[argn - 1], 0);
  901. X        Lastx = Lasty = 0.0;
  902. X        Zoom = 1.1;
  903. X    }
  904. X
  905. X    if (where.err) {
  906. X        notify(Playernum, Governor, "orbit: error in args.\n");
  907. X        return;
  908. X    }
  909. X    /* orbit type of map */
  910. X    sprintf(output, "#");
  911. X
  912. X    Race = races[Playernum - 1];
  913. X
  914. X    switch (where.level) {
  915. X    case LEVEL_UNIV:
  916. X        for (i = 0; i < Sdata.numstars; i++)
  917. X            if (DontDispNum != i) {
  918. X                DispStar(Playernum, Governor, LEVEL_UNIV, Stars[i], DontDispStars,
  919. X                     (int) Race->God, buf);
  920. X                strcat(output, buf);
  921. X            }
  922. X        if (!DontDispShips) {
  923. X            sh = Sdata.ships;
  924. X            while (sh) {
  925. X                (void) getship(&s, sh);
  926. X                if (DontDispNum != sh) {
  927. X                    DispShip(Playernum, Governor, &where, s, NULL,
  928. X                         (int) Race->God, buf);
  929. X                    strcat(output, buf);
  930. X                }
  931. X                sh = s->nextship;
  932. X                free(s);
  933. X            }
  934. X        }
  935. X        break;
  936. X    case LEVEL_STAR:
  937. X        DispStar(Playernum, Governor, LEVEL_STAR, Stars[where.snum],
  938. X             DontDispStars, (int) Race->God, buf);
  939. X        strcat(output, buf);
  940. X
  941. X        for (i = 0; i < Stars[where.snum]->numplanets; i++)
  942. X            if (DontDispNum != i) {
  943. X                getplanet(&p, (int) where.snum, i);
  944. X                DispPlanet(Playernum, Governor, LEVEL_STAR, p,
  945. X                       Stars[where.snum]->pnames[i], DontDispPlanets, Race, buf);
  946. X                strcat(output, buf);
  947. X                free(p);
  948. X            }
  949. X        /*
  950. X         * check to see if you have ships at orbiting the star, if so
  951. X         * you can see enemy ships
  952. X         */
  953. X        iq = 0;
  954. X        if (Race->God)
  955. X            iq = 1;
  956. X        else {
  957. X            sh = Stars[where.snum]->ships;
  958. X            while (sh && !iq) {
  959. X                (void) getship(&s, sh);
  960. X                if (s->owner == Playernum && Sight(s))
  961. X                    iq = 1;    /* you are there to sight,
  962. X                         * need a crew */
  963. X                sh = s->nextship;
  964. X                free(s);
  965. X            }
  966. X        }
  967. X        if (!DontDispShips) {
  968. X            sh = Stars[where.snum]->ships;
  969. X            while (sh) {
  970. X                (void) getship(&s, sh);
  971. X                if (DontDispNum != sh &&
  972. X                    !(s->owner != Playernum && s->type == STYPE_MINE)) {
  973. X                    if ((s->owner == Playernum) || (iq == 1)) {
  974. X                        DispShip(Playernum, Governor, &where, s, NULL,
  975. X                              (int) Race->God, buf);
  976. X                        strcat(output, buf);
  977. X                    }
  978. X                }
  979. X                sh = s->nextship;
  980. X                free(s);
  981. X            }
  982. X        }
  983. X        break;
  984. X    case LEVEL_PLAN:
  985. X        getplanet(&p, (int) where.snum, (int) where.pnum);
  986. X        DispPlanet(Playernum, Governor, LEVEL_PLAN, p,
  987. X               Stars[where.snum]->pnames[where.pnum],
  988. X               DontDispPlanets, Race, buf);
  989. X        strcat(output, buf);
  990. X
  991. X        /*
  992. X         * check to see if you have ships at landed or orbiting the
  993. X         * planet, if so you can see orbiting enemy ships
  994. X         */
  995. X        iq = 0;
  996. X        sh = p->ships;
  997. X        while (sh && !iq) {
  998. X            (void) getship(&s, sh);
  999. X            if (s->owner == Playernum && Sight(s))
  1000. X                iq = 1;    /* you are there to sight, need a
  1001. X                     * crew */
  1002. X            sh = s->nextship;
  1003. X            free(s);
  1004. X        }
  1005. X        /* end check */
  1006. X        if (!DontDispShips) {
  1007. X            sh = p->ships;
  1008. X            while (sh) {
  1009. X                (void) getship(&s, sh);
  1010. X                if (DontDispNum != sh) {
  1011. X                    if (!landed(s)) {
  1012. X                        if ((s->owner == Playernum) || (iq == 1)) {
  1013. X                            DispShip(Playernum, Governor, &where, s, p,
  1014. X                                 (int) Race->God, buf);
  1015. X                            strcat(output, buf);
  1016. X                        }
  1017. X                    }
  1018. X                }
  1019. X                sh = s->nextship;
  1020. X                free(s);
  1021. X            }
  1022. X        }
  1023. X        free(p);
  1024. X        break;
  1025. X    default:
  1026. X        notify(Playernum, Governor, "Bad scope.\n");
  1027. X        return;
  1028. X    }
  1029. X    strcat(output, "\n");
  1030. X    notify(Playernum, Governor, output);
  1031. X}
  1032. X
  1033. Xvoid 
  1034. XDispStar(int Playernum, int Governor, int level, startype * star,
  1035. X     int DontDispStars, int God, char *string)
  1036. X{
  1037. X    int             x, y;
  1038. X    int             stand;
  1039. X    int             iq;
  1040. X    double          fac;
  1041. X
  1042. X    *string = '\0';
  1043. X
  1044. X    if (level == LEVEL_UNIV) {
  1045. X        fac = 1.0;
  1046. X        x = (int) (SCALE + ((SCALE * (star->xpos - Lastx)) / (UNIVSIZE * Zoom)));
  1047. X        y = (int) (SCALE + ((SCALE * (star->ypos - Lasty)) / (UNIVSIZE * Zoom)));
  1048. X    } else if (level == LEVEL_STAR) {
  1049. X        fac = 1000.0;
  1050. X        x = (int) (SCALE + (SCALE * (-Lastx)) / (SYSTEMSIZE * Zoom));
  1051. X        y = (int) (SCALE + (SCALE * (-Lasty)) / (SYSTEMSIZE * Zoom));
  1052. X    }
  1053. X    /*
  1054. X     * if (star->nova_stage) DispArray(x, y, 11,7,
  1055. X     * Novae[star->nova_stage-1], fac);
  1056. X     */
  1057. X    if (y >= 0 && x >= 0) {
  1058. X        iq = 0;
  1059. X        if (Race->governor[Governor].toggle.color) {
  1060. X            stand = (isset(star->explored, Playernum) ? Playernum : 0) + '?';
  1061. X            sprintf(temp, "%c %d %d 0 * ", (char) stand, x, y);
  1062. X            strcat(string, temp);
  1063. X            stand = (isset(star->inhabited, Playernum) ? Playernum : 0) + '?';
  1064. X            sprintf(temp, "%c %s;", (char) stand, star->name);
  1065. X            strcat(string, temp);
  1066. X        } else {
  1067. X            stand = (isset(star->explored, Playernum) ? 1 : 0);
  1068. X            sprintf(temp, "%d %d %d 0 * ", stand, x, y);
  1069. X            strcat(string, temp);
  1070. X            stand = (isset(star->inhabited, Playernum) ? 1 : 0);
  1071. X            sprintf(temp, "%d %s;", stand, star->name);
  1072. X            strcat(string, temp);
  1073. X        }
  1074. X    }
  1075. X}
  1076. X
  1077. Xvoid 
  1078. XDispPlanet(int Playernum, int Governor, int level, planettype * p,
  1079. X       char *name, int DontDispPlanets, racetype * r, char *string)
  1080. X{
  1081. X    int             x, y;
  1082. X    int             stand;
  1083. X
  1084. X    *string = '\0';
  1085. X
  1086. X    if (level == LEVEL_STAR) {
  1087. X        y = (int) (SCALE + (SCALE * (p->ypos - Lasty)) / (SYSTEMSIZE * Zoom));
  1088. X        x = (int) (SCALE + (SCALE * (p->xpos - Lastx)) / (SYSTEMSIZE * Zoom));
  1089. X    } else if (level == LEVEL_PLAN) {
  1090. X        y = (int) (SCALE + (SCALE * (-Lasty)) / (PLORBITSIZE * Zoom));
  1091. X        x = (int) (SCALE + (SCALE * (-Lastx)) / (PLORBITSIZE * Zoom));
  1092. X    }
  1093. X    if (x >= 0 && y >= 0) {
  1094. X        if (r->governor[Governor].toggle.color) {
  1095. X            stand = (p->info[Playernum - 1].explored ? Playernum : 0) + '?';
  1096. X            sprintf(temp, "%c %d %d 0 %c ", (char) stand, x, y,
  1097. X                (stand > '0' ? Psymbol[p->type] : '?'));
  1098. X            strcat(string, temp);
  1099. X            stand = (p->info[Playernum - 1].numsectsowned ? Playernum : 0) + '?';
  1100. X            sprintf(temp, "%c %s", (char) stand, name);
  1101. X            strcat(string, temp);
  1102. X        } else {
  1103. X            stand = p->info[Playernum - 1].explored ? 1 : 0;
  1104. X            sprintf(temp, "%d %d %d 0 %c ", stand, x, y,
  1105. X                (stand ? Psymbol[p->type] : '?'));
  1106. X            strcat(string, temp);
  1107. X            stand = p->info[Playernum - 1].numsectsowned ? 1 : 0;
  1108. X            sprintf(temp, "%d %s", stand, name);
  1109. X            strcat(string, temp);
  1110. X        }
  1111. X        if (r->governor[Governor].toggle.compat && p->info[Playernum - 1].explored) {
  1112. X            sprintf(temp, "(%d)", (int) compatibility(p, r));
  1113. X            strcat(string, temp);
  1114. X        }
  1115. X        strcat(string, ";");
  1116. X    }
  1117. X}
  1118. X
  1119. Xvoid 
  1120. XDispShip(int Playernum, int Governor, placetype * where, shiptype * ship,
  1121. X     planettype * pl, int God, char *string)
  1122. X{
  1123. X    int             x, y, wm;
  1124. X    int             stand;
  1125. X    shiptype       *aship;
  1126. X    planettype     *apl;
  1127. X    double          xt, yt, slope;
  1128. X
  1129. X    if (!ship->alive)
  1130. X        return;
  1131. X
  1132. X    *string = '\0';
  1133. X
  1134. X    switch (where->level) {
  1135. X    case LEVEL_PLAN:
  1136. X        x = (int) (SCALE + (SCALE * (ship->xpos - (Stars[where->snum]->xpos + pl->xpos)
  1137. X                      - Lastx)) / (PLORBITSIZE * Zoom));
  1138. X        y = (int) (SCALE + (SCALE * (ship->ypos - (Stars[where->snum]->ypos + pl->ypos)
  1139. X                      - Lasty)) / (PLORBITSIZE * Zoom));
  1140. X        break;
  1141. X    case LEVEL_STAR:
  1142. X        x = (int) (SCALE + (SCALE * (ship->xpos - Stars[where->snum]->xpos - Lastx))
  1143. X               / (SYSTEMSIZE * Zoom));
  1144. X        y = (int) (SCALE + (SCALE * (ship->ypos - Stars[where->snum]->ypos - Lasty))
  1145. X               / (SYSTEMSIZE * Zoom));
  1146. X        break;
  1147. X    case LEVEL_UNIV:
  1148. X        x = (int) (SCALE + (SCALE * (ship->xpos - Lastx)) / (UNIVSIZE * Zoom));
  1149. X        y = (int) (SCALE + (SCALE * (ship->ypos - Lasty)) / (UNIVSIZE * Zoom));
  1150. X        break;
  1151. X    default:
  1152. X        notify(Playernum, Governor, "WHOA! error in DispShip.\n");
  1153. X        return;
  1154. X    }
  1155. X
  1156. X    switch (ship->type) {
  1157. X    case STYPE_MIRROR:
  1158. X        if (ship->special.aimed_at.level == LEVEL_STAR) {
  1159. X            xt = Stars[ship->special.aimed_at.snum]->xpos;
  1160. X            yt = Stars[ship->special.aimed_at.snum]->ypos;
  1161. X        } else if (ship->special.aimed_at.level == LEVEL_PLAN) {
  1162. X            if (where->level == LEVEL_PLAN &&
  1163. X                ship->special.aimed_at.pnum == where->pnum) {
  1164. X                /* same planet */
  1165. X                xt = Stars[ship->special.aimed_at.snum]->xpos + pl->xpos;
  1166. X                yt = Stars[ship->special.aimed_at.snum]->ypos + pl->ypos;
  1167. X            } else {/* different planet */
  1168. X                getplanet(&apl, (int) where->snum, (int) where->pnum);
  1169. X                xt = Stars[ship->special.aimed_at.snum]->xpos + apl->xpos;
  1170. X                yt = Stars[ship->special.aimed_at.snum]->ypos + apl->ypos;
  1171. X                free(apl);
  1172. X            }
  1173. X        } else if (ship->special.aimed_at.level == LEVEL_SHIP) {
  1174. X            if (getship(&aship, (int) ship->special.aimed_at.shipno)) {
  1175. X                xt = aship->xpos;
  1176. X                yt = aship->ypos;
  1177. X                free(aship);
  1178. X            } else
  1179. X                xt = yt = 0.0;
  1180. X        } else
  1181. X            xt = yt = 0.0;
  1182. X        wm = 0;
  1183. X
  1184. X        if (xt == ship->xpos) {
  1185. X            if (yt > ship->ypos)
  1186. X                wm = 4;
  1187. X            else
  1188. X                wm = 0;
  1189. X        } else {
  1190. X            slope = (yt - ship->ypos) / (xt - ship->xpos);
  1191. X            if (yt == ship->ypos) {
  1192. X                if (xt > ship->xpos)
  1193. X                    wm = 2;
  1194. X                else
  1195. X                    wm = 6;
  1196. X            } else if (yt > ship->ypos) {
  1197. X                if (slope < -2.414)
  1198. X                    wm = 4;
  1199. X                if (slope > -2.414)
  1200. X                    wm = 5;
  1201. X                if (slope > -0.414)
  1202. X                    wm = 6;
  1203. X                if (slope > 0.000)
  1204. X                    wm = 2;
  1205. X                if (slope > 0.414)
  1206. X                    wm = 3;
  1207. X                if (slope > 2.414)
  1208. X                    wm = 4;
  1209. X            } else if (yt < ship->ypos) {
  1210. X                if (slope < -2.414)
  1211. X                    wm = 0;
  1212. X                if (slope > -2.414)
  1213. X                    wm = 1;
  1214. X                if (slope > -0.414)
  1215. X                    wm = 2;
  1216. X                if (slope > 0.000)
  1217. X                    wm = 6;
  1218. X                if (slope > 0.414)
  1219. X                    wm = 7;
  1220. X                if (slope > 2.414)
  1221. X                    wm = 0;
  1222. X            }
  1223. X        }
  1224. X
  1225. X        /* (magnification) */
  1226. X        if (x >= 0 && y >= 0) {
  1227. X            if (Race->governor[Governor].toggle.color) {
  1228. X                sprintf(string, "%c %d %d %d %c %c %d;",
  1229. X                    (char) (ship->owner + '?'), x, y, wm,
  1230. X                    Shipltrs[ship->type], (char) (ship->owner + '?'),
  1231. X                    ship->number);
  1232. X            } else {
  1233. X                stand = (ship->owner == Race->governor[Governor].toggle.highlight);
  1234. X                sprintf(string, "%d %d %d %d %c %d %d;",
  1235. X                stand, x, y, wm, Shipltrs[ship->type], stand,
  1236. X                    ship->number);
  1237. X            }
  1238. X        }
  1239. X        break;
  1240. X
  1241. X    case OTYPE_CANIST:
  1242. X    case OTYPE_GREEN:
  1243. X        break;
  1244. X
  1245. X    default:
  1246. X        /* other ships can only be seen when in system */
  1247. X        wm = 0;
  1248. X        if (ship->whatorbits != LEVEL_UNIV || ((ship->owner == Playernum) || God))
  1249. X            if (x >= 0 && y >= 0) {
  1250. X                if (Race->governor[Governor].toggle.color) {
  1251. X                    sprintf(string, "%c %d %d %d %c %c %d;",
  1252. X                    (char) (ship->owner + '?'), x, y, wm,
  1253. X                        Shipltrs[ship->type], (char) (ship->owner + '?'),
  1254. X                        ship->number);
  1255. X                } else {
  1256. X                    stand =
  1257. X                        (ship->owner == Race->governor[Governor].toggle.highlight);
  1258. X                    sprintf(string, "%d %d %d %d %c %d %d;",
  1259. X                        stand, x, y, wm, Shipltrs[ship->type], stand,
  1260. X                        ship->number);
  1261. X                }
  1262. X            }
  1263. X        break;
  1264. X    }
  1265. X}
  1266. END_OF_FILE
  1267. if test 12472 -ne `wc -c <'user/orbit.c'`; then
  1268.     echo shar: \"'user/orbit.c'\" unpacked with wrong size!
  1269. fi
  1270. # end of 'user/orbit.c'
  1271. fi
  1272. if test -f 'user/prof.c' -a "${1}" != "-c" ; then 
  1273.   echo shar: Will not clobber existing file \"'user/prof.c'\"
  1274. else
  1275. echo shar: Extracting \"'user/prof.c'\" \(12249 characters\)
  1276. sed "s/^X//" >'user/prof.c' <<'END_OF_FILE'
  1277. X#ident  "@(#)prof.c    1.2 12/15/92 "
  1278. X/*
  1279. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  1280. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  1281. X * GB_copyright.h. Tue Apr  9 16:14:58 MDT 1991 (Evan D. Koffler) Reformatted
  1282. X * the profile and treasury command.
  1283. X * 
  1284. X * prof.c -- print out racial profile
  1285. X */
  1286. X
  1287. X#include <strings.h>
  1288. X#include <stdio.h>
  1289. X#include "GB_copyright.h"
  1290. X#define EXTERN extern
  1291. X#include "vars.h"
  1292. X#include "races.h"
  1293. X#include "ships.h"
  1294. X#include "buffers.h"
  1295. X#include "power.h"
  1296. X#include "config.h"
  1297. X
  1298. Xextern char    *Desnames[];
  1299. X
  1300. Xvoid            whois(int, int, int);
  1301. Xvoid            profile(int, int, int);
  1302. Xchar           *Estimate_f(double, racetype *, int);
  1303. Xchar           *Estimate_i(int, racetype *, int);
  1304. Xint             round_perc(int, racetype *, int);
  1305. X#include "proto.h"
  1306. X
  1307. Xvoid 
  1308. Xwhois(int Playernum, int Governor, int APcount)
  1309. X{
  1310. X    int             i, j, numraces;
  1311. X    racetype       *Race;
  1312. X
  1313. X    if (argn <= 1) {
  1314. X        sprintf(args[1], "%d", Playernum);    /* The coward's way out */
  1315. X        argn = 2;
  1316. X    }
  1317. X    numraces = Num_races;
  1318. X
  1319. X    for (i = 1; i <= argn - 1; i++) {
  1320. X        j = atoi(args[i]);
  1321. X        if (!(j < 1 || j > numraces)) {
  1322. X            Race = races[j - 1];
  1323. X            if (j == Playernum)
  1324. X                sprintf(buf, "[%2d, %d] %s \"%s\"\n",
  1325. X                    j, Governor, Race->name,
  1326. X                    Race->governor[Governor].name);
  1327. X            else
  1328. X                sprintf(buf, "[%2d] %s\n", j, Race->name);
  1329. X        } else {
  1330. X            sprintf(buf,
  1331. X                "Identify: Invalid player number #%d. Try again.\n", j);
  1332. X        }
  1333. X        notify(Playernum, Governor, buf);
  1334. X    }
  1335. X}
  1336. X
  1337. Xvoid 
  1338. Xtreasury(int Playernum, int Governor)
  1339. X{
  1340. X    racetype       *Race;
  1341. X
  1342. X    Race = races[Playernum - 1];
  1343. X
  1344. X    sprintf(buf,
  1345. X        "Income last update was: %d\t\tCost last update was: %d\n",
  1346. X        Race->governor[Governor].income + Race->governor[Governor].profit_market,
  1347. X        Race->governor[Governor].maintain + Race->governor[Governor].cost_tech +
  1348. X        Race->governor[Governor].cost_market);
  1349. X    notify(Playernum, Governor, buf);
  1350. X    sprintf(buf, "    Market: %5d                               Market: %5d\n",
  1351. X        Race->governor[Governor].profit_market,
  1352. X        Race->governor[Governor].cost_market);
  1353. X    notify(Playernum, Governor, buf);
  1354. X    sprintf(buf, "    Taxes:  %5d                               Tech: %5d\n",
  1355. X    Race->governor[Governor].income, Race->governor[Governor].cost_tech);
  1356. X    notify(Playernum, Governor, buf);
  1357. X
  1358. X    sprintf(buf, "                                                Maint: %5d\n", Race->governor[Governor].maintain);
  1359. X    notify(Playernum, Governor, buf);
  1360. X    sprintf(buf, "You have: %d\n", Race->governor[Governor].money);
  1361. X    notify(Playernum, Governor, buf);
  1362. X#ifdef MULTIPLE_COMM_CHANNELS
  1363. X    channel(Playernum, Governor, 0, 1);
  1364. X#endif
  1365. X}
  1366. X
  1367. Xvoid 
  1368. Xprofile(int Playernum, int Governor, int APcount)
  1369. X{
  1370. X    int             p;
  1371. X    racetype       *r, *Race;
  1372. X
  1373. X    Race = races[Playernum - 1];
  1374. X
  1375. X    if (argn == 1) {
  1376. X        sprintf(buf, "--==** Racial profile for %s (player %d) **==--\n",
  1377. X            Race->name, Race->Playernum);
  1378. X        notify(Playernum, Governor, buf);
  1379. X        if (Race->God) {
  1380. X            sprintf(buf, "*** Diety Status ***\n");
  1381. X            notify(Playernum, Governor, buf);
  1382. X        }
  1383. X        sprintf(buf, "Personal: %s\n", Race->info);
  1384. X        notify(Playernum, Governor, buf);
  1385. X        sprintf(buf, "Default Scope: /%s/%s\n",
  1386. X            Stars[Race->governor[Governor].homesystem]->name,
  1387. X            Stars[Race->governor[Governor].homesystem]->pnames[Race->governor[Governor].homeplanetnum]);
  1388. X        notify(Playernum, Governor, buf);
  1389. X        if (Race->Gov_ship == 0)
  1390. X            sprintf(buf, "NO DESIGNATED CAPITAL!!");
  1391. X        else
  1392. X            sprintf(buf, "Designated Capital: #%-8d", Race->Gov_ship);
  1393. X        notify(Playernum, Governor, buf);
  1394. X        sprintf(buf, "\t\tRanges:   guns:   %5.0f\n",
  1395. X            gun_range(Race, (shiptype *) NULL, 1));
  1396. X        notify(Playernum, Governor, buf);
  1397. X        sprintf(buf, "Morale: %5d\t\t\t\t\t    space:  %5.0f\n",
  1398. X            Race->morale, tele_range(OTYPE_STELE, Race->tech));
  1399. X        notify(Playernum, Governor, buf);
  1400. X        sprintf(buf, "Updates active: %d\t\t\t\t      ground: %5.0f\n\n",
  1401. X            Race->turn, tele_range(OTYPE_GTELE, Race->tech));
  1402. X        notify(Playernum, Governor, buf);
  1403. X        sprintf(buf, "%s      Planet Conditions\t      Sector Preferences\n",
  1404. X            Race->Metamorph ? "Metamorphic Race\t" :
  1405. X            "Normal Race\t\t");
  1406. X        notify(Playernum, Governor, buf);
  1407. X        sprintf(buf, "Fert:    %3d%%           Temp:       %d\n",
  1408. X            Race->fertilize, Temp(Race->conditions[TEMP]));
  1409. X        notify(Playernum, Governor, buf);
  1410. X        sprintf(buf,
  1411. X            "Rate:    %3.1f            methane  %5d%%           %-8.8s %c %3.0f%%\n",
  1412. X            Race->birthrate,
  1413. X            Race->conditions[METHANE],
  1414. X            Desnames[SEA], CHAR_SEA,
  1415. X            Race->likes[SEA] * 100.);
  1416. X        notify(Playernum, Governor, buf);
  1417. X        sprintf(buf,
  1418. X            "Mass:   %4.2f            oxygen   %5d%%           %-8.8s %c %3.0f%%\n",
  1419. X            Race->mass,
  1420. X            Race->conditions[OXYGEN],
  1421. X            Desnames[GAS], CHAR_GAS,
  1422. X            Race->likes[GAS] * 100.);
  1423. X        notify(Playernum, Governor, buf);
  1424. X        sprintf(buf,
  1425. X            "Fight:     %d            helium   %5d%%           %-8.8s %c %3.0f%%\n",
  1426. X            Race->fighters,
  1427. X            Race->conditions[HELIUM],
  1428. X            Desnames[ICE], CHAR_ICE,
  1429. X            Race->likes[ICE] * 100.);
  1430. X        notify(Playernum, Governor, buf);
  1431. X        sprintf(buf,
  1432. X            "Metab:  %4.2f            nitrogen %5d%%           %-8.8s %c %3.0f%%\n",
  1433. X            Race->metabolism,
  1434. X            Race->conditions[NITROGEN],
  1435. X            Desnames[MOUNT], CHAR_MOUNT,
  1436. X            Race->likes[MOUNT] * 100.);
  1437. X        notify(Playernum, Governor, buf);
  1438. X        sprintf(buf,
  1439. X            "Sexes:     %1d            CO2      %5d%%           %-8.8s %c %3.0f%%\n",
  1440. X            Race->number_sexes,
  1441. X            Race->conditions[CO2],
  1442. X            Desnames[LAND], CHAR_LAND,
  1443. X            Race->likes[LAND] * 100.);
  1444. X        notify(Playernum, Governor, buf);
  1445. X        sprintf(buf,
  1446. X            "Explore:  %-3.0f%%          hydrogen %5d%%           %-8.8s %c %3.0f%%\n",
  1447. X            Race->adventurism * 100.0,
  1448. X            Race->conditions[HYDROGEN],
  1449. X            Desnames[DESERT], CHAR_DESERT,
  1450. X            Race->likes[DESERT] * 100.);
  1451. X        notify(Playernum, Governor, buf);
  1452. X        sprintf(buf,
  1453. X            "Avg Int: %3d            sulfer   %5d%%           %-8.8s %c %3.0f%%\n",
  1454. X            Race->IQ,
  1455. X            Race->conditions[SULFUR],
  1456. X            Desnames[FOREST], CHAR_FOREST,
  1457. X            Race->likes[FOREST] * 100.);
  1458. X        notify(Playernum, Governor, buf);
  1459. X        sprintf(buf,
  1460. X            "Tech:   %-6.2f          other    %5d%%           %-8.8s %c %3.0f%%\n",
  1461. X            Race->tech,
  1462. X            Race->conditions[OTHER],
  1463. X            Desnames[PLATED], CHAR_PLATED,
  1464. X            Race->likes[PLATED] * 100.);
  1465. X        notify(Playernum, Governor, buf);
  1466. X
  1467. X        notify(Playernum, Governor, "Discoveries:");
  1468. X        if (Crystal(Race))
  1469. X            notify(Playernum, Governor, "  Crystals");
  1470. X        if (Hyper_drive(Race))
  1471. X            notify(Playernum, Governor, "  Hyper-drive");
  1472. X        if (Laser(Race))
  1473. X            notify(Playernum, Governor, "  Combat Lasers");
  1474. X        if (Cew(Race))
  1475. X            notify(Playernum, Governor, "  Confined Energy Weapons");
  1476. X        if (Tractor_beam(Race))
  1477. X            notify(Playernum, Governor, "  Tractor Beam");
  1478. X        if (Transporter(Race))
  1479. X            notify(Playernum, Governor, "  Transporter");
  1480. X        if (Avpm(Race))
  1481. X            notify(Playernum, Governor, "  AVPM");
  1482. X        if (Cloak(Race))
  1483. X            notify(Playernum, Governor, "  Cloaking");
  1484. X        if (Wormhole(Race))
  1485. X            notify(Playernum, Governor, "  Wormhole");
  1486. X        notify(Playernum, Governor, "\n");
  1487. X    } else {
  1488. X        if (!(p = GetPlayer(args[1]))) {
  1489. X            sprintf(buf, "Player does not exist.\n");
  1490. X            notify(Playernum, Governor, buf);
  1491. X            return;
  1492. X        }
  1493. X        r = races[p - 1];
  1494. X        sprintf(buf, "------ Race report on %s (%d) ------\n", r->name, p);
  1495. X        notify(Playernum, Governor, buf);
  1496. X        if (Race->God) {
  1497. X            if (r->God) {
  1498. X                sprintf(buf, "*** Deity Status ***\n");
  1499. X                notify(Playernum, Governor, buf);
  1500. X            }
  1501. X        }
  1502. X        sprintf(buf, "Personal: %s\n", r->info);
  1503. X        notify(Playernum, Governor, buf);
  1504. X        sprintf(buf, "%%Know:  %3d%%\n", Race->translate[p - 1]);
  1505. X        notify(Playernum, Governor, buf);
  1506. X        if (Race->translate[p - 1] > 50) {
  1507. X            sprintf(buf, "%s\t  Planet Conditions\n",
  1508. X            r->Metamorph ? "Metamorphic Race" : "Normal Race\t");
  1509. X            notify(Playernum, Governor, buf);
  1510. X            sprintf(buf, "Fert:    %s",
  1511. X                Estimate_i((int) (r->fertilize), Race, p));
  1512. X            notify(Playernum, Governor, buf);
  1513. X            sprintf(buf, "\t\t  Temp:\t%s\n",
  1514. X              Estimate_i((int) (r->conditions[TEMP]), Race, p));
  1515. X            notify(Playernum, Governor, buf);
  1516. X            sprintf(buf, "Rate:    %s%%",
  1517. X                Estimate_f(r->birthrate * 100.0, Race, p));
  1518. X            notify(Playernum, Governor, buf);
  1519. X        } else {
  1520. X            sprintf(buf, "Unknown Race\t\t  Planet Conditions\n");
  1521. X            notify(Playernum, Governor, buf);
  1522. X            sprintf(buf, "Fert:    %s",
  1523. X                Estimate_i((int) (r->fertilize), Race, p));
  1524. X            notify(Playernum, Governor, buf);
  1525. X            sprintf(buf, "\t\t  Temp:\t%s\n",
  1526. X              Estimate_i((int) (r->conditions[TEMP]), Race, p));
  1527. X            notify(Playernum, Governor, buf);
  1528. X            sprintf(buf, "Rate:    %s",
  1529. X                Estimate_f(r->birthrate, Race, p));
  1530. X            notify(Playernum, Governor, buf);
  1531. X        }
  1532. X        sprintf(buf, "\t\t  methane  %4s%%\t\tRanges:\n",
  1533. X            Estimate_i((int) (r->conditions[METHANE]), Race, p));
  1534. X        notify(Playernum, Governor, buf);
  1535. X        sprintf(buf, "Mass:    %s", Estimate_f(r->mass, Race, p));
  1536. X        notify(Playernum, Governor, buf);
  1537. X        sprintf(buf, "\t\t  oxygen   %4s%%",
  1538. X            Estimate_i((int) (r->conditions[OXYGEN]), Race, p));
  1539. X        notify(Playernum, Governor, buf);
  1540. X        sprintf(buf, "\t\t  guns:   %6s\n",
  1541. X           Estimate_f(gun_range(r, (shiptype *) NULL, 1), Race, p));
  1542. X        notify(Playernum, Governor, buf);
  1543. X        sprintf(buf, "Fight:   %s",
  1544. X            Estimate_i((int) (r->fighters), Race, p));
  1545. X        notify(Playernum, Governor, buf);
  1546. X        sprintf(buf, "\t\t  helium   %4s%%",
  1547. X            Estimate_i((int) (r->conditions[HELIUM]), Race, p));
  1548. X        notify(Playernum, Governor, buf);
  1549. X        sprintf(buf, "\t\t  space:  %6s\n",
  1550. X             Estimate_f(tele_range(OTYPE_STELE, r->tech), Race, p));
  1551. X        notify(Playernum, Governor, buf);
  1552. X        sprintf(buf, "Metab:   %s", Estimate_f(r->metabolism, Race, p));
  1553. X        notify(Playernum, Governor, buf);
  1554. X        sprintf(buf, "\t\t  nitrogen %4s%%",
  1555. X              Estimate_i((int) (r->conditions[NITROGEN]), Race, p));
  1556. X        notify(Playernum, Governor, buf);
  1557. X        sprintf(buf, "\t\t  ground: %6s\n",
  1558. X             Estimate_f(tele_range(OTYPE_GTELE, r->tech), Race, p));
  1559. X        notify(Playernum, Governor, buf);
  1560. X        sprintf(buf, "Sexes:   %s",
  1561. X            Estimate_i((int) (r->number_sexes), Race, p));
  1562. X        notify(Playernum, Governor, buf);
  1563. X        sprintf(buf, "\t\t  CO2      %4s%%\n",
  1564. X            Estimate_i((int) (r->conditions[CO2]), Race, p));
  1565. X        notify(Playernum, Governor, buf);
  1566. X        sprintf(buf, "Explore: %s%%",
  1567. X            Estimate_f(r->adventurism * 100.0, Race, p));
  1568. X        notify(Playernum, Governor, buf);
  1569. X        sprintf(buf, "\t\t  hydrogen %4s%%\n",
  1570. X              Estimate_i((int) (r->conditions[HYDROGEN]), Race, p));
  1571. X        notify(Playernum, Governor, buf);
  1572. X        sprintf(buf, "Avg Int: %s",
  1573. X            Estimate_i((int) (r->IQ), Race, p));
  1574. X        notify(Playernum, Governor, buf);
  1575. X        sprintf(buf, "\t\t  sulfer   %4s%%\n",
  1576. X            Estimate_i((int) (r->conditions[SULFUR]), Race, p));
  1577. X        notify(Playernum, Governor, buf);
  1578. X        sprintf(buf, "Tech:    %s", Estimate_f(r->tech, Race, p));
  1579. X        notify(Playernum, Governor, buf);
  1580. X        sprintf(buf, "\t\t  other    %4s%%",
  1581. X            Estimate_i((int) (r->conditions[OTHER]), Race, p));
  1582. X        notify(Playernum, Governor, buf);
  1583. X        sprintf(buf, "\t\tMorale:   %6s\n",
  1584. X            Estimate_i((int) (r->morale), Race, p));
  1585. X        notify(Playernum, Governor, buf);
  1586. X        sprintf(buf, "Sector type preference : %s\n",
  1587. X            Race->translate[p - 1] > 80 ? Desnames[r->likesbest] : " ? ");
  1588. X        notify(Playernum, Governor, buf);
  1589. X    }
  1590. X}
  1591. X
  1592. Xstatic char     est_buf[20];
  1593. X
  1594. Xchar           *
  1595. XEstimate_f(double data, racetype * r, int p)
  1596. X{
  1597. X    int             est;
  1598. X
  1599. X    sprintf(est_buf, "?");
  1600. X
  1601. X    if (r->translate[p - 1] > 10) {
  1602. X        est = round_perc((int) data, r, p);
  1603. X        if (est < 1000)
  1604. X            sprintf(est_buf, "%d", est);
  1605. X        else if (est < 10000)
  1606. X            sprintf(est_buf, "%.1fK", (double) est / 1000.);
  1607. X        else if (est < 1000000)
  1608. X            sprintf(est_buf, "%.0fK", (double) est / 1000.);
  1609. X        else
  1610. X            sprintf(est_buf, "%.1fM", (double) est / 1000000.);
  1611. X    }
  1612. X    return est_buf;
  1613. X}
  1614. X
  1615. Xchar           *
  1616. XEstimate_i(int data, racetype * r, int p)
  1617. X{
  1618. X    int             est;
  1619. X
  1620. X    sprintf(est_buf, "?");
  1621. X
  1622. X    if (r->translate[p - 1] > 10) {
  1623. X        est = round_perc((int) data, r, p);
  1624. X        if ((int) abs(est) < 1000)
  1625. X            sprintf(est_buf, "%d", est);
  1626. X        else if ((int) abs(est) < 10000)
  1627. X            sprintf(est_buf, "%.1fK", (double) est / 1000.);
  1628. X        else if ((int) abs(est) < 1000000)
  1629. X            sprintf(est_buf, "%.0fK", (double) est / 1000.);
  1630. X        else
  1631. X            sprintf(est_buf, "%.1fM", (double) est / 1000000.);
  1632. X    }
  1633. X    return est_buf;
  1634. X}
  1635. X
  1636. Xint 
  1637. Xround_perc(int data, racetype * r, int p)
  1638. X{
  1639. X    int             k;
  1640. X
  1641. X#if 0                /* r->captured_prisoners[p-1] is never
  1642. X                 * actually used eslewhere. */
  1643. X    k = 101 - MIN(r->translate[p - 1] + r->captured_prisoners[p - 1], 100);
  1644. X#else
  1645. X    k = 101 - MIN(r->translate[p - 1], 100);
  1646. X#endif
  1647. X    return ((data / k) * k);
  1648. X}
  1649. END_OF_FILE
  1650. if test 12249 -ne `wc -c <'user/prof.c'`; then
  1651.     echo shar: \"'user/prof.c'\" unpacked with wrong size!
  1652. fi
  1653. # end of 'user/prof.c'
  1654. fi
  1655. if test -f 'utils/Makelist.c' -a "${1}" != "-c" ; then 
  1656.   echo shar: Will not clobber existing file \"'utils/Makelist.c'\"
  1657. else
  1658. echo shar: Extracting \"'utils/Makelist.c'\" \(2464 characters\)
  1659. sed "s/^X//" >'utils/Makelist.c' <<'END_OF_FILE'
  1660. X/* Galactic Bloodshed Planet List Consolidator
  1661. X *
  1662. X * makelist oldlist addlist > newlist
  1663. X *     Errors are to stderr.
  1664. X *    Normal output to stdout.
  1665. X *    This program takes a list of planets and alphabetizes them.
  1666. X *    and then takes the addlist and tries to add unique planet
  1667. X *    names up to NUM_CHARS, if it can. Otherwise it informs
  1668. X *    which name is being omitted and what name caused the clash.
  1669. X *
  1670. X *    Tue Apr 16 00:02:36 MDT 1991
  1671. X *    Evan Koffler (ekoffler@du.edu)
  1672. X */
  1673. X
  1674. X# include <stdio.h>
  1675. X
  1676. X# define NUM_CHARS    4
  1677. X
  1678. Xextern char *malloc ();
  1679. Xextern char *index ();
  1680. X
  1681. Xtypedef struct list {
  1682. X    char name[257];
  1683. X    struct list *next;
  1684. X    struct list *prev;
  1685. X} LIST;
  1686. X
  1687. XLIST *list_head;
  1688. X
  1689. Xmain (argc, argv)
  1690. Xint argc;
  1691. Xchar **argv;
  1692. X{
  1693. XFILE *input;
  1694. XFILE *add;
  1695. Xchar *c;
  1696. Xchar buf[BUFSIZ];
  1697. Xint names;
  1698. X
  1699. X    if (argc !=3) {
  1700. X        printf ("Usage: %s oldlist newlist > outputlist\n",
  1701. X            argv[0]);
  1702. X        exit (1);
  1703. X    }
  1704. X    
  1705. X    if ((input = fopen(argv[1], "r")) == NULL) {
  1706. X        printf ("Can not open %s for reading.\n", argv[1]);
  1707. X        exit (1);
  1708. X    }
  1709. X    if ((add = fopen(argv[2], "r")) == NULL) {
  1710. X        printf ("Can not open %s for reading.\n", argv[2]);
  1711. X        exit (1);
  1712. X    }
  1713. X
  1714. X    if (fgets (buf, BUFSIZ, input)) {
  1715. X        list_head = (LIST *) malloc (sizeof (LIST));
  1716. X        list_head->prev = NULL;
  1717. X        list_head->next = NULL;
  1718. X        if ((c = index (buf, '\n')) != NULL)
  1719. X            *c = '\0';    
  1720. X        strcpy (list_head->name, buf);
  1721. X    }
  1722. X    while (fgets (buf, BUFSIZ, input))
  1723. X        add_to_list (buf);    
  1724. X    while (fgets (buf, BUFSIZ, add))
  1725. X        add_to_list (buf);    
  1726. X    names = print_list ();
  1727. X    fprintf (stderr, "Done with makelist. %d names total\n", names);
  1728. X}
  1729. X
  1730. Xadd_to_list (s)
  1731. Xchar *s;
  1732. X{
  1733. XLIST *q;
  1734. XLIST *p;
  1735. Xint val;
  1736. Xchar *c;
  1737. X
  1738. X    if (c = index (s, '\n'))
  1739. X        *c = '\0';    
  1740. X    if (*s == '\0') return;
  1741. X    for (p = list_head; p; p = p->next) {
  1742. X        val = strncmp (p->name, s, NUM_CHARS);
  1743. X        if (val > 0) {
  1744. X            q = (LIST *) malloc (sizeof (LIST));
  1745. X            strcpy (q->name, s);
  1746. X            if (p == list_head) {
  1747. X                list_head = q;
  1748. X                q->prev = NULL;
  1749. X                p->prev = q;
  1750. X                q->next = p;
  1751. X            } else {
  1752. X                q->prev = p->prev;
  1753. X                p->prev->next = q;    
  1754. X                q->next = p;
  1755. X                p->prev = q;
  1756. X            }
  1757. X            return;
  1758. X        } else if (val == 0) {
  1759. X            fprintf (stderr,
  1760. X                "Duplicate name. In list %s. Omitting %s\n", 
  1761. X                p->name, s);
  1762. X            return;
  1763. X        }
  1764. X    }
  1765. X    if (!p) {
  1766. X        for (p = list_head; p->next; p = p->next)
  1767. X            ;
  1768. X        p->next = (LIST *) malloc (sizeof (LIST));
  1769. X        strcpy (p->name, s);
  1770. X        p->next->prev = p;
  1771. X        p->next->next = NULL;
  1772. X    }
  1773. X}
  1774. X
  1775. Xint print_list ()
  1776. X{
  1777. XLIST *p;
  1778. Xint i = 0;
  1779. X
  1780. X    for (p = list_head; p; p = p->next) {
  1781. X        printf ("%s\n", p->name);
  1782. X        i++;
  1783. X    }
  1784. X    return (i);
  1785. X}
  1786. END_OF_FILE
  1787. if test 2464 -ne `wc -c <'utils/Makelist.c'`; then
  1788.     echo shar: \"'utils/Makelist.c'\" unpacked with wrong size!
  1789. fi
  1790. # end of 'utils/Makelist.c'
  1791. fi
  1792. echo shar: End of archive 14 \(of 21\).
  1793. cp /dev/null ark14isdone
  1794. MISSING=""
  1795. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
  1796.     if test ! -f ark${I}isdone ; then
  1797.     MISSING="${MISSING} ${I}"
  1798.     fi
  1799. done
  1800. if test "${MISSING}" = "" ; then
  1801.     echo You have unpacked all 21 archives.
  1802.     echo "Now type './buildfiles.sh'"
  1803.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1804. else
  1805.     echo You still need to unpack the following archives:
  1806.     echo "        " ${MISSING}
  1807. fi
  1808. ##  End of shell archive.
  1809. exit 0
  1810.