home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume10 / gb3 / part04 < prev    next >
Internet Message Format  |  1990-06-08  |  56KB

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v10i004:  gb3 - Galactic Bloodshed, an empire-like war game [Ver. 2.0], Part04/14
  5. Message-ID: <5695@tekred.CNA.TEK.COM>
  6. Date: 1 Jun 90 19:06:02 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 2251
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: VANCLEEF@mps.ohio-state.edu
  12. Posting-number: Volume 10, Issue 4
  13. Archive-name: gb3/Part04
  14. Supersedes: GB2: Volume 7, Issue 44-51
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 4 (of 14)."
  25. # Contents:  server/land.c server/load.c server/name.c
  26. #   server/planet.list
  27. # Wrapped by billr@saab on Fri Jun  1 11:53:33 1990
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'server/land.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'server/land.c'\"
  31. else
  32. echo shar: Extracting \"'server/land.c'\" \(18841 characters\)
  33. sed "s/^X//" >'server/land.c' <<'END_OF_FILE'
  34. X/*
  35. X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  36. X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  37. X** Restrictions in GB_copyright.h.
  38. X**
  39. X**  land.c -- land a ship
  40. X**  also.... dock -- dock a ship w/ another ship 
  41. X**  and..... assault -- a very un-PC version of land/dock
  42. X*/
  43. X
  44. X#include "GB_copyright.h"
  45. X#define EXTERN extern
  46. X#include "vars.h"
  47. X#include "ships.h"
  48. X#include "races.h"
  49. X#include "buffers.h"
  50. X#include <signal.h>
  51. X#include <math.h>
  52. X
  53. Xint land_sectdata,land_shdata,land_pdata, land_racedata;
  54. Xint land_stdata;
  55. X
  56. Xland(Playernum,APcount, argn,args, Assault)
  57. Xint Playernum;
  58. Xint APcount;
  59. Xint argn;
  60. Xchar args[MAXARGS][COMMANDSIZE];
  61. Xint Assault;    /* unfriendly land */
  62. X{
  63. Xchar c;
  64. Xshiptype *s,*s2,*s3;
  65. Xplanettype *p;
  66. Xsectortype *sect;
  67. Xplacetype where;
  68. Xracetype *alien;
  69. Xboolean Land=0,Dock=0,cont,planetmod=0,sectmod=0;
  70. Xint boarders,oldspopn,olds2popn,dam,dam2,booby,
  71. X    numdest=0,ship2no,shipno,x= -1,y= -1,i,mask;
  72. Xint old2owner,sh, sh3;
  73. Xint sowner, s2owner, casualties, casualties2;
  74. Xfloat fuel,bstrength,b2strength,pris;
  75. Xdouble Dist;
  76. X
  77. Xland_sectdata = land_shdata = land_pdata = NEUTRAL_FD;
  78. X
  79. X
  80. X    sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
  81. X
  82. X
  83. Xfree(Race);
  84. Xopenracedata(&land_racedata);
  85. Xgetrace(land_racedata, &Race, Playernum); 
  86. Xclose_file(land_racedata);
  87. X
  88. X openshdata(&land_shdata);
  89. X  if (!getship(land_shdata, &s, shipno)) {
  90. X      notify(Playernum, "The ship wasn't found.\n");
  91. Xclose_file(land_shdata);
  92. X    return;
  93. X  }
  94. Xclose_file(land_shdata);
  95. X  if (testship(Playernum,s, shipno)) {
  96. X      notify(Playernum, "Illegal format.\n");
  97. X    return;
  98. X    }
  99. X
  100. X  if (s->is_docked) {
  101. X    sprintf(buf,"Ship #%d is already docked.\n",shipno);
  102. X        notify(Playernum, buf);
  103. X    return;
  104. X  }
  105. X
  106. X
  107. X  if (s->whatorbits==LEVEL_UNIV) {
  108. X     if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount)) {
  109. X    return;
  110. X    } 
  111. X } else
  112. X     if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) { 
  113. X    return;
  114. X    }
  115. X
  116. X        if(args[0][0]=='l')
  117. X        sscanf(args[2],"%d,%d",&x,&y); /* landing on a sector */
  118. X    else
  119. X        sscanf(args[2]+(args[2][0]=='#'),"%d",&ship2no);
  120. X
  121. X  if (args[0][0]=='l') {
  122. X    /* the command was 'land', don't need to get stuff */
  123. X    where.level = LEVEL_PLAN;
  124. X    where.snum = s->storbits;
  125. X    where.pnum = s->pnumorbits;
  126. X    where.err = 0;
  127. X  } else {    
  128. X
  129. X    where = Getplace(Playernum,args[2], 1);
  130. X    if (where.err) {
  131. X    return;
  132. X    }
  133. X  }
  134. X
  135. X  if (where.level==LEVEL_PLAN)
  136. X    Land = 1;
  137. X  else if (where.level==LEVEL_SHIP)
  138. X    Dock = 1;
  139. X  else {
  140. X    sprintf(buf,"Your ship is not equipped to do that!\n");
  141. X    notify(Playernum, buf);
  142. X    return;
  143. X  }
  144. X
  145. X
  146. X  if (Dock) {
  147. X
  148. X    ship2no = where.shipno;
  149. X    s2 = where.shipptr;
  150. X    free(where.shipptr);    /* re-get ship cuz it wasn't locked */
  151. Xopenshdata(&land_shdata);
  152. X         if (!getship(land_shdata, &s2, ship2no)) {
  153. X        close_file(land_shdata);
  154. X        return;
  155. X        }
  156. X    close_file(land_shdata);
  157. X    
  158. X    if ( !(s->type == STYPE_FIGHTER && s2->type == STYPE_CARRIER) ) {
  159. X       if (s2->is_docked && !Assault) {
  160. X        sprintf(buf,"ship #%d is already docked.\n",ship2no);
  161. X            notify(Playernum, buf);
  162. X        return;
  163. X       }
  164. X    sprintf(buf,"Distance to %s #%d: %.2f.\n", s2->name, ship2no,
  165. X          Dist = sqrt((double)Distsq(s2->xpos, s2->ypos, 
  166. X            s->xpos, s->ypos ) ) );
  167. X        notify(Playernum, buf);
  168. X    if (Dist > DIST_TO_LAND) {
  169. X         sprintf(buf,"Ship #%d must be %.2f or closer to ship #%d.\n",
  170. X            shipno, DIST_TO_LAND, ship2no);
  171. X        notify(Playernum, buf);
  172. X        return;
  173. X    }
  174. X
  175. X    fuel = 0.05 + Dist * 0.25 * (Assault ? 2.0 : 1.0);
  176. X    sprintf(buf,"This maneuver will take %.2f fuel (of %.2f.)\n\n",fuel,s->fuel);
  177. X        notify(Playernum, buf);
  178. X    if (fuel > s->fuel) {
  179. X        sprintf(buf,"Not enough fuel.\n");
  180. X            notify(Playernum, buf);
  181. X        return;
  182. X    }
  183. X
  184. X    if (Assault) {
  185. X    openracedata(&land_racedata);
  186. X        getrace(land_racedata, &alien, s2->owner);
  187. X    close_file(land_racedata);
  188. X
  189. X    sscanf(args[3],"%d",&boarders);
  190. X        if (boarders > MIN(s->popn, Max_crew(s2))
  191. X            || boarders <= 0) {
  192. X            sprintf(buf,"Illegal number of boarders (max can be %d).\n",
  193. X                MIN(s->popn, Max_crew(s2)));
  194. X            notify(Playernum, buf);
  195. X            return;
  196. X        }
  197. X        old2owner = s2->owner;
  198. X        s->popn -= boarders;
  199. X        s->mass -= boarders * Race->mass;
  200. X        sprintf(buf,"Boarding strength :%.2f       Defense strength: %.2f.\n", 
  201. X           bstrength = 0.1 * boarders * log10(Race->fighters
  202. X            * (Race->tech+1.0)
  203. X                 * Size(s) * 1 + 10)
  204. X            * .01 * (100 - s->damage),
  205. X        /* 1 is dummy armor */
  206. X
  207. X           b2strength = 0.1* s2->popn * log10(alien->fighters
  208. X            * (alien->tech+1.0)
  209. X             * Size(s2) * (Armor(s2)+1) + 10)
  210. X            * .01 * (100 - s2->damage)
  211. X                );
  212. X    notify(Playernum, buf);
  213. X
  214. X    }
  215. X
  216. X
  217. X     /* the ship moves into position, regardless of success of attack */
  218. X    s->fuel -= fuel;
  219. X    s->mass -= fuel * MASS_FUEL;
  220. X
  221. X    s->xpos = s2->xpos + rposneg();        /* either -1 or 1 */
  222. X    s->ypos = s2->ypos + int_rand(-1,1);
  223. X
  224. X    if (Assault) {
  225. X/* if the assaulted ship is docked, undock it first */
  226. X    if(s2->is_docked && s2->whatdest==LEVEL_SHIP) {
  227. X        openshdata(&land_shdata);
  228. X        getship(land_shdata, &s3, s2->destshipno);
  229. X        s3->is_docked = 0;
  230. X        s3->whatdest = LEVEL_UNIV;
  231. X        s3->destshipno = 0;
  232. X        putship(land_shdata, s3, s2->destshipno);
  233. X        close_file(land_shdata);
  234. X        free(s3);
  235. X        s2->is_docked = 0;
  236. X        s2->whatdest = LEVEL_UNIV;
  237. X        s2->destshipno = 0;
  238. X    }
  239. X         /* nuke both populations, ships */
  240. Xif(b2strength) {    /* otherwise the ship surrenders */
  241. X        casualties = MIN(boarders, int_rand(0,
  242. X               round_rand((float)boarders * b2strength / bstrength)));
  243. X        boarders -= casualties;
  244. X
  245. X            dam = MIN(100, int_rand(0, round_rand(25. * b2strength/bstrength)));
  246. X        s->damage = MIN(100, s->damage+dam);
  247. X        if (s->damage >= 100) {
  248. X            s->popn = 0;
  249. X            kill_ship(s);
  250. X            }            
  251. X
  252. X           casualties2 = MIN(s2->popn, int_rand(0,
  253. X                    round_rand((float)s2->popn * bstrength / b2strength)));
  254. X           s2->popn -= casualties2;
  255. X           s2->mass -= casualties2 * alien->mass;
  256. X            /* (their mass) */
  257. X           dam2 = MIN(100, int_rand(0,round_rand(25. * bstrength/b2strength)));
  258. X           s2->damage = MIN(100, s2->damage+dam2);
  259. X           if ( s2->damage >= 100) {
  260. X            s2->popn = 0;
  261. X            kill_ship(s2);
  262. X            }
  263. X} else {
  264. X    s2->popn = 0;
  265. X/* do booby traps */
  266. X         /* check for boobytrapping */
  267. X        if (!Max_crew(s2) && s2->destruct > 0)
  268. X            booby = MIN(100, int_rand(0,round_rand(
  269. X                     log1p((double)s2->destruct)*50)));
  270. X
  271. X    }
  272. X
  273. X           if ((s2->popn == 0) &&  s->is_alive && s2->is_alive) {
  274. X                /* we got 'em */
  275. X            s->is_docked = 1;
  276. X            s->whatdest = LEVEL_SHIP;
  277. X            s->destshipno = ship2no;
  278. X
  279. X            s2->is_docked = 1;
  280. X            s2->whatdest = LEVEL_SHIP;
  281. X            s2->destshipno = shipno;
  282. X            old2owner = s2->owner;
  283. X            s2->owner = Playernum;
  284. X            s2->popn = boarders;
  285. X            s2->mass += boarders * Race->mass;    /* our mass */
  286. X           } else {        /* retreat */
  287. X            s->popn += boarders;
  288. X            s->mass += boarders * Race->mass;
  289. X           }
  290. X
  291. X    } else {
  292. X        s->is_docked = 1;
  293. X        s->whatdest = LEVEL_SHIP;
  294. X        s->destshipno = ship2no;
  295. X
  296. X        s2->is_docked = 1;
  297. X        s2->whatdest = LEVEL_SHIP;
  298. X        s2->destshipno = shipno;
  299. X    }
  300. X
  301. X    s->notified = s2->notified = 0;
  302. X       openshdata(&land_shdata);
  303. X    putship(land_shdata, s, shipno);
  304. X    putship(land_shdata, s2, ship2no);
  305. X       free(s2);
  306. X       close_file(land_shdata);
  307. X    if (Assault) {
  308. X/* races find out about each other */
  309. X    alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+5, 100);
  310. X    Race->translate[s2->owner-1] = MIN(Race->translate[s2->owner-1]+5, 100);
  311. Xsowner = s->owner;
  312. Xs2owner = s2->owner;
  313. X        sprintf(telegram_buf,"%s #%d ASSAULTED by ",
  314. X            Shipnames[s2->type], ship2no);
  315. X             sprintf(buf,"%s #%d [%d] at %s\n", 
  316. X            Shipnames[s->type], shipno, s->owner, prin_ship_orbits(s2));
  317. X            str_cat(telegram_buf, buf);
  318. X        sprintf(buf,"Your damage: %d%%, theirs: %d%%.\n", dam2, dam);
  319. X            str_cat(telegram_buf, buf);
  320. X        if (!Max_crew(s2) && s2->destruct) {
  321. X               sprintf(buf,"(Your boobytrap gave them %.0f%% damage.)\n",
  322. X                booby);
  323. X            str_cat(telegram_buf, buf);
  324. X            sprintf(buf,"Their boobytrap gave you %.0f%% damage!)\n",
  325. X                booby);
  326. X            notify(Playernum, buf);
  327. X        }
  328. X        sprintf(buf,"Damage taken:  You: %d%% (now %d%%)\n", dam, s->damage);
  329. X            notify(Playernum, buf);
  330. Xif(!s->is_alive) {
  331. X  sprintf(buf,"              YOUR SHIP WAS DESTROYED!!!\n");
  332. X            notify(Playernum, buf);
  333. X  sprintf(buf,"              Their ship DESTROYED!!!\n");
  334. X        str_cat(telegram_buf, buf);
  335. X}
  336. X        sprintf(buf,"              Them: %d%% (now %d%%)\n",dam2,s2->damage);
  337. X            notify(Playernum, buf);
  338. Xif(!s2->is_alive) {
  339. X  sprintf(buf,"              Their ship DESTROYED!!!  Boarders are dead.\n");
  340. X            notify(Playernum, buf);
  341. X  sprintf(buf,"              YOUR SHIP WAS DESTROYED!!!\n");
  342. X        str_cat(telegram_buf, buf);
  343. X}
  344. X        if (s->is_alive) {
  345. X            if (s2->owner==Playernum) {
  346. X                sprintf(buf,"CAPTURED!\n");
  347. X                    str_cat(telegram_buf, buf);
  348. X                sprintf(buf,"VICTORY! the ship is yours!\n");
  349. X                    notify(Playernum, buf);
  350. X                if (boarders) {
  351. X                  sprintf(buf,"%d boarders move in.\n", boarders);
  352. X                    notify(Playernum, buf);
  353. X                    }
  354. X
  355. X    Race->translate[s2owner-1] = MIN(Race->translate[s2owner-1]+25, 100);
  356. X
  357. X            } else if(s2->popn) {
  358. X                sprintf(buf,"The boarding was repulsed; try again.\n");
  359. X                    notify(Playernum, buf);
  360. X                sprintf(buf,"You fought them off!\n");
  361. X                    str_cat(telegram_buf, buf);
  362. X            }
  363. X        } else {
  364. X            sprintf(buf,"The assault was too much for your bucket of bolts.\n");
  365. X                    notify(Playernum, buf);
  366. X            sprintf(buf,"The assault was too much for their ship..\n");
  367. X                str_cat(telegram_buf, buf);
  368. X        }
  369. X        if (s2->is_alive) {
  370. X            if (!boarders) {
  371. X                sprintf(buf,"Oh no! They killed your boarding party to the last man!\n");
  372. X                    notify(Playernum, buf);
  373. X    alien->translate[sowner-1] = MIN(alien->translate[sowner-1]+25, 100);
  374. X            }
  375. X
  376. X            if (!s->popn) {
  377. X                sprintf(buf,"You killed all their crew!\n");
  378. X                str_cat(telegram_buf, buf);
  379. X            } 
  380. X        } else {
  381. X            sprintf(buf,"The assault weakened their ship too much!\n");
  382. X                notify(Playernum, buf);                
  383. X            sprintf(buf,"Your ship was weakened too much!\n");
  384. X                str_cat(telegram_buf, buf);
  385. X        }
  386. X        sprintf(buf,"Casualties: Yours: %d     Theirs: %d\n", casualties2, casualties);
  387. X            str_cat(telegram_buf, buf);
  388. X        sprintf(buf,"Crew casualties: Yours: %d     Theirs: %d\n", casualties, casualties2);
  389. X            notify(Playernum, buf);
  390. X            if(!notify(old2owner, telegram_buf))
  391. X                push_message(TELEG_PLAYER_AUTO, old2owner, telegram_buf);
  392. Xopenracedata(&land_racedata);
  393. Xputrace(land_racedata, Race);
  394. Xputrace(land_racedata, alien);
  395. Xclose_file(land_racedata);
  396. X
  397. X    } else {
  398. X        sprintf(buf,"ship #%d docked with ship #%d.\n",shipno, ship2no);
  399. X            notify(Playernum, buf);
  400. X        }
  401. X
  402. X    } else {
  403. X        /* docking fighters with a carrier */
  404. X
  405. X    if(s->whatorbits==LEVEL_PLAN)
  406. X        {
  407. X     openpdata(&land_pdata);
  408. X     getplanet(land_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
  409. X
  410. X    sh = p->ships;
  411. X    if(sh == shipno){
  412. X        p->ships = s->nextship;
  413. X        putplanet(land_pdata, p, Stars[s->storbits]->planetpos[s->pnumorbits]);
  414. X        } else {
  415. Xopenshdata(&land_shdata);
  416. X        while(sh != shipno){
  417. X        getship(land_shdata, &s3, sh);
  418. X        sh3 = sh;
  419. X        sh = s3->nextship;
  420. X      }
  421. X      s3->nextship = s->nextship;
  422. X      if(sh3 == ship2no)s2->nextship = s3->nextship;
  423. X      putship(land_shdata, s3, sh3);
  424. X      close_file(land_shdata);
  425. Xfree(s3);
  426. X}
  427. X      close_file(land_pdata);
  428. X        }
  429. X
  430. X
  431. X    if(s->whatorbits==LEVEL_STAR)
  432. X        {
  433. X     openstardata(&land_stdata);
  434. X     getstar(land_stdata, &Stars[s->storbits], s->storbits);
  435. X
  436. X    sh = Stars[s->storbits]->ships;
  437. X    if(sh == shipno){
  438. X        Stars[s->storbits]->ships = s->nextship;
  439. X    putstar(land_stdata, Stars[s->storbits], s->storbits);
  440. X            } else {
  441. X    openshdata(&land_shdata);
  442. X    while(sh != shipno){
  443. X         getship(land_shdata, &s3, sh);
  444. X    sh3 = sh;
  445. X    sh = s3->nextship;
  446. X    }
  447. X    s3->nextship = s->nextship;
  448. X    if(sh3 == ship2no)s2->nextship = s3->nextship;
  449. X
  450. X    putship(land_shdata, s3, sh3);
  451. X    close(land_shdata);
  452. X    free(s3);
  453. X    }
  454. X
  455. X     close_file(land_stdata);
  456. X        }
  457. X
  458. X
  459. X        s->fuel -= fuel;
  460. X        s->mass -= fuel * MASS_FUEL;
  461. X        s->is_docked = 1;
  462. X        s->whatdest = LEVEL_SHIP;
  463. X        s->whatorbits = LEVEL_UNIV;
  464. X        s->destshipno = ship2no;
  465. X        s->nextship = 0;
  466. X
  467. X        s->xpos = s2->xpos;
  468. X        s->ypos = s2->ypos;
  469. X
  470. X        s->object.number = s2->object.number;
  471. X        s->object.number4 = 1; /* docked with carrier */
  472. X
  473. X         /* remove fighter from upper level linked list */
  474. X        s2->object.number = shipno;
  475. X        s2->object.number4 += 1; /* number of fighters docked */
  476. X        s2->mass += s->mass;
  477. X
  478. X        s->notified = s2->notified = 0;
  479. X    openshdata(&land_shdata);
  480. X    putship(land_shdata, s, shipno);
  481. X        putship(land_shdata, s2, ship2no);
  482. X    free(s2);
  483. X    close(land_shdata);
  484. X    }
  485. X
  486. X  } else {    /* docking with a planet */
  487. X
  488. X     if (s->whatorbits!=LEVEL_PLAN) {
  489. X    sprintf(buf,"%s #%d doesn't orbit a planet.\n", Shipnames[s->type],
  490. X        shipno);
  491. X        notify(Playernum, buf);
  492. X    return;
  493. X     }
  494. X     if (Assault && s->popn < 1) {
  495. X    sprintf(buf,"The assaulting ship must have >= 1 crew.\n");
  496. X        notify(Playernum, buf);
  497. X    return;
  498. X     }
  499. X
  500. X    if(s->storbits != Dir[Playernum-1].snum || s->pnumorbits != Dir[Playernum-1].pnum)
  501. X        {
  502. X    sprintf(buf,"Wrong scope!\n");
  503. X        notify(Playernum, buf);
  504. X    return;
  505. X    }
  506. X
  507. X
  508. X     openpdata(&land_pdata);
  509. X     getplanet(land_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
  510. X     close_file(land_pdata);
  511. X     
  512. X     sprintf(buf,"Planet /%s/%s has gravity field of %.2f.\n", Stars[s->storbits]->name,
  513. X    Stars[s->storbits]->pnames[s->pnumorbits], gravity(p));
  514. X        notify(Playernum, buf);
  515. X
  516. X     sprintf(buf,"Distance to planet: %.2f.\n",
  517. X      Dist = sqrt((double)Distsq(Stars[s->storbits]->xpos + p->xpos, 
  518. X                Stars[s->storbits]->ypos + p->ypos, 
  519. X                s->xpos, s->ypos ) )
  520. X      );
  521. X        notify(Playernum, buf);
  522. X
  523. X     if (Dist > DIST_TO_LAND) {
  524. X        sprintf(buf,"Ship #%d must be %.3g or closer to the planet (%.2f).\n",shipno, DIST_TO_LAND, Dist);
  525. X        notify(Playernum, buf);
  526. X    return;
  527. X     }
  528. X
  529. X     fuel = 0.05 + logscale((int)s->mass)*gravity(p) * LAND_GRAV_MASS_FACTOR + Assault;
  530. X
  531. X     if (fuel < s->fuel) {
  532. X      if (!Shipdata[s->type][ABIL_CANLAND] && !Dock) {
  533. X        sprintf(buf,"This ship is not equipped to land.\n");
  534. X        notify(Playernum, buf);
  535. X        return;
  536. X      }
  537. X      if (!speed_rating(s)) {
  538. X        sprintf(buf,"This ship is not rated for maneuvering.\n");
  539. X        notify(Playernum, buf);
  540. X        return;
  541. X      }
  542. X      if (!Dock && (s->resource > Max_resource(s)
  543. X        || s->fuel > Max_fuel(s)
  544. X        || s->popn > Max_crew(s)
  545. X        || s->destruct > Max_destruct(s))) {
  546. X        sprintf(buf,"Ship is too overloaded to land.\n");
  547. X        notify(Playernum, buf);
  548. X        return;
  549. X      }
  550. X     }
  551. X
  552. X     sprintf(buf,"That maneuver costs %.2f fuel (of %.2f).\n",fuel, s->fuel);
  553. X        notify(Playernum, buf);
  554. X
  555. X     if (s->fuel < fuel) {
  556. X      sprintf(buf,"NOT ENOUGH FUEL ");
  557. X        notify(Playernum, buf);
  558. X        return;
  559. X     }
  560. X
  561. X     cont = 1;
  562. X     do {
  563. X
  564. X    if(x < 0 || y < 0 || x > p->Maxx || y > p->Maxy) {
  565. X        sprintf(buf,"Illegal coordinates.\n");
  566. X            notify(Playernum, buf);
  567. X            return;
  568. X            }
  569. X    opensectdata(&land_sectdata);
  570. X    getsector(land_sectdata,§,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
  571. X    close_file(land_sectdata);
  572. X       if(s->type != OTYPE_TERRA) {
  573. X       if (Race->likes[sect->des] == 0.0 && !sect->is_wasted) {
  574. X    sprintf(buf,"The ship is not built to land on that sector.\n");
  575. X        notify(Playernum, buf);
  576. X    return;
  577. X       }
  578. X       if (sect->is_wasted) {
  579. X    sprintf(buf,"Warning: That sector is a wasteland!\n");
  580. X        notify(Playernum, buf);
  581. X       }
  582. X     }
  583. X       if (Assault) {
  584. X        if (sect->owner==Playernum) {
  585. X        sprintf(buf,"You cannot assault your own sector.\n");
  586. X        notify(Playernum, buf);
  587. X        return;
  588. X        } else if (sect->popn > 0) {
  589. X        sprintf(buf,"The assaulted sector must have no population.\n");
  590. X        notify(Playernum, buf);
  591. X        return;
  592. X        }
  593. X       } else if (sect->owner && sect->owner!=Playernum) {
  594. X    openracedata(&land_racedata);
  595. X     getrace(land_racedata, &alien, sect->owner);
  596. X    close_file(land_racedata);
  597. X
  598. X       if(!(isset(Race->allied, sect->owner) && 
  599. X        isset(alien->allied, Playernum))) {
  600. X    sprintf(buf,"You are not mutually allied with %s.\n", alien->name);
  601. X        notify(Playernum, buf);
  602. X    return;
  603. X      } else {
  604. X    sprintf(buf,"You have landed on allied sector (%s).\n",alien->name);
  605. X        notify(Playernum, buf);
  606. X      }
  607. X       }
  608. X       if (!cont)
  609. X    free(sect);
  610. X
  611. X
  612. X     } while (!cont);
  613. X
  614. X     if (s->fuel < fuel) {
  615. X
  616. X
  617. X    kill_ship(s);
  618. Xopenshdata(&land_shdata);
  619. X    putship(land_shdata, s, shipno);
  620. X    close(land_shdata);
  621. X    free(s);
  622. X
  623. X    if (!fork()) {
  624. X        /* fork off a child process to do damage */
  625. X      where.level = LEVEL_PLAN;
  626. X      where.snum = s->storbits;
  627. X      where.pnum = s->pnumorbits;
  628. X
  629. X      /* first "where" is dummy-- just checks to see if it's a GR
  630. X         laser; we don't need it */
  631. X      numdest = blast(Playernum,&where, &where, 0, p, x, y, Dist, 100.,
  632. X            round_rand(log1p((double)s->mass)*2+(float)s->destruct/3.), 1);
  633. X      sprintf(buf,"BOOM!! Ship #%d crashes on sector %d,%d with blast radius of %d.\n",
  634. X        shipno, x, y, numdest);
  635. X        notify(Playernum, buf);
  636. X
  637. X      exit(0);
  638. X    }
  639. X
  640. X     } else {
  641. X  
  642. X   
  643. X         s->xpos = (float)x;
  644. X         s->ypos = (float)y;
  645. X
  646. X         s->fuel -= fuel;
  647. X         s->mass -= fuel * MASS_FUEL;
  648. X         s->is_docked = 1;
  649. X         s->whatdest = LEVEL_PLAN;    /* no destination */
  650. X         s->deststar = s->storbits;
  651. X         s->destpnum = s->pnumorbits;
  652. X
  653. X         if (Assault) {
  654. X        /* assault on planet increases combat readiness, */
  655. X        /* but only if we aren't already well-established there */
  656. X      if (p->info[Playernum-1].numsectsowned==0 && p->info[Playernum-1].comread < 50) {
  657. X        p->info[Playernum-1].comread = 100;
  658. X        p->info[Playernum-1].mob_set = 100;
  659. X        sect->mobilization = 100;
  660. X        sect->is_wasted = 0;
  661. X      }
  662. X      sectmod = planetmod = 1;
  663. X       /* unload some people onto the sector */
  664. X      sect->popn = s->popn-1;
  665. X      s->mass -= (s->popn-1) * Race->mass;
  666. X      s->popn = 1;
  667. X      sect->owner = Playernum;
  668. X      p->info[Playernum-1].numsectsowned++;
  669. X       }
  670. X     }
  671. X     s->notified = 0;    /* reset notification */
  672. Xopenshdata(&land_shdata);
  673. X     putship(land_shdata, s, shipno);
  674. X  close_file(land_shdata);
  675. X
  676. X  }
  677. X
  678. X
  679. X
  680. X  if (s->whatorbits==LEVEL_UNIV)
  681. X      deductAPs(Playernum,APcount, 0, 1);
  682. X  else
  683. X      deductAPs(Playernum,APcount, s->storbits, 0);
  684. X
  685. X
  686. X  if (!Dock) {
  687. X      if (planetmod) {
  688. X      openpdata(&land_pdata);
  689. X      putplanet(land_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]);
  690. X      close_file(land_pdata);
  691. X      }
  692. X   /* */
  693. Xopensectdata(&land_sectdata);
  694. X      if (sectmod && !numdest)
  695. X      putsector(land_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
  696. X      close_file(land_sectdata);
  697. X      free(sect);
  698. X
  699. X    /* send telegs to anyone there */
  700. X      if (Assault) {
  701. X          sprintf(telegram_buf,"Planet /%s/%s ",
  702. X            Stars[s->storbits]->name,
  703. X            Stars[s->storbits]->pnames[s->pnumorbits]);
  704. X          sprintf(buf,"ASSAULTED by %s #%d on sector %.0f,%.0f!!\n", 
  705. X            Shipnames[s->type], shipno, s->xpos, s->ypos);
  706. X            str_cat(telegram_buf, buf);
  707. X      } else {
  708. X          sprintf(telegram_buf,"%s #%d observed landing on sector %.0f,%.0f, planet /%s/%s.\n",
  709. X            Shipnames[s->type], shipno, s->xpos,s->ypos,Stars[s->storbits]->name,
  710. X            Stars[s->storbits]->pnames[s->pnumorbits]);
  711. X            str_cat(telegram_buf, buf);
  712. X      }
  713. X      for (i=1; i<=Numraces(); i++)
  714. X        if (p->info[i-1].numsectsowned && i!=Playernum) {
  715. X            notify(i, telegram_buf);
  716. X            }
  717. X   free(p);
  718. X
  719. X        sprintf(buf,"%s #%d %s landed on planet.\n",Shipnames[s->type],
  720. X         shipno,s->name);
  721. X        notify(Playernum, buf);
  722. X  }
  723. X
  724. Xopenracedata(&land_racedata);
  725. Xputrace(land_racedata, Race);
  726. Xclose(land_racedata);
  727. X
  728. X  free(s);
  729. X
  730. X}
  731. X
  732. X
  733. END_OF_FILE
  734. if test 18841 -ne `wc -c <'server/land.c'`; then
  735.     echo shar: \"'server/land.c'\" unpacked with wrong size!
  736. fi
  737. # end of 'server/land.c'
  738. fi
  739. if test -f 'server/load.c' -a "${1}" != "-c" ; then 
  740.   echo shar: Will not clobber existing file \"'server/load.c'\"
  741. else
  742. echo shar: Extracting \"'server/load.c'\" \(15077 characters\)
  743. sed "s/^X//" >'server/load.c' <<'END_OF_FILE'
  744. X/*
  745. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  746. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  747. X * Restrictions in GB_copyright.h.
  748. X *
  749. X *  load.c -- load/unload stuff
  750. X */
  751. X
  752. X#include "GB_copyright.h"
  753. X#define EXTERN extern
  754. X#include "vars.h"
  755. X#include "ships.h"
  756. X#include "races.h"
  757. X#include "buffers.h"
  758. X#include <signal.h>
  759. X
  760. Xint load_shdata,load_pdata,load_sectdata, load_racedata;
  761. X
  762. X
  763. Xload(Playernum,APcount, argn,args)
  764. Xint Playernum;
  765. Xint APcount;
  766. Xint argn;
  767. Xchar args[MAXARGS][COMMANDSIZE];
  768. X{
  769. Xboolean jett=0,sh=0,diff=0;
  770. Xint first=1,proc,Mod=0,lolim,uplim, shipno,amt;
  771. Xint test;
  772. Xint transfercrew;
  773. Xchar commod, buff[128], bufr[128], bufd[128], bufc[128];
  774. Xshiptype *s,*s2;
  775. Xplanettype *p;
  776. Xsectortype *sect;
  777. X
  778. X    load_shdata = load_pdata = load_sectdata = NEUTRAL_FD;
  779. X
  780. X    sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
  781. X
  782. X    openshdata(&load_shdata);
  783. Xif (!getship(load_shdata,&s,shipno)) {
  784. X    close_file(load_shdata);
  785. X    return;
  786. X    }
  787. Xclose_file(load_shdata);
  788. Xif (s->owner!=Playernum || !s->is_alive) {
  789. X    DontOwnErr(Playernum,shipno);
  790. X    sprintf(buf,"(%d)\n",s->owner);
  791. X        notify(Playernum, buf);
  792. X    free(s);
  793. X    return;
  794. X    }
  795. X    if (!s->active) {
  796. X    sprintf(buf,"%s #%d is irradiated and inactive.\n", Shipnames[s->type],shipno);
  797. X        notify(Playernum, buf);
  798. X    free(s);
  799. X    return;
  800. X    }
  801. X
  802. Xfree(Race);
  803. Xopenracedata(&load_racedata);
  804. Xgetrace(load_racedata, &Race, Playernum);
  805. Xclose_file(load_racedata);
  806. X
  807. X    if (s->whatorbits==LEVEL_UNIV) {
  808. X        if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount))
  809. X        free(s);
  810. X    } else 
  811. X    if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
  812. X        free(s);
  813. X        return;
  814. X    }
  815. X
  816. X   
  817. X    proc = 0;
  818. X
  819. X    
  820. X    if (s->type == OTYPE_TRANSDEV && s->object.number > 0) {
  821. X    openshdata(&load_shdata);
  822. X    if (!getship(load_shdata,&s2, s->object.number)) {
  823. X        sprintf(buf,"The hopper seems to be blocked.\n");
  824. X        notify(Playernum, buf);
  825. X        close_file(load_shdata);
  826. X        return;
  827. X    }
  828. X    close_file(load_shdata);
  829. X    if (!s2->is_alive) {
  830. X        sprintf(buf,"The target device does not exist.\n");
  831. X        notify(Playernum, buf);
  832. X        return;
  833. X    }
  834. X    if (s2->type!=OTYPE_TRANSDEV || !s2->on) {
  835. X    sprintf(buf,"s2->type = %d\n",s2->type);
  836. X        notify(Playernum, buf);
  837. X    sprintf(buf,"OTYPE_TRANSDEV = %d\n",OTYPE_TRANSDEV);
  838. X        notify(Playernum, buf);
  839. X
  840. X    sprintf(buf,"s2->on = %d\n",s2->on);
  841. X        notify(Playernum, buf);
  842. X        sprintf(buf,"The target device is not receiving.\n");
  843. X        notify(Playernum, buf);
  844. X        return;
  845. X    }
  846. X    } else if (!s->is_docked) {
  847. X    if (s->type==OTYPE_TRANSDEV) {
  848. X        sprintf(buf,"It does not seem to work in zero-g environments.\n");
  849. X        notify(Playernum, buf);
  850. X        return;
  851. X    }
  852. X    sprintf(buf,"%s #%d is not landed.\n",is_object(s)?"object":"ship",shipno);
  853. X        notify(Playernum, buf);
  854. X        return;
  855. X    } else {
  856. X    if (s->whatdest==LEVEL_PLAN)
  857. X        {
  858. X        sprintf(buf,"Ship #%d at %.0f,%.0f\n", shipno, s->xpos, s->ypos);
  859. X        notify(Playernum, buf);
  860. X              if(s->storbits != Dir[Playernum-1].snum || s->pnumorbits != Dir[Playernum-1].pnum)
  861. X                    {
  862. X                    sprintf(buf,"Wrong scope!\n");
  863. X                    notify(Playernum, buf);
  864. X                    return;
  865. X                    }
  866. X        } else {
  867. X            openshdata(&load_shdata);
  868. X        if (!getship(load_shdata, &s2, s->destshipno) 
  869. X            || !s2->is_alive 
  870. X            || !s->object.number4 &&
  871. X              !(s2->is_docked && s2->whatdest==LEVEL_SHIP 
  872. X              && s2->destshipno==shipno) ) {
  873. X                /* the ship it was docked with died or
  874. X                   undocked with it or something. */
  875. X            s->is_docked = 0;
  876. X            s->whatdest = LEVEL_UNIV;
  877. X            putship(load_shdata, s, shipno);
  878. X            close_file(load_shdata);
  879. X            free(s);
  880. X            sprintf(buf,"ship #%u is not docked.\n", s->destshipno);
  881. X                notify(Playernum, buf);
  882. X            return;
  883. X            }
  884. X        close(load_shdata);
  885. X        sprintf(buf,"Ship #%d docked with %s #%d\n", shipno, 
  886. X                Shipnames[s2->type], s->destshipno);
  887. X            notify(Playernum, buf);
  888. X        sh = 1;
  889. X        if (s2->owner!=Playernum) {
  890. X            sprintf(buf,"Player %d owns that ship.\n", s2->owner);
  891. X                notify(Playernum, buf);
  892. X            diff = 1;
  893. X        }
  894. X    }
  895. X    }
  896. X
  897. X
  898. X commod = args[2][0];
  899. X    if(argn>3)
  900. X            amt = atoi(args[3]);
  901. X    else
  902. X            amt = 0;
  903. X    
  904. X    if (!jett && !sh) {
  905. X        openpdata(&load_pdata);
  906. X        getplanet(load_pdata,&p,Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
  907. X    close_file(load_pdata);
  908. X    }
  909. X
  910. X       if (!jett && !sh && commod=='c') {
  911. X        opensectdata(&load_sectdata);
  912. X        getsector(load_sectdata, §, p->sectormappos 
  913. X            + ( (int)s->ypos*p->Maxx+(int)s->xpos) * sizeof(sectortype) );
  914. X    close_file(load_sectdata);
  915. X    }
  916. X
  917. X    switch (commod) {
  918. X
  919. X    case 'c': if (jett) {
  920. X            uplim = 0;
  921. X            lolim = -s->popn;
  922. X          } else
  923. X            if (sh) {
  924. X                uplim = diff ? 0 : MIN(s2->popn, 
  925. X                  Max_crew(s) - s->popn);
  926. X            lolim = diff ? 0 : - MIN(s->popn, 
  927. X                  Max_crew(s2) - s2->popn);
  928. X            } else {
  929. X                uplim = MIN(sect->popn, 
  930. X                  Max_crew(s) - s->popn);
  931. X            lolim = -s->popn;
  932. X            }
  933. X          proc = 1;
  934. X          break;
  935. X
  936. X    case 'd': if (jett) {
  937. X            uplim = 0;
  938. X            lolim = -s->destruct;
  939. X          } else
  940. X            if (sh) {
  941. X                uplim = diff ? 0 : MIN(s2->destruct, 
  942. X                 Max_destruct(s) - s->destruct);
  943. X            lolim = -MIN(s->destruct, 
  944. X                 Max_destruct(s2) - s2->destruct);
  945. X            } else {
  946. X                uplim = MIN(p->info[Playernum-1].destruct,
  947. X                 Max_destruct(s) - s->destruct);
  948. X            lolim = -s->destruct;
  949. X            }
  950. X          proc = 1;
  951. X          break;
  952. X
  953. X    case 'f': if (jett) {
  954. X            uplim = 0;
  955. X            lolim = -(int)s->fuel;
  956. X          } else
  957. X            if (sh) {
  958. X                uplim = diff ? 0.0 : MIN((int)s2->fuel, 
  959. X                 Max_fuel(s) - (int)s->fuel);
  960. X            lolim = - MIN((int)s->fuel, 
  961. X                 Max_fuel(s2) - (int)s2->fuel);
  962. X            } else {
  963. X                uplim = MIN((int)p->info[Playernum-1].fuel,
  964. X                 Max_fuel(s) - (int)s->fuel);
  965. X            lolim = -(int)s->fuel;
  966. X            }
  967. X          proc = 1;
  968. X          break;
  969. X
  970. X    case 'r': if (jett) {
  971. X            uplim = 0;
  972. X            lolim = -s->resource;
  973. X          } else
  974. X            if (sh) {
  975. X                if (s->type==STYPE_SHUTTLE)
  976. X              uplim = diff ? 0 : s2->resource;
  977. X            else
  978. X              uplim = diff ? 0 : MIN(s2->resource, 
  979. X                   Max_resource(s) - s->resource);
  980. X            if (s2->type==STYPE_SHUTTLE)
  981. X              lolim = -s->resource;
  982. X            else
  983. X              lolim = - MIN(s->resource, 
  984. X                   Max_resource(s2) - s2->resource);
  985. X            } else {
  986. X                uplim = MIN(p->info[Playernum-1].resource,
  987. X                 Max_resource(s) - s->resource);
  988. X            lolim = -s->resource;
  989. X            }
  990. X          proc = 1;
  991. X          break;
  992. X
  993. X    default:
  994. X        notify(Playernum, "No such commodity valid.\n");
  995. X        return;
  996. X      }
  997. X
  998. Xif(amt<lolim || amt>uplim) {
  999. X    sprintf(buf, "you can only transfer between %d and %d.\n", lolim, uplim);
  1000. X    notify(Playernum, buf);
  1001. X    return;
  1002. X    }
  1003. X
  1004. Xif(amt==0) 
  1005. X    amt = uplim;
  1006. X
  1007. X    switch (commod) {
  1008. X
  1009. X      case 'c': if (!jett) {
  1010. X            if (sh) {
  1011. X                s2->popn -= amt;
  1012. X                s2->mass -= amt*Race->mass;
  1013. X                transfercrew = 1;
  1014. X            } else
  1015. X              if(sect->owner && sect->owner != Playernum) {
  1016. X                   sprintf(buf,"That sector is already occupied by another player!\n");
  1017. X                notify(Playernum, buf);
  1018. X            transfercrew = 0;
  1019. X                 } else { 
  1020. X            transfercrew = 1;
  1021. X                 if (!sect->popn && amt<0) {
  1022. X                p->info[Playernum-1].numsectsowned++;
  1023. X                sect->owner = Playernum;
  1024. X                sprintf(buf,"sector %.0f,%.0f COLONIZED.\n",s->xpos,s->ypos);
  1025. X                notify(Playernum, buf);
  1026. X                 }
  1027. X                 sect->popn -= amt;
  1028. X                 p->popn -= amt;
  1029. X                 if (sect->popn==0) {
  1030. X                p->info[Playernum-1].numsectsowned--;
  1031. X                sect->owner = 0;
  1032. X                sprintf(buf,"sector %.0f,%.0f evacuated.\n",s->xpos,s->ypos);
  1033. X                notify(Playernum, buf);
  1034. X                  }
  1035. X               }
  1036. X          }
  1037. X      if(transfercrew) {
  1038. X          sprintf(buf,"crew complement of ship #%d is now %u.\n", 
  1039. X            shipno, s->popn+amt);
  1040. X                notify(Playernum, buf);
  1041. X          s->popn += amt;
  1042. X          s->mass += amt*Race->mass;
  1043. X          Mod = 1;
  1044. X        }
  1045. X      break;
  1046. X
  1047. X    case 'd': s->destruct += amt;
  1048. X          s->mass += amt*MASS_DESTRUCT;
  1049. X        sprintf(buf, "%d destruct transferred.\n", amt);
  1050. X        notify(Playernum, buf);
  1051. X          if (!Max_crew(s)) {
  1052. X            sprintf(buf,"\n%s #%d ",Shipnames[s->type], shipno);
  1053. X                notify(Playernum, buf);
  1054. X            if (s->destruct) {
  1055. X                 sprintf(buf,"now boobytrapped.\n");
  1056. X            } else {
  1057. X                 sprintf(buf,"no longer boobytrapped.\n");
  1058. X             }
  1059. X                notify(Playernum, buf);
  1060. X            }
  1061. X
  1062. X          if (sh) {
  1063. X            s2->destruct -= amt;
  1064. X            s2->mass -= amt*MASS_DESTRUCT;
  1065. X          } else if (!jett)
  1066. X              p->info[Playernum-1].destruct -= amt;
  1067. X
  1068. X          Mod = 1;
  1069. X          break;
  1070. X
  1071. X    case 'f': s->fuel += amt*1.0;
  1072. X          s->mass += amt*MASS_FUEL;
  1073. X        sprintf(buf, "%d fuel transferred.\n", amt);
  1074. X        notify(Playernum, buf);
  1075. X
  1076. X          if (sh) {
  1077. X            s2->fuel -= amt*1.0;
  1078. X            s2->mass -= amt*MASS_FUEL;
  1079. X          } else if (!jett)
  1080. X              p->info[Playernum-1].fuel -= amt*1.0;
  1081. X
  1082. X          Mod = 1;
  1083. X          break;
  1084. X
  1085. X    case 'r': s->resource += amt;
  1086. X          s->mass += amt*MASS_RESOURCE;
  1087. X        sprintf(buf, "%d resources transferred.\n", amt);
  1088. X        notify(Playernum, buf);
  1089. X
  1090. X          if (sh) {
  1091. X            s2->resource -= amt;
  1092. X            s2->mass -= amt*MASS_RESOURCE;
  1093. X          } else if (!jett)
  1094. X              p->info[Playernum-1].resource -= amt;
  1095. X
  1096. X          Mod = 1;
  1097. X          break;
  1098. X
  1099. X    default:
  1100. X       notify(Playernum, "No such commodity.\n");
  1101. X       return;
  1102. X    break;
  1103. X    }
  1104. X    openshdata(&load_shdata);
  1105. X    putship(load_shdata,s,shipno);
  1106. X    close_file(load_shdata);
  1107. X        if (s->type==OTYPE_TRANSDEV && s->object.number > 0) {
  1108. X
  1109. X       sprintf(buf,"Zap\07!\n");         /* ^G */
  1110. X                notify(Playernum, buf);
  1111. X
  1112. X           /* send stuff to other ship (could be transport device) */
  1113. X       if (s->resource ) {
  1114. X        s2->mass += s->resource * MASS_RESOURCE;
  1115. X        s2->resource += s->resource;
  1116. X
  1117. X        sprintf(buf,"%d resources transferred.\n", s->resource);
  1118. X                notify(Playernum, buf);
  1119. X        sprintf(bufr, "%d Resources\n",s->resource);
  1120. X
  1121. X        s->mass -= s->resource * MASS_RESOURCE;
  1122. X        s->resource  -= s->resource;
  1123. X       } else
  1124. X        bufr[0] = '\0';
  1125. X       if (s->fuel) {
  1126. X        s2->fuel += s->fuel;
  1127. X        s2->mass += s->fuel * MASS_FUEL;
  1128. X
  1129. X        sprintf(buf,"%g fuel transferred.\n", s->fuel);
  1130. X                notify(Playernum, buf);
  1131. X        sprintf(buff, "%g Fuel\n",s->fuel);
  1132. X
  1133. X        s->mass -= s->fuel * MASS_FUEL;
  1134. X        s->fuel -= s->fuel;
  1135. X       } else
  1136. X        buff[0] = '\0';
  1137. X       if (s->destruct) {
  1138. X        s2->mass += s->destruct * MASS_DESTRUCT;
  1139. X        s2->destruct += s->destruct;
  1140. X
  1141. X        sprintf(buf,"%d destruct transferred.\n", s->destruct);
  1142. X                notify(Playernum, buf);
  1143. X        sprintf(bufd, "%d Destruct\n",s->destruct);
  1144. X
  1145. X        s->mass -= s->destruct * MASS_DESTRUCT;
  1146. X        s->destruct -= s->destruct;
  1147. X       } else
  1148. X        bufd[0] = '\0';
  1149. X       if (s->popn) {
  1150. X        s2->mass += s->popn * Race->mass;
  1151. X        s2->popn += s->popn;
  1152. X
  1153. X        sprintf(buf,"%d popn transferred.\n", s->popn);
  1154. X                notify(Playernum, buf);
  1155. X        sprintf(bufc, "%d %s\n",s->destruct,Race->Thing?"tons of biomass" : "population");
  1156. X
  1157. X        s->mass -= s->popn * Race->mass;
  1158. X        s->popn -= s->popn;
  1159. X       } else
  1160. X        bufc[0] = '\0';
  1161. X
  1162. X         if (s2->owner!=s->owner) {
  1163. X       sprintf(telegram_buf,"BULLETIN!\n\n Audio-vibatory-physio-molecular transport device #");
  1164. X       sprintf(buf,"%d just gave your ship #%d the following:\n", shipno, s->object.number);
  1165. X        str_cat(telegram_buf, buf);
  1166. X        str_cat(telegram_buf, bufr);
  1167. X        str_cat(telegram_buf, bufd);
  1168. X        str_cat(telegram_buf, buff);
  1169. X        str_cat(telegram_buf, bufc);
  1170. X        notify(s2->owner, telegram_buf);
  1171. X         }
  1172. X
  1173. X       openshdata(&load_shdata);
  1174. X       putship(load_shdata,s,shipno);
  1175. X       putship(load_shdata, s2, s->object.number);
  1176. X       close_file(load_shdata);
  1177. X
  1178. X    } else if (sh) {
  1179. X        /* ship to ship transfer, non-transport device */
  1180. X
  1181. X    openshdata(&load_shdata);
  1182. X    putship(load_shdata,s2,s->destshipno);
  1183. X    close_file(load_shdata);
  1184. X
  1185. X    buff[0] = bufr[0] = bufd[0] = bufc[0] = '\0';
  1186. X    switch (commod) {
  1187. X        case 'r':
  1188. X            sprintf(buf,"%d resources transferred.\n", amt);
  1189. X                notify(Playernum, buf);
  1190. X            sprintf(bufr, "%d Resources\n",amt);
  1191. X            break;
  1192. X        case 'f':
  1193. X            sprintf(buf,"%d fuel transferred.\n", amt);
  1194. X                notify(Playernum, buf);
  1195. X            sprintf(buff, "%d Fuel\n",amt);
  1196. X            break;
  1197. X        case 'd':
  1198. X            sprintf(buf,"%d destruct transferred.\n", amt);
  1199. X                notify(Playernum, buf);
  1200. X            sprintf(bufd, "%d Destruct\n",amt);
  1201. X            break;
  1202. X        case 'c':
  1203. X            sprintf(buf,"%d popn transferred.\n", amt);
  1204. X                notify(Playernum, buf);
  1205. X            sprintf(bufc, "%d %s\n",amt,Race->Thing?"tons of biomass" : "population");
  1206. X            break;
  1207. X        default:
  1208. X            break;
  1209. X     }
  1210. X
  1211. X
  1212. X         if (s2->owner!=s->owner) {
  1213. X       sprintf(telegram_buf, "BULLETIN!\n\n Audio-vibatory-physio-molecular transport device #");
  1214. X       sprintf(buf,"%d just gave your ship #%d the following:\n", shipno, s->object.number);
  1215. X        str_cat(telegram_buf, buf);
  1216. X        str_cat(telegram_buf, bufr);
  1217. X        str_cat(telegram_buf, bufd);
  1218. X        str_cat(telegram_buf, buff);
  1219. X        str_cat(telegram_buf, bufc);
  1220. X        notify(s2->owner, telegram_buf);
  1221. X         }
  1222. X     }
  1223. X
  1224. X    if (!jett && !sh) {
  1225. X      if (commod=='c') {
  1226. X      opensectdata(&load_sectdata);
  1227. X      putsector(load_sectdata,sect,p->sectormappos + ( (int)s->ypos*p->Maxx+(int)s->xpos) * sizeof(sectortype) );
  1228. X        close_file(load_sectdata);
  1229. X    free(sect);
  1230. X    }
  1231. X      
  1232. X      openpdata(&load_pdata);
  1233. X       putplanet(load_pdata,p,Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
  1234. X       close_file(load_pdata);
  1235. X       free(p);
  1236. X     }
  1237. X
  1238. X    if (Mod && first) {
  1239. X         first = 0;
  1240. X         if (s->whatorbits==LEVEL_UNIV)
  1241. X        deductAPs(Playernum,APcount, 0, 1);    /* ded from sdata */
  1242. X         else 
  1243. X        deductAPs(Playernum,APcount, s->storbits, 0);
  1244. X
  1245. X    }
  1246. X
  1247. X}
  1248. X
  1249. X
  1250. Xtransfer(Playernum,APcount, argn,args)
  1251. Xint Playernum;
  1252. Xint APcount;
  1253. Xint argn;
  1254. Xchar args[MAXARGS][COMMANDSIZE];
  1255. X{
  1256. Xint Mod = 0, transfer_fd, player, give;
  1257. Xplanettype *planet;
  1258. Xchar commod=0;
  1259. Xracetype *r;
  1260. X
  1261. X        if (Dir[Playernum-1].level != LEVEL_PLAN) {
  1262. X      sprintf(buf,"You need to be in planet scope to do this.\n");
  1263. X      notify(Playernum, buf);
  1264. X      return;
  1265. X          }
  1266. X
  1267. X
  1268. X    if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount))
  1269. X            return;
  1270. X
  1271. X    GetPlayer(args[1], &player, &r);
  1272. X
  1273. Xif(player < 0 || player > Numraces() ) {
  1274. X  sprintf(buf,"No such player.\n");
  1275. X        notify(Playernum, buf);
  1276. X  return;
  1277. X    }
  1278. X
  1279. X    openpdata(&transfer_fd);
  1280. X    getplanet(transfer_fd, &planet, Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
  1281. X    close_file(transfer_fd);
  1282. X
  1283. X    sscanf(args[2],"%c",&commod);
  1284. X        give = atoi(args[3]);
  1285. X
  1286. Xif(give < 0) {
  1287. X    notify(Playernum, "You must specify a positive amount.\n");
  1288. X    return;
  1289. X    }
  1290. X
  1291. Xswitch(commod) {
  1292. X    case 'r' :
  1293. X       if(give > planet->info[Playernum-1].resource)
  1294. X    {
  1295. X      sprintf(buf,"You don't have %d on this planet.\n",give);
  1296. X        notify(Playernum, buf);
  1297. X    } else {
  1298. X      planet->info[Playernum-1].resource -= give;
  1299. X      planet->info[player-1].resource += give;
  1300. X      sprintf(buf,"%d resources transferred to player #%d\n",give,player);
  1301. X        notify(Playernum, buf);
  1302. X    }
  1303. X      break;
  1304. X    case 'f' :
  1305. X      if(give > planet->info[Playernum-1].fuel)
  1306. X    {
  1307. X      sprintf(buf,"You don't have %d fuel on this planet.\n",give);
  1308. X        notify(Playernum, buf);
  1309. X    } else {
  1310. X      planet->info[Playernum-1].fuel -= give;
  1311. X      planet->info[player-1].fuel += give;
  1312. X      sprintf(buf,"%d fuel transferred to player #%d\n",give,player);
  1313. X        notify(Playernum, buf);
  1314. X    }
  1315. X      break;
  1316. X    case 'd' :
  1317. X      if(give > planet->info[Playernum-1].destruct)
  1318. X    {
  1319. X      sprintf(buf,"You don't have %d destruct on this planet.\n",give);
  1320. X      notify(Playernum, buf);
  1321. X      } else {
  1322. X      planet->info[Playernum-1].destruct -= give;
  1323. X      planet->info[player-1].destruct += give;
  1324. X      sprintf(buf,"%d destruct transferred to player #%d\n",give,player);
  1325. X        notify(Playernum, buf);
  1326. X    }
  1327. X      break;
  1328. X    default :
  1329. X      sprintf(buf,"What?\n");
  1330. X        notify(Playernum, buf);
  1331. X    }
  1332. Xopenpdata(&transfer_fd);
  1333. X    putplanet(transfer_fd, planet, Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
  1334. X    close_file(transfer_fd);
  1335. XMod = 1;
  1336. X    if (Mod)
  1337. X        deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
  1338. X
  1339. X}
  1340. X
  1341. END_OF_FILE
  1342. if test 15077 -ne `wc -c <'server/load.c'`; then
  1343.     echo shar: \"'server/load.c'\" unpacked with wrong size!
  1344. fi
  1345. # end of 'server/load.c'
  1346. fi
  1347. if test -f 'server/name.c' -a "${1}" != "-c" ; then 
  1348.   echo shar: Will not clobber existing file \"'server/name.c'\"
  1349. else
  1350. echo shar: Extracting \"'server/name.c'\" \(14775 characters\)
  1351. sed "s/^X//" >'server/name.c' <<'END_OF_FILE'
  1352. X/*
  1353. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  1354. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  1355. X * Restrictions in GB_copyright.h.
  1356. X *
  1357. X * name.c -- rename something to something else
  1358. X* announce.c -- make announcements in the system you currently in.
  1359. X*            You must be inhabiting that system for your message to sent.
  1360. X*            You must also be in that system (and inhabiting) to receive announcements.
  1361. X* page.c -- send a message to a player requesting his presence in a system. 
  1362. X*/
  1363. X
  1364. X#include "GB_copyright.h"
  1365. X#define EXTERN extern
  1366. X#include "vars.h"
  1367. X#include "races.h"
  1368. X#include "ships.h"
  1369. X#include "buffers.h"
  1370. X#include <ctype.h>
  1371. X#include <signal.h>
  1372. X#include <strings.h>
  1373. X#include <time.h>
  1374. Xint name_shdata,name_stardata, name_racedata, name_pdata;
  1375. X
  1376. Xchar msg[1024];
  1377. Xstruct tm *current_tm;/* for watching for next update */
  1378. Xlong clk;
  1379. X
  1380. Xgive(Playernum, APcount, argn, args)
  1381. Xint Playernum;
  1382. Xint APcount;
  1383. Xint argn;
  1384. Xchar args[MAXARGS][COMMANDSIZE];
  1385. X{
  1386. Xint who, sh;
  1387. Xshiptype *ship;
  1388. Xplanettype *planet;
  1389. Xracetype *alien;
  1390. X
  1391. Xfree(Race);
  1392. Xopenracedata(&name_racedata);
  1393. Xgetrace(name_racedata, &Race, Playernum);
  1394. Xclose_file(name_racedata);
  1395. X
  1396. XGetPlayer(args[1], &who, &alien);
  1397. X   if (who <= 0) {
  1398. X    sprintf(buf,"No such player.\n");
  1399. X        notify(Playernum, buf);
  1400. X    return;
  1401. X   }
  1402. X
  1403. X      /* check to see if both players are mutually allied */
  1404. Xif(!(isset(Race->allied, who) && isset(alien->allied, Playernum))) {
  1405. X      notify(Playernum, "You two are not mutually allied.\n");
  1406. X      return;
  1407. X}
  1408. Xsscanf(args[2]+(args[2][0]=='#'), "%d", &sh);
  1409. X
  1410. X        openshdata(&name_shdata);
  1411. X        if(!getship(name_shdata, &ship, sh)) {
  1412. X            notify(Playernum, "Illegal ship number.\n");
  1413. X            close_file(name_shdata);
  1414. X            return;
  1415. X        }
  1416. X                if(ship->owner != Playernum || !ship->is_alive) {
  1417. X            DontOwnErr(Playernum, sh);
  1418. X            free(ship);
  1419. X            close_file(name_shdata);
  1420. X            return;
  1421. X        }
  1422. Xif(ship->type == STYPE_POD) {
  1423. X    notify(Playernum, "You cannot change the ownership of spore pods.\n");
  1424. X                free(ship);
  1425. X            close_file(name_shdata);
  1426. X            return;
  1427. X}
  1428. X
  1429. Xif(ship->popn && !Race->God) {
  1430. X    notify(Playernum, "You can't give this ship away while it has crew on board.\n");
  1431. X    free(ship);
  1432. X    close_file(name_shdata);
  1433. X    return;
  1434. X    }
  1435. X
  1436. Xswitch(ship->whatorbits) { 
  1437. X    case LEVEL_UNIV:
  1438. X        if(!enufAP(Playernum, Sdata.AP[Playernum-1], APcount))
  1439. X            return;
  1440. X        break;
  1441. X    default:
  1442. X        if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount))
  1443. X            return;
  1444. X        break;
  1445. X    }
  1446. X
  1447. Xship->owner = who;
  1448. Xputship(name_shdata, ship, sh);
  1449. Xclose_file(name_shdata);
  1450. X
  1451. X/* set inhabited/explored bits */
  1452. Xswitch(ship->whatorbits) {
  1453. X  case LEVEL_UNIV:
  1454. X    break;
  1455. X  case LEVEL_STAR:
  1456. X    free(Stars[ship->storbits]);
  1457. X    openstardata(&name_stardata);
  1458. X    getstar(name_stardata, &(Stars[ship->storbits]), ship->storbits);
  1459. X    setbit(Stars[ship->storbits]->inhabited, who);
  1460. X    setbit(Stars[ship->storbits]->explored, who);
  1461. X    putstar(name_stardata, Stars[ship->storbits], ship->storbits);
  1462. X    close_file(name_stardata);
  1463. X    break;
  1464. X  case LEVEL_PLAN:
  1465. X    free(Stars[ship->storbits]);
  1466. X    openstardata(&name_stardata);
  1467. X    getstar(name_stardata, &(Stars[ship->storbits]), ship->storbits);
  1468. X    setbit(Stars[ship->storbits]->inhabited, who);
  1469. X    setbit(Stars[ship->storbits]->explored, who);
  1470. X    putstar(name_stardata, Stars[ship->storbits], ship->storbits);
  1471. X    close_file(name_stardata);
  1472. X    openpdata(&name_pdata);
  1473. X    getplanet(name_pdata, &planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
  1474. X    planet->info[who-1].explored = 1;
  1475. X    putplanet(name_pdata, planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
  1476. X    close_file(name_pdata);
  1477. X    break;
  1478. X  default:
  1479. X    notify(Playernum, "Something wrong with this ship's scope.\n");
  1480. X    free(ship);
  1481. X    return;
  1482. X    break;
  1483. X}
  1484. X
  1485. Xswitch(ship->whatorbits) { 
  1486. X    case LEVEL_UNIV:
  1487. X        deductAPs(Playernum, APcount, 0, 1);
  1488. X            return;
  1489. X        break;
  1490. X    default:
  1491. X        deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
  1492. X        break;
  1493. X    }
  1494. X
  1495. X
  1496. Xnotify(Playernum, "Owner changed.\n");
  1497. Xsprintf(buf, "%s [%d] gave you %s #%d at %s.\n", Race->name, Playernum,
  1498. X    Shipnames[ship->type], sh, prin_ship_orbits(ship));
  1499. Xnotify(who, buf);
  1500. Xpush_message(TELEG_PLAYER_AUTO, who, buf);
  1501. X
  1502. X                    free(ship);
  1503. X}
  1504. X
  1505. X
  1506. Xpage(Playernum, APcount0, argn, args)
  1507. Xint Playernum;
  1508. Xint APcount0;
  1509. Xint argn;
  1510. Xchar args[MAXARGS][COMMANDSIZE];
  1511. X{
  1512. Xint i, who, to_block, dummy, APcount;
  1513. Xracetype *alien;
  1514. X
  1515. XAPcount = APcount0;
  1516. Xto_block = 0;
  1517. Xif(!strcmp(args[1], "block", strlen(args[1]))) {
  1518. X    to_block = 1;
  1519. X    notify(Playernum, "Paging alliance block.\n");
  1520. X} else {
  1521. X   GetPlayer(args[1], &who, &alien);
  1522. X   if (who <= 0) {
  1523. X    sprintf(buf,"No such player.\n");
  1524. X        notify(Playernum, buf);
  1525. X    return;
  1526. X   }
  1527. XAPcount *= !alien->God;
  1528. X}
  1529. X
  1530. Xfree(Race);
  1531. Xopenracedata(&name_racedata);
  1532. Xgetrace(name_racedata, &Race, Playernum); 
  1533. Xclose_file(name_racedata);
  1534. X
  1535. X    switch(Dir[Playernum-1].level) {
  1536. X        case LEVEL_UNIV:
  1537. X            sprintf(buf, "You can't make pages at universal scope.\n");
  1538. X            notify(Playernum, buf);
  1539. X            break;
  1540. X        default:
  1541. X            free(Stars[Dir[Playernum-1].snum]);
  1542. X            openstardata(&name_stardata);
  1543. X        getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
  1544. X            close_file(name_stardata);
  1545. X            if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
  1546. X            return;
  1547. X        }
  1548. X
  1549. X        sprintf(buf, "%s page(s) you from the %s star system.\n",
  1550. X            Race->name, Stars[Dir[Playernum-1].snum]->name);
  1551. X        if(to_block) {
  1552. X          dummy = (Blocks[Playernum-1].invite &
  1553. X                  Blocks[Playernum-1].pledge);
  1554. X          for(i=1; i<=Numraces(); i++)
  1555. X              if(isset(dummy, i) && i!=Playernum)
  1556. X              notify(i, buf);
  1557. X          } else
  1558. X            notify(who, buf);
  1559. X
  1560. X            notify(Playernum, "Request sent.\n");
  1561. X            break;
  1562. X        }
  1563. X    deductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
  1564. X}
  1565. X
  1566. Xsend_message(Playernum, APcount0, argn, args)
  1567. Xint Playernum;
  1568. Xint APcount0;
  1569. Xint argn;
  1570. Xchar args[MAXARGS][COMMANDSIZE];
  1571. X{
  1572. Xint who, i, j, to_block, dummy, APcount;
  1573. Xracetype *alien;
  1574. X
  1575. X    APcount = APcount0;
  1576. X
  1577. Xto_block = 0;
  1578. Xif(!strcmp(args[1], "block", strlen(args[1]))) {
  1579. X    to_block = 1;
  1580. X    notify(Playernum, "Sending message to alliance block.\n");
  1581. X} else {
  1582. XGetPlayer(args[1], &who, &alien);
  1583. X   if (who <= 0) {
  1584. X    sprintf(buf,"No such player.\n");
  1585. X        notify(Playernum, buf);
  1586. X    return;
  1587. X   }
  1588. XAPcount *= !alien->God;
  1589. X}
  1590. X
  1591. Xfree(Race);
  1592. Xopenracedata(&name_racedata);
  1593. Xgetrace(name_racedata, &Race, Playernum); 
  1594. Xclose_file(name_racedata);
  1595. X
  1596. X    switch(Dir[Playernum-1].level) {
  1597. X        case LEVEL_UNIV:
  1598. X            sprintf(buf, "You can't send messages from universal scope.\n");
  1599. X            notify(Playernum, buf);
  1600. X            break;
  1601. X        default:
  1602. X            free(Stars[Dir[Playernum-1].snum]);
  1603. X            openstardata(&name_stardata);
  1604. X        getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
  1605. X            close_file(name_stardata);
  1606. X            if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
  1607. X            return;
  1608. X        }
  1609. X
  1610. X/* send the message */
  1611. X    sprintf(msg, "From %s [%d]: ", Race->name, Playernum);
  1612. X           
  1613. X/* put the message together */
  1614. X        for(j=2; j < argn; j++)    
  1615. X            {
  1616. X            sprintf(buf, "%s ", args[j]);
  1617. X            strcat(msg, buf);            
  1618. X            }
  1619. X/* post it */
  1620. X        sprintf(buf, "%s has sent you a telegram. Use `read' to read it.\n", Race->name);
  1621. X        if(to_block) {
  1622. X          dummy = (Blocks[Playernum-1].invite &
  1623. X                  Blocks[Playernum-1].pledge);
  1624. X          Num_races = Numraces();
  1625. X          for(i=1; i<=Num_races; i++)
  1626. X              if(isset(dummy, i) && i!=Playernum) {
  1627. X                  push_message(Playernum, i, msg); 
  1628. X              notify(i, buf);
  1629. X              }
  1630. X              } else {
  1631. X          push_message(Playernum, who, msg); 
  1632. X          notify(who, buf);
  1633. X          }
  1634. X
  1635. X            notify(Playernum, "Message sent.\n");
  1636. X
  1637. X     if(!to_block) {
  1638. X/* translation modifier increases */
  1639. X    alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+2, 100);
  1640. X    openracedata(&name_racedata);
  1641. X    putrace(name_racedata, alien);    
  1642. X    close_file(name_racedata);
  1643. X               }
  1644. X            break;
  1645. X            }
  1646. X
  1647. XdeductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
  1648. X}
  1649. X
  1650. Xread_messages(Playernum, APcount, argn, args)
  1651. Xint Playernum;
  1652. Xint APcount;
  1653. Xint argn;
  1654. Xchar args[MAXARGS][COMMANDSIZE];
  1655. X{
  1656. Xint i;
  1657. Xteleg_read(Playernum);
  1658. X}
  1659. X
  1660. X
  1661. Xannounce(Playernum, APcount, argn, args, broadcast)
  1662. Xint Playernum;
  1663. Xint APcount;
  1664. Xint argn;
  1665. Xchar args[MAXARGS][COMMANDSIZE];
  1666. Xint broadcast;
  1667. X{
  1668. Xint i, j;
  1669. X
  1670. Xfree(Race);
  1671. Xopenracedata(&name_racedata);
  1672. Xgetrace(name_racedata, &Race, Playernum); 
  1673. Xclose_file(name_racedata);
  1674. X
  1675. Xswitch(Dir[Playernum-1].level) {
  1676. X    case LEVEL_UNIV:
  1677. X        sprintf(buf, "You can't make announcements at universal scope.\n");
  1678. X            notify(Playernum, buf);
  1679. X        break;
  1680. X    default:
  1681. X        free(Stars[Dir[Playernum-1].snum]);
  1682. X        openstardata(&name_stardata);
  1683. X        getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
  1684. X        close_file(name_stardata);
  1685. X        if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
  1686. X            return;
  1687. X        }
  1688. X    if(!(!!isset(Stars[Dir[Playernum-1].snum]->inhabited, Playernum) || Race->God)) {
  1689. X            sprintf(buf, "You do not inhabit this system or have diety privileges.\n");
  1690. X            notify(Playernum, buf);
  1691. X            return;
  1692. X        }
  1693. X
  1694. Xif(!broadcast)
  1695. X    sprintf(msg, "%s : ", Race->name);
  1696. Xelse
  1697. X    sprintf(msg, "Interstellar broadcast from %s :", Race->name);
  1698. X
  1699. X    Num_races = Numraces();
  1700. X
  1701. X        for(j=1; j < argn; j++)    
  1702. X            {
  1703. X            sprintf(buf, "%s ", args[j]);
  1704. X            strcat(msg, buf);            
  1705. X            }
  1706. X            strcat(msg, "\n");
  1707. X
  1708. X    for(i=1; i<=Num_races; i++) 
  1709. X        if(i != Playernum) {
  1710. X        free(Race);
  1711. X    openracedata(&name_racedata);
  1712. X        getrace(name_racedata, &Race, i); 
  1713. X    close_file(name_racedata);
  1714. X
  1715. X    if(broadcast || (Dir[i-1].level != LEVEL_UNIV && (Dir[i-1].snum == Dir[Playernum-1].snum) 
  1716. X            &&  (!!isset(Stars[Dir[Playernum-1].snum]->inhabited, i) || Race->God)))
  1717. X            notify(i, msg);
  1718. X    }
  1719. X
  1720. X        break;
  1721. X    }
  1722. X
  1723. X    deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
  1724. X}
  1725. X
  1726. Xname(Playernum,APcount, argn,args)
  1727. Xint Playernum;
  1728. Xint APcount;
  1729. Xint argn;
  1730. Xchar args[MAXARGS][COMMANDSIZE];
  1731. X{
  1732. Xchar *ch;
  1733. Xregister int i, s, spaces;
  1734. Xboolean check=0;
  1735. Xshiptype *ship;
  1736. Xstartype *star;
  1737. Xplanettype *p;
  1738. Xchar string[1024];
  1739. Xchar temp[128];
  1740. X
  1741. Xname_stardata = NEUTRAL_FD;
  1742. X
  1743. Xfree(Race);
  1744. Xopenracedata(&name_racedata);
  1745. Xgetrace(name_racedata, &Race, Playernum);
  1746. Xclose_file(name_racedata);
  1747. X
  1748. Xif(!isalnum(args[2][0]) || argn < 3) {
  1749. X        notify(Playernum, "Illegal name format.\n");
  1750. X        return;
  1751. X        }
  1752. X
  1753. Xsprintf(buf, "%s", args[2]);
  1754. X        for(i=3; i < argn; i++)    
  1755. X            {
  1756. X            sprintf(temp, " %s", args[i]);
  1757. X            strcat(buf, temp);            
  1758. X            }
  1759. X
  1760. Xsprintf(string, "%s", buf);
  1761. X
  1762. X    i=strlen(args[0]);
  1763. X
  1764. X      /* make sure there are no ^'s or '/' in name, 
  1765. X        also make sure the name has at least 1 character in it */
  1766. X  ch = string;
  1767. X  spaces = 0;
  1768. X  while (*ch!='\0') {
  1769. X      check |= ((!isalnum(*ch) && !(*ch==' ')) || (*ch=='/') );
  1770. X      ch++;
  1771. X      if(*ch==' ') spaces++;
  1772. X    }
  1773. X
  1774. X    if(spaces==strlen(buf)) {                /* keep a player */
  1775. X        notify(Playernum, "Illegal name.\n");
  1776. X        return;
  1777. X        }
  1778. X
  1779. X  if (strlen(buf) < 1 || check) {
  1780. X    sprintf(buf, "Illegal name %s.\n", check ? "form" : "length" );
  1781. X        notify(Playernum, buf);
  1782. X    return;
  1783. X  }
  1784. X
  1785. X        if (!strncmp(args[1],"ship",i)) {
  1786. X        if(Dir[Playernum-1].level == LEVEL_SHIP) {
  1787. X        openshdata(&name_shdata);
  1788. X        getship(name_shdata, &ship, Dir[Playernum-1].shipno);
  1789. X
  1790. X        sprintf(ship->name, "%s", buf);
  1791. X        putship(name_shdata, ship, Dir[Playernum-1].shipno);
  1792. X        close_file(name_shdata);
  1793. X            notify(Playernum, "Name set.\n");
  1794. X            free(ship);
  1795. X            return;
  1796. X        } else {
  1797. X            notify(Playernum, "You have to 'cs' to a ship to name it.\n");
  1798. X            return;
  1799. X        }
  1800. X        } else if (!strncmp(args[1],"class",i)) {
  1801. X        if(Dir[Playernum-1].level == LEVEL_SHIP) {
  1802. X        openshdata(&name_shdata);
  1803. X        getship(name_shdata, &ship, Dir[Playernum-1].shipno);
  1804. X    if(ship->type != OTYPE_FACTORY) {
  1805. X        notify(Playernum, "You are not at a factory!\n");
  1806. X        free(ship);
  1807. X        close_file(name_shdata);
  1808. X        return;
  1809. X        }
  1810. X    if(ship->on) {
  1811. X        notify(Playernum, "This factory is already on line.\n");
  1812. X        free(ship);
  1813. X        close_file(name_shdata);
  1814. X        return;
  1815. X        }
  1816. X
  1817. X        sprintf(ship->class, "%s", buf);
  1818. X        putship(name_shdata, ship, Dir[Playernum-1].shipno);
  1819. X        close_file(name_shdata);
  1820. X            notify(Playernum, "Class set.\n");
  1821. X            free(ship);
  1822. X            return;
  1823. X        } else {
  1824. X            notify(Playernum, "You have to 'cs' to a factory to name the ship class.\n");
  1825. X            return;
  1826. X        }
  1827. X        } else if (!strncmp(args[1], "block", i)) {
  1828. X/* name your alliance block */
  1829. X    sprintf(Blocks[Playernum-1].name, "%s", args[2]);
  1830. X    Putblock(Blocks);
  1831. X    notify(Playernum, "Done.\n");
  1832. X    }else if (!strncmp(args[1],"star",i)) {
  1833. X
  1834. X        if(Dir[Playernum-1].level == LEVEL_STAR) {
  1835. X
  1836. X        if (!Race->God) {
  1837. X            notify(Playernum, "Only dieties may name a star.\n");
  1838. X            return;
  1839. X        }
  1840. X
  1841. X/* got to get all stars, to stop cheaters */
  1842. X            openstardata(&name_stardata);
  1843. X            for (s=0; s<Sdata.numstars; s++) {
  1844. X                free(Stars[s]);
  1845. X                getstar(name_stardata, &Stars[s], s);
  1846. X                }
  1847. X            close_file(name_stardata);
  1848. X
  1849. X            for(s=0; s<Sdata.numstars; s++) {
  1850. X                if(s!=Dir[Playernum-1].snum)
  1851. X                    if(!strcmp(Stars[s]->name, buf, strlen(Stars[s]->name)))
  1852. X                        {
  1853. X            notify(Playernum, 
  1854. X                "Thats not fair trying to name a star that! 50 APs deducted for cheating!!!\n");
  1855. X                        return;
  1856. X                        }
  1857. X                }
  1858. X
  1859. X
  1860. X/* check to see if there are any other stars with this name - stops cheaters */
  1861. X    
  1862. X
  1863. Xsprintf(Stars[Dir[Playernum-1].snum]->name, "%s", buf);
  1864. X            openstardata(&name_stardata);
  1865. X            putstar(name_stardata, Stars[Dir[Playernum-1].snum], 
  1866. X            Dir[Playernum-1].snum);
  1867. X        close_file(name_stardata);
  1868. X        } else {
  1869. X            notify(Playernum, "You have to 'cs' to a star to name it.\n");
  1870. X            return;
  1871. X        }
  1872. X        } else if (!strncmp(args[1],"planet",i)) {
  1873. X        if(Dir[Playernum-1].level == LEVEL_PLAN) {
  1874. X            free(Stars[Dir[Playernum-1].snum]);
  1875. X            openstardata(&name_stardata);
  1876. X            getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
  1877. X            close_file(name_stardata);
  1878. X
  1879. X            if (!Race->God && !MostAPs(Playernum,Stars[Dir[Playernum-1].snum])) {
  1880. X      notify(Playernum,"You don't have the most AP's in that system.\n");
  1881. X        return;
  1882. X            }
  1883. X
  1884. Xfor(s=0; s<Stars[Dir[Playernum-1].snum]->numplanets; s++)
  1885. X            if(!strcmp(Stars[Dir[Playernum-1].snum]->pnames[s], buf, 
  1886. X                strlen(Stars[Dir[Playernum-1].snum]->pnames[s])))
  1887. X                {
  1888. X                notify(Playernum, 
  1889. X                    "Sorry, that name is already taken. 50 APs deducted for cheating!!!\n");
  1890. X                return;
  1891. X                }
  1892. X
  1893. X
  1894. Xsprintf(Stars[Dir[Playernum-1].snum]->pnames[Dir[Playernum-1].pnum], "%s", buf);
  1895. X            openstardata(&name_stardata);
  1896. X            putstar(name_stardata, Stars[Dir[Playernum-1].snum],  Dir[Playernum-1].snum);
  1897. X            close_file(name_stardata);
  1898. X        deductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
  1899. X
  1900. X        } else {
  1901. X            notify(Playernum, "You have to 'cs' to a planet to name it.\n");
  1902. X            return;
  1903. X        }
  1904. X        } else if (!strncmp(args[1],"race",i)) {
  1905. Xsprintf(Race->name, "%s", buf);
  1906. Xif(Playernum==1) Race->God = 1; /* for careless dieties*/
  1907. X    openracedata(&name_racedata);
  1908. X        putrace(name_racedata, Race);
  1909. X    close_file(name_racedata);
  1910. X
  1911. X    } else {
  1912. X        notify(Playernum, "I don't know what you mean.\n");
  1913. X        return;
  1914. X    }    
  1915. X
  1916. X}
  1917. X
  1918. X
  1919. Xint MostAPs(Playernum,s)
  1920. Xint Playernum;
  1921. Xstartype *s;
  1922. X{
  1923. X register int i,t = 0;
  1924. X
  1925. X  for (i=0; i<MAXPLAYERS; i++)
  1926. X     if (s->AP[i] >= t)
  1927. X      t = s->AP[i];
  1928. X
  1929. X  return (s->AP[Playernum-1] == t);
  1930. X
  1931. X}
  1932. X
  1933. X
  1934. END_OF_FILE
  1935. if test 14775 -ne `wc -c <'server/name.c'`; then
  1936.     echo shar: \"'server/name.c'\" unpacked with wrong size!
  1937. fi
  1938. # end of 'server/name.c'
  1939. fi
  1940. if test -f 'server/planet.list' -a "${1}" != "-c" ; then 
  1941.   echo shar: Will not clobber existing file \"'server/planet.list'\"
  1942. else
  1943. echo shar: Extracting \"'server/planet.list'\" \(2235 characters\)
  1944. sed "s/^X//" >'server/planet.list' <<'END_OF_FILE'
  1945. X
  1946. XArioch
  1947. XAmaterasu
  1948. XAzagthoth
  1949. XAnacreon
  1950. XAegea
  1951. XAnsu
  1952. XApaosha
  1953. XAnubis
  1954. XAziDahak
  1955. XArcturus
  1956. XBaezelbub
  1957. XBaal
  1958. XBeholder
  1959. XBadb
  1960. XBakongo
  1961. XBali
  1962. XBenkei
  1963. XBoreas
  1964. XBushido
  1965. XCharondar
  1966. XCthulhu-vec
  1967. XColchis
  1968. XCirrus
  1969. XCanan
  1970. XCastor
  1971. XChancay
  1972. XCh'eng-huang
  1973. XChi'ih-yu
  1974. XChuai
  1975. XConiraya
  1976. XCelephais
  1977. XDis
  1978. XDorcas
  1979. XDagan
  1980. XDannaura
  1981. XDawn
  1982. XDevadatta
  1983. XDharma
  1984. XDinka
  1985. XDjanggawul
  1986. XDorus
  1987. XDoula
  1988. XDruj
  1989. XDwarka
  1990. XDyaus
  1991. XEa
  1992. XEnkindu
  1993. XErishkegal
  1994. XErech
  1995. XEdjo
  1996. XEhecatl
  1997. XEkpe
  1998. XEnlil
  1999. XEphialtes
  2000. XEpigoni
  2001. XEshu
  2002. XEstanatleh
  2003. XEurytion
  2004. XFalcha
  2005. XFreedom
  2006. XFomori
  2007. XFebrus
  2008. XFeiLien
  2009. XFonLegba
  2010. XFortuna
  2011. XFourthWorld
  2012. XFreyja
  2013. XFreyr
  2014. XFu-hsi
  2015. XFujin
  2016. XGaia
  2017. XGrunbunde
  2018. XGandarewa
  2019. XGaokerena
  2020. XGathas
  2021. XGerd
  2022. XGeryon
  2023. XGilgamesh
  2024. XGinnungagap
  2025. XGlispa
  2026. XGranis
  2027. XGungnir
  2028. XHalloway
  2029. XHarry'sWorld
  2030. XHalvec
  2031. XHal
  2032. XHadad
  2033. XHaoma
  2034. XHaroeris
  2035. XHathor
  2036. XHebe
  2037. XHector
  2038. XHei-tiki
  2039. XHoder
  2040. XHorae
  2041. XHotei
  2042. XHyksos
  2043. XInnana
  2044. XIshtar
  2045. XIoue
  2046. XIacchos
  2047. XIllyria
  2048. XIrkalla
  2049. XIswar
  2050. XIulus
  2051. XIxbalanque
  2052. XIzahami
  2053. XJackal
  2054. XJove
  2055. XJade
  2056. XJamsid
  2057. XJanus
  2058. XJataka
  2059. XJocasta
  2060. XJurojin
  2061. XKeshvar
  2062. XKhwanirath
  2063. XKol
  2064. XKachinas
  2065. XKalki
  2066. XKamakura
  2067. XKadath
  2068. XKaraja
  2069. XKettoi
  2070. XKhepri
  2071. XKirin
  2072. XKishijoten
  2073. XK'unLun
  2074. XKunmanggur
  2075. XKuya-Shonin
  2076. XKythamil
  2077. XLeng
  2078. XLevithan
  2079. XLuntag
  2080. XLaindjung
  2081. XLaoTzu
  2082. XLapiths
  2083. XLares
  2084. XLeinster
  2085. XLodbrok
  2086. XLotan
  2087. XLungshan
  2088. XLuyia
  2089. XLycurgus
  2090. XLarnok
  2091. XMorrigan
  2092. XMacha
  2093. XMaenads
  2094. XMandara
  2095. XManitou
  2096. XMarduk
  2097. X(Mashyane
  2098. XMashye)
  2099. XMegara
  2100. XMenrua
  2101. XMetis
  2102. XMjollnir
  2103. XMulungu
  2104. XNyarlathotep
  2105. XNessus
  2106. XNewBeginnings
  2107. XNuada
  2108. XNebo
  2109. XNinhursag
  2110. XNinigi
  2111. XNuba
  2112. XNu-kua
  2113. XNyambe
  2114. XNyx
  2115. XObolus
  2116. XOkokanoffee
  2117. XOeneus
  2118. XOhrmazd
  2119. XOjin
  2120. XOkesa
  2121. XOkuninushi
  2122. XOlifat
  2123. XOrchomenus
  2124. XOro
  2125. XOrunila
  2126. XOtus
  2127. XPlanetX
  2128. XPlanet10
  2129. XPleides
  2130. XPachacutil
  2131. XPandavas
  2132. XP'an-ku
  2133. XParshya
  2134. XParvati
  2135. XPatala
  2136. XPek
  2137. XPelops
  2138. XPrithivi
  2139. XPtolemy
  2140. XQuagKeep
  2141. XQuirnok
  2142. XQaQwaai
  2143. XQuetzalcoatl
  2144. XQuimbaya
  2145. XQuipus
  2146. XQuirinus
  2147. XRagnar
  2148. XRuhe
  2149. XRadha
  2150. XRagnarok
  2151. XRashnu
  2152. XRata
  2153. XRegia
  2154. XRhpisort
  2155. XRudra
  2156. XRukmini
  2157. XRustam
  2158. XRyobu
  2159. XR'lyeh
  2160. XSecundus
  2161. XSolaria
  2162. XSakra
  2163. XSalacia
  2164. XSappedon
  2165. XSati
  2166. XSemele
  2167. XShantak
  2168. XSrishok
  2169. XShapash
  2170. XSiddhartha
  2171. XSuga
  2172. XSugriva
  2173. XSurya
  2174. XSwarga
  2175. XTekeli-li
  2176. XTerminus
  2177. XTrantor
  2178. XTigra-nog'th
  2179. XTadanobu
  2180. XT'aishan
  2181. XTammuz
  2182. XTare
  2183. XTantrus
  2184. XTarturus
  2185. XTethys
  2186. XThinis
  2187. XTiki
  2188. XTi'i
  2189. XTjinimin
  2190. XTrisala
  2191. XTrashtri
  2192. XTsathoggua
  2193. XUnok
  2194. XUrech
  2195. XUkaipu
  2196. XUpuaut
  2197. XUrth
  2198. XUrsharabi
  2199. XUxmal
  2200. XUtnapishtim
  2201. XVilee
  2202. XVirag
  2203. XVanir
  2204. XVasuki
  2205. XVedas
  2206. XVedies
  2207. XVega
  2208. XVigari
  2209. XVirgil
  2210. XVirginus
  2211. XVishtaspa
  2212. XVohuManuh
  2213. XVucu-Caquix
  2214. XWampum
  2215. XWaura
  2216. XWawalag
  2217. XWalla
  2218. XYarnek
  2219. XYog-sothoth
  2220. XYamotodake
  2221. XYami
  2222. XYangtse
  2223. XYggdrasil
  2224. XYima
  2225. XYmir
  2226. XYu
  2227. XYucatan
  2228. XYumCaax
  2229. XYu-ti
  2230. XYaddith
  2231. XYuggoth
  2232. XZahak
  2233. XZapana
  2234. XZapaotek
  2235. XZoroaster
  2236. XZethus
  2237. XZocho
  2238. XZurvan
  2239. END_OF_FILE
  2240. if test 2235 -ne `wc -c <'server/planet.list'`; then
  2241.     echo shar: \"'server/planet.list'\" unpacked with wrong size!
  2242. fi
  2243. # end of 'server/planet.list'
  2244. fi
  2245. echo shar: End of archive 4 \(of 14\).
  2246. cp /dev/null ark4isdone
  2247. MISSING=""
  2248. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  2249.     if test ! -f ark${I}isdone ; then
  2250.     MISSING="${MISSING} ${I}"
  2251.     fi
  2252. done
  2253. if test "${MISSING}" = "" ; then
  2254.     echo You have unpacked all 14 archives.
  2255.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2256. else
  2257.     echo You still need to unpack the following archives:
  2258.     echo "        " ${MISSING}
  2259. fi
  2260. ##  End of shell archive.
  2261. exit 0
  2262.