home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / vmsnet / sources / games / 444 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  14.3 KB

  1. Path: sparky!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 33/47
  4. Message-ID: <1992Nov20.200638.1@acad2.alaska.edu>
  5. From: asdmf@acad2.alaska.edu
  6. Date: Sat, 21 Nov 1992 00:06:38 GMT
  7. Sender: news@raven.alaska.edu (USENET News System)
  8. Organization: University of Alaska
  9. Nntp-Posting-Host: acad2.alaska.edu
  10. Lines: 546
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 33 -+-+-+-+-+-+-+-+
  13. X    char pad1;
  14. X    char pad2;
  15. X`125;
  16. X
  17. Xstruct playlock_cpacket `123
  18. X    char type;`009`009/* CP_PLAYLOCK */
  19. X    char pnum;
  20. X    char pad1;
  21. X    char pad2;
  22. X`125;
  23. X
  24. Xstruct bomb_cpacket `123
  25. X    char type;`009`009/* CP_BOMB */
  26. X    char state;
  27. X    char pad1;
  28. X    char pad2;
  29. X`125;
  30. X
  31. Xstruct beam_cpacket `123
  32. X    char type;`009`009/* CP_BEAM */
  33. X    char state;
  34. X    char pad1;`032
  35. X    char pad2;
  36. X`125;
  37. X
  38. Xstruct cloak_cpacket `123
  39. X    char type;`009`009/* CP_CLOAK */
  40. X    char state;`009`009
  41. X    char pad1;
  42. X    char pad2;
  43. X`125;
  44. X
  45. Xstruct det_torps_cpacket `123
  46. X    char type;`009`009/* CP_DET_TORPS */
  47. X    char pad1;
  48. X    char pad2;
  49. X    char pad3;
  50. X`125;
  51. X
  52. Xstruct det_mytorp_cpacket `123
  53. X    char type;`009`009/* CP_DET_MYTORP */
  54. X    char pad1;
  55. X    short tnum;
  56. X`125;
  57. X
  58. Xstruct copilot_cpacket `123
  59. X    char type;`009`009/* CP_COPLIOT */
  60. X    char state;
  61. X    char pad1;
  62. X    char pad2;
  63. X`125;
  64. X
  65. Xstruct refit_cpacket `123
  66. X    char type;`009`009/* CP_REFIT */
  67. X    char ship;
  68. X    char pad1;
  69. X    char pad2;
  70. X`125;
  71. X
  72. Xstruct tractor_cpacket `123
  73. X    char type;`009`009/* CP_TRACTOR */
  74. X    char state;
  75. X    char pnum;
  76. X    char pad2;
  77. X`125;
  78. X
  79. Xstruct repress_cpacket `123
  80. X    char type;`009`009/* CP_REPRESS */
  81. X    char state;
  82. X    char pnum;
  83. X    char pad2;
  84. X`125;
  85. X
  86. Xstruct coup_cpacket `123
  87. X    char type;`009`009/* CP_COUP */
  88. X    char pad1;
  89. X    char pad2;
  90. X    char pad3;
  91. X`125;
  92. X
  93. Xstruct socket_cpacket `123
  94. X    char type;`009`009/* CP_SOCKET */
  95. X    char version;
  96. X    char udp_version;`009/* was pad2 */
  97. X    char pad3;
  98. X    unsigned socket;
  99. X`125;
  100. X
  101. Xstruct options_cpacket `123
  102. X    char type;`009`009/* CP_OPTIONS */
  103. X    char pad1;
  104. X    char pad2;
  105. X    char pad3;
  106. X    unsigned flags;
  107. X    char keymap`09196`093;
  108. X`125;
  109. X
  110. Xstruct bye_cpacket `123
  111. X    char type;`009`009/* CP_BYE */
  112. X    char pad1;
  113. X    char pad2;
  114. X    char pad3;
  115. X`125;
  116. X
  117. Xstruct dockperm_cpacket `123
  118. X    char type;`009`009/* CP_DOCKPERM */
  119. X    char state;
  120. X    char pad2;
  121. X    char pad3;
  122. X`125;
  123. X
  124. Xstruct updates_cpacket `123
  125. X    char type;`009`009/* CP_UPDATES */
  126. X    char pad1;
  127. X    char pad2;
  128. X    char pad3;
  129. X    unsigned usecs;
  130. X`125;
  131. X
  132. Xstruct resetstats_cpacket `123
  133. X    char type;`009`009/* CP_RESETSTATS */
  134. X    char verify;`009/* 'Y' - just to make sure he meant it */
  135. X    char pad2;
  136. X    char pad3;
  137. X`125;
  138. X
  139. Xstruct reserved_cpacket `123
  140. X    char type;`009`009/* CP_RESERVED */
  141. X    char pad1;
  142. X    char pad2;
  143. X    char pad3;
  144. X    char data`09116`093;
  145. X    char resp`09116`093;
  146. X`125;
  147. X
  148. Xstruct scan_cpacket `123`009`009/* ATM */
  149. X    char type;`009`009/* CP_SCAN */
  150. X    char pnum;
  151. X    char pad1;
  152. X    char pad2;
  153. X`125;
  154. X
  155. Xstruct udp_req_cpacket `123`009/* UDP */
  156. X    char type;`009`009/* CP_UDP_REQ */
  157. X    char request;
  158. X    char connmode;`009/* respond with port # or just send UDP packet? */
  159. X    char pad2;
  160. X    int  port;`009`009/* compensate for hosed recvfrom() */
  161. X`125;
  162. X
  163. Xstruct sequence_cpacket `123`009/* UDP */
  164. X    char type;`009`009/* CP_SEQUENCE */
  165. X    char pad1;
  166. X    unsigned short sequence;
  167. X`125;
  168. X
  169. $ CALL UNPACK PACKETS.H;1 1410954082
  170. $ create/nolog 'f'
  171. X/*
  172. X * planetlist.c
  173. X */
  174. X#include "copyright.h"
  175. X#include <stdio.h>
  176. X#include "Wlib.h"
  177. X#include "defs.h"
  178. X#include "struct.h"
  179. X#include "data.h"
  180. X
  181. Xstatic char *teamname`0919`093 = `123
  182. X    "IND",
  183. X    "FED",
  184. X    "ROM",
  185. X    "",
  186. X    "KLI",
  187. X    "",
  188. X    "",
  189. X    "",
  190. X    "ORI"
  191. X`125;
  192. X
  193. X/*
  194. X** Open a window which contains all the planets and their current
  195. X** statistics.  Players will not know about planets that their team
  196. X** has not orbited.
  197. X*/
  198. X
  199. Xplanetlist()
  200. X`123
  201. X    register int i;
  202. X    register int k = 0;
  203. X    char buf`091BUFSIZ`093;
  204. X    register struct planet *j;
  205. X
  206. X    W_ClearWindow(planetw);
  207. X    (void) sprintf(buf, "Planet Name      own armies REPAIR FUEL AGRI info")
  208. V;
  209. X    W_WriteText(planetw, 2, 1, textColor, buf, strlen(buf), W_RegularFont);
  210. X    k = 2;
  211. X    for (i = 0, j = &planets`091i`093; i < MAXPLANETS; i++, j++) `123
  212. X`009if (j->pl_info & me->p_team) `123
  213. X`009    (void) sprintf(buf, "%-16s %3s %3d    %6s %4s %4s %c%c%c%c",
  214. X`009`009j->pl_name,
  215. X`009`009teamname`091j->pl_owner`093,
  216. X`009`009j->pl_armies,
  217. X`009`009(j->pl_flags & PLREPAIR ? "REPAIR" : "      "),
  218. X`009`009(j->pl_flags & PLFUEL ? "FUEL" : "    "),
  219. X`009`009(j->pl_flags & PLAGRI ? "AGRI" : "    "),
  220. X`009`009(j->pl_info & FED ? 'F' : ' '),
  221. X`009`009(j->pl_info & ROM ? 'R' : ' '),
  222. X`009`009(j->pl_info & KLI ? 'K' : ' '),
  223. X`009`009(j->pl_info & ORI ? 'O' : ' '));
  224. X`009    W_WriteText(planetw, 2, k++, planetColor(j), buf, strlen(buf),
  225. X`009`009planetFont(j));
  226. X`009`125
  227. X`009else `123
  228. X`009    (void) sprintf(buf, "%-16s",
  229. X`009`009j->pl_name);
  230. X`009    W_WriteText(planetw, 2, k++, unColor, buf, strlen(buf),
  231. X`009`009W_RegularFont);
  232. X`009`125
  233. X    `125
  234. X`125
  235. $ CALL UNPACK PLANETLIST.C;1 1294516970
  236. $ create/nolog 'f'
  237. X/*`032
  238. X * planets.c
  239. X *
  240. X * Kevin P. Smith  2/21/89
  241. X *
  242. X * This file contains the galaxy definition as well as some support for`032
  243. X *  determining when parts of the galactic map need to be redrawn.
  244. X */
  245. X#include "copyright2.h"
  246. X
  247. X#include <stdio.h>
  248. X#include <math.h>
  249. X#include "Wlib.h"
  250. X#include "defs.h"
  251. X#include "struct.h"
  252. X#include "data.h"
  253. X
  254. X/* Note:  DETAIL * MUST * be a factor of GWIDTH. */
  255. X#define DETAIL 40`009`009/* Size of redraw array */
  256. X#define DIST 4500`009`009/* Distance to turn on redraw flag */
  257. X#define SIZE (GWIDTH/DETAIL)
  258. X
  259. Xint redraws`091DETAIL`093`091DETAIL`093;
  260. Xstatic int initialized=0;
  261. X
  262. XinitPlanets()
  263. X`123
  264. X    int i,j,k;
  265. X    int endi, endj;
  266. X    struct planet *pl;
  267. X    int offset=DIST/SIZE+1;
  268. X    float dist;
  269. X
  270. X    for (i=0; i<DETAIL; i++) `123
  271. X`009for (j=0; j<DETAIL; j++) `123
  272. X`009    redraws`091i`093`091j`093= -1;
  273. X`009`125
  274. X    `125
  275. X
  276. X    for (k=0, pl=planets; k<MAXPLANETS; k++, pl++) `123
  277. X`009endi=pl->pl_x / SIZE+offset+1;
  278. X`009for (i=(pl->pl_x / SIZE)-offset; i<endi && i<DETAIL; i++) `123
  279. X`009    if (i<0) i=0;
  280. X`009    endj=pl->pl_y / SIZE+offset+1;
  281. X`009    for (j=(pl->pl_y / SIZE) - offset; j<endj && j<DETAIL; j++) `123
  282. X`009`009dist=hypot((float) (pl->pl_x - (i*SIZE + SIZE/2)),
  283. X`009`009`009   (float) (pl->pl_y - (j*SIZE + SIZE/2)));
  284. X`009`009if (dist<=DIST) `123
  285. X`009`009    redraws`091i`093`091j`093=k;
  286. X`009`009`125
  287. X`009    `125
  288. X`009`125
  289. X    `125
  290. X    initialized=1;
  291. X`125
  292. X
  293. XcheckRedraw(x,y)
  294. Xint x,y;
  295. X`123
  296. X    int i;
  297. X
  298. X    if (!initialized `124`124 x<0 `124`124 y<0 `124`124 x>=GWIDTH `124`124 y
  299. V>=GWIDTH) return;
  300. X    i=redraws`091x/SIZE`093`091y/SIZE`093;
  301. X    if (i==-1) return;
  302. X    planets`091i`093.pl_flags `124= PLREDRAW;
  303. X`125
  304. $ CALL UNPACK PLANETS.C;1 812796066
  305. $ create/nolog 'f'
  306. X/*
  307. X * playerlist.c
  308. X */
  309. X#include "copyright.h"
  310. X
  311. X#include <stdio.h>
  312. X#include "Wlib.h"
  313. X#include "defs.h"
  314. X#include "struct.h"
  315. X#include "data.h"
  316. X
  317. Xstatic char *classes`091NUM_TYPES`093 = `123
  318. X`009"SC", "DD", "CA", "BB", "AS", "SB", "GA", "??"`009/* ATM - Galaxy */
  319. X`125;
  320. X
  321. Xplayerlist()
  322. X`123
  323. X    int i;
  324. X    char buf`091100`093;
  325. X
  326. X    W_ClearWindow(playerw);
  327. X    (void) strcpy(buf, "  Type Rank      Name            Kills   Win  Loss
  328. V  Ratio Offense Defense     DI");
  329. X    W_WriteText(playerw, 0, 1, textColor, buf, strlen(buf), W_RegularFont);
  330. X    for (i=0; i<MAXPLAYER; i++) `123
  331. X`009updatePlayer`091i`093=1;
  332. X    `125
  333. X    playerlist2();
  334. X`125
  335. X
  336. Xplayerlist2()
  337. X`123
  338. X    register int i;
  339. X    char buf`091100`093;
  340. X    register struct player *j;
  341. X    int kills, losses;
  342. X    double ratio;
  343. X    float pRating, oRating, dRating, bRating;
  344. X
  345. X    if (!W_IsMapped(playerw)) return;
  346. X    for (i = 0, j = &players`091i`093; i < MAXPLAYER; i++, j++) `123
  347. X`009if (!updatePlayer`091i`093) continue;
  348. X`009if (!j->p_stats.st_tticks) continue;`009/* avoid bronco FP exception */
  349. X`009updatePlayer`091i`093=0;
  350. X`009if (j->p_status != PALIVE) `123
  351. X`009    W_ClearArea(playerw, 0, i+2, 83, 1, backColor);
  352. X`009    continue;
  353. X`009`125
  354. X`009if (j->p_ship.s_type == STARBASE) `123
  355. X`009    kills=j->p_stats.st_sbkills;
  356. X`009    losses=j->p_stats.st_sblosses;
  357. X`009`125 else `123
  358. X`009    kills=j->p_stats.st_kills + j->p_stats.st_tkills;
  359. X`009    losses=j->p_stats.st_losses + j->p_stats.st_tlosses;
  360. X`009`125
  361. X`009if (losses==0) `123
  362. X`009    ratio=kills;
  363. X`009`125 else `123
  364. X`009    ratio=(double) kills/losses;
  365. X`009`125
  366. X`009oRating = offenseRating(j);
  367. X`009dRating = defenseRating(j);
  368. X`009pRating = planetRating(j);
  369. X`009bRating = bombingRating(j);
  370. X`009(void) sprintf(buf, "%c%c %s  %-9.9s %-16.16s%5.2f %5d %5d %6.2lf   %5.2
  371. Vf   %5.2f %8.2f",
  372. X`009    teamlet`091j->p_team`093,
  373. X`009    shipnos`091j->p_no`093,
  374. X`009    classes`091j->p_ship.s_type`093,
  375. X`009    ranks`091j->p_stats.st_rank`093.name,
  376. X`009    j->p_name,
  377. X`009    j->p_kills,
  378. X`009    kills,
  379. X`009    losses,
  380. X`009    ratio,
  381. X`009    oRating,
  382. X`009    dRating,
  383. X`009    (oRating+pRating+bRating)*(j->p_stats.st_tticks/36000.0));
  384. X`009W_WriteText(playerw, 0, i+2, playerColor(j), buf, strlen(buf),
  385. X`009    shipFont(j));
  386. X    `125
  387. X`125
  388. $ CALL UNPACK PLAYERLIST.C;1 1752417274
  389. $ create/nolog 'f'
  390. X/*`032
  391. X * ranklist.c
  392. X *
  393. X * Kevin P. Smith 12/5/88
  394. X *
  395. X */
  396. X#include "copyright2.h"
  397. X
  398. X#include <stdio.h>
  399. X#include "Wlib.h"
  400. X#include "defs.h"
  401. X#include "struct.h"
  402. X#include "data.h"
  403. X
  404. Xranklist()
  405. X`123
  406. X    register int i;
  407. X    char buf`09180`093;
  408. X
  409. X    W_ClearWindow(rankw);
  410. X    (void) strcpy(buf, "  Rank       Hours  Defense  Ratings      DI");
  411. X    W_WriteText(rankw, 1, 1, textColor, buf, strlen(buf), W_BoldFont);
  412. X    for (i = 0; i < NUMRANKS; i++) `123
  413. X`009sprintf(buf, "%-11.11s %5.0f %8.2f %8.2f   %7.2f",
  414. X`009    ranks`091i`093.name,
  415. X`009    ranks`091i`093.hours,
  416. X`009    ranks`091i`093.defense,
  417. X`009    ranks`091i`093.ratings,
  418. X`009    ranks`091i`093.ratings * ranks`091i`093.hours);
  419. X`009if (mystats->st_rank==i) `123
  420. X`009    W_WriteText(rankw, 1, i+2, W_Cyan, buf, strlen(buf), W_BoldFont);
  421. X`009`125 else `123
  422. X`009    W_WriteText(rankw, 1, i+2, textColor, buf, strlen(buf), W_RegularFon
  423. Vt);
  424. X`009`125
  425. X    `125
  426. X    strcpy(buf, "To achieve a rank, you need a high enough defense, and");
  427. X    W_WriteText(rankw, 1, i+3, textColor, buf, strlen(buf), W_RegularFont);
  428. X    strcpy(buf, "either enough hours, and bombing + planet + offense ratings
  429. V");
  430. X    W_WriteText(rankw, 1, i+4, textColor, buf, strlen(buf), W_RegularFont);
  431. X    strcpy(buf, "above shown ratings, or too few hours, and a DI rating abov
  432. Ve");
  433. X    W_WriteText(rankw, 1, i+5, textColor, buf, strlen(buf), W_RegularFont);
  434. X    strcpy(buf, "the shown DI rating.");
  435. X    W_WriteText(rankw, 1, i+6, textColor, buf, strlen(buf), W_RegularFont);
  436. X`125
  437. $ CALL UNPACK RANKLIST.C;1 1649156320
  438. $ create/nolog 'f'
  439. Xnetrek
  440. X `032
  441. X  The client half of the xtrek code.
  442. X
  443. X  This half of the code will call up the xtrek server, and interfaces
  444. X  the user with the game.  It also reads a .xtrekrc file to set up the`032
  445. X  user defaults (a different file may be specified by netrek -r filename).
  446. X  A sample .xtrekrc file is provided herein.
  447. X `032
  448. X  Currently, there is an X10 version, and an X11 version and an SGI
  449. X  gl version.  It would conceivably be "easy" to add another graphics`032
  450. X  interface, though, by simply writing another module like x10window.c,
  451. X  x11window.c, or glwindow.c (about 1300 lines of code).
  452. X
  453. X  Options include:
  454. X
  455. X  -r defaultfile:`009Specify your own .xtrekrc file.
  456. X  -s socketnum:`009`009Use a specific socket number for connection.  This`03
  457. V2
  458. X`009`009`009requires the ntserv program to be started up by hand.
  459. X  -h hostname:`009`009Specify xtrek host to connect to.
  460. X  -d display:`009`009Specify display to connect to.
  461. X  -p socketnum:`009`009Specifies the foreign port to attempt a connection
  462. X`009`009`009to.
  463. X
  464. XAdditional notes:
  465. X  Many people don't like it when the client gets those window manager border
  466. Vs.
  467. X  If you don't like them, then remove all XSetClassHints() calls, and the`03
  468. V2
  469. X  XSetWMHints() calls which immediately follow them.  Also, set all of`032
  470. X  the override_redirect flags to True (they are all being explicitly set`032
  471. X  to false currently).
  472. $ CALL UNPACK README._1;1 509809021
  473. $ create/nolog 'f'
  474. X/*
  475. X * redraw.c
  476. X */
  477. X#include "copyright.h"
  478. X
  479. X#include <stdio.h>
  480. X#include <signal.h>
  481. X#include <math.h>
  482. X#include "Wlib.h"
  483. X#include "defs.h"
  484. X#include "struct.h"
  485. X#include "data.h"
  486. X#include "packets.h"
  487. X
  488. Xstatic int clearzone`0914`093`091(MAXTORP + 1) * MAXPLAYER +`032
  489. X`009`009`009(MAXPLASMA + 1) * MAXPLAYER + MAXPLANETS`093;
  490. Xstatic int clearcount;
  491. Xstatic int clearline`0914`093`091MAXPLAYER`093;
  492. Xstatic int clearlcount;
  493. Xstatic int mclearzone`0916`093`091MAXPLAYER`093;`009/* For map window */
  494. X
  495. Xstatic short nplayers;
  496. Xstatic int vissup = 0;`009`009/* vis tractor sup: 0=unk, 1=sup, -1=notsup */
  497. X
  498. Xintrupt()
  499. X`123
  500. X    static long lastread;
  501. X    long time();
  502. X
  503. X    udcounter++;
  504. X    if (readFromServer()) `123
  505. X`009lastread=time(NULL);
  506. X`009redraw();
  507. X`009playerlist2();
  508. X    `125
  509. X    if (reinitPlanets) `123
  510. X`009initPlanets();
  511. X`009reinitPlanets=0;
  512. X    `125
  513. X    if (lastread+3 < time(NULL)) `123
  514. X`009/* We haven't heard from server for awhile...`032
  515. X`009 * Strategy:  send a useless packet to "ping" server.
  516. X`009 */
  517. X`009sendWarReq(me->p_hostile);
  518. X    `125
  519. X    if (me->p_status==POUTFIT) `123
  520. X`009death();
  521. X    `125
  522. X`125
  523. X
  524. Xredraw()
  525. X`123
  526. X
  527. X    /* erase warning line if necessary */
  528. X    if ((warntimer <= udcounter) && (warncount > 0)) `123
  529. X`009W_ClearArea(warnw, 5, 5, W_Textwidth * warncount, W_Textheight, backColo
  530. Vr);
  531. X`009warncount = 0;
  532. X    `125
  533. X
  534. X    if (W_FastClear) `123
  535. X`009W_ClearWindow(w);
  536. X`009clearcount=0;
  537. X`009clearlcount=0;
  538. X    `125 else `123
  539. X`009while (clearcount) `123
  540. X`009    clearcount--;
  541. X`009    W_ClearArea(w, clearzone`0910`093`091clearcount`093, clearzone`0911`
  542. V093`091clearcount`093,
  543. X`009`009clearzone`0912`093`091clearcount`093, clearzone`0913`093`091clearcou
  544. Vnt`093,
  545. X`009`009backColor);
  546. X`009`125
  547. X`009while (clearlcount) `123
  548. X`009    clearlcount--;
  549. X`009    W_MakeLine(w, clearline`0910`093`091clearlcount`093, clearline`0911`
  550. V093`091clearlcount`093,
  551. X`009`009clearline`0912`093`091clearlcount`093, clearline`0913`093`091clearlc
  552. Vount`093,
  553. X`009`009backColor);
  554. X`009`125
  555. X    `125
  556. X
  557. +-+-+-+-+-+-+-+-  END  OF PART 33 +-+-+-+-+-+-+-+-
  558.