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

  1. Newsgroups: vmsnet.sources.games
  2. Path: sparky!uunet!cs.utexas.edu!usc!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 31/47
  5. Message-ID: <1992Nov15.214830.1@acad2.alaska.edu>
  6. Lines: 441
  7. Sender: news@raven.alaska.edu (USENET News System)
  8. Nntp-Posting-Host: acad2.alaska.edu
  9. Organization: University of Alaska
  10. Date: Mon, 16 Nov 1992 01:48:30 GMT
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 31 -+-+-+-+-+-+-+-+
  13. X   0x00, 0x00, 0x00, 0x80, 0xe7, 0xee, 0x3c, 0x80, 0x01, 0x00, 0x41, 0x00,
  14. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x80, 0x31, 0xc0, 0x80, 0x01, 0x00,
  15. X   0x47, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x60, 0xce, 0x00, 0x81,
  16. X   0x01, 0x00, 0xf9, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
  17. X   0x00, 0x81, 0x01, 0x00, 0xe4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  18. X   0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe0, 0x00, 0x00, 0x80, 0x7f, 0x00,
  19. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe0, 0x00, 0x00, 0xc0,
  20. X   0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe0, 0x00,
  21. X   0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
  22. X   0xf0, 0x01, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  23. X   0x01, 0x00, 0xe0, 0x00, 0x00, 0x7c, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00,
  24. X   0x00, 0x80, 0x01, 0x00, 0x40, 0x00, 0x00, 0xfa, 0xff, 0xff, 0xfe, 0x7f,
  25. X   0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe0, 0x00, 0x00, 0x84, 0x0f, 0x7d,
  26. X   0xff, 0xff, 0x07, 0x00, 0x00, 0x80, 0x01, 0x00, 0x40, 0x00, 0xf0, 0xff,
  27. X   0xff, 0xfb, 0xff, 0xff, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
  28. X   0xf0, 0xff, 0xff, 0x3f, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
  29. X   0x00, 0x00, 0x00, 0xfe, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  30. X   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  31. X   0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  32. X   0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  33. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  34. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00,
  35. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0x00,
  36. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
  37. X   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  38. X   0x00, 0xf0, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  39. X   0xff, 0xff, 0xff, 0x7f`125;
  40. $ CALL UNPACK OLDBITMAPS.H;1 1678054016
  41. $ create/nolog 'f'
  42. X/*
  43. X * option.c
  44. X */
  45. X#include "copyright.h"
  46. X
  47. X#include <stdio.h>
  48. X#include <ctype.h>
  49. X#include "Wlib.h"
  50. X#include "defs.h"
  51. X#include "struct.h"
  52. X#include "data.h"
  53. X
  54. Xstatic int notdone;`009`009/* not done flag */
  55. Xstatic int updateSpeed=2;`009/* speed of updates from server */
  56. Xstatic char newkeys`09114`093;
  57. X
  58. Xchar *localmes`091`093 = `123 "Show owner on local planets",
  59. X`009`009     "Show resources on local planets",
  60. X`009`009     "Show nothing on local planets",
  61. X`009`009     ""`125;
  62. X
  63. Xchar *galacticmes`091`093 = `123 "Show owner on galactic map",
  64. X`009`009        "Show resources on galactic map",
  65. X`009`009        "Show nothing on galactic map",
  66. X`009`009        ""`125;
  67. X
  68. Xchar *updatemess`091`093 = `123 "9 updates per second",
  69. X`009`009       "7 updates per second",
  70. X`009`009       "5 updates per second",
  71. X`009`009       "4 updates per second",
  72. X`009`009       "3 updates per second",
  73. X`009`009       "2 updates per second",
  74. X`009`009       "1 update per second",
  75. X`009`009       ""`125;
  76. X
  77. Xchar *mapupdates`091`093 = `123 "Don't update galactic map",
  78. X`009`009       "Update galactic map rarely",
  79. X`009`009       "Update galactic map frequently",
  80. X`009`009       ""`125;
  81. X
  82. Xstatic int uspeeds`091`093 = `123111111, 142857, 200000, 250000, 333333, 500
  83. V000, 999999`125;
  84. X
  85. X/*
  86. X * Only one of op_option, op_targetwin, and op_string should be
  87. X * defined. If op_string is defined, op_size should be too and
  88. X * op_text is used without a "Don't" prefix.
  89. X */
  90. Xstatic struct option `123
  91. X    int op_num;
  92. X    char *op_text;`009`009/* text to display when on */
  93. X    int *op_option;`009`009/* variable to test/modify (optional) */
  94. X    W_Window *op_targetwin;`009/* target window to map/unmap (optional) */
  95. X    char *op_string;`009`009/* string to modify (optional) */
  96. X    int op_size;`009`009/* size of *op_string (optional) */
  97. X    char **op_array; `009`009/* array of strings to switch between */
  98. X`125;
  99. X
  100. Xstatic struct option option`091`093 = `123
  101. X    `123 0, "show \"all\" message window",`009`0090, &messwa, 0, 0, NULL`125
  102. V,
  103. X    `123 1, "show \"team\" message window",`0090, &messwt, 0, 0, NULL`125,
  104. X    `123 2, "show \"your\" message window",`0090, &messwi, 0, 0, NULL`125,
  105. X    `123 3, "show \"kill\" message window",`0090, &messwk, 0, 0, NULL`125,
  106. X    `123 4, "show \"total\" message window",`0090, &reviewWin, 0, 0, NULL`12
  107. V5,
  108. X    `123 5, "show tactical planet names",`009&namemode, 0, 0, 0, NULL`125,
  109. X    `123 6, "show shields",`009`009&showShields, 0, 0, 0, NULL`125,
  110. X    `123 7, "show statistic window",`0090, &statwin, 0, 0, NULL`125,
  111. X    `123 8, "",`009`009`009`009&mapmode, 0, 0, 0, mapupdates`125,
  112. X    `123 9, "show help window",`009`0090, &helpWin, 0, 0, NULL`125,
  113. X    `123 10, "stay peaceful when reborn",`009&keeppeace, 0, 0, 0, NULL`125,
  114. X    /* #define KEYMAP must specify this entry */
  115. X    `123 11, "new keymap entries",`009`0090, 0, newkeys, 13, NULL`125,
  116. X    `123 12, "",`009`009`009`009&showlocal, 0, 0, 0, localmes`125,
  117. X    `123 13, "",`009`009`009`009&showgalactic, 0, 0, 0, galacticmes`125,
  118. X    `123 14, "",`009`009`009`009&updateSpeed, 0, 0, 0, updatemess`125,
  119. X    `123 15, "report kill messages",`009&reportKills, 0, 0, 0, NULL`125,
  120. X    `123 16, "show tractors as lines",`009&showTractor, 0, 0, 0, NULL`125,
  121. X    `123 17, "done",`009`009`009¬done, 0, 0, 0, NULL`125,
  122. X    `123 NULL,`009`009`009`0090, 0, 0, 0, NULL`125
  123. X`125;
  124. X
  125. X#define NUMOPTION ((sizeof(option)/sizeof(option`0910`093))-1)
  126. X
  127. X#define KEYMAP 11
  128. X#define OPTIONBORDER`0092
  129. X#define OPTIONLEN`00935
  130. X
  131. X/* Set up the option window */
  132. Xoptionwindow()
  133. X`123
  134. X    register int i;
  135. X
  136. X    /* Init not done flag */
  137. X    notdone = 1;
  138. X
  139. X    *newkeys='\0';
  140. X
  141. X    /* Create window big enough to hold option windows */
  142. X    if (optionWin==NULL) `123
  143. X`009optionWin = W_MakeMenu("option", WINSIDE+10, -BORDER+10, OPTIONLEN,`032
  144. X`009    NUMOPTION, baseWin, OPTIONBORDER);
  145. X
  146. X`009for (i=0; i<NUMOPTION; i++) `123
  147. X`009    optionrefresh(&(option`091i`093));
  148. X`009`125
  149. X    `125
  150. X
  151. X    /* Map window */
  152. X    W_MapWindow(optionWin);
  153. X`125
  154. X
  155. X/* Redraw the specified target window */
  156. Xoptionredrawtarget(win)
  157. XW_Window win;
  158. X`123
  159. X    register struct option *op;
  160. X
  161. X    for (op = option; op->op_text; op++) `123
  162. X`009if (op->op_targetwin && win == *op->op_targetwin) `123
  163. X`009    optionrefresh(op);
  164. X`009    break;
  165. X`009`125
  166. X    `125
  167. X`125
  168. X
  169. X/* Redraw the specified option option */
  170. Xoptionredrawoption(ip)
  171. Xint *ip;
  172. X`123
  173. X    register struct option *op;
  174. X
  175. X    for (op = option; op->op_text; op++) `123
  176. X`009if (ip == op->op_option) `123
  177. X`009    optionrefresh(op);
  178. X`009    break;
  179. X`009`125
  180. X    `125
  181. X`125
  182. X
  183. X/* Refresh the option window given by the option struct */
  184. Xoptionrefresh(op)
  185. Xregister struct option *op;
  186. X`123
  187. X    register int on;
  188. X    char buf`091BUFSIZ`093;
  189. X
  190. X    if (op->op_string) `123
  191. X`009(void) sprintf(buf, "%s: %s_", op->op_text, op->op_string);
  192. X    `125 else if (op->op_array) `123`009/* Array of strings */
  193. X`009strcpy(buf, op->op_array`091*op->op_option`093);
  194. X    `125 else `123
  195. X`009/* Either a boolean or a window */
  196. X`009if (op->op_option)
  197. X`009    on = *op->op_option;`009`009/* use int for status */
  198. X`009else if (op->op_targetwin)
  199. X`009    on = W_IsMapped(*op->op_targetwin);`009/* use window for status */
  200. X`009else
  201. X`009    on = 1;`009`009`009`009/* shouldn't happen */
  202. X
  203. X`009if (!on)
  204. X`009    strcpy(buf, "Don't ");
  205. X`009else
  206. X`009    buf`0910`093 = '\0';
  207. X`009strcat(buf, op->op_text);
  208. X    `125
  209. X    if (islower(buf`0910`093))
  210. X`009buf`0910`093 = toupper(buf`0910`093);
  211. X
  212. X    W_WriteText(optionWin, 0, op->op_num, textColor, buf, strlen(buf), 0);
  213. X`125
  214. X
  215. Xoptionaction(data)
  216. XW_Event *data;
  217. X`123
  218. X    register struct option *op;
  219. X    int i;
  220. X    register char *cp;
  221. X
  222. X    op= &(option`091data->y`093);
  223. X    /* Update string; don't claim keystrokes for non-string options */
  224. X    if (op->op_string == 0) `123
  225. X`009if (data->type == W_EV_KEY)
  226. X`009    return(0);
  227. X    `125 else `123
  228. X`009if (data->type == W_EV_BUTTON) return(0);
  229. X`009switch (data->key) `123
  230. X
  231. X`009case '\b':
  232. X`009case '\177':
  233. X`009    cp = op->op_string;
  234. X`009    i = strlen(cp);
  235. X`009    if (i > 0) `123
  236. X`009`009cp += i - 1;
  237. X`009`009*cp = '\0';
  238. X`009    `125
  239. X`009    break;
  240. X
  241. X`009case '\027':`009/* word erase */
  242. X`009    cp = op->op_string;
  243. X`009    i = strlen(cp);
  244. X`009    /* back up over blanks */
  245. X`009    while (--i >= 0 && isspace(cp`091i`093))
  246. X`009`009;
  247. X`009    i++;
  248. X`009    /* back up over non-blanks */
  249. X`009    while (--i >= 0 && !isspace(cp`091i`093))
  250. X`009`009;
  251. X`009    i++;
  252. X`009    cp`091i`093 = '\0';
  253. X`009    break;
  254. X
  255. X`009case '\025':
  256. X`009case '\030':
  257. X`009    op->op_string`0910`093 = '\0';
  258. X`009    break;
  259. X
  260. X`009default:
  261. X`009    if (data->key < 32 `124`124 data->key > 127) break;
  262. X`009    cp = op->op_string;
  263. X`009    i = strlen(cp);
  264. X`009    if (i < (op->op_size - 1) && !iscntrl(data->key)) `123
  265. X`009`009cp += i;
  266. X`009`009cp`0911`093 = '\0';
  267. X`009`009cp`0910`093 = data->key;
  268. X`009    `125 else
  269. X`009`009W_Beep();
  270. X`009`009break;
  271. X`009`125
  272. X    `125
  273. X
  274. X    /* Toggle int, if it exists */
  275. X    if (op->op_array) `123
  276. X`009(*op->op_option)++;
  277. X`009if (*(op->op_array)`091*op->op_option`093 == '\0') `123
  278. X`009    *op->op_option=0;
  279. X`009`125
  280. X    `125 else if (op->op_option) `123
  281. X`009*op->op_option = ! *op->op_option;
  282. X    `125
  283. X
  284. X    /* Map/unmap window, if it exists */
  285. X    if (op->op_targetwin) `123
  286. X`009if (W_IsMapped(*op->op_targetwin))
  287. X`009    W_UnmapWindow(*op->op_targetwin);
  288. X`009else
  289. X`009    W_MapWindow(*op->op_targetwin);
  290. X    `125
  291. X    if (!notdone)`009/* if done, that is */
  292. X`009optiondone();
  293. X    else
  294. X`009optionrefresh(op);
  295. X    return(1);
  296. X`125
  297. X
  298. Xoptiondone()
  299. X`123
  300. X    char *str;
  301. X
  302. X    /* Unmap window */
  303. X    W_UnmapWindow(optionWin);
  304. X
  305. X    for (str=newkeys; *str!='\0'; str+=2) `123
  306. X`009if (*str >= 32 && *str < 127 `124`124 *str == 'O') `123
  307. X`009    if (*(str+1)=='\0') break;
  308. X`009    mystats->st_keymap`091*str - 32`093= *(str+1);
  309. X`009`125
  310. X`009if (*(str+1)=='\0') break;
  311. X    `125
  312. X    *newkeys='\0';
  313. X    optionrefresh(&(option`091KEYMAP`093));
  314. X    sendOptionsPacket();
  315. X    sendUpdatePacket(uspeeds`091updateSpeed`093);
  316. X`125
  317. $ CALL UNPACK OPTION.C;1 84758759
  318. $ create/nolog 'f'
  319. X/*
  320. X * orbit.c
  321. X */
  322. X#include "copyright.h"
  323. X
  324. X#include <stdio.h>
  325. X#include <math.h>
  326. X#include <types.h>
  327. X#include "Wlib.h"
  328. X#include "defs.h"
  329. X#include "struct.h"
  330. X#include "data.h"
  331. X
  332. X/* orbit a planet */
  333. X
  334. Xorbit()
  335. X`123
  336. X    register int i;
  337. X    register struct planet *l;
  338. X    unsigned char dir;
  339. X    int dx, dy;
  340. X
  341. X
  342. X    if (me->p_speed > ORBSPEED ) `123
  343. X`009warning("Helmsman: Captain, the maximum safe speed for docking or orbiti
  344. Vng is warp 2!");
  345. X`009return;
  346. X    `125
  347. X
  348. X    me->p_flags &= `126PFORBIT;
  349. X
  350. X    if (me->p_flags & PFDOCK) `123
  351. X`009players`091me->p_docked`093.p_docked--;
  352. X`009players`091me->p_docked`093.p_port`091me->p_port`0910`093`093 = VACANT;
  353. X`009me->p_flags &= `126PFDOCK;
  354. X    `125
  355. X
  356. X    if (me->p_ship.s_type != STARBASE) `123
  357. X`009for (i=0; i<MAXPLAYER; i++) `123
  358. X`009    if (me->p_no == i)`032
  359. X`009`009continue;
  360. X`009    if (players`091i`093.p_ship.s_type != STARBASE)
  361. X`009`009continue;
  362. X`009    if (!isAlive(&players`091i`093))
  363. X`009`009continue;
  364. X`009    if (!friendlyPlayer(&players`091i`093))
  365. X`009`009continue;
  366. X`009    dx = ABS(players`091i`093.p_x - me->p_x);
  367. X`009    dy = ABS(players`091i`093.p_y - me->p_y);
  368. X`009    if (dx > DOCKDIST `124`124 dy > DOCKDIST)
  369. X`009`009continue;
  370. X`009`009
  371. X`009    dock(i);
  372. X`009    return;
  373. X`009`125
  374. X    `125
  375. X
  376. X    for (i = 0, l = &planets`091i`093; i < MAXPLANETS; i++, l++) `123
  377. X`009dx = ABS(l->pl_x - me->p_x);
  378. X`009dy = ABS(l->pl_y - me->p_y);
  379. X`009if (dx > ENTORBDIST `124`124 dy > ENTORBDIST)
  380. X`009    continue;
  381. X`009if (dx * dx + dy * dy > ENTORBDIST * ENTORBDIST)
  382. X`009    continue;
  383. X`009if (!(me->p_team & planets`091i`093.pl_owner) &&`032
  384. X`009        me->p_ship.s_type==STARBASE) `123
  385. X`009    warning("Central Command regulations prohibits you from orbiting for
  386. Veign planets");
  387. X`009    return;
  388. X`009`125
  389. X
  390. X`009dir = (unsigned char) (atan2((double) (me->p_x - l->pl_x),
  391. X`009`009`009`009     (double) (l->pl_y - me->p_y))
  392. X`009`009`009       / 3.14159 * 128.);
  393. X`009l->pl_info `124= me->p_team;
  394. X`009me->p_dir = dir + 64;
  395. X`009me->p_flags `124= PFORBIT;
  396. X`009me->p_x = l->pl_x + ORBDIST * Costab`091dir`093;
  397. X`009me->p_y = l->pl_y + ORBDIST * Sintab`091dir`093;
  398. X`009me->p_speed = me->p_desspeed = 0;
  399. X`009me->p_planet = l->pl_no;
  400. X`009return;
  401. X    `125
  402. X
  403. X    warning("Helmsman:  Sensors read no valid targets in range to dock or or
  404. Vbit sir!");
  405. X`125
  406. X
  407. X
  408. Xdock(base_id)
  409. X     int base_id;
  410. X`123
  411. X    int port_id=NUMPORTS;
  412. X    char buf`09180`093;
  413. X
  414. X    if (!(players`091base_id`093.p_flags & PFDOCKOK)) `123
  415. X`009sprintf(buf, "Starbase %s refusing us docking permission captain.",`032
  416. X`009    players`091base_id`093.p_name);
  417. X`009warning(buf);
  418. X`009return;
  419. X    `125
  420. X
  421. X    /* Try to dock on closest port, else pick first vacant port. */
  422. X    if ((me->p_x < players`091base_id`093.p_x && me->p_y < players`091base_i
  423. Vd`093.p_y) && (players`091base_id`093.p_port`0913`093 == VACANT)) `123`032
  424. X`009port_id = 3;
  425. X    `125 else if ((me->p_x < players`091base_id`093.p_x && me->p_y > players
  426. V`091base_id`093.p_y) && (players`091base_id`093.p_port`0912`093 == VACANT))
  427. V `123
  428. X`009port_id = 2;
  429. X    `125 else if ((me->p_x > players`091base_id`093.p_x && me->p_y > players
  430. V`091base_id`093.p_y) && (players`091base_id`093.p_port`0911`093 == VACANT))
  431. V `123
  432. X`009port_id = 1;
  433. X    `125 else if ((me->p_x > players`091base_id`093.p_x && me->p_y < players
  434. V`091base_id`093.p_y) && (players`091base_id`093.p_port`0910`093 == VACANT))
  435. V `123
  436. X`009port_id = 0;
  437. X    `125 else if (players`091base_id`093.p_port`0910`093 == VACANT) `123
  438. X`009port_id = 0;
  439. X    `125 else if (players`091base_id`093.p_port`0911`093 == VACANT) `123
  440. X`009port_id = 1;
  441. X    `125 else if (players`091base_id`093.p_port`0912`093 == VACANT) `123
  442. X`009port_id = 2;
  443. X    `125 else  if (players`091base_id`093.p_port`0913`093 == VACANT) `123
  444. X`009port_id = 3;
  445. X    `125
  446. X
  447. X    if (port_id < NUMPORTS) `123
  448. X`009me->p_x = players`091base_id`093.p_x + DOCKDIST * Costab`091(port_id*90+
  449. V45)*255/360`093;
  450. X`009me->p_y = players`091base_id`093.p_y + DOCKDIST * Sintab`091(port_id*90+
  451. +-+-+-+-+-+-+-+-  END  OF PART 31 +-+-+-+-+-+-+-+-
  452.  
  453.