home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume17 / gbp / part18 < prev    next >
Encoding:
Internet Message Format  |  1993-03-20  |  55.9 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: v17i030:  gbp - Galactic Bloodshed+, an empire-like war game, Part18/21
  5. Message-ID: <4558@master.CNA.TEK.COM>
  6. Date: 12 Feb 93 17:33:09 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1956
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1709
  11.  
  12. Submitted-by: deragon@harpo.cs.nyu.edu (Seeker)
  13. Posting-number: Volume 17, Issue 30
  14. Archive-name: gbp/Part18
  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 18 (of 21)."
  27. # Contents:  doc/CLIENT_PROTOCOL hdrs/config.h hdrs/config.h.SH
  28. #   hdrs/racegen.h user/map.c user/tele.c utils/enroll.c utils/psmap.c
  29. # Wrapped by billr@saab on Fri Feb 12 09:14:30 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'doc/CLIENT_PROTOCOL' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'doc/CLIENT_PROTOCOL'\"
  33. else
  34. echo shar: Extracting \"'doc/CLIENT_PROTOCOL'\" \(6911 characters\)
  35. sed "s/^X//" >'doc/CLIENT_PROTOCOL' <<'END_OF_FILE'
  36. X------------------------------------------------------------------------
  37. XCLIENT - SERVER PROTOCOL (CSP) Data File for GB+ (A product of GBDT)
  38. X------------------------------------------------------------------------
  39. XStarted by: Evan Koffler <koffleva@darkwing.uoregon.edu>
  40. XOn: Sat Jan 23 19:42:09 PST 1993
  41. X------------------------------------------------------------------------
  42. XModification History:
  43. X
  44. X------------------------------------------------------------------------
  45. X
  46. XThis file is to explain the client <-> server protocols that
  47. Xhave developed over the past few years of me (Evan Koffler)
  48. Xworking on the client and server.
  49. X
  50. XFirst off, the server should NEVER make a ship with the letter
  51. X\ or |. These 2 characters are reserved for client-server protocol
  52. X(hereafter referred to as CSP).
  53. X
  54. XTo introduce a NEW CSP or to change an existing CSP, PLEASE POST
  55. Xall relevant information on the appropriate newsgroup (alt.games.gb)
  56. Xcurrently and if a client or server developers mail list exist then
  57. Xsend a message to them as well. Allow enough time to pass for discussion
  58. Xabout the appropriateness of the arguments in the command output
  59. Xand then add the information to this file. This helps prevent
  60. Xfrequent changes to the commands and informs all client developers
  61. Xof any changes they may need to cope with in the future. The road
  62. Xhas been paved so far for you, continue to pave it for those who
  63. Xfollow.
  64. X
  65. X------------------------------------------------------------------------
  66. XThe standard format for the numeric protocol is:
  67. X
  68. X<client char> <number> [<arg1> <arg2> ..... <argn>]
  69. X
  70. XThe client character is:    |
  71. XWhile the <number> should be distinct ranges. That is, a command
  72. Xuses 101 then, the next one should be at 150 or even 200
  73. Xso that there is room to grow, and there is no confusion for
  74. Xthe commands.
  75. X
  76. X------------------------------------------------------------------------
  77. XFormat of this file
  78. X
  79. XEach CSP range should be presented in the following format.
  80. X
  81. XCommand name: <command>
  82. XResponse Range: X-Y
  83. XInput formats:
  84. X    <command> <arguments or options> (X-Y responses for command)
  85. X    <command> <another way of getting information> [X-Y]
  86. X
  87. XOutput formats:
  88. XX format: "scanf/printf format. preferably the scanf format so the
  89. Xclient can be modified to read it easily by copying the line"
  90. X
  91. X------------------------------------------------------------------------
  92. XAt present there are 2 commands that were old server formats
  93. Xthat do not follow this format. The two commands are map and orbit.
  94. XThe format for them follows.
  95. X
  96. XMap:
  97. X$<Planet Name>;<X>;<Y>;<SHOW>;<sector info>
  98. X
  99. XThe $ in position 0 denotes this is a map command.
  100. X<Planet Name> is a string ending in a ;.
  101. X<X> is the width of the planet.
  102. X<Y> is the height of the planet.
  103. X<SHOW> is unused.
  104. X<sector info> is a single digit number followed by a character.
  105. XThe digit means 1 of 2 things, depending if the toggle color option
  106. Xis set on the server.  If color is NOT set, then the digit will
  107. Xbe either a 1 or a 0 if you own or do not own the sector. If color
  108. Xis set then it will be a unique number for coloring the sector.
  109. XAfter the color/ownership information comes the actual character
  110. Xto be used to represent this sector.  The sector info continues for
  111. XX * Y pairs of sectors.
  112. X
  113. XExample:
  114. X$Test;2;2;1*1*0^0^
  115. XThis planet is named Test, is a 2 x 2 planet. You own the
  116. Xfirst 2 sectors, which are land, and do not own the 2 mtn sectors
  117. Xbelow. (assuming color is off).
  118. XMap in a working client would display:
  119. X     'Test'
  120. X   00
  121. X   01
  122. X00 **  <- these 2 sectors would be colored/highlighted to represent ownership
  123. X01 ^^
  124. X
  125. X
  126. XOrbit:
  127. X#<stand1> <X> <Y> <array> <symbol> <stand2> <Name>;[<stand1> <X> <Y> <array> <symbol> <stand2> <Name>;]
  128. X<stand1> is whether the planet is 'explored' by the player and should be
  129. Xhighlighted.
  130. X<X> is x coords.
  131. X<Y> is y coords.
  132. X<array> is the special output array index indicating which array to be
  133. Xdisplayed. Which specific array to be used is determined by the <symbol>
  134. X<symbol> if a 'm' or 'M' then a mirror should be displayed, if it is '*'
  135. Xand array > 0 then a nova should be displayed else it is a normal orbit map.
  136. XAlso, <symbol> will contain a ship letter if the data here is a ship
  137. Xand <stand1> and <stand2> will a positive number if the player owns the ship.
  138. X<stand2> is whether the planet has population of the player on it.
  139. X
  140. XStandard convention is to highlight the symbol if the planet has been
  141. Xowned, and highlight the name if the player has colonized the planet.
  142. X(ie, highlight symbol if <stand1> and name if <stand2>)
  143. X
  144. XExample:
  145. X#1 100 100 0 * 1 Minos;1 93 104 0 o 0 Earth;1 90 90 0 D 1 456;
  146. X
  147. XA star (*) named Minos is not undergoing a nova (since array is 0)
  148. Xand is located at coords 100,100. The player has 'knowledge' of the
  149. Xtype (stand1) and 'owns' the star (meaning popn in the system) (stand2).
  150. XNext is a planet Earth (o) located at 93,104 which the player has
  151. Xexplored (1 for stand1) but does not have popn on (stand2 is 0). The
  152. Xarray has no meaning here so is 0.
  153. XThe last field is a ship (D) located at 90,90 owned by the player
  154. X(stand1 and stand2 are 1). Again, array of 0 has no meaning. And the
  155. Xship is #456 (as specified in the name spot).
  156. X
  157. X------------------------------------------------------------------------
  158. XThe other client server protocols follow the | <number> convention
  159. Xoutlined above.
  160. X
  161. X------------------------------------------------------------------------
  162. XCommand name: client_survey
  163. XResponse Range: 101-103
  164. XInput formats:
  165. X    client_survey -                    (101-103)
  166. X    client_survey minx[:maxx],miny[:maxy]        (102-103)
  167. X
  168. XThe - will request ALL sectors. That is, client_survey 0:MAXX,0:MAXY.
  169. X
  170. XOutput formats:
  171. X101 format: "| 101 %d %d %s %s %d %d %d %d %d %d %lf %d"
  172. X| 101 <maxX> <maxY> <star name> <planet name> <res> <fuel> <des> <popn>
  173. X<max popn> <toxicity> <compat %> <enslaved>
  174. XmaxX:        int        width of planet
  175. XmaxY:        int        height of planet
  176. Xstar name:    word        char * of star name
  177. Xplanet name:    word        char * of planet name
  178. Xres:        int        amt of res on planet
  179. Xfuel:        int        amt of fuel on planet
  180. Xdes:        int        amt of des on planet
  181. Xpopn:        int        amt of popn on planet
  182. Xmax popn:    int        amt of max popn for planet
  183. Xtoxicity:    int        current toxicity of planet
  184. Xcompat %:    double        % compat with planet
  185. Xenslaved:    boolen        is planet enslaved.
  186. X
  187. X102 format: "| 102 %d %d %c %c %d %d %d %d %d %d %d %d %d %d"
  188. X| 102 <x> <y> <sectc> <des> <wasted> <own> <eff> <frt> <mob> <xtal> <res> <civ> <mil> <mpopn>
  189. Xx:        int        x of sector
  190. Xy:        int        y of sector (x,y)
  191. Xsectc:        char        type of sector #^*)-o.
  192. Xdes:        char        server description. could be mil/ship ltr
  193. Xwasted:        boolean        is sector wasted.
  194. Xown:        int        player#
  195. Xeff:        int        eff%
  196. Xfrt:        int        frt in sector
  197. Xmob:        int        mobility of sector
  198. Xxtal:        boolean        is sector xtal.        
  199. Xres:        int        res in sector
  200. Xciv:        int        # civ on sector
  201. Xmil:        int        # mil on sector
  202. Xmax popn:    int        max popn for sector
  203. X
  204. X103 format: "| 103"
  205. X| 103
  206. X103 has NO arguments. It is END OF COMMAND.
  207. X------------------------------------------------------------------------
  208. X
  209. END_OF_FILE
  210. if test 6911 -ne `wc -c <'doc/CLIENT_PROTOCOL'`; then
  211.     echo shar: \"'doc/CLIENT_PROTOCOL'\" unpacked with wrong size!
  212. fi
  213. # end of 'doc/CLIENT_PROTOCOL'
  214. fi
  215. if test -f 'hdrs/config.h' -a "${1}" != "-c" ; then 
  216.   echo shar: Will not clobber existing file \"'hdrs/config.h'\"
  217. else
  218. echo shar: Extracting \"'hdrs/config.h'\" \(6484 characters\)
  219. sed "s/^X//" >'hdrs/config.h' <<'END_OF_FILE'
  220. X/* config.h
  221. X * This file was produced by running the config.h.SH script, which
  222. X * gets its values from config.sh, which is generally produced by
  223. X * running Configure.
  224. X *
  225. X * Feel free to modify any of this as the need arises.  Note, however,
  226. X * that running config.h.SH again will wipe out any changes you've made.
  227. X * For a more permanent change edit config.sh and rerun config.h.SH.
  228. X */
  229. X
  230. X /*  CONFIG.H FILE FOR GB+ Version 1 JPD 12.10.92 */
  231. X
  232. X/* BIN:
  233. X *    This symbol holds the name of the directory in which the user wants
  234. X *    to put publicly executable images for the package in question.  It
  235. X *    is most often a local directory such as /usr/local/bin.
  236. X */
  237. X#define BIN ""             /**/
  238. X
  239. X/* BYTEORDER:
  240. X *    This symbol contains an encoding of the order of bytes in a long.
  241. X *    Usual values (in octal) are 01234, 04321, 02143, 03412...
  242. X */
  243. X#define BYTEORDER 0x4321        /**/
  244. X
  245. X/* CPPSTDIN:
  246. X *    This symbol contains the first part of the string which will invoke
  247. X *    the C preprocessor on the standard input and produce to standard
  248. X *    output.     Typical value of "cc -E" or "/lib/cpp".
  249. X */
  250. X/* CPPMINUS:
  251. X *    This symbol contains the second part of the string which will invoke
  252. X *    the C preprocessor on the standard input and produce to standard
  253. X *    output.  This symbol will have the value "-" if CPPSTDIN needs a minus
  254. X *    to specify standard input, otherwise the value is "".
  255. X */
  256. X#define CPPSTDIN "/usr/lib/cpp"
  257. X#define CPPMINUS ""
  258. X
  259. X/* GETOPT:
  260. X *    This symbol, if defined, indicates that the getopt() routine exists.
  261. X */
  262. X#define    GETOPT        /**/
  263. X
  264. X/* HOSTNAME:
  265. X *    This symbol contains name of the host the program is going to run on.
  266. X *    The domain is not kept with hostname, but must be gotten from MYDOMAIN.
  267. X *    The dot comes with MYDOMAIN, and need not be supplied by the program.
  268. X *    If gethostname() or uname() exist, HOSTNAME may be ignored.
  269. X */
  270. X/* MYDOMAIN:
  271. X *    This symbol contains the domain of the host the program is going to
  272. X *    run on.  The domain must be appended to HOSTNAME to form a complete
  273. X *    host name.  The dot comes with MYDOMAIN, and need not be supplied by
  274. X *    the program.  If the host name is derived from PHOSTNAME, the domain
  275. X *    may or may not already be there, and the program should check.
  276. X */
  277. X/* GB_HOST:
  278. X *    The full qualified hostname and domainname of the GB server
  279. X */
  280. X/* GB_PORT:
  281. X *  This symbol contains the port number that GB will run on.
  282. X */
  283. X#define HOSTNAME "harpo"        /**/
  284. X#define MYDOMAIN "nyu.edu"        /**/
  285. X
  286. X#define GB_HOST  "harpo.cims"        /**/
  287. X#define GB_PORT  2010            /**/
  288. X
  289. X
  290. X/*
  291. X * THRESHLOADING:
  292. X *   Use the threshloading code?
  293. X */
  294. X#define THRESHLOADING /**/
  295. X
  296. X/*
  297. X * AUTOSCRAP:
  298. X *   Use the autoscrap code?
  299. X */
  300. X#define AUTOSCRAP /**/
  301. X
  302. X/* 
  303. X * SUPERPODS:
  304. X *   Use superpods (cost 9r Success 75%)
  305. X */
  306. X/*#undef SUPER_PODS /**/
  307. X
  308. X/*
  309. X * SPORE_SUCCESS_RATE:
  310. X *   Chance of spore survial.  (was in tweakables.h before 
  311. X */
  312. X#define SPORE_SUCCESS_RATE 25
  313. X
  314. X/* 
  315. X * MULTIPLE_COMM_CHANNELS:
  316. X *   Use 3 communications channels instead of 1
  317. X */
  318. X/*#undef MULTIPLE_COMM_CHANNELS /**/
  319. X
  320. X/* MAX_LOGSIZE:
  321. X
  322. X/* MAX_LOGSIZE:
  323. X *  Size in bytes of the log when it truncates
  324. X */
  325. X#define MAX_LOGSIZE 100000  /**/
  326. X/* I_TIME:
  327. X *    This symbol is defined if the program should include <time.h>.
  328. X */
  329. X/* I_SYSTIME:
  330. X *    This symbol is defined if the program should include <sys/time.h>.
  331. X */
  332. X/* I_SYSTIMEKERNEL:
  333. X *    This symbol is defined if the program should include <sys/time.h>
  334. X *    with KERNEL defined.
  335. X */
  336. X/*#undef        I_TIME         /**/
  337. X#define    I_SYSTIME     /**/
  338. X/*#undef    SYSTIMEKERNEL     /**/
  339. X
  340. X/* CONFIGURE_DATE
  341. X *    This symbol contains the last date that configure was run for Gb -v output.
  342. X */
  343. X#define        CONFIGURE_DATE    "02/01/93 05:55"
  344. X#define       VERS            "02/01/93 05:55"
  345. X
  346. X/* XENIX:
  347. X *    This symbol, if defined, indicates this is a Xenix system,
  348. X *    for knocking  out the far keyword in selected places.
  349. X */
  350. X/* BSD:
  351. X *    This symbol, if defined, indicates this is a BSD type system,
  352. X */
  353. X/*#undef    XENIX    /**/
  354. X#define    BSD    /**/
  355. X
  356. X/* ------------------------------------------------ */
  357. X/* Below are the variables not changed by configure */
  358. X/*   You should not modify these unless you know    */
  359. X/*                 you are doing!!                  */
  360. X/* ------------------------------------------------ */
  361. X
  362. X/* COMMAND_TIME_MSEC    
  363. X *  The time slice lenght in milliseconds
  364. X */
  365. X#define COMMAND_TIME_MSEC      250
  366. X
  367. X/* COMMANDS_PER_TIME
  368. X *  Commands per time slice after burst 
  369. X */
  370. X#define COMMANDS_PER_TIME       1
  371. X
  372. X/* COMMAND_BURST_SIZE    
  373. X *  Commands allowed per user in a burst
  374. X */
  375. X#define COMMAND_BURST_SIZE        250
  376. X
  377. X/* DISCONNECT_TIME 
  378. X *  Maximum idle time
  379. X */
  380. X#define DISCONNECT_TIME            7200
  381. X
  382. X/* MAX_OUTPUT
  383. X *  ?????
  384. X */
  385. X#define MAX_OUTPUT                32768
  386. X
  387. X/* QUIT_COMMAND
  388. X * WHO_COMMAND 
  389. X * HELP_COMMAND
  390. X * EMULATE_COMMAND
  391. X */
  392. X#define QUIT_COMMAND             "quit"
  393. X#define WHO_COMMAND                "who"
  394. X#define HELP_COMMAND            "help"
  395. X#define EMULATE_COMMAND            "emulate"
  396. X
  397. X/* WELCOME_FILE
  398. X * HELP_FILE
  399. X * LEAVE_MESSAGE
  400. X */
  401. X#define WELCOME_FILE    "welcome.txt"
  402. X#define HELP_FILE       "help.txt"
  403. X#define LEAVE_MESSAGE   "\n*** Thank you for playing Galactic Bloodshed ***\n"
  404. X
  405. X/* EXTERNAL_TRIGGER 
  406. X *  Used in the older versions with GB_daemon
  407. X */
  408. X/*define EXTERNAL_TRIGGER /* if you wish to allow the below passwords to
  409. X                             trigger updates and movement segments */
  410. X#ifdef EXTERNAL_TRIGGER
  411. X#define UPDATE_PASSWORD         "put_your_update_password_here"
  412. X#define SEGMENT_PASSWORD        "put_your_segment_password_here"
  413. X#endif
  414. X
  415. X/* DEBUG 
  416. X *  Uncomment if you want to use memory debugging
  417. X */
  418. X/* #define DEBUG  */
  419. X
  420. X/* MARKET
  421. X * comment out if you dont want the market
  422. X */
  423. X#define MARKET 
  424. X
  425. X/* VICTORY
  426. X *  if you want to use victory conditions
  427. X */
  428. X/* #define VICTORY */
  429. X
  430. X/* DISSOLVE
  431. X *  If you want to allow players to dissolve mid-game 
  432. X *  CAUTION: THIS CAN CORRUPT THE DATABASE
  433. X */
  434. X/*#define DISSOLVE  */
  435. X
  436. X/* DEFENSE 
  437. X *  If you want to allow planetary defenses
  438. X */
  439. X#define DEFENSE 
  440. X
  441. X/* VOTING
  442. X *  If you want the voting code 
  443. X */
  444. X#define VOTING 
  445. X
  446. X/* ACCESS_CHECK
  447. X *  If you want the access-checking code
  448. X */
  449. X/*#define ACCESS_CHECK */
  450. X
  451. X/* NOMANDS
  452. X *  If you want to allow min # of sexes to always colonize
  453. X */
  454. X/*#define NOMADS */
  455. X
  456. X/* MONITOR 
  457. X *  allows deity to monitor messages etc (deity can set with
  458. X * 'toggle monitor' option. I use it to watch battles in progress.
  459. X */
  460. X#define MONITOR
  461. X
  462. X/* SHOW_COWARDS
  463. X * If you want the number of invisible players to be shown to other players 
  464. X */
  465. X#define SHOW_COWARDS
  466. X
  467. X/* POD_TERRAFORM
  468. X *  If pods will terraform sectors they infect 
  469. X */
  470. X/* #define POD_TERRAFORM */
  471. X
  472. X/* END OF CONFIG.H */
  473. END_OF_FILE
  474. if test 6484 -ne `wc -c <'hdrs/config.h'`; then
  475.     echo shar: \"'hdrs/config.h'\" unpacked with wrong size!
  476. fi
  477. # end of 'hdrs/config.h'
  478. fi
  479. if test -f 'hdrs/config.h.SH' -a "${1}" != "-c" ; then 
  480.   echo shar: Will not clobber existing file \"'hdrs/config.h.SH'\"
  481. else
  482. echo shar: Extracting \"'hdrs/config.h.SH'\" \(6925 characters\)
  483. sed "s/^X//" >'hdrs/config.h.SH' <<'END_OF_FILE'
  484. Xcase $CONFIG in
  485. X'')
  486. X    if test ! -f config.sh; then
  487. X    ln ../config.sh . || \
  488. X    ln ../../config.sh . || \
  489. X    ln ../../../config.sh . || \
  490. X    (echo "Can't find config.sh."; exit 1)
  491. X    echo "Using config.sh from above..."
  492. X    fi
  493. X    . ./config.sh
  494. X    ;;
  495. Xesac
  496. Xecho "Extracting config.h (with variable substitutions)"
  497. Xsed <<!GROK!THIS! >config.h -e 's!^#undef!/\*#undef!'
  498. X/* config.h
  499. X * This file was produced by running the config.h.SH script, which
  500. X * gets its values from config.sh, which is generally produced by
  501. X * running Configure.
  502. X *
  503. X * Feel free to modify any of this as the need arises.  Note, however,
  504. X * that running config.h.SH again will wipe out any changes you've made.
  505. X * For a more permanent change edit config.sh and rerun config.h.SH.
  506. X */
  507. X
  508. X /*  CONFIG.H FILE FOR GB+ Version 1 JPD 12.10.92 */
  509. X
  510. X/* BIN:
  511. X *    This symbol holds the name of the directory in which the user wants
  512. X *    to put publicly executable images for the package in question.  It
  513. X *    is most often a local directory such as /usr/local/bin.
  514. X */
  515. X#define BIN "$bin"             /**/
  516. X
  517. X/* BYTEORDER:
  518. X *    This symbol contains an encoding of the order of bytes in a long.
  519. X *    Usual values (in octal) are 01234, 04321, 02143, 03412...
  520. X */
  521. X#define BYTEORDER 0x$byteorder        /**/
  522. X
  523. X/* CPPSTDIN:
  524. X *    This symbol contains the first part of the string which will invoke
  525. X *    the C preprocessor on the standard input and produce to standard
  526. X *    output.     Typical value of "cc -E" or "/lib/cpp".
  527. X */
  528. X/* CPPMINUS:
  529. X *    This symbol contains the second part of the string which will invoke
  530. X *    the C preprocessor on the standard input and produce to standard
  531. X *    output.  This symbol will have the value "-" if CPPSTDIN needs a minus
  532. X *    to specify standard input, otherwise the value is "".
  533. X */
  534. X#define CPPSTDIN "$cppstdin"
  535. X#define CPPMINUS "$cppminus"
  536. X
  537. X/* GETOPT:
  538. X *    This symbol, if defined, indicates that the getopt() routine exists.
  539. X */
  540. X#$d_getopt    GETOPT        /**/
  541. X
  542. X/* HOSTNAME:
  543. X *    This symbol contains name of the host the program is going to run on.
  544. X *    The domain is not kept with hostname, but must be gotten from MYDOMAIN.
  545. X *    The dot comes with MYDOMAIN, and need not be supplied by the program.
  546. X *    If gethostname() or uname() exist, HOSTNAME may be ignored.
  547. X */
  548. X/* MYDOMAIN:
  549. X *    This symbol contains the domain of the host the program is going to
  550. X *    run on.  The domain must be appended to HOSTNAME to form a complete
  551. X *    host name.  The dot comes with MYDOMAIN, and need not be supplied by
  552. X *    the program.  If the host name is derived from PHOSTNAME, the domain
  553. X *    may or may not already be there, and the program should check.
  554. X */
  555. X/* GB_HOST:
  556. X *    The full qualified hostname and domainname of the GB server
  557. X */
  558. X/* GB_PORT:
  559. X *  This symbol contains the port number that GB will run on.
  560. X */
  561. X#define HOSTNAME "$hostname"        /**/
  562. X#define MYDOMAIN "$mydomain"        /**/
  563. X
  564. X#define GB_HOST  "$host"        /**/
  565. X#define GB_PORT  $port            /**/
  566. X
  567. X
  568. X/*
  569. X * THRESHLOADING:
  570. X *   Use the threshloading code?
  571. X */
  572. X#$d_threshloading THRESHLOADING /**/
  573. X
  574. X/*
  575. X * AUTOSCRAP:
  576. X *   Use the autoscrap code?
  577. X */
  578. X#$d_autoscrap AUTOSCRAP /**/
  579. X
  580. X/* 
  581. X * SUPERPODS:
  582. X *   Use superpods (cost 9r Success 75%)
  583. X */
  584. X#$d_superpod SUPER_PODS /**/
  585. X
  586. X/*
  587. X * SPORE_SUCCESS_RATE:
  588. X *   Chance of spore survial.  (was in tweakables.h before 
  589. X */
  590. X#define SPORE_SUCCESS_RATE $spore_success_rate
  591. X
  592. X/* 
  593. X * MULTIPLE_COMM_CHANNELS:
  594. X *   Use 3 communications channels instead of 1
  595. X */
  596. X#$d_multi_comm MULTIPLE_COMM_CHANNELS /**/
  597. X
  598. X/* MAX_LOGSIZE:
  599. X
  600. X/* MAX_LOGSIZE:
  601. X *  Size in bytes of the log when it truncates
  602. X */
  603. X#define MAX_LOGSIZE $maxlogsize  /**/
  604. X/* I_TIME:
  605. X *    This symbol is defined if the program should include <time.h>.
  606. X */
  607. X/* I_SYSTIME:
  608. X *    This symbol is defined if the program should include <sys/time.h>.
  609. X */
  610. X/* I_SYSTIMEKERNEL:
  611. X *    This symbol is defined if the program should include <sys/time.h>
  612. X *    with KERNEL defined.
  613. X */
  614. X#$i_time        I_TIME         /**/
  615. X#$i_systime    I_SYSTIME     /**/
  616. X#$d_systimekernel    SYSTIMEKERNEL     /**/
  617. X
  618. X/* CONFIGURE_DATE
  619. X *    This symbol contains the last date that configure was run for Gb -v output.
  620. X */
  621. X#define        CONFIGURE_DATE    "$c_date"
  622. X#define       VERS            "$c_date"
  623. X
  624. X/* XENIX:
  625. X *    This symbol, if defined, indicates this is a Xenix system,
  626. X *    for knocking  out the far keyword in selected places.
  627. X */
  628. X/* BSD:
  629. X *    This symbol, if defined, indicates this is a BSD type system,
  630. X */
  631. X#$d_xenix    XENIX    /**/
  632. X#$d_bsd    BSD    /**/
  633. X
  634. X/* ------------------------------------------------ */
  635. X/* Below are the variables not changed by configure */
  636. X/*   You should not modify these unless you know    */
  637. X/*                 you are doing!!                  */
  638. X/* ------------------------------------------------ */
  639. X
  640. X/* COMMAND_TIME_MSEC    
  641. X *  The time slice lenght in milliseconds
  642. X */
  643. X#define COMMAND_TIME_MSEC      250
  644. X
  645. X/* COMMANDS_PER_TIME
  646. X *  Commands per time slice after burst 
  647. X */
  648. X#define COMMANDS_PER_TIME       1
  649. X
  650. X/* COMMAND_BURST_SIZE    
  651. X *  Commands allowed per user in a burst
  652. X */
  653. X#define COMMAND_BURST_SIZE        250
  654. X
  655. X/* DISCONNECT_TIME 
  656. X *  Maximum idle time
  657. X */
  658. X#define DISCONNECT_TIME            7200
  659. X
  660. X/* MAX_OUTPUT
  661. X *  ?????
  662. X */
  663. X#define MAX_OUTPUT                32768
  664. X
  665. X/* QUIT_COMMAND
  666. X * WHO_COMMAND 
  667. X * HELP_COMMAND
  668. X * EMULATE_COMMAND
  669. X */
  670. X#define QUIT_COMMAND             "quit"
  671. X#define WHO_COMMAND                "who"
  672. X#define HELP_COMMAND            "help"
  673. X#define EMULATE_COMMAND            "emulate"
  674. X
  675. X/* WELCOME_FILE
  676. X * HELP_FILE
  677. X * LEAVE_MESSAGE
  678. X */
  679. X#define WELCOME_FILE    "welcome.txt"
  680. X#define HELP_FILE       "help.txt"
  681. X#define LEAVE_MESSAGE   "\n*** Thank you for playing Galactic Bloodshed ***\n"
  682. X
  683. X/* EXTERNAL_TRIGGER 
  684. X *  Used in the older versions with GB_daemon
  685. X */
  686. X/*define EXTERNAL_TRIGGER /* if you wish to allow the below passwords to
  687. X                             trigger updates and movement segments */
  688. X#ifdef EXTERNAL_TRIGGER
  689. X#define UPDATE_PASSWORD         "put_your_update_password_here"
  690. X#define SEGMENT_PASSWORD        "put_your_segment_password_here"
  691. X#endif
  692. X
  693. X/* DEBUG 
  694. X *  Uncomment if you want to use memory debugging
  695. X */
  696. X/* #define DEBUG  */
  697. X
  698. X/* MARKET
  699. X * comment out if you dont want the market
  700. X */
  701. X#define MARKET 
  702. X
  703. X/* VICTORY
  704. X *  if you want to use victory conditions
  705. X */
  706. X/* #define VICTORY */
  707. X
  708. X/* DISSOLVE
  709. X *  If you want to allow players to dissolve mid-game 
  710. X *  CAUTION: THIS CAN CORRUPT THE DATABASE
  711. X */
  712. X/*#define DISSOLVE  */
  713. X
  714. X/* DEFENSE 
  715. X *  If you want to allow planetary defenses
  716. X */
  717. X#define DEFENSE 
  718. X
  719. X/* VOTING
  720. X *  If you want the voting code 
  721. X */
  722. X#define VOTING 
  723. X
  724. X/* ACCESS_CHECK
  725. X *  If you want the access-checking code
  726. X */
  727. X/*#define ACCESS_CHECK */
  728. X
  729. X/* NOMANDS
  730. X *  If you want to allow min # of sexes to always colonize
  731. X */
  732. X/*#define NOMADS */
  733. X
  734. X/* MONITOR 
  735. X *  allows deity to monitor messages etc (deity can set with
  736. X * 'toggle monitor' option. I use it to watch battles in progress.
  737. X */
  738. X#define MONITOR
  739. X
  740. X/* SHOW_COWARDS
  741. X * If you want the number of invisible players to be shown to other players 
  742. X */
  743. X#define SHOW_COWARDS
  744. X
  745. X/* POD_TERRAFORM
  746. X *  If pods will terraform sectors they infect 
  747. X */
  748. X/* #define POD_TERRAFORM */
  749. X
  750. X/* END OF CONFIG.H */
  751. X!GROK!THIS!
  752. END_OF_FILE
  753. if test 6925 -ne `wc -c <'hdrs/config.h.SH'`; then
  754.     echo shar: \"'hdrs/config.h.SH'\" unpacked with wrong size!
  755. fi
  756. # end of 'hdrs/config.h.SH'
  757. fi
  758. if test -f 'hdrs/racegen.h' -a "${1}" != "-c" ; then 
  759.   echo shar: Will not clobber existing file \"'hdrs/racegen.h'\"
  760. else
  761. echo shar: Extracting \"'hdrs/racegen.h'\" \(7169 characters\)
  762. sed "s/^X//" >'hdrs/racegen.h' <<'END_OF_FILE'
  763. X/* racegen.h - defined values and datatypes for racegen
  764. X * Copyright (c) Leonard Dickens 1991   (leonard@cs.umd.edu)
  765. X *
  766. X * Permission to copy, distribute, and/or alter is granted as long as the copy-
  767. X * right notice and these terms are left unchanged in all derivatives/copies.
  768. X * 
  769. X * Anybody who does alter this program, please take credit!
  770. X */
  771. X#include <stdio.h>
  772. X#define GBVERSION "1.5.3"
  773. X
  774. X/**************
  775. X * Game dependencies.  This file should be gotten from the net, whenever
  776. X * a new game is announced.  It contains #defines for addresses, number
  777. X * of points, and other such stuff that may vary from game to game.
  778. X *
  779. X * Look for a later version of this program where all of this information
  780. X * is read in at run-time.  Recompiling racegen for each new game is klunky.
  781. X */
  782. X#include "game_info.h"
  783. X
  784. X/**************
  785. X * This #define is used to compile the code in this program needed for the
  786. X * enroll program.  Unless you are a game-god, you will never need to use it.
  787. X */
  788. X#ifdef ENROLL
  789. X#define IS_PLAYER 0
  790. X#else
  791. X#define IS_PLAYER 1
  792. X#endif
  793. X
  794. X/**************
  795. X * System dependencies.  These will likely not change much.
  796. X */
  797. X#define MAILER     "/usr/lib/sendmail"
  798. X#define SAVETO     "racegen.save"
  799. X#define TMP        "/tmp/racegen.save"
  800. X
  801. X
  802. X/**************
  803. X * Other stuff.
  804. X */
  805. X#define START_RECORD_STRING "<************"
  806. X#define END_RECORD_STRING "************>"
  807. X#define min(x, y) (((x) < (y)) ? (x) : (y))
  808. X
  809. X#ifdef __STDC__
  810. Xdouble atof(char *nptr) ;
  811. X
  812. Xvoid bcopy(void *src, void *dst, int length) ;
  813. Xvoid bzero(void *b, int length) ;
  814. X
  815. Xint fclose(FILE *stream) ;
  816. Xint fflush(FILE *stream) ;
  817. X
  818. Xint fprintf(FILE *f, const char *format, ...) ;
  819. Xint fscanf(FILE *f, const char *format, ...) ;
  820. Xint printf(const char *format, ...) ;
  821. X
  822. Xint strncasecmp(const char *s1, const char *s2, int len) ;
  823. X
  824. Xvoid exit(int status) ;
  825. Xint system(const char *string) ;
  826. X
  827. X#else
  828. Xdouble atof() ;
  829. X#define const
  830. Xint Dialogue() ;
  831. X#endif
  832. X
  833. X
  834. X
  835. X/**************
  836. X * Attributes, attribute names, and parameters for attribute costs.
  837. X */
  838. X#define FIRST_ATTRIBUTE 0
  839. X#define ADVENT FIRST_ATTRIBUTE
  840. X#define ABSORB (ADVENT+1)
  841. X#define BIRTH  (ABSORB+1)
  842. X#define COL_IQ (BIRTH +1)
  843. X#define FERT   (COL_IQ+1)
  844. X#define A_IQ   (FERT  +1)
  845. X#define FIGHT  (A_IQ  +1)
  846. X#define PODS   (FIGHT +1)
  847. X#define MASS   (PODS  +1)
  848. X#define SEXES  (MASS  +1)
  849. X#define METAB  (SEXES +1)
  850. X#define LAST_ATTRIBUTE (METAB)
  851. X#define N_ATTRIBUTES (LAST_ATTRIBUTE+1)
  852. X
  853. Xtypedef struct {
  854. X  int number ;
  855. X  char print_name[16] ;
  856. X  double e_factor, e_fudge, e_hinge, l_factor, l_fudge ;
  857. X  double minimum, init, maximum ;
  858. X  double cov[N_ATTRIBUTES] ;
  859. X  int is_integral ;
  860. X  } attribute ;
  861. X
  862. X#define ATTR_RANGE(a) (attr[a].maximum - attr[a].minimum)
  863. X
  864. X
  865. X/* The formula for determining the price of any particular attribute
  866. X * is as follows:
  867. X *   exp( (e_fudge * (attribute - e_hinge) )) * e_factor 
  868. X *     + attribute * l_factor + l_fudge
  869. X * This allows great flexibility in generating functions for 
  870. X * attribute costs.      */
  871. X
  872. X/* Increasing an attribute's e_factor will raise the cost of the attribute
  873. X * everywhere (since exp(x)>0 forall x); however, it raises the cost quite
  874. X * disproportionately.  If a correponding decrease in l_fudge is made, this
  875. X * will have little effect on the cost to buy an attribute below the hinge 
  876. X * point, but will have a strong effect on the cost above the hinge.     */
  877. X
  878. X/* Increasing an attribute's e_fudge will have the effect of driving the cost
  879. X * of attributes below the hinge down (slightly), and driving the cost of 
  880. X * attributes above the hinge significantly higher.     */
  881. X
  882. X/* An attribute's e_hinge is the point is that the exponential "takes off";
  883. X * that is, the exponential will have a small effect on the cost for an
  884. X * attribute below this value, but will have a much larger impact for 
  885. X * those over this value.      */
  886. X
  887. X/* An attribute's l_factor (linear factor) allows you to increase the
  888. X * cost over the whole range of the attribute, in a smoothly increasing (or 
  889. X * decreasing) way.      */
  890. X
  891. X/* The l_fudge value is a constant adjustment to the cost of an attribute.  
  892. X * It is used to get the init value of an attribute to cost zero.    
  893. X * It is set automatically at startup, so don't bother to mess with it.    */
  894. X
  895. X
  896. X
  897. X
  898. X
  899. X/**************
  900. X * Home planet types, names, and costs.
  901. X */
  902. X#define FIRST_HOME_PLANET_TYPE 0
  903. X#define H_EARTH   FIRST_HOME_PLANET_TYPE
  904. X#define H_FOREST  (H_EARTH+1)
  905. X#define H_DESERT  (H_FOREST+1)
  906. X#define H_WATER   (H_DESERT+1)
  907. X#define H_AIRLESS (H_WATER+1)
  908. X#define H_ICEBALL (H_AIRLESS+1)
  909. X#define H_JOVIAN  (H_ICEBALL+1)
  910. X#define LAST_HOME_PLANET_TYPE H_JOVIAN
  911. X#define N_HOME_PLANET_TYPES (LAST_HOME_PLANET_TYPE+1)
  912. X
  913. Xextern const char *planet_print_name[N_HOME_PLANET_TYPES] ;
  914. Xextern const int planet_cost[N_HOME_PLANET_TYPES] ;
  915. X
  916. X
  917. X
  918. X/**************
  919. X * Race types, names, and costs
  920. X */
  921. X#define FIRST_RACE_TYPE 0
  922. X#define R_NORMAL        FIRST_RACE_TYPE
  923. X#define R_METAMORPH     (R_NORMAL+1)
  924. X#define LAST_RACE_TYPE  R_METAMORPH
  925. X#define N_RACE_TYPES    (LAST_RACE_TYPE+1)
  926. X
  927. Xextern const char *race_print_name[N_RACE_TYPES] ;
  928. Xextern const int race_cost[N_RACE_TYPES] ;
  929. X
  930. X
  931. X
  932. X/**************
  933. X * Type of privileges this race will have:
  934. X */
  935. X#define FIRST_PRIV_TYPE 0
  936. X#define P_GOD           (FIRST_PRIV_TYPE)
  937. X#define P_GUEST         (P_GOD+1)
  938. X#define P_NORMAL        (P_GUEST+1)
  939. X#define LAST_PRIV_TYPE  (P_NORMAL)
  940. X#define N_PRIV_TYPES    (LAST_PRIV_TYPE+1)
  941. X
  942. Xextern const char *priv_print_name[N_PRIV_TYPES] ;
  943. X
  944. X
  945. X
  946. X/**************
  947. X * Sector types and names.  Sector costs are hardwired in currently.
  948. X */
  949. X#define FIRST_SECTOR_TYPE 0
  950. X#define S_WATER    FIRST_SECTOR_TYPE
  951. X#define S_LAND     (S_WATER+1)
  952. X#define S_MOUNTAIN (S_LAND+1)
  953. X#define S_GAS      (S_MOUNTAIN+1)
  954. X#define S_ICE      (S_GAS+1)
  955. X#define S_FOREST   (S_ICE+1)
  956. X#define S_DESERT   (S_FOREST+1)
  957. X#define S_PLATED   (S_DESERT+1)
  958. X#define LAST_SECTOR_TYPE S_PLATED
  959. X#define N_SECTOR_TYPES (LAST_SECTOR_TYPE+1)
  960. X
  961. Xextern const char *sector_print_name[N_SECTOR_TYPES] ;
  962. Xconst int n_sector_types_cost[N_SECTOR_TYPES] ;
  963. X
  964. X
  965. X/*
  966. X * The covariance between two sectors is:
  967. X *   actual_cost(a1) = base_cost(a1) * 
  968. X *                      (1 + cov[a1][a2] * (a2 - cov[a1][a2].fudge)) ;
  969. X */
  970. Xextern const double compat_cov[N_SECTOR_TYPES][N_SECTOR_TYPES] ;
  971. Xextern const double planet_compat_cov[N_HOME_PLANET_TYPES][N_SECTOR_TYPES] ;
  972. X
  973. X#define STATUS_ENROLLED     -2
  974. X#define STATUS_UNENROLLABLE -1
  975. X#define STATUS_UNBALANCED    0
  976. X#define STATUS_BALANCED      1
  977. X
  978. X/**************
  979. X * Structure for holding information about a race.
  980. X */
  981. Xstruct x {
  982. X  char address[64] ;              /* Person who this is from, or going to. */
  983. X  char filename[64] ;
  984. X  char name[64] ;
  985. X  char password[64] ;
  986. X  char rejection[256] ;           /* Error if this is non-"" */
  987. X  char status ;
  988. X
  989. X  double attr[N_ATTRIBUTES] ;
  990. X  int race_type ;
  991. X  int priv_type ;
  992. X  int home_planet_type ;
  993. X  int n_sector_types ;
  994. X  double compat[N_SECTOR_TYPES] ;
  995. X  } ;
  996. X
  997. X
  998. X
  999. X/**************
  1000. X * Global variables for this program.
  1001. X */
  1002. Xextern struct x race, cost, last ;
  1003. X
  1004. Xextern int npoints ;
  1005. Xextern int last_npoints ;
  1006. Xextern int altered ;   /* 1 iff race has been altered since last saved */
  1007. Xextern int changed ;   /* 1 iff race has been changed since last printed */
  1008. Xextern int please_quit ;   /* 1 iff you want to exit ASAP. */
  1009. END_OF_FILE
  1010. if test 7169 -ne `wc -c <'hdrs/racegen.h'`; then
  1011.     echo shar: \"'hdrs/racegen.h'\" unpacked with wrong size!
  1012. fi
  1013. # end of 'hdrs/racegen.h'
  1014. fi
  1015. if test -f 'user/map.c' -a "${1}" != "-c" ; then 
  1016.   echo shar: Will not clobber existing file \"'user/map.c'\"
  1017. else
  1018. echo shar: Extracting \"'user/map.c'\" \(6953 characters\)
  1019. sed "s/^X//" >'user/map.c' <<'END_OF_FILE'
  1020. X/*
  1021. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  1022. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  1023. X * GB_copyright.h.
  1024. X * 
  1025. X * map.c -- display sector map of current planet
  1026. X */
  1027. X
  1028. X#define DISP_DATA 1
  1029. X
  1030. X#include "GB_copyright.h"
  1031. X#define EXTERN extern
  1032. X#include "vars.h"
  1033. X#include "ships.h"
  1034. X#include "races.h"
  1035. X#include "power.h"
  1036. X#include "buffers.h"
  1037. X#include <curses.h>
  1038. X
  1039. Xracetype       *Race;
  1040. Xextern char    *Planet_types[];
  1041. X
  1042. Xvoid            map(int, int, int);
  1043. Xvoid            show_map(int, int, int, int, planettype *, int, int);
  1044. Xchar            desshow(int, int, planettype *, int, int, racetype *);
  1045. X#include "proto.h"
  1046. X
  1047. Xvoid 
  1048. Xmap(int Playernum, int Governor, int APcount)
  1049. X{
  1050. X    planettype     *p;
  1051. X    placetype       where;
  1052. X
  1053. X    where = Getplace(Playernum, Governor, args[1], 0);
  1054. X
  1055. X    if (where.err)
  1056. X        return;
  1057. X    else if (where.level == LEVEL_SHIP) {
  1058. X        notify(Playernum, Governor, "Bad scope.\n");
  1059. X        return;
  1060. X    } else if (where.level == LEVEL_PLAN) {
  1061. X        getplanet(&p, (int) where.snum, (int) where.pnum);
  1062. X        show_map(Playernum, Governor, (int) where.snum, (int) where.pnum,
  1063. X             p, DISP_DATA, 0);
  1064. X        free(p);
  1065. X        if (Stars[where.snum]->stability > 50)
  1066. X            notify(Playernum, Governor, "WARNING! This planet's primary is unstable.\n");
  1067. X    } else
  1068. X        orbit(Playernum, Governor, APcount);    /* make orbit map
  1069. X                             * instead */
  1070. X}
  1071. X
  1072. Xvoid 
  1073. Xshow_map(int Playernum, int Governor, int snum, int pnum, planettype * p,
  1074. X     int show, int iq)
  1075. X{
  1076. X    reg int         x, y, i, f = 0, owner, owned1;
  1077. X    int             sh;
  1078. X    shiptype       *s;
  1079. X    char            shiplocs[MAX_X][MAX_Y];
  1080. X    hugestr         output;
  1081. X
  1082. X    bzero((char *) shiplocs, sizeof(shiplocs));
  1083. X
  1084. X    Race = races[Playernum - 1];
  1085. X    getsmap(Smap, p);
  1086. X    if (!Race->governor[Governor].toggle.geography) {
  1087. X        /*
  1088. X         * traverse ship list on planet; find out if we can look at
  1089. X         * ships here.
  1090. X         */
  1091. X        iq = !!p->info[Playernum - 1].numsectsowned;
  1092. X        sh = p->ships;
  1093. X
  1094. X        while (sh) {
  1095. X            if (!getship(&s, sh)) {
  1096. X                sh = 0;
  1097. X                continue;
  1098. X            }
  1099. X            if (s->owner == Playernum && authorized(Governor, s) &&
  1100. X                (s->popn || (s->type == OTYPE_PROBE)))
  1101. X                iq = 1;
  1102. X            if (s->alive && landed(s))
  1103. X                shiplocs[s->land_x][s->land_y] = Shipltrs[s->type];
  1104. X            sh = s->nextship;
  1105. X            free(s);
  1106. X        }
  1107. X    }
  1108. X    /* report that this is a planet map */
  1109. X    sprintf(output, "$");
  1110. X
  1111. X    sprintf(buf, "%s;", Stars[snum]->pnames[pnum]);
  1112. X    strcat(output, buf);
  1113. X
  1114. X    sprintf(buf, "%d;%d;%d;", p->Maxx, p->Maxy, show);
  1115. X    strcat(output, buf);
  1116. X
  1117. X    /* send map data */
  1118. X    for (y = 0; y < p->Maxy; y++)
  1119. X        for (x = 0; x < p->Maxx; x++) {
  1120. X            owner = Sector(*p, x, y).owner;
  1121. X            owned1 = (owner == Race->governor[Governor].toggle.highlight);
  1122. X            if (shiplocs[x][y] && iq) {
  1123. X                if (Race->governor[Governor].toggle.color)
  1124. X                    sprintf(buf, "%c%c", (char) (owner + '?'), shiplocs[x][y]);
  1125. X                else {
  1126. X                    if (owned1 && Race->governor[Governor].toggle.inverse)
  1127. X                        sprintf(buf, "1%c", shiplocs[x][y]);
  1128. X                    else
  1129. X                        sprintf(buf, "0%c", shiplocs[x][y]);
  1130. X                }
  1131. X            } else {
  1132. X                if (Race->governor[Governor].toggle.color)
  1133. X                    sprintf(buf, "%c%c", (char) (owner + '?'),
  1134. X                        desshow(Playernum, Governor, p, x, y, Race));
  1135. X                else {
  1136. X                    if (owned1 && Race->governor[Governor].toggle.inverse)
  1137. X                        sprintf(buf, "1%c", desshow(Playernum, Governor, p, x, y, Race));
  1138. X                    else
  1139. X                        sprintf(buf, "0%c", desshow(Playernum, Governor, p, x, y, Race));
  1140. X                }
  1141. X            }
  1142. X            strcat(output, buf);
  1143. X        }
  1144. X    strcat(output, "\n");
  1145. X    notify(Playernum, Governor, output);
  1146. X
  1147. X    if (show) {
  1148. X        sprintf(temp, "Type: %8s   Sects %7s: %3u   Aliens:",
  1149. X        Planet_types[p->type], Race->Metamorph ? "covered" : "owned",
  1150. X            p->info[Playernum - 1].numsectsowned);
  1151. X        if (p->explored || Race->tech >= TECH_EXPLORE) {
  1152. X            f = 0;
  1153. X            for (i = 1; i < MAXPLAYERS; i++)
  1154. X                if (p->info[i - 1].numsectsowned && i != Playernum) {
  1155. X                    f = 1;
  1156. X                    sprintf(buf, "%c%d", isset(Race->atwar, i) ? '*' : ' ', i);
  1157. X                    strcat(temp, buf);
  1158. X                }
  1159. X            if (!f)
  1160. X                strcat(temp, "(none)");
  1161. X        } else
  1162. X            strcat(temp, "\?\?\?");
  1163. X        strcat(temp, "\n");
  1164. X        notify(Playernum, Governor, temp);
  1165. X        sprintf(temp, "              Guns : %3d             Mob Points : %d\n",
  1166. X            p->info[Playernum - 1].guns,
  1167. X            p->info[Playernum - 1].mob_points);
  1168. X        notify(Playernum, Governor, temp);
  1169. X        sprintf(temp, "      Mobilization : %3d (%3d)     Compatibility: %.2f%%",
  1170. X            p->info[Playernum - 1].comread,
  1171. X            p->info[Playernum - 1].mob_set,
  1172. X            compatibility(p, Race));
  1173. X        if (p->conditions[TOXIC] > 50) {
  1174. X            sprintf(buf, "    (%d%% TOXIC)", p->conditions[TOXIC]);
  1175. X            strcat(temp, buf);
  1176. X        }
  1177. X        strcat(temp, "\n");
  1178. X        notify(Playernum, Governor, temp);
  1179. X        sprintf(temp, "Resource stockpile : %-9u    Fuel stockpile: %u\n",
  1180. X            p->info[Playernum - 1].resource,
  1181. X            p->info[Playernum - 1].fuel);
  1182. X        notify(Playernum, Governor, temp);
  1183. X        sprintf(temp, "      Destruct cap : %-9u%18s: %-5u (%u/%u)\n",
  1184. X            p->info[Playernum - 1].destruct,
  1185. X           Race->Metamorph ? "Tons of biomass" : "Total Population",
  1186. X            p->info[Playernum - 1].popn, p->popn,
  1187. X            round_rand(.01 * (100. - p->conditions[TOXIC]) * p->maxpopn));
  1188. X        notify(Playernum, Governor, temp);
  1189. X        sprintf(temp, "          Crystals : %-9u%18s: %-5u (%u)\n",
  1190. X            p->info[Playernum - 1].crystals,
  1191. X         "Ground forces", p->info[Playernum - 1].troops, p->troops);
  1192. X        notify(Playernum, Governor, temp);
  1193. X        sprintf(temp, "%d Total Resource Deposits     Tax rate %u%%  New %u%%\n",
  1194. X            p->total_resources, p->info[Playernum - 1].tax,
  1195. X            p->info[Playernum - 1].newtax);
  1196. X        notify(Playernum, Governor, temp);
  1197. X        sprintf(temp, "Estimated Production Next Update : %.2f\n",
  1198. X            p->info[Playernum - 1].est_production);
  1199. X        notify(Playernum, Governor, temp);
  1200. X        if (p->slaved_to) {
  1201. X            sprintf(temp, "      ENSLAVED to player %d\n", p->slaved_to);
  1202. X            notify(Playernum, Governor, temp);
  1203. X        }
  1204. X    }
  1205. X}
  1206. X
  1207. Xchar 
  1208. Xdesshow(int Playernum, int Governor, planettype * p,
  1209. X    int x, int y, racetype * r)
  1210. X{
  1211. X    reg sectortype *s;
  1212. X
  1213. X    s = &Sector(*p, x, y);
  1214. X
  1215. X    if (s->troops && !r->governor[Governor].toggle.geography)
  1216. X        if (s->owner == Playernum)
  1217. X            return CHAR_MY_TROOPS;
  1218. X        else if (isset(r->allied, s->owner))
  1219. X            return CHAR_ALLIED_TROOPS;
  1220. X        else if (isset(r->atwar, s->owner))
  1221. X            return CHAR_ATWAR_TROOPS;
  1222. X        else
  1223. X            return CHAR_NEUTRAL_TROOPS;
  1224. X
  1225. X    if (s->owner && !r->governor[Governor].toggle.geography &&
  1226. X        !r->governor[Governor].toggle.color) {
  1227. X        if (!r->governor[Governor].toggle.inverse ||
  1228. X            s->owner != r->governor[Governor].toggle.highlight)
  1229. X            if (!r->governor[Governor].toggle.double_digits)
  1230. X                return s->owner % 10 + '0';
  1231. X            else {
  1232. X                if (s->owner < 10 || x % 2)
  1233. X                    return s->owner % 10 + '0';
  1234. X                else
  1235. X                    return s->owner / 10 + '0';
  1236. X            }
  1237. X    }
  1238. X    if (s->crystals && (r->discoveries[D_CRYSTAL] || r->God))
  1239. X        return CHAR_CRYSTAL;
  1240. X
  1241. X    switch (s->condition) {
  1242. X    case WASTED:
  1243. X        return CHAR_WASTED;
  1244. X    case SEA:
  1245. X        return CHAR_SEA;
  1246. X    case LAND:
  1247. X        return CHAR_LAND;
  1248. X    case MOUNT:
  1249. X        return CHAR_MOUNT;
  1250. X    case GAS:
  1251. X        return CHAR_GAS;
  1252. X    case PLATED:
  1253. X        return CHAR_PLATED;
  1254. X    case ICE:
  1255. X        return CHAR_ICE;
  1256. X    case DESERT:
  1257. X        return CHAR_DESERT;
  1258. X    case FOREST:
  1259. X        return CHAR_FOREST;
  1260. X    default:
  1261. X        return ('?');
  1262. X    }
  1263. X}
  1264. END_OF_FILE
  1265. if test 6953 -ne `wc -c <'user/map.c'`; then
  1266.     echo shar: \"'user/map.c'\" unpacked with wrong size!
  1267. fi
  1268. # end of 'user/map.c'
  1269. fi
  1270. if test -f 'user/tele.c' -a "${1}" != "-c" ; then 
  1271.   echo shar: Will not clobber existing file \"'user/tele.c'\"
  1272. else
  1273. echo shar: Extracting \"'user/tele.c'\" \(6701 characters\)
  1274. sed "s/^X//" >'user/tele.c' <<'END_OF_FILE'
  1275. X#ident  "@(#)tele.c    1.7 2/1/93 "
  1276. X/***********************************************
  1277. X * tele.c
  1278. X *
  1279. X * Created: ??
  1280. X * Author:  Robert Chansky
  1281. X *
  1282. X * Version: 1.7 00:14:43
  1283. X *
  1284. X * Contains: purge()
  1285. X *           post()
  1286. X *           push_telegram_race()
  1287. X *           push_telegram()
  1288. X *           teleg_read()
  1289. X *           news_read()
  1290. X *
  1291. X ***********************************************/
  1292. X
  1293. X#define EXTERN extern
  1294. X#include "GB_copyright.h"
  1295. X#include "vars.h"
  1296. X#include "files.h"
  1297. X#include "races.h"
  1298. X#include "buffers.h"
  1299. X#include "power.h"
  1300. X#include "ships.h"
  1301. X#include <stdio.h>
  1302. X#include <ctype.h>
  1303. X#include <strings.h>
  1304. X#include <errno.h>
  1305. X#include <signal.h>
  1306. X#include <sys/file.h>
  1307. X#include <sys/time.h>
  1308. X#include <sys/stat.h>
  1309. X
  1310. X
  1311. Xlong            tm;
  1312. XFILE            *teleg_read_fd;
  1313. Xchar            telegram_file[PATHLEN];
  1314. Xstruct             stat telestat;
  1315. X
  1316. X
  1317. X/*
  1318. X * Prototypes
  1319. X */
  1320. Xvoid            purge(void);
  1321. Xvoid            post(char *, int);
  1322. Xvoid            push_telegram_race(int, char *);
  1323. Xvoid            push_telegram(int, int, char *);
  1324. Xvoid            teleg_read(int, int);
  1325. Xvoid            news_read(int, int, int);
  1326. X#include "proto.h"
  1327. X
  1328. Xstruct tm      *current_tm;    /* for watching for next update */
  1329. X
  1330. X/*
  1331. X * purge:
  1332. X * 
  1333. X * arguments: none
  1334. X * 
  1335. X * called by: process_commands
  1336. X * 
  1337. X * description:  Used to purge the News files.
  1338. X * 
  1339. X */
  1340. Xvoid 
  1341. Xpurge(void)
  1342. X{
  1343. X    fclose(fopen(DECLARATIONFL, "w+"));
  1344. X    newslength[0] = 0;
  1345. X    fclose(fopen(COMBATFL, "w+"));
  1346. X    newslength[1] = 0;
  1347. X    fclose(fopen(ANNOUNCEFL, "w+"));
  1348. X    newslength[2] = 0;
  1349. X    fclose(fopen(TRANSFERFL, "w+"));
  1350. X    newslength[3] = 0;
  1351. X}
  1352. X
  1353. X/*
  1354. X * post:
  1355. X * 
  1356. X * arguments: msg  The actual message type Type of message.  Valid types are
  1357. X * DECLARATION, TRANSFER, COMBAT and ANNOUNCE.
  1358. X * 
  1359. X * called by:  fire, name, declare, dock, land, dissolve, doship, doturn
  1360. X * 
  1361. X * description: does the acutal posting of messages to the news files
  1362. X * 
  1363. X */
  1364. Xvoid 
  1365. Xpost(char *msg, int type)
  1366. X{
  1367. X    char            telefl[100];
  1368. X    char            pbuf[1024];    /* this is needed, don't use global
  1369. X                     * pointer! */
  1370. X    FILE           *news_fd;
  1371. X    char           *p;
  1372. X
  1373. X    switch (type) {
  1374. X    case DECLARATION:
  1375. X        sprintf(telefl, "%s", DECLARATIONFL);
  1376. X        break;
  1377. X    case TRANSFER:
  1378. X        sprintf(telefl, "%s", TRANSFERFL);
  1379. X        break;
  1380. X    case COMBAT:
  1381. X        sprintf(telefl, "%s", COMBATFL);
  1382. X        break;
  1383. X    case ANNOUNCE:
  1384. X        sprintf(telefl, "%s", ANNOUNCEFL);
  1385. X        break;
  1386. X    default:
  1387. X        return;
  1388. X    }
  1389. X
  1390. X    /* look for special symbols */
  1391. X    for (p = msg; *p; p++) {
  1392. X        if (*p == ';')
  1393. X            *p = '\n';
  1394. X        else if (*p == '|')
  1395. X            *p = '\t';
  1396. X    }
  1397. X
  1398. X    if ((news_fd = fopen(telefl, "a")) == NULL) {
  1399. X        return;
  1400. X    } else {
  1401. X        tm = time(0);
  1402. X        current_tm = localtime(&tm);
  1403. X        sprintf(pbuf, "%2d/%2d %02d:%02d:%02d %s",
  1404. X            current_tm->tm_mon + 1, current_tm->tm_mday, current_tm->tm_hour,
  1405. X            current_tm->tm_min, current_tm->tm_sec, msg);
  1406. X        fprintf(news_fd, "%s", pbuf);
  1407. X        fclose(news_fd);
  1408. X        newslength[type] += strlen(pbuf);
  1409. X    }
  1410. X}
  1411. X
  1412. X/*
  1413. X * push_telegram_race:
  1414. X * 
  1415. X * arguments: recpient msg
  1416. X * 
  1417. X * called by:
  1418. X * 
  1419. X * description:  Sends a message to everyone in the race
  1420. X * 
  1421. X */
  1422. Xvoid
  1423. Xpush_telegram_race(int recpient, char *msg)
  1424. X{
  1425. X    racetype       *Race;
  1426. X    reg int         j;
  1427. X
  1428. X    Race = races[recpient - 1];
  1429. X    for (j = 0; j <= MAXGOVERNORS; j++)
  1430. X        if (Race->governor[j].active)
  1431. X            push_telegram(recpient, j, msg);
  1432. X}
  1433. X
  1434. X/*
  1435. X * push_telegram:
  1436. X * 
  1437. X * arguments: recpient gov msg
  1438. X * 
  1439. X * called by:
  1440. X * 
  1441. X * description:  Sends a message to everyone from person to person
  1442. X * 
  1443. X */
  1444. Xvoid 
  1445. Xpush_telegram(int recpient, int gov, char *msg)
  1446. X{
  1447. X    char            telefl[100];
  1448. X    FILE           *telegram_fd;
  1449. X
  1450. X    sprintf(telefl, "%s.%d.%d", TELEGRAMFL, recpient, gov);
  1451. X
  1452. X    if ((telegram_fd = fopen(telefl, "a")) == NULL)
  1453. X        if ((telegram_fd = fopen(telefl, "w+")) == NULL) {
  1454. X            perror("teleg_send");
  1455. X            return;
  1456. X        }
  1457. X    tm = time(0);
  1458. X    current_tm = localtime(&tm);
  1459. X
  1460. X    fprintf(telegram_fd, "%2d/%2d %02d:%02d:%02d %s\n",
  1461. X       current_tm->tm_mon + 1, current_tm->tm_mday, current_tm->tm_hour,
  1462. X        current_tm->tm_min, current_tm->tm_sec, msg);
  1463. X    fclose(telegram_fd);
  1464. X}
  1465. X/*
  1466. X * *    read_teleg.c -- (try to) read telegrams *     the first byte in
  1467. X * each telegram is the sending player #, or 254 *     to denote
  1468. X * autoreport.  then the time sent, then the message itself, *     terminated
  1469. X * by TELEG_DELIM.
  1470. X */
  1471. X/*
  1472. X * teleg_read:
  1473. X * 
  1474. X * arguments: Playernum Governor
  1475. X * 
  1476. X * called by: process_commands
  1477. X * 
  1478. X * description:  Read the telegrams for the player.  The first byte in each
  1479. X * telegram is the sending player number or 254 to denote an autoreport.
  1480. X * Then the time send, then the message, then terminated by TELEG_DELIM
  1481. X */
  1482. Xvoid
  1483. Xteleg_read(int Playernum, int Governor)
  1484. X{
  1485. X    char           *p;
  1486. X    sprintf(telegram_file, "%s.%d.%d", TELEGRAMFL, Playernum, Governor);
  1487. X
  1488. X    if ((teleg_read_fd = fopen(telegram_file, "r")) != 0) {
  1489. X        notify(Playernum, Governor, "Telegrams:");
  1490. X        stat(telegram_file, &telestat);
  1491. X        if (telestat.st_size > 0) {
  1492. X            notify(Playernum, Governor, "\n");
  1493. X            while (fgets(buf, sizeof buf, teleg_read_fd)) {
  1494. X                for (p = buf; *p; p++)
  1495. X                    if (*p == '\n') {
  1496. X                        *p = '\0';
  1497. X                        break;
  1498. X                    }
  1499. X                strcat(buf, "\n");
  1500. X                notify(Playernum, Governor, buf);
  1501. X            }
  1502. X        } else {
  1503. X            notify(Playernum, Governor, " None.\n");
  1504. X        }
  1505. X
  1506. X        fclose(teleg_read_fd);
  1507. X        teleg_read_fd = fopen(telegram_file, "w+");    /* trunc file */
  1508. X        fclose(teleg_read_fd);
  1509. X    } else {
  1510. X        sprintf(buf, "\nTelegram file %s non-existent.\n", telegram_file);
  1511. X        notify(Playernum, Governor, buf);
  1512. X        loginfo(ERRORLOG, NOERRNO,
  1513. X            "Telegram file for %s non-existant", telegram_file);
  1514. X        return;
  1515. X    }
  1516. X}
  1517. X/*
  1518. X * news_read:
  1519. X * 
  1520. X * arguments: Playernum Governor Type
  1521. X * 
  1522. X * description:  Read the news file
  1523. X * 
  1524. X */
  1525. Xvoid 
  1526. Xnews_read(int Playernum, int Governor, int type)
  1527. X{
  1528. X    char           *p;
  1529. X    racetype       *Race;
  1530. X
  1531. X    switch (type) {
  1532. X    case DECLARATION:
  1533. X        sprintf(telegram_file, "%s", DECLARATIONFL);
  1534. X        break;
  1535. X    case TRANSFER:
  1536. X        sprintf(telegram_file, "%s", TRANSFERFL);
  1537. X        break;
  1538. X    case COMBAT:
  1539. X        sprintf(telegram_file, "%s", COMBATFL);
  1540. X        break;
  1541. X    case ANNOUNCE:
  1542. X        sprintf(telegram_file, "%s", ANNOUNCEFL);
  1543. X        break;
  1544. X    default:
  1545. X        return;
  1546. X    }
  1547. X
  1548. X    if ((teleg_read_fd = fopen(telegram_file, "r")) != 0) {
  1549. X        Race = races[Playernum - 1];
  1550. X        if (Race->governor[Governor].newspos[type] > newslength[type])
  1551. X            Race->governor[Governor].newspos[type] = 0;
  1552. X
  1553. X        fseek(teleg_read_fd, Race->governor[Governor].newspos[type], 0);
  1554. X        while (fgets(buf, sizeof buf, teleg_read_fd)) {
  1555. X            for (p = buf; *p; p++)
  1556. X                if (*p == '\n') {
  1557. X                    *p = '\0';
  1558. X                    break;
  1559. X                }
  1560. X            strcat(buf, "\n");
  1561. X            notify(Playernum, Governor, buf);
  1562. X        }
  1563. X
  1564. X        fclose(teleg_read_fd);
  1565. X        Race->governor[Governor].newspos[type] = newslength[type];
  1566. X        putrace(Race);
  1567. X    } else {
  1568. X        sprintf(buf, "\nNews file %s non-existent.\n", telegram_file);
  1569. X        notify(Playernum, Governor, buf);
  1570. X        loginfo(ERRORLOG, NOERRNO,
  1571. X            "Telegram file for %s non-existant", telegram_file);
  1572. X        return;
  1573. X    }
  1574. X}
  1575. END_OF_FILE
  1576. if test 6701 -ne `wc -c <'user/tele.c'`; then
  1577.     echo shar: \"'user/tele.c'\" unpacked with wrong size!
  1578. fi
  1579. # end of 'user/tele.c'
  1580. fi
  1581. if test -f 'utils/enroll.c' -a "${1}" != "-c" ; then 
  1582.   echo shar: Will not clobber existing file \"'utils/enroll.c'\"
  1583. else
  1584. echo shar: Extracting \"'utils/enroll.c'\" \(5980 characters\)
  1585. sed "s/^X//" >'utils/enroll.c' <<'END_OF_FILE'
  1586. X/* enroll - racegen interface for Galactic Bloodshed race enrollment program.
  1587. X * Copyright (c) Leonard Dickens 1991   (leonard@cs.umd.edu)
  1588. X *
  1589. X * Permission to copy, distribute, and/or alter is granted as long as the copy-
  1590. X * right notice and these terms are left unchanged in all derivatives/copies.
  1591. X * 
  1592. X * Anybody who does alter this program, please take credit!
  1593. X */
  1594. X#include "racegen.h"
  1595. X
  1596. X#define DEFAULT_ENROLLMENT_FILENAME "enroll.saves"
  1597. X#define DEFAULT_ENROLLMENT_FAILURE_FILENAME "failures.saves"
  1598. X
  1599. X#ifdef __STDC__
  1600. Xextern int enroll_valid_race(void) ;
  1601. X#else
  1602. Xextern int enroll_valid_race() ;
  1603. X#endif
  1604. X
  1605. X/*
  1606. X * Returns: 0 if the race was successfully enrolled, or 1 if not.
  1607. X */
  1608. Xint enroll_player_race(failure_filename)
  1609. X     char *failure_filename ;
  1610. X{
  1611. X  char c[128] ;
  1612. X  FILE *f, *g ;
  1613. X  int n ;
  1614. X  static int recursing = 0 ;
  1615. X  static int successful_enroll_in_fix_mode = 0 ;
  1616. X
  1617. X  while (n = critique_to_file(NULL, 1, 1)) {
  1618. X    printf("Race (%s) unacceptable, for the following reason%c:\n",
  1619. X       race.name, (n > 1) ? 's' : '\0') ;
  1620. X    critique_to_file(stdout, 1, 1) ;
  1621. X    if (recursing) {
  1622. X      printf("\"Quit\" to break out of fix mode.\n") ;
  1623. X      return 1 ;
  1624. X      }
  1625. X    if (race.status == STATUS_ENROLLED)
  1626. X      return 0 ;
  1627. X    n = Dialogue("Abort, enroll anyway, fix, mail rejection?",
  1628. X         "abort", "enroll", "fix", "mail", 0) ;
  1629. X    if (n == 1)     /* enroll anyway */
  1630. X      break ;
  1631. X    if (n == 2) {   /* fix */
  1632. X      printf("Recursive racegen.  \"Enroll\" or \"Quit\" to exit.\n") ;
  1633. X      recursing = 1 ;
  1634. X      modify_print_loop(1) ;
  1635. X      please_quit = recursing = 0 ;
  1636. X      if (successful_enroll_in_fix_mode) {
  1637. X    successful_enroll_in_fix_mode = 0 ;
  1638. X    return 0 ;
  1639. X    }
  1640. X      continue ;
  1641. X      }
  1642. X    if (failure_filename != NULL) 
  1643. X      if (NULL == fopen(failure_filename, "w+")) {
  1644. X    printf("Warning: unable to open failures file \"%s\".\n", 
  1645. X           failure_filename) ;
  1646. X    printf("Race not saved to failures file.\n") ;
  1647. X    }
  1648. X      else {
  1649. X    print_to_file(f, 0) ;
  1650. X    printf("Race appended to failures file \"%s\".\n", failure_filename) ;
  1651. X    fclose(f) ;
  1652. X    }
  1653. X    if (n == 0)    /* Abort */
  1654. X      return 1 ;
  1655. X    
  1656. X    g = fopen(TMP, "w") ;
  1657. X    if (g == NULL) {
  1658. X      printf("Unable to open file \"%s\".\n", TMP) ;
  1659. X      return 1 ;
  1660. X      }
  1661. X    fprintf(g, "To: %s\n", race.address) ;
  1662. X    fprintf(g, "Subject: %s Race Rejection\n", GAME) ;
  1663. X    fprintf(g, "\n") ;
  1664. X    fprintf(g, "The race you submitted (%s) was not accepted, for the following reason%c:\n", race.name, (n > 1) ? 's' : '\0') ;
  1665. X    critique_to_file(g, 1, 1) ;
  1666. X    fprintf(g, "\n") ;
  1667. X    fprintf(g, "Please re-submit a race if you want to play in %s.\n", GAME);
  1668. X    fprintf(g, "(Check to make sure you are using racegen %s)\n", GBVERSION) ;
  1669. X    fprintf(g, "\n") ;
  1670. X    fprintf(g, "For verification, here is my understanding of your race:\n");
  1671. X    print_to_file(g, 1, 0) ;
  1672. X    fclose(g) ;
  1673. X    
  1674. X    printf("Sending critique to %s via %s...", race.address, MAILER) ;
  1675. X    fflush(stdout) ;
  1676. X    sprintf(c, "cat %s | %s %s", TMP, MAILER, race.address) ;
  1677. X    system(c) ;
  1678. X    printf("done.\n") ;
  1679. X
  1680. X    return 1 ;
  1681. X    }
  1682. X
  1683. X  if (enroll_valid_race())
  1684. X    return enroll_player_race(failure_filename) ;
  1685. X  
  1686. X  if (recursing) {
  1687. X    successful_enroll_in_fix_mode = 1 ;
  1688. X    please_quit = 1 ;
  1689. X    }
  1690. X  
  1691. X  g = fopen(TMP, "w") ;
  1692. X  if (g == NULL) {
  1693. X    printf("Unable to open file \"%s\".\n", TMP) ;
  1694. X    return 0 ;
  1695. X    }
  1696. X  fprintf(g, "To: %s\n", race.address) ;
  1697. X  fprintf(g, "Subject: %s Race Accepted\n", GAME) ;
  1698. X  fprintf(g, "\n") ;
  1699. X  fprintf(g, "The race you submitted (%s) was accepted.\n", race.name) ;
  1700. X#if 0
  1701. X  if (race.modified_by_diety) {
  1702. X    fprintf(g, "The race was altered in order to be acceptable.\n") ;
  1703. X    fprintf(g, "Your race now looks like this:\n") ;
  1704. X    fprintf(g, "\n") ;
  1705. X    print_to_file(g, verbose, 0) ;
  1706. X    fprintf(g, "\n") ;
  1707. X    }
  1708. X#endif
  1709. X  fclose(g) ;
  1710. X  
  1711. X  printf("Sending acceptance to %s via %s...", race.address, MAILER) ;
  1712. X  fflush(stdout) ;
  1713. X  sprintf(c, "cat %s | %s %s", TMP, MAILER, race.address) ;
  1714. X  system(c) ;
  1715. X  printf("done.\n") ;
  1716. X  
  1717. X  return 0 ;
  1718. X  }
  1719. X
  1720. X
  1721. Xint enroll(argc, argv)
  1722. X     int argc ;
  1723. X     char *argv[] ;
  1724. X{
  1725. X  int ret ;
  1726. X  FILE *g ;
  1727. X
  1728. X  if (argc < 2)
  1729. X    argv[1] = DEFAULT_ENROLLMENT_FAILURE_FILENAME ;
  1730. X  g = fopen(argv[1], "w+") ;
  1731. X  if (g == NULL)
  1732. X    printf("Unable to open failures file \"%s\".\n", argv[1]) ;
  1733. X  fclose(g) ;
  1734. X  bcopy(&race, &last, sizeof(struct x)) ;
  1735. X
  1736. X  /*
  1737. X   * race.address will be unequal to TO in the instance that this is a
  1738. X   * race submission mailed from somebody other than the moderator.  */
  1739. X  if (strcmp(race.address, TO))
  1740. X    ret = enroll_player_race(argv[1]) ;
  1741. X  else
  1742. X    if (ret = critique_to_file(NULL, 1, 0)) {
  1743. X      printf("Race (%s) unacceptable, for the following reason%c:\n",
  1744. X         race.name, (ret > 1) ? 's' : '\0') ;
  1745. X      critique_to_file(stdout, 1, 0) ;
  1746. X      }
  1747. X    else
  1748. X      if (ret = enroll_valid_race())
  1749. X    critique_to_file(stdout, 1, 0) ;
  1750. X
  1751. X  if (ret)
  1752. X    printf("Enroll failed.\n") ;
  1753. X  return ret ;
  1754. X  }
  1755. X
  1756. X
  1757. X/**************
  1758. X * Iteratively loads races from a file, and enrolls them.
  1759. X */
  1760. Xvoid process(argc, argv)
  1761. X     int argc ;
  1762. X     char *argv[] ;
  1763. X{
  1764. X  FILE *f, *g ;
  1765. X  int n, nenrolled ;
  1766. X
  1767. X  if (argc < 2)
  1768. X    argv[1] = DEFAULT_ENROLLMENT_FILENAME ;
  1769. X  f = fopen(argv[1], "r") ;
  1770. X  if (f == NULL) {
  1771. X    printf("Unable to open races file \"%s\".\n", argv[1]) ;
  1772. X    return ;
  1773. X    }
  1774. X
  1775. X  if (argc < 3)
  1776. X    argv[2] = DEFAULT_ENROLLMENT_FAILURE_FILENAME ;
  1777. X  g = fopen(argv[2], "w") ;
  1778. X  if (g == NULL)
  1779. X    printf("Unable to open failures file \"%s\".\n", argv[2]) ;
  1780. X  fclose(g) ;
  1781. X
  1782. X  n = 0 ;
  1783. X  nenrolled = 0 ;
  1784. X  while (! feof(f)) {
  1785. X    if (! load_from_file(f))
  1786. X      continue ;
  1787. X    n++ ;
  1788. X    printf("%s, from %s\n", race.name, race.address) ;
  1789. X    /* We need the side effects: */
  1790. X    last_npoints = npoints ;
  1791. X    npoints = STARTING_POINTS - cost_of_race() ;
  1792. X    if (! enroll_player_race(argv[2]))
  1793. X      nenrolled += 1 ;
  1794. X    }
  1795. X  fclose(f) ;
  1796. X
  1797. X  printf("Enrolled %d race%c; %d failure%c saved in file %s.\n",
  1798. X     nenrolled, (nenrolled != 1)?'s':'\0', 
  1799. X     n - nenrolled, (n - nenrolled != 1)?'s':'\0', argv[2]) ;
  1800. X  }
  1801. END_OF_FILE
  1802. if test 5980 -ne `wc -c <'utils/enroll.c'`; then
  1803.     echo shar: \"'utils/enroll.c'\" unpacked with wrong size!
  1804. fi
  1805. # end of 'utils/enroll.c'
  1806. fi
  1807. if test -f 'utils/psmap.c' -a "${1}" != "-c" ; then 
  1808.   echo shar: Will not clobber existing file \"'utils/psmap.c'\"
  1809. else
  1810. echo shar: Extracting \"'utils/psmap.c'\" \(3514 characters\)
  1811. sed "s/^X//" >'utils/psmap.c' <<'END_OF_FILE'
  1812. X#include "stdio.h"
  1813. X
  1814. X/* starmap.c                                                           */
  1815. X/* produces a Postscript map from the output of the GB command 'stars' */
  1816. X/* Copyright: Andreas Girgensohn (andreasg@cs.colorado.edu)            */
  1817. X
  1818. Xstruct star {
  1819. X  int   x,
  1820. X        y;
  1821. X  char  name[80];
  1822. X};
  1823. X
  1824. Xstruct star stars[200];
  1825. Xint   nstars,
  1826. X      highlight_home = 1,
  1827. X      highlighted_star = -1,    /* star that will be highlighted */
  1828. X      nrings = 20,        /* number of distance rings around the
  1829. X                   highlighted star */
  1830. X      ring_spacing = 10000;
  1831. X
  1832. Xmain (argc, argv)
  1833. Xint   argc;
  1834. Xchar *argv[];
  1835. X{
  1836. X  scan_stars (stdin);
  1837. X  if (nstars == 0)
  1838. X    fprintf (stderr, "No stars\n");
  1839. X  else
  1840. X    produce_postscript ();
  1841. X  exit (0);
  1842. X}
  1843. X
  1844. Xscan_stars (fin)
  1845. XFILE * fin;
  1846. X{
  1847. X  char  line[200];
  1848. X  int   distance,
  1849. X        in_stars = 0;
  1850. X
  1851. X  nstars = 0;
  1852. X  while (fgets (line, 200, fin) != NULL) {
  1853. X    if (sscanf (line, "(%*d) %79s ( %d, %d) %d", stars[nstars].name,
  1854. X      &(stars[nstars].x), &(stars[nstars].y), &distance) == 4) {
  1855. X      if (highlight_home && distance == 0)
  1856. X    highlighted_star = nstars;
  1857. X      nstars++;
  1858. X      if (!in_stars)
  1859. X    in_stars = 1;
  1860. X    }
  1861. X    else
  1862. X      if (in_stars)
  1863. X    break;
  1864. X  }
  1865. X}
  1866. X
  1867. Xproduce_postscript () {
  1868. X  int   min_x,
  1869. X        max_x,
  1870. X        min_y,
  1871. X        max_y,
  1872. X        i;
  1873. X  double  scale,
  1874. X          nscale;
  1875. X
  1876. X  min_x = max_x = stars[0].x;
  1877. X  min_y = max_y = stars[0].y;
  1878. X  for (i = 1; i < nstars; i++) {
  1879. X    if (stars[i].x < min_x)
  1880. X      min_x = stars[i].x;
  1881. X    if (stars[i].x > max_x)
  1882. X      max_x = stars[i].x;
  1883. X    if (stars[i].y < min_y)
  1884. X      min_y = stars[i].y;
  1885. X    if (stars[i].y > max_y)
  1886. X      max_y = stars[i].y;
  1887. X  }
  1888. X  /* max map size: 8.5in x 11in sheet, 0.5in borders, */
  1889. X  /* 0.5in on the right for star names */
  1890. X  /* 72 points = 1in */
  1891. X  scale = 7.0 * 72 / (max_x - min_x);
  1892. X  nscale = 10.0 * 72 / (max_y - min_y);
  1893. X  if (nscale < scale)
  1894. X    scale = nscale;
  1895. X  printf ("%%!PS-Adobe-2.0\n\n");
  1896. X  /* 0,0 is in the topleft corner */
  1897. X  printf ("0.5 72 mul 10.5 72 mul translate\n");
  1898. X  printf ("/drawcircle\n");
  1899. X  printf ("{\n");
  1900. X  printf ("  newpath 0 360 arc stroke\n");
  1901. X  printf ("}\n");
  1902. X  printf ("def\n\n");
  1903. X  printf ("/drawstar\n");
  1904. X  printf ("{\n");
  1905. X  printf ("  /starname exch def\n");
  1906. X  printf ("  /ypos exch def\n");
  1907. X  printf ("  /xpos exch def\n");
  1908. X  printf ("  xpos ypos 2 drawcircle\n");
  1909. X  printf ("  4 xpos add ypos moveto\n");
  1910. X  printf ("  starname show\n");
  1911. X  printf ("}\n");
  1912. X  printf ("def\n\n");
  1913. X  printf ("0 setlinewidth\n");
  1914. X  printf ("newpath -10 10 moveto 7.5 72 mul 10 add 10 lineto\n");
  1915. X  printf ("7.5 72 mul 10 add %d lineto -10 %d lineto closepath clip\n",
  1916. X      (int) ((min_y - max_y) * scale) - 10,
  1917. X      (int) ((min_y - max_y) * scale) - 10);
  1918. X  if (highlighted_star >= 0 && highlighted_star < nstars) {
  1919. X    printf ("\n/Times-Bold findfont 9 scalefont setfont\n\n");
  1920. X    draw_star (stars + highlighted_star, min_x, min_y, scale);
  1921. X    for (i = 1; i <= nrings; i++)
  1922. X      printf ("%d %d %d drawcircle\n",
  1923. X      (int) ((stars[highlighted_star].x - min_x) * scale),
  1924. X      (int) ((min_y - stars[highlighted_star].y) * scale),
  1925. X      (int) (i * ring_spacing * scale));
  1926. X  }
  1927. X  printf ("\n/Times-Roman findfont 8 scalefont setfont\n\n");
  1928. X  for (i = 0; i < nstars; i++)
  1929. X    if (i != highlighted_star)
  1930. X      draw_star (stars + i, min_x, min_y, scale);
  1931. X  printf ("\nshowpage\n");
  1932. X}
  1933. X
  1934. Xdraw_star (star, min_x, min_y, scale)
  1935. Xstruct star *star;
  1936. Xint   min_x,
  1937. X      min_y;
  1938. Xdouble  scale;
  1939. X{
  1940. X  printf ("%d %d (%s) drawstar\n", (int) ((star -> x - min_x) * scale),
  1941. X      (int) ((min_y - star -> y) * scale), star -> name);
  1942. X}
  1943. X
  1944. END_OF_FILE
  1945. if test 3514 -ne `wc -c <'utils/psmap.c'`; then
  1946.     echo shar: \"'utils/psmap.c'\" unpacked with wrong size!
  1947. fi
  1948. # end of 'utils/psmap.c'
  1949. fi
  1950. echo shar: End of archive 18 \(of 21\).
  1951. cp /dev/null ark18isdone
  1952. MISSING=""
  1953. 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
  1954.     if test ! -f ark${I}isdone ; then
  1955.     MISSING="${MISSING} ${I}"
  1956.     fi
  1957. done
  1958. if test "${MISSING}" = "" ; then
  1959.     echo You have unpacked all 21 archives.
  1960.     echo "Now type './buildfiles.sh'"
  1961.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1962. else
  1963.     echo You still need to unpack the following archives:
  1964.     echo "        " ${MISSING}
  1965. fi
  1966. ##  End of shell archive.
  1967. exit 0
  1968.