home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume14 / xbattle / part01 < prev    next >
Encoding:
Internet Message Format  |  1993-01-26  |  54.9 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: v14i072:  xbattle - multi-player battle strategy game for X-Windows, Part01/07
  5. Message-ID: <3511@master.CNA.TEK.COM>
  6. Date: 7 Sep 92 21:22:36 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1777
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: slehar@cns.bu.edu
  12. Posting-number: Volume 14, Issue 72
  13. Archive-name: xbattle/Part01
  14. Environment: Xlib
  15.  
  16. [From the author:
  17. This  is the latest  version  of xbattle,  a  multi-player  concurrent
  18. battle strategy game  in    xwindows.  Each player gets   a  gameboard
  19. consisting of a grid of squares, some of which contain smaller colored
  20. squares   representing   troops.   Players   command    their   troops
  21. simultaneously using mouse clicks,  to occupy territory  and eliminate
  22. enemy forces.]
  23.  
  24. #! /bin/sh
  25. # This is a shell archive.  Remove anything before this line, then unpack
  26. # it by saving it into a file and typing "sh file".  To overwrite existing
  27. # files, type "sh file -c".  You can also feed this as standard input via
  28. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  29. # will see the following message at the end:
  30. #        "End of archive 1 (of 7)."
  31. # Contents:  README MANIFEST Imakefile default.xbo skirmish.xbo
  32. #   update.c
  33. # Wrapped by billr@saab on Mon Sep  7 14:18:49 1992
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. if test -f 'README' -a "${1}" != "-c" ; then 
  36.   echo shar: Will not clobber existing file \"'README'\"
  37. else
  38. echo shar: Extracting \"'README'\" \(10048 characters\)
  39. sed "s/^X//" >'README' <<'END_OF_FILE'
  40. Xxbattle     concurrent multi-player battle strategy game
  41. X
  42. X        Steve Lehar  (slehar@cns.bu.edu)
  43. X        Greg  Lesher (lesher@cns.bu.edu)
  44. X
  45. XDESCRIPTION
  46. X
  47. X  This is  version  4.0 of  xbattle, by    Greg Lesher,   based on the
  48. X  original  by Steve  Lehar  released  in  1991  and including certain
  49. X  enhancements, modifications and bug  fixes suggested  by a number of
  50. X  contributers from all over the world.  The  new changes are outlined
  51. X  below.   The  latest  version  can  be obtained  by anonymous ftp to
  52. X  park.bu.edu (cd pub/xbattle) in both shar and tar.Z formats.
  53. X
  54. X  xbattle  is  a  concurrent  multi-player battle strategy   game that
  55. X  captures the dynamics of a wide range  of military scenarios.  It is
  56. X  based on X windows, which you must have installed to  run this game.
  57. X  Players  play  from separate  displays,   and commands are  executed
  58. X  concurrently, i.e.  the players do  not take "turns", they all issue
  59. X  their commands simultaneously.  There can be  any number of players,
  60. X  and each player is assigned to a color team (or black,  white & gray
  61. X  for  monochrome monitors).  The  game  board is a matrix of  squares
  62. X  that can be occupied by  colored troops, and the aim  of the game is
  63. X  to eliminate the enemy from the board by  attacking squares occupied
  64. X  enemy troops.
  65. X
  66. X  To get  the feel  of the  game, you can   run  the tutorials (called
  67. X  "tutorial1" and "tutorial2") that are supplied with the game.  These
  68. X  are shell scripts that run on unix systems and start up  a series of
  69. X  small  example games that  you can play   around  with  to learn the
  70. X  various options available with the game.  If  you are  not on a unix
  71. X  system, print out  the  tutorials and type  in the  command lines by
  72. X  hand. If you  are interested in  the philosophical and   game design
  73. X  issues of  xbattle,  or want to  get immediate  notice of the latest
  74. X  changes     bugs,     and    bug     fixes,  send      email      to
  75. X  xbattle_request@park.bu.edu and  we   will  put you  on  the xbattle
  76. X  mailing list.
  77. X
  78. XINSTALLATION
  79. X
  80. X  After unpacking  the shell archives, create  a  makefile  using  the
  81. X  command "xmkmf", then compile using the command "make".
  82. X
  83. X
  84. XDIFFERENCES BETWEEN VERSION VERSION 3.2 AND VERSION 4.0
  85. X
  86. X  Added option  "-hex" whereby  the  game board  comes  up as hexagons
  87. X  instead of squares.  This makes for a more interesting geometry, but
  88. X  slows the game down noticably.  Also, this option will not work with
  89. X  the combination of "-horizon" AND "-wrap", among other restrictions.
  90. X
  91. X  Changed the options "-fill <n>" and "-dig <n>"  to take command line
  92. X  arguments.   These options allow you  to modify the terrain, raising
  93. X  or lowering hill elevations, or digging  and filling seas.  With the
  94. X  new arguments, it costs  <n>  full troopsquares to completely dig or
  95. X  fill a  sea.  A partially filled sea  is displayed  as  a sea square
  96. X  with a square  island in the middle  whose size proportional  to the
  97. X  number of fills left.  The  argument for  "-dig" and "-fill" must be
  98. X  the same value, otherwise  the last argument supplied is  applied to
  99. X  both, i.e.  the first is ignored.
  100. X
  101. X  Added option "-attack" whereby hitting 'a' when pointing to an enemy
  102. X  square causes all your adjacent squares to attack that square.  This
  103. X  helps synchronize simultaneous attacks.
  104. X
  105. X  Added option "-area" whereby the troop strength is represented by a
  106. X  troop square whose area is proportional to the strength, rather than
  107. X  the length of the side, which is the default.
  108. X
  109. X  Established new  default  that  grid appears automatically; replaced
  110. X  "-grid" option with "-nogrid" option if you require no grid.
  111. X
  112. X  Changed the names of gray1 and gray3 to light and dark, representing
  113. X  light and dark shades  of gray.  (Gray2,  the "stealth" color  still
  114. X  exists, but is not documented).
  115. X
  116. X  Added a new feature- xbattle now  prints out  the random number seed
  117. X  used in a particular game, to  make it easier to  reproduce the same
  118. X  game again using the parameter "-seed <n>".
  119. X
  120. X  Added a new command key 'z' which cancels  all command vectors, like
  121. X  clicking in the  center of  the  gamesquare.  This  is  particularly
  122. X  useful with the new hex option.
  123. X
  124. X  Allow fractional speed settings like "-speed  0.5".  Very slow games
  125. X  favor new players, and  make for a more  chess-like game of strategy
  126. X  and planning rather than an arcade style shoot-em-up.
  127. X
  128. X  Defined  default   board and   square  sizes more   appropriate  for
  129. X  beginners (big squares, small boards).
  130. X
  131. X  Changed the RGB color definitions for Cyan, Yellow and Green to more
  132. X  pleasing combinations, although they  are no  longer the true colors
  133. X  of those names.
  134. X
  135. X  Added compile time option MULTIFLUSH (default FALSE) whereby command
  136. X  vectors are displayed immediately  after the command  is clicked, to
  137. X  give the user  immediate confirmation of  the command.  This feature
  138. X  noticably slows the game however.
  139. X
  140. X  Bug fix: Previously when  playing with  colored armies on monochrome
  141. X  monitor  (for example color  "-red"  which appears as  black  with a
  142. X  letter "R") the team color displayed  on the  xbattle window was the
  143. X  monochrome color (or black, in  this example) instead  of the actual
  144. X  color (or red).  This has now been fixed.
  145. X
  146. X  Bug   fix: Fixed  marching  bug which  accidentally enabled bounding
  147. X  movement window.
  148. X
  149. X  Bug fix: Fixed movement bug which shortchanged fractional moves < 1.
  150. X
  151. X
  152. XCOPYRIGHT
  153. X
  154. X  Copied   from the GNU Emacs  'copyleft'  policy.  Basically, you are
  155. X  free to copy, modify and distribute this  program as long as  you do
  156. X  not sell it or use it in a product that you sell.
  157. X
  158. X              COPYING POLICIES
  159. X
  160. X  1. You may copy and  distribute  verbatim  copies of  xbattle source
  161. Xcode as you receive it, in any medium, provided that you conspicuously
  162. Xand  appropriately publish   on  each copy  a   valid copyright notice
  163. X"Copyright (C)    1991 Steve  Lehar"   (or   with  whatever   year  is
  164. Xappropriate); keep intact the notices on all  files that refer to this
  165. XLicense Agreement  and to the  absence of  any warranty;  and give any
  166. Xother recipients  of  the xbattle program   a  copy of  this   License
  167. XAgreement along with  the program.   You may charge a distribution fee
  168. Xfor the physical act of transferring a copy.
  169. X
  170. X  2. You may modify your copy or copies of xbattle source  code or any
  171. Xportion of it,  and copy and distribute  such  modifications under the
  172. Xterms of Paragraph 1 above, provided that you also do the following:
  173. X
  174. X    a) cause the modified files to carry prominent notices stating
  175. X    that you changed the files and the date of any change; and
  176. X
  177. X    b) cause the whole of any work that you distribute or publish,
  178. X    that in whole or in part contains or is a derivative of xbattle
  179. X    or any part thereof, to be licensed at no charge to all third
  180. X    parties on terms identical to those contained in this License
  181. X    Agreement (except that you may choose to grant more extensive
  182. X    warranty protection to some or all third parties, at your option).
  183. X
  184. X    c) You may charge a distribution fee for the physical act of
  185. X    transferring a copy, and you may at your option offer warranty
  186. X    protection in exchange for a fee.
  187. X
  188. XMere aggregation of another unrelated program with this program (or its
  189. Xderivative) on a volume of a storage or distribution medium does not bring
  190. Xthe other program under the scope of these terms.
  191. X
  192. X  3. You may copy and distribute xbattle (or a portion or derivative of it,
  193. Xunder Paragraph 2) in object code or executable form under the terms of
  194. XParagraphs 1 and 2 above provided that you also do one of the following:
  195. X
  196. X    a) accompany it with the complete corresponding machine-readable
  197. X    source code, which must be distributed under the terms of
  198. X    Paragraphs 1 and 2 above; or,
  199. X
  200. X    b) accompany it with a written offer, valid for at least three
  201. X    years, to give any third party free (except for a nominal
  202. X    shipping charge) a complete machine-readable copy of the
  203. X    corresponding source code, to be distributed under the terms of
  204. X    Paragraphs 1 and 2 above; or,
  205. X
  206. X    c) accompany it with the information you received as to where the
  207. X    corresponding source code may be obtained.  (This alternative is
  208. X    allowed only for noncommercial distribution and only if you
  209. X    received the program in object code or executable form alone.)
  210. X
  211. XFor an executable file, complete source code means all the source code for
  212. Xall modules it contains; but, as a special exception, it need not include
  213. Xsource code for modules which are standard libraries that accompany the
  214. Xoperating system on which the executable file runs.
  215. X
  216. X  4. You may not copy, sublicense, distribute or transfer xbattle
  217. Xexcept as expressly provided under this License Agreement.  Any attempt
  218. Xotherwise to copy, sublicense, distribute or transfer xbattle is void and
  219. Xyour rights to use xbattle under this License agreement shall be
  220. Xautomatically terminated.  However, parties who have received computer
  221. Xsoftware programs from you with this License Agreement will not have
  222. Xtheir licenses terminated so long as such parties remain in full compliance.
  223. X
  224. X               NO WARRANTY
  225. X
  226. X  BECAUSE XBATTLE IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO
  227. XWARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  THE ENTIRE
  228. XRISK AS TO THE  QUALITY AND PERFORMANCE  OF THE PROGRAM IS  WITH  YOU.
  229. XSHOULD THE XBATTLE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
  230. XNECESSARY SERVICING, REPAIR OR CORRECTION.
  231. X
  232. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL STEVE LEHAR OR ANY
  233. XOTHER  PARTY  WHO MAY MODIFY AND   REDISTRIBUTE  XBATTLE  AS PERMITTED
  234. XABOVE, BE LIABLE TO YOU FOR DAMAGES,  INCLUDING ANY LOST PROFITS, LOST
  235. XMONIES, OR OTHER SPECIAL, INCIDENTAL  OR CONSEQUENTIAL DAMAGES ARISING
  236. XOUT OF THE USE OR INABILITY TO USE  (INCLUDING BUT NOT LIMITED TO LOSS
  237. XOF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD
  238. XPARTIES OR  A FAILURE  OF  THE  PROGRAM TO OPERATE  WITH  PROGRAMS NOT
  239. XDISTRIBUTED BY STEVE LEHAR) THE PROGRAM, EVEN IF YOU HAVE BEEN ADVISED
  240. XOF THE POSSIBILITY OF SUCH  DAMAGES, OR FOR  ANY CLAIM   BY ANY  OTHER
  241. XPARTY.
  242. X
  243. END_OF_FILE
  244. if test 10048 -ne `wc -c <'README'`; then
  245.     echo shar: \"'README'\" unpacked with wrong size!
  246. fi
  247. # end of 'README'
  248. fi
  249. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  250.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  251. else
  252. echo shar: Extracting \"'MANIFEST'\" \(672 characters\)
  253. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  254. X   File Name        Archive #    Description
  255. X-----------------------------------------------------------
  256. X Imakefile                  1    
  257. X MANIFEST                   1    This shipping list
  258. X README                     1    
  259. X default.xbo                1    
  260. X draw.c                     4    
  261. X extern.h                   4    
  262. X global.h                   5    
  263. X init.c                     5    
  264. X main.c                     2    
  265. X parse.c                    6    
  266. X patchlevel.h               2    
  267. X skirmish.xbo               1    
  268. X tribal.xbo                 2    
  269. X tutorial1                  7    
  270. X tutorial2                  6    
  271. X update.c                   1    
  272. X utils.c                    7    
  273. X xbattle.man                3    
  274. END_OF_FILE
  275. if test 672 -ne `wc -c <'MANIFEST'`; then
  276.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  277. fi
  278. # end of 'MANIFEST'
  279. fi
  280. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  281.   echo shar: Will not clobber existing file \"'Imakefile'\"
  282. else
  283. echo shar: Extracting \"'Imakefile'\" \(254 characters\)
  284. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  285. X# @(#)Imakefile 10/1/91
  286. X# Imakefile - xbattle
  287. XLOCAL_LIBRARIES = $(XLIB)
  288. X  SYS_LIBRARIES = -lm
  289. X           SRCS = main.c init.c parse.c update.c utils.c draw.c
  290. X           OBJS = main.o init.o parse.o update.o utils.o draw.o
  291. X
  292. XComplexProgramTarget(xbattle)
  293. X
  294. END_OF_FILE
  295. if test 254 -ne `wc -c <'Imakefile'`; then
  296.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  297. fi
  298. # end of 'Imakefile'
  299. fi
  300. if test -f 'default.xbo' -a "${1}" != "-c" ; then 
  301.   echo shar: Will not clobber existing file \"'default.xbo'\"
  302. else
  303. echo shar: Extracting \"'default.xbo'\" \(31 characters\)
  304. sed "s/^X//" >'default.xbo' <<'END_OF_FILE'
  305. X-decay 2
  306. X-repeat
  307. X-area
  308. X-attack
  309. END_OF_FILE
  310. if test 31 -ne `wc -c <'default.xbo'`; then
  311.     echo shar: \"'default.xbo'\" unpacked with wrong size!
  312. fi
  313. # end of 'default.xbo'
  314. fi
  315. if test -f 'skirmish.xbo' -a "${1}" != "-c" ; then 
  316.   echo shar: Will not clobber existing file \"'skirmish.xbo'\"
  317. else
  318. echo shar: Extracting \"'skirmish.xbo'\" \(138 characters\)
  319. sed "s/^X//" >'skirmish.xbo' <<'END_OF_FILE'
  320. X-guns 5
  321. X-para 5
  322. X-horizon
  323. X-decay 2
  324. X-square 32
  325. X-board 24
  326. X-sea 8
  327. X-rbases 5
  328. X-fill 4
  329. X-dig 4
  330. X-scuttle
  331. X-build 8
  332. X-store
  333. X-reserve
  334. X-repeat
  335. X-march 4
  336. END_OF_FILE
  337. if test 138 -ne `wc -c <'skirmish.xbo'`; then
  338.     echo shar: \"'skirmish.xbo'\" unpacked with wrong size!
  339. fi
  340. # end of 'skirmish.xbo'
  341. fi
  342. if test -f 'update.c' -a "${1}" != "-c" ; then 
  343.   echo shar: Will not clobber existing file \"'update.c'\"
  344. else
  345. echo shar: Extracting \"'update.c'\" \(39423 characters\)
  346. sed "s/^X//" >'update.c' <<'END_OF_FILE'
  347. X#include <stdio.h>
  348. X  
  349. X/**** x include files ****/
  350. X#include <X11/Xlib.h>
  351. X#include <X11/Xutil.h>
  352. X#include <X11/Xatom.h>
  353. X#include <X11/keysym.h>
  354. X#include <X11/keysymdef.h>
  355. X
  356. X#include "extern.h"
  357. X
  358. X/*************************************************************************/
  359. X/**    update_board                            **/
  360. X/** Update all game board values based on the values encoded in the     **/
  361. X/** squares, and display any square that has changed.  The xtab[] and     **/
  362. X/** ytab[] arrays are shuffled randomly so that each square will be     **/
  363. X/** updated in a random order to remove update sequence artifacts.    **/
  364. X/**    Steve Lehar (slehar@park.bu.edu)                **/
  365. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  366. X/*************************************************************************/
  367. Xupdate_board(board)
  368. X  square_type *board;
  369. X{
  370. X  int i, j, k, l,
  371. X      disrupt,
  372. X      wrap,
  373. X      swapindex, tempindex,
  374. X      x1, y1, x2, y2;
  375. X  static int firstime=1,
  376. X             xtab[MAXBOARDSIZE],ytab[MAXBOARDSIZE];
  377. X  square_type *square, *square2;
  378. X  static unsigned int xrand=0;
  379. X  double thresh;
  380. X
  381. X#if PAUSE
  382. X  if (paused)
  383. X    return;
  384. X#endif
  385. X
  386. X  /*** initialize the tables first time ****/
  387. X  if (firstime)
  388. X  {
  389. X    firstime = 0;
  390. X    for (i=0; i<boardsizex; i++)
  391. X       xtab[i] = i;
  392. X    for (i=0; i<boardsizey; i++)
  393. X       ytab[i] = i;
  394. X
  395. X    /**** make all squares outdated ****/
  396. X    for (i=0; i<boardsizex; i++)
  397. X      for (j=0; j<boardsizey; j++)
  398. X      {
  399. X        outdated[i][j] = ALL;
  400. X        oldvalue[i][j] = -1;
  401. X      }
  402. X  }
  403. X
  404. X  /**** shuffle the tab tables ****/
  405. X  for (i=0; i<boardsizex; i++)
  406. X  {
  407. X    swapindex = (int)(drand48()*(double)(boardsizex));
  408. X    tempindex = xtab[i];
  409. X    xtab[i] = xtab[swapindex];
  410. X    xtab[swapindex] = tempindex;
  411. X  }
  412. X
  413. X  for (i=0; i<boardsizey; i++)
  414. X  {
  415. X    swapindex = (int)(drand48()*(double)(boardsizey));
  416. X    tempindex = ytab[i];
  417. X    ytab[i] = ytab[swapindex];
  418. X    ytab[swapindex] = tempindex;
  419. X  }
  420. X
  421. X  /**** update the board ****/
  422. X  for (i=0; i<boardsizex; i++)
  423. X  {
  424. X    for (j=0; j<boardsizey; j++)
  425. X    {
  426. X      x1 = xtab[i];
  427. X      y1 = ytab[j];
  428. X
  429. X      /**** grow ****/
  430. X      growsquare(SQUARE(board,x1,y1));
  431. X
  432. X      if (enable_decay)
  433. X        decaysquare(SQUARE(board,x1,y1));
  434. X
  435. X      /**** fight ****/
  436. X      if (SQUARE(board,x1,y1)->color == FIGHT)
  437. X    fight(board,SQUARE(board,x1,y1));
  438. X
  439. X      if (SQUARE(board,x1,y1)->color != FIGHT && SQUARE(board,x1,y1)->color != none)
  440. X      {
  441. X        disrupt = enable_disrupt[SQUARE(board,x1,y1)->color];
  442. X        wrap = enable_wrap[SQUARE(board,x1,y1)->color];
  443. X        if (SQUARE(board,x1,y1)->value[SQUARE(board,x1,y1)->color] > 0)
  444. X          SQUARE(board,x1,y1)->age = 0;
  445. X      }
  446. X      else
  447. X      {
  448. X        disrupt = FALSE;
  449. X        wrap = enable_anywrap;
  450. X        SQUARE(board,x1,y1)->age = 0;
  451. X      }
  452. X    
  453. X      /**** if move command is active ****/
  454. X      if (SQUARE(board,x1,y1)->move) 
  455. X      {
  456. X        if (SQUARE(board,x1,y1)->color!=FIGHT || !disrupt)
  457. X        {
  458. X          xrand = (xrand+1)%directions;
  459. X          for (k=0; k<directions; k++)
  460. X          {
  461. X            l = (k+xrand)%directions;
  462. X
  463. X        if (SQUARE(board,x1,y1)->dir[l])
  464. X            {
  465. X
  466. X              square2 = SQUARE(board,x1,y1)->connect[l];
  467. X
  468. X              if (enable_sea)
  469. X              {
  470. X                if (square2->value[none] > 0)
  471. X                  update_square(board,SQUARE(board,x1,y1),square2);
  472. X              }
  473. X              else
  474. X                update_square(board,SQUARE(board,x1,y1),square2);
  475. X            }
  476. X      }
  477. X        }
  478. X      }
  479. X    }
  480. X  }
  481. X
  482. X  /**** redraw all squares that have been changed ****/
  483. X
  484. X  for (i=0; i<boardsizex; i++)
  485. X  {
  486. X    for (j=0; j<boardsizey; j++)
  487. X    {
  488. X      x1 = xtab[i];
  489. X      y1 = ytab[j];
  490. X      square = SQUARE(board,x1,y1);
  491. X
  492. X      /**** outdate if change in value has occurred ****/
  493. X      if (square->color != FIGHT)
  494. X      {
  495. X        if (square->value[square->color] != oldvalue[x1][y1])
  496. X          outdated[x1][y1] = ALL;
  497. X
  498. X        square->age++;
  499. X
  500. X        if (enable_erode[square->color])
  501. X        {
  502. X          if (square->age > eroderate[square->color])
  503. X          {
  504. X            if (drand48() < ERODETHRESH)
  505. X            {
  506. X              for (k=0; k<directions; k++)
  507. X                square->dir[k] = 0;
  508. X              square->move = 0;
  509. X              square->age = 0;
  510. X              outdated[x1][y1] = ALL;
  511. X              if (square->value[square->color] == 0)
  512. X                square->color = none;
  513. X            }
  514. X          }
  515. X        }
  516. X      }
  517. X
  518. X      for (k=0;k<nplayers;k++)
  519. X      {
  520. X        if (!winopen[k])
  521. X          continue;
  522. X        if (outdated[x1][y1] == ALL || outdated[x1][y1] == colorarray[k])
  523. X        {
  524. X          if (visible(board,colorarray[k],x1,y1))
  525. X            drawsquare(xwindow[k],square,colorarray[k],squaresize[colorarray[k]]);
  526. X          else
  527. X            drawblank(xwindow[k], x1, y1, square->value[none], square->seen[colorarray[k]],
  528. X                          square->growth, colorarray[k], squaresize[colorarray[k]], square);
  529. X        }
  530. X      }
  531. X
  532. X      /**** make indated ****/
  533. X      if (outdated[x1][y1] >= 0)
  534. X      {
  535. X        if (enable_storage)
  536. X          storedrawsquare(square, squaresize[0], FALSE);
  537. X        outdated[x1][y1] = OK;
  538. X      }
  539. X
  540. X      /**** set old values ****/
  541. X      if (square->color != FIGHT)
  542. X        oldvalue[x1][y1] = square->value[square->color];
  543. X      else
  544. X        oldvalue[x1][y1] = -1;
  545. X    }
  546. X  }
  547. X
  548. X  if (enable_march)
  549. X    drawmarch(board);
  550. X}
  551. X
  552. X
  553. X/*************************************************************************/
  554. X/**    update_square                            **/
  555. X/** update the square with a move command, and the  destination square    **/
  556. X/** into   which  it is  moving by  decrementing  the square value and    **/
  557. X/** incrementing the destination    square value.   The influences  of    **/
  558. X/** hills and forests are also accounted for.                **/
  559. X/**    Steve Lehar (slehar@park.bu.edu)                **/
  560. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  561. X/*************************************************************************/
  562. Xupdate_square(board,square1,square2)
  563. X  square_type *board,*square1,*square2;
  564. X{
  565. X  int i,
  566. X      side,
  567. X      disrupt,
  568. X      color1,color2,
  569. X      surplus,
  570. X      nmove;
  571. X  double slope,
  572. X         hinder,
  573. X         shunt,
  574. X         doublenmove;
  575. X
  576. X  /**** get color ****/
  577. X  color1 = square1->color;
  578. X  color2 = square2->color;
  579. X
  580. X  if (color1 == FIGHT)
  581. X    disrupt = enable_disrupt[0];
  582. X  else
  583. X    disrupt = enable_disrupt[color1];
  584. X
  585. X  if (color1 == FIGHT && !disrupt)
  586. X  {
  587. X    if (color2 == none || color2 == square1->oldcolor)
  588. X      color1 = square1->oldcolor;
  589. X  }
  590. X
  591. X  surplus = square1->value[color1] - square1->lowbound;
  592. X  if (surplus < 0)
  593. X    surplus = 0;
  594. X
  595. X  /**** check value ****/
  596. X  if (surplus == 0)
  597. X    goto quit;
  598. X
  599. X  /**** compute slope and forest hinderance ****/
  600. X
  601. X  if (color1 != FIGHT)
  602. X  {
  603. X    slope = (double)(square2->value[none] - square1->value[none]) /
  604. X      NGREYTONES * hillfactor[color1];
  605. X    hinder = slowfactor[color1] + forest[color1] * (double)square2->value[none];
  606. X
  607. X    if (enable_digin[color1])
  608. X      shunt = shuntval[color1]*((double)(square2->value[color1]))/MAXVAL + 1.0;
  609. X    else
  610. X      shunt = 1.0;
  611. X  }
  612. X  else
  613. X  {
  614. X    slope = (double)(square2->value[none] - square1->value[none]) /
  615. X      NGREYTONES * hillfactor[0];
  616. X    hinder = slowfactor[0] + forest[0] * (double)square2->value[none];
  617. X  }
  618. X
  619. X  /**** advance into grey square ****/
  620. X  if (color2 == none && color1 != FIGHT)
  621. X  {
  622. X    /**** compute the number to move ****/
  623. X
  624. X    doublenmove = (double)surplus / hinder / shunt /
  625. X          (double)square1->move * (1.0-slope);
  626. X    nmove = (int)(doublenmove);
  627. X          
  628. X    if (nmove > surplus)
  629. X      nmove = surplus;
  630. X    if (nmove + square2->value[color1] > MAXVAL)
  631. X      nmove = MAXVAL - square2->value[color1];
  632. X    if (nmove == 0 && doublenmove > 0.0 && drand48() < doublenmove)
  633. X      nmove = 1;
  634. X    if (nmove <= 0)
  635. X      goto quit;
  636. X
  637. X    /**** move ****/
  638. X    square1->value[color1] = square1->value[color1] - nmove;
  639. X    for (i=0; i<directions; i++)
  640. X      square1->dir[i] = square1->dir[i];
  641. X    square2->color = color2 = color1;
  642. X    square2->value[color2] = nmove;
  643. X    square2->age = 0;
  644. X
  645. X    /**** outdate the squares (for later redrawing) ****/
  646. X    outdated[square1->x][square1->y] = ALL;
  647. X    outdated[square2->x][square2->y] = ALL;
  648. X
  649. X    /**** outdate neighboring squares if using horizon ****/
  650. X    if (enable_horizon)
  651. X    {
  652. X      if (square1->value[color1] == 0)
  653. X        outdatehorizon (board, square1->x, square1->y, color1);
  654. X      if (square2->value[color1] > 0)
  655. X        outdatehorizon (board, square2->x, square2->y, color1);
  656. X    }
  657. X
  658. X  /**** move into friendly square ****/
  659. X  }
  660. X  else if (color1 == color2 && color1 != FIGHT)
  661. X  {
  662. X    /**** compute the number to move ****/
  663. X
  664. X    doublenmove = (double)surplus / hinder / shunt /
  665. X          (double)square1->move * (1.0-slope);
  666. X    nmove = (int)(doublenmove);
  667. X
  668. X    if (nmove > surplus)
  669. X      nmove = surplus;
  670. X    if (nmove + square2->value[color1] > MAXVAL)
  671. X      nmove = MAXVAL - square2->value[color1];
  672. X    if (nmove == 0 && doublenmove > 0.0 && drand48() < doublenmove)
  673. X      nmove = 1;
  674. X    if (nmove <= 0)
  675. X      goto quit;
  676. X
  677. X    /**** move ****/
  678. X    square1->value[color1] = square1->value[color1] - nmove;
  679. X    square2->value[color2] = square2->value[color1] + nmove;
  680. X
  681. X    /**** outdate neighboring squares if using horizon ****/
  682. X    if (enable_horizon)
  683. X    {
  684. X      if (square1->value[color1] == 0)
  685. X        outdatehorizon (board, square1->x, square1->y, color1);
  686. X      if (square2->value[color1] == nmove && nmove>0)
  687. X        outdatehorizon (board, square2->x, square2->y, color1);
  688. X    }
  689. X
  690. X  /**** invade enemy square ****/
  691. X  }
  692. X  else if (color1 != color2 && color2 != none && color2 != FIGHT)
  693. X  {
  694. X    /**** compute the number to move ****/
  695. X    doublenmove = (double)surplus / hinder / shunt /
  696. X          (double)square1->move * (1.0-slope);
  697. X    nmove = (int)(doublenmove);
  698. X
  699. X    if (nmove > surplus)
  700. X      nmove = surplus;
  701. X    if (nmove + square2->value[color1] > MAXVAL)
  702. X      nmove = MAXVAL - square2->value[color1];
  703. X    if (nmove == 0 && doublenmove > 0.0 && drand48() < doublenmove)
  704. X      nmove = 1;
  705. X    if (nmove <= 0)
  706. X      goto quit;
  707. X
  708. X    /**** immobilize the enemy ****/
  709. X    if (disrupt)
  710. X      for (i=0; i<directions; i++)
  711. X        square2->dir[i] = 0;
  712. X
  713. X    /**** do the move ****/
  714. X    square2->color = FIGHT;
  715. X    square1->value[color1]  = square1->value[color1] - nmove;
  716. X    square2->value[color1] = square2->value[color1] + nmove;
  717. X    square2->oldcolor = color2;
  718. X
  719. X    /**** outdate the squares (for later redrawing) ****/
  720. X    outdated[square1->x][square1->y] = ALL;
  721. X    outdated[square2->x][square2->y] = ALL;
  722. X
  723. X    /**** outdate neighboring squares if using horizon ****/
  724. X    if (enable_horizon)
  725. X    {
  726. X      if (square1->value[color1] == 0)
  727. X        outdatehorizon (board, square1->x, square1->y, color1);
  728. X      outdatehorizon (board, square2->x, square2->y, color1);
  729. X    }
  730. X
  731. X  /**** join battle in square ****/
  732. X  }
  733. X  else if (color2 == FIGHT)
  734. X  {
  735. X    /**** compute the number to move ****/
  736. X    doublenmove = (double)surplus / hinder / shunt /
  737. X          (double)square1->move * (1.0-slope);
  738. X    nmove = (int)(doublenmove);
  739. X
  740. X    if (nmove > surplus)
  741. X      nmove = surplus;
  742. X    if (nmove + square2->value[color1] > MAXVAL)
  743. X      nmove = MAXVAL - square2->value[color1];
  744. X    if (nmove == 0 && doublenmove > 0.0 && drand48() < doublenmove)
  745. X      nmove = 1;
  746. X    if (nmove <= 0)
  747. X      goto quit;
  748. X
  749. X    /**** do the move ****/
  750. X    square1->value[color1] = square1->value[color1] - nmove;
  751. X    square2->value[color1] = square2->value[color1] + nmove;
  752. X
  753. X    /**** outdate the squares (for later redrawing) ****/
  754. X    outdated[square1->x][square1->y] = ALL;
  755. X    outdated[square2->x][square2->y] = ALL;
  756. X
  757. X    /**** outdate neighboring squares if using horizon ****/
  758. X    if (enable_horizon)
  759. X    {
  760. X      if (square1->value[color1] == 0)
  761. X        outdatehorizon (board, square1->x, square1->y, color1);
  762. X    }
  763. X  }
  764. X  quit:;
  765. X}
  766. X
  767. X
  768. X/*************************************************************************/
  769. X/**    growsquare                            **/
  770. X/** every square with a grow value is incremented in each update cycle    **/
  771. X/** by the grow value.  This applies to farms, towns and bases.        **/
  772. X/**    Steve Lehar (slehar@park.bu.edu)                **/
  773. X/*************************************************************************/
  774. Xgrowsquare(square)
  775. X  square_type *square;
  776. X{
  777. X  int activecolor;
  778. X
  779. X  /**** get color ****/
  780. X  activecolor = square->color;
  781. X  if(activecolor == none || activecolor == FIGHT) goto quit;
  782. X
  783. X  /**** grow square ****/
  784. X  if(square->growth>0 && square->value[activecolor]<MAXVAL)
  785. X  {
  786. X    if(square->growth>50)
  787. X      square->age = 0;
  788. X    if(square->growth > (int)(100.0 * drand48())) 
  789. X      square->value[activecolor] ++;
  790. X    if(square->value[activecolor] > MAXVAL) 
  791. X      square->value[activecolor] = MAXVAL;
  792. X  }
  793. X quit:;
  794. X}
  795. X
  796. X
  797. X/*************************************************************************/
  798. X/**    decaysquare                            **/
  799. X/**     Greg Lesher (lesher@park.bu.edu                **/
  800. X/*************************************************************************/
  801. Xdecaysquare(square)
  802. X  square_type *square;
  803. X{
  804. X  int activecolor;
  805. X
  806. X  double thresh;
  807. X
  808. X  /**** get color ****/
  809. X  activecolor = square->color;
  810. X  if(activecolor == none || activecolor == FIGHT) 
  811. X    return;
  812. X
  813. X  thresh = decayrate[activecolor] * square->value[activecolor];
  814. X  if (drand48() < thresh)
  815. X    square->value[activecolor] -= 1;
  816. X
  817. X  if (square->value[activecolor] < 0)
  818. X    square->value[activecolor] = 0;
  819. X}
  820. X
  821. X
  822. X/*************************************************************************/
  823. X/**    fight                                **/
  824. X/** Battles  occur when  opposing  forces  occupy a square  (color  ==    **/
  825. X/** FIGHT).   The outcome of the  battle   is  determined by a   random    **/
  826. X/** variable and a nonlinear function of the relative strengths of the    **/
  827. X/** combatants, such that a larger unbalance  results in a much larger    **/
  828. X/** advantage.    In  each update    cycle each  side  suffers  losses    **/
  829. X/** determined by that function.                    **/
  830. X/**    Steve Lehar (slehar@park.bu.edu)                **/
  831. X/**    Greg Lesher (lesher@park.bu.edu)                **/
  832. X/*************************************************************************/
  833. Xfight(board,square)
  834. X  square_type *board,*square;
  835. X{
  836. X  int i,j,
  837. X      count, pos,
  838. X      versus[MAXSIDES];
  839. X
  840. X  double sideinfer[MAXSIDES],
  841. X         sideloss[MAXSIDES];
  842. X
  843. X  /**** compute the number of attacking forces against each color ****/
  844. X  for (i=0; i<nsides; i++)
  845. X  {
  846. X    versus[i] = 0;
  847. X    for (j=0; j<nsides; j++)
  848. X    {
  849. X      if (j!=i)
  850. X      {
  851. X        if (square->value[j] > 0)
  852. X          versus[i] += square->value[j];
  853. X      }
  854. X    }
  855. X  }
  856. X
  857. X  /**** compute damages for each color ****/
  858. X  for (i=0; i<nsides; i++)
  859. X    if (square->value[i] > 0)
  860. X      sideinfer[i] = (double)versus[i]/((double)square->value[i]);
  861. X
  862. X  for (i=0; i<nsides; i++)
  863. X  {
  864. X    if (square->value[i] > 0)
  865. X    {
  866. X      sideloss[i] = ((sideinfer[i]*sideinfer[i]) - 1.0 + drand48()*2.0) * firepower[i];
  867. X      if (sideloss[i] < 0.0)
  868. X        sideloss[i] = 0.0;
  869. X    }
  870. X    else
  871. X      sideloss[i] = 0.0;
  872. X    square->value[i] -= (int)(sideloss[i]+0.5);
  873. X  }
  874. X
  875. X  /**** count remaining colors ****/
  876. X  count = 0;
  877. X  for (i=0; i<nsides; i++)
  878. X  {
  879. X    if (square->value[i] <= 0)
  880. X      square->value[i] = 0;
  881. X    else
  882. X    {
  883. X      count++;
  884. X      pos = i;
  885. X    }
  886. X  }
  887. X
  888. X  /**** if there is a winner, give the square to that color ****/
  889. X  if (count == 1)
  890. X  {
  891. X    square->color = pos;  
  892. X    square->age = 0;
  893. X    if (square->oldcolor != pos)
  894. X    {
  895. X      for (i=0; i<directions; i++) square->dir[i] = 0;
  896. X      square->move = 0;
  897. X      square->lowbound = 0;
  898. X    }
  899. X  }
  900. X  else if (count == 0)
  901. X  {
  902. X    square->color = none;
  903. X    square->move = 0;
  904. X    square->lowbound = 0;
  905. X    square->age = 0;
  906. X    for (i=0; i<directions; i++) square->dir[i] = 0;
  907. X  }
  908. X
  909. X  /**** outdate squares for later redrawing ****/
  910. X  outdated[square->x][square->y] = ALL;
  911. X  if (enable_horizon)
  912. X  {
  913. X    outdatehorizon (board, square->x, square->y, ALL);
  914. X  }
  915. X}
  916. X
  917. X
  918. X/*************************************************************************/
  919. X/**     march                                                           **/
  920. X/**  handle marching                             **/
  921. X/**     Greg Lesher (lesher@park.bu.edu)                                **/
  922. X/*************************************************************************/
  923. Xmarch (board)
  924. X  square_type *board;
  925. X{
  926. X  int i, j,
  927. X      x, y,
  928. X      newx, newy,
  929. X      color;
  930. X
  931. X  square_type *square, *square2;
  932. X
  933. X
  934. X  for (x=0; x<boardsizex; x++)
  935. X  {
  936. X    for (y=0; y<boardsizey; y++)
  937. X    {
  938. X      square = SQUARE(board,x,y);
  939. X      color = square->color; 
  940. X
  941. X      if (square->anymarch == ACTIVE)
  942. X      {
  943. X        if (color == none || color==FIGHT)
  944. X          square->anymarch = FALSE;
  945. X        else if (color != square->marchcolor)
  946. X          square->anymarch = FALSE;
  947. X      }
  948. X
  949. X      if (enable_personalmarch[color] && square->anymarch==ACTIVE)
  950. X      {
  951. X        square->marchcount += 1;
  952. X        if (square->marchcount == marchrate[color]) 
  953. X        {
  954. X          square->anymarch = FALSE;
  955. X          outdated[square->x][square->y] = ALL;
  956. X
  957. X          square->move = 0;
  958. X          for (i=0; i<directions; i++)
  959. X          {
  960. X            if (square->marchtype[color] == FORCE)
  961. X              square->dir[i] = square->marchdir[color][i];
  962. X            else
  963. X              square->dir[i] = square->marchdir[color][i] || square->dir[i];
  964. X            if (square->dir[i])
  965. X              square->move++;
  966. X          }
  967. X
  968. X          for (i=0; i<directions; i++)
  969. X          {
  970. X            newx = x; 
  971. X            newy = y; 
  972. X
  973. X            if (square->marchdir[color][i])
  974. X            {
  975. X              square2 = SQUARE(board,x,y)->connect[i];
  976. X
  977. X              if (square2->color == none || square2->color == color)
  978. X              {
  979. X                if (enable_sea && square2->value[none] <= 0)
  980. X                {
  981. X                }
  982. X                else if (square2->march[color] == PASSIVE) 
  983. X                {
  984. X                   square2->anymarch = TEMP;
  985. X                   square2->march[color] = FALSE;
  986. X                   square2->marchcolor = color;
  987. X                   square2->marchcount = 0;
  988. X                }
  989. X                else
  990. X                {
  991. X                  square2->anymarch = TEMP;
  992. X                  square2->marchtype[color] = SQUARE(board,x,y)->marchtype[color];
  993. X                  square2->marchcount = 0;
  994. X                  square2->marchcolor = color;
  995. X                  for (j=0; j<directions; j++)
  996. X                    square2->marchdir[color][j] = square->marchdir[color][j];
  997. X                }
  998. X              }
  999. X            }
  1000. X          }
  1001. X        }
  1002. X      }
  1003. X
  1004. X      if (color != none && color != FIGHT)
  1005. X      {
  1006. X        if (square->march[color] == PASSIVE)
  1007. X        {
  1008. X          if (square->value[color] > 0)
  1009. X          {
  1010. X            square->anymarch = ACTIVE;
  1011. X            square->march[color] = FALSE;
  1012. X            square->marchcolor = color;
  1013. X            square->marchcount = 0;
  1014. X          }
  1015. X        }
  1016. X      }
  1017. X    }
  1018. X  }
  1019. X
  1020. X  for (x=0; x<boardsizex; x++)
  1021. X    for (y=0; y<boardsizey; y++)
  1022. X      if (SQUARE(board,x,y)->anymarch == TEMP)
  1023. X        SQUARE(board,x,y)->anymarch = ACTIVE;
  1024. X}
  1025. X
  1026. X
  1027. X/*************************************************************************/
  1028. X/**     fire                                                            **/
  1029. X/**  control artillery fire                        **/
  1030. X/**     Greg Lesher (lesher@park.bu.edu)                                **/
  1031. X/*************************************************************************/
  1032. Xfire (board, xpos, ypos, x, y, colorarray)
  1033. X  square_type *board;
  1034. X  int xpos, ypos,
  1035. X      x, y,
  1036. X      colorarray[];
  1037. X{
  1038. X  static int xrand, yrand;
  1039. X
  1040. X  int i,
  1041. X      tdir[DIRS],
  1042. X      xdiff, ydiff,
  1043. X      xdest, ydest,
  1044. X      xfdest, yfdest,
  1045. X      destcolor,
  1046. X      sourcecolor,
  1047. X      csize, hafc,
  1048. X      winxsize, winysize;
  1049. X
  1050. X  square_type *square;
  1051. X
  1052. X  /**** make sure shell can be afforded ****/
  1053. X  if (SQUARE(board,x,y)->value[SQUARE(board,x,y)->color] < SHELL_COST+1)
  1054. X    return;
  1055. X  SQUARE(board,x,y)->value[SQUARE(board,x,y)->color] -= SHELL_COST;
  1056. X
  1057. X  sourcecolor = SQUARE(board,x,y)->color;
  1058. X
  1059. X  /**** compute direction and distance of artillery shell ****/
  1060. X
  1061. X  if (enable_hex)
  1062. X  {
  1063. X    xdiff = xpos - SQUARE(board,x,y)->xpos;
  1064. X    ydiff = ypos - SQUARE(board,x,y)->ypos;
  1065. X  }
  1066. X  else
  1067. X  {
  1068. X    xdiff = xpos - (squaresize[sourcecolor]*SQUARE(board,x,y)->x+squaresize[sourcecolor]/2);
  1069. X    ydiff = ypos - (squaresize[sourcecolor]*SQUARE(board,x,y)->y+squaresize[sourcecolor]/2);
  1070. X  }
  1071. X
  1072. X  xfdest = xpos + xdiff * 40 * artillery[SQUARE(board,x,y)->color];
  1073. X  yfdest = ypos + ydiff * 40 * artillery[SQUARE(board,x,y)->color];
  1074. X
  1075. X  if (enable_wrap[sourcecolor])
  1076. X  {
  1077. X    if (enable_hex)
  1078. X    {
  1079. X      winxsize = (boardsizex-1)*3*(hex_halfside) + 2*hex_side;
  1080. X      winysize = boardsizey*2*hex_vert + hex_vert;
  1081. X    }
  1082. X    else
  1083. X    {
  1084. X      winxsize = boardsizex*squaresize[sourcecolor];
  1085. X      winysize = boardsizey*squaresize[sourcecolor];
  1086. X    }
  1087. X
  1088. X    if (xfdest > winxsize)
  1089. X      xfdest -= winxsize;
  1090. X    else if (xfdest < 0)
  1091. X      xfdest = winxsize + xfdest;
  1092. X
  1093. X    if (yfdest > winysize)
  1094. X      yfdest -= winysize;
  1095. X    else if (yfdest < 0)
  1096. X      yfdest = winysize + yfdest;
  1097. X  }
  1098. X
  1099. X  getsquare (xfdest, yfdest, &xdest, &ydest, tdir, squaresize[sourcecolor], board, FALSE);
  1100. X
  1101. X  if (xdest < 0)
  1102. X    xdest = 0;
  1103. X  else if (xdest > boardsizex-1)
  1104. X    xdest = boardsizex-1;
  1105. X
  1106. X  if (ydest < 0)
  1107. X    ydest = 0;
  1108. X  else if (ydest > boardsizey-1)
  1109. X    ydest = boardsizey-1;
  1110. X
  1111. X  /**** compute effect of artillery shell ****/
  1112. X  square = SQUARE(board,xdest,ydest);
  1113. X  destcolor = square->color;
  1114. X
  1115. X  if (destcolor != none && destcolor != FIGHT)
  1116. X  {
  1117. X    square->value[destcolor] -= SHELL;
  1118. X    if (square->value[destcolor] < 0)
  1119. X    {
  1120. X      square->color = none;
  1121. X      square->age = 0;
  1122. X      square->march[destcolor] = FALSE;
  1123. X      square->anymarch = FALSE;
  1124. X      square->value[destcolor] = 0;
  1125. X      square->move = 0;
  1126. X      square->lowbound = 0;
  1127. X      for (i=0; i<directions; i++)
  1128. X        square->dir[i] = 0;
  1129. X      if (enable_horizon)
  1130. X      {
  1131. X        outdatehorizon (board, xdest, ydest, destcolor);
  1132. X      }
  1133. X    }
  1134. X  }
  1135. X
  1136. X  /**** redraw affected squares and shell burst ****/
  1137. X
  1138. X  for (i=0; i<nplayers; i++)
  1139. X  {
  1140. X
  1141. X    csize = 10 * squaresize[colorarray[i]]/50;
  1142. X    if (enable_hex)
  1143. X      hafc = csize/2;
  1144. X    else
  1145. X      hafc = (squaresize[colorarray[i]]-csize)/2; 
  1146. X
  1147. X    if (!winopen[i])
  1148. X      continue;
  1149. X
  1150. X    if (visible(board,colorarray[i],x,y))
  1151. X    {
  1152. X      if (enable_hidden[colorarray[i]])
  1153. X      {
  1154. X        if (SQUARE(board,x,y)->color == colorarray[i])
  1155. X          drawsquare(xwindow[i],SQUARE(board,x,y),colorarray[i],squaresize[colorarray[i]]);
  1156. X      }
  1157. X      else
  1158. X       drawsquare(xwindow[i],SQUARE(board,x,y),colorarray[i],squaresize[colorarray[i]]);
  1159. X    }
  1160. X
  1161. X    if (enable_storage && !i)
  1162. X      storedrawsquare(SQUARE(board,x,y),squaresize[0], FALSE);
  1163. X
  1164. X    if (visible(board,colorarray[i],xdest,ydest))
  1165. X    {
  1166. X      if (enable_hidden[colorarray[i]])
  1167. X      {
  1168. X        if (SQUARE(board,xdest,ydest)->color == colorarray[i])
  1169. X              drawsquare(xwindow[i],SQUARE(board,xdest,ydest),colorarray[i],squaresize[colorarray[i]]);
  1170. X      }
  1171. X      else
  1172. X       drawsquare(xwindow[i],SQUARE(board,xdest,ydest),colorarray[i],squaresize[colorarray[i]]);
  1173. X
  1174. X      if (enable_hex)
  1175. X      {
  1176. X        xrand = (xrand+2938345)%hex_side;
  1177. X        yrand = (yrand+2398321)%hex_side;
  1178. X
  1179. X        XFillArc(xwindow[i]->display,xwindow[i]->window,xwindow[i]->hue[sourcecolor],
  1180. X                 SQUARE(board,xdest,ydest)->xpos - hafc + xrand - hex_halfside,
  1181. X                 SQUARE(board,xdest,ydest)->ypos - hafc + yrand - hex_halfside,
  1182. X                 csize, csize, 0, 23040);
  1183. X      }
  1184. X      else
  1185. X      {
  1186. X        xrand = (xrand+2938345)%(squaresize[colorarray[i]]/2);
  1187. X        yrand = (yrand+2398321)%(squaresize[colorarray[i]]/2);
  1188. X
  1189. X        XFillArc(xwindow[i]->display,xwindow[i]->window,xwindow[i]->hue[sourcecolor],
  1190. X                 xdest*squaresize[colorarray[i]]+hafc+xrand-squaresize[colorarray[i]]/4,
  1191. X                 ydest*squaresize[colorarray[i]]+hafc+yrand-squaresize[colorarray[i]]/4,
  1192. X                 csize, csize, 0, 23040);
  1193. X      }
  1194. X      outdated[xdest][ydest] = ALL;
  1195. X    }
  1196. X    if (enable_storage && !i)
  1197. X    {
  1198. X      storedrawsquare(SQUARE(board,xdest,ydest),squaresize[0], FALSE);
  1199. X      fprintf (fpout, "H%c%c%c%c", xdest, ydest, csize, sourcecolor);
  1200. X    }
  1201. X  }
  1202. X}
  1203. X
  1204. X
  1205. X/*************************************************************************/
  1206. X/**     para                                                            **/
  1207. X/**  control paratroopers                        **/
  1208. X/**     Greg Lesher (lesher@park.bu.edu)                                **/
  1209. X/*************************************************************************/
  1210. Xpara (board, xpos, ypos, x, y, colorarray)
  1211. X  square_type *board;
  1212. X  int xpos, ypos,
  1213. X      x, y,
  1214. X      colorarray[];
  1215. X{
  1216. X  static xrand, yrand;
  1217. X
  1218. X  int i,
  1219. X      tdir[DIRS],
  1220. X      xdiff, ydiff,
  1221. X      xdest, ydest,
  1222. X      xfdest, yfdest,
  1223. X      ipos, jpos,
  1224. X      destcolor,
  1225. X      sourcecolor,
  1226. X      csize, hafc,
  1227. X      winxsize, winysize;
  1228. X
  1229. X  square_type *square;
  1230. X
  1231. X  /**** make sure that paratroopers can be afforded ****/
  1232. X  if (SQUARE(board,x,y)->value[SQUARE(board,x,y)->color] < PARA_COST+1)
  1233. X    return;
  1234. X  SQUARE(board,x,y)->value[SQUARE(board,x,y)->color] -= PARA_COST;
  1235. X  sourcecolor = SQUARE(board,x,y)->color;
  1236. X
  1237. X  /**** compute direction and distance of paratroopers ****/
  1238. X
  1239. X  if (enable_hex)
  1240. X  {
  1241. X    xdiff = xpos - SQUARE(board,x,y)->xpos;
  1242. X    ydiff = ypos - SQUARE(board,x,y)->ypos;
  1243. X  }
  1244. X  else
  1245. X  {
  1246. X    xdiff = xpos - (squaresize[sourcecolor]*SQUARE(board,x,y)->x+squaresize[sourcecolor]/2);
  1247. X    ydiff = ypos - (squaresize[sourcecolor]*SQUARE(board,x,y)->y+squaresize[sourcecolor]/2);
  1248. X  }
  1249. X
  1250. X  xfdest = xpos + xdiff * 40 * artillery[SQUARE(board,x,y)->color];
  1251. X  yfdest = ypos + ydiff * 40 * artillery[SQUARE(board,x,y)->color];
  1252. X
  1253. X  if (enable_wrap[sourcecolor])
  1254. X  {
  1255. X    if (enable_hex)
  1256. X    {
  1257. X      winxsize = (boardsizex-1)*3*(hex_halfside) + 2*hex_side;
  1258. X      winysize = boardsizey*2*hex_vert + hex_vert;
  1259. X    }
  1260. X    else
  1261. X    {
  1262. X      winxsize = boardsizex*squaresize[sourcecolor];
  1263. X      winysize = boardsizey*squaresize[sourcecolor];
  1264. X    }
  1265. X
  1266. X    if (xfdest > winxsize)
  1267. X      xfdest -= winxsize;
  1268. X    else if (xfdest < 0)
  1269. X      xfdest = winxsize + xfdest;
  1270. X
  1271. X    if (yfdest > winysize)
  1272. X      yfdest -= winysize;
  1273. X    else if (yfdest < 0)
  1274. X      yfdest = winysize + yfdest;
  1275. X  }
  1276. X
  1277. X
  1278. X  getsquare (xfdest, yfdest, &xdest, &ydest, tdir, squaresize[sourcecolor], board);
  1279. X
  1280. X  if (xdest < 0)
  1281. X    xdest = 0;
  1282. X  else if (xdest > boardsizex-1)
  1283. X    xdest = boardsizex-1;
  1284. X
  1285. X  if (ydest < 0)
  1286. X    ydest = 0;
  1287. X  else if (ydest > boardsizey-1)
  1288. X    ydest = boardsizey-1;
  1289. X
  1290. X  /**** compute effect of paratroopers ****/
  1291. X  square = SQUARE(board,xdest,ydest);
  1292. X  destcolor = square->color;
  1293. X
  1294. X  if (enable_sea && square->value[none] <= 0)
  1295. X  {
  1296. X  }
  1297. X  else
  1298. X  {
  1299. X    if (destcolor == none || destcolor == sourcecolor)
  1300. X    {
  1301. X      square->color = sourcecolor;
  1302. X      square->age = 0;
  1303. X      square->anymarch = FALSE;
  1304. X      square->value[sourcecolor] += PARA;
  1305. X      if (square->value[sourcecolor] > MAXVAL)
  1306. X        square->value[sourcecolor] = MAXVAL;
  1307. X      if (enable_horizon && destcolor == none)
  1308. X      {
  1309. X        outdatehorizon (board, xdest, ydest, sourcecolor);
  1310. X      }
  1311. X    }
  1312. X    else if (destcolor != sourcecolor && destcolor != FIGHT)
  1313. X    {
  1314. X      square->value[sourcecolor] += PARA;
  1315. X      square->color = FIGHT;
  1316. X
  1317. X      if (enable_disrupt[sourcecolor])
  1318. X      {
  1319. X        for (i=0; i<directions; i++)
  1320. X          square->dir[i] = 0;
  1321. X        square->move = 0;
  1322. X      }
  1323. X
  1324. X      if (enable_horizon)
  1325. X      {
  1326. X        outdatehorizon (board, xdest, ydest, sourcecolor);
  1327. X      }
  1328. X    }
  1329. X    else if (destcolor == FIGHT)
  1330. X    {
  1331. X      square->value[sourcecolor] += PARA;
  1332. X      if (square->value[sourcecolor] > MAXVAL)
  1333. X        square->value[sourcecolor] = MAXVAL;
  1334. X    }
  1335. X  }
  1336. X
  1337. X  /**** redraw affected squares and parachute ****/
  1338. X
  1339. X  for (i=0; i<nplayers; i++)
  1340. X  {
  1341. X    csize = 20 * squaresize[colorarray[i]]/50;
  1342. X    if (enable_hex)
  1343. X      hafc = csize/2;
  1344. X    else
  1345. X      hafc = (squaresize[colorarray[i]]-csize)/2; 
  1346. X
  1347. X    if (!winopen[i])
  1348. X      continue;
  1349. X    if (visible(board,colorarray[i],x,y))
  1350. X    {
  1351. X      if (enable_hidden[colorarray[i]])
  1352. X      {
  1353. X        if (SQUARE(board,x,y)->color == colorarray[i])
  1354. X              drawsquare(xwindow[i],SQUARE(board,x,y),colorarray[i],squaresize[colorarray[i]]);
  1355. X      }
  1356. X      else
  1357. X       drawsquare(xwindow[i],SQUARE(board,x,y),colorarray[i],squaresize[colorarray[i]]);
  1358. X    }
  1359. X    if (enable_storage && !i)
  1360. X      storedrawsquare(SQUARE(board,x,y),squaresize[0], FALSE);
  1361. X
  1362. X    if (visible(board,colorarray[i],xdest,ydest))
  1363. X    {
  1364. X      if (enable_hidden[colorarray[i]])
  1365. X      {
  1366. X        if (SQUARE(board,xdest,ydest)->color == colorarray[i])
  1367. X              drawsquare(xwindow[i],SQUARE(board,xdest,ydest),colorarray[i],squaresize[colorarray[i]]);
  1368. X      }
  1369. X      else
  1370. X        drawsquare(xwindow[i],SQUARE(board,xdest,ydest),colorarray[i],squaresize[colorarray[i]]);
  1371. X
  1372. X      if (enable_hex)
  1373. X      {
  1374. X        xrand = (xrand+2938345)%hex_side;
  1375. X        yrand = (yrand+2398321)%hex_side;
  1376. X
  1377. X        ipos = SQUARE(board,xdest,ydest)->xpos - hafc + xrand - hex_halfside;
  1378. X        jpos = SQUARE(board,xdest,ydest)->ypos - hafc + yrand - hex_halfside;
  1379. X      }
  1380. X      else
  1381. X      {
  1382. X        xrand = (xrand+2938345)%(squaresize[colorarray[i]]/2);
  1383. X        yrand = (yrand+2398321)%(squaresize[colorarray[i]]/2);
  1384. X
  1385. X        ipos = xdest*squaresize[colorarray[i]]+hafc+xrand-squaresize[colorarray[i]]/4;
  1386. X        jpos = ydest*squaresize[colorarray[i]]+hafc+yrand-squaresize[colorarray[i]]/4;
  1387. X      }
  1388. X
  1389. X      XFillArc(xwindow[i]->display,xwindow[i]->window,xwindow[i]->hue[sourcecolor],
  1390. X               ipos, jpos, csize, csize, 0, 11520);
  1391. X
  1392. X      XDrawLine(xwindow[i]->display,xwindow[i]->window,xwindow[i]->hue[sourcecolor],
  1393. X               ipos, jpos + csize/2, ipos + csize/2, jpos + csize);
  1394. X
  1395. X      XDrawLine(xwindow[i]->display,xwindow[i]->window,xwindow[i]->hue[sourcecolor],
  1396. X               ipos + csize/2, jpos + csize, ipos + csize, jpos + csize/2);
  1397. X
  1398. X      XDrawLine(xwindow[i]->display,xwindow[i]->window,xwindow[i]->hue[sourcecolor],
  1399. X               ipos + csize/2, jpos + csize/2, ipos + csize/2, jpos + csize);
  1400. X
  1401. X      outdated[xdest][ydest] = ALL;
  1402. X    }
  1403. X    if (enable_storage && !i)
  1404. X    {
  1405. X      storedrawsquare(SQUARE(board,xdest,ydest),squaresize[0], FALSE);
  1406. X      fprintf (fpout, "I%c%c%c%c", xdest, ydest, csize, sourcecolor);
  1407. X    } 
  1408. X  }
  1409. X}
  1410. X
  1411. X
  1412. X/*************************************************************************/
  1413. X/**     visible                                                         **/
  1414. X/**  Checks viewer has controlling troops within VIEWRANGE of SQUARE    **/
  1415. X/**     Mark Lauer (elric@cs.su.oz.au)                                  **/
  1416. X/**     Greg Lesher (lesher@park.bu.edu)                                **/
  1417. X/*************************************************************************/
  1418. Xvisible(board, activecolor, x, y)
  1419. X  square_type *board;
  1420. X  int activecolor,
  1421. X      x, y;
  1422. X{
  1423. X  int i, j, i1, i2, j1, j2,
  1424. X      ipos, jpos;
  1425. X
  1426. X  /**** return TRUE if player owns square or horizon disabled ****/
  1427. X  if (!enable_personalhorizon[activecolor])
  1428. X    return (TRUE);
  1429. X  if (SQUARE(board,x,y)->color == activecolor)
  1430. X    return (TRUE);
  1431. X
  1432. X  if (!enable_hex)
  1433. X  {
  1434. X    i1 = x-viewrange[activecolor];
  1435. X    i2 = x+viewrange[activecolor];
  1436. X    j1 = y-viewrange[activecolor];
  1437. X    j2 = y+viewrange[activecolor];
  1438. X  }
  1439. X
  1440. X  /**** search for nearby squares of color color ****/
  1441. X  if (enable_wrap[activecolor])
  1442. X  {
  1443. X    for (i=i1; i<=i2; i++)
  1444. X      for (j=j1; j<=j2; j++)
  1445. X        if (SQUARE(board,MODX(i),MODY(j))->value[activecolor] > 0)
  1446. X          return (TRUE);
  1447. X  }
  1448. X  else
  1449. X  {
  1450. X    if (enable_hex)
  1451. X    {
  1452. X      for (i=0; i<hex_horizon_number; i++)
  1453. X      {
  1454. X
  1455. X        if (x%2 == 0)
  1456. X        {
  1457. X          ipos = x + hex_horizon_even[i][0];
  1458. X          jpos = y + hex_horizon_even[i][1];
  1459. X        }
  1460. X        else
  1461. X        {
  1462. X          ipos = x + hex_horizon_odd[i][0];
  1463. X          jpos = y + hex_horizon_odd[i][1];
  1464. X        }
  1465. X
  1466. X        ipos = (ipos<0) ? 0 : ipos;
  1467. X        ipos = (ipos>boardsizex-1) ? boardsizex-1 : ipos;
  1468. X        jpos = (jpos<0) ? 0 : jpos;
  1469. X        jpos = (jpos>boardsizey-1) ? boardsizey-1 : jpos;
  1470. X
  1471. X        if (SQUARE(board,ipos,jpos)->value[activecolor] > 0)
  1472. X          return (TRUE);
  1473. X      }
  1474. X    }
  1475. X    else
  1476. X    {
  1477. X      i1 = (i1<0) ? 0 : i1;
  1478. X      i2 = (i2>boardsizex-1) ? boardsizex-1 : i2;
  1479. X      j1 = (j1<0) ? 0 : j1;
  1480. X      j2 = (j2>boardsizey-1) ? boardsizey-1 : j2;
  1481. X
  1482. X      for (i=i1; i<=i2; i++)
  1483. X        for (j=j1; j<=j2; j++)
  1484. X          if (SQUARE(board,i,j)->value[activecolor] > 0)
  1485. X            return (TRUE);
  1486. X    }
  1487. X  }
  1488. X  return (FALSE);
  1489. X}
  1490. X
  1491. X
  1492. X/*************************************************************************/
  1493. X/**     outdatehorizon                                                  **/
  1494. X/**  Make area outdated for (possible) redrawing            **/
  1495. X/**     Mark Lauer (elric@cs.su.oz.au)                                  **/
  1496. X/**     Greg Lesher (lesher@park.bu.edu)                                **/
  1497. X/*************************************************************************/
  1498. Xoutdatehorizon (board, x, y, currentcolor)
  1499. X  square_type *board;
  1500. X  int x, y,
  1501. X      currentcolor;
  1502. X{
  1503. X  int i, j, i1, i2, j1, j2, ci, cj,
  1504. X      ipos, jpos,
  1505. X      range,
  1506. X      activecolor;
  1507. X
  1508. X  if (currentcolor >= nsides)
  1509. X  {
  1510. X    currentcolor = ALL;
  1511. X    range = maxviewrange;
  1512. X  }
  1513. X  else
  1514. X    range = viewrange[currentcolor]; 
  1515. X
  1516. X  i1 = x-range;
  1517. X  i2 = x+range;
  1518. X  j1 = y-range;
  1519. X  j2 = y+range;
  1520. X
  1521. X  /**** outdate VIEWRANGE area ****/
  1522. X  if (enable_anywrap)
  1523. X  {
  1524. X    for (i=i1; i<=i2; i++)
  1525. X      for (j=j1; j<=j2; j++)
  1526. X      {
  1527. X        ci = MODX(i);
  1528. X        cj = MODY(j);
  1529. X
  1530. X        /**** outdate differently colored squares ****/
  1531. X        activecolor = SQUARE(board,ci,cj)->color;
  1532. X        if (activecolor != none && activecolor != currentcolor)
  1533. X        {
  1534. X          if (outdated[ci][cj] == OK)
  1535. X            outdated[ci][cj] = currentcolor;
  1536. X          else if (outdated[ci][cj] != currentcolor)
  1537. X            outdated[ci][cj] = ALL;
  1538. X        }
  1539. X        else if (enable_anylocalmap && activecolor == none)
  1540. X        {
  1541. X          if (outdated[ci][cj] == OK)
  1542. X            outdated[ci][cj] = currentcolor;
  1543. X          else if (outdated[ci][cj] != currentcolor)
  1544. X            outdated[ci][cj] = ALL;
  1545. X        }
  1546. X        else if (activecolor == none && SQUARE(board,ci,cj)->growth > 50)
  1547. X        {
  1548. X          if (outdated[ci][cj] == OK)
  1549. X            outdated[ci][cj] = currentcolor;
  1550. X          else if (outdated[ci][cj] != currentcolor)
  1551. X            outdated[ci][cj] = ALL;
  1552. X        }
  1553. X        else if (currentcolor != ALL)
  1554. X        {
  1555. X          if (!SQUARE(board,ci,cj)->seen[currentcolor])
  1556. X          {
  1557. X            if (activecolor == none && enable_terrain) 
  1558. X            {
  1559. X              if (enable_sea && !enable_hills && !enable_forest)
  1560. X              {
  1561. X                if (SQUARE(board,ci,cj)->value[none] <= 0)
  1562. X                  outdated[ci][cj] = currentcolor;
  1563. X              }
  1564. X              else
  1565. X                outdated[ci][cj] = currentcolor;
  1566. X            }
  1567. X          }
  1568. X        }
  1569. X        
  1570. X        if (currentcolor != ALL)
  1571. X          SQUARE(board,ci,cj)->seen[currentcolor] = TRUE;
  1572. X      }
  1573. X  }
  1574. X  else
  1575. X  {
  1576. X    if (enable_hex)
  1577. X    {
  1578. X      i1 = 0;
  1579. X      i2 = 0;
  1580. X      j1 = 0;
  1581. X      j2 = hex_horizon_number-1;
  1582. X    }
  1583. X    else
  1584. X    {
  1585. X      i1 = (i1<0) ? 0 : i1;
  1586. X      i2 = (i2>boardsizex-1) ? boardsizex-1 : i2;
  1587. X      j1 = (j1<0) ? 0 : j1;
  1588. X      j2 = (j2>boardsizey-1) ? boardsizey-1 : j2;
  1589. X    }
  1590. X
  1591. X    for (i=i1; i<=i2; i++)
  1592. X      for (j=j1; j<=j2; j++)
  1593. X      {
  1594. X        if (enable_hex)
  1595. X        {
  1596. X          if (x%2 == 0)
  1597. X          {
  1598. X            ipos = x + hex_horizon_even[j][0];
  1599. X            jpos = y + hex_horizon_even[j][1];
  1600. X          }
  1601. X          else
  1602. X          {
  1603. X            ipos = x + hex_horizon_odd[j][0];
  1604. X            jpos = y + hex_horizon_odd[j][1];
  1605. X          }
  1606. X
  1607. X          ipos = (ipos<0) ? 0 : ipos;
  1608. X          ipos = (ipos>boardsizex-1) ? boardsizex-1 : ipos;
  1609. X          jpos = (jpos<0) ? 0 : jpos;
  1610. X          jpos = (jpos>boardsizey-1) ? boardsizey-1 : jpos;
  1611. X        }
  1612. X        else
  1613. X        {
  1614. X          ipos = i;
  1615. X          jpos = j;
  1616. X        }
  1617. X
  1618. X        activecolor = SQUARE(board,ipos,jpos)->color;
  1619. X        if (activecolor != none && activecolor != currentcolor)
  1620. X        {
  1621. X          if (outdated[ipos][jpos] == OK)
  1622. X            outdated[ipos][jpos] = currentcolor;
  1623. X          else if (outdated[ipos][jpos] != currentcolor)
  1624. X            outdated[ipos][jpos] = ALL;
  1625. X        }
  1626. X        else if (enable_anylocalmap && activecolor == none)
  1627. X        {
  1628. X          if (outdated[ipos][jpos] == OK)
  1629. X            outdated[ipos][jpos] = currentcolor;
  1630. X          else if (outdated[ipos][jpos] != currentcolor)
  1631. X            outdated[ipos][jpos] = ALL;
  1632. X        }
  1633. X        else if (activecolor == none && SQUARE(board,ipos,jpos)->growth > 50)
  1634. X        {
  1635. X          if (outdated[ipos][jpos] == OK)
  1636. X            outdated[ipos][jpos] = currentcolor;
  1637. X          else if (outdated[ipos][jpos] != currentcolor)
  1638. X            outdated[ipos][jpos] = ALL;
  1639. X        }
  1640. X        else if (currentcolor != ALL)
  1641. X        {
  1642. X          if (!(SQUARE(board,ipos,jpos)->seen[currentcolor]))
  1643. X          {
  1644. X            if (activecolor == none && enable_terrain) 
  1645. X            {
  1646. X              if (enable_sea && !enable_hills && !enable_forest)
  1647. X              {
  1648. X                if (SQUARE(board,ipos,jpos)->value[none] <= 0)
  1649. X                  outdated[ipos][jpos] = currentcolor;
  1650. X              }
  1651. X              else
  1652. X                outdated[ipos][jpos] = currentcolor;
  1653. X            }
  1654. X          }
  1655. X        }
  1656. X
  1657. X        if (currentcolor != ALL)
  1658. X          SQUARE(board,ipos,jpos)->seen[currentcolor] = TRUE;
  1659. X      }
  1660. X  }
  1661. X}
  1662. X
  1663. X
  1664. X#if VARMOUSE
  1665. X/*************************************************************************/
  1666. X/**   moveon                                                              **/
  1667. X/** set the move command fields in the square                             **/
  1668. X/**   J Greely <jgreely@cis.ohio-state.edu>                               **/
  1669. X/*************************************************************************/
  1670. Xmoveon(square,dir)
  1671. X  square_type *square;
  1672. X  int dir[DIRS];
  1673. X{
  1674. X  int i;
  1675. X
  1676. X  /**** set direction flags ****/
  1677. X  square->move = 0;
  1678. X  for (i=0;i<directions;i++)
  1679. X  {
  1680. X    if (dir[i])
  1681. X      square->dir[i] = 1;;
  1682. X    square->move += square->dir[i];
  1683. X  }
  1684. X}
  1685. X#else
  1686. X/*************************************************************************/
  1687. X/**    setmove                                **/
  1688. X/** set the move command fields in the square                **/
  1689. X/**    Steve Lehar (slehar@park.bu.edu)                **/
  1690. X/*************************************************************************/
  1691. Xsetmove(square,dir)
  1692. X  square_type *square;
  1693. X  int dir[DIRS];
  1694. X{
  1695. X  int i;
  1696. X
  1697. X  /**** set direction flags ****/
  1698. X  square->move = 0;
  1699. X  for (i=0;i<directions;i++)
  1700. X  {
  1701. X    if (dir[i])
  1702. X    {
  1703. X      if (square->dir[i])
  1704. X        square->dir[i] = 0;
  1705. X      else
  1706. X        square->dir[i] = 1;
  1707. X    }
  1708. X    if (square->dir[i])
  1709. X    {
  1710. X      square->move ++;
  1711. X    }
  1712. X  }
  1713. X}
  1714. X#endif
  1715. X
  1716. X
  1717. X#if VARMOUSE
  1718. X/*************************************************************************/
  1719. X/**   moveoff                                                             **/
  1720. X/** unset the move command fields in the square                **/
  1721. X/**   J Greely <jgreely@cis.ohio-state.edu>                               **/
  1722. X/*************************************************************************/
  1723. Xmoveoff(square,dir)
  1724. X  square_type *square;
  1725. X  int dir[DIRS];
  1726. X{
  1727. X  int i;
  1728. X
  1729. X  /**** set direction flags ****/
  1730. X  square->move = 0;
  1731. X  for (i=0;i<directions;i++)
  1732. X  {
  1733. X    if (dir[i])
  1734. X      square->dir[i] = 0;
  1735. X    square->move += square->dir[i];
  1736. X  }
  1737. X}
  1738. X#else
  1739. X/*************************************************************************/
  1740. X/**    forcemove                            **/
  1741. X/** clear existing move commands and set the new one.            **/
  1742. X/**    Steve Lehar (slehar@park.bu.edu)                **/
  1743. X/*************************************************************************/
  1744. Xforcemove(square,dir)
  1745. X  square_type *square;
  1746. X  int dir[DIRS];
  1747. X{
  1748. X  int i;
  1749. X
  1750. X  /**** set direction flags ****/
  1751. X  square->move = 0;
  1752. X  for (i=0; i<directions; i++)
  1753. X  {
  1754. X    if (dir[i])
  1755. X      square->dir[i] = 1;
  1756. X    else
  1757. X      square->dir[i] = 0;
  1758. X    if (square->dir[i])
  1759. X    {
  1760. X      square->move ++;
  1761. X    }
  1762. X  }
  1763. X}
  1764. X#endif
  1765. END_OF_FILE
  1766. if test 39423 -ne `wc -c <'update.c'`; then
  1767.     echo shar: \"'update.c'\" unpacked with wrong size!
  1768. fi
  1769. # end of 'update.c'
  1770. fi
  1771. echo shar: End of archive 1 \(of 7\).
  1772. cp /dev/null ark1isdone
  1773. MISSING=""
  1774. for I in 1 2 3 4 5 6 7 ; do
  1775.     if test ! -f ark${I}isdone ; then
  1776.     MISSING="${MISSING} ${I}"
  1777.     fi
  1778. done
  1779. if test "${MISSING}" = "" ; then
  1780.     echo You have unpacked all 7 archives.
  1781.     rm -f ark[1-9]isdone
  1782. else
  1783.     echo You still need to unpack the following archives:
  1784.     echo "        " ${MISSING}
  1785. fi
  1786. ##  End of shell archive.
  1787. exit 0
  1788.