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

  1. Path: uunet!news.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v17i019:  gbp - Galactic Bloodshed+, an empire-like war game, Part07/21
  5. Message-ID: <4547@master.CNA.TEK.COM>
  6. Date: 12 Feb 93 17:30:45 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1643
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1698
  11.  
  12. Submitted-by: deragon@harpo.cs.nyu.edu (Seeker)
  13. Posting-number: Volume 17, Issue 19
  14. Archive-name: gbp/Part07
  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 7 (of 21)."
  27. # Contents:  hdrs/proto.h server/doplanet.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/proto.h' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'hdrs/proto.h'\"
  32. else
  33. echo shar: Extracting \"'hdrs/proto.h'\" \(18590 characters\)
  34. sed "s/^X//" >'hdrs/proto.h' <<'END_OF_FILE'
  35. X#ident  "%W% %G% %Q%"
  36. X/***********************************************
  37. X * proto.h
  38. X *
  39. X * Created: Thu Jan 28 16:08:03 EST 1993
  40. X * Author:  J. Deragon (deragon@jethro.nyu.edu)
  41. X *
  42. X * Version: %I% %U%
  43. X * 
  44. X * File with ALL the function prototypes.
  45. X * (replaces numerous *.p)
  46. X */
  47. X
  48. X/* GB_server.c function prototypes */
  49. X
  50. Xextern void notify_race(int, char *);
  51. Xextern int notify(int, int, char *);
  52. Xextern void d_think(int, int, char *);
  53. Xextern void d_broadcast(int, int, char *, int);
  54. Xextern void d_shout(int, int, char *);
  55. Xextern void d_announce(int, int, int, char *);
  56. Xextern void do_next_thing(void);
  57. Xextern void load_race_data(void);
  58. Xextern void load_star_data(void);
  59. Xextern void GB_time(int, int);
  60. Xextern void GB_schedule(int, int);
  61. Xextern void check_for_telegrams(int, int);
  62. Xextern void kill_ship(int, shiptype *);
  63. Xextern void compute_power_blocks(void);
  64. Xextern void insert_sh_univ(struct stardata *, shiptype *);
  65. Xextern void insert_sh_star(startype *, shiptype *);
  66. Xextern void insert_sh_plan(planettype *, shiptype *);
  67. Xextern void insert_sh_ship(shiptype *, shiptype *);
  68. Xextern void remove_sh_star(shiptype *);
  69. Xextern void remove_sh_plan(shiptype *);
  70. Xextern void remove_sh_ship(shiptype *, shiptype *);
  71. Xextern double GetComplexity(int);
  72. Xextern int ShipCompare(int *, int *);
  73. Xextern void SortShips(void);
  74. Xextern void warn_race(int, char *);
  75. Xextern void warn(int, int, char *);
  76. Xextern void warn_star(int, int, int, char *);
  77. Xextern void notify_star(int, int, int, int, char *);
  78. Xextern void post_star(char *, int, int);
  79. Xextern void adjust_morale(racetype *, racetype *, int);
  80. Xextern void version(int, int);
  81. X
  82. X/* VN.c prototypes */
  83. Xextern void do_VN(shiptype *);
  84. Xextern void planet_doVN(shiptype *, planettype *);
  85. Xextern void order_berserker(shiptype *);
  86. Xextern void order_VN(shiptype *);
  87. X/*
  88. X * analysis.c prototypes
  89. X*/
  90. X
  91. Xextern void analysis(int, int, int);
  92. Xextern void do_analysis(int, int, int, int, int, int, int);
  93. X
  94. X/* autoreport.c function prototypes */
  95. X
  96. Xextern void autoreport(int, int, int);
  97. X
  98. X/*
  99. Xautoshoot.c function prototypes
  100. X*/
  101. X
  102. Xextern int Bombard(shiptype *, planettype *, racetype *);
  103. X
  104. X/*
  105. Xbuild.c function prototypes
  106. X*/
  107. X
  108. Xextern void upgrade(int, int, int);
  109. Xextern void make_mod(int, int, int, int);
  110. Xextern void build(int, int, int);
  111. Xextern int getcount(int, char *);
  112. Xextern int can_build_at_planet(int, int, startype *, planettype *);
  113. Xextern int get_build_type(char *);
  114. Xextern int can_build_this(int, racetype *, char *);
  115. Xextern int can_build_on_ship(int, racetype *, shiptype *, char *);
  116. Xextern int can_build_on_sector(int, racetype *, planettype *, sectortype *, 
  117. X    int, int, char *);
  118. Xextern int build_at_ship(int, int, racetype *, shiptype *, int *, int *);
  119. Xextern void autoload_at_planet(int, shiptype *, planettype *, sectortype *, int *,
  120. X            double *);
  121. Xextern void autoload_at_ship(int, shiptype *, shiptype *, int *, double *);
  122. Xextern void initialize_new_ship(int, int, racetype *, shiptype *, double, int);
  123. Xextern void create_ship_by_planet(int, int, racetype *, shiptype *, planettype *,
  124. X               int, int, int, int);
  125. Xextern void create_ship_by_ship(int, int, racetype *, int, startype *, planettype *,
  126. X             shiptype *, shiptype *);
  127. Xextern double getmass(shiptype *);
  128. Xextern int ship_size(shiptype *);
  129. Xextern double cost(shiptype *);
  130. Xextern void system_cost(double *, double *, int, int);
  131. Xextern double complexity(shiptype *);
  132. Xextern void Getship(shiptype *, int, racetype *);
  133. Xextern void Getfactship(shiptype *, shiptype *);
  134. Xextern int Shipcost(int, racetype *);
  135. Xextern void sell(int, int, int);
  136. Xextern void bid(int, int, int);
  137. Xextern int shipping_cost(int, int, double *, int);
  138. X/* capital.c function prototypes */
  139. X
  140. Xextern void capital(int, int, int);
  141. X
  142. X/* capture.c function prototypes */
  143. X
  144. Xextern void capture(int, int, int);
  145. Xextern void capture_stuff(shiptype *);
  146. X
  147. X/* cs.c function prototypes */
  148. X
  149. Xextern void center(int, int, int);
  150. Xextern void do_prompt(int, int);
  151. Xextern void cs(int, int, int);
  152. X
  153. X/* declare.c function prototypes */
  154. X
  155. Xextern void invite(int, int, int, int);
  156. Xextern void declare(int, int, int);
  157. Xextern void vote(int, int, int);
  158. Xextern void show_votes(int, int);
  159. Xextern void pledge(int, int, int, int);
  160. X/* dissolve.c function prototypes */
  161. X
  162. Xextern void dissolve(int, int);
  163. Xextern int revolt(planettype *, int, int);
  164. X
  165. X/* dock.c function prototypes */
  166. X
  167. Xextern void dock(int, int, int, int);
  168. X
  169. X/* doplanet.c function prototypes */
  170. X
  171. Xextern int doplanet(int, planettype *, int);
  172. Xextern int moveship_onplanet(shiptype *, planettype *);
  173. Xextern void terraform(shiptype *, planettype *);
  174. Xextern void plow(shiptype *, planettype *);
  175. Xextern void do_dome(shiptype *, planettype *);
  176. Xextern void do_quarry(shiptype *, planettype *);
  177. Xextern void do_recover(planettype *, int, int);
  178. Xextern double est_production(sectortype *);
  179. X
  180. X/* dosector.c function prototypes */
  181. X
  182. Xextern void produce(startype *, planettype *, sectortype *);
  183. Xextern void spread(planettype *, sectortype *, int, int);
  184. Xextern void Migrate2(planettype *, int, int, sectortype *, int *);
  185. Xextern void explore(planettype *, sectortype *, int, int, int);
  186. Xextern void plate(sectortype *);
  187. X
  188. X/* doship.c function prototypes */
  189. X
  190. Xextern void doship(shiptype *, int);
  191. Xextern void domass(shiptype *);
  192. Xextern void doown(shiptype *);
  193. Xextern void domissile(shiptype *);
  194. Xextern void domine(int, int);
  195. Xextern void doabm(shiptype *);
  196. Xextern void do_repair(shiptype *);
  197. Xextern void do_habitat(shiptype *);
  198. Xextern void do_pod(shiptype *);
  199. Xextern int infect_planet(int, int, int);
  200. Xextern void do_meta_infect(int, planettype *);
  201. Xextern void do_canister(shiptype *);
  202. Xextern void do_greenhouse(shiptype *);
  203. Xextern void do_mirror(shiptype *);
  204. Xextern void do_god(shiptype *);
  205. Xextern void do_ap(shiptype *);
  206. Xextern double crew_factor(shiptype *);
  207. Xextern double ap_planet_factor(planettype *);
  208. Xextern void do_oap(shiptype *);
  209. Xextern int do_weapon_plant(shiptype *);
  210. X
  211. X
  212. X/* doturn.c function prototypes */
  213. X
  214. Xextern void do_turn(int);
  215. Xextern int APadd(int, int, racetype *);
  216. Xextern int governed(racetype *);
  217. Xextern void fix_stability(startype *);
  218. Xextern void do_reset(int);
  219. Xextern void handle_victory(void);
  220. Xextern void make_discoveries(racetype *);
  221. X#ifdef MARKET
  222. Xextern void maintain(racetype *, int, int);
  223. X#endif
  224. Xextern int attack_planet(shiptype *);
  225. Xextern void output_ground_attacks(void);
  226. Xextern int planet_points(planettype *);
  227. X
  228. X/* enslave.c function prototypes */
  229. X
  230. Xextern void enslave(int, int, int);
  231. X
  232. X/* examine.c function prototypes */
  233. X
  234. Xextern void examine(int, int, int);
  235. X
  236. X/* explore.c function prototypes */
  237. X
  238. Xextern void colonies_at_star(int, int, racetype *, int, int);
  239. Xextern void colonies(int, int, int, int);
  240. Xextern void distance(int, int, int);
  241. Xextern void star_locations(int, int, int);
  242. Xextern void exploration(int, int, int);
  243. Xextern void tech_status(int, int, int);
  244. Xextern void tech_report_star(int, int, startype *, int, int *, double *, double *);
  245. X
  246. X/* files_rw.c function prototypes */
  247. X
  248. Xextern void Fileread(int, char *, int, int);
  249. Xextern void Filewrite(int, char *, int, int);
  250. X
  251. X/* files_shl.c function prototypes */
  252. X
  253. Xextern void close_file(int);
  254. Xextern void open_data_files(void);
  255. Xextern void close_data_files(void);
  256. Xextern void openstardata(int *);
  257. Xextern void openshdata(int *);
  258. Xextern void opencommoddata(int *);
  259. Xextern void openpdata(int *);
  260. Xextern void opensectdata(int *);
  261. Xextern void openracedata(int *);
  262. Xextern void getsdata(struct stardata *S);
  263. X#ifdef DEBUG
  264. Xextern void DEBUGgetrace(racetype **, int, char *, int);
  265. Xextern void DEBUGgetstar(startype **, int, char *, int);
  266. Xextern void DEBUGgetplanet(planettype **, int, int, char *, int);
  267. Xextern int DEBUGgetship(shiptype **, int, char *, int);
  268. Xextern int DEBUGgetcommod(commodtype **, int, char *, int);
  269. X#else
  270. Xextern void getrace(racetype **, int);
  271. Xextern void getstar(startype **, int);
  272. Xextern void getplanet(planettype **, int, int);
  273. Xextern int getship(shiptype **, int);
  274. Xextern int getcommod(commodtype **, int);
  275. X#endif
  276. Xextern void getsector(sectortype **, planettype *, int, int);
  277. Xextern void getsmap(sectortype *, planettype *);
  278. Xextern int getdeadship(void);
  279. Xextern int getdeadcommod(void);
  280. Xextern void putsdata(struct stardata *);
  281. Xextern void putrace(racetype *);
  282. Xextern void putstar(startype *, int);
  283. Xextern void putplanet(planettype *, int, int);
  284. Xextern void putsector(sectortype *, planettype *, int, int);
  285. Xextern void putsmap(sectortype *, planettype *);
  286. Xextern void putship(shiptype *);
  287. Xextern void putcommod(commodtype *, int);
  288. Xextern int Numraces(void);
  289. Xextern int Numships(void);
  290. Xextern int Numcommods(void);
  291. Xextern int Newslength(int);
  292. Xextern void clr_shipfree(void);
  293. Xextern void clr_commodfree(void);
  294. Xextern void makeshipdead(int);
  295. Xextern void makecommoddead(int);
  296. Xextern void Putpower(struct power [MAXPLAYERS]);
  297. Xextern void Getpower(struct power [MAXPLAYERS]);
  298. Xextern void Putblock(struct block [MAXPLAYERS]);
  299. Xextern void Getblock(struct block [MAXPLAYERS]);
  300. X
  301. X/* fire.c function prototypes */
  302. X
  303. Xextern void fire(int, int, int, int);
  304. Xextern void bombard(int, int, int);
  305. Xextern void defend(int, int, int);
  306. Xextern void detonate(int, int, int);
  307. Xextern int retal_strength(shiptype *);
  308. Xextern int adjacent(int, int, int, int, planettype *);
  309. Xextern int landed(shiptype *);
  310. Xextern void check_overload(shiptype *, int, int *);
  311. Xextern void check_retal_strength(shiptype *, int *);
  312. Xextern int laser_on(shiptype *);
  313. X
  314. X/* fuel.c function prototypes */
  315. X
  316. Xextern void proj_fuel(int, int, int);
  317. Xextern void fuel_output(int, int, double, double, double, double, int);
  318. Xextern int do_trip(double, double);
  319. X
  320. X/* get4args function prototypes */
  321. X
  322. Xextern void get4args(char *, int *, int *, int *, int *);
  323. X
  324. X/* getplace.c function prototypes */
  325. X
  326. Xextern placetype Getplace(int, int, char *, int);
  327. Xextern placetype Getplace2(int, int, char *, placetype *, int, int);
  328. Xextern char *Dispshiploc_brief(shiptype *);
  329. Xextern char *Dispshiploc(shiptype *);
  330. Xextern char *Dispplace(int, int, placetype *);
  331. Xextern int testship(int, int, shiptype *);
  332. X
  333. X/* land.c function prototypes */
  334. X
  335. Xextern void land(int, int, int);
  336. Xextern int crash(shiptype *, double);
  337. Xextern int docked(shiptype *);
  338. Xextern int overloaded(shiptype *);
  339. X
  340. X/* launch.c function prototypes */
  341. X
  342. Xextern void launch(int, int, int);
  343. X
  344. X/* load.c function prototypes */
  345. X
  346. Xextern void load(int, int, int, int);
  347. Xextern void jettison(int, int, int);
  348. Xextern int jettison_check(int, int, int, int);
  349. Xextern void dump(int, int, int);
  350. Xextern void transfer(int, int, int);
  351. Xextern void mount(int, int, int, int);
  352. Xextern void use_fuel(shiptype *, double);
  353. Xextern void use_destruct(shiptype *, int);
  354. Xextern void use_resource(shiptype *, int);
  355. Xextern void use_popn(shiptype *, int, double);
  356. Xextern void rcv_fuel(shiptype *, double);
  357. Xextern void rcv_resource(shiptype *, int);
  358. Xextern void rcv_destruct(shiptype *, int);
  359. Xextern void rcv_popn(shiptype *, int, double);
  360. Xextern void rcv_troops(shiptype *, int, double);
  361. Xextern void do_transporter(racetype *, int, shiptype *);
  362. Xextern int landed_on(shiptype *, int);
  363. Xextern void unload_onto_alien_sector(int, int, planettype *, shiptype *,
  364. X                      sectortype *, int, int);
  365. X
  366. X/* map.c function prototypes */
  367. X
  368. Xextern void map(int, int, int);
  369. Xextern void show_map(int, int, int, int, planettype *, int, int);
  370. Xextern char desshow(int, int, planettype *, int, int, racetype *);
  371. X
  372. X/* max.c function prototypes */
  373. X
  374. Xextern int maxsupport(racetype *, sectortype *, double, int);
  375. Xextern double compatibility(planettype *, racetype *);
  376. Xextern double gravity(planettype *);
  377. Xextern char *prin_ship_orbits(shiptype *);
  378. X
  379. X/* misc.c function prototypes */
  380. X
  381. Xextern double logscale(int);
  382. X
  383. X/* mobiliz.c function prototypes */
  384. X
  385. Xextern void mobilize(int, int, int);
  386. Xextern void tax(int, int, int);
  387. Xextern int control(int, int, startype *);
  388. X
  389. X/* move.c function prototypes */
  390. X
  391. Xextern void arm(int, int, int, int);
  392. Xextern void move_popn(int, int, int);
  393. Xextern void walk(int, int, int);
  394. Xextern int get_move(char, int, int, int *, int *, planettype *);
  395. Xextern void mech_defend(int, int, int *, int, planettype *, int, int, sectortype *,
  396. X         int, int, sectortype *);
  397. Xextern void mech_attack_people(shiptype *, int *, int *, racetype *, racetype *,
  398. X            sectortype *, int, int, int, char *, char *);
  399. Xextern void people_attack_mech(shiptype *, int, int, racetype *, racetype *,
  400. X            sectortype *, int, int, char *, char *);
  401. Xextern void ground_attack(racetype *, racetype *, int *, int, unsigned short *,
  402. X           unsigned short *, unsigned int, unsigned int,
  403. X           double, double, double *, double *, int *, int *, int *);
  404. X
  405. X/* moveplanet.c function prototypes */
  406. X
  407. Xextern void moveplanet(int, planettype *, int);
  408. X
  409. X/* moveship.c function prototypes */
  410. X
  411. Xextern void Moveship(shiptype *, int, int, int);
  412. Xextern void msg_OOF(shiptype *);
  413. Xextern int followable(shiptype *, shiptype *);
  414. Xextern int do_merchant(shiptype *, planettype *);
  415. X
  416. X/* name.c function prototypes */
  417. X
  418. Xextern void personal(int, int, char *);
  419. Xextern void bless(int, int, int);
  420. Xextern void insurgency(int, int, int);
  421. Xextern void pay(int, int, int);
  422. Xextern void give(int, int, int);
  423. Xextern void page(int, int, int);
  424. Xextern void send_message(int, int, int, int);
  425. Xextern void read_messages(int, int, int);
  426. Xextern void motto(int, int, int, char *);
  427. Xextern void name(int, int, int);
  428. Xextern int MostAPs(int, startype *);
  429. Xextern void announce(int, int, char *, int, int);
  430. X
  431. X/* orbit.c function prototypes */
  432. X
  433. Xextern void orbit(int, int, int);
  434. Xextern void DispStar(int, int, int, startype *, int, int, char *);
  435. Xextern void DispPlanet(int, int, int, planettype *, char *, int, racetype *, char *);
  436. Xextern void DispShip(int, int, placetype *, shiptype *, planettype *, int, char *);
  437. X
  438. X/* order.c function prototypes */
  439. X
  440. Xextern void order(int, int, int);
  441. Xextern void give_orders(int, int, int, shiptype *);
  442. Xextern char *prin_aimed_at(int, int, shiptype *);
  443. Xextern char *prin_ship_dest(int, int, shiptype *);
  444. Xextern void mk_expl_aimed_at(int, int, shiptype *);
  445. Xextern void DispOrdersHeader(int, int);
  446. Xextern void DispOrders(int, int, shiptype *);
  447. Xextern void route(int, int, int);
  448. X
  449. X
  450. X/* perm.c function prototypes */
  451. X
  452. Xextern void PermuteSects(planettype *);
  453. Xextern int Getxysect(planettype *, int *, int *, int);
  454. X
  455. X/* power.c function prototypes */
  456. X
  457. Xextern void block(int, int, int);
  458. Xextern void power(int, int, int);
  459. Xextern void prepare_output_line(racetype *, racetype *, int, int);
  460. X
  461. X/* prof.c function prototypes */
  462. X
  463. Xextern void whois(int, int, int);
  464. Xextern void profile(int, int, int);
  465. Xextern char *Estimate_f(double, racetype *, int);
  466. Xextern char *Estimate_i(int, racetype *, int);
  467. Xextern int round_perc(int, racetype *, int);
  468. Xextern void treasury(int, int);
  469. X/* rand.c function prototypes */
  470. X
  471. Xextern double double_rand(void);
  472. Xextern int int_rand(int, int);
  473. Xextern int round_rand(double);
  474. Xextern int rposneg(void);
  475. X
  476. X/* read_teleg.c function prototypes */
  477. X
  478. Xextern void teleg_read(int, int);
  479. Xextern void news_read(int, int, int);
  480. X
  481. X/* relation.c function prototypes */
  482. X
  483. Xextern void relation(int, int, int);
  484. Xextern char *allied(racetype *, int, int, int);
  485. X
  486. X/* rst.c function prototypes */
  487. X
  488. Xextern void rst(int, int, int, int);
  489. Xextern void ship_report(int, int, int, unsigned char []);
  490. Xextern void plan_getrships(int, int, int, int);
  491. Xextern void star_getrships(int, int, int);
  492. Xextern int Getrship(int, int, int);
  493. Xextern void Free_rlist(void);
  494. Xextern int listed(int, char *);
  495. X
  496. X/* scrap.c function prototypes */
  497. X
  498. Xextern void scrap(int, int, int);
  499. X
  500. X/* shlmisc.c function prototypes */
  501. X
  502. Xextern char *Ship(shiptype *s);
  503. Xextern void grant(int, int, int);
  504. Xextern void governors(int, int, int);
  505. Xextern void do_revoke(racetype *, int, int);
  506. Xextern int authorized(int, shiptype *);
  507. Xextern int start_shiplist(int, int, char *);
  508. Xextern int do_shiplist(shiptype **, int *);
  509. Xextern int in_list(int, char *, shiptype *, int *);
  510. Xextern void fix(int, int);
  511. Xextern int match(char *, char *);
  512. Xextern void DontOwnErr(int, int, int);
  513. Xextern int enufAP(int, int, unsigned short, int);
  514. Xextern int Getracenum(char *, char *, int *, int *);
  515. Xextern int GetPlayer(char *);
  516. Xextern void allocateAPs(int, int, int);
  517. Xextern void deductAPs(int, int, int, int, int);
  518. Xextern void list(int, int);
  519. Xextern double morale_factor(double);
  520. X#if DEBUG
  521. Xextern char *DEBUGmalloc(int, char *, int);
  522. Xextern void DEBUGfree(char *);
  523. Xextern char *DEBUGrealloc(char *, int, char *, int);
  524. Xextern void DEBUGcheck(int, int);
  525. Xextern void DEBUGreset(int, int);
  526. X#endif
  527. X
  528. X/* shootblast.c function prototypes */
  529. X
  530. Xextern int shoot_ship_to_ship(shiptype *, shiptype *, int, int, int, char *,
  531. X                   char *);
  532. X#ifdef DEFENSE
  533. Xextern int shoot_planet_to_ship(racetype *, planettype *, shiptype *, int,
  534. X                 char *, char *);
  535. X#endif
  536. Xextern int shoot_ship_to_planet(shiptype *, planettype *, int, int, int, int, int,
  537. X                 int, char *, char *);
  538. Xextern int do_radiation(shiptype *, double, int, int, char *, char *);
  539. Xextern int do_damage(int, shiptype *, double, int, int, int, int, double, char *,
  540. X              char *);
  541. Xextern void ship_disposition(shiptype *, int *, int *, int *);
  542. Xextern int CEW_hit(double, int);
  543. Xextern int Num_hits(double, int, int, double, int, int, int, int, int, int, int,
  544. X             int);
  545. Xextern int hit_odds(double, int *, double, int, int, int, int, int, int, int, int);
  546. Xextern int cew_hit_odds(double, int);
  547. Xextern double gun_range(racetype *, shiptype *, int);
  548. Xextern double tele_range(int, double);
  549. Xextern int current_caliber(shiptype *);
  550. Xextern void do_critical_hits(int, shiptype *, int *, int *, int, char *);
  551. Xextern void do_collateral(shiptype *, int, int *, int *, int *, int *);
  552. Xextern int getdefense(shiptype *);
  553. Xextern double p_factor(double, double);
  554. Xextern int planet_guns(int);
  555. Xextern void mutate_sector(sectortype *);
  556. X
  557. X/* survey.c function prototypes */
  558. X
  559. Xextern void survey(int, int, int, int);
  560. Xextern void repair(int, int, int);
  561. X
  562. X/* tech.c function prototypes */
  563. X
  564. Xextern void technology(int, int, int);
  565. Xextern double tech_prod(int, int);
  566. X
  567. X/* teleg_send.c function prototypes */
  568. X
  569. Xextern void purge(void);
  570. Xextern void post(char *, int);
  571. Xextern void push_telegram_race(int, char *);
  572. Xextern void push_telegram(int, int, char *);
  573. X
  574. X/* toggle.c function prototypes */
  575. X
  576. Xextern void toggle(int, int, int);
  577. Xextern void highlight(int, int);
  578. Xextern void tog(int, int, char *, char *);
  579. X
  580. X/* toxicity.c function prototypes */
  581. X
  582. Xextern void toxicity(int, int, int);
  583. X
  584. X/* victory.c function prototypes */
  585. X
  586. Xextern void victory(int, int);
  587. Xextern void create_victory_list(struct vic [MAXPLAYERS]);
  588. Xextern int victory_sort(struct vic *, struct vic *);
  589. X
  590. X/* zoom.c function prototypes */
  591. X
  592. Xextern void zoom(int, int);
  593. X
  594. X/* client.c function prototypes */
  595. Xextern void CSP_process_command(int, int);
  596. Xextern void CSP_client_on(int , int);
  597. Xextern void CSP_client_off(int, int);
  598. Xextern void CSP_client_toggle(int, int, int);
  599. Xextern void CSP_client_version(int, int );
  600. END_OF_FILE
  601. if test 18590 -ne `wc -c <'hdrs/proto.h'`; then
  602.     echo shar: \"'hdrs/proto.h'\" unpacked with wrong size!
  603. fi
  604. # end of 'hdrs/proto.h'
  605. fi
  606. if test -f 'server/doplanet.c' -a "${1}" != "-c" ; then 
  607.   echo shar: Will not clobber existing file \"'server/doplanet.c'\"
  608. else
  609. echo shar: Extracting \"'server/doplanet.c'\" \(33331 characters\)
  610. sed "s/^X//" >'server/doplanet.c' <<'END_OF_FILE'
  611. X#ident  "@(#)doplanet.c    1.7 1/31/93 "
  612. Xint             Sectormappos;
  613. X/*
  614. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  615. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  616. X * GB_copyright.h. doplanet.c -- do one turn on a planet.
  617. X */
  618. X
  619. X#include <math.h>
  620. X/* #include <malloc.h> */
  621. X
  622. X#include "GB_copyright.h"
  623. X#define EXTERN extern
  624. X#include "vars.h"
  625. X#include "ships.h"
  626. X#include "races.h"
  627. X#include "doturn.h"
  628. X#include "power.h"
  629. X#include "buffers.h"
  630. X
  631. Xextern long     Shipdata[NUMSTYPES][NUMABILS];
  632. X
  633. X/* types of accidents that can occur on a toxic planet. */
  634. Xchar           *Accidents_uninhab[] = {
  635. X    /* on water sectors */
  636. X    "Widespread waste spill",
  637. X    "Ecological instability",
  638. X    /* on land sectors */
  639. X    "Massive volcanic eruptions",
  640. X    "Ecological instability",
  641. X    /* on mountain sectors */
  642. X    "Massive volcanic eruptions",
  643. X    "Ecological instability",
  644. X    /* gas sectors */
  645. X    "Lethal toxin concentration",
  646. X    "Ecological instability",
  647. X    /* ice */
  648. X    "Leak in isolated chemical plant",
  649. X    "Continental warming cause glacial melting",
  650. X    /* plate */
  651. X    "Nuclear accident",
  652. X    "Untended nuclear plant explodes"
  653. X};
  654. X
  655. Xchar           *Accidents_inhab[] = {
  656. X    "Nuclear accident",
  657. X    "Terrorists trigger nuclear weapon",
  658. X    "Release of toxic waste",
  659. X    "Weapons dump explosion",
  660. X    "Massive starvation",
  661. X    "Virus epidemic",
  662. X    "famine",
  663. X    "starvation",
  664. X    "Widespread cultist suicide",
  665. X    "Atomic experiment gone wrong",
  666. X    "Great Hrung collapse"
  667. X};
  668. X
  669. Xint             doplanet(int, planettype *, int);
  670. Xint             moveship_onplanet(shiptype *, planettype *);
  671. Xvoid            terraform(shiptype *, planettype *);
  672. Xvoid            plow(shiptype *, planettype *);
  673. Xvoid            do_dome(shiptype *, planettype *);
  674. Xvoid            do_quarry(shiptype *, planettype *);
  675. Xvoid            do_recover(planettype *, int, int);
  676. Xdouble          est_production(sectortype *);
  677. X
  678. X#include "proto.h"
  679. X
  680. Xint 
  681. Xdoplanet(int starnum, planettype * planet, int planetnum)
  682. X{
  683. X    int             shipno, x, y, nukex, nukey;
  684. X    int             o = 0;
  685. X    char            *nukem;
  686. X    reg int         i;
  687. X    sectortype     *p;
  688. X    shiptype       *ship;
  689. X    double          fadd;
  690. X    int             timer = 20;
  691. X    unsigned char   allmod = 0, allexp = 0;
  692. X
  693. X    Sectormappos = planet->sectormappos;
  694. X    /*
  695. X     * if (!(Stars[starnum]->inhabited[0]+Stars[starnum]->inhabited[1]))
  696. X     * return 0;  /* no one's here now
  697. X     */
  698. X
  699. X    getsmap(Smap, planet);
  700. X    PermuteSects(planet);
  701. X    bzero((char *) Sectinfo, sizeof(Sectinfo));
  702. X
  703. X    bzero((char *) avg_mob, sizeof(avg_mob));
  704. X    bzero((char *) sects_gained, sizeof(sects_gained));
  705. X    bzero((char *) sects_lost, sizeof(sects_lost));
  706. X    bzero((char *) prod_res, sizeof(prod_res));
  707. X    bzero((char *) prod_fuel, sizeof(prod_fuel));
  708. X    bzero((char *) prod_destruct, sizeof(prod_destruct));
  709. X    bzero((char *) prod_crystals, sizeof(prod_crystals));
  710. X
  711. X    tot_resdep = prod_eff = prod_mob = tot_captured = 0;
  712. X    Claims = 0;
  713. X
  714. X    planet->maxpopn = 0;
  715. X
  716. X    planet->popn = 0;    /* initialize population for recount */
  717. X    planet->troops = 0;
  718. X    planet->total_resources = 0;
  719. X
  720. X    /* reset global variables */
  721. X    for (i = 1; i <= Num_races; i++) {
  722. X        Compat[i - 1] = compatibility(planet, races[i - 1]);
  723. X        planet->info[i - 1].numsectsowned = 0;
  724. X        planet->info[i - 1].troops = 0;
  725. X        planet->info[i - 1].popn = 0;
  726. X        planet->info[i - 1].est_production = 0.0;
  727. X        prod_crystals[i - 1] = 0;
  728. X        prod_fuel[i - 1] = 0;
  729. X        prod_destruct[i - 1] = 0;
  730. X        prod_res[i - 1] = 0;
  731. X        avg_mob[i - 1] = 0;
  732. X    }
  733. X
  734. X    shipno = planet->ships;
  735. X    while (shipno) {
  736. X        ship = ships[shipno];
  737. X        if (ship->alive && !ship->rad) {
  738. X            /*
  739. X             * planet level functions - do these here because
  740. X             * they use the sector map or affect planet
  741. X             * production
  742. X             */
  743. X            switch (ship->type) {
  744. X            case OTYPE_TERRA:
  745. X                if (ship->on && landed(ship) && ship->popn)
  746. X                    if (ship->fuel >= (double) FUEL_COST_TERRA)
  747. X                        terraform(ship, planet);
  748. X                    else if (!ship->notified) {
  749. X                        ship->notified = 1;
  750. X                        msg_OOF(ship);
  751. X                    }
  752. X                break;
  753. X            case OTYPE_PLOW:
  754. X                if (ship->on && landed(ship)) {
  755. X                    if (ship->fuel >= (double) FUEL_COST_PLOW)
  756. X                        plow(ship, planet);
  757. X                    else if (!ship->notified) {
  758. X                        ship->notified = 1;
  759. X                        msg_OOF(ship);
  760. X                    }
  761. X                } else if (ship->on) {
  762. X                    sprintf(buf, "K%d is not landed.", ship->number);
  763. X                    push_telegram(ship->owner, ship->governor, buf);
  764. X                } else {
  765. X                    sprintf(buf, "K%d is not switched on.", ship->number);
  766. X                    push_telegram(ship->owner, ship->governor, buf);
  767. X                }
  768. X                break;
  769. X            case OTYPE_DOME:
  770. X                if (ship->on && landed(ship)) {
  771. X                    if (ship->resource >= RES_COST_DOME)
  772. X                        do_dome(ship, planet);
  773. X                    else {
  774. X                        sprintf(buf, "Y%d does not have enough resources.", ship->number);
  775. X                        push_telegram(ship->owner, ship->governor, buf);
  776. X                    }
  777. X                } else if (ship->on) {
  778. X                    sprintf(buf, "Y%d is not landed.", ship->number);
  779. X                    push_telegram(ship->owner, ship->governor, buf);
  780. X                } else {
  781. X                    sprintf(buf, "Y%d is not switched on.", ship->number);
  782. X                    push_telegram(ship->owner, ship->governor, buf);
  783. X                }
  784. X                break;
  785. X            case OTYPE_WPLANT:
  786. X                if (landed(ship))
  787. X                    if (ship->resource >= RES_COST_WPLANT
  788. X                      && ship->fuel >= FUEL_COST_WPLANT)
  789. X                        prod_destruct[ship->owner - 1] += do_weapon_plant(ship);
  790. X                    else {
  791. X                        if (ship->resource < RES_COST_WPLANT) {
  792. X                            sprintf(buf, "W%d does not have enough resources.", ship->number);
  793. X                            push_telegram(ship->owner, ship->governor, buf);
  794. X                        } else {
  795. X                            sprintf(buf, "W%d does not have enough fuel.", ship->number);
  796. X                            push_telegram(ship->owner, ship->governor, buf);
  797. X                        }
  798. X                    }
  799. X                else {
  800. X                    sprintf(buf, "W%d is not landed.", ship->number);
  801. X                    push_telegram(ship->owner, ship->governor, buf);
  802. X                }
  803. X                break;
  804. X            case OTYPE_QUARRY:
  805. X                if (ship->on && landed(ship) && ship->popn)
  806. X                    if (ship->fuel >= FUEL_COST_QUARRY)
  807. X                        do_quarry(ship, planet);
  808. X                    else if (!ship->notified) {
  809. X                        ship->on = 0;
  810. X                        msg_OOF(ship);
  811. X                    } else {
  812. X                        if (!ship->on) {
  813. X                            sprintf(buf, "q%d is not switched on.", ship->number);
  814. X                        }
  815. X                        if (!landed(ship)) {
  816. X                            sprintf(buf, "q%d is not landed.", ship->number);
  817. X                        }
  818. X                        if (!ship->popn) {
  819. X                            sprintf(buf, "q%d does not have workers aboard.", ship->number);
  820. X                        }
  821. X                        push_telegram(ship->owner, ship->governor, buf);
  822. X                    }
  823. X                break;
  824. X            }
  825. X            /* add fuel for ships orbiting a gas giant */
  826. X            if (!landed(ship) && planet->type == TYPE_GASGIANT) {
  827. X                switch (ship->type) {
  828. X                case STYPE_TANKER:
  829. X                    fadd = FUEL_GAS_ADD_TANKER;
  830. X                    break;
  831. X                case STYPE_HABITAT:
  832. X                    fadd = FUEL_GAS_ADD_HABITAT;
  833. X                    break;
  834. X                default:
  835. X                    fadd = FUEL_GAS_ADD;
  836. X                    break;
  837. X                }
  838. X                fadd = MIN((double) Max_fuel(ship) - ship->fuel, fadd);
  839. X                rcv_fuel(ship, fadd);
  840. X            }
  841. X        }
  842. X        shipno = ship->nextship;
  843. X    }
  844. X
  845. X    /*
  846. X     * if (!Stinfo[starnum][planetnum].inhab) return 0;  /* (no one's
  847. X     * explored the planet)
  848. X     */
  849. X
  850. X    /* check for space mirrors (among other things) warming the planet */
  851. X    /* if a change in any artificial warming/cooling trends */
  852. X    planet->conditions[TEMP] = planet->conditions[RTEMP] +
  853. X        Stinfo[starnum][planetnum].temp_add + int_rand(-5, 5);
  854. X
  855. X
  856. X    (void) Getxysect(planet, &x, &y, 1);
  857. X
  858. X    while (Getxysect(planet, &x, &y, 0)) {
  859. X        p = &Sector(*planet, x, y);
  860. X
  861. X        if (p->owner && (p->popn || p->troops)) {
  862. X            allmod = 1;
  863. X            if (!Stars[starnum]->nova_stage) {
  864. X                produce(Stars[starnum], planet, p);
  865. X                if (p->owner)
  866. X                    planet->info[p->owner - 1].est_production += est_production(p);
  867. X                spread(planet, p, x, y);
  868. X            } else {
  869. X                /* damage sector from supernova */
  870. X                p->resource++;
  871. X                p->fert *= 0.8;
  872. X                if (Stars[starnum]->nova_stage == 14)
  873. X                    p->popn = p->owner = p->troops = 0;
  874. X                else
  875. X                    p->popn = round_rand((double) p->popn * .50);
  876. X            }
  877. X            Sectinfo[x][y].done = 1;
  878. X        }
  879. X        if ((!p->popn && !p->troops) || !p->owner) {
  880. X            p->owner = 0;
  881. X            p->popn = p->troops = 0;
  882. X        }
  883. X        /*
  884. X         * if (p->wasted) { if (x>1 && x<planet->Maxx-2) { if
  885. X         * (p->des==DES_SEA || p->des==DES_GAS) { if ( y>1 &&
  886. X         * y<planet->Maxy-2 && (!(p-1)->wasted || !(p+1)->wasted) &&
  887. X         * !random()%5) p->wasted = 0; } else if (p->des==DES_LAND ||
  888. X         * p->des==DES_MOUNT || p->des==DES_ICE) { if ( y>1 &&
  889. X         * y<planet->Maxy-2 && ((p-1)->popn || (p+1)->popn) &&
  890. X         * !random()%10) p->wasted = 0; } } }
  891. X         */
  892. X        /*
  893. X         * if (Stars[starnum]->nova_stage) { if (p->des==DES_ICE)
  894. X         * if(random()&01) p->des = DES_LAND; else if
  895. X         * (p->des==DES_SEA) if(random()&01) if ( (x>0 &&
  896. X         * (p-1)->des==DES_LAND) || (x<planet->Maxx-1 &&
  897. X         * (p+1)->des==DES_LAND) || (y>0 &&
  898. X         * (p-planet->Maxx)->des==DES_LAND) || (y<planet->Maxy-1 &&
  899. X         * (p+planet->Maxx)->des==DES_LAND ) ) { p->des = DES_LAND;
  900. X         * p->popn = p->owner = p->troops = 0; p->resource +=
  901. X         * int_rand(1,5); p->fert = int_rand(1,4); } }
  902. X         */
  903. X    }
  904. X
  905. X
  906. X    (void) Getxysect(planet, &x, &y, 1);
  907. X    while (Getxysect(planet, &x, &y, 0)) {
  908. X        p = &Sector(*planet, x, y);
  909. X        if (p->owner)
  910. X            planet->info[p->owner - 1].numsectsowned++;
  911. X    }
  912. X
  913. X    if (planet->expltimer >= 1)
  914. X        planet->expltimer--;
  915. X    if (!Stars[starnum]->nova_stage && !planet->expltimer) {
  916. X        if (!planet->expltimer)
  917. X            planet->expltimer = 5;
  918. X        for (i = 1; !Claims && !allexp && i <= Num_races; i++) {
  919. X            /* sectors have been modified for this player */
  920. X            if (planet->info[i - 1].numsectsowned)
  921. X                while (!Claims && !allexp && timer > 0) {
  922. X                    timer -= 1;
  923. X                    o = 1;
  924. X                    (void) Getxysect(planet, &x, &y, 1);
  925. X                    while (!Claims && Getxysect(planet, &x, &y, 0)) {
  926. X                        /*
  927. X                         * find out if all sectors
  928. X                         * have been explored
  929. X                         */
  930. X                        o &= Sectinfo[x][y].explored;
  931. X                        p = &Sector(*planet, x, y);
  932. X                        if (((Sectinfo[x][y].explored == i) && !(random() & 02))
  933. X                            && (!p->owner && p->condition != WASTED
  934. X                            && p->condition == races[i - 1]->likesbest)) {
  935. X                            /*
  936. X                             * explorations have
  937. X                             * found an island
  938. X                             */
  939. X                            Claims = i;
  940. X                            p->popn = races[i - 1]->number_sexes;
  941. X                            p->owner = i;
  942. X                            tot_captured = 1;
  943. X                        } else
  944. X                            explore(planet, p, x, y, i);
  945. X                    }
  946. X                    allexp |= o;    /* all sectors explored
  947. X                             * for this player */
  948. X                }
  949. X        }
  950. X    }
  951. X    if (allexp)
  952. X        planet->expltimer = 5;
  953. X
  954. X    /* environment nukes a random sector */
  955. X    if (planet->conditions[TOXIC] > ENVIR_DAMAGE_TOX) {
  956. X        nukex = int_rand(0, (int) planet->Maxx - 1);
  957. X        nukey = int_rand(0, (int) planet->Maxy - 1);
  958. X        p = &Sector(*planet, nukex, nukey);
  959. X        p->condition = WASTED;
  960. X        /* index into accident type array */
  961. X        nukem = p->popn + p->troops ?
  962. X            Accidents_inhab[int_rand(0, sizeof(Accidents_inhab) / sizeof(char *))]
  963. X            : Accidents_uninhab[p->type * 2 + (random() &01)];
  964. X        p->popn = p->owner = p->troops = 0;
  965. X    }
  966. X    for (i = 1; i <= Num_races; i++)
  967. X        if (sects_gained[i - 1] || sects_lost[i - 1]) {
  968. X            sprintf(telegram_buf, "****** Report: Planet /%s/%s ******\n",
  969. X                Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
  970. X            sprintf(buf, " WAR STATUS: %d sectors gained, %d sectors lost.\n",
  971. X                sects_gained[i - 1], sects_lost[i - 1]);
  972. X            strcat(telegram_buf, buf);
  973. X            push_telegram(i, (int) Stars[starnum]->governor[i - 1], telegram_buf);
  974. X        }
  975. X    for (i = 1; i <= Num_races; i++) {
  976. X        planet->info[i - 1].prod_crystals = prod_crystals[i - 1];
  977. X        planet->info[i - 1].prod_res = prod_res[i - 1];
  978. X        planet->info[i - 1].prod_fuel = prod_fuel[i - 1];
  979. X        planet->info[i - 1].prod_dest = prod_destruct[i - 1];
  980. X        if (planet->info[i - 1].autorep) {
  981. X            planet->info[i - 1].autorep--;
  982. X            sprintf(telegram_buf, "\nFrom /%s/%s\n",
  983. X                Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
  984. X
  985. X            if (Stinfo[starnum][planetnum].temp_add) {
  986. X                sprintf(buf, "Temp: %d to %d\n",
  987. X                    planet->conditions[RTEMP], planet->conditions[TEMP]);
  988. X                strcat(telegram_buf, buf);
  989. X            }
  990. X            sprintf(buf, "Total      Prod: %dr %df %dd\n", prod_res[i - 1],
  991. X                prod_fuel[i - 1], prod_destruct[i - 1]);
  992. X            strcat(telegram_buf, buf);
  993. X            if (prod_crystals[i - 1]) {
  994. X                sprintf(buf, "    %d crystals found\n", prod_crystals[i - 1]);
  995. X                strcat(telegram_buf, buf);
  996. X            }
  997. X            if (tot_captured) {
  998. X                sprintf(buf, "%d sectors captured\n", tot_captured);
  999. X                strcat(telegram_buf, buf);
  1000. X            }
  1001. X            if (Stars[starnum]->nova_stage) {
  1002. X                sprintf(buf, "This planet's primary is in a Stage %d nova.\n",
  1003. X                    Stars[starnum]->nova_stage);
  1004. X                strcat(telegram_buf, buf);
  1005. X            }
  1006. X            /*
  1007. X             * remind the player that he should clean up the
  1008. X             * environment.
  1009. X             */
  1010. X            if (planet->conditions[TOXIC] > ENVIR_DAMAGE_TOX) {
  1011. X                sprintf(buf, "Environmental damage on sector %d,%d\n",
  1012. X                    nukex, nukey);
  1013. X                strcat(telegram_buf, buf);
  1014. X            }
  1015. X            if (planet->slaved_to) {
  1016. X                sprintf(buf, "ENSLAVED to player %d\n", planet->slaved_to);
  1017. X                strcat(telegram_buf, buf);
  1018. X            }
  1019. X            push_telegram(i, Stars[starnum]->governor[i - 1], telegram_buf);
  1020. X        }
  1021. X    }
  1022. X
  1023. X    /* find out who is on this planet, for nova notification */
  1024. X    if (Stars[starnum]->nova_stage == 1) {
  1025. X        sprintf(telegram_buf, "BULLETIN from /%s/%s\n",
  1026. X           Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
  1027. X        sprintf(buf, "\nStar %s is undergoing nova.\n", Stars[starnum]->name);
  1028. X        strcat(telegram_buf, buf);
  1029. X        if (planet->type == TYPE_EARTH || planet->type == TYPE_WATER ||
  1030. X            planet->type == TYPE_FOREST) {
  1031. X            strcat(buf, "Seas and rivers are boiling!\n");
  1032. X            strcat(telegram_buf, buf);
  1033. X        }
  1034. X        sprintf(buf, "This planet must be evacuated immediately!\n%c",
  1035. X            TELEG_DELIM);
  1036. X        strcat(telegram_buf, buf);
  1037. X        for (i = 1; i <= Num_races; i++)
  1038. X            if (planet->info[i - 1].numsectsowned)
  1039. X                push_telegram(i, Stars[starnum]->governor[i - 1], telegram_buf);
  1040. X    }
  1041. X    do_recover(planet, starnum, planetnum);
  1042. X
  1043. X    planet->popn = 0;
  1044. X    planet->troops = 0;
  1045. X    planet->maxpopn = 0;
  1046. X    planet->total_resources = 0;
  1047. X
  1048. X    for (i = 1; i <= Num_races; i++) {
  1049. X        planet->info[i - 1].numsectsowned = 0;
  1050. X        planet->info[i - 1].popn = 0;
  1051. X        planet->info[i - 1].troops = 0;
  1052. X    }
  1053. X
  1054. X    (void) Getxysect(planet, &x, &y, 1);
  1055. X    while (Getxysect(planet, &x, &y, 0)) {
  1056. X        p = &Sector(*planet, x, y);
  1057. X        if (p->owner) {
  1058. X            planet->info[p->owner - 1].numsectsowned++;
  1059. X            planet->info[p->owner - 1].troops += p->troops;
  1060. X            planet->info[p->owner - 1].popn += p->popn;
  1061. X            planet->popn += p->popn;
  1062. X            planet->troops += p->troops;
  1063. X            planet->maxpopn += maxsupport(races[p->owner - 1], p,
  1064. X               Compat[p->owner - 1], planet->conditions[TOXIC]);
  1065. X            Power[p->owner - 1].troops += p->troops;
  1066. X            Power[p->owner - 1].popn += p->popn;
  1067. X            Power[p->owner - 1].sum_eff += p->eff;
  1068. X            Power[p->owner - 1].sum_mob += p->mobilization;
  1069. X            starpopns[starnum][p->owner - 1] += p->popn;
  1070. X        } else {
  1071. X            p->popn = 0;
  1072. X            p->troops = 0;
  1073. X        }
  1074. X        planet->total_resources += p->resource;
  1075. X    }
  1076. X
  1077. X    /* deal with enslaved planets */
  1078. X    if (planet->slaved_to) {
  1079. X        if (planet->info[planet->slaved_to - 1].popn > planet->popn / 1000) {
  1080. X            for (i = 1; i <= Num_races; i++)
  1081. X                /* add production to slave holder of planet */
  1082. X                if (planet->info[i - 1].numsectsowned) {
  1083. X                    planet->info[planet->slaved_to - 1].resource += prod_res[i - 1];
  1084. X                    prod_res[i - 1] = 0;
  1085. X                    planet->info[planet->slaved_to - 1].fuel += prod_fuel[i - 1];
  1086. X                    prod_fuel[i - 1] = 0;
  1087. X                    planet->info[planet->slaved_to - 1].destruct += prod_destruct[i - 1];
  1088. X                    prod_destruct[i - 1] = 0;
  1089. X                }
  1090. X        } else {
  1091. X            /* slave revolt! */
  1092. X            /* first nuke some random sectors from the revolt */
  1093. X            i = planet->popn / 1000 + 1;
  1094. X            while (--i) {
  1095. X                p = &Sector(*planet, int_rand(0, (int) planet->Maxx - 1),
  1096. X                       int_rand(0, (int) planet->Maxy - 1));
  1097. X                if (p->popn + p->troops) {
  1098. X                    p->owner = p->popn = p->troops = 0;
  1099. X                    p->condition = WASTED;
  1100. X                }
  1101. X            }
  1102. X            /* now nuke all sectors belonging to former master */
  1103. X            (void) Getxysect(planet, &x, &y, 1);
  1104. X            while (Getxysect(planet, &x, &y, 0)) {
  1105. X                if (Stinfo[starnum][planetnum].intimidated && random() & 01) {
  1106. X                    p = &Sector(*planet, x, y);
  1107. X                    if (p->owner == planet->slaved_to) {
  1108. X                        p->owner = 0;
  1109. X                        p->popn = 0;
  1110. X                        p->troops = 0;
  1111. X                        p->condition = WASTED;
  1112. X                    }
  1113. X                }
  1114. X                /* also add up the populations while here */
  1115. X            }
  1116. X            sprintf(telegram_buf, "\nThere has been a SLAVE REVOLT on /%s/%s!\n",
  1117. X                Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
  1118. X            strcat(telegram_buf, buf);
  1119. X            sprintf(buf, "All population belonging to player #%d on the planet have been killed!\n", planet->slaved_to);
  1120. X            strcat(telegram_buf, buf);
  1121. X            strcat(buf, "Productions now go to their rightful owners.\n");
  1122. X            strcat(telegram_buf, buf);
  1123. X            for (i = 1; i <= Num_races; i++)
  1124. X                if (planet->info[i - 1].numsectsowned)
  1125. X                    push_telegram(i,
  1126. X                              (int) Stars[starnum]->governor[i - 1], telegram_buf);
  1127. X            planet->slaved_to = 0;
  1128. X        }
  1129. X    }
  1130. X    /* add production to all people here */
  1131. X    for (i = 1; i <= Num_races; i++)
  1132. X        if (planet->info[i - 1].numsectsowned) {
  1133. X            planet->info[i - 1].fuel += prod_fuel[i - 1];
  1134. X            planet->info[i - 1].resource += prod_res[i - 1];
  1135. X            planet->info[i - 1].destruct += prod_destruct[i - 1];
  1136. X            planet->info[i - 1].crystals += prod_crystals[i - 1];
  1137. X
  1138. X            /* tax the population - set new tax rate when done */
  1139. X            if (races[i - 1]->Gov_ship) {
  1140. X                planet->info[i - 1].prod_money = round_rand(INCOME_FACTOR *
  1141. X                                        (double) planet->info[i - 1].tax * (double) planet->info[i - 1].popn);
  1142. X                races[i - 1]->governor[Stars[starnum]->governor[i - 1]].money +=
  1143. X                    planet->info[i - 1].prod_money;
  1144. X                planet->info[i - 1].tax += MIN((int) planet->info[i - 1].newtax
  1145. X                    - (int) planet->info[i - 1].tax, 5);
  1146. X            } else
  1147. X                planet->info[i - 1].prod_money = 0;
  1148. X            races[i - 1]->governor[Stars[starnum]->governor[i - 1]].income +=
  1149. X                planet->info[i - 1].prod_money;
  1150. X
  1151. X            /* do tech investments */
  1152. X            if (races[i - 1]->Gov_ship) {
  1153. X                if (races[i - 1]->governor[Stars[starnum]->governor[i - 1]].money >=
  1154. X                    planet->info[i - 1].tech_invest) {
  1155. X                    planet->info[i - 1].prod_tech =
  1156. X                        tech_prod((int) (planet->info[i - 1].tech_invest),
  1157. X                      (int) (planet->info[i - 1].popn));
  1158. X                    races[i - 1]->governor[Stars[starnum]->governor[i - 1]].money -=
  1159. X                        planet->info[i - 1].tech_invest;
  1160. X                    races[i - 1]->tech += planet->info[i - 1].prod_tech;
  1161. X                    races[i - 1]->governor[Stars[starnum]->governor[i - 1]].cost_tech +=
  1162. X                        planet->info[i - 1].tech_invest;
  1163. X                } else
  1164. X                    planet->info[i - 1].prod_tech = 0;
  1165. X            } else
  1166. X                planet->info[i - 1].prod_tech = 0;
  1167. X
  1168. X            /* build wc's if it's been ordered */
  1169. X            if (planet->info[i - 1].tox_thresh > 0 &&
  1170. X                planet->conditions[TOXIC] >= planet->info[i - 1].tox_thresh &&
  1171. X                planet->info[i - 1].resource >= Shipcost(OTYPE_TOXWC, races[i - 1])) {
  1172. X                shiptype       *s2;
  1173. X                reg int         t;
  1174. X                ++Num_ships;
  1175. X                ships = (shiptype **) realloc(ships,
  1176. X                                  (unsigned) ((Num_ships + 1) * sizeof(shiptype *)));
  1177. X                s2 = ships[Num_ships] = Malloc(shiptype);
  1178. X                bzero((char *) s2, sizeof(shiptype));
  1179. X                s2->number = Num_ships;
  1180. X                s2->type = OTYPE_TOXWC;
  1181. X
  1182. X                s2->armor = Shipdata[OTYPE_TOXWC][ABIL_ARMOR];
  1183. X                s2->guns = NONE;
  1184. X                s2->primary = Shipdata[OTYPE_TOXWC][ABIL_GUNS];
  1185. X                s2->primtype = Shipdata[OTYPE_TOXWC][ABIL_PRIMARY];
  1186. X                s2->secondary = Shipdata[OTYPE_TOXWC][ABIL_GUNS];
  1187. X                s2->sectype = Shipdata[OTYPE_TOXWC][ABIL_SECONDARY];
  1188. X                s2->max_crew = Shipdata[OTYPE_TOXWC][ABIL_MAXCREW];
  1189. X                s2->max_resource = Shipdata[OTYPE_TOXWC][ABIL_CARGO];
  1190. X                s2->max_fuel = Shipdata[OTYPE_TOXWC][ABIL_FUELCAP];
  1191. X                s2->max_destruct = Shipdata[OTYPE_TOXWC][ABIL_DESTCAP];
  1192. X                s2->max_speed = Shipdata[OTYPE_TOXWC][ABIL_SPEED];
  1193. X                s2->build_cost = Shipcost(OTYPE_TOXWC, races[i - 1]);
  1194. X                s2->size = ship_size(s2);
  1195. X                s2->base_mass = 1.0;    /* a hack */
  1196. X                s2->mass = s2->base_mass;
  1197. X                s2->alive = 1;
  1198. X                s2->active = 1;
  1199. X                sprintf(s2->name, "Scum%04d", Num_ships);
  1200. X
  1201. X                insert_sh_plan(planet, s2);
  1202. X
  1203. X                s2->whatorbits = LEVEL_PLAN;
  1204. X                s2->storbits = starnum;
  1205. X                s2->pnumorbits = planetnum;
  1206. X                s2->docked = 1;
  1207. X                s2->xpos = Stars[starnum]->xpos + planet->xpos;
  1208. X                s2->ypos = Stars[starnum]->ypos + planet->ypos;
  1209. X                s2->land_x = int_rand(0, (int) planet->Maxx - 1);
  1210. X                s2->land_y = int_rand(0, (int) planet->Maxy - 1);
  1211. X                s2->whatdest = LEVEL_PLAN;
  1212. X                s2->deststar = starnum;
  1213. X                s2->destpnum = planetnum;
  1214. X                s2->owner = i;
  1215. X                s2->governor = Stars[starnum]->governor[i - 1];
  1216. X                t = MIN(TOXMAX, planet->conditions[TOXIC]);    /* amt of tox */
  1217. X                planet->conditions[TOXIC] -= t;
  1218. X                s2->special.waste.toxic = t;
  1219. X            }
  1220. X        }        /* (if numsectsowned[i]) */
  1221. X    if (planet->maxpopn > 0 && planet->conditions[TOXIC] < 100)
  1222. X        planet->conditions[TOXIC] += planet->popn / planet->maxpopn;
  1223. X
  1224. X    if (planet->conditions[TOXIC] > 100)
  1225. X        planet->conditions[TOXIC] = 100;
  1226. X    else if (planet->conditions[TOXIC] < 0)
  1227. X        planet->conditions[TOXIC] = 0;
  1228. X
  1229. X#ifdef THRESHLOADING
  1230. X  /* CWL Threshloading done here! */
  1231. X  shipno = planet->ships;
  1232. X  while (shipno) {
  1233. X    if (((ship = ships[shipno]) != NULL)
  1234. X    && ship->alive && !ship->rad
  1235. X    && (ship->whatdest == LEVEL_PLAN) && landed(ship)
  1236. X    && (has_switch(ship) && ship->on || !has_switch(ship))) {
  1237. X      unsigned int             amti;
  1238. X
  1239. X      if (!ship->resource && ship->threshload[TH_RESOURCE]) {
  1240. X    if (ship->threshload[TH_RESOURCE] >
  1241. X        planet->info[ship->owner - 1].resource)
  1242. X      amti = planet->info[ship->owner - 1].resource;
  1243. X    else
  1244. X      amti = ship->threshload[TH_RESOURCE];
  1245. X    planet->info[ship->owner - 1].resource -= amti;
  1246. X    ship->resource += amti;
  1247. X    /*
  1248. X     * sprintf(buf, "%s: %c%d %s threshloaded %dr.",
  1249. X     * prin_ship_orbits(ship), Shipltrs[ship->type], shipno, ship->name,
  1250. X     * amti); push_message(TELEG_PLAYER_AUTO, 0, (int) ship->owner, (int)
  1251. X     * ship->locked_to, buf, TELEGRAM);
  1252. X     */
  1253. X      }
  1254. X      if (!ship->destruct && ship->threshload[TH_DESTRUCT]) {
  1255. X    if (ship->threshload[TH_DESTRUCT] >
  1256. X        planet->info[ship->owner - 1].destruct)
  1257. X      amti = planet->info[ship->owner - 1].destruct;
  1258. X    else
  1259. X      amti = ship->threshload[TH_DESTRUCT];
  1260. X    planet->info[ship->owner - 1].destruct -= amti;
  1261. X    ship->destruct += amti;
  1262. X    /*
  1263. X     * sprintf(buf, "%s: %c%d %s threshloaded %dd.",
  1264. X     * prin_ship_orbits(ship), Shipltrs[ship->type], shipno, ship->name,
  1265. X     * amti); push_message(TELEG_PLAYER_AUTO, 0, (int) ship->owner, (int)
  1266. X     * ship->locked_to, buf, TELEGRAM);
  1267. X     */
  1268. X      }
  1269. X      if (ship->fuel < 1.0 && ship->threshload[TH_FUEL]) {
  1270. X    ship->fuel = 0.0;
  1271. X    if (ship->threshload[TH_FUEL] >
  1272. X        planet->info[ship->owner - 1].fuel)
  1273. X      amti = (int) planet->info[ship->owner - 1].fuel;
  1274. X    else
  1275. X      amti = ship->threshload[TH_FUEL];
  1276. X    planet->info[ship->owner - 1].fuel -= amti;
  1277. X    ship->fuel += (float) amti;
  1278. X    /*
  1279. X     * sprintf(buf, "%s: %c%d %s threshloaded %df.",
  1280. X     * prin_ship_orbits(ship), Shipltrs[ship->type], shipno, ship->name,
  1281. X     * amti); push_message(TELEG_PLAYER_AUTO, 0, (int) ship->owner, (int)
  1282. X     * ship->locked_to, buf, TELEGRAM);
  1283. X     */
  1284. X      }
  1285. X      if (!ship->crystals && ship->threshload[TH_CRYSTALS]) {
  1286. X    if (ship->threshload[TH_CRYSTALS] >
  1287. X        planet->info[ship->owner - 1].crystals)
  1288. X      amti = planet->info[ship->owner - 1].crystals;
  1289. X    else
  1290. X      amti = ship->threshload[TH_CRYSTALS];
  1291. X    planet->info[ship->owner - 1].crystals -= amti;
  1292. X    ship->crystals += amti;
  1293. X    /*
  1294. X     * sprintf(buf, "%s: %c%d %s threshloaded %dx.",
  1295. X     * prin_ship_orbits(ship), Shipltrs[ship->type], shipno, ship->name,
  1296. X     * amti); push_message(TELEG_PLAYER_AUTO, 0, (int) ship->owner, (int)
  1297. X     * ship->locked_to, buf, TELEGRAM);
  1298. X     */
  1299. X      }
  1300. X    }                /* end threshloading */
  1301. X    shipno = ship->nextship;
  1302. X  }                /* end while shipno */
  1303. X  /* end threshloading */
  1304. X
  1305. X#endif
  1306. X
  1307. X    for (i = 1; i <= Num_races; i++) {
  1308. X        Power[i - 1].resource += planet->info[i - 1].resource;
  1309. X        Power[i - 1].destruct += planet->info[i - 1].destruct;
  1310. X        Power[i - 1].fuel += planet->info[i - 1].fuel;
  1311. X        Power[i - 1].sectors_owned += planet->info[i - 1].numsectsowned;
  1312. X        Power[i - 1].planets_owned += !!planet->info[i - 1].numsectsowned;
  1313. X        if (planet->info[i - 1].numsectsowned) {
  1314. X            /*
  1315. X             * combat readiness naturally moves towards the avg
  1316. X             * mobilization
  1317. X             */
  1318. X            planet->info[i - 1].mob_points = avg_mob[i - 1];
  1319. X            avg_mob[i - 1] /= (int) planet->info[i - 1].numsectsowned;
  1320. X            planet->info[i - 1].comread = avg_mob[i - 1];
  1321. X        } else
  1322. X            planet->info[i - 1].comread = 0;
  1323. X        planet->info[i - 1].guns = planet_guns(planet->info[i - 1].mob_points);
  1324. X    }
  1325. X    return allmod;
  1326. X}
  1327. X
  1328. Xint 
  1329. Xmoveship_onplanet(shiptype * ship, planettype * planet)
  1330. X{
  1331. X    int             x, y, bounced = 0;
  1332. X
  1333. X    if (ship->class[ship->special.terraform.index] == 's') {
  1334. X        ship->on = 0;
  1335. X        return 0;
  1336. X    } else if (ship->class[ship->special.terraform.index] == 'c')
  1337. X        ship->special.terraform.index = 0;    /* reset the orders */
  1338. X
  1339. X    (void) get_move(ship->class[ship->special.terraform.index],
  1340. X            ship->land_x, ship->land_y, &x, &y, planet);
  1341. X    if (y >= planet->Maxy)
  1342. X        bounced = 1, y -= 2;    /* bounce off of south pole! */
  1343. X    else if (y < 0)
  1344. X        bounced = y = 1;/* bounce off of north pole! */
  1345. X    if (planet->Maxy == 1)
  1346. X        y = 0;
  1347. X    if (ship->class[ship->special.terraform.index + 1] != '\0') {
  1348. X        ++ship->special.terraform.index;
  1349. X        if ((ship->class[ship->special.terraform.index + 1] == '\0') &&
  1350. X            (!ship->notified)) {
  1351. X            char            teleg_buf[1000];
  1352. X            ship->notified = 1;
  1353. X            sprintf(teleg_buf, "%s is out of orders at %s.", Ship(ship),
  1354. X                prin_ship_orbits(ship));
  1355. X            push_telegram((int) (ship->owner),
  1356. X                      (int) ship->governor, teleg_buf);
  1357. X        }
  1358. X    } else if (bounced)
  1359. X        ship->class[ship->special.terraform.index] +=
  1360. X            ((ship->class[ship->special.terraform.index] > '5') ? -6 : 6);
  1361. X    ship->land_x = x;
  1362. X    ship->land_y = y;
  1363. X    return 1;
  1364. X}
  1365. X
  1366. Xvoid 
  1367. Xterraform(shiptype * ship, planettype * planet)
  1368. X{
  1369. X    sectortype     *s;
  1370. X
  1371. X    /* move, and then terraform. */
  1372. X    if (!moveship_onplanet(ship, planet))
  1373. X        return;
  1374. X    s = &Sector(*planet, (int) ship->land_x, (int) ship->land_y);
  1375. X    if ((s->condition != races[ship->owner - 1]->likesbest) &&
  1376. X        (s->condition != GAS) &&
  1377. X    success((100 - (int) ship->damage) * ship->popn / ship->max_crew)) {
  1378. X        /* gas sectors can't be terraformed. */
  1379. X        /* only condition can be terraformed, type doesn't change */
  1380. X        s->condition = races[ship->owner - 1]->likesbest;
  1381. X        s->eff = 0;
  1382. X        s->mobilization = 0;
  1383. X        s->popn = s->troops = 0;
  1384. X        s->owner = 0;
  1385. X        use_fuel(ship, FUEL_COST_TERRA);
  1386. X        if ((random() & 01) && (planet->conditions[TOXIC] < 100))
  1387. X            planet->conditions[TOXIC] += 1;
  1388. X        if ((ship->fuel < (double) FUEL_COST_TERRA) && (!ship->notified)) {
  1389. X            ship->notified = 1;
  1390. X            msg_OOF(ship);
  1391. X        }
  1392. X    } else if (s->condition == races[ship->owner - 1]->likesbest) {
  1393. X        sprintf(buf, " T%d is full of zealots!!!", ship->number);
  1394. X        push_telegram(ship->owner, ship->governor, buf);
  1395. X    }
  1396. X    if (s->condition == GAS) {
  1397. X        sprintf(buf, " T%d is trying to terraform gas.", ship->number);
  1398. X        push_telegram(ship->owner, ship->governor, buf);
  1399. X    }
  1400. X}
  1401. X
  1402. Xvoid 
  1403. Xplow(shiptype * ship, planettype * planet)
  1404. X{
  1405. X    sectortype     *s;
  1406. X
  1407. X    if (!moveship_onplanet(ship, planet))
  1408. X        return;
  1409. X    s = &Sector(*planet, (int) ship->land_x, (int) ship->land_y);
  1410. X    if ((races[ship->owner - 1]->likes[s->condition]) && (s->fert < 100)) {
  1411. X        int             adjust = round_rand(10 * (0.01 * (100.0 - (double) ship->damage)
  1412. X                   * (double) ship->popn) / ship->max_crew);
  1413. X        if ((ship->fuel < (double) FUEL_COST_PLOW) && (!ship->notified)) {
  1414. X            ship->notified = 1;
  1415. X            msg_OOF(ship);
  1416. X            return;
  1417. X        }
  1418. X        s->fert = MIN(100, s->fert + adjust);
  1419. X        if (s->fert >= 100) {
  1420. X            sprintf(buf, " K%d is full of zealots!!!", ship->number);
  1421. X            push_telegram(ship->owner, ship->governor, buf);
  1422. X        }
  1423. X        use_fuel(ship, FUEL_COST_PLOW);
  1424. X        if ((random() & 01) && (planet->conditions[TOXIC] < 100))
  1425. X            planet->conditions[TOXIC] += 1;
  1426. X    }
  1427. X}
  1428. X
  1429. Xvoid 
  1430. Xdo_dome(shiptype * ship, planettype * planet)
  1431. X{
  1432. X    sectortype     *s;
  1433. X    int             adjust;
  1434. X
  1435. X    s = &Sector(*planet, (int) ship->land_x, (int) ship->land_y);
  1436. X    if (s->eff >= 100) {
  1437. X        sprintf(buf, " Y%d is full of zealots!!!", ship->number);
  1438. X        push_telegram(ship->owner, ship->governor, buf);
  1439. X        return;
  1440. X    }
  1441. X    adjust = round_rand(.05 * (100. - (double) ship->damage)
  1442. X                * (double) ship->popn / ship->max_crew);
  1443. X    s->eff += adjust;
  1444. X    if (s->eff > 100)
  1445. X        s->eff = 100;
  1446. X    use_resource(ship, RES_COST_DOME);
  1447. X#ifdef AUTOSCRAP
  1448. X    if (ship->autoscrap && s->eff == 100) {
  1449. X    /* Autoscrap this ship */
  1450. X        s->popn += ship->popn;
  1451. X        s->troops += ship->troops;
  1452. X        planet->popn += ship->popn;
  1453. X        planet->troops += ship->troops;
  1454. X        planet->info[ship->owner - 1].resource += ship->resource +
  1455. X            (int) (Cost(ship) / 2);
  1456. X        planet->info[ship->owner - 1].destruct += ship->destruct;
  1457. X        planet->info[ship->owner - 1].fuel += (int) ship->fuel;
  1458. X        planet->info[ship->owner - 1].crystals += ship->crystals;
  1459. X        sprintf(buf, "%s: Dome #%d autoscrapped.",
  1460. X            prin_ship_orbits(ship), ship->number);
  1461. X        push_telegram(ship->owner, ship->governor, buf);
  1462. X        kill_ship(ship->owner, ship);
  1463. X    }
  1464. X#endif 
  1465. X
  1466. X}
  1467. X
  1468. Xvoid 
  1469. Xdo_quarry(shiptype * ship, planettype * planet)
  1470. X{
  1471. X    sectortype     *s;
  1472. X    int             prod, tox;
  1473. X
  1474. X    s = &Sector(*planet, (int) (ship->land_x), (int) (ship->land_y));
  1475. X
  1476. X    if ((ship->fuel < (double) FUEL_COST_QUARRY)) {
  1477. X        if (!ship->notified)
  1478. X            msg_OOF(ship);
  1479. X        ship->notified = 1;
  1480. X        return;
  1481. X    }
  1482. X    /* nuke the sector */
  1483. X    s->condition = WASTED;
  1484. X    prod = round_rand(races[ship->owner - 1]->metabolism
  1485. X              * (double) ship->popn / (double) ship->max_crew);
  1486. X    ship->fuel -= FUEL_COST_QUARRY;
  1487. X    prod_res[ship->owner - 1] += prod;
  1488. X    tox = int_rand(0, int_rand(0, prod));
  1489. X    planet->conditions[TOXIC] = MIN(100, planet->conditions[TOXIC] + tox);
  1490. X    if (s->fert >= prod)
  1491. X        s->fert -= prod;
  1492. X    else
  1493. X        s->fert = 0;
  1494. X}
  1495. X
  1496. Xvoid 
  1497. Xdo_recover(planettype * planet, int starnum, int planetnum)
  1498. X{
  1499. X    int             owners = 0, i, j;
  1500. X    int             ownerbits[2];
  1501. X    int             stolenres = 0, stolendes = 0, stolenfuel = 0, stolencrystals = 0;
  1502. X    int             all_buddies_here = 1;
  1503. X
  1504. X    ownerbits[0] = ownerbits[1] = 0;
  1505. X
  1506. X    for (i = 1; i <= Num_races && all_buddies_here; i++) {
  1507. X        if (planet->info[i - 1].numsectsowned > 0) {
  1508. X            owners++;
  1509. X            setbit(ownerbits, i);
  1510. X            for (j = 1; j < i && all_buddies_here; j++)
  1511. X                if (isset(ownerbits, j) && (!isset(races[i - 1]->allied, j) ||
  1512. X                       !isset(races[j - 1]->allied, i)))
  1513. X                    all_buddies_here = 0;
  1514. X        } else {    /* Player i owns no sectors */
  1515. X            if (i != 1) {    /* Can't steal from God */
  1516. X                stolenres += planet->info[i - 1].resource;
  1517. X                stolendes += planet->info[i - 1].destruct;
  1518. X                stolenfuel += planet->info[i - 1].fuel;
  1519. X                stolencrystals += planet->info[i - 1].crystals;
  1520. X            }
  1521. X        }
  1522. X    }
  1523. X    if (all_buddies_here && owners != 0 && (stolenres > 0 ||
  1524. X           stolendes > 0 || stolenfuel > 0 || stolencrystals > 0)) {
  1525. X        /* Okay, we've got some loot to divvy up */
  1526. X        int             shares = owners;
  1527. X        int             res, des, fuel, crystals;
  1528. X        int             givenres = 0, givendes = 0, givenfuel = 0,
  1529. X                        givencrystals = 0;
  1530. X
  1531. X        for (i = 1; i <= Num_races; i++)
  1532. X            if (isset(ownerbits, i)) {
  1533. X                sprintf(telegram_buf, "Recovery Report: Planet /%s/%s\n",
  1534. X                    Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
  1535. X                push_telegram(i,
  1536. X                      (int) Stars[starnum]->governor[i - 1],
  1537. X                          telegram_buf);
  1538. X                sprintf(telegram_buf, "%-14.14s %5s %5s %5s %5s\n",
  1539. X                    "", "res", "destr", "fuel", "xtal");
  1540. X                push_telegram(i,
  1541. X                      (int) Stars[starnum]->governor[i - 1],
  1542. X                          telegram_buf);
  1543. X            }
  1544. X        /* First: give the loot the the conquerers */
  1545. X        for (i = 1; i <= Num_races && owners > 1; i++)
  1546. X            if (isset(ownerbits, i)) {    /* We have a winnah! */
  1547. X                if ((res = round_rand((double) stolenres / shares))
  1548. X                    + givenres > stolenres)
  1549. X                    res = stolenres - givenres;
  1550. X                if ((des = round_rand((double) stolendes / shares))
  1551. X                    + givendes > stolendes)
  1552. X                    des = stolendes - givendes;
  1553. X                if ((fuel = round_rand((double) stolenfuel / shares))
  1554. X                    + givenfuel > stolenfuel)
  1555. X                    fuel = stolenfuel - givenfuel;
  1556. X                if ((crystals = round_rand((double) stolencrystals / shares))
  1557. X                    + givencrystals > stolencrystals)
  1558. X                    crystals = stolencrystals - givencrystals;
  1559. X                planet->info[i - 1].resource += res;
  1560. X                givenres += res;
  1561. X                planet->info[i - 1].destruct += des;
  1562. X                givendes += des;
  1563. X                planet->info[i - 1].fuel += fuel;
  1564. X                givenfuel += fuel;
  1565. X                planet->info[i - 1].crystals += crystals;
  1566. X                givencrystals += crystals;
  1567. X
  1568. X                owners--;
  1569. X                sprintf(telegram_buf, "%-14.14s %5d %5d %5d %5d",
  1570. X                    races[i - 1]->name, res, des, fuel, crystals);
  1571. X                for (j = 1; j <= Num_races; j++)
  1572. X                    if (isset(ownerbits, j))
  1573. X                        push_telegram(j,
  1574. X                                  (int) Stars[starnum]->governor[j - 1],
  1575. X                                  telegram_buf);
  1576. X            }
  1577. X        /* Leftovers for last player */
  1578. X        for (; i <= Num_races; i++)
  1579. X            if (isset(ownerbits, i))
  1580. X                break;
  1581. X        if (i <= Num_races) {    /* It should be */
  1582. X            res = stolenres - givenres;
  1583. X            des = stolendes - givendes;
  1584. X            fuel = stolenfuel - givenfuel;
  1585. X            crystals = stolencrystals - givencrystals;
  1586. X
  1587. X            planet->info[i - 1].resource += res;
  1588. X            planet->info[i - 1].destruct += des;
  1589. X            planet->info[i - 1].fuel += fuel;
  1590. X            planet->info[i - 1].crystals += crystals;
  1591. X            sprintf(telegram_buf, "%-14.14s %5d %5d %5d %5d",
  1592. X                  races[i - 1]->name, res, des, fuel, crystals);
  1593. X            sprintf(buf, "%-14.14s %5d %5d %5d %5d\n", "Total:",
  1594. X              stolenres, stolendes, stolenfuel, stolencrystals);
  1595. X            for (j = 1; j <= Num_races; j++)
  1596. X                if (isset(ownerbits, j)) {
  1597. X                    push_telegram(j, (int) Stars[starnum]->governor[j - 1],
  1598. X                              telegram_buf);
  1599. X                    push_telegram(j, (int) Stars[starnum]->governor[j - 1],
  1600. X                              buf);
  1601. X                }
  1602. X        } else
  1603. X            push_telegram(1, 0, "Bug in stealing resources\n");
  1604. X        /* Next: take all the loot away from the losers */
  1605. X        for (i = 2; i <= Num_races; i++)
  1606. X            if (!isset(ownerbits, i)) {
  1607. X                planet->info[i - 1].resource = 0;
  1608. X                planet->info[i - 1].destruct = 0;
  1609. X                planet->info[i - 1].fuel = 0;
  1610. X                planet->info[i - 1].crystals = 0;
  1611. X            }
  1612. X    }
  1613. X}
  1614. X
  1615. Xdouble 
  1616. Xest_production(sectortype * s)
  1617. X{
  1618. X
  1619. X    /* Mod by SKF -- added by JPD */
  1620. X
  1621. X    double est_sec_prod;
  1622. X
  1623. X    est_sec_prod = races[s->owner-1]->metabolism*(double)s->eff*
  1624. X                (double)s->eff/200.0;
  1625. X
  1626. X    if (est_sec_prod > s->resource)
  1627. X            return ((double)s->resource);
  1628. X
  1629. X    return(est_sec_prod);
  1630. X}
  1631. END_OF_FILE
  1632. if test 33331 -ne `wc -c <'server/doplanet.c'`; then
  1633.     echo shar: \"'server/doplanet.c'\" unpacked with wrong size!
  1634. fi
  1635. # end of 'server/doplanet.c'
  1636. fi
  1637. echo shar: End of archive 7 \(of 21\).
  1638. cp /dev/null ark7isdone
  1639. MISSING=""
  1640. 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
  1641.     if test ! -f ark${I}isdone ; then
  1642.     MISSING="${MISSING} ${I}"
  1643.     fi
  1644. done
  1645. if test "${MISSING}" = "" ; then
  1646.     echo You have unpacked all 21 archives.
  1647.     echo "Now type './buildfiles.sh'"
  1648.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1649. else
  1650.     echo You still need to unpack the following archives:
  1651.     echo "        " ${MISSING}
  1652. fi
  1653. ##  End of shell archive.
  1654. exit 0
  1655.