Permalink
Switch branches/tags
Nothing to show
Find file Copy path
ef60915 Aug 18, 2013
1 contributor

Users who have contributed to this file

9787 lines (8360 sloc) 299 KB
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#include "types.h"
#include "develop.h"
#include "scriplib.h"
#include "file_lib.h"
#include "gamedefs.h"
#include "keyboard.h"
#include "util_lib.h"
#include "function.h"
#include "control.h"
#include "fx_man.h"
#include "sounds.h"
#include "config.h"
#include "sndcards.h"
#include "duke3d.h"
#ifdef VOLUMEONE
#define VERSION "1.4"
#else
#define VERSION "1.4"
#endif
#define HEAD "Duke Nukem 3D Unregistered Shareware v"VERSION" "
#ifdef PLUTOPAK
#define HEAD2 "Duke Nukem 3D v"VERSION" - Atomic Edition"
#else
#define HEAD2 "Duke Nukem 3D Full Version v"VERSION
#endif
#define HEADA "Duke Nukem 3D AUSSIE Unregistered Shareware v"VERSION
#define HEAD2A "Duke Nukem 3D AUSSIE Full Version v"VERSION
#define IDFSIZE 479985668
// #define IDFSIZE 9961476
// #define IDFSIZE 16384
#define IDFILENAME "DUKE3D.IDF"
#define TIMERUPDATESIZ 32
long cameradist = 0, cameraclock = 0;
char eightytwofifty = 0;
char playerswhenstarted;
char qe,cp;
int32 CommandSoundToggleOff = 0;
int32 CommandMusicToggleOff = 0;
char confilename[128] = {"GAME.CON"},boardfilename[128] = {0};
char waterpal[768], slimepal[768], titlepal[768], drealms[768], endingpal[768];
char firstdemofile[80] = { '\0' };
#define patchstatusbar(x1,y1,x2,y2) \
{ \
rotatesprite(0,(200-34)<<16,65536L,0,BOTTOMSTATUSBAR,4,0,10+16+64+128, \
scale(x1,xdim,320),scale(y1,ydim,200), \
scale(x2,xdim,320)-1,scale(y2,ydim,200)-1); \
}
void __interrupt __far newint24( int errval, int ax, int bp, int si );
int recfilep,totalreccnt;
char debug_on = 0,actor_tog = 0,*rtsptr,memorycheckoveride=0;
extern char syncstate;
extern int32 numlumps;
FILE *frecfilep = (FILE *)NULL;
void pitch_test( void );
char restorepalette,screencapt,nomorelogohack;
int sendmessagecommand = -1;
task *TimerPtr=NULL;
extern long lastvisinc;
void timerhandler()
{
totalclock++;
}
void inittimer()
{
TimerPtr = TS_ScheduleTask( timerhandler,TICRATE, 1, NULL );
TS_Dispatch();
}
void uninittimer(void)
{
if (TimerPtr)
TS_Terminate( TimerPtr );
TimerPtr = NULL;
TS_Shutdown();
}
int gametext(int x,int y,char *t,char s,short dabits)
{
short ac,newx;
char centre, *oldt;
centre = ( x == (320>>1) );
newx = 0;
oldt = t;
if(centre)
{
while(*t)
{
if(*t == 32) {newx+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM ) break;
if(*t >= '0' && *t <= '9')
newx += 8;
else newx += tilesizx[ac];
t++;
}
t = oldt;
x = (320>>1)-(newx>>1);
}
while(*t)
{
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM )
break;
rotatesprite(x<<16,y<<16,65536L,0,ac,s,0,dabits,0,0,xdim-1,ydim-1);
if(*t >= '0' && *t <= '9')
x += 8;
else x += tilesizx[ac];
t++;
}
return (x);
}
int gametextpal(int x,int y,char *t,char s,char p)
{
short ac,newx;
char centre, *oldt;
centre = ( x == (320>>1) );
newx = 0;
oldt = t;
if(centre)
{
while(*t)
{
if(*t == 32) {newx+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM ) break;
if(*t >= '0' && *t <= '9')
newx += 8;
else newx += tilesizx[ac];
t++;
}
t = oldt;
x = (320>>1)-(newx>>1);
}
while(*t)
{
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM )
break;
rotatesprite(x<<16,y<<16,65536L,0,ac,s,p,2+8+16,0,0,xdim-1,ydim-1);
if(*t >= '0' && *t <= '9')
x += 8;
else x += tilesizx[ac];
t++;
}
return (x);
}
int gametextpart(int x,int y,char *t,char s,short p)
{
short ac,newx, cnt;
char centre, *oldt;
centre = ( x == (320>>1) );
newx = 0;
oldt = t;
cnt = 0;
if(centre)
{
while(*t)
{
if(cnt == p) break;
if(*t == 32) {newx+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM ) break;
newx += tilesizx[ac];
t++;
cnt++;
}
t = oldt;
x = (320>>1)-(newx>>1);
}
cnt = 0;
while(*t)
{
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM ) break;
if(cnt == p)
{
rotatesprite(x<<16,y<<16,65536L,0,ac,s,1,2+8+16,0,0,xdim-1,ydim-1);
break;
}
else
rotatesprite(x<<16,y<<16,65536L,0,ac,s,0,2+8+16,0,0,xdim-1,ydim-1);
x += tilesizx[ac];
t++;
cnt++;
}
return (x);
}
int minitext(int x,int y,char *t,char p,char sb)
{
short ac;
while(*t)
{
*t = toupper(*t);
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + MINIFONT;
rotatesprite(x<<16,y<<16,65536L,0,ac,0,p,sb,0,0,xdim-1,ydim-1);
x += 4; // tilesizx[ac]+1;
t++;
}
return (x);
}
int minitextshade(int x,int y,char *t,char s,char p,char sb)
{
short ac;
while(*t)
{
*t = toupper(*t);
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + MINIFONT;
rotatesprite(x<<16,y<<16,65536L,0,ac,s,p,sb,0,0,xdim-1,ydim-1);
x += 4; // tilesizx[ac]+1;
t++;
}
return (x);
}
void gamenumber(long x,long y,long n,char s)
{
char b[10];
ltoa(n,b,10);
gametext(x,y,b,s,2+8+16);
}
char recbuf[80];
void allowtimetocorrecterrorswhenquitting(void)
{
long i, j, oldtotalclock;
ready2send = 0;
for(j=0;j<8;j++)
{
oldtotalclock = totalclock;
while (totalclock < oldtotalclock+TICSPERFRAME)
getpackets();
if(KB_KeyPressed(sc_Escape)) return;
packbuf[0] = 127;
for(i=connecthead;i>=0;i=connectpoint2[i])
if (i != myconnectindex)
sendpacket(i,packbuf,1);
}
}
#define MAXUSERQUOTES 4
long quotebot, quotebotgoal;
short user_quote_time[MAXUSERQUOTES];
char user_quote[MAXUSERQUOTES][128];
// char typebuflen,typebuf[41];
adduserquote(char *daquote)
{
long i;
for(i=MAXUSERQUOTES-1;i>0;i--)
{
strcpy(user_quote[i],user_quote[i-1]);
user_quote_time[i] = user_quote_time[i-1];
}
strcpy(user_quote[0],daquote);
user_quote_time[0] = 180;
pub = NUMPAGES;
}
void getpackets(void)
{
long i, j, k, l;
FILE *fp;
short other, packbufleng;
input *osyn, *nsyn;
if(qe == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && KB_KeyPressed(sc_Delete))
{
qe = 1;
gameexit("Quick Exit.");
}
if (numplayers < 2) return;
while ((packbufleng = getpacket(&other,packbuf)) > 0)
{
switch(packbuf[0])
{
case 125:
cp = 0;
break;
case 126:
multiflag = 2;
multiwhat = 0;
multiwho = other;
multipos = packbuf[1];
loadplayer( multipos );
multiflag = 0;
break;
case 0: //[0] (receive master sync buffer)
j = 1;
if ((movefifoend[other]&(TIMERUPDATESIZ-1)) == 0)
for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
{
if (playerquitflag[i] == 0) continue;
if (i == myconnectindex)
otherminlag = (long)((signed char)packbuf[j]);
j++;
}
osyn = (input *)&inputfifo[(movefifoend[connecthead]-1)&(MOVEFIFOSIZ-1)][0];
nsyn = (input *)&inputfifo[(movefifoend[connecthead])&(MOVEFIFOSIZ-1)][0];
k = j;
for(i=connecthead;i>=0;i=connectpoint2[i])
j += playerquitflag[i];
for(i=connecthead;i>=0;i=connectpoint2[i])
{
if (playerquitflag[i] == 0) continue;
l = packbuf[k++];
if (i == myconnectindex)
{ j += ((l&1)<<1)+(l&2)+((l&4)>>2)+((l&8)>>3)+((l&16)>>4)+((l&32)>>5)+((l&64)>>6)+((l&128)>>7); continue; }
copybufbyte(&osyn[i],&nsyn[i],sizeof(input));
if (l&1) nsyn[i].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2;
if (l&2) nsyn[i].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2;
if (l&4) nsyn[i].avel = (signed char)packbuf[j++];
if (l&8) nsyn[i].bits = ((nsyn[i].bits&0xffffff00)|((long)packbuf[j++]));
if (l&16) nsyn[i].bits = ((nsyn[i].bits&0xffff00ff)|((long)packbuf[j++])<<8);
if (l&32) nsyn[i].bits = ((nsyn[i].bits&0xff00ffff)|((long)packbuf[j++])<<16);
if (l&64) nsyn[i].bits = ((nsyn[i].bits&0x00ffffff)|((long)packbuf[j++])<<24);
if (l&128) nsyn[i].horz = (signed char)packbuf[j++];
if (nsyn[i].bits&(1<<26)) playerquitflag[i] = 0;
movefifoend[i]++;
}
while (j != packbufleng)
{
for(i=connecthead;i>=0;i=connectpoint2[i])
if(i != myconnectindex)
{
syncval[i][syncvalhead[i]&(MOVEFIFOSIZ-1)] = packbuf[j];
syncvalhead[i]++;
}
j++;
}
for(i=connecthead;i>=0;i=connectpoint2[i])
if (i != myconnectindex)
for(j=1;j<movesperpacket;j++)
{
copybufbyte(&nsyn[i],&inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i],sizeof(input));
movefifoend[i]++;
}
movefifosendplc += movesperpacket;
break;
case 1: //[1] (receive slave sync buffer)
j = 2; k = packbuf[1];
osyn = (input *)&inputfifo[(movefifoend[other]-1)&(MOVEFIFOSIZ-1)][0];
nsyn = (input *)&inputfifo[(movefifoend[other])&(MOVEFIFOSIZ-1)][0];
copybufbyte(&osyn[other],&nsyn[other],sizeof(input));
if (k&1) nsyn[other].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2;
if (k&2) nsyn[other].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2;
if (k&4) nsyn[other].avel = (signed char)packbuf[j++];
if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((long)packbuf[j++]));
if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((long)packbuf[j++])<<8);
if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16);
if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24);
if (k&128) nsyn[other].horz = (signed char)packbuf[j++];
movefifoend[other]++;
while (j != packbufleng)
{
syncval[other][syncvalhead[other]&(MOVEFIFOSIZ-1)] = packbuf[j++];
syncvalhead[other]++;
}
for(i=1;i<movesperpacket;i++)
{
copybufbyte(&nsyn[other],&inputfifo[movefifoend[other]&(MOVEFIFOSIZ-1)][other],sizeof(input));
movefifoend[other]++;
}
break;
case 4:
strcpy(recbuf,packbuf+1);
recbuf[packbufleng-1] = 0;
adduserquote(recbuf);
sound(EXITMENUSOUND);
pus = NUMPAGES;
pub = NUMPAGES;
break;
case 5:
ud.m_level_number = ud.level_number = packbuf[1];
ud.m_volume_number = ud.volume_number = packbuf[2];
ud.m_player_skill = ud.player_skill = packbuf[3];
ud.m_monsters_off = ud.monsters_off = packbuf[4];
ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5];
ud.m_respawn_items = ud.respawn_items = packbuf[6];
ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7];
ud.m_coop = packbuf[8];
ud.m_marker = ud.marker = packbuf[9];
ud.m_ffire = ud.ffire = packbuf[10];
for(i=connecthead;i>=0;i=connectpoint2[i])
{
resetweapons(i);
resetinventory(i);
}
newgame(ud.volume_number,ud.level_number,ud.player_skill);
ud.coop = ud.m_coop;
enterlevel(MODE_GAME);
break;
case 6:
if (packbuf[1] != BYTEVERSION)
gameexit("\nYou cannot play Duke with different versions.");
for (i=2;packbuf[i];i++)
ud.user_name[other][i-2] = packbuf[i];
ud.user_name[other][i-2] = 0;
break;
case 9:
for (i=1;i<packbufleng;i++)
ud.wchoice[other][i-1] = packbuf[i];
break;
case 7:
if(numlumps == 0) break;
if (SoundToggle == 0 || ud.lockout == 1 || FXDevice == NumSoundCards)
break;
rtsptr = (char *)RTS_GetSound(packbuf[1]-1);
if (*rtsptr == 'C')
FX_PlayVOC3D(rtsptr,0,0,0,255,-packbuf[1]);
else
FX_PlayWAV3D(rtsptr,0,0,0,255,-packbuf[1]);
rtsplaying = 7;
break;
case 8:
ud.m_level_number = ud.level_number = packbuf[1];
ud.m_volume_number = ud.volume_number = packbuf[2];
ud.m_player_skill = ud.player_skill = packbuf[3];
ud.m_monsters_off = ud.monsters_off = packbuf[4];
ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5];
ud.m_respawn_items = ud.respawn_items = packbuf[6];
ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7];
ud.m_coop = ud.coop = packbuf[8];
ud.m_marker = ud.marker = packbuf[9];
ud.m_ffire = ud.ffire = packbuf[10];
copybufbyte(packbuf+10,boardfilename,packbufleng-11);
boardfilename[packbufleng-11] = 0;
for(i=connecthead;i>=0;i=connectpoint2[i])
{
resetweapons(i);
resetinventory(i);
}
newgame(ud.volume_number,ud.level_number,ud.player_skill);
enterlevel(MODE_GAME);
break;
case 16:
movefifoend[other] = movefifoplc = movefifosendplc = fakemovefifoplc = 0;
syncvalhead[other] = syncvaltottail = 0L;
case 17:
j = 1;
if ((movefifoend[other]&(TIMERUPDATESIZ-1)) == 0)
if (other == connecthead)
for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
{
if (i == myconnectindex)
otherminlag = (long)((signed char)packbuf[j]);
j++;
}
osyn = (input *)&inputfifo[(movefifoend[other]-1)&(MOVEFIFOSIZ-1)][0];
nsyn = (input *)&inputfifo[(movefifoend[other])&(MOVEFIFOSIZ-1)][0];
copybufbyte(&osyn[other],&nsyn[other],sizeof(input));
k = packbuf[j++];
if (k&1) nsyn[other].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2;
if (k&2) nsyn[other].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2;
if (k&4) nsyn[other].avel = (signed char)packbuf[j++];
if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((long)packbuf[j++]));
if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((long)packbuf[j++])<<8);
if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16);
if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24);
if (k&128) nsyn[other].horz = (signed char)packbuf[j++];
movefifoend[other]++;
for(i=1;i<movesperpacket;i++)
{
copybufbyte(&nsyn[other],&inputfifo[movefifoend[other]&(MOVEFIFOSIZ-1)][other],sizeof(input));
movefifoend[other]++;
}
if (j > packbufleng)
printf("INVALID GAME PACKET!!! (%ld too many bytes)\n",j-packbufleng);
while (j != packbufleng)
{
syncval[other][syncvalhead[other]&(MOVEFIFOSIZ-1)] = packbuf[j++];
syncvalhead[other]++;
}
break;
case 127:
break;
case 250:
playerreadyflag[other]++;
break;
case 255:
gameexit(" ");
break;
}
}
}
void faketimerhandler()
{
long i, j, k, l;
// short who;
input *osyn, *nsyn;
if(qe == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && KB_KeyPressed(sc_Delete))
{
qe = 1;
gameexit("Quick Exit.");
}
if ((totalclock < ototalclock+TICSPERFRAME) || (ready2send == 0)) return;
ototalclock += TICSPERFRAME;
getpackets(); if (getoutputcirclesize() >= 16) return;
for(i=connecthead;i>=0;i=connectpoint2[i])
if (i != myconnectindex)
if (movefifoend[i] < movefifoend[myconnectindex]-200) return;
getinput(myconnectindex);
avgfvel += loc.fvel;
avgsvel += loc.svel;
avgavel += loc.avel;
avghorz += loc.horz;
avgbits |= loc.bits;
if (movefifoend[myconnectindex]&(movesperpacket-1))
{
copybufbyte(&inputfifo[(movefifoend[myconnectindex]-1)&(MOVEFIFOSIZ-1)][myconnectindex],
&inputfifo[movefifoend[myconnectindex]&(MOVEFIFOSIZ-1)][myconnectindex],sizeof(input));
movefifoend[myconnectindex]++;
return;
}
nsyn = &inputfifo[movefifoend[myconnectindex]&(MOVEFIFOSIZ-1)][myconnectindex];
nsyn[0].fvel = avgfvel/movesperpacket;
nsyn[0].svel = avgsvel/movesperpacket;
nsyn[0].avel = avgavel/movesperpacket;
nsyn[0].horz = avghorz/movesperpacket;
nsyn[0].bits = avgbits;
avgfvel = avgsvel = avgavel = avghorz = avgbits = 0;
movefifoend[myconnectindex]++;
if (numplayers < 2)
{
if (ud.multimode > 1) for(i=connecthead;i>=0;i=connectpoint2[i])
if(i != myconnectindex)
{
//clearbufbyte(&inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i],sizeof(input),0L);
if(ud.playerai)
computergetinput(i,&inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i]);
movefifoend[i]++;
}
return;
}
for(i=connecthead;i>=0;i=connectpoint2[i])
if (i != myconnectindex)
{
k = (movefifoend[myconnectindex]-1)-movefifoend[i];
myminlag[i] = min(myminlag[i],k);
mymaxlag = max(mymaxlag,k);
}
if (((movefifoend[myconnectindex]-1)&(TIMERUPDATESIZ-1)) == 0)
{
i = mymaxlag-bufferjitter; mymaxlag = 0;
if (i > 0) bufferjitter += ((3+i)>>2);
else if (i < 0) bufferjitter -= ((1-i)>>2);
}
if (networkmode == 1)
{
packbuf[0] = 17;
if ((movefifoend[myconnectindex]-1) == 0) packbuf[0] = 16;
j = 1;
//Fix timers and buffer/jitter value
if (((movefifoend[myconnectindex]-1)&(TIMERUPDATESIZ-1)) == 0)
{
if (myconnectindex != connecthead)
{
i = myminlag[connecthead]-otherminlag;
if (klabs(i) > 8) i >>= 1;
else if (klabs(i) > 2) i = ksgn(i);
else i = 0;
totalclock -= TICSPERFRAME*i;
myminlag[connecthead] -= i; otherminlag += i;
}
if (myconnectindex == connecthead)
for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
packbuf[j++] = min(max(myminlag[i],-128),127);
for(i=connecthead;i>=0;i=connectpoint2[i])
myminlag[i] = 0x7fffffff;
}
osyn = (input *)&inputfifo[(movefifoend[myconnectindex]-2)&(MOVEFIFOSIZ-1)][myconnectindex];
nsyn = (input *)&inputfifo[(movefifoend[myconnectindex]-1)&(MOVEFIFOSIZ-1)][myconnectindex];
k = j;
packbuf[j++] = 0;
if (nsyn[0].fvel != osyn[0].fvel)
{
packbuf[j++] = (char)nsyn[0].fvel;
packbuf[j++] = (char)(nsyn[0].fvel>>8);
packbuf[k] |= 1;
}
if (nsyn[0].svel != osyn[0].svel)
{
packbuf[j++] = (char)nsyn[0].svel;
packbuf[j++] = (char)(nsyn[0].svel>>8);
packbuf[k] |= 2;
}
if (nsyn[0].avel != osyn[0].avel)
{
packbuf[j++] = (signed char)nsyn[0].avel;
packbuf[k] |= 4;
}
if ((nsyn[0].bits^osyn[0].bits)&0x000000ff) packbuf[j++] = (nsyn[0].bits&255), packbuf[k] |= 8;
if ((nsyn[0].bits^osyn[0].bits)&0x0000ff00) packbuf[j++] = ((nsyn[0].bits>>8)&255), packbuf[k] |= 16;
if ((nsyn[0].bits^osyn[0].bits)&0x00ff0000) packbuf[j++] = ((nsyn[0].bits>>16)&255), packbuf[k] |= 32;
if ((nsyn[0].bits^osyn[0].bits)&0xff000000) packbuf[j++] = ((nsyn[0].bits>>24)&255), packbuf[k] |= 64;
if (nsyn[0].horz != osyn[0].horz)
{
packbuf[j++] = (char)nsyn[0].horz;
packbuf[k] |= 128;
}
while (syncvalhead[myconnectindex] != syncvaltail)
{
packbuf[j++] = syncval[myconnectindex][syncvaltail&(MOVEFIFOSIZ-1)];
syncvaltail++;
}
for(i=connecthead;i>=0;i=connectpoint2[i])
if (i != myconnectindex)
sendpacket(i,packbuf,j);
return;
}
if (myconnectindex != connecthead) //Slave
{
//Fix timers and buffer/jitter value
if (((movefifoend[myconnectindex]-1)&(TIMERUPDATESIZ-1)) == 0)
{
i = myminlag[connecthead]-otherminlag;
if (klabs(i) > 8) i >>= 1;
else if (klabs(i) > 2) i = ksgn(i);
else i = 0;
totalclock -= TICSPERFRAME*i;
myminlag[connecthead] -= i; otherminlag += i;
for(i=connecthead;i>=0;i=connectpoint2[i])
myminlag[i] = 0x7fffffff;
}
packbuf[0] = 1; packbuf[1] = 0; j = 2;
osyn = (input *)&inputfifo[(movefifoend[myconnectindex]-2)&(MOVEFIFOSIZ-1)][myconnectindex];
nsyn = (input *)&inputfifo[(movefifoend[myconnectindex]-1)&(MOVEFIFOSIZ-1)][myconnectindex];
if (nsyn[0].fvel != osyn[0].fvel)
{
packbuf[j++] = (char)nsyn[0].fvel;
packbuf[j++] = (char)(nsyn[0].fvel>>8);
packbuf[1] |= 1;
}
if (nsyn[0].svel != osyn[0].svel)
{
packbuf[j++] = (char)nsyn[0].svel;
packbuf[j++] = (char)(nsyn[0].svel>>8);
packbuf[1] |= 2;
}
if (nsyn[0].avel != osyn[0].avel)
{
packbuf[j++] = (signed char)nsyn[0].avel;
packbuf[1] |= 4;
}
if ((nsyn[0].bits^osyn[0].bits)&0x000000ff) packbuf[j++] = (nsyn[0].bits&255), packbuf[1] |= 8;
if ((nsyn[0].bits^osyn[0].bits)&0x0000ff00) packbuf[j++] = ((nsyn[0].bits>>8)&255), packbuf[1] |= 16;
if ((nsyn[0].bits^osyn[0].bits)&0x00ff0000) packbuf[j++] = ((nsyn[0].bits>>16)&255), packbuf[1] |= 32;
if ((nsyn[0].bits^osyn[0].bits)&0xff000000) packbuf[j++] = ((nsyn[0].bits>>24)&255), packbuf[1] |= 64;
if (nsyn[0].horz != osyn[0].horz)
{
packbuf[j++] = (char)nsyn[0].horz;
packbuf[1] |= 128;
}
while (syncvalhead[myconnectindex] != syncvaltail)
{
packbuf[j++] = syncval[myconnectindex][syncvaltail&(MOVEFIFOSIZ-1)];
syncvaltail++;
}
sendpacket(connecthead,packbuf,j);
return;
}
//This allows allow packet-resends
for(i=connecthead;i>=0;i=connectpoint2[i])
if (movefifoend[i] <= movefifosendplc)
{
packbuf[0] = 127;
for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
sendpacket(i,packbuf,1);
return;
}
while (1) //Master
{
for(i=connecthead;i>=0;i=connectpoint2[i])
if (playerquitflag[i] && (movefifoend[i] <= movefifosendplc)) return;
osyn = (input *)&inputfifo[(movefifosendplc-1)&(MOVEFIFOSIZ-1)][0];
nsyn = (input *)&inputfifo[(movefifosendplc )&(MOVEFIFOSIZ-1)][0];
//MASTER -> SLAVE packet
packbuf[0] = 0; j = 1;
//Fix timers and buffer/jitter value
if ((movefifosendplc&(TIMERUPDATESIZ-1)) == 0)
{
for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
if (playerquitflag[i])
packbuf[j++] = min(max(myminlag[i],-128),127);
for(i=connecthead;i>=0;i=connectpoint2[i])
myminlag[i] = 0x7fffffff;
}
k = j;
for(i=connecthead;i>=0;i=connectpoint2[i])
j += playerquitflag[i];
for(i=connecthead;i>=0;i=connectpoint2[i])
{
if (playerquitflag[i] == 0) continue;
packbuf[k] = 0;
if (nsyn[i].fvel != osyn[i].fvel)
{
packbuf[j++] = (char)nsyn[i].fvel;
packbuf[j++] = (char)(nsyn[i].fvel>>8);
packbuf[k] |= 1;
}
if (nsyn[i].svel != osyn[i].svel)
{
packbuf[j++] = (char)nsyn[i].svel;
packbuf[j++] = (char)(nsyn[i].svel>>8);
packbuf[k] |= 2;
}
if (nsyn[i].avel != osyn[i].avel)
{
packbuf[j++] = (signed char)nsyn[i].avel;
packbuf[k] |= 4;
}
if ((nsyn[i].bits^osyn[i].bits)&0x000000ff) packbuf[j++] = (nsyn[i].bits&255), packbuf[k] |= 8;
if ((nsyn[i].bits^osyn[i].bits)&0x0000ff00) packbuf[j++] = ((nsyn[i].bits>>8)&255), packbuf[k] |= 16;
if ((nsyn[i].bits^osyn[i].bits)&0x00ff0000) packbuf[j++] = ((nsyn[i].bits>>16)&255), packbuf[k] |= 32;
if ((nsyn[i].bits^osyn[i].bits)&0xff000000) packbuf[j++] = ((nsyn[i].bits>>24)&255), packbuf[k] |= 64;
if (nsyn[i].horz != osyn[i].horz)
{
packbuf[j++] = (char)nsyn[i].horz;
packbuf[k] |= 128;
}
k++;
}
while (syncvalhead[myconnectindex] != syncvaltail)
{
packbuf[j++] = syncval[myconnectindex][syncvaltail&(MOVEFIFOSIZ-1)];
syncvaltail++;
}
for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
if (playerquitflag[i])
{
sendpacket(i,packbuf,j);
if (nsyn[i].bits&(1<<26))
playerquitflag[i] = 0;
}
movefifosendplc += movesperpacket;
}
}
extern long cacnum;
typedef struct { long *hand, leng; char *lock; } cactype;
extern cactype cac[];
void caches(void)
{
short i,k;
k = 0;
for(i=0;i<cacnum;i++)
if ((*cac[i].lock) >= 200)
{
sprintf(tempbuf,"Locked- %ld: Leng:%ld, Lock:%ld",i,cac[i].leng,*cac[i].lock);
printext256(0L,k,31,-1,tempbuf,1); k += 6;
}
k += 6;
for(i=1;i<11;i++)
if (lumplockbyte[i] >= 200)
{
sprintf(tempbuf,"RTS Locked %ld:",i);
printext256(0L,k,31,-1,tempbuf,1); k += 6;
}
}
void checksync(void)
{
long i, k;
for(i=connecthead;i>=0;i=connectpoint2[i])
if (syncvalhead[i] == syncvaltottail) break;
if (i < 0)
{
syncstat = 0;
do
{
for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
if (syncval[i][syncvaltottail&(MOVEFIFOSIZ-1)] !=
syncval[connecthead][syncvaltottail&(MOVEFIFOSIZ-1)])
syncstat = 1;
syncvaltottail++;
for(i=connecthead;i>=0;i=connectpoint2[i])
if (syncvalhead[i] == syncvaltottail) break;
} while (i < 0);
}
if (connectpoint2[connecthead] < 0) syncstat = 0;
if (syncstat)
{
printext256(4L,130L,31,0,"Out Of Sync - Please restart game",0);
printext256(4L,138L,31,0,"RUN DN3DHELP.EXE for information.",0);
}
if (syncstate)
{
printext256(4L,160L,31,0,"Missed Network packet!",0);
printext256(4L,138L,31,0,"RUN DN3DHELP.EXE for information.",0);
}
}
void check_fta_sounds(short i)
{
if(sprite[i].extra > 0) switch(PN)
{
case LIZTROOPONTOILET:
case LIZTROOPJUSTSIT:
case LIZTROOPSHOOT:
case LIZTROOPJETPACK:
case LIZTROOPDUCKING:
case LIZTROOPRUNNING:
case LIZTROOP:
spritesound(PRED_RECOG,i);
break;
case LIZMAN:
case LIZMANSPITTING:
case LIZMANFEEDING:
case LIZMANJUMP:
spritesound(CAPT_RECOG,i);
break;
case PIGCOP:
case PIGCOPDIVE:
spritesound(PIG_RECOG,i);
break;
case RECON:
spritesound(RECO_RECOG,i);
break;
case DRONE:
spritesound(DRON_RECOG,i);
break;
case COMMANDER:
case COMMANDERSTAYPUT:
spritesound(COMM_RECOG,i);
break;
case ORGANTIC:
spritesound(TURR_RECOG,i);
break;
case OCTABRAIN:
case OCTABRAINSTAYPUT:
spritesound(OCTA_RECOG,i);
break;
case BOSS1:
sound(BOS1_RECOG);
break;
case BOSS2:
if(sprite[i].pal == 1)
sound(BOS2_RECOG);
else sound(WHIPYOURASS);
break;
case BOSS3:
if(sprite[i].pal == 1)
sound(BOS3_RECOG);
else sound(RIPHEADNECK);
break;
case BOSS4:
case BOSS4STAYPUT:
if(sprite[i].pal == 1)
sound(BOS4_RECOG);
sound(BOSS4_FIRSTSEE);
break;
case GREENSLIME:
spritesound(SLIM_RECOG,i);
break;
}
}
short inventory(spritetype *s)
{
switch(s->picnum)
{
case FIRSTAID:
case STEROIDS:
case HEATSENSOR:
case BOOTS:
case JETPACK:
case HOLODUKE:
case AIRTANK:
return 1;
}
return 0;
}
short badguy(spritetype *s)
{
switch(s->picnum)
{
case SHARK:
case RECON:
case DRONE:
case LIZTROOPONTOILET:
case LIZTROOPJUSTSIT:
case LIZTROOPSTAYPUT:
case LIZTROOPSHOOT:
case LIZTROOPJETPACK:
case LIZTROOPDUCKING:
case LIZTROOPRUNNING:
case LIZTROOP:
case OCTABRAIN:
case COMMANDER:
case COMMANDERSTAYPUT:
case PIGCOP:
case EGG:
case PIGCOPSTAYPUT:
case PIGCOPDIVE:
case LIZMAN:
case LIZMANSPITTING:
case LIZMANFEEDING:
case LIZMANJUMP:
case ORGANTIC:
case BOSS1:
case BOSS2:
case BOSS3:
case BOSS4:
case GREENSLIME:
case GREENSLIME+1:
case GREENSLIME+2:
case GREENSLIME+3:
case GREENSLIME+4:
case GREENSLIME+5:
case GREENSLIME+6:
case GREENSLIME+7:
case RAT:
case ROTATEGUN:
return 1;
}
if( actortype[s->picnum] ) return 1;
return 0;
}
short badguypic(short pn)
{
switch(pn)
{
case SHARK:
case RECON:
case DRONE:
case LIZTROOPONTOILET:
case LIZTROOPJUSTSIT:
case LIZTROOPSTAYPUT:
case LIZTROOPSHOOT:
case LIZTROOPJETPACK:
case LIZTROOPDUCKING:
case LIZTROOPRUNNING:
case LIZTROOP:
case OCTABRAIN:
case COMMANDER:
case COMMANDERSTAYPUT:
case PIGCOP:
case EGG:
case PIGCOPSTAYPUT:
case PIGCOPDIVE:
case LIZMAN:
case LIZMANSPITTING:
case LIZMANFEEDING:
case LIZMANJUMP:
case ORGANTIC:
case BOSS1:
case BOSS2:
case BOSS3:
case BOSS4:
case GREENSLIME:
case GREENSLIME+1:
case GREENSLIME+2:
case GREENSLIME+3:
case GREENSLIME+4:
case GREENSLIME+5:
case GREENSLIME+6:
case GREENSLIME+7:
case RAT:
case ROTATEGUN:
return 1;
}
if( actortype[pn] ) return 1;
return 0;
}
void myos(long x, long y, short tilenum, signed char shade, char orientation)
{
char p;
short a;
if(orientation&4)
a = 1024;
else a = 0;
p = sector[ps[screenpeek].cursectnum].floorpal;
rotatesprite(x<<16,y<<16,65536L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2);
}
void myospal(long x, long y, short tilenum, signed char shade, char orientation, char p)
{
char fp;
short a;
if(orientation&4)
a = 1024;
else a = 0;
fp = sector[ps[screenpeek].cursectnum].floorpal;
rotatesprite(x<<16,y<<16,65536L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2);
}
void invennum(long x,long y,char num1,char ha,char sbits)
{
char dabuf[80] = {0};
sprintf(dabuf,"%ld",num1);
if(num1 > 99)
{
rotatesprite((x-4)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,sbits,0,0,xdim-1,ydim-1);
rotatesprite((x)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[1]-'0',ha,0,sbits,0,0,xdim-1,ydim-1);
rotatesprite((x+4)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[2]-'0',ha,0,sbits,0,0,xdim-1,ydim-1);
}
else if(num1 > 9)
{
rotatesprite((x)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,sbits,0,0,xdim-1,ydim-1);
rotatesprite((x+4)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[1]-'0',ha,0,sbits,0,0,xdim-1,ydim-1);
}
else
rotatesprite((x+4)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,sbits,0,0,xdim-1,ydim-1);
}
#ifdef VOLUMEONE
void orderweaponnum(short ind,long x,long y,long num1, long num2,char ha)
{
rotatesprite((x-7)<<16,y<<16,65536L,0,THREEBYFIVE+ind+1,ha-10,7,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x-3)<<16,y<<16,65536L,0,THREEBYFIVE+10,ha,0,10+128,0,0,xdim-1,ydim-1);
minitextshade(x+1,y-4,"ORDER",26,6,2+8+16+128);
}
#endif
void weaponnum(short ind,long x,long y,long num1, long num2,char ha)
{
char dabuf[80] = {0};
rotatesprite((x-7)<<16,y<<16,65536L,0,THREEBYFIVE+ind+1,ha-10,7,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x-3)<<16,y<<16,65536L,0,THREEBYFIVE+10,ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+9)<<16,y<<16,65536L,0,THREEBYFIVE+11,ha,0,10+128,0,0,xdim-1,ydim-1);
if(num1 > 99) num1 = 99;
if(num2 > 99) num2 = 99;
sprintf(dabuf,"%ld",num1);
if(num1 > 9)
{
rotatesprite((x)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+4)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[1]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
}
else rotatesprite((x+4)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
sprintf(dabuf,"%ld",num2);
if(num2 > 9)
{
rotatesprite((x+13)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+17)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[1]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
}
else rotatesprite((x+13)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
}
void weaponnum999(char ind,long x,long y,long num1, long num2,char ha)
{
char dabuf[80] = {0};
rotatesprite((x-7)<<16,y<<16,65536L,0,THREEBYFIVE+ind+1,ha-10,7,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x-4)<<16,y<<16,65536L,0,THREEBYFIVE+10,ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+13)<<16,y<<16,65536L,0,THREEBYFIVE+11,ha,0,10+128,0,0,xdim-1,ydim-1);
sprintf(dabuf,"%ld",num1);
if(num1 > 99)
{
rotatesprite((x)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+4)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[1]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+8)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[2]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
}
else if(num1 > 9)
{
rotatesprite((x+4)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+8)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[1]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
}
else rotatesprite((x+8)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
sprintf(dabuf,"%ld",num2);
if(num2 > 99)
{
rotatesprite((x+17)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+21)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[1]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+25)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[2]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
}
else if(num2 > 9)
{
rotatesprite((x+17)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
rotatesprite((x+21)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[1]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
}
else rotatesprite((x+25)<<16,y<<16,65536L,0,THREEBYFIVE+dabuf[0]-'0',ha,0,10+128,0,0,xdim-1,ydim-1);
}
//REPLACE FULLY
void weapon_amounts(struct player_struct *p,long x,long y,long u)
{
int cw;
cw = p->curr_weapon;
if (u&4)
{
if (u != 0xffffffff) patchstatusbar(96,178,96+12,178+6);
weaponnum999(PISTOL_WEAPON,x,y,
p->ammo_amount[PISTOL_WEAPON],max_ammo_amount[PISTOL_WEAPON],
12-20*(cw == PISTOL_WEAPON) );
}
if (u&8)
{
if (u != 0xffffffff) patchstatusbar(96,184,96+12,184+6);
weaponnum999(SHOTGUN_WEAPON,x,y+6,
p->ammo_amount[SHOTGUN_WEAPON],max_ammo_amount[SHOTGUN_WEAPON],
(!p->gotweapon[SHOTGUN_WEAPON]*9)+12-18*
(cw == SHOTGUN_WEAPON) );
}
if (u&16)
{
if (u != 0xffffffff) patchstatusbar(96,190,96+12,190+6);
weaponnum999(CHAINGUN_WEAPON,x,y+12,
p->ammo_amount[CHAINGUN_WEAPON],max_ammo_amount[CHAINGUN_WEAPON],
(!p->gotweapon[CHAINGUN_WEAPON]*9)+12-18*
(cw == CHAINGUN_WEAPON) );
}
if (u&32)
{
if (u != 0xffffffff) patchstatusbar(135,178,135+8,178+6);
weaponnum(RPG_WEAPON,x+39,y,
p->ammo_amount[RPG_WEAPON],max_ammo_amount[RPG_WEAPON],
(!p->gotweapon[RPG_WEAPON]*9)+12-19*
(cw == RPG_WEAPON) );
}
if (u&64)
{
if (u != 0xffffffff) patchstatusbar(135,184,135+8,184+6);
weaponnum(HANDBOMB_WEAPON,x+39,y+6,
p->ammo_amount[HANDBOMB_WEAPON],max_ammo_amount[HANDBOMB_WEAPON],
(((!p->ammo_amount[HANDBOMB_WEAPON])|(!p->gotweapon[HANDBOMB_WEAPON]))*9)+12-19*
((cw == HANDBOMB_WEAPON) || (cw == HANDREMOTE_WEAPON)));
}
if (u&128)
{
if (u != 0xffffffff) patchstatusbar(135,190,135+8,190+6);
#ifdef VOLUMEONE
orderweaponnum(SHRINKER_WEAPON,x+39,y+12,
p->ammo_amount[SHRINKER_WEAPON],max_ammo_amount[SHRINKER_WEAPON],
(!p->gotweapon[SHRINKER_WEAPON]*9)+12-18*
(cw == SHRINKER_WEAPON) );
#else
if(p->subweapon&(1<<GROW_WEAPON))
weaponnum(SHRINKER_WEAPON,x+39,y+12,
p->ammo_amount[GROW_WEAPON],max_ammo_amount[GROW_WEAPON],
(!p->gotweapon[GROW_WEAPON]*9)+12-18*
(cw == GROW_WEAPON) );
else
weaponnum(SHRINKER_WEAPON,x+39,y+12,
p->ammo_amount[SHRINKER_WEAPON],max_ammo_amount[SHRINKER_WEAPON],
(!p->gotweapon[SHRINKER_WEAPON]*9)+12-18*
(cw == SHRINKER_WEAPON) );
#endif
}
if (u&256)
{
if (u != 0xffffffff) patchstatusbar(166,178,166+8,178+6);
#ifdef VOLUMEONE
orderweaponnum(DEVISTATOR_WEAPON,x+70,y,
p->ammo_amount[DEVISTATOR_WEAPON],max_ammo_amount[DEVISTATOR_WEAPON],
(!p->gotweapon[DEVISTATOR_WEAPON]*9)+12-18*
(cw == DEVISTATOR_WEAPON) );
#else
weaponnum(DEVISTATOR_WEAPON,x+70,y,
p->ammo_amount[DEVISTATOR_WEAPON],max_ammo_amount[DEVISTATOR_WEAPON],
(!p->gotweapon[DEVISTATOR_WEAPON]*9)+12-18*
(cw == DEVISTATOR_WEAPON) );
#endif
}
if (u&512)
{
if (u != 0xffffffff) patchstatusbar(166,184,166+8,184+6);
#ifdef VOLUMEONE
orderweaponnum(TRIPBOMB_WEAPON,x+70,y+6,
p->ammo_amount[TRIPBOMB_WEAPON],max_ammo_amount[TRIPBOMB_WEAPON],
(!p->gotweapon[TRIPBOMB_WEAPON]*9)+12-18*
(cw == TRIPBOMB_WEAPON) );
#else
weaponnum(TRIPBOMB_WEAPON,x+70,y+6,
p->ammo_amount[TRIPBOMB_WEAPON],max_ammo_amount[TRIPBOMB_WEAPON],
(!p->gotweapon[TRIPBOMB_WEAPON]*9)+12-18*
(cw == TRIPBOMB_WEAPON) );
#endif
}
if (u&65536L)
{
if (u != 0xffffffff) patchstatusbar(166,190,166+8,190+6);
#ifdef VOLUMEONE
orderweaponnum(-1,x+70,y+12,
p->ammo_amount[FREEZE_WEAPON],max_ammo_amount[FREEZE_WEAPON],
(!p->gotweapon[FREEZE_WEAPON]*9)+12-18*
(cw == FREEZE_WEAPON) );
#else
weaponnum(-1,x+70,y+12,
p->ammo_amount[FREEZE_WEAPON],max_ammo_amount[FREEZE_WEAPON],
(!p->gotweapon[FREEZE_WEAPON]*9)+12-18*
(cw == FREEZE_WEAPON) );
#endif
}
}
void digitalnumber(long x,long y,long n,char s,char cs)
{
short i, j, k, p, c;
char b[10];
ltoa(n,b,10);
i = strlen(b);
j = 0;
for(k=0;k<i;k++)
{
p = DIGITALNUM+*(b+k)-'0';
j += tilesizx[p]+1;
}
c = x-(j>>1);
j = 0;
for(k=0;k<i;k++)
{
p = DIGITALNUM+*(b+k)-'0';
rotatesprite((c+j)<<16,y<<16,65536L,0,p,s,0,cs,0,0,xdim-1,ydim-1);
j += tilesizx[p]+1;
}
}
/*
void scratchmarks(long x,long y,long n,char s,char p)
{
long i, ni;
ni = n/5;
for(i=ni;i >= 0;i--)
{
overwritesprite(x-2,y,SCRATCH+4,s,0,0);
x += tilesizx[SCRATCH+4]-1;
}
ni = n%5;
if(ni) overwritesprite(x,y,SCRATCH+ni-1,s,p,0);
}
*/
void displayinventory(struct player_struct *p)
{
short n, j, xoff, y;
j = xoff = 0;
n = (p->jetpack_amount > 0)<<3; if(n&8) j++;
n |= ( p->scuba_amount > 0 )<<5; if(n&32) j++;
n |= (p->steroids_amount > 0)<<1; if(n&2) j++;
n |= ( p->holoduke_amount > 0)<<2; if(n&4) j++;
n |= (p->firstaid_amount > 0); if(n&1) j++;
n |= (p->heat_amount > 0)<<4; if(n&16) j++;
n |= (p->boot_amount > 0)<<6; if(n&64) j++;
xoff = 160-(j*11);
j = 0;
if(ud.screen_size > 4)
y = 154;
else y = 172;
if(ud.screen_size == 4)
{
if(ud.multimode > 1)
xoff += 56;
else xoff += 65;
}
while( j <= 9 )
{
if( n&(1<<j) )
{
switch( n&(1<<j) )
{
case 1:
rotatesprite(xoff<<16,y<<16,65536L,0,FIRSTAID_ICON,0,0,2+16,windowx1,windowy1,windowx2,windowy2);break;
case 2:
rotatesprite((xoff+1)<<16,y<<16,65536L,0,STEROIDS_ICON,0,0,2+16,windowx1,windowy1,windowx2,windowy2);break;
case 4:
rotatesprite((xoff+2)<<16,y<<16,65536L,0,HOLODUKE_ICON,0,0,2+16,windowx1,windowy1,windowx2,windowy2);break;
case 8:
rotatesprite(xoff<<16,y<<16,65536L,0,JETPACK_ICON,0,0,2+16,windowx1,windowy1,windowx2,windowy2);break;
case 16:
rotatesprite(xoff<<16,y<<16,65536L,0,HEAT_ICON,0,0,2+16,windowx1,windowy1,windowx2,windowy2);break;
case 32:
rotatesprite(xoff<<16,y<<16,65536L,0,AIRTANK_ICON,0,0,2+16,windowx1,windowy1,windowx2,windowy2);break;
case 64:
rotatesprite(xoff<<16,(y-1)<<16,65536L,0,BOOT_ICON,0,0,2+16,windowx1,windowy1,windowx2,windowy2);break;
}
xoff += 22;
if(p->inven_icon == j+1)
rotatesprite((xoff-2)<<16,(y+19)<<16,65536L,1024,ARROW,-32,0,2+16,windowx1,windowy1,windowx2,windowy2);
}
j++;
}
}
void displayfragbar(void)
{
short i, j;
j = 0;
for(i=connecthead;i>=0;i=connectpoint2[i])
if(i > j) j = i;
rotatesprite(0,0,65600L,0,FRAGBAR,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1);
if(j >= 4) rotatesprite(319,(8)<<16,65600L,0,FRAGBAR,0,0,10+16+64+128,0,0,xdim-1,ydim-1);
if(j >= 8) rotatesprite(319,(16)<<16,65600L,0,FRAGBAR,0,0,10+16+64+128,0,0,xdim-1,ydim-1);
if(j >= 12) rotatesprite(319,(24)<<16,65600L,0,FRAGBAR,0,0,10+16+64+128,0,0,xdim-1,ydim-1);
for(i=connecthead;i>=0;i=connectpoint2[i])
{
minitext(21+(73*(i&3)),2+((i&28)<<1),&ud.user_name[i][0],sprite[ps[i].i].pal,2+8+16+128);
sprintf(tempbuf,"%d",ps[i].frag-ps[i].fraggedself);
minitext(17+50+(73*(i&3)),2+((i&28)<<1),tempbuf,sprite[ps[i].i].pal,2+8+16+128);
}
}
void coolgaugetext(short snum)
{
struct player_struct *p;
long i, j, o, ss, u;
char c, permbit;
p = &ps[snum];
if (p->invdisptime > 0) displayinventory(p);
if(ps[snum].gm&MODE_MENU)
if( (current_menu >= 400 && current_menu <= 405) )
return;
ss = ud.screen_size; if (ss < 4) return;
if ( ud.multimode > 1 && ud.coop != 1 )
{
if (pus)
{ displayfragbar(); }
else
{
for(i=connecthead;i>=0;i=connectpoint2[i])
if (ps[i].frag != sbar.frag[i]) { displayfragbar(); break; }
}
for(i=connecthead;i>=0;i=connectpoint2[i])
if (i != myconnectindex)
sbar.frag[i] = ps[i].frag;
}
if (ss == 4) //DRAW MINI STATUS BAR:
{
rotatesprite(5<<16,(200-28)<<16,65536L,0,HEALTHBOX,0,21,10+16,0,0,xdim-1,ydim-1);
if (p->inven_icon)
rotatesprite(69<<16,(200-30)<<16,65536L,0,INVENTORYBOX,0,21,10+16,0,0,xdim-1,ydim-1);
if(sprite[p->i].pal == 1 && p->last_extra < 2)
digitalnumber(20,200-17,1,-16,10+16);
else digitalnumber(20,200-17,p->last_extra,-16,10+16);
rotatesprite(37<<16,(200-28)<<16,65536L,0,AMMOBOX,0,21,10+16,0,0,xdim-1,ydim-1);
if (p->curr_weapon == HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; else i = p->curr_weapon;
digitalnumber(53,200-17,p->ammo_amount[i],-16,10+16);
o = 158; permbit = 0;
if (p->inven_icon)
{
switch(p->inven_icon)
{
case 1: i = FIRSTAID_ICON; break;
case 2: i = STEROIDS_ICON; break;
case 3: i = HOLODUKE_ICON; break;
case 4: i = JETPACK_ICON; break;
case 5: i = HEAT_ICON; break;
case 6: i = AIRTANK_ICON; break;
case 7: i = BOOT_ICON; break;
default: i = -1;
}
if (i >= 0) rotatesprite((231-o)<<16,(200-21)<<16,65536L,0,i,0,0,10+16+permbit,0,0,xdim-1,ydim-1);
minitext(292-30-o,190,"%",6,10+16+permbit);
j = 0x80000000;
switch(p->inven_icon)
{
case 1: i = p->firstaid_amount; break;
case 2: i = ((p->steroids_amount+3)>>2); break;
case 3: i = ((p->holoduke_amount+15)/24); j = p->holoduke_on; break;
case 4: i = ((p->jetpack_amount+15)>>4); j = p->jetpack_on; break;
case 5: i = p->heat_amount/12; j = p->heat_on; break;
case 6: i = ((p->scuba_amount+63)>>6); break;
case 7: i = (p->boot_amount>>1); break;
}
invennum(284-30-o,200-6,(char)i,0,10+permbit);
if (j > 0) minitext(288-30-o,180,"ON",0,10+16+permbit);
else if (j != 0x80000000) minitext(284-30-o,180,"OFF",2,10+16+permbit);
if (p->inven_icon >= 6) minitext(284-35-o,180,"AUTO",2,10+16+permbit);
}
return;
}
//DRAW/UPDATE FULL STATUS BAR:
if (pus) { pus = 0; u = 0xffffffff; } else u = 0;
if (sbar.frag[myconnectindex] != p->frag) { sbar.frag[myconnectindex] = p->frag; u |= 32768; }
if (sbar.got_access != p->got_access) { sbar.got_access = p->got_access; u |= 16384; }
if (sbar.last_extra != p->last_extra) { sbar.last_extra = p->last_extra; u |= 1; }
if (sbar.shield_amount != p->shield_amount) { sbar.shield_amount = p->shield_amount; u |= 2; }
if (sbar.curr_weapon != p->curr_weapon) { sbar.curr_weapon = p->curr_weapon; u |= (4+8+16+32+64+128+256+512+1024+65536L); }
for(i=1;i < 10;i++)
{
if (sbar.ammo_amount[i] != p->ammo_amount[i]) {
sbar.ammo_amount[i] = p->ammo_amount[i]; if(i < 9) u |= ((2<<i)+1024); else u |= 65536L+1024; }
if (sbar.gotweapon[i] != p->gotweapon[i]) { sbar.gotweapon[i] =
p->gotweapon[i]; if(i < 9 ) u |= ((2<<i)+1024); else u |= 65536L+1024; }
}
if (sbar.inven_icon != p->inven_icon) { sbar.inven_icon = p->inven_icon; u |= (2048+4096+8192); }
if (sbar.holoduke_on != p->holoduke_on) { sbar.holoduke_on = p->holoduke_on; u |= (4096+8192); }
if (sbar.jetpack_on != p->jetpack_on) { sbar.jetpack_on = p->jetpack_on; u |= (4096+8192); }
if (sbar.heat_on != p->heat_on) { sbar.heat_on = p->heat_on; u |= (4096+8192); }
if (sbar.firstaid_amount != p->firstaid_amount) { sbar.firstaid_amount = p->firstaid_amount; u |= 8192; }
if (sbar.steroids_amount != p->steroids_amount) { sbar.steroids_amount = p->steroids_amount; u |= 8192; }
if (sbar.holoduke_amount != p->holoduke_amount) { sbar.holoduke_amount = p->holoduke_amount; u |= 8192; }
if (sbar.jetpack_amount != p->jetpack_amount) { sbar.jetpack_amount = p->jetpack_amount; u |= 8192; }
if (sbar.heat_amount != p->heat_amount) { sbar.heat_amount = p->heat_amount; u |= 8192; }
if (sbar.scuba_amount != p->scuba_amount) { sbar.scuba_amount = p->scuba_amount; u |= 8192; }
if (sbar.boot_amount != p->boot_amount) { sbar.boot_amount = p->boot_amount; u |= 8192; }
if (u == 0) return;
//0 - update health
//1 - update armor
//2 - update PISTOL_WEAPON ammo
//3 - update SHOTGUN_WEAPON ammo
//4 - update CHAINGUN_WEAPON ammo
//5 - update RPG_WEAPON ammo
//6 - update HANDBOMB_WEAPON ammo
//7 - update SHRINKER_WEAPON ammo
//8 - update DEVISTATOR_WEAPON ammo
//9 - update TRIPBOMB_WEAPON ammo
//10 - update ammo display
//11 - update inventory icon
//12 - update inventory on/off
//13 - update inventory %
//14 - update keys
//15 - update kills
//16 - update FREEZE_WEAPON ammo
if (u == 0xffffffff)
{
patchstatusbar(0,0,320,200);
if (ud.multimode > 1 && ud.coop != 1)
rotatesprite(277<<16,(200-27)<<16,65536L,0,KILLSICON,0,0,10+16+128,0,0,xdim-1,ydim-1);
}
if (ud.multimode > 1 && ud.coop != 1)
{
if (u&32768)
{
if (u != 0xffffffff) patchstatusbar(276,183,299,193);
digitalnumber(287,200-17,max(p->frag-p->fraggedself,0),-16,10+16+128);
}
}
else
{
if (u&16384)
{
if (u != 0xffffffff) patchstatusbar(275,182,299,194);
if (p->got_access&4) rotatesprite(275<<16,182<<16,65536L,0,ACCESS_ICON,0,23,10+16+128,0,0,xdim-1,ydim-1);
if (p->got_access&2) rotatesprite(288<<16,182<<16,65536L,0,ACCESS_ICON,0,21,10+16+128,0,0,xdim-1,ydim-1);
if (p->got_access&1) rotatesprite(281<<16,189<<16,65536L,0,ACCESS_ICON,0,0,10+16+128,0,0,xdim-1,ydim-1);
}
}
if (u&(4+8+16+32+64+128+256+512+65536L)) weapon_amounts(p,96,182,u);
if (u&1)
{
if (u != 0xffffffff) patchstatusbar(20,183,43,193);
if(sprite[p->i].pal == 1 && p->last_extra < 2)
digitalnumber(32,200-17,1,-16,10+16+128);
else digitalnumber(32,200-17,p->last_extra,-16,10+16+128);
}
if (u&2)
{
if (u != 0xffffffff) patchstatusbar(52,183,75,193);
digitalnumber(64,200-17,p->shield_amount,-16,10+16+128);
}
if (u&1024)
{
if (u != 0xffffffff) patchstatusbar(196,183,219,193);
if (p->curr_weapon != KNEE_WEAPON)
{
if (p->curr_weapon == HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; else i = p->curr_weapon;
digitalnumber(230-22,200-17,p->ammo_amount[i],-16,10+16+128);
}
}
if (u&(2048+4096+8192))
{
if (u != 0xffffffff)
{
if (u&(2048+4096)) { patchstatusbar(231,179,265,197); }
else { patchstatusbar(250,190,261,195); }
}
if (p->inven_icon)
{
o = 0; permbit = 128;
if (u&(2048+4096))
{
switch(p->inven_icon)
{
case 1: i = FIRSTAID_ICON; break;
case 2: i = STEROIDS_ICON; break;
case 3: i = HOLODUKE_ICON; break;
case 4: i = JETPACK_ICON; break;
case 5: i = HEAT_ICON; break;
case 6: i = AIRTANK_ICON; break;
case 7: i = BOOT_ICON; break;
}
rotatesprite((231-o)<<16,(200-21)<<16,65536L,0,i,0,0,10+16+permbit,0,0,xdim-1,ydim-1);
minitext(292-30-o,190,"%",6,10+16+permbit);
if (p->inven_icon >= 6) minitext(284-35-o,180,"AUTO",2,10+16+permbit);
}
if (u&(2048+4096))
{
switch(p->inven_icon)
{
case 3: j = p->holoduke_on; break;
case 4: j = p->jetpack_on; break;
case 5: j = p->heat_on; break;
default: j = 0x80000000;
}
if (j > 0) minitext(288-30-o,180,"ON",0,10+16+permbit);
else if (j != 0x80000000) minitext(284-30-o,180,"OFF",2,10+16+permbit);
}
if (u&8192)
{
switch(p->inven_icon)
{
case 1: i = p->firstaid_amount; break;
case 2: i = ((p->steroids_amount+3)>>2); break;
case 3: i = ((p->holoduke_amount+15)/24); break;
case 4: i = ((p->jetpack_amount+15)>>4); break;
case 5: i = p->heat_amount/12; break;
case 6: i = ((p->scuba_amount+63)>>6); break;
case 7: i = (p->boot_amount>>1); break;
}
invennum(284-30-o,200-6,(char)i,0,10+permbit);
}
}
}
}
#define AVERAGEFRAMES 16
static long frameval[AVERAGEFRAMES], framecnt = 0;
void tics(void)
{
long i;
char b[10];
i = totalclock;
if (i != frameval[framecnt])
{
sprintf(b,"%ld",(TICRATE*AVERAGEFRAMES)/(i-frameval[framecnt]));
printext256(windowx1,windowy1,31,-21,b,1);
frameval[framecnt] = i;
}
framecnt = ((framecnt+1)&(AVERAGEFRAMES-1));
}
void coords(short snum)
{
short y = 0;
if(ud.coop != 1)
{
if(ud.multimode > 1 && ud.multimode < 5)
y = 8;
else if(ud.multimode > 4)
y = 16;
}
sprintf(tempbuf,"X= %ld",ps[snum].posx);
printext256(250L,y,31,-1,tempbuf,1);
sprintf(tempbuf,"Y= %ld",ps[snum].posy);
printext256(250L,y+7L,31,-1,tempbuf,1);
sprintf(tempbuf,"Z= %ld",ps[snum].posz);
printext256(250L,y+14L,31,-1,tempbuf,1);
sprintf(tempbuf,"A= %ld",ps[snum].ang);
printext256(250L,y+21L,31,-1,tempbuf,1);
sprintf(tempbuf,"ZV= %ld",ps[snum].poszv);
printext256(250L,y+28L,31,-1,tempbuf,1);
sprintf(tempbuf,"OG= %ld",ps[snum].on_ground);
printext256(250L,y+35L,31,-1,tempbuf,1);
sprintf(tempbuf,"AM= %ld",ps[snum].ammo_amount[GROW_WEAPON]);
printext256(250L,y+43L,31,-1,tempbuf,1);
sprintf(tempbuf,"LFW= %ld",ps[snum].last_full_weapon);
printext256(250L,y+50L,31,-1,tempbuf,1);
sprintf(tempbuf,"SECTL= %ld",sector[ps[snum].cursectnum].lotag);
printext256(250L,y+57L,31,-1,tempbuf,1);
sprintf(tempbuf,"SEED= %ld",randomseed);
printext256(250L,y+64L,31,-1,tempbuf,1);
sprintf(tempbuf,"THOLD= %ld",ps[snum].transporter_hold);
printext256(250L,y+64L+7,31,-1,tempbuf,1);
}
void operatefta(void)
{
long i, j, k;
if(ud.screen_size > 0) j = 200-45; else j = 200-8;
quotebot = min(quotebot,j);
quotebotgoal = min(quotebotgoal,j);
if(ps[myconnectindex].gm&MODE_TYPE) j -= 8;
quotebotgoal = j; j = quotebot;
for(i=0;i<MAXUSERQUOTES;i++)
{
k = user_quote_time[i]; if (k <= 0) break;
if (k > 4)
gametext(320>>1,j,user_quote[i],0,2+8+16);
else if (k > 2) gametext(320>>1,j,user_quote[i],0,2+8+16+1);
else gametext(320>>1,j,user_quote[i],0,2+8+16+1+32);
j -= 8;
}
if (ps[screenpeek].fta <= 1) return;
if (ud.coop != 1 && ud.screen_size > 0 && ud.multimode > 1)
{
j = 0; k = 8;
for(i=connecthead;i>=0;i=connectpoint2[i])
if (i > j) j = i;
if (j >= 4 && j <= 8) k += 8;
else if (j > 8 && j <= 12) k += 16;
else if (j > 12) k += 24;
}
else k = 0;
if (ps[screenpeek].ftq == 115 || ps[screenpeek].ftq == 116)
{
k = quotebot;
for(i=0;i<MAXUSERQUOTES;i++)
{
if (user_quote_time[i] <= 0) break;
k -= 8;
}
k -= 4;
}
j = ps[screenpeek].fta;
if (j > 4)
gametext(320>>1,k,fta_quotes[ps[screenpeek].ftq],0,2+8+16);
else
if (j > 2) gametext(320>>1,k,fta_quotes[ps[screenpeek].ftq],0,2+8+16+1);
else
gametext(320>>1,k,fta_quotes[ps[screenpeek].ftq],0,2+8+16+1+32);
}
void FTA(short q,struct player_struct *p)
{
if( ud.fta_on == 1)
{
if( p->fta > 0 && q != 115 && q != 116 )
if( p->ftq == 115 || p->ftq == 116 ) return;
p->fta = 100;
if( p->ftq != q || q == 26 )
// || q == 26 || q == 115 || q ==116 || q == 117 || q == 122 )
{
p->ftq = q;
pub = NUMPAGES;
pus = NUMPAGES;
}
}
}
void showtwoscreens(void)
{
short i;
#ifndef VOLUMEALL
setview(0,0,xdim-1,ydim-1);
flushperms();
ps[myconnectindex].palette = palette;
for(i=0;i<64;i+=7) palto(0,0,0,i);
KB_FlushKeyboardQueue();
rotatesprite(0,0,65536L,0,3291,0,0,2+8+16+64, 0,0,xdim-1,ydim-1);
nextpage(); for(i=63;i>0;i-=7) palto(0,0,0,i);
while( !KB_KeyWaiting() ) getpackets();
for(i=0;i<64;i+=7) palto(0,0,0,i);
KB_FlushKeyboardQueue();
rotatesprite(0,0,65536L,0,3290,0,0,2+8+16+64, 0,0,xdim-1,ydim-1);
nextpage(); for(i=63;i>0;i-=7) palto(0,0,0,i);
while( !KB_KeyWaiting() ) getpackets();
#else
// CTW - REMOVED
/* setview(0,0,xdim-1,ydim-1);
flushperms();
ps[myconnectindex].palette = palette;
for(i=0;i<64;i+=7) palto(0,0,0,i);
KB_FlushKeyboardQueue();
clearview(0L);
rotatesprite(0,0,65536L,0,TENSCREEN,0,0,2+8+16+64, 0,0,xdim-1,ydim-1);
nextpage(); for(i=63;i>0;i-=7) palto(0,0,0,i);
totalclock = 0;
while( !KB_KeyWaiting() && totalclock < 2400) getpackets();*/
// CTW END - REMOVED
#endif
}
void binscreen(void)
{
long fil;
#ifdef VOLUMEONE
fil = kopen4load("dukesw.bin",1);
#else
fil = kopen4load("duke3d.bin",1);
#endif
if(fil == -1) return;
kread(fil,(char *)0xb8000,4000);
kclose(fil);
}
void gameexit(char *t)
{
short i;
if(*t != 0) ps[myconnectindex].palette = (char *) &palette[0];
if(numplayers > 1)
{
allowtimetocorrecterrorswhenquitting();
uninitmultiplayers();
}
if(ud.recstat == 1) closedemowrite();
else if(ud.recstat == 2) { fclose(frecfilep); }
if(qe || cp)
goto GOTOHERE;
if(playerswhenstarted > 1 && ud.coop != 1 && *t == ' ')
{
dobonus(1);
// CTW - MODIFICATION
// setgamemode();
setgamemode(ScreenMode,ScreenWidth,ScreenHeight);
// CTW END - MODIFICATION
}
#ifdef ONELEVELDEMO
doorders();
t = "You have been playing a ONE LEVEL demo of Duke Nukem 3D.";
#endif
// CTW - MODIFICATION
/* if( *t != 0 && *(t+1) != 'V' && *(t+1) != 'Y' && playonten == 0 )
showtwoscreens();*/
if( *t != 0 && *(t+1) != 'V' && *(t+1) != 'Y' && true)
showtwoscreens();
// CTW END - MODIFICATION
GOTOHERE:
Shutdown();
if(*t != 0)
{
setvmode(0x3);
binscreen();
// CTW - MODIFICATION
/* if(playonten == 0)
{
if(*t == ' ' && *(t+1) == 0) *t = 0;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("%s%s","\n",t);
}*/
if(true)
{
if(*t == ' ' && *(t+1) == 0) *t = 0;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("%s%s","\n",t);
}
// CTW END - MODIFICATION
}
uninitgroupfile();
unlink("duke3d.tmp");
exit(0);
}
short inputloc = 0;
short strget(short x,short y,char *t,short dalen,short c)
{
short ch,sc;
while(KB_KeyWaiting())
{
sc = 0;
ch = KB_Getch();
if (ch == 0)
{
sc = KB_Getch();
if( sc == 104) return(1);
continue;
}
else
{
if(ch == 8)
{
if( inputloc > 0 )
{
inputloc--;
*(t+inputloc) = 0;
}
}
else
{
if(ch == asc_Enter || sc == 104)
{
KB_ClearKeyDown(sc_Enter);
KB_ClearKeyDown(sc_kpad_Enter);
return (1);
}
else if(ch == asc_Escape)
{
KB_ClearKeyDown(sc_Escape);
return (-1);
}
else if ( ch >= 32 && inputloc < dalen && ch < 127)
{
ch = toupper(ch);
*(t+inputloc) = ch;
*(t+inputloc+1) = 0;
inputloc++;
}
}
}
}
if( c == 999 ) return(0);
if( c == 998 )
{
char b[41],ii;
for(ii=0;ii<inputloc;ii++)
b[ii] = '*';
b[ii] = 0;
x = gametext(x,y,b,c,2+8+16);
}
else x = gametext(x,y,t,c,2+8+16);
c = 4-(sintable[(totalclock<<4)&2047]>>11);
rotatesprite((x+8)<<16,(y+4)<<16,32768L,0,SPINNINGNUKEICON+((totalclock>>3)%7),c,0,2+8,0,0,xdim-1,ydim-1);
return (0);
}
void typemode(void)
{
short ch, hitstate, i, j;
if( ps[myconnectindex].gm&MODE_SENDTOWHOM )
{
if(sendmessagecommand != -1 || ud.multimode < 3 || movesperpacket == 4)
{
tempbuf[0] = 4;
tempbuf[1] = 0;
recbuf[0] = 0;
if(ud.multimode < 3)
sendmessagecommand = 2;
strcat(recbuf,ud.user_name[myconnectindex]);
strcat(recbuf,": ");
strcat(recbuf,typebuf);
j = strlen(recbuf);
recbuf[j] = 0;
strcat(tempbuf+1,recbuf);
if(sendmessagecommand >= ud.multimode || movesperpacket == 4)
{
for(ch=connecthead;ch >= 0;ch=connectpoint2[ch])
if (ch != myconnectindex)
sendpacket(ch,tempbuf,j+1);
adduserquote(recbuf);
quotebot += 8;
quotebotgoal = quotebot;
}
else if(sendmessagecommand >= 0)
sendpacket(sendmessagecommand,tempbuf,j+1);
sendmessagecommand = -1;
ps[myconnectindex].gm &= ~(MODE_TYPE|MODE_SENDTOWHOM);
}
else if(sendmessagecommand == -1)
{
j = 50;
gametext(320>>1,j,"SEND MESSAGE TO...",0,2+8+16); j += 8;
for(i=connecthead;i>=0;i=connectpoint2[i])
// for(i=0;i<ud.multimode;i++)
{
if (i == myconnectindex)
{
minitextshade((320>>1)-40+1,j+1,"A/ENTER - ALL",26,0,2+8+16);
minitext((320>>1)-40,j,"A/ENTER - ALL",0,2+8+16); j += 7;
}
else
{
sprintf(buf," %ld - %s",i+1,ud.user_name[i]);
minitextshade((320>>1)-40-6+1,j+1,buf,26,0,2+8+16);
minitext((320>>1)-40-6,j,buf,0,2+8+16); j += 7;
}
}
minitextshade((320>>1)-40-4+1,j+1," ESC - Abort",26,0,2+8+16);
minitext((320>>1)-40-4,j," ESC - Abort",0,2+8+16); j += 7;
//sprintf(buf,"PRESS 1-%ld FOR INDIVIDUAL PLAYER.",ud.multimode);
//gametext(320>>1,j,buf,0,2+8+16); j += 8;
//gametext(320>>1,j,"'A' OR 'ENTER' FOR ALL PLAYERS",0,2+8+16); j += 8;
//gametext(320>>1,j,"ESC ABORTS",0,2+8+16); j += 8;
if (ud.screen_size > 0) j = 200-45; else j = 200-8;
gametext(320>>1,j,typebuf,0,2+8+16);
if( KB_KeyWaiting() )
{
i = KB_GetCh();
if(i == 'A' || i == 'a' || i == 13)
sendmessagecommand = ud.multimode;
else if(i >= '1' || i <= (ud.multimode + '1') )
sendmessagecommand = i - '1';
else
{
sendmessagecommand = ud.multimode;
if(i == 27)
{
ps[myconnectindex].gm &= ~(MODE_TYPE|MODE_SENDTOWHOM);
sendmessagecommand = -1;
}
else
typebuf[0] = 0;
}
KB_ClearKeyDown(sc_1);
KB_ClearKeyDown(sc_2);
KB_ClearKeyDown(sc_3);
KB_ClearKeyDown(sc_4);
KB_ClearKeyDown(sc_5);
KB_ClearKeyDown(sc_6);
KB_ClearKeyDown(sc_7);
KB_ClearKeyDown(sc_8);
KB_ClearKeyDown(sc_A);
KB_ClearKeyDown(sc_Escape);
KB_ClearKeyDown(sc_Enter);
}
}
}
else
{
if(ud.screen_size > 0) j = 200-45; else j = 200-8;
hitstate = strget(320>>1,j,typebuf,30,1);
if(hitstate == 1)
{
KB_ClearKeyDown(sc_Enter);
ps[myconnectindex].gm |= MODE_SENDTOWHOM;
}
else if(hitstate == -1)
ps[myconnectindex].gm &= ~(MODE_TYPE|MODE_SENDTOWHOM);
else pub = NUMPAGES;
}
}
void moveclouds(void)
{
if( totalclock > cloudtotalclock || totalclock < (cloudtotalclock-7))
{
short i;
cloudtotalclock = totalclock+6;
for(i=0;i<numclouds;i++)
{
cloudx[i] += (sintable[(ps[screenpeek].ang+512)&2047]>>9);
cloudy[i] += (sintable[ps[screenpeek].ang&2047]>>9);
sector[clouds[i]].ceilingxpanning = cloudx[i]>>6;
sector[clouds[i]].ceilingypanning = cloudy[i]>>6;
}
}
}
void displayrest(long smoothratio)
{
long a, i, j;
struct player_struct *pp;
walltype *wal;
long cposx,cposy,cang;
pp = &ps[screenpeek];
if( pp->pals_time > 0 && pp->loogcnt == 0)
{
palto( pp->pals[0],
pp->pals[1],
pp->pals[2],
pp->pals_time|128);
restorepalette = 1;
}
else if( restorepalette )
{
setbrightness(ud.brightness>>2,&pp->palette[0]);
restorepalette = 0;
}
else if(pp->loogcnt > 0) palto(0,64,0,(pp->loogcnt>>1)+128);
if(ud.show_help)
{
switch(ud.show_help)
{
case 1:
rotatesprite(0,0,65536L,0,TEXTSTORY,0,0,10+16+64, 0,0,xdim-1,ydim-1);
break;
case 2:
rotatesprite(0,0,65536L,0,F1HELP,0,0,10+16+64, 0,0,xdim-1,ydim-1);
break;
}
if ( KB_KeyPressed(sc_Escape ) )
{
KB_ClearKeyDown(sc_Escape);
ud.show_help = 0;
if(ud.multimode < 2 && ud.recstat != 2)
{
ready2send = 1;
totalclock = ototalclock;
}
vscrn();
}
return;
}
i = pp->cursectnum;
show2dsector[i>>3] |= (1<<(i&7));
wal = &wall[sector[i].wallptr];
for(j=sector[i].wallnum;j>0;j--,wal++)
{
i = wal->nextsector;
if (i < 0) continue;
if (wal->cstat&0x0071) continue;
if (wall[wal->nextwall].cstat&0x0071) continue;
if (sector[i].lotag == 32767) continue;
if (sector[i].ceilingz >= sector[i].floorz) continue;
show2dsector[i>>3] |= (1<<(i&7));
}
if(ud.camerasprite == -1)
{
if( ud.overhead_on != 2 )
{
if(pp->newowner >= 0)
cameratext(pp->newowner);
else
{
displayweapon(screenpeek);
if(pp->over_shoulder_on == 0 )
displaymasks(screenpeek);
}
moveclouds();
}
if( ud.overhead_on > 0 )
{
smoothratio = min(max(smoothratio,0),65536);
dointerpolations(smoothratio);
if( ud.scrollmode == 0 )
{
if(pp->newowner == -1)
{
if (screenpeek == myconnectindex && numplayers > 1)
{
cposx = omyx+mulscale16((long)(myx-omyx),smoothratio);
cposy = omyy+mulscale16((long)(myy-omyy),smoothratio);
cang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio);
}
else
{
cposx = pp->oposx+mulscale16((long)(pp->posx-pp->oposx),smoothratio);
cposy = pp->oposy+mulscale16((long)(pp->posy-pp->oposy),smoothratio);
cang = pp->oang+mulscale16((long)(((pp->ang+1024-pp->oang)&2047)-1024),smoothratio);
}
}
else
{
cposx = pp->oposx;
cposy = pp->oposy;
cang = pp->oang;
}
}
else
{
ud.fola += ud.folavel>>3;
ud.folx += (ud.folfvel*sintable[(512+2048-ud.fola)&2047])>>14;
ud.foly += (ud.folfvel*sintable[(512+1024-512-ud.fola)&2047])>>14;
cposx = ud.folx;
cposy = ud.foly;
cang = ud.fola;
}
if(ud.overhead_on == 2)
{
clearview(0L);
drawmapview(cposx,cposy,pp->zoom,cang);
}
drawoverheadmap( cposx,cposy,pp->zoom,cang);
restoreinterpolations();
if(ud.overhead_on == 2)
{
if(ud.screen_size > 0) a = 147;
else a = 182;
minitext(1,a+6,volume_names[ud.volume_number],0,2+8+16);
minitext(1,a+12,level_names[ud.volume_number*11 + ud.level_number],0,2+8+16);
}
}
}
coolgaugetext(screenpeek);
operatefta();
if( KB_KeyPressed(sc_Escape) && ud.overhead_on == 0
&& ud.show_help == 0
&& ps[myconnectindex].newowner == -1)
{
if( (ps[myconnectindex].gm&MODE_MENU) == MODE_MENU && current_menu < 51)
{
KB_ClearKeyDown(sc_Escape);
ps[myconnectindex].gm &= ~MODE_MENU;
if(ud.multimode < 2 && ud.recstat != 2)
{
ready2send = 1;
totalclock = ototalclock;
cameraclock = totalclock;
cameradist = 65536L;
}
walock[MAXTILES-1] = 199;
vscrn();
}
else if( (ps[myconnectindex].gm&MODE_MENU) != MODE_MENU &&
ps[myconnectindex].newowner == -1 &&
(ps[myconnectindex].gm&MODE_TYPE) != MODE_TYPE)
{
KB_ClearKeyDown(sc_Escape);
FX_StopAllSounds();
clearsoundlocks();
intomenusounds();
ps[myconnectindex].gm |= MODE_MENU;
if(ud.multimode < 2 && ud.recstat != 2) ready2send = 0;
if(ps[myconnectindex].gm&MODE_GAME) cmenu(50);
else cmenu(0);
screenpeek = myconnectindex;
}
}
if(ps[myconnectindex].newowner == -1 && ud.overhead_on == 0 && ud.crosshair && ud.camerasprite == -1)
rotatesprite((160L-(ps[myconnectindex].look_ang>>1))<<16,100L<<16,65536L,0,CROSSHAIR,0,0,2+1,windowx1,windowy1,windowx2,windowy2);
if(ps[myconnectindex].gm&MODE_TYPE)
typemode();
else
menus();
if( ud.pause_on==1 && (ps[myconnectindex].gm&MODE_MENU) == 0 )
menutext(160,100,0,0,"GAME PAUSED");
if(ud.coords)
coords(screenpeek);
if(ud.tickrate)
tics();
}
void updatesectorz(long x, long y, long z, short *sectnum)
{
walltype *wal;
long i, j, cz, fz;
getzsofslope(*sectnum,x,y,&cz,&fz);
if ((z >= cz) && (z <= fz))
if (inside(x,y,*sectnum) != 0) return;
if ((*sectnum >= 0) && (*sectnum < numsectors))
{
wal = &wall[sector[*sectnum].wallptr];
j = sector[*sectnum].wallnum;
do
{
i = wal->nextsector;
if (i >= 0)
{
getzsofslope(i,x,y,&cz,&fz);
if ((z >= cz) && (z <= fz))
if (inside(x,y,(short)i) == 1)
{ *sectnum = i; return; }
}
wal++; j--;
} while (j != 0);
}
for(i=numsectors-1;i>=0;i--)
{
getzsofslope(i,x,y,&cz,&fz);
if ((z >= cz) && (z <= fz))
if (inside(x,y,(short)i) == 1)
{ *sectnum = i; return; }
}
*sectnum = -1;
}
void view(struct player_struct *pp, long *vx, long *vy,long *vz,short *vsectnum, short ang, short horiz)
{
spritetype *sp;
long i, nx, ny, nz, hx, hy, hz, hitx, hity, hitz;
short bakcstat, hitsect, hitwall, hitsprite, daang;
nx = (sintable[(ang+1536)&2047]>>4);
ny = (sintable[(ang+1024)&2047]>>4);
nz = (horiz-100)*128;
sp = &sprite[pp->i];
bakcstat = sp->cstat;
sp->cstat &= (short)~0x101;
updatesectorz(*vx,*vy,*vz,vsectnum);
hitscan(*vx,*vy,*vz,*vsectnum,nx,ny,nz,&hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1);
if(*vsectnum < 0)
{
sp->cstat = bakcstat;
return;
}
hx = hitx-(*vx); hy = hity-(*vy);
if (klabs(nx)+klabs(ny) > klabs(hx)+klabs(hy))
{
*vsectnum = hitsect;
if (hitwall >= 0)
{
daang = getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,
wall[wall[hitwall].point2].y-wall[hitwall].y);
i = nx*sintable[daang]+ny*sintable[(daang+1536)&2047];
if (klabs(nx) > klabs(ny)) hx -= mulscale28(nx,i);
else hy -= mulscale28(ny,i);
}
else if (hitsprite < 0)
{
if (klabs(nx) > klabs(ny)) hx -= (nx>>5);
else hy -= (ny>>5);
}
if (klabs(nx) > klabs(ny)) i = divscale16(hx,nx);
else i = divscale16(hy,ny);
if (i < cameradist) cameradist = i;
}
*vx = (*vx)+mulscale16(nx,cameradist);
*vy = (*vy)+mulscale16(ny,cameradist);
*vz = (*vz)+mulscale16(nz,cameradist);
cameradist = min(cameradist+((totalclock-cameraclock)<<10),65536);
cameraclock = totalclock;
updatesectorz(*vx,*vy,*vz,vsectnum);
sp->cstat = bakcstat;
}
//REPLACE FULLY
void drawbackground(void)
{
short dapicnum;
long x,y,x1,y1,x2,y2,topy;
flushperms();
switch(ud.m_volume_number)
{
default:dapicnum = BIGHOLE;break;
case 1:dapicnum = BIGHOLE;break;
case 2:dapicnum = BIGHOLE;break;
}
y1 = 0; y2 = ydim;
if( ready2send || ud.recstat == 2 )
{
if(ud.coop != 1)
{
if (ud.multimode > 1) y1 += scale(ydim,8,200);
if (ud.multimode > 4) y1 += scale(ydim,8,200);
}
if (ud.screen_size >= 8) y2 = scale(ydim,200-34,200);
}
for(y=y1;y<y2;y+=128)
for(x=0;x<xdim;x+=128)
rotatesprite(x<<16,y<<16,65536L,0,dapicnum,8,0,8+16+64+128,0,y1,xdim-1,y2-1);
if(ud.screen_size > 8)
{
y = 0;
if(ud.coop != 1)
{
if (ud.multimode > 1) y += 8;
if (ud.multimode > 4) y += 8;
}
x1 = max(windowx1-4,0);
y1 = max(windowy1-4,y);
x2 = min(windowx2+4,xdim-1);
y2 = min(windowy2+4,scale(ydim,200-34,200)-1);
for(y=y1+4;y<y2-4;y+=64)
{
rotatesprite(x1<<16,y<<16,65536L,0,VIEWBORDER,0,0,8+16+64+128,x1,y1,x2,y2);
rotatesprite((x2+1)<<16,(y+64)<<16,65536L,1024,VIEWBORDER,0,0,8+16+64+128,x1,y1,x2,y2);
}
for(x=x1+4;x<x2-4;x+=64)
{
rotatesprite((x+64)<<16,y1<<16,65536L,512,VIEWBORDER,0,0,8+16+64+128,x1,y1,x2,y2);
rotatesprite(x<<16,(y2+1)<<16,65536L,1536,VIEWBORDER,0,0,8+16+64+128,x1,y1,x2,y2);
}
rotatesprite(x1<<16,y1<<16,65536L,0,VIEWBORDER+1,0,0,8+16+64+128,x1,y1,x2,y2);
rotatesprite((x2+1)<<16,y1<<16,65536L,512,VIEWBORDER+1,0,0,8+16+64+128,x1,y1,x2,y2);
rotatesprite((x2+1)<<16,(y2+1)<<16,65536L,1024,VIEWBORDER+1,0,0,8+16+64+128,x1,y1,x2,y2);
rotatesprite(x1<<16,(y2+1)<<16,65536L,1536,VIEWBORDER+1,0,0,8+16+64+128,x1,y1,x2,y2);
}
}
// Floor Over Floor
// If standing in sector with SE42
// then draw viewing to SE41 and raise all =hi SE43 cielings.
// If standing in sector with SE43
// then draw viewing to SE40 and lower all =hi SE42 floors.
// If standing in sector with SE44
// then draw viewing to SE40.
// If standing in sector with SE45
// then draw viewing to SE41.
#define FOFTILE 13
#define FOFTILEX 32
#define FOFTILEY 32
long tempsectorz[MAXSECTORS];
long tempsectorpicnum[MAXSECTORS];
//short tempcursectnum;
SE40_Draw(int spnum,long x,long y,long z,short a,short h,long smoothratio)
{
int i=0,j=0,k=0;
int floor1=0,floor2=0,ok=0,fofmode=0;
long offx,offy;
if(sprite[spnum].ang!=512) return;
i = FOFTILE; //Effect TILE
if (!(gotpic[i>>3]&(1<<(i&7)))) return;
gotpic[i>>3] &= ~(1<<(i&7));
floor1=spnum;
if(sprite[spnum].lotag==42) fofmode=40;
if(sprite[spnum].lotag==43) fofmode=41;
if(sprite[spnum].lotag==44) fofmode=40;
if(sprite[spnum].lotag==45) fofmode=41;
// fofmode=sprite[spnum].lotag-2;
// sectnum=sprite[j].sectnum;
// sectnum=cursectnum;
ok++;
/* recursive?
for(j=0;j<MAXSPRITES;j++)
{
if(
sprite[j].sectnum==sectnum &&
sprite[j].picnum==1 &&
sprite[j].lotag==110
) { DrawFloorOverFloor(j); break;}
}
*/
// if(ok==0) { Message("no fof",RED); return; }
for(j=0;j<MAXSPRITES;j++)
{
if(
sprite[j].picnum==1 &&
sprite[j].lotag==fofmode &&
sprite[j].hitag==sprite[floor1].hitag
) { floor1=j; fofmode=sprite[j].lotag; ok++; break;}
}
// if(ok==1) { Message("no floor1",RED); return; }
if(fofmode==40) k=41; else k=40;
for(j=0;j<MAXSPRITES;j++)
{
if(
sprite[j].picnum==1 &&
sprite[j].lotag==k &&
sprite[j].hitag==sprite[floor1].hitag
) {floor2=j; ok++; break;}
}
// if(ok==2) { Message("no floor2",RED); return; }
for(j=0;j<MAXSPRITES;j++) // raise ceiling or floor
{
if(sprite[j].picnum==1 &&
sprite[j].lotag==k+2 &&
sprite[j].hitag==sprite[floor1].hitag
)
{
if(k==40)
{tempsectorz[sprite[j].sectnum]=sector[sprite[j].sectnum].floorz;
sector[sprite[j].sectnum].floorz+=(((z-sector[sprite[j].sectnum].floorz)/32768)+1)*32768;
tempsectorpicnum[sprite[j].sectnum]=sector[sprite[j].sectnum].floorpicnum;
sector[sprite[j].sectnum].floorpicnum=13;
}
if(k==41)
{tempsectorz[sprite[j].sectnum]=sector[sprite[j].sectnum].ceilingz;
sector[sprite[j].sectnum].ceilingz+=(((z-sector[sprite[j].sectnum].ceilingz)/32768)-1)*32768;
tempsectorpicnum[sprite[j].sectnum]=sector[sprite[j].sectnum].ceilingpicnum;
sector[sprite[j].sectnum].ceilingpicnum=13;
}
}
}
i=floor1;
offx=x-sprite[i].x;
offy=y-sprite[i].y;
i=floor2;
drawrooms(offx+sprite[i].x,offy+sprite[i].y,z,a,h,sprite[i].sectnum);
animatesprites(x,y,a,smoothratio);
drawmasks();
for(j=0;j<MAXSPRITES;j++) // restore ceiling or floor
{
if(sprite[j].picnum==1 &&
sprite[j].lotag==k+2 &&
sprite[j].hitag==sprite[floor1].hitag
)
{
if(k==40)
{sector[sprite[j].sectnum].floorz=tempsectorz[sprite[j].sectnum];
sector[sprite[j].sectnum].floorpicnum=tempsectorpicnum[sprite[j].sectnum];
}
if(k==41)
{sector[sprite[j].sectnum].ceilingz=tempsectorz[sprite[j].sectnum];
sector[sprite[j].sectnum].ceilingpicnum=tempsectorpicnum[sprite[j].sectnum];
}
}// end if
}// end for
} // end SE40
void se40code(long x,long y,long z,long a,long h, long smoothratio)
{
int i;
i = headspritestat[15];
while(i >= 0)
{
switch(sprite[i].lotag)
{
// case 40:
// case 41:
// SE40_Draw(i,x,y,a,smoothratio);
// break;
case 42:
case 43:
case 44:
case 45:
if(ps[screenpeek].cursectnum == sprite[i].sectnum)
SE40_Draw(i,x,y,z,a,h,smoothratio);
break;
}
i = nextspritestat[i];
}
}
static long oyrepeat=-1;
void displayrooms(short snum,long smoothratio)
{
long cposx,cposy,cposz,dst,j,fz,cz,hz,lz;
short sect, cang, k, choriz,tsect;
struct player_struct *p;
long tposx,tposy,tposz,dx,dy,thoriz,i;
short tang;
p = &ps[snum];
// if(screencapt == 0 && (p->gm&MODE_MENU) && ( (current_menu/100) == 3 ) || (current_menu >= 1000 && current_menu < 2999 ) )
// return;
if(pub > 0)
{
if(ud.screen_size > 8) drawbackground();
pub = 0;
}
if( ud.overhead_on == 2 || ud.show_help || p->cursectnum == -1)
return;
smoothratio = min(max(smoothratio,0),65536);
visibility = p->visibility;
if(ud.pause_on || ps[snum].on_crane > -1) smoothratio = 65536;
sect = p->cursectnum;
if(sect < 0 || sect >= MAXSECTORS) return;
dointerpolations(smoothratio);
animatecamsprite();
if(ud.camerasprite >= 0)
{
spritetype *s;
s = &sprite[ud.camerasprite];
if(s->yvel < 0) s->yvel = -100;
else if(s->yvel > 199) s->yvel = 300;
cang = hittype[ud.camerasprite].tempang+mulscale16((long)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio);
se40code(s->x,s->y,s->z,cang,s->yvel,smoothratio);
drawrooms(s->x,s->y,s->z-(4<<8),cang,s->yvel,s->sectnum);
animatesprites(s->x,s->y,cang,smoothratio);
drawmasks();
}
else
{
i = divscale22(1,sprite[p->i].yrepeat+28);
if (i != oyrepeat)
{
oyrepeat = i;
setaspect(oyrepeat,yxaspect);
}
if(screencapt)
{
walock[MAXTILES-1] = 254;
if (waloff[MAXTILES-1] == 0)
allocache((long *)&waloff[MAXTILES-1],100*160,&walock[MAXTILES-1]);
setviewtotile(MAXTILES-1,100L,160L);
}
else if( ( ud.screen_tilting && p->rotscrnang ) || ud.detail==0 )
{
if (ud.screen_tilting) tang = p->rotscrnang; else tang = 0;
walock[MAXTILES-2] = 255;
if (waloff[MAXTILES-2] == 0)
allocache(&waloff[MAXTILES-2],320L*320L,&walock[MAXTILES-2]);
if ((tang&1023) == 0)
setviewtotile(MAXTILES-2,200L>>(1-ud.detail),320L>>(1-ud.detail));
else
setviewtotile(MAXTILES-2,320L>>(1-ud.detail),320L>>(1-ud.detail));
if ((tang&1023) == 512)
{ //Block off unscreen section of 90ø tilted screen
j = ((320-60)>>(1-ud.detail));
for(i=(60>>(1-ud.detail))-1;i>=0;i--)
{
startumost[i] = 1; startumost[i+j] = 1;
startdmost[i] = 0; startdmost[i+j] = 0;
}
}
i = (tang&511); if (i > 256) i = 512-i;
i = sintable[i+512]*8 + sintable[i]*5L;
setaspect(i>>1,yxaspect);
}
if ( (snum == myconnectindex) && (numplayers > 1) )
{
cposx = omyx+mulscale16((long)(myx-omyx),smoothratio);
cposy = omyy+mulscale16((long)(myy-omyy),smoothratio);
cposz = omyz+mulscale16((long)(myz-omyz),smoothratio);
cang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio);
choriz = omyhoriz+omyhorizoff+mulscale16((long)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio);
sect = mycursectnum;
}
else
{
cposx = p->oposx+mulscale16((long)(p->posx-p->oposx),smoothratio);
cposy = p->oposy+mulscale16((long)(p->posy-p->oposy),smoothratio);
cposz = p->oposz+mulscale16((long)(p->posz-p->oposz),smoothratio);
cang = p->oang+mulscale16((long)(((p->ang+1024-p->oang)&2047)-1024),smoothratio);
choriz = p->ohoriz+p->ohorizoff+mulscale16((long)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio);
}
cang += p->look_ang;
if (p->newowner >= 0)
{
cang = p->ang+p->look_ang;
choriz = p->horiz+p->horizoff;
cposx = p->posx;
cposy = p->posy;
cposz = p->posz;
sect = sprite[p->newowner].sectnum;
smoothratio = 65536L;
}
else if( p->over_shoulder_on == 0 )
cposz += p->opyoff+mulscale16((long)(p->pyoff-p->opyoff),smoothratio);
else view(p,&cposx,&cposy,&cposz,&sect,cang,choriz);
cz = hittype[p->i].ceilingz;
fz = hittype[p->i].floorz;
if(earthquaketime > 0 && p->on_ground == 1)
{
cposz += 256-(((earthquaketime)&1)<<9);
cang += (2-((earthquaketime)&2))<<2;
}
if(sprite[p->i].pal == 1) cposz -= (18<<8);
if(p->newowner >= 0)
choriz = 100+sprite[p->newowner].shade;
else if(p->spritebridge == 0)
{
if( cposz < ( p->truecz + (4<<8) ) ) cposz = cz + (4<<8);
else if( cposz > ( p->truefz - (4<<8) ) ) cposz = fz - (4<<8);
}
if (sect >= 0)
{
getzsofslope(sect,cposx,cposy,&cz,&fz);
if (cposz < cz+(4<<8)) cposz = cz+(4<<8);
if (cposz > fz-(4<<8)) cposz = fz-(4<<8);
}
if(choriz > 299) choriz = 299;
else if(choriz < -99) choriz = -99;
se40code(cposx,cposy,cposz,cang,choriz,smoothratio);
if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0)
{
dst = 0x7fffffff; i = 0;
for(k=0;k<mirrorcnt;k++)
{
j = klabs(wall[mirrorwall[k]].x-cposx);
j += klabs(wall[mirrorwall[k]].y-cposy);
if (j < dst) dst = j, i = k;
}
if( wall[mirrorwall[i]].overpicnum == MIRROR )
{
preparemirror(cposx,cposy,cposz,cang,choriz,mirrorwall[i],mirrorsector[i],&tposx,&tposy,&tang);
j = visibility;
visibility = (j>>1) + (j>>2);
drawrooms(tposx,tposy,cposz,tang,choriz,mirrorsector[i]+MAXSECTORS);
display_mirror = 1;
animatesprites(tposx,tposy,tang,smoothratio);
display_mirror = 0;
drawmasks();
completemirror(); //Reverse screen x-wise in this function
visibility = j;
}
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
}
drawrooms(cposx,cposy,cposz,cang,choriz,sect);
animatesprites(cposx,cposy,cang,smoothratio);
drawmasks();
if(screencapt == 1)
{
setviewback();
walock[MAXTILES-1] = 1;
screencapt = 0;
}
else if( ( ud.screen_tilting && p->rotscrnang) || ud.detail==0 )
{
if (ud.screen_tilting) tang = p->rotscrnang; else tang = 0;
setviewback();
picanm[MAXTILES-2] &= 0xff0000ff;
i = (tang&511); if (i > 256) i = 512-i;
i = sintable[i+512]*8 + sintable[i]*5L;
if ((1-ud.detail) == 0) i >>= 1;
rotatesprite(160<<16,100<<16,i,tang+512,MAXTILES-2,0,0,4+2+64,windowx1,windowy1,windowx2,windowy2);
walock[MAXTILES-2] = 199;
}
}
restoreinterpolations();
if (totalclock < lastvisinc)
{
if (klabs(p->visibility-ud.const_visibility) > 8)
p->visibility += (ud.const_visibility-p->visibility)>>2;
}
else p->visibility = ud.const_visibility;
}
short LocateTheLocator(short n,short sn)
{
short i;
i = headspritestat[7];
while(i >= 0)
{
if( (sn == -1 || sn == SECT) && n == SLT )
return i;
i = nextspritestat[i];
}
return -1;
}
short EGS(short whatsect,long s_x,long s_y,long s_z,short s_pn,signed char s_s,signed char s_xr,signed char s_yr,short s_a,short s_ve,long s_zv,short s_ow,signed char s_ss)
{
short i;
spritetype *s;
i = insertsprite(whatsect,s_ss);
if( i < 0 )
gameexit(" Too many sprites spawned.");
hittype[i].bposx = s_x;
hittype[i].bposy = s_y;
hittype[i].bposz = s_z;
s = &sprite[i];
s->x = s_x;
s->y = s_y;
s->z = s_z;
s->cstat = 0;
s->picnum = s_pn;
s->shade = s_s;
s->xrepeat = s_xr;
s->yrepeat = s_yr;
s->pal = 0;
s->ang = s_a;
s->xvel = s_ve;
s->zvel = s_zv;
s->owner = s_ow;
s->xoffset = 0;
s->yoffset = 0;
s->yvel = 0;
s->clipdist = 0;
s->pal = 0;
s->lotag = 0;
hittype[i].picnum = sprite[s_ow].picnum;
hittype[i].lastvx = 0;
hittype[i].lastvy = 0;
hittype[i].timetosleep = 0;
hittype[i].actorstayput = -1;
hittype[i].extra = -1;
hittype[i].owner = s_ow;
hittype[i].cgg = 0;
hittype[i].movflag = 0;
hittype[i].tempang = 0;
hittype[i].dispicnum = 0;
hittype[i].floorz = hittype[s_ow].floorz;
hittype[i].ceilingz = hittype[s_ow].ceilingz;
T1=T3=T4=T6=0;
if( actorscrptr[s_pn] )
{
s->extra = *actorscrptr[s_pn];
T5 = *(actorscrptr[s_pn]+1);
T2 = *(actorscrptr[s_pn]+2);
s->hitag = *(actorscrptr[s_pn]+3);
}
else
{
T2=T5=0;
s->extra = 0;
s->hitag = 0;
}
if (show2dsector[SECT>>3]&(1<<(SECT&7))) show2dsprite[i>>3] |= (1<<(i&7));
else show2dsprite[i>>3] &= ~(1<<(i&7));
/*
if(s->sectnum < 0)
{
s->xrepeat = s->yrepeat = 0;
changespritestat(i,5);
}
*/
return(i);
}
char wallswitchcheck(short i)
{
switch(PN)
{
case HANDPRINTSWITCH:
case HANDPRINTSWITCH+1:
case ALIENSWITCH:
case ALIENSWITCH+1:
case MULTISWITCH:
case MULTISWITCH+1:
case MULTISWITCH+2:
case MULTISWITCH+3:
case ACCESSSWITCH:
case ACCESSSWITCH2:
case PULLSWITCH:
case PULLSWITCH+1:
case HANDSWITCH:
case HANDSWITCH+1:
case SLOTDOOR:
case SLOTDOOR+1:
case LIGHTSWITCH:
case LIGHTSWITCH+1:
case SPACELIGHTSWITCH:
case SPACELIGHTSWITCH+1:
case SPACEDOORSWITCH:
case SPACEDOORSWITCH+1:
case FRANKENSTINESWITCH:
case FRANKENSTINESWITCH+1:
case LIGHTSWITCH2:
case LIGHTSWITCH2+1:
case POWERSWITCH1:
case POWERSWITCH1+1:
case LOCKSWITCH1:
case LOCKSWITCH1+1:
case POWERSWITCH2:
case POWERSWITCH2+1:
case DIPSWITCH:
case DIPSWITCH+1:
case DIPSWITCH2:
case DIPSWITCH2+1:
case TECHSWITCH:
case TECHSWITCH+1:
case DIPSWITCH3:
case DIPSWITCH3+1:
return 1;
}
return 0;
}
long tempwallptr;
short spawn( short j, short pn )
{
short i, s, startwall, endwall, sect, clostest;
long x, y, d;
spritetype *sp;
if(j >= 0)
{
i = EGS(sprite[j].sectnum,sprite[j].x,sprite[j].y,sprite[j].z
,pn,0,0,0,0,0,0,j,0);
hittype[i].picnum = sprite[j].picnum;
}
else
{
i = pn;
hittype[i].picnum = PN;
hittype[i].timetosleep = 0;
hittype[i].extra = -1;
hittype[i].bposx = SX;
hittype[i].bposy = SY;
hittype[i].bposz = SZ;
OW = hittype[i].owner = i;
hittype[i].cgg = 0;
hittype[i].movflag = 0;
hittype[i].tempang = 0;
hittype[i].dispicnum = 0;
hittype[i].floorz = sector[SECT].floorz;
hittype[i].ceilingz = sector[SECT].ceilingz;
hittype[i].lastvx = 0;
hittype[i].lastvy = 0;
hittype[i].actorstayput = -1;
T1 = T2 = T3 = T4 = T5 = T6 = 0;
if( PN != SPEAKER && PN != LETTER && PN != DUCK && PN != TARGET && PN != TRIPBOMB && PN != VIEWSCREEN && PN != VIEWSCREEN2 && (CS&48) )
if( !(PN >= CRACK1 && PN <= CRACK4) )
{
if(SS == 127) return i;
if( wallswitchcheck(i) == 1 && (CS&16) )
{
if( PN != ACCESSSWITCH && PN != ACCESSSWITCH2 && sprite[i].pal)
{
if( (ud.multimode < 2) || (ud.multimode > 1 && ud.coop==1) )
{
sprite[i].xrepeat = sprite[i].yrepeat = 0;
sprite[i].cstat = SLT = SHT = 0;
return i;
}
}
CS |= 257;
if( sprite[i].pal && PN != ACCESSSWITCH && PN != ACCESSSWITCH2)
sprite[i].pal = 0;
return i;
}
if( SHT )
{
changespritestat(i,12);
CS |= 257;
SH = impact_damage;
return i;
}
}
s = PN;
if( CS&1 ) CS |= 256;
if( actorscrptr[s] )
{
SH = *(actorscrptr[s]);
T5 = *(actorscrptr[s]+1);
T2 = *(actorscrptr[s]+2);
if( *(actorscrptr[s]+3) && SHT == 0 )
SHT = *(actorscrptr[s]+3);
}
else T2 = T5 = 0;
}
sp = &sprite[i];
sect = sp->sectnum;
switch(sp->picnum)
{
default:
if( actorscrptr[sp->picnum] )
{
if( j == -1 && sp->lotag > ud.player_skill )
{
sp->xrepeat=sp->yrepeat=0;
changespritestat(i,5);
break;
}
// Init the size
if(sp->xrepeat == 0 || sp->yrepeat == 0)
sp->xrepeat = sp->yrepeat = 1;
if( actortype[sp->picnum] & 3)
{
if( ud.monsters_off == 1 )
{
sp->xrepeat=sp->yrepeat=0;
changespritestat(i,5);
break;
}
makeitfall(i);
if( actortype[sp->picnum] & 2)
hittype[i].actorstayput = sp->sectnum;
ps[myconnectindex].max_actors_killed++;
sp->clipdist = 80;
if(j >= 0)
{
if(sprite[j].picnum == RESPAWN)
hittype[i].tempang = sprite[i].pal = sprite[j].pal;
changespritestat(i,1);
}
else changespritestat(i,2);
}
else
{
sp->clipdist = 40;
sp->owner = i;
changespritestat(i,1);
}
hittype[i].timetosleep = 0;
if(j >= 0)
sp->ang = sprite[j].ang;
}
break;
case FOF:
sp->xrepeat = sp->yrepeat = 0;
changespritestat(i,5);
break;
case WATERSPLASH2:
if(j >= 0)
{
setsprite(i,sprite[j].x,sprite[j].y,sprite[j].z);
sp->xrepeat = sp->yrepeat = 8+(TRAND&7);
}
else sp->xrepeat = sp->yrepeat = 16+(TRAND&15);
sp->shade = -16;
sp->cstat |= 128;
if(j >= 0)
{
if(sector[sprite[j].sectnum].lotag == 2)
{
sp->z = getceilzofslope(SECT,SX,SY)+(16<<8);
sp->cstat |= 8;
}
else if( sector[sprite[j].sectnum].lotag == 1)
sp->z = getflorzofslope(SECT,SX,SY);
}
if(sector[sect].floorpicnum == FLOORSLIME ||
sector[sect].ceilingpicnum == FLOORSLIME)
sp->pal = 7;
case NEON1:
case NEON2:
case NEON3:
case NEON4:
case NEON5:
case NEON6:
case DOMELITE:
if(sp->picnum != WATERSPLASH2)
sp->cstat |= 257;
case NUKEBUTTON:
if(sp->picnum == DOMELITE)
sp->cstat |= 257;
case JIBS1:
case JIBS2:
case JIBS3:
case JIBS4:
case JIBS5:
case JIBS6:
case HEADJIB1:
case ARMJIB1:
case LEGJIB1:
case LIZMANHEAD1:
case LIZMANARM1:
case LIZMANLEG1:
case DUKETORSO:
case DUKEGUN:
case DUKELEG:
changespritestat(i,5);
break;
case TONGUE:
if(j >= 0)
sp->ang = sprite[j].ang;
sp->z -= 38<<8;
sp->zvel = 256-(TRAND&511);
sp->xvel = 64-(TRAND&127);
changespritestat(i,4);
break;
case NATURALLIGHTNING:
sp->cstat &= ~257;
sp->cstat |= 32768;
break;
case TRANSPORTERSTAR:
case TRANSPORTERBEAM:
if(j == -1) break;
if(sp->picnum == TRANSPORTERBEAM)
{
sp->xrepeat = 31;
sp->yrepeat = 1;
sp->z = sector[sprite[j].sectnum].floorz-(40<<8);
}
else
{
if(sprite[j].statnum == 4)
{
sp->xrepeat = 8;
sp->yrepeat = 8;
}
else
{
sp->xrepeat = 48;
sp->yrepeat = 64;
if(sprite[j].statnum == 10 || badguy(&sprite[j]) )
sp->z -= (32<<8);
}
}
sp->shade = -127;
sp->cstat = 128|2;
sp->ang = sprite[j].ang;
sp->xvel = 128;
changespritestat(i,5);
ssp(i,CLIPMASK0);
setsprite(i,sp->x,sp->y,sp->z);
break;
case FRAMEEFFECT1:
if(j >= 0)
{
sp->xrepeat = sprite[j].xrepeat;
sp->yrepeat = sprite[j].yrepeat;
T2 = sprite[j].picnum;
}
else sp->xrepeat = sp->yrepeat = 0;
changespritestat(i,5);
break;
case LASERLINE:
sp->yrepeat = 6;
sp->xrepeat = 32;
if(lasermode == 1)
sp->cstat = 16 + 2;
else if(lasermode == 0 || lasermode == 2)
sp->cstat = 16;
else
{
sp->xrepeat = 0;
sp->yrepeat = 0;
}
if(j >= 0) sp->ang = hittype[j].temp_data[5]+512;
changespritestat(i,5);
break;
case FORCESPHERE:
if(j == -1 )
{
sp->cstat = (short) 32768;
changespritestat(i,2);
}
else
{
sp->xrepeat = sp->yrepeat = 1;
changespritestat(i,5);
}
break;
case BLOOD:
sp->xrepeat = sp->yrepeat = 16;
sp->z -= (26<<8);
if( j >= 0 && sprite[j].pal == 6 )
sp->pal = 6;
changespritestat(i,5);
break;
case BLOODPOOL:
case PUKE:
{
short s1;
s1 = sp->sectnum;
updatesector(sp->x+108,sp->y+108,&s1);
if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz)
{
updatesector(sp->x-108,sp->y-108,&s1);
if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz)
{
updatesector(sp->x+108,sp->y-108,&s1);
if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz)
{
updatesector(sp->x-108,sp->y+108,&s1);
if(s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz)
{ sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;}
}
else { sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;}
}
else { sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;}
}
else { sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;}
}
if( sector[SECT].lotag == 1 )
{
changespritestat(i,5);
break;
}
if(j >= 0 && sp->picnum != PUKE)
{
if( sprite[j].pal == 1)
sp->pal = 1;
else if( sprite[j].pal != 6 && sprite[j].picnum != NUKEBARREL && sprite[j].picnum != TIRE )
{
if(sprite[j].picnum == FECES)
sp->pal = 7; // Brown
else sp->pal = 2; // Red
}
else sp->pal = 0; // green
if(sprite[j].picnum == TIRE)
sp->shade = 127;
}
sp->cstat |= 32;
case FECES:
if( j >= 0)
sp->xrepeat = sp->yrepeat = 1;
changespritestat(i,5);
break;
case BLOODSPLAT1:
case BLOODSPLAT2:
case BLOODSPLAT3:
case BLOODSPLAT4:
sp->cstat |= 16;
sp->xrepeat = 7+(TRAND&7);
sp->yrepeat = 7+(TRAND&7);
sp->z -= (16<<8);
if(j >= 0 && sprite[j].pal == 6)
sp->pal = 6;
insertspriteq(i);
changespritestat(i,5);
break;
case TRIPBOMB:
if( sp->lotag > ud.player_skill )
{
sp->xrepeat=sp->yrepeat=0;
changespritestat(i,5);
break;
}
sp->xrepeat=4;
sp->yrepeat=5;
sp->owner = i;
sp->hitag = i;
sp->xvel = 16;
ssp(i,CLIPMASK0);
hittype[i].temp_data[0] = 17;
hittype[i].temp_data[2] = 0;
hittype[i].temp_data[5] = sp->ang;
case SPACEMARINE:
if(sp->picnum == SPACEMARINE)
{
sp->extra = 20;
sp->cstat |= 257;
}
changespritestat(i,2);
break;
case HYDRENT:
case PANNEL1:
case PANNEL2:
case SATELITE:
case FUELPOD:
case SOLARPANNEL:
case ANTENNA:
case GRATE1:
case CHAIR1:
case CHAIR2:
case CHAIR3:
case BOTTLE1:
case BOTTLE2:
case BOTTLE3:
case BOTTLE4:
case BOTTLE5:
case BOTTLE6:
case BOTTLE7:
case BOTTLE8:
case BOTTLE10:
case BOTTLE11:
case BOTTLE12:
case BOTTLE13:
case BOTTLE14:
case BOTTLE15:
case BOTTLE16:
case BOTTLE17:
case BOTTLE18:
case BOTTLE19:
case OCEANSPRITE1:
case OCEANSPRITE2:
case OCEANSPRITE3:
case OCEANSPRITE5:
case MONK:
case INDY:
case LUKE:
case JURYGUY:
case SCALE:
case VACUUM:
case FANSPRITE:
case CACTUS:
case CACTUSBROKE:
case HANGLIGHT:
case FETUS:
case FETUSBROKE:
case CAMERALIGHT:
case MOVIECAMERA:
case IVUNIT:
case POT1:
case POT2:
case POT3:
case TRIPODCAMERA:
case SUSHIPLATE1:
case SUSHIPLATE2:
case SUSHIPLATE3:
case SUSHIPLATE4:
case SUSHIPLATE5:
case WAITTOBESEATED:
case VASE:
case PIPE1:
case PIPE2:
case PIPE3:
case PIPE4:
case PIPE5:
case PIPE6:
sp->clipdist = 32;
sp->cstat |= 257;
case OCEANSPRITE4:
changespritestat(i,0);
break;
case FEMMAG1:
case FEMMAG2:
sp->cstat &= ~257;
changespritestat(i,0);
break;
case DUKETAG:
case SIGN1:
case SIGN2:
if(ud.multimode < 2 && sp->pal)
{
sp->xrepeat = sp->yrepeat = 0;
changespritestat(i,5);
}
else sp->pal = 0;
break;
case MASKWALL1:
case MASKWALL2:
case MASKWALL3:
case MASKWALL4:
case MASKWALL5:
case MASKWALL6:
case MASKWALL7:
case MASKWALL8:
case MASKWALL9:
case MASKWALL10:
case MASKWALL11:
case MASKWALL12:
case MASKWALL13:
case MASKWALL14:
case MASKWALL15:
j = sp->cstat&60;
sp->cstat = j|1;
changespritestat(i,0);
break;
case FOOTPRINTS:
case FOOTPRINTS2:
case FOOTPRINTS3:
case FOOTPRINTS4:
if(j >= 0)
{
short s1;
s1 = sp->sectnum;
updatesector(sp->x+84,sp->y+84,&s1);
if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz)
{
updatesector(sp->x-84,sp->y-84,&s1);
if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz)
{
updatesector(sp->x+84,sp->y-84,&s1);
if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz)
{
updatesector(sp->x-84,sp->y+84,&s1);
if(s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz)
{ sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;}
}
else { sp->xrepeat = sp->yrepeat = 0;break;}
}
else { sp->xrepeat = sp->yrepeat = 0;break;}
}
else { sp->xrepeat = sp->yrepeat = 0;break;}
sp->cstat = 32+((ps[sprite[j].yvel].footprintcount&1)<<2);
sp->ang = sprite[j].ang;
}
sp->z = sector[sect].floorz;
if(sector[sect].lotag != 1 && sector[sect].lotag != 2)
sp->xrepeat = sp->yrepeat = 32;
insertspriteq(i);
changespritestat(i,5);
break;
case FEM1:
case FEM2:
case FEM3:
case FEM4:
case FEM5:
case FEM6:
case FEM7:
case FEM8:
case FEM9:
case FEM10:
case PODFEM1:
case NAKED1:
case STATUE:
case TOUGHGAL:
sp->yvel = sp->hitag;
sp->hitag = -1;
if(sp->picnum == PODFEM1) sp->extra <<= 1;
case BLOODYPOLE:
case QUEBALL:
case STRIPEBALL:
if(sp->picnum == QUEBALL || sp->picnum == STRIPEBALL)
{
sp->cstat = 256;
sp->clipdist = 8;
}
else
{
sp->cstat |= 257;
sp->clipdist = 32;
}
changespritestat(i,2);
break;
case DUKELYINGDEAD:
if(j >= 0 && sprite[j].picnum == APLAYER)
{
sp->xrepeat = sprite[j].xrepeat;
sp->yrepeat = sprite[j].yrepeat;
sp->shade = sprite[j].shade;
sp->pal = ps[sprite[j].yvel].palookup;
}
case DUKECAR:
case HELECOPT:
// if(sp->picnum == HELECOPT || sp->picnum == DUKECAR) sp->xvel = 1024;
sp->cstat = 0;
sp->extra = 1;
sp->xvel = 292;
sp->zvel = 360;
case RESPAWNMARKERRED:
case BLIMP:
if(sp->picnum == RESPAWNMARKERRED)
{
sp->xrepeat = sp->yrepeat = 24;
if(j >= 0) sp->z = hittype[j].floorz; // -(1<<4);
}
else
{
sp->cstat |= 257;
sp->clipdist = 128;
}
case MIKE:
if(sp->picnum == MIKE)
sp->yvel = sp->hitag;
case WEATHERWARN:
changespritestat(i,1);
break;
case SPOTLITE:
T1 = sp->x;
T2 = sp->y;
break;
case BULLETHOLE:
sp->xrepeat = sp->yrepeat = 3;
sp->cstat = 16+(krand()&12);
insertspriteq(i);
case MONEY:
case MAIL:
case PAPER:
if( sp->picnum == MONEY || sp->picnum == MAIL || sp->picnum == PAPER )
{
hittype[i].temp_data[0] = TRAND&2047;
sp->cstat = TRAND&12;
sp->xrepeat = sp->yrepeat = 8;
sp->ang = TRAND&2047;
}
changespritestat(i,5);
break;
case VIEWSCREEN:
case VIEWSCREEN2:
sp->owner = i;
sp->lotag = 1;
sp->extra = 1;
changespritestat(i,6);
break;
case SHELL: //From the player
case SHOTGUNSHELL:
if( j >= 0 )
{
short snum,a;
if(sprite[j].picnum == APLAYER)
{
snum = sprite[j].yvel;
a = ps[snum].ang-(TRAND&63)+8; //Fine tune