home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume13 / x4war2 / part01 < prev    next >
Encoding:
Text File  |  1992-08-02  |  52.0 KB  |  1,752 lines

  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: v13i082:  x4war2 - An X11 version of Chinese four-state war game (Ver. 1.1), Part01/04
  5. Message-ID: <2793@master.CNA.TEK.COM>
  6. Date: 25 Apr 92 00:49:20 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1741
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Xiaobing Chen <xiaobing@cs.sfu.ca>
  12. Posting-number: Volume 13, Issue 82
  13. Archive-name: x4war2/Part01
  14. Supersedes: x4war: Volume 13, Issue 77-79
  15. Environment: X11, Xlib, Xt
  16.  
  17.     [This is an updated version of the previously posted 'x4war'. In
  18.      addition to feature enhancements and bugfixes, it includes a set
  19.      of pictoral bitmaps in addition to the original chinese character
  20.      bitmaps. (Comment out the -DCHINESE define in the [I]Makefile.)
  21.             -br]
  22.  
  23. #! /bin/sh
  24. # This is a shell archive.  Remove anything before this line, then unpack
  25. # it by saving it into a file and typing "sh file".  To overwrite existing
  26. # files, type "sh file -c".  You can also feed this as standard input via
  27. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  28. # will see the following message at the end:
  29. #        "End of archive 1 (of 4)."
  30. # Contents:  README MANIFEST bgbitmap.c bitmaps bitmaps/chinese_piece
  31. #   bitmaps/image_piece bitmaps/war_logo.xbm war.c war.h
  32. # Wrapped by billr@saab on Fri Apr 24 17:36:55 1992
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. if test -f 'README' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'README'\"
  36. else
  37. echo shar: Extracting \"'README'\" \(3469 characters\)
  38. sed "s/^X//" >'README' <<'END_OF_FILE'
  39. Xx4war - An X11 version of Chinese four-state war game.
  40. X
  41. X
  42. XWHAT IS IT?
  43. X
  44. XThis is a board game which implements the Chinese four-state war game in the
  45. XX Window environment. It allows four players to play the game on four displays,
  46. Xeach coordinating a complete army, players at the opposite position of the
  47. Xplaying board are allied. The goal of the game is to capture the COLOURS of
  48. Xthe enemy.
  49. X
  50. XI heard it's sort of like the American game 'stratego'.
  51. X
  52. X
  53. XCOMPILING
  54. X
  55. XThe program is implemented using Xlib and Xt. It should be compilable in
  56. Xmost of  X11/R4 environment. Presently the program is tested only under
  57. XSunOS 4.1.1 and IRIX 4.0.1 System V.
  58. X
  59. XThere are two sets of bitmaps which can be used for the faces of pieces, one
  60. Xis in Chiese characters under subdirectory ./bitmaps/chinese_piece, the other
  61. Xis drawings under subdirectory ./bitmaps/image_piece. When you
  62. Xcompile, you can select one of the bitmaps set.
  63. X
  64. X
  65. X1) select a set of bitmaps
  66. X
  67. XIf you want to use the Chinese character bitmaps, nothing needs to be changed.
  68. X
  69. XIf you want to use the image bitmaps, edit Makefile.simple to define DEFS to
  70. Xempty, or comment out DEFINES definition in Imakefile if you use Imakefile.
  71. X
  72. X
  73. X2) compilation.
  74. X
  75. XIf you use Makefile.simple, the steps are as follows:
  76. X
  77. X    %make -f Makefile.simple bgbitmap
  78. X        to get 'bgbitmap' for creating the background of the board.
  79. X
  80. X    %bgbitmap
  81. X        wait for a second and a background bitmap file called
  82. X        'war_background.xbm' will be created in the bitmaps
  83. X        subdirectory.
  84. X
  85. X    %make -f Makefile.simple
  86. X        this will get you the 'x4war' executable.
  87. X
  88. X
  89. XIf you use Imakefile, you can type 'xmkmf' to get a Makefile, then use the above
  90. Xcommands for Makefile.simple with '-f Makefile.simple' omitted.
  91. X
  92. XThe file 'x4war' is enough for the game. Other files can be removed after you
  93. Xget the 'x4war' file.
  94. X
  95. X
  96. XUSAGE
  97. X
  98. XType 'x4war -usage' to get command options.
  99. X
  100. XFor the meaning of the pieces and rules of the game, please consult one who can
  101. Xread Chinese characters and knows the conventional rules. Also read x4war.man
  102. Xfor detail.
  103. X
  104. X
  105. XACKNOWLEDGEMENTS
  106. X
  107. XSpecial thanks to Zhongmin Guo, Bo Wang, Ju Wu, and Danpo Zhang, who created
  108. Xmost of the bitmaps and had given many valuable suggestions. And many thanks
  109. Xto my fellow students at School of Computing Science and Engineering Science,
  110. XSimon Fraser University, who had helped to test the program and given all
  111. Xkinds of support.
  112. X
  113. XI'm also grateful to those who, after the first release of the program, 
  114. Xcommunicated with me via e-mail and gave me suggestions about the program.
  115. XEspecially to Reece Peacock (nrp@btcase.bt.co.uk), who provided most of the
  116. Xbitmaps in ./bitmaps/image_piece, and kindly granted me the permission to
  117. Xdistribute them to the public.
  118. X
  119. X
  120. XCOPYRIGHT
  121. X
  122. XCopyright 1992 by Xiaobing Chen
  123. X
  124. XPermission to use, copy, and distribute for non-commercial purposes,
  125. Xis hereby granted without fee, providing that the above copyright
  126. Xnotice appear in all copies and that both the copyright notice and this
  127. Xpermission notice appear in supporting documentation. 
  128. X
  129. XThe software may be modified for your own purposes, but modified versions
  130. Xmay not be distributed without prior consent of the the author.
  131. X
  132. XThis software is provided "as is" without any expressed or implied warranty.
  133. X
  134. XThe author may be contacted via:
  135. X    Address:   Xiaobing Chen
  136. X               School of Computing Science
  137. X               Simon Fraser University  
  138. X               Burnaby, B.C.,  V5A 1S6
  139. X           Canada
  140. X
  141. X    EMail:     xiaobing@cs.sfu.ca       
  142. X
  143. X
  144. X
  145. X
  146. END_OF_FILE
  147. if test 3469 -ne `wc -c <'README'`; then
  148.     echo shar: \"'README'\" unpacked with wrong size!
  149. fi
  150. # end of 'README'
  151. fi
  152. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  153.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  154. else
  155. echo shar: Extracting \"'MANIFEST'\" \(1770 characters\)
  156. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  157. X   File Name        Archive #    Description
  158. X-----------------------------------------------------------
  159. X Imakefile                  4    
  160. X MANIFEST                   1    This shipping list
  161. X Makefile.simple            4    
  162. X Patchlevel                 4    
  163. X README                     1    
  164. X bgbitmap.c                 1    
  165. X bitmaps                    1    
  166. X bitmaps/back0.xbm          4    
  167. X bitmaps/back1.xbm          4    
  168. X bitmaps/back2.xbm          4    
  169. X bitmaps/back3.xbm          4    
  170. X bitmaps/chinese_piece      1    
  171. X bitmaps/chinese_piece/bomb.xbm  3    
  172. X bitmaps/chinese_piece/brigadier.xbm  3    
  173. X bitmaps/chinese_piece/captain.xbm  3    
  174. X bitmaps/chinese_piece/colonel.xbm  3    
  175. X bitmaps/chinese_piece/colours.xbm  3    
  176. X bitmaps/chinese_piece/f_lieutenant.xbm  3    
  177. X bitmaps/chinese_piece/general.xbm  3    
  178. X bitmaps/chinese_piece/m_general.xbm  3    
  179. X bitmaps/chinese_piece/major.xbm  3    
  180. X bitmaps/chinese_piece/marshal.xbm  3    
  181. X bitmaps/chinese_piece/mine.xbm  3    
  182. X bitmaps/chinese_piece/sapper.xbm  3    
  183. X bitmaps/cursor.xbm         4    
  184. X bitmaps/cursormask.xbm     2    
  185. X bitmaps/go.xbm             3    
  186. X bitmaps/image_piece        1    
  187. X bitmaps/image_piece/bomb.xbm  3    
  188. X bitmaps/image_piece/brigadier.xbm  3    
  189. X bitmaps/image_piece/captain.xbm  3    
  190. X bitmaps/image_piece/colonel.xbm  3    
  191. X bitmaps/image_piece/colours.xbm  3    
  192. X bitmaps/image_piece/f_lieutenant.xbm  3    
  193. X bitmaps/image_piece/general.xbm  3    
  194. X bitmaps/image_piece/m_general.xbm  3    
  195. X bitmaps/image_piece/major.xbm  3    
  196. X bitmaps/image_piece/marshal.xbm  3    
  197. X bitmaps/image_piece/mine.xbm  4    
  198. X bitmaps/image_piece/sapper.xbm  3    
  199. X bitmaps/nodemask.xbm       3    
  200. X bitmaps/pillar.xbm         4    
  201. X bitmaps/stop.xbm           2    
  202. X bitmaps/war_logo.xbm       1    
  203. X war.c                      1    
  204. X war.h                      1    
  205. X x4war.c                    2    
  206. X x4war.man                  3    
  207. END_OF_FILE
  208. if test 1770 -ne `wc -c <'MANIFEST'`; then
  209.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  210. fi
  211. # end of 'MANIFEST'
  212. fi
  213. if test -f 'bgbitmap.c' -a "${1}" != "-c" ; then 
  214.   echo shar: Will not clobber existing file \"'bgbitmap.c'\"
  215. else
  216. echo shar: Extracting \"'bgbitmap.c'\" \(14959 characters\)
  217. sed "s/^X//" >'bgbitmap.c' <<'END_OF_FILE'
  218. X#include <X11/Xlib.h>
  219. X#include <X11/Xutil.h>
  220. X#include <X11/Xos.h>
  221. X#include <X11/Xatom.h>
  222. X
  223. X#include <stdio.h>
  224. X
  225. X#include "war.h"
  226. X
  227. XDisplay *display;
  228. Xint screen_num;
  229. XGC gc, undraw_gc;
  230. XPixmap pixmap;
  231. X
  232. X
  233. Xvoid main(argc, argv)
  234. Xint argc;
  235. Xchar **argv;
  236. X{
  237. X    XFontStruct *font_info;
  238. X    XGCValues values;
  239. X
  240. X    if ((display = XOpenDisplay(NULL)) == NULL) {
  241. X        fprintf(stderr, "cannot open display\n");
  242. X        exit(-1);
  243. X    }
  244. X    screen_num = DefaultScreen(display);
  245. X
  246. X    pixmap = XCreatePixmap(display, RootWindow(display, screen_num),
  247. X        DIMENSION, DIMENSION, 1);
  248. X
  249. X    font_info = XLoadQueryFont(display, "9x15bold");
  250. X
  251. X    values.arc_mode = ArcChord;
  252. X
  253. X    values.foreground = 0;
  254. X    values.background = 1;
  255. X    undraw_gc = XCreateGC(display, pixmap, GCForeground | GCBackground |
  256. X        GCArcMode, &values);
  257. X
  258. X    values.foreground = 1;
  259. X    values.background = 0;
  260. X
  261. X    values.font = font_info->fid;
  262. X    gc = XCreateGC(display, pixmap, GCForeground|GCBackground|GCFont,
  263. X        &values);
  264. X
  265. X    printf("'war_background.xbm' file will be created at ./bitmaps\n");
  266. X    printf("please wait a second...\n");
  267. X    draw();
  268. X
  269. X    XWriteBitmapFile(display, "war_background", pixmap,
  270. X            DIMENSION, DIMENSION, -1, -1);
  271. X    system("mv ./war_background ./bitmaps/war_background.xbm");
  272. X
  273. X    printf("completed!\n");
  274. X
  275. X    XUnloadFont(display, font_info->fid);
  276. X    XFreeGC(display, gc);
  277. X    XFreeGC(display, undraw_gc);
  278. X    XCloseDisplay(display);
  279. X    exit(0);
  280. X}
  281. X
  282. X
  283. X
  284. Xdraw()
  285. X{
  286. X    static unsigned char dash_list[] = {10, 10};
  287. X    int i, j;
  288. X
  289. X    XFillRectangle(display, pixmap, undraw_gc, 0, 0, DIMENSION, DIMENSION);
  290. X
  291. X    XDrawString(display, pixmap, gc, 110, 575, "DEATH ANGEL", 11);
  292. X    XDrawString(display, pixmap, gc, 695, 628, "NEW GAME", 8);
  293. X    XDrawString(display, pixmap, gc, 695, 668, "START WAR", 9);
  294. X    XDrawString(display, pixmap, gc, 695, 708, "REDEPLOY", 8);
  295. X    XDrawString(display, pixmap, gc, 695, 748, "PEACE", 5);
  296. X    XDrawString(display, pixmap, gc, 695, 788, "SURRENDER", 9);
  297. X    XDrawString(display, pixmap, gc, 695, 828, "QUIT", 4);
  298. X
  299. X    XSetLineAttributes(display, gc, 5, LineOnOffDash, CapButt, JoinMiter);
  300. X    XSetDashes(display, gc, 0, dash_list, 2);
  301. X
  302. X    XDrawLine(display, pixmap, gc, P3, P1+50, P3, P6-50);
  303. X    XDrawLine(display, pixmap, gc, P4, P1+50, P4, P6-50);
  304. X    XDrawLine(display, pixmap, gc, P1+50, P3, P6-50, P3);
  305. X    XDrawLine(display, pixmap, gc, P1+50, P4, P6-50, P4);
  306. X
  307. X    XDrawLine(display, pixmap, gc, P3, P1+50, P4, P1+50);
  308. X    XDrawLine(display, pixmap, gc, P3, P2, P4, P2);
  309. X    XDrawLine(display, pixmap, gc, P3, P5, P4, P5);
  310. X    XDrawLine(display, pixmap, gc, P3, P6-50, P4, P6-50);
  311. X
  312. X    XDrawLine(display, pixmap, gc, P1+50, P3, P1+50, P4);
  313. X    XDrawLine(display, pixmap, gc, P2, P3, P2, P4);
  314. X    XDrawLine(display, pixmap, gc, P5, P3, P5, P4);
  315. X    XDrawLine(display, pixmap, gc, P6-50, P3, P6-50, P4);
  316. X
  317. X    XDrawLine(display, pixmap, gc, P2, P3+100, P5, P3+100);
  318. X    XDrawLine(display, pixmap, gc, P3+100, P2, P3+100, P5);
  319. X
  320. X    XDrawArc(display, pixmap, gc, P2-50, P2-50, 100, 100, 0, -90*64);
  321. X    XDrawArc(display, pixmap, gc, P4, P2-50, 100, 100, 180*64, 90*64);
  322. X    XDrawArc(display, pixmap, gc, P2-50, P4, 100, 100, 0, 90*64);
  323. X    XDrawArc(display, pixmap, gc, P4, P4, 100, 100, 90*64, 90*64);
  324. X
  325. X    XSetLineAttributes(display, gc, 1, LineSolid, CapButt, JoinRound);
  326. X
  327. X    XDrawArc(display, pixmap, gc, P2-52, P2-52, 104, 104, 0, -90*64);
  328. X    XDrawArc(display, pixmap, gc, P2-48, P2-48,  96,  96, 0, -90*64);
  329. X    XDrawArc(display, pixmap, gc, P4-2, P2-52, 104, 104, 180*64, 90*64);
  330. X    XDrawArc(display, pixmap, gc, P4+2, P2-48,  96,  96, 180*64, 90*64);
  331. X    XDrawArc(display, pixmap, gc, P2-52, P4-2, 104, 104, 0, 90*64);
  332. X    XDrawArc(display, pixmap, gc, P2-48, P4+2,  96,  96, 0, 90*64);
  333. X    XDrawArc(display, pixmap, gc, P4-2, P4-2, 104, 104, 90*64, 90*64);
  334. X    XDrawArc(display, pixmap, gc, P4+2, P4+2,  96,  96, 90*64, 90*64);
  335. X
  336. X    XDrawLine(display, pixmap, gc, P3-2, P1+50, P3-2, P6-50);
  337. X    XDrawLine(display, pixmap, gc, P3+2, P1+50, P3+2, P6-50);
  338. X    XDrawLine(display, pixmap, gc, P4-2, P1+50, P4-2, P6-50);
  339. X    XDrawLine(display, pixmap, gc, P4+2, P1+50, P4+2, P6-50);
  340. X    XDrawLine(display, pixmap, gc, P1+50, P3-2, P6-50, P3-2);
  341. X    XDrawLine(display, pixmap, gc, P1+50, P3+2, P6-50, P3+2);
  342. X    XDrawLine(display, pixmap, gc, P1+50, P4-2, P6-50, P4-2);
  343. X    XDrawLine(display, pixmap, gc, P1+50, P4+2, P6-50, P4+2);
  344. X
  345. X    XDrawLine(display, pixmap, gc, P3, P1+48, P4, P1+48);
  346. X    XDrawLine(display, pixmap, gc, P3, P1+52, P4, P1+52);
  347. X    XDrawLine(display, pixmap, gc, P3, P2-2, P4, P2-2);
  348. X    XDrawLine(display, pixmap, gc, P3, P2+2, P4, P2+2);
  349. X    XDrawLine(display, pixmap, gc, P3, P5-2, P4, P5-2);
  350. X    XDrawLine(display, pixmap, gc, P3, P5+2, P4, P5+2);
  351. X    XDrawLine(display, pixmap, gc, P3, P6-52, P4, P6-52);
  352. X    XDrawLine(display, pixmap, gc, P3, P6-48, P4, P6-48);
  353. X
  354. X    XDrawLine(display, pixmap, gc, P1+48, P3, P1+48, P4);
  355. X    XDrawLine(display, pixmap, gc, P1+52, P3, P1+52, P4);
  356. X    XDrawLine(display, pixmap, gc, P2-2, P3, P2-2, P4);
  357. X    XDrawLine(display, pixmap, gc, P2+2, P3, P2+2, P4);
  358. X    XDrawLine(display, pixmap, gc, P5-2, P3, P5-2, P4);
  359. X    XDrawLine(display, pixmap, gc, P5+2, P3, P5+2, P4);
  360. X    XDrawLine(display, pixmap, gc, P6-48, P3, P6-48, P4);
  361. X    XDrawLine(display, pixmap, gc, P6-52, P3, P6-52, P4);
  362. X
  363. X    XDrawLine(display, pixmap, gc, P2, P3+98, P5, P3+98);
  364. X    XDrawLine(display, pixmap, gc, P2, P3+102, P5, P3+102);
  365. X    XDrawLine(display, pixmap, gc, P3+98, P2, P3+98, P5);
  366. X    XDrawLine(display, pixmap, gc, P3+102, P2, P3+102, P5);
  367. X
  368. X    for (i=RIP_Y+50; i<RIP_Y+RIP_DIMENSION; i += 50)
  369. X    XDrawLine(display, pixmap, gc, P1, i, P1+RIP_DIMENSION, i);
  370. X    for (i=P1+50; i<P1+RIP_DIMENSION; i += 50)
  371. X    XDrawLine(display, pixmap, gc, i, RIP_Y, i, RIP_Y+RIP_DIMENSION);
  372. X
  373. X    for (i=P3+50; i<P4; i += 50)
  374. X    XDrawLine(display, pixmap, gc, i, P5, i, P6);
  375. X    for (i=P5+50; i<P6-50; i += 50)
  376. X    XDrawLine(display, pixmap, gc, P3, i, P4, i);
  377. X    XDrawLine(display, pixmap, gc, P3, P5, P4, P6-50);
  378. X    XDrawLine(display, pixmap, gc, P3, P5+100, P3+100, P6-50);
  379. X    XDrawLine(display, pixmap, gc, P3+100, P5, P4, P5+100);
  380. X    XDrawLine(display, pixmap, gc, P3, P6-50, P4, P5);
  381. X    XDrawLine(display, pixmap, gc, P3, P5+100, P3+100, P5);
  382. X    XDrawLine(display, pixmap, gc, P3+100, P6-50, P4, P5+100);
  383. X
  384. X    for (i=P3+50; i<P4; i += 50)
  385. X    XDrawLine(display, pixmap, gc, i, P1, i, P2);
  386. X    for (i=P1+100; i<P2; i += 50)
  387. X    XDrawLine(display, pixmap, gc, P3, i, P4, i);
  388. X    XDrawLine(display, pixmap, gc, P3, P1+50, P4, P2);
  389. X    XDrawLine(display, pixmap, gc, P3, P2-100, P3+100, P2);
  390. X    XDrawLine(display, pixmap, gc, P3+100, P1+50, P4, P2-100);
  391. X    XDrawLine(display, pixmap, gc, P3, P2-100, P3+100, P1+50);
  392. X    XDrawLine(display, pixmap, gc, P3, P2, P4, P1+50);
  393. X    XDrawLine(display, pixmap, gc, P3+100, P2, P4, P2-100);
  394. X
  395. X    for (i=P3+50; i<P4; i += 50)
  396. X    XDrawLine(display, pixmap, gc, P1, i, P2, i);
  397. X    for (i=P1+100; i<P2; i += 50)
  398. X    XDrawLine(display, pixmap, gc, i, P3, i, P4);
  399. X    XDrawLine(display, pixmap, gc, P1+50, P3+100, P2-100, P4);
  400. X    XDrawLine(display, pixmap, gc, P1+50, P3, P2, P4);
  401. X    XDrawLine(display, pixmap, gc, P2-100, P3, P2, P3+100);
  402. X    XDrawLine(display, pixmap, gc, P1+50, P3+100, P2-100, P3);
  403. X    XDrawLine(display, pixmap, gc, P2, P3, P1+50, P4);
  404. X    XDrawLine(display, pixmap, gc, P2-100, P4, P2, P3+100);
  405. X
  406. X    for (i=P3+50; i<P4; i += 50)
  407. X    XDrawLine(display, pixmap, gc, P5, i, P6, i);
  408. X    for (i=P5+50; i<P6-50; i += 50)
  409. X    XDrawLine(display, pixmap, gc, i, P3, i, P4);
  410. X    XDrawLine(display, pixmap, gc, P5, P3+100, P5+100, P4);
  411. X    XDrawLine(display, pixmap, gc, P5, P3, P6-50, P4);
  412. X    XDrawLine(display, pixmap, gc, P5+100, P3, P6-50, P3+100);
  413. X    XDrawLine(display, pixmap, gc, P5, P3+100, P5+100, P3);
  414. X    XDrawLine(display, pixmap, gc, P5, P4, P6-50, P3);
  415. X    XDrawLine(display, pixmap, gc, P5+100, P4, P6-50, P3+100);
  416. X
  417. X    XSetLineAttributes(display, gc, 3, LineSolid, CapButt, JoinRound);
  418. X
  419. X    XDrawRectangle(display, pixmap, gc, TALK_L_X,TALK_Y,TALK_WIDTH,TALK_HEIGHT);
  420. X    XDrawRectangle(display, pixmap, gc, TALK_L_X, TALK_Y+90,
  421. X        TALK_WIDTH, TALK_HEIGHT);
  422. X    XDrawRectangle(display, pixmap, gc, TALK_R_X,TALK_Y,TALK_WIDTH,TALK_HEIGHT);
  423. X    XDrawRectangle(display, pixmap, gc, TALK_R_X, TALK_Y+90,
  424. X        TALK_WIDTH, TALK_HEIGHT);
  425. X
  426. X    XDrawRectangle(display, pixmap, gc, P1, P1, 66, 66);
  427. X    XDrawRectangle(display, pixmap, gc, MSG_BOX_X, MSG_BOX_Y,
  428. X        MSG_WIDTH, MSG_HEIGHT);
  429. X
  430. X    XDrawLine(display, pixmap, gc, P3-1, P1-1, P3-1, P1+50);
  431. X    XDrawLine(display, pixmap, gc, P4+1, P1-1, P4+1, P1+50);
  432. X    XDrawLine(display, pixmap, gc, P3-1, P1-1, P4+1, P1-1);
  433. X
  434. X    XDrawLine(display, pixmap, gc, P3-1, P6-50, P3-1, P6+1);
  435. X    XDrawLine(display, pixmap, gc, P4+1, P6-50, P4+1, P6+1);
  436. X    XDrawLine(display, pixmap, gc, P3-1, P6+1, P4+1, P6+1);
  437. X
  438. X    XDrawLine(display, pixmap, gc, P6-50, P3-1, P6+1, P3-1);
  439. X    XDrawLine(display, pixmap, gc, P6-50, P4+1, P6+1, P4+1);
  440. X    XDrawLine(display, pixmap, gc, P6+1, P3-1, P6+1, P4+1);
  441. X
  442. X    XDrawLine(display, pixmap, gc, P1-1, P3-1, P1+50, P3-1);
  443. X    XDrawLine(display, pixmap, gc, P1-1, P4+1, P1+50, P4+1);
  444. X    XDrawLine(display, pixmap, gc, P1-1, P3-1, P1-1, P4+1);
  445. X
  446. X    XDrawRectangle(display, pixmap, gc, P1, RIP_Y, 
  447. X    RIP_DIMENSION-1,RIP_DIMENSION-1);
  448. X
  449. X    for (i=NEW_Y; i<=NEW_Y+BUTTON_DIS*5; i += BUTTON_DIS)
  450. X    XDrawRectangle(display, pixmap, gc, BUTTON_X, i,
  451. X        BUTTON_WIDTH, BUTTON_HEIGHT);
  452. X
  453. X    XSetLineAttributes(display, gc, 2, LineSolid, CapButt, JoinRound);
  454. X
  455. X    XFillArc(display, pixmap, undraw_gc, P3+30, P1+80, 40, 40, 0, 360*64);
  456. X    XDrawArc(display, pixmap, gc, P3+30, P1+80, 40, 40, 0, 360*64);
  457. X    XFillArc(display, pixmap, undraw_gc, P4-70, P1+80, 40, 40, 0, 360*64);
  458. X    XDrawArc(display, pixmap, gc, P4-70, P1+80, 40, 40, 0, 360*64);
  459. X    XFillArc(display, pixmap, undraw_gc, P3+80, P2-120, 40, 40, 0, 360*64);
  460. X    XDrawArc(display, pixmap, gc, P3+80, P2-120, 40, 40, 0, 360*64);
  461. X    XFillArc(display, pixmap, undraw_gc, P3+30, P2-70, 40, 40, 0, 360*64);
  462. X    XDrawArc(display, pixmap, gc, P3+30, P2-70, 40, 40, 0, 360*64);
  463. X    XFillArc(display, pixmap, undraw_gc, P4-70, P2-70, 40, 40, 0, 360*64);
  464. X    XDrawArc(display, pixmap, gc, P4-70, P2-70, 40, 40, 0, 360*64);
  465. X
  466. X    XFillArc(display, pixmap, undraw_gc, P5+30, P3+30, 40, 40, 0, 360*64);
  467. X    XDrawArc(display, pixmap, gc, P5+30, P3+30, 40, 40, 0, 360*64);
  468. X    XFillArc(display, pixmap, undraw_gc, P5+30, P4-70, 40, 40, 0, 360*64);
  469. X    XDrawArc(display, pixmap, gc, P5+30, P4-70, 40, 40, 0, 360*64);
  470. X    XFillArc(display, pixmap, undraw_gc, P5+80, P3+80, 40, 40, 0, 360*64);
  471. X    XDrawArc(display, pixmap, gc, P5+80, P3+80, 40, 40, 0, 360*64);
  472. X    XFillArc(display, pixmap, undraw_gc, P6-120, P3+30, 40, 40, 0, 360*64);
  473. X    XDrawArc(display, pixmap, gc, P6-120, P3+30, 40, 40, 0, 360*64);
  474. X    XFillArc(display, pixmap, undraw_gc, P6-120, P4-70, 40, 40, 0, 360*64);
  475. X    XDrawArc(display, pixmap, gc, P6-120, P4-70, 40, 40, 0, 360*64);
  476. X
  477. X    XFillArc(display, pixmap, undraw_gc, P1+80, P3+30, 40, 40, 0, 360*64);
  478. X    XDrawArc(display, pixmap, gc, P1+80, P3+30, 40, 40, 0, 360*64);
  479. X    XFillArc(display, pixmap, undraw_gc, P1+80, P4-70, 40, 40, 0, 360*64);
  480. X    XDrawArc(display, pixmap, gc, P1+80, P4-70, 40, 40, 0, 360*64);
  481. X    XFillArc(display, pixmap, undraw_gc, P1+130, P3+80, 40, 40, 0, 360*64);
  482. X    XDrawArc(display, pixmap, gc, P1+130, P3+80, 40, 40, 0, 360*64);
  483. X    XFillArc(display, pixmap, undraw_gc, P2-70, P3+30, 40, 40, 0, 360*64);
  484. X    XDrawArc(display, pixmap, gc, P2-70, P3+30, 40, 40, 0, 360*64);
  485. X    XFillArc(display, pixmap, undraw_gc, P2-70, P4-70, 40, 40, 0, 360*64);
  486. X    XDrawArc(display, pixmap, gc, P2-70, P4-70, 40, 40, 0, 360*64);
  487. X
  488. X    XFillArc(display, pixmap, undraw_gc, P3+30, P5+30, 40, 40, 0, 360*64);
  489. X    XDrawArc(display, pixmap, gc, P3+30, P5+30, 40, 40, 0, 360*64);
  490. X    XFillArc(display, pixmap, undraw_gc, P3+30, P6-120, 40, 40, 0, 360*64);
  491. X    XDrawArc(display, pixmap, gc, P3+30, P6-120, 40, 40, 0, 360*64);
  492. X    XFillArc(display, pixmap, undraw_gc, P3+80, P5+80, 40, 40, 0, 360*64);
  493. X    XDrawArc(display, pixmap, gc, P3+80, P5+80, 40, 40, 0, 360*64);
  494. X    XFillArc(display, pixmap, undraw_gc, P4-70, P5+30, 40, 40, 0, 360*64);
  495. X    XDrawArc(display, pixmap, gc, P4-70, P5+30, 40, 40, 0, 360*64);
  496. X    XFillArc(display, pixmap, undraw_gc, P4-70, P6-120, 40, 40, 0, 360*64);
  497. X    XDrawArc(display, pixmap, gc, P4-70, P6-120, 40, 40, 0, 360*64);
  498. X
  499. X    for (i=P3-15; i<P4; i += 100)
  500. X      for (j=P3-15; j<P4; j += 100) {
  501. X    XFillRectangle(display, pixmap, undraw_gc, i, j, 30, 30);
  502. X    XDrawRectangle(display, pixmap, gc, i, j, 29, 29);
  503. X    }
  504. X
  505. X    for (i=P3-20; i<P4; i += 50)
  506. X      for (j=P5-10; j<P6; j += 50)
  507. X    if (i==P3+30 && j==P5+40 || i==P4-70 && j==P5+40 ||
  508. X        i==P3+80 && j==P5+90 ||
  509. X        i==P3+30 && j==P6-110 || i==P4-70 && j==P6-110 )
  510. X        ;
  511. X    else {
  512. X        XFillRectangle(display, pixmap, undraw_gc, i, j, 40, 20);
  513. X        XDrawRectangle(display, pixmap, gc, i, j, 40, 20);
  514. X    }
  515. X
  516. X    for (i=P3-20; i<P4; i += 50)
  517. X      for (j=P1-10; j<P2; j += 50)
  518. X    if (i==P3+30 && j==P1+90 || i==P4-70 && j==P1+90 ||
  519. X        i==P3+80 && j==P2-110 ||
  520. X        i==P3+30 && j==P2-60 || i==P4-70 && j==P2-60 )
  521. X        ;
  522. X    else {
  523. X        XFillRectangle(display, pixmap, undraw_gc, i, j, 40, 20);
  524. X        XDrawRectangle(display, pixmap, gc, i, j, 40, 20);
  525. X    }
  526. X
  527. X    for (i=P1-10; i<P2; i += 50)
  528. X      for (j=P3-20; j<P4; j += 50)
  529. X    if (i==P1+90 && j==P3+30 || i==P2-60 && j==P3+30 ||
  530. X        i==P2-110 && j==P3+80 ||
  531. X        i==P1+90 && j==P4-70 || i==P2-60 && j==P4-70)
  532. X        ;
  533. X    else {
  534. X        XFillRectangle(display, pixmap, undraw_gc, i, j, 20, 40);
  535. X        XDrawRectangle(display, pixmap, gc, i, j, 20, 40);
  536. X    }
  537. X
  538. X    for (i=P5-10; i<P6; i += 50)
  539. X      for (j=P3-20; j<P4; j += 50)
  540. X    if (i==P5+40 && j==P3+30 || i==P6-110 && j==P3+30 ||
  541. X        i==P5+90 && j==P3+80 ||
  542. X        i==P5+40 && j==P4-70 || i==P6-110 && j==P4-70)
  543. X        ;
  544. X    else {
  545. X        XFillRectangle(display, pixmap, undraw_gc, i, j, 20, 40);
  546. X        XDrawRectangle(display, pixmap, gc, i, j, 20, 40);
  547. X    }
  548. X
  549. X    XFillArc(display, pixmap, undraw_gc, P3+35, P1-14, 30, 30, 210*64, 120*64);
  550. X    XDrawArc(display, pixmap, gc, P3+35, P1-14, 30, 30, 215*64, 110*64);
  551. X    XFillArc(display, pixmap, undraw_gc, P4-65, P1-14, 30, 30, 210*64, 120*64);
  552. X    XDrawArc(display, pixmap, gc, P4-65, P1-14, 30, 30, 215*64, 110*64);
  553. X
  554. X    XFillArc(display, pixmap, undraw_gc, P3+35, P6-16, 30, 30, 30*64, 120*64);
  555. X    XDrawArc(display, pixmap, gc, P3+35, P6-16, 30, 30, 35*64, 110*64);
  556. X    XFillArc(display, pixmap, undraw_gc, P4-65, P6-16, 30, 30, 30*64, 120*64);
  557. X    XDrawArc(display, pixmap, gc, P4-65, P6-16, 30, 30, 35*64, 110*64);
  558. X
  559. X    XFillArc(display, pixmap, undraw_gc, P1-14, P3+35, 30, 30, 60*64, -120*64);
  560. X    XDrawArc(display, pixmap, gc, P1-14, P3+35, 30, 30, 55*64, -110*64);
  561. X    XFillArc(display, pixmap, undraw_gc, P1-14, P4-65, 30, 30, 60*64, -120*64);
  562. X    XDrawArc(display, pixmap, gc, P1-14, P4-65, 30, 30, 55*64, -110*64);
  563. X
  564. X    XFillArc(display, pixmap, undraw_gc, P6-16, P3+35, 30, 30, 120*64, 120*64);
  565. X    XDrawArc(display, pixmap, gc, P6-16, P3+35, 30, 30, 125*64, 110*64);
  566. X    XFillArc(display, pixmap, undraw_gc, P6-16, P4-65, 30, 30, 120*64, 120*64);
  567. X    XDrawArc(display, pixmap, gc, P6-16, P4-65, 30, 30, 125*64, 110*64);
  568. X}
  569. X
  570. X
  571. X
  572. X
  573. X
  574. END_OF_FILE
  575. if test 14959 -ne `wc -c <'bgbitmap.c'`; then
  576.     echo shar: \"'bgbitmap.c'\" unpacked with wrong size!
  577. fi
  578. # end of 'bgbitmap.c'
  579. fi
  580. if test ! -d 'bitmaps' ; then
  581.     echo shar: Creating directory \"'bitmaps'\"
  582.     mkdir 'bitmaps'
  583. fi
  584. if test ! -d 'bitmaps/chinese_piece' ; then
  585.     echo shar: Creating directory \"'bitmaps/chinese_piece'\"
  586.     mkdir 'bitmaps/chinese_piece'
  587. fi
  588. if test ! -d 'bitmaps/image_piece' ; then
  589.     echo shar: Creating directory \"'bitmaps/image_piece'\"
  590.     mkdir 'bitmaps/image_piece'
  591. fi
  592. if test -f 'bitmaps/war_logo.xbm' -a "${1}" != "-c" ; then 
  593.   echo shar: Will not clobber existing file \"'bitmaps/war_logo.xbm'\"
  594. else
  595. echo shar: Extracting \"'bitmaps/war_logo.xbm'\" \(3291 characters\)
  596. sed "s/^X//" >'bitmaps/war_logo.xbm' <<'END_OF_FILE'
  597. X#define war_logo_width 64
  598. X#define war_logo_height 64
  599. Xstatic char war_logo_bits[] = {
  600. X   0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x06, 0x7f, 0x0f, 0x00, 0x00,
  601. X   0x00, 0x06, 0x00, 0x07, 0x66, 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06,
  602. X   0x66, 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x66, 0x04, 0x00, 0x00,
  603. X   0x00, 0x06, 0x00, 0x06, 0x6e, 0x04, 0x1f, 0xce, 0x01, 0x06, 0xf0, 0x06,
  604. X   0xee, 0x82, 0x38, 0x2c, 0x03, 0x06, 0x8c, 0x07, 0xcc, 0x42, 0x70, 0x1c,
  605. X   0x03, 0x06, 0x04, 0x07, 0xec, 0x62, 0x60, 0x0c, 0x00, 0x06, 0x06, 0x06,
  606. X   0xdc, 0x63, 0x60, 0x0c, 0x00, 0x06, 0x06, 0x06, 0xdc, 0x61, 0x60, 0x0c,
  607. X   0x00, 0x06, 0x06, 0x06, 0x98, 0x61, 0x60, 0x0c, 0x00, 0x06, 0x06, 0x06,
  608. X   0x98, 0xe1, 0x20, 0x0c, 0x00, 0x06, 0x0e, 0x07, 0x98, 0xc1, 0x11, 0x0c,
  609. X   0x00, 0x06, 0x9c, 0x06, 0x98, 0x81, 0x0f, 0x1e, 0x80, 0x1f, 0x78, 0x0e,
  610. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  611. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  612. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  613. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  614. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  615. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x7e, 0xf0, 0x03, 0x00, 0x00,
  616. X   0x00, 0x80, 0x73, 0xee, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x80, 0x73, 0xe0,
  617. X   0xe0, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7f, 0xf8, 0xe0, 0x00, 0x00, 0x00,
  618. X   0x00, 0x80, 0x7f, 0xfc, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7f, 0xee,
  619. X   0xe1, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7f, 0xee, 0xe1, 0x00, 0x00, 0x00,
  620. X   0x00, 0x80, 0x73, 0xfc, 0xf1, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  621. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  622. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  623. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  624. X   0x00, 0x00, 0x1f, 0x7c, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38,
  625. X   0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00,
  626. X   0x00, 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38,
  627. X   0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00,
  628. X   0x00, 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38,
  629. X   0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00,
  630. X   0x00, 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x7c,
  631. X   0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  632. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  633. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  634. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  635. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  636. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  637. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  638. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  639. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  640. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  641. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  642. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  643. X
  644. X
  645. X
  646. X
  647. END_OF_FILE
  648. if test 3291 -ne `wc -c <'bitmaps/war_logo.xbm'`; then
  649.     echo shar: \"'bitmaps/war_logo.xbm'\" unpacked with wrong size!
  650. fi
  651. # end of 'bitmaps/war_logo.xbm'
  652. fi
  653. if test -f 'war.c' -a "${1}" != "-c" ; then 
  654.   echo shar: Will not clobber existing file \"'war.c'\"
  655. else
  656. echo shar: Extracting \"'war.c'\" \(21998 characters\)
  657. sed "s/^X//" >'war.c' <<'END_OF_FILE'
  658. X#include "war.h"
  659. X
  660. Xextern Arr arr[4][6][5], mid[3][3];
  661. X
  662. Xextern Sapper_path sap[];
  663. X
  664. Xextern int round;
  665. X
  666. X/*******************************************************************
  667. X*
  668. X*   Synopsis
  669. X*    fatal_error(s)
  670. X*        char *s;
  671. X*
  672. X*   Description
  673. X*    it prints s as an error message and exit.
  674. X*
  675. X*******************************************************************/
  676. X
  677. Xfatal_error(s)
  678. Xchar *s;
  679. X{
  680. X    printf("%s\n", s);
  681. X    exit(-1);
  682. X}
  683. X
  684. X
  685. X
  686. X/****************************************************************
  687. X*
  688. X*   Synopsis
  689. X*    syntax(s)
  690. X*        char *s;
  691. X*
  692. X*   Argument
  693. X*    s    the program name, usually x4war;
  694. X*
  695. X*   Description
  696. X*    x4war command line arguments specification
  697. X*
  698. X****************************************************************/
  699. X
  700. Xsyntax(s)
  701. Xchar *s;
  702. X{
  703. X    printf("Usage: %s [options ...]\n\n", s);
  704. X    printf("where options include:\n");
  705. X    printf("\t-p0 string\t\tplayer0's name\n");
  706. X    printf("\t-d0 string\t\tplayer0's display\n");
  707. X    printf("\t-c0 string\t\tplayer0's node color\n");
  708. X    printf("\t-p1 string\t\tplayer1's name\n");
  709. X    printf("\t-d1 string\t\tplayer1's display\n");
  710. X    printf("\t-c1 string\t\tplayer1's node color\n");
  711. X    printf("\t-p2 string\t\tplayer2's name\n");
  712. X    printf("\t-d2 string\t\tplayer2's display\n");
  713. X    printf("\t-c2 string\t\tplayer2's node color\n");
  714. X    printf("\t-p3 string\t\tplayer3's name\n");
  715. X    printf("\t-d3 string\t\tplayer3's display\n");
  716. X    printf("\t-c3 string\t\tplayer3's node color\n");
  717. X    printf("\t-two \t\t\tplay a two players game\n");
  718. X    printf("\t-debug\t\t\ta default deploy\n");
  719. X    printf("\t-usage\t\t\tthis usage list\n");
  720. X    printf("\t-help\t\t\tthis usage list\n\n");
  721. X}
  722. X
  723. X
  724. X
  725. X/***********************************************************************
  726. X *
  727. X *  Synopsis
  728. X *    int fight(x, y)
  729. X *        int x, y;
  730. X *
  731. X *  Arguments
  732. X *    x, y    representing two node values between COLOURS and BOMB.
  733. X *        x must be a movable, i.e., not COLOURS and MINE.
  734. X *
  735. X *  Return values
  736. X *    x < y: return 2;
  737. X *    x = y: return 3;
  738. X *    x > y: return 4;
  739. X *
  740. X *  Description
  741. X *    it returns the fighting result when node x moved to meet node y.
  742. X *
  743. X ***********************************************************************/
  744. X
  745. Xint fight(x, y)
  746. Xint x, y;
  747. X{
  748. X    if (x==SAPPER && y==MINE)  return(4);
  749. X    if (x==BOMB || y==BOMB)  return(3);
  750. X    if (x==y) return(3);
  751. X    if (x<y)  return(2);
  752. X    if (x>y)  return(4);
  753. X}
  754. X
  755. X
  756. X/**********************************************************************
  757. X*
  758. X*   Synopsis
  759. X*    int boardtofield(x, y, i, j)
  760. X*        int x, y;
  761. X*        int *i, *j;        return values
  762. X*
  763. X*   Arguments
  764. X*    x, y    coordinates of a point on board;
  765. X*    *i, *j  contain the converted field coordinates;
  766. X*
  767. X*   Return values
  768. X*    return a value from F0 to OTHERPLACE according to the position (x,y),
  769. X*    i and j are set if returned values between F0 and RIP.
  770. X*
  771. X***********************************************************************/
  772. X
  773. Xint boardtofield(x, y, i, j)
  774. Xint x, y, *i, *j;
  775. X{
  776. X    if (x>=315 && x<=555 && y>=565 && y<=855) {
  777. X    *j = (x-310)/50;
  778. X    *i = (y-560)/50;
  779. X    return(F0);
  780. X    }
  781. X    if (x>=565 && x<=855 && y>=315 && y<=555) {
  782. X    *i = (x-560)/50;
  783. X    *j = 4-(y-310)/50;
  784. X    return(F1);
  785. X    }
  786. X    if (x>=315 && x<=555 && y>=15 && y<=305) {
  787. X    *i = 5-(y-10)/50;
  788. X    *j = 4-(x-310)/50;
  789. X    return(F2);
  790. X    }
  791. X    if (x>=15 && x<=305 && y>=315 && y<=555) {
  792. X    *i = 5-(x-10)/50;
  793. X    *j = (y-310)/50;
  794. X    return(F3);
  795. X    }
  796. X    if (x>=315 && x<=555 && y>=315 && y<=555) {
  797. X    *j = (x-310)/100;
  798. X    *i = (y-310)/100;
  799. X    return(MIDFIELD);
  800. X    }
  801. X    if (x>=35 && x<=285 && y>=585 && y<=835) {
  802. X    *j = (x-35)/50;
  803. X    *i = (y-585)/50;
  804. X    return(RIP);
  805. X    }
  806. X
  807. X    if (x>=BUTTON_X && x<=BUTTON_X + BUTTON_WIDTH) {
  808. X    if (y>=610 && y<=635)  return(NEW);
  809. X    if (y>=650 && y<=675)  return(READY);
  810. X    if (y>=690 && y<=715)  return(REDEPLOY);
  811. X    if (y>=730 && y<=755)  return(PEACE);
  812. X    if (y>=770 && y<=795)  return(SURRENDER);
  813. X    if (y>=810 && y<=835)  return(QUIT);
  814. X    }
  815. X    return(OTHERPLACE);
  816. X}
  817. X
  818. X
  819. X
  820. X/********************************************************************
  821. X*
  822. X*   Synopsis
  823. X*    fieldtoboard(f, i, j, x, y)
  824. X*        int f, i, j;
  825. X*        int *x, *y;        return
  826. X*
  827. X*   Arguments
  828. X*    f    field id between F0 and RIP;
  829. X*    i, j    coordinates of the field;
  830. X*    *x, *y    contains returned values of coordinates of the board;
  831. X*
  832. X*********************************************************************/
  833. X
  834. Xfieldtoboard(f, i, j, x, y)
  835. Xint f, i, j, *x, *y;
  836. X{
  837. X    switch (f) {
  838. X      case F0:
  839. X    *x = 335+j*50;
  840. X    *y = 585+i*50;
  841. X    break;
  842. X      case F1:
  843. X    *x = 585+i*50;
  844. X    *y = 335+(4-j)*50;
  845. X    break;
  846. X      case F2:
  847. X    *x = 335+(4-j)*50;
  848. X    *y = 35+(5-i)*50;
  849. X    break;
  850. X      case F3:
  851. X    *x = 35+(5-i)*50;
  852. X    *y = 335+j*50;
  853. X    break;
  854. X      case MIDFIELD:
  855. X    *x = 335+j*100;
  856. X    *y = 335+i*100;
  857. X    break;
  858. X      case RIP:
  859. X    *x = 60+j*50;
  860. X    *y = 610+i*50;
  861. X    }
  862. X}
  863. X
  864. X
  865. X
  866. X/**********************************************************************
  867. X*
  868. X*   Synopsis
  869. X*    arrtoboard(id, g, i, j, x, y)
  870. X*        int id, g, i, j;
  871. X*        int *x, *y;        return
  872. X*
  873. X*   Arguments
  874. X*    id    0-3, specifies the player of the board;
  875. X*    g    F0 - RIP, which array;
  876. X*    i, j    coordinates of the array;
  877. X*    *x, *y  contains the results;
  878. X*
  879. X**********************************************************************/
  880. X
  881. Xarrtoboard(id, g, i, j, x, y)
  882. Xint id, g, i, j, *x, *y;
  883. X{
  884. X    int k;
  885. X
  886. X    if (g==MIDFIELD)
  887. X    switch (id) {
  888. X      case 1:
  889. X        k = i;  i = j;  j = 2-k;
  890. X        break;
  891. X      case 2:
  892. X        i = 2-i;  j = 2-j;
  893. X        break;
  894. X      case 3:
  895. X        k = i;  i = 2-j; j = k;
  896. X    }
  897. X    else if (g != RIP) {
  898. X    g -= id;
  899. X    if (g<0) g += 4;
  900. X    }
  901. X    fieldtoboard(g,i,j,x,y);
  902. X}
  903. X
  904. X
  905. X
  906. X
  907. X
  908. X/*********************************************************************
  909. X*
  910. X*   Synopsis
  911. X*    int fieldtoarr(id, f, fi, fj, ai, aj)
  912. X*        int id, f, fi, fj;
  913. X*        int *ai, *aj;
  914. X*
  915. X*   Arguments
  916. X*    id    0-3, the player of the board;
  917. X*    f    F0 - RIP, field number;
  918. X*    fi, fj    coordinates in the field;
  919. X*    *ai, *aj    result coordinates of the array;
  920. X*
  921. X*   Return value
  922. X*    returns which array is resulted
  923. X*
  924. X**********************************************************************/
  925. X
  926. Xint fieldtoarr(id, f, fi, fj, ai, aj)
  927. Xint id, f, fi, fj, *ai, *aj;
  928. X{
  929. X    *ai = fi;
  930. X    *aj = fj;
  931. X    if ( f==MIDFIELD )
  932. X    switch (id) {
  933. X      case 1:
  934. X        *ai = 2-fj; *aj = fi;
  935. X        break;
  936. X      case 2:
  937. X        *ai = 2 - fi; *aj = 2 - fj;
  938. X        break;
  939. X      case 3:
  940. X        *ai = fj;  *aj = 2 - fi;
  941. X    }
  942. X    return((f>=F0 && f<MIDFIELD) ? (f+id)%4 : f);
  943. X}
  944. X
  945. X
  946. X
  947. X/*********************************************************************
  948. X*
  949. X*   Synopsis
  950. X*    int boardtoarr(f, x, y, i, j)
  951. X*        int f, x, y, *i, *j;
  952. X*
  953. X*   Arguments
  954. X*    f    specifies who's board;
  955. X*    x, y    the coordinates on board;
  956. X*    *i, *j    return the coordinates in the array;
  957. X*
  958. X*   Return value
  959. X*    it returns which array the point corresponds.
  960. X*    returns -1 if no array to match.
  961. X*
  962. X**********************************************************************/
  963. X
  964. Xint boardtoarr(f, x, y, i, j)
  965. Xint f, x, y, *i, *j;
  966. X{
  967. X    int m, n, s;
  968. X
  969. X    s = boardtofield(x, y, &m, &n);
  970. X    if (s > RIP) return(-1);
  971. X    s = fieldtoarr(f, s, m, n, i, j);
  972. X    return(s);
  973. X}
  974. X
  975. X
  976. X
  977. X
  978. X/************************************************************************
  979. X*
  980. X*   Synopsis
  981. X*    int area_intersection(ax1, ay1, ax2, ay2, bx1, by1, bx2, by2,
  982. X*        cx1, cy1, cx2, cy2)
  983. X*        int ax1, ay1, ax2, ay2, bx1, by1, bx2, by2;
  984. X*        int *cx1, *cy1, *cx2, *cy2;        return
  985. X*
  986. X*   Arguments
  987. X*    a's and b's:    coordinates of two rectangles;
  988. X*    c's        contains the coordinates of the intersection area;
  989. X*
  990. X*   Return values
  991. X*    1    if the two rectangles intersect, and c's are set;
  992. X*    0    if the two rectangles not intersect;
  993. X*
  994. X**************************************************************************/
  995. X
  996. Xint area_intersection(ax1, ay1, ax2, ay2, bx1, by1, bx2, by2,
  997. X        cx1, cy1, cx2, cy2)
  998. Xint ax1, ay1, ax2, ay2, bx1, by1, bx2, by2, *cx1, *cy1, *cx2, *cy2;
  999. X{
  1000. X    int k;
  1001. X
  1002. X    if (ax1>ax2) {
  1003. X    k = ax1; ax1 = ax2; ax2 = k;
  1004. X    }
  1005. X    if (ay1>ay2) {
  1006. X    k = ay1; ay1 = ay2; ay2 = k;
  1007. X    }
  1008. X    if (bx1>bx2) {
  1009. X    k = bx1; bx1 = bx2; bx2 = k;
  1010. X    }
  1011. X    if (by1>by2) {
  1012. X    k = by1; by1 = by2; by2 = k;
  1013. X    }
  1014. X    *cx2 = (ax2<bx2) ? ax2 : bx2;
  1015. X    *cy2 = (ay2<by2) ? ay2 : by2;
  1016. X    if (ax1<=bx1 && ay1<=by1 && bx1<ax2 && by1<ay2) {
  1017. X    *cx1 = bx1;  *cy1 = by1;
  1018. X    return(1);
  1019. X    }
  1020. X    if (ax1<=bx1 && ay1>by1 && ay1<by2 && ax2>bx1) {
  1021. X    *cx1 = bx1; *cy1 = ay1;
  1022. X    return(1);
  1023. X    }
  1024. X    if (ax1>bx1 && ay1>by1 && ax1<bx2 && ay1<by2) {
  1025. X    *cx1 = ax1; *cy1 = ay1;
  1026. X    return(1);
  1027. X    }
  1028. X    if (ax1>bx1 && ay1<by1 && ax1<bx2 && ay2>by1) {
  1029. X    *cx1 = ax1; *cy1 = by1;
  1030. X    return(1);
  1031. X    }
  1032. X    return(0);
  1033. X}
  1034. X
  1035. X
  1036. X
  1037. X
  1038. X/**********************************************************************
  1039. X*
  1040. X*   Synopsis
  1041. X*    int sapper_check(i, x, y, z)
  1042. X*        int i, x, y, z;
  1043. X*
  1044. X*   Arguments
  1045. X*    i    start check from i of sap[];
  1046. X*    x, y, z the destination;
  1047. X*
  1048. X*   Return values
  1049. X*    0    if cannot reach destination;
  1050. X*    1    if can reach destination;
  1051. X*
  1052. X*   Side effect
  1053. X*    mark all visited nodes to round.
  1054. X*
  1055. X*   Description
  1056. X*    it recursively checks if a SAPPER can reach a destination, starting
  1057. X*    from a position in sap[i]; sap[i] must not have been visited, and
  1058. X*    the starting position must not be the destination.
  1059. X*
  1060. X***********************************************************************/
  1061. X
  1062. Xint sapper_check(i, x, y, z)
  1063. Xint i, x, y, z;
  1064. X{
  1065. X    int m, n, a, b, c, j;
  1066. X
  1067. X    sap[i].visited = round;
  1068. X    m = 0;
  1069. X    if (i<12) {
  1070. X    a = i/3;
  1071. X    c = 2*(i%3);
  1072. X    if (c==0) {
  1073. X        n = (a-1);
  1074. X        if (n<0)  n = 3;
  1075. X        if (y==0 && z==4 && x==n)  return(1);
  1076. X        if (sap[n*3+2].visited != round && arr[n][0][4].value == EMPTY)
  1077. X        m = sapper_check(n*3+2, x, y, z);
  1078. X        if (m) return(1);
  1079. X
  1080. X        n = sap[i].neighbor[0];
  1081. X        b = (n-12)/3;
  1082. X        c = (n-12)%3;
  1083. X        if (x==MIDFIELD && y==b && z==c)  return(1);
  1084. X        if (sap[n].visited != round && mid[b][c].value == EMPTY)
  1085. X        m = sapper_check(n, x, y, z);
  1086. X        if (m) return(1);
  1087. X
  1088. X        if (x==a && y==0 && z==1)  return(1);
  1089. X        if (arr[a][0][1].value == EMPTY) {
  1090. X        if (x==a && y==0 && z==2)  return(1);
  1091. X        if (sap[a*3+1].visited != round && arr[a][0][2].value == EMPTY)
  1092. X            m = sapper_check(a*3+1, x, y, z);
  1093. X        if (m) return(1);
  1094. X        }
  1095. X
  1096. X        if (a==x || sap[a*3+2].visited != round) {
  1097. X        if (a==x && z==0) {
  1098. X            for (j=1; j<y; j++)
  1099. X            if (arr[a][j][0].value != EMPTY) return(0);
  1100. X            return(1);
  1101. X        }
  1102. X        for (j=1; j<5; j++)
  1103. X            if (arr[a][j][0].value != EMPTY) return(0);
  1104. X        if (a==x && y==4) {
  1105. X            for (j=1; j<z; j++)
  1106. X            if (arr[a][4][j].value != EMPTY) return(0);
  1107. X            return(1);
  1108. X        }
  1109. X        for (j=1; j<5; j++)
  1110. X            if (arr[a][4][j].value != EMPTY) return(0);
  1111. X        if (a==x && z==4) {
  1112. X            for (j=y+1; j<4; j++)
  1113. X            if (arr[a][j][4].value != EMPTY) return(0);
  1114. X            return(1);
  1115. X        }
  1116. X        if (sap[a*3+2].visited == round) return(0);
  1117. X        for (j=0; j<4; j++)
  1118. X            if (arr[a][j][4].value != EMPTY) return(0);
  1119. X        return(sapper_check(a*3+2, x, y, z));
  1120. X        }
  1121. X        return(0);
  1122. X    }
  1123. X    if (c==2) {
  1124. X        if (a==x && y==0 && z==1)  return(1);
  1125. X        if (arr[a][0][1].value == EMPTY) {
  1126. X        if (a==x && y==0 && z==0)  return(1);
  1127. X        if (sap[a*3].visited != round && arr[a][0][0].value == EMPTY)
  1128. X            m = sapper_check(a*3, x, y, z);
  1129. X        if (m) return(1);
  1130. X        }
  1131. X        n = sap[i].neighbor[0];
  1132. X        b = (n-12)/3;
  1133. X        c = (n-12)%3;
  1134. X        if (x==MIDFIELD && y==b && z==c)  return(1);
  1135. X        if (sap[n].visited != round && mid[b][c].value == EMPTY)
  1136. X        m = sapper_check(n, x, y, z);
  1137. X        if (m) return(1);
  1138. X
  1139. X        if (a==x && y==0 && z==3)  return(1);
  1140. X        if (arr[a][0][3].value == EMPTY) {
  1141. X        if (a==x && y==0 && z==4)  return(1);
  1142. X        if (sap[a*3+2].visited != round && arr[a][0][4].value == EMPTY)
  1143. X            m = sapper_check(a*3+2, x, y, z);
  1144. X        if (m) return(1);
  1145. X        }
  1146. X        return(0);
  1147. X    }
  1148. X    /* now c==4 */
  1149. X    if (a==x && y==0 && z==3)  return(1);
  1150. X    if (arr[a][0][3].value == EMPTY) {
  1151. X        if (a==x && y==0 && z==2)  return(1);
  1152. X        if (sap[a*3+1].visited != round && arr[a][0][2].value == EMPTY)
  1153. X        m = sapper_check(a*3+1, x, y, z);
  1154. X        if (m) return(1);
  1155. X    }
  1156. X    n = sap[i].neighbor[0];
  1157. X    b = (n-12)/3;
  1158. X    c = (n-12)%3;
  1159. X    if (x==MIDFIELD && b==y && c==z)  return(1);
  1160. X    if (sap[n].visited != round && mid[b][c].value == EMPTY)
  1161. X        m = sapper_check(n, x, y, z);
  1162. X    if (m) return(1);
  1163. X    n = (a+1)%4;
  1164. X    if (x==n && y==0 && z==0)  return(1);
  1165. X    if (sap[n*3].visited != round && arr[n][0][0].value == EMPTY)
  1166. X        m = sapper_check(n*3, x, y, z);
  1167. X    if (m) return(1);
  1168. X
  1169. X    if (sap[a*3].visited != round || a==x) {
  1170. X        if (a==x && z==4) {
  1171. X        for (j=1; j<y; j++)
  1172. X            if (arr[a][j][4].value != EMPTY) return(0);
  1173. X        return(1);
  1174. X        }
  1175. X        for (j=1; j<5; j++)
  1176. X        if (arr[a][j][4].value != EMPTY) return(0);
  1177. X        if (a==x && y==4) {
  1178. X        for (j=z+1; j<4; j++)
  1179. X            if (arr[a][4][j].value != EMPTY) return(0);
  1180. X        return(1);
  1181. X        }
  1182. X        for (j=0; j<4; j++)
  1183. X        if (arr[a][4][j].value != EMPTY) return(0);
  1184. X        if (a==x && z==0) {
  1185. X        for (j=y+1; j<4; j++)
  1186. X            if (arr[a][j][0].value != EMPTY) return(0);
  1187. X        return(1);
  1188. X        }
  1189. X        if (sap[a*3].visited == round) return(0);
  1190. X        for (j=0; j<4; j++)
  1191. X        if (arr[a][j][0].value != EMPTY) return(0);
  1192. X        return(sapper_check(a*3, x, y, z));
  1193. X    }
  1194. X    return(0);
  1195. X    }
  1196. X    else {    /* starting position in the MIDFIELD */
  1197. X    j = 0;
  1198. X    while (!m && j<4) {
  1199. X        n = sap[i].neighbor[j];
  1200. X        if (sap[n].visited != round)
  1201. X        if (n<12) {
  1202. X            a = n/3;
  1203. X            c = 2*(n%3);
  1204. X            if (x==a && y==0 && z==c) return(1);
  1205. X            if (arr[a][0][c].value == EMPTY)
  1206. X            m = sapper_check(n, x, y, z);
  1207. X        }
  1208. X        else {
  1209. X            b = (n-12)/3;
  1210. X            c = (n-12)%3;
  1211. X            if (x==MIDFIELD && y==b && z==c)  return(1);
  1212. X            if (mid[b][c].value == EMPTY)
  1213. X            m = sapper_check(n, x, y, z);
  1214. X        }
  1215. X        j++;
  1216. X    }
  1217. X    return(m);
  1218. X    }
  1219. X}
  1220. X
  1221. X
  1222. X
  1223. X
  1224. X
  1225. X
  1226. X
  1227. X
  1228. X/**********************************************************************
  1229. X*
  1230. X*   Synopsis
  1231. X*    int valid_move(a, b, c, x, y, z)
  1232. X*        int a, b, c, x, y, z;
  1233. X*
  1234. X*   Return values
  1235. X*    1    for valid move;
  1236. X*    0    for invalid move;
  1237. X*
  1238. X*   Description
  1239. X*    It checks if a move as (a,b,c)=>(x,y,z) is valid according to
  1240. X*    the positions;
  1241. X*
  1242. X***********************************************************************/
  1243. X
  1244. Xint valid_move(a, b, c, x, y, z)
  1245. Xint a, b, c, x, y, z;
  1246. X{
  1247. X    int m, n, i, l;
  1248. X
  1249. X    if ((a<MIDFIELD && x<MIDFIELD) && (b==5 || y==5 ||
  1250. X        (0<b && b<4 && 0<c && c<4) || (0<y && y<4 && 0<z && z<4))) {
  1251. X    /* can move only one step far */
  1252. X    if (a != x) return(0);
  1253. X    m = abs(b-y) + abs(c-z);
  1254. X    if (m<1 || m>2)  return(0);
  1255. X    if ( (abs(b-y)<2 && abs(c-z)<2) &&
  1256. X        (((b==1 || b==3) && (c==1 || c==3)) || (b==2 && c==2) ||
  1257. X        ((y==1 || y==3) && (z==1 || z==3)) || (y==2 && z==2)))
  1258. X        return(1);
  1259. X    if (m == 1) return(1);
  1260. X    else return(0);
  1261. X    }
  1262. X
  1263. X/* from now on, the source and the destination are both on the railway */
  1264. X    if (a==MIDFIELD && mid[b][c].value == SAPPER ||
  1265. X    a<MIDFIELD && arr[a][b][c].value == SAPPER) {
  1266. X    round++;
  1267. X    m = 0;
  1268. X    if (a<MIDFIELD && (b!=0 || (b==0 && (c==1 || c==3)))) {
  1269. X        if (b==0)
  1270. X        if (c==1) {
  1271. X            if (x==a && y==0 && (z==0 || z==2)) return(1);
  1272. X            if (arr[a][0][0].value == EMPTY)
  1273. X            m = sapper_check(a*3, x, y, z);
  1274. X            if (m) return(1);
  1275. X            if (sap[a*3+1].visited!=round && arr[a][0][2].value==EMPTY)
  1276. X            m = sapper_check(a*3+1, x, y, z);
  1277. X            return(m);
  1278. X        }
  1279. X        else {
  1280. X            if (x==a && y==0 && (z==2 || z==4)) return(1);
  1281. X            if (arr[a][0][2].value != EMPTY)
  1282. X            m = sapper_check(a*3+1, x, y, z);
  1283. X            if (m) return(1);
  1284. X            if (sap[a*3+2].visited!=round && arr[a][0][4].value==EMPTY)
  1285. X            m = sapper_check(a*3+2, x, y, z);
  1286. X            return(m);
  1287. X        }
  1288. X        else
  1289. X        if (c==0 || c==4) {
  1290. X            if (a==x && z==c && y<b) {
  1291. X            for (i=y+1; i<b; i++)
  1292. X                if (arr[a][i][c].value != EMPTY) break;
  1293. X            if (i==b) return(1);
  1294. X            }
  1295. X            else {
  1296. X            for (i=0; i<b; i++)
  1297. X                if (arr[a][i][c].value != EMPTY) break;
  1298. X            if (i==b)
  1299. X                m = sapper_check(a*3+(c/2), x, y, z);
  1300. X            if (m) return(1);
  1301. X            }
  1302. X            if (a==x || sap[a*3].visited != round ||
  1303. X                sap[a*3+2].visited != round) {
  1304. X            if (a==x && z==c && y>b) {
  1305. X                for (i=b+1; i<y; i++)
  1306. X                if (arr[a][i][c].value != EMPTY) return(0);
  1307. X                return(1);
  1308. X            }
  1309. X            for (i=b+1; i<5; i++)
  1310. X                if (arr[a][i][c].value != EMPTY) return(0);
  1311. X            if (a==x && y==4)
  1312. X                if (c==0) {
  1313. X                for (i=1; i<z; i++)
  1314. X                    if (arr[a][4][i].value != EMPTY) return(0);
  1315. X                return(1);
  1316. X                }
  1317. X                else {
  1318. X                for (i=z+1; i<4; i++)
  1319. X                    if (arr[a][4][i].value != EMPTY) return(0);
  1320. X                return(1);
  1321. X                }
  1322. X            n = (c==0) ? 1 : 0;
  1323. X            for (i=0; i<4; i++)
  1324. X                if (arr[a][4][i+n].value != EMPTY) return(0);
  1325. X            n = (c==0) ? 4 : 0;
  1326. X            if (a==x && n==z) {
  1327. X                for (i=y+1; i<4; i++)
  1328. X                if (arr[a][i][n].value != EMPTY) return(0);
  1329. X                return(1);
  1330. X            }
  1331. X            if (sap[a*3+n/2].visited == round) return(0);
  1332. X            for (i=0; i<4; i++)
  1333. X                if (arr[a][i][n].value != EMPTY) return(0);
  1334. X            return(sapper_check(a*3+n/2, x, y, z));
  1335. X            }
  1336. X            return(0);
  1337. X        }
  1338. X        else {        /* starting point is at the second bottom line */
  1339. X            if (a==x && y==4 && z<c) {
  1340. X            for (i=z+1; i<c; i++)
  1341. X                if (arr[a][4][i].value != EMPTY) break;
  1342. X            if (i==c) return(1);
  1343. X            }
  1344. X            else
  1345. X            for (i=0; i<c; i++)
  1346. X                if (arr[a][4][i].value != EMPTY) break;
  1347. X            if (i==c) {
  1348. X            if (a==x && y<4 && z==0) {
  1349. X                for (i=y+1; i<4; i++)
  1350. X                if (arr[a][i][0].value != EMPTY) break;
  1351. X                if (i==4) return(1);
  1352. X            }
  1353. X            else
  1354. X                for (i=0; i<4; i++)
  1355. X                if (arr[a][i][0].value != EMPTY) break;
  1356. X            if (i==4) {
  1357. X                m = sapper_check(a*3, x, y, z);
  1358. X                if (m) return(1);
  1359. X            }
  1360. X            }
  1361. X            if (a==x || sap[a*3].visited != round ||
  1362. X                sap[a*3+2].visited != round) {
  1363. X            if (a==x && y==4 && z>c) {
  1364. X                for (i=c+1; i<z; i++)
  1365. X                if (arr[a][4][i].value != EMPTY) return(0);
  1366. X                return(1);
  1367. X            }
  1368. X            for (i=c+1; i<5; i++)
  1369. X                if (arr[a][4][i].value != EMPTY) return(0);
  1370. X            if (a==x && y<4 && z==4) {
  1371. X                for (i=y+1; i<4; i++)
  1372. X                if (arr[a][i][4].value != EMPTY) return(0);
  1373. X                return(1);
  1374. X            }
  1375. X            if (sap[a*3+2].visited==round) return(0);
  1376. X            for (i=0; i<4; i++)
  1377. X                if (arr[a][i][4].value != EMPTY) return(0);
  1378. X            return(sapper_check(a*3+2, x, y, z));
  1379. X            }
  1380. X            return(0);
  1381. X        }
  1382. X    }
  1383. X    else
  1384. X        if (a<4)  return(sapper_check(a*3+c/2, x, y, z));
  1385. X        else return(sapper_check(12+b*3+c, x, y, z));
  1386. X    }
  1387. X
  1388. X
  1389. X/* now the moving node is not a SAPPER */
  1390. X
  1391. X    if (a<MIDFIELD && a==x) {
  1392. X    if (b==y && (b==0 || b==4)) {
  1393. X        if (c < z) {
  1394. X        m = c;  n = z;
  1395. X        }
  1396. X        else {
  1397. X        m = z;  n = c;
  1398. X        }
  1399. X        for (i=m+1; i<n; i++)
  1400. X        if (arr[a][b][i].value != EMPTY)  return(0);
  1401. X        return(1);
  1402. X    }
  1403. X    else if (c==z && (c==0 || c==4)) {
  1404. X        if (b < y) {
  1405. X        m = b;  n = y;
  1406. X        }
  1407. X        else {
  1408. X        m = y;  n = b;
  1409. X        }
  1410. X        for (i=m+1; i<n; i++)
  1411. X        if (arr[a][i][c].value != EMPTY) return(0);
  1412. X        return(1);
  1413. X    }
  1414. X    else return(0);
  1415. X    }
  1416. X
  1417. X/* from now on the source and the destination are on different fields */
  1418. X    if (a != MIDFIELD)
  1419. X    if (c==0 || c==4) {
  1420. X        for (i=0; i<b; i++)
  1421. X        if (arr[a][i][c].value != EMPTY) return(0);
  1422. X    }
  1423. X    else
  1424. X        if (b!=0 || c!=2) return(0);
  1425. X    if (x != MIDFIELD)
  1426. X    if (z==0 || z==4) {
  1427. X        for (i=0; i<y; i++)
  1428. X        if (arr[x][i][z].value != EMPTY) return(0);
  1429. X    }
  1430. X    else
  1431. X        if (y!=0 || z!=2) return(0);
  1432. X
  1433. X    if (a<MIDFIELD && x<MIDFIELD) {
  1434. X    if ((x+1)%4 == a)
  1435. X        if (z==4 && c==0)  return(1);
  1436. X        else return(0);
  1437. X    else if ((a+1)%4 == x)
  1438. X        if (z==0 && c==4) return(1);
  1439. X        else return(0);
  1440. X    if (!((c==0 && z==4) || (c==4 && z==0) || (c==2 && z==2)))
  1441. X        return(0);
  1442. X    }
  1443. X
  1444. X/* now the move has to go across the MIDFIELD */
  1445. X    if ((a<MIDFIELD && a%2==0) || (x<MIDFIELD && x%2==0) ||
  1446. X    (a==MIDFIELD && x==MIDFIELD && c==z)) {
  1447. X    if (a != MIDFIELD) {
  1448. X        if (a==F0) {
  1449. X        l = c/2;
  1450. X        n = 2;
  1451. X        m = (x==MIDFIELD) ? (y+1) : 0;
  1452. X        }
  1453. X        else {
  1454. X        l = (4-c)/2;
  1455. X        m = 0;
  1456. X        n = (x==MIDFIELD) ? (y-1) : 2;
  1457. X        }
  1458. X        if (x==MIDFIELD && l!=z) return(0);
  1459. X    }
  1460. X    else
  1461. X        if (x != MIDFIELD) {
  1462. X        if (x==F0) {
  1463. X            l = z/2;
  1464. X            m = b+1;
  1465. X            n = 2;
  1466. X        }
  1467. X        else {
  1468. X            l = (4-z)/2;
  1469. X            m = 0;
  1470. X            n = b-1;
  1471. X        }
  1472. X        if (l != c)  return(0);
  1473. X        }
  1474. X        else {
  1475. X        l = z;
  1476. X        if (b<y) {
  1477. X            m = b+1; n = y-1;
  1478. X        }
  1479. X        else {
  1480. X            m = y+1; n = b-1;
  1481. X        }
  1482. X        }
  1483. X
  1484. X    for (i=m; i<=n; i++)
  1485. X        if (mid[i][l].value != EMPTY) return(0);
  1486. X    return(1);
  1487. X    }
  1488. X
  1489. X    if ((a<MIDFIELD && a%2!=0) || (x<MIDFIELD && x%2!=0) ||
  1490. X    (a==MIDFIELD && x==MIDFIELD && b==y)) {
  1491. X    if (a != MIDFIELD) {
  1492. X        if (a==F1) {
  1493. X        l = (4-c)/2;
  1494. X        n = 2;
  1495. X        m = (x==MIDFIELD) ? (z+1) : 0;
  1496. X        }
  1497. X        else {
  1498. X        l = c/2;
  1499. X        m = 0;
  1500. X        n = (x==MIDFIELD) ? (z-1) : 2;
  1501. X        }
  1502. X        if (x == MIDFIELD && l != y) return(0);
  1503. X    }
  1504. X    else
  1505. X        if (x != MIDFIELD) {
  1506. X        if (x==F1) {
  1507. X            l = (4-z)/2;
  1508. X            m = c+1;
  1509. X            n = 2;
  1510. X        }
  1511. X        else {
  1512. X            l = z/2;
  1513. X            m = 0;
  1514. X            n = c-1;
  1515. X        }
  1516. X        if (l != b)  return(0);
  1517. X        }
  1518. X        else {
  1519. X        l = b;
  1520. X        if (c<z) {
  1521. X            m = c+1; n = z-1;
  1522. X        }
  1523. X        else {
  1524. X            m = z+1; n = c-1;
  1525. X        }
  1526. X        }
  1527. X
  1528. X
  1529. X    for (i=m; i<=n; i++)
  1530. X        if (mid[l][i].value != EMPTY) return(0);
  1531. X    return(1);
  1532. X    }
  1533. X
  1534. X    return(0);
  1535. X}
  1536. X
  1537. X
  1538. X/*************************************************************************
  1539. X*
  1540. X*   Synopsis
  1541. X*    initial_sapper()
  1542. X*
  1543. X*   Description
  1544. X*    initializes the array 'sap' of the sapper move checking path.
  1545. X*
  1546. X**************************************************************************/
  1547. X
  1548. Xinitial_sapper()
  1549. X{
  1550. X    int i;
  1551. X
  1552. X    round = 0;
  1553. X
  1554. X    for (i=0; i<21; i++)
  1555. X    sap[i].visited = 0;
  1556. X
  1557. X    sap[0].neighbor[0] = 18;
  1558. X    sap[1].neighbor[0] = 19;
  1559. X    sap[2].neighbor[0] = 20;
  1560. X    sap[3].neighbor[0] = 20;
  1561. X    sap[4].neighbor[0] = 17;
  1562. X    sap[5].neighbor[0] = 14;
  1563. X    sap[6].neighbor[0] = 14;
  1564. X    sap[7].neighbor[0] = 13;
  1565. X    sap[8].neighbor[0] = 12;
  1566. X    sap[9].neighbor[0] = 12;
  1567. X    sap[10].neighbor[0] = 15;
  1568. X    sap[11].neighbor[0] = 18;
  1569. X
  1570. X    sap[12].neighbor[0] = 9;
  1571. X    sap[12].neighbor[1] = 8;
  1572. X    sap[12].neighbor[2] = 13;
  1573. X    sap[12].neighbor[3] = 15;
  1574. X    sap[13].neighbor[0] = 12;
  1575. X    sap[13].neighbor[1] = 7;
  1576. X    sap[13].neighbor[2] = 14;
  1577. X    sap[13].neighbor[3] = 16;
  1578. X    sap[14].neighbor[0] = 13;
  1579. X    sap[14].neighbor[1] = 6;
  1580. X    sap[14].neighbor[2] = 5;
  1581. X    sap[14].neighbor[3] = 17;
  1582. X
  1583. X    sap[15].neighbor[0] = 10;
  1584. X    sap[15].neighbor[1] = 12;
  1585. X    sap[15].neighbor[2] = 16;
  1586. X    sap[15].neighbor[3] = 18;
  1587. X    sap[16].neighbor[0] = 15;
  1588. X    sap[16].neighbor[1] = 13;
  1589. X    sap[16].neighbor[2] = 17;
  1590. X    sap[16].neighbor[3] = 19;
  1591. X    sap[17].neighbor[0] = 16;
  1592. X    sap[17].neighbor[1] = 14;
  1593. X    sap[17].neighbor[2] = 4;
  1594. X    sap[17].neighbor[3] = 20;
  1595. X
  1596. X    sap[18].neighbor[0] = 11;
  1597. X    sap[18].neighbor[1] = 15;
  1598. X    sap[18].neighbor[2] = 19;
  1599. X    sap[18].neighbor[3] = 0;
  1600. X    sap[19].neighbor[0] = 18;
  1601. X    sap[19].neighbor[1] = 16;
  1602. X    sap[19].neighbor[2] = 20;
  1603. X    sap[19].neighbor[3] = 1;
  1604. X    sap[20].neighbor[0] = 19;
  1605. X    sap[20].neighbor[1] = 17;
  1606. X    sap[20].neighbor[2] = 3;
  1607. X    sap[20].neighbor[3] = 2;
  1608. X}
  1609. X
  1610. X
  1611. X
  1612. X
  1613. X
  1614. END_OF_FILE
  1615. if test 21998 -ne `wc -c <'war.c'`; then
  1616.     echo shar: \"'war.c'\" unpacked with wrong size!
  1617. fi
  1618. # end of 'war.c'
  1619. fi
  1620. if test -f 'war.h' -a "${1}" != "-c" ; then 
  1621.   echo shar: Will not clobber existing file \"'war.h'\"
  1622. else
  1623. echo shar: Extracting \"'war.h'\" \(1787 characters\)
  1624. sed "s/^X//" >'war.h' <<'END_OF_FILE'
  1625. X#define DEFAULT_BOARD_BG "gray"
  1626. X#define DEFAULT_BOARD_FG "black"
  1627. X#define PLAYER0_COLOR "red"
  1628. X#define PLAYER1_COLOR "black"
  1629. X#define PLAYER2_COLOR "blue"
  1630. X#define PLAYER3_COLOR "purple"
  1631. X
  1632. X#define DIMENSION 870
  1633. X
  1634. X#define P1    35
  1635. X#define P2    285
  1636. X#define P3    335
  1637. X#define P4    535
  1638. X#define P5    585
  1639. X#define P6    835
  1640. X
  1641. X#define TALK_WIDTH 250
  1642. X#define TALK_HEIGHT 60
  1643. X#define TALK_Y    135        /* the y-coordinate for the upper talk
  1644. X                 * boxes. the lower talk box's is
  1645. X                 * TALK_Y+TALK_HEIGHT+30.
  1646. X                 */
  1647. X#define TALK_L_X P1
  1648. X#define TALK_R_X P5
  1649. X#define TALK_X_INC 9        /* char gap in x-direction of talk
  1650. X                 * string.
  1651. X                 */
  1652. X#define TALK_Y_INC 20
  1653. X#define TALK0_X  P1+5        /* talk string's x-coordinate for
  1654. X                 * player 0
  1655. X                 */
  1656. X#define TALK0_Y  TALK_Y+15
  1657. X#define TALK1_X  P5+5
  1658. X#define TALK1_Y  TALK_Y+15
  1659. X#define TALK2_X  P1+5
  1660. X#define TALK2_Y  TALK_Y+105
  1661. X#define TALK3_X  P5+5
  1662. X#define TALK3_Y  TALK_Y+105
  1663. X
  1664. X#define RIP_Y    585
  1665. X#define RIP_DIMENSION 250
  1666. X
  1667. X#define BUTTON_WIDTH 100
  1668. X#define BUTTON_HEIGHT 25
  1669. X#define BUTTON_X  685
  1670. X#define NEW_Y    610
  1671. X#define BUTTON_DIS  40
  1672. X
  1673. X#define MSG_BOX_X P5
  1674. X#define MSG_BOX_Y P1
  1675. X#define MSG_WIDTH 250
  1676. X#define MSG_HEIGHT 50
  1677. X#define MSG_X    592
  1678. X#define MSG_Y    53
  1679. X
  1680. X#define MAX_MSG 27
  1681. X
  1682. X#define SIGN_DIMENSION 64
  1683. X
  1684. X#define PILLAR -2
  1685. X#define EMPTY -1
  1686. X#define COLOURS 0
  1687. X#define SAPPER 1
  1688. X#define F_LIEUTENANT 2
  1689. X#define CAPTAIN 3
  1690. X#define MAJOR 4
  1691. X#define COLONEL 5
  1692. X#define BRIGADIER 6
  1693. X#define M_GENERAL 7
  1694. X#define GENERAL 8
  1695. X#define MARSHAL 9
  1696. X#define MINE 10
  1697. X#define BOMB 11
  1698. X
  1699. X#define F0 0
  1700. X#define F1 1
  1701. X#define F2 2
  1702. X#define F3 3
  1703. X#define MIDFIELD 4
  1704. X#define RIP 5
  1705. X#define NEW 6
  1706. X#define READY 7
  1707. X#define REDEPLOY 8
  1708. X#define PEACE 9
  1709. X#define SURRENDER 10
  1710. X#define QUIT 11
  1711. X#define OTHERPLACE 12
  1712. X
  1713. X
  1714. Xtypedef struct {
  1715. X    int id;
  1716. X    int value;
  1717. X} Arr;
  1718. X
  1719. X
  1720. Xtypedef struct {
  1721. X    int neighbor[4];
  1722. X    int visited;
  1723. X} Sapper_path;
  1724. X
  1725. X
  1726. X
  1727. X
  1728. X
  1729. END_OF_FILE
  1730. if test 1787 -ne `wc -c <'war.h'`; then
  1731.     echo shar: \"'war.h'\" unpacked with wrong size!
  1732. fi
  1733. # end of 'war.h'
  1734. fi
  1735. echo shar: End of archive 1 \(of 4\).
  1736. cp /dev/null ark1isdone
  1737. MISSING=""
  1738. for I in 1 2 3 4 ; do
  1739.     if test ! -f ark${I}isdone ; then
  1740.     MISSING="${MISSING} ${I}"
  1741.     fi
  1742. done
  1743. if test "${MISSING}" = "" ; then
  1744.     echo You have unpacked all 4 archives.
  1745.     rm -f ark[1-9]isdone
  1746. else
  1747.     echo You still need to unpack the following archives:
  1748.     echo "        " ${MISSING}
  1749. fi
  1750. ##  End of shell archive.
  1751. exit 0
  1752.