home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / vmsnet / sources / games / 456 < prev    next >
Encoding:
Text File  |  1992-11-20  |  14.3 KB  |  557 lines

  1. Newsgroups: vmsnet.sources.games
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!news.u.washington.edu!raven.alaska.edu!acad2.alaska.edu!asdmf
  3. From: asdmf@acad2.alaska.edu
  4. Subject: Vmsnetrek 44/47
  5. Message-ID: <1992Nov20.210435.1@acad2.alaska.edu>
  6. Lines: 545
  7. Sender: news@raven.alaska.edu (USENET News System)
  8. Nntp-Posting-Host: acad2.alaska.edu
  9. Organization: University of Alaska
  10. Date: Sat, 21 Nov 1992 01:04:35 GMT
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 44 -+-+-+-+-+-+-+-+
  13. X`009    strcat(buf, "simple UDP"); break;
  14. X`009case MODE_FAT:
  15. X`009    strcat(buf, "fat UDP"); break;
  16. X#ifdef DOUBLE_UDP
  17. X`009case MODE_DOUBLE:
  18. X`009    strcat(buf, "double UDP"); break;
  19. X#endif
  20. X`009`125
  21. X`009break;
  22. X    case UDP_FORCE_RESET:
  23. X`009sprintf(buf, "Force reset to TCP");
  24. X`009break;
  25. X    case UDP_UPDATE_ALL:
  26. X`009sprintf(buf, "Request full update (=)");
  27. X`009break;
  28. X    case UDP_DONE:
  29. X`009strcpy(buf, "Done");
  30. X`009break;
  31. X#ifdef GATEWAY
  32. X    case UDP_GW:
  33. X`009sprintf(buf, "gw: %s %d/%d/%d", gw_mach, gw_serv_port, gw_port,
  34. X`009`009gw_local_port);
  35. X`009break;
  36. X#endif
  37. X    default:
  38. X`009fprintf(stderr, "netrek: UDP error: bad udprefresh(%d) call\n", i);
  39. X    `125
  40. X
  41. X    W_WriteText(udpWin, 0, i, textColor, buf, strlen(buf), 0);
  42. X`125
  43. X
  44. Xudpaction(data)
  45. XW_Event *data;
  46. X`123
  47. X    int i;
  48. X
  49. X    switch (data->y) `123
  50. X    case UDP_CURRENT:
  51. X`009if (commMode == COMM_TCP)
  52. X`009    sendUdpReq(COMM_UDP);
  53. X`009else
  54. X`009    sendUdpReq(COMM_TCP);
  55. X`009break;
  56. X    case UDP_STATUS:
  57. X    case UDP_DROPPED:
  58. X`009W_Beep();
  59. X`009break;
  60. X    case UDP_SEQUENCE:
  61. X`009udpSequenceChk = !udpSequenceChk;
  62. X`009udprefresh(UDP_SEQUENCE);
  63. X`009break;
  64. X    case UDP_SEND:
  65. X`009udpClientSend++;
  66. X`009if (udpClientSend > 3) udpClientSend = 0;
  67. X`009udprefresh(UDP_SEND);
  68. X`009break;
  69. X    case UDP_RECV:
  70. X`009udpClientRecv++;
  71. X#ifdef DOUBLE_UDP
  72. X`009if (udpClientRecv > MODE_DOUBLE) udpClientRecv = 0;
  73. X#else
  74. X`009if (udpClientRecv >= MODE_DOUBLE) udpClientRecv = 0;
  75. X#endif
  76. X`009udprefresh(UDP_RECV);
  77. X`009sendUdpReq(COMM_MODE + udpClientRecv);
  78. X`009break;
  79. X    case UDP_DEBUG:
  80. X`009udpDebug++;
  81. X`009if (udpDebug > 2) udpDebug = 0;
  82. X`009udprefresh(UDP_DEBUG);
  83. X`009break;
  84. X    case UDP_FORCE_RESET:
  85. X`009/* clobber UDP */
  86. X`009UDPDIAG(("*** FORCE RESET REQUESTED\n"));
  87. X`009sendUdpReq(COMM_TCP);
  88. X`009commMode = commModeReq = COMM_TCP;
  89. X`009commStatus = STAT_CONNECTED;
  90. X`009commSwitchTimeout = 0;
  91. X`009udpClientSend = udpClientRecv = udpSequenceChk = udpTotal = 1;
  92. X`009udpDebug = udpDropped = udpRecentDropped = 0;
  93. X`009if (udpSock >= 0)
  94. X`009    closeUdpConn(udpSock);
  95. X`009for (i=0; i<UDP_NUMOPTS; i++)
  96. X`009    udprefresh(i);
  97. X`009break;
  98. X    case UDP_UPDATE_ALL:
  99. X`009sendUdpReq(COMM_UPDATE);
  100. X`009break;
  101. X    case UDP_DONE:
  102. X`009udpdone();
  103. X`009break;
  104. X#ifdef GATEWAY
  105. X    case UDP_GW:
  106. X`009W_Beep();
  107. X`009break;
  108. X#endif
  109. X    `125
  110. X`125
  111. X
  112. Xudpdone()
  113. X`123
  114. X    /* Unmap window */
  115. X    W_UnmapWindow(udpWin);
  116. X`125
  117. X
  118. $ CALL UNPACK UDPOPT.C;1 658975029
  119. $ create/nolog 'f'
  120. X/*
  121. X * util.c
  122. X */
  123. X#include "copyright.h"
  124. X
  125. X#include <stdio.h>
  126. X#include <math.h>
  127. X#include <signal.h>
  128. X#include "Wlib.h"
  129. X#include "defs.h"
  130. X#include "struct.h"
  131. X#include "data.h"
  132. X
  133. X/*
  134. X** Provide the angular distance between two angles.
  135. X*/
  136. Xangdist(x, y)
  137. Xunsigned char x, y;
  138. X`123
  139. X    register unsigned char res;
  140. X
  141. X    if (x>y) res=x-y;
  142. X    else res=y-x;
  143. X    if (res > 128)
  144. X`009return(256 - (int) res);
  145. X    return((int) res);
  146. X`125
  147. X
  148. X/*
  149. X** Find the object nearest mouse.  Returns a pointer to an
  150. X** obtype structure.  This is used for info and locking on.
  151. X**
  152. X** Because we are never interested in it, this function will
  153. X** never return your own ship as the target.
  154. X**
  155. X** Finally, this only works on the two main windows
  156. X*/
  157. X
  158. Xstatic struct obtype _target;
  159. X
  160. Xstruct obtype *
  161. Xgettarget(ww, x, y, targtype)
  162. XW_Window ww;
  163. Xint x, y;
  164. Xint targtype;
  165. X`123
  166. X    register int i;
  167. X    register struct player *j;
  168. X    register struct planet *k;
  169. X    int`009g_x, g_y;
  170. X    double dist, closedist;
  171. X
  172. X    if (ww == mapw) `123
  173. X`009g_x = x * GWIDTH / WINSIDE;
  174. X`009g_y = y * GWIDTH / WINSIDE;
  175. X    `125
  176. X    else `123
  177. X`009g_x = me->p_x + ((x - WINSIDE/2) * SCALE);
  178. X`009g_y = me->p_y + ((y - WINSIDE/2) * SCALE);
  179. X    `125
  180. X    closedist = GWIDTH;
  181. X
  182. X    if (targtype & TARG_PLANET) `123
  183. X`009for (i = 0, k = &planets`091i`093; i < MAXPLANETS; i++, k++) `123
  184. X`009    dist = hypot((double) (g_x - k->pl_x), (double) (g_y - k->pl_y));
  185. X`009    if (dist < closedist) `123
  186. X`009`009_target.o_type = PLANETTYPE;
  187. X`009`009_target.o_num = i;
  188. X`009`009closedist = dist;
  189. X`009    `125
  190. X
  191. X`009`125
  192. X    `125
  193. X
  194. X    if (targtype & TARG_PLAYER) `123
  195. X`009for (i = 0, j = &players`091i`093; i < MAXPLAYER; i++, j++) `123
  196. X`009    if (j->p_status != PALIVE)
  197. X`009`009continue;
  198. X`009    if ((j->p_flags & PFCLOAK) && (!(targtype & TARG_CLOAK)))
  199. X`009`009continue;
  200. X`009    if (j == me && !(targtype & TARG_SELF))
  201. X`009`009continue;
  202. X`009    dist = hypot((double) (g_x - j->p_x), (double) (g_y - j->p_y));
  203. X`009    if (dist < closedist) `123
  204. X`009`009_target.o_type = PLAYERTYPE;
  205. X`009`009_target.o_num = i;
  206. X`009`009closedist = dist;
  207. X`009    `125
  208. X`009`125
  209. X    `125
  210. X
  211. X    if (closedist == GWIDTH) `123`009`009/* Didn't get one.  bad news */
  212. X`009_target.o_type = PLAYERTYPE;
  213. X`009_target.o_num = me->p_no;`009/* Return myself.  Oh well... */
  214. X`009return(&_target);
  215. X    `125
  216. X    else `123
  217. X`009return(&_target);
  218. X    `125
  219. X`125
  220. X
  221. X#ifdef hpux
  222. X
  223. Xsrandom(foo)
  224. Xint foo;
  225. X`123
  226. X    rand(foo);
  227. X`125
  228. X
  229. Xrandom()
  230. X`123
  231. X    return(rand());
  232. X`125
  233. X
  234. X#include <time.h>
  235. X#include <sys/resource.h>
  236. X
  237. Xgetrusage(foo, buf)
  238. Xint foo;
  239. Xstruct rusage *buf;
  240. X`123
  241. X    buf->ru_utime.tv_sec = 0;
  242. X    buf->ru_stime.tv_sec = 0;
  243. X`125
  244. X
  245. X#include <sys/signal.h>
  246. X
  247. Xint (*
  248. Xsignal(sig, funct))()
  249. Xint sig;
  250. Xint (*funct)();
  251. X`123
  252. X    struct sigvec vec, oldvec;
  253. X
  254. X    sigvector(sig, 0, &vec);
  255. X    vec.sv_handler = funct;
  256. X    sigvector(sig, &vec, (struct sigvec *) 0);
  257. X`125
  258. X#endif /*hpux*/
  259. $ CALL UNPACK UTIL.C;1 1781591964
  260. $ create/nolog 'f'
  261. X#include "vmsutils.h"
  262. X
  263. X#include <stdio.h>
  264. X#include <ssdef.h>
  265. X#include <jpidef.h>
  266. X
  267. Xtypedef struct itmlst_str `123
  268. X  short buffer_length;
  269. X  short item_code;
  270. X  long buffer_address;
  271. X  long retlen_address;
  272. X`125 Itmlst;
  273. X
  274. Xlong random(void) `123
  275. X  long rand();
  276. X  return (rand());
  277. X`125
  278. X
  279. Xint fork(void) `123
  280. X  int vfork();
  281. X  return (vfork());
  282. X`125
  283. X
  284. Xvoid srandom(int seed) `123
  285. X  srand(seed);
  286. X`125
  287. X
  288. Xchar *crypt(char *cryptstr, char *key) `123
  289. X  return (cryptstr);                         /* not really crypted */
  290. X`125
  291. X
  292. Xbcopy(char *from_str, char *to_str, int length) `123
  293. X  int i;
  294. X  for (i=0; i<length; i++)
  295. X    to_str`091i`093 = from_str`091i`093;
  296. X`125
  297. X
  298. Xbzero( char *str, int length) `123
  299. X  int i;
  300. X  for (i=0; i<length; i++)`032
  301. X    str`091i`093 = '\0';
  302. X`125
  303. X
  304. Xchar *index(char *str, char c) `123
  305. X  while (*str != '\0') `123
  306. X    if (*str == c)
  307. X      return (str);
  308. X    else`032
  309. X      str++;
  310. X  `125
  311. X  return ((char *) 0);
  312. X`125
  313. X
  314. Xchar *rindex(char *str, char c) `123
  315. X  char *firstc = str;
  316. X
  317. X  str += strlen(str);       /* go to the end of the string  */
  318. X  while (str >= str) `123      /* while not over the beginning */
  319. X    if (*str == c)         `032
  320. X      return (str);
  321. X    else`032
  322. X      str--;
  323. X  `125
  324. X  return ((char *) 0);
  325. X`125
  326. X
  327. Xint bcmp(char *b1, char *b2, int length) `123
  328. X  int i;
  329. X
  330. X  for (i=0; i<length; i++) `123
  331. X    if (b1`091i`093 != b2`091i`093)
  332. X      return (-1);  /* strings aren't alike */
  333. X  `125
  334. X  return (0);   /* strings are alike */
  335. X`125
  336. X
  337. Xstruct passwd *getpwuid(int not_used) `123
  338. X  struct passwd *passwd= (struct passwd *) malloc(sizeof(struct passwd));
  339. X  short retlen;
  340. X  char *cptr  = malloc(20*sizeof(char));
  341. X  Itmlst itmlst = `12319, JPI$_USERNAME, (long)cptr, (long)&retlen`125;
  342. X
  343. X  passwd->pw_name = cptr;
  344. X
  345. X  if (!(sys$getjpiw(NULL, NULL, NULL, &itmlst, NULL, NULL, NULL) & 0x1)) `12
  346. V3
  347. X    passwd->pw_name`091retlen`093 = '\0';
  348. X    while (*cptr) `123          /* find first whitespace and terminate there
  349. V */
  350. X      if (*cptr == ' ') `123
  351. X`009*cptr = '\0';`032
  352. X      `125
  353. X      cptr++;
  354. X    `125
  355. X    return (passwd);
  356. X  `125 else `123
  357. X    strcpy(passwd->pw_name, "VMS-nousername");
  358. X    return (NULL);
  359. X  `125
  360. X`125
  361. $ CALL UNPACK VMSUTILS.C;1 1431268095
  362. $ create/nolog 'f'
  363. X#ifndef VMSUTILS_H
  364. X#define VMSUTILS_H
  365. X
  366. Xstruct passwd `123
  367. X  char *pw_name;
  368. X`125;
  369. X
  370. X#ifdef NOT
  371. Xtypedef long fd_set;
  372. X
  373. X#define FD_ZERO(fdl)         ((*fdl)=0L)
  374. X#define FD_SET(fd, fdl)     ((*fdl) `124= (1<<(fd)))
  375. X#define FD_ISSET(fd, fdl)   ((*fdl) & (1<<(fd)))
  376. X#endif`032
  377. X
  378. X#endif VMSUTILS_H
  379. X
  380. $ CALL UNPACK VMSUTILS.H;1 308030016
  381. $ create/nolog 'f'
  382. XUDP version of VMSnetrek (beta):
  383. X
  384. XWhy UDP?
  385. X`009Well, using the User Datagram Protocol allows us to bypass some of TCPs
  386. X(Transport Control Protocol) more file-transfer friendly features.  For
  387. Xexample, using tcp if an error occurs in the tranmission of a update packet
  388. Xbeing sent to you, all updates are held up until the lost update times out a
  389. Vnd
  390. Xis retransmitted.  Of course, while this retranmission is going on you have`
  391. V032
  392. Xbeen destroyed by your enemy.  The UDP protocol does not check for lost`032
  393. Xpackets and thus you are free to ignore the one lost packet and use the newe
  394. Vr
  395. Xones.  For more info about UDP and real time tranmission, see a real time te
  396. Vxt
  397. Xor Unix Network Programming (Stevens).
  398. X
  399. XTo compile, at the prompt type:
  400. X
  401. X`009$ mms defines   ! to build logicals for include files
  402. X`009$ mms libs      ! to build x11 libraries
  403. X`009$ mms           ! to compile VMSnetrek.exe
  404. X
  405. Xto compile the source, you must have DECwindows/Motif installed, have the X-
  406. Vwindow`032
  407. Xheader files, have UCX and its header files, and have mms.  The code may com
  408. Vpile
  409. Xwith another IP package; however, it has not been tried by me.  If you do no
  410. Vt have
  411. Xthe mms package, you may be able to use gnu make to compile; otherwise you w
  412. Vill
  413. Xhave to build it by hand.  The source was compiled by the VAX C compiler ver
  414. Vsion`032
  415. X3.1.  If you have any problems or if you make changes, please notify me.
  416. X
  417. Xto run, at the prompt type:
  418. X`009
  419. X`009$ set display /create /node=yourXnodename /screen=0 /trans=tcpip
  420. X`009$ VMSnetrek == "$''f$environment("DEFAULT")'VMSnetrek.exe"
  421. X`009$ VMSnetrek`032
  422. X
  423. Xalternatively, you can run the setup file :
  424. X
  425. X`009$ @setup <nodename>        !fill in the X window display server for <nod
  426. Vename>
  427. X
  428. XThis will connect you to bigmax.ulowell.edu.  If the bigmax server is not`03
  429. V2
  430. Xrunning or if no one is logged on, then use another server.
  431. X
  432. X`009$ VMSnetrek -h 128.103.25.59 -p 2592  ! connect to harvard server
  433. X`009$ VMSnetrek -h bigmax.ulowell.edu -p 2592  ! connect to ulowell server
  434. X
  435. XThe display argument is ignored by the VMSnetrek client.  You need to set th
  436. Ve display
  437. Xusing the "set display" command above.
  438. X
  439. XFor more information on servers read the rec.games.netrek news group.  There
  440. V`032
  441. Xis a list of servers and what they run.  A list of current servers is includ
  442. Ved
  443. Xwith this distibution.
  444. X
  445. XThis client is NOT BLESSED.  This means that you cannot log in to a "bronco"
  446. Xserver that requires blessed binaries.  I am working on getting the client`0
  447. V32
  448. Xblessed, but I need to find someone with reserved.c who can use a vms machin
  449. Ve.
  450. XIf you know of such a person please send me mail!
  451. X
  452. XYou should be able to play on bigmax all the time (we don't have reserved.c)
  453. Xand you will be able to play on harvard every other day (when borgs are`032
  454. Xallowed).
  455. X
  456. XPorting info:
  457. X
  458. X`009o most problems were caused by name collisions with VMS or
  459. X`009  function/data types unavalible in VMS
  460. X`009o all changed code should be surrounded by "#ifdef VMS"
  461. X
  462. Xserver code:`032
  463. X`009
  464. X`009o I have ported all the server code.  Unfortunately, there remains a`032
  465. X`009  problem running the ntserver on a VMS system.  Because VMS does not`03
  466. V2
  467. X`009  pass it's file descriptors (except a pipe implemented as a mailbox)`03
  468. V2
  469. X`009  to child programs like a unix system would after a fork/exec I cannot
  470. X`009  make a startd.  It is possible that UCX 2.0 will have a inetd
  471. X`009  which will do this work for us... for those with access to it.
  472. X`009  Until then, I don't think we will be able to run the server`032
  473. X`009  on a VMS system without major chages which will then not be`032
  474. X`009  compatible with the current unix versions.
  475. X`009  However, if you want to run the server, ask me for the code and
  476. X`009  I will mail it to you.  It will work if you run the ntserver
  477. X`009  first (specifying a socket number) and then connect using the`032
  478. X`009  client.
  479. X
  480. XJohn 'MacGyver' Richardson `124"sun dogs fire on the horizon        \ \   \
  481. Xjrichard@cs.ulowell.edu    `124 meteor rain stars across the night   * *   \
  482. V   /\
  483. Xjrichard@duck.ulowell.edu  `124 ...the spark still flies                /\
  484. V  * /  \
  485. X                           `124 reflected in another pair of eyes." /\ /  \/
  486. V\/
  487. X                                                           ------  \   / /`0
  488. V32
  489. X
  490. X
  491. X
  492. $ CALL UNPACK VMS_README.TXT_4;1 1514079118
  493. $ create/nolog 'f'
  494. X/*
  495. X * war.c
  496. X */
  497. X#include "copyright.h"
  498. X
  499. X#include <stdio.h>
  500. X#include <math.h>
  501. X#include <signal.h>
  502. X#include "Wlib.h"
  503. X#include "defs.h"
  504. X#include "struct.h"
  505. X#include "data.h"
  506. X#include "packets.h"
  507. X
  508. Xstatic int newhostile;
  509. X
  510. X/* Set up the war window and map it */
  511. Xstatic char *feds = "FED - ";
  512. Xstatic char *roms = "ROM - ";
  513. Xstatic char *klis = "KLI - ";
  514. Xstatic char *oris = "ORI - ";
  515. Xstatic char *gos = "  Re-program";
  516. Xstatic char *exs = "  Exit - no change";
  517. Xstatic char *peaces = "Peace";
  518. Xstatic char *hostiles = "Hostile";
  519. Xstatic char *wars = "War";
  520. X
  521. Xwarwindow()
  522. X`123
  523. X    W_MapWindow(war);
  524. X    newhostile = me->p_hostile;
  525. X    warrefresh();
  526. X`125
  527. X
  528. Xwarrefresh()
  529. X`123
  530. X    fillwin(0, feds, newhostile, me->p_swar, FED);
  531. X    fillwin(1, roms, newhostile, me->p_swar, ROM);
  532. X    fillwin(2, klis, newhostile, me->p_swar, KLI);
  533. X    fillwin(3, oris, newhostile, me->p_swar, ORI);
  534. X    W_WriteText(war, 0, 4, textColor, gos, strlen(gos), 0);
  535. X    W_WriteText(war, 0, 5, textColor, exs, strlen(exs), 0);
  536. X`125
  537. X
  538. Xfillwin(menunum, string, hostile, warbits, team)
  539. Xint menunum;
  540. Xchar *string;
  541. Xint hostile, warbits;
  542. Xint team;
  543. X`123
  544. X    char buf`09180`093;
  545. X
  546. X    if (team & warbits) `123
  547. X`009(void) sprintf(buf, "  %s%s", string, wars);
  548. X`009W_WriteText(war, 0, menunum, rColor, buf, strlen(buf), 0);
  549. X    `125
  550. X    else if (team & hostile) `123
  551. X`009(void) sprintf(buf, "  %s%s", string, hostiles);
  552. X`009W_WriteText(war, 0, menunum, yColor, buf, strlen(buf), 0);
  553. X    `125
  554. X    else `123
  555. X`009(void) sprintf(buf, "  %s%s", string, peaces);
  556. +-+-+-+-+-+-+-+-  END  OF PART 44 +-+-+-+-+-+-+-+-
  557.