home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume14 / xbattle / part06 < prev    next >
Encoding:
Internet Message Format  |  1993-01-26  |  54.7 KB

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i077:  xbattle - multi-player battle strategy game for X-Windows, Part06/07
  5. Message-ID: <3516@master.CNA.TEK.COM>
  6. Date: 7 Sep 92 21:23:32 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2035
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: slehar@cns.bu.edu
  12. Posting-number: Volume 14, Issue 77
  13. Archive-name: xbattle/Part06
  14. Environment: Xlib
  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 6 (of 7)."
  25. # Contents:  parse.c tutorial2
  26. # Wrapped by billr@saab on Mon Sep  7 14:18:50 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'parse.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'parse.c'\"
  30. else
  31. echo shar: Extracting \"'parse.c'\" \(32059 characters\)
  32. sed "s/^X//" >'parse.c' <<'END_OF_FILE'
  33. X#include <stdio.h>
  34. X  
  35. X/**** x include files ****/
  36. X#include <X11/Xlib.h>
  37. X#include <X11/Xutil.h>
  38. X#include <X11/Xatom.h>
  39. X#include <X11/keysym.h>
  40. X#include <X11/keysymdef.h>
  41. X
  42. X#include "extern.h"
  43. X
  44. X/*************************************************************************/
  45. X/**    get_displaynames                        **/
  46. X/** extract the display names from the command line arguments        **/
  47. X/**    Steve Lehar (slehar@park.bu.edu)                **/
  48. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  49. X/*************************************************************************/
  50. Xget_displaynames(displayname,colorarray,rcolorarray,argc,argv)
  51. X  char displayname[MAXPLAYERS][80],
  52. X       *argv[];
  53. X  int argc,
  54. X      colorarray[MAXPLAYERS],
  55. X      rcolorarray[MAXHUES];
  56. X{
  57. X  int i, j, k,
  58. X      extra,
  59. X      index=0, count=0,
  60. X      primary, secondary,
  61. X      colon,
  62. X      sidetaken[MAXSIDES+1];
  63. X
  64. X  char *ptr;
  65. X
  66. X  char line[100];
  67. X
  68. X  nplayers = 0;
  69. X  for (j=1;j<=MAXSIDES; j++)
  70. X    sidetaken[j] = FALSE;
  71. X
  72. X  for (j=0;j<MAXHUES; j++)
  73. X    rcolorarray[j] = NOT_TAKEN;
  74. X
  75. X  /**** initialize message strings ****/
  76. X  sprintf (messagestr,"");
  77. X
  78. X  for (i=0; i<MAXPLAYERS; i++)
  79. X  {
  80. X    winopen[i] = TRUE;
  81. X    winwatch[i] = FALSE;
  82. X  }
  83. X
  84. X  /**** set other displays ****/
  85. X  for (i=1; i<argc; )
  86. X  {
  87. X    if (goodoption(argv[i]))
  88. X    {
  89. X      extra = installoption (argc, argv, i, GLOBAL);
  90. X      i += extra;
  91. X    }
  92. X    else
  93. X    {
  94. X      primary = -1;
  95. X      for (j=1;j<=MAXHUES && primary<0; j++)
  96. X      {
  97. X        /**** find primary (c1) color ****/
  98. X        if (matchstr(&(argv[i][1]), huename[j]))
  99. X        {
  100. X          primary = j;
  101. X          secondary = -1;
  102. X
  103. X          /**** find secondary (c2) color ****/
  104. X          if (strlen(argv[i]) <= strlen(huename[j])+1)
  105. X          {
  106. X            /**** no secondary color ****/
  107. X          }
  108. X          else
  109. X          {
  110. X            ptr = &(argv[i][1+strlen(huename[primary])]);
  111. X            for (k=1;k<=MAXHUES; k++)
  112. X            {
  113. X              if (matchstr(ptr,grayname[k]))
  114. X              {
  115. X                secondary = k;
  116. X              }
  117. X            }
  118. X          }
  119. X
  120. X          if (argv[i+1][0] == '{')
  121. X          {
  122. X            i+=2;
  123. X            while (argv[i][0] != '}')
  124. X            {
  125. X              if (goodoption(argv[i]))
  126. X              {
  127. X                if (rcolorarray[primary] != NOT_TAKEN)
  128. X                  extra = installoption (argc, argv, i, rcolorarray[primary]);
  129. X                else
  130. X                  extra = installoption (argc, argv, i, count);
  131. X                i += extra;
  132. X              }
  133. X              else
  134. X              {
  135. X                printf ("BAD OPTION IN BRACKETS\n");
  136. X                exit (0);
  137. X              }
  138. X            }
  139. X          }
  140. X
  141. X          if(strcmp(argv[i+1],"me") == 0)
  142. X            strcpy(displayname[index],"");
  143. X          else
  144. X          {
  145. X            /**** if no :x.y given in display name add :0.0 ****/
  146. X            colon = FALSE;
  147. X            for (k=0; k<strlen(argv[i+1]); k++)
  148. X              if (argv[i+1][k] == ':')
  149. X                colon = TRUE;
  150. X            strcpy (line, argv[i+1]);
  151. X            if (!colon)
  152. X              strcat (line, ":0.0");
  153. X  
  154. X            strcpy(displayname[index],line);
  155. X          }
  156. X  
  157. X          if (strcmp(argv[i+1],"you") == 0)
  158. X          {
  159. X            /**** dummy player ****/
  160. X          }
  161. X          else
  162. X          {
  163. X            /**** set up player to color mapping ****/
  164. X            if (!sidetaken[primary])
  165. X            {
  166. X              colorarray[index]=count;
  167. X              rcolorarray[primary]=count;
  168. X            }
  169. X            else
  170. X            {
  171. X              for (k=0; k<count; k++)
  172. X                if (sidemap[k] == primary)
  173. X                  colorarray[index]=k;
  174. X            }
  175. X            index++;
  176. X          }
  177. X  
  178. X          /**** set up side to color mapping ****/
  179. X          if (!sidetaken[primary])
  180. X          {
  181. X            sidemap[count] = primary;
  182. X            if (secondary >= 0)
  183. X              color2bw[primary] = secondary;
  184. X  
  185. X            if (secondary < 0 && primary > WHITE)
  186. X            {
  187. X              lettermap[count][0] = huename[primary][0] - 'a' + 'A';
  188. X              lettermap[count][1] = '\0';
  189. X            }
  190. X            else
  191. X              lettermap[count][0] = FALSE;
  192. X  
  193. X            count++;
  194. X          }
  195. X          sidetaken[primary] = TRUE;
  196. X        }
  197. X      }
  198. X      if (primary == -1)
  199. X      {
  200. X        printf ("Invalid command    : %s\n", argv[i]);
  201. X        i++;
  202. X      }
  203. X      else
  204. X        i+=2;
  205. X    }
  206. X  }
  207. X
  208. X  nplayers = index;
  209. X  nsides = count;
  210. X  none = nsides;
  211. X  dark = nsides+1;
  212. X  light = nsides+2;
  213. X
  214. X  if (nsides < 1 && !is_arg("-replay",argc,argv))
  215. X  {
  216. X    printf (usage);
  217. X    exit (0);
  218. X  }
  219. X}
  220. X
  221. X
  222. X/*************************************************************************/
  223. X/**    init_defaults                            **/
  224. X/** initialize default option values                    **/
  225. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  226. X/*************************************************************************/
  227. Xinit_defaults()
  228. X{
  229. X  int i, j;
  230. X
  231. X  char str[100];
  232. X
  233. X  for (i=0; i<MAXSIDES; i++)
  234. X  {
  235. X    slowfactor[i] = SLOWFACTOR;
  236. X    artillery[i] = 0;
  237. X    paratroops[i] = 0;
  238. X    bases[i] = 0;
  239. X    rbases[i] = 0;
  240. X    militia[i] = 0;
  241. X    armies[i] = 0;
  242. X    firepower[i] = FIREPOWER / (1.0 + gamespeed/5.0);
  243. X    forest[i] = 0;
  244. X    hillfactor[i] = 0;
  245. X    decayrate[i] = 0;
  246. X    eroderate[i] = 0;
  247. X    viewrange[i] = VIEWRANGE;
  248. X    squaresize[i] = SQUARESIZE;
  249. X    enable_fill[i] = FALSE;
  250. X    enable_dig[i] = FALSE;
  251. X    enable_scuttle[i] = FALSE;
  252. X    enable_build[i] = FALSE;
  253. X    enable_personalmarch[i] = FALSE;
  254. X    marchrate[i] = MARCH;
  255. X    enable_artillery[i] = FALSE;
  256. X    enable_paratroops[i] = FALSE;
  257. X    enable_grid[i] = TRUE;
  258. X    enable_manpos[i] = FALSE;
  259. X    enable_hidden[i] = FALSE;
  260. X    enable_disrupt[i] = FALSE;
  261. X    enable_map[i] = FALSE;
  262. X    enable_basemap[i] = FALSE;
  263. X    enable_localmap[i] = FALSE;
  264. X    enable_personalhorizon[i] = FALSE;
  265. X    enable_personalbound[i] = FALSE;
  266. X    enable_erode[i] = FALSE;
  267. X    enable_digin[i] = FALSE;
  268. X    enable_repeat[i] = FALSE;
  269. X    enable_reserve[i] = FALSE;
  270. X    enable_attack[i] = FALSE;
  271. X    enable_nospigot[i] = FALSE;
  272. X
  273. X    for (j=0; j<4; j++)
  274. X      dir[i][j] = 0;
  275. X    dirtype[i] = FORCE;
  276. X  }
  277. X  delay = 5000;
  278. X  seed = getpid() + time(NULL);
  279. X  maxviewrange = 0;
  280. X  enable_anylocalmap = FALSE;
  281. X  enable_bound = FALSE;
  282. X  enable_march = FALSE;
  283. X  enable_edit = FALSE;
  284. X  enable_area = FALSE;
  285. X  fillnumber = 1;
  286. X  directions = 4;
  287. X
  288. X  sprintf(str,"seed=%d ",seed);
  289. X  strcat(messagestr,str);
  290. X}
  291. X
  292. X
  293. X/*************************************************************************/
  294. X/**    installoption                            **/
  295. X/** install current option                        **/
  296. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  297. X/*************************************************************************/
  298. Xinstalloption (argc, argv, pos, side)
  299. X  int argc;
  300. X  char *argv[];
  301. X  int pos,
  302. X      side;
  303. X{
  304. X  double djunk,
  305. X         atof();
  306. X  int i, j,
  307. X      extra,
  308. X      ijunk;
  309. X
  310. X  char str[80],
  311. X       filename[80],
  312. X       line[80];
  313. X
  314. X  strcpy (line, argv[pos]);
  315. X
  316. X  if (strcmp(line,"-seed") == 0)
  317. X    return (2);
  318. X
  319. X  if (strcmp(line,"-hills") == 0)
  320. X  {
  321. X    djunk = atof (argv[pos+1]);
  322. X    enable_hills = TRUE;
  323. X    enable_terrain = TRUE;
  324. X    sprintf(str,"hills=%d ", (int)(djunk));
  325. X    strcat(messagestr,str);
  326. X
  327. X    if (side == GLOBAL)
  328. X    {
  329. X      for (i=0; i<MAXSIDES; i++)
  330. X        hillfactor[i] = djunk*0.2;
  331. X    }
  332. X    else
  333. X      hillfactor[side] = djunk*0.2;
  334. X
  335. X    return (2);
  336. X  }
  337. X
  338. X  if (strcmp(line,"-forest") == 0)
  339. X  {
  340. X    djunk = atof (argv[pos+1]);
  341. X    enable_forest = TRUE;
  342. X    enable_terrain = TRUE;
  343. X    sprintf(str,"forest=%d ", (int)(djunk));
  344. X    strcat(messagestr,str);
  345. X
  346. X    if (side == GLOBAL)
  347. X    {
  348. X      for (i=0; i<MAXSIDES; i++)
  349. X        forest[i] = djunk*0.2;
  350. X    }
  351. X    else
  352. X      forest[side] = djunk*0.2;
  353. X
  354. X    return (2);
  355. X  }
  356. X
  357. X  if (strcmp(line,"-sea") == 0)
  358. X    return (2);
  359. X
  360. X  if (strcmp(line,"-move") == 0)
  361. X  {
  362. X    djunk = atof (argv[pos+1]);
  363. X    sprintf(str,"move=%d ", (int)(djunk));
  364. X    strcat(messagestr,str);
  365. X    if (side == GLOBAL)
  366. X    {
  367. X      for (i=0; i<MAXSIDES; i++)
  368. X        slowfactor[i] = (10.0-djunk)*0.6;
  369. X    }
  370. X    else
  371. X      slowfactor[side] = (10.0-djunk)*0.6;
  372. X    return (2);
  373. X  }
  374. X
  375. X  if (strcmp(line,"-digin") == 0)
  376. X  {
  377. X    djunk = atof (argv[pos+1]);
  378. X    sprintf(str,"digin=%d ", (int)(djunk));
  379. X    strcat(messagestr,str);
  380. X    if (side == GLOBAL)
  381. X    {
  382. X      for (i=0; i<MAXSIDES; i++)
  383. X      {
  384. X        enable_digin[i] = TRUE;
  385. X        shuntval[i] = djunk;
  386. X      }
  387. X    }
  388. X    else
  389. X    {
  390. X      enable_digin[side] = TRUE;
  391. X      shuntval[side] = djunk;
  392. X    }
  393. X    return (2);
  394. X  }
  395. X
  396. X  if (strcmp(line,"-guns") == 0)
  397. X  {
  398. X    djunk = atof (argv[pos+1]);
  399. X    sprintf(str,"guns=%d ", (int)(djunk));
  400. X    strcat(messagestr,str);
  401. X
  402. X    if (side == GLOBAL)
  403. X      for (i=0; i<MAXSIDES; i++)
  404. X      {
  405. X        enable_artillery[i] = TRUE;
  406. X        artillery[i] = djunk*0.05;
  407. X      }
  408. X    else
  409. X    {
  410. X      artillery[side] = djunk*0.05;
  411. X      enable_artillery[side] = TRUE;
  412. X    }
  413. X    return (2);
  414. X  }
  415. X
  416. X  if (strcmp(line,"-para") == 0)
  417. X  {
  418. X    djunk = atof (argv[pos+1]);
  419. X    sprintf(str,"para=%d ", (int)(djunk));
  420. X    strcat(messagestr,str);
  421. X
  422. X    if (side == GLOBAL)
  423. X      for (i=0; i<MAXSIDES; i++)
  424. X      {
  425. X        paratroops[i] = djunk*0.05;
  426. X        enable_paratroops[i] = TRUE;
  427. X      }
  428. X    else
  429. X    {
  430. X      paratroops[side] = djunk*0.05;
  431. X      enable_paratroops[side] = TRUE;
  432. X    }
  433. X    return (2);
  434. X  }
  435. X
  436. X  if (strcmp(line,"-farms") == 0)
  437. X    return (2); 
  438. X
  439. X  if (strcmp(line,"-hex") == 0)
  440. X    return (1); 
  441. X
  442. X  if (strcmp(line,"-border") == 0)
  443. X    return (1); 
  444. X
  445. X  if (strcmp(line,"-towns") == 0)
  446. X    return (2);
  447. X
  448. X  if (strcmp(line,"-bases") == 0)
  449. X  {
  450. X    enable_bases = TRUE;
  451. X    ijunk = atoi (argv[pos+1]);
  452. X    sprintf(str,"bases=%d ", ijunk);
  453. X    strcat(messagestr,str);
  454. X
  455. X    if (side == GLOBAL)
  456. X      for (i=0; i<MAXSIDES; i++)
  457. X        bases[i] = ijunk;
  458. X    else
  459. X      bases[side] = ijunk;
  460. X    return (2);
  461. X  }
  462. X
  463. X  if (strcmp(line,"-rbases") == 0)
  464. X  {
  465. X    enable_rbases = TRUE;
  466. X    ijunk = atoi (argv[pos+1]);
  467. X    sprintf(str,"rbases=%d ", ijunk);
  468. X    strcat(messagestr,str);
  469. X
  470. X    if (side == GLOBAL)
  471. X      for (i=0; i<MAXSIDES; i++)
  472. X        rbases[i] = ijunk;
  473. X    else
  474. X      rbases[side] = ijunk;
  475. X    return (2);
  476. X  }
  477. X
  478. X  if (strcmp(line,"-armies") == 0)
  479. X  {
  480. X    enable_armies = TRUE;
  481. X    ijunk = atoi (argv[pos+1]);
  482. X    sprintf(str,"armies=%d ", ijunk);
  483. X    strcat(messagestr,str);
  484. X
  485. X    if (side == GLOBAL)
  486. X      for (i=0; i<MAXSIDES; i++)
  487. X        armies[i] = ijunk;
  488. X    else
  489. X      armies[side] = ijunk;
  490. X    return (2);
  491. X  }
  492. X
  493. X  if (strcmp(line,"-militia") == 0)
  494. X  {
  495. X    enable_militia = TRUE;
  496. X    djunk = atof (argv[pos+1]);
  497. X    sprintf(str,"militia=%d ", (int)(djunk));
  498. X    strcat(messagestr,str);
  499. X
  500. X    if (side == GLOBAL)
  501. X      for (i=0; i<MAXSIDES; i++)
  502. X        militia[i] = djunk;
  503. X    else
  504. X      militia[side] = djunk;
  505. X    return (2);
  506. X  }
  507. X
  508. X  if (strcmp(line,"-speed") == 0)
  509. X    return (2);
  510. X
  511. X  if (strcmp(line,"-fight") == 0)
  512. X  {
  513. X    djunk = atof (argv[pos+1]);
  514. X    sprintf(str,"fight=%d ", (int)(djunk));
  515. X    strcat(messagestr,str);
  516. X
  517. X    if (side == GLOBAL)
  518. X      for (i=0; i<MAXSIDES; i++)
  519. X        firepower[i] = (djunk)/(1.0+(gamespeed/5.0));
  520. X    else
  521. X      firepower[side] = (djunk)/(1.0+(gamespeed/5.0));
  522. X    return (2);
  523. X  }
  524. X
  525. X  if (strcmp(line,"-decay") == 0)
  526. X  {
  527. X    enable_decay = TRUE;
  528. X    djunk = atof (argv[pos+1]);
  529. X    sprintf(str,"decay=%d ", (int)(djunk));
  530. X    strcat(messagestr,str);
  531. X
  532. X    if (side == GLOBAL)
  533. X      for (i=0; i<MAXSIDES; i++)
  534. X        decayrate[i] = djunk/(10.0*(double)(MAXVAL));
  535. X    else
  536. X      decayrate[side] = djunk/(10.0*(double)(MAXVAL));
  537. X
  538. X    return (2);
  539. X  }
  540. X
  541. X
  542. X  if (strcmp(line,"-erode") == 0)
  543. X  {
  544. X    djunk = atof (argv[pos+1]);
  545. X    sprintf(str,"erode=%d ", (int)(djunk));
  546. X    strcat(messagestr,str);
  547. X
  548. X    if (side == GLOBAL)
  549. X    {
  550. X      for (i=0; i<MAXSIDES; i++)
  551. X      {
  552. X        enable_erode[i] = TRUE;
  553. X        eroderate[i] = djunk*10.0;
  554. X      }
  555. X    }
  556. X    else
  557. X    {
  558. X      enable_erode[side] = TRUE;
  559. X      eroderate[side] = djunk*10.0;
  560. X    }
  561. X
  562. X    return (2);
  563. X  }
  564. X
  565. X  if (strcmp(line,"-fill") == 0)
  566. X  {
  567. X    djunk = atof (argv[pos+1]);
  568. X    sprintf(str,"fill=%d ", (int)(djunk));
  569. X    strcat(messagestr,str);
  570. X
  571. X    if (side == GLOBAL)
  572. X    {
  573. X      for (i=0; i<MAXSIDES; i++)
  574. X      {
  575. X        enable_fill[i] = TRUE;
  576. X        fillnumber = (int)(djunk);
  577. X      }
  578. X    }
  579. X    else
  580. X    {
  581. X      enable_fill[side] = TRUE;
  582. X      fillnumber = (int)(djunk);
  583. X    }
  584. X
  585. X    return (2);
  586. X  }
  587. X
  588. X  if (strcmp(line,"-dig") == 0)
  589. X  {
  590. X    djunk = atof (argv[pos+1]);
  591. X    sprintf(str,"dig=%d ", (int)(djunk));
  592. X    strcat(messagestr,str);
  593. X
  594. X    if (side == GLOBAL)
  595. X    {
  596. X      for (i=0; i<MAXSIDES; i++)
  597. X      {
  598. X        enable_dig[i] = TRUE;
  599. X        fillnumber = (int)(djunk);
  600. X      }
  601. X    }
  602. X    else
  603. X    {
  604. X      enable_dig[side] = TRUE;
  605. X      fillnumber = (int)(djunk);
  606. X    }
  607. X    return (2);
  608. X  }
  609. X
  610. X  if (strcmp(line,"-scuttle") == 0)
  611. X  {
  612. X    strcat(messagestr,"scuttle ");
  613. X    if (side == GLOBAL)
  614. X      for (i=0; i<MAXSIDES; i++)
  615. X        enable_scuttle[i] = TRUE;
  616. X    else
  617. X      enable_scuttle[side] = TRUE;
  618. X    return (1);
  619. X  }
  620. X
  621. X  if (strcmp(line,"-build") == 0)
  622. X  {
  623. X    ijunk = atoi (argv[pos+1]);
  624. X    sprintf(str,"build=%d ", ijunk);
  625. X    strcat(messagestr,str);
  626. X
  627. X
  628. X    if (side == GLOBAL)
  629. X      for (i=0; i<MAXSIDES; i++)
  630. X      {
  631. X        enable_build[i] = TRUE;
  632. X        buildrate[i] = 23040/ijunk;
  633. X        scuttlerate[i] = MAXVAL/ijunk;
  634. X      }
  635. X    else
  636. X    {
  637. X      enable_build[side] = TRUE;
  638. X      buildrate[side] = 23040/ijunk;
  639. X      scuttlerate[side] = MAXVAL/ijunk;
  640. X    }
  641. X    return (2);
  642. X  }
  643. X
  644. X  if (strcmp(line,"-march") == 0)
  645. X  {
  646. X    ijunk = atoi (argv[pos+1]);
  647. X    enable_march = TRUE;
  648. X    sprintf(str,"march=%d ", ijunk);
  649. X    strcat(messagestr,str);
  650. X
  651. X    if (side == GLOBAL)
  652. X      for (i=0; i<MAXSIDES; i++)
  653. X      {
  654. X        enable_personalmarch[i] = TRUE;
  655. X        marchrate[i] = ijunk;
  656. X      }
  657. X    else
  658. X    {
  659. X      enable_personalmarch[side] = TRUE;
  660. X      marchrate[side] = ijunk;
  661. X    }
  662. X    return (2);
  663. X  }
  664. X
  665. X  if (strcmp(line,"-reserve") == 0)
  666. X  {
  667. X    strcat(messagestr,"reserve ");
  668. X    if (side == GLOBAL)
  669. X      for (i=0; i<MAXSIDES; i++)
  670. X        enable_reserve[i] = TRUE;
  671. X    else
  672. X      enable_reserve[side] = TRUE;
  673. X    return (1);
  674. X  }
  675. X
  676. X  if (strcmp(line,"-bound") == 0)
  677. X  {
  678. X    strcat(messagestr,"bound ");
  679. X    enable_bound = TRUE;
  680. X    if (side == GLOBAL)
  681. X      for (i=0; i<MAXSIDES; i++)
  682. X        enable_personalbound[i] = TRUE;
  683. X    else
  684. X      enable_personalbound[side] = TRUE;
  685. X    return (1);
  686. X  }
  687. X
  688. X  if (strcmp(line,"-area") == 0)
  689. X  {
  690. X    strcat(messagestr,"area ");
  691. X    enable_area = TRUE;
  692. X    return (1);
  693. X  }
  694. X
  695. X  if (strcmp(line,"-repeat") == 0)
  696. X  {
  697. X    strcat(messagestr,"repeat ");
  698. X    if (side == GLOBAL)
  699. X      for (i=0; i<MAXSIDES; i++)
  700. X        enable_repeat[i] = TRUE;
  701. X    else
  702. X      enable_repeat[side] = TRUE;
  703. X    return (1);
  704. X  }
  705. X
  706. X  if (strcmp(line,"-attack") == 0)
  707. X  {
  708. X    strcat(messagestr,"attack ");
  709. X    if (side == GLOBAL)
  710. X      for (i=0; i<MAXSIDES; i++)
  711. X        enable_attack[i] = TRUE;
  712. X    else
  713. X      enable_attack[side] = TRUE;
  714. X    return (1);
  715. X  }
  716. X
  717. X  if (strcmp(line,"-nospigot") == 0)
  718. X  {
  719. X    strcat(messagestr,"nospigot ");
  720. X    if (side == GLOBAL)
  721. X      for (i=0; i<MAXSIDES; i++)
  722. X        enable_nospigot[i] = TRUE;
  723. X    else
  724. X      enable_nospigot[side] = TRUE;
  725. X    return (1);
  726. X  }
  727. X
  728. X  if (strcmp(line,"-wrap") == 0)
  729. X  {
  730. X    enable_anywrap = TRUE;
  731. X    strcat(messagestr,"wrap ");
  732. X
  733. X    if (side == GLOBAL)
  734. X      for (i=0; i<MAXSIDES; i++)
  735. X      {
  736. X        enable_wrap[i] = TRUE;
  737. X      }
  738. X    else
  739. X      enable_wrap[side] = TRUE;
  740. X
  741. X    return (1);
  742. X  }
  743. X
  744. X  if (strcmp(line,"-nogrid") == 0)
  745. X  {
  746. X    if (side == GLOBAL)
  747. X      for (i=0; i<MAXSIDES; i++)
  748. X      {
  749. X        enable_grid[i] = FALSE;
  750. X      }
  751. X    else
  752. X      enable_grid[side] = FALSE;
  753. X    return (1);
  754. X  }
  755. X
  756. X  if (strcmp(line,"-horizon") == 0)
  757. X  {
  758. X    enable_horizon = TRUE;
  759. X    if (pos < argc-1)
  760. X    {
  761. X      if (argv[pos+1][0] >= '0' && argv[pos+1][0] <= '9')
  762. X      {
  763. X        ijunk = atoi (argv[pos+1]);
  764. X        extra = 2;
  765. X      }
  766. X      else
  767. X      {
  768. X        ijunk = VIEWRANGE;
  769. X        extra = 1;
  770. X      }
  771. X    }
  772. X    else
  773. X    {
  774. X      ijunk = VIEWRANGE;
  775. X      extra = 1;
  776. X    }
  777. X    sprintf(str,"horizon=%d ", ijunk);
  778. X    strcat(messagestr,str);
  779. X
  780. X    if (side == GLOBAL)
  781. X      for (i=0; i<MAXSIDES; i++)
  782. X      {
  783. X        viewrange[i] = ijunk;
  784. X        enable_personalhorizon[i] = TRUE;
  785. X      }
  786. X    else
  787. X    {
  788. X      viewrange[side] = ijunk;
  789. X      enable_personalhorizon[side] = TRUE;
  790. X    }
  791. X
  792. X    return (extra);
  793. X  }
  794. X
  795. X  if (strcmp(line,"-hidden") == 0)
  796. X  {
  797. X    strcat(messagestr,"hidden ");
  798. X
  799. X    if (side == GLOBAL)
  800. X      for (i=0; i<MAXSIDES; i++)
  801. X        enable_hidden[i] = TRUE;
  802. X    else
  803. X      enable_hidden[side] = TRUE;
  804. X    return (1);
  805. X  }
  806. X
  807. X  if (strcmp(line,"-map") == 0)
  808. X  {
  809. X    strcat(messagestr,"map ");
  810. X
  811. X    if (side == GLOBAL)
  812. X      for (i=0; i<MAXSIDES; i++)
  813. X        enable_map[i] = TRUE;
  814. X    else
  815. X      enable_map[side] = TRUE;
  816. X    return (1);
  817. X  }
  818. X
  819. X  if (strcmp(line,"-basemap") == 0)
  820. X  {
  821. X    strcat(messagestr,"basemap ");
  822. X
  823. X    if (side == GLOBAL)
  824. X      for (i=0; i<MAXSIDES; i++)
  825. X        enable_basemap[i] = TRUE;
  826. X    else
  827. X      enable_basemap[side] = TRUE;
  828. X    return (1);
  829. X  }
  830. X
  831. X  if (strcmp(line,"-localmap") == 0)
  832. X  {
  833. X    strcat(messagestr,"localmap ");
  834. X    enable_anylocalmap = TRUE;
  835. X
  836. X    if (side == GLOBAL)
  837. X      for (i=0; i<MAXSIDES; i++)
  838. X        enable_localmap[i] = TRUE;
  839. X    else
  840. X      enable_localmap[side] = TRUE;
  841. X    return (1);
  842. X  }
  843. X
  844. X  if (strcmp(line,"-disrupt") == 0)
  845. X  {
  846. X    strcat(messagestr,"disrupt ");
  847. X
  848. X    if (side == GLOBAL)
  849. X      for (i=0; i<MAXSIDES; i++)
  850. X        enable_disrupt[i] = TRUE;
  851. X    else
  852. X      enable_disrupt[side] = TRUE;
  853. X    return (1);
  854. X  }
  855. X
  856. X  if (strcmp(line,"-board") == 0)
  857. X    return (2);
  858. X
  859. X  if (strcmp(line,"-boardx") == 0)
  860. X    return (2);
  861. X
  862. X  if (strcmp(line,"-boardy") == 0)
  863. X    return (2);
  864. X
  865. X  if (strcmp(line,"-square") == 0)
  866. X  {
  867. X    ijunk = atoi (argv[pos+1]);
  868. X
  869. X    if (side == GLOBAL)
  870. X      for (i=0; i<MAXSIDES; i++)
  871. X        squaresize[i] = ijunk;
  872. X    else
  873. X      squaresize[side] = ijunk;
  874. X    return (2);
  875. X  }
  876. X
  877. X  if (strcmp(line,"-manpos") == 0)
  878. X  {
  879. X    if (side == GLOBAL)
  880. X      for (i=0; i<MAXSIDES; i++)
  881. X      {
  882. X        enable_manpos[i] = TRUE;
  883. X      }
  884. X    else
  885. X        enable_manpos[side] = TRUE;
  886. X    return (1);
  887. X  }
  888. X
  889. X  if (strcmp(line,"-store") == 0)
  890. X  {
  891. X    if (!stringval ("-store",argc,argv,filename))
  892. X      return (1);
  893. X    else
  894. X      return (2);
  895. X  }
  896. X
  897. X  if (strcmp(line,"-replay") == 0)
  898. X  {
  899. X    if (!stringval ("-replay",argc,argv,filename))
  900. X      return (1);
  901. X    else
  902. X      return (2);
  903. X  }
  904. X
  905. X  if (strcmp(line,"-load") == 0)
  906. X  {
  907. X    if (!stringval ("-load",argc,argv,filename))
  908. X      return (1);
  909. X    else
  910. X      return (2);
  911. X  }
  912. X
  913. X  if (strcmp(line,"-edit") == 0)
  914. X  {
  915. X    if (!stringval ("-edit",argc,argv,filename))
  916. X      return (1);
  917. X    else
  918. X      return (2);
  919. X  }
  920. X
  921. X  if (strcmp(line,"-options") == 0)
  922. X  {
  923. X    if (pos == argc-1)
  924. X    {
  925. X      strcpy (filename, "default.xbo");
  926. X      extra = 1;
  927. X    }
  928. X    else if (argv[pos+1][0] == '-' || argv[pos+1][0] == '}')
  929. X    {
  930. X      strcpy (filename, "default.xbo");
  931. X      extra = 1;
  932. X    }
  933. X    else
  934. X    {
  935. X      strcpy (filename, argv[pos+1]);
  936. X      extra = 2;
  937. X    }
  938. X
  939. X    loadoptions (filename, side);
  940. X
  941. X    return (extra);
  942. X  }
  943. X}
  944. X
  945. X
  946. X/*************************************************************************/
  947. X/**    loadoptions                            **/
  948. X/** load options from file                        **/
  949. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  950. X/*************************************************************************/
  951. Xloadoptions(filename, side)
  952. X  char filename[];
  953. X  int side;
  954. X{
  955. X  int ptr1,
  956. X      ptr2;
  957. X      
  958. X  char line[100],
  959. X       *option[3],
  960. X       junkdisplayname[MAXPLAYERS][80];
  961. X
  962. X  FILE *fpopts,
  963. X       *fopen();
  964. X
  965. X  option[0] = (char *)(malloc(50*sizeof(char)));
  966. X  option[1] = (char *)(malloc(50*sizeof(char)));
  967. X  option[2] = (char *)(malloc(50*sizeof(char)));
  968. X
  969. X  if ((fpopts = fopen (filename, "r")) == NULL)
  970. X  {
  971. X    printf ("Unable to open option file %s\n", filename);
  972. X    exit (0);
  973. X  }
  974. X
  975. X  while (fgets (line, 100, fpopts) != NULL)
  976. X  {
  977. X    option[0][0] = '\0';
  978. X
  979. X    for (ptr1=0; line[ptr1] != ' ' && line[ptr1] != '\0' && line[ptr1] != '\n'; ptr1++)
  980. X      option[1][ptr1] = line[ptr1];
  981. X    option[1][ptr1] = '\0';  
  982. X
  983. X    for (; line[ptr1] == ' ' && line[ptr1] != '\0' && line[ptr1] != '\n'; ptr1++);
  984. X
  985. X    for (ptr2=0; line[ptr1] != '\0' && line[ptr1] != '\n'; ptr1++, ptr2++)
  986. X      option[2][ptr2] = line[ptr1];
  987. X    option[2][ptr2] = '\0';  
  988. X
  989. X    if (option[2][0] == '\0')
  990. X    {
  991. X      strcpy (option[2], "-blah");
  992. X    }
  993. X
  994. X    if (goodoption(option[1]))
  995. X    {
  996. X      installoption (3, option, 1, side);
  997. X      init_options (junkdisplayname, 3, option);
  998. X    }
  999. X    else
  1000. X    {
  1001. X      printf ("illegal argument in option file:   %s\n", line);
  1002. X    }
  1003. X  }
  1004. X
  1005. X  fclose (fpopts);
  1006. X}
  1007. X
  1008. X
  1009. X/*************************************************************************/
  1010. X/**    goodoption                            **/
  1011. X/** Return TRUE if string is valid option                **/
  1012. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  1013. X/*************************************************************************/
  1014. Xgoodoption(line)
  1015. X  char line[];
  1016. X{
  1017. X  int i, j,
  1018. X      valid,
  1019. X      allvalid,
  1020. X      ptr;
  1021. X
  1022. X  valid = FALSE;
  1023. X  for (i=0; i<NOPTS && !valid; i++)
  1024. X  {
  1025. X    if (strcmp(line,options[i]) == 0)
  1026. X    {
  1027. X      valid = TRUE;
  1028. X    }
  1029. X  }
  1030. X  return (valid);
  1031. X}
  1032. X
  1033. X
  1034. X/*************************************************************************/
  1035. X/**    checkoptions                            **/
  1036. X/** Make sure all command line arguments are valid            **/
  1037. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  1038. X/*************************************************************************/
  1039. Xcheckoptions(argc,argv)
  1040. X  int argc;
  1041. X  char *argv[];
  1042. X{
  1043. X  int i, j,
  1044. X      valid,
  1045. X      allvalid,
  1046. X      inbracket,
  1047. X      ptr;
  1048. X
  1049. X  char lastside[100];
  1050. X
  1051. X  ptr = 1;
  1052. X  allvalid = TRUE;
  1053. X  inbracket = FALSE;
  1054. X
  1055. X  while (ptr < argc)
  1056. X  {
  1057. X    valid = FALSE;
  1058. X    for (i=0; i<NOPTS && !valid; i++)
  1059. X    {
  1060. X      if (strcmp(argv[ptr],options[i]) == 0)
  1061. X      {
  1062. X        valid = TRUE;
  1063. X        if (i < POPTS)
  1064. X        {
  1065. X          if (ptr+1 == argc)
  1066. X          {
  1067. X            allvalid = FALSE; 
  1068. X            printf ("missing argument:     %s\n", argv[ptr]); 
  1069. X            ptr++;
  1070. X          }
  1071. X          else if (argv[ptr+1][0] == '-' || (inbracket && argv[ptr+1][0] == '}'))
  1072. X          {
  1073. X            allvalid = FALSE; 
  1074. X            printf ("missing argument:     %s\n", argv[ptr]); 
  1075. X            ptr++;
  1076. X          }
  1077. X          else
  1078. X            ptr += 2;
  1079. X        }
  1080. X        else if (i < POPTS + PVOPTS)
  1081. X        {
  1082. X          if (ptr+1 == argc)
  1083. X            ptr++;
  1084. X          else if (argv[ptr+1][0] == '-' || (inbracket && argv[ptr+1][0] == '}'))
  1085. X            ptr++;
  1086. X          else
  1087. X            ptr += 2;
  1088. X        }
  1089. X        else
  1090. X        {
  1091. X          if (ptr+1 != argc)
  1092. X          {
  1093. X            if (argv[ptr+1][0] != '-' && !(inbracket && argv[ptr+1][0] == '}'))
  1094. X            {
  1095. X              allvalid = FALSE; 
  1096. X              printf ("extra argument:       %s %s\n", argv[ptr], argv[ptr+1]); 
  1097. X              ptr += 2;
  1098. X            }
  1099. X            else
  1100. X              ptr++;
  1101. X          }
  1102. X          else
  1103. X            ptr++;
  1104. X        }
  1105. X      }
  1106. X    }
  1107. X
  1108. X    if (!valid && inbracket)
  1109. X    {
  1110. X      if (argv[ptr][0] == '}')
  1111. X      {
  1112. X        valid = TRUE;
  1113. X        if (ptr+1 == argc)
  1114. X        {
  1115. X          allvalid = FALSE;
  1116. X          printf ("missing screen name:  %s\n", lastside);
  1117. X          ptr++;
  1118. X        }      
  1119. X        else if (argv[ptr+1][0] == '-')
  1120. X        {
  1121. X          allvalid = FALSE;
  1122. X          printf ("missing screen name:  %s\n", lastside);
  1123. X          ptr++;
  1124. X        }      
  1125. X        else
  1126. X        {
  1127. X          ptr+=2;
  1128. X        }
  1129. X
  1130. X        inbracket = FALSE;
  1131. X      }
  1132. X    }
  1133. X    else if (!valid)
  1134. X    {
  1135. X      for (j=1; j<=MAXHUES && !valid; j++)
  1136. X      {
  1137. X        if (matchstr(&(argv[ptr][1]), huename[j]))
  1138. X        {
  1139. X          valid = TRUE;
  1140. X          if (ptr+1 == argc)
  1141. X          {
  1142. X            allvalid = FALSE; 
  1143. X            printf ("missing argument:     %s\n", argv[ptr]); 
  1144. X            ptr++;
  1145. X          }
  1146. X          else if (argv[ptr+1][0] == '-')
  1147. X          {
  1148. X            allvalid = FALSE; 
  1149. X            printf ("missing argument:     %s\n", argv[ptr]); 
  1150. X            ptr++;
  1151. X          }
  1152. X          else
  1153. X          {
  1154. X            if (argv[ptr+1][0] == '{')
  1155. X            {
  1156. X              inbracket = TRUE;
  1157. X              strcpy (lastside, argv[ptr]);
  1158. X            }
  1159. X            ptr += 2;
  1160. X          }
  1161. X        }
  1162. X      }
  1163. X    }
  1164. X
  1165. X    if (!valid)
  1166. X    {
  1167. X      allvalid = FALSE; 
  1168. X      if (ptr+1 == argc)
  1169. X      {
  1170. X        printf ("illegal argument:     %s\n", argv[ptr]); 
  1171. X        ptr++;
  1172. X      }
  1173. X      else if (argv[ptr+1][0] == '-')
  1174. X      {
  1175. X        printf ("illegal argument:     %s\n", argv[ptr]); 
  1176. X        ptr++;
  1177. X      }
  1178. X      else
  1179. X      {
  1180. X        printf ("illegal argument:     %s %s\n", argv[ptr], argv[ptr+1]); 
  1181. X        ptr += 2;
  1182. X      }
  1183. X    }
  1184. X  }
  1185. X
  1186. X  if (inbracket)
  1187. X  {
  1188. X    allvalid = FALSE;
  1189. X    printf ("incomplete side:      %s\n", lastside);
  1190. X  }
  1191. X
  1192. X  if (!allvalid)
  1193. X    exit (0);
  1194. X}
  1195. X      
  1196. X
  1197. X/*************************************************************************/
  1198. X/**     storeparameters                                                 **/
  1199. X/**  store relevant game parameters at head of storage file        **/
  1200. X/**     Greg Lesher (lesher@park.bu.edu)                                **/
  1201. X/*************************************************************************/
  1202. Xstoreparameters ()
  1203. X{
  1204. X  int i;
  1205. X
  1206. X  fprintf (fpout, "%c", squaresize[0]);
  1207. X  fprintf (fpout, "%c", boardsizex);
  1208. X  fprintf (fpout, "%c", boardsizey);
  1209. X  fprintf (fpout, "%c", enable_hex);
  1210. X  fprintf (fpout, "%c", enable_hills);
  1211. X  fprintf (fpout, "%c", enable_forest);
  1212. X  fprintf (fpout, "%c", enable_sea);
  1213. X  fprintf (fpout, "%c", enable_terrain);
  1214. X  fprintf (fpout, "%c", nsides);
  1215. X  fprintf (fpout, "%c", fillnumber);
  1216. X  for (i=0; i<nsides; i++)
  1217. X    fprintf (fpout, "%c", sidemap[i]);
  1218. X  for (i=0; i<nsides; i++)
  1219. X    fprintf (fpout, "%c", color2bw[sidemap[i]]);
  1220. X}
  1221. X
  1222. X
  1223. X/*************************************************************************/
  1224. X/**     loadparameters                                                  **/
  1225. X/**  load relevant game parameters from replay file            **/
  1226. X/**     Greg Lesher (lesher@park.bu.edu)                                **/
  1227. X/*************************************************************************/
  1228. Xloadparameters (displayname)
  1229. X  char displayname[MAXPLAYERS][80];
  1230. X{
  1231. X  int i;
  1232. X
  1233. X  squaresize[0] = getc (fpout);
  1234. X  boardsizex = getc (fpout);
  1235. X  boardsizey = getc (fpout);
  1236. X  enable_hex = getc (fpout);
  1237. X  enable_hills = getc (fpout);
  1238. X  enable_forest = getc (fpout);
  1239. X  enable_sea = getc (fpout);
  1240. X  enable_terrain = getc (fpout);
  1241. X  nsides = getc (fpout);
  1242. X  fillnumber = getc (fpout);
  1243. X  for (i=0; i<nsides; i++)
  1244. X    sidemap[i] = getc(fpout);
  1245. X  for (i=0; i<nsides; i++)
  1246. X    color2bw[sidemap[i]] = getc (fpout);
  1247. X
  1248. X  for (i=0; i<nsides; i++)
  1249. X    lettermap[i][0] = FALSE;
  1250. X
  1251. X  colorarray[0] = 0;
  1252. X
  1253. X  /**** if no command line display names ****/
  1254. X  if (nplayers == 0)
  1255. X  {
  1256. X    nplayers = 1;
  1257. X    strcpy (displayname[0], "");
  1258. X  }
  1259. X
  1260. X  none = nsides;
  1261. X  dark = nsides+1;
  1262. X  light = nsides+2;
  1263. X}
  1264. X
  1265. X
  1266. X/*************************************************************************/
  1267. X/**    init_options                            **/
  1268. X/** initialize the game board options using global variables        **/
  1269. X/**    Steve Lehar (slehar@park.bu.edu)                **/
  1270. X/*************************************************************************/
  1271. Xinit_options(displayname,argc,argv)
  1272. X  char displayname[MAXPLAYERS][80];
  1273. X  int argc;
  1274. X  char *argv[];
  1275. X{
  1276. X  int i,
  1277. X      pos;
  1278. X  char str[80];
  1279. X  extern double doubleval();
  1280. X
  1281. X  /**** set random seed ****/
  1282. X  if (is_arg("-seed",argc,argv))
  1283. X  {
  1284. X    seed = intval("-seed",argc,argv);
  1285. X    strcat(messagestr,str);
  1286. X  } 
  1287. X
  1288. X  if (is_arg("-sea",argc,argv))
  1289. X  {
  1290. X    enable_sea = TRUE;
  1291. X    sprintf(str,"sea=%2.0f ",doubleval("-sea",argc,argv));
  1292. X    strcat(messagestr,str);
  1293. X    enable_terrain = TRUE;
  1294. X    sea = 20.0 - 2.0*doubleval("-sea",argc,argv);
  1295. X    if (sea <= 0.0)
  1296. X      sea = 2.0;
  1297. X  }
  1298. X
  1299. X  /**** farms ****/
  1300. X  if (is_arg("-farms",argc,argv))
  1301. X  {
  1302. X    enable_farms = TRUE;
  1303. X    farms = doubleval("-farms",argc,argv);
  1304. X
  1305. X    sprintf(str,"farms=%2.0f ",doubleval("-farms",argc,argv));
  1306. X    strcat(messagestr,str);
  1307. X  }
  1308. X
  1309. X  /**** border ****/
  1310. X  if (is_arg("-border",argc,argv))
  1311. X  {
  1312. X    enable_border = TRUE;
  1313. X  }
  1314. X
  1315. X  /**** hex ****/
  1316. X  if (is_arg("-hex",argc,argv))
  1317. X  {
  1318. X    enable_hex = TRUE;
  1319. X    directions = 6;
  1320. X  }
  1321. X
  1322. X  /**** town ****/
  1323. X  if (is_arg("-towns",argc,argv))
  1324. X  {
  1325. X    enable_towns = TRUE;
  1326. X    towns = doubleval("-towns",argc,argv);
  1327. X
  1328. X    sprintf(str,"towns=%d ", (int)(towns));
  1329. X    strcat(messagestr,str);
  1330. X  }
  1331. X
  1332. X  /**** game speed ****/
  1333. X  if (is_arg("-speed",argc,argv))
  1334. X  {
  1335. X    gamespeed = doubleval("-speed",argc,argv);
  1336. X    if (gamespeed == 0.0)
  1337. X      gamespeed = 0.5;
  1338. X    delay = (int)(25000.0/gamespeed + 0.5);
  1339. X
  1340. X    sprintf(str,"speed=%3.1f ",doubleval("-speed",argc,argv));
  1341. X    strcat(messagestr,str);
  1342. X  }
  1343. X
  1344. X  if (is_arg("-board",argc,argv))
  1345. X  {
  1346. X    boardsizex = intval("-board",argc,argv);
  1347. X    boardsizey = boardsizex;
  1348. X  }
  1349. X
  1350. X  if (is_arg("-boardx",argc,argv))
  1351. X    boardsizex = intval("-boardx",argc,argv);
  1352. X
  1353. X  if (is_arg("-boardy",argc,argv))
  1354. X    boardsizey = intval("-boardy",argc,argv);
  1355. X
  1356. X  /**** set up program for file storage ****/
  1357. X  if (is_arg("-store",argc,argv))
  1358. X  {
  1359. X    enable_storage = TRUE;
  1360. X    if (!stringval ("-store",argc,argv,storagename))
  1361. X      strcpy (storagename, "xbattle.xba");
  1362. X    strcat(messagestr,"store ");
  1363. X  }
  1364. X
  1365. X  if (is_arg("-load",argc,argv))
  1366. X  {
  1367. X    enable_load = TRUE;
  1368. X    if (!stringval ("-load",argc,argv,mapname))
  1369. X      strcpy (mapname, "xbattle.xbt");
  1370. X    strcat(messagestr,"load ");
  1371. X  }
  1372. X
  1373. X  if (is_arg("-edit",argc,argv))
  1374. X  {
  1375. X    enable_edit = TRUE;
  1376. X    if (!stringval ("-edit",argc,argv,mapname))
  1377. X      strcpy (mapname, "xbattle.xbt");
  1378. X    strcat(messagestr,"edit ");
  1379. X  }
  1380. X
  1381. X  /**** set up program for replay ****/
  1382. X  if (is_arg("-replay",argc,argv))
  1383. X  {
  1384. X    enable_replay = TRUE;
  1385. X    if (!stringval ("-replay",argc,argv,replayname))
  1386. X      strcpy (replayname, "xbattle.xba");
  1387. X
  1388. X    strcpy (messagestr, " REPLAY    REPLAY    REPLAY    REPLAY    REPLAY    REPLAY    REPLAY    REPLAY    REPLAY     REPLAY    REPLAY    REPLAY    REPLAY    REPLAY    REPLAY    REPLAY");
  1389. X  }
  1390. X}
  1391. X
  1392. X
  1393. X/*************************************************************************/
  1394. X/**    clean_options                            **/
  1395. X/** clean up incongruous options                    **/
  1396. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  1397. X/*************************************************************************/
  1398. Xclean_options(displayname)
  1399. X  char displayname[MAXPLAYERS][80];
  1400. X{
  1401. X  int i;
  1402. X
  1403. X  double full, base,
  1404. X         offset, factor,
  1405. X         sqrt();
  1406. X
  1407. X  FILE *fptemp,
  1408. X       *fopen();
  1409. X      
  1410. X  for (i=0; i<nsides; i++)
  1411. X  {
  1412. X    if (enable_map[i] || enable_localmap[i])
  1413. X    {
  1414. X      enable_horizon = TRUE;
  1415. X      enable_personalhorizon[i] = TRUE;
  1416. X    }
  1417. X
  1418. X    if (enable_localmap[i])
  1419. X    {
  1420. X      enable_map[i] = TRUE;
  1421. X      enable_basemap[i] = FALSE;
  1422. X    }
  1423. X  }
  1424. X
  1425. X  if (enable_horizon)
  1426. X  { 
  1427. X    for (i=0; i<nsides; i++)
  1428. X      if (enable_personalhorizon[i])
  1429. X        if (viewrange[i] > maxviewrange)
  1430. X          maxviewrange = viewrange[i];
  1431. X  }
  1432. X
  1433. X  if (enable_storage)
  1434. X  {
  1435. X    if ((fpout = fopen (storagename, "w")) == NULL)
  1436. X    {
  1437. X      printf ("Cannot open storage file %s\n", filename);
  1438. X      exit (0);
  1439. X    }
  1440. X    storeparameters ();
  1441. X  }
  1442. X
  1443. X  if (enable_replay)
  1444. X  {
  1445. X    if ((fpout = fopen (replayname, "r")) == NULL)
  1446. X    {
  1447. X      printf ("Cannot open replay file %s\n", filename);
  1448. X      exit (0);
  1449. X    }
  1450. X    loadparameters (displayname);
  1451. X  }
  1452. X
  1453. X  if (enable_load && !enable_edit)
  1454. X  {
  1455. X    if ((fptemp = fopen (mapname, "r")) == NULL)
  1456. X    {
  1457. X      printf ("Cannot open map file %s\n", mapname);
  1458. X      exit (0);
  1459. X    }
  1460. X
  1461. X    fread (&boardsizex, sizeof(int), 1, fptemp);
  1462. X    fread (&boardsizey, sizeof(int), 1, fptemp);
  1463. X    fread (&enable_hex, sizeof(int), 1, fptemp);
  1464. X    fread (&enable_hills, sizeof(int), 1, fptemp);
  1465. X    fread (&enable_forest, sizeof(int), 1, fptemp);
  1466. X    fread (&enable_sea, sizeof(int), 1, fptemp);
  1467. X    fread (&enable_terrain, sizeof(int), 1, fptemp);
  1468. X
  1469. X    fclose (fptemp);
  1470. X  }
  1471. X
  1472. X  if (enable_hex)
  1473. X  {
  1474. X    squaresize[0] = squaresize[0]/2;
  1475. X
  1476. X    if (squaresize[0]%2 == 1)
  1477. X      squaresize[0] -= 1;
  1478. X  }
  1479. X
  1480. X  if (enable_area)
  1481. X  {
  1482. X    full = ((double)(MAXVAL))/((MAXVAL+4)*(MAXVAL+4));
  1483. X
  1484. X    offset = 0.18;
  1485. X    factor = sqrt(full*MAXVAL)/(sqrt(full*MAXVAL)-offset); 
  1486. X
  1487. X
  1488. X    for (i=0; i<=MAXVAL+4; i++)
  1489. X    {
  1490. X      areavalue[i] = (sqrt(full*(float)i)-offset)*factor;
  1491. X      if (areavalue[i] < 0.0)
  1492. X        areavalue[i] = 0.0;
  1493. X    }
  1494. X  }
  1495. X  else
  1496. X  {
  1497. X    for (i=0; i<=MAXVAL+4; i++)
  1498. X      areavalue[i] =  ((double)(i)) / (MAXVAL + 4);
  1499. X  }
  1500. X
  1501. X#if MULTITEXT
  1502. X  for (i=0; i<nsides; i++)
  1503. X    strcpy (personal_messagestr[i], messagestr);
  1504. X#endif
  1505. X}
  1506. X
  1507. END_OF_FILE
  1508. if test 32059 -ne `wc -c <'parse.c'`; then
  1509.     echo shar: \"'parse.c'\" unpacked with wrong size!
  1510. fi
  1511. # end of 'parse.c'
  1512. fi
  1513. if test -f 'tutorial2' -a "${1}" != "-c" ; then 
  1514.   echo shar: Will not clobber existing file \"'tutorial2'\"
  1515. else
  1516. echo shar: Extracting \"'tutorial2'\" \(19904 characters\)
  1517. sed "s/^X//" >'tutorial2' <<'END_OF_FILE'
  1518. X#! /bin/sh
  1519. X
  1520. Xecho "=================== XBATTLE TUTORIAL 2 ========================" 
  1521. Xecho "hit RETURN to continue"
  1522. Xread p1
  1523. Xclear
  1524. X
  1525. Xecho "I will presume that  you have  already  done the first tutorial,"
  1526. Xecho "and  hopefully played  a few games   with some of   your friends"
  1527. Xecho "before trying out  this tutorial.   Here we will  show you  some"
  1528. Xecho "more advanced things you can do with xbattle."
  1529. X
  1530. Xecho
  1531. X
  1532. Xecho "hit RETURN to continue"
  1533. Xread p1
  1534. Xclear
  1535. X
  1536. Xecho "First, we  will   introduce  guns  and   paratroops.  These  are"
  1537. Xecho "particularly  handy when you have  seas  that cannot be crossed,"
  1538. Xecho "and can  also be used  for commando attacks or to  break  supply"
  1539. Xecho "lines behind enemy lines.  Guns are aimed with the  mouse in the"
  1540. Xecho "game square from which you wish to shoot, and the  direction and"
  1541. Xecho "distance of your cursor click from the center of the game square"
  1542. Xecho "determines the azimuth and range of  the shot.  For  example, if"
  1543. Xecho "the mouse is in position A below,  i.e. just above  center, then"
  1544. Xecho "the shot will  fall  at short range to  the  north.   Position B"
  1545. Xecho "represents a long range shot to the north, and C, a medium range"
  1546. Xecho "shot to the south  east.  The shot is  triggered by striking the"
  1547. Xecho "'g'  key on the  keyboard (g for  'guns') while aiming  with the"
  1548. Xecho "mouse."
  1549. X
  1550. Xecho "              GAME SQUARE"
  1551. Xecho "       =============================="
  1552. Xecho "       ||             B             ||"
  1553. Xecho "       ||                           ||"
  1554. Xecho "       ||                           ||"
  1555. Xecho "       ||                           ||"
  1556. Xecho "       ||                           ||"
  1557. Xecho "       ||             A             ||"
  1558. Xecho "       ||                           ||"
  1559. Xecho "       ||            -|-            ||"
  1560. Xecho "       ||                           ||"
  1561. Xecho "       ||                           ||"
  1562. Xecho "       ||                           ||"
  1563. Xecho "       ||                           ||"
  1564. Xecho "       ||                   C       ||"
  1565. Xecho "       ||                           ||"
  1566. Xecho "       ||                           ||"
  1567. Xecho "       ||                           ||"
  1568. Xecho "       =============================="
  1569. X
  1570. Xecho "hit RETURN to continue"
  1571. Xread p1
  1572. Xclear
  1573. X
  1574. Xecho "Paratroops  are  launched in exactly  the same way,  except this"
  1575. Xecho "time you use  the 'p' key  (p for paratroops).  Every shot costs"
  1576. Xecho "one troop, and will kill  one troop in  the enemy square,  while"
  1577. Xecho "every paratroop  costs  3  troops from  the  source  square, and"
  1578. Xecho "arrives in the enemy square as a normal troop.  Be  careful with"
  1579. Xecho "the  guns, because they  can kill  your troops  as  well  as the"
  1580. Xecho "enemy's.   Guns  and  paratroops  are  called   with the command"
  1581. Xecho "options '-guns' and '-para', each with an argument that controls"
  1582. Xecho "the maximum range (in game squares).  For  example, try  out the"
  1583. Xecho "following game."
  1584. X
  1585. Xecho
  1586. Xecho "> xbattle -black me -white you -board 10 -square 64 -militia 5  -rbases 1 -guns 5 -para 5"
  1587. Xecho
  1588. X
  1589. Xecho
  1590. Xecho "hit RETURN to start the game"
  1591. Xread p1
  1592. X
  1593. Xxbattle -black me -white you -board 10 -square 64 -militia 5  -rbases 1  -guns 5 -para 5 &
  1594. X
  1595. Xecho
  1596. Xecho "hit RETURN to continue after game"
  1597. Xread p1
  1598. Xclear
  1599. X
  1600. Xecho "Another set of options allow you to build and destroy the supply"
  1601. Xecho "bases.  The option '-build <n>' lets you  build them by pointing"
  1602. Xecho "to a game square which is completely full of troops and pressing"
  1603. Xecho "the 'b' key (b for build).  This operation will cost you all the"
  1604. Xecho "troops in  the square, and  will only build  a partial base- the"
  1605. Xecho "operation will have to be repeated a number of times  before the"
  1606. Xecho "base is complete and can go into production.   The total cost of"
  1607. Xecho "building a base is <n> full troop squares.  "
  1608. X
  1609. Xecho
  1610. X
  1611. Xecho "Bases can be scuttled (destroyed) with the '-scuttle' option (no"
  1612. Xecho "argument) by  again positioning   the  cursor on the    base and"
  1613. Xecho "pressing the 's' key  (s for  scuttle).  Again, you will have to"
  1614. Xecho "have some troops in the square,  and it may take several scuttle"
  1615. Xecho "operations  to completely  destroy it, but  each operation costs"
  1616. Xecho "only a single  troop,  and  is thus  much cheaper  than building"
  1617. Xecho "them.  A base can be scuttled to  prevent it falling  into enemy"
  1618. Xecho "hands."
  1619. X
  1620. Xecho
  1621. X
  1622. Xecho "Try building and scuttling a few bases in the next example.  Try"
  1623. Xecho "doing a partial scuttle and then rebuilding again."
  1624. Xecho
  1625. Xecho "> xbattle -black me -white you -board 10 -square 64 -hex -militia 5  -rbases 1  -build 4 -scuttle"
  1626. X
  1627. X
  1628. Xecho
  1629. Xecho "hit RETURN to start the game"
  1630. Xread p1
  1631. X
  1632. Xxbattle -black me -white you -board 10 -square 64 -hex -militia 5  -rbases 1  -build 4 -scuttle &
  1633. X
  1634. Xecho
  1635. Xecho "hit RETURN to continue after game"
  1636. Xread p1
  1637. Xclear
  1638. X
  1639. Xecho "Another way you can modify the game board during the  game is to"
  1640. Xecho "fill or  dig, to raise  or lower the  elevation.  When used with"
  1641. Xecho "'-sea', digging  creates a new square  of sea, while filling can"
  1642. Xecho "fill one in.  Each operation costs  <n>  full troop squares, and"
  1643. Xecho "is performed by putting  the cursor in  that square  and hitting"
  1644. Xecho "'d' to dig.  To fill  in a sea, the troops  cannot march into it"
  1645. Xecho "first,  so you must  do the next  best  thing- march your troops"
  1646. Xecho "next to  the sea  and then command  them to  march into  it   by"
  1647. Xecho "clicking a command vector to point to the sea,  then hit the 'f'"
  1648. Xecho "key to fill  in.  The arguments for dig  and fill  must have the"
  1649. Xecho "same value."
  1650. Xecho
  1651. Xecho "Try digging and filling a few seas in the next example.  "
  1652. Xecho
  1653. X
  1654. Xecho "> xbattle -black me -white you -board 10 -square 64 -militia 5  -rbases 1  -sea 2 -dig 4 -fill 4"
  1655. X
  1656. Xecho
  1657. Xecho "hit RETURN to start the game"
  1658. Xread p1
  1659. X
  1660. Xxbattle -black me -white you -board 10 -square 64 -militia 5  -rbases 1  -sea 2 -dig 4 -fill 4 &
  1661. X
  1662. Xecho
  1663. Xecho "hit RETURN to continue after game"
  1664. Xread p1
  1665. Xclear
  1666. X
  1667. Xecho "When used with the '-hills' option, the  digging and filling can"
  1668. Xecho "be used to  lower  or raise the   elevation to  create defensive"
  1669. Xecho "fortifications.  In this  case, each  dig or fill costs only one"
  1670. Xecho "full  troop square regardless of  the  value you  supply for the"
  1671. Xecho "arguments -dig  and   -fill.   You must supply  dummy  arguments"
  1672. Xecho "nevertheless.  Try this out in the next example."
  1673. Xecho
  1674. Xecho "> xbattle -black me -white you -board 10 -square 64 -militia 5  -rbases 1  -hills 9 -dig 5 -fill 5 &"
  1675. X
  1676. X
  1677. Xecho
  1678. Xecho "hit RETURN to start the game"
  1679. Xread p1
  1680. X
  1681. Xxbattle -black me -white you -board 10 -square 64 -militia 5  -rbases 1  -hills 9 -dig 2 -fill 2 &
  1682. X
  1683. Xecho
  1684. Xecho "hit RETURN to continue after game"
  1685. Xread p1
  1686. Xclear
  1687. X
  1688. Xecho "You can bias a game to favor a player with less experience.  Not"
  1689. Xecho "all xbattle parameters can be biased, but a good many can.  Here"
  1690. Xecho "is an example."
  1691. Xecho
  1692. Xecho "> xbattle -options tribal.xbo -black { -fight 9 -move 9 } me -white me -board 10 -manpos"
  1693. Xecho
  1694. X
  1695. Xecho "In this example the arguments  in the {braces}  between '-black'"
  1696. Xecho "and 'me' apply only to black, not  to white.  In this  case, the"
  1697. Xecho "black troops will move quickly  and have an  increased  fighting"
  1698. Xecho "strength compared to white, who  has the default values of these"
  1699. Xecho "parameters.  Note the spaces on either side  of the '{' and '}'."
  1700. Xecho "Xbattle  options  are evaluated  sequentially,   therefore later"
  1701. Xecho "options can overwrite   earlier options. If you wished  to set a"
  1702. Xecho "default '-fight  3' for  all players except  black,  this option"
  1703. Xecho "would have to be placed first in  the sequence in order to avoid"
  1704. Xecho "overwriting the  biased  options set   for black.  Try   out the"
  1705. Xecho "difference between these fight and move settings."
  1706. X
  1707. Xecho
  1708. Xecho "hit RETURN to start the game"
  1709. Xread p1
  1710. X
  1711. Xxbattle -options tribal.xbo -black { -fight 9 -move 9 } me -white me -board 10  -manpos&
  1712. X
  1713. Xecho
  1714. Xecho "hit RETURN to continue after game"
  1715. Xread p1
  1716. Xclear
  1717. X
  1718. Xecho "Another  interesting dynamic parameter  called '-digin' dictates"
  1719. Xecho "that  troops moving through open  country  move faster than when"
  1720. Xecho "they  have to 'trip  over'  each other.  With this parameter, it"
  1721. Xecho "takes  time for your troops  to 'dig in' at the  front; the more"
  1722. Xecho "troops there are  in a square, the  slower the new  troops enter"
  1723. Xecho "that square, rather like  the charging  of a capacitor.  Another"
  1724. Xecho "option called 'hidden' makes the troop command vectors invisible"
  1725. Xecho "to the   enemy, so that   the enemy  can only see    your  troop"
  1726. Xecho "deployment, not  your marching   orders.  Another option  called"
  1727. Xecho "'disrupt' will cause  your  troops to forget all  their marching"
  1728. Xecho "orders as soon  as they are   under attack.  This will  make you"
  1729. Xecho "have to  repeat your orders to them  when they panic in the heat"
  1730. Xecho "of  battle.  These options  can all be biased,  as shown in  the"
  1731. Xecho "next example.  Note that in  this case,  all three options serve"
  1732. Xecho "to hinder black; his  troop convoys are  sluggish, he cannot see"
  1733. Xecho "white's command vectors, and his supply lines can be cut  with a"
  1734. Xecho "single momentary attack by white."
  1735. Xecho
  1736. Xecho "> xbattle -options tribal.xbo -black { -digin 9 -hidden } me -white { -disrupt } me -board 10  -manpos&"
  1737. X
  1738. Xecho
  1739. Xecho "hit RETURN to start the game"
  1740. Xread p1
  1741. X
  1742. Xxbattle -options tribal.xbo -black { -digin 9 -hidden } me -white { -disrupt } me -board 10  -manpos&
  1743. X
  1744. Xecho
  1745. Xecho "hit RETURN to continue after game"
  1746. Xread p1
  1747. Xclear
  1748. X
  1749. Xecho "There are a few alternative  ways  to command groups of your men"
  1750. Xecho "to  march  simultaneously.   One is   controlled  by the  option"
  1751. Xecho "'-march <n>'  whereby you  command your troops to start marching"
  1752. Xecho "in a particular direction and continue until told  to stop.  The"
  1753. Xecho "speed  is set  with the  argument <n>.  To  march  your  troops,"
  1754. Xecho "position your mouse and hold down the shift key as you click.  A"
  1755. Xecho "march command is displayed as a  double command vector, and such"
  1756. Xecho "commands can be  set up on  empty  game  squares  to steer  your"
  1757. Xecho "troops in more complex paths.  The  stop command can also be set"
  1758. Xecho "by clicking in the center  of the square,  and is displayed as a"
  1759. Xecho "small box.  If  the march is commenced  with  a shift-leftmouse,"
  1760. Xecho "the troops will split if they cross another supply line, whereas"
  1761. Xecho "when set with  the  middle mouse, they  will cross  over   other"
  1762. Xecho "supply lines.  Try out the march option in the following game."
  1763. Xecho
  1764. Xecho "> xbattle -black me -militia 3 -march 5"
  1765. Xecho
  1766. Xecho "hit RETURN to start the game"
  1767. Xread p1
  1768. X
  1769. Xxbattle -black me -militia 3 -march 5&
  1770. X
  1771. Xecho
  1772. Xecho "hit RETURN to continue after game"
  1773. Xread p1
  1774. Xclear
  1775. X
  1776. Xecho "Another  way to give  group commands to your troops  is with the"
  1777. Xecho "'bound'  option.  When this option  is active, you can  give the"
  1778. Xecho "same movement command   to  all  the troops  within  a  bounding"
  1779. Xecho "rectangle defined as follows.  Click the  mouse, for instance to"
  1780. Xecho "'march east' in a particular square, but hold the mouse down and"
  1781. Xecho "drag it diagonally across other gamesquares to the square at the"
  1782. Xecho "opposite corner of the  bounding rectangle before  releasing the"
  1783. Xecho "button.   All the troops within  the    rectangle will obey  the"
  1784. Xecho "command.  Try this option in the following game."
  1785. Xecho
  1786. Xecho "> xbattle -black me -militia 3 -bound"
  1787. Xecho
  1788. Xecho "hit RETURN to start the game"
  1789. Xread p1
  1790. X
  1791. Xxbattle -black me -militia 3 -bound&
  1792. X
  1793. Xecho
  1794. Xecho "hit RETURN to continue after game"
  1795. Xread p1
  1796. Xclear
  1797. X
  1798. Xecho "If  you have  played an interesting game  you may wish to review"
  1799. Xecho "the action afterwards to learn from your  mistakes.  This can be"
  1800. Xecho "done with the '-store' option, which  will save all the graphics"
  1801. Xecho "commands to a file.  The file can  be reviewed with  the -replay"
  1802. Xecho "option.  The stored  file can be  enormous, especially for  long"
  1803. Xecho "games on a  large  board, so   be careful.   If your    quota is"
  1804. Xecho "exceeded during the game,  xbattle will quietly stop  writing to"
  1805. Xecho "the store file,  but the game will  continue uninterrupted.  You"
  1806. Xecho "will just miss the tail end of the battle on the replay."
  1807. Xecho
  1808. Xecho "We will  try to store a game  in the next  example-   move  your"
  1809. Xecho "armies around the board in interesting formations, and then exit"
  1810. Xecho "the game as usual.  Then we will watch the replay."
  1811. Xecho
  1812. Xecho "> xbattle -black me -white you -board 10 -farms 5 -militia 5 -store xbattle.xba"
  1813. Xecho
  1814. X
  1815. Xecho
  1816. Xecho "hit RETURN to start the game"
  1817. Xread p1
  1818. X
  1819. X
  1820. Xxbattle -black me -white you -board 13 -farms 5 -militia 5 -store xbattle.xba&
  1821. X
  1822. Xecho
  1823. Xecho "hit RETURN to continue after game"
  1824. Xread p1
  1825. Xclear
  1826. X
  1827. Xecho "To replay the game, all you have to  do is  give a display name,"
  1828. Xecho "the other options will not be needed.  To flag the  display name"
  1829. Xecho "you will have to give a dummy team color,  for example '-black',"
  1830. Xecho "although this  argument will  actually be  ignored, so you could"
  1831. Xecho "just as well have used '-white', or '-red' for that matter.  You"
  1832. Xecho "must however give the display name on which the  replay is to be"
  1833. Xecho "viewed."
  1834. X
  1835. Xecho
  1836. X
  1837. Xecho "The replay file stores none of the actual game  parameters, only"
  1838. Xecho "the  graphics commands,  and  in  replay mode xbattle   does not"
  1839. Xecho "respond to any of the normal commands, it is  even impossible to"
  1840. Xecho "quit from the replay after it is done (sorry- we have not gotten"
  1841. Xecho "around to  that yet)  so you will have to  kill the window  some"
  1842. Xecho "other way, or  just hide it  behind another  window for now.  We"
  1843. Xecho "will   use  the  '-manpos' option  so  you can place  the window"
  1844. Xecho "conveniently."
  1845. X
  1846. Xecho
  1847. Xecho "> xbattle -black me -manpos -replay xbattle.xba"
  1848. Xecho
  1849. X
  1850. Xecho
  1851. Xecho "hit RETURN to start the replay"
  1852. Xread p1
  1853. X
  1854. Xxbattle -black me -manpos -replay xbattle.xba&
  1855. X
  1856. Xecho
  1857. Xecho "hit RETURN to continue after game"
  1858. Xread p1
  1859. Xclear
  1860. X
  1861. Xecho "The replayed  game board  will  not respond to any commands, not"
  1862. Xecho "even the control-c exit key, so you will have to dispose of it's"
  1863. Xecho "xwindow by other means (such as a  kill  window command, or kill"
  1864. Xecho "the process)."
  1865. Xecho
  1866. Xecho "We  will  now  delete  the  saved file  to conserve  disk space."
  1867. Xecho "Remember to do this, since these files can be very big.  On unix"
  1868. Xecho "systems it is convenient to save your games to /tmp/xbattle.xba,"
  1869. Xecho "the system temporary directory."
  1870. X
  1871. Xecho
  1872. Xecho "> rm xbattle.xba"
  1873. Xecho
  1874. X
  1875. Xrm xbattle.xba
  1876. X
  1877. Xecho
  1878. Xecho "It is also possible to save the state  of  the game at any point"
  1879. Xecho "during the combat, and to continue the game from that point some"
  1880. Xecho "time in the future.  This is done by pressing 'control-p' in the"
  1881. Xecho "text  area      during   the game.    The  game  will   continue"
  1882. Xecho "uninterrupted, and the  only  acknowledgement  you will see is a"
  1883. Xecho "print out of some game  statistics on the  window where the game"
  1884. Xecho "was started.  Later we will show you how to resume the game."
  1885. X
  1886. Xecho
  1887. X
  1888. Xecho "In the  next example, do some  moves,  then press 'control-p' in"
  1889. Xecho "the text area, then do  some more moves  and then exit normally."
  1890. Xecho "You will see that when we load the game state file the game will"
  1891. Xecho "resume from the point where you pressed the control-p."
  1892. X
  1893. Xecho
  1894. Xecho "> xbattle -black me -white you -board 10 -farms 5 -militia 5"
  1895. Xecho
  1896. X
  1897. Xecho
  1898. Xecho "hit RETURN to start the game"
  1899. Xread p1
  1900. X
  1901. Xxbattle -black me -white you -board 10 -farms 5 -militia 5
  1902. X
  1903. Xecho
  1904. Xecho "hit RETURN to continue after game"
  1905. Xread p1
  1906. Xclear
  1907. X
  1908. Xecho "Now, we will resume the game from the point where  you saved it."
  1909. Xecho "by using  the '-load' option.  This  option sets several options"
  1910. Xecho "automatically from the file, but  must have other options set in"
  1911. Xecho "the  command  line to   match  the original  parameters that the"
  1912. Xecho "original  game used.   Read the  manual very   carefully on this"
  1913. Xecho "subject, as  it gets  quite complicated.  In future  releases of"
  1914. Xecho "xbattle we will probably have cleaned this up somewhat."
  1915. X
  1916. Xecho
  1917. Xecho "> xbattle -black me -white you -board 10 -load"
  1918. X
  1919. Xecho
  1920. Xecho "hit RETURN to start the replay"
  1921. Xread p1
  1922. X
  1923. Xxbattle -black me -white you -board 10 -load&
  1924. X
  1925. Xecho
  1926. Xecho "hit RETURN to continue after the resumed game"
  1927. Xread p1
  1928. Xclear
  1929. X
  1930. Xecho "It  is possible  to  edit the  stored file  and  to change  many"
  1931. Xecho "features of the terrain,  or to set  up new armies, and create a"
  1932. Xecho "whole battle scenario in advance.  This is done with the command"
  1933. Xecho "option '-edit', which completely redefines the xbattle controls,"
  1934. Xecho "and disables all normal playing.  When editing an existing file,"
  1935. Xecho "you must be very careful to call exactly  the same options as in"
  1936. Xecho "the original file- number of teams and team colors, hills, seas,"
  1937. Xecho "board size, square size, etc. otherwise  unexpected things might"
  1938. Xecho "happen.  The edit feature is brand new, and still has a few bugs"
  1939. Xecho "in it.  Let  us therefore edit a completely  new file, and allow"
  1940. Xecho "for hills, seas, and two armies.  "
  1941. X
  1942. Xecho
  1943. X
  1944. Xecho "When you start this game, place the window to  the  side so that"
  1945. Xecho "you  will be  able to see  the  menu that  describes the editing"
  1946. Xecho "commands.  Try them out, and  remember to finish with 'd'  (dump"
  1947. Xecho "to file) and 'e' (exit).  Afterwards,  we will play  on your new"
  1948. Xecho "terrain map."
  1949. X
  1950. Xecho
  1951. Xecho "> xbattle -edit -manpos -black me -white you -board 10 -hills 5 -sea 5"
  1952. Xecho
  1953. Xecho "hit RETURN to start the editing"
  1954. Xread p1
  1955. X
  1956. Xxbattle -edit -manpos -black me -white you -board 10 -hills 5 -sea 5&
  1957. X
  1958. Xecho "EDIT MODE COMMANDS"
  1959. Xecho "=================="
  1960. Xecho
  1961. Xecho "      left button:     lower terrain by one notch (sea lowest)"
  1962. Xecho "      middle button:   raise  terrain  by  one  notch  (sea lowest)"
  1963. Xecho "      right button:    toggle between lowest and mid terrain"
  1964. Xecho ""
  1965. Xecho "      c:    create city (growth = 100)"
  1966. Xecho "      t:    create town (growth = 80)"
  1967. Xecho "      v:    create village (growth = 60)"
  1968. Xecho "      k:    increase size of city by 5 percent"
  1969. Xecho "      j:    decrease size of city by 5 percent"
  1970. Xecho "      s:   scuttle city - remove 36 degrees of arc"
  1971. Xecho "      b:    build city - add 36 degrees of arc"
  1972. Xecho ""
  1973. Xecho "      0-9:  create troop square with troops of current color"
  1974. Xecho "      [:    decrease troop amount by 1"
  1975. Xecho "      ]:    increase troop amount by 1"
  1976. Xecho "      r:    change current color"
  1977. Xecho "      f:    change color of existent troop square"
  1978. Xecho "      d:    dump board with name <filename>"
  1979. Xecho "      l:    load board with name <filename>"
  1980. Xecho "      e:    exit"
  1981. Xecho ""
  1982. Xecho " FINISH EDITING with 'd' (dump) followed by 'e' (exit)"
  1983. Xecho
  1984. Xecho "hit RETURN after editing"
  1985. Xread p1
  1986. Xclear
  1987. X
  1988. Xecho "And now we will play on the game board you just created by using"
  1989. Xecho "the    '-load'   option.    This   looks for   the  file  called"
  1990. Xecho "'xbattle.xbt', unless it is given another filename."
  1991. X
  1992. Xecho
  1993. Xecho ">  xbattle -load -black me -white you  -board 10 -hills 5 -sea 5"
  1994. X
  1995. Xecho
  1996. Xecho "hit RETURN to start the game"
  1997. Xread p1
  1998. X
  1999. Xxbattle -load -black me -white you  -board 10 -hills 5 -sea 5&
  2000. X
  2001. Xecho
  2002. Xecho "hit RETURN to continue after game"
  2003. Xread p1
  2004. Xclear
  2005. X
  2006. Xecho "You have  now been introduced to  just about all of  the options"
  2007. Xecho "available  in xbattle.  We have  skipped over  some  of the more"
  2008. Xecho "obscure variations of the horizon option (map, basemap, localmap"
  2009. Xecho "etc.) but you can read about these  in  the man page  if you are"
  2010. Xecho "interested. Also in the man page is a description of a number of"
  2011. Xecho "different compile-time options sent  in  by xbattlers around the"
  2012. Xecho "world, including different  mouse button definitions,  different"
  2013. Xecho "text lines, different command vectors, and so forth.  Finally, I"
  2014. Xecho "encourage  you to try  'skirmish.xbo', an options file used with"
  2015. Xecho "the   '-options'  argument.  This   creates  a  fast paced  game"
  2016. Xecho "employing a  good   many   of the   options  introduced  in this"
  2017. Xecho "tutorial.  Try your own variations, and above all,"
  2018. Xecho
  2019. Xecho "           Happy xbattling!"
  2020. X
  2021. Xecho "================= END OF XBATTLE TUTORIAL ==================="
  2022. END_OF_FILE
  2023. if test 19904 -ne `wc -c <'tutorial2'`; then
  2024.     echo shar: \"'tutorial2'\" unpacked with wrong size!
  2025. fi
  2026. chmod +x 'tutorial2'
  2027. # end of 'tutorial2'
  2028. fi
  2029. echo shar: End of archive 6 \(of 7\).
  2030. cp /dev/null ark6isdone
  2031. MISSING=""
  2032. for I in 1 2 3 4 5 6 7 ; do
  2033.     if test ! -f ark${I}isdone ; then
  2034.     MISSING="${MISSING} ${I}"
  2035.     fi
  2036. done
  2037. if test "${MISSING}" = "" ; then
  2038.     echo You have unpacked all 7 archives.
  2039.     rm -f ark[1-9]isdone
  2040. else
  2041.     echo You still need to unpack the following archives:
  2042.     echo "        " ${MISSING}
  2043. fi
  2044. ##  End of shell archive.
  2045. exit 0
  2046.