home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / vmsnet / vmstrek / part44 < prev    next >
Encoding:
Text File  |  1992-11-20  |  14.3 KB  |  558 lines

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