home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
vmsnet.sources.games
/
vmsnetrek
/
part27
< prev
next >
Wrap
Text File
|
1992-11-14
|
15KB
|
533 lines
Newsgroups: vmsnet.sources.games
Path: uunet!stanford.edu!agate!spool.mu.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!news.u.washington.edu!raven.alaska.edu!acad2.alaska.edu!asdmf
From: asdmf@acad2.alaska.edu
Subject: Vmsnetrek 27/47
Message-ID: <1992Nov13.140910.1@acad2.alaska.edu>
Lines: 520
Sender: news@raven.alaska.edu (USENET News System)
Nntp-Posting-Host: acad2.alaska.edu
Organization: University of Alaska
Date: Fri, 13 Nov 1992 18:09:10 GMT
Xref: uunet vmsnet.sources.games:515
-+-+-+-+-+-+-+-+ START OF PART 27 -+-+-+-+-+-+-+-+
X`009`009me->p_ghostbuster = 0;
X`009`009tv.tv_sec = 1;
X`009`009tv.tv_usec = 0;
X`009`009/* If we don't have a socket, we go nuts polling. */
X`009`009if (W_Socket() != -1) `123
X`009`009 mask = 1 << W_Socket();
X`009`009 select(32, &mask, 0, 0, &tv);
X`009`009`125
X`009`009elapsed = time(0) - startTime;
X`009`009if (elapsed > AUTOQUIT) `123
X`009`009 printf("Auto-Quit.\n");
X`009`009 *team = 4;
X`009`009 break;
X`009`009`125
X`009`009if (lasttime != time(0)) `123
X`009`009 showTimeLeft(elapsed, AUTOQUIT);
X`009`009 lasttime=time(0);
X`009`009`125
X
X`009`009okayMask = tournMask;
X
X for (i = 0; i < 4; i++) `123
X if ((okayMask `094 lastOkayMask) & (1 << i)) `123
X if (okayMask & (1 << i)) `123
X`009`009`009 W_UnTileWindow(teamWin`091i`093);
X `125 else `123
X`009`009`009 W_TileWindow(teamWin`091i`093, stipple);
X `125
X lastplayercount`091i`093 = -1; /* force updat
Ve */
X `125
X redrawTeam(teamWin`091i`093, i, &lastplayercount`091i`09
V3);
X `125
X lastOkayMask = okayMask;
X`009 `125
X`009 if (*team == 4)
X`009`009break;
X`009 `032
X`009 if (time(0) - startTime <= spareTime) `123
X`009`009spareTime -= time(0) - startTime;
X`009`009startTime = time(0);
X`009 `125 else `123
X`009`009startTime += spareTime;
X`009`009spareTime = 0;
X`009 `125
X`009 if (!W_EventsPending()) continue;
X`009 W_NextEvent(&event);
X`009 typeok=1;
X`009 switch ((int) event.type) `123
X`009 case W_EV_KEY:
X`009`009switch (event.key) `123
X`009`009case 's': *s_type = SCOUT;
X`009`009`009 break;
X`009`009case 'd': *s_type = DESTROYER;
X`009`009`009 break;
X`009`009case 'c': *s_type = CRUISER;
X`009`009`009 break;
X`009`009case 'b': *s_type = BATTLESHIP;
X`009`009`009 break;
X`009`009case 'a': *s_type = ASSAULT;
X`009`009`009 break;
X`009`009case 'o': *s_type = STARBASE;
X`009`009`009 break;`009`009/* FIX */
X`009`009case 'g': *s_type = GALAXY;`009/* ATM - Galaxy */
X`009`009`009 break;
X`009`009case '*': *s_type = ATT;
X`009`009`009 break;
X`009`009default: typeok = 0;
X`009`009`009 break;
X`009`009`125
X`009`009if (event.Window == w) `123
X`009`009 switch(event.key) `123
X`009`009 case 'y':
X`009`009`009if (resetting) `123
X`009`009`009 sendResetStatsReq('Y');
X`009`009`009 warning("OK, your stats have been reset.");
X`009`009`009 resetting=0;
X`009`009`009`125
X`009`009`009break;
X`009`009 case 'n':
X`009`009`009if (resetting) `123
X`009`009`009 warning("I didn't think so.");
X`009`009`009 resetting=0;
X`009`009`009`125
X`009`009`009break;
X`009`009 case 'R':
X`009`009`009warning("Are you sure you want to reset your stats?");
X`009`009`009resetting=1;
X`009`009`009break;
X`009`009 case 'f':`009`009/* Scroll motd forward */
X`009`009`009line=line+28;
X`009`009`009if (line>maxline) `123
X`009`009`009 line=line-28;
X`009`009`009 break;
X`009`009`009`125
X`009`009`009showMotd();
X`009`009`009break;
X`009`009 case 'b':`009`009/* Scroll motd backward */
X`009`009`009if (line==0) break;
X`009`009`009line=line-28;
X`009`009`009if (line<0) line=0;
X`009`009`009showMotd();
X`009`009`009break;
X`009`009 `125
X`009`009`125
X`009`009/* No break, we just fall through */
X`009 case W_EV_BUTTON:
X`009`009if (typeok == 0) break;
X`009`009for (i = 0; i < 4; i++)
X`009`009 if (event.Window == teamWin`091i`093) `123
X`009`009`009*team = i;
X`009`009`009break;
X`009`009 `125
X`009`009if (event.Window == qwin)`123
X`009`009 *team = 4;
X`009`009 break;
X`009`009`125
X`009`009if (*team!=-1 && !teamRequest(*team, *s_type)) `123
X`009`009 *team= -1;
X`009`009`125
X`009`009break;
X`009 case W_EV_EXPOSE:
X`009`009for (i = 0; i < 4; i++)
X`009`009 if (event.Window == teamWin`091i`093) `123
X`009`009`009lastplayercount`091i`093 = -1; /* force update */
X`009`009`009redrawTeam(teamWin`091i`093, i, &lastplayercount`091i`093);
X`009`009`009break;
X`009`009 `125
X`009`009if (event.Window == qwin)
X`009`009 redrawQuit();
X`009`009else if (event.Window == tstatw)
X`009`009 redrawTstats();
X`009`009else if (event.Window == iconWin)
X`009`009 drawIcon();
X`009`009else if (event.Window == w)
X`009`009 showMotd();
X`009`009else if (event.Window == helpWin)
X`009`009 fillhelp();
X`009`009else if (event.Window == playerw)`032
X`009`009 playerlist();
X`009`009else if (event.Window == warnw)`032
X`009`009 W_ClearWindow(warnw);
X`009`009else if (event.Window == messagew)
X`009`009 W_ClearWindow(messagew);
X`009`009break;
X`009 `125
X `125 while (*team < 0);
X if (event.Window != qwin)
X`009warning("Welcome aboard Captain!");
X
X if (*team == 4) `123
X`009*team = -1;
X `125
X`009`009`009`009
X for (i = 0; i < 4; i++)
X W_UnmapWindow(teamWin`091i`093);
X W_UnmapWindow(qwin);
X`125
X
X/* Attempt to pick specified team & ship */
XteamRequest(team, ship)`032
Xint team,ship;
X`123
X int lastTime;
X
X pickOk= -1;
X sendTeamReq(team,ship);
X lastTime=time(NULL);
X while (pickOk == -1) `123
X`009if (lastTime+3 < time(NULL)) `123
X`009 sendTeamReq(team,ship);
X`009`125
X`009socketPause();
X`009readFromServer();
X`009if (isServerDead()) `123
X`009 printf("Whoops! We've been ghostbusted!\n");
X`009 printf("Pray for a miracle!\n");
X`009 /* UDP fail-safe */
X`009 commMode = commModeReq = COMM_TCP;
X`009 commSwitchTimeout = 0;
X`009 if (udpSock >= 0)
X`009`009closeUdpConn();
X`009 if (udpWin) `123
X`009`009udprefresh(UDP_CURRENT);
X`009`009udprefresh(UDP_STATUS);
X`009 `125
X`009 connectToServer(nextSocket);
X`009 printf("Yea! We've been resurrected!\n");
X`009 pickOk=0;
X`009 break;
X`009`125
X `125
X return(pickOk);
X`125
X
XnumShips(owner)
X`123
X`009int`009`009i, num = 0;
X`009struct player`009*p;
X
X`009for (i = 0, p = players; i < MAXPLAYER; i++, p++)
X`009`009if (p->p_status == PALIVE && p->p_team == owner)
X`009`009`009num++;
X`009return (num);
X`125
X
XrealNumShips(owner)
X`123
X`009int`009`009i, num = 0;
X`009struct player`009*p;
X
X`009for (i = 0, p = players; i < MAXPLAYER; i++, p++)
X`009`009if (p->p_status != PFREE &&`032
X`009`009 p->p_team == owner)
X`009`009`009num++;
X`009return (num);
X`125
X
XdeadTeam(owner)
Xint owner;
X/* The team is dead if it has no planets and cannot coup it's home planet */
X`123
X int i,num=0;
X struct planet *p;
X
X if (planets`091remap`091owner`093*10-10`093.pl_couptime == 0) return(0);
X for (i=0, p=planets; i<MAXPLANETS; i++,p++) `123
X`009if (p->pl_owner & owner) `123
X`009 num++;
X`009`125
X `125
X if (num!=0) return(0);
X return(1);
X`125
X
Xstatic char`009*AUTHOR`091`093 = `123
X "",
X "--- XtrekII Release Version 6.1 ---",
X "",
X "By Chris Guthrie, Ed James,",
X "Scott Silvey (scott@scam), and Kevin Smith (ksmith@miro)",
X "",
X "Amdahl UDP Version",`009`009/* UDP */
X`125;
X
XcheckBold(line)
X/* Determine if that line should be highlighted on sign-on screen */
X/* Which is done when it is the players own score being displayed */
Xchar *line;
X`123
X char *s, *t;
X int i;
X int end=0;
X
X if (strlen(line) < 60) return(0);
X s = line+4;
X t = me->p_name;
X
X for (i=0; i<16; i++) `123
X`009if (!end) `123
X`009 if (*t == '\0') end=1;
X`009 else if (*t != *s) return(0);
X`009`125
X`009if (end) `123
X`009 if (*s != ' ') return(0);
X`009`125
X`009s++;
X`009t++;
X `125
X return(1);
X`125
X
Xstruct list `123
X char bold;
X struct list *next;
X char *data;
X`125;
Xstatic struct list *motddata = NULL;
X
XshowMotd()
X`123
X FILE *fopen();
X int`009i, length, top, center;
X struct list *data;
X static int first=1;
X int count;
X
X W_ClearWindow(w);
X for (i = 0; i < SIZEOF(AUTHOR); i++) `123
X`009length = strlen(AUTHOR`091i`093);
X`009center = WINSIDE / 2 - (length * W_Textwidth) / 2;
X`009W_WriteText(w, center, i*W_Textheight, textColor, AUTHOR`091i`093, lengt
Vh,
X`009 W_RegularFont);
X `125
X top = SIZEOF(AUTHOR) + 5;`009`009/* UDP: was 7 */
X
X if (first) `123
X`009first=0;
X`009data=motddata;
X`009while (data!=NULL) `123
X`009 data->bold=checkBold(data->data);
X`009 data=data->next;
X`009`125
X `125
X
X data=motddata;
X for (i=0; i<line; i++) `123
X`009if (data==NULL) `123
X`009 line=0;
X`009 data=motddata;
X`009 break;
X`009`125
X`009data=data->next;
X `125
X count=28;`009/* Magical # of lines to display */
X for (i=top; i<50; i++) `123
X`009if (data==NULL) break;
X`009if (!strcmp(data->data, "\t@@@"))`009`009/* ATM */
X`009 break;
X`009if (data->bold) `123
X`009 W_WriteText(w, 20, i*W_Textheight, textColor, data->data,
X`009`009strlen(data->data), W_BoldFont);
X`009`125 else `123
X`009 W_WriteText(w, 20, i*W_Textheight, textColor, data->data,
X`009`009strlen(data->data), W_RegularFont);
X`009`125
X`009data=data->next;
X`009count--;
X`009if (count<=0) break;
X `125
X
X showValues(data);
X`125
X
X/*
X * ATM: show the current values of the .sysdef parameters.
X */
XshowValues(data)
Xstruct list *data;
X`123
X int i;
X static char *msg = "OPTIONS SET WHEN YOU STARTED WERE:";
X
X /* try to find the start of the info */
X while (1) `123
X`009if (data == NULL) return;
X`009if (!strcmp(data->data, STATUS_TOKEN))
X`009 break;
X`009data = data->next;
X `125
X data = data->next;
X
X W_WriteText(mapw, 20, 14*W_Textheight, textColor, msg,
X`009strlen(msg), W_RegularFont);
X for (i = 16; i < 50; i += 2) `123
X`009if (data == NULL) break;
X`009if (data->data`0910`093 == '+')`009/* quick boldface hack */
X`009 W_WriteText(mapw, 20, i*W_Textheight, textColor, data->data+1,
X`009`009strlen(data->data)-1, W_BoldFont);
X`009else
X`009 W_WriteText(mapw, 20, i*W_Textheight, textColor, data->data,
X`009`009strlen(data->data), W_RegularFont);
X`009data = data->next;
X `125
X`125
X
XnewMotdLine(line)
Xchar *line;
X`123
X static struct list **temp = &motddata;
X static int statmode = 0;`009`009`009/* ATM */
X
X if (!statmode && !strcmp(line, STATUS_TOKEN))
X`009statmode = 1;
X if (!statmode) maxline++;`009`009`009/* ATM - don't show on left */
X (*temp) = (struct list *) malloc(sizeof(struct list));
X (*temp)->next = NULL;
X (*temp)->data = malloc(strlen(line)+1);
X strcpy((*temp)->data, line);
X temp= &((*temp)->next);
X`125
X
XgetResources(prog)
Xchar`009*prog;
X`123
X getColorDefs(prog);
X getTiles();
X`125
X
XgetTiles()
X`123
X stipple = W_StoreBitmap(stipple_width, stipple_height, stipple_bits, w);
X`125
X
XredrawTeam(win, teamNo, lastnum)
XW_Window win;
Xint *lastnum;
X`123
X char buf`091BUFSIZ`093;
X static char *teams`091`093 = `123 "Federation", "Romulan", "Klingon", "O
Vrion" `125;
X int num = numShips(1 << teamNo);
X
X /* Only redraw if number of players has changed */
X if (*lastnum == num)
X return;
X
X W_ClearWindow(win);
X W_WriteText(win, 5, 5, shipCol`091teamNo + 1`093, teams`091teamNo`093,`0
V32
X`009strlen(teams`091teamNo`093), W_RegularFont);
X (void) sprintf(buf, "%d", num);
X W_MaskText(win, 5, 46, shipCol`091teamNo + 1`093, buf, strlen(buf),`032
X`009W_BigFont);
X *lastnum = num;
X`125
X
XredrawQuit()
X`123
X W_WriteText(qwin, 5, 5, textColor, "Quit xtrek", 10, W_RegularFont);
X`125
X
Xchar *help_message`091`093 = `123
X "0-9 Set speed",
X ") speed = 10",
X "! speed = 11",
X "@ speed = 12",
X "k Set course",
X "p Fire phaser",
X "t Fire photon torpedo",
X "f Fire plasma torpedo",
X "a Use scanning beam",
X "d Detonate enemy torps",
X "D Detonate own torps",
X "L List players",
X "P List planets",
X "S Status graph toggle",
X "M Turn on/off map window updating",
X "`093 Put up shields",
X "`091 Put down shields",
X "u Shield toggle",
X "i Info on player/planet",
X "I Extended info on player",
X "b Bomb planet",
X "z Beam up armies",
X "x Beam down armies",
X "T Toggle tractor beam",
X "y Toggle pressor beam",
X "R Enter repair mode",
X "o Orbit planet or dock to outpost",
X "e Docking permission toggle",
X "r Change vessels (ship type)",
X "Q Quit",
X "? Message window toggle",
X "c Cloaking device toggle",
X "C Coup a planet",
X "l Lock on to player/planet",
X "h Help window toggle",
X "w War declarations window",
X "N Planet names toggle",
X "V Rotate local planet display",
X "B Rotate galactic planet display",
X "E Send distress call",
X "* Send in practice robot",
X "U Show rankings window",
X "+ Show UDP options window",
X "= Update all",
X "Space Remove info, planet, rank windows",
X 0,
X`125;
X
X#define MAXHELP 40
X
Xfillhelp()
X`123
X register int i = 0, row, column;
X
X W_ClearWindow(helpWin);
X for (column = 0; column < 4; column++) `123
X`009for (row = 1; row < 12; row++) `123
X`009 if (help_message`091i`093 == 0)
X`009`009break;
X`009 else `123
X`009`009W_WriteText(helpWin, MAXHELP * column, row, textColor,
X`009`009 help_message`091i`093, strlen(help_message`091i`093), W_RegularF
Vont);
X`009`009i++;
X`009 `125
X`009`125
X`009if (help_message`091i`093 == 0)
X`009 break;
X `125
X`125
X
XdrawIcon()
X`123
X W_WriteBitmap(0, 0, icon, W_White);
X`125
X
X#define CLOCK_WID`009(BOXSIDE * 9 / 10)
X#define CLOCK_HEI`009(BOXSIDE * 2 / 3)
X#define CLOCK_BDR`0090
X#define CLOCK_X`009`009(BOXSIDE / 2 - CLOCK_WID / 2)
X#define CLOCK_Y`009`009(BOXSIDE / 2 - CLOCK_HEI / 2)
X
X#define PI`009`0093.141592654
X
XshowTimeLeft(time, max)
Xint time, max;
X`123
X char`009buf`091BUFSIZ`093, *cp;
X int`009cx, cy, ex, ey, tx, ty;
X
X if ((max - time) < 10 && time & 1) `123
X`009W_Beep();
X `125
+-+-+-+-+-+-+-+- END OF PART 27 +-+-+-+-+-+-+-+-