home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume17 / gbp / part06 < prev    next >
Encoding:
Internet Message Format  |  1993-03-20  |  54.0 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: v17i018:  gbp - Galactic Bloodshed+, an empire-like war game, Part06/21
  5. Message-ID: <4546@master.CNA.TEK.COM>
  6. Date: 12 Feb 93 17:30:33 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1691
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1697
  11.  
  12. Submitted-by: deragon@harpo.cs.nyu.edu (Seeker)
  13. Posting-number: Volume 17, Issue 18
  14. Archive-name: gbp/Part06
  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 6 (of 21)."
  27. # Contents:  hdrs/interface.h user/name.c utils/makeplanet.c
  28. # Wrapped by billr@saab on Fri Feb 12 09:14:25 1993
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'hdrs/interface.h' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'hdrs/interface.h'\"
  32. else
  33. echo shar: Extracting \"'hdrs/interface.h'\" \(443 characters\)
  34. sed "s/^X//" >'hdrs/interface.h' <<'END_OF_FILE'
  35. X#include "TinyMUD_copyright.h"
  36. X
  37. X/* these symbols must be defined by the interface */
  38. Xextern int notify();
  39. Xextern int shutdown_flag; /* if non-zero, interface should shut down */
  40. Xextern void emergency_shutdown();
  41. X
  42. X/* the following symbols are provided by game.c */
  43. X
  44. X/* max length of command argument to process_command */
  45. X#define MAX_COMMAND_LEN 512
  46. X#define BUFFER_LEN ((MAX_COMMAND_LEN)*8)
  47. Xextern void process_command();
  48. X
  49. Xextern void panic();
  50. END_OF_FILE
  51. if test 443 -ne `wc -c <'hdrs/interface.h'`; then
  52.     echo shar: \"'hdrs/interface.h'\" unpacked with wrong size!
  53. fi
  54. # end of 'hdrs/interface.h'
  55. fi
  56. if test -f 'user/name.c' -a "${1}" != "-c" ; then 
  57.   echo shar: Will not clobber existing file \"'user/name.c'\"
  58. else
  59. echo shar: Extracting \"'user/name.c'\" \(34058 characters\)
  60. sed "s/^X//" >'user/name.c' <<'END_OF_FILE'
  61. X/*
  62. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  63. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  64. X * GB_copyright.h.
  65. X * 
  66. X * name.c -- rename something to something else announce.c -- make announcements
  67. X * in the system you currently in. You must be inhabiting that system for
  68. X * your message to sent. You must also be in that system (and inhabiting) to
  69. X * receive announcements. page.c -- send a message to a player requesting his
  70. X * presence in a system.
  71. X */
  72. X#include <ctype.h>
  73. X#include <signal.h>
  74. X#include <strings.h>
  75. X#include <time.h>
  76. X#include <math.h>
  77. X
  78. X#include "GB_copyright.h"
  79. X#define EXTERN extern
  80. X#include "vars.h"
  81. X#include "races.h"
  82. X#include "power.h"
  83. X#include "ships.h"
  84. X#include "buffers.h"
  85. X#include "config.h"
  86. X
  87. Xchar            msg[1024];
  88. Xstruct tm      *current_tm;    /* for watching for next update */
  89. Xlong            clk;
  90. X
  91. Xvoid            personal(int, int, char *);
  92. Xvoid            bless(int, int, int);
  93. Xvoid            insurgency(int, int, int);
  94. Xvoid            pay(int, int, int);
  95. Xvoid            give(int, int, int);
  96. Xvoid            page(int, int, int);
  97. Xvoid            send_message(int, int, int, int);
  98. Xvoid            read_messages(int, int, int);
  99. Xvoid            motto(int, int, int, char *);
  100. Xvoid            name(int, int, int);
  101. Xint             MostAPs(int, startype *);
  102. Xvoid            announce(int, int, char *, int, int);
  103. X#include "proto.h"
  104. X
  105. Xvoid 
  106. Xpersonal(int Playernum, int Governor, char *message)
  107. X{
  108. X    racetype       *Race;
  109. X
  110. X    if (Governor) {
  111. X        notify(Playernum, Governor, "Only the leader can do this.\n");
  112. X        return;
  113. X    }
  114. X    Race = races[Playernum - 1];
  115. X    strncpy(Race->info, message, PERSONALSIZE - 1);
  116. X    putrace(Race);
  117. X}
  118. X
  119. Xvoid 
  120. Xbless(int Playernum, int Governor, int APcount)
  121. X{
  122. X    planettype     *planet;
  123. X    racetype       *Race;
  124. X    int             who, amount, Mod;
  125. X    char            commod;
  126. X
  127. X    Race = races[Playernum - 1];
  128. X    if (!Race->God) {
  129. X        notify(Playernum, Governor, "You are not privileged to use this command.\n");
  130. X        return;
  131. X    }
  132. X    if (Dir[Playernum - 1][Governor].level != LEVEL_PLAN) {
  133. X        notify(Playernum, Governor, "Please cs to the planet in question.\n");
  134. X        return;
  135. X    }
  136. X    who = atoi(args[1]);
  137. X    if (who < 1 || who > Num_races) {
  138. X        notify(Playernum, Governor, "No such player number.\n");
  139. X        return;
  140. X    }
  141. X    if (argn < 3) {
  142. X        notify(Playernum, Governor, "Syntax: bless <player> <what> <+amount>\n");
  143. X        return;
  144. X    }
  145. X    amount = atoi(args[3]);
  146. X
  147. X    Race = races[who - 1];
  148. X    /* race characteristics? */
  149. X    Mod = 1;
  150. X
  151. X    if (match(args[2], "money")) {
  152. X        Race->governor[0].money += amount;
  153. X        sprintf(buf, "Deity gave you %d money.\n", amount);
  154. X    } else if (match(args[2], "password")) {
  155. X        strcpy(Race->password, args[3]);
  156. X        sprintf(buf, "Deity changed your race password to `%s'\n", args[3]);
  157. X    } else if (match(args[2], "morale")) {
  158. X        Race->morale += amount;
  159. X        sprintf(buf, "Deity gave you %d morale.\n", amount);
  160. X    } else if (match(args[2], "pods")) {
  161. X        Race->pods = 1;
  162. X        sprintf(buf, "Deity gave you pod ability.\n");
  163. X    } else if (match(args[2], "nopods")) {
  164. X        Race->pods = 0;
  165. X        sprintf(buf, "Deity took away pod ability.\n");
  166. X    } else if (match(args[2], "collectiveiq")) {
  167. X        Race->collective_iq = 1;
  168. X        sprintf(buf, "Deity gave you collective intelligence.\n");
  169. X    } else if (match(args[2], "nocollectiveiq")) {
  170. X        Race->collective_iq = 0;
  171. X        sprintf(buf, "Deity took away collective intelligence.\n");
  172. X    } else if (match(args[2], "maxiq")) {
  173. X        Race->IQ_limit = atoi(args[3]);
  174. X        sprintf(buf, "Deity gave you a maximum IQ of %d.\n", Race->IQ_limit);
  175. X    } else if (match(args[2], "mass")) {
  176. X        Race->mass = atof(args[3]);
  177. X        sprintf(buf, "Deity gave you %.2f mass.\n", Race->mass);
  178. X    } else if (match(args[2], "metabolism")) {
  179. X        Race->metabolism = atof(args[3]);
  180. X        sprintf(buf, "Deity gave you %.2f metabolism.\n", Race->metabolism);
  181. X    } else if (match(args[2], "adventurism")) {
  182. X        Race->adventurism = atof(args[3]);
  183. X        sprintf(buf, "Deity gave you %-3.0f%% adventurism.\n", Race->adventurism * 100.0);
  184. X    } else if (match(args[2], "birthrate")) {
  185. X        Race->birthrate = atof(args[3]);
  186. X        sprintf(buf, "Deity gave you %.2f birthrate.\n", Race->birthrate);
  187. X    } else if (match(args[2], "fertility")) {
  188. X        Race->fertilize = amount;
  189. X        sprintf(buf, "Deity gave you a fetilization ability of %d.\n", amount);
  190. X    } else if (match(args[2], "IQ")) {
  191. X        Race->IQ = amount;
  192. X        sprintf(buf, "Deity gave you %d IQ.\n", amount);
  193. X    } else if (match(args[2], "fight")) {
  194. X        Race->fighters = amount;
  195. X        sprintf(buf, "Deity set your fighting ability to %d.\n", amount);
  196. X    } else if (match(args[2], "technology")) {
  197. X        Race->tech += (double) amount;
  198. X        sprintf(buf, "Deity gave you %d technology.\n", amount);
  199. X    } else if (match(args[2], "guest")) {
  200. X        Race->Guest = 1;
  201. X        sprintf(buf, "Deity turned you into a guest race.\n");
  202. X    } else if (match(args[2], "god")) {
  203. X        Race->God = 1;
  204. X        sprintf(buf, "Deity turned you into a deity race.\n");
  205. X    } else if (match(args[2], "mortal")) {
  206. X        Race->God = 0;
  207. X        Race->Guest = 0;
  208. X        sprintf(buf, "Deity turned you into a mortal race.\n");
  209. X        /* sector preferences */
  210. X    } else if (match(args[2], "water")) {
  211. X        Race->likes[SEA] = 0.01 * (double) amount;
  212. X        sprintf(buf, "Deity set your water preference to %d%%\n", amount);
  213. X    } else if (match(args[2], "land")) {
  214. X        Race->likes[LAND] = 0.01 * (double) amount;
  215. X        sprintf(buf, "Deity set your land preference to %d%%\n", amount);
  216. X    } else if (match(args[2], "mountain")) {
  217. X        Race->likes[MOUNT] = 0.01 * (double) amount;
  218. X        sprintf(buf, "Deity set your mountain preference to %d%%\n", amount);
  219. X    } else if (match(args[2], "gas")) {
  220. X        Race->likes[GAS] = 0.01 * (double) amount;
  221. X        sprintf(buf, "Deity set your gas preference to %d%%\n", amount);
  222. X    } else if (match(args[2], "ice")) {
  223. X        Race->likes[ICE] = 0.01 * (double) amount;
  224. X        sprintf(buf, "Deity set your ice preference to %d%%\n", amount);
  225. X    } else if (match(args[2], "forest")) {
  226. X        Race->likes[FOREST] = 0.01 * (double) amount;
  227. X        sprintf(buf, "Deity set your forest preference to %d%%\n", amount);
  228. X    } else if (match(args[2], "desert")) {
  229. X        Race->likes[DESERT] = 0.01 * (double) amount;
  230. X        sprintf(buf, "Deity set your desert preference to %d%%\n", amount);
  231. X    } else if (match(args[2], "plated")) {
  232. X        Race->likes[PLATED] = 0.01 * (double) amount;
  233. X        sprintf(buf, "Deity set your plated preference to %d%%\n", amount);
  234. X    } else
  235. X        Mod = 0;
  236. X    if (Mod) {
  237. X        putrace(Race);
  238. X        warn(who, 0, buf);
  239. X    }
  240. X    if (Mod)
  241. X        return;
  242. X    /* ok, must be the planet then */
  243. X    commod = args[2][0];
  244. X    getplanet(&planet, Dir[Playernum - 1][Governor].snum, Dir[Playernum - 1][Governor].pnum);
  245. X    if (match(args[2], "explorebit")) {
  246. X        planet->info[who - 1].explored = 1;
  247. X        getstar(&Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  248. X        setbit(Stars[Dir[Playernum - 1][Governor].snum]->explored, who);
  249. X        putstar(Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  250. X        sprintf(buf, "Deity set your explored bit at /%s/%s.\n",
  251. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  252. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum]);
  253. X    } else if (match(args[2], "noexplorebit")) {
  254. X        planet->info[who - 1].explored = 0;
  255. X        sprintf(buf, "Deity reset your explored bit at /%s/%s.\n",
  256. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  257. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum]);
  258. X    } else if (match(args[2], "planetpopulation")) {
  259. X        planet->info[who - 1].popn = atoi(args[3]);
  260. X        planet->popn++;
  261. X        sprintf(buf, "Deity set your population variable to %d at /%s/%s.\n",
  262. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  263. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum]);
  264. X    } else if (match(args[2], "inhabited")) {
  265. X        getstar(&Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  266. X        setbit(Stars[Dir[Playernum - 1][Governor].snum]->inhabited, Playernum);
  267. X        putstar(Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  268. X        sprintf(buf, "Deity has set your inhabited bit for /%s/%s.\n",
  269. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  270. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum]);
  271. X    } else if (match(args[2], "numsectsowned")) {
  272. X        planet->info[who - 1].numsectsowned = atoi(args[3]);
  273. X        sprintf(buf, "Deity set your \"numsectsowned\" variable at /%s/%s to %d.\n",
  274. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  275. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum],
  276. X            planet->info[who - 1].numsectsowned);
  277. X    } else {
  278. X        switch (commod) {
  279. X        case 'r':
  280. X            planet->info[who - 1].resource += amount;
  281. X            sprintf(buf, "Deity gave you %d resources at %s/%s.\n",
  282. X                amount,
  283. X                 Stars[Dir[Playernum - 1][Governor].snum]->name,
  284. X                Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum]);
  285. X            break;
  286. X        case 'd':
  287. X            planet->info[who - 1].destruct += amount;
  288. X            sprintf(buf, "Deity gave you %d destruct at %s/%s.\n",
  289. X                amount,
  290. X                 Stars[Dir[Playernum - 1][Governor].snum]->name,
  291. X                Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum]);
  292. X            break;
  293. X        case 'f':
  294. X            planet->info[who - 1].fuel += amount;
  295. X            sprintf(buf, "Deity gave you %d fuel at %s/%s.\n",
  296. X                amount,
  297. X                 Stars[Dir[Playernum - 1][Governor].snum]->name,
  298. X                Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum]);
  299. X            break;
  300. X        case 'x':
  301. X            planet->info[who - 1].crystals += amount;
  302. X            sprintf(buf, "Deity gave you %d crystals at %s/%s.\n",
  303. X                amount,
  304. X                 Stars[Dir[Playernum - 1][Governor].snum]->name,
  305. X                Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum]);
  306. X            break;
  307. X        case 'a':
  308. X            getstar(&Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  309. X            Stars[Dir[Playernum - 1][Governor].snum]->AP[who - 1] += amount;
  310. X            putstar(Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  311. X            sprintf(buf, "Deity gave you %d action points at %s.\n",
  312. X                amount,
  313. X                Stars[Dir[Playernum - 1][Governor].snum]->name);
  314. X            break;
  315. X        default:
  316. X            notify(Playernum, Governor, "No such commodity.\n");
  317. X            free(planet);
  318. X            return;
  319. X        }
  320. X    }
  321. X    putplanet(planet, Dir[Playernum - 1][Governor].snum, Dir[Playernum - 1][Governor].pnum);
  322. X    warn_race(who, buf);
  323. X    free(planet);
  324. X}
  325. X
  326. Xvoid 
  327. Xinsurgency(int Playernum, int Governor, int APcount)
  328. X{
  329. X    int             who, amount, eligible, them = 0;
  330. X    racetype       *Race, *alien;
  331. X    planettype     *p;
  332. X    double          x;
  333. X    int             changed_hands, chance;
  334. X    register int    i;
  335. X
  336. X    if (Dir[Playernum - 1][Governor].level != LEVEL_PLAN) {
  337. X        notify(Playernum, Governor, "You must 'cs' to the planet you wish to try it on.\n");
  338. X        return;
  339. X    }
  340. X    if (!control(Playernum, Governor, Stars[Dir[Playernum - 1][Governor].snum])) {
  341. X        notify(Playernum, Governor, "You are not authorized to do that here.\n");
  342. X        return;
  343. X    }
  344. X    /*
  345. X     * if(argn<3) { notify(Playernum, Governor, "The correct syntax is
  346. X     * 'insurgency <race> <money>'\n"); return; }
  347. X     */
  348. X    if (!enufAP(Playernum, Governor, Stars[Dir[Playernum - 1][Governor].snum]->AP[Playernum - 1], APcount))
  349. X        return;
  350. X    if (!(who = GetPlayer(args[1]))) {
  351. X        sprintf(buf, "No such player.\n");
  352. X        notify(Playernum, Governor, buf);
  353. X        return;
  354. X    }
  355. X    Race = races[Playernum - 1];
  356. X    alien = races[who - 1];
  357. X    if (alien->Guest) {
  358. X        notify(Playernum, Governor, "Don't be such a dickweed.\n");
  359. X        return;
  360. X    }
  361. X    if (who == Playernum) {
  362. X        notify(Playernum, Governor, "You can't revolt against yourself!\n");
  363. X        return;
  364. X    }
  365. X    eligible = 0;
  366. X    them = 0;
  367. X    for (i = 0; i < Stars[Dir[Playernum - 1][Governor].snum]->numplanets; i++) {
  368. X        getplanet(&p, Dir[Playernum - 1][Governor].snum, i);
  369. X        eligible += p->info[Playernum - 1].popn;
  370. X        them += p->info[who - 1].popn;
  371. X        free(p);
  372. X    }
  373. X    if (!eligible) {
  374. X        notify(Playernum, Governor, "You must have population in the star system to attempt insurgency\n.");
  375. X        return;
  376. X    }
  377. X    getplanet(&p, Dir[Playernum - 1][Governor].snum, Dir[Playernum - 1][Governor].pnum);
  378. X
  379. X    if (!p->info[who - 1].popn) {
  380. X        notify(Playernum, Governor, "This player does not occupy this planet.\n");
  381. X        free(p);
  382. X        return;
  383. X    }
  384. X    sscanf(args[2], "%d", &amount);
  385. X    if (amount < 0) {
  386. X        notify(Playernum, Governor, "You have to use a positive amount of money.\n");
  387. X        free(p);
  388. X        return;
  389. X    }
  390. X    if (Race->governor[Governor].money < amount) {
  391. X        notify(Playernum, Governor, "Nice try.\n");
  392. X        free(p);
  393. X        return;
  394. X    }
  395. X    x = INSURG_FACTOR * (double) amount *
  396. X                    (double) p->info[who - 1].tax / (double) p->info[who - 1].popn;
  397. X    x *= morale_factor((double) (Race->morale - alien->morale));
  398. X    x *= morale_factor((double) (eligible - them) / 50.0);
  399. X    x *= morale_factor(10.0 * (double) (Race->fighters * p->info[Playernum - 1].troops -
  400. X             alien->fighters * p->info[who - 1].troops)) / 50.0;
  401. X    sprintf(buf, "x = %f\n", x);
  402. X    notify(Playernum, Governor, buf);
  403. X    chance = round_rand(200.0 * atan((double) x) / 3.14159265);
  404. X    sprintf(long_buf, "%s/%s: %s [%d] tries insurgency vs %s [%d]\n",
  405. X        Stars[Dir[Playernum - 1][Governor].snum]->name,
  406. X        Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum],
  407. X        Race->name, Playernum, alien->name, who);
  408. X    sprintf(buf, "\t%s: %d total civs [%d]  opposing %d total civs [%d]\n",
  409. X        Stars[Dir[Playernum - 1][Governor].snum]->name,
  410. X        eligible, Playernum, them, who);
  411. X    strcat(long_buf, buf);
  412. X    sprintf(buf, "\t\t %d morale [%d] vs %d morale [%d]\n",
  413. X        Race->morale, Playernum, alien->morale, who);
  414. X    strcat(long_buf, buf);
  415. X    sprintf(buf, "\t\t %d money against %d population at tax rate %d%%\n",
  416. X        amount, p->info[who - 1].popn, p->info[who - 1].tax);
  417. X    strcat(long_buf, buf);
  418. X    sprintf(buf, "Success chance is %d%%\n", chance);
  419. X    strcat(long_buf, buf);
  420. X    if (success(chance)) {
  421. X        changed_hands = revolt(p, who, Playernum);
  422. X        notify(Playernum, Governor, long_buf);
  423. X        sprintf(buf, "Success!  You liberate %d sector%s.\n", changed_hands,
  424. X            (changed_hands == 1) ? "" : "s");
  425. X        notify(Playernum, Governor, buf);
  426. X        sprintf(buf,
  427. X            "A revolt on /%s/%s instigated by %s [%d] costs you %d sector%s\n",
  428. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  429. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum],
  430. X            Race->name, Playernum,
  431. X            changed_hands, (changed_hands == 1) ? "" : "s");
  432. X        strcat(long_buf, buf);
  433. X        warn(who, (int) Stars[Dir[Playernum - 1][Governor].snum]->governor[who - 1], long_buf);
  434. X        p->info[Playernum - 1].tax = p->info[who - 1].tax;
  435. X        /* you inherit their tax rate (insurgency wars he he ) */
  436. X        sprintf(buf, "/%s/%s: Successful insurgency by %s [%d] against %s [%d]\n",
  437. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  438. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum],
  439. X            Race->name, Playernum, alien->name, who);
  440. X        post(buf, DECLARATION);
  441. X    } else {
  442. X        notify(Playernum, Governor, long_buf);
  443. X        notify(Playernum, Governor, "The insurgency failed!\n");
  444. X        sprintf(buf,
  445. X            "A revolt on /%s/%s instigated by %s [%d] fails\n",
  446. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  447. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum],
  448. X            Race->name, Playernum);
  449. X        strcat(long_buf, buf);
  450. X        warn(who, (int) Stars[Dir[Playernum - 1][Governor].snum]->governor[who - 1], long_buf);
  451. X        sprintf(buf, "/%s/%s: Failed insurgency by %s [%d] against %s [%d]\n",
  452. X            Stars[Dir[Playernum - 1][Governor].snum]->name,
  453. X            Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum],
  454. X            Race->name, Playernum, alien->name, who);
  455. X        post(buf, DECLARATION);
  456. X    }
  457. X    deductAPs(Playernum, Governor, APcount, Dir[Playernum - 1][Governor].snum, 0);
  458. X    Race->governor[Governor].money -= amount;
  459. X    putrace(Race);
  460. X    free(p);
  461. X}
  462. X
  463. Xvoid 
  464. Xpay(int Playernum, int Governor, int APcount)
  465. X{
  466. X    int             who, amount;
  467. X    racetype       *Race, *alien;
  468. X
  469. X    if (!(who = GetPlayer(args[1]))) {
  470. X        sprintf(buf, "No such player.\n");
  471. X        notify(Playernum, Governor, buf);
  472. X        return;
  473. X    }
  474. X    if (Governor) {
  475. X        notify(Playernum, Governor, "You are not authorized to do that.\n");
  476. X        return;
  477. X    }
  478. X    Race = races[Playernum - 1];
  479. X    alien = races[who - 1];
  480. X
  481. X    sscanf(args[2], "%d", &amount);
  482. X    if (amount < 0) {
  483. X        notify(Playernum, Governor, "You have to give a player a positive amount of money.\n");
  484. X        return;
  485. X    }
  486. X    if (Race->Guest) {
  487. X        notify(Playernum, Governor, "Nice try. Your attempt has been duly noted.\n");
  488. X        return;
  489. X    }
  490. X    if (Race->governor[Governor].money < amount) {
  491. X        notify(Playernum, Governor, "You don't have that much money to give!\n");
  492. X        return;
  493. X    }
  494. X    Race->governor[Governor].money -= amount;
  495. X    alien->governor[0].money += amount;
  496. X    sprintf(buf, "%s [%d] payed you %d.\n", Race->name, Playernum, amount);
  497. X    warn(who, 0, buf);
  498. X    sprintf(buf, "%d payed to %s [%d].\n", amount, alien->name, who);
  499. X    notify(Playernum, Governor, buf);
  500. X
  501. X    sprintf(buf, "%s [%d] pays %s [%d].\n", Race->name,
  502. X        Playernum, alien->name, who);
  503. X    post(buf, TRANSFER);
  504. X
  505. X    putrace(alien);
  506. X    putrace(Race);
  507. X}
  508. X
  509. Xvoid 
  510. Xgive(int Playernum, int Governor, int APcount)
  511. X{
  512. X    int             who, sh;
  513. X    shiptype       *ship;
  514. X    planettype     *planet;
  515. X    racetype       *Race, *alien;
  516. X
  517. X    if (!(who = GetPlayer(args[1]))) {
  518. X        sprintf(buf, "No such player.\n");
  519. X        notify(Playernum, Governor, buf);
  520. X        return;
  521. X    }
  522. X    if (Governor) {
  523. X        notify(Playernum, Governor, "You are not authorized to do that.\n");
  524. X        return;
  525. X    }
  526. X    alien = races[who - 1];
  527. X    Race = races[Playernum - 1];
  528. X    if (alien->Guest && !Race->God) {
  529. X        notify(Playernum, Governor, "You can't give this player anything.\n");
  530. X        return;
  531. X    }
  532. X    if (Race->Guest) {
  533. X        notify(Playernum, Governor, "You can't give anyone anything.\n");
  534. X        return;
  535. X    }
  536. X    /* check to see if both players are mutually allied */
  537. X    if (!Race->God &&
  538. X        !(isset(Race->allied, who) && isset(alien->allied, Playernum))) {
  539. X        notify(Playernum, Governor, "You two are not mutually allied.\n");
  540. X        return;
  541. X    }
  542. X    sscanf(args[2] + (args[2][0] == '#'), "%d", &sh);
  543. X
  544. X    if (!getship(&ship, sh)) {
  545. X        notify(Playernum, Governor, "Illegal ship number.\n");
  546. X        return;
  547. X    }
  548. X    if (ship->owner != Playernum || !ship->alive) {
  549. X        DontOwnErr(Playernum, Governor, sh);
  550. X        free(ship);
  551. X        return;
  552. X    }
  553. X    if (ship->type == STYPE_POD) {
  554. X        notify(Playernum, Governor, "You cannot change the ownership of spore pods.\n");
  555. X        free(ship);
  556. X        return;
  557. X    }
  558. X    if ((ship->popn + ship->troops) && !Race->God) {
  559. X        notify(Playernum, Governor, "You can't give this ship away while it has crew/mil on board.\n");
  560. X        free(ship);
  561. X        return;
  562. X    }
  563. X    if (ship->ships && !Race->God) {
  564. X        notify(Playernum, Governor, "You can't give away this ship, it has other ships loaded on it.\n");
  565. X        free(ship);
  566. X        return;
  567. X    }
  568. X    switch (ship->whatorbits) {
  569. X    case LEVEL_UNIV:
  570. X        if (!enufAP(Playernum, Governor, Sdata.AP[Playernum - 1], APcount)) {
  571. X            free(ship);
  572. X            return;
  573. X        }
  574. X        break;
  575. X    default:
  576. X        if (!enufAP(Playernum, Governor, Stars[Dir[Playernum - 1][Governor].snum]->AP[Playernum - 1], APcount)) {
  577. X            free(ship);
  578. X            return;
  579. X        }
  580. X        break;
  581. X    }
  582. X
  583. X    ship->owner = who;
  584. X    ship->governor = 0;    /* give to the leader */
  585. X    capture_stuff(ship);
  586. X
  587. X    putship(ship);
  588. X
  589. X    /* set inhabited/explored bits */
  590. X    switch (ship->whatorbits) {
  591. X    case LEVEL_UNIV:
  592. X        break;
  593. X    case LEVEL_STAR:
  594. X        getstar(&(Stars[ship->storbits]), (int) ship->storbits);
  595. X        setbit(Stars[ship->storbits]->explored, who);
  596. X        putstar(Stars[ship->storbits], (int) ship->storbits);
  597. X        break;
  598. X    case LEVEL_PLAN:
  599. X        getstar(&(Stars[ship->storbits]), (int) ship->storbits);
  600. X        setbit(Stars[ship->storbits]->explored, who);
  601. X        putstar(Stars[ship->storbits], (int) ship->storbits);
  602. X
  603. X        getplanet(&planet, (int) ship->storbits, (int) ship->pnumorbits);
  604. X        planet->info[who - 1].explored = 1;
  605. X        putplanet(planet, (int) ship->storbits, (int) ship->pnumorbits);
  606. X        free(planet);
  607. X
  608. X        break;
  609. X    default:
  610. X        notify(Playernum, Governor, "Something wrong with this ship's scope.\n");
  611. X        free(ship);
  612. X        return;
  613. X    }
  614. X
  615. X    switch (ship->whatorbits) {
  616. X    case LEVEL_UNIV:
  617. X        deductAPs(Playernum, Governor, APcount, 0, 1);
  618. X        free(ship);
  619. X        return;
  620. X    default:
  621. X        deductAPs(Playernum, Governor, APcount, Dir[Playernum - 1][Governor].snum, 0);
  622. X        break;
  623. X    }
  624. X    notify(Playernum, Governor, "Owner changed.\n");
  625. X    sprintf(buf, "%s [%d] gave you %s at %s.\n", Race->name, Playernum,
  626. X        Ship(ship), prin_ship_orbits(ship));
  627. X    warn(who, 0, buf);
  628. X
  629. X    if (!Race->God) {
  630. X        sprintf(buf, "%s [%d] gives %s [%d] a ship.\n", Race->name,
  631. X            Playernum, alien->name, who);
  632. X        post(buf, TRANSFER);
  633. X        free(ship);
  634. X    }
  635. X}
  636. X
  637. Xvoid 
  638. Xpage(int Playernum, int Governor, int APcount0)
  639. X{
  640. X    int             i, who, gov, to_block, dummy[2], APcount;
  641. X    racetype       *Race, *alien;
  642. X
  643. X    APcount = APcount0;
  644. X    if (!enufAP(Playernum, Governor, Stars[Dir[Playernum - 1][Governor].snum]->AP[Playernum - 1], APcount))
  645. X        return;
  646. X
  647. X    to_block = 0;
  648. X    if (match(args[1], "block")) {
  649. X        to_block = 1;
  650. X        notify(Playernum, Governor, "Paging alliance block.\n");
  651. X    } else {
  652. X        if (!(who = GetPlayer(args[1]))) {
  653. X            sprintf(buf, "No such player.\n");
  654. X            notify(Playernum, Governor, buf);
  655. X            return;
  656. X        }
  657. X        alien = races[who - 1];
  658. X        APcount *= !alien->God;
  659. X        if (argn > 1)
  660. X            gov = atoi(args[2]);
  661. X    }
  662. X
  663. X    switch (Dir[Playernum - 1][Governor].level) {
  664. X    case LEVEL_UNIV:
  665. X        sprintf(buf, "You can't make pages at universal scope.\n");
  666. X        notify(Playernum, Governor, buf);
  667. X        break;
  668. X    default:
  669. X        getstar(&Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  670. X        if (!enufAP(Playernum, Governor, Stars[Dir[Playernum - 1][Governor].snum]->AP[Playernum - 1], APcount)) {
  671. X            return;
  672. X        }
  673. X        Race = races[Playernum - 1];
  674. X
  675. X        sprintf(buf, "%s \"%s\" page(s) you from the %s star system.\n",
  676. X            Race->name, Race->governor[Governor].name,
  677. X            Stars[Dir[Playernum - 1][Governor].snum]->name);
  678. X
  679. X        if (to_block) {
  680. X            dummy[0] = Blocks[Playernum - 1].invite[0] & Blocks[Playernum - 1].pledge[0];
  681. X            dummy[1] = Blocks[Playernum - 1].invite[1] & Blocks[Playernum - 1].pledge[1];
  682. X            for (i = 1; i <= Num_races; i++)
  683. X                if (isset(dummy, i) && i != Playernum)
  684. X                    notify_race(i, buf);
  685. X        } else {
  686. X            if (argn > 1)
  687. X                notify(who, gov, buf);
  688. X            else
  689. X                notify_race(who, buf);
  690. X        }
  691. X
  692. X        notify(Playernum, Governor, "Request sent.\n");
  693. X        break;
  694. X    }
  695. X    deductAPs(Playernum, Governor, APcount, Dir[Playernum - 1][Governor].snum, 0);
  696. X}
  697. X
  698. Xvoid 
  699. Xsend_message(int Playernum, int Governor, int APcount0, int postit)
  700. X{
  701. X    int             who, i, j, to_block, dummy[2], APcount;
  702. X    int             to_star, star, start;
  703. X    placetype       where;
  704. X    racetype       *Race, *alien;
  705. X
  706. X    APcount = APcount0;
  707. X
  708. X    to_star = to_block = 0;
  709. X
  710. X    if (argn < 2) {
  711. X        notify(Playernum, Governor, "Send what?\n");
  712. X        return;
  713. X    }
  714. X    if (postit) {
  715. X        Race = races[Playernum - 1];
  716. X        sprintf(msg, "%s \"%s\" [%d,%d]: ",
  717. X            Race->name, Race->governor[Governor].name,
  718. X            Playernum, Governor);
  719. X        /* put the message together */
  720. X        for (j = 1; j < argn; j++) {
  721. X            sprintf(buf, "%s ", args[j]);
  722. X            strcat(msg, buf);
  723. X        }
  724. X        strcat(msg, "\n");
  725. X        post(msg, ANNOUNCE);
  726. X        return;
  727. X    }
  728. X    if (match(args[1], "block")) {
  729. X        to_block = 1;
  730. X        notify(Playernum, Governor, "Sending message to alliance block.\n");
  731. X        if (!(who = GetPlayer(args[2]))) {
  732. X            sprintf(buf, "No such alliance block.\n");
  733. X            notify(Playernum, Governor, buf);
  734. X            return;
  735. X        }
  736. X        alien = races[who - 1];
  737. X        APcount *= !alien->God;
  738. X    } else if (match(args[1], "star")) {
  739. X        to_star = 1;
  740. X        notify(Playernum, Governor, "Sending message to star system.\n");
  741. X        where = Getplace(Playernum, Governor, args[2], 1);
  742. X        if (where.err || where.level != LEVEL_STAR) {
  743. X            sprintf(buf, "No such star.\n");
  744. X            notify(Playernum, Governor, buf);
  745. X            return;
  746. X        }
  747. X        star = where.snum;
  748. X        getstar(&(Stars[star]), star);
  749. X    } else {
  750. X        if (!(who = GetPlayer(args[1]))) {
  751. X            sprintf(buf, "No such player.\n");
  752. X            notify(Playernum, Governor, buf);
  753. X            return;
  754. X        }
  755. X        alien = races[who - 1];
  756. X        APcount *= !alien->God;
  757. X    }
  758. X
  759. X    switch (Dir[Playernum - 1][Governor].level) {
  760. X    case LEVEL_UNIV:
  761. X        sprintf(buf, "You can't send messages from universal scope.\n");
  762. X        notify(Playernum, Governor, buf);
  763. X        return;
  764. X
  765. X    case LEVEL_SHIP:
  766. X        sprintf(buf, "You can't send messages from ship scope.\n");
  767. X        notify(Playernum, Governor, buf);
  768. X        return;
  769. X
  770. X    default:
  771. X        getstar(&Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  772. X        if (!enufAP(Playernum, Governor, Stars[Dir[Playernum - 1][Governor].snum]->AP[Playernum - 1], APcount))
  773. X            return;
  774. X        break;
  775. X    }
  776. X
  777. X    Race = races[Playernum - 1];
  778. X
  779. X    /* send the message */
  780. X    if (to_block)
  781. X        sprintf(msg, "%s \"%s\" [%d,%d] to %s [%d]: ", Race->name,
  782. X            Race->governor[Governor].name, Playernum, Governor,
  783. X            Blocks[who - 1].name, who);
  784. X    else if (to_star)
  785. X        sprintf(msg, "%s \"%s\" [%d,%d] to inhabitants of %s: ", Race->name,
  786. X            Race->governor[Governor].name, Playernum,
  787. X            Governor, Stars[star]->name);
  788. X    else
  789. X        sprintf(msg, "%s \"%s\" [%d,%d]: ", Race->name,
  790. X            Race->governor[Governor].name, Playernum, Governor);
  791. X
  792. X    if (to_star || to_block || isdigit(*args[2]))
  793. X        start = 3;
  794. X    else if (postit)
  795. X        start = 1;
  796. X    else
  797. X        start = 2;
  798. X    /* put the message together */
  799. X    for (j = start; j < argn; j++) {
  800. X        sprintf(buf, "%s ", args[j]);
  801. X        strcat(msg, buf);
  802. X    }
  803. X    /* post it */
  804. X    sprintf(buf, "%s \"%s\" [%d,%d] has sent you a telegram. Use `read' to read it.\n",
  805. X        Race->name, Race->governor[Governor].name,
  806. X        Playernum, Governor);
  807. X    if (to_block) {
  808. X        dummy[0] = (Blocks[who - 1].invite[0] & Blocks[who - 1].pledge[0]);
  809. X        dummy[1] = (Blocks[who - 1].invite[1] & Blocks[who - 1].pledge[1]);
  810. X        sprintf(buf, "%s \"%s\" [%d,%d] sends a message to %s [%d] alliance block.\n",
  811. X            Race->name, Race->governor[Governor].name, Playernum, Governor,
  812. X            Blocks[who - 1].name, who);
  813. X        for (i = 1; i <= Num_races; i++) {
  814. X            if (isset(dummy, i)) {
  815. X                notify_race(i, buf);
  816. X                push_telegram_race(i, msg);
  817. X            }
  818. X        }
  819. X    } else if (to_star) {
  820. X        sprintf(buf, "%s \"%s\" [%d,%d] sends a stargram to %s.\n", Race->name,
  821. X            Race->governor[Governor].name, Playernum,
  822. X            Governor, Stars[star]->name);
  823. X        notify_star(Playernum, Governor, 0, star, buf);
  824. X        warn_star(Playernum, 0, star, msg);
  825. X    } else {
  826. X        int             gov;
  827. X        if (who == Playernum)
  828. X            APcount = 0;
  829. X        if (isdigit(*args[2]) && (gov = atoi(args[2])) >= 0 && gov <= MAXGOVERNORS) {
  830. X            push_telegram(who, gov, msg);
  831. X            notify(who, gov, buf);
  832. X        } else {
  833. X            push_telegram_race(who, msg);
  834. X            notify_race(who, buf);
  835. X        }
  836. X
  837. X        alien = races[who - 1];
  838. X        /* translation modifier increases */
  839. X        alien->translate[Playernum - 1] = MIN(alien->translate[Playernum - 1] + 2, 100);
  840. X        putrace(alien);
  841. X    }
  842. X    notify(Playernum, Governor, "Message sent.\n");
  843. X    deductAPs(Playernum, Governor, APcount, Dir[Playernum - 1][Governor].snum, 0);
  844. X}
  845. X
  846. Xvoid 
  847. Xread_messages(int Playernum, int Governor, int APcount)
  848. X{
  849. X    if (argn == 1 || match(args[1], "telegram"))
  850. X        teleg_read(Playernum, Governor);
  851. X    else if (match(args[1], "news")) {
  852. X        notify(Playernum, Governor, CUTE_MESSAGE);
  853. X        notify(Playernum, Governor, "\n----------        Declarations        ----------\n");
  854. X        news_read(Playernum, Governor, DECLARATION);
  855. X        notify(Playernum, Governor, "\n----------           Combat           ----------\n");
  856. X        news_read(Playernum, Governor, COMBAT);
  857. X        notify(Playernum, Governor, "\n----------          Business          ----------\n");
  858. X        news_read(Playernum, Governor, TRANSFER);
  859. X        notify(Playernum, Governor, "\n----------          Bulletins         ----------\n");
  860. X        news_read(Playernum, Governor, ANNOUNCE);
  861. X    } else
  862. X        notify(Playernum, Governor, "Read what?\n");
  863. X}
  864. X
  865. Xvoid 
  866. Xmotto(int Playernum, int Governor, int APcount, char *message)
  867. X{
  868. X    if (Governor) {
  869. X        notify(Playernum, Governor, "You are not authorized to do this.\n");
  870. X        return;
  871. X    }
  872. X    strncpy(Blocks[Playernum - 1].motto, message, MOTTOSIZE - 1);
  873. X    Putblock(Blocks);
  874. X    notify(Playernum, Governor, "Done.\n");
  875. X}
  876. X
  877. Xvoid 
  878. Xname(int Playernum, int Governor, int APcount)
  879. X{
  880. X    char           *ch;
  881. X    register int    i, spaces;
  882. X    int             len;
  883. X    unsigned char   check = 0;
  884. X    shiptype       *ship;
  885. X    char            string[1024];
  886. X    char            temp[128];
  887. X    racetype       *Race;
  888. X
  889. X    if (!isalnum(args[2][0]) || argn < 3) {
  890. X        notify(Playernum, Governor, "Illegal name format.\n");
  891. X        return;
  892. X    }
  893. X    sprintf(buf, "%s", args[2]);
  894. X    for (i = 3; i < argn; i++) {
  895. X        sprintf(temp, " %s", args[i]);
  896. X        strcat(buf, temp);
  897. X    }
  898. X
  899. X    sprintf(string, "%s", buf);
  900. X
  901. X    i = strlen(args[0]);
  902. X
  903. X    /*
  904. X     * make sure there are no ^'s or '/' in name, also make sure the name
  905. X     * has at least 1 character in it
  906. X     */
  907. X    ch = string;
  908. X    spaces = 0;
  909. X    while (*ch != '\0') {
  910. X        check |= ((!isalnum(*ch) && !(*ch == ' ') && !(*ch == '.')) || (*ch == '/'));
  911. X        ch++;
  912. X        if (*ch == ' ')
  913. X            spaces++;
  914. X    }
  915. X
  916. X    len = strlen(buf);
  917. X    if (spaces == strlen(buf)) {
  918. X        notify(Playernum, Governor, "Illegal name.\n");
  919. X        return;
  920. X    }
  921. X    if (strlen(buf) < 1 || check) {
  922. X        sprintf(buf, "Illegal name %s.\n", check ? "form" : "length");
  923. X        notify(Playernum, Governor, buf);
  924. X        return;
  925. X    }
  926. X    if (match(args[1], "ship")) {
  927. X        if (Dir[Playernum - 1][Governor].level == LEVEL_SHIP) {
  928. X            (void) getship(&ship, Dir[Playernum - 1][Governor].shipno);
  929. X            strncpy(ship->name, buf, SHIP_NAMESIZE);
  930. X            putship(ship);
  931. X            notify(Playernum, Governor, "Name set.\n");
  932. X            free(ship);
  933. X            return;
  934. X        } else {
  935. X            notify(Playernum, Governor, "You have to 'cs' to a ship to name it.\n");
  936. X            return;
  937. X        }
  938. X    } else if (match(args[1], "class")) {
  939. X        if (Dir[Playernum - 1][Governor].level == LEVEL_SHIP) {
  940. X            (void) getship(&ship, Dir[Playernum - 1][Governor].shipno);
  941. X            if (ship->type != OTYPE_FACTORY) {
  942. X                notify(Playernum, Governor, "You are not at a factory!\n");
  943. X                free(ship);
  944. X                return;
  945. X            }
  946. X            if (ship->on) {
  947. X                notify(Playernum, Governor, "This factory is already on line.\n");
  948. X                free(ship);
  949. X                return;
  950. X            }
  951. X            strncpy(ship->class, buf, SHIP_NAMESIZE - 1);
  952. X            putship(ship);
  953. X            notify(Playernum, Governor, "Class set.\n");
  954. X            free(ship);
  955. X            return;
  956. X        } else {
  957. X            notify(Playernum, Governor, "You have to 'cs' to a factory to name the ship class.\n");
  958. X            return;
  959. X        }
  960. X    } else if (match(args[1], "block")) {
  961. X        /* name your alliance block */
  962. X        if (Governor) {
  963. X            notify(Playernum, Governor, "You are not authorized to do this.\n");
  964. X            return;
  965. X        }
  966. X        strncpy(Blocks[Playernum - 1].name, buf, RNAMESIZE - 1);
  967. X        Putblock(Blocks);
  968. X        notify(Playernum, Governor, "Done.\n");
  969. X    } else if (match(args[1], "star")) {
  970. X        if (Dir[Playernum - 1][Governor].level == LEVEL_STAR) {
  971. X            Race = races[Playernum - 1];
  972. X            if (!Race->God) {
  973. X                notify(Playernum, Governor, "Only dieties may name a star.\n");
  974. X                return;
  975. X            }
  976. X            strncpy(Stars[Dir[Playernum - 1][Governor].snum]->name, buf, NAMESIZE - 1);
  977. X            putstar(Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  978. X        } else {
  979. X            notify(Playernum, Governor, "You have to 'cs' to a star to name it.\n");
  980. X            return;
  981. X        }
  982. X    } else if (match(args[1], "planet")) {
  983. X        if (Dir[Playernum - 1][Governor].level == LEVEL_PLAN) {
  984. X            getstar(&Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  985. X            Race = races[Playernum - 1];
  986. X            if (!Race->God) {
  987. X                notify(Playernum, Governor, "Only deity can rename planets.\n");
  988. X                return;
  989. X            }
  990. X            strncpy(Stars[Dir[Playernum - 1][Governor].snum]->pnames[Dir[Playernum - 1][Governor].pnum],
  991. X                buf, NAMESIZE - 1);
  992. X            putstar(Stars[Dir[Playernum - 1][Governor].snum], Dir[Playernum - 1][Governor].snum);
  993. X            deductAPs(Playernum, Governor, APcount, Dir[Playernum - 1][Governor].snum, 0);
  994. X        } else {
  995. X            notify(Playernum, Governor, "You have to 'cs' to a planet to name it.\n");
  996. X            return;
  997. X        }
  998. X    } else if (match(args[1], "race")) {
  999. X        Race = races[Playernum - 1];
  1000. X        if (Governor) {
  1001. X            notify(Playernum, Governor, "You are not authorized to do this.\n");
  1002. X            return;
  1003. X        }
  1004. X        strncpy(Race->name, buf, RNAMESIZE - 1);
  1005. X        sprintf(buf, "Name changed to `%s'.\n", Race->name);
  1006. X        notify(Playernum, Governor, buf);
  1007. X        putrace(Race);
  1008. X    } else if (match(args[1], "governor")) {
  1009. X        Race = races[Playernum - 1];
  1010. X        strncpy(Race->governor[Governor].name, buf, RNAMESIZE - 1);
  1011. X        sprintf(buf, "Name changed to `%s'.\n", Race->governor[Governor].name);
  1012. X        notify(Playernum, Governor, buf);
  1013. X        putrace(Race);
  1014. X    } else {
  1015. X        notify(Playernum, Governor, "I don't know what you mean.\n");
  1016. X        return;
  1017. X    }
  1018. X}
  1019. X
  1020. Xint 
  1021. XMostAPs(int Playernum, startype * s)
  1022. X{
  1023. X    register int    i, t = 0;
  1024. X
  1025. X    for (i = 0; i < MAXPLAYERS; i++)
  1026. X        if (s->AP[i] >= t)
  1027. X            t = s->AP[i];
  1028. X
  1029. X    return (s->AP[Playernum - 1] == t);
  1030. X}
  1031. X
  1032. Xvoid 
  1033. Xannounce(int Playernum, int Governor, char *message, int mode, int override)
  1034. X{
  1035. X    racetype       *Race;
  1036. X    char            symbol;
  1037. X    int             channel_to_send_on = COMM_CHANNEL1;
  1038. X
  1039. X    Race = races[Playernum - 1];
  1040. X
  1041. X#ifdef MULTIPLE_COMM_CHANNELS
  1042. X
  1043. X    if (!override) {
  1044. X        if (isset(races[Playernum -1]->governor[Governor].channel, 
  1045. X            COMM_DEF_CHANNEL1))
  1046. X            channel_to_send_on = COMM_CHANNEL1;
  1047. X        else if (isset(races[Playernum -1]->governor[Governor].channel, 
  1048. X            COMM_DEF_CHANNEL2))
  1049. X            channel_to_send_on = COMM_CHANNEL2;
  1050. X        else if (isset(races[Playernum -1]->governor[Governor].channel, 
  1051. X            COMM_DEF_CHANNEL3))
  1052. X            channel_to_send_on = COMM_CHANNEL3;
  1053. X        else {
  1054. X            channel_to_send_on = COMM_CHANNEL1;
  1055. X            notify(Playernum, Governor, "No default channel specifed, sending on 1\n");
  1056. X        }
  1057. X    } else 
  1058. X        channel_to_send_on = override;
  1059. X#endif
  1060. X
  1061. X    if (mode == SHOUT && !Race->God) {
  1062. X        notify(Playernum, Governor, "You are not privileged to use this command.\n");
  1063. X        return;
  1064. X    }
  1065. X    switch (Dir[Playernum - 1][Governor].level) {
  1066. X    case LEVEL_UNIV:
  1067. X        if (mode == ANN)
  1068. X            mode = BROADCAST;
  1069. X        break;
  1070. X    default:
  1071. X        if ((mode == ANN) &&
  1072. X            !(!!isset(Stars[Dir[Playernum - 1][Governor].snum]->inhabited, Playernum)
  1073. X              || Race->God)) {
  1074. X            sprintf(buf,
  1075. X                "You do not inhabit this system or have diety privileges.\n");
  1076. X            notify(Playernum, Governor, buf);
  1077. X            return;
  1078. X        }
  1079. X    }
  1080. X
  1081. X    switch (mode) {
  1082. X    case ANN:
  1083. X        symbol = ':';
  1084. X        break;
  1085. X    case BROADCAST:
  1086. X        symbol = '>';
  1087. X        break;
  1088. X    case SHOUT:
  1089. X        symbol = '!';
  1090. X        break;
  1091. X    case THINK:
  1092. X        symbol = '=';
  1093. X        break;
  1094. X    }
  1095. X#ifdef MULTIPLE_COMM_CHANNELS
  1096. X    sprintf(msg, "%s \"%s\" [%d,%d] %d %c%s\n", Race->name,
  1097. X        Race->governor[Governor].name, Playernum, Governor,
  1098. X        channel_to_send_on, symbol, message);
  1099. X#else
  1100. X    sprintf(msg, "%s \"%s\" [%d,%d] %c %s\n", Race->name,
  1101. X        Race->governor[Governor].name, Playernum, Governor,
  1102. X        symbol, message);
  1103. X#endif 
  1104. X
  1105. X    switch (mode) {
  1106. X    case ANN:
  1107. X        d_announce(Playernum, Governor, Dir[Playernum - 1][Governor].snum, msg);
  1108. X        break;
  1109. X    case BROADCAST:
  1110. X        d_broadcast(Playernum, Governor, msg, channel_to_send_on);
  1111. X        break;
  1112. X    case SHOUT:
  1113. X        d_shout(Playernum, Governor, msg);
  1114. X        break;
  1115. X    case THINK:
  1116. X        d_think(Playernum, Governor, msg);
  1117. X        break;
  1118. X    default:
  1119. X        break;
  1120. X    }
  1121. X}
  1122. END_OF_FILE
  1123. if test 34058 -ne `wc -c <'user/name.c'`; then
  1124.     echo shar: \"'user/name.c'\" unpacked with wrong size!
  1125. fi
  1126. # end of 'user/name.c'
  1127. fi
  1128. if test -f 'utils/makeplanet.c' -a "${1}" != "-c" ; then 
  1129.   echo shar: Will not clobber existing file \"'utils/makeplanet.c'\"
  1130. else
  1131. echo shar: Extracting \"'utils/makeplanet.c'\" \(16391 characters\)
  1132. sed "s/^X//" >'utils/makeplanet.c' <<'END_OF_FILE'
  1133. X/* makeplanet.c -- makes one planet.
  1134. X *
  1135. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  1136. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  1137. X * Restrictions in GB_copyright.h.
  1138. X */
  1139. X#include "GB_copyright.h"
  1140. X
  1141. X#define MAP_ISLANDS 3        /* # of beginning islands for makeuniv */
  1142. X#define MAP_MOUNT_PERCENT 0.22    /* percentage of mountain areas */
  1143. X#define MAP_DESERT_PERCENT 0.10    /* percent of desert areas */
  1144. X#define MAP_GASGIANT_BANDMIN 20  /* min size gasgiants that have bands */
  1145. X#define LANDPERCENTAGE int_rand(20,70)/100
  1146. X#define POLEFUDGE 10
  1147. X
  1148. X#define EXTERN extern
  1149. X#include "vars.h"
  1150. X#include <math.h>
  1151. X
  1152. Xextern double double_rand(void);
  1153. Xextern int int_rand(int, int);
  1154. Xextern int round_rand(double);
  1155. Xextern int rposneg(void);
  1156. X
  1157. X
  1158. X/*             @   o   O   #   ~   .   (   -    */
  1159. Xint xmin[] = {15,  1,  4,  4, 30,  6, 10, 10} ;
  1160. Xint xmax[] = {23,  3,  8,  8, 36, 15, 20, 25} ;
  1161. X
  1162. X/*             @   o   O   #   ~   .   (   -    */
  1163. Xint fmin[] = {20,  1,  1, 35, 32, 25, 60,  1} ;
  1164. Xint fmax[] = {45,  2,  8, 55, 52, 55, 80, 20} ;
  1165. X
  1166. X
  1167. X/*               .    *    ^    ~  */
  1168. Xint rmin[]  = {150, 120, 200,  20} ;
  1169. Xint rmax1[] = {200, 120, 600,  20} ;
  1170. Xint rmax2[] = {200, 300, 600,  60} ;
  1171. X
  1172. X/*               @      o     O    #    ~    .       (       _  */
  1173. Xint type1[] = {SEA, MOUNT, LAND, SEA, GAS, SEA,   LAND,   LAND};
  1174. Xint cond1[] = {SEA, MOUNT, LAND, ICE, GAS, SEA, FOREST, DESERT};
  1175. X
  1176. X#define RES_GAS int_rand(rmin[GAS], int_rand(rmax[GAS], rmax1[GAS]));
  1177. X#define RES_MOUNT int_rand(rmin[MOUNT], int_rand(rmax1[MOUNT], rmax1[MOUNT])) ;
  1178. X#define RES_LAND int_rand(rmin[LAND], int_rand(rmax1[LAND], rmax1[LAND])) ;
  1179. X#define RES_SEA int_rand(rmin[SEA], int_rand(rmax1[SEA], rmax1[SEA])) ;
  1180. X
  1181. X#if 0
  1182. X/* Define this for old-style GG's, which had bands of water (?) on them: */
  1183. X#define MAKE_WATERY_JOVIANS
  1184. X#endif
  1185. X
  1186. Xextern int    Temperature(double, int);
  1187. X
  1188. Xdouble DistmapSq(int, int, int, int);
  1189. Xvoid   MakeEarthAtmosphere(planettype *, int);
  1190. Xint    Numneighbors(planettype *, int, int, int);
  1191. Xint    SectorTemp(planettype *, int, int);
  1192. Xvoid   Smashup(planettype *, double, char, int, int, int);
  1193. Xint    Volcano(planettype *, int, int, int, char);
  1194. Xvoid   Makesurface(planettype *);
  1195. Xshort  SectTemp(planettype *, int);
  1196. Xplanettype Makeplanet(double, short, int);
  1197. X
  1198. Xplanettype Makeplanet(double dist, short stemp, int type)
  1199. X{
  1200. X    reg int x, y ;
  1201. X    sectortype *s ;
  1202. X    planettype planet ;
  1203. X    int i, atmos, landsects, Numlandsects, cont_type ;
  1204. X    int desert;
  1205. X    short rowtemp;
  1206. X    char c, t;
  1207. X    double f;
  1208. X    
  1209. X    Bzero(planet);
  1210. X    bzero((char *)Smap, sizeof(Smap));
  1211. X    planet.type = type;
  1212. X    planet.expltimer = 5;
  1213. X    planet.conditions[TEMP] = planet.conditions[RTEMP] = Temperature(dist, stemp);
  1214. X  
  1215. X    planet.Maxx = int_rand(xmin[type], xmax[type]) ;
  1216. X    f = (double)planet.Maxx / RATIOXY;
  1217. X    planet.Maxy = round_rand(f) + 1;
  1218. X    if(!(planet.Maxy % 2))
  1219. X    planet.Maxy++;        /* make odd number of latitude bands */
  1220. X
  1221. X    if (type == TYPE_ASTEROID)
  1222. X    planet.Maxy = int_rand(1, 3) ;   /* Asteroids have funny shapes. */
  1223. X
  1224. X    t = type1[type];
  1225. X    c = cond1[type];
  1226. X
  1227. X    if ((type == TYPE_ASTEROID) && (!int_rand(0, 4)))
  1228. X    c = DESERT ;
  1229. X
  1230. X    for (y=0; y<planet.Maxy; y++) {
  1231. X    for (x=0; x<planet.Maxx; x++) {
  1232. X        s = &Sector(planet,x,y);
  1233. X        s->type = t;
  1234. X        s->condition = c;
  1235. X        s->fert = int_rand(fmin[type], fmax[type]) ;
  1236. X        s->resource = int_rand(rmin[t], int_rand(rmax1[t], rmax2[t])) ;
  1237. X    }
  1238. X    }
  1239. X  
  1240. X    switch (type) {
  1241. X      case TYPE_GASGIANT:        /* gas giant planet */
  1242. X    /* either lots of meth or not too much */
  1243. X    if (int_rand(0, 1)) {    /* methane planet */
  1244. X        atmos = 100 - (planet.conditions[METHANE] = int_rand(70, 80)); 
  1245. X        atmos -= planet.conditions[HYDROGEN] = int_rand(1, atmos/2);
  1246. X        atmos -= planet.conditions[HELIUM] = 1;
  1247. X        atmos -= planet.conditions[OXYGEN] = 0;
  1248. X        atmos -= planet.conditions[CO2] = 1;
  1249. X        atmos -= planet.conditions[NITROGEN] = int_rand(1, atmos/2);
  1250. X        atmos -= planet.conditions[SULFUR] = 0;
  1251. X        planet.conditions[OTHER] = atmos;
  1252. X    } else {
  1253. X        atmos = 100 - (planet.conditions[HYDROGEN] = int_rand(30,75));
  1254. X        atmos -= planet.conditions[HELIUM] = int_rand(20,atmos/2);
  1255. X        atmos -= planet.conditions[METHANE] = random()&01;
  1256. X        atmos -= planet.conditions[OXYGEN] = 0;
  1257. X        atmos -= planet.conditions[CO2] = random()&01;
  1258. X        atmos -= planet.conditions[NITROGEN] = int_rand(1,atmos/2);
  1259. X        atmos -= planet.conditions[SULFUR] = 0;
  1260. X        planet.conditions[OTHER] = atmos;
  1261. X    }
  1262. X#ifdef MAKE_WATERY_JOVIANS
  1263. X    if (planet.Maxx > MAP_GASGIANT_BANDMIN) {
  1264. X        int nbands = round_rand(planet.Maxy/7.0);
  1265. X        for (i=1; i<=nbands; i++) {
  1266. X        y = int_rand(1,planet.Maxy-2);
  1267. X        for (x=0; x<planet.Maxx; x++) {
  1268. X            s = &Sector(planet,x,y);
  1269. X            s->des = SEA;    /* make random bands of water */
  1270. X            s->resource = RES_SEA;
  1271. X            s->fert = int_rand(20,30);
  1272. X        }
  1273. X        }
  1274. X        for (i=0; i<=MAP_ISLANDS*6; i++) {
  1275. X        x=int_rand(0,planet.Maxx-1);
  1276. X        y=int_rand(0,planet.Maxy-1);
  1277. X        s = &Sector(planet,x,y);
  1278. X        s->des = SEA;    /* make random spots of water */
  1279. X        s->resource = RES_SEA;
  1280. X        s->fert = int_rand(60,90);
  1281. X        }
  1282. X    }
  1283. X#endif
  1284. X    break;
  1285. X      case TYPE_MARS:
  1286. X    planet.conditions[HYDROGEN] = 0;
  1287. X    planet.conditions[HELIUM] = 0;
  1288. X    planet.conditions[METHANE] = 0;
  1289. X    planet.conditions[OXYGEN] = 0;
  1290. X    if (random()&01) {    /* some have an atmosphere, some don't */
  1291. X        atmos = 100 - (planet.conditions[CO2] = int_rand(30,45));
  1292. X        atmos -= planet.conditions[NITROGEN] = int_rand(10, atmos/2);
  1293. X        atmos -= planet.conditions[SULFUR] = 
  1294. X        (random()&01) ? 0 : int_rand(20,atmos/2) ;
  1295. X        atmos -= planet.conditions[OTHER] = atmos;
  1296. X    } else {
  1297. X        planet.conditions[CO2] = 0;
  1298. X        planet.conditions[NITROGEN] = 0;
  1299. X        planet.conditions[SULFUR] = 0;
  1300. X        planet.conditions[OTHER] = 0;
  1301. X    }
  1302. X    Smashup(&planet, 1.5, MOUNT,  5, 1, 0);  /* make mountain ranges */
  1303. X    break;
  1304. X      case TYPE_ASTEROID:         /* asteroid */
  1305. X    /* no atmosphere */
  1306. X    for (y=0; y<planet.Maxy; y++)
  1307. X        for (x=0; x<planet.Maxx; x++)
  1308. X        if (!int_rand(0,3)) {
  1309. X            s = &Sector(planet, int_rand(1,planet.Maxx), 
  1310. X                int_rand(1,planet.Maxy));
  1311. X            s->type = LAND ;
  1312. X        }
  1313. X    break;
  1314. X      case TYPE_ICEBALL:        /* ball of ice */
  1315. X    /* no atmosphere */
  1316. X    planet.conditions[HYDROGEN] = 0;
  1317. X    planet.conditions[HELIUM] = 0;
  1318. X    planet.conditions[METHANE] = 0;
  1319. X    planet.conditions[OXYGEN] = 0;
  1320. X    if (planet.Maxx * planet.Maxy > int_rand(0,20)) {
  1321. X        atmos = 100 - (planet.conditions[CO2] = int_rand(30,45)) ;
  1322. X        atmos -= planet.conditions[NITROGEN] = int_rand(10, atmos/2) ;
  1323. X        atmos -= planet.conditions[SULFUR] = 
  1324. X        (random()&01) ? 0 : int_rand(20, atmos/2) ;
  1325. X        atmos -= planet.conditions[OTHER] = atmos ;
  1326. X    } else {
  1327. X        planet.conditions[CO2] = 0;
  1328. X        planet.conditions[NITROGEN] = 0;
  1329. X        planet.conditions[SULFUR] = 0;
  1330. X        planet.conditions[OTHER] = 0;
  1331. X    }
  1332. X    Smashup(&planet, double_rand(), MOUNT, 20, 0, 0);       
  1333. X    /* make some random mountains */
  1334. X    for (i=0; i<MAP_ISLANDS; i++) {
  1335. X        x = int_rand(0,planet.Maxx-1);
  1336. X        y = int_rand(0,planet.Maxy-1);
  1337. X        Sector(planet,x,y).type = MOUNT;
  1338. X        Sector(planet,x,y).condition = MOUNT;
  1339. X        Sector(planet,x,y).resource = RES_MOUNT;
  1340. X        Sector(planet,x,y).fert *= 0.3;
  1341. X    }
  1342. X    break;
  1343. X      case TYPE_EARTH:
  1344. X    MakeEarthAtmosphere(&planet, 1) ;
  1345. X    Numlandsects = planet.Maxx*planet.Maxy*LANDPERCENTAGE;
  1346. X    /* make first isolated islands */
  1347. X    for (i=0; i<MAP_ISLANDS; i++) {
  1348. X        s = &Sector(planet, int_rand(planet.Maxx/5,planet.Maxx-planet.Maxx/5),
  1349. X            int_rand(1,planet.Maxy-2));
  1350. X        s->type = LAND;  
  1351. X        s->condition = LAND;
  1352. X        s->resource = RES_LAND;
  1353. X        s->fert = int_rand(6,20);
  1354. X    }
  1355. X    landsects=0;
  1356. X    while (landsects<=Numlandsects)
  1357. X        landsects += Volcano(&planet, landsects, Numlandsects, 1, MOUNT);
  1358. X    /* make more isolated islands */
  1359. X    for (i=0; i<=MAP_ISLANDS*3; i++) {
  1360. X        x=int_rand(0,planet.Maxx-1);
  1361. X        y=int_rand(0,planet.Maxy-1);
  1362. X        s = &Sector(planet,x,y);
  1363. X        s->type = (int_rand(0,1) ? LAND : MOUNT);
  1364. X        s->condition = s->type;
  1365. X        s->resource = RES_LAND;
  1366. X        s->fert = int_rand(35,55) ;
  1367. X    }
  1368. X    break;
  1369. X      case TYPE_FOREST:
  1370. X    MakeEarthAtmosphere(&planet, 0) ;
  1371. X    Numlandsects = planet.Maxx*planet.Maxy*LANDPERCENTAGE;
  1372. X    /* make first isolated islands */
  1373. X    for (i=0; i<=MAP_ISLANDS; i++) {
  1374. X        x = int_rand(0, planet.Maxx-1) ;
  1375. X        y = int_rand(0, planet.Maxy-1) ;
  1376. X        s = &Sector(planet, x, y) ;
  1377. X        s->type = LAND;
  1378. X        s->condition = s->type;
  1379. X        s->resource = RES_LAND;
  1380. X        s->fert = int_rand(6,20);
  1381. X    }
  1382. X    landsects=0;
  1383. X    while (landsects<=Numlandsects)
  1384. X        landsects += Volcano(&planet, landsects, Numlandsects, 1, SEA);
  1385. X    landsects=0;
  1386. X    while (landsects<=Numlandsects)
  1387. X        landsects += Volcano(&planet, landsects, Numlandsects, 1, MOUNT);
  1388. X    Smashup(&planet, double_rand(), SEA, 20, 40,0);
  1389. X    
  1390. X    /* make more isolated islands */
  1391. X    for (i=0; i<=MAP_ISLANDS; i++) {
  1392. X        x=int_rand(0,planet.Maxx-1);
  1393. X        y=int_rand(0,planet.Maxy-1);
  1394. X        s = &Sector(planet,x,y);
  1395. X        s->type = int_rand(0,2) ? LAND : MOUNT;
  1396. X        s->condition = s->type;
  1397. X        s->resource = RES_LAND;
  1398. X        s->fert = int_rand(35,55) ;
  1399. X    }
  1400. X    break;
  1401. X      case TYPE_WATER:
  1402. X    MakeEarthAtmosphere(&planet, 2) ;
  1403. X    Smashup(&planet, double_rand()/2.0, LAND, 50, 50, 0);
  1404. X    Numlandsects = planet.Maxx*planet.Maxy*LANDPERCENTAGE;
  1405. X    cont_type = int_rand(0,3) ? LAND : MOUNT;
  1406. X    landsects=0;
  1407. X    while (landsects<=Numlandsects)
  1408. X        landsects += Volcano(&planet, landsects, Numlandsects, 1, cont_type); 
  1409. X    break;
  1410. X      case TYPE_DESERT:
  1411. X    MakeEarthAtmosphere(&planet, 2) ;
  1412. X    Smashup(&planet, double_rand(), LAND, 100, 20, 0);
  1413. X    Smashup(&planet, 1.0+double_rand(), MOUNT, 200, 10, 0);
  1414. X    Numlandsects = planet.Maxx*planet.Maxy*LANDPERCENTAGE;
  1415. X    landsects=0;
  1416. X    while (landsects<=Numlandsects)
  1417. X        landsects += Volcano(&planet, landsects, Numlandsects, 0, MOUNT); 
  1418. X    break;
  1419. X      default:
  1420. X    break;
  1421. X    }
  1422. X    Makesurface(&planet);  /* determine surface geology based on environment */
  1423. X  
  1424. X    /* make crystal deposits */
  1425. X    for (y=0; y<planet.Maxy; y++)
  1426. X    for (x=0; x<planet.Maxx; x++) {
  1427. X        s = &Sector(planet,x,y);
  1428. X        if(!int_rand(0, 200))
  1429. X        s->crystals=int_rand(1,10);
  1430. X        else
  1431. X        s->crystals = 0;
  1432. X    }
  1433. X    return planet;
  1434. X}
  1435. X
  1436. Xvoid MakeEarthAtmosphere(planettype *pptr, int chance)
  1437. X{
  1438. X    int atmos = 100 ;
  1439. X  
  1440. X    if (int_rand(0,chance)) {
  1441. X    /* oxygen-reducing atmosphere */
  1442. X    atmos -= pptr->conditions[OXYGEN] = int_rand(10, 25) ;
  1443. X    atmos -= pptr->conditions[NITROGEN] = int_rand(20, atmos-20);
  1444. X    atmos -= pptr->conditions[CO2] = int_rand(10, atmos/2);
  1445. X    atmos -= pptr->conditions[HELIUM] = int_rand(2, atmos/8+1);
  1446. X    atmos -= pptr->conditions[METHANE] = random()&01;
  1447. X    atmos -= pptr->conditions[SULFUR] = 0;
  1448. X    atmos -= pptr->conditions[HYDROGEN] = 0;
  1449. X    pptr->conditions[OTHER] = atmos;
  1450. X    } else {
  1451. X    /* methane atmosphere */
  1452. X    atmos -= pptr->conditions[METHANE] = int_rand(70, 80) ;
  1453. X    atmos -= pptr->conditions[HYDROGEN] = int_rand(1, atmos/2);
  1454. X    atmos -= pptr->conditions[HELIUM] = 1 + (random()&01) ;
  1455. X    atmos -= pptr->conditions[OXYGEN] = 0;
  1456. X    atmos -= pptr->conditions[CO2] = 1 + (random()&01) ;
  1457. X    atmos -= pptr->conditions[SULFUR] = (random()&01) ;
  1458. X    atmos -= pptr->conditions[NITROGEN] = int_rand(1, atmos/2);
  1459. X    pptr->conditions[OTHER] = atmos;
  1460. X    }
  1461. X}
  1462. X
  1463. X/* 
  1464. X * Smash psuedo-meteors into a planet
  1465. X */
  1466. Xvoid Smashup(planettype *pptr, double f, char desig, int res, int fert, 
  1467. X         int waste)
  1468. X{
  1469. X    reg int r,x,y;
  1470. X    reg int x2,y2, xx;
  1471. X    reg sectortype *s;
  1472. X    double rr ;
  1473. X    
  1474. X    int n = round_rand(f) ;
  1475. X  
  1476. X    while (n--) {
  1477. X    x = int_rand(0, pptr->Maxx-1);
  1478. X    y = int_rand(0, pptr->Maxy-1);
  1479. X    rr = 0.7 + double_rand() * int_rand(1, round_rand(pptr->Maxy/3.0)) ;
  1480. X    r = round_rand(rr) ;
  1481. X    rr *= rr ;
  1482. X    for (x2=x-r; x2<=x+r; x2++) {
  1483. X        if (x2 < 0)
  1484. X        xx = x2 + pptr->Maxx ;
  1485. X        else if (x2 >= pptr->Maxx)
  1486. X        xx = x2 - pptr->Maxx ;
  1487. X        else 
  1488. X        xx = x2 ;
  1489. X        for (y2=y-r; y2<=y+r; y2++) {
  1490. X        if (y2 < 0)
  1491. X            continue ;
  1492. X        if (y2 >= pptr->Maxy)
  1493. X            break ;
  1494. X        if (round_rand(rr - DistmapSq(x,y,x2,y2)) > 0) {
  1495. X            s = &Sector(*pptr, xx, y2) ;
  1496. X            s->type = desig ;
  1497. X            s->condition = s->type;
  1498. X            if (waste) s->condition = WASTED;
  1499. X            if (res)   s->resource += int_rand(res/2, res*2);
  1500. X            if (fert)  s->fert += int_rand(fert/2, fert*2);
  1501. X        }
  1502. X        }
  1503. X    }
  1504. X    }
  1505. X}
  1506. X
  1507. X
  1508. Xdouble DistmapSq(int x, int y, int x2, int y2)
  1509. X{
  1510. X#if 0
  1511. X    return fabs((double)(x-x2)) / RATIOXY + fabs( (double)(y-y2));
  1512. X#else
  1513. X    return (0.8*(x-x2)*(x-x2) + (y-y2)*(y-y2)) ;
  1514. X#endif
  1515. X}
  1516. X
  1517. X
  1518. Xint SectorTemp(planettype *pptr, int x, int y)
  1519. X{        
  1520. X    int p_x, p_xg ;       /* X of the pole, and the ghost pole. */
  1521. X    int p_y ;             /* Y of the nearest pole. */
  1522. X    double f, d ;         /* `distance' to pole. */
  1523. X    static double renorm[] = 
  1524. X    {0, 1.0/1.0, 2.0/2.0, 4.0/3.0, 6.0/4.0, 9.0/5.0, 12.0/6.0, 16.0/7.0,
  1525. X     20.0/8.0, 25.0/9.0, 30.0/10.0, 36.0/11.0, 42.0/12.0, 49.0/13.0} ;
  1526. X    /*                        @   o   O   #   ~   .   (   -    */
  1527. X    static int variance[] = {25, 40, 40, 40, 10, 20, 30, 30} ;
  1528. X    
  1529. X
  1530. X  /* I use pptr->sectormappos to calculate the pole position from.
  1531. X     This in spite of the fact that the two have nothing to do with each other.
  1532. X     I did it because (a) I don't want the pole to move, and sectormappos will
  1533. X     also not change, and (b) sectormappos will not show up to the player in
  1534. X     any other fashion. */
  1535. X    p_x = pptr->sectormappos % pptr->Maxx ;
  1536. X    if (y < (pptr->Maxy / 2.0))
  1537. X    p_y = -1 ;
  1538. X    else {
  1539. X    p_y = pptr->Maxy ;
  1540. X    p_x = p_x + pptr->Maxx / 2.0 ;
  1541. X    if (p_x >= pptr->Maxx)
  1542. X        p_x -= pptr->Maxx ;
  1543. X    }
  1544. X    if (p_x <= (pptr->Maxy / 2))
  1545. X    p_xg = p_x + pptr->Maxy ;
  1546. X    else
  1547. X    p_xg = p_x - pptr->Maxy ;
  1548. X    d = (y-p_y) * (y-p_y) ;
  1549. X
  1550. X    f = (x-p_x+0.2) / pptr->Maxx ;
  1551. X    if (f < 0.0)
  1552. X    f = -f ;
  1553. X    if (f > 0.5)
  1554. X    f = 1.0 - f ;
  1555. X    d = sqrt(d + f - 0.5) ;
  1556. X    return (pptr->conditions[RTEMP] + 
  1557. X        variance[pptr->type] * (d - renorm[pptr->Maxy])) ;
  1558. X}
  1559. X
  1560. Xint Volcano(planettype *pptr, int landsectors, int Numlandsects, 
  1561. X        int continent, char type)
  1562. X{        
  1563. X    reg int x,y;
  1564. X    sectortype *s;
  1565. X  
  1566. X    x = int_rand(0, pptr->Maxx-1);
  1567. X    y = int_rand(0, pptr->Maxy-1);
  1568. X    s = &Sector(*pptr,x,y);
  1569. X
  1570. X    if ((random() & 01) && (random() & 01))
  1571. X    return 1 ;
  1572. X    if ((continent) && 
  1573. X    (Numneighbors(pptr,x,y,LAND) || Numneighbors(pptr,x,y,type))) {
  1574. X   /*    s->des=(landsectors>(MAP_MOUNT_PERCENT*Numlandsects))?LAND:type;*/
  1575. X    s->type = int_rand(0,1) ? LAND : type;
  1576. X    s->condition = s->type;
  1577. X    s->resource = round_rand((double)(Numlandsects - landsectors + 5)
  1578. X                 / (double)Numlandsects * 100);
  1579. X    /* min content prop to dist from sea */
  1580. X    if (s->type == SEA)
  1581. X        s->fert = round_rand((double)(landsectors + 5) 
  1582. X                 / (double)Numlandsects * 100);
  1583. X    /* fert content prop to dist from center of continent */
  1584. X    return(1);
  1585. X    }
  1586. X    return(0) ;
  1587. X}
  1588. X
  1589. X
  1590. X/* 
  1591. X * Returns # of neighbors of a given designation that a sector has. 
  1592. X */
  1593. Xint Numneighbors(planettype *p, int x, int y, int des)
  1594. X{
  1595. X    int l = x - 1 ;
  1596. X    int r = x + 1 ;    /* Left and right columns. */
  1597. X    int n = 0 ;        /* Number of neighbors so far. */
  1598. X
  1599. X    if (x == 0)
  1600. X    l = p->Maxx - 1 ;
  1601. X    else if (r == p->Maxx)
  1602. X    r = 0 ;
  1603. X    if (y > 0)
  1604. X    n += (Sector(*p,x,y-1).type == des) ;
  1605. X    n += ((Sector(*p,l,y).type == des) +
  1606. X      (Sector(*p,r,y).type == des)) ;
  1607. X    if (y < p->Maxy-1)
  1608. X    n += (Sector(*p,x,y+1).type == des) ;
  1609. X    return n ;
  1610. X}
  1611. X
  1612. Xvoid Makesurface(planettype *p)
  1613. X{
  1614. X    reg int r,x,y;
  1615. X    reg int x2,y2, xx, temp;
  1616. X    reg sectortype *s;
  1617. X    double rr;
  1618. X
  1619. X    if(p->type==GAS) 
  1620. X    return;
  1621. X    for(x=0; x<p->Maxx; x++) {
  1622. X    for(y=0;y<p->Maxy; y++) {
  1623. X        s = &Sector(*p, x, y);
  1624. X        temp = SectTemp(p, y);
  1625. X        switch(s->type) {
  1626. X          case SEA:
  1627. X        if(success(-temp))
  1628. X            s->condition = ICE;
  1629. X        break;
  1630. X          case LAND:
  1631. X        if(success(-temp))
  1632. X            s->condition = ICE;
  1633. X        else if(success(temp/2))
  1634. X            s->condition = DESERT;
  1635. X        else if(success(p->conditions[CO2]+p->conditions[NITROGEN])) {
  1636. X            if(p->type==TYPE_FOREST) {
  1637. X            if(success(3*temp))
  1638. X                s->condition = FOREST;
  1639. X            } else if(p->type==TYPE_EARTH) {
  1640. X            if(success(temp))
  1641. X                s->condition = FOREST;
  1642. X            }
  1643. X        }
  1644. X        break;
  1645. X          case MOUNT:
  1646. X        if(success(-temp))
  1647. X            s->condition = ICE;
  1648. X        else if(success(temp/2))
  1649. X            s->condition = DESERT;
  1650. X        else if(success(p->conditions[CO2]+p->conditions[NITROGEN])) {
  1651. X            if(p->type==TYPE_FOREST) {
  1652. X            if(success(2*temp))
  1653. X                s->condition = FOREST;
  1654. X            } else if(p->type==TYPE_EARTH) {
  1655. X            if(success(temp))
  1656. X                s->condition = FOREST;
  1657. X            }
  1658. X        }
  1659. X        break;
  1660. X        }
  1661. X    }
  1662. X    }
  1663. X}
  1664. X
  1665. X#define TFAC 10
  1666. X
  1667. Xshort SectTemp(planettype *p, int y)
  1668. X{
  1669. X  register int i, dy, mid, temp;
  1670. X
  1671. X  temp = p->conditions[TEMP];
  1672. X  mid = (p->Maxy+1)/2-1;
  1673. X  dy = abs(y-mid);
  1674. X
  1675. X  temp -= TFAC*dy*dy;
  1676. X  return temp;
  1677. X/*  return(p->conditions[TEMP]); */
  1678. X}
  1679. END_OF_FILE
  1680. if test 16391 -ne `wc -c <'utils/makeplanet.c'`; then
  1681.     echo shar: \"'utils/makeplanet.c'\" unpacked with wrong size!
  1682. fi
  1683. # end of 'utils/makeplanet.c'
  1684. fi
  1685. echo shar: End of archive 6 \(of 21\).
  1686. cp /dev/null ark6isdone
  1687. MISSING=""
  1688. 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
  1689.     if test ! -f ark${I}isdone ; then
  1690.     MISSING="${MISSING} ${I}"
  1691.     fi
  1692. done
  1693. if test "${MISSING}" = "" ; then
  1694.     echo You have unpacked all 21 archives.
  1695.     echo "Now type './buildfiles.sh'"
  1696.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1697. else
  1698.     echo You still need to unpack the following archives:
  1699.     echo "        " ${MISSING}
  1700. fi
  1701. ##  End of shell archive.
  1702. exit 0
  1703.