home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / vmsnet / maxewr2 / part02 < prev    next >
Internet Message Format  |  1993-07-13  |  97KB

  1. Path: uunet!elroy.jpl.nasa.gov!ames!koriel!lll-winken.llnl.gov!fnnews.fnal.gov!fnnews!SNYDER
  2. From: SNYDER@d0sb10.fnal.gov
  3. Newsgroups: vmsnet.sources.games
  4. Subject: Mazewar for VMS (2/5) (repost)
  5. Date: 14 Jul 1993 06:02:45 GMT
  6. Organization: SUNY Stony Brook High Energy Physics
  7. Lines: 2903
  8. Message-ID: <SNYDER.93Jul14000245@d0sb10.fnal.gov>
  9. NNTP-Posting-Host: d0sb10.fnal.gov
  10. Xref: uunet vmsnet.sources.games:753
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
  13. X`20*`20be`20either`20a`20character`20string`20name,`20or`20an`20address`20in
  14. V`20the`20form`20a.b.c.d`20where
  15. X`20*`20the`20pieces`20are`20octal,`20decimal,`20or`20hex`20numbers.`20`20Retur
  16. Vns`20a`20pointer`20to`20a
  17. X`20*`20sockaddr_in`20struct`20(note`20this`20structure`20is`20statically`20all
  18. Vocated`20and`20must
  19. X`20*`20be`20copied),`20or`20NULL`20if`20the`20name`20is`20unknown.
  20. X`20*/
  21. X
  22. XSockaddr`20*
  23. XresolveHost(name)
  24. Xregister`20char`20*name;
  25. X`7B
  26. X`09register`20struct`20hostent`20*fhost;
  27. X`09struct`20in_addr`20fadd;
  28. X`09static`20Sockaddr`20sa;
  29. X
  30. X`09if`20((fhost`20=`20gethostbyname(name))`20!=`20NULL)`20`7B
  31. X`09`09sa.sin_family`20=`20fhost->h_addrtype;
  32. X`09`09sa.sin_port`20=`200;
  33. X`09`09bcopy(fhost->h_addr,`20`26sa.sin_addr,`20fhost->h_length);
  34. X`09`7D`20else`20`7B
  35. X`09`09fadd.s_addr`20=`20inet_addr(name);
  36. X`09`09if`20(fadd.s_addr`20!=`20-1)`20`7B
  37. X`09`09`09sa.sin_family`20=`20AF_INET;`09/*`20grot`20*/
  38. X`09`09`09sa.sin_port`20=`200;
  39. X`09`09`09sa.sin_addr.s_addr`20=`20fadd.s_addr;
  40. X`09`09`7D`20else
  41. X`09`09`09return(NULL);
  42. X`09`7D
  43. X`09return(`26sa);
  44. X`7D
  45. $ call unpack [.MAZEWAR]INIT.C;11 473945742 ""
  46. $!
  47. $ create 'f'
  48. X.TH`20MAZEFIND`206
  49. X.SH`20NAME
  50. Xmazefind`20`5C-`20discover`20current`20MazeWar`20games
  51. X.SH`20SYNTAX
  52. X.B`20/usr/games/mazefind
  53. X.SH`20DESCRIPTION
  54. X.I`20Mazefind
  55. Xbroadcasts`20a`20query`20on`20the`20net`20to`20discover`20what`20MazeWar`20gam
  56. Ves`20are`20being
  57. Xplayed,`20and`20prints`20out`20useful`20information`20about`20them.
  58. XIt's`20useful`20for`20discovering`20what`20games`20might`20be`20interesting
  59. V`20to`20connect`20to
  60. Xon`20a`20distant`20network.
  61. X.SH`20"SEE`20ALSO"
  62. Xmazewar(6)
  63. $ call unpack [.MAZEWAR]MAZEFIND.6;1 136260481 ""
  64. $!
  65. $ create 'f'
  66. X/*`20$Header:`20mazefind.c,v`201.5`2088/09/07`2011:23:42`20kent`20Exp`20$`20*/
  67. V
  68. X
  69. X/*`20
  70. X`20*`20mazefind.c`20-`20find`20ongoing`20mazewar`20games
  71. X`20*`20
  72. X`20*`20Author:`09Christopher`20A.`20Kent
  73. X`20*`20`09`09Western`20Research`20Laboratory
  74. X`20*`20`09`09Digital`20Equipment`20Corporation
  75. X`20*`20Date:`09Thu`20Dec`20`204`201986
  76. X`20*/
  77. X
  78. X/***********************************************************
  79. XCopyright`201986`20by`20Digital`20Equipment`20Corporation,`20Maynard,`20Massac
  80. Vhusetts,
  81. X
  82. X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20All
  83. V`20Rights`20Reserved
  84. X
  85. XPermission`20to`20use,`20copy,`20modify,`20and`20distribute`20this`20software
  86. V`20and`20its`20
  87. Xdocumentation`20for`20any`20purpose`20and`20without`20fee`20is`20hereby`20gran
  88. Vted,`20
  89. Xprovided`20that`20the`20above`20copyright`20notice`20appear`20in`20all`20copie
  90. Vs`20and`20that
  91. Xboth`20that`20copyright`20notice`20and`20this`20permission`20notice`20appear
  92. V`20in`20
  93. Xsupporting`20documentation,`20and`20that`20the`20names`20of`20Digital`20not
  94. V`20be
  95. Xused`20in`20advertising`20or`20publicity`20pertaining`20to`20disstribution`20o
  96. Vf`20the
  97. Xsoftware`20without`20specific,`20written`20prior`20permission.`20`20
  98. X
  99. XDIGITAL`20DISCLAIMS`20ALL`20WARRANTIES`20WITH`20REGARD`20TO`20THIS`20SOFTWARE,
  100. V`20INCLUDING
  101. XALL`20IMPLIED`20WARRANTIES`20OF`20MERCHANTABILITY`20AND`20FITNESS,`20IN`20NO
  102. V`20EVENT`20SHALL
  103. XDIGITAL`20BE`20LIABLE`20FOR`20ANY`20SPECIAL,`20INDIRECT`20OR`20CONSEQUENTIAL
  104. V`20DAMAGES`20OR
  105. XANY`20DAMAGES`20WHATSOEVER`20RESULTING`20FROM`20LOSS`20OF`20USE,`20DATA`20OR
  106. V`20PROFITS,
  107. XWHETHER`20IN`20AN`20ACTION`20OF`20CONTRACT,`20NEGLIGENCE`20OR`20OTHER`20TORTIO
  108. VUS`20ACTION,
  109. XARISING`20OUT`20OF`20OR`20IN`20CONNECTION`20WITH`20THE`20USE`20OR`20PERFORMANC
  110. VE`20OF`20THIS
  111. XSOFTWARE.
  112. X
  113. X******************************************************************/
  114. X
  115. X/*
  116. X`20*`20vms`20port`207/93`20`20scott`20snyder`20<snyder@fnald0.fnal.gov>
  117. X`20*`20$Log:`09mazefind.c,v`20$
  118. X`20*`20Revision`201.5`20`2088/09/07`20`2011:23:42`20`20kent
  119. X`20*`20
  120. X`20*`20
  121. X`20*`20Revision`201.4`20`2088/08/25`20`2009:57:53`20`20kent
  122. X`20*`20
  123. X`20*`20
  124. X`20*`20Revision`201.3`20`2088/06/15`20`2016:36:20`20`20kent
  125. X`20*`20
  126. X`20*`20
  127. X`20*`20Revision`201.2`20`2087/03/31`20`2014:42:26`20`20kent
  128. X`20*`20Portability`20considerations,`20especially`20byteswapping`20to/from`20t
  129. Vhe`20net.
  130. X`20*`20
  131. X`20*`20Revision`201.1`20`2086/12/04`20`2017:19:31`20`20kent
  132. X`20*`20Initial`20revision
  133. X`20*`20
  134. X`20*/
  135. X
  136. Xstatic`20char`20rcs_ident`5B`5D`20=`20"$Header:`20mazefind.c,v`201.5`2088/09/0
  137. V7`2011:23:42`20kent`20Exp`20$";
  138. X
  139. X#include`20<sys/types.h>
  140. X#include`20<sys/socket.h>
  141. X#include`20<sys/time.h>
  142. X
  143. X#include`20<netinet/in.h>
  144. X
  145. X#include`20<errno.h>
  146. X#include`20<netdb.h>
  147. X#include`20<stdio.h>
  148. X#ifdef`20VMS
  149. X#include`20<string.h>
  150. X#else
  151. X#include`20<strings.h>
  152. X#endif
  153. X
  154. X#include`20"mazewar.h"
  155. X
  156. Xstruct`20answer`20`7B
  157. X`09Sockaddr`09source;
  158. X`09int`09`09srclen;
  159. X`09RatPacket`09packet;
  160. X`7D;
  161. X
  162. XBoolean`09FoundOne`20=`20FALSE;
  163. X
  164. X/*`20
  165. X`20*`20Broadcast`20to`20check`20out`20all`20the`20games`20on`20the`20net.`20Th
  166. Vis`20is`20basically
  167. X`20*`20findDuke()`20from`20init.c.
  168. X`20*/
  169. X
  170. Xmain()
  171. X`7B
  172. X`09register`20int`09i;
  173. X`09int`09`09cnt`20=`200;
  174. X`09Sockaddr`09rmtAddr;
  175. X`09struct`09timeval`09timeout;
  176. X`09RatPacket`09*b`20=`20(RatPacket`20*)`20malloc(sizeof(RatPacket));
  177. X`09struct`20answer`09answer;
  178. X`09int`09`09fd;
  179. X`09fd_set`20`20`20`20`20`20`20`20`20`20fds;
  180. X`09int`09`09ret,`20cc;
  181. X`09int`09`09mazePort;
  182. X`09struct`20servent`09*mazeService;
  183. X`09char`09`09buf`5B128`5D;
  184. X`09Boolean`09`09duke(),`20freeSlot();
  185. X`09u_long`09`09inet_makeaddr();
  186. X`09Sockaddr`09*resolveHost();
  187. X
  188. X`09fd`20=`20socket(AF_INET,`20SOCK_DGRAM,`200);
  189. X`09if`20(fd`20<`200)
  190. X`09`09MFError("can't`20get`20socket");
  191. X#ifdef`09SO_BROADCAST
  192. X#ifdef`09BSD_43
  193. X`09`7B
  194. X`09int`09one`20=`201;
  195. X
  196. X`09if`20(setsockopt(fd,`20SOL_SOCKET,`20SO_BROADCAST,`20`26one,`20sizeof`20one
  197. V)`20<`200)
  198. X`09`09MFError("can't`20get`20broadcast`20permission");
  199. X`09`7D
  200. X#else`09BSD_43
  201. X`09if`20(setsockopt(fd,`20SOL_SOCKET,`20SO_BROADCAST,`20NULL,`200)`20<`200)
  202. X`09`09MFError("can't`20get`20broadcast`20permission");
  203. X#endif`09BSD_43
  204. X#endif`09SO_BROADCAST
  205. X
  206. X`09mazeService`20=`20getservbyname(MAZESERVICE,`20"udp");
  207. X`09if`20(mazeService`20!=`20(struct`20servent`20*)`20NULL)
  208. X`09`09mazePort`20=`20mazeService->s_port;
  209. X`09else
  210. X`09`09mazePort`20=`20htons(MAZEPORT);
  211. X
  212. X`09gethostname(buf,`20sizeof(buf));
  213. X`09bcopy((char`20*)resolveHost(buf),`20(char`20*)`20`26rmtAddr,`20sizeof(rmtAd
  214. Vdr));
  215. X`09rmtAddr.sin_addr.s_addr`20=`20inet_makeaddr(inet_netof(rmtAddr.sin_addr),
  216. X`09`09`09`09`09BROAD_ADDR);`09/*`20from`20Makefile`20*/
  217. X`09rmtAddr.sin_port`20=`20mazePort;
  218. X
  219. X`09setupSurvey(b);
  220. X`09ConvertOutgoing(b);
  221. X`09if`20(sendto(fd,`20(char`20*)`20b,`20sizeof(*b),`200,`20`26rmtAddr,`20sizeo
  222. Vf(rmtAddr))`20<`200)
  223. X`09`09MFError("survey");
  224. X
  225. X`09while`20(1)`20`7B
  226. X`09`20`20`20`20`20`20`20`20FD_ZERO`20(`26fds);
  227. X`09`09FD_SET`20(fd,`20`26fds);
  228. X`09`09timeout.tv_sec`20=`205;
  229. X`09`09timeout.tv_usec`20=`200;
  230. X`09`09ret`20=`20select(FD_SETSIZE,`20`26fds,`20NULL,`20NULL,`20`26timeout);
  231. X`09`09if`20(ret`20<`200)
  232. X`09`09`09MFError("select");
  233. X`09`09if`20(ret`20==`200)
  234. X`09`09`09break;
  235. X`09`09answer.srclen`20=`20sizeof(Sockaddr);
  236. X`09`09cc`20=`20recvfrom(fd,`20`26answer.packet,`20sizeof(RatPacket),
  237. X`09`09`090,`20`26answer.source,`20`26answer.srclen);
  238. X`09`09if`20(cc`20<`200)
  239. X`09`09`09MFError("recv");
  240. X`09`09ConvertIncoming(`26answer.packet);
  241. X`09`09if`20(answer.packet.type`20!=`20RAT_STATUS)
  242. X`09`09`09continue;
  243. X`09`09if`20(!duke(`26answer))`20`7B
  244. X`09`09`09RatStatus`09rs;
  245. X
  246. X`09`09`09rs`20=`20(RatStatus)`20`26answer.packet.body;
  247. X`09`09`09setupSurvey(b);
  248. X`09`09`09ConvertOutgoing(b);
  249. X`09`09`09if`20(rs->rats`5Brs->dukeRat`5D.addr.sin_port`20==`20mazePort)
  250. X`09`09`09`09continue;`09/*`20will`20answer`20himself`20*/
  251. X`09`09`09`09
  252. X`09`09`09if`20(sendto(fd,`20b,`20sizeof(*b),`200,
  253. X`09`09`09`09`20`20`20`26rs->rats`5Brs->dukeRat`5D.addr,
  254. X`09`09`09`09`20`20`20sizeof(rs->rats`5Brs->dukeRat`5D.addr))`20<`200)
  255. X`09`09`09`09MFError("resend");
  256. X`09`09`09continue;
  257. X`09`09`7D`20else
  258. X`09`09`09printAnswer(`26answer);
  259. X`09`7D
  260. X`09if`20(FoundOne`20==`20FALSE)
  261. X`09`09printf("No`20one's`20playing`20now`5Cn");
  262. X`09exit(0);
  263. X`7D
  264. X
  265. XMFError(s)
  266. Xchar`20*s;
  267. X`7B
  268. X`09fprintf(stderr,`20"mazefind:`20%s`5Cn",`20s);
  269. X`09perror("mazefind");
  270. X`09exit(-1);
  271. X`7D
  272. X
  273. X/*`20
  274. X`20*`20Fill`20in`20the`20RAT_SURVEY`20packet.
  275. X`20*/
  276. X
  277. XsetupSurvey(b)
  278. XRatPacket`20*b;
  279. X`7B
  280. X`09RatNew`09ratSurvey;
  281. X
  282. X`09b->type`20=`20RAT_SURVEY;
  283. X`09ratSurvey`20=`20(RatNew)`20`26b->body;
  284. X`09ratSurvey->pass`20=`20RAT_PASSWORD;
  285. X`7D
  286. X
  287. X/*`20
  288. X`20*`20Check`20if`20this`20guy's`20the`20duke`20of`20his`20game.
  289. X`20*/
  290. X
  291. XBoolean
  292. Xduke(a)
  293. Xstruct`20answer`09*a;
  294. X`7B
  295. X`09RatStatus`09test;
  296. X
  297. X`09test`20=`20(RatStatus)`20`26a->packet.body;
  298. X`09return`20!bcmp((char`20*)`20`26test->rats`5Btest->dukeRat`5D.addr.sin_addr,
  299. V
  300. X`09`09`09(char`20*)`20`26a->source.sin_addr,`20sizeof(struct`20in_addr));
  301. X`7D
  302. X
  303. X/*`20
  304. X`20*`20Decode`20an`20answer`20packet.
  305. X`20*/
  306. X
  307. XprintAnswer(a)
  308. Xstruct`20answer`09*a;
  309. X`7B
  310. X`09RatStatus`09status;
  311. X`09RatId`09`09ratId;
  312. X`09RatInfo`09`09rat;
  313. X`09struct`20hostent`09*host;
  314. X
  315. X`09status`20=`20(RatStatus)`20`26a->packet.body;
  316. X`09
  317. X`09if`20(FoundOne`20==`20FALSE)`20`7B
  318. X`09`09FoundOne`20=`20TRUE;
  319. X`09`09printf("Current`20game(s):`5Cn");
  320. X`09`09printf("`5Ct%-20s`5Ct%s`5Ct`5Cthost`5Cn",`20"Name",`20"score");
  321. X`09`7D`20else
  322. X`09`09printf("`5Cn");
  323. X`09for(ratId`20=`200;`20ratId`20<`20MAXRATS;`20ratId++)`20`7B
  324. X`09`09rat`20=`20(RatInfo)`20`26status->rats`5BratId`5D;
  325. X`09`09if`20(rat->playing`20==`20FALSE)
  326. X`09`09`09continue;
  327. X
  328. X`09`09if`20(ratId`20==`20status->dukeRat)
  329. X`09`09`09printf("duke");
  330. X`09`09printf("`5Ct");
  331. X
  332. X`09`09printf("%-20s`5Ct%d`5Ct`5Ct",`20rat->name,`20rat->score);
  333. X
  334. X`09`09host`20=`20gethostbyaddr(`26rat->addr.sin_addr,
  335. X`09`09`09`09sizeof(struct`20in_addr),`20AF_INET);
  336. X`09`09if`20(host`20!=`20NULL)
  337. X`09`09`09printf("%s`5Cn",`20host->h_name);
  338. X`09`09else
  339. X`09`09`09printf("%s`5Cn",`20inet_ntoa(rat->addr.sin_addr));
  340. X`09`7D
  341. X`7D
  342. X
  343. X/*
  344. X`20*`20Resolve`20the`20specified`20host`20name`20into`20an`20internet`20addres
  345. Vs.`20`20The`20"name"`20may
  346. X`20*`20be`20either`20a`20character`20string`20name,`20or`20an`20address`20in
  347. V`20the`20form`20a.b.c.d`20where
  348. X`20*`20the`20pieces`20are`20octal,`20decimal,`20or`20hex`20numbers.`20`20Retur
  349. Vns`20a`20pointer`20to`20a
  350. X`20*`20sockaddr_in`20struct`20(note`20this`20structure`20is`20statically`20all
  351. Vocated`20and`20must
  352. X`20*`20be`20copied),`20or`20NULL`20if`20the`20name`20is`20unknown.
  353. X`20*/
  354. X
  355. XSockaddr`20*
  356. XresolveHost(name)
  357. Xregister`20char`20*name;
  358. X`7B
  359. X`09register`20struct`20hostent`20*fhost;
  360. X`09struct`20in_addr`20fadd;
  361. X`09static`20Sockaddr`20sa;
  362. X
  363. X`09if`20((fhost`20=`20gethostbyname(name))`20!=`20NULL)`20`7B
  364. X`09`09sa.sin_family`20=`20fhost->h_addrtype;
  365. X`09`09sa.sin_port`20=`200;
  366. X`09`09bcopy(fhost->h_addr,`20`26sa.sin_addr,`20fhost->h_length);
  367. X`09`7D`20else`20`7B
  368. X`09`09fadd.s_addr`20=`20inet_addr(name);
  369. X`09`09if`20(fadd.s_addr`20!=`20-1)`20`7B
  370. X`09`09`09sa.sin_family`20=`20AF_INET;`09/*`20grot`20*/
  371. X`09`09`09sa.sin_port`20=`200;
  372. X`09`09`09sa.sin_addr.s_addr`20=`20fadd.s_addr;
  373. X`09`09`7D`20else
  374. X`09`09`09return(NULL);
  375. X`09`7D
  376. X`09return(`26sa);
  377. X`7D
  378. X
  379. X/*`20
  380. X`20*`20Convert`20the`20contents`20of`20a`20packet`20to`20network`20order`20bef
  381. Vore`20sending.
  382. X`20*/
  383. X
  384. XConvertOutgoing(p)
  385. XRatPacket`20*p;
  386. X`7B
  387. X`09char`09`09buf`5B64`5D;
  388. X`09RatId`09`09ratId;
  389. X`09RatLocation`09ratLoc;
  390. X`09RatKill`09`09ratKill;
  391. X`09RatDead`09`09ratDead;
  392. X`09RatStatus`09ratStatus;
  393. X`09RatNew`09`09ratNew;
  394. X`09RatGone`09`09ratGone;
  395. X`09RatQuery`09ratQuery;
  396. X`09RatAlive`09ratAlive;
  397. X`09RatMove`09`09ratMove;
  398. X
  399. X`09switch(p->type)`20`7B
  400. X`09case`20RAT_LOCATION:
  401. X`09`09ratLoc`20=`20(RatLocation)`20`26p->body;
  402. X`09`09ratLoc->ratId`20=`20htonl(ratLoc->ratId);
  403. X`09`09ratLoc->xLoc`20=`20`20htons(ratLoc->xLoc);
  404. X`09`09ratLoc->yLoc`20=`20`20htons(ratLoc->yLoc);
  405. X`09`09ratLoc->dir`20=`20`20`20htons(ratLoc->dir);
  406. X`09`09ratLoc->score`20=`20htonl(ratLoc->score);
  407. X`09`09break;
  408. X
  409. X`09case`20RAT_KILL:
  410. X`09`09ratKill`20=`20(RatKill)`20`26p->body;
  411. X`09`09ratKill->ratId`20=`20htonl(ratKill->ratId);
  412. X`09`09ratKill->xLoc`20`20=`20htons(ratKill->xLoc);
  413. X`09`09ratKill->yLoc`20`20=`20htons(ratKill->yLoc);
  414. X`09`09ratKill->dir`20`20`20=`20htons(ratKill->dir);
  415. X`09`09break;
  416. X
  417. X`09case`20RAT_DEAD:
  418. X`09`09ratDead`20=`20(RatDead)`20`26p->body;
  419. X`09`09ratDead->ratId`20=`20htonl(ratDead->ratId);
  420. X`09`09ratDead->killedBy`20=`20htonl(ratDead->killedBy);
  421. X`09`09break;
  422. X
  423. X`09case`20RAT_STATUS:
  424. X`09`09ratStatus`20=`20(RatStatus)`20`26p->body;
  425. X`09`09ratStatus->dukeRat`20=`20htonl(ratStatus->dukeRat);
  426. X`09`09for`20(ratId`20=`200;`20ratId`20<`20MAXRATS;`20ratId++)`20`7B
  427. X`09`09`09RatInfo`09ratInfo;
  428. X
  429. X`09`09`09ratInfo`20=`20`26ratStatus->rats`5BratId`5D;
  430. X`09`09`09ratInfo->playing`20=`20htons(ratInfo->playing);
  431. X`09`09`09ratInfo->xLoc`20=`20htons(ratInfo->xLoc);
  432. X`09`09`09ratInfo->yLoc`20=`20htons(ratInfo->yLoc);
  433. X`09`09`09ratInfo->dir`20=`20htons(ratInfo->dir);
  434. X`09`09`09ratInfo->score`20=`20htonl(ratInfo->score);
  435. X`09`09`09ratInfo->addr.sin_family`20=
  436. X`09`09`09`09ntohs(ratInfo->addr.sin_family);
  437. X`09`09`09/*`20don't`20touch`20address`20or`20name`20*/
  438. X`09`09`7D
  439. X`09`09break;
  440. X
  441. X`09case`20RAT_NEW:
  442. X`09`09ratNew`20=`20(RatNew)`20`26p->body;
  443. X`09`09ratNew->pass`20=`20htons(ratNew->pass);
  444. X`09`09ratNew->xLoc`20=`20htons(ratNew->xLoc);
  445. X`09`09ratNew->yLoc`20=`20htons(ratNew->yLoc);
  446. X`09`09ratNew->dir`20`20=`20htons(ratNew->dir);
  447. X`09`09ratNew->addr.sin_family`20=
  448. X`09`09`09htons(ratNew->addr.sin_family);
  449. X`09`09/*`20don't`20touch`20address`20or`20name`20*/
  450. X`09`09break;
  451. X
  452. X`09case`20RAT_GOING:
  453. X`09`09ratGone`20=`20(RatGone)`20`26p->body;
  454. X`09`09ratGone->ratId`20=`20htonl(ratGone->ratId);
  455. X`09`09break;
  456. X
  457. X`09case`20RAT_QUERY:
  458. X`09`09ratQuery`20=`20(RatQuery)`20`26p->body;
  459. X`09`09ratQuery->ratId`20=`20htonl(ratQuery->ratId);
  460. X`09`09break;
  461. X
  462. X`09case`20RAT_ALIVE:
  463. X`09`09ratAlive`20=`20(RatAlive)`20`26p->body;
  464. X`09`09ratAlive->ratId`20=`20htonl(ratAlive->ratId);
  465. X`09`09break;
  466. X
  467. X`09case`20RAT_SURVEY:
  468. X`09`09ratNew`20=`20(RatNew)`20`26p->body;
  469. X`09`09ratNew->pass`20=`20htons(ratNew->pass);
  470. X`09`09ratNew->xLoc`20=`20htons(ratNew->xLoc);
  471. X`09`09ratNew->yLoc`20=`20htons(ratNew->yLoc);
  472. X`09`09ratNew->dir`20`20=`20htons(ratNew->dir);
  473. X`09`09/*`20don't`20touch`20address`20or`20name`20*/
  474. X`09`09break;
  475. X
  476. X`09case`20RAT_MOVE:
  477. X`09`09ratMove`20=`20(RatMove)`20`26p->body;
  478. X`09`09ratMove->ratId`20=`20htonl(ratMove->ratId);
  479. X`09`09break;
  480. X
  481. X`09default:
  482. X`09`09sprintf(buf,`20"ConvertOutgoing`20bad`20type`20%d`20(%d)",
  483. X`09`09`09p->type,`20htons(p->type));
  484. X`09`09MFError(buf);
  485. X`09`7D
  486. X`09p->type`20=`20htonl(p->type);
  487. X`7D
  488. X
  489. X/*`20
  490. X`20*`20Convert`20the`20contents`20of`20a`20packet`20to`20host`20order`20after
  491. V`20ConvertIncoming.
  492. X`20*/
  493. X
  494. XConvertIncoming(p)
  495. XRatPacket`20*p;
  496. X`7B
  497. X`09char`09`09buf`5B64`5D;
  498. X`09RatId`09`09ratId;
  499. X`09RatLocation`09ratLoc;
  500. X`09RatKill`09`09ratKill;
  501. X`09RatDead`09`09ratDead;
  502. X`09RatStatus`09ratStatus;
  503. X`09RatNew`09`09ratNew;
  504. X`09RatGone`09`09ratGone;
  505. X`09RatQuery`09ratQuery;
  506. X`09RatAlive`09ratAlive;
  507. X`09RatMove`09`09ratMove;
  508. X
  509. X`09p->type`20=`20ntohl(p->type);
  510. X`09switch(p->type)`20`7B
  511. X`09case`20RAT_LOCATION:
  512. X`09`09ratLoc`20=`20(RatLocation)`20`26p->body;
  513. X`09`09ratLoc->ratId`20=`20ntohl(ratLoc->ratId);
  514. X`09`09ratLoc->xLoc`20=`20`20ntohs(ratLoc->xLoc);
  515. X`09`09ratLoc->yLoc`20=`20`20ntohs(ratLoc->yLoc);
  516. X`09`09ratLoc->dir`20=`20`20`20ntohs(ratLoc->dir);
  517. X`09`09ratLoc->score`20=`20ntohl(ratLoc->score);
  518. X`09`09break;
  519. X
  520. X`09case`20RAT_KILL:
  521. X`09`09ratKill`20=`20(RatKill)`20`26p->body;
  522. X`09`09ratKill->ratId`20=`20ntohl(ratKill->ratId);
  523. X`09`09ratKill->xLoc`20`20=`20ntohs(ratKill->xLoc);
  524. X`09`09ratKill->yLoc`20`20=`20ntohs(ratKill->yLoc);
  525. X`09`09ratKill->dir`20`20`20=`20ntohs(ratKill->dir);
  526. X`09`09break;
  527. X
  528. X`09case`20RAT_DEAD:
  529. X`09`09ratDead`20=`20(RatDead)`20`26p->body;
  530. X`09`09ratDead->ratId`20=`20ntohl(ratDead->ratId);
  531. X`09`09ratDead->killedBy`20=`20ntohl(ratDead->killedBy);
  532. X`09`09break;
  533. X
  534. X`09case`20RAT_STATUS:
  535. X`09`09ratStatus`20=`20(RatStatus)`20`26p->body;
  536. X`09`09ratStatus->dukeRat`20=`20ntohl(ratStatus->dukeRat);
  537. X`09`09for`20(ratId`20=`200;`20ratId`20<`20MAXRATS;`20ratId++)`20`7B
  538. X`09`09`09RatInfo`09ratInfo;
  539. X
  540. X`09`09`09ratInfo`20=`20`26ratStatus->rats`5BratId`5D;
  541. X`09`09`09ratInfo->playing`20=`20ntohs(ratInfo->playing);
  542. X`09`09`09ratInfo->xLoc`20=`20ntohs(ratInfo->xLoc);
  543. X`09`09`09ratInfo->yLoc`20=`20ntohs(ratInfo->yLoc);
  544. X`09`09`09ratInfo->dir`20=`20ntohs(ratInfo->dir);
  545. X`09`09`09ratInfo->score`20=`20ntohl(ratInfo->score);
  546. X`09`09`09ratInfo->addr.sin_family`20=
  547. X`09`09`09`09ntohs(ratInfo->addr.sin_family);
  548. X`09`09`09/*`20don't`20touch`20address`20or`20name`20*/
  549. X`09`09`7D
  550. X`09`09break;
  551. X
  552. X`09case`20RAT_NEW:
  553. X`09`09ratNew`20=`20(RatNew)`20`26p->body;
  554. X`09`09ratNew->pass`20=`20ntohs(ratNew->pass);
  555. X`09`09ratNew->xLoc`20=`20ntohs(ratNew->xLoc);
  556. X`09`09ratNew->yLoc`20=`20ntohs(ratNew->yLoc);
  557. X`09`09ratNew->dir`20`20=`20ntohs(ratNew->dir);
  558. X`09`09ratNew->addr.sin_family`20=
  559. X`09`09`09ntohs(ratNew->addr.sin_family);
  560. X`09`09/*`20don't`20touch`20address`20or`20name`20*/
  561. X`09`09break;
  562. X
  563. X`09case`20RAT_GOING:
  564. X`09`09ratGone`20=`20(RatGone)`20`26p->body;
  565. X`09`09ratGone->ratId`20=`20ntohl(ratGone->ratId);
  566. X`09`09break;
  567. X
  568. X`09case`20RAT_QUERY:
  569. X`09`09ratQuery`20=`20(RatQuery)`20`26p->body;
  570. X`09`09ratQuery->ratId`20=`20ntohl(ratQuery->ratId);
  571. X`09`09break;
  572. X
  573. X`09case`20RAT_ALIVE:
  574. X`09`09ratAlive`20=`20(RatAlive)`20`26p->body;
  575. X`09`09ratAlive->ratId`20=`20ntohl(ratAlive->ratId);
  576. X`09`09break;
  577. X
  578. X`09case`20RAT_SURVEY:
  579. X`09`09ratNew`20=`20(RatNew)`20`26p->body;
  580. X`09`09ratNew->pass`20=`20ntohs(ratNew->pass);
  581. X`09`09ratNew->xLoc`20=`20ntohs(ratNew->xLoc);
  582. X`09`09ratNew->yLoc`20=`20ntohs(ratNew->yLoc);
  583. X`09`09ratNew->dir`20`20=`20ntohs(ratNew->dir);
  584. X`09`09/*`20don't`20touch`20address`20or`20name`20*/
  585. X`09`09break;
  586. X
  587. X`09case`20RAT_MOVE:
  588. X`09`09ratMove`20=`20(RatMove)`20`26p->body;
  589. X`09`09ratMove->ratId`20=`20ntohl(ratMove->ratId);
  590. X`09`09break;
  591. X
  592. X`09default:
  593. X`09`09sprintf(buf,`20"ConvertIncoming`20bad`20type`20%d`20(%d)",
  594. X`09`09`09p->type,`20ntohs(p->type));
  595. X`09`09MFError(buf);
  596. X`09`7D
  597. X`7D
  598. X
  599. $ call unpack [.MAZEWAR]MAZEFIND.C;5 1359695108 ""
  600. $!
  601. $ create 'f'
  602. X
  603. X
  604. X
  605. XMAZEFIND(6)`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20
  606. V`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20MAZEFIND(6)
  607. X
  608. X
  609. XN`08NA`08AM`08ME`08E
  610. X`20`20`20`20`20mazefind`20-`20discover`20current`20MazeWar`20games
  611. X
  612. XS`08SY`08YN`08NT`08TA`08AX`08X
  613. X`20`20`20`20`20/`08/u`08us`08sr`08r/`08/g`08ga`08am`08me`08es`08s/`08/m`08ma
  614. V`08az`08ze`08ef`08fi`08in`08nd`08d
  615. X
  616. XD`08DE`08ES`08SC`08CR`08RI`08IP`08PT`08TI`08IO`08ON`08N
  617. X`20`20`20`20`20_`08M_`08a_`08z_`08e_`08f_`08i_`08n_`08d`20`20broadcasts`20`20a
  618. V`20`20query`20`20on`20`20the`20net`20to`20discover`20what
  619. X`20`20`20`20`20MazeWar`20games`20are`20being`20played,`20and`20prints`20out
  620. V`20useful`20infor-
  621. X`20`20`20`20`20mation`20`20about`20`20them.`20`20It's`20useful`20for`20discove
  622. Vring`20what`20games
  623. X`20`20`20`20`20might`20be`20interesting`20to`20connect`20to`20on`20a`20distant
  624. V`20network.
  625. X
  626. XS`08SE`08EE`08E`20A`08AL`08LS`08SO`08O
  627. X`20`20`20`20`20mazewar(6)
  628. X
  629. X
  630. X
  631. X
  632. X
  633. X
  634. X
  635. X
  636. X
  637. X
  638. X
  639. X
  640. X
  641. X
  642. X
  643. X
  644. X
  645. X
  646. X
  647. X
  648. X
  649. X
  650. X
  651. X
  652. X
  653. X
  654. X
  655. X
  656. X
  657. X
  658. X
  659. X
  660. X
  661. X
  662. X
  663. X
  664. X
  665. X
  666. X
  667. X
  668. X
  669. X
  670. X
  671. X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20
  672. V`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20
  673. V`20`20`20`20`20`20`20`20`20`20`20`20`20`201
  674. X
  675. X
  676. $ call unpack [.MAZEWAR]MAZEFIND.DOC;1 1478691461 ""
  677. $!
  678. $ create 'f'
  679. X-+-+-+-+-+-+-+-+`20START`20OF`20PART`202`20-+-+-+-+-+-+-+-+
  680. XX
  681. XX`6020`6020`6020`60200x00e3,`60200x9fff,`60200xffff,`60200xff00,`60200x01ef,
  682. V`60200xcfff,`60200xffff
  683. XV,`60200xff80,
  684. XX`6020`6020`6020`60200x00e3,`60200x9fff,`60200xffff,`60200xff00,`60200x00e3,
  685. V`60200x9fff,`60200xffff
  686. XV,`60200xff00,
  687. XX`6020`6020`6020`60200x3c1f,`60200xfffc,`60200x3fff,`60200xfffc,`60200x0fff,
  688. V`60200xf00f,`60200xfff0
  689. XV,`60200x03c0,
  690. XX
  691. XX`6020`6020`6020`60200x01ef,`60200xcfff,`60200xffff,`60200xff80,`60200x01df,
  692. V`60200xffff,`60200xffff
  693. XV,`60200xfc80,
  694. XX`6020`6020`6020`60200x01ef,`60200xcfff,`60200xffff,`60200xff80,`60200x01e7,
  695. V`60200xcfff,`60200xffff
  696. XV,`60200xff80,
  697. XX`6020`6020`6020`60200x383f,`60200xfffc,`60200x3fff,`60200xfffc,`60200x07ff,
  698. V`60200xe007,`60200xffe0
  699. XV,`60200x0df0,
  700. XX
  701. XX`6020`6020`6020`60200x013f,`60200xffff,`60200xffff,`60200xff80,`60200x03ff,
  702. V`60200xffff,`60200xffff
  703. XV,`60200xc0c0,
  704. XX`6020`6020`6020`60200x01df,`60200xffff,`60200xffff,`60200xff80,`60200x01df,
  705. V`60200xffff,`60200xffff
  706. XV,`60200xff80,
  707. XX`6020`6020`6020`60200x187f,`60200xfff8,`60200x1fff,`60200xfff8,`60200x03ff,
  708. V`60200xc003,`60200xffc0
  709. XV,`60200x13f8,
  710. XX
  711. XX`6020`6020`6020`60200x0303,`60200xffff,`60200xffff,`60200xffc0,`60200x03ff,
  712. V`60200xffff,`60200xfffe
  713. XV,`60200x0040,
  714. XX`6020`6020`6020`60200x03ff,`60200xffff,`60200xffff,`60200xffc0,`60200x03ff,
  715. V`60200xffe0,`60200x07ff
  716. XV,`60200xffc0,
  717. XX`6020`6020`6020`60200x10ff,`60200xfff8,`60200x1fff,`60200xfff8,`60200x0b7e,
  718. V`60200x680b,`60200x7e68
  719. XV,`60200x2ffc,
  720. XX
  721. XX`6020`6020`6020`60200x0200,`60200x7fff,`60200xffff,`60200xffc0,`60200x03ff,
  722. V`60200xffff,`60200xfff8
  723. XV,`60200x0040,
  724. XX`6020`6020`6020`60200x03ff,`60200xffff,`60200xffff,`60200xffc0,`60200x03ff,
  725. V`60200xff00,`60200x00ff
  726. XV,`60200xffc0,
  727. XX`6020`6020`6020`60200x19ff,`60200xfff8,`60200x1fff,`60200xfff8,`60200x15f9,
  728. V`60200xd415,`60200xf9d4
  729. XV,`60200x3ff4,
  730. XX
  731. XX`6020`6020`6020`60200x0200,`60200x1fff,`60200xffff,`60200xffc0,`60200x07ff,
  732. V`60200xffff,`60200xffe0
  733. XV,`60200x0060,
  734. XX`6020`6020`6020`60200x03ff,`60200xffff,`60200xffff,`60200xffc0,`60200x03ff,
  735. V`60200xf800,`60200x001f
  736. XV,`60200xffc0,
  737. XX`6020`6020`6020`60200x0fff,`60200xfff0,`60200x0fff,`60200xfff0,`60200x0aae,
  738. V`60200xa80a,`60200xaea8
  739. XV,`60200x7fe2,
  740. XX
  741. XX`6020`6020`6020`60200x0600,`60200x07ff,`60200xffff,`60200xffe0,`60200x07ff,
  742. V`60200xffff,`60200xffc0
  743. XV,`60200x00e0,
  744. XX`6020`6020`6020`60200x07ff,`60200xffff,`60200xffff,`60200xffe0,`60200x07ff,
  745. V`60200xc000,`60200x0003
  746. XV,`60200xffe0,
  747. XX`6020`6020`6020`60200x0fff,`60200xfff0,`60200x0fff,`60200xfff0,`60200x0155,
  748. V`60200x4001,`60200x5540
  749. XV,`60200x7fc6,
  750. XX
  751. XX`6020`6020`6020`60200x0700,`60200xcfff,`60200xffff,`60200xffe0,`60200x07ff,
  752. V`60200xffff,`60200xff0a
  753. XV,`60200x00e0,
  754. XX`6020`6020`6020`60200x07ff,`60200xffff,`60200xffff,`60200xffe0,`60200x07ff,
  755. V`60200x0007,`60200xe000
  756. XV,`60200xffe0,
  757. XX`6020`6020`6020`60200x07ff,`60200xff60,`60200x07ff,`60200xff60,`60200x0000,
  758. V`60200x0000,`60200x0000
  759. XV,`60200x7fc6,
  760. XX
  761. XX`6020`6020`6020`60200x0700,`60200x30ff,`60200xffff,`60200xffe0,`60200x07ff,
  762. V`60200xffff,`60200xfe0c
  763. XV,`60200x00e0,
  764. XX`6020`6020`6020`60200x07ff,`60200xffff,`60200xffff,`60200xffe0,`60200x07fc,
  765. V`60200x000d,`60200xb800
  766. XV,`60200x3fe0,
  767. XX`6020`6020`6020`60200x03ff,`60200xfcc0,`60200x03ff,`60200xfcc0,`60200x0000,
  768. V`60200x0000,`60200x0000
  769. XV,`60200x7fe2,
  770. XX
  771. XX`6020`6020`6020`60200x0700,`60200x407f,`60200xffff,`60200xffe0,`60200x0fff,
  772. V`60200xffff,`60200xfc38
  773. XV,`60200x01f0,
  774. XX`6020`6020`6020`60200x07ff,`60200xffff,`60200xffff,`60200xffe0,`60200x07f0,
  775. V`60200x0005,`60200xbc00
  776. XV,`60200x0fe0,
  777. XX`6020`6020`6020`60200x07ff,`60200xff68,`60200x07ff,`60200xff68,`60200x003c,
  778. V`60200x0000,`60200x3c00
  779. XV,`60200x3ff4,
  780. XX
  781. XX`6020`6020`6020`60200x0f81,`60200x003f,`60200xffff,`60200xfff0,`60200x0fff,
  782. V`60200xffff,`60200xf875
  783. XV,`60200x81b0,
  784. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0fc0,
  785. V`60200x0003,`60200x7602
  786. XV,`60200x03f0,
  787. XX`6020`6020`6020`60200x15ff,`60200xf9d4,`60200x15ff,`60200xf9d4,`60200x009f,
  788. V`60200x0000,`60200x9f00
  789. XV,`60200x3ffc,
  790. XX
  791. XX`6020`6020`6020`60200x0d80,`60200x021f,`60200xffff,`60200xfff0,`60200x0fff,
  792. V`60200xffff,`60200xf382
  793. XV,`60200x41f0,
  794. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0fc1,
  795. V`60200x0043,`60200xce00
  796. XV,`60200x8df0,
  797. XX`6020`6020`6020`60200x2adf,`60200xe3aa,`60200x2adf,`60200xe3aa,`60200x037f,
  798. V`60200xc003,`60200x7fc0
  799. XV,`60200x1ff8,
  800. XX
  801. XX`6020`6020`6020`60200x0f80,`60200x01cf,`60200xffff,`60200xfff0,`60200x0fff,
  802. V`60200xffff,`60200xee00
  803. XV,`60200x0170,
  804. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0f2a,
  805. V`60200x00c3,`60200xef00
  806. XV,`60200x70f0,
  807. XX`6020`6020`6020`60200x157c,`60200x3f54,`60200x157c,`60200x3f54,`60200x04ff,
  808. V`60200xe004,`60200xffe0
  809. XV,`60200x1bdc,
  810. XX
  811. XX`6020`6020`6020`60200x0e80,`60200x6677,`60200xffff,`60200xfff0,`60200x0fff,
  812. V`60200xffff,`60200xfc00
  813. XV,`60200x0170,
  814. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0e6d,
  815. V`60200x0091,`60200xf900
  816. XV,`60200x8070,
  817. XX`6020`6020`6020`60200x0aaf,`60200xfaa8,`60200x0aaf,`60200xfaa8,`60200x0bff,
  818. V`60200xf00b,`60200xfff0
  819. XV,`60200x2e3a,
  820. XX
  821. XX`6020`6020`6020`60200x0e80,`60200x183f,`60200xffff,`60200xfff0,`60200x0fff,
  822. V`60200xffff,`60200xc000
  823. XV,`60200x0170,
  824. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0c10,
  825. V`60200x00f8,`60200xff00
  826. XV,`60200x03b0,
  827. XX`6020`6020`6020`60200x0155,`60200x5540,`60200x0155,`60200x5540,`60200x0fff,
  828. V`60200xd00f,`60200x81f0
  829. XV,`60200x17f4,
  830. XX
  831. XX`6020`6020`6020`60200x0e80,`60200x0003,`60200xffff,`60200xfff0,`60200x0fff,
  832. V`60200xffff,`60200xe000
  833. XV,`60200x01f0,
  834. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0c0c,
  835. V`60200x00ff,`60200xf700
  836. XV,`60200x25f0,
  837. XX`6020`6020`6020`60200x0000,`60200x0000,`60200x0000,`60200x0000,`60200x1fff,
  838. V`60200x881e,`60200x0078
  839. XV,`60200x0000,
  840. XX
  841. XX`6020`6020`6020`60200x0f80,`60200x0007,`60200xffff,`60200xfff0,`60200x0fff,
  842. V`60200xffff,`60200xf000
  843. XV,`60200x01f0,
  844. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0e02,
  845. V`60200x0097,`60200xf900
  846. XV,`60200x1c70,
  847. XX`6020`6020`6020`60200x0000,`60200x0000,`60200x0000,`60200x0000,`60200x1fff,
  848. V`60200x0818,`60200x1818
  849. XV,`60200x03c0,
  850. XX
  851. XX`6020`6020`6020`60200x0f80,`60200x000f,`60200xffff,`60200xfff0,`60200x0fff,
  852. V`60200xffff,`60200xf800
  853. XV,`60200x01f0,
  854. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0f01,
  855. V`60200x00fb,`60200xe700
  856. XV,`60200x00f0,
  857. XX`6020`6020`6020`60200x0007,`60200xe000,`60200x0007,`60200xe000,`60200x3ffe,
  858. V`60200x0c30,`60200x1c0c
  859. XV,`60200x0df0,
  860. XX
  861. XX`6020`6020`6020`60200x0f80,`60200x601f,`60200xffff,`60200xfff0,`60200x0fff,
  862. V`60200xffff,`60200xfc00
  863. XV,`60200x01b0,
  864. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0f80,
  865. V`60200x0075,`60200xde00
  866. XV,`60200x51f0,
  867. XX`6020`6020`6020`60200x003f,`60200xfc00,`60200x003f,`60200xfc00,`60200x3ffc,
  868. V`60200x1c20,`60200x4e04
  869. XV,`60200x13f8,
  870. XX
  871. XX`6020`6020`6020`60200x0d80,`60200x91ff,`60200xffff,`60200xfff0,`60200x07ff,
  872. V`60200xffff,`60200xfe00
  873. XV,`60200x01e0,
  874. XX`6020`6020`6020`60200x0fff,`60200xffff,`60200xffff,`60200xfff0,`60200x0fc0,
  875. V`60200x006f,`60200x1604
  876. XV,`60200x8bf0,
  877. XX`6020`6020`6020`60200x00f3,`60200xff00,`60200x00f3,`60200xff00,`60200x3ffc,
  878. V`60200x1c20,`60200x6e04
  879. XV,`60200x2ffc,
  880. XX
  881. XX`6020`6020`6020`60200x0780,`60200x0f7f,`60200xffff,`60200xffe0,`60200x07ff,
  882. V`60200xffff,`60200xff00
  883. XV,`60200x00e0,
  884. XX`6020`6020`6020`60200x07ff,`60200xffff,`60200xffff,`60200xffe0,`60200x07f0,
  885. V`60200x0039,`60200x7c03
  886. XV,`60200x07e0,
  887. XX`6020`6020`6020`60200x01c7,`60200xff80,`60200x01c7,`60200xff80,`60200x3ffe,
  888. V`60200x0c30,`60200x7e0c
  889. XV,`60200x3ffc,
  890. XX
  891. XX`6020`6020`6020`60200x0700,`60200x00ff,`60200xffff,`60200xffe0,`60200x07ff,
  892. V`60200xffff,`60200xffc0
  893. XV,`60200x00e0,
  894. XX`6020`6020`6020`60200x07ff,`60200xffff,`60200xffff,`60200xffe0,`60200x07fc,
  895. V`60200x001d,`60200xb810
  896. XV,`60200x1fe0,
  897. XX`6020`6020`6020`60200x031f,`60200xffc0,`60200x031f,`60200xffc0,`60200x1fff,
  898. V`60200x0818,`60200x3c18
  899. XV,`60200x7ffe,
  900. XX
  901. XX`6020`6020`6020`60200x0710,`60200x03ff,`60200xffff,`60200xffe0,`60200x07ff,
  902. V`60200xffff,`60200xffe0
  903. XV,`60200x00e0,
  904. XX`6020`6020`6020`60200x07ff,`60200xffff,`60200xffff,`60200xffe0,`60200x07ff,
  905. V`60200x0007,`60200xe208
  906. XV,`60200x7fe0,
  907. XX`6020`6020`6020`60200x067f,`60200xffe0,`60200x067f,`60200xffe0,`60200x1fff,
  908. V`60200x881e,`60200x1878
  909. XV,`60200x7ffe,
  910. XX
  911. XX`6020`6020`6020`60200x0708,`60200x07ff,`60200xffff,`60200xffe0,`60200x03ff,
  912. V`60200xffff,`60200xfff8
  913. XV,`60200x00c0,
  914. XX`6020`6020`6020`60200x07ff,`60200xffff,`60200xffff,`60200xffe0,`60200x07ff,
  915. V`60200xc000,`60200x0191
  916. XV,`60200xffe0,
  917. XX`6020`6020`6020`60200x0cff,`60200xfff0,`60200x0cff,`60200xfff0,`60200x0fff,
  918. V`60200xf00f,`60200x81f0
  919. XV,`60200x7ffe,
  920. XX
  921. XX`6020`6020`6020`60200x0228,`60200x1fff,`60200xffff,`60200xffc0,`60200x03ff,
  922. V`60200xffff,`60200xfffe
  923. XV,`60200x01c0,
  924. XX`6020`6020`6020`60200x03ff,`60200xffff,`60200xffff,`60200xffc0,`60200x03ff,
  925. V`60200xf800,`60200x0077
  926. XV,`60200xffc0,
  927. XX`6020`6020`6020`60200x0bff,`60200xfff0,`60200x0bff,`60200xfff0,`60200x0fff,
  928. V`60200xf00f,`60200xfff0
  929. XV,`60200x7ffe,
  930. XX
  931. XX`6020`6020`6020`60200x0214,`60200x7fff,`60200xffff,`60200xffc0,`60200x03ff,
  932. V`60200xffff,`60200xffff
  933. XV,`60200xc1c0,
  934. XX`6020`6020`6020`60200x03ff,`60200xffff,`60200xffff,`60200xffc0,`60200x03ff,
  935. V`60200xff00,`60200x001f
  936. XV,`60200xffc0,
  937. XX`6020`6020`6020`60200x1fff,`60200xff98,`60200x1ff0,`60200x0ff8,`60200x07ff,
  938. V`60200xe007,`60200xffe0
  939. XV,`60200x3ffc,
  940. XX
  941. XX`6020`6020`6020`60200x0203,`60200xffff,`60200xffff,`60200xffc0,`60200x01ff,
  942. V`60200xffff,`60200xffff
  943. XV,`60200xf980,
  944. XX`6020`6020`6020`60200x03ff,`60200xffff,`60200xffff,`60200xffc0,`60200x03ff,
  945. V`60200xff00,`60200x00ff
  946. XV,`60200xffc0,
  947. XX`6020`6020`6020`60200x1fff,`60200xff08,`60200x1f80,`60200x01f8,`60200x03ff,
  948. V`60200xc003,`60200xffc0
  949. XV,`60200x3ffc,
  950. XX
  951. XX`6020`6020`6020`60200x011f,`60200xffff,`60200xffff,`60200xff80,`60200x01ff,
  952. V`60200xffff,`60200xffff
  953. XV,`60200xff80,
  954. XX`6020`6020`6020`60200x01ff,`60200xffff,`60200xffff,`60200xff80,`60200x01ff,
  955. V`60200xffe0,`60200x07ff
  956. XV,`60200xff80,
  957. XX`6020`6020`6020`60200x1fff,`60200xfe18,`60200x1e03,`60200xc078,`60200x0b7e,
  958. V`60200x680b,`60200x7e68
  959. XV,`60200x1ff8,
  960. XX
  961. XX`6020`6020`6020`60200x01ff,`60200xffff,`60200xffff,`60200xff80,`60200x00ff,
  962. V`60200xffff,`60200xffff
  963. XV,`60200xdf00,
  964. XX`6020`6020`6020`60200x01ff,`60200xffff,`60200xffff,`60200xff80,`60200x01ff,
  965. V`60200xffff,`60200xffff
  966. XV,`60200xff80,
  967. XX`6020`6020`6020`60200x3fff,`60200xfc1c,`60200x3801,`60200xe01c,`60200x15f9,
  968. V`60200xd415,`60200xf9d4
  969. XV,`60200x1bd4,
  970. XX
  971. XX`6020`6020`6020`60200x00fb,`60200xffff,`60200xffff,`60200xff00,`60200x00ff,
  972. V`60200xffff,`60200xffff
  973. XV,`60200xff00,
  974. XX`6020`6020`6020`60200x00ff,`60200xffff,`60200xffff,`60200xdf00,`60200x00ff,
  975. V`60200xffff,`60200xffff
  976. XV,`60200xdf00,
  977. XX`6020`6020`6020`60200x3fff,`60200xf83c,`60200x3009,`60200xf00c,`60200x0aae,
  978. V`60200xa80a,`60200xaea8
  979. XV,`60200x2e2a,
  980. XX
  981. XX`6020`6020`6020`60200x00ff,`60200xffff,`60200xffff,`60200xff00,`60200x007f,
  982. V`60200xffff,`60200xffff
  983. XV,`60200xbe00,
  984. XX`6020`6020`6020`60200x00ff,`60200xffff,`60200xffff,`60200xff00,`60200x00ff,
  985. V`60200xffff,`60200xffff
  986. XV,`60200xff00,
  987. XX`6020`6020`6020`60200x3fff,`60200xf03c,`60200x200c,`60200xf004,`60200x0155,
  988. V`60200x4001,`60200x5540
  989. XV,`60200x17d4,
  990. XX
  991. XX`6020`6020`6020`60200x007f,`60200xffff,`60200xffff,`60200xbe00,`60200x003f,
  992. V`60200xffff,`60200xffff
  993. XV,`60200x7c00,
  994. XX`6020`6020`6020`60200x007f,`60200xffff,`60200xffff,`60200xbe00,`60200x007f,
  995. V`60200xffff,`60200xffff
  996. XV,`60200xbe00,
  997. XX`6020`6020`6020`60200x3fff,`60200xf03c,`60200x200f,`60200xf004,`60200x3e1f,
  998. V`60200x0f87,`60200xc000
  999. XV,`60200x0000,
  1000. XX
  1001. XX`6020`6020`6020`60200x003f,`60200xffff,`60200xffff,`60200x7c00,`60200x001f,
  1002. V`60200xffff,`60200xfff8
  1003. XV,`60200xf800,
  1004. XX`6020`6020`6020`60200x003f,`60200xffff,`60200xffff,`60200x7c00,`60200x003f,
  1005. V`60200xffff,`60200xffff
  1006. XV,`60200x7c00,
  1007. XX`6020`6020`6020`60200x3fff,`60200xf83c,`60200x300f,`60200xf00c,`60200x7f3f,
  1008. V`60200x9fcf,`60200xe000
  1009. XV,`60200x03c0,
  1010. XX
  1011. XX`6020`6020`6020`60200x001f,`60200xffff,`60200xfff8,`60200xf800,`60200x000f,
  1012. V`60200xffff,`60200xffe1
  1013. XV,`60200xf000,
  1014. XX`6020`6020`6020`60200x001f,`60200xffff,`60200xfff8,`60200xf800,`60200x001f,
  1015. V`60200xffff,`60200xfff8
  1016. XV,`60200xf800,
  1017. XX`6020`6020`6020`60200x3fff,`60200xfc1c,`60200x3807,`60200xe01c,`60200xffff,
  1018. V`60200xfffe,`60200xf000
  1019. XV,`60200x0df0,
  1020. XX
  1021. XX`6020`6020`6020`60200x000f,`60200xffff,`60200xffe1,`60200xf000,`60200x0003,
  1022. V`60200xffff,`60200xff07
  1023. XV,`60200xa000,
  1024. XX`6020`6020`6020`60200x000f,`60200xffff,`60200xffe1,`60200xf000,`60200x000f,
  1025. V`60200xffff,`60200xffe1
  1026. XV,`60200xf000,
  1027. XX`6020`6020`6020`60200x1fff,`60200xfe18,`60200x1e03,`60200xc078,`60200x3fff,
  1028. V`60200x3ff8,`60200x3000
  1029. XV,`60200x13f8,
  1030. XX
  1031. XX`6020`6020`6020`60200x0003,`60200xffff,`60200xff07,`60200xa000,`60200x0007,
  1032. V`60200xffff,`60200xf00e
  1033. XV,`60200x4000,
  1034. XX`6020`6020`6020`60200x0003,`60200xffff,`60200xff07,`60200xa000,`60200x0003,
  1035. V`60200xffff,`60200xff07
  1036. XV,`60200xa000,
  1037. XX`6020`6020`6020`60200x1fff,`60200xff08,`60200x1f80,`60200x01f8,`60200x8ffc,
  1038. V`60200x7ff1,`60200x1ad2
  1039. XV,`60200x2ffc,
  1040. XX
  1041. XX`6020`6020`6020`60200x0007,`60200xffff,`60200xf00e,`60200x4000,`60200x00ab,
  1042. V`60200xffff,`60200xfc7d
  1043. XV,`60200xff00,
  1044. XX`6020`6020`6020`60200x0007,`60200xffff,`60200xf00e,`60200x4000,`60200x0007,
  1045. V`60200xffff,`60200xf00e
  1046. XV,`60200x4000,
  1047. XX`6020`6020`6020`60200x1fff,`60200xff98,`60200x1ff0,`60200x0ff8,`60200x3fff,
  1048. V`60200x3ff8,`60200x3000
  1049. XV,`60200x381c,
  1050. XX
  1051. XX`6020`6020`6020`60200x00ab,`60200xffff,`60200xfc7d,`60200xff00,`60200x0155,
  1052. V`60200xffff,`60200xffe3
  1053. XV,`60200xd540,
  1054. XX`6020`6020`6020`60200x00ab,`60200xffff,`60200xfc7d,`60200xff00,`60200x00ab,
  1055. V`60200xffff,`60200xfc7d
  1056. XV,`60200xff00,
  1057. XX`6020`6020`6020`60200x0fff,`60200xfff0,`60200x0fff,`60200xfff0,`60200xffff,
  1058. V`60200xfffe,`60200xf000
  1059. XV,`60200x6186,
  1060. XX
  1061. XX`6020`6020`6020`60200x0155,`60200xffff,`60200xffe3,`60200xd540,`60200x02aa,
  1062. V`60200xff7f,`60200xffcf
  1063. XV,`60200xaaa0,
  1064. XX`6020`6020`6020`60200x0155,`60200xffff,`60200xffe3,`60200xd540,`60200x0155,
  1065. V`60200xffff,`60200xffe3
  1066. XV,`60200xd540,
  1067. XX`6020`6020`6020`60200x0fff,`60200xfff0,`60200x0fff,`60200xfff0,`60200x7f3f,
  1068. V`60200x9fcf,`60200xe000
  1069. XV,`60200x42c2,
  1070. XX
  1071. XX`6020`6020`6020`60200x02aa,`60200xff7f,`60200xffcf,`60200xaaa0,`60200x0555,
  1072. V`60200x5f3f,`60200xfc7f
  1073. XV,`60200x5550,
  1074. XX`6020`6020`6020`60200x02aa,`60200xff7f,`60200xffcf,`60200xaaa0,`60200x02aa,
  1075. V`60200xff7f,`60200xffcf
  1076. XV,`60200xaaa0,
  1077. XX`6020`6020`6020`60200x07ff,`60200xff60,`60200x07ff,`60200xff60,`60200x3e1f,
  1078. V`60200x0f87,`60200xc000
  1079. XV,`60200x43c2,
  1080. XX
  1081. XX`6020`6020`6020`60200x0555,`60200x5f3f,`60200xfc7f,`60200x5550,`60200x0aaa,
  1082. V`60200xaff3,`60200xcffe
  1083. XV,`60200xaaa0,
  1084. XX`6020`6020`6020`60200x0555,`60200x5f3f,`60200xfc7f,`60200x5550,`60200x0555,
  1085. V`60200x5f3f,`60200xfc7f
  1086. XV,`60200x5550,
  1087. XX`6020`6020`6020`60200x03ff,`60200xfcc0,`60200x03ff,`60200xfcc0,`60200x30c3,
  1088. V`60200x0c49,`60200x2000
  1089. XV,`60200x6186,
  1090. XX
  1091. XX`6020`6020`6020`60200x0aaa,`60200xaff3,`60200xcffe,`60200xaaa0,`60200x0555,
  1092. V`60200x57f8,`60200x1ff5
  1093. XV,`60200x5540,
  1094. XX`6020`6020`6020`60200x0aaa,`60200xaff3,`60200xcffe,`60200xaaa0,`60200x0aaa,
  1095. V`60200xaff3,`60200xcffe
  1096. XV,`60200xaaa0,
  1097. XX`6020`6020`6020`60200x07ff,`60200xff68,`60200x07ff,`60200xff68,`60200x79e7,
  1098. V`60200x9e33,`60200xd000
  1099. XV,`60200x381c,
  1100. XX
  1101. XX`6020`6020`6020`60200x0555,`60200x57f8,`60200x1ff5,`60200x5540,`60200x02aa,
  1102. V`60200xaaff,`60200xffaa
  1103. XV,`60200xaa80,
  1104. XX`6020`6020`6020`60200x0555,`60200x57f8,`60200x1ff5,`60200x5540,`60200x0555,
  1105. V`60200x57f8,`60200x1ff5
  1106. XV,`60200x5540,
  1107. XX`6020`6020`6020`60200x15ff,`60200xf9d4,`60200x15ff,`60200xf9d4,`60200x3fcf,
  1108. V`60200xf349,`60200x2000
  1109. XV,`60200x3ffc,
  1110. XX
  1111. XX`6020`6020`6020`60200x02aa,`60200xaaff,`60200xffaa,`60200xaa80,`60200x0055,
  1112. V`60200x555f,`60200xf555
  1113. XV,`60200x5500,
  1114. XX`6020`6020`6020`60200x02aa,`60200xaaff,`60200xffaa,`60200xaa80,`60200x02aa,
  1115. V`60200xaaff,`60200xffaa
  1116. XV,`60200xaa80,
  1117. XX`6020`6020`6020`60200x2adf,`60200xe3aa,`60200x2adf,`60200xe3aa,`60200x3fcf,
  1118. V`60200xf366,`60200x6600
  1119. XV,`60200x1ff8,
  1120. XX
  1121. XX`6020`6020`6020`60200x0055,`60200x555f,`60200xf555,`60200x5500,`60200x000a,
  1122. V`60200xaaaa,`60200xaaaa
  1123. XV,`60200xa000,
  1124. XX`6020`6020`6020`60200x0055,`60200x555f,`60200xf555,`60200x5500,`60200x0055,
  1125. V`60200x555f,`60200xf555
  1126. XV,`60200x5500,
  1127. XX`6020`6020`6020`60200x157c,`60200x3f54,`60200x157c,`60200x3f54,`60200x79e7,
  1128. V`60200x9e3c,`60200xf900
  1129. XV,`60200x13d4,
  1130. XX
  1131. XX`6020`6020`6020`60200x000a,`60200xaaaa,`60200xaaaa,`60200xa000,`60200x0000,
  1132. V`60200x0555,`60200x5550
  1133. XV,`60200x0000,
  1134. XX`6020`6020`6020`60200x000a,`60200xaaaa,`60200xaaaa,`60200xa000,`60200x000a,
  1135. V`60200xaaaa,`60200xaaaa
  1136. XV,`60200xa000,
  1137. XX`6020`6020`6020`60200x0aaf,`60200xfaa8,`60200x0aaf,`60200xfaa8,`60200x30c3,
  1138. V`60200x0c3c,`60200xf900
  1139. XV,`60200x2a2a,
  1140. XX
  1141. XX`6020`6020`6020`60200x0000,`60200x0555,`60200x5550,`60200x0000,`60200x0000,
  1142. V`60200x0000,`60200x0000
  1143. XV,`60200x0000,
  1144. XX`6020`6020`6020`60200x0000,`60200x0555,`60200x5550,`60200x0000,`60200x0000,
  1145. V`60200x0555,`60200x5550
  1146. XV,`60200x0000,
  1147. XX`6020`6020`6020`60200x0155,`60200x5540,`60200x0155,`60200x5540,`60200x0000,
  1148. V`60200x0066,`60200x6600
  1149. XV,`60200x1554
  1150. XX`607D;
  1151. XX
  1152. XXstatic`6020RelativeTokens`6009relativeTokens`6020=`6020`607B
  1153. XX`6009`607B`6020REAR,`6009FRONT,`6020RIGHT,`6020LEFT`6020`607D,`6009/*`6020me
  1154. V`6020north,`6020him`6020`605Bn
  1155. XV,`6020s,`6020e,`6020w`605D`6020*/
  1156. XX`6009`607B`6020FRONT,`6020REAR,`6020LEFT,`6020RIGHT`6020`607D,`6009/*`6020me
  1157. V`6020south,`6020him`6020`605Bn
  1158. XV,`6020s,`6020e,`6020w`605D`6020*/
  1159. XX`6009`607B`6020LEFT,`6020RIGHT,`6020REAR,`6020FRONT`6020`607D,`6009/*`6020me
  1160. V`6020east`6020...`6020*/
  1161. XX`6009`607B`6020RIGHT,`6020LEFT,`6020FRONT,`6020REAR`6020`607D`6009/*`6020me
  1162. V`6020west`6020...`6020*/
  1163. XX`607D;
  1164. XX
  1165. XX/*`6020
  1166. XX`6020*`6020Initialize`6020the`6020display`6020manager.
  1167. XX`6020*/
  1168. XX
  1169. XXInitDisplay(argc,`6020argv)
  1170. XXchar`6020**argv;
  1171. XX`607B
  1172. XX`6009register`6020int`6009i;
  1173. XX`6009register`6020RatState`6009*rsp;
  1174. XX
  1175. XX`6009for`6020(i`6020=`60200;`6020i`6020<`6020MAXRATS;`6020i++)`6020`607B
  1176. XX`6009`6009rsp`6020=`6020`6026clearArray`605Bi`605D;
  1177. XX`6009`6009rsp->playing`6020=`6020FALSE;
  1178. XX`6009`6009rsp->x`6020=`60201;
  1179. XX`6009`6009rsp->y`6020=`60201;
  1180. XX`6009`6009rsp->dir`6020=`6020NORTH;
  1181. XX`6009`607D
  1182. XX
  1183. XX`6009InitWindow(argc,`6020argv);
  1184. XX`607D
  1185. XX
  1186. XX/*
  1187. XX`6020*`6020all`6020in`6020the`6020name`6020of`6020portability...`6020actually
  1188. V`6020put`6020the`6020di
  1189. XVsplay`6020on
  1190. XX`6020*`6020the`6020screen.`6020Some`6020window`6020systems`6020need`6020to
  1191. V`6020do`6020initializati
  1192. XVon`6020before
  1193. XX`6020*`6020the`6020net`6020is`6020started,`6020but`6020don't`6020want`6020to
  1194. V`6020display`6020until
  1195. XV`6020after.
  1196. XX`6020*/
  1197. XX
  1198. XXStartDisplay()
  1199. XX`607B
  1200. XX`6009StartWindow(ratBits,`6020ratBits_width,`6020ratBits_height);
  1201. XX`607D
  1202. XX
  1203. XX/*`6020
  1204. XX`6020*`6020Manage`6020the`6020top`6020portion`6020of`6020the`6020screen,`6020
  1205. Vthe`6020perspective
  1206. XV`6020view`6020of`6020the
  1207. XX`6020*`6020maze,`6020with`6020the`6020eyeballs.`6020What`6020is`6020seen`6020
  1208. Vis`6020controlled`6020b
  1209. XVy`6020the`6020position
  1210. XX`6020*`6020in`6020the`6020maze`6020and`6020what`6020players`6020are`6020visib
  1211. Vle.`6020This`6020latter
  1212. XV`6020is`6020recorded
  1213. XX`6020*`6020in`6020the`6020R2d2`6020array`6020(the`6020significance`6020of`602
  1214. V0the`6020name`6020is
  1215. XV`6020lost`6020to
  1216. XX`6020*`6020history),`6020which`6020is`6020recomputed`6020every`6020time`6020s
  1217. Vomeone`6020moves.
  1218. XX`6020*
  1219. XX`6020*`6020The`6020perspective`6020view`6020is`6020calculated`6020on`6020the
  1220. V`6020fly`6020from`6020th
  1221. XVe`6020viewTable`6020array.
  1222. XX`6020*`6020viewTable`6020contains`6020a`6020set`6020of`602012`6020line`6020se
  1223. Vgments`6020for`602030
  1224. XV`6020views.`6020The`6020longest
  1225. XX`6020*`6020corridor`6020is`602030`6020spaces,`6020and`6020for`6020each`6020ce
  1226. Vll`6020in`6020the`6020maz
  1227. XVe,`6020there`6020are`602012
  1228. XX`6020*`6020distinct`6020lines`6020(wall`6020edges)`6020that`6020could`6020be
  1229. V`6020visible`6020(neve
  1230. XVr`6020all`6020at`6020once).
  1231. XX`6020*
  1232. XX`6020*`6020Each`6020time,`6020march`6020down`6020the`6020hall`6020in`6020the
  1233. V`6020direction`6020faced
  1234. XV`6020and`6020figure
  1235. XX`6020*`6020out`6020which`6020lines`6020to`6020actually`6020draw.`6020Then`602
  1236. V0look`6020in`6020R2d2
  1237. XV`6020and`6020draw`6020in`6020opponents.
  1238. XX`6020*/
  1239. XX
  1240. XX#define`6009NDIR`6009NDIRECTION
  1241. XXstatic`6020Boolean`6009prevEdge3,`6020prevEdge7;`6009/*`6020plotter`6020smart
  1242. Vs`6020*/
  1243. XXstatic`6020Boolean`6009edge1,`6020edge2,`6020edge3,`6020edge4,`6020edge5,`602
  1244. V0edge6,`6020edge7
  1245. XV;
  1246. XXstatic`6020XYpair`6009edge3Lines`605B2`605D,`6020edge7Lines`605B2`605D;
  1247. XXstatic`6020XY`6009l1Delta`605BNDIR`605D`6020=`6020`607B`6020`607B0,`6020-1
  1248. V`607D,`6020`607B0,`60201`607D,`6020
  1249. XV`607B1,`60200`607D,`6020`607B-1,`60200`607D`6020`607D;
  1250. XXstatic`6020XY`6009l2Delta`605BNDIR`605D`6020=`6020`607B`6020`607B1,`6020-1
  1251. V`607D,`6020`607B-1,`60201`607D,
  1252. XV`6020`607B1,`60201`607D,`6020`607B-1,`6020-1`607D`6020`607D;
  1253. XXstatic`6020XY`6009c2Delta`605BNDIR`605D`6020=`6020`607B`6020`607B1,`60200`607
  1254. VD,`6020`607B-1,`60200`607D,`6020
  1255. XV`607B0,`60201`607D,`6020`607B0,`6020-1`607D`6020`607D;
  1256. XXstatic`6020XY`6009r1Delta`605BNDIR`605D`6020=`6020`607B`6020`607B0,`60201`607
  1257. VD,`6020`607B0,`6020-1`607D,`6020
  1258. XV`607B-1,`60200`607D,`6020`607B1,`60200`607D`6020`607D;
  1259. XXstatic`6020XY`6009r2Delta`605BNDIR`605D`6020=`6020`607B`6020`607B1,`60201`607
  1260. VD,`6020`607B-1,`6020-1`607D,
  1261. XV`6020`607B-1,`60201`607D,`6020`607B1,`6020-1`607D`6020`607D;
  1262. XX#undef`6009NDIR
  1263. XX
  1264. XXShowView(x,`6020y,`6020dir)
  1265. XXint`6009`6009x,`6020y;
  1266. XXDirection`6009dir;
  1267. XX`607B
  1268. XX`6009register`6020XYpair`6009`6009*tp`6020=`6020viewTable;
  1269. XX`6009register`6020int`6009`6009tx`6020=`6020x;
  1270. XX`6009register`6020int`6009`6009ty`6020=`6020y;
  1271. XX`6009RatId`6009`6009`6009ratId;
  1272. XX`6009RatLook`6009`6009`6009ratLook;
  1273. XX`6009Boolean`6009`6009`6009oldVisible;
  1274. XX`6009XYpair`6009`6009`6009*hidden(),`6020*plotLine();
  1275. XX
  1276. XX`6009ClearView();
  1277. XX`6009prevEdge3`6020=`6020prevEdge7`6020=`6020FALSE;
  1278. XX`6009while`6020(!M.maze`605Btx`605D.y`605Bty`605D)`6020`607B
  1279. XX`6009`6009tp`6020=`6020hidden(tx,`6020ty,`6020dir,`6020tp);`6009/*`6020draw
  1280. V`6020a`6020cell`6020*/
  1281. XX`6009`6009switch`6020(dir)`6020`607B
  1282. XX`6009`6009case`6020NORTH:`6009tx++;`6020break;
  1283. XX`6009`6009case`6020SOUTH:`6009tx--;`6020break;
  1284. XX`6009`6009case`6020EAST:`6009ty++;`6020break;
  1285. XX`6009`6009case`6020WEST:`6009ty--;`6020break;
  1286. XX`6009`6009`607D
  1287. XX`6009`607D
  1288. XX`6009if`6020(prevEdge3)
  1289. XX`6009`6009(void)`6020plotLine(edge3Lines,`6020TRUE);
  1290. XX`6009if`6020(prevEdge7)
  1291. XX`6009`6009(void)`6020plotLine(edge7Lines,`6020TRUE);
  1292. XX
  1293. XX`6009/*`6020show`6020the`6020tokens`6020*/
  1294. XX
  1295. XX`6009for`6020(ratId`6020=`60200;`6020ratId`6020<`6020MAXRATS;`6020ratId++)
  1296. V`6020`607B
  1297. XX`6009`6009if`6020(ratId`6020==`6020M.myRatId)
  1298. XX`6009`6009`6009continue;
  1299. XX`6009`6009ratLook`6020=`6020`6026R2d2`605BratId`605D;
  1300. XX`6009`6009oldVisible`6020=`6020ratLook->visible;
  1301. XX`6009`6009TokenVisible(ratId);
  1302. XX`6009`6009if`6020(ratLook->visible`6020==`6020TRUE)
  1303. XX`6009`6009`6009XORToken(ratId);
  1304. XX`6009`6009if`6020(ratLook->visible`6020!=`6020oldVisible)
  1305. XX`6009`6009`6009UpdateScoreCard(ratId);
  1306. XX`6009`607D
  1307. XX`607D
  1308. XX
  1309. XXXYpair`6009*
  1310. XXplotLine(p,`6020two)
  1311. XXXYpair`6009*p;
  1312. XXBoolean`6009two;
  1313. XX`607B
  1314. XX`6009while`6020(1)`6020`607B
  1315. XX`6009`6009DrawViewLine(p->p1.x,`6020p->p1.y,`6020p->p2.x,`6020p->p2.y);
  1316. XX`6009`6009p++;
  1317. XX`6009`6009if`6020(!two)
  1318. XX`6009`6009`6009return`6020p;
  1319. XX`6009`6009two`6020=`6020FALSE;
  1320. XX`6009`607D
  1321. XX`607D
  1322. XX
  1323. XXXYpair`6020*
  1324. XXhidden(x,`6020y,`6020dir,`6020p)
  1325. XXint`6009`6009x,`6020y;
  1326. XXDirection`6009dir;
  1327. XXXYpair`6009`6009*p;
  1328. XX`607B
  1329. XX`6009int`6009l1x,`6020l1y,`6020l2x,`6020l2y;
  1330. XX`6009int`6009r1x,`6020r1y,`6020r2x,`6020r2y;
  1331. XX`6009int`6009c2x,`6020c2y;
  1332. XX
  1333. XX`6009/*`6020first`6020calculate`6020the`6020coordinates`6020of`6020the`6020ne
  1334. Vighboring`6020cubes
  1335. XV`6020*/
  1336. XX
  1337. XX`6009l1x`6020=`6020x`6020+`6020l1Delta`605Bdir`605D.xcor;`6009/*`6020find`602
  1338. V0left`6020cube`6020*/
  1339. XX`6009l1y`6020=`6020y`6020+`6020l1Delta`605Bdir`605D.ycor;
  1340. XX`6009l2x`6020=`6020x`6020+`6020l2Delta`605Bdir`605D.xcor;`6009/*`6020find`602
  1341. V0left`6020forward`6020cub
  1342. XVe`6020*/
  1343. XX`6009l2y`6020=`6020y`6020+`6020l2Delta`605Bdir`605D.ycor;
  1344. XX`6009r1x`6020=`6020x`6020+`6020r1Delta`605Bdir`605D.xcor;`6009/*`6020find`602
  1345. V0right`6020cube`6020*/
  1346. XX`6009r1y`6020=`6020y`6020+`6020r1Delta`605Bdir`605D.ycor;
  1347. XX`6009r2x`6020=`6020x`6020+`6020r2Delta`605Bdir`605D.xcor;`6009/*`6020find`602
  1348. V0right`6020forward`6020cu
  1349. XVbe`6020*/
  1350. XX`6009r2y`6020=`6020y`6020+`6020r2Delta`605Bdir`605D.ycor;
  1351. XX`6009c2x`6020=`6020x`6020+`6020c2Delta`605Bdir`605D.xcor;`6009/*`6020find`602
  1352. V0forward`6020cube`6020*/
  1353. XX`6009c2y`6020=`6020y`6020+`6020c2Delta`605Bdir`605D.ycor;
  1354. XX
  1355. XX`6009/*`6020next`6020calculate`6020which`6020of`6020the`60207`6020possible
  1356. V`6020cube`6020edges`6020ar
  1357. XVe`6020visible`6020*/
  1358. XX
  1359. XX`6009edge2`6020=`6020M.maze`605Bc2x`605D.y`605Bc2y`605D;`6009/*`6020c2`6020*/
  1360. V
  1361. XX`6009edge3`6020=`6020M.maze`605Bl1x`605D.y`605Bl1y`605D;`6009/*`6020l1`6020*/
  1362. V
  1363. XX`6009edge4`6020=`6020!edge3;`6009`6009`6009/*`6020!l1`6020*/
  1364. XX
  1365. XX`6009edge7`6020=`6020M.maze`605Br1x`605D.y`605Br1y`605D;`6009/*`6020r1`6020*/
  1366. V
  1367. XX`6009edge6`6020=`6020!edge7;`6009`6009`6009/*`6020!r1`6020*/
  1368. XX
  1369. XX`6009edge1`6020=`6020edge3`6020`6026`6026`6020(edge2`6020`607C`607C`6020!M.ma
  1370. Vze`605Bl2x`605D.y`605Bl2y`605D)
  1371. XV
  1372. XX`6009`6009`607C`607C`6020((!edge2)`6020`6026`6026`6020edge4);
  1373. XX`6009edge5`6020=`6020edge7`6020`6026`6026`6020(edge2`6020`607C`607C`6020!M.ma
  1374. Vze`605Br2x`605D.y`605Br2y`605D)
  1375. XV
  1376. XX`6009`6009`607C`607C`6020((!edge2)`6020`6026`6026`6020edge6);
  1377. XX
  1378. XX`6009/*`6020
  1379. XX`6009`6020*`6020Should`6020be`6020matching`6020the`6020following:
  1380. XX`6009`6020*`6009x1`6020=`6020l1`6020(c2`6020+`6020!l2)`6020+`6020!c2`6020!l1
  1381. XX`6009`6020*`6009x2`6020=`6020c2
  1382. XX`6009`6020*`6009x3`6020=`6020l1
  1383. XX`6009`6020*`6009x4`6020=`6020!l1
  1384. XX`6009`6020*`6009x5`6020=`6020r1`6020(c2`6020+`6020!r2)`6020+`6020!c2`6020!r1
  1385. XX`6009`6020*`6009x6`6020=`6020!r1
  1386. XX`6009`6020*`6009x7`6020=`6020r1
  1387. XX`6009`6020*/
  1388. XX
  1389. XX`6009if`6020(edge1)
  1390. XX`6009`6009p`6020=`6020plotLine(p,`6020FALSE);
  1391. XX`6009else
  1392. XX`6009`6009p++;
  1393. XX`6009if`6020(edge2)
  1394. XX`6009`6009p`6020=`6020plotLine(p,`6020TRUE);
  1395. XX`6009else
  1396. XX`6009`6009p`6020+=`60202;
  1397. XX`6009if`6020(edge3)`6020`607B
  1398. XX`6009`6009if`6020(prevEdge3)`6020`607B
  1399. XX`6009`6009`6009edge3Lines`605B0`605D.p2`6020=`6020(p++)->p2;
  1400. XX`6009`6009`6009edge3Lines`605B1`605D.p2`6020=`6020p->p2;
  1401. XX`6009`6009`607D`6020else`6020`607B
  1402. XX`6009`6009`6009edge3Lines`605B0`605D`6020=`6020*p++;
  1403. XX`6009`6009`6009edge3Lines`605B1`605D`6020=`6020*p;
  1404. XX`6009`6009`6009prevEdge3`6020=`6020TRUE;
  1405. XX`6009`6009`607D
  1406. XX`6009`6009p++;
  1407. XX`6009`607D`6020else`6020`607B
  1408. XX`6009`6009if`6020(prevEdge3)`6020`607B
  1409. XX`6009`6009`6009(void)`6020plotLine(edge3Lines,`6020TRUE);
  1410. XX`6009`6009`6009prevEdge3`6020=`6020FALSE;
  1411. XX`6009`6009`607D
  1412. XX`6009`6009p`6020+=`60202;
  1413. XX`6009`607D
  1414. XX`6009if`6020(edge4)
  1415. XX`6009`6009p`6020=`6020plotLine(p,`6020TRUE);
  1416. XX`6009else
  1417. XX`6009`6009p`6020+=`60202;
  1418. XX`6009if`6020(edge5)
  1419. XX`6009`6009p`6020=`6020plotLine(p,`6020FALSE);
  1420. XX`6009else
  1421. XX`6009`6009p++;
  1422. XX`6009if`6020(edge6)
  1423. XX`6009`6009p`6020=`6020plotLine(p,`6020TRUE);
  1424. XX`6009else
  1425. XX`6009`6009p`6020+=`60202;
  1426. XX`6009if`6020(edge7)`6020`607B
  1427. XX`6009`6009if`6020(prevEdge7)`6020`607B
  1428. XX`6009`6009`6009edge7Lines`605B0`605D.p1`6020=`6020(p++)->p1;
  1429. XX`6009`6009`6009edge7Lines`605B1`605D.p1`6020=`6020p->p1;
  1430. XX`6009`6009`607D`6020else`6020`607B
  1431. XX`6009`6009`6009edge7Lines`605B0`605D`6020=`6020*p++;
  1432. XX`6009`6009`6009edge7Lines`605B1`605D`6020=`6020*p;
  1433. XX`6009`6009`6009prevEdge7`6020=`6020TRUE;
  1434. XX`6009`6009`607D
  1435. XX`6009`6009p++;
  1436. XX`6009`607D`6020else`6020`607B
  1437. XX`6009`6009if`6020(prevEdge7)`6020`607B
  1438. XX`6009`6009`6009(void)`6020plotLine(edge7Lines,`6020TRUE);
  1439. XX`6009`6009`6009prevEdge7`6020=`6020FALSE;
  1440. XX`6009`6009`607D
  1441. XX`6009`6009p`6020+=`60202;
  1442. XX`6009`607D
  1443. XX`6009return`6020p;
  1444. XX`607D
  1445. XX
  1446. XX/*
  1447. XX`6020*`6020sets`6020R2d2`605BhisRatId`605D`6020variables
  1448. XX`6020*`6020uses`6020M.ratcb`605BhisRatId`605D`6020as`6020input`6020for`6020hi
  1449. Vs`6020position`6020and
  1450. XV`6020direction
  1451. XX`6020*/
  1452. XX
  1453. XXTokenVisible(hisRatId)
  1454. XXRatId`6009hisRatId;
  1455. XX`607B
  1456. XX`6009RatLook`6009`6009ratLook`6020=`6020`6026R2d2`605BhisRatId`605D;
  1457. XX`6009RatInfo`6009`6009ratInfo`6020=`6020`6026M.ratcb.rats`605BhisRatId`605D;
  1458. XX`6009Loc`6009`6009tx,`6020ty;
  1459. XX`6009Direction`6009td;
  1460. XX`6009int`6009`6009ix,`6020ix12;
  1461. XX
  1462. XX`6009ratLook->visible`6020=`6020FALSE;
  1463. XX`6009if`6020(!ratInfo->playing)
  1464. XX`6009`6009return;
  1465. XX`6009if`6020(M.peeking)`6020`607B
  1466. XX`6009`6009tx`6020=`6020M.xPeek;
  1467. XX`6009`6009ty`6020=`6020M.yPeek;
  1468. XX`6009`6009td`6020=`6020M.dirPeek;
  1469. XX`6009`607D`6020else`6020`607B
  1470. XX`6009`6009tx`6020=`6020M.xloc;
  1471. XX`6009`6009ty`6020=`6020M.yloc;
  1472. XX`6009`6009td`6020=`6020M.dir;
  1473. XX`6009`607D
  1474. XX`6009ix`6020=`60200;
  1475. XX`6009while`6020(!M.maze`605Btx`605D.y`605Bty`605D)`6020`607B
  1476. XX`6009`6009switch(td)`6020`607B
  1477. XX`6009`6009case`6020NORTH:`6009tx++;`6020break;
  1478. XX`6009`6009case`6020SOUTH:`6009tx--;`6020break;
  1479. XX`6009`6009case`6020EAST:`6009ty++;`6020break;
  1480. XX`6009`6009case`6020WEST:`6009ty--;`6020break;
  1481. XX`6009`6009`607D
  1482. XX`6009`6009ix++;
  1483. XX`6009`6009if`6020((tx`6020==`6020ratInfo->xLoc)`6020`6026`6026`6020(ty`6020==
  1484. V`6020ratInfo->yLoc))
  1485. XV`6020`607B
  1486. XX`6009`6009`6009ratLook->visible`6020=`6020TRUE;
  1487. XX`6009`6009`6009ix12`6020=`6020ix`6020*`602012;
  1488. XX`6009`6009`6009ratLook->x`6020=`6020(viewTable`605Bix12+3`605D.p2.x`6020+
  1489. XX`6009`6009`6009`6009`6020`6020`6020`6020`6020viewTable`605Bix12+10`605D.p1.x)
  1490. V/2;
  1491. XX`6009`6009`6009ratLook->y`6020=`6020(viewTable`605Bix12+3`605D.p1.y`6020+
  1492. XX`6009`6009`6009`6009`6020`6020`6020`6020`6020viewTable`605Bix12+3`605D.p2.y)/
  1493. V2;
  1494. XX`6009`6009`6009ratLook->tokenId`6020=`6020relativeTokens`605Btd`605D.t`605Bra
  1495. VtInfo->dir`605D;
  1496. XX`6009`6009`6009ratLook->distance`6020=`6020ix;
  1497. XX`6009`6009`6009break;
  1498. XX`6009`6009`607D
  1499. XX`6009`607D
  1500. XX`607D
  1501. XX
  1502. XX/*`6020
  1503. XX`6020*`6020draw`6020him`6020into`6020the`6020maze,`6020with`6020the`6020right
  1504. V`6020size`6020for`6020his
  1505. XV`6020distance`6020away
  1506. XX`6020*`6020and`6020facing`6020the`6020right`6020way.
  1507. XX`6020*/
  1508. XX
  1509. XXXORToken(hisRatId)
  1510. XXRatId`6009hisRatId;
  1511. XX`607B
  1512. XX`6009int`6009size;
  1513. XX`6009int`6009srcX,`6020srcY;
  1514. XX
  1515. XX`6009getRat(hisRatId,`6020`6026srcX,`6020`6026srcY,`6020`6026size);
  1516. XX`6009DisplayRatBitmap(R2d2`605BhisRatId`605D.x`6020-`6020size/2,
  1517. XX`6009`6009`6009R2d2`605BhisRatId`605D.y`6020`6020-`6020size/2,
  1518. XX`6009`6009`6009size,`6020size,`6020srcX,`6020srcY);
  1519. XX`607D
  1520. XX
  1521. XX/*`6020
  1522. XX`6020*`6020Dig`6020the`6020appropriate`6020bitmap`6020out`6020of`6020the`6020
  1523. Vmaster`6020bitmap,
  1524. XV`6020which`6020has`6020all
  1525. XX`6020*`6020possible`6020views`6020neatly`6020packed`6020into`6020place.
  1526. XX`6020*/
  1527. XX
  1528. XXgetRat(hisRatId,`6020x,`6020y,`6020size)
  1529. XXRatId`6009hisRatId;
  1530. XXint`6009*x,`6020*y,`6020*size;
  1531. XX`607B
  1532. XX`6009int`6009viewT`6020=`6020LEFT;
  1533. XX`6009int`6009view`6020=`6020R2d2`605BhisRatId`605D.tokenId;
  1534. XX
  1535. XX`6009switch`6020(R2d2`605BhisRatId`605D.distance)`6020`607B
  1536. XX`6009`6009case`60201:
  1537. XX`6009`6009`6009*size`6020=`602064;
  1538. XX`6009`6009`6009*x`6020=`60200;
  1539. XX`6009`6009`6009*y`6020=`60200;
  1540. XX`6009`6009`6009for`6020(viewT`6020=`60200;`6020viewT`6020!=`6020view;`6020*x
  1541. V`6020+=`602064)
  1542. XX`6009`6009`6009`6009viewT++;
  1543. XX`6009`6009`6009return;
  1544. XX
  1545. XX`6009`6009case`60202:
  1546. XX`6009`6009`6009*size`6020=`602032;
  1547. XX`6009`6009`6009for`6020(*x`6020=`60204*64;`6020*x`6020!=`602064*5;`6020*x`602
  1548. V0+=`602032)
  1549. XX`6009`6009`6009`6009for`6020(*y`6020=`60200;`6020*y`6020!=`602064;`6020*y`602
  1550. V0+=`602032)
  1551. XX`6009`6009`6009`6009`6009if`6020(viewT`6020==`6020view)
  1552. XX`6009`6009`6009`6009`6009`6009return;
  1553. XX`6009`6009`6009`6009`6009else
  1554. XX`6009`6009`6009`6009`6009`6009viewT++;
  1555. XX
  1556. XX`6009`6009case`60203:
  1557. XX`6009`6009`6009*size`6020=`602024;
  1558. XX`6009`6009`6009for`6020(*x`6020=`60205*64;`6020*x`6020!=`602064*5+48;`6020*x
  1559. V`6020+=`602024)
  1560. XX`6009`6009`6009`6009for`6020(*y`6020=`60200;`6020*y`6020!=`602048;`6020*y`602
  1561. V0+=`602024)
  1562. XX`6009`6009`6009`6009`6009if`6020(viewT`6020==`6020view)
  1563. XX`6009`6009`6009`6009`6009`6009return;
  1564. XX`6009`6009`6009`6009`6009else
  1565. XX`6009`6009`6009`6009`6009`6009viewT++;
  1566. XX
  1567. XX`6009`6009case`60204:
  1568. XX`6009`6009case`60205:
  1569. XX`6009`6009`6009*size`6020=`602016;
  1570. XX`6009`6009`6009*x`6020=`602064*5+48;
  1571. XX`6009`6009`6009for`6020(*y`6020=`60200;`6020*y`6020!=`602064;`6020*y`6020+=
  1572. V`602016)
  1573. XX`6009`6009`6009`6009if`6020(viewT`6020==`6020view)
  1574. XX`6009`6009`6009`6009`6009return;
  1575. XX`6009`6009`6009`6009else
  1576. XX`6009`6009`6009`6009`6009viewT++;
  1577. XX
  1578. XX`6009`6009case`60206:
  1579. XX`6009`6009case`60207:
  1580. XX`6009`6009case`60208:
  1581. XX`6009`6009`6009*size`6020=`60209;
  1582. XX`6009`6009`6009*y`6020=`602048;
  1583. XX`6009`6009`6009for`6020(*x`6020=`602064*5;`6020*x`6020!=`602064*5`6020+`60204
  1584. V*9;`6020*x`6020+=`60209)
  1585. XX`6009`6009`6009`6009if`6020(viewT`6020==`6020view)
  1586. XX`6009`6009`6009`6009`6009return;
  1587. XX`6009`6009`6009`6009else
  1588. XX`6009`6009`6009`6009`6009viewT++;
  1589. XX
  1590. XX`6009`6009case`60209:
  1591. XX`6009`6009case`602010:
  1592. XX`6009`6009case`602011:
  1593. XX`6009`6009case`602012:
  1594. XX`6009`6009`6009*size`6020=`60206;
  1595. XX`6009`6009`6009*y`6020=`602048+9;
  1596. XX`6009`6009`6009for`6020(*x`6020=`602064*5;`6020*x`6020!=`602064*5`6020+`60204
  1597. V*6;`6020*x`6020+=`60206)
  1598. XX`6009`6009`6009`6009if`6020(viewT`6020==`6020view)
  1599. XX`6009`6009`6009`6009`6009return;
  1600. XX`6009`6009`6009`6009else
  1601. XX`6009`6009`6009`6009`6009viewT++;
  1602. XX
  1603. XX`6009`6009case`602013:
  1604. XX`6009`6009case`602014:
  1605. XX`6009`6009case`602015:
  1606. XX`6009`6009case`602016:
  1607. XX`6009`6009case`602017:
  1608. XX`6009`6009case`602018:
  1609. XX`6009`6009`6009*size`6020=`60204;
  1610. XX`6009`6009`6009*y`6020=`602048+9+3;
  1611. XX`6009`6009`6009for`6020(*x`6020=`602064*5`6020+`60204*6;`6020*x`6020!=`602064
  1612. V*5`6020+4*6`6020+`60204*4;
  1613. XV`6020*x`6020+=`60204)
  1614. XX`6009`6009`6009`6009if`6020(viewT`6020==`6020view)
  1615. XX`6009`6009`6009`6009`6009return;
  1616. XX`6009`6009`6009`6009else
  1617. XX`6009`6009`6009`6009`6009viewT++;
  1618. XX
  1619. XX`6009`6009default:
  1620. XX`6009`6009`6009*size`6020=`60203;
  1621. XX`6009`6009`6009*y`6020=`602048+9;
  1622. XX`6009`6009`6009for`6020(*x`6020=`602064*5`6020+`60204*6;`6020*x`6020!=`602064
  1623. V*5`6020+`60204*6`6020+`60204*3;
  1624. XV`6020*x`6020+=`60203)
  1625. XX`6009`6009`6009`6009if`6020(viewT`6020==`6020view)
  1626. XX`6009`6009`6009`6009`6009return;
  1627. XX`6009`6009`6009`6009else
  1628. XX`6009`6009`6009`6009`6009viewT++;
  1629. XX`6009`607D
  1630. XX`607D
  1631. XX
  1632. XX/*`6020
  1633. XX`6020*`6020The`6020maze`6020display.`6020This`6020is`6020controlled`6020by
  1634. V`6020the`6020clearArray
  1635. XV`6020(another
  1636. XX`6020*`6020historically`6020significant`6020name,`6020I'm`6020afraid).`6020Ea
  1637. Vch`6020player`6020h
  1638. XVas`6020his
  1639. XX`6020*`6020loaction`6020and`6020playing`6020information`6020stored`6020here
  1640. V`6020as`6020well`6020as
  1641. XV`6020in`6020M.ratcb.
  1642. XX`6020*`6020This`6020is`6020to`6020tell`6020who`6020was`6020playing`6020before
  1643. V`6020the`6020last`6020upd
  1644. XVate/status/location
  1645. XX`6020*`6020packet`6020came`6020in,`6020so`6020we`6020can`6020do`6020the`6020r
  1646. Vight`6020thing`6020for
  1647. XV`6020adding/deleting`6020players.
  1648. XX`6020*
  1649. XX`6020*`6020There`6020are`6020various`6020hooks`6020for`6020setting`6020the
  1650. V`6020contents`6020of`6020c
  1651. XVlearArray
  1652. XX`6020*`6020from`6020the`6020outside,`6020like`6020SetMyRatId().
  1653. XX`6020*/
  1654. XX
  1655. XXSetMyRatId(ratId)
  1656. XXRatId`6009ratId;
  1657. XX`607B
  1658. XX`6009clearArray`605BratId`605D.playing`6020=`6020TRUE;
  1659. XX`607D
  1660. XX
  1661. XX/*`6020
  1662. XX`6020*`6020Someone`6020joined`6020us;`6020add`6020him`6020to`6020the`6020disp
  1663. Vlay.
  1664. XX`6020*/
  1665. XX
  1666. XXAddNewPlayer(ratId,`6020xloc,`6020yloc,`6020dir)
  1667. XXRatId`6009ratId;
  1668. XXDirection`6020dir;
  1669. XX`607B
  1670. XX`6009clearArray`605BratId`605D.playing`6020=`6020TRUE;
  1671. XX`6009clearArray`605BratId`605D.x`6020=`6020xloc;
  1672. XX`6009clearArray`605BratId`605D.y`6020=`6020yloc;
  1673. XX`6009clearArray`605BratId`605D.dir`6020=`6020dir;
  1674. XX`6009DisplayOthersPosition(ratId,`6020xloc,`6020yloc,`6020dir);
  1675. XX`6009NotifyPlayer();
  1676. XX`607D
  1677. XX
  1678. XX/*
  1679. XX`6020*`6020Someone`6020left.
  1680. XX`6020*/
  1681. XXExitPlayer(ratId)
  1682. XXRatId`6009ratId;
  1683. XX`607B
  1684. XX`6009clearPosition(ratId,`6020clearArray`605BratId`605D.x,`6020clearArray`605
  1685. VBratId`605D.y);
  1686. XV
  1687. XX`6009clearArray`605BratId`605D.playing`6020=`6020FALSE;
  1688. XX`607D
  1689. XX
  1690. XX/*`6020
  1691. XX`6020*`6020Tell`6020the`6020display`6020controller`6020I`6020moved.
  1692. XX`6020*/
  1693. XX
  1694. XXShowPosition(xloc,`6020yloc,`6020invincible,`6020tdir)
  1695. XXint`6009`6009xloc,`6020yloc;
  1696. XXBoolean`6009`6009invincible;
  1697. XXDirection`6009tdir;
  1698. XX`607B
  1699. XX`6009clearPosition(M.myRatId,`6020clearArray`605BM.myRatId`605D.x,
  1700. XX`6009`6009clearArray`605BM.myRatId`605D.y);
  1701. XX`6009showMe(xloc,`6020yloc,`6020invincible,`6020tdir);
  1702. XX`607D
  1703. XX
  1704. XX/*`6020
  1705. XX`6020*`6020Show`6020where`6020everybody`6020is`6020(only`6020for`6020wizards)
  1706. V.
  1707. XX`6020*/
  1708. XX
  1709. XXShowAllPositions()
  1710. XX`607B
  1711. XX`6009RatId`6009ratId;
  1712. XX
  1713. XX`6009for`6020(ratId`6020=`60200;`6020ratId`6020<`6020MAXRATS;`6020ratId++)
  1714. V`6020`607B
  1715. XX`6009`6009if`6020(ratId`6020==`6020M.myRatId)
  1716. XX`6009`6009`6009continue;
  1717. XX`6009`6009if`6020(clearArray`605BratId`605D.playing`6020`6026`6026`6020!M.rat
  1718. Vcb.rats`605BratId`605D.
  1719. XVplaying)
  1720. XX`6009`6009`6009ExitPlayer(ratId);
  1721. XX`6009`6009else`6020if`6020(!clearArray`605BratId`605D.playing`6020`6026`6026
  1722. XX`6009`6009`6009`6020M.ratcb.rats`605BratId`605D.playing)
  1723. XX`6009`6009`6009AddNewPlayer(ratId,`6020M.ratcb.rats`605BratId`605D.xLoc,
  1724. XX`6009`6009`6009`6009`6009`6020`6020`6020`6020M.ratcb.rats`605BratId`605D.yLoc
  1725. V,
  1726. XX`6009`6009`6009`6009`6009`6020`6020`6020`6020M.ratcb.rats`605BratId`605D.dir)
  1727. V;
  1728. XX`6009`6009else`6020if`6020(clearArray`605BratId`605D.playing)
  1729. XX`6009`6009`6009DisplayOthersPosition(ratId,`6020M.ratcb.rats`605BratId`605D.x
  1730. VLoc,
  1731. XX`6009`6009`6009`6009`6009`6009`6020`6020`6020`6020`6020M.ratcb.rats`605BratId
  1732. V`605D.yLoc,
  1733. XX`6009`6009`6009`6009`6009`6009`6020`6020`6020`6020`6020M.ratcb.rats`605BratId
  1734. V`605D.dir);
  1735. XX`6009`607D
  1736. XX`607D
  1737. XX
  1738. XX/*`6020
  1739. XX`6020*`6020Someone`6020else`6020moved;`6020update`6020his`6020info`6020and
  1740. V`6020display`6020the`6020n
  1741. XVew`6020position.
  1742. XX`6020*`6020Again,`6020only`6020for`6020wizards`6020who`6020are`6020exercising
  1743. V`6020their`6020powers
  1744. XV.
  1745. XX`6020*/
  1746. XX
  1747. XXDisplayOthersPosition(ratId,`6020xloc,`6020yloc,`6020dir)
  1748. XXRatId`6009ratId;
  1749. XXDirection`6020dir;
  1750. XX`607B
  1751. XX`6009if`6020(!clearArray`605BratId`605D.playing`6020`6026`6026`6020M.ratcb.ra
  1752. Vts`605BratId`605D.pla
  1753. XVying)`6020`607B
  1754. XX`6009`6009AddNewPlayer(ratId,`6020xloc,`6020yloc,`6020dir);`6009/*`6020calls
  1755. V`6020me`6020back`6020*
  1756. XV/
  1757. XX`6009`6009return;
  1758. XX`6009`607D
  1759. XX`6009`6009
  1760. XX`6009clearPosition(ratId,`6020clearArray`605BratId`605D.x,`6020clearArray`605
  1761. VBratId`605D.y);
  1762. XV
  1763. XX`6009if`6020(clearArray`605BratId`605D.playing`6020`6026`6026`6020M.omniscien
  1764. Vt)
  1765. XX`6009`6009showOther(ratId,`6020xloc,`6020yloc,`6020dir);
  1766. XX`607D
  1767. XX
  1768. XX/*`6020
  1769. XX`6020*`6020Do`6020the`6020actual`6020work`6020of`6020showing`6020me,`6020with
  1770. V`6020the`6020right`6020so
  1771. XVrt`6020of`6020arrow`6020(in
  1772. XX`6020*`6020case`6020I'm`6020playing`6020wizard).
  1773. XX`6020*/
  1774. XX
  1775. XXshowMe(xloc,`6020yloc,`6020invincible,`6020dir)
  1776. XXint`6009`6009xloc,`6020yloc;
  1777. XXBoolean`6009`6009invincible;
  1778. XXDirection`6009dir;
  1779. XX`607B
  1780. XX`6009register`6020BitCell`6009*bp;
  1781. XX`6009register`6020RatState`6009*rsp;
  1782. XX
  1783. XX`6009if`6020(invincible)
  1784. XX`6009`6009bp`6020=`6020invincibleArrows;
  1785. XX`6009else
  1786. XX`6009`6009bp`6020=`6020normalArrows;
  1787. XX
  1788. XX`6009HackMazeBitmap(xloc,`6020yloc,`6020`6026bp`605Bdir`605D);
  1789. XX
  1790. XX`6009rsp`6020=`6020`6026clearArray`605BM.myRatId`605D;
  1791. XX`6009rsp->playing`6020=`6020TRUE;
  1792. XX`6009rsp->x`6020=`6020xloc;
  1793. XX`6009rsp->y`6020=`6020yloc;
  1794. XX`6009rsp->dir`6020=`6020dir;
  1795. XX`6009M.invincible`6020=`6020invincible;
  1796. XX`607D
  1797. XX
  1798. XX/*`6020
  1799. XX`6020*`6020Bang`6020the`6020bits`6020to`6020show`6020the`6020other`6020guy.
  1800. XX`6020*/
  1801. XX
  1802. XXshowOther(ratId,`6020xloc,`6020yloc,`6020dir)
  1803. XXDirection`6020dir;
  1804. XX`607B
  1805. XX`6009register`6020int`6009`6009i;
  1806. XX`6009register`6020RatState`6009*rsp;
  1807. XX`6009BitCell`6009`6009`6009bits;
  1808. XX
  1809. XX`6009for`6020(i`6020=`60200;`6020i`6020<`602016;`6020i++)
  1810. XX`6009`6009bits.bits`605Bi`605D`6020=`6020otherArrows`605Bdir`605D.bits`605Bi
  1811. V`605D`6020`607C
  1812. XX`6009`6009`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020
  1813. V`6020`6020numbers`605BratId`605D.bits`605Bi
  1814. XV`605D;`6020
  1815. XX
  1816. XX`6009HackMazeBitmap(xloc,`6020yloc,`6020`6026bits);
  1817. XX
  1818. XX`6009rsp`6020=`6020`6026clearArray`605BratId`605D;
  1819. XX`6009rsp->playing`6020=`6020TRUE;
  1820. XX`6009rsp->x`6020=`6020xloc;
  1821. XX`6009rsp->y`6020=`6020yloc;
  1822. XX`6009rsp->dir`6020=`6020dir;
  1823. XX`607D
  1824. XX
  1825. XX/*`6020
  1826. XX`6020*`6020When`6020someone`6020moves`6020off`6020a`6020position,`6020clear
  1827. V`6020it`6020out.`6020If
  1828. XV`6020there's`6020someone
  1829. XX`6020*`6020"under"`6020him,`6020display`6020the`6020second`6020guy.`6020
  1830. XX`6020*/
  1831. XX
  1832. XXclearPosition(ratId,`6020xClear,`6020yClear)
  1833. XXRatId`6009ratId;
  1834. XX`607B
  1835. XX`6009register`6020RatState`6009*rsp;
  1836. XX`6009register`6020int`6009`6009i;
  1837. XX`6009
  1838. XX`6009clearSquare(xClear,`6020yClear);
  1839. XX`6009for`6020(i`6020=`60200;`6020i`6020<`6020MAXRATS;`6020i++)`6020`607B
  1840. XX`6009`6009rsp`6020=`6020`6026clearArray`605Bi`605D;
  1841. XX`6009`6009if`6020((i`6020==`6020ratId)`6020`607C`607C`6020!(rsp->playing))
  1842. XX`6009`6009`6009continue;
  1843. XX`6009`6009if`6020((rsp->x`6020==`6020xClear)`6020`6026`6026`6020(rsp->y`6020=
  1844. V=`6020yClear))
  1845. XX`6009`6009`6009if`6020(i`6020==`6020M.myRatId)
  1846. XX`6009`6009`6009`6009showMe(rsp->x,`6020rsp->y,`6020M.invincible,`6020rsp->dir
  1847. V);
  1848. XX`6009`6009`6009else
  1849. XX`6009`6009`6009`6009if`6020(M.omniscient)
  1850. XX`6009`6009`6009`6009`6009showOther(i,`6020rsp->x,`6020rsp->y,`6020rsp->dir);
  1851. XX`6009`607D
  1852. XX`607D
  1853. XX
  1854. XXstatic`6020BitCell`6020EMPTY`6020=`6020`607B0,`60200,`60200,`60200,`60200,
  1855. V`60200,`60200,`60200,`60200,
  1856. XV`60200,`60200,`60200,`60200,`60200,`60200,`60200`607D;
  1857. XX
  1858. XX/*`6020clear`6020out`6020a`6020square`6020of`6020the`6020maze`6020*/
  1859. XXclearSquare(xClear,`6020yClear)
  1860. XX`607B
  1861. XX`6009HackMazeBitmap(xClear,`6020yClear,`6020`6026EMPTY);
  1862. XX`607D
  1863. XX
  1864. XX/*`6020
  1865. XX`6020*`6020Handle`6020the`6020score`6020card`6020area.`6020Most`6020of`6020th
  1866. Ve`6020work`6020is`6020don
  1867. XVe`6020in`6020window`6020system
  1868. XX`6020*`6020dependent`6020routines.
  1869. XX`6020*/
  1870. XX
  1871. XXNewScoreCard()
  1872. XX`607B
  1873. XX`6009register`6020RatId`6009ratId;
  1874. XX
  1875. XX`6009for(`6020ratId`6020=`60200;`6020ratId`6020<`6020MAXRATS;`6020ratId++)
  1876. XX`6009`6009UpdateScoreCard(ratId);
  1877. XX`6009if`6020(M.omniscient)
  1878. XX`6009`6009ShowAllPositions();
  1879. XX`607D
  1880. XX
  1881. XXUpdateScoreCard(ratId)
  1882. XXRatId`6009ratId;
  1883. XX`607B
  1884. XX`6009ClearScoreLine(ratId);
  1885. XX`6009if`6020(M.ratcb.rats`605BratId`605D.playing)
  1886. XX`6009`6009WriteScoreString(ratId);
  1887. XX`6009if`6020(R2d2`605BratId`605D.visible`6020==`6020TRUE)
  1888. XX`6009`6009InvertScoreLine(ratId);
  1889. XX`607D
  1890. XX
  1891. XX/*
  1892. XX`6020*`6020Some`6020window`6020systems`6020(notably`6020X10)`6020choose`6020t
  1893. Vo`6020represent`6020b
  1894. XVitmaps`6020in
  1895. XX`6020*`6020little-endian`6020order.`6020That`6020is,`6020the`6020least`6020si
  1896. Vgnificant`6020bit
  1897. XV`6020in`6020the`6020word`6020is
  1898. XX`6020*`6020the`6020leftmost`6020bit`6020on`6020the`6020screen.`6020This`6020m
  1899. Veans`6020that`6020bitma
  1900. XVps`6020look
  1901. XX`6020*`6020"backwards"`6020on`6020the`6020screen`6020from`6020the`6020way`602
  1902. V0they`6020look`6020in
  1903. XV`6020source`6020code.`6020So,`6020we
  1904. XX`6020*`6020flip`6020them`6020all`6020here,`6020once,`6020at`6020initializatio
  1905. Vn`6020time,`6020so
  1906. XV`6020they`6020can`6020be`6020edited
  1907. XX`6020*`6020"by`6020hand".
  1908. XX`6020*
  1909. XX`6020*`6020It`6020is`6020up`6020to`6020the`6020window`6020system`6020initiali
  1910. Vzation`6020code`6020to
  1911. XV`6020call`6020this,`6020if
  1912. XX`6020*`6020deemed`6020necessary.
  1913. XX`6020*
  1914. XX`6020*`6020Hack`6020hack.
  1915. XX`6020*/
  1916. XX
  1917. XXFlipBitmaps()
  1918. XX`607B
  1919. XX`6009register`6020i;
  1920. XX
  1921. XX`6009bitFlip(normalArrows);
  1922. XX`6009bitFlip(invincibleArrows);
  1923. XX`6009bitFlip(otherArrows);
  1924. XX`6009bitFlip(numbers);`6009`6009/*`6020only`6020gets`6020the`6020first`60204
  1925. V`6020*/
  1926. XX`6009bitFlip(`6026numbers`605B4`605D);`6009`6009/*`6020get`6020the`6020rest
  1927. V`6020*/
  1928. XX`6009for`6020(i`6020=`60200;`6020i`6020<`6020ratBits_width`6020*`6020ratBits_
  1929. Vheight`6020/`602016;
  1930. XV`6020i`6020+=`602064)
  1931. XX`6009`6009bitFlip((BitCell`6020*)`6020`6026ratBits`605Bi`605D);
  1932. XX`607D
  1933. XX
  1934. XX/*
  1935. XX`6020*`6020quick`6020bit`6020flipper`6020--`6020divide`6020and`6020conquer
  1936. V`6020due`6020to`6020Jeff
  1937. XV`6020Mogul.
  1938. XX`6020*`6020unrolled`6020to`6020do`60204`602016`6020bit`6020words,`6020but`602
  1939. V0generally`6020extensib
  1940. XVle.
  1941. XX`6020*/
  1942. XX
  1943. XXbitFlip(bits)
  1944. XXregister`6020BitCell`6020*bits;
  1945. XX`607B
  1946. XX`6009register`6020int`6009num,`6020top,`6020bot,`6020i,`6020j;
  1947. XX
  1948. XX`6009for`6020(i`6020=`60200;`6020i`6020<`60204;`6020i++)`6020`607B
  1949. XX`6009`6009for`6020(j`6020=`60200;`6020j`6020<`602016;`6020j++)`6020`607B
  1950. XX`6009`6009`6009num`6020=`6020bits->bits`605Bj`605D`6020`6026`60200xffff;
  1951. XX`6009`6009`6009top`6020=`6020num`6020`6026`60200xff00;
  1952. XX`6009`6009`6009bot`6020=`6020num`6020`6026`60200x00ff;
  1953. XX`6009`6009`6009top`6020>>=`60208;
  1954. XX`6009`6009`6009bot`6020<<=`60208;
  1955. XX`6009`6009`6009num`6020=`6020top`607Cbot;
  1956. XX
  1957. XX`6009`6009`6009top`6020=`6020num`6020`6026`60200xf0f0;
  1958. XX`6009`6009`6009bot`6020=`6020num`6020`6026`60200x0f0f;
  1959. XX`6009`6009`6009top`6020>>=`60204;
  1960. XX`6009`6009`6009bot`6020<<=`60204;
  1961. XX`6009`6009`6009num`6020=`6020top`607Cbot;
  1962. XX
  1963. XX`6009`6009`6009top`6020=`6020num`6020`6026`60200xcccc;
  1964. XX`6009`6009`6009bot`6020=`6020num`6020`6026`60200x3333;
  1965. XX`6009`6009`6009top`6020>>=`60202;
  1966. XX`6009`6009`6009bot`6020<<=`60202;
  1967. XX`6009`6009`6009num`6020=`6020top`607Cbot;
  1968. XX
  1969. XX`6009`6009`6009top`6020=`6020num`6020`6026`60200xaaaa;
  1970. XX`6009`6009`6009bot`6020=`6020num`6020`6026`60200x5555;
  1971. XX`6009`6009`6009top`6020>>=`60201;
  1972. XX`6009`6009`6009bot`6020<<=`60201;
  1973. XX`6009`6009`6009bits->bits`605Bj`605D`6020=`6020top`607Cbot;
  1974. XX`6009`6009`607D
  1975. XX`6009`6009bits++;
  1976. XX`6009`607D
  1977. XX`607D
  1978. XX
  1979. XX
  1980. XX/*
  1981. XX`6020*`6020Then`6020there`6020are`6020the`6020systems`6020that`6020are`6020pe
  1982. Vrfectly`6020happy`6020w
  1983. XVith`6020MSBFirst`6020data,`6020but
  1984. XX`6020*`6020byte`6020swap`6020the`6020shorts`6020that`6020are`6020used.`6020
  1985. V`6020We`6020fix`6020that
  1986. XV`6020here.
  1987. XX`6020*
  1988. XX`6020*`6020The`6020htons()`6020routine`6020is`6020a`6020defined`6020to`6020be
  1989. V`6020a`6020no-op`6020on
  1990. XV`6020machines`6020that`6020don't`6020have
  1991. XX`6020*`6020this`6020problem.
  1992. XX`6020*
  1993. XX`6020*/
  1994. XX
  1995. XXSwapBitmaps()
  1996. XX`607B
  1997. XX`6009register`6020i;
  1998. XX
  1999. XX`6009byteSwap(normalArrows);
  2000. XX`6009byteSwap(invincibleArrows);
  2001. XX`6009byteSwap(otherArrows);
  2002. XX`6009byteSwap(numbers);`6009/*`6020only`6020gets`6020first`60204`6020*/
  2003. XX`6009byteSwap(`6026numbers`605B4`605D);`6009/*`6020get`6020the`6020rest`6020*
  2004. V/
  2005. XX`6009for`6020(i`6020=`60200;`6020i`6020<`6020ratBits_width`6020*`6020ratBits_
  2006. Vheight`6020/`602016;
  2007. XV`6020i`6020+=`602064)
  2008. XX`6009`6009byteSwap((BitCell`6020*)`6020`6026ratBits`605Bi`605D);
  2009. XX`607D
  2010. XX
  2011. XX/*
  2012. XX`6020*`6020Byte`6020swap`60204`602016x16`6020bitmaps.
  2013. XX`6020*/
  2014. XX
  2015. XXbyteSwap(bits)
  2016. XXregister`6020BitCell`6020*bits;
  2017. XX`607B
  2018. XX`6009register`6020int`6020i,`6020j;
  2019. XX`6009
  2020. XX`6009for`6020(i`6020=`60200;`6020i`6020<`60204;`6020i++,`6020bits++)
  2021. XX`6009`6009for`6020(j`6020=`60200;`6020j`6020<`602016;`6020j++)
  2022. XX`6009`6009`6009bits->bits`605Bj`605D`6020=`6020htons(bits->bits`605Bj`605D
  2023. V`6020`6026`60200xffff);
  2024. XX`607D
  2025. X$`20call`20unpack`20DISPLAY.C;1`201029848417`20""
  2026. X$!
  2027. X$`20create`20'f'
  2028. XX/*`6020$Header:`6020init.c,v`60201.13`602088/09/07`602014:37:21`6020kent`6020
  2029. VExp`6020$`6020*/
  2030. XX
  2031. XX/*`6020
  2032. XX`6020*`6020init.c`6020-`6020Initialization`6020code`6020for`6020mazewar
  2033. XX`6020*`6020
  2034. XX`6020*`6020Author:`6009Christopher`6020A.`6020Kent
  2035. XX`6020*`6020`6009`6009Western`6020Research`6020Laboratory
  2036. XX`6020*`6009`6020`6009Digital`6020Equipment`6020Corporation
  2037. XX`6020*`6020Date:`6009Thu`6020Oct`6020`60202`60201986
  2038. XX`6020*/
  2039. XX
  2040. XX/***********************************************************
  2041. XXCopyright`60201986`6020by`6020Digital`6020Equipment`6020Corporation,`6020Mayn
  2042. Vard,`6020Massac
  2043. XVhusetts,
  2044. XX
  2045. XX`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020
  2046. V`6020`6020`6020`6020`6020`6020`6020`6020`6020All
  2047. XV`6020Rights`6020Reserved
  2048. XX
  2049. XXPermission`6020to`6020use,`6020copy,`6020modify,`6020and`6020distribute`6020t
  2050. Vhis`6020software
  2051. XV`6020and`6020its`6020
  2052. XXdocumentation`6020for`6020any`6020purpose`6020and`6020without`6020fee`6020is
  2053. V`6020hereby`6020gran
  2054. XVted,`6020
  2055. XXprovided`6020that`6020the`6020above`6020copyright`6020notice`6020appear`6020i
  2056. Vn`6020all`6020copie
  2057. XVs`6020and`6020that
  2058. XXboth`6020that`6020copyright`6020notice`6020and`6020this`6020permission`6020no
  2059. Vtice`6020appear
  2060. XV`6020in`6020
  2061. XXsupporting`6020documentation,`6020and`6020that`6020the`6020names`6020of`6020D
  2062. Vigital`6020not
  2063. XV`6020be
  2064. XXused`6020in`6020advertising`6020or`6020publicity`6020pertaining`6020to`6020di
  2065. Vsstribution`6020o
  2066. XVf`6020the
  2067. XXsoftware`6020without`6020specific,`6020written`6020prior`6020permission.`6020
  2068. V`6020
  2069. XX
  2070. XXDIGITAL`6020DISCLAIMS`6020ALL`6020WARRANTIES`6020WITH`6020REGARD`6020TO`6020T
  2071. VHIS`6020SOFTWARE,
  2072. XV`6020INCLUDING
  2073. XXALL`6020IMPLIED`6020WARRANTIES`6020OF`6020MERCHANTABILITY`6020AND`6020FITNESS
  2074. V,`6020IN`6020NO
  2075. XV`6020EVENT`6020SHALL
  2076. XXDIGITAL`6020BE`6020LIABLE`6020FOR`6020ANY`6020SPECIAL,`6020INDIRECT`6020OR
  2077. V`6020CONSEQUENTIAL
  2078. XV`6020DAMAGES`6020OR
  2079. XXANY`6020DAMAGES`6020WHATSOEVER`6020RESULTING`6020FROM`6020LOSS`6020OF`6020USE
  2080. V,`6020DATA`6020OR
  2081. XV`6020PROFITS,
  2082. XXWHETHER`6020IN`6020AN`6020ACTION`6020OF`6020CONTRACT,`6020NEGLIGENCE`6020OR
  2083. V`6020OTHER`6020TORTIO
  2084. XVUS`6020ACTION,
  2085. XXARISING`6020OUT`6020OF`6020OR`6020IN`6020CONNECTION`6020WITH`6020THE`6020USE
  2086. V`6020OR`6020PERFORMANC
  2087. XVE`6020OF`6020THIS
  2088. XXSOFTWARE.
  2089. XX
  2090. XX******************************************************************/
  2091. XX
  2092. XX/*
  2093. XX`6020*`6020$Log:`6009init.c,v`6020$
  2094. XX`6020*`6020Revision`60201.13`6020`602088/09/07`6020`602014:37:21`6020`6020ken
  2095. Vt
  2096. XX`6020*`6020Portability`6020changes`6020for`6020broadcasts.
  2097. XX`6020*`6020
  2098. XX`6020*`6020Revision`60201.12`6020`602088/08/25`6020`602009:57:53`6020`6020ken
  2099. Vt
  2100. XX`6020*`6020Copyright`6020and`6020changed`6020to`6020allow`6020the`6020broadca
  2101. Vst`6020address`6020to
  2102. XV`6020be`6020set`6020in`6020Makefile.
  2103. XX`6020*`6020
  2104. XX`6020*`6020Revision`60201.11`6020`602088/06/15`6020`602016:36:31`6020`6020ken
  2105. Vt
  2106. XX`6020*`6020Updated`6020to`6020use`6020proper`6020broadcast`6020address.
  2107. XX`6020*`6020
  2108. XX`6020*`6020Revision`60201.10`6020`602087/07/28`6020`602013:51:16`6020`6020ken
  2109. Vt
  2110. XX`6020*`6020Fixed`6020a`6020problem`6020in`6020netInit();`6020didn't`6020handl
  2111. Ve`6020the`6020case
  2112. XV`6020when`6020gethostname()
  2113. XX`6020*`6020returned`6020something`6020that`6020couldn't`6020be`6020found`6020
  2114. Vin`6020the`6020host
  2115. XV`6020table.
  2116. XX`6020*`6020
  2117. XX`6020*`6020Revision`60201.9`6020`602087/03/31`6020`602014:42:14`6020`6020kent
  2118. V
  2119. XX`6020*`6020Portability`6020considerations,`6020especially`6020byteswapping
  2120. V`6020to/from`6020t
  2121. XVhe`6020net.
  2122. XX`6020*`6020
  2123. XX`6020*`6020Revision`60201.8`6020`602086/12/04`6020`602017:48:05`6020`6020kent
  2124. V
  2125. XX`6020*`6020findDuke's`6020return`6020value`6020pointed`6020to`6020something
  2126. V`6020on`6020the`6020sta
  2127. XVck!
  2128. XX`6020*`6020
  2129. XX`6020*`6020Revision`60201.7`6020`602086/12/04`6020`602011:16:54`6020`6020kent
  2130. V
  2131. XX`6020*`6020Handle`6020name`6020case`6020when`6020there's`6020no`6020comma`602
  2132. V0in`6020the`6020gecos
  2133. XV`6020field.
  2134. XX`6020*`6020
  2135. X+-+-+-+-+-+-+-+-`20`20END`20`20OF`20PART`202`20+-+-+-+-+-+-+-+-
  2136. $ call unpack [.MAZEWAR]MAZEWAR.2;1 1820318911 ""
  2137. $!
  2138. $ create 'f'
  2139. X-+-+-+-+-+-+-+-+`20START`20OF`20PART`203`20-+-+-+-+-+-+-+-+
  2140. XX`6020*`6020Revision`60201.6`6020`602086/12/04`6020`602011:14:23`6020`6020kent
  2141. V
  2142. XX`6020*`6020Clean`6020up`6020join,`6020so`6020you`6020can`6020specify`6020any
  2143. V`6020host`6020in`6020a`6020g
  2144. XVame,`6020not`6020just`6020the`6020duke.
  2145. XX`6020*`6020
  2146. XX`6020*`6020Revision`60201.5`6020`602086/12/03`6020`602013:31:25`6020`6020kent
  2147. V
  2148. XX`6020*`6020
  2149. XX`6020*`6020
  2150. XX`6020*`6020Revision`60201.4`6020`602086/12/03`6020`602010:00:45`6020`6020kent
  2151. V
  2152. XX`6020*`6020Changes`6020to`6020allow`6020multiple`6020players`6020per`6020mach
  2153. Vine.
  2154. XX`6020*`6020
  2155. XX`6020*`6020Revision`60201.3`6020`602086/12/01`6020`602023:44:25`6020`6020kent
  2156. V
  2157. XX`6020*`6020Housecleaning`6020and`6020documentation`6020pass.
  2158. XX`6020*`6020
  2159. XX`6020*`6020Revision`60201.2`6020`602086/12/01`6020`602014:48:17`6020`6020kent
  2160. V
  2161. XX`6020*`6020Changes`6020for`6020a`6020realistic`6020implementation`6020of`6020
  2162. Vshooting.
  2163. XX`6020*`6020
  2164. XX`6020*`6020Revision`60201.1`6020`602086/11/26`6020`602016:57:42`6020`6020kent
  2165. V
  2166. XX`6020*`6020Initial`6020revision
  2167. XX`6020*`6020
  2168. XX`6020*/
  2169. XX
  2170. XX#ifndef`6009lint
  2171. XXstatic`6020char`6020rcs_ident`605B`605D`6020=`6020"$Header:`6020init.c,v`6020
  2172. V1.13`602088/09/07
  2173. XV`602014:37:21`6020kent`6020Exp`6020$";
  2174. XX#endif
  2175. XX
  2176. XX#include`6020<sys/types.h>
  2177. XX#include`6020<sys/socket.h>
  2178. XX#include`6020<sys/time.h>
  2179. XX
  2180. XX#include`6020<netinet/in.h>
  2181. XX
  2182. XX#include`6020<errno.h>
  2183. XX#include`6020<netdb.h>
  2184. XX#include`6020<stdio.h>
  2185. XX#ifdef`6020VMS
  2186. XX#else
  2187. XX#include`6020<pwd.h>
  2188. XX#include`6020<string.h>
  2189. XX#endif
  2190. XX
  2191. XX#include`6020"mazewar.h"
  2192. XX
  2193. XXint`6009RV`605BVECTORSIZE`605D`6020=`6020`607B
  2194. XX`60090031575,`60200055455,`60200147160,`60200176745,`60200173126,`60200117426
  2195. V,`60200033612,
  2196. XV`60200136020,
  2197. XX`60090054013,`60200167672,`60200070252,`60200033100,`60200015700,`60200113523
  2198. V,`60200170465,
  2199. XV`60200024344,
  2200. XX`60090175535,`60200137325,`60200126211,`60200010207,`60200173547,`60200016071
  2201. V,`60200056622,
  2202. XV`60200014433,
  2203. XX`60090113225,`60200047553,`60200103024,`60200110174,`60200000124,`60200173304
  2204. V,`60200076700,
  2205. XV`60200104042,
  2206. XX`60090135030,`60200126234,`60200175154,`60200140123,`60200167542,`60200000405
  2207. V,`60200035464,
  2208. XV`60200166537,
  2209. XX`60090050260,`60200167655,`60200123715,`60200176164,`60200172206,`60200140365
  2210. V,`60200074606,
  2211. XV`60200075656,
  2212. XX`60090176163,`60200030017,`60200022102,`60200040051,`60200154620,`60200017144
  2213. V,`60200073372
  2214. XX`607D;
  2215. XX
  2216. XXstatic`6020MazeType`6020mazeBits`6020=`6020`607B
  2217. XX`6009`607B`60201,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1`607D,`6009/*`60200`6020*/
  2218. XX`6009`607B`60201,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1`607D,
  2219. XX`6009`607B`60201,0,1,1,1,1,1,0,1,1,1,1,0,1,1,1`607D,
  2220. XX`6009`607B`60201,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1`607D,
  2221. XX
  2222. XX`6009`607B`60201,0,1,0,1,0,0,0,1,0,1,1,1,1,0,1`607D,`6009/*`60201`6020*/
  2223. XX`6009`607B`60201,0,1,1,1,0,1,0,1,0,1,0,0,0,0,1`607D,
  2224. XX`6009`607B`60201,0,0,0,0,0,1,0,0,0,1,0,1,1,0,1`607D,
  2225. XX`6009`607B`60201,1,1,1,1,0,1,1,1,0,0,0,0,0,0,1`607D,
  2226. XX
  2227. XX`6009`607B`60201,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1`607D,`6009/*`60202`6020*/
  2228. XX`6009`607B`60201,0,1,1,1,1,1,0,1,0,1,0,0,0,0,1`607D,
  2229. XX`6009`607B`60201,0,0,0,0,0,1,0,0,0,1,0,1,1,1,1`607D,
  2230. XX`6009`607B`60201,0,1,1,1,0,1,0,1,0,1,0,0,0,0,1`607D,
  2231. XX
  2232. XX`6009`607B`60201,0,0,0,0,0,1,0,1,0,1,1,1,1,0,1`607D,`6009/*`60203`6020*/
  2233. XX`6009`607B`60201,0,1,1,1,1,1,0,1,0,1,1,0,1,0,1`607D,
  2234. XX`6009`607B`60201,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1`607D,
  2235. XX`6009`607B`60201,0,1,1,1,1,1,1,1,0,1,0,1,1,1,1`607D,
  2236. XX
  2237. XX`6009`607B`60201,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1`607D,`6009/*`60204`6020*/
  2238. XX`6009`607B`60201,1,1,0,1,0,1,0,1,0,1,0,1,1,0,1`607D,
  2239. XX`6009`607B`60201,0,0,0,1,0,1,0,1,0,1,0,0,1,0,1`607D,
  2240. XX`6009`607B`60201,0,1,1,1,0,1,0,1,0,1,1,0,0,0,1`607D,
  2241. XX
  2242. XX`6009`607B`60201,0,0,0,0,0,0,0,1,0,1,0,0,1,0,1`607D,`6009/*`60205`6020*/
  2243. XX`6009`607B`60201,0,1,1,1,1,1,1,1,0,1,0,1,1,0,1`607D,
  2244. XX`6009`607B`60201,0,0,0,1,0,0,0,1,0,1,0,0,1,0,1`607D,
  2245. XX`6009`607B`60201,0,1,0,1,0,1,0,1,0,1,1,0,0,0,1`607D,
  2246. XX
  2247. XX`6009`607B`60201,0,1,0,1,0,1,0,1,0,0,0,0,1,0,1`607D,`6009/*`60206`6020*/
  2248. XX`6009`607B`60201,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1`607D,
  2249. XX`6009`607B`60201,0,1,0,1,0,1,0,1,0,1,0,0,1,0,1`607D,
  2250. XX`6009`607B`60201,0,1,0,0,0,1,0,1,0,1,1,0,1,0,1`607D,
  2251. XX
  2252. XX`6009`607B`60201,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1`607D,`6009/*`60207`6020*/
  2253. XX`6009`607B`60201,0,1,0,1,0,1,0,1,0,1,1,1,1,0,1`607D,
  2254. XX`6009`607B`60201,0,0,0,1,0,0,0,1,0,0,0,0,1,0,1`607D,
  2255. XX`6009`607B`60201,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1`607D
  2256. XX`607D;
  2257. XX
  2258. XXstatic`6020char`6009*ratName`6020=`6020NULL;
  2259. XXstatic`6020char`6009*dukeName`6020=`6020NULL;
  2260. XXstatic`6020Sockaddr`6009dukeAddr;
  2261. XX
  2262. XXSockaddr`6009*resolveHost();
  2263. XX
  2264. XXextern`6020int`6009errno;
  2265. XX
  2266. XXMazeInit(argc,`6020argv)
  2267. XXchar`6009**argv;
  2268. XX`607B
  2269. XX`6009register`6020RatId`6009ratId;
  2270. XX
  2271. XX`6009for`6020(ratId`6020=`60200;`6020ratId`6020<`6020MAXRATS;`6020ratId++)
  2272. V`6020`607B
  2273. XX`6009`6009bzero((char`6020*)`6020M.ratcb.rats`605BratId`605D.name,`6020NAMESI
  2274. VZE);
  2275. XX`6009`6009M.ratcb.rats`605BratId`605D.playing`6020=`6020FALSE;
  2276. XX`6009`6009R2d2`605BratId`605D.visible`6020=`6020FALSE;
  2277. XX`6009`607D
  2278. XX`6009M.invincible`6020=`6020FALSE;
  2279. XX`6009M.omniscient`6020=`6020FALSE;
  2280. XX`6009RatKillQ`6020=`6020(RatKillQ_t)`6020NULL;
  2281. XX
  2282. XX`6009getMaze();
  2283. XX
  2284. XX`6009setRandom();
  2285. XX`6009InitRandom();
  2286. XX
  2287. XX`6009InitDisplay(argc,`6020argv);
  2288. XX`6009getNames();
  2289. XX`6009NewPosition();
  2290. XX
  2291. XX`6009/*
  2292. XX`6009`6020*`6020We`6020don't`6020do`6020ShowPosition()`6020or`6020ShowView()
  2293. V`6020here,`6020but`6020l
  2294. XVet`6020the`6020update
  2295. XX`6009`6020*`6020routine`6020in`6020the`6020window`6020handler`6020do`6020it
  2296. V`6020for`6020the`6020first
  2297. XV`6020time`6020when
  2298. XX`6009`6020*`6020the`6020window`6020is`6020exposed.
  2299. XX`6009`6020*/
  2300. XX
  2301. XX`6009netInit();
  2302. XX`6009StartDisplay();
  2303. XX`6009RatCursor();
  2304. XX`607D
  2305. XX
  2306. XX/*`6020get`6020the`6020maze`6020into`6020memory`6020*/
  2307. XXgetMaze()
  2308. XX`607B
  2309. XX`6009int`6020i,`6020j;
  2310. XX
  2311. XX`6009for`6020(i`6020=`60200;`6020i`6020<`6020MAZEXMAX;`6020i++)
  2312. XX`6009`6009for`6020(j`6020=`60200;`6020j`6020<`6020MAZEYMAX;`6020j++)
  2313. XX`6009`6009`6009if`6020(mazeBits`605Bi`605D.y`605BMAZEYMAX-1`6020-`6020j`605D
  2314. V`6020==`60201)
  2315. XX`6009`6009`6009`6009M.maze`605Bi`605D.y`605Bj`605D`6020=`6020TRUE;
  2316. XX`6009`6009`6009else
  2317. XX`6009`6009`6009`6009M.maze`605Bi`605D.y`605Bj`605D`6020=`6020FALSE;
  2318. XX`607D
  2319. XX
  2320. XX/*`6020initialize`6020the`6020random`6020vector`6020*/
  2321. XXsetRandom()
  2322. XX`607B
  2323. XX`6009register`6009i;
  2324. XX
  2325. XX`6009for`6020(i`6020=`60200;`6020i`6020<`6020VECTORSIZE;`6020i++)
  2326. XX`6009`6009M.randomVector`605Bi`605D`6020=`6020RV`605Bi`605D;
  2327. XX`607D
  2328. XX
  2329. XX/*`6020get`6020player`6020and`6020duke`6020host`6020names`6020*/
  2330. XXgetNames()
  2331. XX`607B
  2332. XX`6009char`6009`6009buf`605B128`605D,`6020*cp;
  2333. XX`6009char`6009`6009*comma;
  2334. XX`6009Sockaddr`6009*duke;
  2335. XX`6009char`6009`6009*getenv();
  2336. XX`6009struct`6020passwd`6009*getpwuid();
  2337. XX
  2338. XX`6009buf`605B0`605D`6020=`6020'`605C0';
  2339. XX`6009printf("Welcome`6020to`6020Alto`6020MazeWar!`605Cn`605Cn");
  2340. XX`6009printf("Your`6020Name:`6020");
  2341. XX`6009gets(buf);
  2342. XX`6009if`6020(buf`605B0`605D`6020==`6020'`605C0')`6020`607B
  2343. XX`6009`6009if`6020((cp`6020=`6020getenv("USERNAME"))`6020!=`6020NULL)
  2344. XX`6009`6009`6009strcpy(buf,`6020cp);
  2345. XX`6009`6009else`6020if`6020((cp`6020=`6020getenv("USER"))`6020!=`6020NULL)
  2346. XX`6009`6009`6009strcpy(buf,`6020cp);
  2347. XX`6009`6009else`6020`607B
  2348. XX#ifdef`6020VMS
  2349. XX`6009`6009`6020`6020`6020`6020`6020`6020`6020`6020strcpy`6020(buf,`6020"Whozi
  2350. Vt?");
  2351. XX#else
  2352. XX`6009`6009`6009strcpy(buf,`6020(getpwuid(getuid()))->pw_gecos);
  2353. XX`6009`6009`6009comma`6020=`6020index(buf,`6020',');
  2354. XX`6009`6009`6009if`6020(comma`6020!=`6020NULL)
  2355. XX`6009`6009`6009`6009*comma`6020=`6020'`605C0';
  2356. XX#endif
  2357. XX`6009`6009`607D
  2358. XX`6009`607D
  2359. XX`6009ratName`6020=`6020malloc((unsigned)`6020(strlen(buf)`6020+`60201));
  2360. XX`6009if`6020(ratName`6020==`6020NULL)
  2361. XX`6009`6009MWError("no`6020mem`6020for`6020ratName");
  2362. XX`6009strcpy(ratName,`6020buf);
  2363. XX`6009for`6020(duke`6020=`6020NULL;`6020duke`6020==`6020NULL;`6020)`6020`607B
  2364. XX#ifndef`6009NO_BROADCAST
  2365. XX`6009`6009printf("Duke`6020Host`6020(CR`6020for`6020any`6020game):`6020");
  2366. XX#else
  2367. XX`6009`6009printf("Duke`6020Host:`6020");
  2368. XX#endif`6009NO_BROADCAST
  2369. XX`6009`6009gets(buf);
  2370. XX`6009`6009if`6020(strlen(buf)`6020==`60200)
  2371. XX`6009`6009`6009break;
  2372. XX`6009`6009dukeName`6020=`6020malloc((unsigned)`6020(strlen(buf)`6020+`60201))
  2373. V;
  2374. XX`6009`6009if`6020(dukeName`6020==`6020NULL)
  2375. XX`6009`6009`6009MWError("no`6020mem`6020for`6020dukeName");
  2376. XX`6009`6009strcpy(dukeName,`6020buf);
  2377. XX
  2378. XX`6009`6009/*`6020check`6020for`6020valid`6020duke`6020name`6020*/
  2379. XX`6009`6009duke`6020=`6020resolveHost(dukeName);
  2380. XX`6009`6009if`6020(duke`6020==`6020(Sockaddr`6020*)`6020NULL)`6020`607B
  2381. XX`6009`6009`6009printf("Don't`6020know`6020host`6020%s`605Cn",`6020dukeName);
  2382. XX`6009`6009`6009free(dukeName);
  2383. XX`6009`6009`6009dukeName`6020=`6020NULL;
  2384. XX`6009`6009`607D
  2385. XX`6009`607D
  2386. XX`6009if`6020((dukeName`6020!=`6020NULL)`6020`6026`6026
  2387. XX`6009`6020`6020`6020`6020(strlen(dukeName)`6020!=`60200))
  2388. XX`6009`6009bcopy((char`6020*)`6020duke,`6020(char`6020*)`6020`6026dukeAddr,
  2389. V`6020sizeof(Sockaddr))
  2390. XV;
  2391. XX`607D
  2392. XX
  2393. XXnetInit()
  2394. XX`607B
  2395. XX`6009register`6020RatId`6009ratId;
  2396. XX`6009Boolean`6009`6009joinGame();
  2397. XX`6009struct`6020servent`6009*mazeService;
  2398. XX`6009u_short`6009`6009port;
  2399. XX`6009Sockaddr`6009nullAddr;
  2400. XX`6009Sockaddr`6009*thisHost;
  2401. XX`6009char`6009`6009buf`605B128`605D;
  2402. XX
  2403. XX`6009mazeService`6020=`6020getservbyname(MAZESERVICE,`6020"udp");
  2404. XX`6009if`6020(mazeService`6020!=`6020(struct`6020servent`6020*)`6020NULL)
  2405. XX`6009`6009M.mazePort`6020=`6020mazeService->s_port;
  2406. XX`6009else
  2407. XX`6009`6009M.mazePort`6020=`6020htons(MAZEPORT);
  2408. XX
  2409. XX`6009gethostname(buf,`6020sizeof(buf));
  2410. XX`6009if`6020((thisHost`6020=`6020resolveHost(buf))`6020==`6020(Sockaddr`6020*
  2411. V)`6020NULL)
  2412. XX`6009`6009MWError("who`6020am`6020I?");
  2413. XX`6009bcopy((caddr_t)`6020thisHost,`6020(caddr_t)`6020`6026M.myAddr,`6020sizeo
  2414. Vf(Sockaddr));
  2415. XV
  2416. XX`6009nullAddr`6020=`6020M.myAddr;
  2417. XX`6009bzero((char`6020*)`6026nullAddr.sin_addr,`6020sizeof(nullAddr.sin_addr))
  2418. V;
  2419. XX
  2420. XX`6009/*`6020
  2421. XX`6009`6020*`6020Figure`6020out`6020which`6020port`6020I`6020can`6020use.`6020
  2422. VStart`6020at`6020MAZEPORT
  2423. XV`6020and`6020go
  2424. XX`6009`6020*`6020up`6020till`6020there's`6020a`6020free`6020one.`6020We`6020us
  2425. Ve`6020nullAddr`6020so`6020t
  2426. XVhat`6020we
  2427. XX`6009`6020*`6020can`6020receive`6020any`6020incoming`6020packet,`6020in`6020c
  2428. Vase`6020there's`6020som
  2429. XVe
  2430. XX`6009`6020*`6020multi-homed`6020nonsense.`6020However,`6020not`6020binding
  2431. V`6020may`6020cause`6020t
  2432. XVroubles
  2433. XX`6009`6020*`6020if`6020a`6020specified`6020duke`6020is`6020on`6020a`6020net
  2434. V`6020that`6020causes`6020the
  2435. XV`6020source`6020of`6020the
  2436. XX`6009`6020*`6020packets`6020to`6020be`6020something`6020other`6020than`6020wh
  2437. Vat`6020M.myAddr`6020is.
  2438. XV..
  2439. XX`6009`6020*`6020There`6020also`6020seems`6020to`6020be`6020a`6020problem`6020
  2440. Vwith`6020broadcasts`6020n
  2441. XVot`6020being
  2442. XX`6009`6020*`6020accepted`6020on`6020sockets`6020that`6020have`6020an`6020addr
  2443. Vess`6020bound`6020to
  2444. XV`6020them.
  2445. XX`6009`6020*/
  2446. XX
  2447. XX`6009M.theSocket`6020=`6020socket(AF_INET,`6020SOCK_DGRAM,`60200);
  2448. XX`6009if`6020(M.theSocket`6020<`60200)
  2449. XX`6009`6009MWError("can't`6020get`6020socket");
  2450. XX
  2451. XX`6009for`6020(port`6020=`6020ntohs(M.mazePort);`6020;`6020port++)`6020`607B
  2452. XX`6009`6009nullAddr.sin_port`6020=`6020htons(port);
  2453. XX`6009`6009if`6020(bind(M.theSocket,`6020`6026nullAddr,`6020sizeof(nullAddr))
  2454. V`6020<`60200)
  2455. XX#ifdef`6020VMS
  2456. XX`6009`6009`6009if`6020(socket_errno`6020!=`6020EADDRINUSE)
  2457. XX#else
  2458. XX`6009`6009`6009if`6020(errno`6020!=`6020EADDRINUSE)
  2459. XX#endif
  2460. XX`6009`6009`6009`6009MWError("netInit`6020binding");
  2461. XX`6009`6009`6009else
  2462. XX`6009`6009`6009`6009continue;
  2463. XX`6009`6009else
  2464. XX`6009`6009`6009break;
  2465. XX`6009`607D
  2466. XX`6009M.myAddr.sin_port`6020=`6020nullAddr.sin_port;
  2467. XX
  2468. XX`6009/*
  2469. XX`6009`6020*`6020Now`6020we`6020can`6020try`6020to`6020find`6020a`6020game`602
  2470. V0to`6020join;`6020if`6020none
  2471. XV,`6020start`6020one.
  2472. XX`6009`6020*/
  2473. XX
  2474. XX`6009if`6020(!joinGame())
  2475. XX`6009`6009startGame();
  2476. XX`6009printf("`605Cn");
  2477. XX
  2478. XX`6009for`6020(ratId`6020=`60200;`6020ratId`6020<`6020MAXRATS;`6020ratId++)
  2479. XX`6009`6009TokenVisible(ratId);`6009/*`6020oh`6020oh`6020say`6020can`6020we
  2480. V`6020see?`6020*/
  2481. XX
  2482. XX`607D
  2483. XX
  2484. XX/*`6020
  2485. XX`6020*`6020Find`6020a`6020game.`6020If`6020the`6020user`6020specified`6020a
  2486. V`6020"duke"`6020host,`6020c
  2487. XVontact`6020that
  2488. XX`6020*`6020duke.`6020Otherwise`6020broadcast`6020to`6020find`6020a`6020duke.
  2489. V`6020Finally`6020join
  2490. XV`6020that`6020game.
  2491. XX`6020*/
  2492. XX
  2493. XXBoolean
  2494. XXjoinGame()
  2495. XX`607B
  2496. XX`6009Sockaddr`6009*duke,`6020*findDuke();
  2497. XX`6009Boolean`6009`6009join();
  2498. XX
  2499. XX`6009if`6020((dukeName`6020==`6020NULL)`6020`607C`607C
  2500. XX`6009`6020`6020`6020`6020(strlen(dukeName)`6020==`60200))`6020`607B
  2501. XX`6009`6009duke`6020=`6020findDuke();
  2502. XX`6009`6009if`6020(duke`6020!=`6020NULL)
  2503. XX`6009`6009`6009bcopy((char`6020*)`6020duke,`6020(char`6020*)`6020`6026dukeAdd
  2504. Vr,
  2505. XX`6009`6009`6009`6009sizeof(Sockaddr));
  2506. XX`6009`6009else
  2507. XX`6009`6009`6009return`6020FALSE;
  2508. XX`6009`607D`6020else
  2509. XX`6009`6009dukeAddr.sin_port`6020=`6020M.mazePort;
  2510. XX`6009return`6020join(dukeAddr);
  2511. XX`607D
  2512. XX
  2513. XX/*`6020
  2514. XX`6020*`6020No`6020game`6020to`6020join;`6020set`6020ourselves`6020up`6020as
  2515. V`6020duke`6020and`6020wait
  2516. XV`6020for`6020others`6020to`6020join.
  2517. XX`6020*/
  2518. XX
  2519. XXstartGame()
  2520. XX`607B
  2521. XX`6009RatId`6009i;
  2522. XX`6009RatInfo`6009`6009rsp;
  2523. XX
  2524. XX`6009printf("starting`6020a`6020new`6020game");
  2525. XX`6009M.myRatId`6020=`60200;
  2526. XX`6009M.score`6020=`60200;
  2527. XX`6009SetMyRatId(0);
  2528. XX`6009M.ratcb.dukeRat`6020=`6020M.myRatId;
  2529. XX`6009M.ratcb.rats`605BM.myRatId`605D.addr`6020=`6020M.myAddr;
  2530. XX`6009rsp`6020=`6020`6026M.ratcb.rats`605BM.myRatId`605D;
  2531. XX`6009rsp->playing`6020=`6020TRUE;
  2532. XX`6009rsp->xLoc`6020=`6020M.xloc;
  2533. XX`6009rsp->yLoc`6020=`6020M.yloc;
  2534. XX`6009rsp->dir`6020=`6020M.dir;
  2535. XX`6009rsp->score`6020=`6020M.score;
  2536. XX`6009rsp->addr`6020=`6020M.myAddr;
  2537. XX`6009strncpy(rsp->name,`6020ratName,`6020NAMESIZE);
  2538. XX`6009for`6020(i`6020=`60201;`6020i`6020<`6020MAXRATS;`6020i++)
  2539. XX`6009`6009M.ratcb.rats`605Bi`605D.playing`6020=`6020FALSE;
  2540. XX`6009M.duke`6020=`6020TRUE;
  2541. XX`607D
  2542. XX
  2543. XX/*`6020
  2544. XX`6020*`6020Join`6020an`6020existing`6020game.`6020Send`6020a`6020RAT_NEW`6020
  2545. Vpacket`6020and`6020wait
  2546. XV`6020for`6020a
  2547. XX`6020*`6020RAT_STATUS`6020packet`6020to`6020come`6020back`6020with`6020the
  2548. V`6020other`6020players.
  2549. XV`6020
  2550. XX`6020*/
  2551. XX
  2552. XXBoolean
  2553. XXjoin(addr)
  2554. XXSockaddr`6020addr;
  2555. XX`607B
  2556. XX`6009RatPacket`6009b,`6020r;
  2557. XX`6009RatNew`6009`6009ratNew;
  2558. XX`6009RatId`6009`6009id;
  2559. XX`6009RatStatus`6009status;
  2560. XX`6009int`6009`6009i,`6020ret;
  2561. XX`6009fd_set`6009`6009fds;
  2562. XX`6009struct`6020timeval`6009timeout;
  2563. XX`6009Boolean`6009`6009retVal`6020=`6020FALSE;
  2564. XX`6009
  2565. XX`6009b.type`6020=`6020RAT_NEW;
  2566. XX`6009ratNew`6020=`6020(RatNew)`6020`6026b.body;
  2567. XX`6009ratNew->pass`6020=`6020RAT_PASSWORD;
  2568. XX`6009ratNew->xLoc`6020=`6020M.xloc;
  2569. XX`6009ratNew->yLoc`6020=`6020M.yloc;
  2570. XX`6009ratNew->dir`6020=`6020M.dir;
  2571. XX`6009ratNew->addr`6020=`6020M.myAddr;
  2572. XX`6009strncpy(ratNew->name,`6020ratName,`6020NAMESIZE);
  2573. XX`6009free(ratName);
  2574. XX`6009ConvertOutgoing(`6026b);
  2575. XX
  2576. XX`6009for`6020(i`6020=`60200;`6020i`6020<`60205;`6020i++)`6020`607B
  2577. XX`6009`6009int`6020fromlen;
  2578. XX`6009`6009struct`6020sockaddr`6020from;
  2579. XX
  2580. XX`6009`6009if`6020(sendto(M.theSocket,`6020(char`6020*)`6020`6026b,`6020sizeof
  2581. V(b),`60200,`6020`6026ad
  2582. XVdr,
  2583. XX`6009`6009`6009`6020`6020`6020sizeof(addr))`6020<`60200)
  2584. XX`6009`6009`6009MWError("join`6020sendto");
  2585. XX`6009`6009FD_ZERO`6020(`6026fds);
  2586. XX`6009`6009FD_SET`6020(M.theSocket,`6020`6026fds);
  2587. XX`6009`6009timeout.tv_sec`6020=`60205;
  2588. XX`6009`6009timeout.tv_usec`6020=`60200;
  2589. XX`6009`6009ret`6020=`6020select(FD_SETSIZE,`6020`6026fds,`6020NULL,`6020NULL,
  2590. V`6020`6026timeout);
  2591. XX`6009`6009if`6020(ret`6020<`60200)
  2592. XX`6009`6009`6009MWError("join`6020select");
  2593. XX`6009`6009if`6020(ret`6020==`60200)
  2594. XX`6009`6009`6009continue;
  2595. XX`6009`6009if`6020(recvfrom(M.theSocket,`6020(char`6020*)`6020`6026r,`6020size
  2596. Vof(r),
  2597. XX`6009`6009`6009`60090,`6020`6026from,`6020`6026fromlen)`6020<`60200)
  2598. XX`6009`6009`6009MWError("join`6020status`6020receive");
  2599. XX`6009`6009ConvertIncoming(`6026r);
  2600. XX`6009`6009if`6020(r.type`6020!=`6020RAT_STATUS)
  2601. XX`6009`6009`6009continue;
  2602. XX
  2603. XX`6009`6009/*`6020see`6020if`6020I`6020got`6020into`6020the`6020game`6020*/
  2604. XX`6009`6009status`6020=`6020`6026r.body;
  2605. XX`6009`6009for`6020(id`6020=`60200;`6020id`6020<`6020MAXRATS;`6020id++)
  2606. XX`6009`6009`6009if`6020(status->rats`605Bid`605D.playing`6020`6026`6026
  2607. XX`6009`6009`6009`6020`6020`6020`6020!bcmp(`6026status->rats`605Bid`605D.addr,
  2608. V`6020`6026M.myAddr,
  2609. XX`6009`6009`6009`6009`6020`6020sizeof(M.myAddr)))`6020`607B
  2610. XX`6009`6009`6009`6009M.myRatId`6020=`6020id;
  2611. XX`6009`6009`6009`6009break;
  2612. XX`6009`6009`6009`607D
  2613. XX
  2614. XX`6009`6009/*`6020
  2615. XX`6009`6009`6020*`6020Didn't`6020find`6020me;`6020this`6020guy`6020must`6020no
  2616. Vt`6020really`6020be`6020the
  2617. XV
  2618. XX`6009`6009`6020*`6020duke.`6020Contact`6020the`6020duke`6020of`6020the`6020ga
  2619. Vme`6020and`6020get`6020adde
  2620. XVd.
  2621. XX`6009`6009`6020*/
  2622. XX
  2623. XX`6009`6009if`6020(id`6020==`6020MAXRATS)`6020`607B
  2624. XX`6009`6009`6009addr`6020=`6020status->rats`605Bstatus->dukeRat`605D.addr;
  2625. XX`6009`6009`6009continue;
  2626. XX`6009`6009`607D
  2627. XX`6009`6009
  2628. XX`6009`6009bcopy((char`6020*)`6020status,`6020(char`6020*)`6020`6026M.ratcb,
  2629. V`6020sizeof(RatCb));
  2630. XX`6009`6009retVal`6020=`6020TRUE;
  2631. XX`6009`6009break;
  2632. XX`6009`607D
  2633. XX`6009return`6020retVal;
  2634. XX`607D
  2635. XX
  2636. XX/*`6020
  2637. XX`6020*`6020Find`6020a`6020"duke"`6020host.`6020Broadcast`6020a`6020RAT_SURVEY
  2638. V`6020packet`6020to
  2639. XV`6020MAZEPORT.
  2640. XX`6020*
  2641. XX`6020*`6020The`6020broadcast`6020is`6020done`6020just`6020on`6020the`6020netw
  2642. Vork`6020that`6020is`6020a
  2643. XVssociated
  2644. XX`6020*`6020with`6020the`6020name`6020returned`6020by`6020gethostname();`6020f
  2645. Vor`6020most`6020works
  2646. XVtations
  2647. XX`6020*`6020this`6020is`6020accurate,`6020but`6020multi-homed`6020hosts`6020ma
  2648. Vy`6020miss`6020some
  2649. XV`6020games.`6020Oh
  2650. XX`6020*`6020well.
  2651. XX`6020*
  2652. XX`6020*`6020After`6020the`6020broadcast,`6020collect`6020responses.`6020This
  2653. V`6020goes`6020on`6020un
  2654. XVtil`6020no`6020packets
  2655. XX`6020*`6020have`6020been`6020received`6020for`60205`6020seconds`6020or`6020th
  2656. Ve`6020max`6020number
  2657. XV`6020have`6020been`6020seen
  2658. XX`6020*
  2659. XX`6020*`6020All`6020players`6020are`6020supposed`6020to`6020respond.`6020If
  2660. V`6020a`6020packet`6020come
  2661. XVs`6020from`6020a`6020non-duke,
  2662. XX`6020*`6020the`6020information`6020is`6020inspected`6020to`6020send`6020a`602
  2663. V0RAT_SURVEY`6020direc
  2664. XVtly`6020to`6020him.
  2665. XX`6020*`6020Otherwise,`6020the`6020answer`6020is`6020saved.`6020When`6020all
  2666. V`6020the`6020answers
  2667. XV`6020are`6020in,`6020the
  2668. XX`6020*`6020first`6020game`6020with`6020an`6020empty`6020slot`6020is`6020chose
  2669. Vn.
  2670. XX`6020*
  2671. XX`6020*`6020If`6020all`6020players`6020were`6020listening`6020on`6020MAZEPORT,
  2672. V`6020we`6020could`6020p
  2673. XVrobably`6020do
  2674. XX`6020*`6020without`6020the`6020resending`6020nonsense.`6020Since`6020the`6020
  2675. Vduke`6020might`6020no
  2676. XVt`6020be`6020on
  2677. XX`6020*`6020MAZEPORT,`6020this`6020is`6020necessary.`6020It`6020also`6020adds
  2678. V`6020a`6020certain`6020r
  2679. XVobustness,`6020in
  2680. XX`6020*`6020case`6020the`6020duke`6020drops`6020the`6020packet`6020or`6020some
  2681. Vsuch.`6020Care`6020is
  2682. XV`6020taken`6020elsewhere
  2683. XX`6020*`6020(ratLeft()`6020and`6020ratDoctor())to`6020make`6020sure`6020there
  2684. V`6020are`6020always
  2685. XV`6020players
  2686. XX`6020*`6020listening`6020on`6020MAZEPORT.
  2687. XX`6020*/
  2688. XX
  2689. XXstruct`6020answer`6020`607B
  2690. XX`6009Sockaddr`6009source;
  2691. XX`6009int`6009`6009srclen;
  2692. XX`6009RatPacket`6009packet;
  2693. XX`607D;
  2694. XX
  2695. XXSockaddr`6020*
  2696. XXfindDuke()
  2697. XX`607B
  2698. XX#ifndef`6009NO_BROADCAST
  2699. XX`6009register`6020int`6009i;
  2700. XX`6009int`6009`6009cnt`6020=`60200;
  2701. XX`6009int`6009`6009maxAnswers`6020=`602010;
  2702. XX`6009static`6020Sockaddr`6009rmtAddr;
  2703. XX`6009struct`6009timeval`6009timeout;
  2704. XX`6009RatPacket`6009*b`6020=`6020(RatPacket`6020*)`6020malloc(sizeof(RatPacket
  2705. V));
  2706. XX`6009struct`6020answer`6009*answers;
  2707. XX`6009int`6009`6009fd`6020=`6020M.theSocket;
  2708. XX`6009fd_set`6020`6020`6020`6020`6020`6020`6020`6020`6020`6020fds;
  2709. XX`6009int`6009`6009ret,`6020cc;
  2710. XX`6009Boolean`6009`6009duke(),`6020freeSlot();
  2711. XX`6009u_long`6009`6009inet_makeaddr();
  2712. XX
  2713. XX`6009printf("Checking`6020out`6020available`6020games...");`6020fflush(stdout
  2714. V);
  2715. XX
  2716. XX#ifdef`6009SO_BROADCAST
  2717. XX#ifdef`6009BSD_43
  2718. XX`6009`607B
  2719. XX`6009int`6009one`6020=`60201;
  2720. XX
  2721. XX`6009if`6020(setsockopt(M.theSocket,`6020SOL_SOCKET,`6020SO_BROADCAST,`6020
  2722. XX`6009`6009`6009`6009`6026one,`6020sizeof`6020one)`6020<`60200)
  2723. XX`6009`6009MWError("can't`6020get`6020broadcast`6020permission");
  2724. XX`6009`607D
  2725. XX#else`6009BSD_43
  2726. XX`6009if`6020(setsockopt(M.theSocket,`6020SOL_SOCKET,`6020SO_BROADCAST,`6020NU
  2727. VLL,`60200)
  2728. XV`6020<`60200)
  2729. XX`6009`6009MWError("can't`6020get`6020broadcast`6020permission");
  2730. XX#endif`6009BSD_43
  2731. XX#endif`6009SO_BROADCAST
  2732. XX
  2733. XX`6009rmtAddr`6020=`6020M.myAddr;
  2734. XX`6009rmtAddr.sin_addr.s_addr`6020=`6020inet_makeaddr(inet_netof(M.myAddr.sin_
  2735. Vaddr),
  2736. XX`6009`6009`6009`6009`6009BROAD_ADDR);`6009/*`6020from`6020Makefile`6020*/
  2737. XX`6009rmtAddr.sin_port`6020=`6020M.mazePort;
  2738. XX
  2739. XX`6009answers`6020=`6020(struct`6020answer`6020*)
  2740. XX`6009`6009malloc((unsigned)`6020(maxAnswers`6020*`6020sizeof(*answers)));
  2741. XX
  2742. XX`6009setupSurvey(b);
  2743. XX`6009ConvertOutgoing(b);
  2744. XX`6009if`6020(sendto(fd,`6020(char`6020*)`6020b,`6020sizeof(*b),`60200,`6020
  2745. V`6026rmtAddr,`6020sizeo
  2746. XVf(rmtAddr))`6020<`60200)
  2747. XX`6009`6009fprintf(stderr,`6020"findDuke`6020survey`6020can't`6020broadcast
  2748. V`605Cn");
  2749. XX
  2750. XX`6009while`6020(1)`6020`607B
  2751. XX`6020`6020`6009`6020`6020`6020`6020`6020`6020`6020`6020FD_ZERO`6020(`6026fds)
  2752. V;
  2753. XX`6009`6009FD_SET`6020(fd,`6020`6026fds);
  2754. XX`6009`6009timeout.tv_sec`6020=`60205;
  2755. XX`6009`6009timeout.tv_usec`6020=`60200;
  2756. XX`6009`6009ret`6020=`6020select(FD_SETSIZE,`6020`6026fds,`6020NULL,`6020NULL,
  2757. V`6020`6026timeout);
  2758. XX`6009`6009if`6020(ret`6020<`60200)
  2759. XX`6009`6009`6009MWError("findDuke`6020select");
  2760. XX`6009`6009if`6020(ret`6020==`60200)
  2761. XX`6009`6009`6009break;
  2762. XX`6009`6009answers`605Bcnt`605D.srclen`6020=`6020sizeof(Sockaddr);
  2763. XX`6009`6009if`6020(recvfrom(fd,`6020`6026answers`605Bcnt`605D.packet,`6020size
  2764. Vof(RatPacket),
  2765. XV`60200,
  2766. XX`6009`6009`6009`6020`6020`6020`6020`6020`6026answers`605Bcnt`605D.source,`602
  2767. V0`6026answers`605Bcnt`605D.srcl
  2768. XVen)`6020<`60200)
  2769. XX`6009`6009`6009MWError("findDuke`6020recv");
  2770. XX`6009`6009ConvertIncoming(`6026answers`605Bcnt`605D.packet);
  2771. XX`6009`6009if`6020(answers`605Bcnt`605D.packet.type`6020!=`6020RAT_STATUS)
  2772. XX`6009`6009`6009continue;
  2773. XX`6009`6009if`6020(!duke(`6026answers`605Bcnt`605D))`6020`607B
  2774. XX`6009`6009`6009RatStatus`6009rs;
  2775. XX
  2776. XX`6009`6009`6009rs`6020=`6020(RatStatus)`6020`6026answers`605Bcnt`605D.packet.
  2777. Vbody;
  2778. XX`6009`6009`6009setupSurvey(b);
  2779. XX`6009`6009`6009ConvertOutgoing(b);
  2780. XX`6009`6009`6009if`6020(sendto(fd,`6020b,`6020sizeof(*b),`60200,
  2781. XX`6009`6009`6009`6009`6020`6020`6020`6026rs->rats`605Brs->dukeRat`605D.addr,
  2782. XX`6009`6009`6009`6009`6020`6020`6020sizeof(rs->rats`605Brs->dukeRat`605D.addr)
  2783. V)`6020<`60200)
  2784. XX`6009`6009`6009`6009fprintf(stderr,`6020
  2785. XX`6009`6009`6009`6009`6009"findDuke`6020resend`6020can't`6020broadcast");
  2786. XX`6009`6009`6009continue;
  2787. XX`6009`6009`607D
  2788. XX`6009`6009if`6020(freeSlot(`6026answers`605Bcnt`605D))
  2789. XX`6009`6009`6009if`6020(++cnt`6020==`6020maxAnswers)
  2790. XX`6009`6009`6009`6009break;
  2791. XX`6009`607D
  2792. XX
  2793. XX`6009for`6020(i`6020=`60200;`6020i`6020<`6020cnt;`6020i++)
  2794. XX`6009`6009if`6020(duke(`6026answers`605Bi`605D))`6020`607B
  2795. XX`6009`6009`6009rmtAddr`6020=`6020answers`605Bi`605D.source;
  2796. XX`6009`6009`6009break;
  2797. XX`6009`6009`607D
  2798. XX`6009free((char`6020*)`6020answers);
  2799. XX`6009free((char`6020*)`6020b);
  2800. XX`6009if`6020(i`6020==`6020cnt)
  2801. XX`6009`6009return`6020(Sockaddr`6020*)`6020NULL;
  2802. XX`6009else
  2803. XX`6009`6009return`6020`6026rmtAddr;
  2804. XX#else`6009NO_BROADCAST
  2805. XX`6009return`6020(Sockaddr`6020*)`6020NULL;
  2806. XX#endif`6009NO_BROADCAST
  2807. XX`607D
  2808. XX
  2809. XX/*`6020
  2810. XX`6020*`6020See`6020if`6020the`6020game`6020contains`6020any`6020empty`6020slo
  2811. Vts`6020for`6020players.
  2812. XV
  2813. XX`6020*/
  2814. XX
  2815. XXBoolean
  2816. XXfreeSlot(a)
  2817. XXstruct`6020answer`6009*a;
  2818. XX`607B
  2819. XX`6009RatStatus`6009test;
  2820. XX`6009RatId`6009`6009id;
  2821. XX
  2822. XX`6009test`6020=`6020(RatStatus)`6020`6026a->packet.body;
  2823. XX`6009for`6020(id`6020=`60200;`6020id`6020<`6020MAXRATS;`6020id++)
  2824. XX`6009`6009if`6020(!test->rats`605Bid`605D.playing)
  2825. XX`6009`6009`6009return`6020TRUE;
  2826. XX`6009return`6020FALSE;
  2827. XX`607D
  2828. XX
  2829. XX/*`6020
  2830. XX`6020*`6020Fill`6020in`6020the`6020RAT_SURVEY`6020packet.
  2831. XX`6020*/
  2832. XX
  2833. XXsetupSurvey(b)
  2834. XXRatPacket`6020*b;
  2835. XX`607B
  2836. XX`6009RatNew`6009ratSurvey;
  2837. XX
  2838. XX`6009b->type`6020=`6020RAT_SURVEY;
  2839. XX`6009ratSurvey`6020=`6020(RatNew)`6020`6026b->body;
  2840. XX`6009ratSurvey->pass`6020=`6020RAT_PASSWORD;
  2841. XX`607D
  2842. XX
  2843. XX/*`6020
  2844. XX`6020*`6020Check`6020if`6020this`6020guy's`6020the`6020duke`6020of`6020his
  2845. V`6020game.
  2846. XX`6020*/
  2847. XX
  2848. XXBoolean
  2849. XXduke(a)
  2850. XXstruct`6020answer`6009*a;
  2851. XX`607B
  2852. XX`6009RatStatus`6009test;
  2853. XX
  2854. XX`6009test`6020=`6020(RatStatus)`6020`6026a->packet.body;
  2855. XX`6009return`6020!bcmp((char`6020*)`6020`6026test->rats`605Btest->dukeRat`605D
  2856. V.addr.sin_addr,
  2857. XV
  2858. XX`6009`6009`6009(char`6020*)`6020`6026a->source.sin_addr,`6020sizeof(struct
  2859. V`6020in_addr));
  2860. XX`607D
  2861. XX
  2862. XX/*
  2863. XX`6020*`6020Resolve`6020the`6020specified`6020host`6020name`6020into`6020an
  2864. V`6020internet`6020addres
  2865. XVs.`6020`6020The`6020"name"`6020may
  2866. XX`6020*`6020be`6020either`6020a`6020character`6020string`6020name,`6020or`6020
  2867. Van`6020address`6020in
  2868. XV`6020the`6020form`6020a.b.c.d`6020where
  2869. XX`6020*`6020the`6020pieces`6020are`6020octal,`6020decimal,`6020or`6020hex`6020
  2870. Vnumbers.`6020`6020Retur
  2871. XVns`6020a`6020pointer`6020to`6020a
  2872. XX`6020*`6020sockaddr_in`6020struct`6020(note`6020this`6020structure`6020is`602
  2873. V0statically`6020all
  2874. XVocated`6020and`6020must
  2875. XX`6020*`6020be`6020copied),`6020or`6020NULL`6020if`6020the`6020name`6020is`602
  2876. V0unknown.
  2877. XX`6020*/
  2878. XX
  2879. XXSockaddr`6020*
  2880. XXresolveHost(name)
  2881. XXregister`6020char`6020*name;
  2882. XX`607B
  2883. XX`6009register`6020struct`6020hostent`6020*fhost;
  2884. XX`6009struct`6020in_addr`6020fadd;
  2885. XX`6009static`6020Sockaddr`6020sa;
  2886. XX
  2887. XX`6009if`6020((fhost`6020=`6020gethostbyname(name))`6020!=`6020NULL)`6020`607B
  2888. V
  2889. XX`6009`6009sa.sin_family`6020=`6020fhost->h_addrtype;
  2890. XX`6009`6009sa.sin_port`6020=`60200;
  2891. XX`6009`6009bcopy(fhost->h_addr,`6020`6026sa.sin_addr,`6020fhost->h_length);
  2892. XX`6009`607D`6020else`6020`607B
  2893. XX`6009`6009fadd.s_addr`6020=`6020inet_addr(name);
  2894. XX`6009`6009if`6020(fadd.s_addr`6020!=`6020-1)`6020`607B
  2895. XX`6009`6009`6009sa.sin_family`6020=`6020AF_INET;`6009/*`6020grot`6020*/
  2896. XX`6009`6009`6009sa.sin_port`6020=`60200;
  2897. XX`6009`6009`6009sa.sin_addr.s_addr`6020=`6020fadd.s_addr;
  2898. XX`6009`6009`607D`6020else
  2899. XX`6009`6009`6009return(NULL);
  2900. XX`6009`607D
  2901. XX`6009return(`6026sa);
  2902. XX`607D
  2903. X$`20call`20unpack`20INIT.C;9`201914317551`20""
  2904. X$!
  2905. X$`20create`20'f'
  2906. XX.TH`6020MAZEFIND`60206
  2907. XX.SH`6020NAME
  2908. XXmazefind`6020`605C-`6020discover`6020current`6020MazeWar`6020games
  2909. XX.SH`6020SYNTAX
  2910. XX.B`6020/usr/games/mazefind
  2911. XX.SH`6020DESCRIPTION
  2912. XX.I`6020Mazefind
  2913. XXbroadcasts`6020a`6020query`6020on`6020the`6020net`6020to`6020discover`6020wha
  2914. +-+-+-+-+-+-+-+-  END  OF PART 2 +-+-+-+-+-+-+-+-
  2915.