home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume18 / spllcast / part06 < prev    next >
Encoding:
Internet Message Format  |  1993-07-18  |  59.8 KB

  1. Path: uunet!news.tek.com!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v18i032:  spellcast - strategy game for X11, Part06/07
  5. Date: 14 Jul 1993 19:40:33 GMT
  6. Organization: Tektronix, Inc, Redmond, OR, USA
  7. Lines: 2112
  8. Approved: billr@saab.CNA.TEK.COM
  9. Message-ID: <221nfh$rpl@ying.cna.tek.com>
  10. NNTP-Posting-Host: saab.cna.tek.com
  11. Xref: uunet comp.sources.games:1832
  12.  
  13. Submitted-by: Andrew Plotkin <ap1i+@andrew.cmu.edu>
  14. Posting-number: Volume 18, Issue 32
  15. Archive-name: spellcast/part06
  16. Environment: X11, Xlib
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 6 (of 7)."
  27. # Contents:  bitmaps/base.ps bitmaps/sd2.bm espells.c handwave.h
  28. #   internal.h main.c patchlevel.h xbutton.c xgest.c xtalk.c
  29. # Wrapped by billr@saab on Wed Jul 14 12:32:51 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'bitmaps/base.ps' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'bitmaps/base.ps'\"
  33. else
  34. echo shar: Extracting \"'bitmaps/base.ps'\" \(5774 characters\)
  35. sed "s/^X//" >'bitmaps/base.ps' <<'END_OF_FILE'
  36. X%!
  37. X
  38. X/centershow
  39. X   {gsave dup stringwidth pop 2 div neg 0 rmoveto
  40. X    show 
  41. X    grestore} def 
  42. X
  43. X/clapstr 288 string def
  44. X/snapstr 288 string def
  45. X/wavestr 288 string def
  46. X/digitstr 288 string def
  47. X/palmstr 288 string def
  48. X/fingerstr 288 string def
  49. X
  50. Xcurrentfile clapstr readhexstring
  51. Xffffffffffffffffffffffffffffffffffffffffffff3fffffffffff1fff
  52. Xfffffffe1ffffffffffe1ffffffffffe1ffffffffffc3ffffffffff83fff
  53. Xfffffff83ffffffffff87ffffffffff07ffffffffff07fffffffffe07fff
  54. Xffffffe0ffffffffffe0ffffffffffc0ffffffffffc0ffffffffffc0ffff
  55. Xffffffc0ffffffffffc0ffffffffffc0ffffffffff80ffffffffff80ffff
  56. Xffffff80ffffffffff80ffffffffffc07fffffffffc07fffffffffc07fff
  57. Xffffffc07fffffffffc07fffffffffc03fffffffffc03fffffffffc01fff
  58. Xffffffc01fffffffffc01fffffffffc00fffffffff800fffffffff800fff
  59. Xffffff801fffffffff001ffffffffe001ffffffffe003ffffffffc003fff
  60. Xfffff0007fffffffe000ffffffffffffffff
  61. Xpop pop
  62. X
  63. Xcurrentfile snapstr readhexstring
  64. Xfffffffffffffffffffffffffffff7ffbffffffffbffbffffffffdffbfff
  65. Xfffffdff7ffffffffeff7fffffffffffffffffffffffff3ffffffffff8ff
  66. Xffffffc7f7ffffffff03fffffffff803fffffffff000ffffffffc0007fff
  67. Xffff00007ffffffe00007e03fffc00007ffffff800607ffffff000e07fff
  68. Xffe001e0ffffffc003c0ffffff8007c0fbffff000f80fdffff001f01feff
  69. Xfe001e01ff7ffe003c01fffffc002001fffffc000000fffffc0000007fff
  70. Xfc0000003ffffc0000001ffffe0000001fffff0000001fffff0000000fff
  71. Xffc000000fffffe000000ffffff000000ffffff800000ffffffe00000fff
  72. Xffff00000fffffff80000fffffffc0001fffffffe0001fffffffe0003fff
  73. Xfffff8003ffffffff8007fffffffffffffff
  74. Xpop pop
  75. X
  76. Xcurrentfile wavestr readhexstring
  77. Xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
  78. Xfffffffffffffffffffffffffffffffffffffffffffffffffffffff0ffff
  79. Xffffffe07fffffffff807fffffffff01fffffffffc03fffffffff007ffff
  80. Xffffc01fffffffff803fffffffff007fffffffff00fffffffffe01ffffff
  81. Xfffc03fffffffff803fffffffff007ffffffffe007ffffffffc00fffffff
  82. Xffc00fffffffff8007ffffffff8007ffffffff8003ffffffffc001ffffff
  83. Xffe000fffffffff0003ffffffff8001ffffffffc000ffffffffe0007ffff
  84. Xffff0003ffffffff8000ffffffffc0007fffffffe0003ffffffff0001fff
  85. Xfffff0001ffffffff0000ffffffff0000ffffffff0000fffffffe0000fff
  86. Xffffc0001fffffffc0003fffffffffffffff
  87. Xpop pop
  88. X
  89. Xcurrentfile digitstr readhexstring
  90. Xfffffffffffffffffffffffffffffffffffffffffffcfffffffffffc7fff
  91. Xfffffff87ffffffffff87ffffffffff07ffffffffff07fffffffffe0ffff
  92. Xffffffe0ffffffffffe0ffffffffffc1ffffffffffc1ffffffffff81ffff
  93. Xffffff81ffffffffff03ffffffffff03fffffffffe03fffffffffc03ffff
  94. Xffffc003ffffffffc003fffffffe0003fffffffc00021ffffffc00001fff
  95. Xffe000003fffffe000003fffffc000003fffff8000007fffff8000007fff
  96. Xff8000007fffff8000007fffff8000007fffff8000007fffff800000ffff
  97. Xff800000ffffff800001ffffff800001ffffff800003ffffffc00003ffff
  98. Xffc00007ffffffe0000ffffffff0001ffffffff0001ffffffff0007fffff
  99. Xffe000ffffffffc000ffffffffffffffffff
  100. Xpop pop
  101. X
  102. Xcurrentfile palmstr readhexstring
  103. Xfffffffffffffffffffffffffffffe7ffffffffffe3ffffffffffc39ffff
  104. Xfffffc38fffffffffc30ffffffff9c30ffffffff1c30ffffffff0c30ffff
  105. Xffff0c30ffffffff0c30ffffffff0c30ffffffff0c30ffffffff0c30ffff
  106. Xffff0c30fffffff70c30ffffffe30c30ffffffe30c30ffffffe30c30ffff
  107. Xffe30c30ffffffc30c10ff3fffc20800fe3fffc20000fe3fffc20000fc3f
  108. Xffc20000fc3fffc00000783fffc00000783fffc00000707fffc00000607f
  109. Xffc00000407fffc00000007fffc0000000ffffc0000000ffffc0000001ff
  110. Xffc0000003ffffe0000003ffffe0000007ffffe000000fffffe000000fff
  111. Xfff000001ffffff000001ffffff000003ffffff800007ffffff800007fff
  112. Xfffc0001fffffffe0001ffffffffffffffff
  113. Xpop pop
  114. X
  115. Xcurrentfile fingerstr readhexstring
  116. Xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
  117. Xfffffffffffffffffffffffffffffffffffffffffffffffffffffcf87fff
  118. Xfffff8707ffffffff0e0ffffffffc1c1fc3fffff8383f03fffff0707e07f
  119. Xffe70e0fc0ffffc60c1f83ffff861c1f03ffff0c183e07ffff18183e0fff
  120. Xfe18383c0ffffe30303c1ffffc3030381ffffc2060103ffffc2000003fff
  121. Xfc0000003ffffc0000003ffffc0000007e3ffc0000007e3ffc0000007c3f
  122. Xfc000000783ffc000000703ffc000000607ffe000000007ffe00000000ff
  123. Xfe00000001fffe00000003fffe00000007ffff0000000fffff8000003fff
  124. Xff8000007fffff000000fffffe000003fffffc00000ffffff800001fffff
  125. Xf000007ffffff000007fffffffffffffffff
  126. Xpop pop
  127. X
  128. X/showfinger {
  129. Xgsave
  130. Xtranslate 12 12 scale 
  131. X48 48 false [ 48 0 0 -48 0 48 ] { fingerstr }
  132. Ximagemask
  133. Xgrestore
  134. X} def
  135. X
  136. X/showpalm {
  137. Xgsave
  138. Xtranslate 12 12 scale 
  139. X48 48 false [ 48 0 0 -48 0 48 ] { palmstr }
  140. Ximagemask
  141. Xgrestore
  142. X} def
  143. X
  144. X/showdigit {
  145. Xgsave
  146. Xtranslate 12 12 scale 
  147. X48 48 false [ 48 0 0 -48 0 48 ] { digitstr }
  148. Ximagemask
  149. Xgrestore
  150. X} def
  151. X
  152. X/showsnap {
  153. Xgsave
  154. Xtranslate 12 12 scale 
  155. X48 48 false [ 48 0 0 -48 0 48 ] { snapstr }
  156. Ximagemask
  157. Xgrestore
  158. X} def
  159. X
  160. X/showwave {
  161. Xgsave
  162. Xtranslate 12 12 scale 
  163. X48 48 false [ 48 0 0 -48 0 48 ] { wavestr }
  164. Ximagemask
  165. Xgrestore
  166. X} def
  167. X
  168. X/showclap {
  169. Xgsave
  170. Xtranslate 12 12 scale 
  171. X48 48 false [ 48 0 0 -48 0 48 ] { clapstr }
  172. Ximagemask
  173. Xgrestore
  174. X} def
  175. X
  176. X/showclap2 {
  177. Xgsave
  178. Xtranslate 12 12 scale 
  179. X-0.3 0 translate
  180. X48 48 false [ 48 0 0 -48 0 48 ] { clapstr }
  181. Ximagemask
  182. X1.6 0 translate
  183. X-1 1 scale
  184. X48 48 false [ 48 0 0 -48 0 48 ] { clapstr }
  185. Ximagemask
  186. Xgrestore
  187. X} def
  188. X
  189. X/showdigit2 {
  190. Xgsave
  191. Xtranslate 12 12 scale 
  192. X-0.0 0 translate
  193. X48 48 false [ 48 0 0 -48 0 48 ] { digitstr }
  194. Ximagemask
  195. X1.5 0 translate
  196. X-1 1 scale
  197. X48 48 false [ 48 0 0 -48 0 48 ] { digitstr }
  198. Ximagemask
  199. Xgrestore
  200. X} def
  201. X
  202. X/showwave2 {
  203. Xgsave
  204. Xtranslate 12 12 scale 
  205. X-0.0 0 translate
  206. X48 48 false [ 48 0 0 -48 0 48 ] { wavestr }
  207. Ximagemask
  208. X1.55 0 translate
  209. X-1 1 scale
  210. X48 48 false [ 48 0 0 -48 0 48 ] { wavestr }
  211. Ximagemask
  212. Xgrestore
  213. X} def
  214. X
  215. X/showsnap2 {
  216. Xgsave
  217. Xtranslate 12 12 scale 
  218. X-0.0 0 translate
  219. X48 48 false [ 48 0 0 -48 0 48 ] { snapstr }
  220. Ximagemask
  221. X1.55 0 translate
  222. X-1 1 scale
  223. X48 48 false [ 48 0 0 -48 0 48 ] { snapstr }
  224. Ximagemask
  225. Xgrestore
  226. X} def
  227. X
  228. X/showpalm2 {
  229. Xgsave
  230. Xtranslate 12 12 scale 
  231. X-0.2 0 translate
  232. X48 48 false [ 48 0 0 -48 0 48 ] { palmstr }
  233. Ximagemask
  234. X1.6 0 translate
  235. X-1 1 scale
  236. X48 48 false [ 48 0 0 -48 0 48 ] { palmstr }
  237. Ximagemask
  238. Xgrestore
  239. X} def
  240. X
  241. X/nullact {
  242. Xpop pop
  243. X} def
  244. X
  245. END_OF_FILE
  246. if test 5774 -ne `wc -c <'bitmaps/base.ps'`; then
  247.     echo shar: \"'bitmaps/base.ps'\" unpacked with wrong size!
  248. fi
  249. # end of 'bitmaps/base.ps'
  250. fi
  251. if test -f 'bitmaps/sd2.bm' -a "${1}" != "-c" ; then 
  252.   echo shar: Will not clobber existing file \"'bitmaps/sd2.bm'\"
  253. else
  254. echo shar: Extracting \"'bitmaps/sd2.bm'\" \(276 characters\)
  255. sed "s/^X//" >'bitmaps/sd2.bm' <<'END_OF_FILE'
  256. X#define sd2_width 16
  257. X#define sd2_height 16
  258. X#define sd2_x_hot -1
  259. X#define sd2_y_hot -1
  260. Xstatic char sd2_bits[] = {
  261. X0x00,0x00,0x80,0x04,0xc0,0x0c,0xc0,0x0c,0x60,0x0c,0x60,0x0c,
  262. X0x70,0x1c,0x7c,0x7c,0xfe,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,
  263. X0x7f,0xfc,0x7f,0xfc,0x3e,0xf8,0x1f,0xf8};
  264. END_OF_FILE
  265. if test 276 -ne `wc -c <'bitmaps/sd2.bm'`; then
  266.     echo shar: \"'bitmaps/sd2.bm'\" unpacked with wrong size!
  267. fi
  268. # end of 'bitmaps/sd2.bm'
  269. fi
  270. if test -f 'espells.c' -a "${1}" != "-c" ; then 
  271.   echo shar: Will not clobber existing file \"'espells.c'\"
  272. else
  273. echo shar: Extracting \"'espells.c'\" \(5841 characters\)
  274. sed "s/^X//" >'espells.c' <<'END_OF_FILE'
  275. X#include <strings.h>
  276. X
  277. X#include "handwave.h"
  278. X#include "internal.h"
  279. X
  280. X/* the following are purely for readability */
  281. X#define P Gesture_PALM
  282. X#define D Gesture_DIGIT
  283. X#define F Gesture_FINGERS
  284. X#define W Gesture_WAVE
  285. X#define C Gesture_CLAPHALF
  286. X#define S Gesture_SNAP
  287. X#define P2 (Gesture_PALM | Gesture_DOUBLE)
  288. X#define D2 (Gesture_DIGIT | Gesture_DOUBLE)
  289. X#define F2 (Gesture_FINGERS | Gesture_DOUBLE)
  290. X#define W2 (Gesture_WAVE | Gesture_DOUBLE)
  291. X#define C2 (Gesture_CLAPHALF | Gesture_DOUBLE)
  292. X#define S2 (Gesture_SNAP | Gesture_DOUBLE)
  293. X
  294. Xstruct spelldef spelllist[NUMSPELLS] = {
  295. X    {4, {C2, D,  P,  W},    0, 1, "Dispel Magic"},
  296. X    {5, {C2, S,  W,  W,  S},    0, 1, "Summon Elemental"},
  297. X    {2, {C2, W2},        0, 1, "Magic Mirror"},
  298. X    {5, {D,  F,  F,  D,  D},    0, 0, "Lightning Bolt"},
  299. X    {4, {D,  F,  P,  W},    0, 1, "Cure Heavy Wounds"},
  300. X    {3, {D,  F,  W},        0, 1, "Cure Light Wounds"},
  301. X    {3, {D,  P,  P},        1, 0, "Amnesia"},
  302. X    {3, {D,  S,  F},        1, 0, "Confusion"},
  303. X    {6, {D,  S,  F,  F,  F,  C2},0, 0,"Disease"},
  304. X    {5, {D,  W,  F,  F,  D2},    1, 0, "Blindness"},
  305. X    {6, {D,  W,  S,  S,  S,  P},0, 1, "Delayed Effect"},
  306. X    {6, {D,  W,  W,  F,  W,  C2},0, 1,"Raise Dead"},
  307. X    {6, {D,  W,  W,  F,  W,  D},0, 0, "Poison"},
  308. X    {3, {F,  F,  F},        1, 0, "Paralysis"},
  309. X    {5, {F,  P,  S,  F,  W},    0, 1, "Summon Troll"},
  310. X    {5, {F,  S,  S,  D,  D},    0, 0, "Fireball"},
  311. X    {1, {P},            0, 1, "Shield"},
  312. X    {1, {P2},            0, 0, "SURRENDER"},
  313. X    {4, {P,  D,  W,  P},    0, 1, "Remove Enchantment"},
  314. X    {4, {P,  P,  W2, S2},    1, 1, "Invisibility"},
  315. X    {4, {P,  S,  D,  D},    1, 0, "Charm Monster"},
  316. X    {4, {P,  S,  D,  F},    1, 0, "Charm Person"},
  317. X    {4, {P,  S,  F,  W},    0, 1, "Summon Ogre"},
  318. X    {8, {P,  W,  P,  F,  S,  S,  S,  D},0,0,"Finger of Death"},
  319. X    {6, {P,  W,  P,  W,  W,  C2},1, 1,"Haste"},
  320. X    {2, {S,  D},        0, 0, "Missile"},
  321. X    {3, {S,  F,  W},        0, 1, "Summon Goblin"},
  322. X    {3, {S,  P,  F},        0, 0, "Anti-Spell"},
  323. X    {7, {S,  P,  F,  P,  S,  D,  W},0,1,"Permanency"},
  324. X    {4, {S,  P,  P,  C2},    0, 1, "Time Stop"},
  325. X    {4, {S,  S,  F,  P},    1, 1, "Resist Cold"},
  326. X    {3, {S,  W,  D},        1, 0, "Fear"},
  327. X    {4, {S,  W,  W,  C2},    0, 0, "Fire Storm"},
  328. X    {4, {W,  D,  D,  C2},    0, 0, "Lightning Bolt"},
  329. X    {3, {W,  F,  P},        0, 0, "Cause Light Wounds"},
  330. X    {6, {W,  F,  P,  S,  F,  W},0, 1, "Summon Giant"},
  331. X    {4, {W,  P,  F,  D},    0, 0, "Cause Heavy Wounds"},
  332. X    {3, {W,  P,  P},        0, 0, "Counter-Spell"},
  333. X    {4, {W,  S,  S,  C2},    0, 0, "Ice Storm"},
  334. X    {4, {W,  W,  F,  P},    1, 1, "Resist Heat"},
  335. X    {3, {W,  W,  P},        1, 1, "Protection From Evil"},
  336. X    {3, {W,  W,  S},        0, 0, "Counter-Spell"},
  337. X    {1,    {Gesture_KNIFE},    0, 0, "stab"}
  338. X};
  339. X
  340. X#undef P
  341. X#undef D
  342. X#undef F
  343. X#undef W
  344. X#undef C
  345. X#undef S
  346. X#undef P2
  347. X#undef D2
  348. X#undef F2
  349. X#undef W2
  350. X#undef C2
  351. X#undef S2
  352. X
  353. Xint reverse_sort_list[NUMSPELLS] = {
  354. X    SP__LIGHTNING_BOLT2, SP__DISEASE, SP__TIME_STOP, SP__ICE_STORM, SP__RAISE_DEAD,
  355. X    SP__HASTE, SP__FIRE_STORM, SP__LIGHTNING_BOLT, SP__CHARM_MONSTER, SP__FIREBALL,
  356. X    SP__BLINDNESS, SP__CAUSE_HEAVY_WOUNDS, SP__MISSILE, SP__FINGER_OF_DEATH,
  357. X    SP__POISON, SP__FEAR, SP__CHARM_PERSON, SP__PARALYSIS, SP__ANTI_SPELL,
  358. X    SP__CONFUSION, SP__SHIELD, SP__SURRENDER, SP__RESIST_COLD, SP__CAUSE_LIGHT_WOUNDS,
  359. X    SP__RESIST_HEAT, SP__AMNESIA, SP__COUNTER_SPELL, SP__DELAYED_EFFECT,
  360. X    SP__REMOVE_ENCHANTMENT, SP__PROTECTION_FROM_EVIL, SP__INVISIBILITY,
  361. X    SP__COUNTER_SPELL2, SP__SUMMON_ELEMENTAL, SP__MAGIC_MIRROR, SP__PERMANENCY,
  362. X    SP__CURE_LIGHT_WOUNDS, SP__SUMMON_GOBLIN, SP__SUMMON_OGRE, SP__SUMMON_TROLL,
  363. X    SP__SUMMON_GIANT, SP__DISPEL_MAGIC, SP__CURE_HEAVY_WOUNDS, SP__STAB
  364. X};
  365. Xint alphabet_sort_list[NUMSPELLS] = {
  366. X    SP__AMNESIA, SP__ANTI_SPELL, SP__BLINDNESS, SP__CAUSE_HEAVY_WOUNDS,
  367. X    SP__CAUSE_LIGHT_WOUNDS, SP__CHARM_MONSTER, SP__CHARM_PERSON, SP__CONFUSION,
  368. X    SP__COUNTER_SPELL, SP__COUNTER_SPELL2, SP__CURE_HEAVY_WOUNDS,
  369. X    SP__CURE_LIGHT_WOUNDS, SP__DELAYED_EFFECT, SP__DISEASE, SP__DISPEL_MAGIC,
  370. X    SP__FEAR, SP__FINGER_OF_DEATH, SP__FIRE_STORM, SP__FIREBALL, SP__HASTE,
  371. X    SP__ICE_STORM, SP__INVISIBILITY, SP__LIGHTNING_BOLT, SP__LIGHTNING_BOLT2,
  372. X    SP__MAGIC_MIRROR, SP__MISSILE, SP__PARALYSIS, SP__PERMANENCY, SP__POISON,
  373. X    SP__PROTECTION_FROM_EVIL, SP__RAISE_DEAD, SP__REMOVE_ENCHANTMENT,
  374. X    SP__RESIST_COLD, SP__RESIST_HEAT, SP__SHIELD, SP__SUMMON_ELEMENTAL,
  375. X    SP__SUMMON_GIANT, SP__SUMMON_GOBLIN, SP__SUMMON_OGRE, SP__SUMMON_TROLL,
  376. X    SP__SURRENDER, SP__TIME_STOP, SP__STAB
  377. X};
  378. X
  379. Xstatic int check_one_spell(numgests, glist, mainhand, spel)
  380. Xint numgests;
  381. Xstruct wizgesture *glist;
  382. Xint mainhand;
  383. Xstruct spelldef *spel;
  384. X{
  385. X    int otherhand = (1-mainhand);
  386. X    int jx, result, pos;
  387. X
  388. X    for (jx=spel->length-1; jx>=0; jx--) {
  389. X    pos = numgests - (spel->length - jx);
  390. X    if (pos<0) {
  391. X        /* fell off beginning of gesture list */
  392. X        return 0; 
  393. X    }
  394. X    if (spel->gests[jx] & Gesture_DOUBLE) {
  395. X        result = spel->gests[jx] & (~Gesture_DOUBLE);
  396. X        if (!(glist[pos].did[mainhand] == result
  397. X          && glist[pos].did[otherhand] == result)) {
  398. X        /* failed to do two-handed gesture */
  399. X        return 0; 
  400. X        }
  401. X    }
  402. X    else {
  403. X        if (!(glist[pos].did[mainhand] == spel->gests[jx])) {
  404. X        /* failed to do one-handed gesture */
  405. X         return 0; 
  406. X        }
  407. X    }
  408. X    }
  409. X
  410. X    return 1;
  411. X}
  412. X
  413. X/* writes results into found[] (OR of MASK_LEFT and MASK_RIGHT, or else MASK_BOTH) */
  414. Xvoid find_castspells(found, numgests, glist)
  415. Xint *found; /* pointer to array[NUMSPELLS] */
  416. Xint numgests;
  417. Xstruct wizgesture *glist;
  418. X{
  419. X    int ix, result;
  420. X    struct spelldef *spel;
  421. X
  422. X    for (ix=0; ix<NUMSPELLS; ix++) {
  423. X    spel = &(spelllist[ix]);
  424. X    result = 0;
  425. X    if (check_one_spell(numgests, glist, 0, spel))
  426. X        result |= MASK_LEFT;
  427. X    if (check_one_spell(numgests, glist, 1, spel))
  428. X        result |= MASK_RIGHT;
  429. X    if (result && (spel->gests[spel->length-1] & Gesture_DOUBLE)) {
  430. X        /* spell was completed with a double-handed gesture */
  431. X        result = MASK_TWOHAND;
  432. X    }
  433. X    found[ix] = result;
  434. X    }
  435. X}
  436. END_OF_FILE
  437. if test 5841 -ne `wc -c <'espells.c'`; then
  438.     echo shar: \"'espells.c'\" unpacked with wrong size!
  439. fi
  440. # end of 'espells.c'
  441. fi
  442. if test -f 'handwave.h' -a "${1}" != "-c" ; then 
  443.   echo shar: Will not clobber existing file \"'handwave.h'\"
  444. else
  445. echo shar: Extracting \"'handwave.h'\" \(4432 characters\)
  446. sed "s/^X//" >'handwave.h' <<'END_OF_FILE'
  447. X/* header file for client */
  448. X
  449. Xtypedef void game;
  450. X
  451. X#define Turn_NORMAL    (0)
  452. X#define Turn_HASTE    (1)
  453. X#define Turn_TIMESTOP    (2)
  454. X
  455. X#define Gesture_NOTHING        (0)
  456. X#define Gesture_PALM        (1)
  457. X#define Gesture_DIGIT        (2)
  458. X#define Gesture_FINGERS        (3)
  459. X#define Gesture_WAVE        (4)
  460. X#define Gesture_CLAPHALF    (5)
  461. X#define Gesture_SNAP        (6)
  462. X#define Gesture_KNIFE        (7)
  463. X
  464. X#define Gesture_ANTISPELL    (8) /* not less than NUMGESTURES, because. */
  465. X#define Gesture_UNCLEAR        (9) /* not less than NUMGESTURES, because. */
  466. X
  467. X#define NUMGESTURES        (8)
  468. X#define Gesture_DOUBLE        (16)
  469. X
  470. X#define MAXPLAYERS        (8)
  471. X
  472. X#define Gender_NONE        (0)
  473. X#define Gender_MALE        (1)
  474. X#define Gender_FEMALE        (2)
  475. X#define Gender_NEUTER        (3)
  476. X
  477. X#define Stuff_RESIST_HEAT    (1<<0)
  478. X#define Stuff_RESIST_COLD    (1<<1)
  479. X#define Stuff_PROTECT_EVIL    (1<<2)
  480. X#define Stuff_POISON        (1<<3)
  481. X#define Stuff_DISEASE        (1<<4)
  482. X#define Stuff_INVISIBLE        (1<<5)
  483. X#define Stuff_BLIND        (1<<6)
  484. X
  485. X#define Qu_NoQuery    (0)
  486. X/* placeholder; to be ignored by client */
  487. X#define Qu_LeftHand    (1)
  488. X#define Qu_RightHand    (2)
  489. X/* rock is an array of int. rock[0] is the list length; rock[1..len] is a spell number,
  490. X   ORed with QuVal_Hand_Both if the spell requires both hands. Answer is an index 
  491. X   into rock (0..len-1) */
  492. X#define Qu_SetOffDelay    (3)
  493. X/* rock is the spell number */
  494. X
  495. X#define Qu_ElementalType (4)
  496. X/* no rock */
  497. X
  498. X#define Qu_ParalysisHand (5)
  499. X#define Qu_CharmHand (6)
  500. X/* rock is index number of target wizard */
  501. X
  502. X#define Qu_CharmGesture (7)
  503. X/* rock is index number of target wizard. Answer is Gesture_*. */
  504. X
  505. X#define Qu_MonsterTarget (8)
  506. X/* rock is (0 if monster gets one attack, 1 or 2 if it gets two) * 256 + monster index.
  507. X   Answer is a wizard/creature number, ORed with QuVal_Target_*. (Or 0 for none). */
  508. X
  509. X#define Qu_WhichToDelay (9)
  510. X#define Qu_WhichToPerm (10)
  511. X/* rock is a pointer to an int array of spell numbers, terminated by -1. */
  512. X
  513. X/* for qtypes higher than this, it's a target picker. rock is the spell number,
  514. X   ORed with QuVal_Hand_*. Answer is a wizard/creature/corpse number, ORed with
  515. X   QuVal_Target_*. (Or 0 for none) */
  516. X
  517. X#define Qu_TargetBeing        (20)
  518. X#define Qu_TargetBeingNone    (21)
  519. X#define Qu_TargetWizard        (22)
  520. X#define Qu_TargetWizardNone    (23)
  521. X#define Qu_TargetRaiseDead    (24)
  522. X
  523. X
  524. X#define QuVal_Hand_Left        (256)
  525. X#define QuVal_Hand_Right    (512)
  526. X#define QuVal_Hand_Both        (1024)
  527. X#define QuVal_Hand_MASK        (QuVal_Hand_Left | QuVal_Hand_Right | QuVal_Hand_Both)
  528. X
  529. X#define QuVal_Target_Wizard    (256)
  530. X#define QuVal_Target_Creature    (512)
  531. X#define QuVal_Target_Corpse    (1024)
  532. X#define QuVal_Target_MASK    (QuVal_Target_Wizard | QuVal_Target_Creature | QuVal_Target_Corpse)
  533. X
  534. X
  535. Xstruct query {
  536. X    int player;
  537. X    int qtype;
  538. X    char *rock;
  539. X    int answer; /* to be filled in */
  540. X};
  541. X
  542. Xstruct interface {
  543. X    /* in the printing calls, any char * may be NULL */
  544. X    void (*proc_PrintMsg)( /* char *msg, game *game, rock */ );
  545. X    void (*proc_PrintMsg2)( /* int person1, char *msg1, char *msgelse, game *game, rock */ );  
  546. X    void (*proc_PrintMsg3)( /* int person1, int person2, char *msg1, char *msg2,
  547. X        char *msgelse, game *game, rock */ );
  548. X    void (*proc_Queries)( /* int numqueries, struct query *qlist, game *game, rock */ ); 
  549. X};
  550. X
  551. Xextern game *BeginGame( /* int numplayers, char **names, int *genders, struct interface *callbacks, rock */ );
  552. X/* names is a pointer to an array of name strings. */
  553. X
  554. Xextern int RunTurn( /* game *game, int *moves */ );
  555. X/* moves contains two ints for each player (left, right). The encoding is with Gesture_*. */
  556. X
  557. Xextern void SeeGesture( /* game *game, int player, int asker, int *buf, int size */ );
  558. X
  559. Xextern void FreeGame( /* game *game */ );
  560. X
  561. Xextern int TurnType( /* game *game */ );
  562. Xextern int TurnPlayerActive( /* game *game, int player */ );
  563. X
  564. Xextern int NumberOfTargets( /* game *game, int targettype */);
  565. Xextern char *NameOfTarget( /* game *game, int targettype, int targetnum */);
  566. Xextern int StuffAboutTarget( /* game *game, int targettype, int targetnum */);
  567. X/* targettype is QuVal_Target_* */
  568. X
  569. Xextern int NumberOfBeings( /* game *game, int targettype */);
  570. Xextern int HitPointsOfBeing( /* game *game, int targettype, int indexnum */);
  571. Xextern int StuffAboutBeing( /* game *game, int targettype, int indexnum */);
  572. Xextern int OwnerOfCreature( /* game *game, int indexnum */);
  573. Xextern char *NameOfBeing( /* game *game, int targettype, int indexnum */);
  574. X/* targettype is QuVal_Target_* */
  575. X
  576. Xextern void LogInTranscript( /* game *game, char *str */);
  577. Xextern void WriteTranscript( /* game *game, FILE *f */);
  578. END_OF_FILE
  579. if test 4432 -ne `wc -c <'handwave.h'`; then
  580.     echo shar: \"'handwave.h'\" unpacked with wrong size!
  581. fi
  582. # end of 'handwave.h'
  583. fi
  584. if test -f 'internal.h' -a "${1}" != "-c" ; then 
  585.   echo shar: Will not clobber existing file \"'internal.h'\"
  586. else
  587. echo shar: Extracting \"'internal.h'\" \(4288 characters\)
  588. sed "s/^X//" >'internal.h' <<'END_OF_FILE'
  589. X#include "spelllist.h"
  590. X
  591. X#define PrintMsg(msg)   (log_text(self, msg),\
  592. X            self->callbacks.proc_PrintMsg)((msg), self,\
  593. X            (self->rock))
  594. X#define PrintMsg2(person, msg1, msgelse)   (log_text(self, msgelse),\
  595. X            self->callbacks.proc_PrintMsg2)((person), (msg1),\
  596. X            (msgelse), self, (self->rock))
  597. X#define PrintMsg3(person1, person2, msg1, msg2, msgelse)   (log_text(self, msgelse),\
  598. X            self->callbacks.proc_PrintMsg3)((person1), (person2),\
  599. X            (msg1), (msg2), (msgelse), self, (self->rock))
  600. X#define Queries(numqueries, querylist)   (setup_targetlist(self),\
  601. X            (self->callbacks.proc_Queries)((numqueries),\
  602. X            (querylist), self, (self->rock)))
  603. X
  604. X#define MAXSPELLCHOICES (16)    /* max number of spells that could possibly be
  605. X                invoked with one gesture */
  606. X
  607. Xstruct target {
  608. X    char *name;
  609. X    int index;
  610. X    long stuff;
  611. X};
  612. X
  613. Xstruct realgame {
  614. X    struct interface callbacks;
  615. X    char *rock;
  616. X    int numplayers;
  617. X    int turn;
  618. X    int turntype;
  619. X    int turnactive[MAXPLAYERS];
  620. X
  621. X    char *gamelog;
  622. X    int gamelog_pos;
  623. X    int gamelog_size;
  624. X
  625. X    struct wizard *wiz[MAXPLAYERS];
  626. X    struct creature *cre;
  627. X    int numcres, cre_size;
  628. X
  629. X    struct query *querylist;
  630. X    int querylist_size;
  631. X    int numqueries;
  632. X
  633. X    int numtargets[3];
  634. X    struct target *targetlist[3];
  635. X    int targetlist_size[3];
  636. X
  637. X    struct castspell *castlist, *hastelist;
  638. X
  639. X    /* per-round data */
  640. X    int fl_icestorm, fl_firestorm, fl_dispelmagic;
  641. X    int blind_array;
  642. X};
  643. X
  644. Xstruct wizgesture {
  645. X    int did[2];
  646. X    int invisible; /* was invisible for this move? */
  647. X    int blind; /* bit-array -- who was blind this move? */
  648. X    int turnnum, log_hp;
  649. X};
  650. X
  651. Xstruct permstats {
  652. X    int mind_spell, mind_detail;
  653. X    int fl_haste;
  654. X    int fl_prot_evil;
  655. X    int fl_resist_heat;
  656. X    int fl_resist_cold;
  657. X    int fl_blindness;
  658. X    int fl_invisibility;
  659. X};
  660. X
  661. Xstruct wizard {
  662. X    int alive;
  663. X    int hitpoints, max_hitpoints;
  664. X    int resistant_heat, resistant_cold, prot_from_evil, haste, timestop;
  665. X    int invisibility, blindness;
  666. X    int poison_time, disease_time;
  667. X    int mind_spell, mind_caster;
  668. X    struct permstats perm;
  669. X    char *name;
  670. X    int gender;
  671. X    /* per-round */
  672. X    int zaplist[NUMSPELLS];
  673. X    int enchant_caster, raisedead_caster, enchant_ppend;
  674. X    int fl_resist_heat, fl_resist_cold;
  675. X    int fl_resist_icestorm; /* due to fireball hits */
  676. X
  677. X    int numgests;
  678. X    int gests_size;
  679. X    struct wizgesture *gests;
  680. X    int surrendered;
  681. X    int fl_cast_lightning;
  682. X    int hand_paralyzed;
  683. X    int perm_time, delay_time;
  684. X    int delay_bank;
  685. X
  686. X    int foundlist[NUMSPELLS];
  687. X    int llist[MAXSPELLCHOICES], rlist[MAXSPELLCHOICES];
  688. X};
  689. X
  690. Xstruct creature {
  691. X    int alive;
  692. X    int hitpoints, max_hitpoints;
  693. X    int resistant_heat, resistant_cold, prot_from_evil, haste, timestop;
  694. X    int invisibility, blindness;
  695. X    int poison_time, disease_time;
  696. X    int mind_spell, mind_caster;
  697. X    struct permstats perm;
  698. X    char *name;
  699. X    int gender;
  700. X    /* per-round */
  701. X    int zaplist[NUMSPELLS];
  702. X    int enchant_caster, raisedead_caster, enchant_ppend;
  703. X    int fl_resist_heat, fl_resist_cold;
  704. X    int fl_resist_icestorm; /* due to fireball hits */
  705. X
  706. X    int type;
  707. X    int nocorpse;
  708. X    int owner;
  709. X    int last_target, last_targettype;
  710. X    int nowm_spell, nowm_caster;
  711. X};
  712. X
  713. Xunion being {
  714. X    struct {
  715. X    int alive;
  716. X    int hitpoints, max_hitpoints;
  717. X    int resistant_heat, resistant_cold, prot_from_evil, haste, timestop;
  718. X    int invisibility, blindness;
  719. X    int poison_time, disease_time;
  720. X    int mind_spell, mind_caster;
  721. X    struct permstats perm;
  722. X    char *name;
  723. X    int gender;
  724. X    /* per-round */
  725. X    int zaplist[NUMSPELLS];
  726. X    int enchant_caster, raisedead_caster, enchant_ppend;
  727. X    int fl_resist_heat, fl_resist_cold;
  728. X    int fl_resist_icestorm; /* due to fireball hits */
  729. X    } both;
  730. X
  731. X    struct wizard wiz;
  732. X    struct creature cre;
  733. X};
  734. X
  735. X
  736. X#define MASK_LEFT (1)
  737. X#define MASK_RIGHT (2)
  738. X#define MASK_TWOHAND (4)
  739. X
  740. Xstruct castspell {
  741. X    int caster;
  742. X    int handage;
  743. X    int spellnum;
  744. X    int target;
  745. X    int targettype; /* QuVal_Target_*, or 0 for nobody, or (-1) for no target required */
  746. X    int permanent;
  747. X    int rock;
  748. X
  749. X    struct castspell *next;
  750. X};
  751. X
  752. X#define Creature_GOBLIN (1)
  753. X#define Creature_OGRE   (2)
  754. X#define Creature_TROLL  (3)
  755. X#define Creature_GIANT  (4)
  756. X#define Creature_ICEL   (5)
  757. X#define Creature_FIREL  (6)
  758. X
  759. Xextern void setup_targetlist(); /* needed if Queries() is to be used */
  760. END_OF_FILE
  761. if test 4288 -ne `wc -c <'internal.h'`; then
  762.     echo shar: \"'internal.h'\" unpacked with wrong size!
  763. fi
  764. # end of 'internal.h'
  765. fi
  766. if test -f 'main.c' -a "${1}" != "-c" ; then 
  767.   echo shar: Will not clobber existing file \"'main.c'\"
  768. else
  769. echo shar: Extracting \"'main.c'\" \(11365 characters\)
  770. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  771. X/* This program is copyright 1993 by Andrew Plotkin.
  772. X The source code may be freely copied, distributed,
  773. X and modified, as long as this copyright notice is
  774. X retained.
  775. X */
  776. X
  777. X#include <stdio.h>
  778. X#include <string.h>
  779. X#include <X11/Xlib.h>
  780. X#include <X11/Xutil.h>
  781. X
  782. X#include "handwave.h"
  783. X#include "spelllist.h"
  784. X#include "patchlevel.h"
  785. X
  786. X#include "xspell.h"
  787. X
  788. Xint win_wid, win_hgt;
  789. X
  790. Xstruct player *players;
  791. Xint numplayers;
  792. Xint turnstate;
  793. X
  794. Xgame *gameval = NULL;
  795. X
  796. Xstatic int defaultnum = 0;
  797. Xstatic char *defaultnamelist[10] = {"White", "Black", "Red", "Green", "Blue",
  798. X        "Yellow", "Orange", "Purple", "Grey", "Charteuse"};
  799. Xstatic char *namelist[MAXPLAYERS] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
  800. Xstatic char *displist[MAXPLAYERS] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
  801. Xstatic int genderlist[MAXPLAYERS] = {Gender_MALE, Gender_MALE, Gender_MALE,
  802. X        Gender_MALE, Gender_MALE, Gender_MALE, Gender_MALE, Gender_MALE};
  803. X
  804. Xstatic struct query savequery = {
  805. X    0,
  806. X    Qu_SaveTranscript,
  807. X    NULL,
  808. X    0
  809. X};
  810. X
  811. Xstatic void PrintMsg(), PrintMsg2(), PrintMsg3();
  812. Xextern void redraw();
  813. Xextern void XQueries();
  814. X
  815. Xmain(argc, argv)
  816. Xint argc;
  817. Xchar *argv[];
  818. X{
  819. X    struct interface procs;
  820. X    struct maingame ignorerock;
  821. X    static char inbuf[256];
  822. X    int whowon;
  823. X    int ix, val;
  824. X    struct player *py;
  825. X    int movelist[MAXPLAYERS*2];
  826. X
  827. X    procs.proc_PrintMsg = PrintMsg;
  828. X    procs.proc_PrintMsg2 = PrintMsg2;
  829. X    procs.proc_PrintMsg3 = PrintMsg3;
  830. X    procs.proc_Queries = XQueries;
  831. X
  832. X    if (argc==1) {
  833. X    printf("usage: spellcast RemoteDisplay [ RemoteDisplay2 ... ]\n");
  834. X    exit(12);
  835. X    }
  836. X
  837. X    numplayers = 1;
  838. X    displist[0] = NULL;
  839. X    for (ix=1; ix<argc; ix++) {
  840. X    if (strlen(argv[ix])!=0) {
  841. X        if (index(argv[ix], ':'))
  842. X        displist[numplayers] = argv[ix];
  843. X        else {
  844. X        displist[numplayers] = (char *)malloc(strlen(argv[ix])+6);
  845. X        strcpy(displist[numplayers], argv[ix]);
  846. X        strcat(displist[numplayers], ":0.0");
  847. X        }
  848. X    }
  849. X    else
  850. X        displist[numplayers] = NULL;
  851. X    /* allow an empty argument to signify NULL display */
  852. X    numplayers++;
  853. X    }
  854. X
  855. X    if (numplayers < 2) {
  856. X    printf("You have listed only %d players!\n", numplayers);
  857. X    exit(12);
  858. X    }
  859. X    if (numplayers > MAXPLAYERS) {
  860. X    printf("There is a maximum of %d players!\n", MAXPLAYERS);
  861. X    exit(12);
  862. X    }
  863. X
  864. X    players = (struct player *)malloc(sizeof(struct player) * numplayers);
  865. X
  866. X    win_wid = 832;
  867. X    if (numplayers > 3)
  868. X    win_wid += (numplayers-3) * (2*GEST_SIZE + 20);
  869. X    win_hgt = 750;
  870. X    turnstate = State_Init;
  871. X
  872. X    for (ix=0; ix<numplayers; ix++) {
  873. X    val = win_init(ix);
  874. X    if (!val) {
  875. X        fprintf(stderr, "spellcast: exiting.\n");
  876. X        exit(-1);
  877. X    }
  878. X    }
  879. X
  880. X    gameval = BeginGame(numplayers, namelist, genderlist, &procs, &ignorerock);
  881. X
  882. X    do {
  883. X    val = TurnType(gameval);
  884. X    turnstate = State_Top;
  885. X    for (ix=0; ix<numplayers; ix++) {
  886. X        py = &(players[ix]);
  887. X        py->turn_active = TurnPlayerActive(gameval, ix); 
  888. X        py->turn_done = !py->turn_active;
  889. X    }
  890. X    for (ix=0; ix<numplayers; ix++) {
  891. X        py = &(players[ix]);
  892. X        py->gesture_chosen[0] = Gesture_NOTHING;
  893. X        py->gesture_chosen[1] = Gesture_NOTHING;
  894. X        clear_answers(py);
  895. X        if (py->turn_active)
  896. X        switch (val) {
  897. X            case Turn_HASTE:
  898. X            add_answer(py, "Enter your gestures for your Hastened move.",
  899. X                    "", 1, 0, NULL, 0);
  900. X            break;
  901. X            case Turn_TIMESTOP:
  902. X            add_answer(py, "Enter your gestures for your Time-Stopped move.",
  903. X                    "", 1, 0, NULL, 0);
  904. X            break;
  905. X            default:
  906. X            add_answer(py,
  907. X"Enter your gestures for this move, at the bottom of your gesture list.",
  908. X                    "", 1, 0, NULL, 0);
  909. X            break;
  910. X        }
  911. X        else
  912. X        switch (val) {
  913. X            case Turn_HASTE:
  914. X            add_answer(py, "Other people are Hastened this turn.",
  915. X                    "", 1, 0, NULL, 0);
  916. X            break;
  917. X            case Turn_TIMESTOP:
  918. X            add_answer(py, "You are frozen in time.", "", 1, 0, NULL, 0);
  919. X            break;
  920. X            default:
  921. X            add_answer(py, "You are out of the game.", "", 1, 0, NULL, 0);
  922. X            break;
  923. X        }
  924. X        redraw_column(py);
  925. X        draw_button(py, 0, 1); /* redraw turn-end button */
  926. X        redraw_queries_only(py, 0);
  927. X        /*update_statlist(py);*/
  928. X    }
  929. X    mainloop();
  930. X
  931. X    for (ix=0; ix<numplayers; ix++) {
  932. X        struct player *py = &(players[ix]);
  933. X        movelist[ix*2+0] = py->gesture_chosen[0];
  934. X        movelist[ix*2+1] = py->gesture_chosen[1];
  935. X    }
  936. X    whowon = RunTurn(gameval, movelist);
  937. X    } while (whowon < 0);
  938. X
  939. X    if (whowon==MAXPLAYERS)
  940. X    sprintf(inbuf, "\n+++ The game is a draw +++\n");
  941. X    else
  942. X    sprintf(inbuf, "\n+++ %s has won +++\n", NameOfBeing(gameval,
  943. X            QuVal_Target_Wizard, whowon));
  944. X    PrintMsg(inbuf, gameval, &ignorerock);
  945. X    LogInTranscript(gameval, inbuf);
  946. X    LogInTranscript(gameval, "\n");
  947. X
  948. X    turnstate = State_End;
  949. X    for (ix=0; ix<numplayers; ix++) {
  950. X    py = &(players[ix]);
  951. X    py->turn_active = 1;
  952. X    py->turn_done = 0;
  953. X    }
  954. X    for (ix=0; ix<numplayers; ix++) {
  955. X    py = &(players[ix]);
  956. X    clear_answers(py);
  957. X    if (ix==0)
  958. X        add_answer(py, "Do you want to save a transcript of this game?",
  959. X            "No", 1, 0, &savequery, 0);
  960. X    redraw_column(py);
  961. X    draw_button(py, 0, 1); /* redraw turn-end button */
  962. X    redraw_queries_only(py, 0);
  963. X    /*update_statlist(py);*/
  964. X    }
  965. X    mainloop();
  966. X
  967. X    savequery.answer = players[0].answers[0].answer;
  968. X    if (savequery.answer) {
  969. X    char fname[512];
  970. X    FILE *fl;
  971. X
  972. X    sprintf(fname, "%s/spellcast-%d", TRANSCRIPTDIR, getpid());
  973. X    fl = fopen(fname, "w");
  974. X    if (!fl) {
  975. X        printf("spellcast: unable to open %s for writing\n", fname);
  976. X        perror("spellcast: error");
  977. X    }
  978. X    else {
  979. X        WriteTranscript((game *)gameval, fl);
  980. X        fclose(fl);
  981. X        printf("Saved transcript in %s.\n", fname);
  982. X    }
  983. X    }
  984. X    FreeGame(gameval);
  985. X
  986. X}
  987. X
  988. Xint win_init(pnum)
  989. Xint pnum;
  990. X{
  991. X    XSetWindowAttributes attr;
  992. X    XGCValues gcvalues;
  993. X    char winname[256];
  994. X    char *fontname;
  995. X    char *name, *tmp;
  996. X    int ix, val;
  997. X
  998. X    struct player *py = &(players[pnum]);
  999. X
  1000. X    py->dpy = XOpenDisplay(displist[pnum]);
  1001. X    if (!py->dpy) {
  1002. X    fprintf(stderr, "spellcast: could not open display for player %d.\n", pnum);
  1003. X    return 0;
  1004. X    }
  1005. X
  1006. X    py->scn = DefaultScreen(py->dpy);
  1007. X    py->win = XCreateSimpleWindow(py->dpy, DefaultRootWindow(py->dpy), 100, 100,
  1008. X        win_wid, win_hgt, 1, BlackPixel(py->dpy, py->scn),
  1009. X        WhitePixel(py->dpy, py->scn));
  1010. X    py->backpm = XCreatePixmap(py->dpy, py->win, win_wid, win_hgt,
  1011. X        DefaultDepth(py->dpy, py->scn));
  1012. X    py->backstore = 0;
  1013. X
  1014. X    { /* make some window managers happy */
  1015. X    XWMHints wmhints;
  1016. X    wmhints.flags = InputHint;
  1017. X    wmhints.input = True;
  1018. X    XSetWMHints(py->dpy, py->win, &wmhints);
  1019. X    }
  1020. X
  1021. X    attr.event_mask = EVENTMASK;
  1022. X    XChangeWindowAttributes(py->dpy, py->win, CWEventMask, &attr);
  1023. X
  1024. X    tmp = XGetDefault(py->dpy, "spellcast", "name");
  1025. X    if (tmp) {
  1026. X    name = (char *)malloc(strlen(tmp)+1);
  1027. X    strcpy(name, tmp);
  1028. X    tmp = index(name, ':');
  1029. X    if (!tmp)
  1030. X        genderlist[pnum] = Gender_MALE;
  1031. X    else {
  1032. X        switch (*(tmp+1)) {
  1033. X        case 'f':
  1034. X        case 'F':
  1035. X            genderlist[pnum] = Gender_FEMALE;
  1036. X            break;
  1037. X        case 'n':
  1038. X        case 'N':
  1039. X            genderlist[pnum] = Gender_NEUTER;
  1040. X            break;
  1041. X        case 'x':
  1042. X        case 'X':
  1043. X            genderlist[pnum] = Gender_NONE;
  1044. X            break;
  1045. X        case 'm':
  1046. X        case 'M':
  1047. X        default:
  1048. X            genderlist[pnum] = Gender_MALE;
  1049. X            break;
  1050. X        }
  1051. X        *tmp = '\0';
  1052. X    }
  1053. X    tmp = name+strlen(name)-1;
  1054. X    while (tmp>name && (*tmp==' ' || *tmp=='\t'))
  1055. X        tmp--;
  1056. X    *(tmp+1) = '\0';
  1057. X    namelist[pnum] = name;
  1058. X    }
  1059. X    else {
  1060. X    namelist[pnum] = defaultnamelist[defaultnum];
  1061. X    defaultnum++;
  1062. X    }
  1063. X
  1064. X    do {
  1065. X    val = 0;
  1066. X    if (strlen(namelist[pnum])<1)
  1067. X        val = 1;
  1068. X    if (!strcmp(namelist[pnum], "nobody"))
  1069. X        val = 1;
  1070. X    if (!strcmp(namelist[pnum], "Nobody"))
  1071. X        val = 1;
  1072. X    for (ix=0; ix<pnum; ix++)
  1073. X        if (!strcmp(namelist[pnum], namelist[ix]))
  1074. X        val = 1;
  1075. X
  1076. X    if (val) {
  1077. X        tmp = namelist[pnum];
  1078. X        namelist[pnum] = defaultnamelist[defaultnum];
  1079. X        defaultnum++;
  1080. X
  1081. X        fprintf(stderr,
  1082. X"spellcast: the name '%s' for player %d is taken. Switching to '%s'...\n",
  1083. X            tmp, pnum, namelist[pnum]);
  1084. X    }
  1085. X    } while (val);
  1086. X
  1087. X    sprintf(winname, "Spellcast: %s", namelist[pnum]);
  1088. X    XStoreName(py->dpy, py->win, winname);
  1089. X
  1090. X    XMapWindow(py->dpy, py->win);
  1091. X
  1092. X    fontname = XGetDefault(py->dpy, "spellcast", "font");
  1093. X    if (!fontname)
  1094. X    fontname = BODYFONT;
  1095. X    py->font = XLoadQueryFont(py->dpy, fontname);
  1096. X
  1097. X    if (!py->font) {
  1098. X    fprintf(stderr,
  1099. X"spellcast: could not find font %s for player %d. Switching to %s...\n",
  1100. X            fontname, pnum, BODYFONT_ALT);
  1101. X    py->font = XLoadQueryFont(py->dpy, BODYFONT_ALT);
  1102. X    if (!py->font) {
  1103. X        fprintf(stderr,
  1104. X"spellcast: could not find font %s for player %d. Switching to %s...\n",
  1105. X            BODYFONT_ALT, pnum, BODYFONT_ALT2);
  1106. X        py->font = XLoadQueryFont(py->dpy, BODYFONT_ALT2);
  1107. X        if (!py->font) {
  1108. X        fprintf(stderr, "spellcast: could not find font %s for player %d.\n",
  1109. X                BODYFONT_ALT2, pnum);
  1110. X
  1111. X        return 0;
  1112. X        }
  1113. X
  1114. X    }
  1115. X    }
  1116. X
  1117. X    gcvalues.font = py->font->fid;
  1118. X    gcvalues.foreground = BlackPixel(py->dpy, py->scn);
  1119. X    gcvalues.background = WhitePixel(py->dpy, py->scn);
  1120. X    py->blackgc = XCreateGC(py->dpy, py->win, GCForeground|GCBackground|GCFont,
  1121. X        &gcvalues);
  1122. X    XSetGraphicsExposures(py->dpy, py->blackgc, 0);
  1123. X
  1124. X    gcvalues.foreground = WhitePixel(py->dpy, py->scn);
  1125. X    gcvalues.background = BlackPixel(py->dpy, py->scn);
  1126. X    py->whitegc = XCreateGC(py->dpy, py->win, GCForeground|GCBackground|GCFont,
  1127. X        &gcvalues);
  1128. X    XSetGraphicsExposures(py->dpy, py->whitegc, 0);
  1129. X
  1130. X    init_bitmaps(py);
  1131. X    init_xtext(pnum);
  1132. X    init_query(py);
  1133. X    init_stats(py);
  1134. X    init_talk(py);
  1135. X    py->button_lit = (-1);
  1136. X    redraw(py);
  1137. X
  1138. X    return 1;
  1139. X}
  1140. X
  1141. X#define POPUP_ELBOW (8)
  1142. X
  1143. Xvoid adjust_rect(mrec)
  1144. Xstruct rect *mrec;
  1145. X{
  1146. X    if (mrec->x+mrec->w >= win_wid-POPUP_ELBOW)
  1147. X    mrec->x = win_wid-POPUP_ELBOW - mrec->w;
  1148. X    if (mrec->y+mrec->h >= win_hgt-POPUP_ELBOW)
  1149. X    mrec->y = win_hgt-POPUP_ELBOW - mrec->h;
  1150. X    if (mrec->x < POPUP_ELBOW)
  1151. X    mrec->x = POPUP_ELBOW;
  1152. X    if (mrec->y < POPUP_ELBOW)
  1153. X    mrec->y = POPUP_ELBOW;
  1154. X}
  1155. X
  1156. Xvoid backing_store(py, mrec)
  1157. Xstruct player *py;
  1158. Xstruct rect *mrec;
  1159. X{
  1160. X    py->backrec = (*mrec);
  1161. X    if (py->backstore) {
  1162. X    printf("ERROR: backing store already on\n");
  1163. X    }
  1164. X    py->backstore = 1;
  1165. X    py->gotexpose = 0;
  1166. X    XCopyArea(py->dpy, py->win, py->backpm, py->blackgc, mrec->x, mrec->y,
  1167. X        mrec->w, mrec->h, 0, 0);
  1168. X}
  1169. X
  1170. Xvoid backing_restore(py)
  1171. Xstruct player *py;
  1172. X{
  1173. X    if (!py->backstore) {
  1174. X    printf("ERROR: backing store already off\n");
  1175. X    }
  1176. X    py->backstore = 0;
  1177. X    if (py->gotexpose) {
  1178. X    XClearArea(py->dpy, py->win, py->backrec.x, py->backrec.y,
  1179. X            py->backrec.w, py->backrec.h, 0);
  1180. X    redraw(py);
  1181. X    }
  1182. X    else {
  1183. X    XCopyArea(py->dpy, py->backpm, py->win, py->blackgc, 0, 0,
  1184. X            py->backrec.w, py->backrec.h, py->backrec.x, py->backrec.y);
  1185. X    }
  1186. X}
  1187. X
  1188. Xstatic void PrintMsg(msg, gameval, rock)
  1189. Xchar *msg;
  1190. Xgame *gameval;
  1191. Xstruct maingame *rock;
  1192. X{
  1193. X    int ix;
  1194. X    if (msg) {
  1195. X    for (ix=0; ix<numplayers; ix++)
  1196. X        dump_text(ix, msg);
  1197. X    }
  1198. X}
  1199. X
  1200. Xstatic void PrintMsg2(person1, msg1, msgelse, gameval, rock)
  1201. Xint person1;
  1202. Xchar *msg1, *msgelse;
  1203. Xgame *gameval;
  1204. Xstruct maingame *rock;
  1205. X{
  1206. X    int ix;
  1207. X
  1208. X    for (ix=0; ix<numplayers; ix++) {
  1209. X    if (ix==person1) {
  1210. X        if (msg1)
  1211. X        dump_text(ix, msg1);
  1212. X    }
  1213. X    else {
  1214. X        if (msgelse)
  1215. X        dump_text(ix, msgelse);
  1216. X    }
  1217. X    }
  1218. X}
  1219. X
  1220. Xstatic void PrintMsg3(person1, person2, msg1, msg2, msgelse, gameval, rock)
  1221. Xint person1, person2;
  1222. Xchar *msg1, *msg2, *msgelse;
  1223. Xgame *gameval;
  1224. Xstruct maingame *rock;
  1225. X{
  1226. X    int ix;
  1227. X
  1228. X    for (ix=0; ix<numplayers; ix++) {
  1229. X    if (ix==person1) {
  1230. X        if (msg1)
  1231. X        dump_text(ix, msg1);
  1232. X    }
  1233. X    else if (ix==person2) {
  1234. X        if (msg2)
  1235. X        dump_text(ix, msg2);
  1236. X    }
  1237. X    else {
  1238. X        if (msgelse)
  1239. X        dump_text(ix, msgelse);
  1240. X    }
  1241. X    }
  1242. X}
  1243. X
  1244. END_OF_FILE
  1245. if test 11365 -ne `wc -c <'main.c'`; then
  1246.     echo shar: \"'main.c'\" unpacked with wrong size!
  1247. fi
  1248. # end of 'main.c'
  1249. fi
  1250. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  1251.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  1252. else
  1253. echo shar: Extracting \"'patchlevel.h'\" \(23 characters\)
  1254. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  1255. X#define PATCHLEVEL "0"
  1256. END_OF_FILE
  1257. if test 23 -ne `wc -c <'patchlevel.h'`; then
  1258.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  1259. fi
  1260. # end of 'patchlevel.h'
  1261. fi
  1262. if test -f 'xbutton.c' -a "${1}" != "-c" ; then 
  1263.   echo shar: Will not clobber existing file \"'xbutton.c'\"
  1264. else
  1265. echo shar: Extracting \"'xbutton.c'\" \(7415 characters\)
  1266. sed "s/^X//" >'xbutton.c' <<'END_OF_FILE'
  1267. X#include <string.h>
  1268. X#include <X11/Xlib.h>
  1269. X#include <X11/Xutil.h>
  1270. X#include "handwave.h"
  1271. X#include "spelllist.h"
  1272. X#include "xspell.h"
  1273. X
  1274. X#define BBOX_X (32)
  1275. X#define BBOX_Y (576)
  1276. X#define BBOX_W (2)
  1277. X#define BBOX_H (1)
  1278. X
  1279. X#define BUTTON_W (150)
  1280. X#define BUTTON_H (32)
  1281. X#define BUTTON_CORNER (3)
  1282. X#define BUTTON_SPACE (4)
  1283. X
  1284. Xvoid draw_button();
  1285. X
  1286. Xvoid DrawStringCentered(py, str, xpos, ypos)
  1287. Xstruct player *py;
  1288. Xchar *str;
  1289. Xint xpos, ypos;
  1290. X{
  1291. X    static XCharStruct overall;
  1292. X    int direction, ascent, descent;
  1293. X    int len = strlen(str);
  1294. X
  1295. X    XTextExtents(py->font, str, len, &direction, &ascent, &descent, &overall);
  1296. X    XDrawImageString(py->dpy, py->win, py->blackgc, xpos-(overall.width)/2, ypos, str, len);
  1297. X
  1298. X}
  1299. X
  1300. X/* list NUMSPELLS-1 spells (skip SP__STAB) */
  1301. Xvoid draw_spelllist(py)
  1302. Xstruct player *py;
  1303. X{
  1304. X    int ix, jx, snum, gx, val, pos;
  1305. X    int tablehgt;
  1306. X    struct spelldef *spel;
  1307. X    char *cx;
  1308. X
  1309. X#define SL_COLUMNS (2)
  1310. X    int posx = py->spelllist_rect.x+16;
  1311. X    int posy = py->spelllist_rect.y+32;
  1312. X
  1313. X    draw_frame(py, &py->spelllist_rect);
  1314. X
  1315. X    if (py->spelllist_way==1)
  1316. X    cx = "Spell List (left button: sorted by gesture)";
  1317. X    else if (py->spelllist_way==2)
  1318. X    cx = "Spell List (middle button: alphabetical sort)";
  1319. X    else
  1320. X    cx = "Spell List (right button: reversed sort by gesture)";
  1321. X
  1322. X    DrawStringCentered(py, cx, py->spelllist_rect.x+py->spelllist_rect.w/2,
  1323. X        py->spelllist_rect.y+4+py->lineheight);
  1324. X
  1325. X    tablehgt = (NUMSPELLS-1+SL_COLUMNS-1) / SL_COLUMNS;
  1326. X    for (ix=0; ix<SL_COLUMNS; ix++)
  1327. X    for (jx=0; jx<tablehgt; jx++) {
  1328. X        if (py->spelllist_way==1)
  1329. X        snum = ix*tablehgt+jx;
  1330. X        else if (py->spelllist_way==2)
  1331. X        snum = alphabet_sort_list[ix*tablehgt+jx];
  1332. X        else
  1333. X        snum = reverse_sort_list[ix*tablehgt+jx];
  1334. X        if (snum >= NUMSPELLS-1)
  1335. X        break;
  1336. X        spel = &(spelllist[snum]);
  1337. X        for (gx=0; gx<spel->length; gx++) {
  1338. X        val = spel->gests[gx];
  1339. X        pos = ((py->spelllist_way==3) ? (gx+(8-spel->length))*(GEST_SMALL+1)-8 :
  1340. X                gx*(GEST_SMALL+1));
  1341. X                /*spel->length-gx-1 for reversed gestures*/
  1342. X        XCopyPlane(py->dpy, py->spelllistbm [(val&Gesture_DOUBLE)?1:0]
  1343. X                [(val&(~Gesture_DOUBLE))-1], py->win, py->blackgc,
  1344. X                0, 0, GEST_SMALL, GEST_SMALL, posx+ix*300+pos,
  1345. X                posy+jx*18, 1);
  1346. X        }
  1347. X        if (py->spelllist_way!=3) 
  1348. X        for (gx = spel->length; gx<8; gx++) {
  1349. X            pos = gx*(GEST_SMALL+1);
  1350. X            XCopyPlane(py->dpy, py->spelllistbm[0][6], py->win, py->blackgc,
  1351. X                0, 0, GEST_SMALL, GEST_SMALL, posx+ix*300+pos,
  1352. X                posy+jx*18, 1);
  1353. X        }
  1354. X        XDrawImageString(py->dpy, py->win, py->blackgc, posx+ix*300+8*(GEST_SMALL+1),
  1355. X            posy+jx*18+((GEST_SMALL+py->lineheight)/2)-2, spel->name,
  1356. X            strlen(spel->name));
  1357. X    }
  1358. X}
  1359. X
  1360. Xstatic void light_button(py, bnum)
  1361. Xstruct player *py;
  1362. Xint bnum;
  1363. X{
  1364. X    int hitx, hity;
  1365. X
  1366. X    if (py->button_lit != (-1)) {
  1367. X    hitx = py->button_lit % BBOX_W;
  1368. X    hity = py->button_lit / BBOX_W;
  1369. X    XDrawRectangle(py->dpy, py->win, py->whitegc, BBOX_X+hitx*BUTTON_W-1,
  1370. X            BBOX_Y+hity*BUTTON_H-1, BUTTON_W-BUTTON_SPACE+2,
  1371. X            BUTTON_H-BUTTON_SPACE+2);
  1372. X    }
  1373. X
  1374. X    py->button_lit = bnum;
  1375. X    if (py->button_lit != (-1)) {
  1376. X    hitx = py->button_lit % BBOX_W;
  1377. X    hity = py->button_lit / BBOX_W;
  1378. X    XDrawRectangle(py->dpy, py->win, py->blackgc, BBOX_X+hitx*BUTTON_W-1,
  1379. X            BBOX_Y+hity*BUTTON_H-1, BUTTON_W-BUTTON_SPACE+2,
  1380. X            BUTTON_H-BUTTON_SPACE+2);
  1381. X    }
  1382. X}
  1383. X
  1384. Xvoid redraw_buttons(py)
  1385. Xstruct player *py;
  1386. X{
  1387. X    int bnum;
  1388. X
  1389. X    for (bnum=0; bnum<BBOX_W*BBOX_H; bnum++) {
  1390. X    draw_button(py, bnum, 0);
  1391. X    }
  1392. X    light_button(py, py->button_lit);
  1393. X}
  1394. X
  1395. Xvoid draw_button(py, bnum, mode)
  1396. Xstruct player *py;
  1397. Xint bnum;
  1398. Xint mode; /* 0 for all, 1 for clear interior and relabel */
  1399. X{
  1400. X    int ix, jx;
  1401. X    char *cx;
  1402. X
  1403. X    static XPoint plist[9] = {
  1404. X    {0+BUTTON_CORNER, 0},
  1405. X    {BUTTON_W-BUTTON_SPACE-2*BUTTON_CORNER, 0},
  1406. X    {BUTTON_CORNER, BUTTON_CORNER},
  1407. X    {0, BUTTON_H-BUTTON_SPACE-2*BUTTON_CORNER},
  1408. X    {-BUTTON_CORNER, BUTTON_CORNER},
  1409. X    {-(BUTTON_W-BUTTON_SPACE-2*BUTTON_CORNER), 0},
  1410. X    {-BUTTON_CORNER, -BUTTON_CORNER},
  1411. X    {0, -(BUTTON_H-BUTTON_SPACE-2*BUTTON_CORNER)},
  1412. X    {BUTTON_CORNER, -BUTTON_CORNER},
  1413. X    };
  1414. X
  1415. X    ix = bnum % BBOX_W;
  1416. X    jx = bnum / BBOX_W;
  1417. X
  1418. X    if (mode==0) {
  1419. X    plist[0].x = BBOX_X + ix*BUTTON_W + BUTTON_CORNER;
  1420. X    plist[0].y = BBOX_Y + jx*BUTTON_H;
  1421. X    XDrawLines(py->dpy, py->win, py->blackgc, plist, 9, CoordModePrevious);
  1422. X    }
  1423. X
  1424. X    if (mode==1) {
  1425. X    /* clear interior */
  1426. X    XClearArea(py->dpy, py->win, BBOX_X + ix*BUTTON_W + BUTTON_CORNER,
  1427. X            BBOX_Y + jx*BUTTON_H + BUTTON_CORNER,
  1428. X            BUTTON_W-BUTTON_SPACE-2*BUTTON_CORNER,
  1429. X            BUTTON_H-BUTTON_SPACE-2*BUTTON_CORNER, 0);
  1430. X    }
  1431. X
  1432. X    switch (bnum) {
  1433. X    case 0:
  1434. X        if (!py->turn_active)
  1435. X        cx = "please wait....";
  1436. X        else if (turnstate == State_Top) {
  1437. X        if (!py->turn_done)
  1438. X            cx = "End Move";
  1439. X        else
  1440. X            cx = "Move ENDED.";
  1441. X        }
  1442. X        else if (turnstate == State_End) {
  1443. X        if (!py->turn_done)
  1444. X            cx = "Quit";
  1445. X        else
  1446. X            cx = "Wait....";
  1447. X        }
  1448. X        else {
  1449. X        if (!py->turn_done)
  1450. X            cx = "End Answers";
  1451. X        else
  1452. X            cx = "Answers ENDED.";
  1453. X        }
  1454. X        DrawStringCentered(py, cx, BBOX_X+ix*BUTTON_W+BUTTON_W/2,
  1455. X            BBOX_Y+jx*BUTTON_H+py->lineheight+1);
  1456. X        break;
  1457. X    case 1:
  1458. X        DrawStringCentered(py, "Spell List", BBOX_X+ix*BUTTON_W+BUTTON_W/2,
  1459. X            BBOX_Y+jx*BUTTON_H+py->lineheight+1);
  1460. X        break;
  1461. X    default:
  1462. X        break;
  1463. X    }
  1464. X
  1465. X}
  1466. X
  1467. Xint in_bbox_box(py, xpos, ypos)
  1468. Xstruct player *py;
  1469. Xint xpos, ypos;
  1470. X{
  1471. X    return (xpos >= BBOX_X
  1472. X        && xpos < BBOX_X + BBOX_W*BUTTON_W
  1473. X        && ypos >= BBOX_Y
  1474. X        && ypos < BBOX_Y + BBOX_H*BUTTON_H);
  1475. X}
  1476. X
  1477. Xint button_hit(py, xpos, ypos, button)
  1478. Xstruct player *py;
  1479. Xint xpos, ypos;
  1480. Xint button;
  1481. X{
  1482. X    int hitx, hity, bnum;
  1483. X    int ix;
  1484. X
  1485. X    hitx = (xpos-BBOX_X) / BUTTON_W;
  1486. X    hity = (ypos-BBOX_Y) / BUTTON_H;
  1487. X
  1488. X    if (hitx<0 || hity<0 || hitx>=BBOX_W || hity>=BBOX_H)
  1489. X    return ms_None;
  1490. X
  1491. X    bnum = hitx + hity*BBOX_W;
  1492. X
  1493. X    switch (bnum) {
  1494. X    case 0:
  1495. X        if (!py->turn_active)
  1496. X        return ms_None;
  1497. X        light_button(py, bnum);
  1498. X        return ms_DoneBtn;
  1499. X        break;
  1500. X    case 1:
  1501. X        py->spelllist_rect.w = 620;
  1502. X        py->spelllist_rect.h = 420;
  1503. X        py->spelllist_rect.x = 10;
  1504. X        py->spelllist_rect.y = 10;
  1505. X        py->spelllist_way = button;
  1506. X        backing_store(py, &py->spelllist_rect);
  1507. X        draw_spelllist(py);
  1508. X        return ms_SpellBtn;
  1509. X        break;
  1510. X    default:
  1511. X        printf("ERROR: unknown button thing!\n");
  1512. X        break;
  1513. X    }
  1514. X}
  1515. X
  1516. Xint button_motion(py, xpos, ypos, button)
  1517. Xstruct player *py;
  1518. Xint xpos, ypos;
  1519. Xint button;
  1520. X{
  1521. X    int hitx, hity, bnum;
  1522. X
  1523. X    switch (py->mousestate) {
  1524. X    case ms_DoneBtn:
  1525. X        hitx = (xpos-BBOX_X+BUTTON_W) / BUTTON_W - 1;
  1526. X        hity = (ypos-BBOX_Y+BUTTON_H) / BUTTON_H - 1;
  1527. X        if (hitx==0 && hity==0) {
  1528. X        if (py->button_lit!=0)
  1529. X            light_button(py, 0);
  1530. X        }
  1531. X        else {
  1532. X        if (py->button_lit!=(-1))
  1533. X            light_button(py, (-1));
  1534. X        }
  1535. X        break;
  1536. X    case ms_SpellBtn:
  1537. X    default:
  1538. X        break;
  1539. X    }
  1540. X}
  1541. X
  1542. Xint button_release(py, xpos, ypos, button)
  1543. Xstruct player *py;
  1544. Xint xpos, ypos;
  1545. Xint button;
  1546. X{
  1547. X    int ix, isok;
  1548. X
  1549. X    switch (py->mousestate) {
  1550. X    case ms_DoneBtn:
  1551. X        isok = 1;
  1552. X        if (turnstate==State_EQueries || turnstate==State_Queries) {
  1553. X        for (ix=0; ix<py->siquery.nlines; ix++)
  1554. X            if (!py->answers[ix].done) {
  1555. X            isok = 0;
  1556. X            strcpy(py->answers[ix].ans_str, "<answer?>");
  1557. X            /* ### set value to scroll to? */
  1558. X            }
  1559. X        }
  1560. X        if (py->button_lit==0) {
  1561. X        if (isok) {
  1562. X            py->turn_done = !(py->turn_done);
  1563. X            redraw_done_markers(py);
  1564. X        }
  1565. X        else
  1566. X            redraw_queries_only(py, 0);
  1567. X        light_button(py, (-1));
  1568. X        }
  1569. X        draw_button(py, 0, 1);
  1570. X        break;
  1571. X    case ms_SpellBtn:
  1572. X        backing_restore(py);
  1573. X        break;
  1574. X    default:
  1575. X        break;
  1576. X    }
  1577. X}
  1578. END_OF_FILE
  1579. if test 7415 -ne `wc -c <'xbutton.c'`; then
  1580.     echo shar: \"'xbutton.c'\" unpacked with wrong size!
  1581. fi
  1582. # end of 'xbutton.c'
  1583. fi
  1584. if test -f 'xgest.c' -a "${1}" != "-c" ; then 
  1585.   echo shar: Will not clobber existing file \"'xgest.c'\"
  1586. else
  1587. echo shar: Extracting \"'xgest.c'\" \(11180 characters\)
  1588. sed "s/^X//" >'xgest.c' <<'END_OF_FILE'
  1589. X#include <string.h>
  1590. X#include <X11/Xlib.h>
  1591. X#include <X11/Xutil.h>
  1592. X#include "handwave.h"
  1593. X#include "spelllist.h"
  1594. X#include "xspell.h"
  1595. X
  1596. X#include "ba.bm"
  1597. X#include "bc.bm"
  1598. X#include "bd.bm"
  1599. X#include "bf.bm"
  1600. X#include "bk.bm"
  1601. X#include "bn.bm"
  1602. X#include "bp.bm"
  1603. X#include "bs.bm"
  1604. X#include "bu.bm"
  1605. X#include "bw.bm"
  1606. X#include "bva.bm"
  1607. X#include "bvc.bm"
  1608. X#include "bvd.bm"
  1609. X#include "bvf.bm"
  1610. X#include "bvk.bm"
  1611. X#include "bvp.bm"
  1612. X#include "bvs.bm"
  1613. X#include "bvw.bm"
  1614. X
  1615. X#include "sc.bm"
  1616. X#include "sd.bm"
  1617. X#include "sd2.bm"
  1618. X#include "sf.bm"
  1619. X#include "sf2.bm"
  1620. X#include "sp.bm"
  1621. X#include "sp2.bm"
  1622. X#include "ss.bm"
  1623. X#include "ss2.bm"
  1624. X#include "sw.bm"
  1625. X#include "sw2.bm"
  1626. X#include "sdot.bm"
  1627. X
  1628. X#define COLUMN_SIZE (8)
  1629. X#define COLUMN_X (476)
  1630. X#define COLUMN_Y (33)
  1631. X#define GEST_SPACE (50)
  1632. X
  1633. Xvoid init_bitmaps(py)
  1634. Xstruct player *py;
  1635. X{
  1636. X    py->gesturebm[0][0] = XCreatePixmapFromBitmapData(py->dpy, py->win, bn_bits,
  1637. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1638. X    py->gesturebm[0][1] = XCreatePixmapFromBitmapData(py->dpy, py->win, bp_bits,
  1639. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1640. X    py->gesturebm[0][2] = XCreatePixmapFromBitmapData(py->dpy, py->win, bd_bits,
  1641. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1642. X    py->gesturebm[0][3] = XCreatePixmapFromBitmapData(py->dpy, py->win, bf_bits,
  1643. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1644. X    py->gesturebm[0][4] = XCreatePixmapFromBitmapData(py->dpy, py->win, bw_bits,
  1645. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1646. X    py->gesturebm[0][5] = XCreatePixmapFromBitmapData(py->dpy, py->win, bc_bits,
  1647. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1648. X    py->gesturebm[0][6] = XCreatePixmapFromBitmapData(py->dpy, py->win, bs_bits,
  1649. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1650. X    py->gesturebm[0][7] = XCreatePixmapFromBitmapData(py->dpy, py->win, bk_bits,
  1651. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1652. X    py->gesturebm[0][8] = XCreatePixmapFromBitmapData(py->dpy, py->win, ba_bits,
  1653. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1654. X    py->gesturebm[0][9] = XCreatePixmapFromBitmapData(py->dpy, py->win, bu_bits,
  1655. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1656. X
  1657. X    py->gesturebm[1][0] = XCreatePixmapFromBitmapData(py->dpy, py->win, bn_bits,
  1658. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1659. X    py->gesturebm[1][1] = XCreatePixmapFromBitmapData(py->dpy, py->win, bvp_bits,
  1660. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1661. X    py->gesturebm[1][2] = XCreatePixmapFromBitmapData(py->dpy, py->win, bvd_bits,
  1662. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1663. X    py->gesturebm[1][3] = XCreatePixmapFromBitmapData(py->dpy, py->win, bvf_bits,
  1664. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1665. X    py->gesturebm[1][4] = XCreatePixmapFromBitmapData(py->dpy, py->win, bvw_bits,
  1666. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1667. X    py->gesturebm[1][5] = XCreatePixmapFromBitmapData(py->dpy, py->win, bvc_bits,
  1668. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1669. X    py->gesturebm[1][6] = XCreatePixmapFromBitmapData(py->dpy, py->win, bvs_bits,
  1670. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1671. X    py->gesturebm[1][7] = XCreatePixmapFromBitmapData(py->dpy, py->win, bvk_bits,
  1672. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1673. X    py->gesturebm[1][8] = XCreatePixmapFromBitmapData(py->dpy, py->win, bva_bits,
  1674. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1675. X    py->gesturebm[1][9] = XCreatePixmapFromBitmapData(py->dpy, py->win, bu_bits,
  1676. X        GEST_SIZE, GEST_SIZE, 1, 0, 1);
  1677. X
  1678. X    py->spelllistbm[0][0] = XCreatePixmapFromBitmapData(py->dpy, py->win, sp_bits,
  1679. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1680. X    py->spelllistbm[0][1] = XCreatePixmapFromBitmapData(py->dpy, py->win, sd_bits,
  1681. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1682. X    py->spelllistbm[0][2] = XCreatePixmapFromBitmapData(py->dpy, py->win, sf_bits,
  1683. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1684. X    py->spelllistbm[0][3] = XCreatePixmapFromBitmapData(py->dpy, py->win, sw_bits,
  1685. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1686. X    py->spelllistbm[0][4] = 0; /* there is no single clap */
  1687. X    py->spelllistbm[0][5] = XCreatePixmapFromBitmapData(py->dpy, py->win, ss_bits,
  1688. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1689. X    py->spelllistbm[0][6] = XCreatePixmapFromBitmapData(py->dpy, py->win, sdot_bits,
  1690. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1691. X
  1692. X    py->spelllistbm[1][0] = XCreatePixmapFromBitmapData(py->dpy, py->win, sp2_bits,
  1693. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1694. X    py->spelllistbm[1][1] = XCreatePixmapFromBitmapData(py->dpy, py->win, sd2_bits,
  1695. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1696. X    py->spelllistbm[1][2] = XCreatePixmapFromBitmapData(py->dpy, py->win, sf2_bits,
  1697. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1698. X    py->spelllistbm[1][3] = XCreatePixmapFromBitmapData(py->dpy, py->win, sw2_bits,
  1699. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1700. X    py->spelllistbm[1][4] = XCreatePixmapFromBitmapData(py->dpy, py->win, sc_bits,
  1701. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1702. X    py->spelllistbm[1][5] = XCreatePixmapFromBitmapData(py->dpy, py->win, ss2_bits,
  1703. X        GEST_SMALL, GEST_SMALL, 1, 0, 1);
  1704. X    py->spelllistbm[1][6] = 0; /* no double dots */
  1705. X
  1706. X}
  1707. X
  1708. Xvoid redraw_column(py)
  1709. Xstruct player *py;
  1710. X{
  1711. X    int buf[COLUMN_SIZE+1];
  1712. X    int ix, gx;
  1713. X    int vall, valr;
  1714. X    int posx, posy;
  1715. X    int pnum = py-players;
  1716. X
  1717. X    if (turnstate==State_Init) {
  1718. X    return;
  1719. X    }
  1720. X
  1721. X    for (ix=0; ix<numplayers; ix++) {
  1722. X    posx = COLUMN_X + ix*(2*GEST_SIZE + 20);
  1723. X    posy = COLUMN_Y;
  1724. X
  1725. X    DrawStringCentered(py, NameOfBeing(gameval, QuVal_Target_Wizard, ix),
  1726. X            posx+GEST_SIZE, posy-py->lineheight+py->ascent);
  1727. X
  1728. X    if (turnstate!=State_Top) {
  1729. X        SeeGesture(gameval, ix, pnum, buf, COLUMN_SIZE);
  1730. X        gx=0;
  1731. X        if (turnstate==State_EQueries && ix!=pnum) {
  1732. X        buf[0] = (Gesture_UNCLEAR<<5) + Gesture_UNCLEAR;
  1733. X        }
  1734. X    }
  1735. X    else {
  1736. X        SeeGesture(gameval, ix, pnum, buf+1, COLUMN_SIZE);
  1737. X        gx=1;
  1738. X        if (ix==pnum) {
  1739. X        vall = py->gesture_chosen[0];
  1740. X        valr = py->gesture_chosen[1];
  1741. X        }
  1742. X        else {
  1743. X        vall = Gesture_UNCLEAR;
  1744. X        valr = Gesture_UNCLEAR;
  1745. X        }
  1746. X        XCopyPlane(py->dpy, py->gesturebm[0][vall], py->win, py->blackgc,
  1747. X            0, 0, GEST_SIZE, GEST_SIZE, posx,
  1748. X            posy+(GEST_SPACE)*(COLUMN_SIZE-1), 1);
  1749. X        XCopyPlane(py->dpy, py->gesturebm[1][valr], py->win, py->blackgc,
  1750. X            0, 0, GEST_SIZE, GEST_SIZE, posx+GEST_SPACE,
  1751. X            posy+(GEST_SPACE)*(COLUMN_SIZE-1), 1);
  1752. X    }
  1753. X    for (/* gx is set */; gx<COLUMN_SIZE; gx++) {
  1754. X        if (buf[gx]==(-1)) {
  1755. X        valr = Gesture_NOTHING;
  1756. X        vall = Gesture_NOTHING;
  1757. X        }
  1758. X        else {
  1759. X        valr = buf[gx] >> 5;
  1760. X        vall = buf[gx] & 31; /* 31==01111 */
  1761. X        }
  1762. X        XCopyPlane(py->dpy, py->gesturebm[0][vall], py->win, py->blackgc,
  1763. X            0, 0, GEST_SIZE, GEST_SIZE, posx,
  1764. X            posy+(GEST_SPACE)*(COLUMN_SIZE-(gx+1)), 1);
  1765. X        XCopyPlane(py->dpy, py->gesturebm[1][valr], py->win, py->blackgc,
  1766. X            0, 0, GEST_SIZE, GEST_SIZE, posx+GEST_SPACE,
  1767. X            posy+(GEST_SPACE)*(COLUMN_SIZE-(gx+1)), 1);
  1768. X    }
  1769. X    }
  1770. X}
  1771. X
  1772. Xvoid draw_frame(py, mrec)
  1773. Xstruct player *py;
  1774. Xstruct rect *mrec;
  1775. X{
  1776. X    XClearArea(py->dpy, py->win, mrec->x, mrec->y, mrec->w, mrec->h, 0);
  1777. X
  1778. X    XDrawRectangle(py->dpy, py->win, py->blackgc, mrec->x, mrec->y,
  1779. X        mrec->w-FRAME_SHADOW, mrec->h-FRAME_SHADOW);
  1780. X    XDrawRectangle(py->dpy, py->win, py->blackgc, mrec->x+1, mrec->y+1,
  1781. X        mrec->w-FRAME_SHADOW-2, mrec->h-FRAME_SHADOW-2);
  1782. X    XFillRectangle(py->dpy, py->win, py->blackgc, mrec->x+mrec->w-FRAME_SHADOW,
  1783. X        mrec->y+FRAME_SHADOW, FRAME_SHADOW, mrec->h-FRAME_SHADOW);
  1784. X    XFillRectangle(py->dpy, py->win, py->blackgc, mrec->x+FRAME_SHADOW,
  1785. X        mrec->y+mrec->h-FRAME_SHADOW, mrec->w-FRAME_SHADOW, FRAME_SHADOW);
  1786. X}
  1787. X
  1788. Xvoid draw_gesture_menu(py)
  1789. Xstruct player *py;
  1790. X{
  1791. X    static char gesture_prompt[2][128];
  1792. X    int ix, jx;
  1793. X    int posx, posy;
  1794. X
  1795. X    draw_frame(py, &py->gesture_rect);
  1796. X    sprintf(gesture_prompt[0], "What gesture do you want to");
  1797. X    sprintf(gesture_prompt[1], "make with your %s hand?",
  1798. X        py->gesture_hand?"right":"left");
  1799. X    XDrawImageString(py->dpy, py->win, py->blackgc, py->gesture_rect.x+20,
  1800. X        py->gesture_rect.y+10+py->lineheight, gesture_prompt[0],
  1801. X        strlen(gesture_prompt[0]));
  1802. X    XDrawImageString(py->dpy, py->win, py->blackgc, py->gesture_rect.x+20,
  1803. X        py->gesture_rect.y+10+2*py->lineheight, gesture_prompt[1],
  1804. X        strlen(gesture_prompt[1]));
  1805. X
  1806. X    posx = py->gesture_rect.x+20;
  1807. X    posy = py->gesture_rect.y+60;
  1808. X    for (jx=0; jx<2; jx++)
  1809. X    for (ix=0; ix<4; ix++) {
  1810. X        XCopyPlane(py->dpy, py->gesturebm[py->gesture_hand][jx*4+ix],
  1811. X            py->win, py->blackgc, 0, 0, GEST_SIZE, GEST_SIZE,
  1812. X            posx+ix*GEST_SPACE, posy+jx*GEST_SPACE, 1);
  1813. X    }
  1814. X}
  1815. X
  1816. Xint in_gesture_box(py, xpos, ypos)
  1817. Xstruct player *py;
  1818. Xint xpos, ypos;
  1819. X{
  1820. X    return (xpos >= COLUMN_X
  1821. X        && xpos < COLUMN_X + numplayers*(2*GEST_SIZE + 20)
  1822. X        && ypos >= COLUMN_Y
  1823. X        && ypos < COLUMN_Y + GEST_SPACE*COLUMN_SIZE);
  1824. X}
  1825. X
  1826. Xint gesture_hit(py, xpos, ypos, button)
  1827. Xstruct player *py;
  1828. Xint xpos, ypos; /* relative to column pos */
  1829. Xint button;
  1830. X{
  1831. X    int pnum = py-players;
  1832. X    int hitcol, hitrow, hithand;
  1833. X
  1834. X    xpos -= COLUMN_X;
  1835. X    ypos -= COLUMN_Y;
  1836. X
  1837. X    if (!py->turn_active || py->turn_done)
  1838. X    return ms_None;
  1839. X
  1840. X    hitcol = xpos / (2*GEST_SIZE + 20);
  1841. X    hitrow = ypos / GEST_SPACE;
  1842. X    hithand = (xpos % (2*GEST_SIZE + 20)) / GEST_SPACE;
  1843. X    if (hithand < 0 || hithand > 1)
  1844. X    return ms_None;
  1845. X
  1846. X    if (hitrow==COLUMN_SIZE-1 && hitcol==pnum && button==1 && turnstate==State_Top) {
  1847. X    py->gesture_rect.w = 240;
  1848. X    py->gesture_rect.h = 180;
  1849. X    py->gesture_rect.x = xpos + COLUMN_X - py->gesture_rect.w/2;
  1850. X    py->gesture_rect.y = ypos + COLUMN_Y - py->gesture_rect.h/2;
  1851. X    py->gesture_hand = hithand;
  1852. X    py->gesture_sel = (-1);
  1853. X    adjust_rect(&py->gesture_rect);
  1854. X    backing_store(py, &py->gesture_rect);
  1855. X    draw_gesture_menu(py);
  1856. X    gesture_motion(py, xpos+COLUMN_X, ypos+COLUMN_Y, button);
  1857. X    return ms_Gesture;
  1858. X    }
  1859. X
  1860. X    return ms_None;
  1861. X}
  1862. X
  1863. Xint gesture_motion(py, xpos, ypos, button)
  1864. Xstruct player *py;
  1865. Xint xpos, ypos;
  1866. Xint button;
  1867. X{
  1868. X    int hitx, hity, hit;
  1869. X    int posx, posy;
  1870. X
  1871. X    posx = py->gesture_rect.x+20;
  1872. X    posy = py->gesture_rect.y+60;
  1873. X
  1874. X    hitx = (xpos - posx + GEST_SPACE) / GEST_SPACE - 1;
  1875. X    hity = (ypos - posy + GEST_SPACE) / GEST_SPACE - 1;
  1876. X
  1877. X    if (hitx>=0 && hitx<4 && hity>=0 && hity<2)
  1878. X    hit = hity*4 + hitx;
  1879. X    else
  1880. X    hit = (-1);
  1881. X
  1882. X    if (hit==py->gesture_sel)
  1883. X    return;
  1884. X
  1885. X    if (py->gesture_sel != (-1)) {
  1886. X    /* erase old */
  1887. X    hitx = py->gesture_sel % 4;
  1888. X    hity = py->gesture_sel / 4;
  1889. X    XDrawRectangle(py->dpy, py->win, py->whitegc, posx+hitx*GEST_SPACE-1,
  1890. X            posy+hity*GEST_SPACE-1, GEST_SIZE+1, GEST_SIZE+1);
  1891. X    XDrawRectangle(py->dpy, py->win, py->whitegc, posx+hitx*GEST_SPACE-2,
  1892. X            posy+hity*GEST_SPACE-2, GEST_SIZE+3, GEST_SIZE+3);
  1893. X    }
  1894. X
  1895. X    py->gesture_sel = hit;
  1896. X
  1897. X    if (py->gesture_sel != (-1)) {
  1898. X    /* draw new */
  1899. X    hitx = py->gesture_sel % 4;
  1900. X    hity = py->gesture_sel / 4;
  1901. X    XDrawRectangle(py->dpy, py->win, py->blackgc, posx+hitx*GEST_SPACE-1,
  1902. X            posy+hity*GEST_SPACE-1, GEST_SIZE+1, GEST_SIZE+1);
  1903. X    XDrawRectangle(py->dpy, py->win, py->blackgc, posx+hitx*GEST_SPACE-2,
  1904. X            posy+hity*GEST_SPACE-2, GEST_SIZE+3, GEST_SIZE+3);
  1905. X    }
  1906. X}
  1907. X
  1908. Xint gesture_release(py, xpos, ypos, button)
  1909. Xstruct player *py;
  1910. Xint xpos, ypos; /* relative to column pos */
  1911. Xint button;
  1912. X{
  1913. X    int posx, posy;
  1914. X    int pnum = py-players;
  1915. X
  1916. X    xpos -= COLUMN_X;
  1917. X    ypos -= COLUMN_Y;
  1918. X
  1919. X    backing_restore(py);
  1920. X    if (py->gesture_sel != (-1))
  1921. X    py->gesture_chosen[py->gesture_hand] = py->gesture_sel;
  1922. X
  1923. X    posx = COLUMN_X + pnum*(2*GEST_SIZE + 20);
  1924. X    posy = COLUMN_Y;
  1925. X    XCopyPlane(py->dpy, py->gesturebm[0][py->gesture_chosen[0]], py->win,
  1926. X        py->blackgc, 0, 0, GEST_SIZE, GEST_SIZE, posx,
  1927. X        posy+(GEST_SPACE)*(COLUMN_SIZE-1), 1);
  1928. X    XCopyPlane(py->dpy, py->gesturebm[1][py->gesture_chosen[1]], py->win,
  1929. X        py->blackgc, 0, 0, GEST_SIZE, GEST_SIZE, posx+GEST_SPACE,
  1930. X        posy+(GEST_SPACE)*(COLUMN_SIZE-1), 1);
  1931. X}
  1932. END_OF_FILE
  1933. if test 11180 -ne `wc -c <'xgest.c'`; then
  1934.     echo shar: \"'xgest.c'\" unpacked with wrong size!
  1935. fi
  1936. # end of 'xgest.c'
  1937. fi
  1938. if test -f 'xtalk.c' -a "${1}" != "-c" ; then 
  1939.   echo shar: Will not clobber existing file \"'xtalk.c'\"
  1940. else
  1941. echo shar: Extracting \"'xtalk.c'\" \(3542 characters\)
  1942. sed "s/^X//" >'xtalk.c' <<'END_OF_FILE'
  1943. X#include <stdio.h>
  1944. X#include <string.h>
  1945. X#include <ctype.h>
  1946. X#include <X11/Xlib.h>
  1947. X#include <X11/Xutil.h>
  1948. X#include "handwave.h"
  1949. X#include "spelllist.h"
  1950. X#include "xspell.h"
  1951. X
  1952. X#define TALK_X (348)
  1953. X#define TALK_Y (576)
  1954. X#define TALK_W (448)
  1955. X#define TALK_LEADING (8)
  1956. X
  1957. Xstatic char bigbuf[2048], bigbuf2[2048];
  1958. X
  1959. Xvoid init_talk(py)
  1960. Xstruct player *py;
  1961. X{
  1962. X    py->talk_size = 128;
  1963. X    py->talk_buf = (char *)malloc(sizeof(char) * py->talk_size);
  1964. X    strcpy(py->talk_buf, "");
  1965. X    py->talk_pt = 0;
  1966. X    py->talk_xlast = (-1);
  1967. X    py->talk_x = 0;
  1968. X    py->talk_toobig = 0;
  1969. X}
  1970. X
  1971. Xvoid redraw_talk_only(py, recomp)
  1972. Xstruct player *py;
  1973. Xint recomp;
  1974. X{
  1975. X    static XCharStruct overall;
  1976. X    int direction, ascent, descent;
  1977. X    int width;
  1978. X
  1979. X    static XPoint caret[3] = {
  1980. X    {0, 0}, {2, -3}, {2, 3} 
  1981. X    };
  1982. X
  1983. X    if (recomp) {
  1984. X    XTextExtents(py->font, py->talk_buf, py->talk_pt, &direction, &ascent,
  1985. X            &descent, &overall);
  1986. X    py->talk_x = overall.width;
  1987. X    }
  1988. X
  1989. X    if (py->talk_x != py->talk_xlast) {
  1990. X    caret[0].x = TALK_X+py->talk_xlast - 2;
  1991. X    caret[0].y = TALK_Y+py->lineheight + 4;
  1992. X    XDrawLines(py->dpy, py->win, py->whitegc, caret, 3, CoordModePrevious);
  1993. X    py->talk_xlast = py->talk_x;
  1994. X    }
  1995. X
  1996. X    width = DrawStringField(py, py->talk_buf, TALK_X, TALK_Y+py->lineheight, TALK_W);
  1997. X
  1998. X    caret[0].x = TALK_X+py->talk_x - 2;
  1999. X    caret[0].y = TALK_Y+py->lineheight + 4;
  2000. X    XDrawLines(py->dpy, py->win, py->blackgc, caret, 3, CoordModePrevious);
  2001. X
  2002. X    py->talk_toobig = (width >= (TALK_W-py->lineheight));
  2003. X}
  2004. X
  2005. Xvoid redraw_talk(py)
  2006. Xstruct player *py;
  2007. X{
  2008. X    XDrawRectangle(py->dpy, py->win, py->blackgc, TALK_X-3, TALK_Y-2, TALK_W+6,
  2009. X        py->lineheight+TALK_LEADING+4);
  2010. X
  2011. X    redraw_talk_only(py, 0);
  2012. X}
  2013. X
  2014. Xstatic void ensure_talk_size(py, size)
  2015. Xstruct player *py;
  2016. Xint size;
  2017. X{
  2018. X    if (size < py->talk_size)
  2019. X    return;
  2020. X
  2021. X    while (size < py->talk_size)
  2022. X    py->talk_size *= 2;
  2023. X
  2024. X    py->talk_buf = (char *)realloc(py->talk_buf, sizeof(char) * py->talk_size);
  2025. X}
  2026. X
  2027. Xvoid talk_handle_char(py, ch)
  2028. Xstruct player *py;
  2029. Xchar ch;
  2030. X{
  2031. X    char *cp;
  2032. X    int ix;
  2033. X    int pnum;
  2034. X
  2035. X    if (isprint(ch)) {
  2036. X    if (!py->talk_toobig) {
  2037. X        ensure_talk_size(py, strlen(py->talk_buf)+1);
  2038. X        for (cp = &(py->talk_buf[py->talk_pt]); *cp; cp++);
  2039. X        for (; cp >= &(py->talk_buf[py->talk_pt]); cp--)
  2040. X        *(cp+1) = *cp;
  2041. X        py->talk_buf[py->talk_pt] = ch;
  2042. X        py->talk_pt++;
  2043. X        redraw_talk_only(py, 1);
  2044. X    }
  2045. X    }
  2046. X    else
  2047. X    switch (ch) {
  2048. X        case '\n':
  2049. X        case '\r':
  2050. X        case '\023':
  2051. X        if (py->talk_pt) {
  2052. X            pnum = py-players;
  2053. X            sprintf(bigbuf, "You say \"%s\"\n", py->talk_buf);
  2054. X            sprintf(bigbuf2, "%s says \"%s\"\n", NameOfBeing(gameval,
  2055. X                QuVal_Target_Wizard, pnum), py->talk_buf);
  2056. X            for (ix=0; ix<numplayers; ix++)
  2057. X            if (ix==pnum)
  2058. X                dump_text(ix, bigbuf);
  2059. X            else
  2060. X                dump_text(ix, bigbuf2);
  2061. X            LogInTranscript(gameval, bigbuf2);
  2062. X        }
  2063. X        py->talk_pt = 0;
  2064. X        py->talk_buf[0] = '\0';
  2065. X        redraw_talk_only(py, 1);
  2066. X        break;
  2067. X        case '\177':
  2068. X        if (py->talk_pt) {
  2069. X            py->talk_pt--;
  2070. X            for (cp = &(py->talk_buf[py->talk_pt]); *cp; cp++)
  2071. X            *cp = *(cp+1);
  2072. X            redraw_talk_only(py, 1);
  2073. X        }
  2074. X        break;
  2075. X        case '\013':
  2076. X        py->talk_buf[py->talk_pt] = '\0';
  2077. X        redraw_talk_only(py, 1);
  2078. X        break;
  2079. X        case '\002':
  2080. X        if (py->talk_pt) {
  2081. X            py->talk_pt--;
  2082. X            redraw_talk_only(py, 1);
  2083. X        }
  2084. X        break;
  2085. X        case '\006':
  2086. X        if (py->talk_buf[py->talk_pt]) {
  2087. X            py->talk_pt++;
  2088. X            redraw_talk_only(py, 1);
  2089. X        }
  2090. X        break;
  2091. X        case '\001':
  2092. X        py->talk_pt = 0;
  2093. X        redraw_talk_only(py, 1);
  2094. X        break;
  2095. X        case '\005':
  2096. X        while (py->talk_buf[py->talk_pt])
  2097. X            py->talk_pt++;
  2098. X        redraw_talk_only(py, 1);
  2099. X        break;
  2100. X    }
  2101. X}
  2102. END_OF_FILE
  2103. if test 3542 -ne `wc -c <'xtalk.c'`; then
  2104.     echo shar: \"'xtalk.c'\" unpacked with wrong size!
  2105. fi
  2106. # end of 'xtalk.c'
  2107. fi
  2108. echo shar: End of archive 6 \(of 7\).
  2109. cp /dev/null ark6isdone
  2110. MISSING=""
  2111. for I in 1 2 3 4 5 6 7 ; do
  2112.     if test ! -f ark${I}isdone ; then
  2113.     MISSING="${MISSING} ${I}"
  2114.     fi
  2115. done
  2116. if test "${MISSING}" = "" ; then
  2117.     echo You have unpacked all 7 archives.
  2118.     rm -f ark[1-9]isdone
  2119. else
  2120.     echo You still need to unpack the following archives:
  2121.     echo "        " ${MISSING}
  2122. fi
  2123. ##  End of shell archive.
  2124. exit 0
  2125.