home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / vmsnet / vmstrek / part38 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  14.2 KB

  1. Path: uunet!usc!sol.ctr.columbia.edu!destroyer!cs.ubc.ca!bcsystems!spruce.pfc.forestry.ca!news.u.washington.edu!raven.alaska.edu!acad2.alaska.edu!asdmf
  2. Newsgroups: vmsnet.sources.games
  3. Subject: Vmsnetrek 38/47
  4. Message-ID: <1992Nov20.203919.1@acad2.alaska.edu>
  5. From: asdmf@acad2.alaska.edu
  6. Date: Sat, 21 Nov 1992 00:39:19 GMT
  7. Sender: news@raven.alaska.edu (USENET News System)
  8. Organization: University of Alaska
  9. Nntp-Posting-Host: acad2.alaska.edu
  10. Lines: 628
  11. Xref: uunet vmsnet.sources.games:538
  12.  
  13. -+-+-+-+-+-+-+-+ START OF PART 38 -+-+-+-+-+-+-+-+
  14. X    0.3599,
  15. X    0.3827,
  16. X    0.4052,
  17. X    0.4275,
  18. X    0.4496,
  19. X    0.4714,
  20. X    0.4929,
  21. X    0.5141,
  22. X    0.5350,
  23. X    0.5556,
  24. X    0.5758,
  25. X    0.5957,
  26. X    0.6152,
  27. X    0.6344,
  28. X    0.6532,
  29. X    0.6715,
  30. X    0.6895,
  31. X    0.7071,
  32. X    0.7242,
  33. X    0.7409,
  34. X    0.7572,
  35. X    0.7730,
  36. X    0.7883,
  37. X    0.8032,
  38. X    0.8176,
  39. X    0.8315,
  40. X    0.8448,
  41. X    0.8577,
  42. X    0.8701,
  43. X    0.8819,
  44. X    0.8932,
  45. X    0.9040,
  46. X    0.9142,
  47. X    0.9239,
  48. X    0.9330,
  49. X    0.9415,
  50. X    0.9495,
  51. X    0.9569,
  52. X    0.9638,
  53. X    0.9700,
  54. X    0.9757,
  55. X    0.9808,
  56. X    0.9853,
  57. X    0.9892,
  58. X    0.9925,
  59. X    0.9952,
  60. X    0.9973,
  61. X    0.9988,
  62. X    0.9997,
  63. X    1.0000,
  64. X    0.9997,
  65. X    0.9988,
  66. X    0.9973,
  67. X    0.9952,
  68. X    0.9925,
  69. X    0.9892,
  70. X    0.9853,
  71. X    0.9808,
  72. X    0.9757,
  73. X    0.9700,
  74. X    0.9638,
  75. X    0.9570,
  76. X    0.9495,
  77. X    0.9416,
  78. X    0.9330,
  79. X    0.9239,
  80. X    0.9142,
  81. X    0.9040,
  82. X    0.8933,
  83. X    0.8819,
  84. X    0.8701,
  85. X    0.8578,
  86. X    0.8449,
  87. X    0.8315,
  88. X    0.8176,
  89. X    0.8032,
  90. X    0.7884,
  91. X    0.7731,
  92. X    0.7573,
  93. X    0.7410,
  94. X    0.7243,
  95. X    0.7072,
  96. X    0.6896,
  97. X    0.6716,
  98. X    0.6532,
  99. X    0.6344,
  100. X    0.6153,
  101. X    0.5958,
  102. X    0.5759,
  103. X    0.5556,
  104. X    0.5351,
  105. X    0.5142,
  106. X    0.4930,
  107. X    0.4715,
  108. X    0.4497,
  109. X    0.4276,
  110. X    0.4053,
  111. X    0.3828,
  112. X    0.3600,
  113. X    0.3370,
  114. X    0.3138,
  115. X    0.2904,
  116. X    0.2668,
  117. X    0.2431,
  118. X    0.2192,
  119. X    0.1952,
  120. X    0.1710,
  121. X    0.1468,
  122. X    0.1225,
  123. X    0.0981,
  124. X    0.0737,
  125. X    0.0492,
  126. X    0.0246,
  127. X    0.0001,
  128. X    -0.0244,
  129. X    -0.0490,
  130. X    -0.0735,
  131. X    -0.0979,
  132. X    -0.1223,
  133. X    -0.1466,
  134. X    -0.1709,
  135. X    -0.1950,
  136. X    -0.2190,
  137. X    -0.2429,
  138. X    -0.2666,
  139. X    -0.2902,
  140. X    -0.3136,
  141. X    -0.3368,
  142. X    -0.3598,
  143. X    -0.3826,
  144. X    -0.4051,
  145. X    -0.4275,
  146. X    -0.4495,
  147. X    -0.4713,
  148. X    -0.4928,
  149. X    -0.5140,
  150. X    -0.5349,
  151. X    -0.5555,
  152. X    -0.5757,
  153. X    -0.5956,
  154. X    -0.6151,
  155. X    -0.6343,
  156. X    -0.6531,
  157. X    -0.6715,
  158. X    -0.6895,
  159. X    -0.7070,
  160. X    -0.7242,
  161. X    -0.7409,
  162. X    -0.7571,
  163. X    -0.7729,
  164. X    -0.7883,
  165. X    -0.8031,
  166. X    -0.8175,
  167. X    -0.8314,
  168. X    -0.8448,
  169. X    -0.8577,
  170. X    -0.8700,
  171. X    -0.8819,
  172. X    -0.8932,
  173. X    -0.9039,
  174. X    -0.9142,
  175. X    -0.9238,
  176. X    -0.9329,
  177. X    -0.9415,
  178. X    -0.9495,
  179. X    -0.9569,
  180. X    -0.9637,
  181. X    -0.9700,
  182. X    -0.9757,
  183. X    -0.9808,
  184. X    -0.9853,
  185. X    -0.9892,
  186. X    -0.9925,
  187. X    -0.9952,
  188. X    -0.9973,
  189. X    -0.9988,
  190. X    -0.9997,
  191. X    -1.0000,
  192. X    -0.9997,
  193. X    -0.9988,
  194. X    -0.9973,
  195. X    -0.9952,
  196. X    -0.9925,
  197. X    -0.9892,
  198. X    -0.9853,
  199. X    -0.9808,
  200. X    -0.9757,
  201. X    -0.9701,
  202. X    -0.9638,
  203. X    -0.9570,
  204. X    -0.9496,
  205. X    -0.9416,
  206. X    -0.9330,
  207. X    -0.9239,
  208. X    -0.9143,
  209. X    -0.9041,
  210. X    -0.8933,
  211. X    -0.8820,
  212. X    -0.8702,
  213. X    -0.8578,
  214. X    -0.8449,
  215. X    -0.8316,
  216. X    -0.8177,
  217. X    -0.8033,
  218. X    -0.7884,
  219. X    -0.7731,
  220. X    -0.7573,
  221. X    -0.7411,
  222. X    -0.7244,
  223. X    -0.7072,
  224. X    -0.6897,
  225. X    -0.6717,
  226. X    -0.6533,
  227. X    -0.6345,
  228. X    -0.6154,
  229. X    -0.5958,
  230. X    -0.5759,
  231. X    -0.5557,
  232. X    -0.5351,
  233. X    -0.5142,
  234. X    -0.4930,
  235. X    -0.4715,
  236. X    -0.4498,
  237. X    -0.4277,
  238. X    -0.4054,
  239. X    -0.3828,
  240. X    -0.3601,
  241. X    -0.3371,
  242. X    -0.3138,
  243. X    -0.2905,
  244. X    -0.2669,
  245. X    -0.2432,
  246. X    -0.2193,
  247. X    -0.1953,
  248. X    -0.1711,
  249. X    -0.1469,
  250. X    -0.1226,
  251. X    -0.0982,
  252. X    -0.0737,
  253. X    -0.0493,
  254. X    -0.0247
  255. X`125;
  256. $ CALL UNPACK SINTAB.C;1 323794660
  257. $ create/nolog 'f'
  258. X/*
  259. X * smessage.c
  260. X */
  261. X#include "copyright.h"
  262. X
  263. X#include <stdio.h>
  264. X#include <math.h>
  265. X#include <signal.h>
  266. X#include <ctype.h>
  267. X#include "Wlib.h"
  268. X#include "defs.h"
  269. X#include "struct.h"
  270. X#include "data.h"
  271. X
  272. X#define ADDRLEN 10
  273. X
  274. X#define BLANKCHAR(col, n) W_ClearArea(messagew, 5+W_Textwidth*(col), 5, \
  275. X    W_Textwidth * (n), W_Textheight, backColor);
  276. X#define DRAWCURSOR(col) W_WriteText(messagew, 5+W_Textwidth*(col), 5, \
  277. X    textColor, &cursor, 1, W_RegularFont);
  278. X
  279. Xstatic int lcount;
  280. Xstatic char buf`09180`093;
  281. Xstatic char cursor = '_';
  282. X
  283. Xchar *getaddr(), *getaddr2();
  284. X
  285. Xsmessage(ichar)
  286. X    char ichar;
  287. X`123
  288. X    register int i;
  289. X    char *getaddr();
  290. X    char twochar`0912`093;
  291. X    static char addr, *addr_str;
  292. X
  293. X    if (messpend == 0) `123
  294. X`009messpend = 1;
  295. X`009if (mdisplayed) `123
  296. X`009    BLANKCHAR(0, lastcount);
  297. X`009    mdisplayed = 0;
  298. X`009`125
  299. X`009/* Put the proper recipient in the window */
  300. X`009if ((ichar == 't') `124`124 (ichar == 'T'))
  301. X`009    addr = teamlet`091me->p_team`093;
  302. X`009else
  303. X`009    addr = ichar;
  304. X`009addr_str = getaddr(addr);
  305. X`009if (addr_str == 0) `123
  306. X`009    /* print error message */
  307. X`009    messpend = 0;
  308. X`009    W_WarpPointer(NULL);`009/* ATM - msg warp */
  309. X`009    return;
  310. X`009`125
  311. X`009W_WriteText(messagew, 5, 5, textColor, addr_str, strlen(addr_str),
  312. X`009    W_RegularFont);
  313. X`009lcount = ADDRLEN;
  314. X`009DRAWCURSOR(ADDRLEN);
  315. X`009return;
  316. X    `125
  317. X    switch ((unsigned char)ichar & `126(0x80)) `123
  318. X`009case '\b':`009/* character erase */
  319. X`009case '\177':
  320. X`009    if (--lcount < ADDRLEN) `123
  321. X`009`009lcount = ADDRLEN;
  322. X`009`009break;
  323. X`009    `125
  324. X`009    BLANKCHAR(lcount + 1, 1);
  325. X`009    DRAWCURSOR(lcount);
  326. X`009    break;
  327. X
  328. X`009case '\027':`009/* word erase */
  329. X`009    i = 0;
  330. X`009    /* back up over blanks */
  331. X`009    while (--lcount >= ADDRLEN &&
  332. X`009`009isspace((unsigned char)buf`091lcount - ADDRLEN`093 & `126(0x80)))
  333. X`009`009i++;
  334. X`009    lcount++;
  335. X`009    /* back up over non-blanks */
  336. X`009    while (--lcount >= ADDRLEN &&
  337. X`009`009!isspace((unsigned char)buf`091lcount - ADDRLEN`093 & `126(0x80)))
  338. X`009`009i++;
  339. X`009    lcount++;
  340. X
  341. X`009    if (i > 0) `123
  342. X`009`009BLANKCHAR(lcount, i + 1);
  343. X`009`009DRAWCURSOR(lcount);
  344. X`009    `125
  345. X`009    break;
  346. X
  347. X`009case '\025':`009/* kill line */
  348. X`009case '\030':
  349. X`009    if (lcount > ADDRLEN) `123
  350. X`009`009BLANKCHAR(ADDRLEN, lcount - ADDRLEN + 1);
  351. X`009`009lcount = ADDRLEN;
  352. X`009`009DRAWCURSOR(ADDRLEN);
  353. X`009    `125
  354. X`009    break;
  355. X
  356. X`009case '\033':`009/* abort message */
  357. X`009    BLANKCHAR(0, lcount + 1);
  358. X`009    mdisplayed = 0;
  359. X`009    messpend = 0;
  360. X`009    W_WarpPointer(NULL);`009/* ATM - msg warp */
  361. X`009    break;
  362. X
  363. X`009case '\r':`009/* send message */
  364. X`009    buf`091lcount - ADDRLEN`093 = '\0';
  365. X`009    messpend = 0;
  366. X`009    switch (addr) `123
  367. X`009`009case 'A':
  368. X`009`009    pmessage(buf, 0, MALL);
  369. X`009`009    break;
  370. X`009`009case 'G':
  371. X`009`009    pmessage(buf, me->p_mapchars`0911`093 - '0', MGOD);
  372. X`009`009    break;
  373. X`009`009case 'F':
  374. X`009`009    pmessage(buf, FED, MTEAM);
  375. X`009`009    break;
  376. X`009`009case 'R':
  377. X`009`009    pmessage(buf, ROM, MTEAM);
  378. X`009`009    break;
  379. X`009`009case 'K':
  380. X`009`009    pmessage(buf, KLI, MTEAM);
  381. X`009`009    break;
  382. X`009`009case 'O':
  383. X`009`009    pmessage(buf, ORI, MTEAM);
  384. X`009`009    break;
  385. X`009`009case '0':
  386. X`009`009case '1':
  387. X`009`009case '2':
  388. X`009`009case '3':
  389. X`009`009case '4':
  390. X`009`009case '5':
  391. X`009`009case '6':
  392. X`009`009case '7':
  393. X`009`009case '8':
  394. X`009`009case '9':
  395. X`009`009    pmessage(buf, addr - '0', MINDIV);
  396. X`009`009    break;
  397. X`009`009case 'a': case 'b': case 'c': case 'd':
  398. X`009`009case 'e': case 'f': case 'g': case 'h':
  399. X`009`009case 'i': case 'j': case 'k': case 'l':
  400. X`009`009case 'm': case 'n': case 'o': case 'p':
  401. X`009`009case 'q': case 'r': case 's': case 't':`032
  402. X`009`009case 'u': case 'v': case 'w': case 'x':`032
  403. X`009`009case 'y': case 'z':
  404. X`009`009    pmessage(buf, addr - 'a' + 10, MINDIV);
  405. X`009`009    break;
  406. X`009`009default:
  407. X`009`009    warning("Not legal recipient");
  408. X`009    `125
  409. X`009    BLANKCHAR(0, lcount + 1);
  410. X`009    mdisplayed = 0;
  411. X`009    lcount = 0;
  412. X`009    break;
  413. X
  414. X`009default:`009/* add character */
  415. X`009    if (lcount >= 80) `123
  416. X`009`009W_Beep();
  417. X`009`009break;
  418. X`009    `125
  419. X`009    if (iscntrl((unsigned char )ichar & `126(0x80)))
  420. X`009`009break;
  421. X`009    twochar`0910`093 = ichar;
  422. X`009    twochar`0911`093 = cursor;
  423. X`009    W_WriteText(messagew, 5 + W_Textwidth * lcount, 5, textColor,
  424. X`009`009twochar, 2, W_RegularFont);
  425. X`009    buf`091(lcount++) - ADDRLEN`093 = ichar;
  426. X`009    break;
  427. X    `125
  428. X`125
  429. X
  430. Xpmessage(str, recip, group)
  431. Xchar *str;
  432. Xint recip;
  433. Xint group;
  434. X`123
  435. X    char newbuf`091100`093;
  436. X
  437. X    sendMessage(str, group, recip);
  438. X    if ((group==MTEAM && recip!=me->p_team) `124`124`032
  439. X`009(group==MINDIV && recip!=me->p_no)) `123
  440. X`009sprintf(newbuf, "%s  %s", getaddr2(group, recip), str);
  441. X`009newbuf`09179`093=0;
  442. X`009dmessage(newbuf, group, me->p_no, recip);
  443. X    `125
  444. X    W_WarpPointer(NULL);`009`009/* ATM - msg warp */
  445. X`125
  446. X
  447. Xchar *getaddr(who)
  448. Xchar who;
  449. X`123
  450. X    switch (who) `123
  451. X    case 'A':
  452. X`009return(getaddr2(MALL, 0));
  453. X    case 'F':
  454. X`009return(getaddr2(MTEAM, FED));
  455. X    case 'R':
  456. X`009return(getaddr2(MTEAM, ROM));
  457. X    case 'K':
  458. X`009return(getaddr2(MTEAM, KLI));
  459. X    case 'O':
  460. X`009return(getaddr2(MTEAM, ORI));
  461. X    case 'G':
  462. X`009return(getaddr2(MGOD, 0));
  463. X    case '0':
  464. X    case '1':
  465. X    case '2':
  466. X    case '3':
  467. X    case '4':
  468. X    case '5':
  469. X    case '6':
  470. X    case '7':
  471. X    case '8':
  472. X    case '9':
  473. X`009if (isAlive(&players`091who - '0'`093)) `123
  474. X`009    return(getaddr2(MINDIV, who-'0'));
  475. X`009`125
  476. X`009else `123
  477. X`009    warning("Player is not in game");
  478. X`009    return(0);
  479. X`009`125
  480. X`009break;
  481. X    case 'a': case 'b': case 'c': case 'd':
  482. X    case 'e': case 'f': case 'g': case 'h':
  483. X    case 'i': case 'j': case 'k': case 'l':
  484. X    case 'm': case 'n': case 'o': case 'p':
  485. X    case 'q': case 'r': case 's': case 't':`032
  486. X    case 'u': case 'v': case 'w': case 'x':`032
  487. X    case 'y': case 'z':
  488. X`009if (who-'a'+10 > MAXPLAYER) `123
  489. X`009    warning("Player is not in game");
  490. X`009    return(0);
  491. X`009`125
  492. X`009if (isAlive(&players`091who - 'a' + 10`093)) `123
  493. X`009    return(getaddr2(MINDIV, who-'a'+10));
  494. X`009`125
  495. X`009else `123
  496. X`009    warning("Player is not in game");
  497. X`009    return(0);
  498. X`009`125
  499. X`009break;
  500. X    default:
  501. X`009warning("Not legal recipient");
  502. X`009return(0);
  503. X    `125
  504. X`125
  505. X
  506. Xchar *getaddr2(flags, recip)`032
  507. Xint flags;
  508. Xint recip;
  509. X`123
  510. X    static char addrmesg`091ADDRLEN`093;
  511. X
  512. X    (void) sprintf(addrmesg, " %c%c->", teamlet`091me->p_team`093, shipnos`0
  513. V91me->p_no`093);
  514. X    switch(flags) `123
  515. X    case MALL:
  516. X`009(void) sprintf(&addrmesg`0915`093, "ALL");
  517. X`009break;
  518. X    case MGOD:
  519. X`009(void) sprintf(&addrmesg`0915`093, "GOD");
  520. X`009break;
  521. X    case MTEAM:
  522. X`009(void) sprintf(&addrmesg`0915`093, teamshort`091recip`093);
  523. X`009break;
  524. X    case MINDIV:
  525. X`009(void) sprintf(&addrmesg`0915`093, "%c%c ",
  526. X`009    teamlet`091players`091recip`093.p_team`093, shipnos`091recip`093);
  527. X`009break;
  528. X    `125
  529. X    return(addrmesg);
  530. X`125
  531. X
  532. X/* Send an emergency signal out to everyone. */
  533. X
  534. Xemergency()
  535. X`123
  536. X    char addrbuf`091ADDRLEN`093;
  537. X    char ebuf`09180`093;
  538. X
  539. X    if (myship->s_type==STARBASE) `123
  540. X`009sprintf(ebuf,`032
  541. X`009    "Distress Call from %c%c (Starbase!):  %d%% damage, %d%% shields, %d
  542. V armies!",
  543. X`009    teamlet`091me->p_team`093, shipnos`091me->p_no`093,
  544. X`009    (100*me->p_damage)/me->p_ship.s_maxdamage,
  545. X`009    (100*me->p_shield)/me->p_ship.s_maxshield,
  546. X`009    me->p_armies);
  547. X    `125 else `123
  548. X`009sprintf(ebuf,`032
  549. X`009    "Distress Call from %c%c:  %d%% damage, %d%% shields, %d armies!",
  550. X`009    teamlet`091me->p_team`093, shipnos`091me->p_no`093,
  551. X`009    (100*me->p_damage)/me->p_ship.s_maxdamage,
  552. X`009    (100*me->p_shield)/me->p_ship.s_maxshield,
  553. X`009    me->p_armies);
  554. X    `125
  555. X    pmessage(ebuf, me->p_team, MTEAM);
  556. X`125
  557. $ CALL UNPACK SMESSAGE.C;1 1182574212
  558. $ create/nolog 'f'
  559. X/*
  560. X * Socket.c
  561. X *
  562. X * Kevin P. Smith 1/29/89
  563. X * UDP stuff v1.0 by Andy McFadden  Feb-Apr 1992
  564. X *
  565. X * UDP protocol v1.0
  566. X *
  567. X * Routines to allow connection to the xtrek server.
  568. X */
  569. X#include "copyright2.h"
  570. X
  571. X#ifndef GATEWAY
  572. X# define USE_PORTSWAP`009`009/* instead of using recvfrom() */
  573. X#endif
  574. X
  575. X#include <stdio.h>
  576. X#include <errno.h>
  577. X#include "TWG$TCP:`091NETDIST.INCLUDE.SYS`093types.h"
  578. X#define  ECONNREFUSED 61
  579. X#include <socket.h>
  580. X#include <time.h>
  581. X#include <in.h>
  582. X#include <netdb.h>
  583. X#include "Wlib.h"
  584. X#include "defs.h"
  585. X#include "struct.h"
  586. X#include "data.h"
  587. X#include "packets.h"
  588. X
  589. X#ifdef VMS
  590. X#include "vmsutils.h"
  591. X#endif
  592. X
  593. X#define INCLUDE_SCAN`009`009/* include Amdahl scanning beams */
  594. X#define INCLUDE_VISTRACT`009/* include visible tractor beams */
  595. X
  596. X#ifdef GATEWAY
  597. X/*
  598. X * (these values are now defined in "main.c":)
  599. X * char *gw_mach`009= "charon";`009`124client gateway; strcmp(serverName)
  600. X * int   gw_serv_port`009= 5000;`009`009`124what to tell the server to use
  601. X * int   gw_port`009= 5001;`009`009`124where we will contact gw
  602. X * int   gw_local_port`009= 5100;`009`009`124where we expect gw to contact u
  603. Vs
  604. X *
  605. X * The client binds to "5100" and sends "5000" to the server (TCP).  The
  606. X * server sees that and sends a UDP packet to gw on port udp5000, which pass
  607. Ves
  608. X * it through to port udp5100 on the client.  The client-gw gets the server'
  609. Vs
  610. X * host and port from recvfrom.  (The client can't use the same method since
  611. X * these sockets are one-way only, so it connect()s to gw_port (udp5001)
  612. X * on the gateway machine regardless of what the server sends.)
  613. X *
  614. X * So all we need in .gwrc is:
  615. X *`009udp 5000 5001 tde.uts 5100
  616. X *
  617. X * assuming the client is on tde.uts.  Note that a UDP declaration will
  618. X * work for ANY server, but you need one per player, and the client has to
  619. X * have the port numbers in advance.
  620. X *
  621. X * If we're using a standard server, we're set.  If we're running through a
  622. X * gatewayed server, we have to do some unpleasant work on the server side..
  623. V.
  624. X */
  625. X#endif
  626. X
  627. Xint handleMessage(), handlePhaser(), handlePlyrInfo();
  628. Xint handlePlayer(), handleSelf(), handleStatus();
  629. Xint handleWarning(), handleTorp(), handleTorpInfo();
  630. Xint handlePlanet(), handleQueue(), handlePickok(), handleLogin();
  631. Xint handlePlasmaInfo(), handlePlasma();
  632. Xint handleKills(), handleFlags(), handlePStatus();
  633. Xint handleMotd(), handleMask();
  634. Xint handleBadVersion(), handlePlanetLoc();
  635. Xint handleHostile(), handleStats(), handlePlyrLogin();
  636. Xint handleReserved();
  637. X#ifdef INCLUDE_SCAN
  638. Xint handleScan();
  639. X#endif
  640. +-+-+-+-+-+-+-+-  END  OF PART 38 +-+-+-+-+-+-+-+-
  641.