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

  1. Newsgroups: vmsnet.sources.games
  2. Path: uunet!stanford.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!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 22/47
  5. Message-ID: <1992Nov13.135428.1@acad2.alaska.edu>
  6. Lines: 464
  7. Sender: news@raven.alaska.edu (USENET News System)
  8. Nntp-Posting-Host: acad2.alaska.edu
  9. Organization: University of Alaska
  10. Date: Fri, 13 Nov 1992 17:54:28 GMT
  11. Xref: uunet vmsnet.sources.games:508
  12.  
  13. -+-+-+-+-+-+-+-+ START OF PART 22 -+-+-+-+-+-+-+-+
  14. X`009`009    displayStartup(defname);
  15. X`009`009`125 else `123
  16. X`009`009    adjustString(ch, tempname, defname);
  17. X`009`009`125
  18. X`009`009break;
  19. X`009    case ST_GETPASS:
  20. X`009`009if (ch == 13) `123
  21. X`009`009    checkpassword();
  22. X`009`009    displayStartup(defname);
  23. X`009`009`125 else `123
  24. X`009`009    adjustString(ch, password1, defname);
  25. X`009`009`125
  26. X`009`009break;
  27. X`009    case ST_MAKEPASS1:
  28. X`009`009if (ch == 13) `123
  29. X`009`009    state=ST_MAKEPASS2;
  30. X`009`009    displayStartup(defname);
  31. X`009`009`125 else `123
  32. X`009`009    adjustString(ch, password1, defname);
  33. X`009`009`125
  34. X`009`009break;
  35. X`009    case ST_MAKEPASS2:
  36. X`009`009if (ch == 13) `123
  37. X`009`009    makeNewGuy();
  38. X`009`009    displayStartup(defname);
  39. X`009`009`125 else `123
  40. X`009`009    adjustString(ch, password2, defname);
  41. X`009`009`125
  42. X`009`009break;
  43. X`009    `125
  44. X`009`125
  45. X    `125
  46. X`125
  47. X
  48. Xloaddude()
  49. X/* Query dude.
  50. X */
  51. X`123
  52. X    if (strcmp(tempname, "Guest")==0 `124`124 strcmp(tempname, "guest")==0)
  53. V `123
  54. X`009loginAccept= -1;
  55. X`009sendLoginReq(tempname, "", passwd->pw_name, 0);
  56. X`009state = ST_DONE;
  57. X`009me->p_pos = -1;
  58. X`009me->p_stats.st_tticks = 1;`009/* prevent overflow */
  59. X`009strcpy(me->p_name, tempname);
  60. X`009while (loginAccept== -1) `123
  61. X`009    socketPause();
  62. X`009    readFromServer();
  63. X`009    if (isServerDead()) `123
  64. X`009`009printf("Server is dead!\n");
  65. X`009`009exit(0);
  66. X`009    `125
  67. X`009`125
  68. X`009if (loginAccept==0) `123
  69. X`009    printf("Hmmm... The SOB server won't let me log in as guest!\n");
  70. X`009    exit(0);
  71. X`009`125
  72. X`009return;
  73. X    `125
  74. X    /* Ask about the user */
  75. X    loginAccept= -1;
  76. X    sendLoginReq(tempname, "", passwd->pw_name, 1);
  77. X    while (loginAccept== -1) `123
  78. X`009socketPause();
  79. X`009readFromServer();
  80. X`009if (isServerDead()) `123
  81. X`009    printf("Server is dead!\n");
  82. X`009    exit(0);
  83. X`009`125
  84. X    `125
  85. X    *password1= *password2= 0;
  86. X    if (loginAccept==0) `123
  87. X`009state = ST_MAKEPASS1;
  88. X    `125 else `123
  89. X`009state = ST_GETPASS;
  90. X    `125
  91. X`125
  92. X
  93. Xcheckpassword()
  94. X/* Check dude's password.
  95. X * If he is ok, move to state ST_DONE.
  96. X */
  97. X`123
  98. X    char *s;
  99. X
  100. X    sendLoginReq(tempname, password1, passwd->pw_name, 0);
  101. X    loginAccept= -1;
  102. X    while (loginAccept== -1) `123
  103. X`009socketPause();
  104. X`009readFromServer();
  105. X`009if (isServerDead()) `123
  106. X`009    printf("Server is dead!\n");
  107. X`009    exit(0);
  108. X`009`125
  109. X    `125
  110. X    if (loginAccept==0) `123
  111. X`009s = "Bad password!";
  112. X`009W_WriteText(w, 100, 100, textColor, s, strlen(s), W_BoldFont);
  113. X`009(void) W_EventsPending();
  114. X`009sleep(3);
  115. X`009W_ClearWindow(w);
  116. X`009*tempname=0;
  117. X`009state=ST_GETNAME;
  118. X`009return;
  119. X    `125
  120. X    strcpy(me->p_name, tempname);
  121. X    showShields = (me->p_stats.st_flags / ST_SHOWSHIELDS) & 1;`032
  122. X    mapmode = (me->p_stats.st_flags / ST_MAPMODE) & 1;
  123. X    namemode = (me->p_stats.st_flags / ST_NAMEMODE) & 1;
  124. X    keeppeace = (me->p_stats.st_flags / ST_KEEPPEACE) & 1;
  125. X    showlocal = (me->p_stats.st_flags / ST_SHOWLOCAL) & 3;
  126. X    showgalactic = (me->p_stats.st_flags / ST_SHOWGLOBAL) & 3;
  127. X    state = ST_DONE;
  128. X`125
  129. X
  130. XmakeNewGuy()
  131. X/* Make the dude with name tempname and password password1.
  132. X * Move to state ST_DONE.
  133. X */
  134. X`123
  135. X    char *s;
  136. X
  137. X    if (strcmp(password1, password2) != 0) `123
  138. X`009s = "Passwords do not match";
  139. X`009W_WriteText(w, 100, 120, textColor, s, strlen(s), W_BoldFont);
  140. X`009(void) W_EventsPending();
  141. X`009sleep(3);
  142. X`009W_ClearWindow(w);
  143. X`009*tempname=0;
  144. X`009state=ST_GETNAME;
  145. X`009return;
  146. X    `125
  147. X   `032
  148. X    /* same routine! */
  149. X    checkpassword();
  150. X`125
  151. X
  152. XadjustString(ch, str, defname)
  153. Xchar ch, *str;
  154. Xchar *defname;
  155. X`123
  156. X    if (ch == 21) `123
  157. X`009*str='\0';
  158. X`009if (state==ST_GETNAME) displayStartup(defname);
  159. X    `125 else if (ch == 8 `124`124 ch=='\177') `123
  160. X`009if (strlen(str)>0) `123
  161. X`009    str`091strlen(str)-1`093='\0';
  162. X`009    if (state==ST_GETNAME) displayStartup(defname);
  163. X`009`125
  164. X    `125 else `123
  165. X`009if (strlen(str)==15) return;
  166. X`009str`091strlen(str)+1`093='\0';
  167. X`009str`091strlen(str)`093= ch;
  168. X`009if (state==ST_GETNAME) displayStartup(defname);
  169. X    `125
  170. X`125
  171. X
  172. XdisplayStartup(defname)
  173. Xchar *defname;
  174. X/* Draws entry screen based upon state. */
  175. X`123
  176. X    char s`091100`093;
  177. X    char *t;
  178. X
  179. X    if (state == ST_DONE) return;
  180. X    t = "Enter your name.  Use the name 'guest' to remain anonymous.";
  181. X    W_WriteText(w, 100, 30, textColor, t, strlen(t), W_BoldFont);
  182. X    t = "Type `094D (Ctrl - D) to quit.";
  183. X    W_WriteText(w, 100, 40, textColor, t, strlen(t), W_BoldFont);
  184. X    sprintf(s, "Your name (default = %s): %s               ", defname, tempn
  185. Vame);
  186. X    W_WriteText(w, 100, 50, textColor, s, strlen(s), W_BoldFont);
  187. X    if (state==ST_GETPASS) `123
  188. X`009t = "Enter password: ";
  189. X`009W_WriteText(w, 100, 60, textColor, t, strlen(t), W_BoldFont);
  190. X    `125
  191. X    if (state>ST_GETPASS) `123
  192. X`009t = "You need to make a password.";
  193. X`009W_WriteText(w, 100, 70, textColor, t, strlen(t), W_BoldFont);
  194. X`009t = "So think of a password you can remember, and enter it.";
  195. X`009W_WriteText(w, 100, 80, textColor, t, strlen(t), W_BoldFont);
  196. X`009t = "What is your password? :";
  197. X`009W_WriteText(w, 100, 90, textColor, t, strlen(t), W_BoldFont);
  198. X    `125
  199. X    if (state==ST_MAKEPASS2) `123
  200. X`009t = "Enter it again to make sure you typed it right.";
  201. X`009W_WriteText(w, 100, 100, textColor, t, strlen(t), W_BoldFont);
  202. X`009t = "Your password? :";
  203. X`009W_WriteText(w, 100, 110, textColor, t, strlen(t), W_BoldFont);
  204. X    `125
  205. X`125
  206. X
  207. $ CALL UNPACK GETNAME.C;1 710794459
  208. $ create/nolog 'f'
  209. X/*
  210. X * getship.c for client of socket protocol.
  211. X *
  212. X * This file has been mangled so it only sets the ship characteristics neede
  213. Vd.
  214. X */
  215. X#include "copyright.h"
  216. X
  217. X#include <stdio.h>
  218. X#include <types.h>
  219. X#include "Wlib.h"
  220. X#include "defs.h"
  221. X#include "struct.h"
  222. X#include "data.h"
  223. X
  224. X/* fill in ship characteristics */
  225. X
  226. Xgetship(shipp, s_type)
  227. Xstruct ship *shipp;
  228. Xint s_type;
  229. X`123
  230. X    switch (s_type) `123
  231. X    case SCOUT:
  232. X`009    shipp->s_type = SCOUT;
  233. X`009    shipp->s_torpspeed = 16;
  234. X`009    shipp->s_phaserdamage = 75;
  235. X`009    shipp->s_maxspeed = 12;
  236. X`009    shipp->s_maxfuel = 5000;
  237. X`009    shipp->s_maxarmies = 2;
  238. X`009    shipp->s_maxshield = 75;`032
  239. X`009    shipp->s_maxdamage = 75;
  240. X`009    shipp->s_maxwpntemp = 1000;
  241. X`009    shipp->s_maxegntemp = 1200;
  242. X`009    shipp->s_width = 20;
  243. X`009    shipp->s_height = 20;
  244. X`009    break;
  245. X    case DESTROYER:
  246. X`009    shipp->s_type = DESTROYER;
  247. X`009    shipp->s_torpspeed = 14;
  248. X`009    shipp->s_phaserdamage = 85;
  249. X`009    shipp->s_maxspeed = 10;
  250. X`009    shipp->s_maxfuel = 7000;
  251. X`009    shipp->s_maxarmies = 5;
  252. X`009    shipp->s_maxshield = 85;
  253. X`009    shipp->s_maxdamage = 85;
  254. X`009    shipp->s_maxwpntemp = 1000;
  255. X`009    shipp->s_maxegntemp = 1000;
  256. X`009    shipp->s_width = 20;
  257. X`009    shipp->s_height = 20;
  258. X`009    break;
  259. X    case BATTLESHIP:`032
  260. X`009    shipp->s_type = BATTLESHIP;
  261. X`009    shipp->s_torpspeed = 12;
  262. X`009    shipp->s_phaserdamage = 105;
  263. X`009    shipp->s_maxspeed = 8;
  264. X`009    shipp->s_maxfuel = 14000;
  265. X`009    shipp->s_maxarmies = 6;
  266. X`009    shipp->s_maxshield = 130;
  267. X`009    shipp->s_maxdamage = 130;
  268. X`009    shipp->s_maxwpntemp = 1000;
  269. X`009    shipp->s_maxegntemp = 1000;
  270. X`009    shipp->s_width = 20;
  271. X`009    shipp->s_height = 20;
  272. X`009    break;
  273. X    case ASSAULT:
  274. X`009    shipp->s_type = ASSAULT;
  275. X`009    shipp->s_torpspeed = 16;
  276. X`009    shipp->s_phaserdamage = 80;
  277. X`009    shipp->s_maxspeed = 8;
  278. X`009    shipp->s_maxfuel = 6000;
  279. X`009    shipp->s_maxarmies = 20;
  280. X`009    shipp->s_maxshield = 80;
  281. X`009    shipp->s_maxdamage = 200;
  282. X`009    shipp->s_maxwpntemp = 1000;
  283. X`009    shipp->s_maxegntemp = 1200;
  284. X`009    shipp->s_width = 20;
  285. X`009    shipp->s_height = 20;
  286. X`009    break;
  287. X    case STARBASE:
  288. X`009    shipp->s_type = STARBASE;
  289. X`009    shipp->s_torpspeed = 14;
  290. X`009    shipp->s_phaserdamage = 120;
  291. X`009    shipp->s_maxspeed = 2;
  292. X`009    shipp->s_maxfuel = 60000;
  293. X`009    shipp->s_maxarmies = 25;
  294. X`009    shipp->s_maxshield = 500;
  295. X`009    shipp->s_maxdamage = 600;
  296. X`009    shipp->s_maxwpntemp = 1300;
  297. X`009    shipp->s_maxegntemp = 1000;
  298. X`009    shipp->s_width = 20;
  299. X`009    shipp->s_height = 20;
  300. X`009    break;
  301. X    case GALAXY:`009/* ATM - Galaxy */
  302. X            shipp->s_type = GALAXY;
  303. X            shipp->s_torpspeed = 13;
  304. X            shipp->s_phaserdamage = 100;
  305. X            shipp->s_maxspeed = 9;
  306. X            shipp->s_maxfuel = 12000;
  307. X            shipp->s_maxarmies = 12;
  308. X            shipp->s_maxshield = 120;`009/* ATM: was 140 */
  309. X            shipp->s_maxdamage = 120;
  310. X            shipp->s_maxwpntemp = 1000;
  311. X            shipp->s_maxegntemp = 1000;
  312. X            shipp->s_width = 20;
  313. X            shipp->s_height = 20;
  314. X            break;  `032
  315. X    case ATT:`009`009/* ATM */
  316. X            shipp->s_type = ATT;
  317. X            shipp->s_torpspeed = 30;
  318. X            shipp->s_phaserdamage = 10000;
  319. X            shipp->s_maxspeed = 60;
  320. X            shipp->s_maxfuel = 60000;
  321. X            shipp->s_maxarmies = 999;`009`009/* 1000 */
  322. X            shipp->s_maxshield = 999;`009`009/* 30000 */
  323. X            shipp->s_maxdamage = 999;`009`009/* 30000 */
  324. X            shipp->s_maxwpntemp = 9999;`009`009/* 10000 */
  325. X            shipp->s_maxegntemp = 9999;`009`009/* 10000 */
  326. X            shipp->s_width = 20;
  327. X            shipp->s_height = 20;
  328. X`009    break;
  329. X    case CRUISER:
  330. X    default:
  331. X`009    shipp->s_type = CRUISER;
  332. X`009    shipp->s_torpspeed = 12;
  333. X`009    shipp->s_phaserdamage = 100;
  334. X`009    shipp->s_maxspeed = 9;
  335. X`009    shipp->s_maxfuel = 10000;
  336. X`009    shipp->s_maxarmies = 10;
  337. X`009    shipp->s_maxshield = 100;
  338. X`009    shipp->s_maxdamage = 100;
  339. X`009    shipp->s_maxwpntemp = 1000;
  340. X`009    shipp->s_maxegntemp = 1000;
  341. X`009    shipp->s_width = 20;
  342. X`009    shipp->s_height = 20;
  343. X`009    break;
  344. X    `125
  345. X`125
  346. X
  347. $ CALL UNPACK GETSHIP.C;1 561114538
  348. $ create/nolog 'f'
  349. X/*
  350. X * inform.c
  351. X */
  352. X#include "copyright.h"
  353. X
  354. X#include <stdio.h>
  355. X#include <math.h>
  356. X#include <signal.h>
  357. X#include "Wlib.h"
  358. X#include "defs.h"
  359. X#include "struct.h"
  360. X#include "data.h"
  361. X
  362. X/* Display information about the nearest object to mouse */
  363. X
  364. X/*
  365. X** When the player asks for info, this routine finds the object
  366. X** nearest the mouse, either player or planet, and pop up a window
  367. X** with the desired information in it.
  368. X**`032
  369. X** We intentionally provide less information than is actually
  370. X** available.  Keeps the fog of war up.
  371. X**
  372. X** There is a different sized window for each type player/planet
  373. X** and we take care to keep it from extending beyond the main
  374. X** window boundaries.
  375. X*/
  376. X
  377. Xstatic char *classes`091NUM_TYPES`093 = `123
  378. X    "SC", "DD", "CA", "BB", "AS", "SB", "GA", "??"`009/* ATM - Galaxy */
  379. X   `125;
  380. X
  381. Xinform(ww, x, y, key)
  382. XW_Window ww;
  383. Xint x, y;
  384. Xchar key;
  385. X`123
  386. X    char buf`091BUFSIZ`093;
  387. X    int line = 0;
  388. X    register struct player *j;
  389. X    register struct planet *k;
  390. X    int mx, my;
  391. X    double dist;
  392. X    struct obtype *gettarget(), *target;
  393. X    int windowWidth, windowHeight;
  394. X
  395. X    mx=x;
  396. X    my=y;
  397. X    infomapped = 1;
  398. X    if (key == 'i') `123
  399. X`009target = gettarget(ww, x, y, TARG_PLAYER`124TARG_PLANET);
  400. X    `125 else `123
  401. X`009target = gettarget(ww, x, y, TARG_PLAYER`124TARG_SELF);
  402. X    `125
  403. X
  404. X    /* This is pretty lame.  We make a graphics window for the info window
  405. X     *  so we can accurately space the thing to barely fit into the galactic
  406. X     *  map or whatever.
  407. X     */
  408. X
  409. X    windowWidth=W_WindowWidth(ww);
  410. X    windowHeight=W_WindowHeight(ww);
  411. X    if (target->o_type == PLAYERTYPE) `123
  412. X`009/* Too close to the edge? */
  413. X`009if (mx + 23 * W_Textwidth + 2 > windowWidth)
  414. X`009    mx = windowWidth - 23 * W_Textwidth - 2;
  415. X`009if (my + 8 * W_Textheight + 2 > windowHeight)
  416. X`009    my = windowHeight - 8 * W_Textheight - 2;
  417. X
  418. X`009infow = W_MakeWindow("info", mx, my, 23*W_Textwidth, 8*W_Textheight,`032
  419. X`009    ww, 2,foreColor);
  420. X`009W_MapWindow(infow);
  421. X`009j = &players`091target->o_num`093;
  422. X`009(void) sprintf(buf, "%s (%c%c):", j->p_name, teamlet`091j->p_team`093, s
  423. Vhipnos`091j->p_no`093);
  424. X`009W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j), buf
  425. V, strlen(buf), shipFont(j));
  426. X`009if (key == 'i') `123
  427. X`009    dist = hypot((double) (me->p_x - j->p_x),
  428. X`009`009(double) (me->p_y - j->p_y));
  429. X`009    (void) sprintf(buf, "Login   %-s", j->p_login);
  430. X`009    W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  431. V buf, strlen(buf),
  432. X`009`009W_RegularFont);
  433. X`009    (void) sprintf(buf, "Display %-s", j->p_monitor);
  434. X`009    W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  435. V buf, strlen(buf),
  436. X`009`009W_RegularFont);
  437. X`009    (void) sprintf(buf, "Speed   %-d", j->p_speed);
  438. X`009    W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  439. V buf, strlen(buf),
  440. X`009`009W_RegularFont);
  441. X
  442. X`009    (void) sprintf(buf, "kills   %-4.2f", j->p_kills);
  443. X`009    W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  444. V buf, strlen(buf),
  445. X`009`009W_RegularFont);
  446. X`009    (void) sprintf(buf, "dist    %-d", (int) dist);
  447. X`009    W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  448. V buf, strlen(buf),
  449. X`009`009W_RegularFont);
  450. X`009    (void) sprintf(buf, "S-Class %-s", classes`091j->p_ship.s_type`093);
  451. X`009    W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  452. V buf, strlen(buf),
  453. X`009`009W_RegularFont);
  454. X`009   `032
  455. X`009    if (j->p_swar & me->p_team)
  456. X`009`009W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  457. V "WAR", 3,
  458. X`009`009    W_RegularFont);
  459. X`009    else if (j->p_hostile & me->p_team)
  460. X`009`009W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  461. V "HOSTILE", 7,
  462. X`009`009    W_RegularFont);
  463. X`009    else
  464. X`009`009W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  465. V "PEACEFUL", 8,
  466. X`009`009    W_RegularFont);
  467. X`009`125 else `123`009/* New information window! */
  468. X`009    strcpy(buf, "        Rating Total");
  469. X`009    W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  470. V buf, strlen(buf),
  471. X`009`009W_RegularFont);
  472. X`009    sprintf(buf, "Bombing: %5.2f  %5d",`032
  473. X`009`009bombingRating(j),
  474. X`009`009j->p_stats.st_armsbomb + j->p_stats.st_tarmsbomb);
  475. X`009    W_WriteText(infow, W_Textwidth, W_Textheight*line++, playerColor(j),
  476. +-+-+-+-+-+-+-+-  END  OF PART 22 +-+-+-+-+-+-+-+-
  477.