home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume17 / gbp / part12 < prev    next >
Encoding:
Internet Message Format  |  1993-03-20  |  54.3 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: v17i024:  gbp - Galactic Bloodshed+, an empire-like war game, Part12/21
  5. Message-ID: <4552@master.CNA.TEK.COM>
  6. Date: 12 Feb 93 17:31:44 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1649
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1703
  11.  
  12. Submitted-by: deragon@harpo.cs.nyu.edu (Seeker)
  13. Posting-number: Volume 17, Issue 24
  14. Archive-name: gbp/Part12
  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 12 (of 21)."
  27. # Contents:  misc/daemon.txt user/dock.c user/rst.c user/survey.c
  28. # Wrapped by billr@saab on Fri Feb 12 09:14:27 1993
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'misc/daemon.txt' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'misc/daemon.txt'\"
  32. else
  33. echo shar: Extracting \"'misc/daemon.txt'\" \(3421 characters\)
  34. sed "s/^X//" >'misc/daemon.txt' <<'END_OF_FILE'
  35. X    The Galactic Bloodshed game sequence is controlled by
  36. Xtwo defines in tweakables.h.
  37. X
  38. X    The first is DEFAULT_UPDATE_TIME.  This specifies an interval of
  39. Xminutes between updates.
  40. X
  41. X    The second is MOVES_PER_UPDATE.  This specifies how many movement
  42. Xsegments should be included in each update phase.  An update counts as
  43. Xone movement segment; so, if you set this to 1, there will be zero movement
  44. Xsegments between updates.  Setting it to 3 would give you two evenly spaced
  45. Xmovement segments between the updates.  Any movement segments between updates
  46. Xwill be evenly spaced in terms of time.
  47. X
  48. X    To provide a little randomness into the expected update/movement
  49. Xtime, there are two more defines:  DEFAULT_RANDOM_UPDATE_RANGE
  50. Xand DEFAULT_RANDOM_SEGMENT_RANGE.  A random number of minutes between zero
  51. Xand these values will be added to the "programmed" update/movement time.
  52. X(I'm not exactly sure why this is needed, but the old GB_daemon program
  53. X used to do this, so I left it in).
  54. X
  55. X    The server now keeps track of when the last update/movement time
  56. Xwas using two new files:  DFILE(Update.time) and DFILE(Segment.time).
  57. XThe last modification time of these files indicates the last time of that
  58. Xparticular operation.  In addition, the ascii value in Segment.time specifies
  59. Xwhich movement segment was the last one performed.  If this value is
  60. Xless than MOVES_PER_UPDATE, there are more movement segments to do.
  61. XWhen the server starts up, it looks at these files to determine the next
  62. Xupdate/movement times.  If it determines that the time indicated was in
  63. Xthe past (it was down when it would normally have done an update/movment),
  64. Xit will basically "skip" that time and figure the next time from when it
  65. Xwas started (i.e., the next update time will be DEFAULT_UPDATE_TIME minutes
  66. Xinto the future).
  67. X
  68. X    One other file added was PATH(nogo).  If this file exists, the
  69. Xserver will not do any "automatic" updates/movements.  When the file
  70. Xis removed or does not exist, updates/movements will continue normally.
  71. XI have found it useful to make crontab entries to create/delete this
  72. Xfile on weekend, effectively stopping updates/movements during that time.
  73. X
  74. X    You may still connect to the server and give either the update
  75. Xor movement password to cause one of these things to happen.  This overrides
  76. Xthe existence check for the nogo file (just like the old GB_daemon).
  77. X
  78. X
  79. XCAVEATS
  80. X    - This server modification does away with the need for the GB_daemon
  81. X      program.  The function provided by the daemon program has been
  82. X      internalized by the server.
  83. X    - DEFAULT_UPDATE_TIME used to specify hours, not minutes.
  84. X
  85. XHISTORICAL Daemon INFORMATION:
  86. X    The Galactic Bloodshed game sequence is controlled by a
  87. X`daemon' program which updates the positions of ships, planets 
  88. Xand stars at a set time interval (usually 1 to 3 hours, set by the
  89. Xgame master). The growth/depletion of the planetary resources, population,
  90. Xfuel and destructive capacity is monitored and updated by this program.
  91. XBetween updates, players may issue commands, construct ships, initiate
  92. Xattacks and do whatever they see fit with the available commands.
  93. X
  94. X    It isn't necessary to be present at all times, since interstellar
  95. Xtravel takes some time, and it takes several iterations of the daemon to
  96. Xgenerate significant changes in planetary status. It is wise, however,
  97. Xto check up on things from time to time to keep yourself from getting
  98. Xoverrun by some hostile race.
  99. X
  100. XSEE ALSO
  101. X    vote, updates
  102. END_OF_FILE
  103. if test 3421 -ne `wc -c <'misc/daemon.txt'`; then
  104.     echo shar: \"'misc/daemon.txt'\" unpacked with wrong size!
  105. fi
  106. # end of 'misc/daemon.txt'
  107. fi
  108. if test -f 'user/dock.c' -a "${1}" != "-c" ; then 
  109.   echo shar: Will not clobber existing file \"'user/dock.c'\"
  110. else
  111. echo shar: Extracting \"'user/dock.c'\" \(14652 characters\)
  112. sed "s/^X//" >'user/dock.c' <<'END_OF_FILE'
  113. X#ident  "@(#)dock.c    1.6 2/1/93 "
  114. X/*
  115. X * * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, *
  116. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. * Restrictions in
  117. X * GB_copyright.h. *
  118. X * 
  119. X *  dock.c -- dock a ship *  and..... assault -- a very un-PC version of dock
  120. X */
  121. X
  122. X#include "GB_copyright.h"
  123. X#define EXTERN extern
  124. X#include "vars.h"
  125. X#include "ships.h"
  126. X#include "races.h"
  127. X#include "power.h"
  128. X#include "buffers.h"
  129. X#include <signal.h>
  130. X#include <math.h>
  131. X#include <strings.h>
  132. X
  133. Xvoid            dock(int, int, int, int);
  134. X#include "proto.h"
  135. X
  136. Xvoid 
  137. Xdock(int Playernum, int Governor, int APcount, int Assault)
  138. X{
  139. X    shiptype       *s, *s2, *s3, ship;
  140. X    int             boarders = 0, dam = 0, dam2 = 0, booby = 0;
  141. X    int             ship2no, shipno, what, nextshipno;
  142. X    int             old2owner, old2gov;
  143. X    int             casualties = 0, casualties2 = 0, casualties3 = 0,
  144. X                    casualty_scale = 0;
  145. X    double          fuel, bstrength, b2strength;
  146. X    double          Dist;
  147. X    racetype       *Race, *alien;
  148. X    char            dfire[MAXARGS][COMMANDSIZE];
  149. X
  150. X    if (argn < 3) {
  151. X        notify(Playernum, Governor, "Dock with what?\n");
  152. X        return;
  153. X    } if (argn < 5)
  154. X        what = MIL;
  155. X    else if (Assault) {
  156. X        if (match(args[4], "civilians"))
  157. X            what = CIV;
  158. X        else if (match(args[4], "military"))
  159. X            what = MIL;
  160. X        else {
  161. X            notify(Playernum, Governor, "Assault with what?\n");
  162. X            return;
  163. X        }
  164. X    }
  165. X    nextshipno = start_shiplist(Playernum, Governor, args[1]);
  166. X    while (shipno = do_shiplist(&s, &nextshipno))
  167. X        if (in_list(Playernum, args[1], s, &nextshipno) &&
  168. X            (!Governor || s->governor == Governor)) {
  169. X            if (Assault && s->type == STYPE_POD) {
  170. X                notify(Playernum, Governor, "Sorry. Pods cannot be used to assault.\n");
  171. X                free(s);
  172. X                continue;
  173. X            }
  174. X            if (!Assault) {
  175. X                if (s->docked || s->whatorbits == LEVEL_SHIP) {
  176. X                    sprintf(buf, "%s is already docked.\n", Ship(s));
  177. X                    notify(Playernum, Governor, buf);
  178. X                    free(s);
  179. X                    continue;
  180. X                }
  181. X            } else if (s->docked) {
  182. X                notify(Playernum, Governor, "Your ship is already docked.\n");
  183. X                free(s);
  184. X                continue;
  185. X            } else if (s->whatorbits == LEVEL_SHIP) {
  186. X                notify(Playernum, Governor, "Your ship is landed on another ship.\n");
  187. X                free(s);
  188. X                continue;
  189. X            }
  190. X            if (s->whatorbits == LEVEL_UNIV) {
  191. X                if (!enufAP(Playernum, Governor, Sdata.AP[Playernum - 1], APcount)) {
  192. X                    free(s);
  193. X                    continue;
  194. X                }
  195. X            } else if (!enufAP(Playernum, Governor, Stars[s->storbits]->AP[Playernum - 1],
  196. X                       APcount)) {
  197. X                free(s);
  198. X                continue;
  199. X            }
  200. X            if (Assault && (what == CIV) && !s->popn) {
  201. X                notify(Playernum, Governor, "You have no crew on this ship to assault with.\n");
  202. X                free(s);
  203. X                continue;
  204. X            } else if (Assault && (what == MIL) && !s->troops) {
  205. X                notify(Playernum, Governor, "You have no troops on this ship to assault with.\n");
  206. X                free(s);
  207. X                continue;
  208. X            }
  209. X            sscanf(args[2] + (args[2][0] == '#'), "%d", &ship2no);
  210. X
  211. X            if (shipno == ship2no) {
  212. X                notify(Playernum, Governor, "You can't dock with yourself!\n");
  213. X                free(s);
  214. X                continue;
  215. X            }
  216. X            if (!getship(&s2, ship2no)) {
  217. X                notify(Playernum, Governor, "The ship wasn't found.\n");
  218. X                free(s);
  219. X                return;
  220. X            }
  221. X            if (!Assault && testship(Playernum, Governor, s2)) {
  222. X                notify(Playernum, Governor,
  223. X                    "You are not authorized to do this.\n");
  224. X                free(s2);
  225. X                free(s);
  226. X                return;
  227. X            }
  228. X            /* Check if ships are on same scope level. Maarten */
  229. X            if (s->whatorbits != s2->whatorbits) {
  230. X                notify(Playernum, Governor, "Those ships are not in the same scope.\n");
  231. X                free(s);
  232. X                free(s2);
  233. X                return;
  234. X            }
  235. X            if (s2->docked || (s2->whatorbits == LEVEL_SHIP)) {
  236. X                sprintf(buf, "%s is already docked.\n", Ship(s2));
  237. X                notify(Playernum, Governor, buf);
  238. X                free(s);
  239. X                free(s2);
  240. X                return;
  241. X            }
  242. X            Dist = sqrt((double) Distsq(s2->xpos, s2->ypos, s->xpos, s->ypos));
  243. X            fuel = 0.05 + Dist * 0.025 * (Assault ? 2.0 : 1.0) * sqrt((double) s->mass);
  244. X
  245. X            if (Dist > DIST_TO_DOCK) {
  246. X                sprintf(buf, "%s must be %.2f or closer to %s.\n",
  247. X                    Ship(s), DIST_TO_DOCK, Ship(s2));
  248. X                notify(Playernum, Governor, buf);
  249. X                free(s);
  250. X                free(s2);
  251. X                continue;
  252. X            } else if (s->docked && Assault) {
  253. X                /* first undock the target ship */
  254. X                s->docked = 0;
  255. X                s->whatdest = LEVEL_UNIV;
  256. X                (void) getship(&s3, (int) s->destshipno);
  257. X                s3->docked = 0;
  258. X                s3->whatdest = LEVEL_UNIV;
  259. X                putship(s3);
  260. X                free(s3);
  261. X            }
  262. X            if (fuel > s->fuel) {
  263. X                sprintf(buf, "Not enough fuel.\n");
  264. X                notify(Playernum, Governor, buf);
  265. X                free(s);
  266. X                free(s2);
  267. X                continue;
  268. X            }
  269. X            sprintf(buf, "Distance to %s: %.2f.\n", Ship(s2), Dist);
  270. X            notify(Playernum, Governor, buf);
  271. X            sprintf(buf, "This maneuver will take %.2f fuel (of %.2f.)\n\n", fuel, s->fuel);
  272. X            notify(Playernum, Governor, buf);
  273. X
  274. X            if (s2->docked && !Assault) {
  275. X                sprintf(buf, "%s is already docked.\n", Ship(s2));
  276. X                notify(Playernum, Governor, buf);
  277. X                free(s);
  278. X                free(s2);
  279. X                return;
  280. X            }
  281. X            /* defending fire gets defensive fire */
  282. X            bcopy(s2, &ship, sizeof(shiptype));    /* for reports */
  283. X            if (Assault) {
  284. X                strcpy(dfire[0], args[0]);
  285. X                strcpy(dfire[1], args[1]);
  286. X                strcpy(dfire[2], args[2]);
  287. X                sprintf(args[0], "fire");
  288. X                sprintf(args[1], "#%d", ship2no);
  289. X                sprintf(args[2], "#%d", shipno);
  290. X                fire((int) s2->owner, (int) s2->governor, 0, 3);
  291. X                strcpy(args[0], dfire[0]);
  292. X                strcpy(args[1], dfire[1]);
  293. X                strcpy(args[2], dfire[2]);
  294. X                /*
  295. X                 * retrieve ships again, since battle may
  296. X                 * change ship stats
  297. X                 */
  298. X                free(s);
  299. X                free(s2);
  300. X                (void) getship(&s, shipno);
  301. X                (void) getship(&s2, ship2no);
  302. X                if (!s->alive) {
  303. X                    free(s);
  304. X                    free(s2);
  305. X                    continue;
  306. X                } else if (!s2->alive) {
  307. X                    free(s);
  308. X                    free(s2);
  309. X                    return;
  310. X                }
  311. X            }
  312. X            if (Assault) {
  313. X                alien = races[s2->owner - 1];
  314. X                Race = races[Playernum - 1];
  315. X                if (argn >= 4) {
  316. X                    sscanf(args[3], "%d", &boarders);
  317. X                    if ((what == MIL) && (boarders > s->troops))
  318. X                        boarders = s->troops;
  319. X                    else if ((what == CIV) && (boarders > s->popn))
  320. X                        boarders = s->popn;
  321. X                } else {
  322. X                    if (what == CIV)
  323. X                        boarders = s->popn;
  324. X                    else if (what == MIL)
  325. X                        boarders = s->troops;
  326. X                }
  327. X                if (boarders > s2->max_crew)
  328. X                    boarders = s2->max_crew;
  329. X
  330. X                /* Allow assault of crewless ships. */
  331. X                if (s2->max_crew && boarders <= 0) {
  332. X                    sprintf(buf, "Illegal number of boarders (%d).\n", boarders);
  333. X                    notify(Playernum, Governor, buf);
  334. X                    free(s);
  335. X                    free(s2);
  336. X                    continue;
  337. X                }
  338. X                old2owner = s2->owner;
  339. X                old2gov = s2->governor;
  340. X                if (what == MIL)
  341. X                    s->troops -= boarders;
  342. X                else if (what == CIV)
  343. X                    s->popn -= boarders;
  344. X                s->mass -= boarders * Race->mass;
  345. X                sprintf(buf, "Boarding strength :%.2f       Defense strength: %.2f.\n",
  346. X                    bstrength = boarders * (what == MIL ? 10 * Race->fighters : 1)
  347. X                    * .01 * Race->tech
  348. X                    * morale_factor((double) (Race->morale - alien->morale)),
  349. X
  350. X                    b2strength = (s2->popn + 10 * s2->troops * alien->fighters)
  351. X                    * .01 * alien->tech
  352. X                    * morale_factor((double) (alien->morale - Race->morale))
  353. X                    );
  354. X                notify(Playernum, Governor, buf);
  355. X            }
  356. X            /*
  357. X             * the ship moves into position, regardless of
  358. X             * success of attack
  359. X             */
  360. X            use_fuel(s, fuel);
  361. X            s->xpos = s2->xpos + int_rand(-1, 1);
  362. X            s->ypos = s2->ypos + int_rand(-1, 1);
  363. X            if (s->hyper_drive.on) {
  364. X                s->hyper_drive.on = 0;
  365. X                notify(Playernum, Governor, "Hyper-drive deactivated.\n");
  366. X            }
  367. X            if (Assault) {
  368. X                /*
  369. X                 * if the assaulted ship is docked, undock it
  370. X                 * first
  371. X                 */
  372. X                if (s2->docked && s2->whatdest == LEVEL_SHIP) {
  373. X                    (void) getship(&s3, (int) s2->destshipno);
  374. X                    s3->docked = 0;
  375. X                    s3->whatdest = LEVEL_UNIV;
  376. X                    s3->destshipno = 0;
  377. X                    putship(s3);
  378. X                    free(s3);
  379. X
  380. X                    s2->docked = 0;
  381. X                    s2->whatdest = LEVEL_UNIV;
  382. X                    s2->destshipno = 0;
  383. X                }
  384. X                /* nuke both populations, ships */
  385. X                casualty_scale = MIN(boarders, s2->troops + s2->popn);
  386. X
  387. X                if (b2strength) {    /* otherwise the ship
  388. X                             * surrenders */
  389. X                    casualties = int_rand(0, round_rand((double) casualty_scale * (b2strength + 1.0) /
  390. X                            (bstrength + 1.0)));
  391. X                    casualties = MIN(boarders, casualties);
  392. X                    boarders -= casualties;
  393. X
  394. X                    dam = int_rand(0, round_rand(25. * (b2strength + 1.0) / (bstrength + 1.0)));
  395. X                    dam = MIN(100, dam);
  396. X                    s->damage = MIN(100, s->damage + dam);
  397. X                    if (s->damage >= 100)
  398. X                        kill_ship(Playernum, s);
  399. X
  400. X                    casualties2 = int_rand(0, round_rand((double) casualty_scale * (bstrength + 1.0) /
  401. X                               (b2strength + 1.0)));
  402. X                    casualties2 = MIN(s2->popn, casualties2);
  403. X                    casualties3 = int_rand(0, round_rand((double) casualty_scale * (bstrength + 1.0) /
  404. X                               (b2strength + 1.0)));
  405. X                    casualties3 = MIN(s2->troops, casualties3);
  406. X                    s2->popn -= casualties2;
  407. X                    s2->mass -= casualties2 * alien->mass;
  408. X                    s2->troops -= casualties3;
  409. X                    s2->mass -= casualties3 * alien->mass;
  410. X                    /* (their mass) */
  411. X                    dam2 = int_rand(0, round_rand(25. * (bstrength + 1.0) / (b2strength + 1.0)));
  412. X                    dam2 = MIN(100, dam2);
  413. X                    s2->damage = MIN(100, s2->damage + dam2);
  414. X                    if (s2->damage >= 100)
  415. X                        kill_ship(Playernum, s2);
  416. X                } else {
  417. X                    s2->popn = 0;
  418. X                    s2->troops = 0;
  419. X                    booby = 0;
  420. X                    /* do booby traps */
  421. X                    /* check for boobytrapping */
  422. X                    if (!s2->max_crew && s2->destruct)
  423. X                        booby = int_rand(0, 10 * (int) s2->destruct);
  424. X                    booby = MIN(100, booby);
  425. X                }
  426. X
  427. X                if ((!s2->popn && !s2->troops) && s->alive && s2->alive) {
  428. X                    /* we got 'em */
  429. X                    s->docked = 1;
  430. X                    s->whatdest = LEVEL_SHIP;
  431. X                    s->destshipno = ship2no;
  432. X
  433. X                    s2->docked = 1;
  434. X                    s2->whatdest = LEVEL_SHIP;
  435. X                    s2->destshipno = shipno;
  436. X                    old2owner = s2->owner;
  437. X                    old2gov = s2->governor;
  438. X                    s2->owner = s->owner;
  439. X                    s2->governor = s->governor;
  440. X                    if (what == MIL)
  441. X                        s2->troops = boarders;
  442. X                    else
  443. X                        s2->popn = boarders;
  444. X                    s2->mass += boarders * Race->mass;    /* our mass */
  445. X                    if (casualties2 + casualties3) {
  446. X                        /*
  447. X                         * You must kill to get
  448. X                         * morale
  449. X                         */
  450. X                        adjust_morale(Race, alien, (int) s2->build_cost);
  451. X                    }
  452. X                } else {    /* retreat */
  453. X                    if (what == MIL)
  454. X                        s->troops += boarders;
  455. X                    else if (what == CIV)
  456. X                        s->popn += boarders;
  457. X                    s->mass += boarders * Race->mass;
  458. X                    adjust_morale(alien, Race, (int) Race->fighters);
  459. X                }
  460. X
  461. X                /* races find out about each other */
  462. X                alien->translate[Playernum - 1] = MIN(alien->translate[Playernum - 1] + 5, 100);
  463. X                Race->translate[old2owner - 1] = MIN(Race->translate[old2owner - 1] + 5, 100);
  464. X
  465. X                if (!boarders && (s2->popn + s2->troops))    /* boarding party killed */
  466. X                    alien->translate[Playernum - 1] = MIN(alien->translate[Playernum - 1] + 25, 100);
  467. X                if (s2->owner == Playernum)    /* captured ship */
  468. X                    Race->translate[old2owner - 1] = MIN(Race->translate[old2owner - 1] + 25, 100);
  469. X                putrace(Race);
  470. X                putrace(alien);
  471. X            } else {
  472. X                s->docked = 1;
  473. X                s->whatdest = LEVEL_SHIP;
  474. X                s->destshipno = ship2no;
  475. X
  476. X                s2->docked = 1;
  477. X                s2->whatdest = LEVEL_SHIP;
  478. X                s2->destshipno = shipno;
  479. X            }
  480. X
  481. X            if (Assault) {
  482. X                sprintf(telegram_buf, "%s ASSAULTED by %s at %s\n",
  483. X                Ship(&ship), Ship(s), prin_ship_orbits(s2));
  484. X                sprintf(buf, "Your damage: %d%%, theirs: %d%%.\n", dam2, dam);
  485. X                strcat(telegram_buf, buf);
  486. X                if (!s2->max_crew && s2->destruct) {
  487. X                    sprintf(buf, "(Your boobytrap gave them %d%% damage.)\n",
  488. X                        booby);
  489. X                    strcat(telegram_buf, buf);
  490. X                    sprintf(buf, "Their boobytrap gave you %d%% damage!)\n",
  491. X                        booby);
  492. X                    notify(Playernum, Governor, buf);
  493. X                }
  494. X                sprintf(buf, "Damage taken:  You: %d%% (now %d%%)\n",
  495. X                    dam, s->damage);
  496. X                notify(Playernum, Governor, buf);
  497. X                if (!s->alive) {
  498. X                    sprintf(buf, "              YOUR SHIP WAS DESTROYED!!!\n");
  499. X                    notify(Playernum, Governor, buf);
  500. X                    sprintf(buf, "              Their ship DESTROYED!!!\n");
  501. X                    strcat(telegram_buf, buf);
  502. X                }
  503. X                sprintf(buf, "              Them: %d%% (now %d%%)\n",
  504. X                    dam2, s2->damage);
  505. X                notify(Playernum, Governor, buf);
  506. X                if (!s2->alive) {
  507. X                    sprintf(buf, "              Their ship DESTROYED!!!  Boarders are dead.\n");
  508. X                    notify(Playernum, Governor, buf);
  509. X                    sprintf(buf, "              YOUR SHIP WAS DESTROYED!!!\n");
  510. X                    strcat(telegram_buf, buf);
  511. X                }
  512. X                if (s->alive) {
  513. X                    if (s2->owner == Playernum) {
  514. X                        sprintf(buf, "CAPTURED!\n");
  515. X                        strcat(telegram_buf, buf);
  516. X                        sprintf(buf, "VICTORY! the ship is yours!\n");
  517. X                        notify(Playernum, Governor, buf);
  518. X                        if (boarders) {
  519. X                            sprintf(buf, "%d boarders move in.\n", boarders);
  520. X                            notify(Playernum, Governor, buf);
  521. X                        }
  522. X                        capture_stuff(s2);
  523. X                    } else if (s2->popn + s2->troops) {
  524. X                        sprintf(buf, "The boarding was repulsed; try again.\n");
  525. X                        notify(Playernum, Governor, buf);
  526. X                        sprintf(buf, "You fought them off!\n");
  527. X                        strcat(telegram_buf, buf);
  528. X                    }
  529. X                } else {
  530. X                    sprintf(buf, "The assault was too much for your bucket of bolts.\n");
  531. X                    notify(Playernum, Governor, buf);
  532. X                    sprintf(buf, "The assault was too much for their ship..\n");
  533. X                    strcat(telegram_buf, buf);
  534. X                }
  535. X                if (s2->alive) {
  536. X                    if (s2->max_crew && !boarders) {
  537. X                        sprintf(buf, "Oh no! They killed your boarding party to the last man!\n");
  538. X                        notify(Playernum, Governor, buf);
  539. X                    }
  540. X                    if (!s->popn && !s->troops) {
  541. X                        sprintf(buf, "You killed all their crew!\n");
  542. X                        strcat(telegram_buf, buf);
  543. X                    }
  544. X                } else {
  545. X                    sprintf(buf, "The assault weakened their ship too much!\n");
  546. X                    notify(Playernum, Governor, buf);
  547. X                    sprintf(buf, "Your ship was weakened too much!\n");
  548. X                    strcat(telegram_buf, buf);
  549. X                }
  550. X                sprintf(buf, "Casualties: Yours: %d mil/%d civ    Theirs: %d %s\n",
  551. X                    casualties3, casualties2, casualties, what == MIL ? "mil" : "civ");
  552. X                strcat(telegram_buf, buf);
  553. X                sprintf(buf, "Crew casualties: Yours: %d %s    Theirs: %d mil/%d civ\n",
  554. X                    casualties, what == MIL ? "mil" : "civ", casualties3, casualties2);
  555. X                notify(Playernum, Governor, buf);
  556. X                warn(old2owner, old2gov, telegram_buf);
  557. X                sprintf(buf, "%s %s %s at %s.\n", Ship(s),
  558. X                    s2->alive ? (s2->owner == Playernum ? "CAPTURED" : "assaulted") :
  559. X                    "DESTROYED",
  560. X                    Ship(&ship), prin_ship_orbits(s));
  561. X                if (s2->owner == Playernum || !s2->alive)
  562. X                    post(buf, COMBAT);
  563. X                notify_star(Playernum, Governor, old2owner,
  564. X                        (int) s->storbits, buf);
  565. X            } else {
  566. X                sprintf(buf, "%s docked with %s.\n", Ship(s), Ship(s2));
  567. X                notify(Playernum, Governor, buf);
  568. X            }
  569. X
  570. X            if (Dir[Playernum - 1][Governor].level == LEVEL_UNIV)
  571. X                deductAPs(Playernum, Governor, APcount, 0, 1);
  572. X            else
  573. X                deductAPs(Playernum, Governor, APcount, Dir[Playernum - 1][Governor].snum, 0);
  574. X
  575. X            s->notified = s2->notified = 0;
  576. X            putship(s);
  577. X            putship(s2);
  578. X            free(s2);
  579. X            free(s);
  580. X        } else
  581. X            free(s);
  582. X}
  583. END_OF_FILE
  584. if test 14652 -ne `wc -c <'user/dock.c'`; then
  585.     echo shar: \"'user/dock.c'\" unpacked with wrong size!
  586. fi
  587. # end of 'user/dock.c'
  588. fi
  589. if test -f 'user/rst.c' -a "${1}" != "-c" ; then 
  590.   echo shar: Will not clobber existing file \"'user/rst.c'\"
  591. else
  592. echo shar: Extracting \"'user/rst.c'\" \(17462 characters\)
  593. sed "s/^X//" >'user/rst.c' <<'END_OF_FILE'
  594. X/*
  595. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  596. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  597. X * GB_copyright.h.
  598. X * 
  599. X * ship -- report -- stock -- tactical -- stuff on ship
  600. X * 
  601. X * Command "factories" programmed by varneyml@gb.erc.clarkson.edu
  602. X */
  603. X
  604. X#define REPORT    0
  605. X#define STOCK    1
  606. X#define TACTICAL 2
  607. X#define SHIP    3
  608. X#define STATUS    4
  609. X#define WEAPONS    5
  610. X#define FACTORIES 6
  611. X
  612. X#define PLANET 1
  613. X
  614. X#include <ctype.h>
  615. X#include <math.h>
  616. X
  617. X#include "GB_copyright.h"
  618. X#define EXTERN extern
  619. X#include "vars.h"
  620. X#include "ships.h"
  621. X#include "races.h"
  622. X#include "power.h"
  623. X#include "buffers.h"
  624. X
  625. Xextern char     Shipltrs[];
  626. X
  627. Xchar            Caliber[] = {' ', 'L', 'M', 'H'};
  628. Xchar            shiplist[256];
  629. X
  630. Xstatic unsigned char Status, SHip, Stock, Report, Tactical, Weapons, Factories,
  631. X                first;
  632. X
  633. Xstruct reportdata {
  634. X    unsigned char   type;    /* ship or planet */
  635. X    shiptype       *s;
  636. X    planettype     *p;
  637. X    short           n;
  638. X    unsigned char   star;
  639. X    unsigned char   pnum;
  640. X    double          x;
  641. X    double          y;
  642. X};
  643. X
  644. Xracetype       *Race;
  645. Xstruct reportdata *rd;
  646. Xint             enemies_only, who;
  647. X
  648. Xvoid            rst(int, int, int, int);
  649. Xvoid            ship_report(int, int, int, unsigned char[]);
  650. Xvoid            plan_getrships(int, int, int, int);
  651. Xvoid            star_getrships(int, int, int);
  652. Xint             Getrship(int, int, int);
  653. Xvoid            Free_rlist(void);
  654. Xint             listed(int, char *);
  655. X#include "proto.h"
  656. X
  657. Xvoid 
  658. Xrst(int Playernum, int Governor, int APcount, int Rst)
  659. X{
  660. X    int             shipno;
  661. X    reg int         shn, i;
  662. X    int             n_ships, num;
  663. X    unsigned char   Report_types[NUMSTYPES];
  664. X
  665. X    for (i = 0; i < NUMSTYPES; i++)
  666. X        Report_types[i] = 1;
  667. X    enemies_only = 0;
  668. X    Num_ships = 0;
  669. X    first = 1;
  670. X    switch (Rst) {
  671. X    case REPORT:
  672. X        Report = 1;
  673. X        Weapons = Status = Stock = SHip = Tactical = Factories = 0;
  674. X        break;
  675. X    case STOCK:
  676. X        Stock = 1;
  677. X        Weapons = Status = Report = SHip = Tactical = Factories = 0;
  678. X        break;
  679. X    case TACTICAL:
  680. X        Tactical = 1;
  681. X        Weapons = Status = Report = SHip = Stock = Factories = 0;
  682. X        break;
  683. X    case SHIP:
  684. X        SHip = Report = Stock = 1;
  685. X        Tactical = 0;
  686. X        Weapons = Status = Factories = 1;
  687. X        break;
  688. X    case STATUS:
  689. X        Status = 1;
  690. X        Weapons = Report = Stock = Tactical = SHip = Factories = 0;
  691. X        break;
  692. X    case WEAPONS:
  693. X        Weapons = 1;
  694. X        Status = Report = Stock = Tactical = SHip = Factories = 0;
  695. X        break;
  696. X    case FACTORIES:
  697. X        Factories = 1;
  698. X        Status = Report = Stock = Tactical = SHip = Weapons = 0;
  699. X        break;
  700. X    }
  701. X    n_ships = Numships();
  702. X    rd = (struct reportdata *) malloc(sizeof(struct reportdata) *
  703. X                   (n_ships + Sdata.numstars * MAXPLANETS));
  704. X    /* (one list entry for each ship, planet in universe) */
  705. X
  706. X    Race = races[Playernum - 1];
  707. X
  708. X    if (argn == 3) {
  709. X        if (isdigit(args[2][0]))
  710. X            who = atoi(args[2]);
  711. X        else {
  712. X            who = 999;    /* treat args[2] as a list of ship
  713. X                     * types */
  714. X            strcpy(shiplist, args[2]);
  715. X        }
  716. X    } else
  717. X        who = 0;
  718. X
  719. X    if (argn >= 2) {
  720. X        if (*args[1] == '#' || isdigit(*args[1])) {
  721. X            /* report on a couple ships */
  722. X            int             l = 1;
  723. X            while (l < MAXARGS && *args[l] != '\0') {
  724. X                sscanf(args[l] + (*args[l] == '#'), "%d", &shipno);
  725. X                if (shipno > n_ships || shipno < 1) {
  726. X                    sprintf(buf, "rst: no such ship #%d \n", shipno);
  727. X                    notify(Playernum, Governor, buf);
  728. X                    free(rd);
  729. X                    return;
  730. X                }
  731. X                (void) Getrship(Playernum, Governor, shipno);
  732. X                num = Num_ships;
  733. X                if (rd[Num_ships - 1].s->whatorbits != LEVEL_UNIV) {
  734. X                    star_getrships(Playernum, Governor, (int) rd[num - 1].s->storbits);
  735. X                    ship_report(Playernum, Governor, num - 1, Report_types);
  736. X                } else
  737. X                    ship_report(Playernum, Governor, num - 1, Report_types);
  738. X                l++;
  739. X            }
  740. X            Free_rlist();
  741. X            return;
  742. X        } else {
  743. X            int             l;
  744. X            l = strlen(args[1]);
  745. X            for (i = 0; i < NUMSTYPES; i++)
  746. X                Report_types[i] = 0;
  747. X
  748. X            while (l--) {
  749. X                i = NUMSTYPES;
  750. X                while (--i && Shipltrs[i] != args[1][l]);
  751. X                if (Shipltrs[i] != args[1][l]) {
  752. X                    sprintf(buf, "'%c' -- no such ship letter\n", args[1][l]);
  753. X                    notify(Playernum, Governor, buf);
  754. X                } else
  755. X                    Report_types[i] = 1;
  756. X            }
  757. X        }
  758. X    }
  759. X    switch (Dir[Playernum - 1][Governor].level) {
  760. X    case LEVEL_UNIV:
  761. X        if (!(Rst == TACTICAL && argn < 2)) {
  762. X            shn = Sdata.ships;
  763. X            while (shn && Getrship(Playernum, Governor, shn))
  764. X                shn = rd[Num_ships - 1].s->nextship;
  765. X
  766. X            for (i = 0; i < Sdata.numstars; i++)
  767. X                star_getrships(Playernum, Governor, i);
  768. X            for (i = 0; i < Num_ships; i++)
  769. X                ship_report(Playernum, Governor, i, Report_types);
  770. X        } else {
  771. X            notify(Playernum, Governor, "You can't do tactical option from universe level.\n");
  772. X            free(rd);    /* nothing allocated */
  773. X            return;
  774. X        }
  775. X        break;
  776. X    case LEVEL_PLAN:
  777. X        plan_getrships(Playernum, Governor, Dir[Playernum - 1][Governor].snum, Dir[Playernum - 1][Governor].pnum);
  778. X        for (i = 0; i < Num_ships; i++)
  779. X            ship_report(Playernum, Governor, i, Report_types);
  780. X        break;
  781. X    case LEVEL_STAR:
  782. X        star_getrships(Playernum, Governor, Dir[Playernum - 1][Governor].snum);
  783. X        for (i = 0; i < Num_ships; i++)
  784. X            ship_report(Playernum, Governor, i, Report_types);
  785. X        break;
  786. X    case LEVEL_SHIP:
  787. X        (void) Getrship(Playernum, Governor, Dir[Playernum - 1][Governor].shipno);
  788. X        ship_report(Playernum, Governor, 0, Report_types);    /* first ship report */
  789. X        shn = rd[0].s->ships;
  790. X        Num_ships = 0;
  791. X
  792. X        while (shn && Getrship(Playernum, Governor, shn))
  793. X            shn = rd[Num_ships - 1].s->nextship;
  794. X
  795. X        for (i = 0; i < Num_ships; i++)
  796. X            ship_report(Playernum, Governor, i, Report_types);
  797. X        break;
  798. X    }
  799. X    Free_rlist();
  800. X}
  801. X
  802. Xvoid 
  803. Xship_report(int Playernum, int Governor, int indx, unsigned char rep_on[])
  804. X{
  805. X    shiptype       *s;
  806. X    planettype     *p;
  807. X    int             shipno;
  808. X    reg int         i, sight, caliber;
  809. X    placetype       where;
  810. X    char            orb[PLACENAMESIZE];
  811. X    char            strng[COMMANDSIZE], locstrn[COMMANDSIZE];
  812. X    char            tmpbuf1[10], tmpbuf2[10], tmpbuf3[10], tmpbuf4[10];
  813. X    double          Dist;
  814. X
  815. X    /* last ship gotten from disk */
  816. X    s = rd[indx].s;
  817. X    p = rd[indx].p;
  818. X    shipno = rd[indx].n;
  819. X
  820. X    /* launched canister, non-owned ships don't show up */
  821. X    if ((rd[indx].type == PLANET && p->info[Playernum - 1].numsectsowned)
  822. X     || (rd[indx].type != PLANET && s->alive && s->owner == Playernum &&
  823. X         authorized(Governor, s) &&
  824. X         rep_on[s->type] && !(s->type == OTYPE_CANIST && !s->docked) &&
  825. X         !(s->type == OTYPE_GREEN && !s->docked))) {
  826. X        if (rd[indx].type != PLANET && Stock) {
  827. X            if (first) {
  828. X                sprintf(buf, "    #       name        x  hanger   res        des         fuel      crew/mil\n");
  829. X                notify(Playernum, Governor, buf);
  830. X                if (!SHip)
  831. X                    first = 0;
  832. X            }
  833. X            sprintf(buf, "%5d %c %14.14s%3u%4u:%-3u%5u:%-5d%5u:%-5d%7.1f:%-6d%u/%u:%d\n",
  834. X                shipno, Shipltrs[s->type],
  835. X                (s->active ? s->name : "INACTIVE"),
  836. X                s->crystals, s->hanger, s->max_hanger,
  837. X                s->resource, Max_resource(s), s->destruct, Max_destruct(s),
  838. X                s->fuel, Max_fuel(s), s->popn, s->troops, s->max_crew);
  839. X            notify(Playernum, Governor, buf);
  840. X        }
  841. X        if (rd[indx].type != PLANET && Status) {
  842. X            if (first) {
  843. X                sprintf(buf, "    #       name       las cew hyp    guns   arm tech spd cost  mass size\n");
  844. X                notify(Playernum, Governor, buf);
  845. X                if (!SHip)
  846. X                    first = 0;
  847. X            }
  848. X            sprintf(buf, "%5d %c %14.14s %s%s%s%3u%c/%3u%c%4u%5.0f%4u%5u%7.1f%4u",
  849. X                shipno, Shipltrs[s->type],
  850. X                (s->active ? s->name : "INACTIVE"),
  851. X                s->laser ? "yes " : "    ",
  852. X                s->cew ? "yes " : "    ",
  853. X                s->hyper_drive.has ? "yes " : "    ",
  854. X                s->primary, Caliber[s->primtype], s->secondary, Caliber[s->sectype],
  855. X                Armor(s), s->tech, Max_speed(s), Cost(s), Mass(s), Size(s));
  856. X            notify(Playernum, Governor, buf);
  857. X            if (s->type == STYPE_POD) {
  858. X                sprintf(buf, " (%d)", s->special.pod.temperature);
  859. X                notify(Playernum, Governor, buf);
  860. X            }
  861. X            notify(Playernum, Governor, "\n");
  862. X        }
  863. X        if (rd[indx].type != PLANET && Weapons) {
  864. X            if (first) {
  865. X                sprintf(buf, "    #       name      laser   cew     safe     guns    damage   class\n");
  866. X                notify(Playernum, Governor, buf);
  867. X                if (!SHip)
  868. X                    first = 0;
  869. X            }
  870. X            sprintf(buf, "%5d %c %14.14s %s  %3d/%-4d  %4d  %3d%c/%3d%c    %3d%%  %c %s\n",
  871. X                shipno, Shipltrs[s->type],
  872. X                (s->active ? s->name : "INACTIVE"),
  873. X               s->laser ? "yes " : "    ", s->cew, s->cew_range,
  874. X                (int) ((1.0 - .01 * s->damage) * s->tech / 4.0),
  875. X                s->primary, Caliber[s->primtype],
  876. X                s->secondary, Caliber[s->sectype],
  877. X                s->damage, s->type == OTYPE_FACTORY ? Shipltrs[s->build_type] : ' ',
  878. X                ((s->type == OTYPE_TERRA) ||
  879. X              (s->type == OTYPE_PLOW)) ? "Standard" : s->class);
  880. X            notify(Playernum, Governor, buf);
  881. X        }
  882. X        if (rd[indx].type != PLANET && Factories && (s->type == OTYPE_FACTORY)) {
  883. X            if (first) {
  884. X                sprintf(buf, "   #    Cost Tech Mass Sz A Crw Ful Crg Hng Dst Sp Weapons Lsr CEWs Range Dmg\n");
  885. X                notify(Playernum, Governor, buf);
  886. X                if (!SHip)
  887. X                    first = 0;
  888. X            }
  889. X            if ((s->build_type == 0) || (s->build_type == OTYPE_FACTORY)) {
  890. X                sprintf(buf, "%5d               (No ship type specified yet)                      75% (OFF)", shipno);
  891. X                notify(Playernum, Governor, buf);
  892. X            } else {
  893. X                if (s->primtype)
  894. X                    sprintf(tmpbuf1, "%2d%s", s->primary, s->primtype == LIGHT ?
  895. X                        "L" : s->primtype == MEDIUM ? "M" : s->primtype == HEAVY ? "H" : "N");
  896. X                else
  897. X                    strcpy(tmpbuf1, "---");
  898. X                if (s->sectype)
  899. X                    sprintf(tmpbuf2, "%2d%s", s->secondary, s->sectype == LIGHT ?
  900. X                        "L" : s->sectype == MEDIUM ? "M" : s->sectype == HEAVY ? "H" : "N");
  901. X                else
  902. X                    strcpy(tmpbuf2, "---");
  903. X                if (s->cew)
  904. X                    sprintf(tmpbuf3, "%4d", s->cew);
  905. X                else
  906. X                    strcpy(tmpbuf3, "----");
  907. X                if (s->cew)
  908. X                    sprintf(tmpbuf4, "%5d", s->cew_range);
  909. X                else
  910. X                    strcpy(tmpbuf4, "-----");
  911. X                sprintf(buf, "%5d %c%4d%6.1f%5.1f%3d%2d%4d%4d%4d%4d%4d %c%1d %s/%s %s %s %s %02d%%%s\n",
  912. X                    shipno, Shipltrs[s->build_type],
  913. X                    s->build_cost, s->complexity, s->base_mass, ship_size(s),
  914. X                    s->armor, s->max_crew, s->max_fuel, s->max_resource,
  915. X                    s->max_hanger, s->max_destruct,
  916. X                    s->hyper_drive.has ? (s->mount ? (s->mounted ? '+' : '-')
  917. X                         : '*') : ' ',
  918. X                    s->max_speed, tmpbuf1, tmpbuf2, s->laser ? "yes" : " no",
  919. X                    tmpbuf3, tmpbuf4, s->damage,
  920. X                    s->damage ? (s->on ? "" : "*") : "");
  921. X                notify(Playernum, Governor, buf);
  922. X            }
  923. X        }
  924. X        if (rd[indx].type != PLANET && Report) {
  925. X            if (first) {
  926. X                sprintf(buf, " #      name       gov dam crew mil  des fuel sp orbits     destination\n");
  927. X                notify(Playernum, Governor, buf);
  928. X                if (!SHip)
  929. X                    first = 0;
  930. X            }
  931. X            if (s->docked)
  932. X                if (s->whatdest == LEVEL_SHIP)
  933. X                    sprintf(locstrn, "D#%d", s->destshipno);
  934. X                else
  935. X                    sprintf(locstrn, "L%2d,%-2d", s->land_x, s->land_y);
  936. X            else if (s->navigate.on)
  937. X                sprintf(locstrn, "nav:%d (%d)", s->navigate.bearing,
  938. X                    s->navigate.turns);
  939. X            else
  940. X                strcpy(locstrn, prin_ship_dest(Playernum, Governor, s));
  941. X
  942. X            if (!s->active) {
  943. X                sprintf(strng, "INACTIVE(%d)", s->rad);
  944. X                notify(Playernum, Governor, buf);
  945. X            }
  946. X            sprintf(buf, "%c%-5d %12.12s %2d %3u%5u%4u%5u%5.0f %c%1u %-10s %-18s\n",
  947. X                Shipltrs[s->type], shipno,
  948. X                (s->active ? s->name : strng), s->governor,
  949. X                s->damage, s->popn, s->troops,
  950. X                s->destruct, s->fuel,
  951. X                s->hyper_drive.has ? (s->mount ? (s->mounted ? '+' : '-') : '*') : ' ',
  952. X                s->speed, Dispshiploc_brief(s), locstrn,
  953. X                0);
  954. X            notify(Playernum, Governor, buf);
  955. X        }
  956. X        if (Tactical) {
  957. X            int             fev = 0, fspeed = 0, defense, fdam = 0;
  958. X            double          tech;
  959. X
  960. X            sprintf(buf, "\n  #         name        tech    guns  armor size dest   fuel dam spd evad               orbits\n");
  961. X            notify(Playernum, Governor, buf);
  962. X
  963. X            if (rd[indx].type == PLANET) {
  964. X                tech = Race->tech;
  965. X                /* tac report from planet */
  966. X                sprintf(buf, "(planet)%15.15s%4.0f %4dM           %5u %6u\n",
  967. X                Stars[rd[indx].star]->pnames[rd[indx].pnum],
  968. X                    tech, p->info[Playernum - 1].guns,
  969. X                    p->info[Playernum - 1].destruct,
  970. X                    p->info[Playernum - 1].fuel);
  971. X                notify(Playernum, Governor, buf);
  972. X                caliber = MEDIUM;
  973. X            } else {
  974. X                where.level = s->whatorbits;
  975. X                where.snum = s->storbits;
  976. X                where.pnum = s->pnumorbits;
  977. X                tech = s->tech;
  978. X                caliber = current_caliber(s);
  979. X                if ((s->whatdest != LEVEL_UNIV || s->navigate.on) &&
  980. X                    !s->docked && s->active) {
  981. X                    fspeed = s->speed;
  982. X                    fev = s->protect.evade;
  983. X                }
  984. X                fdam = s->damage;
  985. X                sprintf(orb, "%30.30s", Dispplace(Playernum, Governor, &where));
  986. X                sprintf(buf, "%3d %c %16.16s %4.0f%3d%c/%3d%c%6d%5d%5u%7.1f%3d%%  %d  %3s%21.22s",
  987. X                    shipno, Shipltrs[s->type],
  988. X                    (s->active ? s->name : "INACTIVE"),
  989. X                    s->tech,
  990. X                    s->primary, Caliber[s->primtype],
  991. X                    s->secondary, Caliber[s->sectype],
  992. X                    s->armor, s->size,
  993. X                    s->destruct, s->fuel, s->damage, fspeed,
  994. X                    (fev ? "yes" : "   "),
  995. X                    orb);
  996. X                notify(Playernum, Governor, buf);
  997. X                if (landed(s)) {
  998. X                    sprintf(buf, " (%d,%d)", s->land_x, s->land_y);
  999. X                    notify(Playernum, Governor, buf);
  1000. X                }
  1001. X                if (!s->active) {
  1002. X                    sprintf(buf, " INACTIVE(%d)", s->rad);
  1003. X                    notify(Playernum, Governor, buf);
  1004. X                }
  1005. X                sprintf(buf, "\n");
  1006. X                notify(Playernum, Governor, buf);
  1007. X            }
  1008. X
  1009. X            sight = 0;
  1010. X            if (rd[indx].type == PLANET)
  1011. X                sight = 1;
  1012. X            else if (Sight(s))
  1013. X                sight = 1;
  1014. X
  1015. X            /* tactical display */
  1016. X            sprintf(buf, "\n  Tactical: #  own typ        name   rng   (50%%) size spd evade hit  dam  loc\n");
  1017. X            notify(Playernum, Governor, buf);
  1018. X
  1019. X            if (sight)
  1020. X                for (i = 0; i < Num_ships; i++) {
  1021. X                    if (i != indx &&
  1022. X                        (Dist = sqrt(Distsq(rd[indx].x, rd[indx].y,
  1023. X                                rd[i].x, rd[i].y))) < gun_range(Race, rd[indx].s, (rd[indx].type == PLANET)))
  1024. X                        if (rd[i].type == PLANET) {
  1025. X                            /*
  1026. X                             * tac report at
  1027. X                             * planet
  1028. X                             */
  1029. X                            sprintf(buf, " %13s(planet)          %8.0f\n",
  1030. X                                Stars[rd[i].star]->pnames[rd[i].pnum], Dist);
  1031. X                            notify(Playernum, Governor, buf);
  1032. X                        } else if (!who || who == rd[i].s->owner ||
  1033. X                               (who == 999 && listed((int) rd[i].s->type, shiplist))) {
  1034. X                            /* tac report at ship */
  1035. X                            if ((rd[i].s->owner != Playernum || !authorized(Governor, rd[i].s)) &&
  1036. X                                rd[i].s->alive &&
  1037. X                                rd[i].s->type != OTYPE_CANIST &&
  1038. X                                rd[i].s->type != OTYPE_GREEN) {
  1039. X                                int             tev = 0,
  1040. X                                                tspeed = 0,
  1041. X                                                body = 0,
  1042. X                                                prob = 0;
  1043. X                                int             factor = 0;
  1044. X                                if ((rd[i].s->whatdest != LEVEL_UNIV || rd[i].s->navigate.on)
  1045. X                                    && !rd[i].s->docked && rd[i].s->active) {
  1046. X                                    tspeed = rd[i].s->speed;
  1047. X                                    tev = rd[i].s->protect.evade;
  1048. X                                }
  1049. X                                body = Size(rd[i].s);
  1050. X                                defense = getdefense(rd[i].s);
  1051. X                                prob = hit_odds(Dist, &factor, tech, fdam, fev, tev, fspeed, tspeed, body, caliber, defense);
  1052. X                                if (rd[indx].type != PLANET &&
  1053. X                                    laser_on(rd[indx].s) && rd[indx].s->focus)
  1054. X                                    prob = prob * prob / 100;
  1055. X                                sprintf(buf, "%13d %s%2d,%1d %c%14.14s %4.0f  %4d   %4d %d  %3s  %3d%% %3u%%%s",
  1056. X                                    rd[i].n, (isset(races[Playernum - 1]->atwar,
  1057. X                                            rd[i].s->owner)) ? "-" :
  1058. X                                    (isset(races[Playernum - 1]->allied,
  1059. X                                           rd[i].s->owner)) ? "+" : " ",
  1060. X                                    rd[i].s->owner, rd[i].s->governor,
  1061. X                                    Shipltrs[rd[i].s->type],
  1062. X                                    rd[i].s->name, Dist, factor, body, tspeed, (tev ? "yes" : "   "), prob, rd[i].s->damage,
  1063. X                                    (rd[i].s->active ? "" : " INACTIVE"));
  1064. X                                if ((enemies_only == 0) || ((enemies_only == 1) && (!isset(races[Playernum - 1]->allied, rd[i].s->owner)))) {
  1065. X                                    notify(Playernum, Governor, buf);
  1066. X                                    if (landed(rd[i].s)) {
  1067. X                                        sprintf(buf, " (%d,%d)", rd[i].s->land_x, rd[i].s->land_y);
  1068. X                                        notify(Playernum, Governor, buf);
  1069. X                                    } else {
  1070. X                                        sprintf(buf, "     ");
  1071. X                                        notify(Playernum, Governor, buf);
  1072. X                                    }
  1073. X                                    sprintf(buf, "\n");
  1074. X                                    notify(Playernum, Governor, buf);
  1075. X                                }
  1076. X                            }
  1077. X                        }
  1078. X                }
  1079. X        }
  1080. X    }
  1081. X}
  1082. X
  1083. X
  1084. Xvoid 
  1085. Xplan_getrships(int Playernum, int Governor, int snum, int pnum)
  1086. X{
  1087. X    reg int         shn;
  1088. X    planettype     *p;
  1089. X
  1090. X    getplanet(&(rd[Num_ships].p), snum, pnum);
  1091. X    p = rd[Num_ships].p;
  1092. X    /* add this planet into the ship list */
  1093. X    rd[Num_ships].star = snum;
  1094. X    rd[Num_ships].pnum = pnum;
  1095. X    rd[Num_ships].type = PLANET;
  1096. X    rd[Num_ships].n = 0;
  1097. X    rd[Num_ships].x = Stars[snum]->xpos + p->xpos;
  1098. X    rd[Num_ships].y = Stars[snum]->ypos + p->ypos;
  1099. X    Num_ships++;
  1100. X
  1101. X    if (p->info[Playernum - 1].explored) {
  1102. X        shn = p->ships;
  1103. X        while (shn && Getrship(Playernum, Governor, shn))
  1104. X            shn = rd[Num_ships - 1].s->nextship;
  1105. X    }
  1106. X}
  1107. X
  1108. Xvoid 
  1109. Xstar_getrships(int Playernum, int Governor, int snum)
  1110. X{
  1111. X    reg int         shn;
  1112. X    int             i;
  1113. X
  1114. X    if (isset(Stars[snum]->explored, Playernum)) {
  1115. X        shn = Stars[snum]->ships;
  1116. X        while (shn && Getrship(Playernum, Governor, shn))
  1117. X            shn = rd[Num_ships - 1].s->nextship;
  1118. X        for (i = 0; i < Stars[snum]->numplanets; i++)
  1119. X            plan_getrships(Playernum, Governor, snum, i);
  1120. X    }
  1121. X}
  1122. X
  1123. X/* get a ship from the disk and add it to the ship list we're maintaining. */
  1124. Xint 
  1125. XGetrship(int Playernum, int Governor, int shipno)
  1126. X{
  1127. X    if (getship(&(rd[Num_ships].s), shipno)) {
  1128. X        rd[Num_ships].type = 0;
  1129. X        rd[Num_ships].n = shipno;
  1130. X        rd[Num_ships].x = rd[Num_ships].s->xpos;
  1131. X        rd[Num_ships].y = rd[Num_ships].s->ypos;
  1132. X        Num_ships++;
  1133. X        return 1;
  1134. X    } else {
  1135. X        sprintf(buf, "Getrship: error on ship get (%d).\n", shipno);
  1136. X        notify(Playernum, Governor, buf);
  1137. X        return 0;
  1138. X    }
  1139. X}
  1140. X
  1141. Xvoid 
  1142. XFree_rlist(void)
  1143. X{
  1144. X    reg int         i;
  1145. X    for (i = 0; i < Num_ships; i++)
  1146. X        if (rd[i].type == PLANET)
  1147. X            free(rd[i].p);
  1148. X        else
  1149. X            free(rd[i].s);
  1150. X    free(rd);
  1151. X}
  1152. X
  1153. Xint 
  1154. Xlisted(int type, char *string)
  1155. X{
  1156. X    char           *p;
  1157. X
  1158. X    for (p = string; *p; p++) {
  1159. X        if (Shipltrs[type] == *p)
  1160. X            return 1;
  1161. X    }
  1162. X    return 0;
  1163. X}
  1164. END_OF_FILE
  1165. if test 17462 -ne `wc -c <'user/rst.c'`; then
  1166.     echo shar: \"'user/rst.c'\" unpacked with wrong size!
  1167. fi
  1168. # end of 'user/rst.c'
  1169. fi
  1170. if test -f 'user/survey.c' -a "${1}" != "-c" ; then 
  1171.   echo shar: Will not clobber existing file \"'user/survey.c'\"
  1172. else
  1173. echo shar: Extracting \"'user/survey.c'\" \(15363 characters\)
  1174. sed "s/^X//" >'user/survey.c' <<'END_OF_FILE'
  1175. X/*
  1176. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  1177. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  1178. X * GB_copyright.h.
  1179. X * 
  1180. X * survey.c -- print out survey for planets
  1181. X * 
  1182. X * Tue Apr 16 16:34:38 MDT 1991 (Evan Koffler) Added the client_survey and mode
  1183. X * parts Thu Apr 25 11:37:56 MDT 1991 Added the ships per sector stuff. Works
  1184. X * well.
  1185. X * 
  1186. X */
  1187. X
  1188. X#include "GB_copyright.h"
  1189. X#define EXTERN extern
  1190. X#include "vars.h"
  1191. X#include "ships.h"
  1192. X#include "races.h"
  1193. X#include "power.h"
  1194. X#include "buffers.h"
  1195. X#include "csp.h"
  1196. X#include <strings.h>
  1197. X#include <ctype.h>
  1198. X
  1199. X#define MAX_SHIPS_PER_SECTOR    10
  1200. X
  1201. Xextern char    *Desnames[], Dessymbols[];
  1202. X
  1203. Xchar           *Tox[] = {
  1204. X    "Stage 0, mild",
  1205. X    "Stage 1, mild",
  1206. X    "Stage 2, semi-mild",
  1207. X    "Stage 3, semi-semi mild",
  1208. X    "Stage 4, ecologically unsound",
  1209. X    "Stage 5: ecologically unsound",
  1210. X    "Stage 6: below birth threshold",
  1211. X    "Stage 7: ecologically unstable--below birth threshold",
  1212. X    "Stage 8: ecologically poisonous --below birth threshold",
  1213. X    "Stage 9: WARNING: nearing 100% toxicity",
  1214. X    "Stage 10: WARNING: COMPLETELY TOXIC!!!",
  1215. X    "???"
  1216. X};
  1217. X
  1218. Xvoid            survey(int, int, int, int);
  1219. Xvoid            repair(int, int, int);
  1220. X#include "proto.h"
  1221. X
  1222. Xvoid 
  1223. Xsurvey(int Playernum, int Governor, int APcount, int mode)
  1224. X{
  1225. X    int             lowx, hix, lowy, hiy, x2;
  1226. X    char            d;
  1227. X    char            sect_char;
  1228. X    sectortype     *s;
  1229. X    planettype     *p;
  1230. X    int             tindex;
  1231. X    placetype       where;
  1232. X    double          compat;
  1233. X    int             avg_fert, avg_resource;
  1234. X    int             crystal_count;
  1235. X    racetype       *Race;
  1236. X    int             all = 0;/* full survey 1, specific 0 */
  1237. X    struct numshipstuff {
  1238. X        int             pos;
  1239. X        struct shipstuff {
  1240. X            int             shipno;
  1241. X            char            ltr;
  1242. X            unsigned char   owner;
  1243. X        }               shipstuffs[MAX_SHIPS_PER_SECTOR];
  1244. X    };
  1245. X    struct numshipstuff shiplocs[MAX_X][MAX_Y];
  1246. X    int             inhere;
  1247. X    int             shiplist;
  1248. X    shiptype       *shipa;
  1249. X    int             i;
  1250. X
  1251. X    if (argn == 1) {    /* no args */
  1252. X        where.level = Dir[Playernum - 1][Governor].level;
  1253. X        where.snum = Dir[Playernum - 1][Governor].snum;
  1254. X        where.pnum = Dir[Playernum - 1][Governor].pnum;
  1255. X    } else {
  1256. X        /* they are surveying a sector */
  1257. X        if ((isdigit(args[1][0]) && index(args[1], ',') != NULL) ||
  1258. X            (*args[1] == '-') && (all = 1)) {
  1259. X            if (Dir[Playernum - 1][Governor].level != LEVEL_PLAN) {
  1260. X                sprintf(buf, "There are no sectors here.\n");
  1261. X                notify(Playernum, Governor, buf);
  1262. X                return;
  1263. X            } else {
  1264. X                where.level = LEVEL_PLAN;
  1265. X                where.snum = Dir[Playernum - 1][Governor].snum;
  1266. X                where.pnum = Dir[Playernum - 1][Governor].pnum;
  1267. X            }
  1268. X        } else {
  1269. X            where = Getplace(Playernum, Governor, args[1], 0);
  1270. X            if (where.err || where.level == LEVEL_SHIP)
  1271. X                return;
  1272. X        }
  1273. X    }
  1274. X
  1275. X    Race = races[Playernum - 1];
  1276. X
  1277. X    if (where.level == LEVEL_PLAN) {
  1278. X        getplanet(&p, (int) where.snum, (int) where.pnum);
  1279. X
  1280. X        compat = compatibility(p, Race);
  1281. X
  1282. X        if ((isdigit(args[1][0]) && index(args[1], ',') != NULL) || all) {
  1283. X            getsmap(Smap, p);
  1284. X
  1285. X            if (!all) {
  1286. X                get4args(args[1], &x2, &hix, &lowy, &hiy);
  1287. X                /* ^^^ translate from lowx:hix,lowy:hiy */
  1288. X                x2 = MAX(0, x2);
  1289. X                hix = MIN(hix, p->Maxx - 1);
  1290. X                lowy = MAX(0, lowy);
  1291. X                hiy = MIN(hiy, p->Maxy - 1);
  1292. X            } else {
  1293. X                x2 = 0;
  1294. X                hix = p->Maxx - 1;
  1295. X                lowy = 0;
  1296. X                hiy = p->Maxy - 1;
  1297. X            }
  1298. X
  1299. X            if (!mode) {
  1300. X                sprintf(buf, " x,y cond/type  owner race eff mob frt  res  mil popn ^popn xtals\n");
  1301. X                notify(Playernum, Governor, buf);
  1302. X            }
  1303. X            if (mode) {
  1304. X                if (all) {
  1305. X                    sprintf(buf,
  1306. X                        "%c %d %d %d %s %s %d %d %d %d %d %d %.2f %d\n",
  1307. X                        CSP_CLIENT, CSP_SURVEY_INTRO,
  1308. X                        p->Maxx, p->Maxy, Stars[where.snum]->name,
  1309. X                        Stars[where.snum]->pnames[where.pnum],
  1310. X                        p->info[Playernum - 1].resource,
  1311. X                        p->info[Playernum - 1].fuel,
  1312. X                        p->info[Playernum - 1].destruct,
  1313. X                        p->popn, p->maxpopn, p->conditions[TOXIC],
  1314. X                        compatibility(p, Race), p->slaved_to);
  1315. X                    notify(Playernum, Governor, buf);
  1316. X                }
  1317. X                bzero((struct shipstuff *) shiplocs, sizeof(shiplocs));
  1318. X                inhere = p->info[Playernum - 1].numsectsowned;
  1319. X                shiplist = p->ships;
  1320. X                while (shiplist) {
  1321. X                    (void) getship(&shipa, shiplist);
  1322. X                    if (shipa->owner == Playernum &&
  1323. X                        (shipa->popn || (shipa->type == OTYPE_PROBE)))
  1324. X                        inhere = 1;
  1325. X                    if (shipa->alive && landed(shipa) &&
  1326. X                        shiplocs[shipa->land_x][shipa->land_y].pos <
  1327. X                        MAX_SHIPS_PER_SECTOR) {
  1328. X                        shiplocs[shipa->land_x][shipa->land_y].shipstuffs[shiplocs[shipa->land_x][shipa->land_y].pos].shipno = shiplist;
  1329. X                        shiplocs[shipa->land_x][shipa->land_y].shipstuffs[shiplocs[shipa->land_x][shipa->land_y].pos].owner = shipa->owner;
  1330. X                        shiplocs[shipa->land_x][shipa->land_y].shipstuffs[shiplocs[shipa->land_x][shipa->land_y].pos].ltr = Shipltrs[shipa->type];
  1331. X                        shiplocs[shipa->land_x][shipa->land_y].pos++;
  1332. X                    }
  1333. X                    shiplist = shipa->nextship;
  1334. X                    free(shipa);
  1335. X                }
  1336. X            }
  1337. X            for (; lowy <= hiy; lowy++)
  1338. X                for (lowx = x2; lowx <= hix; lowx++) {
  1339. X                    s = &Sector(*p, lowx, lowy);
  1340. X                    /* if (s->owner==Playernum) */
  1341. X                    if (!mode) {
  1342. X                        sprintf(buf, "%2d,%-2d ", lowx, lowy);
  1343. X                        notify(Playernum, Governor, buf);
  1344. X                        if ((d = desshow(Playernum, Governor, p, lowx, lowy, Race)) == CHAR_CLOAKED) {
  1345. X                            sprintf(buf, "?  (    ?    )\n");
  1346. X                            notify(Playernum, Governor, buf);
  1347. X                        } else {
  1348. X                            sprintf(buf,
  1349. X                                " %c   %c   %6u%5u%4u%4u%4u%5u%5u%5d%6d%s\n",
  1350. X                                Dessymbols[s->condition], Dessymbols[s->type],
  1351. X                                s->owner, s->race, s->eff,
  1352. X                                s->mobilization, s->fert, s->resource, s->troops, s->popn,
  1353. X                                maxsupport(Race, s, compat, p->conditions[TOXIC]),
  1354. X                                ((s->crystals && (Race->discoveries[D_CRYSTAL]
  1355. X                                          || Race->God)) ? " yes" : " "));
  1356. X                            notify(Playernum, Governor, buf);
  1357. X                        }
  1358. X                    } else {    /* mode */
  1359. X                        switch (s->condition) {
  1360. X                        case SEA:
  1361. X                            sect_char = CHAR_SEA;
  1362. X                            break;
  1363. X                        case LAND:
  1364. X                            sect_char = CHAR_LAND;
  1365. X                            break;
  1366. X                        case MOUNT:
  1367. X                            sect_char = CHAR_MOUNT;
  1368. X                            break;
  1369. X                        case GAS:
  1370. X                            sect_char = CHAR_GAS;
  1371. X                            break;
  1372. X                        case PLATED:
  1373. X                            sect_char = CHAR_PLATED;
  1374. X                            break;
  1375. X                        case ICE:
  1376. X                            sect_char = CHAR_ICE;
  1377. X                            break;
  1378. X                        case DESERT:
  1379. X                            sect_char = CHAR_DESERT;
  1380. X                            break;
  1381. X                        case FOREST:
  1382. X                            sect_char = CHAR_FOREST;
  1383. X                            break;
  1384. X                        default:
  1385. X                            sect_char = '?';
  1386. X                            break;
  1387. X                        }
  1388. X                        sprintf (buf, "%c %d %d %d %c %c %d %u %u %u %u %d %u %u %u %d",
  1389. X                                         CSP_CLIENT, CSP_SURVEY_SECTOR, 
  1390. X                                        lowx, lowy, sect_char,
  1391. X                                         desshow(Playernum, Governor, p, lowx, lowy, Race), 
  1392. X                                         ((s->condition == WASTED)  ? 1 : 0),
  1393. X                                         s->owner, s->eff, s->fert, s->mobilization,
  1394. X                                         ((s->crystals &&
  1395. X                          (Race->discoveries[D_CRYSTAL]
  1396. X                                          || Race->God)) ? 1 : 0),
  1397. X                                         s->resource, s->popn, s->troops,
  1398. X                                         maxsupport (Race,s,compat, p->conditions[TOXIC]));
  1399. X                        notify(Playernum, Governor, buf);
  1400. X
  1401. X                        if (shiplocs[lowx][lowy].pos && inhere) {
  1402. X                            notify(Playernum, Governor, ";");
  1403. X                            for (i = 0;
  1404. X                                 i < shiplocs[lowx][lowy].pos; i++) {
  1405. X                                sprintf(buf, " %d %c %u;",
  1406. X                                    shiplocs[lowx][lowy].shipstuffs[i].shipno, shiplocs[lowx][lowy].shipstuffs[i].ltr, shiplocs[lowx][lowy].shipstuffs[i].owner);
  1407. X                                notify(Playernum, Governor, buf);
  1408. X                            }
  1409. X                        }
  1410. X                        notify(Playernum, Governor, "\n");
  1411. X                    }
  1412. X                }
  1413. X            if (mode) {
  1414. X                sprintf(buf, "%c %d\n", CSP_CLIENT, CSP_SURVEY_END);
  1415. X                notify(Playernum, Governor, buf);
  1416. X            }
  1417. X        } else {
  1418. X            /* survey of planet */
  1419. X            sprintf(buf, "%s:\n", Stars[where.snum]->pnames[where.pnum]);
  1420. X            notify(Playernum, Governor, buf);
  1421. X            sprintf(buf, "gravity   x,y absolute     x,y relative to %s\n",
  1422. X                Stars[where.snum]->name);
  1423. X            notify(Playernum, Governor, buf);
  1424. X            sprintf(buf, "%7.2f   %7.1f,%7.1f   %8.1f,%8.1f\n",
  1425. X                  gravity(p), p->xpos + Stars[where.snum]->xpos,
  1426. X            p->ypos + Stars[where.snum]->ypos, p->xpos, p->ypos);
  1427. X            notify(Playernum, Governor, buf);
  1428. X            sprintf(buf, "======== Planetary conditions: ========\n");
  1429. X            notify(Playernum, Governor, buf);
  1430. X            sprintf(buf, "atmosphere concentrations:\n");
  1431. X            notify(Playernum, Governor, buf);
  1432. X            sprintf(buf, "     methane %02d%%(%02d%%)     oxygen %02d%%(%02d%%)\n",
  1433. X              p->conditions[METHANE], Race->conditions[METHANE],
  1434. X               p->conditions[OXYGEN], Race->conditions[OXYGEN]);
  1435. X            notify(Playernum, Governor, buf);
  1436. X            sprintf(buf, "         CO2 %02d%%(%02d%%)   hydrogen %02d%%(%02d%%)      temperature: %3d (%3d)\n",
  1437. X                p->conditions[CO2], Race->conditions[CO2],
  1438. X            p->conditions[HYDROGEN], Race->conditions[HYDROGEN],
  1439. X                p->conditions[TEMP], Race->conditions[TEMP]);
  1440. X            notify(Playernum, Governor, buf);
  1441. X            sprintf(buf, "    nitrogen %02d%%(%02d%%)     sulfur %02d%%(%02d%%)           normal: %3d\n",
  1442. X            p->conditions[NITROGEN], Race->conditions[NITROGEN],
  1443. X                p->conditions[SULFUR], Race->conditions[SULFUR],
  1444. X                p->conditions[RTEMP]);
  1445. X            notify(Playernum, Governor, buf);
  1446. X            sprintf(buf, "      helium %02d%%(%02d%%)      other %02d%%(%02d%%)\n",
  1447. X                p->conditions[HELIUM], Race->conditions[HELIUM],
  1448. X                 p->conditions[OTHER], Race->conditions[OTHER]);
  1449. X            notify(Playernum, Governor, buf);
  1450. X            if ((tindex = p->conditions[TOXIC] / 10) < 0)
  1451. X                tindex = 0;
  1452. X            else if (tindex > 10)
  1453. X                tindex = 11;
  1454. X            sprintf(buf, "                     Toxicity: %d%% (%s)\n",
  1455. X                p->conditions[TOXIC], Tox[tindex]);
  1456. X            notify(Playernum, Governor, buf);
  1457. X            sprintf(buf, "Total planetary compatibility: %.2f%%\n",
  1458. X                compatibility(p, Race));
  1459. X            notify(Playernum, Governor, buf);
  1460. X
  1461. X            getsmap(Smap, p);
  1462. X
  1463. X            crystal_count = avg_fert = avg_resource = 0;
  1464. X            for (lowx = 0; lowx < p->Maxx; lowx++)
  1465. X                for (lowy = 0; lowy < p->Maxy; lowy++) {
  1466. X                    s = &Sector(*p, lowx, lowy);
  1467. X                    avg_fert += s->fert;
  1468. X                    avg_resource += s->resource;
  1469. X                    if (Race->discoveries[D_CRYSTAL] || Race->God)
  1470. X                        crystal_count += !!s->crystals;
  1471. X                }
  1472. X            sprintf(buf, "%29s: %d\n%29s: %d\n%29s: %d\n",
  1473. X            "Average fertility", avg_fert / (p->Maxx * p->Maxy),
  1474. X                "Average resource", avg_resource / (p->Maxx * p->Maxy),
  1475. X                "Crystal sectors", crystal_count);
  1476. X            notify(Playernum, Governor, buf);
  1477. X            if (LIMITED_RESOURCES) {
  1478. X                sprintf(buf, "%29s: %d\n", "Total resource deposits",
  1479. X                    p->total_resources);
  1480. X                notify(Playernum, Governor, buf);
  1481. X            }
  1482. X            sprintf(buf, "fuel_stock  resource_stock dest_pot.   %s    ^%s\n",
  1483. X                Race->Metamorph ? "biomass" : "popltn",
  1484. X                Race->Metamorph ? "biomass" : "popltn");
  1485. X            notify(Playernum, Governor, buf);
  1486. X            sprintf(buf, "%10lu  %14lu %9lu  %7lu%11lu\n",
  1487. X                p->info[Playernum - 1].fuel,
  1488. X                p->info[Playernum - 1].resource,
  1489. X                p->info[Playernum - 1].destruct,
  1490. X                p->popn, p->maxpopn);
  1491. X            notify(Playernum, Governor, buf);
  1492. X            if (p->slaved_to) {
  1493. X                sprintf(buf, "This planet ENSLAVED to player %d!\n", p->slaved_to);
  1494. X                notify(Playernum, Governor, buf);
  1495. X            }
  1496. X        }
  1497. X        free(p);
  1498. X    } else if (where.level == LEVEL_STAR) {
  1499. X        sprintf(buf, "Star %s\n", Stars[where.snum]->name);
  1500. X        notify(Playernum, Governor, buf);
  1501. X        sprintf(buf, "locn: %f,%f\n", Stars[where.snum]->xpos, Stars[where.snum]->ypos);
  1502. X        notify(Playernum, Governor, buf);
  1503. X        if (Race->God) {
  1504. X            for (i = 0; i < Stars[where.snum]->numplanets; i++) {
  1505. X                getplanet(&p, (int) where.snum, i);
  1506. X                sprintf(buf, "%8d \"%s\"\n", p->sectormappos,
  1507. X                    Stars[where.snum]->pnames[i]);
  1508. X                notify(Playernum, Governor, buf);
  1509. X                free(p);
  1510. X            }
  1511. X        }
  1512. X        sprintf(buf, "gravity: %.2f\tstability: ", Stars[where.snum]->gravity);
  1513. X        notify(Playernum, Governor, buf);
  1514. X
  1515. X        if (Race->tech >= TECH_SEE_STABILITY || Race->God) {
  1516. X            sprintf(buf, "%d%% (%s)\n",
  1517. X                Stars[where.snum]->stability,
  1518. X                  Stars[where.snum]->stability < 20 ? "stable" :
  1519. X                Stars[where.snum]->stability < 40 ? "unstable" :
  1520. X               Stars[where.snum]->stability < 60 ? "dangerous" :
  1521. X                Stars[where.snum]->stability < 100 ?
  1522. X                "WARNING! nova iminent!" :
  1523. X                "undergoing nova");
  1524. X            notify(Playernum, Governor, buf);
  1525. X        } else {
  1526. X            sprintf(buf, "(cannot determine)\n");
  1527. X            notify(Playernum, Governor, buf);
  1528. X        }
  1529. X        sprintf(buf, "temperature class (1->10) %d\n", Stars[where.snum]->temperature);
  1530. X        notify(Playernum, Governor, buf);
  1531. X        sprintf(buf, "%d planets are ", Stars[where.snum]->numplanets);
  1532. X        notify(Playernum, Governor, buf);
  1533. X        for (x2 = 0; x2 < Stars[where.snum]->numplanets; x2++) {
  1534. X            sprintf(buf, "%s ", Stars[where.snum]->pnames[x2]);
  1535. X            notify(Playernum, Governor, buf);
  1536. X        }
  1537. X        sprintf(buf, "\n");
  1538. X        notify(Playernum, Governor, buf);
  1539. X    } else if (where.level == LEVEL_UNIV) {
  1540. X        sprintf(buf, "It's just _there_, you know?\n");
  1541. X        notify(Playernum, Governor, buf);
  1542. X    } else {
  1543. X        sprintf(buf, "Illegal scope.\n");
  1544. X        notify(Playernum, Governor, buf);
  1545. X    }
  1546. X}                /* end survey */
  1547. X
  1548. Xvoid 
  1549. Xrepair(int Playernum, int Governor, int APcount)
  1550. X{
  1551. X    int             lowx, hix, lowy, hiy, x2, sectors, cost;
  1552. X    sectortype     *s;
  1553. X    planettype     *p;
  1554. X    placetype       where;
  1555. X    racetype       *Race;
  1556. X
  1557. X    if (!control(Playernum, Governor, Stars[Dir[Playernum - 1][Governor].snum])) {
  1558. X        notify(Playernum, Governor, "You are not authorized to do that here.\n");
  1559. X        return;
  1560. X    }
  1561. X    if (argn == 1) {    /* no args */
  1562. X        where.level = Dir[Playernum - 1][Governor].level;
  1563. X        where.snum = Dir[Playernum - 1][Governor].snum;
  1564. X        where.pnum = Dir[Playernum - 1][Governor].pnum;
  1565. X    } else {
  1566. X        /* repairing a sector */
  1567. X        if (isdigit(args[1][0]) && index(args[1], ',') != NULL) {
  1568. X            if (Dir[Playernum - 1][Governor].level != LEVEL_PLAN) {
  1569. X                sprintf(buf, "There are no sectors here.\n");
  1570. X                notify(Playernum, Governor, buf);
  1571. X                return;
  1572. X            } else {
  1573. X                where.level = LEVEL_PLAN;
  1574. X                where.snum = Dir[Playernum - 1][Governor].snum;
  1575. X                where.pnum = Dir[Playernum - 1][Governor].pnum;
  1576. X            }
  1577. X        } else {
  1578. X            where = Getplace(Playernum, Governor, args[1], 0);
  1579. X            if (where.err || where.level == LEVEL_SHIP)
  1580. X                return;
  1581. X        }
  1582. X    }
  1583. X
  1584. X    Race = races[Playernum - 1];
  1585. X
  1586. X    if (where.level == LEVEL_PLAN) {
  1587. X        getplanet(&p, (int) where.snum, (int) where.pnum);
  1588. X        if (!p->info[Playernum - 1].numsectsowned) {
  1589. X            notify(Playernum, Governor, "You don't own any sectors on this planet.\n");
  1590. X            free(p);
  1591. X            return;
  1592. X        }
  1593. X        getsmap(Smap, p);
  1594. X        if (isdigit(args[1][0]) && index(args[1], ',') != NULL) {
  1595. X            get4args(args[1], &x2, &hix, &lowy, &hiy);
  1596. X            /* ^^^ translate from lowx:hix,lowy:hiy */
  1597. X            x2 = MAX(0, x2);
  1598. X            hix = MIN(hix, p->Maxx - 1);
  1599. X            lowy = MAX(0, lowy);
  1600. X            hiy = MIN(hiy, p->Maxy - 1);
  1601. X        } else {
  1602. X            /* repair entire planet */
  1603. X            x2 = 0;
  1604. X            hix = p->Maxx - 1;
  1605. X            lowy = 0;
  1606. X            hiy = p->Maxy - 1;
  1607. X        }
  1608. X        sectors = 0;
  1609. X        cost = 0;
  1610. X
  1611. X        for (; lowy <= hiy; lowy++)
  1612. X            for (lowx = x2; lowx <= hix; lowx++) {
  1613. X                if (p->info[Playernum - 1].resource >= SECTOR_REPAIR_COST) {
  1614. X                    s = &Sector(*p, lowx, lowy);
  1615. X                    if (s->condition == WASTED &&
  1616. X                        (s->owner == Playernum || !s->owner)) {
  1617. X                        s->condition = s->type;
  1618. X                        s->fert = MIN(100, s->fert + 20);
  1619. X                        p->info[Playernum - 1].resource -= SECTOR_REPAIR_COST;
  1620. X                        cost += SECTOR_REPAIR_COST;
  1621. X                        sectors += 1;
  1622. X                        putsector(s, p, lowx, lowy);
  1623. X                    }
  1624. X                }
  1625. X            }
  1626. X        putplanet(p, (int) where.snum, (int) where.pnum);
  1627. X        free(p);
  1628. X
  1629. X        sprintf(buf, "%d sectors repaired at a cost of %d resources.\n", sectors, cost);
  1630. X        notify(Playernum, Governor, buf);
  1631. X    } else {
  1632. X        sprintf(buf, "scope must be a planet.\n");
  1633. X        notify(Playernum, Governor, buf);
  1634. X    }
  1635. X}
  1636. X
  1637. END_OF_FILE
  1638. if test 15363 -ne `wc -c <'user/survey.c'`; then
  1639.     echo shar: \"'user/survey.c'\" unpacked with wrong size!
  1640. fi
  1641. # end of 'user/survey.c'
  1642. fi
  1643. echo shar: End of archive 12 \(of 21\).
  1644. cp /dev/null ark12isdone
  1645. MISSING=""
  1646. 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
  1647.     if test ! -f ark${I}isdone ; then
  1648.     MISSING="${MISSING} ${I}"
  1649.     fi
  1650. done
  1651. if test "${MISSING}" = "" ; then
  1652.     echo You have unpacked all 21 archives.
  1653.     echo "Now type './buildfiles.sh'"
  1654.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1655. else
  1656.     echo You still need to unpack the following archives:
  1657.     echo "        " ${MISSING}
  1658. fi
  1659. ##  End of shell archive.
  1660. exit 0
  1661.