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

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