2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
2007-02-08 04:19:39 +00:00
Copyright ( C ) 1996 , 2003 - 3 D Realms Entertainment
Copyright ( C ) 2000 , 2003 - Matt Saettler ( EDuke Enhancements )
Copyright ( C ) 2004 , 2007 - EDuke32 developers
2006-04-13 20:47:06 +00:00
This file is part of EDuke32
EDuke32 is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation .
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 .
*/
//-------------------------------------------------------------------------
2006-04-25 01:56:24 +00:00
# include "duke3d.h"
2006-04-13 20:47:06 +00:00
# include "types.h"
# include "develop.h"
# include "scriplib.h"
# include "file_lib.h"
# include "mathutil.h"
# include "gamedefs.h"
# include "keyboard.h"
# include "mouse.h" // JBF 20030809
# include "function.h"
# include "control.h"
# include "fx_man.h"
# include "sounds.h"
# include "config.h"
# include "osd.h"
# include "osdfuncs.h"
# include "osdcmds.h"
2006-05-01 05:03:44 +00:00
# include "scriptfile.h"
2006-07-22 05:20:25 +00:00
# include "grpscan.h"
2006-04-13 20:47:06 +00:00
//#include "crc32.h"
# include "util_lib.h"
2006-12-14 08:50:18 +00:00
# ifdef _WIN32
2007-03-04 19:52:57 +00:00
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
2006-12-14 08:50:18 +00:00
# include <shellapi.h>
extern int getversionfromwebsite ( char * buffer ) ;
2007-05-17 19:31:14 +00:00
# define BUILDDATE 20070501
# define UPDATEINTERVAL 604800 // 1w
2006-12-14 08:50:18 +00:00
# endif
2006-04-13 20:47:06 +00:00
# define IDFSIZE 479985668
# define IDFILENAME "DUKE3D.IDF"
# define TIMERUPDATESIZ 32
long cameradist = 0 , cameraclock = 0 ;
2007-03-22 20:58:13 +00:00
static int playerswhenstarted ;
static int qe , cp , usecwd = 0 ;
2006-04-13 20:47:06 +00:00
2007-08-26 10:35:52 +00:00
static int32 g_CommandSetup = 0 ;
static int32 g_NoSetup = 0 ;
static int32 g_NoAutoLoad = 0 ;
static int32 g_NoSound = 0 ;
static int32 g_NoMusic = 0 ;
2006-04-13 20:47:06 +00:00
static char * CommandMap = NULL ;
2007-08-26 10:35:52 +00:00
static char * CommandName = NULL ;
static char * CommandNet = NULL ;
static int g_KeepAddr = 0 ;
2006-04-25 05:01:27 +00:00
int32 CommandWeaponChoice = 0 ;
2006-11-15 01:16:55 +00:00
static struct strllist
{
2006-09-10 17:40:34 +00:00
struct strllist * next ;
char * str ;
2006-11-15 01:16:55 +00:00
}
* CommandPaths = NULL , * CommandGrps = NULL ;
2006-04-13 20:47:06 +00:00
2007-02-28 09:12:41 +00:00
char boardfilename [ BMAX_PATH ] = { 0 } ;
2006-12-05 20:39:29 +00:00
char waterpal [ 768 ] , slimepal [ 768 ] , titlepal [ 768 ] , drealms [ 768 ] , endingpal [ 768 ] , animpal [ 768 ] ;
2007-04-15 20:04:52 +00:00
static char firstdemofile [ 80 ] = { ' \0 ' } ;
int display_bonus_screen = 1 ;
static int userconfiles = 0 ;
2006-04-13 20:47:06 +00:00
static int netparamcount = 0 ;
static char * * netparam = NULL ;
2007-08-27 06:46:31 +00:00
int voting = - 1 ;
2006-08-21 21:00:54 +00:00
int vote_map = - 1 , vote_episode = - 1 ;
2006-05-04 03:14:49 +00:00
2006-07-26 01:10:33 +00:00
int recfilep , totalreccnt ;
2007-03-22 20:58:13 +00:00
int debug_on = 0 , actor_tog = 0 ;
static char * rtsptr ;
2006-07-26 01:10:33 +00:00
extern char syncstate ;
extern int32 numlumps ;
2007-03-22 20:58:13 +00:00
static FILE * frecfilep = ( FILE * ) NULL ;
2006-07-26 01:10:33 +00:00
2007-01-05 22:30:35 +00:00
int restorepalette , screencapt ;
2007-08-26 10:35:52 +00:00
static int g_NoLogoAnim = 0 ;
static int g_NoLogo = 0 ;
2007-01-05 22:30:35 +00:00
static int sendmessagecommand = - 1 ;
2006-07-26 01:10:33 +00:00
char defaultduke3dgrp [ BMAX_PATH ] = " duke3d.grp " ;
char * duke3dgrp = defaultduke3dgrp ;
2007-04-15 20:04:52 +00:00
static char defaultconfilename [ BMAX_PATH ] = { " EDUKE.CON " } ;
static char * confilename = defaultconfilename ;
2006-07-26 01:10:33 +00:00
static char * duke3ddef = " duke3d.def " ;
extern long lastvisinc ;
2007-08-26 10:35:52 +00:00
int g_Shareware = 0 ;
int g_GameType = 0 ;
2006-07-26 01:10:33 +00:00
# define MAXUSERQUOTES 4
2007-01-05 22:30:35 +00:00
static long quotebot , quotebotgoal ;
static int user_quote_time [ MAXUSERQUOTES ] ;
static char user_quote [ MAXUSERQUOTES ] [ 178 ] ;
2006-07-26 01:10:33 +00:00
// char typebuflen,typebuf[41];
2006-08-02 20:51:50 +00:00
# ifdef JFAUD
2007-01-05 22:30:35 +00:00
static int MAXCACHE1DSIZE = ( 16 * 1048576 ) ;
2006-08-02 20:51:50 +00:00
# else
2007-01-05 22:30:35 +00:00
static int MAXCACHE1DSIZE = ( 32 * 1048576 ) ;
2006-08-02 20:51:50 +00:00
# endif
2006-07-26 01:10:33 +00:00
long tempwallptr ;
2007-01-05 22:30:35 +00:00
static long nonsharedtimer ;
2006-07-26 01:10:33 +00:00
2006-12-10 03:15:56 +00:00
static void cameratext ( short i ) ;
2006-12-23 02:38:47 +00:00
static int moveloop ( void ) ;
2006-12-10 03:15:56 +00:00
static void doorders ( void ) ;
static void fakedomovethings ( void ) ;
static void fakedomovethingscorrect ( void ) ;
2006-12-23 02:38:47 +00:00
static int domovethings ( void ) ;
2006-12-10 03:15:56 +00:00
static long playback ( void ) ;
2007-04-15 20:04:52 +00:00
static char recbuf [ 180 ] ;
extern void computergetinput ( long snum , input * syn ) ;
2006-11-15 01:16:55 +00:00
enum
{
2006-07-26 01:10:33 +00:00
T_EOF = - 2 ,
T_ERROR = - 1 ,
2007-02-18 22:16:01 +00:00
T_INCLUDE = 0 ,
2006-07-26 01:10:33 +00:00
T_INTERFACE = 0 ,
2007-02-18 22:16:01 +00:00
T_LOADGRP = 1 ,
2006-07-26 01:10:33 +00:00
T_MODE = 1 ,
2007-02-18 22:16:01 +00:00
T_CACHESIZE = 2 ,
T_ALLOW = 2
2006-07-26 01:10:33 +00:00
} ;
2006-11-15 01:16:55 +00:00
typedef struct
{
char * text ;
int tokenid ;
}
2006-11-13 23:12:47 +00:00
tokenlist ;
2006-07-26 01:10:33 +00:00
static int getatoken ( scriptfile * sf , tokenlist * tl , int ntokens )
{
char * tok ;
int i ;
if ( ! sf ) return T_ERROR ;
tok = scriptfile_gettoken ( sf ) ;
if ( ! tok ) return T_EOF ;
2006-11-15 01:16:55 +00:00
for ( i = 0 ; i < ntokens ; i + + )
{
2006-07-26 01:10:33 +00:00
if ( ! Bstrcasecmp ( tok , tl [ i ] . text ) )
return tl [ i ] . tokenid ;
}
return T_ERROR ;
}
2006-12-17 21:20:35 +00:00
inline void setstatusbarscale ( long sc )
2006-04-13 20:47:06 +00:00
{
ud . statusbarscale = min ( 100 , max ( 10 , sc ) ) ;
vscrn ( ) ;
}
static inline long sbarx ( long x )
{
2007-02-16 06:59:05 +00:00
if ( ud . screen_size = = 4 /*|| ud.statusbarmode == 1*/ ) return scale ( x < < 16 , ud . statusbarscale , 100 ) ;
2006-04-13 20:47:06 +00:00
return ( ( ( 320l < < 16 ) - scale ( 320l < < 16 , ud . statusbarscale , 100 ) ) > > 1 ) + scale ( x < < 16 , ud . statusbarscale , 100 ) ;
}
static inline long sbary ( long y )
{
return ( ( 200l < < 16 ) - scale ( 200l < < 16 , ud . statusbarscale , 100 ) + scale ( y < < 16 , ud . statusbarscale , 100 ) ) ;
}
static inline long sbarsc ( long sc )
{
return scale ( sc , ud . statusbarscale , 100 ) ;
}
2006-12-10 03:15:56 +00:00
static void patchstatusbar ( long x1 , long y1 , long x2 , long y2 )
2006-04-13 20:47:06 +00:00
{
long scl , tx , ty ;
long clx1 , cly1 , clx2 , cly2 , clofx , clofy ;
scl = sbarsc ( 65536 ) ;
2006-11-15 01:16:55 +00:00
tx = sbarx ( 0 ) ;
ty = sbary ( 200 - tilesizy [ BOTTOMSTATUSBAR ] ) ;
2006-04-13 20:47:06 +00:00
clx1 = scale ( scale ( x1 , xdim , 320 ) , ud . statusbarscale , 100 ) ;
cly1 = scale ( scale ( y1 , ydim , 200 ) , ud . statusbarscale , 100 ) ;
clx2 = scale ( scale ( x2 , xdim , 320 ) , ud . statusbarscale , 100 ) ;
cly2 = scale ( scale ( y2 , ydim , 200 ) , ud . statusbarscale , 100 ) ;
clofx = ( xdim - scale ( xdim , ud . statusbarscale , 100 ) ) > > 1 ;
clofy = ( ydim - scale ( ydim , ud . statusbarscale , 100 ) ) ;
2007-02-16 06:59:05 +00:00
// if (ud.statusbarmode == 0)
2007-02-26 01:46:38 +00:00
rotatesprite ( tx , ty , scl , 0 , BOTTOMSTATUSBAR , 4 , 0 , 10 + 16 + 64 , clx1 + clofx , cly1 + clofy , clx2 + clofx - 1 , cly2 + clofy - 1 ) ;
2007-02-16 06:59:05 +00:00
// else rotatesprite(tx,ty,scl,0,BOTTOMSTATUSBAR,4,0,10+16+64,clx1,cly1,clx2+clofx-1,cly2+clofy-1);
2006-04-13 20:47:06 +00:00
}
2007-08-27 00:20:15 +00:00
void setgamepalette ( player_struct * player , char * pal , int set )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( player ! = g_player [ screenpeek ] . ps )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
// another head
player - > palette = pal ;
return ;
}
2006-12-05 20:39:29 +00:00
#if 0
2006-11-15 01:16:55 +00:00
if ( getrendermode ( ) < 3 )
{
2006-04-13 20:47:06 +00:00
// 8-bit mode
player - > palette = pal ;
setbrightness ( ud . brightness > > 2 , pal , set ) ;
//pub = pus = NUMPAGES;
return ;
}
2006-11-15 01:16:55 +00:00
if ( pal = = palette | | pal = = waterpal | | pal = = slimepal )
{
2006-04-13 20:47:06 +00:00
if ( player - > palette ! = palette & & player - > palette ! = waterpal & & player - > palette ! = slimepal )
setbrightness ( ud . brightness > > 2 , palette , set ) ;
else setpalettefade ( 0 , 0 , 0 , 0 ) ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-12-05 20:39:29 +00:00
if ( pal ! = titlepal & & pal ! = drealms & & pal ! = endingpal & & pal ! = animpal )
pal = palette ;
2006-04-13 20:47:06 +00:00
setbrightness ( ud . brightness > > 2 , pal , set ) ;
}
2006-12-05 20:39:29 +00:00
# else
if ( ! ( pal = = palette | | pal = = waterpal | | pal = = slimepal | | pal = = drealms | | pal = = titlepal | | pal = = endingpal | | pal = = animpal ) )
pal = palette ;
setbrightness ( ud . brightness > > 2 , pal , set ) ;
# endif
2006-04-13 20:47:06 +00:00
player - > palette = pal ;
}
2007-08-27 00:20:15 +00:00
# define TEXTWRAPLEN (scale(35,ud.config.ScreenWidth,320))
2006-04-21 07:34:05 +00:00
2006-12-23 02:38:47 +00:00
const char * stripcolorcodes ( const char * t )
2006-05-05 07:10:36 +00:00
{
int i = 0 ;
2007-08-25 22:02:40 +00:00
static char colstrip [ 1024 ] ;
2006-05-05 07:10:36 +00:00
2006-11-13 23:12:47 +00:00
while ( * t )
2006-05-05 07:10:36 +00:00
{
2006-11-13 23:12:47 +00:00
if ( * t = = ' ^ ' & & isdigit ( * ( t + 1 ) ) )
2006-05-05 07:10:36 +00:00
{
t + = 2 ;
2006-11-13 23:12:47 +00:00
if ( isdigit ( * t ) )
2006-05-05 07:10:36 +00:00
t + + ;
2006-08-15 17:15:23 +00:00
continue ;
2006-05-05 07:10:36 +00:00
}
colstrip [ i ] = * t ;
i + + , t + + ;
}
colstrip [ i ] = ' \0 ' ;
return ( colstrip ) ;
}
2007-02-28 09:12:41 +00:00
int gametext_ ( int small , int starttile , int x , int y , const char * t , int s , int p , int orientation , long x1 , long y1 , long x2 , long y2 )
2006-04-13 20:47:06 +00:00
{
2007-02-28 09:12:41 +00:00
int ac , newx , oldx = x ;
2006-04-13 20:47:06 +00:00
char centre , * oldt ;
2006-11-14 21:35:50 +00:00
centre = ( x = = ( 320 > > 1 ) ) ;
2006-04-13 20:47:06 +00:00
newx = 0 ;
2006-12-23 02:38:47 +00:00
oldt = ( char * ) t ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( t = = NULL )
2006-04-24 00:49:44 +00:00
return - 1 ;
2006-11-13 23:12:47 +00:00
if ( centre )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
while ( * t )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( * t = = ' ^ ' & & isdigit ( * ( t + 1 ) ) )
2006-05-05 07:10:36 +00:00
{
t + = 2 ;
2006-11-13 23:12:47 +00:00
if ( isdigit ( * t ) ) t + + ;
2006-08-15 17:15:23 +00:00
continue ;
2006-05-05 07:10:36 +00:00
}
2006-11-15 01:16:55 +00:00
if ( * t = = 32 )
{
newx + = 5 ;
t + + ;
continue ;
}
2006-04-13 20:47:06 +00:00
else ac = * t - ' ! ' + starttile ;
2006-11-14 21:35:50 +00:00
if ( ac < starttile | | ac > ( starttile + 93 ) ) break ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( * t > = ' 0 ' & & * t < = ' 9 ' )
2006-04-22 00:17:55 +00:00
newx + = 8 ;
else newx + = tilesizx [ ac ] ;
2006-04-13 20:47:06 +00:00
t + + ;
}
t = oldt ;
x = ( 320 > > 1 ) - ( newx > > 1 ) ;
}
2006-11-13 23:12:47 +00:00
while ( * t )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( * t = = ' ^ ' & & isdigit ( * ( t + 1 ) ) )
2006-05-05 07:10:36 +00:00
{
char smallbuf [ 3 ] ;
t + = 1 ;
2006-11-13 23:12:47 +00:00
if ( isdigit ( * ( t + 1 ) ) )
2006-05-05 07:10:36 +00:00
{
smallbuf [ 0 ] = * ( t + + ) ;
smallbuf [ 1 ] = * ( t + + ) ;
smallbuf [ 2 ] = ' \0 ' ;
p = atol ( smallbuf ) ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-05-05 07:10:36 +00:00
smallbuf [ 0 ] = * ( t + + ) ;
smallbuf [ 1 ] = ' \0 ' ;
p = atol ( smallbuf ) ;
}
2006-08-15 17:15:23 +00:00
continue ;
2006-05-05 07:10:36 +00:00
}
2006-11-15 01:16:55 +00:00
if ( * t = = 32 )
{
x + = 5 ;
t + + ;
continue ;
}
2006-04-13 20:47:06 +00:00
else ac = * t - ' ! ' + starttile ;
2006-11-14 21:35:50 +00:00
if ( ac < starttile | | ac > ( starttile + 93 ) )
2006-04-13 20:47:06 +00:00
break ;
2007-08-27 00:20:15 +00:00
rotatesprite ( x < < 16 , ( y < < 16 ) + ( small ? ud . config . ScreenHeight < < 15 : 0 ) , 65536 , 0 , ac , s , p , small ? ( 8 | 16 ) : ( 2 | orientation ) , x1 , y1 , x2 , y2 ) ;
2006-11-13 23:12:47 +00:00
if ( ( * t > = ' 0 ' & & * t < = ' 9 ' ) )
2006-04-22 00:17:55 +00:00
x + = 8 ;
else x + = tilesizx [ ac ] ; //(tilesizx[ac]>>small);
2006-12-23 02:38:47 +00:00
if ( t - oldt > = ( signed ) TEXTWRAPLEN - ! small ) oldt = ( char * ) t , x = oldx , y + = 8 ;
2006-04-13 20:47:06 +00:00
t + + ;
}
return ( x ) ;
}
2007-02-28 09:12:41 +00:00
inline int gametext ( int x , int y , const char * t , int s , int dabits )
2006-04-21 05:58:24 +00:00
{
2006-05-05 07:10:36 +00:00
return ( gametext_ ( 0 , STARTALPHANUM , x , y , t , s , 0 , dabits , 0 , 0 , xdim - 1 , ydim - 1 ) ) ;
2006-04-21 05:11:57 +00:00
}
2007-02-28 09:12:41 +00:00
inline int gametextpal ( int x , int y , const char * t , int s , int p )
2006-04-13 20:47:06 +00:00
{
2006-05-05 07:10:36 +00:00
return ( gametext_ ( 0 , STARTALPHANUM , x , y , t , s , p , 26 , 0 , 0 , xdim - 1 , ydim - 1 ) ) ;
2006-04-13 20:47:06 +00:00
}
2007-04-15 20:04:52 +00:00
static inline int mpgametext ( int y , const char * t , int s , int dabits )
2006-04-21 05:11:57 +00:00
{
2006-11-13 23:12:47 +00:00
if ( xdim > = 640 & & ydim > = 480 )
2006-05-05 07:10:36 +00:00
return ( gametext_ ( 1 , STARTALPHANUM , 5 , y , t , s , 0 , dabits , 0 , 0 , xdim - 1 , ydim - 1 ) ) ;
2006-12-15 01:09:25 +00:00
return ( gametext_ ( 0 , STARTALPHANUM , 5 , y , t , s , 0 , dabits , 0 , 0 , xdim - 1 , ydim - 1 ) ) ;
2006-04-21 05:11:57 +00:00
}
2007-02-28 09:12:41 +00:00
static int minitext_ ( int x , int y , const char * t , int s , int p , int sb )
2006-04-13 20:47:06 +00:00
{
2007-02-28 09:12:41 +00:00
int ac ;
2006-04-13 20:47:06 +00:00
char ch , cmode ;
cmode = ( sb & 256 ) ! = 0 ;
sb & = 255 ;
2006-11-13 23:12:47 +00:00
while ( * t )
2006-04-13 20:47:06 +00:00
{
ch = Btoupper ( * t ) ;
2006-11-15 01:16:55 +00:00
if ( ch = = 32 )
{
x + = 5 ;
t + + ;
continue ;
}
2006-04-13 20:47:06 +00:00
else ac = ch - ' ! ' + MINIFONT ;
if ( cmode ) rotatesprite ( sbarx ( x ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , ac , s , p , sb , 0 , 0 , xdim - 1 , ydim - 1 ) ;
else 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 ) ;
}
2007-02-28 09:12:41 +00:00
inline int minitextshade ( int x , int y , const char * t , int s , int p , int sb )
2006-05-05 07:10:36 +00:00
{
2006-12-10 21:53:33 +00:00
return ( minitext_ ( x , y , ( char * ) stripcolorcodes ( t ) , s , p , sb ) ) ;
2006-05-05 07:10:36 +00:00
}
2007-02-28 09:12:41 +00:00
inline int minitext ( int x , int y , const char * t , int p , int sb )
2006-04-13 20:47:06 +00:00
{
2006-12-10 21:53:33 +00:00
return ( minitext_ ( x , y , ( char * ) stripcolorcodes ( t ) , 0 , p , sb ) ) ;
2006-04-13 20:47:06 +00:00
}
2006-12-10 03:15:56 +00:00
#if 0
static void gamenumber ( long x , long y , long n , char s )
2006-04-13 20:47:06 +00:00
{
char b [ 10 ] ;
//ltoa(n,b,10);
Bsnprintf ( b , 10 , " %ld " , n ) ;
gametext ( x , y , b , s , 2 + 8 + 16 ) ;
}
2006-12-10 03:15:56 +00:00
# endif
2006-04-13 20:47:06 +00:00
2006-12-10 03:15:56 +00:00
static void allowtimetocorrecterrorswhenquitting ( void )
2006-04-13 20:47:06 +00:00
{
long i , j , oldtotalclock ;
ready2send = 0 ;
2006-11-13 23:12:47 +00:00
for ( j = 0 ; j < 8 ; j + + )
2006-04-13 20:47:06 +00:00
{
oldtotalclock = totalclock ;
2006-11-15 01:16:55 +00:00
while ( totalclock < oldtotalclock + TICSPERFRAME )
{
2006-04-13 20:47:06 +00:00
handleevents ( ) ;
getpackets ( ) ;
}
2006-11-13 23:12:47 +00:00
if ( KB_KeyPressed ( sc_Escape ) ) return ;
2006-04-13 20:47:06 +00:00
packbuf [ 0 ] = 127 ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
{
if ( i ! = myconnectindex ) sendpacket ( i , packbuf , 1 ) ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
}
}
2006-12-23 02:38:47 +00:00
void adduserquote ( const char * daquote )
2006-04-13 20:47:06 +00:00
{
long i ;
2006-11-13 23:12:47 +00:00
for ( i = MAXUSERQUOTES - 1 ; i > 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
2006-07-21 22:25:05 +00:00
Bstrcpy ( user_quote [ i ] , user_quote [ i - 1 ] ) ;
2006-04-13 20:47:06 +00:00
user_quote_time [ i ] = user_quote_time [ i - 1 ] ;
}
2006-07-21 22:25:05 +00:00
Bstrcpy ( user_quote [ 0 ] , daquote ) ;
2006-12-10 21:53:33 +00:00
OSD_Printf ( " %s \n " , stripcolorcodes ( daquote ) ) ;
2006-04-22 02:33:36 +00:00
2006-04-22 06:10:28 +00:00
user_quote_time [ 0 ] = ud . msgdisptime ;
2006-04-13 20:47:06 +00:00
pub = NUMPAGES ;
}
2006-11-30 04:36:20 +00:00
long lastpackettime = 0 ;
2006-04-13 20:47:06 +00:00
void getpackets ( void )
{
long i , j , k , l ;
long other , packbufleng ;
input * osyn , * nsyn ;
sampletimer ( ) ;
AudioUpdate ( ) ;
2006-11-13 23:12:47 +00:00
if ( ALT_IS_PRESSED & & KB_KeyPressed ( sc_Enter ) )
2006-04-25 22:50:57 +00:00
{
2007-08-27 00:20:15 +00:00
if ( setgamemode ( ! ud . config . ScreenMode , ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP ) )
2006-11-15 01:16:55 +00:00
{
2006-04-25 22:50:57 +00:00
OSD_Printf ( " Failed setting fullscreen video mode. \n " ) ;
2007-08-27 00:20:15 +00:00
if ( setgamemode ( ud . config . ScreenMode , ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP ) )
2006-04-25 22:50:57 +00:00
gameexit ( " Failed to recover from failure to set fullscreen video mode. \n " ) ;
}
2007-08-27 00:20:15 +00:00
else ud . config . ScreenMode = ! ud . config . ScreenMode ;
2006-04-25 22:50:57 +00:00
KB_ClearKeyDown ( sc_Enter ) ;
restorepalette = 1 ;
2006-04-30 01:39:58 +00:00
vscrn ( ) ;
2006-04-25 22:50:57 +00:00
}
2007-01-26 05:16:10 +00:00
if ( KB_KeyPressed ( sc_F12 ) )
{
KB_ClearKeyDown ( sc_F12 ) ;
screencapture ( " duke0000.tga " , 0 ) ;
2007-08-27 06:46:31 +00:00
FTA ( 103 , g_player [ myconnectindex ] . ps ) ;
2007-01-26 05:16:10 +00:00
}
2006-04-13 20:47:06 +00:00
// only dispatch commands here when not in a game
2007-08-27 06:46:31 +00:00
if ( ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
2006-11-15 01:16:55 +00:00
{
OSD_DispatchQueued ( ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( qe = = 0 & & KB_KeyPressed ( sc_LeftControl ) & & KB_KeyPressed ( sc_LeftAlt ) & & KB_KeyPressed ( sc_Delete ) )
2006-04-13 20:47:06 +00:00
{
qe = 1 ;
gameexit ( " Quick Exit. " ) ;
}
if ( numplayers < 2 ) return ;
while ( ( packbufleng = getpacket ( & other , packbuf ) ) > 0 )
{
2006-11-30 04:36:20 +00:00
lastpackettime = totalclock ;
2006-12-04 04:12:14 +00:00
#if 0
2006-12-01 22:34:32 +00:00
initprintf ( " RECEIVED PACKET: type: %d : len %d \n " , packbuf [ 0 ] , packbufleng ) ;
2006-11-29 10:30:25 +00:00
# endif
2006-11-13 23:12:47 +00:00
switch ( packbuf [ 0 ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 : //[0] (receive master sync buffer)
j = 1 ;
2006-11-15 01:16:55 +00:00
2007-08-27 00:20:15 +00:00
if ( ( g_player [ other ] . movefifoend & ( TIMERUPDATESIZ - 1 ) ) = = 0 )
2006-11-16 03:02:42 +00:00
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . playerquitflag = = 0 ) continue ;
2006-11-16 03:02:42 +00:00
if ( i = = myconnectindex )
otherminlag = ( long ) ( ( signed char ) packbuf [ j ] ) ;
j + + ;
}
2006-04-13 20:47:06 +00:00
2007-08-27 00:20:15 +00:00
osyn = ( input * ) & inputfifo [ ( g_player [ connecthead ] . movefifoend - 1 ) & ( MOVEFIFOSIZ - 1 ) ] [ 0 ] ;
nsyn = ( input * ) & inputfifo [ ( g_player [ connecthead ] . movefifoend ) & ( MOVEFIFOSIZ - 1 ) ] [ 0 ] ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
k = j ;
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
j + = g_player [ i ] . playerquitflag + g_player [ i ] . playerquitflag ;
2006-11-16 03:02:42 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
{
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . playerquitflag = = 0 ) continue ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
l = packbuf [ k + + ] ;
l + = ( long ) ( packbuf [ k + + ] < < 8 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( i = = myconnectindex )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
j + = ( ( l & 1 ) < < 1 ) + ( l & 2 ) + ( ( l & 4 ) > > 2 ) + ( ( l & 8 ) > > 3 ) + ( ( l & 16 ) > > 4 ) + ( ( l & 32 ) > > 5 ) + ( ( l & 64 ) > > 6 ) + ( ( l & 128 ) > > 7 ) + ( ( l & 256 ) > > 8 ) + ( ( l & 512 ) > > 9 ) + ( ( l & 1024 ) > > 10 ) + ( ( l & 2048 ) > > 11 ) ;
continue ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
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 ( l & 256 ) nsyn [ i ] . extbits = ( ( nsyn [ i ] . extbits & 0xffffff00 ) | ( ( long ) packbuf [ j + + ] ) ) ;
if ( l & 512 ) nsyn [ i ] . extbits = ( ( nsyn [ i ] . extbits & 0xffff00ff ) | ( ( long ) packbuf [ j + + ] ) < < 8 ) ;
if ( l & 1024 ) nsyn [ i ] . extbits = ( ( nsyn [ i ] . extbits & 0xff00ffff ) | ( ( long ) packbuf [ j + + ] ) < < 16 ) ;
if ( l & 2048 ) nsyn [ i ] . extbits = ( ( nsyn [ i ] . extbits & 0x00ffffff ) | ( ( long ) packbuf [ j + + ] ) < < 24 ) ;
2007-08-27 00:20:15 +00:00
if ( nsyn [ i ] . bits & ( 1 < < 26 ) ) g_player [ i ] . playerquitflag = 0 ;
g_player [ i ] . movefifoend + + ;
2006-11-16 03:02:42 +00:00
}
while ( j ! = packbufleng )
{
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = myconnectindex )
2006-11-16 03:02:42 +00:00
{
2007-08-27 00:20:15 +00:00
g_player [ i ] . syncval [ g_player [ i ] . syncvalhead & ( MOVEFIFOSIZ - 1 ) ] = packbuf [ j ] ;
g_player [ i ] . syncvalhead + + ;
2006-11-16 03:02:42 +00:00
}
j + + ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = myconnectindex )
for ( j = 1 ; j < movesperpacket ; j + + )
{
2007-08-27 00:20:15 +00:00
copybufbyte ( & nsyn [ i ] , & inputfifo [ g_player [ i ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ i ] , sizeof ( input ) ) ;
g_player [ i ] . movefifoend + + ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
movefifosendplc + = movesperpacket ;
break ;
case 1 : //[1] (receive slave sync buffer)
j = 3 ;
k = packbuf [ 1 ] + ( long ) ( packbuf [ 2 ] < < 8 ) ;
2007-08-27 00:20:15 +00:00
osyn = ( input * ) & inputfifo [ ( g_player [ other ] . movefifoend - 1 ) & ( MOVEFIFOSIZ - 1 ) ] [ 0 ] ;
nsyn = ( input * ) & inputfifo [ ( g_player [ other ] . movefifoend ) & ( MOVEFIFOSIZ - 1 ) ] [ 0 ] ;
2006-11-16 03:02:42 +00:00
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 + + ] ;
if ( k & 256 ) nsyn [ other ] . extbits = ( ( nsyn [ other ] . extbits & 0xffffff00 ) | ( ( long ) packbuf [ j + + ] ) ) ;
if ( k & 512 ) nsyn [ other ] . extbits = ( ( nsyn [ other ] . extbits & 0xffff00ff ) | ( ( long ) packbuf [ j + + ] ) < < 8 ) ;
if ( k & 1024 ) nsyn [ other ] . extbits = ( ( nsyn [ other ] . extbits & 0xff00ffff ) | ( ( long ) packbuf [ j + + ] ) < < 16 ) ;
if ( k & 2048 ) nsyn [ other ] . extbits = ( ( nsyn [ other ] . extbits & 0x00ffffff ) | ( ( long ) packbuf [ j + + ] ) < < 24 ) ;
2007-08-27 00:20:15 +00:00
g_player [ other ] . movefifoend + + ;
2006-11-16 03:02:42 +00:00
while ( j ! = packbufleng )
{
2007-08-27 00:20:15 +00:00
g_player [ other ] . syncval [ g_player [ other ] . syncvalhead & ( MOVEFIFOSIZ - 1 ) ] = packbuf [ j + + ] ;
g_player [ other ] . syncvalhead + + ;
2006-11-16 03:02:42 +00:00
}
for ( i = 1 ; i < movesperpacket ; i + + )
{
2007-08-27 00:20:15 +00:00
copybufbyte ( & nsyn [ other ] , & inputfifo [ g_player [ other ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ other ] , sizeof ( input ) ) ;
g_player [ other ] . movefifoend + + ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 16 :
2007-08-27 00:20:15 +00:00
g_player [ other ] . movefifoend = movefifoplc = movefifosendplc = fakemovefifoplc = 0 ;
g_player [ other ] . syncvalhead = syncvaltottail = 0L ;
2006-11-16 03:02:42 +00:00
case 17 :
j = 1 ;
2006-04-13 20:47:06 +00:00
2007-08-27 00:20:15 +00:00
if ( ( g_player [ other ] . movefifoend & ( TIMERUPDATESIZ - 1 ) ) = = 0 )
2006-11-16 03:02:42 +00:00
if ( other = = connecthead )
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
{
if ( i = = myconnectindex )
otherminlag = ( long ) ( ( signed char ) packbuf [ j ] ) ;
j + + ;
}
2006-04-13 20:47:06 +00:00
2007-08-27 00:20:15 +00:00
osyn = ( input * ) & inputfifo [ ( g_player [ other ] . movefifoend - 1 ) & ( MOVEFIFOSIZ - 1 ) ] [ 0 ] ;
nsyn = ( input * ) & inputfifo [ ( g_player [ other ] . movefifoend ) & ( MOVEFIFOSIZ - 1 ) ] [ 0 ] ;
2006-11-16 03:02:42 +00:00
copybufbyte ( & osyn [ other ] , & nsyn [ other ] , sizeof ( input ) ) ;
k = packbuf [ j + + ] ;
k + = ( long ) ( packbuf [ j + + ] < < 8 ) ;
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 + + ] ;
if ( k & 256 ) nsyn [ other ] . extbits = ( ( nsyn [ other ] . extbits & 0xffffff00 ) | ( ( long ) packbuf [ j + + ] ) ) ;
if ( k & 512 ) nsyn [ other ] . extbits = ( ( nsyn [ other ] . extbits & 0xffff00ff ) | ( ( long ) packbuf [ j + + ] ) < < 8 ) ;
if ( k & 1024 ) nsyn [ other ] . extbits = ( ( nsyn [ other ] . extbits & 0xff00ffff ) | ( ( long ) packbuf [ j + + ] ) < < 16 ) ;
if ( k & 2048 ) nsyn [ other ] . extbits = ( ( nsyn [ other ] . extbits & 0x00ffffff ) | ( ( long ) packbuf [ j + + ] ) < < 24 ) ;
2007-08-27 00:20:15 +00:00
g_player [ other ] . movefifoend + + ;
2006-11-16 03:02:42 +00:00
for ( i = 1 ; i < movesperpacket ; i + + )
{
2007-08-27 00:20:15 +00:00
copybufbyte ( & nsyn [ other ] , & inputfifo [ g_player [ other ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ other ] , sizeof ( input ) ) ;
g_player [ other ] . movefifoend + + ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j > packbufleng )
2006-11-30 02:09:51 +00:00
initprintf ( " INVALID GAME PACKET!!! (packet %d, %ld too many bytes (%ld %ld)) \n " , packbuf [ 0 ] , j - packbufleng , packbufleng , k ) ;
2006-04-13 20:47:06 +00:00
2006-11-30 02:09:51 +00:00
while ( j < packbufleng )
2006-11-16 03:02:42 +00:00
{
2007-08-27 00:20:15 +00:00
g_player [ other ] . syncval [ g_player [ other ] . syncvalhead & ( MOVEFIFOSIZ - 1 ) ] = packbuf [ j + + ] ;
g_player [ other ] . syncvalhead + + ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
case 127 :
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case 250 :
2007-08-27 00:20:15 +00:00
if ( g_player [ other ] . playerreadyflag = = 0 )
2006-12-01 22:34:32 +00:00
initprintf ( " Player %ld is ready \n " , other ) ;
2007-08-27 00:20:15 +00:00
g_player [ other ] . playerreadyflag + + ;
2006-11-16 03:02:42 +00:00
break ;
case 255 :
gameexit ( " " ) ;
break ;
2006-12-10 06:49:01 +00:00
default :
switch ( packbuf [ 0 ] )
{
case 4 :
//slaves in M/S mode only send to master
if ( ( ! networkmode ) & & ( myconnectindex = = connecthead ) )
{
if ( packbuf [ 1 ] = = 255 )
{
//Master re-transmits message to all others
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other )
sendpacket ( i , packbuf , packbufleng ) ;
}
else if ( ( ( long ) packbuf [ 1 ] ) ! = myconnectindex )
{
//Master re-transmits message not intended for master
sendpacket ( ( long ) packbuf [ 1 ] , packbuf , packbufleng ) ;
break ;
}
}
Bstrcpy ( recbuf , packbuf + 2 ) ;
recbuf [ packbufleng - 2 ] = 0 ;
adduserquote ( recbuf ) ;
sound ( EXITMENUSOUND ) ;
pus = NUMPAGES ;
pub = NUMPAGES ;
break ;
case 5 :
//Slaves in M/S mode only send to master
//Master re-transmits message to all others
if ( ( ! networkmode ) & & ( myconnectindex = = connecthead ) )
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other ) sendpacket ( i , packbuf , packbufleng ) ;
if ( vote_map ! = - 1 | | vote_episode ! = - 1 | | voting ! = - 1 )
adduserquote ( " VOTE SUCCEEDED " ) ;
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 ] ;
ud . m_noexits = ud . noexits = packbuf [ 11 ] ;
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 ;
if ( enterlevel ( MODE_GAME ) ) backtomenu ( ) ;
break ;
case 6 :
//slaves in M/S mode only send to master
//Master re-transmits message to all others
if ( ( ! networkmode ) & & ( myconnectindex = = connecthead ) )
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other ) sendpacket ( i , packbuf , packbufleng ) ;
if ( packbuf [ 2 ] ! = BYTEVERSION )
gameexit ( " \n You cannot play Duke with different versions. " ) ;
other = packbuf [ 1 ] ;
for ( i = 3 ; packbuf [ i ] ; i + + )
2007-08-27 00:20:15 +00:00
g_player [ other ] . user_name [ i - 3 ] = packbuf [ i ] ;
2007-08-27 06:46:31 +00:00
g_player [ other ] . user_name [ i - 3 ] = 0 ;
2006-12-10 06:49:01 +00:00
i + + ;
2007-08-27 06:46:31 +00:00
g_player [ other ] . ps - > aim_mode = packbuf [ i + + ] ;
g_player [ other ] . ps - > auto_aim = packbuf [ i + + ] ;
g_player [ other ] . ps - > weaponswitch = packbuf [ i + + ] ;
g_player [ other ] . ps - > palookup = g_player [ other ] . pcolor = packbuf [ i + + ] ;
2007-08-27 00:20:15 +00:00
g_player [ other ] . pteam = packbuf [ i + + ] ;
2006-12-10 06:49:01 +00:00
2007-08-27 06:46:31 +00:00
/* if(g_player[other].ps->team != j && sprite[g_player[other].ps->i].picnum == APLAYER)
2006-12-10 06:49:01 +00:00
{
2007-08-27 06:46:31 +00:00
hittype [ g_player [ other ] . ps - > i ] . extra = 1000 ;
hittype [ g_player [ other ] . ps - > i ] . picnum = APLAYERTOP ;
2006-12-10 06:49:01 +00:00
} */
break ;
case 10 :
//slaves in M/S mode only send to master
//Master re-transmits message to all others
if ( ( ! networkmode ) & & ( myconnectindex = = connecthead ) )
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other ) sendpacket ( i , packbuf , packbufleng ) ;
other = packbuf [ 1 ] ;
i = 2 ;
j = i ; //This used to be Duke packet #9... now concatenated with Duke packet #6
2007-08-27 06:46:31 +00:00
for ( ; i - j < 10 ; i + + ) g_player [ other ] . wchoice [ i - j ] = packbuf [ i ] ;
2006-12-10 06:49:01 +00:00
break ;
case 7 :
//slaves in M/S mode only send to master
//Master re-transmits message to all others
if ( ( ! networkmode ) & & ( myconnectindex = = connecthead ) )
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other ) sendpacket ( i , packbuf , packbufleng ) ;
if ( numlumps = = 0 ) break ;
2007-08-27 00:20:15 +00:00
if ( ud . config . SoundToggle = = 0 | | ud . lockout = = 1 | | ud . config . FXDevice < 0 )
2006-12-10 06:49:01 +00:00
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 254 :
//slaves in M/S mode only send to master
if ( myconnectindex = = connecthead )
{
//Master re-transmits message to all others
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other )
sendpacket ( i , packbuf , packbufleng ) ;
}
/*
j = packbuf [ 1 ] ;
playerquitflag [ j ] = 0 ;
j = - 1 ;
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
{
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . playerquitflag ) { j = i ; continue ; }
2006-12-10 06:49:01 +00:00
if ( i = = connecthead ) connecthead = connectpoint2 [ connecthead ] ;
else connectpoint2 [ j ] = connectpoint2 [ i ] ;
numplayers - - ;
ud . multimode - - ;
2007-08-27 00:20:15 +00:00
Bsprintf ( buf , " %s is history! " , g_player [ i ] . user_name ) ;
2006-12-10 06:49:01 +00:00
adduserquote ( buf ) ;
if ( numplayers < 2 )
sound ( GENERIC_AMBIENCE17 ) ;
if ( i = = 0 & & networkmode = = 0 ) */
gameexit ( " Game aborted from menu; disconnected. " ) ;
// }
break ;
case 9 :
//slaves in M/S mode only send to master
if ( myconnectindex = = connecthead )
{
//Master re-transmits message to all others
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other )
sendpacket ( i , packbuf , packbufleng ) ;
}
Bstrcpy ( boardfilename , packbuf + 1 ) ;
boardfilename [ packbufleng - 1 ] = 0 ;
2006-12-12 07:25:01 +00:00
Bcorrectfilename ( boardfilename , 0 ) ;
2006-12-10 06:49:01 +00:00
if ( boardfilename [ 0 ] ! = 0 )
{
2007-05-01 04:37:08 +00:00
if ( ( i = kopen4load ( boardfilename , 0 ) ) < 0 )
2006-12-10 06:49:01 +00:00
{
Bmemset ( boardfilename , 0 , sizeof ( boardfilename ) ) ;
sendboardname ( ) ;
}
2007-05-01 04:37:08 +00:00
else kclose ( i ) ;
2006-12-10 06:49:01 +00:00
}
if ( ud . m_level_number = = 7 & & ud . m_volume_number = = 0 & & boardfilename [ 0 ] = = 0 )
ud . m_level_number = 0 ;
break ;
case 18 : // map vote
if ( myconnectindex = = connecthead )
{
//Master re-transmits message to all others
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other )
sendpacket ( i , packbuf , packbufleng ) ;
}
switch ( packbuf [ 1 ] )
{
case 0 :
2007-08-27 06:46:31 +00:00
if ( voting = = myconnectindex & & g_player [ ( unsigned char ) packbuf [ 2 ] ] . gotvote = = 0 )
2006-12-10 06:49:01 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ ( unsigned char ) packbuf [ 2 ] ] . gotvote = 1 ;
g_player [ ( unsigned char ) packbuf [ 2 ] ] . vote = packbuf [ 3 ] ;
Bsprintf ( tempbuf , " GOT VOTE FROM %s " , g_player [ ( unsigned char ) packbuf [ 2 ] ] . user_name ) ;
2006-12-10 06:49:01 +00:00
adduserquote ( tempbuf ) ;
}
break ;
case 1 : // call map vote
voting = packbuf [ 2 ] ;
vote_episode = packbuf [ 3 ] ;
vote_map = packbuf [ 4 ] ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " %s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d) " , g_player [ ( unsigned char ) packbuf [ 2 ] ] . user_name , map [ ( unsigned char ) ( packbuf [ 3 ] * MAXLEVELS + packbuf [ 4 ] ) ] . name , packbuf [ 3 ] + 1 , packbuf [ 4 ] + 1 ) ;
2006-12-10 06:49:01 +00:00
adduserquote ( tempbuf ) ;
Bsprintf ( tempbuf , " PRESS F1 TO VOTE YES, F2 TO VOTE NO " ) ;
adduserquote ( tempbuf ) ;
2007-08-27 06:46:31 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
{
g_player [ i ] . vote = 0 ;
g_player [ i ] . gotvote = 0 ;
}
g_player [ voting ] . gotvote = g_player [ voting ] . vote = 1 ;
2006-12-10 06:49:01 +00:00
break ;
case 2 : // cancel map vote
if ( voting = = packbuf [ 2 ] )
{
voting = - 1 ;
i = 0 ;
for ( j = 0 ; j < MAXPLAYERS ; j + + )
2007-08-27 06:46:31 +00:00
i + = g_player [ j ] . gotvote ;
2006-12-10 06:49:01 +00:00
if ( i ! = numplayers )
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " %s^00 HAS CANCELED THE VOTE " , g_player [ ( unsigned char ) packbuf [ 2 ] ] . user_name ) ;
2006-12-10 06:49:01 +00:00
else Bsprintf ( tempbuf , " VOTE FAILED " ) ;
2007-08-27 06:46:31 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
{
g_player [ i ] . vote = 0 ;
g_player [ i ] . gotvote = 0 ;
}
2006-12-10 06:49:01 +00:00
adduserquote ( tempbuf ) ;
}
break ;
}
break ;
case 126 :
//Slaves in M/S mode only send to master
//Master re-transmits message to all others
if ( ( ! networkmode ) & & ( myconnectindex = = connecthead ) )
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = other ) sendpacket ( i , packbuf , packbufleng ) ;
multiflag = 2 ;
multiwhat = 0 ;
multiwho = packbuf [ 2 ] ; //other: need to send in m/s mode because of possible re-transmit
multipos = packbuf [ 1 ] ;
loadplayer ( multipos ) ;
multiflag = 0 ;
break ;
}
break ;
2006-04-13 20:47:06 +00:00
}
}
}
2006-12-10 03:15:56 +00:00
void faketimerhandler ( void )
2006-04-13 20:47:06 +00:00
{
2006-04-22 22:33:52 +00:00
long i , j , k ;
2006-04-13 20:47:06 +00:00
// short who;
input * osyn , * nsyn ;
2006-11-13 23:12:47 +00:00
if ( qe = = 0 & & KB_KeyPressed ( sc_LeftControl ) & & KB_KeyPressed ( sc_LeftAlt ) & & KB_KeyPressed ( sc_Delete ) )
2006-04-13 20:47:06 +00:00
{
qe = 1 ;
gameexit ( " Quick Exit. " ) ;
}
sampletimer ( ) ;
AudioUpdate ( ) ;
if ( ( totalclock < ototalclock + TICSPERFRAME ) | | ( ready2send = = 0 ) ) return ;
ototalclock + = TICSPERFRAME ;
2006-11-15 01:16:55 +00:00
getpackets ( ) ;
if ( getoutputcirclesize ( ) > = 16 ) return ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
if ( i ! = myconnectindex )
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . movefifoend < g_player [ myconnectindex ] . movefifoend - 200 ) return ;
2006-04-13 20:47:06 +00:00
getinput ( myconnectindex ) ;
avgfvel + = loc . fvel ;
avgsvel + = loc . svel ;
avgavel + = loc . avel ;
avghorz + = loc . horz ;
avgbits | = loc . bits ;
2006-08-22 05:38:59 +00:00
avgextbits | = loc . extbits ;
2007-08-27 00:20:15 +00:00
if ( g_player [ myconnectindex ] . movefifoend & ( movesperpacket - 1 ) )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
copybufbyte ( & inputfifo [ ( g_player [ myconnectindex ] . movefifoend - 1 ) & ( MOVEFIFOSIZ - 1 ) ] [ myconnectindex ] ,
& inputfifo [ g_player [ myconnectindex ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ myconnectindex ] , sizeof ( input ) ) ;
g_player [ myconnectindex ] . movefifoend + + ;
2006-04-13 20:47:06 +00:00
return ;
}
2007-08-27 00:20:15 +00:00
nsyn = & inputfifo [ g_player [ myconnectindex ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ myconnectindex ] ;
2006-04-13 20:47:06 +00:00
nsyn [ 0 ] . fvel = avgfvel / movesperpacket ;
nsyn [ 0 ] . svel = avgsvel / movesperpacket ;
nsyn [ 0 ] . avel = avgavel / movesperpacket ;
nsyn [ 0 ] . horz = avghorz / movesperpacket ;
nsyn [ 0 ] . bits = avgbits ;
2006-08-22 05:38:59 +00:00
nsyn [ 0 ] . extbits = avgextbits ;
avgfvel = avgsvel = avgavel = avghorz = avgbits = avgextbits = 0 ;
2007-08-27 00:20:15 +00:00
g_player [ myconnectindex ] . movefifoend + + ;
2006-04-13 20:47:06 +00:00
if ( numplayers < 2 )
{
2006-11-13 23:12:47 +00:00
if ( ud . multimode > 1 ) for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i ! = myconnectindex )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
//clearbufbyte(&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input),0L);
2006-11-13 23:12:47 +00:00
if ( ud . playerai )
2007-08-27 00:20:15 +00:00
computergetinput ( i , & inputfifo [ g_player [ i ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ i ] ) ;
inputfifo [ g_player [ i ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ i ] . svel + + ;
inputfifo [ g_player [ i ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ i ] . fvel + + ;
g_player [ i ] . movefifoend + + ;
2006-04-13 20:47:06 +00:00
}
return ;
}
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
if ( i ! = myconnectindex )
{
2007-08-27 00:20:15 +00:00
k = ( g_player [ myconnectindex ] . movefifoend - 1 ) - g_player [ i ] . movefifoend ;
g_player [ i ] . myminlag = min ( g_player [ i ] . myminlag , k ) ;
2006-04-13 20:47:06 +00:00
mymaxlag = max ( mymaxlag , k ) ;
}
2007-08-27 00:20:15 +00:00
if ( ( ( g_player [ myconnectindex ] . movefifoend - 1 ) & ( TIMERUPDATESIZ - 1 ) ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
i = mymaxlag - bufferjitter ;
mymaxlag = 0 ;
2006-04-13 20:47:06 +00:00
if ( i > 0 ) bufferjitter + = ( ( 3 + i ) > > 2 ) ;
else if ( i < 0 ) bufferjitter - = ( ( 1 - i ) > > 2 ) ;
}
if ( networkmode = = 1 )
{
packbuf [ 0 ] = 17 ;
2007-08-27 00:20:15 +00:00
if ( ( g_player [ myconnectindex ] . movefifoend - 1 ) = = 0 ) packbuf [ 0 ] = 16 ;
2006-04-13 20:47:06 +00:00
j = 1 ;
//Fix timers and buffer/jitter value
2007-08-27 00:20:15 +00:00
if ( ( ( g_player [ myconnectindex ] . movefifoend - 1 ) & ( TIMERUPDATESIZ - 1 ) ) = = 0 )
2006-04-13 20:47:06 +00:00
{
if ( myconnectindex ! = connecthead )
{
2007-08-27 00:20:15 +00:00
i = g_player [ connecthead ] . myminlag - otherminlag ;
2006-04-13 20:47:06 +00:00
if ( klabs ( i ) > 8 ) i > > = 1 ;
else if ( klabs ( i ) > 2 ) i = ksgn ( i ) ;
else i = 0 ;
totalclock - = TICSPERFRAME * i ;
2007-08-27 00:20:15 +00:00
g_player [ connecthead ] . myminlag - = i ;
2006-11-15 01:16:55 +00:00
otherminlag + = i ;
2006-04-13 20:47:06 +00:00
}
if ( myconnectindex = = connecthead )
2006-11-13 23:12:47 +00:00
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
packbuf [ j + + ] = min ( max ( g_player [ i ] . myminlag , - 128 ) , 127 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
g_player [ i ] . myminlag = 0x7fffffff ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 00:20:15 +00:00
osyn = ( input * ) & inputfifo [ ( g_player [ myconnectindex ] . movefifoend - 2 ) & ( MOVEFIFOSIZ - 1 ) ] [ myconnectindex ] ;
nsyn = ( input * ) & inputfifo [ ( g_player [ myconnectindex ] . movefifoend - 1 ) & ( MOVEFIFOSIZ - 1 ) ] [ myconnectindex ] ;
2006-04-13 20:47:06 +00:00
k = j ;
packbuf [ j + + ] = 0 ;
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 ;
}
k + + ;
packbuf [ k ] = 0 ;
2006-08-22 05:38:59 +00:00
if ( ( nsyn [ 0 ] . extbits ^ osyn [ 0 ] . extbits ) & 0x000000ff ) packbuf [ j + + ] = ( nsyn [ 0 ] . extbits & 255 ) , packbuf [ k ] | = 1 ;
if ( ( nsyn [ 0 ] . extbits ^ osyn [ 0 ] . extbits ) & 0x0000ff00 ) packbuf [ j + + ] = ( ( nsyn [ 0 ] . extbits > > 8 ) & 255 ) , packbuf [ k ] | = 2 ;
if ( ( nsyn [ 0 ] . extbits ^ osyn [ 0 ] . extbits ) & 0x00ff0000 ) packbuf [ j + + ] = ( ( nsyn [ 0 ] . extbits > > 16 ) & 255 ) , packbuf [ k ] | = 4 ;
if ( ( nsyn [ 0 ] . extbits ^ osyn [ 0 ] . extbits ) & 0xff000000 ) packbuf [ j + + ] = ( ( nsyn [ 0 ] . extbits > > 24 ) & 255 ) , packbuf [ k ] | = 8 ;
2006-04-13 20:47:06 +00:00
2007-08-27 00:20:15 +00:00
while ( g_player [ myconnectindex ] . syncvalhead ! = syncvaltail )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
packbuf [ j + + ] = g_player [ myconnectindex ] . syncval [ syncvaltail & ( MOVEFIFOSIZ - 1 ) ] ;
2006-04-13 20:47:06 +00:00
syncvaltail + + ;
}
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
if ( i ! = myconnectindex )
sendpacket ( i , packbuf , j ) ;
return ;
}
if ( myconnectindex ! = connecthead ) //Slave
{
//Fix timers and buffer/jitter value
2007-08-27 00:20:15 +00:00
if ( ( ( g_player [ myconnectindex ] . movefifoend - 1 ) & ( TIMERUPDATESIZ - 1 ) ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
i = g_player [ connecthead ] . myminlag - otherminlag ;
2006-04-13 20:47:06 +00:00
if ( klabs ( i ) > 8 ) i > > = 1 ;
else if ( klabs ( i ) > 2 ) i = ksgn ( i ) ;
else i = 0 ;
totalclock - = TICSPERFRAME * i ;
2007-08-27 00:20:15 +00:00
g_player [ connecthead ] . myminlag - = i ;
2006-11-15 01:16:55 +00:00
otherminlag + = i ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
g_player [ i ] . myminlag = 0x7fffffff ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
packbuf [ 0 ] = 1 ;
packbuf [ 1 ] = 0 ;
packbuf [ 2 ] = 0 ;
j = 3 ;
2006-04-13 20:47:06 +00:00
2007-08-27 00:20:15 +00:00
osyn = ( input * ) & inputfifo [ ( g_player [ myconnectindex ] . movefifoend - 2 ) & ( MOVEFIFOSIZ - 1 ) ] [ myconnectindex ] ;
nsyn = ( input * ) & inputfifo [ ( g_player [ myconnectindex ] . movefifoend - 1 ) & ( MOVEFIFOSIZ - 1 ) ] [ myconnectindex ] ;
2006-04-13 20:47:06 +00:00
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 ;
}
packbuf [ 2 ] = 0 ;
2006-08-22 05:38:59 +00:00
if ( ( nsyn [ 0 ] . extbits ^ osyn [ 0 ] . extbits ) & 0x000000ff ) packbuf [ j + + ] = ( nsyn [ 0 ] . extbits & 255 ) , packbuf [ 2 ] | = 1 ;
if ( ( nsyn [ 0 ] . extbits ^ osyn [ 0 ] . extbits ) & 0x0000ff00 ) packbuf [ j + + ] = ( ( nsyn [ 0 ] . extbits > > 8 ) & 255 ) , packbuf [ 2 ] | = 2 ;
if ( ( nsyn [ 0 ] . extbits ^ osyn [ 0 ] . extbits ) & 0x00ff0000 ) packbuf [ j + + ] = ( ( nsyn [ 0 ] . extbits > > 16 ) & 255 ) , packbuf [ 2 ] | = 4 ;
if ( ( nsyn [ 0 ] . extbits ^ osyn [ 0 ] . extbits ) & 0xff000000 ) packbuf [ j + + ] = ( ( nsyn [ 0 ] . extbits > > 24 ) & 255 ) , packbuf [ 2 ] | = 8 ;
2006-04-13 20:47:06 +00:00
2007-08-27 00:20:15 +00:00
while ( g_player [ myconnectindex ] . syncvalhead ! = syncvaltail )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
packbuf [ j + + ] = g_player [ myconnectindex ] . syncval [ syncvaltail & ( MOVEFIFOSIZ - 1 ) ] ;
2006-04-13 20:47:06 +00:00
syncvaltail + + ;
}
sendpacket ( connecthead , packbuf , j ) ;
return ;
}
//This allows allow packet resends
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . movefifoend < = movefifosendplc )
2006-04-13 20:47:06 +00:00
{
packbuf [ 0 ] = 127 ;
2006-11-13 23:12:47 +00:00
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
sendpacket ( i , packbuf , 1 ) ;
return ;
}
while ( 1 ) //Master
{
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . playerquitflag & & ( g_player [ i ] . movefifoend < = movefifosendplc ) ) return ;
2006-04-13 20:47:06 +00:00
osyn = ( input * ) & inputfifo [ ( movefifosendplc - 1 ) & ( MOVEFIFOSIZ - 1 ) ] [ 0 ] ;
2006-11-14 21:35:50 +00:00
nsyn = ( input * ) & inputfifo [ ( movefifosendplc ) & ( MOVEFIFOSIZ - 1 ) ] [ 0 ] ;
2006-04-13 20:47:06 +00:00
//MASTER -> SLAVE packet
2006-11-15 01:16:55 +00:00
packbuf [ 0 ] = 0 ;
j = 1 ;
2006-04-13 20:47:06 +00:00
//Fix timers and buffer/jitter value
if ( ( movefifosendplc & ( TIMERUPDATESIZ - 1 ) ) = = 0 )
{
2006-11-13 23:12:47 +00:00
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . playerquitflag )
packbuf [ j + + ] = min ( max ( g_player [ i ] . myminlag , - 128 ) , 127 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
g_player [ i ] . myminlag = 0x7fffffff ;
2006-04-13 20:47:06 +00:00
}
k = j ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
j + = g_player [ i ] . playerquitflag + g_player [ i ] . playerquitflag ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . playerquitflag = = 0 ) continue ;
2006-04-13 20:47:06 +00:00
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 + + ;
packbuf [ k ] = 0 ;
2006-08-22 05:38:59 +00:00
if ( ( nsyn [ i ] . extbits ^ osyn [ i ] . extbits ) & 0x000000ff ) packbuf [ j + + ] = ( nsyn [ i ] . extbits & 255 ) , packbuf [ k ] | = 1 ;
if ( ( nsyn [ i ] . extbits ^ osyn [ i ] . extbits ) & 0x0000ff00 ) packbuf [ j + + ] = ( ( nsyn [ i ] . extbits > > 8 ) & 255 ) , packbuf [ k ] | = 2 ;
if ( ( nsyn [ i ] . extbits ^ osyn [ i ] . extbits ) & 0x00ff0000 ) packbuf [ j + + ] = ( ( nsyn [ i ] . extbits > > 16 ) & 255 ) , packbuf [ k ] | = 4 ;
if ( ( nsyn [ i ] . extbits ^ osyn [ i ] . extbits ) & 0xff000000 ) packbuf [ j + + ] = ( ( nsyn [ i ] . extbits > > 24 ) & 255 ) , packbuf [ k ] | = 8 ;
2006-04-13 20:47:06 +00:00
k + + ;
}
2007-08-27 00:20:15 +00:00
while ( g_player [ myconnectindex ] . syncvalhead ! = syncvaltail )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
packbuf [ j + + ] = g_player [ myconnectindex ] . syncval [ syncvaltail & ( MOVEFIFOSIZ - 1 ) ] ;
2006-04-13 20:47:06 +00:00
syncvaltail + + ;
}
2006-11-13 23:12:47 +00:00
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . playerquitflag )
2006-04-13 20:47:06 +00:00
{
sendpacket ( i , packbuf , j ) ;
if ( nsyn [ i ] . bits & ( 1 < < 26 ) )
2007-08-27 00:20:15 +00:00
g_player [ i ] . playerquitflag = 0 ;
2006-04-13 20:47:06 +00:00
}
movefifosendplc + = movesperpacket ;
}
}
extern long cacnum ;
2006-11-15 01:16:55 +00:00
typedef struct
{
long * hand , leng ;
char * lock ;
}
2006-11-13 23:12:47 +00:00
cactype ;
2006-04-13 20:47:06 +00:00
extern cactype cac [ ] ;
2006-12-10 03:15:56 +00:00
static void caches ( void )
2006-04-13 20:47:06 +00:00
{
short i , k ;
k = 0 ;
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < cacnum ; i + + )
2006-04-13 20:47:06 +00:00
if ( ( * cac [ i ] . lock ) > = 200 )
{
Bsprintf ( tempbuf , " Locked- %d: Leng:%ld, Lock:%d " , i , cac [ i ] . leng , * cac [ i ] . lock ) ;
2006-11-15 01:16:55 +00:00
printext256 ( 0L , k , 31 , - 1 , tempbuf , 1 ) ;
k + = 6 ;
2006-04-13 20:47:06 +00:00
}
k + = 6 ;
2006-11-13 23:12:47 +00:00
for ( i = 1 ; i < 11 ; i + + )
2006-04-13 20:47:06 +00:00
if ( lumplockbyte [ i ] > = 200 )
{
Bsprintf ( tempbuf , " RTS Locked %d: " , i ) ;
2006-11-15 01:16:55 +00:00
printext256 ( 0L , k , 31 , - 1 , tempbuf , 1 ) ;
k + = 6 ;
2006-04-13 20:47:06 +00:00
}
}
2006-12-10 03:15:56 +00:00
static void checksync ( void )
2006-04-13 20:47:06 +00:00
{
2006-04-22 22:33:52 +00:00
long i ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . syncvalhead = = syncvaltottail ) break ;
2006-04-13 20:47:06 +00:00
if ( i < 0 )
{
syncstat = 0 ;
do
{
2006-11-13 23:12:47 +00:00
for ( i = connectpoint2 [ connecthead ] ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . syncval [ syncvaltottail & ( MOVEFIFOSIZ - 1 ) ] ! =
g_player [ connecthead ] . syncval [ syncvaltottail & ( MOVEFIFOSIZ - 1 ) ] )
2006-04-13 20:47:06 +00:00
syncstat = 1 ;
syncvaltottail + + ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
if ( g_player [ i ] . syncvalhead = = syncvaltottail ) break ;
2006-11-15 01:16:55 +00:00
}
while ( i < 0 ) ;
2006-04-13 20:47:06 +00:00
}
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 ) ;
}
}
2007-02-28 09:12:41 +00:00
void check_fta_sounds ( int i )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ i ] . extra > 0 )
switch ( dynamictostatic [ PN ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case LIZTROOPONTOILET__STATIC :
case LIZTROOPJUSTSIT__STATIC :
case LIZTROOPSHOOT__STATIC :
case LIZTROOPJETPACK__STATIC :
case LIZTROOPDUCKING__STATIC :
case LIZTROOPRUNNING__STATIC :
case LIZTROOP__STATIC :
spritesound ( PRED_RECOG , i ) ;
break ;
case LIZMAN__STATIC :
case LIZMANSPITTING__STATIC :
case LIZMANFEEDING__STATIC :
case LIZMANJUMP__STATIC :
spritesound ( CAPT_RECOG , i ) ;
break ;
case PIGCOP__STATIC :
case PIGCOPDIVE__STATIC :
spritesound ( PIG_RECOG , i ) ;
break ;
case RECON__STATIC :
spritesound ( RECO_RECOG , i ) ;
break ;
case DRONE__STATIC :
spritesound ( DRON_RECOG , i ) ;
break ;
case COMMANDER__STATIC :
case COMMANDERSTAYPUT__STATIC :
spritesound ( COMM_RECOG , i ) ;
break ;
case ORGANTIC__STATIC :
spritesound ( TURR_RECOG , i ) ;
break ;
case OCTABRAIN__STATIC :
case OCTABRAINSTAYPUT__STATIC :
spritesound ( OCTA_RECOG , i ) ;
break ;
case BOSS1__STATIC :
sound ( BOS1_RECOG ) ;
break ;
case BOSS2__STATIC :
if ( sprite [ i ] . pal = = 1 )
sound ( BOS2_RECOG ) ;
else sound ( WHIPYOURASS ) ;
break ;
case BOSS3__STATIC :
if ( sprite [ i ] . pal = = 1 )
sound ( BOS3_RECOG ) ;
else sound ( RIPHEADNECK ) ;
break ;
case BOSS4__STATIC :
case BOSS4STAYPUT__STATIC :
if ( sprite [ i ] . pal = = 1 )
sound ( BOS4_RECOG ) ;
sound ( BOSS4_FIRSTSEE ) ;
break ;
case GREENSLIME__STATIC :
spritesound ( SLIM_RECOG , i ) ;
break ;
2006-04-13 20:47:06 +00:00
}
}
2007-02-28 09:12:41 +00:00
int inventory ( spritetype * s )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
switch ( dynamictostatic [ s - > picnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case FIRSTAID__STATIC :
case STEROIDS__STATIC :
case HEATSENSOR__STATIC :
case BOOTS__STATIC :
case JETPACK__STATIC :
case HOLODUKE__STATIC :
case AIRTANK__STATIC :
return 1 ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2007-04-15 20:04:52 +00:00
inline int checkspriteflags ( int iActor , int iType )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
if ( ( spriteflags [ sprite [ iActor ] . picnum ] ^ actorspriteflags [ iActor ] ) & iType ) return 1 ;
2006-12-14 08:50:18 +00:00
return 0 ;
2006-04-13 20:47:06 +00:00
}
2006-12-21 09:33:26 +00:00
inline int checkspriteflagsp ( int iPicnum , int iType )
2006-04-13 20:47:06 +00:00
{
2006-12-21 09:33:26 +00:00
if ( spriteflags [ iPicnum ] & iType ) return 1 ;
2006-12-14 08:50:18 +00:00
return 0 ;
2006-04-13 20:47:06 +00:00
}
2006-12-21 09:33:26 +00:00
int badguypic ( int pn )
2006-04-13 20:47:06 +00:00
{
//this case can't be handled by the dynamictostatic system because it adds
//stuff to the value from names.h so handling separately
if ( ( pn > = GREENSLIME ) & & ( pn < = GREENSLIME + 7 ) ) return 1 ;
2006-11-13 23:12:47 +00:00
if ( checkspriteflagsp ( pn , SPRITE_FLAG_BADGUY ) ) return 1 ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( actortype [ pn ] ) return 1 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
switch ( dynamictostatic [ pn ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case SHARK__STATIC :
case RECON__STATIC :
case DRONE__STATIC :
case LIZTROOPONTOILET__STATIC :
case LIZTROOPJUSTSIT__STATIC :
case LIZTROOPSTAYPUT__STATIC :
case LIZTROOPSHOOT__STATIC :
case LIZTROOPJETPACK__STATIC :
case LIZTROOPDUCKING__STATIC :
case LIZTROOPRUNNING__STATIC :
case LIZTROOP__STATIC :
case OCTABRAIN__STATIC :
case COMMANDER__STATIC :
case COMMANDERSTAYPUT__STATIC :
case PIGCOP__STATIC :
case EGG__STATIC :
case PIGCOPSTAYPUT__STATIC :
case PIGCOPDIVE__STATIC :
case LIZMAN__STATIC :
case LIZMANSPITTING__STATIC :
case LIZMANFEEDING__STATIC :
case LIZMANJUMP__STATIC :
case ORGANTIC__STATIC :
case BOSS1__STATIC :
case BOSS2__STATIC :
case BOSS3__STATIC :
case BOSS4__STATIC :
//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__STATIC :
case ROTATEGUN__STATIC :
return 1 ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2006-12-17 21:20:35 +00:00
inline int badguy ( spritetype * s )
2006-04-13 20:47:06 +00:00
{
return ( badguypic ( s - > picnum ) ) ;
}
2006-12-21 09:33:26 +00:00
void myos ( long x , long y , int tilenum , int shade , int orientation )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
int p = sector [ g_player [ screenpeek ] . ps - > cursectnum ] . floorpal , a = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( orientation & 4 )
2006-04-13 20:47:06 +00:00
a = 1024 ;
rotatesprite ( x < < 16 , y < < 16 , 65536L , a , tilenum , shade , p , 2 | orientation , windowx1 , windowy1 , windowx2 , windowy2 ) ;
}
2006-12-21 09:33:26 +00:00
void myospal ( long x , long y , int tilenum , int shade , int orientation , int p )
2006-04-13 20:47:06 +00:00
{
2006-12-18 04:16:41 +00:00
int a = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( orientation & 4 )
2006-04-13 20:47:06 +00:00
a = 1024 ;
rotatesprite ( x < < 16 , y < < 16 , 65536L , a , tilenum , shade , p , 2 | orientation , windowx1 , windowy1 , windowx2 , windowy2 ) ;
}
2006-12-21 09:33:26 +00:00
void myosx ( long x , long y , int tilenum , int shade , int orientation )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
int p = sector [ g_player [ screenpeek ] . ps - > cursectnum ] . floorpal , a = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( orientation & 4 )
2006-04-13 20:47:06 +00:00
a = 1024 ;
rotatesprite ( x < < 16 , y < < 16 , 32768L , a , tilenum , shade , p , 2 | orientation , windowx1 , windowy1 , windowx2 , windowy2 ) ;
}
2006-12-21 09:33:26 +00:00
void myospalx ( long x , long y , int tilenum , int shade , int orientation , int p )
2006-04-13 20:47:06 +00:00
{
2006-12-18 04:16:41 +00:00
int a = 0 ;
2006-12-18 08:37:12 +00:00
2006-11-13 23:12:47 +00:00
if ( orientation & 4 )
2006-04-13 20:47:06 +00:00
a = 1024 ;
rotatesprite ( x < < 16 , y < < 16 , 32768L , a , tilenum , shade , p , 2 | orientation , windowx1 , windowy1 , windowx2 , windowy2 ) ;
}
2006-12-10 03:15:56 +00:00
static void invennum ( long x , long y , char num1 , char ha , char sbits )
2006-04-13 20:47:06 +00:00
{
char dabuf [ 80 ] = { 0 } ;
Bsprintf ( dabuf , " %d " , num1 ) ;
2006-11-13 23:12:47 +00:00
if ( num1 > 99 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( sbarx ( x - 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , sbits , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , sbits , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 2 ] - ' 0 ' , ha , 0 , sbits , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-12-18 04:16:41 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2006-12-18 04:16:41 +00:00
if ( num1 > 9 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( sbarx ( x ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , sbits , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , sbits , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-12-18 04:16:41 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2006-12-18 04:16:41 +00:00
rotatesprite ( sbarx ( x + 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , sbits , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
}
2006-12-10 03:15:56 +00:00
static void weaponnum ( short ind , long x , long y , long num1 , long num2 , char ha )
2006-04-13 20:47:06 +00:00
{
char dabuf [ 80 ] = { 0 } ;
rotatesprite ( sbarx ( x - 7 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + ind + 1 , ha - 10 , 7 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x - 3 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + 10 , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-12-18 04:16:41 +00:00
if ( VOLUMEONE & & ( ind > HANDBOMB_WEAPON | | ind < 0 ) )
{
2007-01-30 09:03:51 +00:00
minitextshade ( x + 1 , y - 4 , " ORDER " , 20 , 11 , 2 + 8 + 16 + 256 ) ;
2006-12-18 04:16:41 +00:00
return ;
}
2006-04-13 20:47:06 +00:00
rotatesprite ( sbarx ( x + 9 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + 11 , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-13 23:12:47 +00:00
if ( num1 > 99 ) num1 = 99 ;
if ( num2 > 99 ) num2 = 99 ;
2006-04-13 20:47:06 +00:00
Bsprintf ( dabuf , " %ld " , num1 ) ;
2006-11-13 23:12:47 +00:00
if ( num1 > 9 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( sbarx ( x ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
else rotatesprite ( sbarx ( x + 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
Bsprintf ( dabuf , " %ld " , num2 ) ;
2006-11-13 23:12:47 +00:00
if ( num2 > 9 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( sbarx ( x + 13 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 17 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-12-18 04:16:41 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2006-12-18 04:16:41 +00:00
rotatesprite ( sbarx ( x + 13 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
}
2006-12-10 03:15:56 +00:00
static void weaponnum999 ( char ind , long x , long y , long num1 , long num2 , char ha )
2006-04-13 20:47:06 +00:00
{
char dabuf [ 80 ] = { 0 } ;
rotatesprite ( sbarx ( x - 7 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + ind + 1 , ha - 10 , 7 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x - 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + 10 , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 13 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + 11 , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
Bsprintf ( dabuf , " %ld " , num1 ) ;
2006-11-13 23:12:47 +00:00
if ( num1 > 99 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( sbarx ( x ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 8 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 2 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
2006-11-13 23:12:47 +00:00
else if ( num1 > 9 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( sbarx ( x + 4 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 8 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
else rotatesprite ( sbarx ( x + 8 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
Bsprintf ( dabuf , " %ld " , num2 ) ;
2006-11-13 23:12:47 +00:00
if ( num2 > 99 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( sbarx ( x + 17 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 21 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 25 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 2 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
2006-11-13 23:12:47 +00:00
else if ( num2 > 9 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( sbarx ( x + 17 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( sbarx ( x + 21 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-12-18 04:16:41 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2006-12-18 04:16:41 +00:00
rotatesprite ( sbarx ( x + 25 ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 00:20:15 +00:00
static void weapon_amounts ( player_struct * p , long x , long y , long u )
2006-04-13 20:47:06 +00:00
{
2006-12-18 04:16:41 +00:00
int cw = p - > curr_weapon ;
2006-04-13 20:47:06 +00:00
if ( u & 4 )
{
if ( u ! = - 1 ) patchstatusbar ( 88 , 178 , 88 + 37 , 178 + 6 ) ; //original code: (96,178,96+12,178+6);
weaponnum999 ( PISTOL_WEAPON , x , y ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ PISTOL_WEAPON ] , p - > max_ammo_amount [ PISTOL_WEAPON ] ,
2006-11-14 21:35:50 +00:00
12 - 20 * ( cw = = PISTOL_WEAPON ) ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 8 )
{
if ( u ! = - 1 ) patchstatusbar ( 88 , 184 , 88 + 37 , 184 + 6 ) ; //original code: (96,184,96+12,184+6);
weaponnum999 ( SHOTGUN_WEAPON , x , y + 6 ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ SHOTGUN_WEAPON ] , p - > max_ammo_amount [ SHOTGUN_WEAPON ] ,
2006-04-13 20:47:06 +00:00
( ! p - > gotweapon [ SHOTGUN_WEAPON ] * 9 ) + 12 - 18 *
2006-11-14 21:35:50 +00:00
( cw = = SHOTGUN_WEAPON ) ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 16 )
{
if ( u ! = - 1 ) patchstatusbar ( 88 , 190 , 88 + 37 , 190 + 6 ) ; //original code: (96,190,96+12,190+6);
weaponnum999 ( CHAINGUN_WEAPON , x , y + 12 ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ CHAINGUN_WEAPON ] , p - > max_ammo_amount [ CHAINGUN_WEAPON ] ,
2006-04-13 20:47:06 +00:00
( ! p - > gotweapon [ CHAINGUN_WEAPON ] * 9 ) + 12 - 18 *
2006-11-14 21:35:50 +00:00
( cw = = CHAINGUN_WEAPON ) ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 32 )
{
if ( u ! = - 1 ) patchstatusbar ( 127 , 178 , 127 + 29 , 178 + 6 ) ; //original code: (135,178,135+8,178+6);
weaponnum ( RPG_WEAPON , x + 39 , y ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ RPG_WEAPON ] , p - > max_ammo_amount [ RPG_WEAPON ] ,
2006-04-13 20:47:06 +00:00
( ! p - > gotweapon [ RPG_WEAPON ] * 9 ) + 12 - 19 *
2006-11-14 21:35:50 +00:00
( cw = = RPG_WEAPON ) ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 64 )
{
if ( u ! = - 1 ) patchstatusbar ( 127 , 184 , 127 + 29 , 184 + 6 ) ; //original code: (135,184,135+8,184+6);
weaponnum ( HANDBOMB_WEAPON , x + 39 , y + 6 ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ HANDBOMB_WEAPON ] , p - > max_ammo_amount [ HANDBOMB_WEAPON ] ,
2006-04-13 20:47:06 +00:00
( ( ( ! p - > ammo_amount [ HANDBOMB_WEAPON ] ) | ( ! p - > gotweapon [ HANDBOMB_WEAPON ] ) ) * 9 ) + 12 - 19 *
( ( cw = = HANDBOMB_WEAPON ) | | ( cw = = HANDREMOTE_WEAPON ) ) ) ;
}
if ( u & 128 )
{
if ( u ! = - 1 ) patchstatusbar ( 127 , 190 , 127 + 29 , 190 + 6 ) ; //original code: (135,190,135+8,190+6);
2006-12-18 04:16:41 +00:00
if ( p - > subweapon & ( 1 < < GROW_WEAPON ) )
weaponnum ( SHRINKER_WEAPON , x + 39 , y + 12 ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ GROW_WEAPON ] , p - > max_ammo_amount [ GROW_WEAPON ] ,
2006-12-18 08:37:12 +00:00
( ! p - > gotweapon [ GROW_WEAPON ] * 9 ) + 12 - 18 *
( cw = = GROW_WEAPON ) ) ;
2006-11-15 01:16:55 +00:00
else
2006-12-18 04:16:41 +00:00
weaponnum ( SHRINKER_WEAPON , x + 39 , y + 12 ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ SHRINKER_WEAPON ] , p - > max_ammo_amount [ SHRINKER_WEAPON ] ,
2006-12-18 08:37:12 +00:00
( ! p - > gotweapon [ SHRINKER_WEAPON ] * 9 ) + 12 - 18 *
( cw = = SHRINKER_WEAPON ) ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 256 )
{
if ( u ! = - 1 ) patchstatusbar ( 158 , 178 , 162 + 29 , 178 + 6 ) ; //original code: (166,178,166+8,178+6);
2006-12-18 04:16:41 +00:00
weaponnum ( DEVISTATOR_WEAPON , x + 70 , y ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ DEVISTATOR_WEAPON ] , p - > max_ammo_amount [ DEVISTATOR_WEAPON ] ,
2006-12-18 08:37:12 +00:00
( ! p - > gotweapon [ DEVISTATOR_WEAPON ] * 9 ) + 12 - 18 *
( cw = = DEVISTATOR_WEAPON ) ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 512 )
{
if ( u ! = - 1 ) patchstatusbar ( 158 , 184 , 162 + 29 , 184 + 6 ) ; //original code: (166,184,166+8,184+6);
2006-12-18 08:37:12 +00:00
2006-12-18 04:16:41 +00:00
weaponnum ( TRIPBOMB_WEAPON , x + 70 , y + 6 ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ TRIPBOMB_WEAPON ] , p - > max_ammo_amount [ TRIPBOMB_WEAPON ] ,
2006-12-18 08:37:12 +00:00
( ! p - > gotweapon [ TRIPBOMB_WEAPON ] * 9 ) + 12 - 18 *
( cw = = TRIPBOMB_WEAPON ) ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 65536L )
{
if ( u ! = - 1 ) patchstatusbar ( 158 , 190 , 162 + 29 , 190 + 6 ) ; //original code: (166,190,166+8,190+6);
2006-12-18 04:16:41 +00:00
weaponnum ( - 1 , x + 70 , y + 12 ,
2007-08-27 23:11:49 +00:00
p - > ammo_amount [ FREEZE_WEAPON ] , p - > max_ammo_amount [ FREEZE_WEAPON ] ,
2006-12-18 08:37:12 +00:00
( ! p - > gotweapon [ FREEZE_WEAPON ] * 9 ) + 12 - 18 *
( cw = = FREEZE_WEAPON ) ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-12-10 03:15:56 +00:00
static void digitalnumber ( long x , long y , long n , char s , char cs )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
int i , j = 0 , k , p , c ;
2006-04-13 20:47:06 +00:00
char b [ 10 ] ;
Bsnprintf ( b , 10 , " %ld " , n ) ;
2006-07-21 22:25:05 +00:00
i = Bstrlen ( b ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( k = 0 ; k < i ; k + + )
2006-04-13 20:47:06 +00:00
{
p = DIGITALNUM + * ( b + k ) - ' 0 ' ;
j + = tilesizx [ p ] + 1 ;
}
c = x - ( j > > 1 ) ;
j = 0 ;
2006-11-13 23:12:47 +00:00
for ( k = 0 ; k < i ; k + + )
2006-04-13 20:47:06 +00:00
{
p = DIGITALNUM + * ( b + k ) - ' 0 ' ;
rotatesprite ( sbarx ( c + j ) , sbary ( y ) , sbarsc ( 65536L ) , 0 , p , s , 0 , cs , 0 , 0 , xdim - 1 , ydim - 1 ) ;
j + = tilesizx [ p ] + 1 ;
}
}
2007-02-28 09:12:41 +00:00
void txdigitalnumber ( int starttile , long x , long y , long n , int s , int pal , int cs , long x1 , long y1 , long x2 , long y2 )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
int i , j = 0 , k , p , c ;
2006-04-13 20:47:06 +00:00
char b [ 10 ] ;
//ltoa(n,b,10);
Bsnprintf ( b , 10 , " %ld " , n ) ;
2006-07-21 22:25:05 +00:00
i = Bstrlen ( b ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( k = 0 ; k < i ; k + + )
2006-04-13 20:47:06 +00:00
{
p = starttile + * ( b + k ) - ' 0 ' ;
j + = tilesizx [ p ] + 1 ;
}
c = x - ( j > > 1 ) ;
j = 0 ;
2006-11-13 23:12:47 +00:00
for ( k = 0 ; k < i ; k + + )
2006-04-13 20:47:06 +00:00
{
p = starttile + * ( b + k ) - ' 0 ' ;
rotatesprite ( ( c + j ) < < 16 , y < < 16 , 65536L , 0 , p , s , pal , 2 | cs , x1 , y1 , x2 , y2 ) ;
/* rotatesprite((c+j)<<16,y<<16,65536L,0,p,s,pal,cs,0,0,xdim-1,ydim-1);
rotatesprite ( x < < 16 , y < < 16 , 32768L , a , tilenum , shade , p , 2 | orientation , windowx1 , windowy1 , windowx2 , windowy2 ) ; */
j + = tilesizx [ p ] + 1 ;
}
}
2007-08-27 00:20:15 +00:00
static void displayinventory ( player_struct * p )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
int n , j = 0 , xoff = 0 , y ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
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 + + ;
2006-04-13 20:47:06 +00:00
xoff = 160 - ( j * 11 ) ;
j = 0 ;
2006-11-13 23:12:47 +00:00
if ( ud . screen_size > 4 )
2006-04-13 20:47:06 +00:00
y = 154 ;
2006-04-18 01:15:02 +00:00
else y = ( ud . drawweapon = = 2 ? 150 : 172 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ud . screen_size = = 4 & & ud . drawweapon ! = 2 )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
xoff + = 65 ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode > 1 )
2007-04-15 20:04:52 +00:00
xoff - = 9 ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
while ( j < = 9 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( n & ( 1 < < j ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
switch ( n & ( 1 < < j ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
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 ;
2006-04-13 20:47:06 +00:00
}
xoff + = 22 ;
2006-11-13 23:12:47 +00:00
if ( p - > inven_icon = = j + 1 )
2006-04-13 20:47:06 +00:00
rotatesprite ( ( xoff - 2 ) < < 16 , ( y + 19 ) < < 16 , 65536L , 1024 , ARROW , - 32 , 0 , 2 + 16 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
}
j + + ;
}
}
void displayfragbar ( void )
{
2007-04-15 20:04:52 +00:00
int i , j = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
if ( i > j ) j = i ;
2006-04-13 20:47:06 +00:00
rotatesprite ( 0 , 0 , 65600L , 0 , FRAGBAR , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-13 23:12:47 +00:00
if ( j > = 4 ) rotatesprite ( 319 , ( 8 ) < < 16 , 65600L , 0 , FRAGBAR , 0 , 0 , 10 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( j > = 8 ) rotatesprite ( 319 , ( 16 ) < < 16 , 65600L , 0 , FRAGBAR , 0 , 0 , 10 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( j > = 12 ) rotatesprite ( 319 , ( 24 ) < < 16 , 65600L , 0 , FRAGBAR , 0 , 0 , 10 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
minitext ( 21 + ( 73 * ( i & 3 ) ) , 2 + ( ( i & 28 ) < < 1 ) , & g_player [ i ] . user_name [ 0 ] , /*sprite[g_player[i].ps->i].pal*/ g_player [ i ] . ps - > palookup , 2 + 8 + 16 ) ;
Bsprintf ( tempbuf , " %d " , g_player [ i ] . ps - > frag - g_player [ i ] . ps - > fraggedself ) ;
minitext ( 17 + 50 + ( 73 * ( i & 3 ) ) , 2 + ( ( i & 28 ) < < 1 ) , tempbuf , /*sprite[g_player[i].ps->i].pal*/ g_player [ i ] . ps - > palookup , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-08-10 02:10:24 +00:00
# define SBY (200-tilesizy[BOTTOMSTATUSBAR])
2006-12-20 03:27:25 +00:00
static void coolgaugetext ( int snum )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
player_struct * p = g_player [ snum ] . ps ;
2007-04-15 20:04:52 +00:00
long i , j , o , ss = ud . screen_size , u ;
2007-02-16 00:11:25 +00:00
int permbit = 0 ;
2006-04-13 20:47:06 +00:00
2007-04-15 20:04:52 +00:00
if ( ss < 4 ) return ;
2007-08-27 06:46:31 +00:00
if ( g_player [ snum ] . ps - > gm & MODE_MENU )
2006-11-14 21:35:50 +00:00
if ( ( current_menu > = 400 & & current_menu < = 405 ) )
2006-04-13 20:47:06 +00:00
return ;
2006-08-10 02:10:24 +00:00
if ( getrendermode ( ) > = 3 ) pus = NUMPAGES ; // JBF 20040101: always redraw in GL
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( ud . multimode > 1 & & ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_FRAGBAR ) )
2006-04-13 20:47:06 +00:00
{
if ( pus )
2006-11-15 01:16:55 +00:00
{
displayfragbar ( ) ;
}
2006-04-13 20:47:06 +00:00
else
{
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 06:46:31 +00:00
if ( g_player [ i ] . ps - > frag ! = sbar . frag [ i ] )
2006-11-15 01:16:55 +00:00
{
displayfragbar ( ) ;
break ;
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
if ( i ! = myconnectindex )
2007-08-27 06:46:31 +00:00
sbar . frag [ i ] = g_player [ i ] . ps - > frag ;
2006-04-13 20:47:06 +00:00
}
if ( ss = = 4 ) //DRAW MINI STATUS BAR:
{
rotatesprite ( sbarx ( 5 ) , sbary ( 200 - 28 ) , sbarsc ( 65536L ) , 0 , HEALTHBOX , 0 , 21 , 10 + 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( p - > inven_icon )
rotatesprite ( sbarx ( 69 ) , sbary ( 200 - 30 ) , sbarsc ( 65536L ) , 0 , INVENTORYBOX , 0 , 21 , 10 + 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-13 23:12:47 +00:00
if ( sprite [ p - > i ] . pal = = 1 & & p - > last_extra < 2 )
2006-04-13 20:47:06 +00:00
digitalnumber ( 20 , 200 - 17 , 1 , - 16 , 10 + 16 ) ;
else digitalnumber ( 20 , 200 - 17 , p - > last_extra , - 16 , 10 + 16 ) ;
rotatesprite ( sbarx ( 37 ) , sbary ( 200 - 28 ) , sbarsc ( 65536L ) , 0 , AMMOBOX , 0 , 21 , 10 + 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-15 01:16:55 +00:00
if ( p - > curr_weapon = = HANDREMOTE_WEAPON ) i = HANDBOMB_WEAPON ;
else i = p - > curr_weapon ;
2006-04-13 20:47:06 +00:00
digitalnumber ( 53 , 200 - 17 , p - > ammo_amount [ i ] , - 16 , 10 + 16 ) ;
2006-11-15 01:16:55 +00:00
o = 158 ;
permbit = 0 ;
2006-04-13 20:47:06 +00:00
if ( p - > inven_icon )
{
2006-11-13 23:12:47 +00:00
switch ( p - > inven_icon )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
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 ;
2006-04-13 20:47:06 +00:00
}
if ( i > = 0 ) rotatesprite ( sbarx ( 231 - o ) , sbary ( 200 - 21 ) , sbarsc ( 65536L ) , 0 , i , 0 , 0 , 10 + 16 + permbit , 0 , 0 , xdim - 1 , ydim - 1 ) ;
minitext ( 292 - 30 - o , 190 , " % " , 6 , 10 + 16 + permbit + 256 ) ;
j = 0x80000000 ;
2006-11-13 23:12:47 +00:00
switch ( p - > inven_icon )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
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 ;
2006-04-13 20:47:06 +00:00
}
2006-04-24 19:04:22 +00:00
invennum ( 284 - 30 - o , 200 - 6 , ( char ) i , 0 , 10 + permbit ) ;
if ( j > 0 ) minitext ( 288 - 30 - o , 180 , " ON " , 0 , 10 + 16 + permbit + 256 ) ;
else if ( ( unsigned long ) j ! = 0x80000000 ) minitext ( 284 - 30 - o , 180 , " OFF " , 2 , 10 + 16 + permbit + 256 ) ;
if ( p - > inven_icon > = 6 ) minitext ( 284 - 35 - o , 180 , " AUTO " , 2 , 10 + 16 + permbit + 256 ) ;
2006-04-13 20:47:06 +00:00
}
return ;
}
//DRAW/UPDATE FULL STATUS BAR:
2006-11-15 01:16:55 +00:00
if ( pus )
{
pus = 0 ;
u = - 1 ;
}
2006-11-13 23:12:47 +00:00
else u = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
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 ;
}
2006-08-10 02:10:24 +00:00
2006-12-17 21:20:35 +00:00
if ( sbar . last_extra ! = p - > last_extra )
{
sbar . last_extra = p - > last_extra ;
u | = 1 ;
}
2006-04-13 20:47:06 +00:00
{
long lAmount = GetGameVar ( " PLR_MORALE " , - 1 , p - > i , snum ) ;
2006-11-13 23:12:47 +00:00
if ( lAmount = = - 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( sbar . shield_amount ! = p - > shield_amount )
{
sbar . shield_amount = p - > shield_amount ;
u | = 2 ;
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-15 01:16:55 +00:00
if ( sbar . shield_amount ! = lAmount )
{
sbar . shield_amount = lAmount ;
u | = 2 ;
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
}
2006-08-10 02:10:24 +00:00
2006-11-15 01:16:55 +00:00
if ( sbar . curr_weapon ! = p - > curr_weapon )
{
sbar . curr_weapon = p - > curr_weapon ;
u | = ( 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 65536L ) ;
}
2006-07-13 03:16:51 +00:00
2006-11-13 23:12:47 +00:00
for ( i = 1 ; i < MAX_WEAPONS ; i + + )
2006-04-13 20:47:06 +00:00
{
if ( sbar . ammo_amount [ i ] ! = p - > ammo_amount [ i ] )
{
sbar . ammo_amount [ i ] = p - > ammo_amount [ i ] ;
2006-11-13 23:12:47 +00:00
if ( i < 9 )
2006-04-13 20:47:06 +00:00
u | = ( ( 2 < < i ) + 1024 ) ;
2006-07-13 03:16:51 +00:00
else u | = 65536L + 1024 ;
2006-04-13 20:47:06 +00:00
}
2006-07-13 03:16:51 +00:00
2006-04-13 20:47:06 +00:00
if ( sbar . gotweapon [ i ] ! = p - > gotweapon [ i ] )
{
sbar . gotweapon [ i ] = p - > gotweapon [ i ] ;
2006-11-14 21:35:50 +00:00
if ( i < 9 )
2006-04-13 20:47:06 +00:00
u | = ( ( 2 < < i ) + 1024 ) ;
2006-07-13 03:16:51 +00:00
else u | = 65536L + 1024 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-15 01:16:55 +00:00
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 ;
}
2006-04-13 20:47:06 +00:00
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
2006-08-10 02:10:24 +00:00
2006-04-13 20:47:06 +00:00
if ( u = = - 1 )
{
patchstatusbar ( 0 , 0 , 320 , 200 ) ;
if ( ud . multimode > 1 & & ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_FRAGBAR ) )
2006-08-10 02:10:24 +00:00
rotatesprite ( sbarx ( 277 + 1 ) , sbary ( SBY + 7 - 1 ) , sbarsc ( 65536L ) , 0 , KILLSICON , 0 , 0 , 10 + 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
}
if ( ud . multimode > 1 & & ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_FRAGBAR ) )
{
if ( u & 32768 )
{
2006-08-10 02:10:24 +00:00
if ( u ! = - 1 ) patchstatusbar ( 276 , SBY + 17 , 299 , SBY + 17 + 10 ) ;
digitalnumber ( 287 , SBY + 17 , max ( p - > frag - p - > fraggedself , 0 ) , - 16 , 10 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
}
else
{
if ( u & 16384 )
{
2006-08-10 02:10:24 +00:00
if ( u ! = - 1 ) patchstatusbar ( 275 , SBY + 18 , 299 , SBY + 18 + 12 ) ;
if ( p - > got_access & 4 ) rotatesprite ( sbarx ( 275 ) , sbary ( SBY + 16 ) , sbarsc ( 65536L ) , 0 , ACCESS_ICON , 0 , 23 , 10 + 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( p - > got_access & 2 ) rotatesprite ( sbarx ( 288 ) , sbary ( SBY + 16 ) , sbarsc ( 65536L ) , 0 , ACCESS_ICON , 0 , 21 , 10 + 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( p - > got_access & 1 ) rotatesprite ( sbarx ( 281 ) , sbary ( SBY + 23 ) , sbarsc ( 65536L ) , 0 , ACCESS_ICON , 0 , 0 , 10 + 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-08-10 02:10:24 +00:00
if ( u & ( 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 65536L ) ) weapon_amounts ( p , 96 , SBY + 16 , u ) ;
2006-04-13 20:47:06 +00:00
if ( u & 1 )
{
2006-08-10 02:10:24 +00:00
if ( u ! = - 1 ) patchstatusbar ( 20 , SBY + 17 , 43 , SBY + 17 + 11 ) ;
2006-04-13 20:47:06 +00:00
if ( sprite [ p - > i ] . pal = = 1 & & p - > last_extra < 2 )
2006-08-10 02:10:24 +00:00
digitalnumber ( 32 , SBY + 17 , 1 , - 16 , 10 + 16 ) ;
else digitalnumber ( 32 , SBY + 17 , p - > last_extra , - 16 , 10 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 2 )
{
long lAmount = GetGameVar ( " PLR_MORALE " , - 1 , p - > i , snum ) ;
2006-08-10 02:10:24 +00:00
if ( u ! = - 1 ) patchstatusbar ( 52 , SBY + 17 , 75 , SBY + 17 + 11 ) ;
2006-11-13 23:12:47 +00:00
if ( lAmount = = - 1 )
2006-08-10 02:10:24 +00:00
digitalnumber ( 64 , SBY + 17 , p - > shield_amount , - 16 , 10 + 16 ) ;
2006-04-13 20:47:06 +00:00
else
2006-08-10 02:10:24 +00:00
digitalnumber ( 64 , SBY + 17 , lAmount , - 16 , 10 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 1024 )
{
2006-08-10 02:10:24 +00:00
if ( u ! = - 1 ) patchstatusbar ( 196 , SBY + 17 , 219 , SBY + 17 + 11 ) ;
2006-04-13 20:47:06 +00:00
if ( p - > curr_weapon ! = KNEE_WEAPON )
{
2006-11-15 01:16:55 +00:00
if ( p - > curr_weapon = = HANDREMOTE_WEAPON ) i = HANDBOMB_WEAPON ;
else i = p - > curr_weapon ;
2006-08-10 02:10:24 +00:00
digitalnumber ( 230 - 22 , SBY + 17 , p - > ammo_amount [ i ] , - 16 , 10 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
}
if ( u & ( 2048 + 4096 + 8192 ) )
{
if ( u ! = - 1 )
{
2006-11-15 01:16:55 +00:00
if ( u & ( 2048 + 4096 ) )
{
patchstatusbar ( 231 , SBY + 13 , 265 , SBY + 13 + 18 ) ;
}
else
{
patchstatusbar ( 250 , SBY + 24 , 261 , SBY + 24 + 6 ) ;
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
if ( p - > inven_icon )
{
2006-11-15 01:16:55 +00:00
o = 0 ;
2007-02-16 00:11:25 +00:00
// permbit = 128;
2006-04-13 20:47:06 +00:00
if ( u & ( 2048 + 4096 ) )
{
2006-11-13 23:12:47 +00:00
switch ( p - > inven_icon )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
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 ;
2006-04-13 20:47:06 +00:00
}
2006-08-10 02:10:24 +00:00
rotatesprite ( sbarx ( 231 - o ) , sbary ( SBY + 13 ) , sbarsc ( 65536L ) , 0 , i , 0 , 0 , 10 + 16 + permbit , 0 , 0 , xdim - 1 , ydim - 1 ) ;
minitext ( 292 - 30 - o , SBY + 24 , " % " , 6 , 10 + 16 + permbit + 256 ) ;
if ( p - > inven_icon > = 6 ) minitext ( 284 - 35 - o , SBY + 14 , " AUTO " , 2 , 10 + 16 + permbit + 256 ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & ( 2048 + 4096 ) )
{
2006-11-13 23:12:47 +00:00
switch ( p - > inven_icon )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 3 :
j = p - > holoduke_on ;
break ;
case 4 :
j = p - > jetpack_on ;
break ;
case 5 :
j = p - > heat_on ;
break ;
default :
j = 0x80000000 ;
2006-04-13 20:47:06 +00:00
}
2006-08-10 02:10:24 +00:00
if ( j > 0 ) minitext ( 288 - 30 - o , SBY + 14 , " ON " , 0 , 10 + 16 + permbit + 256 ) ;
else if ( ( unsigned long ) j ! = 0x80000000 ) minitext ( 284 - 30 - o , SBY + 14 , " OFF " , 2 , 10 + 16 + permbit + 256 ) ;
2006-04-13 20:47:06 +00:00
}
if ( u & 8192 )
{
2006-11-13 23:12:47 +00:00
switch ( p - > inven_icon )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
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 ;
2006-04-13 20:47:06 +00:00
}
2006-08-10 02:10:24 +00:00
invennum ( 284 - 30 - o , SBY + 28 , ( char ) i , 0 , 10 + permbit ) ;
2006-04-13 20:47:06 +00:00
}
}
}
}
# define AVERAGEFRAMES 16
static long frameval [ AVERAGEFRAMES ] , framecnt = 0 ;
2006-12-10 03:15:56 +00:00
static void tics ( void )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
long i = totalclock , j ;
2006-04-13 20:47:06 +00:00
char b [ 10 ] ;
if ( i ! = frameval [ framecnt ] )
{
2006-10-05 07:39:37 +00:00
j = ( timer * AVERAGEFRAMES ) / ( i - frameval [ framecnt ] ) ;
2007-08-27 06:46:31 +00:00
if ( ud . tickrate & & ! ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) )
2006-06-19 19:28:49 +00:00
{
2007-02-23 22:27:22 +00:00
int ii , k = 0 , p = 8 ;
2006-08-21 07:43:45 +00:00
2006-12-23 02:38:47 +00:00
Bsprintf ( b , " %ld " , max ( j , 0 ) ) ;
2007-02-16 00:11:25 +00:00
// minitext(scale(windowx1,320,xdim)+1,scale(windowy1,200,ydim)+1,b,(timer*AVERAGEFRAMES)/(i-frameval[framecnt]) < 40?2:0,26);
ii = scale ( k , ydim , 200 ) + windowy1 ;
2007-02-26 01:46:38 +00:00
2007-02-23 22:27:22 +00:00
if ( j > 9 ) p + = 8 ;
if ( j > 99 ) p + = 8 ;
if ( j > 999 ) p + = 8 ;
if ( xdim < = 640 ) p > > = 1 ;
2007-02-26 01:46:38 +00:00
printext256 ( windowx2 - p + 1 , ii + 2 , 0 , - 1 , b , ! ( xdim > 640 ) ) ;
2007-02-23 22:27:22 +00:00
printext256 ( windowx2 - p , ii + 1 , ( timer * AVERAGEFRAMES ) / ( i - frameval [ framecnt ] ) < 40 ? 248 : 31 , - 1 , b , ! ( xdim > 640 ) ) ;
2006-11-30 04:36:20 +00:00
if ( numplayers > 1 )
if ( ( totalclock - lastpackettime ) > 1 )
{
for ( ii = ( totalclock - lastpackettime ) ; ii > 0 & & ii < ( xdim > > 2 ) ; ii - - )
printext256 ( 4L * ii , scale ( k , ydim , 200 ) , 31 , - 1 , " . " , 0 ) ;
}
2006-06-19 19:28:49 +00:00
}
framerate = j ;
2006-04-13 20:47:06 +00:00
frameval [ framecnt ] = i ;
}
framecnt = ( ( framecnt + 1 ) & ( AVERAGEFRAMES - 1 ) ) ;
}
2006-12-20 03:27:25 +00:00
static void coords ( int snum )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
int y = 8 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_FRAGBAR ) )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
if ( ud . multimode > 4 )
2006-04-13 20:47:06 +00:00
y = 24 ;
2007-04-15 20:04:52 +00:00
else if ( ud . multimode > 1 )
y = 16 ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
sprintf ( tempbuf , " X= %ld " , g_player [ snum ] . ps - > posx ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
sprintf ( tempbuf , " Y= %ld " , g_player [ snum ] . ps - > posy ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 9L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " Z= %ld " , g_player [ snum ] . ps - > posz ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 18L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " A= %d " , g_player [ snum ] . ps - > ang ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 27L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " H= %ld " , g_player [ snum ] . ps - > horiz ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 36L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " ZV= %ld " , g_player [ snum ] . ps - > poszv ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 45L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " OG= %d " , g_player [ snum ] . ps - > on_ground ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 54L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " AM= %d " , g_player [ snum ] . ps - > ammo_amount [ GROW_WEAPON ] ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 63L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " LFW= %d " , g_player [ snum ] . ps - > last_full_weapon ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 72L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " SECTL= %d " , sector [ g_player [ snum ] . ps - > cursectnum ] . lotag ) ;
2006-04-13 20:47:06 +00:00
printext256 ( 250L , y + 81L , 31 , - 1 , tempbuf , 0 ) ;
2006-08-20 22:17:12 +00:00
Bsprintf ( tempbuf , " SEED= %ld " , randomseed ) ;
printext256 ( 250L , y + 90L , 31 , - 1 , tempbuf , 0 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " THOLD= %d " , g_player [ snum ] . ps - > transporter_hold ) ;
2006-08-20 22:17:12 +00:00
printext256 ( 250L , y + 99L + 7 , 31 , - 1 , tempbuf , 0 ) ;
2006-04-13 20:47:06 +00:00
}
2006-12-10 03:15:56 +00:00
static void operatefta ( void )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
long i , j = 200 - 45 , k , l ;
if ( ud . screen_size < 1 ) j = 200 - 8 ;
2006-04-13 20:47:06 +00:00
quotebot = min ( quotebot , j ) ;
quotebotgoal = min ( quotebotgoal , j ) ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE ) j - = 8 ;
2006-11-15 01:16:55 +00:00
quotebotgoal = j ;
j = quotebot ;
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < MAXUSERQUOTES ; i + + )
2006-04-13 20:47:06 +00:00
{
2007-01-22 02:35:54 +00:00
if ( user_quote_time [ i ] < = 0 ) break ;
2006-11-15 01:16:55 +00:00
k = user_quote_time [ i ] ;
2006-04-22 07:00:31 +00:00
l = Bstrlen ( user_quote [ i ] ) ;
2006-11-13 23:12:47 +00:00
while ( l > TEXTWRAPLEN )
2006-04-22 00:17:55 +00:00
{
l - = TEXTWRAPLEN ;
j - = 8 ;
}
2006-04-13 20:47:06 +00:00
if ( k > 4 )
2006-04-22 22:33:52 +00:00
mpgametext ( j , user_quote [ i ] , 0 , 2 + 8 + 16 ) ;
else if ( k > 2 ) mpgametext ( j , user_quote [ i ] , 0 , 2 + 8 + 16 + 1 ) ;
else mpgametext ( j , user_quote [ i ] , 0 , 2 + 8 + 16 + 1 + 32 ) ;
2006-04-22 00:17:55 +00:00
j - = 8 ;
2006-04-13 20:47:06 +00:00
}
2006-04-22 02:33:36 +00:00
if ( ( klabs ( quotebotgoal - quotebot ) < = 16 ) & & ( ud . screen_size < = 8 ) )
quotebot + = ksgn ( quotebotgoal - quotebot ) ;
else
quotebot = quotebotgoal ;
2007-08-27 06:46:31 +00:00
if ( g_player [ screenpeek ] . ps - > fta < = 1 ) return ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( fta_quotes [ g_player [ screenpeek ] . ps - > ftq ] = = NULL )
2006-12-23 02:38:47 +00:00
{
2007-08-27 06:46:31 +00:00
OSD_Printf ( " %s %d null quote %d \n " , __FILE__ , __LINE__ , g_player [ screenpeek ] . ps - > ftq ) ;
2006-12-23 02:38:47 +00:00
return ;
}
k = 0 ;
2006-08-20 22:17:12 +00:00
if ( GTFLAGS ( GAMETYPE_FLAG_FRAGBAR ) & & ud . screen_size > 0 & & ud . multimode > 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
j = 0 ;
k = 8 ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
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 ;
}
2007-08-27 06:46:31 +00:00
if ( g_player [ screenpeek ] . ps - > ftq = = 115 | | g_player [ screenpeek ] . ps - > ftq = = 116 | | g_player [ screenpeek ] . ps - > ftq = = 117 )
2006-04-13 20:47:06 +00:00
{
2006-12-23 02:38:47 +00:00
k = quotebot - 8 - 4 ;
2006-05-04 03:14:49 +00:00
/* for(i=0;i<MAXUSERQUOTES;i++)
{
if ( user_quote_time [ i ] < = 0 ) break ;
k - = 8 ;
l = Bstrlen ( user_quote [ i ] ) ;
while ( l > TEXTWRAPLEN )
{
l - = TEXTWRAPLEN ;
k - = 8 ;
}
2006-12-23 02:38:47 +00:00
}
k - = 4 ; */
2006-04-24 00:49:44 +00:00
}
2007-08-27 06:46:31 +00:00
j = g_player [ screenpeek ] . ps - > fta ;
2006-04-13 20:47:06 +00:00
if ( j > 4 )
2007-08-27 06:46:31 +00:00
gametext ( 320 > > 1 , k , fta_quotes [ g_player [ screenpeek ] . ps - > ftq ] , 0 , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
else
2007-08-27 06:46:31 +00:00
if ( j > 2 ) gametext ( 320 > > 1 , k , fta_quotes [ g_player [ screenpeek ] . ps - > ftq ] , 0 , 2 + 8 + 16 + 1 ) ;
2006-04-13 20:47:06 +00:00
else
2007-08-27 06:46:31 +00:00
gametext ( 320 > > 1 , k , fta_quotes [ g_player [ screenpeek ] . ps - > ftq ] , 0 , 2 + 8 + 16 + 1 + 32 ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 00:20:15 +00:00
void FTA ( int q , player_struct * p )
2006-04-13 20:47:06 +00:00
{
2006-12-23 02:38:47 +00:00
if ( fta_quotes [ p - > ftq ] = = NULL )
2006-04-13 20:47:06 +00:00
{
2006-12-23 02:38:47 +00:00
OSD_Printf ( " %s %d null quote %d \n " , __FILE__ , __LINE__ , p - > ftq ) ;
return ;
}
2006-04-13 20:47:06 +00:00
2006-12-23 02:38:47 +00:00
if ( ud . fta_on = = 0 )
return ;
2007-01-22 02:35:54 +00:00
2006-12-23 02:38:47 +00:00
if ( p - > fta > 0 & & q ! = 115 & & q ! = 116 )
if ( p - > ftq = = 115 | | p - > ftq = = 116 ) return ;
2006-04-13 20:47:06 +00:00
2006-12-23 02:38:47 +00:00
p - > fta = 100 ;
2006-12-09 23:41:43 +00:00
2006-12-23 02:38:47 +00:00
// if(p->ftq != q || q == 26)
// || q == 26 || q == 115 || q ==116 || q == 117 || q == 122)
{
if ( p - > ftq ! = q )
2007-08-27 06:46:31 +00:00
if ( p = = g_player [ screenpeek ] . ps )
2006-12-23 02:38:47 +00:00
OSD_Printf ( " %s \n " , stripcolorcodes ( fta_quotes [ q ] ) ) ;
p - > ftq = q ;
pub = NUMPAGES ;
pus = NUMPAGES ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
}
2006-12-10 06:49:01 +00:00
void fadepal ( int r , int g , int b , int start , int end , int step )
{
if ( getrendermode ( ) > = 3 ) return ;
if ( step > 0 ) for ( ; start < end ; start + = step ) palto ( r , g , b , start ) ;
else for ( ; start > = end ; start + = step ) palto ( r , g , b , start ) ;
}
2006-12-10 03:15:56 +00:00
static void showtwoscreens ( void )
2006-04-13 20:47:06 +00:00
{
2007-08-25 01:05:00 +00:00
int flags = GetGameVar ( " LOGO_FLAGS " , 255 , - 1 , - 1 ) ;
MUSIC_StopSong ( ) ;
2007-08-25 22:02:40 +00:00
FX_StopAllSounds ( ) ;
2007-08-25 01:05:00 +00:00
if ( ! VOLUMEALL | | flags & LOGO_FLAG_SHAREWARESCREENS )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
flushperms ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 1 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
fadepal ( 0 , 0 , 0 , 0 , 64 , 7 ) ;
KB_FlushKeyboardQueue ( ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , 3291 , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-15 01:16:55 +00:00
IFISSOFTMODE fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
else nextpage ( ) ;
while ( ! KB_KeyWaiting ( ) )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
fadepal ( 0 , 0 , 0 , 0 , 64 , 7 ) ;
KB_FlushKeyboardQueue ( ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , 3290 , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-15 01:16:55 +00:00
IFISSOFTMODE fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
else nextpage ( ) ;
while ( ! KB_KeyWaiting ( ) )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
}
2007-08-25 01:05:00 +00:00
if ( flags & LOGO_FLAG_TENSCREEN )
{
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
flushperms ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 1 ) ; // JBF 20040308
2007-08-25 01:05:00 +00:00
fadepal ( 0 , 0 , 0 , 0 , 64 , 7 ) ;
KB_FlushKeyboardQueue ( ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , TENSCREEN , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
IFISSOFTMODE fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
else nextpage ( ) ;
while ( ! KB_KeyWaiting ( ) & & totalclock < 2400 )
{
handleevents ( ) ;
getpackets ( ) ;
}
}
2006-04-13 20:47:06 +00:00
}
extern long qsetmode ;
2006-12-23 02:38:47 +00:00
void gameexit ( const char * t )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( * t ! = 0 ) g_player [ myconnectindex ] . ps - > palette = ( char * ) & palette [ 0 ] ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( numplayers > 1 )
2006-04-13 20:47:06 +00:00
allowtimetocorrecterrorswhenquitting ( ) ;
2006-12-14 03:34:55 +00:00
uninitmultiplayers ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ud . recstat = = 1 ) closedemowrite ( ) ;
2006-11-15 01:16:55 +00:00
else if ( ud . recstat = = 2 )
{
if ( frecfilep ) fclose ( frecfilep ) ;
} // JBF: fixes crash on demo playback
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ! qe & & ! cp )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( playerswhenstarted > 1 & & g_player [ myconnectindex ] . ps - > gm & MODE_GAME & & GTFLAGS ( GAMETYPE_FLAG_SCORESHEET ) & & * t = = ' ' )
2006-04-20 22:18:56 +00:00
{
dobonus ( 1 ) ;
2007-08-27 00:20:15 +00:00
setgamemode ( ud . config . ScreenMode , ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP ) ;
2006-04-20 22:18:56 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( * t ! = 0 & & * ( t + 1 ) ! = ' V ' & & * ( t + 1 ) ! = ' Y ' )
2006-04-20 22:18:56 +00:00
showtwoscreens ( ) ;
}
2006-04-13 20:47:06 +00:00
if ( qsetmode = = 200 )
Shutdown ( ) ;
2006-11-13 23:12:47 +00:00
if ( * t ! = 0 )
2006-04-13 20:47:06 +00:00
{
//setvmode(0x3); // JBF
//binscreen();
// 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");
2006-11-15 01:16:55 +00:00
if ( ! ( t [ 0 ] = = ' ' & & t [ 1 ] = = 0 ) )
{
2006-12-23 02:38:47 +00:00
wm_msgbox ( HEAD2 , ( char * ) t ) ;
2006-04-13 20:47:06 +00:00
}
}
uninitgroupfile ( ) ;
//unlink("duke3d.tmp");
exit ( 0 ) ;
}
2006-05-05 07:10:36 +00:00
char inputloc = 0 ;
2006-04-22 00:17:55 +00:00
2007-02-28 09:12:41 +00:00
static int strget_ ( int small , int x , int y , char * t , int dalen , int c )
2006-04-13 20:47:06 +00:00
{
short ch ;
2006-04-22 00:17:55 +00:00
int i ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
while ( ( ch = KB_Getch ( ) ) ! = 0 | | ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU & & MOUSE_GetButtons ( ) & RIGHT_MOUSE ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( ch = = asc_BackSpace )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( inputloc > 0 )
2006-04-13 20:47:06 +00:00
{
inputloc - - ;
* ( t + inputloc ) = 0 ;
}
}
else
{
2006-11-13 23:12:47 +00:00
if ( ch = = asc_Enter )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_Enter ) ;
KB_ClearKeyDown ( sc_kpad_Enter ) ;
return ( 1 ) ;
}
2007-08-27 06:46:31 +00:00
else if ( ch = = asc_Escape | | ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU & & MOUSE_GetButtons ( ) & RIGHT_MOUSE ) )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_Escape ) ;
2006-12-12 05:59:47 +00:00
MOUSE_ClearButton ( RIGHT_MOUSE ) ;
2006-04-13 20:47:06 +00:00
return ( - 1 ) ;
}
2006-11-14 21:35:50 +00:00
else if ( ch > = 32 & & inputloc < dalen & & ch < 127 )
2006-04-13 20:47:06 +00:00
{
ch = Btoupper ( ch ) ;
2006-11-15 01:16:55 +00:00
if ( c ! = 997 | | ( ch > = ' 0 ' & & ch < = ' 9 ' ) )
2007-08-25 01:05:00 +00:00
{
// JBF 20040508: so we can have numeric only if we want
2006-04-13 20:47:06 +00:00
* ( t + inputloc ) = ch ;
* ( t + inputloc + 1 ) = 0 ;
inputloc + + ;
}
}
}
}
2006-11-14 21:35:50 +00:00
if ( c = = 999 ) return ( 0 ) ;
if ( c = = 998 )
2006-04-13 20:47:06 +00:00
{
2006-04-21 05:11:57 +00:00
char b [ 91 ] , ii ;
2006-11-13 23:12:47 +00:00
for ( ii = 0 ; ii < inputloc ; ii + + )
2006-11-19 08:24:46 +00:00
b [ ( unsigned char ) ii ] = ' * ' ;
b [ ( unsigned char ) ii ] = 0 ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE )
2006-04-22 22:33:52 +00:00
x = mpgametext ( y , b , c , 2 + 8 + 16 ) ;
2006-04-21 05:11:57 +00:00
else x = gametext ( x , y , b , c , 2 + 8 + 16 ) ;
}
2006-04-22 07:00:31 +00:00
else
2006-04-21 05:11:57 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE )
2006-04-22 22:33:52 +00:00
x = mpgametext ( y , t , c , 2 + 8 + 16 ) ;
2006-04-21 05:11:57 +00:00
else x = gametext ( x , y , t , c , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
c = 4 - ( sintable [ ( totalclock < < 4 ) & 2047 ] > > 11 ) ;
2006-04-22 00:17:55 +00:00
2006-04-22 07:00:31 +00:00
i = Bstrlen ( t ) ;
2006-11-13 23:12:47 +00:00
while ( i > TEXTWRAPLEN - ! small )
2006-04-22 00:17:55 +00:00
{
2006-04-22 02:33:36 +00:00
i - = TEXTWRAPLEN - ! small ;
2006-04-22 00:17:55 +00:00
y + = 8 ;
}
2007-08-27 00:20:15 +00:00
rotatesprite ( ( x + ( small ? 4 : 8 ) ) < < 16 , ( ( y + ( small ? 0 : 4 ) ) < < 16 ) + ( small ? ud . config . ScreenHeight < < 15 : 0 ) , 32768 , 0 , SPINNINGNUKEICON + ( ( totalclock > > 3 ) % 7 ) , c , 0 , small ? ( 8 | 16 ) : 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
return ( 0 ) ;
}
2007-02-28 09:12:41 +00:00
inline int strget ( int x , int y , char * t , int dalen , int c )
2006-04-22 00:17:55 +00:00
{
return ( strget_ ( 0 , x , y , t , dalen , c ) ) ;
}
2007-02-28 09:12:41 +00:00
inline int strgetsm ( int x , int y , char * t , int dalen , int c )
2006-04-22 00:17:55 +00:00
{
return ( strget_ ( 1 , x , y , t , dalen , c ) ) ;
}
2007-02-28 09:12:41 +00:00
inline int mpstrget ( int x , int y , char * t , int dalen , int c )
2006-04-22 00:17:55 +00:00
{
2006-11-13 23:12:47 +00:00
if ( xdim > = 640 & & ydim > = 480 )
2006-04-22 00:17:55 +00:00
return ( strgetsm ( x , y , t , dalen , c ) ) ;
2006-12-15 01:09:25 +00:00
return ( strget ( x , y , t , dalen , c ) ) ;
2006-04-22 00:17:55 +00:00
}
2006-12-10 03:15:56 +00:00
static void typemode ( void )
2006-04-13 20:47:06 +00:00
{
2006-04-22 00:17:55 +00:00
short ch , hitstate , i , j , l ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_SENDTOWHOM )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sendmessagecommand ! = - 1 | | ud . multimode < 3 | | movesperpacket = = 4 )
2006-04-13 20:47:06 +00:00
{
tempbuf [ 0 ] = 4 ;
tempbuf [ 2 ] = 0 ;
recbuf [ 0 ] = 0 ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 3 )
2006-04-13 20:47:06 +00:00
sendmessagecommand = 2 ;
2006-11-13 23:12:47 +00:00
if ( typebuf [ 0 ] = = ' / ' & & Btoupper ( typebuf [ 1 ] ) = = ' M ' & & Btoupper ( typebuf [ 2 ] ) = = ' E ' )
2006-06-07 01:29:17 +00:00
{
2006-07-21 22:25:05 +00:00
Bstrcat ( recbuf , " * " ) ;
2006-06-07 01:29:17 +00:00
i = 3 , j = Bstrlen ( typebuf ) ;
Bstrcpy ( tempbuf , typebuf ) ;
2006-11-13 23:12:47 +00:00
while ( i < j )
2006-06-07 01:29:17 +00:00
{
typebuf [ i - 3 ] = tempbuf [ i ] ;
i + + ;
}
typebuf [ i - 3 ] = ' \0 ' ;
2007-08-27 06:46:31 +00:00
Bstrcat ( recbuf , g_player [ myconnectindex ] . user_name ) ;
2006-06-07 01:29:17 +00:00
}
else
{
2007-08-27 00:20:15 +00:00
Bstrcat ( recbuf , g_player [ myconnectindex ] . user_name ) ;
2006-07-21 22:25:05 +00:00
Bstrcat ( recbuf , " : " ) ;
2006-06-07 01:29:17 +00:00
}
2006-08-15 17:15:23 +00:00
Bstrcat ( recbuf , " ^00 " ) ;
2006-07-21 22:25:05 +00:00
Bstrcat ( recbuf , typebuf ) ;
j = Bstrlen ( recbuf ) ;
2006-04-13 20:47:06 +00:00
recbuf [ j ] = 0 ;
2006-07-21 22:25:05 +00:00
Bstrcat ( tempbuf + 2 , recbuf ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( sendmessagecommand > = ud . multimode | | movesperpacket = = 4 )
2006-04-13 20:47:06 +00:00
{
tempbuf [ 1 ] = 255 ;
2006-11-13 23:12:47 +00:00
for ( ch = connecthead ; ch > = 0 ; ch = connectpoint2 [ ch ] )
2006-04-13 20:47:06 +00:00
{
if ( ch ! = myconnectindex ) sendpacket ( ch , tempbuf , j + 2 ) ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
adduserquote ( recbuf ) ;
2006-04-22 02:33:36 +00:00
quotebot + = 8 ;
2006-04-22 07:00:31 +00:00
l = Bstrlen ( recbuf ) ;
2006-11-13 23:12:47 +00:00
while ( l > TEXTWRAPLEN )
2006-04-22 00:17:55 +00:00
{
l - = TEXTWRAPLEN ;
quotebot + = 8 ;
}
2006-04-13 20:47:06 +00:00
quotebotgoal = quotebot ;
}
2006-11-13 23:12:47 +00:00
else if ( sendmessagecommand > = 0 )
2006-04-13 20:47:06 +00:00
{
tempbuf [ 1 ] = ( char ) sendmessagecommand ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) )
sendmessagecommand = connecthead ;
sendpacket ( sendmessagecommand , tempbuf , j + 2 ) ;
}
sendmessagecommand = - 1 ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm & = ~ ( MODE_TYPE | MODE_SENDTOWHOM ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
else if ( sendmessagecommand = = - 1 )
2006-04-13 20:47:06 +00:00
{
j = 50 ;
2006-11-15 01:16:55 +00:00
gametext ( 320 > > 1 , j , " SEND MESSAGE TO... " , 0 , 2 + 8 + 16 ) ;
j + = 8 ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
{
if ( i = = myconnectindex )
{
minitextshade ( ( 320 > > 1 ) - 40 + 1 , j + 1 , " A/ENTER - ALL " , 26 , 0 , 2 + 8 + 16 ) ;
2006-11-15 01:16:55 +00:00
minitext ( ( 320 > > 1 ) - 40 , j , " A/ENTER - ALL " , 0 , 2 + 8 + 16 ) ;
j + = 7 ;
2006-04-13 20:47:06 +00:00
}
else
{
2007-08-27 00:20:15 +00:00
Bsprintf ( buf , " %d - %s " , i + 1 , g_player [ i ] . user_name ) ;
2006-04-13 20:47:06 +00:00
minitextshade ( ( 320 > > 1 ) - 40 - 6 + 1 , j + 1 , buf , 26 , 0 , 2 + 8 + 16 ) ;
2006-11-15 01:16:55 +00:00
minitext ( ( 320 > > 1 ) - 40 - 6 , j , buf , 0 , 2 + 8 + 16 ) ;
j + = 7 ;
2006-04-13 20:47:06 +00:00
}
}
minitextshade ( ( 320 > > 1 ) - 40 - 4 + 1 , j + 1 , " ESC - Abort " , 26 , 0 , 2 + 8 + 16 ) ;
2006-11-15 01:16:55 +00:00
minitext ( ( 320 > > 1 ) - 40 - 4 , j , " ESC - Abort " , 0 , 2 + 8 + 16 ) ;
j + = 7 ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
if ( ud . screen_size > 0 ) j = 200 - 45 ;
else j = 200 - 8 ;
2006-04-22 22:33:52 +00:00
mpgametext ( j , typebuf , 0 , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( KB_KeyWaiting ( ) )
2006-04-13 20:47:06 +00:00
{
i = KB_GetCh ( ) ;
2006-11-13 23:12:47 +00:00
if ( i = = ' A ' | | i = = ' a ' | | i = = 13 )
2006-04-13 20:47:06 +00:00
sendmessagecommand = ud . multimode ;
2006-11-14 21:35:50 +00:00
else if ( i > = ' 1 ' | | i < = ( ud . multimode + ' 1 ' ) )
2006-04-13 20:47:06 +00:00
sendmessagecommand = i - ' 1 ' ;
else
{
sendmessagecommand = ud . multimode ;
2006-11-13 23:12:47 +00:00
if ( i = = 27 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm & = ~ ( MODE_TYPE | MODE_SENDTOWHOM ) ;
2006-04-13 20:47:06 +00:00
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
{
2006-11-15 01:16:55 +00:00
if ( ud . screen_size > 0 ) j = 200 - 45 ;
else j = 200 - 8 ;
2006-04-22 00:17:55 +00:00
hitstate = mpstrget ( 320 > > 1 , j , typebuf , 120 , 1 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( hitstate = = 1 )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_Enter ) ;
2006-11-13 23:12:47 +00:00
if ( ud . automsg )
2006-05-05 01:20:19 +00:00
{
2006-11-13 23:12:47 +00:00
if ( SHIFTS_IS_PRESSED ) sendmessagecommand = - 1 ;
2006-05-05 01:20:19 +00:00
else sendmessagecommand = ud . multimode ;
}
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_SENDTOWHOM ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
else if ( hitstate = = - 1 )
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm & = ~ ( MODE_TYPE | MODE_SENDTOWHOM ) ;
2006-04-13 20:47:06 +00:00
else pub = NUMPAGES ;
}
}
2006-12-10 03:15:56 +00:00
static void moveclouds ( void )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( totalclock > cloudtotalclock | | totalclock < ( cloudtotalclock - 7 ) )
2006-04-13 20:47:06 +00:00
{
2007-01-16 03:19:04 +00:00
int i ;
2006-04-13 20:47:06 +00:00
cloudtotalclock = totalclock + 6 ;
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < numclouds ; i + + )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
cloudx [ i ] + = ( sintable [ ( g_player [ screenpeek ] . ps - > ang + 512 ) & 2047 ] > > 9 ) ;
cloudy [ i ] + = ( sintable [ g_player [ screenpeek ] . ps - > ang & 2047 ] > > 9 ) ;
2006-04-13 20:47:06 +00:00
sector [ clouds [ i ] ] . ceilingxpanning = cloudx [ i ] > > 6 ;
sector [ clouds [ i ] ] . ceilingypanning = cloudy [ i ] > > 6 ;
}
}
}
2006-12-10 03:15:56 +00:00
static void drawoverheadmap ( long cposx , long cposy , long czoom , short cang )
2006-04-13 20:47:06 +00:00
{
long i , j , k , l , x1 , y1 , x2 = 0 , y2 = 0 , x3 , y3 , x4 , y4 , ox , oy , xoff , yoff ;
long dax , day , cosang , sinang , xspan , yspan , sprx , spry ;
long xrepeat , yrepeat , z1 , z2 , startwall , endwall , tilenum , daang ;
long xvect , yvect , xvect2 , yvect2 ;
short p ;
char col ;
walltype * wal , * wal2 ;
spritetype * spr ;
xvect = sintable [ ( - cang ) & 2047 ] * czoom ;
yvect = sintable [ ( 1536 - cang ) & 2047 ] * czoom ;
xvect2 = mulscale16 ( xvect , yxaspect ) ;
yvect2 = mulscale16 ( yvect , yxaspect ) ;
//Draw red lines
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-04-13 20:47:06 +00:00
{
if ( ! ( show2dsector [ i > > 3 ] & ( 1 < < ( i & 7 ) ) ) ) continue ;
startwall = sector [ i ] . wallptr ;
endwall = sector [ i ] . wallptr + sector [ i ] . wallnum ;
2006-11-15 01:16:55 +00:00
z1 = sector [ i ] . ceilingz ;
z2 = sector [ i ] . floorz ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( j = startwall , wal = & wall [ startwall ] ; j < endwall ; j + + , wal + + )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
k = wal - > nextwall ;
if ( k < 0 ) continue ;
2006-04-13 20:47:06 +00:00
//if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue;
//if ((k > j) && ((show2dwall[k>>3]&(1<<(k&7))) > 0)) continue;
if ( sector [ wal - > nextsector ] . ceilingz = = z1 )
if ( sector [ wal - > nextsector ] . floorz = = z2 )
if ( ( ( wal - > cstat | wall [ wal - > nextwall ] . cstat ) & ( 16 + 32 ) ) = = 0 ) continue ;
col = 139 ; //red
if ( ( wal - > cstat | wall [ wal - > nextwall ] . cstat ) & 1 ) col = 234 ; //magenta
if ( ! ( show2dsector [ wal - > nextsector > > 3 ] & ( 1 < < ( wal - > nextsector & 7 ) ) ) )
col = 24 ;
else continue ;
2006-11-15 01:16:55 +00:00
ox = wal - > x - cposx ;
oy = wal - > y - cposy ;
2006-04-13 20:47:06 +00:00
x1 = dmulscale16 ( ox , xvect , - oy , yvect ) + ( xdim < < 11 ) ;
y1 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) + ( ydim < < 11 ) ;
wal2 = & wall [ wal - > point2 ] ;
2006-11-15 01:16:55 +00:00
ox = wal2 - > x - cposx ;
oy = wal2 - > y - cposy ;
2006-04-13 20:47:06 +00:00
x2 = dmulscale16 ( ox , xvect , - oy , yvect ) + ( xdim < < 11 ) ;
y2 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) + ( ydim < < 11 ) ;
drawline256 ( x1 , y1 , x2 , y2 , col ) ;
}
}
//Draw sprites
2007-08-27 06:46:31 +00:00
k = g_player [ screenpeek ] . ps - > i ;
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-04-13 20:47:06 +00:00
{
if ( ! ( show2dsector [ i > > 3 ] & ( 1 < < ( i & 7 ) ) ) ) continue ;
2006-11-13 23:12:47 +00:00
for ( j = headspritesect [ i ] ; j > = 0 ; j = nextspritesect [ j ] )
2006-04-13 20:47:06 +00:00
//if ((show2dsprite[j>>3]&(1<<(j&7))) > 0)
{
spr = & sprite [ j ] ;
if ( j = = k | | ( spr - > cstat & 0x8000 ) | | spr - > cstat = = 257 | | spr - > xrepeat = = 0 ) continue ;
col = 71 ; //cyan
if ( spr - > cstat & 1 ) col = 234 ; //magenta
sprx = spr - > x ;
spry = spr - > y ;
2006-11-14 21:35:50 +00:00
if ( ( spr - > cstat & 257 ) ! = 0 ) switch ( spr - > cstat & 48 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
ox = sprx - cposx ;
oy = spry - cposy ;
x1 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y1 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) ;
ox = ( sintable [ ( spr - > ang + 512 ) & 2047 ] > > 7 ) ;
oy = ( sintable [ ( spr - > ang ) & 2047 ] > > 7 ) ;
x2 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y2 = dmulscale16 ( oy , xvect , ox , yvect ) ;
x3 = mulscale16 ( x2 , yxaspect ) ;
y3 = mulscale16 ( y2 , yxaspect ) ;
drawline256 ( x1 - x2 + ( xdim < < 11 ) , y1 - y3 + ( ydim < < 11 ) ,
x1 + x2 + ( xdim < < 11 ) , y1 + y3 + ( ydim < < 11 ) , col ) ;
drawline256 ( x1 - y2 + ( xdim < < 11 ) , y1 + x3 + ( ydim < < 11 ) ,
x1 + x2 + ( xdim < < 11 ) , y1 + y3 + ( ydim < < 11 ) , col ) ;
drawline256 ( x1 + y2 + ( xdim < < 11 ) , y1 - x3 + ( ydim < < 11 ) ,
x1 + x2 + ( xdim < < 11 ) , y1 + y3 + ( ydim < < 11 ) , col ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 16 :
if ( spr - > picnum = = LASERLINE )
{
x1 = sprx ;
y1 = spry ;
2006-11-15 01:16:55 +00:00
tilenum = spr - > picnum ;
xoff = ( long ) ( ( signed char ) ( ( picanm [ tilenum ] > > 8 ) & 255 ) ) + ( ( long ) spr - > xoffset ) ;
if ( ( spr - > cstat & 4 ) > 0 ) xoff = - xoff ;
k = spr - > ang ;
2006-11-16 03:02:42 +00:00
l = spr - > xrepeat ;
dax = sintable [ k & 2047 ] * l ;
day = sintable [ ( k + 1536 ) & 2047 ] * l ;
l = tilesizx [ tilenum ] ;
k = ( l > > 1 ) + xoff ;
x1 - = mulscale16 ( dax , k ) ;
x2 = x1 + mulscale16 ( dax , l ) ;
y1 - = mulscale16 ( day , k ) ;
y2 = y1 + mulscale16 ( day , l ) ;
2006-11-15 01:16:55 +00:00
ox = x1 - cposx ;
oy = y1 - cposy ;
2006-04-13 20:47:06 +00:00
x1 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y1 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) ;
2006-11-15 01:16:55 +00:00
ox = x2 - cposx ;
oy = y2 - cposy ;
2006-04-13 20:47:06 +00:00
x2 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y2 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) ;
2006-11-15 01:16:55 +00:00
drawline256 ( x1 + ( xdim < < 11 ) , y1 + ( ydim < < 11 ) ,
x2 + ( xdim < < 11 ) , y2 + ( ydim < < 11 ) , col ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 32 :
tilenum = spr - > picnum ;
xoff = ( long ) ( ( signed char ) ( ( picanm [ tilenum ] > > 8 ) & 255 ) ) + ( ( long ) spr - > xoffset ) ;
yoff = ( long ) ( ( signed char ) ( ( picanm [ tilenum ] > > 16 ) & 255 ) ) + ( ( long ) spr - > yoffset ) ;
if ( ( spr - > cstat & 4 ) > 0 ) xoff = - xoff ;
if ( ( spr - > cstat & 8 ) > 0 ) yoff = - yoff ;
k = spr - > ang ;
cosang = sintable [ ( k + 512 ) & 2047 ] ;
sinang = sintable [ k ] ;
xspan = tilesizx [ tilenum ] ;
xrepeat = spr - > xrepeat ;
yspan = tilesizy [ tilenum ] ;
yrepeat = spr - > yrepeat ;
dax = ( ( xspan > > 1 ) + xoff ) * xrepeat ;
day = ( ( yspan > > 1 ) + yoff ) * yrepeat ;
x1 = sprx + dmulscale16 ( sinang , dax , cosang , day ) ;
y1 = spry + dmulscale16 ( sinang , day , - cosang , dax ) ;
l = xspan * xrepeat ;
x2 = x1 - mulscale16 ( sinang , l ) ;
y2 = y1 + mulscale16 ( cosang , l ) ;
l = yspan * yrepeat ;
k = - mulscale16 ( cosang , l ) ;
x3 = x2 + k ;
x4 = x1 + k ;
k = - mulscale16 ( sinang , l ) ;
y3 = y2 + k ;
y4 = y1 + k ;
ox = x1 - cposx ;
oy = y1 - cposy ;
x1 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y1 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) ;
ox = x2 - cposx ;
oy = y2 - cposy ;
x2 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y2 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) ;
ox = x3 - cposx ;
oy = y3 - cposy ;
x3 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y3 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) ;
ox = x4 - cposx ;
oy = y4 - cposy ;
x4 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y4 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) ;
drawline256 ( x1 + ( xdim < < 11 ) , y1 + ( ydim < < 11 ) ,
x2 + ( xdim < < 11 ) , y2 + ( ydim < < 11 ) , col ) ;
drawline256 ( x2 + ( xdim < < 11 ) , y2 + ( ydim < < 11 ) ,
x3 + ( xdim < < 11 ) , y3 + ( ydim < < 11 ) , col ) ;
drawline256 ( x3 + ( xdim < < 11 ) , y3 + ( ydim < < 11 ) ,
x4 + ( xdim < < 11 ) , y4 + ( ydim < < 11 ) , col ) ;
drawline256 ( x4 + ( xdim < < 11 ) , y4 + ( ydim < < 11 ) ,
x1 + ( xdim < < 11 ) , y1 + ( ydim < < 11 ) , col ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
}
//Draw white lines
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-04-13 20:47:06 +00:00
{
if ( ! ( show2dsector [ i > > 3 ] & ( 1 < < ( i & 7 ) ) ) ) continue ;
startwall = sector [ i ] . wallptr ;
endwall = sector [ i ] . wallptr + sector [ i ] . wallnum ;
k = - 1 ;
2006-11-13 23:12:47 +00:00
for ( j = startwall , wal = & wall [ startwall ] ; j < endwall ; j + + , wal + + )
2006-04-13 20:47:06 +00:00
{
if ( wal - > nextwall > = 0 ) continue ;
//if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue;
if ( tilesizx [ wal - > picnum ] = = 0 ) continue ;
if ( tilesizy [ wal - > picnum ] = = 0 ) continue ;
if ( j = = k )
2006-11-15 01:16:55 +00:00
{
x1 = x2 ;
y1 = y2 ;
}
2006-04-13 20:47:06 +00:00
else
{
2006-11-15 01:16:55 +00:00
ox = wal - > x - cposx ;
oy = wal - > y - cposy ;
2006-04-13 20:47:06 +00:00
x1 = dmulscale16 ( ox , xvect , - oy , yvect ) + ( xdim < < 11 ) ;
y1 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) + ( ydim < < 11 ) ;
}
2006-11-15 01:16:55 +00:00
k = wal - > point2 ;
wal2 = & wall [ k ] ;
ox = wal2 - > x - cposx ;
oy = wal2 - > y - cposy ;
2006-04-13 20:47:06 +00:00
x2 = dmulscale16 ( ox , xvect , - oy , yvect ) + ( xdim < < 11 ) ;
y2 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) + ( ydim < < 11 ) ;
drawline256 ( x1 , y1 , x2 , y2 , 24 ) ;
}
}
2006-11-13 23:12:47 +00:00
for ( p = connecthead ; p > = 0 ; p = connectpoint2 [ p ] )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( ud . scrollmode & & p = = screenpeek ) continue ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
ox = sprite [ g_player [ p ] . ps - > i ] . x - cposx ;
oy = sprite [ g_player [ p ] . ps - > i ] . y - cposy ;
daang = ( sprite [ g_player [ p ] . ps - > i ] . ang - cang ) & 2047 ;
2006-11-15 01:16:55 +00:00
if ( p = = screenpeek )
{
ox = 0 ;
oy = 0 ;
daang = 0 ;
}
2006-04-13 20:47:06 +00:00
x1 = mulscale ( ox , xvect , 16 ) - mulscale ( oy , yvect , 16 ) ;
y1 = mulscale ( oy , xvect2 , 16 ) + mulscale ( ox , yvect2 , 16 ) ;
2006-11-14 21:35:50 +00:00
if ( p = = screenpeek | | GTFLAGS ( GAMETYPE_FLAG_OTHERPLAYERSINMAP ) )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( sprite [ g_player [ p ] . ps - > i ] . xvel > 16 & & g_player [ p ] . ps - > on_ground )
2006-04-13 20:47:06 +00:00
i = APLAYERTOP + ( ( totalclock > > 4 ) & 3 ) ;
else
i = APLAYERTOP ;
2007-08-27 06:46:31 +00:00
j = klabs ( g_player [ p ] . ps - > truefz - g_player [ p ] . ps - > posz ) > > 8 ;
j = mulscale ( czoom * ( sprite [ g_player [ p ] . ps - > i ] . yrepeat + j ) , yxaspect , 16 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( j < 22000 ) j = 22000 ;
else if ( j > ( 65536 < < 1 ) ) j = ( 65536 < < 1 ) ;
2006-04-13 20:47:06 +00:00
rotatesprite ( ( x1 < < 4 ) + ( xdim < < 15 ) , ( y1 < < 4 ) + ( ydim < < 15 ) , j ,
2007-08-27 06:46:31 +00:00
daang , i , sprite [ g_player [ p ] . ps - > i ] . shade , /*sprite[g_player[p].ps->i].pal*/ sector [ g_player [ p ] . ps - > cursectnum ] . floorpal ,
( sprite [ g_player [ p ] . ps - > i ] . cstat & 2 ) > > 1 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2007-02-28 09:12:41 +00:00
void palto ( int r , int g , int b , long e )
2006-04-16 03:42:36 +00:00
{
long tc ;
/*
for ( i = 0 ; i < 768 ; i + = 3 )
{
temparray [ i ] =
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > palette [ i + 0 ] + ( ( ( ( long ) r - ( long ) g_player [ myconnectindex ] . ps - > palette [ i + 0 ] ) * ( long ) ( e & 127 ) ) > > 6 ) ;
2006-04-16 03:42:36 +00:00
temparray [ i + 1 ] =
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > palette [ i + 1 ] + ( ( ( ( long ) g - ( long ) g_player [ myconnectindex ] . ps - > palette [ i + 1 ] ) * ( long ) ( e & 127 ) ) > > 6 ) ;
2006-04-16 03:42:36 +00:00
temparray [ i + 2 ] =
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > palette [ i + 2 ] + ( ( ( ( long ) b - ( long ) g_player [ myconnectindex ] . ps - > palette [ i + 2 ] ) * ( long ) ( e & 127 ) ) > > 6 ) ;
2006-04-16 03:42:36 +00:00
}
*/
//setbrightness(ud.brightness>>2,temparray);
setpalettefade ( r , g , b , e & 127 ) ;
if ( getrendermode ( ) > = 3 ) pus = pub = NUMPAGES ; // JBF 20040110: redraw the status bar next time
2006-11-15 01:16:55 +00:00
if ( ( e & 128 ) = = 0 )
{
2006-04-16 03:42:36 +00:00
nextpage ( ) ;
2006-11-14 21:35:50 +00:00
for ( tc = totalclock ; totalclock < tc + 4 ; handleevents ( ) , getpackets ( ) ) ;
2006-04-16 03:42:36 +00:00
}
}
2006-04-13 20:47:06 +00:00
void displayrest ( long smoothratio )
{
long a , i , j ;
char fader = 0 , fadeg = 0 , fadeb = 0 , fadef = 0 , tintr = 0 , tintg = 0 , tintb = 0 , tintf = 0 , dotint = 0 ;
2007-08-27 06:46:31 +00:00
player_struct * pp = g_player [ screenpeek ] . ps ;
2006-04-13 20:47:06 +00:00
walltype * wal ;
long cposx , cposy , cang ;
2006-12-05 20:39:29 +00:00
# if defined(USE_OPENGL) && defined(POLYMOST)
2006-04-13 20:47:06 +00:00
// this takes care of fullscreen tint for OpenGL
2006-11-15 01:16:55 +00:00
if ( getrendermode ( ) > = 3 )
{
2006-12-05 20:39:29 +00:00
#if 0
2006-04-13 20:47:06 +00:00
if ( pp - > palette = = waterpal ) tintr = 0 , tintg = 0 , tintb = 63 , tintf = 8 ;
2006-11-22 01:25:35 +00:00
else if ( pp - > palette = = slimepal ) tintr = 20 , tintg = 63 , tintb = 20 , tintf = 8 ;
2006-12-05 20:39:29 +00:00
# else
2006-12-06 06:27:07 +00:00
if ( pp - > palette = = waterpal )
{
if ( hictinting [ MAXPALOOKUPS - 2 ] . r = = 255 & & hictinting [ MAXPALOOKUPS - 2 ] . g = = 255 & & hictinting [ MAXPALOOKUPS - 2 ] . b = = 255 )
{
hictinting [ MAXPALOOKUPS - 1 ] . r = 192 ;
hictinting [ MAXPALOOKUPS - 1 ] . g = 192 ;
hictinting [ MAXPALOOKUPS - 1 ] . b = 255 ;
}
else Bmemcpy ( & hictinting [ MAXPALOOKUPS - 1 ] , & hictinting [ MAXPALOOKUPS - 2 ] , sizeof ( hictinting [ 0 ] ) ) ;
}
else if ( pp - > palette = = slimepal )
{
if ( hictinting [ MAXPALOOKUPS - 3 ] . r = = 255 & & hictinting [ MAXPALOOKUPS - 3 ] . g = = 255 & & hictinting [ MAXPALOOKUPS - 3 ] . b = = 255 )
{
hictinting [ MAXPALOOKUPS - 1 ] . r = 208 ;
hictinting [ MAXPALOOKUPS - 1 ] . g = 255 ;
hictinting [ MAXPALOOKUPS - 1 ] . b = 192 ;
}
else Bmemcpy ( & hictinting [ MAXPALOOKUPS - 1 ] , & hictinting [ MAXPALOOKUPS - 3 ] , sizeof ( hictinting [ 0 ] ) ) ;
}
else
{
hictinting [ MAXPALOOKUPS - 1 ] . r = 255 ;
hictinting [ MAXPALOOKUPS - 1 ] . g = 255 ;
hictinting [ MAXPALOOKUPS - 1 ] . b = 255 ;
}
2006-12-05 20:39:29 +00:00
# endif
2006-04-13 20:47:06 +00:00
}
2006-12-05 20:39:29 +00:00
# endif
2006-04-13 20:47:06 +00:00
// this does pain tinting etc from the CON
2006-11-14 21:35:50 +00:00
if ( pp - > pals_time > = 0 & & pp - > loogcnt = = 0 ) // JBF 20040101: pals_time > 0 now >= 0
2006-04-13 20:47:06 +00:00
{
fader = pp - > pals [ 0 ] ;
fadeg = pp - > pals [ 1 ] ;
fadeb = pp - > pals [ 2 ] ;
fadef = pp - > pals_time ;
restorepalette = 1 ; // JBF 20040101
dotint = 1 ;
}
// reset a normal palette
2007-02-11 22:05:50 +00:00
else if ( restorepalette )
2006-04-13 20:47:06 +00:00
{
//setbrightness(ud.brightness>>2,&pp->palette[0],0);
2006-12-12 09:28:37 +00:00
setgamepalette ( pp , pp - > palette , 2 ) ;
2006-04-13 20:47:06 +00:00
restorepalette = 0 ;
}
// loogies courtesy of being snotted on
2007-02-11 22:05:50 +00:00
else if ( pp - > loogcnt > 0 )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
//palto(0,64,0,(pp->loogcnt>>1)+128);
fader = 0 ;
fadeg = 64 ;
fadeb = 0 ;
fadef = pp - > loogcnt > > 1 ;
dotint = 1 ;
}
2006-11-15 01:16:55 +00:00
if ( fadef > tintf )
{
2006-04-13 20:47:06 +00:00
tintr = fader ;
tintg = fadeg ;
tintb = fadeb ;
tintf = fadef ;
}
2006-11-13 23:12:47 +00:00
if ( ud . show_help )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
switch ( ud . show_help )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
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 ;
2006-04-13 20:47:06 +00:00
}
2006-12-12 04:31:51 +00:00
if ( KB_KeyPressed ( sc_Escape ) | | MOUSE_GetButtons ( ) & RIGHT_MOUSE )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_Escape ) ;
2006-12-12 04:31:51 +00:00
MOUSE_ClearButton ( RIGHT_MOUSE ) ;
2006-04-13 20:47:06 +00:00
ud . show_help = 0 ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 & & ud . recstat ! = 2 )
2006-04-13 20:47:06 +00:00
{
ready2send = 1 ;
totalclock = ototalclock ;
}
vscrn ( ) ;
}
if ( tintf > 0 | | dotint ) palto ( tintr , tintg , tintb , tintf | 128 ) ;
return ;
}
i = pp - > cursectnum ;
show2dsector [ i > > 3 ] | = ( 1 < < ( i & 7 ) ) ;
wal = & wall [ sector [ i ] . wallptr ] ;
2006-11-13 23:12:47 +00:00
for ( j = sector [ i ] . wallnum ; j > 0 ; j - - , wal + + )
2006-04-13 20:47:06 +00:00
{
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 ) ) ;
}
2006-11-13 23:12:47 +00:00
if ( ud . camerasprite = = - 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ud . overhead_on ! = 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( pp - > newowner > = 0 )
2006-04-13 20:47:06 +00:00
cameratext ( pp - > newowner ) ;
else
{
displayweapon ( screenpeek ) ;
2006-11-14 21:35:50 +00:00
if ( pp - > over_shoulder_on = = 0 )
2006-04-13 20:47:06 +00:00
displaymasks ( screenpeek ) ;
}
moveclouds ( ) ;
}
2006-11-14 21:35:50 +00:00
if ( ud . overhead_on > 0 )
2006-04-13 20:47:06 +00:00
{
smoothratio = min ( max ( smoothratio , 0 ) , 65536 ) ;
dointerpolations ( smoothratio ) ;
2006-11-14 21:35:50 +00:00
if ( ud . scrollmode = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( pp - > newowner = = - 1 & & ! ud . pause_on )
2006-04-13 20:47:06 +00:00
{
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
{
2006-11-13 23:12:47 +00:00
if ( ! ud . pause_on )
2006-04-19 23:48:43 +00:00
{
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 ;
}
2006-04-13 20:47:06 +00:00
cposx = ud . folx ;
cposy = ud . foly ;
cang = ud . fola ;
}
2006-11-13 23:12:47 +00:00
if ( ud . overhead_on = = 2 )
2006-04-13 20:47:06 +00:00
{
clearview ( 0L ) ;
drawmapview ( cposx , cposy , pp - > zoom , cang ) ;
}
2006-11-14 21:35:50 +00:00
drawoverheadmap ( cposx , cposy , pp - > zoom , cang ) ;
2006-04-13 20:47:06 +00:00
restoreinterpolations ( ) ;
2006-11-13 23:12:47 +00:00
if ( ud . overhead_on = = 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( ud . screen_size > 0 ) a = 147 ;
2006-04-13 20:47:06 +00:00
else a = 182 ;
minitext ( 1 , a + 6 , volume_names [ ud . volume_number ] , 0 , 2 + 8 + 16 ) ;
2007-08-26 11:28:32 +00:00
minitext ( 1 , a + 12 , map [ ud . volume_number * MAXLEVELS + ud . level_number ] . name , 0 , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2007-02-13 02:22:17 +00:00
if ( pp - > invdisptime > 0 ) displayinventory ( pp ) ;
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 0 , g_player [ screenpeek ] . ps - > i , screenpeek ) ;
OnEvent ( EVENT_DISPLAYSBAR , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ screenpeek ] . ps - > i , screenpeek ) = = 0 )
2007-02-13 02:22:17 +00:00
coolgaugetext ( screenpeek ) ;
2007-02-13 02:56:10 +00:00
2006-04-13 20:47:06 +00:00
operatefta ( ) ;
2006-11-14 21:35:50 +00:00
if ( KB_KeyPressed ( sc_Escape ) & & ud . overhead_on = = 0
2006-04-13 20:47:06 +00:00
& & ud . show_help = = 0
2007-08-27 06:46:31 +00:00
& & g_player [ myconnectindex ] . ps - > newowner = = - 1 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = MODE_MENU & & current_menu < 51 )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_Escape ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm & = ~ MODE_MENU ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 & & ud . recstat ! = 2 )
2006-04-13 20:47:06 +00:00
{
ready2send = 1 ;
totalclock = ototalclock ;
cameraclock = totalclock ;
cameradist = 65536L ;
}
walock [ TILE_SAVESHOT ] = 199 ;
vscrn ( ) ;
}
2007-08-27 06:46:31 +00:00
else if ( ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) ! = MODE_MENU & &
g_player [ myconnectindex ] . ps - > newowner = = - 1 & &
( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE ) ! = MODE_TYPE )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_Escape ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
intomenusounds ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 & & ud . recstat ! = 2 ) ready2send = 0 ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) cmenu ( 50 ) ;
2006-04-13 20:47:06 +00:00
else cmenu ( 0 ) ;
screenpeek = myconnectindex ;
}
}
2007-08-27 06:46:31 +00:00
OnEvent ( EVENT_DISPLAYREST , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > newowner = = - 1 & & ud . overhead_on = = 0 & & ud . crosshair & & ud . camerasprite = = - 1 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 0 , g_player [ screenpeek ] . ps - > i , screenpeek ) ;
OnEvent ( EVENT_DISPLAYCROSSHAIR , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ screenpeek ] . ps - > i , screenpeek ) = = 0 )
rotatesprite ( ( 160L - ( g_player [ myconnectindex ] . ps - > look_ang > > 1 ) ) < < 16 , 100L < < 16 , ud . crosshair > 1 ? 65536L > > ( ud . crosshair - 1 ) : 65536L , 0 , CROSSHAIR , 0 , 0 , 2 + 1 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
2006-05-06 05:28:28 +00:00
}
2006-08-20 22:17:12 +00:00
#if 0
2006-11-13 23:12:47 +00:00
if ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_TDM )
2006-08-20 22:17:12 +00:00
{
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
2006-08-20 22:17:12 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ i ] . ps - > team = = g_player [ myconnectindex ] . ps - > team )
2006-08-20 22:17:12 +00:00
{
2007-08-27 06:46:31 +00:00
j = min ( max ( ( getincangle ( getangle ( g_player [ i ] . ps - > posx - g_player [ myconnectindex ] . ps - > posx , g_player [ i ] . ps - > posy - g_player [ myconnectindex ] . ps - > posy ) , g_player [ myconnectindex ] . ps - > ang ) ) > > 1 , - 160 ) , 160 ) ;
2006-08-20 22:17:12 +00:00
rotatesprite ( ( 160 - j ) < < 16 , 100L < < 16 , 65536L , 0 , DUKEICON , 0 , 0 , 2 + 1 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
}
}
}
# endif
2006-12-09 23:41:43 +00:00
2007-08-27 06:46:31 +00:00
if ( ud . pause_on = = 1 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = 0 )
2006-12-09 23:41:43 +00:00
menutext ( 160 , 100 , 0 , 0 , " GAME PAUSED " ) ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE )
2006-04-13 20:47:06 +00:00
typemode ( ) ;
else
menus ( ) ;
2006-11-13 23:12:47 +00:00
if ( ud . coords )
2006-04-13 20:47:06 +00:00
coords ( screenpeek ) ;
2006-06-19 19:28:49 +00:00
2006-12-01 22:34:32 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-20 04:55:37 +00:00
{
2007-03-07 20:18:48 +00:00
extern int mdpause ;
2007-03-11 00:47:32 +00:00
2007-03-04 19:52:57 +00:00
mdpause = 0 ;
2007-08-27 06:46:31 +00:00
if ( ud . pause_on | | ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU & & numplayers < 2 ) )
2007-03-04 19:52:57 +00:00
mdpause = 1 ;
2006-11-20 04:55:37 +00:00
}
2006-12-01 22:34:32 +00:00
# endif
2006-11-15 01:16:55 +00:00
2006-06-19 19:28:49 +00:00
tics ( ) ;
2006-04-13 20:47:06 +00:00
// JBF 20040124: display level stats in screen corner
2007-08-27 06:46:31 +00:00
if ( ud . levelstats & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = 0 )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
i = ( ud . screen_size < = 4 ) ? 0 : scale ( tilesizy [ BOTTOMSTATUSBAR ] , ud . statusbarscale , 100 ) ;
Bsprintf ( tempbuf , " Time: %ld:%02ld " ,
2007-08-27 06:46:31 +00:00
( g_player [ myconnectindex ] . ps - > player_par / ( 26 * 60 ) ) ,
( g_player [ myconnectindex ] . ps - > player_par / 26 ) % 60 ) ;
2006-04-13 20:47:06 +00:00
minitext ( 320 - 5 * 12 , 200 - i - 6 - 6 - 6 , tempbuf , 0 , 26 ) ;
2006-11-13 23:12:47 +00:00
if ( ud . player_skill > 3 | | ( ud . multimode > 1 & & ! GTFLAGS ( GAMETYPE_FLAG_PLAYERSFRIENDLY ) ) )
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " Kills: %ld " , ( ud . multimode > 1 & & ! GTFLAGS ( GAMETYPE_FLAG_PLAYERSFRIENDLY ) ) ? g_player [ i ] . ps - > frag - g_player [ i ] . ps - > fraggedself : g_player [ myconnectindex ] . ps - > actors_killed ) ;
2006-04-13 20:47:06 +00:00
else
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " Kills: %ld/%ld " , g_player [ myconnectindex ] . ps - > actors_killed ,
g_player [ myconnectindex ] . ps - > max_actors_killed > g_player [ myconnectindex ] . ps - > actors_killed ?
g_player [ myconnectindex ] . ps - > max_actors_killed : g_player [ myconnectindex ] . ps - > actors_killed ) ;
2006-04-13 20:47:06 +00:00
minitext ( 320 - 5 * 12 , 200 - i - 6 - 6 , tempbuf , 0 , 26 ) ;
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " Secrets: %ld/%ld " , g_player [ myconnectindex ] . ps - > secret_rooms , g_player [ myconnectindex ] . ps - > max_secret_rooms ) ;
2006-04-13 20:47:06 +00:00
minitext ( 320 - 5 * 12 , 200 - i - 6 , tempbuf , 0 , 26 ) ;
}
if ( tintf > 0 | | dotint ) palto ( tintr , tintg , tintb , tintf | 128 ) ;
}
2007-08-27 00:20:15 +00:00
static void view ( player_struct * pp , long * vx , long * vy , long * vz , short * vsectnum , int ang , int horiz )
2006-04-13 20:47:06 +00:00
{
2006-12-23 02:38:47 +00:00
spritetype * sp = & sprite [ pp - > i ] ;
long i , hx , hy , hitx , hity , hitz ;
long nx = ( sintable [ ( ang + 1536 ) & 2047 ] > > 4 ) ;
long ny = ( sintable [ ( ang + 1024 ) & 2047 ] > > 4 ) ;
long nz = ( horiz - 100 ) * 128 ;
short hitsect , hitwall , hitsprite , daang ;
short bakcstat = sp - > cstat ;
2006-04-13 20:47:06 +00:00
sp - > cstat & = ( short ) ~ 0x101 ;
updatesectorz ( * vx , * vy , * vz , vsectnum ) ;
hitscan ( * vx , * vy , * vz , * vsectnum , nx , ny , nz , & hitsect , & hitwall , & hitsprite , & hitx , & hity , & hitz , CLIPMASK1 ) ;
2006-11-13 23:12:47 +00:00
if ( * vsectnum < 0 )
2006-04-13 20:47:06 +00:00
{
sp - > cstat = bakcstat ;
return ;
}
2006-11-15 01:16:55 +00:00
hx = hitx - ( * vx ) ;
hy = hity - ( * vy ) ;
2006-04-13 20:47:06 +00:00
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 , rx ;
flushperms ( ) ;
2006-11-13 23:12:47 +00:00
switch ( ud . m_volume_number )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
default :
dapicnum = BIGHOLE ;
break ;
case 1 :
dapicnum = BIGHOLE ;
break ;
case 2 :
dapicnum = BIGHOLE ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
if ( tilesizx [ dapicnum ] = = 0 | | tilesizy [ dapicnum ] = = 0 )
{
2006-04-13 20:47:06 +00:00
pus = pub = NUMPAGES ;
return ;
}
2006-11-15 01:16:55 +00:00
y1 = 0 ;
y2 = ydim ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME | | ud . recstat = = 2 )
2006-04-13 20:47:06 +00:00
//if (ud.recstat == 0 || ud.recstat == 1 || (ud.recstat == 2 && ud.reccnt > 0)) // JBF 20040717
{
2007-02-16 06:59:05 +00:00
if ( ud . screen_size = = 8 & & ud . statusbarmode = = 0 )
2006-04-13 20:47:06 +00:00
y1 = scale ( ydim , 200 - scale ( tilesizy [ BOTTOMSTATUSBAR ] , ud . statusbarscale , 100 ) , 200 ) ;
2006-11-13 23:12:47 +00:00
else if ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_FRAGBAR )
2006-04-13 20:47:06 +00:00
{
if ( ud . multimode > 1 ) y1 + = scale ( ydim , 8 , 200 ) ;
if ( ud . multimode > 4 ) y1 + = scale ( ydim , 8 , 200 ) ;
}
2007-01-16 03:19:04 +00:00
}
else
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
// when not rendering a game, fullscreen wipe
2006-11-13 23:12:47 +00:00
# define MENUTILE bpp==8?MENUSCREEN:LOADSCREEN
2006-04-20 19:21:40 +00:00
SetGameVarID ( g_iReturnVarID , tilesizx [ MENUTILE ] = = 320 & & tilesizy [ MENUTILE ] = = 200 ? MENUTILE : BIGHOLE , - 1 , - 1 ) ;
2006-11-06 22:14:27 +00:00
OnEvent ( EVENT_GETMENUTILE , - 1 , myconnectindex , - 1 ) ;
2006-04-20 19:21:40 +00:00
if ( GetGameVar ( " MENU_TILE " , tilesizx [ MENUTILE ] = = 320 & & tilesizy [ MENUTILE ] = = 200 ? 0 : 1 , - 1 , - 1 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
for ( y = y1 ; y < y2 ; y + = tilesizy [ GetGameVarID ( g_iReturnVarID , - 1 , - 1 ) ] )
for ( x = 0 ; x < xdim ; x + = tilesizx [ GetGameVarID ( g_iReturnVarID , - 1 , - 1 ) ] )
2006-04-20 09:03:44 +00:00
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , GetGameVarID ( g_iReturnVarID , - 1 , - 1 ) , bpp = = 8 ? 16 : 8 , 0 , 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
}
2006-04-20 19:21:40 +00:00
else rotatesprite ( 320 < < 15 , 200 < < 15 , 65536L , 0 , GetGameVarID ( g_iReturnVarID , - 1 , - 1 ) , bpp = = 8 ? 16 : 8 , 0 , 2 + 8 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
return ;
}
y2 = scale ( ydim , 200 - scale ( tilesizy [ BOTTOMSTATUSBAR ] , ud . statusbarscale , 100 ) , 200 ) ;
2006-11-15 01:16:55 +00:00
if ( ud . screen_size > 8 )
{
2006-04-13 20:47:06 +00:00
// across top
for ( y = 0 ; y < windowy1 ; y + = tilesizy [ dapicnum ] )
for ( x = 0 ; x < xdim ; x + = tilesizx [ dapicnum ] )
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 + 128 , 0 , y1 , xdim - 1 , windowy1 - 1 ) ;
// sides
rx = windowx2 - windowx2 % tilesizx [ dapicnum ] ;
for ( y = windowy1 - windowy1 % tilesizy [ dapicnum ] ; y < windowy2 ; y + = tilesizy [ dapicnum ] )
2006-11-15 01:16:55 +00:00
for ( x = 0 ; x < windowx1 | | x + rx < xdim ; x + = tilesizx [ dapicnum ] )
{
2006-04-13 20:47:06 +00:00
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 + 128 , 0 , windowy1 , windowx1 - 1 , windowy2 - 1 ) ;
rotatesprite ( ( x + rx ) < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 + 128 , windowx2 , windowy1 , xdim - 1 , windowy2 - 1 ) ;
}
// along bottom
for ( y = windowy2 - ( windowy2 % tilesizy [ dapicnum ] ) ; y < y2 ; y + = tilesizy [ dapicnum ] )
for ( x = 0 ; x < xdim ; x + = tilesizx [ dapicnum ] )
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 + 128 , 0 , windowy2 , xdim - 1 , y2 - 1 ) ;
}
// draw in the bits to the left and right of the non-fullsize status bar
2007-02-16 06:59:05 +00:00
if ( ud . statusbarscale < 100 & & ud . screen_size > = 8 & & ud . statusbarmode = = 0 )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
y1 = y2 ;
x2 = ( xdim - scale ( xdim , ud . statusbarscale , 100 ) ) > > 1 ;
2006-11-15 01:16:55 +00:00
x1 = xdim - x2 ;
x1 - = x1 % tilesizx [ dapicnum ] ;
2006-11-13 23:12:47 +00:00
for ( y = y1 - y1 % tilesizy [ dapicnum ] ; y < y2 ; y + = tilesizy [ dapicnum ] )
2006-11-15 01:16:55 +00:00
for ( x = 0 ; x < x2 | | x1 + x < xdim ; x + = tilesizx [ dapicnum ] )
{
2006-04-13 20:47:06 +00:00
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 + 128 , 0 , y1 , x2 - 1 , ydim - 1 ) ;
rotatesprite ( ( x + x1 ) < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 + 128 , xdim - x2 , y1 , xdim - 1 , ydim - 1 ) ;
}
}
2007-02-16 00:11:25 +00:00
if ( ud . screen_size > 8 )
2006-04-13 20:47:06 +00:00
{
y = 0 ;
2006-11-13 23:12:47 +00:00
if ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_FRAGBAR )
2006-04-13 20:47:06 +00:00
{
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 - scale ( tilesizy [ BOTTOMSTATUSBAR ] , ud . statusbarscale , 100 ) , 200 ) - 1 ) ;
2006-11-13 23:12:47 +00:00
for ( y = y1 + 4 ; y < y2 - 4 ; y + = 64 )
2006-04-13 20:47:06 +00:00
{
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 ) ;
}
2006-11-13 23:12:47 +00:00
for ( x = x1 + 4 ; x < x2 - 4 ; x + = 64 )
2006-04-13 20:47:06 +00:00
{
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 ) ;
}
pus = pub = NUMPAGES ;
}
# define SE40
# ifdef SE40
// Floor Over Floor
// If standing in sector with SE42 or SE44
// then draw viewing to SE41 and raise all =hi SE43 cielings.
// If standing in sector with SE43 or SE45
// then draw viewing to SE40 and lower all =hi SE42 floors.
2007-02-28 09:12:41 +00:00
static void SE40_Draw ( int spnum , long x , long y , long z , int a , int h , long smoothratio )
2006-04-13 20:47:06 +00:00
{
static long tempsectorz [ MAXSECTORS ] ;
static long tempsectorpicnum [ MAXSECTORS ] ;
int i = 0 , j = 0 , k = 0 ;
int floor1 = 0 , floor2 = 0 , ok = 0 , fofmode = 0 , draw_both = 0 ;
long offx , offy , offz ;
2006-11-13 23:12:47 +00:00
if ( sprite [ spnum ] . ang ! = 512 ) return ;
2006-04-13 20:47:06 +00:00
// Things are a little different now, as we allow for masked transparent
// floors and ceilings. So the FOF textures is no longer required
// Additionally names.h also defines FOF as 13 which isn't useful for us
// so we'll use 562 instead
tilesizx [ 562 ] = 0 ;
tilesizy [ 562 ] = 0 ;
floor1 = spnum ;
2006-11-13 23:12:47 +00:00
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 ;
2006-04-13 20:47:06 +00:00
// fofmode=sprite[spnum].lotag-2;
// sectnum=sprite[j].sectnum;
// sectnum=cursectnum;
ok + + ;
/* recursive? - Not at the moment
for ( j = 0 ; j < MAXSPRITES ; j + + )
{
if (
sprite [ j ] . sectnum = = sectnum & &
sprite [ j ] . picnum = = 1 & &
sprite [ j ] . lotag = = 110
2006-11-14 21:35:50 +00:00
) { DrawFloorOverFloor ( j ) ; break ; }
2006-04-13 20:47:06 +00:00
}
*/
// if(ok==0) { Message("no fof",RED); return; }
2006-11-13 23:12:47 +00:00
for ( j = headspritestat [ 15 ] ; j > = 0 ; j = nextspritestat [ j ] )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ j ] . picnum = = 1 & & sprite [ j ] . lotag = = fofmode & & sprite [ j ] . hitag = = sprite [ floor1 ] . hitag )
2006-04-13 20:47:06 +00:00
{
floor1 = j ;
fofmode = sprite [ j ] . lotag ;
ok + + ;
break ;
}
}
// if(ok==1) { Message("no floor1",RED); return; }
2006-11-15 01:16:55 +00:00
if ( fofmode = = 40 ) k = 41 ;
else k = 40 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( j = headspritestat [ 15 ] ; j > = 0 ; j = nextspritestat [ j ] )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ j ] . picnum = = 1 & & sprite [ j ] . lotag = = k & & sprite [ j ] . hitag = = sprite [ floor1 ] . hitag )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
floor2 = j ;
ok + + ;
break ;
2006-04-13 20:47:06 +00:00
}
}
i = floor1 ;
offx = sprite [ floor2 ] . x - sprite [ floor1 ] . x ;
offy = sprite [ floor2 ] . y - sprite [ floor1 ] . y ;
offz = 0 ;
if ( sprite [ floor2 ] . ang > = 1024 )
offz = sprite [ floor2 ] . z ;
else if ( fofmode = = 41 )
offz = sector [ sprite [ floor2 ] . sectnum ] . floorz ;
else
offz = sector [ sprite [ floor2 ] . sectnum ] . ceilingz ;
if ( sprite [ floor1 ] . ang > = 1024 )
offz - = sprite [ floor1 ] . z ;
else if ( fofmode = = 40 )
offz - = sector [ sprite [ floor1 ] . sectnum ] . floorz ;
else
offz - = sector [ sprite [ floor1 ] . sectnum ] . ceilingz ;
// if(ok==2) { Message("no floor2",RED); return; }
2006-11-13 23:12:47 +00:00
for ( j = headspritestat [ 15 ] ; j > = 0 ; j = nextspritestat [ j ] ) // raise ceiling or floor
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ j ] . picnum = = 1 & & sprite [ j ] . lotag = = k + 2 & & sprite [ j ] . hitag = = sprite [ floor1 ] . hitag )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( k = = 40 )
2006-04-13 20:47:06 +00:00
{
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 = 562 ;
}
else
{
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 = 562 ;
}
draw_both = 1 ;
}
}
drawrooms ( x + offx , y + offy , z + offz , a , h , sprite [ floor2 ] . sectnum ) ;
animatesprites ( x , y , a , smoothratio ) ;
drawmasks ( ) ;
if ( draw_both )
{
2006-11-13 23:12:47 +00:00
for ( j = headspritestat [ 15 ] ; j > = 0 ; j = nextspritestat [ j ] ) // restore ceiling or floor for the draw both sectors
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ j ] . picnum = = 1 & &
2006-04-13 20:47:06 +00:00
sprite [ j ] . lotag = = k + 2 & &
sprite [ j ] . hitag = = sprite [ floor1 ] . hitag )
{
2006-11-13 23:12:47 +00:00
if ( k = = 40 )
2006-04-13 20:47:06 +00:00
{
sector [ sprite [ j ] . sectnum ] . floorz = tempsectorz [ sprite [ j ] . sectnum ] ;
sector [ sprite [ j ] . sectnum ] . floorpicnum = tempsectorpicnum [ sprite [ j ] . sectnum ] ;
}
else
{
sector [ sprite [ j ] . sectnum ] . ceilingz = tempsectorz [ sprite [ j ] . sectnum ] ;
sector [ sprite [ j ] . sectnum ] . ceilingpicnum = tempsectorpicnum [ sprite [ j ] . sectnum ] ;
}
} // end if
} // end for
// Now re-draw
drawrooms ( x + offx , y + offy , z + offz , a , h , sprite [ floor2 ] . sectnum ) ;
animatesprites ( x , y , a , smoothratio ) ;
drawmasks ( ) ;
}
} // end SE40
2007-03-13 18:37:46 +00:00
void se40code ( long x , long y , long z , long a , long h , long smoothratio )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
int i = headspritestat [ 15 ] ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
int t = sprite [ i ] . lotag ;
2006-11-13 23:12:47 +00:00
switch ( t )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
// case 40:
// case 41:
// SE40_Draw(i,x,y,a,smoothratio);
// break;
case 42 :
case 43 :
case 44 :
case 45 :
2007-08-27 06:46:31 +00:00
if ( g_player [ screenpeek ] . ps - > cursectnum = = sprite [ i ] . sectnum )
2006-11-16 03:02:42 +00:00
SE40_Draw ( i , x , y , z , a , h , smoothratio ) ;
break ;
2006-04-13 20:47:06 +00:00
}
i = nextspritestat [ i ] ;
}
}
# endif
static long oyrepeat = - 1 ;
2006-12-20 03:27:25 +00:00
void displayrooms ( int snum , long smoothratio )
2006-04-13 20:47:06 +00:00
{
2007-02-12 07:58:03 +00:00
long dst , j , fz , cz ;
2007-01-22 02:35:54 +00:00
long tposx , tposy , i ;
2007-02-12 07:58:03 +00:00
short k ;
2007-08-27 06:46:31 +00:00
player_struct * p = g_player [ snum ] . ps ;
2006-04-13 20:47:06 +00:00
short tang ;
long tiltcx , tiltcy , tiltcs = 0 ; // JBF 20030807
2006-10-29 20:18:04 +00:00
# ifdef POLYMOST
2006-10-20 01:17:32 +00:00
extern long rendmode ;
2006-10-29 20:18:04 +00:00
# endif
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( pub > 0 | | getrendermode ( ) > = 3 ) // JBF 20040101: redraw background always
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( ud . screen_size > 8 | | ( ud . screen_size = = 8 & & ud . statusbarscale < 100 ) ) drawbackground ( ) ;
2006-04-13 20:47:06 +00:00
pub = 0 ;
}
2006-10-29 20:18:04 +00:00
# ifdef POLYMOST
2006-11-14 21:35:50 +00:00
if ( ud . overhead_on = = 2 | | ud . show_help | | ( p - > cursectnum = = - 1 & & rendmode ! = 4 ) )
2006-10-29 20:18:04 +00:00
# else
2006-11-14 21:35:50 +00:00
if ( ud . overhead_on = = 2 | | ud . show_help | | p - > cursectnum = = - 1 )
2006-10-29 20:18:04 +00:00
# endif
2006-04-13 20:47:06 +00:00
return ;
smoothratio = min ( max ( smoothratio , 0 ) , 65536 ) ;
visibility = p - > visibility ;
2007-08-27 06:46:31 +00:00
if ( ud . pause_on | | g_player [ snum ] . ps - > on_crane > - 1 ) smoothratio = 65536 ;
2006-04-13 20:47:06 +00:00
2007-02-12 21:17:52 +00:00
ud . camerasect = p - > cursectnum ;
2006-10-29 20:18:04 +00:00
# ifdef POLYMOST
2006-11-13 23:12:47 +00:00
if ( rendmode ! = 4 )
2006-10-29 20:18:04 +00:00
# endif
2007-02-12 21:17:52 +00:00
if ( ud . camerasect < 0 | | ud . camerasect > = MAXSECTORS ) return ;
2006-04-13 20:47:06 +00:00
dointerpolations ( smoothratio ) ;
animatecamsprite ( ) ;
2006-11-13 23:12:47 +00:00
if ( ud . camerasprite > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-12-21 09:33:26 +00:00
spritetype * s = & sprite [ ud . camerasprite ] ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( s - > yvel < 0 ) s - > yvel = - 100 ;
else if ( s - > yvel > 199 ) s - > yvel = 300 ;
2006-04-13 20:47:06 +00:00
2007-02-12 21:17:52 +00:00
ud . cameraang = hittype [ ud . camerasprite ] . tempang + mulscale16 ( ( long ) ( ( ( s - > ang + 1024 - hittype [ ud . camerasprite ] . tempang ) & 2047 ) - 1024 ) , smoothratio ) ;
2006-04-13 20:47:06 +00:00
# ifdef SE40
2007-02-12 21:17:52 +00:00
se40code ( s - > x , s - > y , s - > z , ud . cameraang , s - > yvel , smoothratio ) ;
2006-04-13 20:47:06 +00:00
# endif
2007-02-12 21:17:52 +00:00
drawrooms ( s - > x , s - > y , s - > z - ( 4 < < 8 ) , ud . cameraang , s - > yvel , s - > sectnum ) ;
animatesprites ( s - > x , s - > y , ud . cameraang , smoothratio ) ;
2006-04-13 20:47:06 +00:00
drawmasks ( ) ;
}
else
{
i = divscale22 ( 1 , sprite [ p - > i ] . yrepeat + 28 ) ;
if ( i ! = oyrepeat )
{
oyrepeat = i ;
setaspect ( oyrepeat , yxaspect ) ;
}
2006-11-13 23:12:47 +00:00
if ( screencapt )
2006-04-13 20:47:06 +00:00
{
walock [ TILE_SAVESHOT ] = 199 ;
if ( waloff [ TILE_SAVESHOT ] = = 0 )
allocache ( ( long * ) & waloff [ TILE_SAVESHOT ] , 200 * 320 , & walock [ TILE_SAVESHOT ] ) ;
setviewtotile ( TILE_SAVESHOT , 200L , 320L ) ;
}
2006-11-14 21:35:50 +00:00
else if ( getrendermode ( ) = = 0 & & ( ( ud . screen_tilting & & p - > rotscrnang ) | | ud . detail = = 0 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( ud . screen_tilting ) tang = p - > rotscrnang ;
else tang = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
if ( xres < = 320 & & yres < = 240 )
2007-08-25 01:05:00 +00:00
{
// JBF 20030807: Increased tilted-screen quality
2006-04-13 20:47:06 +00:00
tiltcs = 1 ;
tiltcx = 320 ;
tiltcy = 200 ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-04-13 20:47:06 +00:00
tiltcs = 2 ;
tiltcx = 640 ;
tiltcy = 480 ;
}
walock [ TILE_TILT ] = 255 ;
if ( waloff [ TILE_TILT ] = = 0 )
allocache ( & waloff [ TILE_TILT ] , tiltcx * tiltcx , & walock [ TILE_TILT ] ) ;
if ( ( tang & 1023 ) = = 0 )
setviewtotile ( TILE_TILT , tiltcy > > ( 1 - ud . detail ) , tiltcx > > ( 1 - ud . detail ) ) ;
else
setviewtotile ( TILE_TILT , tiltcx > > ( 1 - ud . detail ) , tiltcx > > ( 1 - ud . detail ) ) ;
if ( ( tang & 1023 ) = = 512 )
2007-08-25 01:05:00 +00:00
{
//Block off unscreen section of 90ø tilted screen
2006-04-13 20:47:06 +00:00
j = ( ( tiltcx - ( 60 * tiltcs ) ) > > ( 1 - ud . detail ) ) ;
2006-11-13 23:12:47 +00:00
for ( i = ( ( 60 * tiltcs ) > > ( 1 - ud . detail ) ) - 1 ; i > = 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
startumost [ i ] = 1 ;
startumost [ i + j ] = 1 ;
startdmost [ i ] = 0 ;
startdmost [ i + j ] = 0 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-15 01:16:55 +00:00
i = ( tang & 511 ) ;
if ( i > 256 ) i = 512 - i ;
2006-04-13 20:47:06 +00:00
i = sintable [ i + 512 ] * 8 + sintable [ i ] * 5L ;
setaspect ( i > > 1 , yxaspect ) ;
2006-11-15 01:16:55 +00:00
}
2007-02-13 02:22:17 +00:00
else if ( getrendermode ( ) > 0 & & ud . screen_tilting /*&& (p->rotscrnang || p->orotscrnang)*/ )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
setrollangle ( p - > orotscrnang + mulscale16 ( ( ( p - > rotscrnang - p - > orotscrnang + 1024 ) & 2047 ) - 1024 , smoothratio ) ) ;
p - > orotscrnang = p - > rotscrnang ; // JBF: save it for next time
}
2006-11-14 21:35:50 +00:00
if ( ( snum = = myconnectindex ) & & ( numplayers > 1 ) )
2006-04-13 20:47:06 +00:00
{
2007-02-12 21:17:52 +00:00
ud . camerax = omyx + mulscale16 ( ( long ) ( myx - omyx ) , smoothratio ) ;
ud . cameray = omyy + mulscale16 ( ( long ) ( myy - omyy ) , smoothratio ) ;
ud . cameraz = omyz + mulscale16 ( ( long ) ( myz - omyz ) , smoothratio ) ;
ud . cameraang = omyang + mulscale16 ( ( long ) ( ( ( myang + 1024 - omyang ) & 2047 ) - 1024 ) , smoothratio ) ;
ud . camerahoriz = omyhoriz + omyhorizoff + mulscale16 ( ( long ) ( myhoriz + myhorizoff - omyhoriz - omyhorizoff ) , smoothratio ) ;
ud . camerasect = mycursectnum ;
2006-04-13 20:47:06 +00:00
}
else
{
2007-02-12 21:17:52 +00:00
ud . camerax = p - > oposx + mulscale16 ( ( long ) ( p - > posx - p - > oposx ) , smoothratio ) ;
ud . cameray = p - > oposy + mulscale16 ( ( long ) ( p - > posy - p - > oposy ) , smoothratio ) ;
ud . cameraz = p - > oposz + mulscale16 ( ( long ) ( p - > posz - p - > oposz ) , smoothratio ) ;
ud . cameraang = p - > oang + mulscale16 ( ( long ) ( ( ( p - > ang + 1024 - p - > oang ) & 2047 ) - 1024 ) , smoothratio ) ;
ud . camerahoriz = p - > ohoriz + p - > ohorizoff + mulscale16 ( ( long ) ( p - > horiz + p - > horizoff - p - > ohoriz - p - > ohorizoff ) , smoothratio ) ;
2006-04-13 20:47:06 +00:00
}
2007-02-12 21:17:52 +00:00
ud . cameraang + = p - > look_ang ;
2006-04-13 20:47:06 +00:00
if ( p - > newowner > = 0 )
{
2007-02-12 21:17:52 +00:00
ud . cameraang = p - > ang + p - > look_ang ;
ud . camerahoriz = p - > horiz + p - > horizoff ;
ud . camerax = p - > posx ;
ud . cameray = p - > posy ;
ud . cameraz = p - > posz ;
ud . camerasect = sprite [ p - > newowner ] . sectnum ;
2006-04-13 20:47:06 +00:00
smoothratio = 65536L ;
}
2006-11-14 21:35:50 +00:00
else if ( p - > over_shoulder_on = = 0 )
2007-02-23 22:27:22 +00:00
{
if ( ud . viewbob )
ud . cameraz + = p - > opyoff + mulscale16 ( ( long ) ( p - > pyoff - p - > opyoff ) , smoothratio ) ;
2007-02-26 01:46:38 +00:00
}
2007-02-12 21:17:52 +00:00
else view ( p , & ud . camerax , & ud . cameray , & ud . cameraz , & ud . camerasect , ud . cameraang , ud . camerahoriz ) ;
2006-04-13 20:47:06 +00:00
cz = hittype [ p - > i ] . ceilingz ;
fz = hittype [ p - > i ] . floorz ;
2006-11-13 23:12:47 +00:00
if ( earthquaketime > 0 & & p - > on_ground = = 1 )
2006-04-13 20:47:06 +00:00
{
2007-02-12 21:17:52 +00:00
ud . cameraz + = 256 - ( ( ( earthquaketime ) & 1 ) < < 9 ) ;
ud . cameraang + = ( 2 - ( ( earthquaketime ) & 2 ) ) < < 2 ;
2006-04-13 20:47:06 +00:00
}
2007-02-12 21:17:52 +00:00
if ( sprite [ p - > i ] . pal = = 1 ) ud . cameraz - = ( 18 < < 8 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( p - > newowner > = 0 )
2007-02-12 21:17:52 +00:00
ud . camerahoriz = 100 + sprite [ p - > newowner ] . shade ;
2006-11-13 23:12:47 +00:00
else if ( p - > spritebridge = = 0 )
2006-04-13 20:47:06 +00:00
{
2007-02-12 21:17:52 +00:00
if ( ud . cameraz < ( p - > truecz + ( 4 < < 8 ) ) ) ud . cameraz = cz + ( 4 < < 8 ) ;
else if ( ud . cameraz > ( p - > truefz - ( 4 < < 8 ) ) ) ud . cameraz = fz - ( 4 < < 8 ) ;
2006-04-13 20:47:06 +00:00
}
2007-02-12 21:17:52 +00:00
if ( ud . camerasect > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-02-12 21:17:52 +00:00
getzsofslope ( ud . camerasect , ud . camerax , ud . cameray , & cz , & fz ) ;
if ( ud . cameraz < cz + ( 4 < < 8 ) ) ud . cameraz = cz + ( 4 < < 8 ) ;
if ( ud . cameraz > fz - ( 4 < < 8 ) ) ud . cameraz = fz - ( 4 < < 8 ) ;
2006-04-13 20:47:06 +00:00
}
2007-02-12 21:17:52 +00:00
if ( ud . camerahoriz > 299 ) ud . camerahoriz = 299 ;
else if ( ud . camerahoriz < - 99 ) ud . camerahoriz = - 99 ;
2007-02-13 01:28:50 +00:00
2007-08-27 06:46:31 +00:00
OnEvent ( EVENT_DISPLAYROOMS , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 ) ;
2007-02-13 01:28:50 +00:00
2006-04-13 20:47:06 +00:00
# ifdef SE40
2007-02-12 21:17:52 +00:00
se40code ( ud . camerax , ud . cameray , ud . cameraz , ud . cameraang , ud . camerahoriz , smoothratio ) ;
2006-04-13 20:47:06 +00:00
# endif
if ( ( gotpic [ MIRROR > > 3 ] & ( 1 < < ( MIRROR & 7 ) ) ) > 0 )
{
2006-11-15 01:16:55 +00:00
dst = 0x7fffffff ;
i = 0 ;
2006-11-13 23:12:47 +00:00
for ( k = 0 ; k < mirrorcnt ; k + + )
2006-04-13 20:47:06 +00:00
{
2007-02-12 21:17:52 +00:00
j = klabs ( wall [ mirrorwall [ k ] ] . x - ud . camerax ) ;
j + = klabs ( wall [ mirrorwall [ k ] ] . y - ud . cameray ) ;
2006-04-13 20:47:06 +00:00
if ( j < dst ) dst = j , i = k ;
}
2006-11-14 21:35:50 +00:00
if ( wall [ mirrorwall [ i ] ] . overpicnum = = MIRROR )
2006-04-13 20:47:06 +00:00
{
2007-02-12 21:17:52 +00:00
preparemirror ( ud . camerax , ud . cameray , ud . cameraz , ud . cameraang , ud . camerahoriz , mirrorwall [ i ] , mirrorsector [ i ] , & tposx , & tposy , & tang ) ;
2006-04-13 20:47:06 +00:00
j = visibility ;
visibility = ( j > > 1 ) + ( j > > 2 ) ;
2007-02-12 21:17:52 +00:00
drawrooms ( tposx , tposy , ud . cameraz , tang , ud . camerahoriz , mirrorsector [ i ] + MAXSECTORS ) ;
2006-04-13 20:47:06 +00:00
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 ) ) ;
}
2007-02-12 21:17:52 +00:00
drawrooms ( ud . camerax , ud . cameray , ud . cameraz , ud . cameraang , ud . camerahoriz , ud . camerasect ) ;
animatesprites ( ud . camerax , ud . cameray , ud . cameraang , smoothratio ) ;
2006-04-13 20:47:06 +00:00
drawmasks ( ) ;
2006-11-13 23:12:47 +00:00
if ( screencapt = = 1 )
2006-04-13 20:47:06 +00:00
{
setviewback ( ) ;
screencapt = 0 ;
// walock[TILE_SAVESHOT] = 1;
}
2006-11-14 21:35:50 +00:00
else if ( getrendermode ( ) = = 0 & & ( ( ud . screen_tilting & & p - > rotscrnang ) | | ud . detail = = 0 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( ud . screen_tilting ) tang = p - > rotscrnang ;
else tang = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
if ( getrendermode ( ) = = 0 )
{
2006-04-13 20:47:06 +00:00
setviewback ( ) ;
picanm [ TILE_TILT ] & = 0xff0000ff ;
2006-11-15 01:16:55 +00:00
i = ( tang & 511 ) ;
if ( i > 256 ) i = 512 - i ;
2006-04-13 20:47:06 +00:00
i = sintable [ i + 512 ] * 8 + sintable [ i ] * 5L ;
if ( ( 1 - ud . detail ) = = 0 ) i > > = 1 ;
i > > = ( tiltcs - 1 ) ; // JBF 20030807
rotatesprite ( 160 < < 16 , 100 < < 16 , i , tang + 512 , TILE_TILT , 0 , 0 , 4 + 2 + 64 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
walock [ TILE_TILT ] = 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 ;
}
2006-12-10 03:15:56 +00:00
static void dumpdebugdata ( void )
2006-11-14 19:58:59 +00:00
{
int i , j , x ;
FILE * fp = fopen ( " debug.con " , " w " ) ;
for ( i = 0 ; i < MAX_WEAPONS ; i + + )
{
for ( j = 0 ; j < numplayers ; j + + )
{
fprintf ( fp , " Player %d \n \n " , j ) ;
fprintf ( fp , " WEAPON%d_CLIP %ld \n " , i , aplWeaponClip [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_RELOAD %ld \n " , i , aplWeaponReload [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_FIREDELAY %ld \n " , i , aplWeaponFireDelay [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_TOTALTIME %ld \n " , i , aplWeaponTotalTime [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_HOLDDELAY %ld \n " , i , aplWeaponHoldDelay [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_FLAGS %ld \n " , i , aplWeaponFlags [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_SHOOTS %ld \n " , i , aplWeaponShoots [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_SPAWNTIME %ld \n " , i , aplWeaponSpawnTime [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_SPAWN %ld \n " , i , aplWeaponSpawn [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_SHOTSPERBURST %ld \n " , i , aplWeaponShotsPerBurst [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_WORKSLIKE %ld \n " , i , aplWeaponWorksLike [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_INITIALSOUND %ld \n " , i , aplWeaponInitialSound [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_FIRESOUND %ld \n " , i , aplWeaponFireSound [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_SOUND2TIME %ld \n " , i , aplWeaponSound2Time [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_SOUND2SOUND %ld \n " , i , aplWeaponSound2Sound [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_RELOADSOUND1 %ld \n " , i , aplWeaponReloadSound1 [ i ] [ j ] ) ;
fprintf ( fp , " WEAPON%d_RELOADSOUND2 %ld \n " , i , aplWeaponReloadSound2 [ i ] [ j ] ) ;
}
fprintf ( fp , " \n " ) ;
}
for ( x = 0 ; x < MAXSTATUS ; x + + )
{
j = headspritestat [ x ] ;
while ( j > = 0 )
{
fprintf ( fp , " Sprite %d (%ld,%ld,%ld) (picnum: %d) \n " , j , sprite [ j ] . x , sprite [ j ] . y , sprite [ j ] . z , sprite [ j ] . picnum ) ;
for ( i = 0 ; i < iGameVarCount ; i + + )
{
if ( aGameVars [ i ] . dwFlags & ( GAMEVAR_FLAG_PERACTOR ) )
{
if ( aGameVars [ i ] . plValues [ j ] ! = aDefaultGameVars [ i ] . lValue )
{
fprintf ( fp , " gamevar %s " , aGameVars [ i ] . szLabel ) ;
fprintf ( fp , " %ld " , aGameVars [ i ] . plValues [ j ] ) ;
fprintf ( fp , " GAMEVAR_FLAG_PERACTOR " ) ;
if ( aGameVars [ i ] . dwFlags ! = GAMEVAR_FLAG_PERACTOR )
{
fprintf ( fp , " // " ) ;
if ( aGameVars [ i ] . dwFlags & ( GAMEVAR_FLAG_SYSTEM ) )
{
fprintf ( fp , " (system) " ) ;
}
}
fprintf ( fp , " \n " ) ;
}
}
}
fprintf ( fp , " \n " ) ;
j = nextspritestat [ j ] ;
}
}
DumpGameVars ( fp ) ;
fclose ( fp ) ;
2007-08-27 06:46:31 +00:00
saveboard ( " debug.map " , & g_player [ myconnectindex ] . ps - > posx , & g_player [ myconnectindex ] . ps - > posy , & g_player [ myconnectindex ] . ps - > posz , & g_player [ myconnectindex ] . ps - > ang , & g_player [ myconnectindex ] . ps - > cursectnum ) ;
2006-11-14 19:58:59 +00:00
}
2006-12-20 03:27:25 +00:00
int EGS ( int whatsect , long s_x , long s_y , long s_z , int s_pn , int s_s , int s_xr , int s_yr , int s_a , int s_ve , long s_zv , int s_ow , int s_ss )
2006-04-13 20:47:06 +00:00
{
2006-12-21 09:33:26 +00:00
int i = insertsprite ( whatsect , s_ss ) ;
2006-04-13 20:47:06 +00:00
long p ;
2006-12-23 02:38:47 +00:00
spritetype * s = & sprite [ i ] ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( i < 0 )
2006-11-14 19:58:59 +00:00
{
dumpdebugdata ( ) ;
OSD_Printf ( " Failed spawning sprite with tile %ld from sprite %ld (%ld) at x:%ld,y:%ld,z:%ld,sector:%ld \n " , s_pn , s_ow , sprite [ s_ow ] . picnum , s_x , s_y , s_z , whatsect ) ;
gameexit ( " Too many sprites spawned. " ) ;
}
2006-04-13 20:47:06 +00:00
hittype [ i ] . bposx = s_x ;
hittype [ i ] . bposy = s_y ;
hittype [ i ] . bposz = s_z ;
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 = T7 = T8 = T9 = 0 ;
2006-04-16 03:42:36 +00:00
actorspriteflags [ i ] = 0 ;
2006-04-13 20:47:06 +00:00
2007-03-08 21:07:10 +00:00
sprpos [ i ] . x = sprite [ i ] . x ;
sprpos [ i ] . y = sprite [ i ] . y ;
sprpos [ i ] . z = sprite [ i ] . z ;
2007-03-22 18:28:41 +00:00
sprpos [ i ] . ang = sprpos [ i ] . oldang = sprite [ i ] . ang ;
2007-03-11 00:47:32 +00:00
2006-11-14 21:35:50 +00:00
if ( actorscrptr [ s_pn ] )
2006-04-13 20:47:06 +00:00
{
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 ) ) ;
clearbufbyte ( & spriteext [ i ] , sizeof ( spriteexttype ) , 0 ) ;
/*
if ( s - > sectnum < 0 )
{
s - > xrepeat = s - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
}
*/
ResetActorGameVars ( i ) ;
actorspriteflags [ i ] = 0 ;
OnEvent ( EVENT_EGS , i , findplayer ( & sprite [ i ] , & p ) , p ) ;
return ( i ) ;
}
2007-02-28 09:12:41 +00:00
int wallswitchcheck ( int i )
2006-04-13 20:47:06 +00:00
{
int j ;
//MULTISWITCH has 4 states so deal with it separately
if ( ( PN > = MULTISWITCH ) & & ( PN < = MULTISWITCH + 3 ) ) return 1 ;
// ACCESSSWITCH and ACCESSSWITCH2 are only active in 1 state so deal with them separately
if ( ( PN = = ACCESSSWITCH ) | | ( PN = = ACCESSSWITCH2 ) ) return 1 ;
//loop to catch both states of switches
2006-11-15 01:16:55 +00:00
for ( j = 0 ; j < = 1 ; j + + )
{
2006-11-13 23:12:47 +00:00
switch ( dynamictostatic [ PN - j ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case HANDPRINTSWITCH__STATIC :
//case HANDPRINTSWITCH+1:
case ALIENSWITCH__STATIC :
//case ALIENSWITCH+1:
case MULTISWITCH__STATIC :
//case MULTISWITCH+1:
//case MULTISWITCH+2:
//case MULTISWITCH+3:
//case ACCESSSWITCH:
//case ACCESSSWITCH2:
case PULLSWITCH__STATIC :
//case PULLSWITCH+1:
case HANDSWITCH__STATIC :
//case HANDSWITCH+1:
case SLOTDOOR__STATIC :
//case SLOTDOOR+1:
case LIGHTSWITCH__STATIC :
//case LIGHTSWITCH+1:
case SPACELIGHTSWITCH__STATIC :
//case SPACELIGHTSWITCH+1:
case SPACEDOORSWITCH__STATIC :
//case SPACEDOORSWITCH+1:
case FRANKENSTINESWITCH__STATIC :
//case FRANKENSTINESWITCH+1:
case LIGHTSWITCH2__STATIC :
//case LIGHTSWITCH2+1:
case POWERSWITCH1__STATIC :
//case POWERSWITCH1+1:
case LOCKSWITCH1__STATIC :
//case LOCKSWITCH1+1:
case POWERSWITCH2__STATIC :
//case POWERSWITCH2+1:
case DIPSWITCH__STATIC :
//case DIPSWITCH+1:
case DIPSWITCH2__STATIC :
//case DIPSWITCH2+1:
case TECHSWITCH__STATIC :
//case TECHSWITCH+1:
case DIPSWITCH3__STATIC :
//case DIPSWITCH3+1:
return 1 ;
2006-04-13 20:47:06 +00:00
}
}
return 0 ;
}
2006-12-20 03:27:25 +00:00
int spawn ( int j , int pn )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
int i , s , startwall , endwall , sect , clostest = 0 ;
2006-04-13 20:47:06 +00:00
long x , y , d , p ;
spritetype * sp ;
2006-11-13 23:12:47 +00:00
if ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
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 = T7 = T8 = T9 = 0 ;
2006-04-16 03:42:36 +00:00
actorspriteflags [ i ] = 0 ;
2006-04-13 20:47:06 +00:00
2007-03-08 21:07:10 +00:00
sprpos [ i ] . x = sprite [ i ] . x ;
sprpos [ i ] . y = sprite [ i ] . y ;
sprpos [ i ] . z = sprite [ i ] . z ;
2007-03-22 18:28:41 +00:00
sprpos [ i ] . ang = sprpos [ i ] . oldang = sprite [ i ] . ang ;
2007-03-08 21:07:10 +00:00
2006-11-14 21:35:50 +00:00
if ( PN ! = SPEAKER & & PN ! = LETTER & & PN ! = DUCK & & PN ! = TARGET & & PN ! = TRIPBOMB & & PN ! = VIEWSCREEN & & PN ! = VIEWSCREEN2 & & ( CS & 48 ) )
if ( ! ( PN > = CRACK1 & & PN < = CRACK4 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( SS = = 127 ) return i ;
2006-11-14 21:35:50 +00:00
if ( wallswitchcheck ( i ) = = 1 & & ( CS & 16 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( PN ! = ACCESSSWITCH & & PN ! = ACCESSSWITCH2 & & sprite [ i ] . pal )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ( ud . multimode < 2 ) | | ( ud . multimode > 1 & & ! GTFLAGS ( GAMETYPE_FLAG_DMSWITCHES ) ) )
2006-04-13 20:47:06 +00:00
{
sprite [ i ] . xrepeat = sprite [ i ] . yrepeat = 0 ;
sprite [ i ] . cstat = SLT = SHT = 0 ;
return i ;
}
}
CS | = 257 ;
2006-11-14 21:35:50 +00:00
if ( sprite [ i ] . pal & & PN ! = ACCESSSWITCH & & PN ! = ACCESSSWITCH2 )
2006-04-13 20:47:06 +00:00
sprite [ i ] . pal = 0 ;
return i ;
}
2006-11-14 21:35:50 +00:00
if ( SHT )
2006-04-13 20:47:06 +00:00
{
changespritestat ( i , 12 ) ;
CS | = 257 ;
SH = impact_damage ;
return i ;
}
}
s = PN ;
2006-11-14 21:35:50 +00:00
if ( CS & 1 ) CS | = 256 ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( actorscrptr [ s ] )
2006-04-13 20:47:06 +00:00
{
SH = * ( actorscrptr [ s ] ) ;
T5 = * ( actorscrptr [ s ] + 1 ) ;
T2 = * ( actorscrptr [ s ] + 2 ) ;
2006-11-14 21:35:50 +00:00
if ( * ( actorscrptr [ s ] + 3 ) & & SHT = = 0 )
2006-04-13 20:47:06 +00:00
SHT = * ( actorscrptr [ s ] + 3 ) ;
}
else T2 = T5 = 0 ;
}
sp = & sprite [ i ] ;
sect = sp - > sectnum ;
//some special cases that can't be handled through the dynamictostatic system.
if ( ( ( sp - > picnum > = BOLT1 ) & & ( sp - > picnum < = BOLT1 + 3 ) ) | | ( ( sp - > picnum > = SIDEBOLT1 ) & & ( sp - > picnum < = SIDEBOLT1 + 3 ) ) )
{
T1 = sp - > xrepeat ;
T2 = sp - > yrepeat ;
sp - > yvel = 0 ;
changespritestat ( i , 6 ) ;
}
else if ( ( ( sp - > picnum > = CAMERA1 ) & & ( sp - > picnum < = CAMERA1 + 3 ) ) | | ( sp - > picnum = = CAMERAPOLE ) | | ( sp - > picnum = = GENERICPOLE ) )
{
2006-11-15 01:16:55 +00:00
if ( sp - > picnum ! = GENERICPOLE )
{
2006-04-13 20:47:06 +00:00
sp - > extra = 1 ;
2006-11-13 23:12:47 +00:00
if ( camerashitable ) sp - > cstat = 257 ;
2006-04-13 20:47:06 +00:00
else sp - > cstat = 0 ;
}
2006-11-14 21:35:50 +00:00
if ( ud . multimode < 2 & & sp - > pal ! = 0 )
2006-04-13 20:47:06 +00:00
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
}
2006-11-15 01:16:55 +00:00
else
{
2006-04-13 20:47:06 +00:00
sp - > pal = 0 ;
2006-11-15 01:16:55 +00:00
if ( ! ( sp - > picnum = = CAMERAPOLE | | sp - > picnum = = GENERICPOLE ) )
{
2006-04-13 20:47:06 +00:00
sp - > picnum = CAMERA1 ;
changespritestat ( i , 1 ) ;
}
}
}
2006-11-13 23:12:47 +00:00
else switch ( dynamictostatic [ sp - > picnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
default :
if ( actorscrptr [ sp - > picnum ] )
{
if ( j = = - 1 & & sp - > lotag > ud . player_skill )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
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 )
{
2006-04-13 20:47:06 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
break ;
}
2006-11-16 03:02:42 +00:00
makeitfall ( i ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( actortype [ sp - > picnum ] & 2 )
hittype [ i ] . actorstayput = sp - > sectnum ;
2006-11-15 01:16:55 +00:00
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > max_actors_killed + + ;
2006-11-16 03:02:42 +00:00
sp - > clipdist = 80 ;
if ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . picnum = = RESPAWN )
hittype [ i ] . tempang = sprite [ i ] . pal = sprite [ j ] . pal ;
2006-04-13 20:47:06 +00:00
changespritestat ( i , 1 ) ;
}
2006-11-16 03:02:42 +00:00
else changespritestat ( i , 2 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > clipdist = 40 ;
sp - > owner = i ;
changespritestat ( i , 1 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
hittype [ i ] . timetosleep = 0 ;
2006-11-13 23:12:47 +00:00
if ( j > = 0 )
2006-11-16 03:02:42 +00:00
sp - > ang = sprite [ j ] . ang ;
}
break ;
case FOF__STATIC :
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
break ;
case WATERSPLASH2__STATIC :
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 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > z = getceilzofslope ( SECT , SX , SY ) + ( 16 < < 8 ) ;
sp - > cstat | = 8 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else if ( sector [ sprite [ j ] . sectnum ] . lotag = = 1 )
sp - > z = getflorzofslope ( SECT , SX , SY ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sect ] . floorpicnum = = FLOORSLIME | |
sector [ sect ] . ceilingpicnum = = FLOORSLIME )
sp - > pal = 7 ;
case NEON1__STATIC :
case NEON2__STATIC :
case NEON3__STATIC :
case NEON4__STATIC :
case NEON5__STATIC :
case NEON6__STATIC :
case DOMELITE__STATIC :
if ( sp - > picnum ! = WATERSPLASH2 )
sp - > cstat | = 257 ;
case NUKEBUTTON__STATIC :
if ( sp - > picnum = = DOMELITE )
sp - > cstat | = 257 ;
case JIBS1__STATIC :
case JIBS2__STATIC :
case JIBS3__STATIC :
case JIBS4__STATIC :
case JIBS5__STATIC :
case JIBS6__STATIC :
case HEADJIB1__STATIC :
case ARMJIB1__STATIC :
case LEGJIB1__STATIC :
case LIZMANHEAD1__STATIC :
case LIZMANARM1__STATIC :
case LIZMANLEG1__STATIC :
case DUKETORSO__STATIC :
case DUKEGUN__STATIC :
case DUKELEG__STATIC :
changespritestat ( i , 5 ) ;
break ;
case TONGUE__STATIC :
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__STATIC :
sp - > cstat & = ~ 257 ;
sp - > cstat | = 32768 ;
break ;
case TRANSPORTERSTAR__STATIC :
case TRANSPORTERBEAM__STATIC :
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 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > xrepeat = 8 ;
sp - > yrepeat = 8 ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-16 03:02:42 +00:00
sp - > xrepeat = 48 ;
sp - > yrepeat = 64 ;
if ( sprite [ j ] . statnum = = 10 | | badguy ( & sprite [ j ] ) )
sp - > z - = ( 32 < < 8 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > shade = - 127 ;
sp - > cstat = 128 | 2 ;
sp - > ang = sprite [ j ] . ang ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > xvel = 128 ;
changespritestat ( i , 5 ) ;
ssp ( i , CLIPMASK0 ) ;
setsprite ( i , sp - > x , sp - > y , sp - > z ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case FRAMEEFFECT1_13__STATIC :
if ( PLUTOPAK ) break ;
case FRAMEEFFECT1__STATIC :
if ( j > = 0 )
{
sp - > xrepeat = sprite [ j ] . xrepeat ;
sp - > yrepeat = sprite [ j ] . yrepeat ;
T2 = sprite [ j ] . picnum ;
}
else sp - > xrepeat = sp - > yrepeat = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
changespritestat ( i , 5 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case LASERLINE__STATIC :
sp - > yrepeat = 6 ;
sp - > xrepeat = 32 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( lasermode = = 1 )
sp - > cstat = 16 + 2 ;
else if ( lasermode = = 0 | | lasermode = = 2 )
sp - > cstat = 16 ;
else
{
sp - > xrepeat = 0 ;
sp - > yrepeat = 0 ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j > = 0 ) sp - > ang = hittype [ j ] . temp_data [ 5 ] + 512 ;
changespritestat ( i , 5 ) ;
break ;
case FORCESPHERE__STATIC :
if ( j = = - 1 )
{
sp - > cstat = ( short ) 32768 ;
changespritestat ( i , 2 ) ;
}
else
{
sp - > xrepeat = sp - > yrepeat = 1 ;
2006-04-13 20:47:06 +00:00
changespritestat ( i , 5 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case BLOOD__STATIC :
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__STATIC :
case PUKE__STATIC :
{
short s1 ;
s1 = sp - > sectnum ;
2006-04-13 20:47:06 +00:00
2006-12-02 06:00:49 +00:00
updatesector ( sp - > x + 108 , sp - > y + 108 , & s1 ) ;
2006-11-16 03:02:42 +00:00
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
2006-11-13 23:12:47 +00:00
{
2006-12-02 06:00:49 +00:00
updatesector ( sp - > x - 108 , sp - > y - 108 , & s1 ) ;
2006-11-13 23:12:47 +00:00
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
2006-04-13 20:47:06 +00:00
{
2006-12-02 06:00:49 +00:00
updatesector ( sp - > x + 108 , sp - > y - 108 , & s1 ) ;
2006-11-13 23:12:47 +00:00
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
2006-04-13 20:47:06 +00:00
{
2006-12-02 06:00:49 +00:00
updatesector ( sp - > x - 108 , sp - > y + 108 , & s1 ) ;
2006-11-16 03:02:42 +00:00
if ( s1 > = 0 & & sector [ s1 ] . floorz ! = sector [ sp - > sectnum ] . floorz )
2006-11-15 01:16:55 +00:00
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
break ;
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
break ;
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
break ;
}
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2006-11-15 01:16:55 +00:00
changespritestat ( i , 5 ) ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
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
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else sp - > pal = 0 ; // green
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . picnum = = TIRE )
sp - > shade = 127 ;
}
sp - > cstat | = 32 ;
case FECES__STATIC :
if ( j > = 0 )
sp - > xrepeat = sp - > yrepeat = 1 ;
changespritestat ( i , 5 ) ;
break ;
case BLOODSPLAT1__STATIC :
case BLOODSPLAT2__STATIC :
case BLOODSPLAT3__STATIC :
case BLOODSPLAT4__STATIC :
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__STATIC :
if ( sp - > lotag > ud . player_skill )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2006-11-15 01:16:55 +00:00
changespritestat ( i , 5 ) ;
break ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > xrepeat = 4 ;
sp - > yrepeat = 5 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > owner = i ;
sp - > hitag = i ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
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 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case SPACEMARINE__STATIC :
if ( sp - > picnum = = SPACEMARINE )
{
sp - > extra = 20 ;
sp - > cstat | = 257 ;
}
changespritestat ( i , 2 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case HYDRENT__STATIC :
case PANNEL1__STATIC :
case PANNEL2__STATIC :
case SATELITE__STATIC :
case FUELPOD__STATIC :
case SOLARPANNEL__STATIC :
case ANTENNA__STATIC :
case GRATE1__STATIC :
case CHAIR1__STATIC :
case CHAIR2__STATIC :
case CHAIR3__STATIC :
case BOTTLE1__STATIC :
case BOTTLE2__STATIC :
case BOTTLE3__STATIC :
case BOTTLE4__STATIC :
case BOTTLE5__STATIC :
case BOTTLE6__STATIC :
case BOTTLE7__STATIC :
case BOTTLE8__STATIC :
case BOTTLE10__STATIC :
case BOTTLE11__STATIC :
case BOTTLE12__STATIC :
case BOTTLE13__STATIC :
case BOTTLE14__STATIC :
case BOTTLE15__STATIC :
case BOTTLE16__STATIC :
case BOTTLE17__STATIC :
case BOTTLE18__STATIC :
case BOTTLE19__STATIC :
case OCEANSPRITE1__STATIC :
case OCEANSPRITE2__STATIC :
case OCEANSPRITE3__STATIC :
case OCEANSPRITE5__STATIC :
case MONK__STATIC :
case INDY__STATIC :
case LUKE__STATIC :
case JURYGUY__STATIC :
case SCALE__STATIC :
case VACUUM__STATIC :
case FANSPRITE__STATIC :
case CACTUS__STATIC :
case CACTUSBROKE__STATIC :
case HANGLIGHT__STATIC :
case FETUS__STATIC :
case FETUSBROKE__STATIC :
case CAMERALIGHT__STATIC :
case MOVIECAMERA__STATIC :
case IVUNIT__STATIC :
case POT1__STATIC :
case POT2__STATIC :
case POT3__STATIC :
case TRIPODCAMERA__STATIC :
case SUSHIPLATE1__STATIC :
case SUSHIPLATE2__STATIC :
case SUSHIPLATE3__STATIC :
case SUSHIPLATE4__STATIC :
case SUSHIPLATE5__STATIC :
case WAITTOBESEATED__STATIC :
case VASE__STATIC :
case PIPE1__STATIC :
case PIPE2__STATIC :
case PIPE3__STATIC :
case PIPE4__STATIC :
case PIPE5__STATIC :
case PIPE6__STATIC :
sp - > clipdist = 32 ;
sp - > cstat | = 257 ;
case OCEANSPRITE4__STATIC :
changespritestat ( i , 0 ) ;
break ;
case FEMMAG1__STATIC :
case FEMMAG2__STATIC :
sp - > cstat & = ~ 257 ;
changespritestat ( i , 0 ) ;
break ;
case DUKETAG__STATIC :
case SIGN1__STATIC :
case SIGN2__STATIC :
if ( ud . multimode < 2 & & sp - > pal )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
}
else sp - > pal = 0 ;
break ;
case MASKWALL1__STATIC :
case MASKWALL2__STATIC :
case MASKWALL3__STATIC :
case MASKWALL4__STATIC :
case MASKWALL5__STATIC :
case MASKWALL6__STATIC :
case MASKWALL7__STATIC :
case MASKWALL8__STATIC :
case MASKWALL9__STATIC :
case MASKWALL10__STATIC :
case MASKWALL11__STATIC :
case MASKWALL12__STATIC :
case MASKWALL13__STATIC :
case MASKWALL14__STATIC :
case MASKWALL15__STATIC :
j = sp - > cstat & 60 ;
sp - > cstat = j | 1 ;
changespritestat ( i , 0 ) ;
break ;
case FOOTPRINTS__STATIC :
case FOOTPRINTS2__STATIC :
case FOOTPRINTS3__STATIC :
case FOOTPRINTS4__STATIC :
if ( j > = 0 )
{
short s1 ;
s1 = sp - > sectnum ;
2006-11-15 01:16:55 +00:00
2006-12-02 06:00:49 +00:00
updatesector ( sp - > x + 84 , sp - > y + 84 , & s1 ) ;
2006-11-16 03:02:42 +00:00
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
2006-11-15 01:16:55 +00:00
{
2006-12-02 06:00:49 +00:00
updatesector ( sp - > x - 84 , sp - > y - 84 , & s1 ) ;
2006-11-13 23:12:47 +00:00
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
2006-04-13 20:47:06 +00:00
{
2006-12-02 06:00:49 +00:00
updatesector ( sp - > x + 84 , sp - > y - 84 , & s1 ) ;
2006-11-13 23:12:47 +00:00
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
2006-04-13 20:47:06 +00:00
{
2006-12-02 06:00:49 +00:00
updatesector ( sp - > x - 84 , sp - > y + 84 , & s1 ) ;
2006-11-16 03:02:42 +00:00
if ( s1 > = 0 & & sector [ s1 ] . floorz ! = sector [ sp - > sectnum ] . floorz )
2006-11-15 01:16:55 +00:00
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2006-11-16 03:02:42 +00:00
changespritestat ( i , 5 ) ;
2006-11-15 01:16:55 +00:00
break ;
}
}
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
break ;
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-16 03:02:42 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
break ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
sp - > cstat = 32 + ( ( g_player [ sprite [ j ] . yvel ] . ps - > footprintcount & 1 ) < < 2 ) ;
2006-11-16 03:02:42 +00:00
sp - > ang = sprite [ j ] . ang ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > z = sector [ sect ] . floorz ;
if ( sector [ sect ] . lotag ! = 1 & & sector [ sect ] . lotag ! = 2 )
sp - > xrepeat = sp - > yrepeat = 32 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
insertspriteq ( i ) ;
changespritestat ( i , 5 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case FEM1__STATIC :
case FEM2__STATIC :
case FEM3__STATIC :
case FEM4__STATIC :
case FEM5__STATIC :
case FEM6__STATIC :
case FEM7__STATIC :
case FEM8__STATIC :
case FEM9__STATIC :
case FEM10__STATIC :
case PODFEM1__STATIC :
case NAKED1__STATIC :
case STATUE__STATIC :
case TOUGHGAL__STATIC :
sp - > yvel = sp - > hitag ;
sp - > hitag = - 1 ;
if ( sp - > picnum = = PODFEM1 ) sp - > extra < < = 1 ;
case BLOODYPOLE__STATIC :
case QUEBALL__STATIC :
case STRIPEBALL__STATIC :
if ( sp - > picnum = = QUEBALL | | sp - > picnum = = STRIPEBALL )
{
sp - > cstat = 256 ;
sp - > clipdist = 8 ;
}
else
{
sp - > cstat | = 257 ;
sp - > clipdist = 32 ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
changespritestat ( i , 2 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case DUKELYINGDEAD__STATIC :
if ( j > = 0 & & sprite [ j ] . picnum = = APLAYER )
{
sp - > xrepeat = sprite [ j ] . xrepeat ;
sp - > yrepeat = sprite [ j ] . yrepeat ;
sp - > shade = sprite [ j ] . shade ;
2007-08-27 06:46:31 +00:00
sp - > pal = g_player [ sprite [ j ] . yvel ] . ps - > palookup ;
2006-11-16 03:02:42 +00:00
}
case DUKECAR__STATIC :
case HELECOPT__STATIC :
// if(sp->picnum == HELECOPT || sp->picnum == DUKECAR) sp->xvel = 1024;
sp - > cstat = 0 ;
sp - > extra = 1 ;
sp - > xvel = 292 ;
sp - > zvel = 360 ;
case RESPAWNMARKERRED__STATIC :
case BLIMP__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
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__STATIC :
if ( sp - > picnum = = MIKE )
{
sp - > yvel = sp - > hitag ;
sp - > hitag = 0 ;
}
case WEATHERWARN__STATIC :
changespritestat ( i , 1 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case SPOTLITE__STATIC :
T1 = sp - > x ;
T2 = sp - > y ;
break ;
case BULLETHOLE__STATIC :
sp - > xrepeat = sp - > yrepeat = 3 ;
sp - > cstat = 16 + ( krand ( ) & 12 ) ;
insertspriteq ( i ) ;
case MONEY__STATIC :
case MAIL__STATIC :
case PAPER__STATIC :
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 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case VIEWSCREEN__STATIC :
case VIEWSCREEN2__STATIC :
sp - > owner = i ;
sp - > lotag = 1 ;
sp - > extra = 1 ;
changespritestat ( i , 6 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case SHELL__STATIC : //From the player
case SHOTGUNSHELL__STATIC :
if ( j > = 0 )
{
2006-12-20 03:27:25 +00:00
int snum , a ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . picnum = = APLAYER )
{
snum = sprite [ j ] . yvel ;
2007-08-27 06:46:31 +00:00
a = g_player [ snum ] . ps - > ang - ( TRAND & 63 ) + 8 ; //Fine tune
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T1 = TRAND & 1 ;
if ( sp - > picnum = = SHOTGUNSHELL )
2007-08-27 06:46:31 +00:00
sp - > z = ( 6 < < 8 ) + g_player [ snum ] . ps - > pyoff + g_player [ snum ] . ps - > posz - ( ( g_player [ snum ] . ps - > horizoff + g_player [ snum ] . ps - > horiz - 100 ) < < 4 ) ;
else sp - > z = ( 3 < < 8 ) + g_player [ snum ] . ps - > pyoff + g_player [ snum ] . ps - > posz - ( ( g_player [ snum ] . ps - > horizoff + g_player [ snum ] . ps - > horiz - 100 ) < < 4 ) ;
2006-11-16 03:02:42 +00:00
sp - > zvel = - ( TRAND & 255 ) ;
}
else
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
a = sp - > ang ;
sp - > z = sprite [ j ] . z - PHEIGHT + ( 3 < < 8 ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
sp - > x = sprite [ j ] . x + ( sintable [ ( a + 512 ) & 2047 ] > > 7 ) ;
sp - > y = sprite [ j ] . y + ( sintable [ a & 2047 ] > > 7 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > shade = - 8 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > yvel = = 1 | | NAM )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > ang = a + 512 ;
sp - > xvel = 30 ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > ang = a - 512 ;
sp - > xvel = 20 ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
sp - > xrepeat = sp - > yrepeat = 4 ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
changespritestat ( i , 5 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case RESPAWN__STATIC :
sp - > extra = 66 - 13 ;
case MUSICANDSFX__STATIC :
if ( ud . multimode < 2 & & sp - > pal = = 1 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
sp - > cstat = ( short ) 32768 ;
changespritestat ( i , 11 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case EXPLOSION2__STATIC :
case EXPLOSION2BOT__STATIC :
case BURNING__STATIC :
case BURNING2__STATIC :
case SMALLSMOKE__STATIC :
case SHRINKEREXPLOSION__STATIC :
case COOLEXPLOSION1__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j > = 0 )
{
sp - > ang = sprite [ j ] . ang ;
sp - > shade = - 64 ;
sp - > cstat = 128 | ( TRAND & 4 ) ;
}
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum = = EXPLOSION2 | | sp - > picnum = = EXPLOSION2BOT )
{
sp - > xrepeat = 48 ;
sp - > yrepeat = 48 ;
sp - > shade = - 127 ;
sp - > cstat | = 128 ;
}
else if ( sp - > picnum = = SHRINKEREXPLOSION )
{
sp - > xrepeat = 32 ;
sp - > yrepeat = 32 ;
}
else if ( sp - > picnum = = SMALLSMOKE )
{
// 64 "money"
sp - > xrepeat = 24 ;
sp - > yrepeat = 24 ;
}
else if ( sp - > picnum = = BURNING | | sp - > picnum = = BURNING2 )
{
sp - > xrepeat = 4 ;
sp - > yrepeat = 4 ;
}
if ( j > = 0 )
{
x = getflorzofslope ( sp - > sectnum , sp - > x , sp - > y ) ;
if ( sp - > z > x - ( 12 < < 8 ) )
sp - > z = x - ( 12 < < 8 ) ;
}
changespritestat ( i , 5 ) ;
break ;
case PLAYERONWATER__STATIC :
if ( j > = 0 )
{
sp - > xrepeat = sprite [ j ] . xrepeat ;
sp - > yrepeat = sprite [ j ] . yrepeat ;
sp - > zvel = 128 ;
if ( sector [ sp - > sectnum ] . lotag ! = 2 )
sp - > cstat | = 32768 ;
}
changespritestat ( i , 13 ) ;
break ;
case APLAYER__STATIC :
sp - > xrepeat = sp - > yrepeat = 0 ;
//j = ud.coop;
//if(j == 2) j = 0;
j = ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_COOPSPAWN ) / GAMETYPE_FLAG_COOPSPAWN ;
if ( ud . multimode < 2 | | ( ud . multimode > 1 & & j ! = sp - > lotag ) )
2006-11-15 01:16:55 +00:00
changespritestat ( i , 5 ) ;
2006-11-16 03:02:42 +00:00
else
changespritestat ( i , 10 ) ;
break ;
case WATERBUBBLE__STATIC :
if ( j > = 0 & & sprite [ j ] . picnum = = APLAYER )
sp - > z - = ( 16 < < 8 ) ;
if ( sp - > picnum = = WATERBUBBLE )
{
if ( j > = 0 )
sp - > ang = sprite [ j ] . ang ;
sp - > xrepeat = sp - > yrepeat = 4 ;
}
else sp - > xrepeat = sp - > yrepeat = 32 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
changespritestat ( i , 5 ) ;
break ;
case CRANE__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > cstat | = 64 | 257 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > picnum + = 2 ;
sp - > z = sector [ sect ] . ceilingz + ( 48 < < 8 ) ;
T5 = tempwallptr ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
msx [ tempwallptr ] = sp - > x ;
msy [ tempwallptr ] = sp - > y ;
msx [ tempwallptr + 2 ] = sp - > z ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
s = headspritestat [ 0 ] ;
while ( s > = 0 )
{
if ( sprite [ s ] . picnum = = CRANEPOLE & & SHT = = ( sprite [ s ] . hitag ) )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
msy [ tempwallptr + 2 ] = s ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
T2 = sprite [ s ] . sectnum ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
sprite [ s ] . xrepeat = 48 ;
sprite [ s ] . yrepeat = 128 ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
msx [ tempwallptr + 1 ] = sprite [ s ] . x ;
msy [ tempwallptr + 1 ] = sprite [ s ] . y ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
sprite [ s ] . x = sp - > x ;
sprite [ s ] . y = sp - > y ;
sprite [ s ] . z = sp - > z ;
sprite [ s ] . shade = sp - > shade ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
setsprite ( s , sprite [ s ] . x , sprite [ s ] . y , sprite [ s ] . z ) ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
s = nextspritestat [ s ] ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
tempwallptr + = 3 ;
sp - > owner = - 1 ;
sp - > extra = 8 ;
changespritestat ( i , 6 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case WATERDRIP__STATIC :
if ( ( j > = 0 & & sprite [ j ] . statnum = = 10 ) | | sprite [ j ] . statnum = = 1 )
{
sp - > shade = 32 ;
if ( sprite [ j ] . pal ! = 1 )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > pal = 2 ;
sp - > z - = ( 18 < < 8 ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else sp - > z - = ( 13 < < 8 ) ;
2007-08-27 06:46:31 +00:00
sp - > ang = getangle ( g_player [ connecthead ] . ps - > posx - sp - > x , g_player [ connecthead ] . ps - > posy - sp - > y ) ;
2006-11-16 03:02:42 +00:00
sp - > xvel = 48 - ( TRAND & 31 ) ;
ssp ( i , CLIPMASK0 ) ;
}
else if ( j = = - 1 )
{
sp - > z + = ( 4 < < 8 ) ;
T1 = sp - > z ;
T2 = TRAND & 127 ;
}
case TRASH__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum ! = WATERDRIP )
sp - > ang = TRAND & 2047 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case WATERDRIPSPLASH__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > xrepeat = 24 ;
sp - > yrepeat = 24 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
changespritestat ( i , 6 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case PLUG__STATIC :
sp - > lotag = 9999 ;
changespritestat ( i , 6 ) ;
break ;
case TOUCHPLATE__STATIC :
T3 = sector [ sect ] . floorz ;
if ( sector [ sect ] . lotag ! = 1 & & sector [ sect ] . lotag ! = 2 )
sector [ sect ] . floorz = sp - > z ;
if ( sp - > pal & & ud . multimode > 1 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
case WATERBUBBLEMAKER__STATIC :
if ( sp - > hitag & & sp - > picnum = = WATERBUBBLEMAKER )
2007-08-25 01:05:00 +00:00
{
// JBF 20030913: Pisses off move(), eg. in bobsp2
2006-11-16 03:02:42 +00:00
OSD_Printf ( " WARNING: WATERBUBBLEMAKER %d @ %d,%d with hitag!=0. Applying fixup. \n " ,
i , sp - > x , sp - > y ) ;
sp - > hitag = 0 ;
}
sp - > cstat | = 32768 ;
changespritestat ( i , 6 ) ;
break ;
//case BOLT1:
//case BOLT1+1:
//case BOLT1+2:
//case BOLT1+3:
//case SIDEBOLT1:
//case SIDEBOLT1+1:
//case SIDEBOLT1+2:
//case SIDEBOLT1+3:
// T1 = sp->xrepeat;
// T2 = sp->yrepeat;
case MASTERSWITCH__STATIC :
if ( sp - > picnum = = MASTERSWITCH )
2006-04-13 20:47:06 +00:00
sp - > cstat | = 32768 ;
2006-11-16 03:02:42 +00:00
sp - > yvel = 0 ;
changespritestat ( i , 6 ) ;
break ;
case TARGET__STATIC :
case DUCK__STATIC :
case LETTER__STATIC :
sp - > extra = 1 ;
sp - > cstat | = 257 ;
changespritestat ( i , 1 ) ;
break ;
case OCTABRAINSTAYPUT__STATIC :
case LIZTROOPSTAYPUT__STATIC :
case PIGCOPSTAYPUT__STATIC :
case LIZMANSTAYPUT__STATIC :
case BOSS1STAYPUT__STATIC :
case PIGCOPDIVE__STATIC :
case COMMANDERSTAYPUT__STATIC :
case BOSS4STAYPUT__STATIC :
hittype [ i ] . actorstayput = sp - > sectnum ;
case BOSS1__STATIC :
case BOSS2__STATIC :
case BOSS3__STATIC :
case BOSS4__STATIC :
case ROTATEGUN__STATIC :
case GREENSLIME__STATIC :
if ( sp - > picnum = = GREENSLIME )
2006-04-13 20:47:06 +00:00
sp - > extra = 1 ;
2006-11-16 03:02:42 +00:00
case DRONE__STATIC :
case LIZTROOPONTOILET__STATIC :
case LIZTROOPJUSTSIT__STATIC :
case LIZTROOPSHOOT__STATIC :
case LIZTROOPJETPACK__STATIC :
case LIZTROOPDUCKING__STATIC :
case LIZTROOPRUNNING__STATIC :
case LIZTROOP__STATIC :
case OCTABRAIN__STATIC :
case COMMANDER__STATIC :
case PIGCOP__STATIC :
case LIZMAN__STATIC :
case LIZMANSPITTING__STATIC :
case LIZMANFEEDING__STATIC :
case LIZMANJUMP__STATIC :
case ORGANTIC__STATIC :
case RAT__STATIC :
case SHARK__STATIC :
if ( sp - > pal = = 0 )
{
switch ( dynamictostatic [ sp - > picnum ] )
{
case LIZTROOPONTOILET__STATIC :
case LIZTROOPSHOOT__STATIC :
case LIZTROOPJETPACK__STATIC :
case LIZTROOPDUCKING__STATIC :
case LIZTROOPRUNNING__STATIC :
case LIZTROOPSTAYPUT__STATIC :
case LIZTROOPJUSTSIT__STATIC :
case LIZTROOP__STATIC :
sp - > pal = 22 ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum = = BOSS4STAYPUT | | sp - > picnum = = BOSS1 | | sp - > picnum = = BOSS2 | | sp - > picnum = = BOSS1STAYPUT | | sp - > picnum = = BOSS3 | | sp - > picnum = = BOSS4 )
{
if ( j > = 0 & & sprite [ j ] . picnum = = RESPAWN )
sp - > pal = sprite [ j ] . pal ;
if ( sp - > pal )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > clipdist = 80 ;
sp - > xrepeat = 40 ;
sp - > yrepeat = 40 ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-16 03:02:42 +00:00
sp - > xrepeat = 80 ;
sp - > yrepeat = 80 ;
sp - > clipdist = 164 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
else
{
if ( sp - > picnum ! = SHARK )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sp - > xrepeat = 40 ;
sp - > yrepeat = 40 ;
sp - > clipdist = 80 ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-16 03:02:42 +00:00
sp - > xrepeat = 60 ;
sp - > yrepeat = 60 ;
sp - > clipdist = 40 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j > = 0 ) sp - > lotag = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ( sp - > lotag > ud . player_skill ) | | ud . monsters_off = = 1 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
else
{
makeitfall ( i ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum = = RAT )
{
sp - > ang = TRAND & 2047 ;
sp - > xrepeat = sp - > yrepeat = 48 ;
sp - > cstat = 0 ;
}
else
{
sp - > cstat | = 257 ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum ! = SHARK )
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > max_actors_killed + + ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum = = ORGANTIC ) sp - > cstat | = 128 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
hittype [ i ] . timetosleep = 0 ;
check_fta_sounds ( i ) ;
changespritestat ( i , 1 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else changespritestat ( i , 2 ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum = = ROTATEGUN )
sp - > zvel = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case LOCATORS__STATIC :
sp - > cstat | = 32768 ;
changespritestat ( i , 7 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case ACTIVATORLOCKED__STATIC :
case ACTIVATOR__STATIC :
sp - > cstat = ( short ) 32768 ;
if ( sp - > picnum = = ACTIVATORLOCKED )
sector [ sp - > sectnum ] . lotag | = 16384 ;
changespritestat ( i , 8 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case DOORSHOCK__STATIC :
sp - > cstat | = 1 + 256 ;
sp - > shade = - 12 ;
changespritestat ( i , 6 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case OOZ__STATIC :
case OOZ2__STATIC :
sp - > shade = - 12 ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
if ( j > = 0 )
{
if ( sprite [ j ] . picnum = = NUKEBARREL )
sp - > pal = 8 ;
insertspriteq ( i ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
changespritestat ( i , 1 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
getglobalz ( i ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = ( hittype [ i ] . floorz - hittype [ i ] . ceilingz ) > > 9 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > yrepeat = j ;
sp - > xrepeat = 25 - ( j > > 1 ) ;
sp - > cstat | = ( TRAND & 4 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case HEAVYHBOMB__STATIC :
if ( j > = 0 )
sp - > owner = j ;
else sp - > owner = i ;
sp - > xrepeat = sp - > yrepeat = 9 ;
sp - > yvel = 4 ;
case REACTOR2__STATIC :
case REACTOR__STATIC :
case RECON__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum = = RECON )
{
if ( sp - > lotag > ud . player_skill )
2006-04-13 20:47:06 +00:00
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
2006-11-16 03:02:42 +00:00
return i ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > max_actors_killed + + ;
2006-11-16 03:02:42 +00:00
hittype [ i ] . temp_data [ 5 ] = 0 ;
if ( ud . monsters_off = = 1 )
2006-04-13 20:47:06 +00:00
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
break ;
}
2006-11-16 03:02:42 +00:00
sp - > extra = 130 ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum = = REACTOR | | sp - > picnum = = REACTOR2 )
sp - > extra = impact_damage ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
CS | = 257 ; // Make it hitable
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ud . multimode < 2 & & sp - > pal ! = 0 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
sp - > pal = 0 ;
SS = - 17 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
changespritestat ( i , 2 ) ;
break ;
case ATOMICHEALTH__STATIC :
case STEROIDS__STATIC :
case HEATSENSOR__STATIC :
case SHIELD__STATIC :
case AIRTANK__STATIC :
case TRIPBOMBSPRITE__STATIC :
case JETPACK__STATIC :
case HOLODUKE__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case FIRSTGUNSPRITE__STATIC :
case CHAINGUNSPRITE__STATIC :
case SHOTGUNSPRITE__STATIC :
case RPGSPRITE__STATIC :
case SHRINKERSPRITE__STATIC :
case FREEZESPRITE__STATIC :
case DEVISTATORSPRITE__STATIC :
case SHOTGUNAMMO__STATIC :
case FREEZEAMMO__STATIC :
case HBOMBAMMO__STATIC :
case CRYSTALAMMO__STATIC :
case GROWAMMO__STATIC :
case BATTERYAMMO__STATIC :
case DEVISTATORAMMO__STATIC :
case RPGAMMO__STATIC :
case BOOTS__STATIC :
case AMMO__STATIC :
case AMMOLOTS__STATIC :
case COLA__STATIC :
case FIRSTAID__STATIC :
case SIXPAK__STATIC :
if ( j > = 0 )
{
sp - > lotag = 0 ;
sp - > z - = ( 32 < < 8 ) ;
sp - > zvel = - 1024 ;
ssp ( i , CLIPMASK0 ) ;
sp - > cstat = TRAND & 4 ;
}
else
{
2006-04-13 20:47:06 +00:00
sp - > owner = i ;
2006-11-16 03:02:42 +00:00
sp - > cstat = 0 ;
}
if ( ( ud . multimode < 2 & & sp - > pal ! = 0 ) | | ( sp - > lotag > ud . player_skill ) )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > pal = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case ACCESSCARD__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > picnum = = ATOMICHEALTH )
sp - > cstat | = 128 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ud . multimode > 1 & & ! GTFLAGS ( GAMETYPE_FLAG_ACCESSCARDSPRITES ) & & sp - > picnum = = ACCESSCARD )
{
2006-11-15 01:16:55 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2006-11-16 03:02:42 +00:00
changespritestat ( i , 5 ) ;
break ;
}
else
{
if ( sp - > picnum = = AMMO )
sp - > xrepeat = sp - > yrepeat = 16 ;
else sp - > xrepeat = sp - > yrepeat = 32 ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > shade = - 17 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j > = 0 ) changespritestat ( i , 1 ) ;
else
{
changespritestat ( i , 2 ) ;
makeitfall ( i ) ;
}
break ;
case WATERFOUNTAIN__STATIC :
SLT = 1 ;
case TREE1__STATIC :
case TREE2__STATIC :
case TIRE__STATIC :
case CONE__STATIC :
case BOX__STATIC :
CS = 257 ; // Make it hitable
sprite [ i ] . extra = 1 ;
changespritestat ( i , 6 ) ;
break ;
case FLOORFLAME__STATIC :
sp - > shade = - 127 ;
changespritestat ( i , 6 ) ;
break ;
case BOUNCEMINE__STATIC :
sp - > owner = i ;
sp - > cstat | = 1 + 256 ; //Make it hitable
sp - > xrepeat = sp - > yrepeat = 24 ;
sp - > shade = - 127 ;
sp - > extra = impact_damage < < 2 ;
changespritestat ( i , 2 ) ;
break ;
case STEAM__STATIC :
if ( j > = 0 )
{
sp - > ang = sprite [ j ] . ang ;
sp - > cstat = 16 + 128 + 2 ;
sp - > xrepeat = sp - > yrepeat = 1 ;
sp - > xvel = - 8 ;
ssp ( i , CLIPMASK0 ) ;
}
case CEILINGSTEAM__STATIC :
changespritestat ( i , 6 ) ;
break ;
case SECTOREFFECTOR__STATIC :
sp - > yvel = sector [ sect ] . extra ;
sp - > cstat | = 32768 ;
sp - > xrepeat = sp - > yrepeat = 0 ;
switch ( sp - > lotag )
{
case 28 :
T6 = 65 ; // Delay for lightning
break ;
case 7 : // Transporters!!!!
case 23 : // XPTR END
if ( sp - > lotag ! = 23 )
{
for ( j = 0 ; j < MAXSPRITES ; j + + )
if ( sprite [ j ] . statnum < MAXSTATUS & & sprite [ j ] . picnum = = SECTOREFFECTOR & & ( sprite [ j ] . lotag = = 7 | | sprite [ j ] . lotag = = 23 ) & & i ! = j & & sprite [ j ] . hitag = = SHT )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
OW = j ;
break ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
else OW = i ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T5 = sector [ sect ] . floorz = = SZ ;
sp - > cstat = 0 ;
changespritestat ( i , 9 ) ;
return i ;
case 1 :
sp - > owner = - 1 ;
T1 = 1 ;
break ;
case 18 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > ang = = 512 )
{
T2 = sector [ sect ] . ceilingz ;
if ( sp - > pal )
2006-11-15 01:16:55 +00:00
sector [ sect ] . ceilingz = sp - > z ;
2006-11-16 03:02:42 +00:00
}
else
{
T2 = sector [ sect ] . floorz ;
if ( sp - > pal )
sector [ sect ] . floorz = sp - > z ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > hitag < < = 2 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 19 :
sp - > owner = - 1 ;
break ;
case 25 : // Pistons
T4 = sector [ sect ] . ceilingz ;
T5 = 1 ;
sector [ sect ] . ceilingz = sp - > z ;
setinterpolation ( & sector [ sect ] . ceilingz ) ;
break ;
case 35 :
sector [ sect ] . ceilingz = sp - > z ;
break ;
case 27 :
if ( ud . recstat = = 1 )
{
sp - > xrepeat = sp - > yrepeat = 64 ;
sp - > cstat & = 32767 ;
}
break ;
case 12 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T2 = sector [ sect ] . floorshade ;
T3 = sector [ sect ] . ceilingshade ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 13 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T1 = sector [ sect ] . ceilingz ;
T2 = sector [ sect ] . floorz ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( klabs ( T1 - sp - > z ) < klabs ( T2 - sp - > z ) )
sp - > owner = 1 ;
else sp - > owner = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > ang = = 512 )
{
if ( sp - > owner )
sector [ sect ] . ceilingz = sp - > z ;
else
sector [ sect ] . floorz = sp - > z ;
}
else
sector [ sect ] . ceilingz = sector [ sect ] . floorz = sp - > z ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sect ] . ceilingstat & 1 )
{
sector [ sect ] . ceilingstat ^ = 1 ;
T4 = 1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ! sp - > owner & & sp - > ang = = 512 )
{
sector [ sect ] . ceilingstat ^ = 1 ;
T4 = 0 ;
}
sector [ sect ] . ceilingshade =
sector [ sect ] . floorshade ;
if ( sp - > ang = = 512 )
{
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
for ( j = startwall ; j < endwall ; j + + )
{
x = wall [ j ] . nextsector ;
if ( x > = 0 )
if ( ! ( sector [ x ] . ceilingstat & 1 ) )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ sect ] . ceilingpicnum =
sector [ x ] . ceilingpicnum ;
sector [ sect ] . ceilingshade =
sector [ x ] . ceilingshade ;
break ; //Leave earily
2006-11-15 01:16:55 +00:00
}
}
2006-11-16 03:02:42 +00:00
}
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 17 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T3 = sector [ sect ] . floorz ; //Stopping loc
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = nextsectorneighborz ( sect , sector [ sect ] . floorz , - 1 , - 1 ) ;
T4 = sector [ j ] . ceilingz ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = nextsectorneighborz ( sect , sector [ sect ] . ceilingz , 1 , 1 ) ;
T5 = sector [ j ] . floorz ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( numplayers < 2 )
{
setinterpolation ( & sector [ sect ] . floorz ) ;
setinterpolation ( & sector [ sect ] . ceilingz ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 24 :
sp - > yvel < < = 1 ;
case 36 :
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case 20 :
{
long q ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
//find the two most clostest wall x's and y's
q = 0x7fffffff ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( s = startwall ; s < endwall ; s + + )
{
x = wall [ s ] . x ;
y = wall [ s ] . y ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
d = FindDistance2D ( sp - > x - x , sp - > y - y ) ;
if ( d < q )
{
q = d ;
clostest = s ;
}
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T2 = clostest ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
q = 0x7fffffff ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( s = startwall ; s < endwall ; s + + )
{
x = wall [ s ] . x ;
y = wall [ s ] . y ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
d = FindDistance2D ( sp - > x - x , sp - > y - y ) ;
if ( d < q & & s ! = T2 )
{
q = d ;
clostest = s ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T3 = clostest ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 3 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T4 = sector [ sect ] . floorshade ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sector [ sect ] . floorshade = sp - > shade ;
sector [ sect ] . ceilingshade = sp - > shade ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > owner = sector [ sect ] . ceilingpal < < 8 ;
sp - > owner | = sector [ sect ] . floorpal ;
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
//fix all the walls;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( s = startwall ; s < endwall ; s + + )
{
if ( ! ( wall [ s ] . hitag & 1 ) )
wall [ s ] . shade = sp - > shade ;
if ( ( wall [ s ] . cstat & 2 ) & & wall [ s ] . nextwall > = 0 )
wall [ wall [ s ] . nextwall ] . shade = sp - > shade ;
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 31 :
T2 = sector [ sect ] . floorz ;
// T3 = sp->hitag;
if ( sp - > ang ! = 1536 ) sector [ sect ] . floorz = sp - > z ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( s = startwall ; s < endwall ; s + + )
if ( wall [ s ] . hitag = = 0 ) wall [ s ] . hitag = 9999 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
setinterpolation ( & sector [ sect ] . floorz ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
case 32 :
T2 = sector [ sect ] . ceilingz ;
T3 = sp - > hitag ;
if ( sp - > ang ! = 1536 ) sector [ sect ] . ceilingz = sp - > z ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( s = startwall ; s < endwall ; s + + )
if ( wall [ s ] . hitag = = 0 ) wall [ s ] . hitag = 9999 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
setinterpolation ( & sector [ sect ] . ceilingz ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 4 : //Flashing lights
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T3 = sector [ sect ] . floorshade ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > owner = sector [ sect ] . ceilingpal < < 8 ;
sp - > owner | = sector [ sect ] . floorpal ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( s = startwall ; s < endwall ; s + + )
if ( wall [ s ] . shade > T4 )
T4 = wall [ s ] . shade ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 9 :
if ( sector [ sect ] . lotag & &
labs ( sector [ sect ] . ceilingz - sp - > z ) > 1024 )
sector [ sect ] . lotag | = 32768 ; //If its open
case 8 :
//First, get the ceiling-floor shade
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T1 = sector [ sect ] . floorshade ;
T2 = sector [ sect ] . ceilingshade ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( s = startwall ; s < endwall ; s + + )
if ( wall [ s ] . shade > T3 )
T3 = wall [ s ] . shade ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T4 = 1 ; //Take Out;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 11 : //Pivitor rotater
if ( sp - > ang > 1024 ) T4 = 2 ;
else T4 = - 2 ;
case 0 :
case 2 : //Earthquakemakers
case 5 : //Boss Creature
case 6 : //Subway
case 14 : //Caboos
case 15 : //Subwaytype sliding door
case 16 : //That rotating blocker reactor thing
case 26 : //ESCELATOR
case 30 : //No rotational subways
if ( sp - > lotag = = 0 )
{
if ( sector [ sect ] . lotag = = 30 )
{
if ( sp - > pal ) sprite [ i ] . clipdist = 1 ;
else sprite [ i ] . clipdist = 0 ;
T4 = sector [ sect ] . floorz ;
sector [ sect ] . hitag = i ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( j = 0 ; j < MAXSPRITES ; j + + )
{
if ( sprite [ j ] . statnum < MAXSTATUS )
if ( sprite [ j ] . picnum = = SECTOREFFECTOR & &
sprite [ j ] . lotag = = 1 & &
sprite [ j ] . hitag = = sp - > hitag )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sp - > ang = = 512 )
{
sp - > x = sprite [ j ] . x ;
sp - > y = sprite [ j ] . y ;
}
break ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
if ( j = = MAXSPRITES )
{
Bsprintf ( tempbuf , " Found lonely Sector Effector (lotag 0) at (%ld,%ld) \n " , sp - > x , sp - > y ) ;
gameexit ( tempbuf ) ;
}
sp - > owner = j ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T2 = tempwallptr ;
for ( s = startwall ; s < endwall ; s + + )
{
msx [ tempwallptr ] = wall [ s ] . x - sp - > x ;
msy [ tempwallptr ] = wall [ s ] . y - sp - > y ;
tempwallptr + + ;
if ( tempwallptr > 2047 )
{
Bsprintf ( tempbuf , " Too many moving sectors at (%ld,%ld). \n " , wall [ s ] . x , wall [ s ] . y ) ;
gameexit ( tempbuf ) ;
}
}
if ( sp - > lotag = = 30 | | sp - > lotag = = 6 | | sp - > lotag = = 14 | | sp - > lotag = = 5 )
{
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sect ] . hitag = = - 1 )
sp - > extra = 0 ;
else sp - > extra = 1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sector [ sect ] . hitag = i ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( s = startwall ; s < endwall ; s + + )
{
if ( wall [ s ] . nextsector > = 0 & &
sector [ wall [ s ] . nextsector ] . hitag = = 0 & &
sector [ wall [ s ] . nextsector ] . lotag < 3 )
{
s = wall [ s ] . nextsector ;
j = 1 ;
break ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j = = 0 )
{
Bsprintf ( tempbuf , " Subway found no zero'd sectors with locators \n at (%ld,%ld). \n " , sp - > x , sp - > y ) ;
gameexit ( tempbuf ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > owner = - 1 ;
T1 = s ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sp - > lotag ! = 30 )
T4 = sp - > hitag ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else if ( sp - > lotag = = 16 )
T4 = sector [ sect ] . ceilingz ;
else if ( sp - > lotag = = 26 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
T4 = sp - > x ;
T5 = sp - > y ;
if ( sp - > shade = = sector [ sect ] . floorshade ) //UP
sp - > zvel = - 256 ;
else
sp - > zvel = 256 ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
sp - > shade = 0 ;
}
else if ( sp - > lotag = = 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
T6 = sector [ sp - > sectnum ] . floorheinum ;
sector [ sp - > sectnum ] . floorheinum = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
switch ( sp - > lotag )
{
case 6 :
case 14 :
j = callsound ( sect , i ) ;
if ( j = = - 1 ) j = SUBWAY ;
hittype [ i ] . lastvx = j ;
case 30 :
if ( numplayers > 1 ) break ;
case 0 :
case 1 :
case 5 :
case 11 :
case 15 :
case 16 :
case 26 :
setsectinterpolate ( i ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
switch ( sprite [ i ] . lotag )
{
case 40 :
case 41 :
case 42 :
case 43 :
case 44 :
case 45 :
changespritestat ( i , 15 ) ;
break ;
default :
changespritestat ( i , 3 ) ;
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case SEENINE__STATIC :
case OOZFILTER__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > shade = - 16 ;
if ( sp - > xrepeat < = 8 )
{
sp - > cstat = ( short ) 32768 ;
sp - > xrepeat = sp - > yrepeat = 0 ;
}
else sp - > cstat = 1 + 256 ;
sp - > extra = impact_damage < < 2 ;
sp - > owner = i ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
changespritestat ( i , 6 ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CRACK1__STATIC :
case CRACK2__STATIC :
case CRACK3__STATIC :
case CRACK4__STATIC :
case FIREEXT__STATIC :
if ( sp - > picnum = = FIREEXT )
{
sp - > cstat = 257 ;
sp - > extra = impact_damage < < 2 ;
}
else
{
sp - > cstat | = ( sp - > cstat & 48 ) ? 1 : 17 ;
sp - > extra = 1 ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ud . multimode < 2 & & sp - > pal ! = 0 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp - > pal = 0 ;
sp - > owner = i ;
changespritestat ( i , 6 ) ;
sp - > xvel = 8 ;
ssp ( i , CLIPMASK0 ) ;
break ;
case TOILET__STATIC :
case STALL__STATIC :
sp - > lotag = 1 ;
sp - > cstat | = 257 ;
sp - > clipdist = 8 ;
sp - > owner = i ;
break ;
case CANWITHSOMETHING__STATIC :
case CANWITHSOMETHING2__STATIC :
case CANWITHSOMETHING3__STATIC :
case CANWITHSOMETHING4__STATIC :
case RUBBERCAN__STATIC :
sp - > extra = 0 ;
case EXPLODINGBARREL__STATIC :
case HORSEONSIDE__STATIC :
case FIREBARREL__STATIC :
case NUKEBARREL__STATIC :
case FIREVASE__STATIC :
case NUKEBARRELDENTED__STATIC :
case NUKEBARRELLEAKED__STATIC :
case WOODENHORSE__STATIC :
if ( j > = 0 )
sp - > xrepeat = sp - > yrepeat = 32 ;
sp - > clipdist = 72 ;
makeitfall ( i ) ;
if ( j > = 0 )
sp - > owner = j ;
else sp - > owner = i ;
case EGG__STATIC :
if ( ud . monsters_off = = 1 & & sp - > picnum = = EGG )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , 5 ) ;
}
else
{
if ( sp - > picnum = = EGG )
sp - > clipdist = 24 ;
sp - > cstat = 257 | ( TRAND & 4 ) ;
changespritestat ( i , 2 ) ;
}
break ;
case TOILETWATER__STATIC :
sp - > shade = - 16 ;
changespritestat ( i , 6 ) ;
break ;
2006-04-13 20:47:06 +00:00
}
OnEvent ( EVENT_SPAWN , i , findplayer ( & sprite [ i ] , & p ) , p ) ;
return i ;
}
# ifdef _MSC_VER
// Visual C thought this was a bit too hard to optimise so we'd better
// tell it not to try... such a pussy it is.
2006-11-14 21:35:50 +00:00
//#pragma auto_inline(off)
2006-04-13 20:47:06 +00:00
# pragma optimize("g",off)
# endif
2007-02-28 09:12:41 +00:00
void animatesprites ( long x , long y , int a , long smoothratio )
2006-04-13 20:47:06 +00:00
{
2007-02-28 09:12:41 +00:00
int i , j , k , p , sect ;
2006-04-13 20:47:06 +00:00
long l , t1 , t3 , t4 ;
spritetype * s , * t ;
int switchpic ;
2006-11-13 23:12:47 +00:00
for ( j = 0 ; j < spritesortcnt ; j + + )
2006-04-13 20:47:06 +00:00
{
t = & tsprite [ j ] ;
i = t - > owner ;
s = & sprite [ t - > owner ] ;
2007-03-08 21:07:10 +00:00
2006-04-13 20:47:06 +00:00
//greenslime can't be handled through the dynamictostatic system due to addition on constant
2006-11-15 01:16:55 +00:00
if ( ( t - > picnum > = GREENSLIME ) & & ( t - > picnum < = GREENSLIME + 7 ) )
2007-08-25 01:05:00 +00:00
{ }
2006-11-13 23:12:47 +00:00
else switch ( dynamictostatic [ t - > picnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case BLOODPOOL__STATIC :
case PUKE__STATIC :
case FOOTPRINTS__STATIC :
case FOOTPRINTS2__STATIC :
case FOOTPRINTS3__STATIC :
case FOOTPRINTS4__STATIC :
if ( t - > shade = = 127 ) continue ;
break ;
case RESPAWNMARKERRED__STATIC :
case RESPAWNMARKERYELLOW__STATIC :
case RESPAWNMARKERGREEN__STATIC :
if ( ud . marker = = 0 )
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
case CHAIR3__STATIC :
2006-11-15 01:16:55 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-16 03:02:42 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( t - > picnum ) > = 0 )
{
t - > cstat & = ~ 4 ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
# endif
k = ( ( ( t - > ang + 3072 + 128 - a ) & 2047 ) > > 8 ) & 7 ;
if ( k > 4 )
{
k = 8 - k ;
t - > cstat | = 4 ;
}
else t - > cstat & = ~ 4 ;
t - > picnum = s - > picnum + k ;
break ;
case BLOODSPLAT1__STATIC :
case BLOODSPLAT2__STATIC :
case BLOODSPLAT3__STATIC :
case BLOODSPLAT4__STATIC :
if ( ud . lockout ) t - > xrepeat = t - > yrepeat = 0 ;
else if ( t - > pal = = 6 )
{
t - > shade = - 127 ;
2006-04-13 20:47:06 +00:00
continue ;
2006-11-16 03:02:42 +00:00
}
case BULLETHOLE__STATIC :
case CRACK1__STATIC :
case CRACK2__STATIC :
case CRACK3__STATIC :
case CRACK4__STATIC :
t - > shade = 16 ;
continue ;
case NEON1__STATIC :
case NEON2__STATIC :
case NEON3__STATIC :
case NEON4__STATIC :
case NEON5__STATIC :
case NEON6__STATIC :
continue ;
//case GREENSLIME:
//case GREENSLIME+1:
//case GREENSLIME+2:
//case GREENSLIME+3:
//case GREENSLIME+4:
//case GREENSLIME+5:
//case GREENSLIME+6:
//case GREENSLIME+7:
// break;
default :
if ( ( ( t - > cstat & 16 ) ) | | ( badguy ( t ) & & t - > extra > 0 ) | | t - > statnum = = 10 )
2006-04-13 20:47:06 +00:00
continue ;
}
2006-07-22 00:06:57 +00:00
if ( checkspriteflags ( t - > owner , SPRITE_FLAG_NOSHADE ) )
l = sprite [ t - > owner ] . shade ;
2006-04-16 03:42:36 +00:00
else
{
if ( sector [ t - > sectnum ] . ceilingstat & 1 )
l = sector [ t - > sectnum ] . ceilingshade ;
else
l = sector [ t - > sectnum ] . floorshade ;
2006-11-13 23:12:47 +00:00
if ( l < - 127 ) l = - 127 ;
if ( l > 128 ) l = 127 ;
2006-04-16 03:42:36 +00:00
}
2006-04-13 20:47:06 +00:00
t - > shade = l ;
}
2006-11-14 21:35:50 +00:00
for ( j = 0 ; j < spritesortcnt ; j + + ) //Between drawrooms() and drawmasks()
2007-08-25 01:05:00 +00:00
{
//is the perfect time to animate sprites
2006-04-13 20:47:06 +00:00
t = & tsprite [ j ] ;
i = t - > owner ;
s = & sprite [ i ] ;
2006-11-13 23:12:47 +00:00
switch ( dynamictostatic [ s - > picnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case SECTOREFFECTOR__STATIC :
if ( t - > lotag = = 27 & & ud . recstat = = 1 )
{
t - > picnum = 11 + ( ( totalclock > > 3 ) & 1 ) ;
t - > cstat | = 128 ;
}
else
t - > xrepeat = t - > yrepeat = 0 ;
break ;
case NATURALLIGHTNING__STATIC :
t - > shade = - 127 ;
break ;
case FEM1__STATIC :
case FEM2__STATIC :
case FEM3__STATIC :
case FEM4__STATIC :
case FEM5__STATIC :
case FEM6__STATIC :
case FEM7__STATIC :
case FEM8__STATIC :
case FEM9__STATIC :
case FEM10__STATIC :
case MAN__STATIC :
case MAN2__STATIC :
case WOMAN__STATIC :
case NAKED1__STATIC :
case PODFEM1__STATIC :
case FEMMAG1__STATIC :
case FEMMAG2__STATIC :
case FEMPIC1__STATIC :
case FEMPIC2__STATIC :
case FEMPIC3__STATIC :
case FEMPIC4__STATIC :
case FEMPIC5__STATIC :
case FEMPIC6__STATIC :
case FEMPIC7__STATIC :
case BLOODYPOLE__STATIC :
case FEM6PAD__STATIC :
case STATUE__STATIC :
case STATUEFLASH__STATIC :
case OOZ__STATIC :
case OOZ2__STATIC :
case WALLBLOOD1__STATIC :
case WALLBLOOD2__STATIC :
case WALLBLOOD3__STATIC :
case WALLBLOOD4__STATIC :
case WALLBLOOD5__STATIC :
case WALLBLOOD7__STATIC :
case WALLBLOOD8__STATIC :
case SUSHIPLATE1__STATIC :
case SUSHIPLATE2__STATIC :
case SUSHIPLATE3__STATIC :
case SUSHIPLATE4__STATIC :
case FETUS__STATIC :
case FETUSJIB__STATIC :
case FETUSBROKE__STATIC :
case HOTMEAT__STATIC :
case FOODOBJECT16__STATIC :
case DOLPHIN1__STATIC :
case DOLPHIN2__STATIC :
case TOUGHGAL__STATIC :
case TAMPON__STATIC :
case XXXSTACY__STATIC :
if ( ud . lockout )
{
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
}
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
switch ( s - > picnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 4946 :
case 4947 :
case 693 :
case 2254 :
case 4560 :
case 4561 :
case 4562 :
case 4498 :
case 4957 :
if ( ud . lockout )
{
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
}
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( t - > statnum = = 99 ) continue ;
2007-08-27 06:46:31 +00:00
if ( s - > statnum ! = 1 & & s - > picnum = = APLAYER & & g_player [ s - > yvel ] . ps - > newowner = = - 1 & & s - > owner > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
t - > x - = mulscale16 ( 65536 - smoothratio , g_player [ s - > yvel ] . ps - > posx - g_player [ s - > yvel ] . ps - > oposx ) ;
t - > y - = mulscale16 ( 65536 - smoothratio , g_player [ s - > yvel ] . ps - > posy - g_player [ s - > yvel ] . ps - > oposy ) ;
t - > z = g_player [ s - > yvel ] . ps - > oposz + mulscale16 ( smoothratio , g_player [ s - > yvel ] . ps - > posz - g_player [ s - > yvel ] . ps - > oposz ) ;
2006-04-13 20:47:06 +00:00
t - > z + = ( 40 < < 8 ) ;
}
2006-11-14 21:35:50 +00:00
else if ( ( s - > statnum = = 0 & & s - > picnum ! = CRANEPOLE ) | | s - > statnum = = 10 | | s - > statnum = = 6 | | s - > statnum = = 4 | | s - > statnum = = 5 | | s - > statnum = = 1 )
2006-04-13 20:47:06 +00:00
{
t - > x - = mulscale16 ( 65536 - smoothratio , s - > x - hittype [ i ] . bposx ) ;
t - > y - = mulscale16 ( 65536 - smoothratio , s - > y - hittype [ i ] . bposy ) ;
t - > z - = mulscale16 ( 65536 - smoothratio , s - > z - hittype [ i ] . bposz ) ;
}
sect = s - > sectnum ;
2006-11-15 01:16:55 +00:00
t1 = T2 ;
t3 = T4 ;
t4 = T5 ;
2006-04-13 20:47:06 +00:00
switchpic = s - > picnum ;
//some special cases because dynamictostatic system can't handle addition to constants
if ( ( s - > picnum > = SCRAP6 ) & & ( s - > picnum < = SCRAP6 + 7 ) )
switchpic = SCRAP5 ;
else if ( ( s - > picnum = = MONEY + 1 ) | | ( s - > picnum = = MAIL + 1 ) | | ( s - > picnum = = PAPER + 1 ) )
switchpic - - ;
2006-11-15 01:16:55 +00:00
switch ( dynamictostatic [ switchpic ] )
{
2006-11-16 03:02:42 +00:00
case DUKELYINGDEAD__STATIC :
t - > z + = ( 24 < < 8 ) ;
break ;
case BLOODPOOL__STATIC :
case FOOTPRINTS__STATIC :
case FOOTPRINTS2__STATIC :
case FOOTPRINTS3__STATIC :
case FOOTPRINTS4__STATIC :
if ( t - > pal = = 6 )
t - > shade = - 127 ;
case PUKE__STATIC :
case MONEY__STATIC :
//case MONEY+1__STATIC:
case MAIL__STATIC :
//case MAIL+1__STATIC:
case PAPER__STATIC :
//case PAPER+1__STATIC:
if ( ud . lockout & & s - > pal = = 2 )
{
t - > xrepeat = t - > yrepeat = 0 ;
2006-04-13 20:47:06 +00:00
continue ;
2006-11-16 03:02:42 +00:00
}
break ;
case TRIPBOMB__STATIC :
continue ;
case FORCESPHERE__STATIC :
if ( t - > statnum = = 5 )
{
short sqa , sqb ;
sqa =
getangle (
2007-08-27 06:46:31 +00:00
sprite [ s - > owner ] . x - g_player [ screenpeek ] . ps - > posx ,
sprite [ s - > owner ] . y - g_player [ screenpeek ] . ps - > posy ) ;
2006-11-16 03:02:42 +00:00
sqb =
getangle (
sprite [ s - > owner ] . x - t - > x ,
sprite [ s - > owner ] . y - t - > y ) ;
if ( klabs ( getincangle ( sqa , sqb ) ) > 512 )
2007-08-27 06:46:31 +00:00
if ( ldist ( & sprite [ s - > owner ] , t ) < ldist ( & sprite [ g_player [ screenpeek ] . ps - > i ] , & sprite [ s - > owner ] ) )
2006-11-16 03:02:42 +00:00
t - > xrepeat = t - > yrepeat = 0 ;
}
continue ;
case BURNING__STATIC :
case BURNING2__STATIC :
if ( sprite [ s - > owner ] . statnum = = 10 )
{
2007-08-27 06:46:31 +00:00
if ( display_mirror = = 0 & & sprite [ s - > owner ] . yvel = = screenpeek & & g_player [ sprite [ s - > owner ] . yvel ] . ps - > over_shoulder_on = = 0 )
2006-11-16 03:02:42 +00:00
t - > xrepeat = 0 ;
else
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
t - > ang = getangle ( x - t - > x , y - t - > y ) ;
t - > x = sprite [ s - > owner ] . x ;
t - > y = sprite [ s - > owner ] . y ;
t - > x + = sintable [ ( t - > ang + 512 ) & 2047 ] > > 10 ;
t - > y + = sintable [ t - > ang & 2047 ] > > 10 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case ATOMICHEALTH__STATIC :
t - > z - = ( 4 < < 8 ) ;
break ;
case CRYSTALAMMO__STATIC :
t - > shade = ( sintable [ ( totalclock < < 4 ) & 2047 ] > > 10 ) ;
continue ;
case VIEWSCREEN__STATIC :
case VIEWSCREEN2__STATIC :
if ( camsprite > = 0 & & hittype [ OW ] . temp_data [ 0 ] = = 1 )
{
t - > picnum = STATIC ;
t - > cstat | = ( rand ( ) & 12 ) ;
t - > xrepeat + = 8 ;
t - > yrepeat + = 8 ;
}
else if ( camsprite > = 0 & & waloff [ TILE_VIEWSCR ] & & walock [ TILE_VIEWSCR ] > 200 )
{
t - > picnum = TILE_VIEWSCR ;
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case SHRINKSPARK__STATIC :
t - > picnum = SHRINKSPARK + ( ( totalclock > > 4 ) & 3 ) ;
break ;
case GROWSPARK__STATIC :
t - > picnum = GROWSPARK + ( ( totalclock > > 4 ) & 3 ) ;
break ;
case RPG__STATIC :
2006-11-15 01:16:55 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-16 03:02:42 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( t - > picnum ) > = 0 )
{
t - > cstat & = ~ 4 ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
# endif
k = getangle ( s - > x - x , s - > y - y ) ;
k = ( ( ( s - > ang + 3072 + 128 - k ) & 2047 ) / 170 ) ;
if ( k > 6 )
{
k = 12 - k ;
t - > cstat | = 4 ;
}
else t - > cstat & = ~ 4 ;
t - > picnum = RPG + k ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case RECON__STATIC :
2006-05-12 21:55:05 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-16 03:02:42 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( t - > picnum ) > = 0 )
{
t - > cstat & = ~ 4 ;
break ;
}
2006-05-12 21:55:05 +00:00
# endif
2006-11-16 03:02:42 +00:00
k = getangle ( s - > x - x , s - > y - y ) ;
if ( T1 < 4 )
k = ( ( ( s - > ang + 3072 + 128 - k ) & 2047 ) / 170 ) ;
else k = ( ( ( s - > ang + 3072 + 128 - k ) & 2047 ) / 170 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( k > 6 )
{
k = 12 - k ;
t - > cstat | = 4 ;
}
else t - > cstat & = ~ 4 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( klabs ( t3 ) > 64 ) k + = 7 ;
t - > picnum = RECON + k ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case APLAYER__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
p = s - > yvel ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( t - > pal = = 1 ) t - > z - = ( 18 < < 8 ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ p ] . ps - > over_shoulder_on > 0 & & g_player [ p ] . ps - > newowner < 0 )
2006-11-16 03:02:42 +00:00
{
t - > cstat | = 2 ;
if ( screenpeek = = myconnectindex & & numplayers > = 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
t - > x = omyx + mulscale16 ( ( long ) ( myx - omyx ) , smoothratio ) ;
t - > y = omyy + mulscale16 ( ( long ) ( myy - omyy ) , smoothratio ) ;
t - > z = omyz + mulscale16 ( ( long ) ( myz - omyz ) , smoothratio ) + ( 40 < < 8 ) ;
t - > ang = omyang + mulscale16 ( ( long ) ( ( ( myang + 1024 - omyang ) & 2047 ) - 1024 ) , smoothratio ) ;
t - > sectnum = mycursectnum ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2007-03-11 00:20:32 +00:00
if ( ( display_mirror | | screenpeek ! = p | | s - > owner = = - 1 ) & & ud . multimode > 1 )
2006-11-16 03:02:42 +00:00
{
2007-08-27 06:46:31 +00:00
if ( ud . showweapons & & sprite [ g_player [ p ] . ps - > i ] . extra > 0 & & g_player [ p ] . ps - > curr_weapon > 0 )
2007-02-08 04:19:39 +00:00
{
memcpy ( ( spritetype * ) & tsprite [ spritesortcnt ] , ( spritetype * ) t , sizeof ( spritetype ) ) ;
2006-04-13 20:47:06 +00:00
2007-02-08 04:19:39 +00:00
tsprite [ spritesortcnt ] . statnum = 99 ;
2006-04-13 20:47:06 +00:00
2007-02-08 04:19:39 +00:00
tsprite [ spritesortcnt ] . yrepeat = ( t - > yrepeat > > 3 ) ;
if ( t - > yrepeat < 4 ) t - > yrepeat = 4 ;
2006-04-13 20:47:06 +00:00
2007-02-08 04:19:39 +00:00
tsprite [ spritesortcnt ] . shade = t - > shade ;
tsprite [ spritesortcnt ] . cstat = 0 ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
tsprite [ spritesortcnt ] . picnum = ( g_player [ p ] . ps - > curr_weapon = = GROW_WEAPON ? GROWSPRITEICON : weapon_sprites [ g_player [ p ] . ps - > curr_weapon ] ) ;
2006-04-13 20:47:06 +00:00
2007-02-08 04:19:39 +00:00
if ( s - > owner > = 0 )
2007-08-27 06:46:31 +00:00
tsprite [ spritesortcnt ] . z = g_player [ p ] . ps - > posz - ( 12 < < 8 ) ;
2007-02-08 04:19:39 +00:00
else tsprite [ spritesortcnt ] . z = s - > z - ( 51 < < 8 ) ;
if ( tsprite [ spritesortcnt ] . picnum = = HEAVYHBOMB )
{
tsprite [ spritesortcnt ] . xrepeat = 10 ;
tsprite [ spritesortcnt ] . yrepeat = 10 ;
}
else
{
tsprite [ spritesortcnt ] . xrepeat = 16 ;
tsprite [ spritesortcnt ] . yrepeat = 16 ;
}
tsprite [ spritesortcnt ] . pal = 0 ;
spritesortcnt + + ;
2006-11-16 03:02:42 +00:00
}
2006-05-09 04:24:44 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ p ] . sync - > extbits & ( 1 < < 7 ) & & ! ud . pause_on )
2007-02-08 04:19:39 +00:00
{
memcpy ( ( spritetype * ) & tsprite [ spritesortcnt ] , ( spritetype * ) t , sizeof ( spritetype ) ) ;
2006-05-09 04:24:44 +00:00
2007-02-08 04:19:39 +00:00
tsprite [ spritesortcnt ] . statnum = 99 ;
2006-05-09 04:24:44 +00:00
2007-02-08 04:19:39 +00:00
tsprite [ spritesortcnt ] . yrepeat = ( t - > yrepeat > > 3 ) ;
if ( t - > yrepeat < 4 ) t - > yrepeat = 4 ;
2006-05-09 04:24:44 +00:00
2007-02-08 04:19:39 +00:00
tsprite [ spritesortcnt ] . cstat = 0 ;
2006-05-09 04:24:44 +00:00
2007-02-08 04:19:39 +00:00
tsprite [ spritesortcnt ] . picnum = RESPAWNMARKERGREEN ;
2006-05-09 04:24:44 +00:00
2007-02-08 04:19:39 +00:00
if ( s - > owner > = 0 )
2007-08-27 06:46:31 +00:00
tsprite [ spritesortcnt ] . z = g_player [ p ] . ps - > posz - ( 20 < < 8 ) ;
2007-02-08 04:19:39 +00:00
else tsprite [ spritesortcnt ] . z = s - > z - ( 96 < < 8 ) ;
tsprite [ spritesortcnt ] . xrepeat = 32 ;
tsprite [ spritesortcnt ] . yrepeat = 32 ;
tsprite [ spritesortcnt ] . pal = 20 ;
spritesortcnt + + ;
}
2006-11-16 03:02:42 +00:00
}
if ( s - > owner = = - 1 )
{
2006-05-12 21:55:05 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-16 03:02:42 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( s - > picnum ) > = 0 )
{
k = 0 ;
t - > cstat & = ~ 4 ;
}
else
2006-05-12 21:55:05 +00:00
# endif
2006-11-16 03:02:42 +00:00
{
k = ( ( ( s - > ang + 3072 + 128 - a ) & 2047 ) > > 8 ) & 7 ;
if ( k > 4 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
k = 8 - k ;
t - > cstat | = 4 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else t - > cstat & = ~ 4 ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ t - > sectnum ] . lotag = = 2 ) k + = 1795 - 1405 ;
else if ( ( hittype [ i ] . floorz - s - > z ) > ( 64 < < 8 ) ) k + = 60 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
t - > picnum + = k ;
2007-08-27 06:46:31 +00:00
t - > pal = g_player [ p ] . ps - > palookup ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
goto PALONLY ;
}
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ p ] . ps - > on_crane = = - 1 & & ( sector [ s - > sectnum ] . lotag & 0x7ff ) ! = 1 )
2006-11-16 03:02:42 +00:00
{
2007-08-27 06:46:31 +00:00
l = s - > z - hittype [ g_player [ p ] . ps - > i ] . floorz + ( 3 < < 8 ) ;
2006-11-16 03:02:42 +00:00
if ( l > 1024 & & s - > yrepeat > 32 & & s - > extra > 0 )
s - > yoffset = ( signed char ) ( l / ( s - > yrepeat < < 2 ) ) ;
else s - > yoffset = 0 ;
}
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ p ] . ps - > newowner > - 1 )
2006-11-16 03:02:42 +00:00
{
t4 = * ( actorscrptr [ APLAYER ] + 1 ) ;
t3 = 0 ;
t1 = * ( actorscrptr [ APLAYER ] + 2 ) ;
}
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( ud . camerasprite = = - 1 & & g_player [ p ] . ps - > newowner = = - 1 )
if ( s - > owner > = 0 & & display_mirror = = 0 & & g_player [ p ] . ps - > over_shoulder_on = = 0 )
2006-11-16 03:02:42 +00:00
if ( ud . multimode < 2 | | ( ud . multimode > 1 & & p = = screenpeek ) )
{
t - > owner = - 1 ;
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
}
2006-04-13 20:47:06 +00:00
PALONLY :
2007-08-27 06:46:31 +00:00
if ( sector [ sect ] . floorpal & & sector [ sect ] . floorpal < g_NumPalettes )
2006-11-16 03:02:42 +00:00
t - > pal = sector [ sect ] . floorpal ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( s - > owner = = - 1 ) continue ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( t - > z > hittype [ i ] . floorz & & t - > xrepeat < 32 )
t - > z = hittype [ i ] . floorz ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case JIBS1__STATIC :
case JIBS2__STATIC :
case JIBS3__STATIC :
case JIBS4__STATIC :
case JIBS5__STATIC :
case JIBS6__STATIC :
case HEADJIB1__STATIC :
case LEGJIB1__STATIC :
case ARMJIB1__STATIC :
case LIZMANHEAD1__STATIC :
case LIZMANARM1__STATIC :
case LIZMANLEG1__STATIC :
case DUKELEG__STATIC :
case DUKEGUN__STATIC :
case DUKETORSO__STATIC :
if ( ud . lockout )
{
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
}
if ( t - > pal = = 6 ) t - > shade = - 120 ;
case SCRAP1__STATIC :
case SCRAP2__STATIC :
case SCRAP3__STATIC :
case SCRAP4__STATIC :
case SCRAP5__STATIC :
if ( hittype [ i ] . picnum = = BLIMP & & t - > picnum = = SCRAP1 & & s - > yvel > = 0 )
t - > picnum = s - > yvel ;
else t - > picnum + = T1 ;
t - > shade - = 6 ;
2007-08-27 06:46:31 +00:00
if ( sector [ sect ] . floorpal & & sector [ sect ] . floorpal < g_NumPalettes )
2006-11-16 03:02:42 +00:00
t - > pal = sector [ sect ] . floorpal ;
break ;
case WATERBUBBLE__STATIC :
if ( sector [ t - > sectnum ] . floorpicnum = = FLOORSLIME )
{
t - > pal = 7 ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
default :
2007-08-27 06:46:31 +00:00
if ( sector [ sect ] . floorpal & & sector [ sect ] . floorpal < g_NumPalettes )
2006-11-16 03:02:42 +00:00
t - > pal = sector [ sect ] . floorpal ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( actorscrptr [ s - > picnum ] )
2006-04-13 20:47:06 +00:00
{
2007-03-21 20:37:24 +00:00
#if 0
2007-03-13 18:37:46 +00:00
t - > x = sprpos [ i ] . x + mulscale16 ( ( long ) ( s - > x - sprpos [ i ] . x ) , smoothratio ) ;
t - > y = sprpos [ i ] . y + mulscale16 ( ( long ) ( s - > y - sprpos [ i ] . y ) , smoothratio ) ;
t - > z = sprpos [ i ] . z + mulscale16 ( ( long ) ( s - > z - sprpos [ i ] . z ) , smoothratio ) ;
t - > ang = sprpos [ i ] . ang + mulscale16 ( ( long ) ( s - > ang - sprpos [ i ] . ang ) , smoothratio ) ;
2007-03-21 20:37:24 +00:00
# endif
2007-03-22 18:28:41 +00:00
if ( ud . angleinterpolation )
{
if ( sprpos [ i ] . ang ! = sprpos [ i ] . oldang )
t - > ang = ( sprpos [ i ] . oldang + ( mulscale16 ( ( long ) ( sprpos [ i ] . angdif ) , smoothratio ) * sprpos [ i ] . angdir ) ) & 2047 ;
else
t - > ang = sprpos [ i ] . ang ;
}
2006-11-13 23:12:47 +00:00
if ( t4 )
2006-04-13 20:47:06 +00:00
{
l = * ( long * ) ( t4 + 8 ) ;
2006-05-12 21:55:05 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-15 01:16:55 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( s - > picnum ) > = 0 )
{
2006-04-13 20:47:06 +00:00
k = 0 ;
t - > cstat & = ~ 4 ;
}
2006-05-12 21:55:05 +00:00
else
# endif
2006-11-14 21:35:50 +00:00
switch ( l )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 2 :
k = ( ( ( s - > ang + 3072 + 128 - a ) & 2047 ) > > 8 ) & 1 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 3 :
case 4 :
k = ( ( ( s - > ang + 3072 + 128 - a ) & 2047 ) > > 7 ) & 7 ;
if ( k > 3 )
{
t - > cstat | = 4 ;
k = 7 - k ;
}
else t - > cstat & = ~ 4 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 5 :
k = getangle ( s - > x - x , s - > y - y ) ;
k = ( ( ( s - > ang + 3072 + 128 - k ) & 2047 ) > > 8 ) & 7 ;
if ( k > 4 )
{
k = 8 - k ;
t - > cstat | = 4 ;
}
else t - > cstat & = ~ 4 ;
break ;
case 7 :
k = getangle ( s - > x - x , s - > y - y ) ;
k = ( ( ( s - > ang + 3072 + 128 - k ) & 2047 ) / 170 ) ;
if ( k > 6 )
{
k = 12 - k ;
t - > cstat | = 4 ;
}
else t - > cstat & = ~ 4 ;
break ;
case 8 :
k = ( ( ( s - > ang + 3072 + 128 - a ) & 2047 ) > > 8 ) & 7 ;
t - > cstat & = ~ 4 ;
break ;
default :
k = 0 ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
t - > picnum + = k + ( * ( long * ) t4 ) + l * t3 ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( l > 0 ) while ( tilesizx [ t - > picnum ] = = 0 & & t - > picnum > 0 )
2006-04-13 20:47:06 +00:00
t - > picnum - = l ; //Hack, for actors
2006-11-14 21:35:50 +00:00
if ( hittype [ i ] . dispicnum > = 0 )
2006-04-13 20:47:06 +00:00
hittype [ i ] . dispicnum = t - > picnum ;
}
2006-11-13 23:12:47 +00:00
else if ( display_mirror = = 1 )
2006-04-13 20:47:06 +00:00
t - > cstat | = 4 ;
}
2007-08-27 06:46:31 +00:00
if ( g_player [ screenpeek ] . ps - > heat_amount > 0 & & g_player [ screenpeek ] . ps - > heat_on & & ( badguy ( s ) | | checkspriteflags ( t - > owner , SPRITE_FLAG_NVG ) | | s - > picnum = = APLAYER | | s - > statnum = = 13 ) )
2006-09-07 17:46:00 +00:00
{
t - > pal = 6 ;
t - > shade = 0 ;
}
2006-11-14 21:35:50 +00:00
if ( s - > statnum = = 13 | | badguy ( s ) | | checkspriteflags ( t - > owner , SPRITE_FLAG_SHADOW ) | | ( s - > picnum = = APLAYER & & s - > owner > = 0 ) )
2006-11-13 23:12:47 +00:00
if ( t - > statnum ! = 99 & & s - > picnum ! = EXPLOSION2 & & s - > picnum ! = HANGLIGHT & & s - > picnum ! = DOMELITE )
if ( s - > picnum ! = HOTMEAT )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( hittype [ i ] . dispicnum < 0 )
2006-04-13 20:47:06 +00:00
{
hittype [ i ] . dispicnum + + ;
continue ;
}
2006-11-14 21:35:50 +00:00
else if ( ud . shadows & & spritesortcnt < ( MAXSPRITESONSCREEN - 2 ) )
2006-04-13 20:47:06 +00:00
{
long daz , xrep , yrep ;
2006-11-14 21:35:50 +00:00
if ( ( sector [ sect ] . lotag & 0xff ) > 2 | | s - > statnum = = 4 | | s - > statnum = = 5 | | s - > picnum = = DRONE | | s - > picnum = = COMMANDER )
2006-04-13 20:47:06 +00:00
daz = sector [ sect ] . floorz ;
else
daz = hittype [ i ] . floorz ;
2006-11-14 21:35:50 +00:00
if ( ( s - > z - daz ) < ( 8 < < 8 ) )
2007-08-27 06:46:31 +00:00
if ( g_player [ screenpeek ] . ps - > posz < daz )
2006-04-13 20:47:06 +00:00
{
memcpy ( ( spritetype * ) & tsprite [ spritesortcnt ] , ( spritetype * ) t , sizeof ( spritetype ) ) ;
tsprite [ spritesortcnt ] . statnum = 99 ;
2006-11-14 21:35:50 +00:00
tsprite [ spritesortcnt ] . yrepeat = ( t - > yrepeat > > 3 ) ;
2006-11-13 23:12:47 +00:00
if ( t - > yrepeat < 4 ) t - > yrepeat = 4 ;
2006-04-13 20:47:06 +00:00
tsprite [ spritesortcnt ] . shade = 127 ;
tsprite [ spritesortcnt ] . cstat | = 2 ;
tsprite [ spritesortcnt ] . z = daz ;
xrep = tsprite [ spritesortcnt ] . xrepeat ; // - (klabs(daz-t->z)>>11);
tsprite [ spritesortcnt ] . xrepeat = xrep ;
tsprite [ spritesortcnt ] . pal = 4 ;
yrep = tsprite [ spritesortcnt ] . yrepeat ; // - (klabs(daz-t->z)>>11);
tsprite [ spritesortcnt ] . yrepeat = yrep ;
2006-05-12 21:55:05 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-04-13 20:47:06 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( t - > picnum ) > = 0 )
{
tsprite [ spritesortcnt ] . yrepeat = 0 ;
// 512:trans reverse
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
tsprite [ spritesortcnt ] . cstat | = ( 512 + 1024 ) ;
}
2006-11-13 23:12:47 +00:00
else if ( bpp > 8 )
2006-08-29 08:07:06 +00:00
{
int ii ;
2007-08-27 06:46:31 +00:00
ii = getangle ( tsprite [ spritesortcnt ] . x - g_player [ screenpeek ] . ps - > posx ,
tsprite [ spritesortcnt ] . y - g_player [ screenpeek ] . ps - > posy ) ;
2006-08-29 08:07:06 +00:00
tsprite [ spritesortcnt ] . x + = sintable [ ( ii + 2560 ) & 2047 ] > > 9 ;
tsprite [ spritesortcnt ] . y + = sintable [ ( ii + 2048 ) & 2047 ] > > 9 ;
}
2006-05-12 21:55:05 +00:00
# endif
2006-04-13 20:47:06 +00:00
spritesortcnt + + ;
}
}
}
2006-11-13 23:12:47 +00:00
switch ( dynamictostatic [ s - > picnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case LASERLINE__STATIC :
if ( sector [ t - > sectnum ] . lotag = = 2 ) t - > pal = 8 ;
t - > z = sprite [ s - > owner ] . z - ( 3 < < 8 ) ;
2007-08-27 06:46:31 +00:00
if ( lasermode = = 2 & & g_player [ screenpeek ] . ps - > heat_on = = 0 )
2006-11-16 03:02:42 +00:00
t - > yrepeat = 0 ;
case EXPLOSION2__STATIC :
case EXPLOSION2BOT__STATIC :
case FREEZEBLAST__STATIC :
case ATOMICHEALTH__STATIC :
case FIRELASER__STATIC :
case SHRINKSPARK__STATIC :
case GROWSPARK__STATIC :
case CHAINGUN__STATIC :
case SHRINKEREXPLOSION__STATIC :
case RPG__STATIC :
case FLOORFLAME__STATIC :
if ( t - > picnum = = EXPLOSION2 )
{
2007-08-27 06:46:31 +00:00
g_player [ screenpeek ] . ps - > visibility = - 127 ;
2006-11-16 03:02:42 +00:00
lastvisinc = totalclock + 32 ;
//restorepalette = 1; // JBF 20040101: why?
}
t - > shade = - 127 ;
break ;
case FIRE__STATIC :
case FIRE2__STATIC :
case BURNING__STATIC :
case BURNING2__STATIC :
if ( sprite [ s - > owner ] . picnum ! = TREE1 & & sprite [ s - > owner ] . picnum ! = TREE2 )
t - > z = sector [ t - > sectnum ] . floorz ;
t - > shade = - 127 ;
break ;
case COOLEXPLOSION1__STATIC :
t - > shade = - 127 ;
t - > picnum + = ( s - > shade > > 1 ) ;
break ;
case PLAYERONWATER__STATIC :
2006-05-12 21:55:05 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-16 03:02:42 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( s - > picnum ) > = 0 )
{
k = 0 ;
t - > cstat & = ~ 4 ;
}
else
2006-05-12 21:55:05 +00:00
# endif
2006-11-16 03:02:42 +00:00
{
k = ( ( ( t - > ang + 3072 + 128 - a ) & 2047 ) > > 8 ) & 7 ;
if ( k > 4 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
k = 8 - k ;
t - > cstat | = 4 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else t - > cstat & = ~ 4 ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
t - > picnum = s - > picnum + k + ( ( T1 < 4 ) * 5 ) ;
t - > shade = sprite [ s - > owner ] . shade ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case WATERSPLASH2__STATIC :
t - > picnum = WATERSPLASH2 + t1 ;
break ;
case REACTOR2__STATIC :
t - > picnum = s - > picnum + T3 ;
break ;
case SHELL__STATIC :
t - > picnum = s - > picnum + ( T1 & 1 ) ;
case SHOTGUNSHELL__STATIC :
t - > cstat | = 12 ;
if ( T1 > 1 ) t - > cstat & = ~ 4 ;
if ( T1 > 2 ) t - > cstat & = ~ 12 ;
break ;
case FRAMEEFFECT1_13__STATIC :
if ( PLUTOPAK ) break ;
case FRAMEEFFECT1__STATIC :
if ( s - > owner > = 0 & & sprite [ s - > owner ] . statnum < MAXSTATUS )
{
if ( sprite [ s - > owner ] . picnum = = APLAYER )
if ( ud . camerasprite = = - 1 )
if ( screenpeek = = sprite [ s - > owner ] . yvel & & display_mirror = = 0 )
{
t - > owner = - 1 ;
break ;
}
if ( ( sprite [ s - > owner ] . cstat & 32768 ) = = 0 )
{
if ( ! hittype [ s - > owner ] . dispicnum )
t - > picnum = hittype [ i ] . temp_data [ 1 ] ;
else t - > picnum = hittype [ s - > owner ] . dispicnum ;
t - > pal = sprite [ s - > owner ] . pal ;
t - > shade = sprite [ s - > owner ] . shade ;
t - > ang = sprite [ s - > owner ] . ang ;
t - > cstat = 2 | sprite [ s - > owner ] . cstat ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case CAMERA1__STATIC :
case RAT__STATIC :
2006-11-15 01:16:55 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-16 03:02:42 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( s - > picnum ) > = 0 )
{
t - > cstat & = ~ 4 ;
break ;
}
2006-11-15 01:16:55 +00:00
# endif
2006-11-16 03:02:42 +00:00
k = ( ( ( t - > ang + 3072 + 128 - a ) & 2047 ) > > 8 ) & 7 ;
if ( k > 4 )
{
k = 8 - k ;
t - > cstat | = 4 ;
}
else t - > cstat & = ~ 4 ;
t - > picnum = s - > picnum + k ;
break ;
2006-04-13 20:47:06 +00:00
}
hittype [ i ] . dispicnum = t - > picnum ;
2006-11-13 23:12:47 +00:00
if ( sector [ t - > sectnum ] . floorpicnum = = MIRROR )
2006-04-13 20:47:06 +00:00
t - > xrepeat = t - > yrepeat = 0 ;
}
}
# ifdef _MSC_VER
2006-11-14 21:35:50 +00:00
//#pragma auto_inline()
2006-04-13 20:47:06 +00:00
# pragma optimize("",on)
# endif
2006-11-18 08:46:58 +00:00
static char terminx [ 64 ] = { " Undead TC still sucks. " } ;
2006-11-15 01:16:55 +00:00
char cheatquotes [ ] [ MAXCHEATLEN ] =
2007-08-25 01:05:00 +00:00
{
" cornholio " , // 0
" stuff " , // 1
" scotty### " , // 2
" coords " , // 3
" view " , // 4
" time " , // 5
" unlock " , // 6
" cashman " , // 7
" items " , // 8
" rate " , // 9
" skill# " , // 10
" beta " , // 11
" hyper " , // 12
" monsters " , // 13
" <RESERVED> " , // 14
" <RESERVED> " , // 15
" todd " , // 16
" showmap " , // 17
" kroz " , // 18
" allen " , // 19
" clip " , // 20
" weapons " , // 21
" inventory " , // 22
" keys " , // 23
" debug " , // 24
" <RESERVED> " , // 25
2007-08-26 10:35:52 +00:00
" sfm " , // 26
2007-08-25 01:05:00 +00:00
} ;
2006-11-15 01:16:55 +00:00
enum cheats
{
2006-04-13 20:47:06 +00:00
CHEAT_CORNHOLIO ,
CHEAT_STUFF ,
CHEAT_SCOTTY ,
CHEAT_COORDS ,
CHEAT_VIEW ,
CHEAT_TIME ,
CHEAT_UNLOCK ,
CHEAT_CASHMAN ,
CHEAT_ITEMS ,
CHEAT_RATE ,
CHEAT_SKILL ,
CHEAT_BETA ,
CHEAT_HYPER ,
CHEAT_MONSTERS ,
CHEAT_RESERVED ,
CHEAT_RESERVED2 ,
CHEAT_TODD ,
CHEAT_SHOWMAP ,
CHEAT_KROZ ,
CHEAT_ALLEN ,
CHEAT_CLIP ,
CHEAT_WEAPONS ,
CHEAT_INVENTORY ,
CHEAT_KEYS ,
CHEAT_DEBUG ,
CHEAT_RESERVED3 ,
2006-04-15 03:12:08 +00:00
CHEAT_SCREAMFORME ,
2006-04-13 20:47:06 +00:00
} ;
void CheatGetInventory ( void )
{
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 400 , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
OnEvent ( EVENT_CHEATGETSTEROIDS , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > steroids_amount =
GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 1200 , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
OnEvent ( EVENT_CHEATGETHEAT , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > heat_amount =
GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 200 , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
OnEvent ( EVENT_CHEATGETBOOT , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > boot_amount =
GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 100 , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
OnEvent ( EVENT_CHEATGETSHIELD , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > shield_amount =
GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 6400 , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
OnEvent ( EVENT_CHEATGETSCUBA , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > scuba_amount =
GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 2400 , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
OnEvent ( EVENT_CHEATGETHOLODUKE , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > holoduke_amount =
GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
SetGameVarID ( g_iReturnVarID , 1600 , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
OnEvent ( EVENT_CHEATGETJETPACK , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > jetpack_amount =
GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 23:11:49 +00:00
SetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > max_player_health , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2007-08-27 06:46:31 +00:00
OnEvent ( EVENT_CHEATGETFIRSTAID , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
if ( GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > firstaid_amount =
GetGameVarID ( g_iReturnVarID , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-19 08:24:46 +00:00
signed char cheatbuf [ MAXCHEATLEN ] , cheatbuflen ;
2006-04-13 20:47:06 +00:00
2006-12-10 06:49:01 +00:00
static void cheats ( void )
2006-04-13 20:47:06 +00:00
{
2006-11-14 19:58:59 +00:00
short ch , i , j , k = 0 , weapon ;
2006-12-23 02:38:47 +00:00
static int z = 0 ;
2006-04-13 20:47:06 +00:00
char consolecheat = 0 ; // JBF 20030914
2006-11-15 01:16:55 +00:00
if ( osdcmd_cheatsinfo_stat . cheatnum ! = - 1 )
2007-08-25 01:05:00 +00:00
{
// JBF 20030914
2006-04-13 20:47:06 +00:00
k = osdcmd_cheatsinfo_stat . cheatnum ;
osdcmd_cheatsinfo_stat . cheatnum = - 1 ;
consolecheat = 1 ;
}
2007-08-27 06:46:31 +00:00
if ( ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE ) | | ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) )
2006-04-13 20:47:06 +00:00
return ;
2006-11-15 01:16:55 +00:00
if ( VOLUMEONE & & ! z )
{
2006-07-21 22:25:05 +00:00
Bstrcpy ( cheatquotes [ 2 ] , " scotty## " ) ;
Bstrcpy ( cheatquotes [ 6 ] , " <RESERVED> " ) ;
2006-04-13 20:47:06 +00:00
z = 1 ;
}
if ( consolecheat & & numplayers < 2 & & ud . recstat = = 0 )
goto FOUNDCHEAT ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > cheat_phase = = 1 )
2006-04-13 20:47:06 +00:00
{
while ( KB_KeyWaiting ( ) )
{
ch = Btolower ( KB_Getch ( ) ) ;
2006-11-14 21:35:50 +00:00
if ( ! ( ( ch > = ' a ' & & ch < = ' z ' ) | | ( ch > = ' 0 ' & & ch < = ' 9 ' ) ) )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
// FTA(46,g_player[myconnectindex].ps);
2006-04-13 20:47:06 +00:00
return ;
}
cheatbuf [ cheatbuflen + + ] = ch ;
cheatbuf [ cheatbuflen ] = 0 ;
2006-08-20 22:17:12 +00:00
// KB_ClearKeysDown();
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( cheatbuflen > MAXCHEATLEN )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-04-13 20:47:06 +00:00
return ;
}
2006-11-13 23:12:47 +00:00
for ( k = 0 ; k < NUMCHEATCODES ; k + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
for ( j = 0 ; j < cheatbuflen ; j + + )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( cheatbuf [ j ] = = cheatquotes [ k ] [ j ] | | ( cheatquotes [ k ] [ j ] = = ' # ' & & ch > = ' 0 ' & & ch < = ' 9 ' ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( cheatquotes [ k ] [ j + 1 ] = = 0 ) goto FOUNDCHEAT ;
2006-11-13 23:12:47 +00:00
if ( j = = cheatbuflen - 1 ) return ;
2006-04-13 20:47:06 +00:00
}
else break ;
}
}
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-04-13 20:47:06 +00:00
return ;
FOUNDCHEAT :
{
2006-11-13 23:12:47 +00:00
switch ( k )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case CHEAT_WEAPONS :
2006-12-18 08:37:12 +00:00
2006-12-17 21:20:35 +00:00
j = 0 ;
2006-12-18 08:37:12 +00:00
2006-11-16 03:02:42 +00:00
if ( VOLUMEONE )
j = 6 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
for ( weapon = PISTOL_WEAPON ; weapon < MAX_WEAPONS - j ; weapon + + )
{
2007-08-27 23:11:49 +00:00
addammo ( weapon , g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > max_ammo_amount [ weapon ] ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gotweapon [ weapon ] = 1 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
FTA ( 119 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_INVENTORY :
KB_FlushKeyBoardQueue ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
CheatGetInventory ( ) ;
2007-08-27 06:46:31 +00:00
FTA ( 120 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_KEYS :
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > got_access = 7 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
FTA ( 121 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
return ;
case CHEAT_DEBUG :
debug_on = 1 - debug_on ;
KB_FlushKeyBoardQueue ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
dumpdebugdata ( ) ;
Bsprintf ( tempbuf , " GAMEVARS DUMPED TO DEBUG.CON " ) ;
adduserquote ( tempbuf ) ;
Bsprintf ( tempbuf , " MAP DUMPED TO DEBUG.MAP " ) ;
adduserquote ( tempbuf ) ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_CLIP :
ud . clipping = 1 - ud . clipping ;
KB_FlushKeyBoardQueue ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
FTA ( 112 + ud . clipping , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
return ;
case CHEAT_RESERVED2 :
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_EOL ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
case CHEAT_ALLEN :
2007-08-27 06:46:31 +00:00
FTA ( 79 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_ClearKeyDown ( sc_N ) ;
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_CORNHOLIO :
case CHEAT_KROZ :
ud . god = 1 - ud . god ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ud . god )
{
pus = 1 ;
pub = 1 ;
2007-08-27 06:46:31 +00:00
sprite [ g_player [ myconnectindex ] . ps - > i ] . cstat = 257 ;
2006-11-16 03:02:42 +00:00
2007-08-27 06:46:31 +00:00
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 0 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 1 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 2 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 3 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 4 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 5 ] = 0 ;
2006-11-16 03:02:42 +00:00
2007-08-27 06:46:31 +00:00
sprite [ g_player [ myconnectindex ] . ps - > i ] . hitag = 0 ;
sprite [ g_player [ myconnectindex ] . ps - > i ] . lotag = 0 ;
sprite [ g_player [ myconnectindex ] . ps - > i ] . pal = g_player [ myconnectindex ] . ps - > palookup ;
2006-11-16 03:02:42 +00:00
2007-08-27 06:46:31 +00:00
FTA ( 17 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
}
else
{
ud . god = 0 ;
2007-08-27 23:11:49 +00:00
sprite [ g_player [ myconnectindex ] . ps - > i ] . extra = g_player [ myconnectindex ] . ps - > max_player_health ;
2007-08-27 06:46:31 +00:00
hittype [ g_player [ myconnectindex ] . ps - > i ] . extra = - 1 ;
2007-08-27 23:11:49 +00:00
g_player [ myconnectindex ] . ps - > last_extra = g_player [ myconnectindex ] . ps - > max_player_health ;
2007-08-27 06:46:31 +00:00
FTA ( 18 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2007-08-27 23:11:49 +00:00
sprite [ g_player [ myconnectindex ] . ps - > i ] . extra = g_player [ myconnectindex ] . ps - > max_player_health ;
2007-08-27 06:46:31 +00:00
hittype [ g_player [ myconnectindex ] . ps - > i ] . extra = 0 ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_SCREAMFORME :
ud . god = 1 - ud . god ;
if ( ud . god )
{
pus = 1 ;
pub = 1 ;
2007-08-27 06:46:31 +00:00
sprite [ g_player [ myconnectindex ] . ps - > i ] . cstat = 257 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 0 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 1 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 2 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 3 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 4 ] = 0 ;
hittype [ g_player [ myconnectindex ] . ps - > i ] . temp_data [ 5 ] = 0 ;
sprite [ g_player [ myconnectindex ] . ps - > i ] . hitag = 0 ;
sprite [ g_player [ myconnectindex ] . ps - > i ] . lotag = 0 ;
sprite [ g_player [ myconnectindex ] . ps - > i ] . pal = g_player [ myconnectindex ] . ps - > palookup ;
2006-11-16 03:02:42 +00:00
Bstrcpy ( fta_quotes [ 122 ] , " Scream for me, Long Beach! " ) ;
2007-08-27 06:46:31 +00:00
FTA ( 122 , g_player [ myconnectindex ] . ps ) ;
2006-12-17 21:20:35 +00:00
CheatGetInventory ( ) ;
for ( weapon = PISTOL_WEAPON ; weapon < MAX_WEAPONS ; weapon + + )
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gotweapon [ weapon ] = 1 ;
2006-12-17 21:20:35 +00:00
for ( weapon = PISTOL_WEAPON ;
weapon < ( MAX_WEAPONS ) ;
weapon + + )
2007-08-27 23:11:49 +00:00
addammo ( weapon , g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > max_ammo_amount [ weapon ] ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > got_access = 7 ;
2006-11-16 03:02:42 +00:00
}
else
{
2007-08-27 23:11:49 +00:00
sprite [ g_player [ myconnectindex ] . ps - > i ] . extra = g_player [ myconnectindex ] . ps - > max_player_health ;
2007-08-27 06:46:31 +00:00
hittype [ g_player [ myconnectindex ] . ps - > i ] . extra = - 1 ;
2007-08-27 23:11:49 +00:00
g_player [ myconnectindex ] . ps - > last_extra = g_player [ myconnectindex ] . ps - > max_player_health ;
2007-08-27 06:46:31 +00:00
FTA ( 18 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
}
2007-08-27 23:11:49 +00:00
sprite [ g_player [ myconnectindex ] . ps - > i ] . extra = g_player [ myconnectindex ] . ps - > max_player_health ;
2007-08-27 06:46:31 +00:00
hittype [ g_player [ myconnectindex ] . ps - > i ] . extra = 0 ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
2006-11-19 03:02:36 +00:00
Bstrcpy ( terminx , terminx ) ;
2006-11-16 03:02:42 +00:00
return ;
case CHEAT_STUFF :
2006-12-17 21:20:35 +00:00
j = 0 ;
2006-12-18 08:37:12 +00:00
2006-11-16 03:02:42 +00:00
if ( VOLUMEONE )
j = 6 ;
2006-12-18 08:37:12 +00:00
2006-11-16 03:02:42 +00:00
for ( weapon = PISTOL_WEAPON ; weapon < MAX_WEAPONS - j ; weapon + + )
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gotweapon [ weapon ] = 1 ;
2006-11-16 03:02:42 +00:00
for ( weapon = PISTOL_WEAPON ;
weapon < ( MAX_WEAPONS - j ) ;
weapon + + )
2007-08-27 23:11:49 +00:00
addammo ( weapon , g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > max_ammo_amount [ weapon ] ) ;
2006-11-16 03:02:42 +00:00
CheatGetInventory ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > got_access = 7 ;
FTA ( 5 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
2007-08-27 06:46:31 +00:00
// FTA(21,g_player[myconnectindex].ps);
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > inven_icon = 1 ;
2006-11-16 03:02:42 +00:00
return ;
case CHEAT_SCOTTY :
case CHEAT_SKILL :
if ( k = = CHEAT_SCOTTY )
{
i = Bstrlen ( cheatquotes [ k ] ) - 3 + VOLUMEONE ;
if ( ! consolecheat )
2007-08-25 01:05:00 +00:00
{
// JBF 20030914
2006-11-16 03:02:42 +00:00
short volnume , levnume ;
if ( VOLUMEALL )
{
volnume = cheatbuf [ i ] - ' 0 ' ;
2006-12-17 01:08:39 +00:00
levnume = ( cheatbuf [ i + 1 ] - ' 0 ' ) * 10 + ( cheatbuf [ i + 2 ] - ' 0 ' ) ;
2006-11-16 03:02:42 +00:00
}
else
{
volnume = cheatbuf [ i ] - ' 0 ' ;
levnume = cheatbuf [ i + 1 ] - ' 0 ' ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
volnume - - ;
levnume - - ;
2006-04-13 20:47:06 +00:00
2006-12-17 21:20:35 +00:00
if ( ( VOLUMEONE & & volnume > 0 ) | | volnume > num_volumes - 1 | |
2007-08-26 11:28:32 +00:00
levnume > = MAXLEVELS | | map [ volnume * MAXLEVELS + levnume ] . filename = = NULL )
2006-11-16 03:02:42 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
}
ud . m_volume_number = ud . volume_number = volnume ;
ud . m_level_number = ud . level_number = levnume ;
}
else
2007-08-25 01:05:00 +00:00
{
// JBF 20030914
2006-11-16 03:02:42 +00:00
ud . m_volume_number = ud . volume_number = osdcmd_cheatsinfo_stat . volume ;
ud . m_level_number = ud . level_number = osdcmd_cheatsinfo_stat . level ;
}
}
else
{
i = Bstrlen ( cheatquotes [ k ] ) - 1 ;
ud . m_player_skill = ud . player_skill = cheatbuf [ i ] - ' 1 ' ;
}
if ( numplayers > 1 & & myconnectindex = = connecthead )
2006-12-12 08:46:32 +00:00
mpchangemap ( ud . m_volume_number , ud . m_level_number ) ;
2007-08-27 06:46:31 +00:00
else g_player [ myconnectindex ] . ps - > gm | = MODE_RESTART ;
2006-11-15 01:16:55 +00:00
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_COORDS :
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
ud . coords = 1 - ud . coords ;
KB_FlushKeyBoardQueue ( ) ;
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_VIEW :
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > over_shoulder_on )
g_player [ myconnectindex ] . ps - > over_shoulder_on = 0 ;
2006-11-16 03:02:42 +00:00
else
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > over_shoulder_on = 1 ;
2006-11-16 03:02:42 +00:00
cameradist = 0 ;
cameraclock = totalclock ;
}
2007-08-27 06:46:31 +00:00
FTA ( 22 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_TIME :
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
FTA ( 21 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
case CHEAT_UNLOCK :
if ( VOLUMEONE ) return ;
for ( i = numsectors - 1 ; i > = 0 ; i - - ) //Unlock
{
j = sector [ i ] . lotag ;
if ( j = = - 1 | | j = = 32767 ) continue ;
if ( ( j & 0x7fff ) > 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( j & ( 0xffff - 16384 ) )
sector [ i ] . lotag & = ( 0xffff - 16384 ) ;
2007-08-27 06:46:31 +00:00
operatesectors ( i , g_player [ myconnectindex ] . ps - > i ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2007-08-27 06:46:31 +00:00
operateforcefields ( g_player [ myconnectindex ] . ps - > i , - 1 ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
FTA ( 100 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_CASHMAN :
ud . cashman = 1 - ud . cashman ;
KB_ClearKeyDown ( sc_N ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_ITEMS :
CheatGetInventory ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > got_access = 7 ;
FTA ( 5 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CHEAT_SHOWMAP : // SHOW ALL OF THE MAP TOGGLE;
ud . showallmap = 1 - ud . showallmap ;
if ( ud . showallmap )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
for ( i = 0 ; i < ( MAXSECTORS > > 3 ) ; i + + )
show2dsector [ i ] = 255 ;
for ( i = 0 ; i < ( MAXWALLS > > 3 ) ; i + + )
show2dwall [ i ] = 255 ;
2007-08-27 06:46:31 +00:00
FTA ( 111 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
}
else
{
for ( i = 0 ; i < ( MAXSECTORS > > 3 ) ; i + + )
show2dsector [ i ] = 0 ;
for ( i = 0 ; i < ( MAXWALLS > > 3 ) ; i + + )
show2dwall [ i ] = 0 ;
2007-08-27 06:46:31 +00:00
FTA ( 1 , g_player [ myconnectindex ] . ps ) ;
2006-11-15 01:16:55 +00:00
}
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
case CHEAT_TODD :
2007-08-27 06:46:31 +00:00
FTA ( 99 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
case CHEAT_RATE :
ud . tickrate = ! ud . tickrate ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
case CHEAT_BETA :
2007-08-27 06:46:31 +00:00
FTA ( 105 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
KB_ClearKeyDown ( sc_H ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
case CHEAT_HYPER :
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > steroids_amount = 399 ;
g_player [ myconnectindex ] . ps - > heat_amount = 1200 ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
FTA ( 37 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
case CHEAT_MONSTERS :
{
2006-12-17 21:20:35 +00:00
char * s [ ] = { " ON " , " OFF " , " ON " } ;
2006-11-16 03:02:42 +00:00
actor_tog + + ;
if ( actor_tog = = 3 ) actor_tog = 0 ;
2007-08-27 06:46:31 +00:00
g_player [ screenpeek ] . ps - > cheat_phase = 0 ;
2006-11-19 08:24:46 +00:00
Bsprintf ( fta_quotes [ 122 ] , " MONSTERS: %s " , s [ ( unsigned char ) actor_tog ] ) ;
2007-08-27 06:46:31 +00:00
FTA ( 122 , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
}
case CHEAT_RESERVED :
case CHEAT_RESERVED3 :
ud . eog = 1 ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_EOL ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
return ;
2006-04-13 20:47:06 +00:00
}
}
}
}
else
{
2006-11-19 08:24:46 +00:00
if ( KB_KeyPressed ( ( unsigned char ) cheatkey [ 0 ] ) )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > cheat_phase > = 0 & & numplayers < 2 & & ud . recstat = = 0 )
2007-02-28 09:12:41 +00:00
{
2007-03-04 19:52:57 +00:00
if ( cheatkey [ 0 ] = = cheatkey [ 1 ] )
KB_ClearKeyDown ( ( unsigned char ) cheatkey [ 0 ] ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = - 1 ;
2007-03-01 00:50:59 +00:00
}
2006-04-13 20:47:06 +00:00
}
2006-11-19 08:24:46 +00:00
if ( KB_KeyPressed ( ( unsigned char ) cheatkey [ 1 ] ) )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > cheat_phase = = - 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( ud . player_skill = = 4 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
FTA ( 22 , g_player [ myconnectindex ] . ps ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-04-13 20:47:06 +00:00
}
else
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 1 ;
// FTA(25,g_player[myconnectindex].ps);
2006-04-13 20:47:06 +00:00
cheatbuflen = 0 ;
}
KB_FlushKeyboardQueue ( ) ;
}
2007-08-27 06:46:31 +00:00
else if ( g_player [ myconnectindex ] . ps - > cheat_phase ! = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2006-11-19 08:24:46 +00:00
KB_ClearKeyDown ( ( unsigned char ) cheatkey [ 0 ] ) ;
KB_ClearKeyDown ( ( unsigned char ) cheatkey [ 1 ] ) ;
2006-04-13 20:47:06 +00:00
}
}
}
}
2006-12-10 06:49:01 +00:00
static void nonsharedkeys ( void )
2006-04-13 20:47:06 +00:00
{
2007-01-05 22:30:35 +00:00
int i , ch ;
2006-04-13 20:47:06 +00:00
long j ;
2006-11-13 23:12:47 +00:00
if ( ud . recstat = = 2 )
2006-04-13 20:47:06 +00:00
{
ControlInfo noshareinfo ;
2006-11-14 21:35:50 +00:00
CONTROL_GetInput ( & noshareinfo ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . gotvote = = 0 & & voting ! = - 1 & & voting ! = myconnectindex )
2006-05-04 04:18:55 +00:00
{
2006-11-13 23:12:47 +00:00
if ( KB_KeyPressed ( sc_F1 ) | | KB_KeyPressed ( sc_F2 ) | | ud . autovote )
2006-05-04 04:18:55 +00:00
{
tempbuf [ 0 ] = 18 ;
tempbuf [ 1 ] = 0 ;
tempbuf [ 2 ] = myconnectindex ;
2006-05-04 23:51:11 +00:00
tempbuf [ 3 ] = ( KB_KeyPressed ( sc_F1 ) | | ud . autovote ? ud . autovote - 1 : 0 ) ;
2006-05-04 04:18:55 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-05-04 04:18:55 +00:00
{
if ( i ! = myconnectindex ) sendpacket ( i , tempbuf , 4 ) ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
adduserquote ( " VOTE CAST " ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . gotvote = 1 ;
2006-05-04 04:18:55 +00:00
KB_ClearKeyDown ( sc_F1 ) ;
KB_ClearKeyDown ( sc_F2 ) ;
2006-06-07 00:07:39 +00:00
voting = - 1 ;
2006-05-04 04:18:55 +00:00
}
}
2007-08-27 06:46:31 +00:00
if ( ! ALT_IS_PRESSED & & ud . overhead_on = = 0 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( BUTTON ( gamefunc_Enlarge_Screen ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
CONTROL_ClearButton ( gamefunc_Enlarge_Screen ) ;
2007-02-13 01:28:50 +00:00
if ( ! SHIFTS_IS_PRESSED )
{
if ( ud . screen_size > 0 )
sound ( THUD ) ;
if ( ud . screen_size = = 8 & & ud . statusbarmode = = 0 & & bpp > 8 )
ud . statusbarmode = 1 ;
else ud . screen_size - = 4 ;
if ( ud . statusbarscale = = 100 & & ud . statusbarmode = = 1 )
{
ud . statusbarmode = 0 ;
ud . screen_size - = 4 ;
}
}
else
{
2007-02-13 09:50:58 +00:00
ud . statusbarscale + = 4 ;
2007-02-13 01:28:50 +00:00
setstatusbarscale ( ud . statusbarscale ) ;
}
2006-04-13 20:47:06 +00:00
vscrn ( ) ;
}
2007-02-13 01:28:50 +00:00
2006-11-14 21:35:50 +00:00
if ( BUTTON ( gamefunc_Shrink_Screen ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
CONTROL_ClearButton ( gamefunc_Shrink_Screen ) ;
2007-02-13 01:28:50 +00:00
if ( ! SHIFTS_IS_PRESSED )
{
if ( ud . screen_size < 64 ) sound ( THUD ) ;
if ( ud . screen_size = = 8 & & ud . statusbarmode = = 1 & & bpp > 8 )
ud . statusbarmode = 0 ;
else ud . screen_size + = 4 ;
}
else
{
2007-02-13 09:50:58 +00:00
ud . statusbarscale - = 4 ;
2007-02-13 01:28:50 +00:00
if ( ud . statusbarscale < 37 )
ud . statusbarscale = 37 ;
setstatusbarscale ( ud . statusbarscale ) ;
}
2006-04-13 20:47:06 +00:00
vscrn ( ) ;
}
}
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > cheat_phase = = 1 | | ( g_player [ myconnectindex ] . ps - > gm & ( MODE_MENU | MODE_TYPE ) ) ) return ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( BUTTON ( gamefunc_See_Coop_View ) & & ( GTFLAGS ( GAMETYPE_FLAG_COOPVIEW ) | | ud . recstat = = 2 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
CONTROL_ClearButton ( gamefunc_See_Coop_View ) ;
2006-04-13 20:47:06 +00:00
screenpeek = connectpoint2 [ screenpeek ] ;
2006-11-13 23:12:47 +00:00
if ( screenpeek = = - 1 ) screenpeek = connecthead ;
2006-04-13 20:47:06 +00:00
restorepalette = 1 ;
}
2006-11-14 21:35:50 +00:00
if ( ud . multimode > 1 & & BUTTON ( gamefunc_Show_Opponents_Weapon ) )
2006-04-13 20:47:06 +00:00
{
CONTROL_ClearButton ( gamefunc_Show_Opponents_Weapon ) ;
ud . showweapons = 1 - ud . showweapons ;
2007-08-27 00:20:15 +00:00
ud . config . ShowOpponentWeapons = ud . showweapons ;
2007-08-27 06:46:31 +00:00
FTA ( 82 - ud . showweapons , g_player [ screenpeek ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( BUTTON ( gamefunc_Toggle_Crosshair ) )
2006-04-13 20:47:06 +00:00
{
CONTROL_ClearButton ( gamefunc_Toggle_Crosshair ) ;
2006-04-23 07:16:16 +00:00
ud . crosshair = ( ud . crosshair = = 3 ) ? 0 : ud . crosshair + 1 ;
2007-08-27 06:46:31 +00:00
FTA ( ud . crosshair ? 20 : 21 , g_player [ screenpeek ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( ud . overhead_on & & BUTTON ( gamefunc_Map_Follow_Mode ) )
2006-04-13 20:47:06 +00:00
{
CONTROL_ClearButton ( gamefunc_Map_Follow_Mode ) ;
ud . scrollmode = 1 - ud . scrollmode ;
2006-11-13 23:12:47 +00:00
if ( ud . scrollmode )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
ud . folx = g_player [ screenpeek ] . ps - > oposx ;
ud . foly = g_player [ screenpeek ] . ps - > oposy ;
ud . fola = g_player [ screenpeek ] . ps - > oang ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
FTA ( 83 + ud . scrollmode , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( SHIFTS_IS_PRESSED | | ALT_IS_PRESSED )
2006-04-13 20:47:06 +00:00
{
i = 0 ;
2006-11-15 01:16:55 +00:00
if ( KB_KeyPressed ( sc_F1 ) )
{
KB_ClearKeyDown ( sc_F1 ) ;
i = 1 ;
}
if ( KB_KeyPressed ( sc_F2 ) )
{
KB_ClearKeyDown ( sc_F2 ) ;
i = 2 ;
}
if ( KB_KeyPressed ( sc_F3 ) )
{
KB_ClearKeyDown ( sc_F3 ) ;
i = 3 ;
}
if ( KB_KeyPressed ( sc_F4 ) )
{
KB_ClearKeyDown ( sc_F4 ) ;
i = 4 ;
}
if ( KB_KeyPressed ( sc_F5 ) )
{
KB_ClearKeyDown ( sc_F5 ) ;
i = 5 ;
}
if ( KB_KeyPressed ( sc_F6 ) )
{
KB_ClearKeyDown ( sc_F6 ) ;
i = 6 ;
}
if ( KB_KeyPressed ( sc_F7 ) )
{
KB_ClearKeyDown ( sc_F7 ) ;
i = 7 ;
}
if ( KB_KeyPressed ( sc_F8 ) )
{
KB_ClearKeyDown ( sc_F8 ) ;
i = 8 ;
}
if ( KB_KeyPressed ( sc_F9 ) )
{
KB_ClearKeyDown ( sc_F9 ) ;
i = 9 ;
}
if ( KB_KeyPressed ( sc_F10 ) )
{
KB_ClearKeyDown ( sc_F10 ) ;
i = 10 ;
}
2006-11-13 23:12:47 +00:00
if ( i )
{
if ( SHIFTS_IS_PRESSED )
{
2007-08-27 06:46:31 +00:00
if ( i = = 5 & & g_player [ myconnectindex ] . ps - > fta > 0 & & g_player [ myconnectindex ] . ps - > ftq = = 26 )
2006-04-13 20:47:06 +00:00
{
2006-12-06 23:14:49 +00:00
i = ( VOLUMEALL ? MAXVOLUMES * MAXLEVELS : 6 ) ;
2006-04-13 20:47:06 +00:00
music_select + + ;
2007-08-26 11:28:32 +00:00
while ( ( map [ ( unsigned char ) music_select ] . musicfn = = NULL ) & & music_select < i )
2006-04-16 03:42:36 +00:00
music_select + + ;
2006-11-13 23:12:47 +00:00
if ( music_select = = i )
2006-04-16 03:42:36 +00:00
music_select = 0 ;
2007-08-26 11:28:32 +00:00
if ( map [ ( unsigned char ) music_select ] . musicfn ! = NULL )
2006-12-06 23:14:49 +00:00
{
2007-08-26 11:28:32 +00:00
Bsprintf ( fta_quotes [ 26 ] , " PLAYING %s " , & map [ ( unsigned char ) music_select ] . musicfn [ 0 ] ) ;
2007-08-27 06:46:31 +00:00
FTA ( 26 , g_player [ myconnectindex ] . ps ) ;
2007-08-26 11:28:32 +00:00
playmusic ( & map [ ( unsigned char ) music_select ] . musicfn [ 0 ] ) ;
2006-12-06 23:14:49 +00:00
}
2006-04-13 20:47:06 +00:00
return ;
}
adduserquote ( ud . ridecule [ i - 1 ] ) ;
ch = 0 ;
tempbuf [ ch ] = 4 ;
tempbuf [ ch + 1 ] = 255 ;
tempbuf [ ch + 2 ] = 0 ;
2006-07-21 22:25:05 +00:00
Bstrcat ( tempbuf + 2 , ud . ridecule [ i - 1 ] ) ;
2006-04-13 20:47:06 +00:00
i = 2 + strlen ( ud . ridecule [ i - 1 ] ) ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode > 1 )
for ( ch = connecthead ; ch > = 0 ; ch = connectpoint2 [ ch ] )
2006-04-13 20:47:06 +00:00
{
if ( ch ! = myconnectindex ) sendpacket ( ch , tempbuf , i ) ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
pus = NUMPAGES ;
pub = NUMPAGES ;
return ;
}
2006-11-13 23:12:47 +00:00
if ( ud . lockout = = 0 )
2007-08-27 00:20:15 +00:00
if ( ud . config . SoundToggle & & ALT_IS_PRESSED & & ( RTS_NumSounds ( ) > 0 ) & & rtsplaying = = 0 & & ud . config . VoiceToggle )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
rtsptr = ( char * ) RTS_GetSound ( i - 1 ) ;
2006-11-13 23:12:47 +00:00
if ( * rtsptr = = ' C ' )
2006-11-14 21:35:50 +00:00
FX_PlayVOC3D ( rtsptr , 0 , 0 , 0 , 255 , - i ) ;
else FX_PlayWAV3D ( rtsptr , 0 , 0 , 0 , 255 , - i ) ;
2006-04-13 20:47:06 +00:00
rtsplaying = 7 ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode > 1 )
2006-04-13 20:47:06 +00:00
{
tempbuf [ 0 ] = 7 ;
tempbuf [ 1 ] = i ;
2006-11-13 23:12:47 +00:00
for ( ch = connecthead ; ch > = 0 ; ch = connectpoint2 [ ch ] )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( ch ! = myconnectindex ) sendpacket ( ch , tempbuf , 2 ) ;
2006-04-13 20:47:06 +00:00
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
}
pus = NUMPAGES ;
pub = NUMPAGES ;
return ;
}
}
}
2006-11-13 23:12:47 +00:00
if ( ! ALT_IS_PRESSED & & ! SHIFTS_IS_PRESSED )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ud . multimode > 1 & & BUTTON ( gamefunc_SendMessage ) )
2006-04-13 20:47:06 +00:00
{
KB_FlushKeyboardQueue ( ) ;
2006-11-14 21:35:50 +00:00
CONTROL_ClearButton ( gamefunc_SendMessage ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_TYPE ;
2006-04-13 20:47:06 +00:00
typebuf [ 0 ] = 0 ;
inputloc = 0 ;
}
2006-12-12 04:31:51 +00:00
if ( KB_KeyPressed ( sc_F1 ) | | ( ud . show_help & & ( KB_KeyPressed ( sc_Space ) | | KB_KeyPressed ( sc_Enter ) | | KB_KeyPressed ( sc_kpad_Enter ) | | MOUSE_GetButtons ( ) & LEFT_MOUSE ) ) )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_F1 ) ;
KB_ClearKeyDown ( sc_Space ) ;
KB_ClearKeyDown ( sc_kpad_Enter ) ;
KB_ClearKeyDown ( sc_Enter ) ;
2006-12-12 04:31:51 +00:00
MOUSE_ClearButton ( LEFT_MOUSE ) ;
2006-04-13 20:47:06 +00:00
ud . show_help + + ;
2006-11-14 21:35:50 +00:00
if ( ud . show_help > 2 )
2006-04-13 20:47:06 +00:00
{
ud . show_help = 0 ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 & & ud . recstat ! = 2 ) ready2send = 1 ;
2006-04-13 20:47:06 +00:00
vscrn ( ) ;
}
else
{
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 & & ud . recstat ! = 2 )
2006-04-13 20:47:06 +00:00
{
ready2send = 0 ;
totalclock = ototalclock ;
}
}
}
// if(ud.multimode < 2)
{
2006-11-14 21:35:50 +00:00
if ( ud . recstat ! = 2 & & KB_KeyPressed ( sc_F2 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F2 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( movesperpacket = = 4 & & connecthead ! = myconnectindex )
2006-04-13 20:47:06 +00:00
return ;
FAKE_F2 :
2007-08-27 06:46:31 +00:00
if ( sprite [ g_player [ myconnectindex ] . ps - > i ] . extra < = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
FTA ( 118 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
return ;
}
cmenu ( 350 ) ;
screencapt = 1 ;
displayrooms ( myconnectindex , 65536 ) ;
//savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100);
screencapt = 0 ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
// setview(0,0,xdim-1,ydim-1);
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 )
2006-04-13 20:47:06 +00:00
{
ready2send = 0 ;
totalclock = ototalclock ;
screenpeek = myconnectindex ;
}
}
2006-11-14 21:35:50 +00:00
if ( KB_KeyPressed ( sc_F3 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F3 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( movesperpacket = = 4 & & connecthead ! = myconnectindex )
2006-04-13 20:47:06 +00:00
return ;
FAKE_F3 :
cmenu ( 300 ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
// setview(0,0,xdim-1,ydim-1);
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 & & ud . recstat ! = 2 )
2006-04-13 20:47:06 +00:00
{
ready2send = 0 ;
totalclock = ototalclock ;
}
screenpeek = myconnectindex ;
}
}
2007-08-27 00:20:15 +00:00
if ( KB_KeyPressed ( sc_F4 ) & & ud . config . FXDevice > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F4 ) ;
2006-04-13 20:47:06 +00:00
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 & & ud . recstat ! = 2 )
2006-04-13 20:47:06 +00:00
{
ready2send = 0 ;
totalclock = ototalclock ;
}
cmenu ( 701 ) ;
}
2007-08-27 06:46:31 +00:00
if ( KB_KeyPressed ( sc_F6 ) & & ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F6 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( movesperpacket = = 4 & & connecthead ! = myconnectindex )
2006-04-13 20:47:06 +00:00
return ;
2006-11-13 23:12:47 +00:00
if ( lastsavedpos = = - 1 ) goto FAKE_F2 ;
2006-04-13 20:47:06 +00:00
KB_FlushKeyboardQueue ( ) ;
2007-08-27 06:46:31 +00:00
if ( sprite [ g_player [ myconnectindex ] . ps - > i ] . extra < = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
FTA ( 118 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
return ;
}
screencapt = 1 ;
displayrooms ( myconnectindex , 65536 ) ;
//savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100);
screencapt = 0 ;
2006-11-14 21:35:50 +00:00
if ( lastsavedpos > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-07-21 22:25:05 +00:00
/* inputloc = Bstrlen(&ud.savegame[lastsavedpos][0]);
2006-04-16 03:42:36 +00:00
current_menu = 360 + lastsavedpos ;
probey = lastsavedpos ; */
2006-11-13 23:12:47 +00:00
if ( ud . multimode > 1 )
2006-04-13 20:47:06 +00:00
saveplayer ( - 1 - ( lastsavedpos ) ) ;
else saveplayer ( lastsavedpos ) ;
}
}
2006-11-14 21:35:50 +00:00
if ( KB_KeyPressed ( sc_F7 ) )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_F7 ) ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > over_shoulder_on )
g_player [ myconnectindex ] . ps - > over_shoulder_on = 0 ;
2006-04-13 20:47:06 +00:00
else
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > over_shoulder_on = 1 ;
2006-04-13 20:47:06 +00:00
cameradist = 0 ;
cameraclock = totalclock ;
}
2007-08-27 06:46:31 +00:00
FTA ( 109 + g_player [ myconnectindex ] . ps - > over_shoulder_on , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 00:20:15 +00:00
if ( KB_KeyPressed ( sc_F5 ) & & ud . config . MusicDevice > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F5 ) ;
2007-08-26 11:28:32 +00:00
if ( map [ ( unsigned char ) music_select ] . musicfn ! = NULL )
Bstrcpy ( fta_quotes [ 26 ] , & map [ ( unsigned char ) music_select ] . musicfn [ 0 ] ) ;
2006-12-06 23:14:49 +00:00
else fta_quotes [ 26 ] [ 0 ] = ' \0 ' ;
2006-04-23 02:20:42 +00:00
Bstrcat ( fta_quotes [ 26 ] , " . USE SHIFT-F5 TO CHANGE. " ) ;
2007-08-27 06:46:31 +00:00
FTA ( 26 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( KB_KeyPressed ( sc_F8 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F8 ) ;
2006-04-13 20:47:06 +00:00
ud . fta_on = ! ud . fta_on ;
2007-08-27 06:46:31 +00:00
if ( ud . fta_on ) FTA ( 23 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
else
{
ud . fta_on = 1 ;
2007-08-27 06:46:31 +00:00
FTA ( 24 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
ud . fta_on = 0 ;
}
}
2007-08-27 06:46:31 +00:00
if ( KB_KeyPressed ( sc_F9 ) & & ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F9 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( movesperpacket = = 4 & & myconnectindex ! = connecthead )
2006-04-13 20:47:06 +00:00
return ;
2006-11-13 23:12:47 +00:00
if ( lastsavedpos = = - 1 ) goto FAKE_F3 ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( lastsavedpos > = 0 )
2006-04-16 03:42:36 +00:00
{
KB_FlushKeyboardQueue ( ) ;
KB_ClearKeysDown ( ) ;
FX_StopAllSounds ( ) ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode > 1 )
2006-04-16 03:42:36 +00:00
{
loadplayer ( - 1 - lastsavedpos ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_GAME ;
2006-04-16 03:42:36 +00:00
}
else
{
i = loadplayer ( lastsavedpos ) ;
2006-11-13 23:12:47 +00:00
if ( i = = 0 )
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_GAME ;
2006-04-16 03:42:36 +00:00
}
}
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( KB_KeyPressed ( sc_F10 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F10 ) ;
2006-04-13 20:47:06 +00:00
cmenu ( 500 ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 & & ud . recstat ! = 2 )
2006-04-13 20:47:06 +00:00
{
ready2send = 0 ;
totalclock = ototalclock ;
}
}
2006-11-14 21:35:50 +00:00
if ( ud . overhead_on ! = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
j = totalclock - nonsharedtimer ;
nonsharedtimer + = j ;
2006-11-14 21:35:50 +00:00
if ( BUTTON ( gamefunc_Enlarge_Screen ) )
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > zoom + = mulscale6 ( j , max ( g_player [ myconnectindex ] . ps - > zoom , 256 ) ) ;
2006-11-14 21:35:50 +00:00
if ( BUTTON ( gamefunc_Shrink_Screen ) )
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > zoom - = mulscale6 ( j , max ( g_player [ myconnectindex ] . ps - > zoom , 256 ) ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( ( g_player [ myconnectindex ] . ps - > zoom > 2048 ) )
g_player [ myconnectindex ] . ps - > zoom = 2048 ;
if ( ( g_player [ myconnectindex ] . ps - > zoom < 48 ) )
g_player [ myconnectindex ] . ps - > zoom = 48 ;
2006-04-13 20:47:06 +00:00
}
}
2007-08-27 06:46:31 +00:00
if ( KB_KeyPressed ( sc_Escape ) & & ud . overhead_on & & g_player [ myconnectindex ] . ps - > newowner = = - 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_Escape ) ;
2006-04-13 20:47:06 +00:00
ud . last_overhead = ud . overhead_on ;
ud . overhead_on = 0 ;
ud . scrollmode = 0 ;
vscrn ( ) ;
}
2006-11-14 21:35:50 +00:00
if ( BUTTON ( gamefunc_AutoRun ) )
2006-04-13 20:47:06 +00:00
{
CONTROL_ClearButton ( gamefunc_AutoRun ) ;
ud . auto_run = 1 - ud . auto_run ;
2007-08-27 00:20:15 +00:00
ud . config . RunMode = ud . auto_run ;
2007-08-27 06:46:31 +00:00
FTA ( 85 + ud . auto_run , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( BUTTON ( gamefunc_Map ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
CONTROL_ClearButton ( gamefunc_Map ) ;
if ( ud . last_overhead ! = ud . overhead_on & & ud . last_overhead )
2006-04-13 20:47:06 +00:00
{
ud . overhead_on = ud . last_overhead ;
ud . last_overhead = 0 ;
}
else
{
ud . overhead_on + + ;
2006-11-14 21:35:50 +00:00
if ( ud . overhead_on = = 3 ) ud . overhead_on = 0 ;
2006-04-13 20:47:06 +00:00
ud . last_overhead = ud . overhead_on ;
}
restorepalette = 1 ;
vscrn ( ) ;
}
2006-11-14 21:35:50 +00:00
if ( KB_KeyPressed ( sc_F11 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_F11 ) ;
2007-01-05 22:30:35 +00:00
ud . brightness + = 8 ;
if ( SHIFTS_IS_PRESSED ) ud . brightness - = 16 ;
2006-04-13 20:47:06 +00:00
2006-12-23 02:38:47 +00:00
if ( ud . brightness > ( 7 < < 3 ) )
2006-04-13 20:47:06 +00:00
ud . brightness = 0 ;
2006-11-13 23:12:47 +00:00
else if ( ud . brightness < 0 )
2006-12-23 02:38:47 +00:00
ud . brightness = ( 7 < < 3 ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
setbrightness ( ud . brightness > > 2 , & g_player [ myconnectindex ] . ps - > palette [ 0 ] , 0 ) ;
if ( ud . brightness < 40 ) FTA ( 29 + ( ud . brightness > > 3 ) , g_player [ myconnectindex ] . ps ) ;
else if ( ud . brightness < 80 ) FTA ( 96 + ( ud . brightness > > 3 ) - 5 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-12-10 06:49:01 +00:00
static void comlinehelp ( void )
2006-04-13 20:47:06 +00:00
{
2007-01-22 05:00:57 +00:00
char * s = " Usage: eduke32 [OPTIONS] \n "
" Example: eduke32 -q4 -a -m -tx -map nukeland.map \n \n "
" -NUM \t \t Load and run a game from slot NUM (0-9) \n "
" -a \t \t Use fake player AI (fake multiplayer only) \n "
" -cNUM \t \t Use MP mode NUM, 1 = DukeMatch(spawn), 2 = Coop, 3 = Dukematch(no spawn) \n "
2007-02-26 01:46:38 +00:00
" -cfg FILE \t Use configuration file FILE \n "
2006-04-13 20:47:06 +00:00
" -dFILE \t \t Start to play demo FILE \n "
2007-02-05 01:33:08 +00:00
/* "-fNUM\t\tSend fewer packets in multiplayer (1, 2, 4) (deprecated)\n" */
2007-01-24 03:42:54 +00:00
" -game_dir DIR \t See -j \n "
" -gFILE, -grp FILE \t Use extra group file FILE \n "
2007-01-22 05:00:57 +00:00
" -hFILE \t \t Use definitions file FILE \n "
" -iNUM \t \t Use networking mode NUM (1/0) (multiplayer only) (default == 1) \n "
2007-01-24 03:42:54 +00:00
" -jDIR \t \t Adds DIR to the file path stack \n "
2007-01-22 05:00:57 +00:00
" -lNUM \t \t Warp to level NUM (1-11), see -v \n "
" -m \t \t Disable monsters \n "
" -map FILE \t Use user map FILE \n "
" -name NAME \t Use NAME as multiplayer name \n "
" -nD \t \t Dump default gamevars to gamevars.txt \n "
2007-04-15 20:04:52 +00:00
" -net PARAMETERS \t Enable network play (see documentation for parameters) \n "
2007-01-22 05:00:57 +00:00
" -nm \t \t Disable music \n "
" -ns \t \t Disable sound \n "
" -qNUM \t \t Use NUM players for fake multiplayer (2-8) \n "
" -r \t \t Record demo \n "
2007-02-05 01:33:08 +00:00
" -rmnet FILE \t Use FILE for network play configuration (see documentation) \n "
2007-01-22 05:00:57 +00:00
" -sNUM \t \t Use skill level NUM (1-4) \n "
2007-01-22 02:35:54 +00:00
# if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
2006-07-01 01:40:18 +00:00
" -setup \t \t Displays the configuration dialog \n "
2007-01-22 02:35:54 +00:00
# endif
2007-01-22 05:00:57 +00:00
" -tNUM \t \t Use respawn mode NUM, 1 = Monsters, 2 = Items, 3 = Inventory, x = All \n "
" -u######### \t User's favorite weapon order (default: 3425689071) \n "
2006-07-01 01:40:18 +00:00
# if !defined(_WIN32)
" -usecwd \t \t Read game data and configuration file from working directory \n "
# endif
2007-01-22 05:00:57 +00:00
" -vNUM \t \t Warp to volume NUM (1-4), see -l \n "
" -xFILE \t \t Load CON script FILE (default EDUKE.CON/GAME.CON) \n "
" -zNUM, -condebug \t Line-by-line CON compilation debugging, NUM is verbosity \n "
" \n -?, -help, --help \t Display this help message and exit "
2006-09-29 05:01:33 +00:00
;
2007-01-24 03:42:54 +00:00
wm_msgbox ( HEAD2 , s ) ;
2006-04-13 20:47:06 +00:00
}
2007-02-05 01:33:08 +00:00
static signed int rancid_players = 0 ;
static char rancid_ip_strings [ MAXPLAYERS ] [ 32 ] , rancid_local_port_string [ 8 ] ;
2006-05-01 05:03:44 +00:00
2006-12-14 03:34:55 +00:00
extern int getexternaladdress ( char * buffer ) ;
2006-05-02 02:57:11 +00:00
2007-02-16 00:11:25 +00:00
static int load_rancid_net ( const char * fn )
2006-05-01 05:03:44 +00:00
{
int tokn ;
char * cmdtokptr ;
2006-08-07 06:18:57 +00:00
2006-12-04 02:10:18 +00:00
tokenlist rancidtokens [ ] =
2007-08-25 01:05:00 +00:00
{
{ " interface " , T_INTERFACE } ,
{ " mode " , T_MODE } ,
{ " allow " , T_ALLOW } ,
} ;
2006-12-04 02:10:18 +00:00
2006-08-07 06:18:57 +00:00
scriptfile * script ;
2007-02-16 00:11:25 +00:00
script = scriptfile_fromfile ( ( char * ) fn ) ;
2006-08-07 06:18:57 +00:00
if ( ! script ) return - 1 ;
2006-11-15 01:16:55 +00:00
while ( 1 )
{
2006-07-26 01:10:33 +00:00
tokn = getatoken ( script , rancidtokens , sizeof ( rancidtokens ) / sizeof ( tokenlist ) ) ;
2006-05-01 05:03:44 +00:00
cmdtokptr = script - > ltextptr ;
2006-11-15 01:16:55 +00:00
switch ( tokn )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
case T_INTERFACE :
{
char * ip ;
2006-05-02 02:57:11 +00:00
2006-11-16 03:02:42 +00:00
if ( scriptfile_getstring ( script , & ip ) ) break ;
2006-11-17 08:22:52 +00:00
Bstrcpy ( rancid_ip_strings [ MAXPLAYERS - 1 ] , ip ) ;
2006-11-16 03:02:42 +00:00
Bstrcpy ( rancid_ip_strings [ rancid_players + + ] , ip ) ;
2007-02-11 22:05:50 +00:00
if ( strtok ( ip , " : " ) )
{
char * p = strtok ( NULL , " : " ) ;
2007-02-13 01:28:50 +00:00
2007-02-11 22:05:50 +00:00
if ( p ! = NULL )
{
2007-02-12 07:58:03 +00:00
if ( atoi ( p ) > 1024 )
Bsprintf ( rancid_local_port_string , " -p %s " , p ) ;
2007-02-11 22:05:50 +00:00
}
}
2006-11-16 03:02:42 +00:00
}
break ;
case T_MODE :
{
char * mode ;
2006-05-02 02:57:11 +00:00
2006-11-16 03:02:42 +00:00
if ( scriptfile_getstring ( script , & mode ) ) break ;
}
break ;
case T_ALLOW :
{
char * ip ;
2006-05-02 02:57:11 +00:00
2006-11-16 03:02:42 +00:00
if ( scriptfile_getstring ( script , & ip ) ) break ;
Bstrcpy ( rancid_ip_strings [ rancid_players + + ] , ip ) ;
}
break ;
case T_EOF :
return ( 0 ) ;
default :
2006-05-01 05:03:44 +00:00
break ;
}
}
scriptfile_close ( script ) ;
scriptfile_clearsymbols ( ) ;
return 0 ;
}
2007-02-05 01:33:08 +00:00
static inline int stringsort ( const char * p1 , const char * p2 )
2006-05-01 06:30:33 +00:00
{
return Bstrcmp ( & p1 [ 0 ] , & p2 [ 0 ] ) ;
}
2006-11-30 04:36:20 +00:00
2007-02-16 00:11:25 +00:00
static void setup_rancid_net ( const char * fn )
2006-11-30 04:36:20 +00:00
{
int i ;
if ( load_rancid_net ( fn ) ! = - 1 )
{
char tmp [ 32 ] ;
2006-12-01 01:20:59 +00:00
if ( ! Bstrlen ( rancid_ip_strings [ MAXPLAYERS - 1 ] ) | | ! Bstrlen ( rancid_ip_strings [ 1 ] ) )
{
if ( ! Bstrlen ( rancid_ip_strings [ MAXPLAYERS - 1 ] ) )
initprintf ( " rmnet: Interface not defined \n " ) ;
if ( ! Bstrlen ( rancid_ip_strings [ 1 ] ) )
initprintf ( " rmnet: No peers configured \n " ) ;
gameexit ( " Malformed network configuration file! " ) ;
return ;
}
2007-08-26 10:35:52 +00:00
if ( g_KeepAddr = = 0 )
2006-11-30 04:36:20 +00:00
{
for ( i = 0 ; i < rancid_players ; i + + )
{
2007-01-26 00:28:44 +00:00
if ( Bstrcmp ( rancid_ip_strings [ i ] , rancid_ip_strings [ MAXPLAYERS - 1 ] ) )
2006-11-30 04:36:20 +00:00
{
Bstrncpy ( tempbuf , rancid_ip_strings [ i ] , 8 ) ;
Bstrcpy ( tmp , strtok ( tempbuf , " . " ) ) ;
if ( Bstrcmp ( tmp , " 10 " ) = = 0 )
{
i = 0 ;
break ;
}
else if ( Bstrcmp ( tmp , " 192 " ) = = 0 )
{
Bstrcpy ( tmp , strtok ( NULL , " . " ) ) ;
if ( Bstrcmp ( tmp , " 168 " ) = = 0 )
{
i = 0 ;
break ;
}
}
else if ( Bstrcmp ( tmp , " 172 " ) = = 0 )
{
Bstrcpy ( tmp , strtok ( NULL , " . " ) ) ;
if ( Bstrcmp ( tmp , " 16 " ) = = 0 )
{
i = 0 ;
break ;
}
}
else if ( Bstrcmp ( tmp , " 169 " ) = = 0 )
{
Bstrcpy ( tmp , strtok ( NULL , " . " ) ) ;
if ( Bstrcmp ( tmp , " 254 " ) = = 0 )
{
i = 0 ;
break ;
}
}
}
}
Bstrcpy ( tempbuf , rancid_ip_strings [ MAXPLAYERS - 1 ] ) ;
Bstrcpy ( tmp , strtok ( tempbuf , " . " ) ) ;
if ( i = = rancid_players & & ( ( Bstrcmp ( tmp , " 192 " ) = = 0 ) | | ( Bstrcmp ( tmp , " 172 " ) = = 0 ) | | ( Bstrcmp ( tmp , " 169 " ) = = 0 ) | | ( Bstrcmp ( tmp , " 10 " ) = = 0 ) ) )
{
2006-12-14 03:34:55 +00:00
if ( getexternaladdress ( tempbuf ) )
2006-11-30 04:36:20 +00:00
{
2006-12-14 03:34:55 +00:00
if ( tempbuf [ 0 ] )
2006-11-30 04:36:20 +00:00
{
2006-12-14 03:34:55 +00:00
for ( i = 0 ; i < rancid_players ; i + + )
2006-11-30 04:36:20 +00:00
{
2006-12-14 03:34:55 +00:00
if ( Bstrcmp ( rancid_ip_strings [ i ] , rancid_ip_strings [ MAXPLAYERS - 1 ] ) = = 0 )
{
Bstrcpy ( rancid_ip_strings [ MAXPLAYERS - 1 ] , tempbuf ) ;
Bstrcpy ( rancid_ip_strings [ i ] , tempbuf ) ;
}
2006-11-30 04:36:20 +00:00
}
}
}
}
}
qsort ( ( char * ) rancid_ip_strings , rancid_players , sizeof ( rancid_ip_strings [ 0 ] ) , ( int ( * ) ( const void * , const void * ) ) stringsort ) ;
2006-12-01 04:22:16 +00:00
networkmode = 1 ;
2006-11-30 04:36:20 +00:00
netparamcount = rancid_players ;
if ( rancid_local_port_string [ 0 ] = = ' - ' )
netparamcount + + ;
netparam = ( char * * ) calloc ( netparamcount , sizeof ( char * * ) ) ;
for ( i = 0 ; i < rancid_players ; i + + )
{
if ( Bstrcmp ( rancid_ip_strings [ i ] , rancid_ip_strings [ MAXPLAYERS - 1 ] ) = = 0 )
Bsprintf ( rancid_ip_strings [ i ] , " /n1 " ) ;
netparam [ i ] = ( char * ) & rancid_ip_strings [ i ] ;
}
if ( i ! = netparamcount )
netparam [ i ] = ( char * ) & rancid_local_port_string ;
}
}
2006-05-01 06:30:33 +00:00
2007-03-21 20:37:24 +00:00
static CACHE1D_FIND_REC * finddirs = NULL , * findfiles = NULL , * finddirshigh = NULL , * findfileshigh = NULL ;
static int numdirs = 0 , numfiles = 0 ;
static int currentlist = 0 ;
static void clearfilenames ( void )
{
klistfree ( finddirs ) ;
klistfree ( findfiles ) ;
finddirs = findfiles = NULL ;
numfiles = numdirs = 0 ;
}
static int getfilenames ( const char * path , char kind [ ] )
{
CACHE1D_FIND_REC * r ;
clearfilenames ( ) ;
finddirs = klistpath ( path , " * " , CACHE1D_FIND_DIR ) ;
findfiles = klistpath ( path , kind , CACHE1D_FIND_FILE ) ;
for ( r = finddirs ; r ; r = r - > next ) numdirs + + ;
for ( r = findfiles ; r ; r = r - > next ) numfiles + + ;
finddirshigh = finddirs ;
findfileshigh = findfiles ;
currentlist = 0 ;
if ( findfileshigh ) currentlist = 1 ;
return ( 0 ) ;
}
static void autoloadgrps ( const char * fn )
{
Bsprintf ( tempbuf , " autoload/%s " , fn ) ;
getfilenames ( tempbuf , " *.grp " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s/%s " , fn , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
Bsprintf ( tempbuf , " autoload/%s " , fn ) ;
getfilenames ( tempbuf , " *.zip " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s/%s " , fn , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
Bsprintf ( tempbuf , " autoload/%s " , fn ) ;
getfilenames ( tempbuf , " *.pk3 " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s/%s " , fn , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
}
2007-04-21 20:25:07 +00:00
static int parsegroupfiles ( scriptfile * script )
2006-07-26 01:10:33 +00:00
{
int tokn ;
char * cmdtokptr ;
2006-12-04 02:10:18 +00:00
tokenlist grptokens [ ] =
2007-08-25 01:05:00 +00:00
{
{ " include " , T_INCLUDE } ,
{ " #include " , T_INCLUDE } ,
{ " loadgrp " , T_LOADGRP } ,
{ " cachesize " , T_CACHESIZE } ,
} ;
2006-12-04 02:10:18 +00:00
2006-11-15 01:16:55 +00:00
while ( 1 )
{
2006-07-26 01:10:33 +00:00
tokn = getatoken ( script , grptokens , sizeof ( grptokens ) / sizeof ( tokenlist ) ) ;
cmdtokptr = script - > ltextptr ;
2006-11-15 01:16:55 +00:00
switch ( tokn )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
case T_LOADGRP :
{
char * fn ;
2007-02-05 01:33:08 +00:00
2007-01-30 09:03:51 +00:00
pathsearchmode = 1 ;
2006-11-16 03:02:42 +00:00
if ( ! scriptfile_getstring ( script , & fn ) )
2006-07-26 01:10:33 +00:00
{
2006-11-16 03:02:42 +00:00
int j = initgroupfile ( fn ) ;
2006-07-26 01:10:33 +00:00
2006-11-16 03:02:42 +00:00
if ( j = = - 1 )
2007-02-13 09:50:58 +00:00
initprintf ( " Could not find group file '%s'. \n " , fn ) ;
2006-11-16 03:02:42 +00:00
else
2007-03-21 20:37:24 +00:00
{
2007-02-13 09:50:58 +00:00
initprintf ( " Using group file '%s'. \n " , fn ) ;
2007-08-26 10:35:52 +00:00
if ( ! g_NoAutoLoad )
2007-07-04 09:15:08 +00:00
autoloadgrps ( fn ) ;
2007-03-21 20:37:24 +00:00
}
2006-07-26 01:10:33 +00:00
}
2007-01-30 09:03:51 +00:00
pathsearchmode = 0 ;
2006-11-16 03:02:42 +00:00
}
2007-01-30 02:04:14 +00:00
break ;
2007-01-02 02:27:57 +00:00
case T_CACHESIZE :
{
int j ;
if ( scriptfile_getnumber ( script , & j ) ) break ;
2007-01-22 02:35:54 +00:00
2007-01-02 02:27:57 +00:00
if ( j > 0 ) MAXCACHE1DSIZE = j < < 10 ;
}
2006-11-16 03:02:42 +00:00
break ;
2007-02-18 22:16:01 +00:00
case T_INCLUDE :
{
char * fn ;
2007-02-26 01:46:38 +00:00
if ( ! scriptfile_getstring ( script , & fn ) )
{
2007-02-18 22:16:01 +00:00
scriptfile * included ;
included = scriptfile_fromfile ( fn ) ;
2007-02-26 01:46:38 +00:00
if ( ! included )
{
2007-02-18 22:16:01 +00:00
initprintf ( " Warning: Failed including %s on line %s:%d \n " ,
fn , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
2007-02-26 01:46:38 +00:00
}
else
{
2007-04-21 20:25:07 +00:00
parsegroupfiles ( included ) ;
2007-02-18 22:16:01 +00:00
scriptfile_close ( included ) ;
}
}
break ;
}
2006-11-16 03:02:42 +00:00
case T_EOF :
return ( 0 ) ;
default :
2006-07-26 01:10:33 +00:00
break ;
}
}
2007-04-21 20:25:07 +00:00
return 0 ;
}
static int loadgroupfiles ( const char * fn )
{
scriptfile * script ;
script = scriptfile_fromfile ( ( char * ) fn ) ;
if ( ! script ) return - 1 ;
parsegroupfiles ( script ) ;
2006-07-26 01:10:33 +00:00
scriptfile_close ( script ) ;
scriptfile_clearsymbols ( ) ;
return 0 ;
}
2007-01-22 02:35:54 +00:00
static void addgroup ( const char * buffer )
{
struct strllist * s ;
s = ( struct strllist * ) calloc ( 1 , sizeof ( struct strllist ) ) ;
s - > str = Bstrdup ( buffer ) ;
if ( Bstrchr ( s - > str , ' . ' ) = = 0 )
Bstrcat ( s - > str , " .grp " ) ;
if ( CommandGrps )
{
struct strllist * t ;
for ( t = CommandGrps ; t - > next ; t = t - > next ) ;
t - > next = s ;
return ;
}
CommandGrps = s ;
}
static void addgamepath ( const char * buffer )
{
struct strllist * s ;
s = ( struct strllist * ) calloc ( 1 , sizeof ( struct strllist ) ) ;
s - > str = strdup ( buffer ) ;
if ( CommandPaths )
{
struct strllist * t ;
for ( t = CommandPaths ; t - > next ; t = t - > next ) ;
t - > next = s ;
return ;
}
CommandPaths = s ;
}
2007-08-19 00:15:30 +00:00
static void checkcommandline ( int argc , const char * * argv )
2006-04-13 20:47:06 +00:00
{
short i , j ;
char * c ;
int firstnet = 0 ;
i = 1 ;
ud . fta_on = 1 ;
ud . god = 0 ;
ud . m_respawn_items = 0 ;
ud . m_respawn_monsters = 0 ;
ud . m_respawn_inventory = 0 ;
ud . warp_on = 0 ;
ud . cashman = 0 ;
ud . m_player_skill = ud . player_skill = 2 ;
2007-08-27 00:20:15 +00:00
g_player [ 0 ] . wchoice [ 0 ] = 3 ;
g_player [ 0 ] . wchoice [ 1 ] = 4 ;
g_player [ 0 ] . wchoice [ 2 ] = 5 ;
g_player [ 0 ] . wchoice [ 3 ] = 7 ;
g_player [ 0 ] . wchoice [ 4 ] = 8 ;
g_player [ 0 ] . wchoice [ 5 ] = 6 ;
g_player [ 0 ] . wchoice [ 6 ] = 0 ;
g_player [ 0 ] . wchoice [ 7 ] = 2 ;
g_player [ 0 ] . wchoice [ 8 ] = 9 ;
g_player [ 0 ] . wchoice [ 9 ] = 1 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( argc > 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
while ( i < argc )
2006-04-13 20:47:06 +00:00
{
2007-08-19 00:15:30 +00:00
c = ( char * ) argv [ i ] ;
2006-04-13 20:47:06 +00:00
if ( ( ( * c = = ' / ' ) | | ( * c = = ' - ' ) ) & & ( ! firstnet ) )
{
2007-01-22 05:00:57 +00:00
if ( ! Bstrcasecmp ( c + 1 , " ? " ) | | ! Bstrcasecmp ( c + 1 , " help " ) | | ! Bstrcasecmp ( c + 1 , " -help " ) )
{
comlinehelp ( ) ;
exit ( 0 ) ;
}
2007-02-05 01:33:08 +00:00
2007-01-22 05:00:57 +00:00
if ( ! Bstrcasecmp ( c + 1 , " grp " ) | | ! Bstrcasecmp ( c + 1 , " g " ) )
2007-01-22 02:35:54 +00:00
{
if ( argc > i + 1 )
{
addgroup ( argv [ i + 1 ] ) ;
i + + ;
}
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " game_dir " ) )
{
if ( argc > i + 1 )
{
addgamepath ( argv [ i + 1 ] ) ;
i + + ;
}
i + + ;
continue ;
}
2006-11-24 04:25:13 +00:00
if ( ! Bstrcasecmp ( c + 1 , " cfg " ) )
{
if ( argc > i + 1 )
{
Bstrcpy ( setupfilename , argv [ i + 1 ] ) ;
i + + ;
}
i + + ;
continue ;
}
2007-07-04 09:15:08 +00:00
if ( ! Bstrcasecmp ( c + 1 , " gamegrp " ) )
{
if ( argc > i + 1 )
{
Bstrcpy ( defaultduke3dgrp , argv [ i + 1 ] ) ;
i + + ;
}
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nam " ) )
{
2006-09-10 17:40:34 +00:00
strcpy ( defaultduke3dgrp , " nam.grp " ) ;
2007-02-28 09:12:41 +00:00
strcpy ( defaultconfilename , " nam.con " ) ;
2007-08-26 10:35:52 +00:00
g_GameType = GAMENAM ;
2006-11-16 23:06:16 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " ww2gi " ) )
{
strcpy ( defaultduke3dgrp , " ww2gi.grp " ) ;
2007-02-28 09:12:41 +00:00
strcpy ( defaultconfilename , " ww2gi.con " ) ;
2007-08-26 10:35:52 +00:00
g_GameType = GAMEWW2 ;
2006-07-22 05:20:25 +00:00
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " setup " ) )
{
2007-08-26 10:35:52 +00:00
g_CommandSetup = TRUE ;
2006-07-01 01:40:18 +00:00
i + + ;
continue ;
}
2007-04-28 21:24:36 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nosetup " ) )
{
2007-08-26 10:35:52 +00:00
g_NoSetup = 1 ;
g_CommandSetup = 0 ;
2007-04-28 21:24:36 +00:00
i + + ;
continue ;
}
2007-07-04 09:15:08 +00:00
if ( ! Bstrcasecmp ( c + 1 , " noautoload " ) )
{
initprintf ( " Autoload disabled \n " ) ;
2007-08-26 10:35:52 +00:00
g_NoAutoLoad = 1 ;
2007-07-04 09:15:08 +00:00
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " keepaddr " ) )
{
2007-08-26 10:35:52 +00:00
g_KeepAddr = 1 ;
2006-05-02 08:12:15 +00:00
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " stun " ) )
{
2006-05-23 23:43:18 +00:00
natfree = 1 ; //Addfaz NatFree
2006-05-03 04:16:08 +00:00
i + + ;
continue ;
}
2006-05-02 02:57:11 +00:00
if ( ! Bstrcasecmp ( c + 1 , " rmnet " ) )
{
if ( argc > i + 1 )
{
2007-08-26 10:35:52 +00:00
g_NoSetup = TRUE ;
2006-11-28 16:23:37 +00:00
networkmode = 1 ;
2007-08-26 10:35:52 +00:00
CommandNet = ( char * ) argv [ i + 1 ] ;
2006-05-01 05:03:44 +00:00
i + + ;
}
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " net " ) )
{
2007-08-26 10:35:52 +00:00
g_NoSetup = TRUE ;
2006-04-13 20:47:06 +00:00
firstnet = i ;
netparamcount = argc - i - 1 ;
netparam = ( char * * ) calloc ( netparamcount , sizeof ( char * * ) ) ;
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " name " ) )
{
if ( argc > i + 1 )
{
2007-08-19 00:15:30 +00:00
CommandName = ( char * ) argv [ i + 1 ] ;
2006-04-13 20:47:06 +00:00
i + + ;
}
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " map " ) )
{
if ( argc > i + 1 )
{
2007-08-19 00:15:30 +00:00
CommandMap = ( char * ) argv [ i + 1 ] ;
2006-04-13 20:47:06 +00:00
i + + ;
}
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " condebug " ) )
{
2007-08-27 06:46:31 +00:00
g_ScriptDebug = 1 ;
2006-04-13 20:47:06 +00:00
i + + ;
continue ;
}
2007-04-17 05:54:12 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nologo " ) )
{
2007-08-26 10:35:52 +00:00
g_NoLogo = 1 ;
2007-04-17 05:54:12 +00:00
i + + ;
continue ;
}
2006-07-01 01:40:18 +00:00
# if !defined(_WIN32)
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " usecwd " ) )
{
2006-07-01 01:40:18 +00:00
usecwd = 1 ;
i + + ;
continue ;
}
# endif
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
if ( firstnet > 0 )
{
if ( * c = = ' - ' | | * c = = ' / ' )
{
2006-04-13 20:47:06 +00:00
c + + ;
2006-11-14 21:35:50 +00:00
if ( ( ( c [ 0 ] = = ' n ' ) | | ( c [ 0 ] = = ' N ' ) ) & & ( c [ 1 ] = = ' 0 ' ) )
2006-11-15 01:16:55 +00:00
{
networkmode = 0 ;
initprintf ( " Network mode: master/slave \n " ) ;
}
2006-04-13 20:47:06 +00:00
else if ( ( ( c [ 0 ] = = ' n ' ) | | ( c [ 0 ] = = ' N ' ) ) & & ( c [ 1 ] = = ' 1 ' ) )
2006-11-15 01:16:55 +00:00
{
networkmode = 1 ;
initprintf ( " Network mode: peer-to-peer \n " ) ;
}
2006-11-13 23:12:47 +00:00
2006-04-13 20:47:06 +00:00
}
2007-08-19 00:15:30 +00:00
netparam [ i - firstnet - 1 ] = ( char * ) argv [ i ] ;
2006-04-13 20:47:06 +00:00
i + + ;
continue ;
}
2006-11-13 23:12:47 +00:00
if ( ( * c = = ' / ' ) | | ( * c = = ' - ' ) )
2006-04-13 20:47:06 +00:00
{
c + + ;
2006-11-13 23:12:47 +00:00
switch ( * c )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case ' a ' :
case ' A ' :
ud . playerai = 1 ;
initprintf ( " Other player AI. \n " ) ;
break ;
case ' c ' :
case ' C ' :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
c + + ;
//if(*c == '1' || *c == '2' || *c == '3')
// ud.m_coop = *c - '0' - 1;
//else ud.m_coop = 0;
2006-09-10 17:40:34 +00:00
2006-11-16 03:02:42 +00:00
ud . m_coop = 0 ;
while ( ( * c > = ' 0 ' ) & & ( * c < = ' 9 ' ) )
{
ud . m_coop * = 10 ;
ud . m_coop + = * c - ' 0 ' ;
2006-11-15 01:16:55 +00:00
c + + ;
2006-11-16 03:02:42 +00:00
}
ud . m_coop - - ;
//switch(ud.m_coop)
//{
//case 0:
// initprintf("Dukematch (spawn).\n");
// break;
//case 1:
// initprintf("Cooperative play.\n");
// break;
//case 2:
// initprintf("Dukematch (no spawn).\n");
// break;
//}
break ;
case ' d ' :
case ' D ' :
c + + ;
if ( strchr ( c , ' . ' ) = = 0 )
Bstrcat ( c , " .dmo " ) ;
initprintf ( " Play demo %s. \n " , c ) ;
Bstrcpy ( firstdemofile , c ) ;
break ;
case ' f ' :
case ' F ' :
c + + ;
if ( * c = = ' 1 ' )
movesperpacket = 1 ;
if ( * c = = ' 2 ' )
movesperpacket = 2 ;
if ( * c = = ' 4 ' )
{
movesperpacket = 4 ;
setpackettimeout ( 0x3fffffff , 0x3fffffff ) ;
}
break ;
case ' g ' :
case ' G ' :
c + + ;
if ( ! * c ) break ;
2007-01-22 02:35:54 +00:00
addgroup ( c ) ;
2006-11-16 03:02:42 +00:00
break ;
case ' h ' :
case ' H ' :
c + + ;
if ( * c )
{
duke3ddef = c ;
initprintf ( " Using DEF file: %s. \n " , duke3ddef ) ;
}
break ;
case ' i ' :
case ' I ' :
c + + ;
if ( * c = = ' 0 ' ) networkmode = 0 ;
if ( * c = = ' 1 ' ) networkmode = 1 ;
initprintf ( " Network Mode %d \n " , networkmode ) ;
break ;
case ' j ' :
case ' J ' :
c + + ;
if ( ! * c ) break ;
2007-01-22 02:35:54 +00:00
addgamepath ( c ) ;
2006-11-16 03:02:42 +00:00
break ;
case ' l ' :
case ' L ' :
ud . warp_on = 1 ;
c + + ;
2006-12-04 22:05:30 +00:00
ud . m_level_number = ud . level_number = ( atol ( c ) - 1 ) % MAXLEVELS ;
2006-11-16 03:02:42 +00:00
break ;
case ' m ' :
case ' M ' :
if ( * ( c + 1 ) ! = ' a ' & & * ( c + 1 ) ! = ' A ' )
{
ud . m_monsters_off = 1 ;
ud . m_player_skill = ud . player_skill = 0 ;
initprintf ( " Monsters off. \n " ) ;
}
break ;
case ' n ' :
case ' N ' :
c + + ;
if ( * c = = ' s ' | | * c = = ' S ' )
{
2007-08-26 10:35:52 +00:00
g_NoSound = 2 ;
2006-11-16 03:02:42 +00:00
initprintf ( " Sound off. \n " ) ;
}
else if ( * c = = ' m ' | | * c = = ' M ' )
{
2007-08-26 10:35:52 +00:00
g_NoMusic = 1 ;
2006-11-16 03:02:42 +00:00
initprintf ( " Music off. \n " ) ;
}
else if ( * c = = ' d ' | | * c = = ' D ' )
{
FILE * fp = fopen ( " gamevars.txt " , " w " ) ;
InitGameVars ( ) ;
DumpGameVars ( fp ) ;
fclose ( fp ) ;
initprintf ( " Game variables saved to gamevars.txt. \n " ) ;
}
else
{
2006-11-19 03:02:36 +00:00
comlinehelp ( ) ;
2006-11-16 03:02:42 +00:00
exit ( - 1 ) ;
}
break ;
case ' q ' :
case ' Q ' :
initprintf ( " Fake multiplayer mode. \n " ) ;
if ( * ( + + c ) = = 0 ) ud . multimode = 1 ;
else ud . multimode = atol ( c ) % 17 ;
ud . m_coop = ud . coop = 0 ;
ud . m_marker = ud . marker = 1 ;
ud . m_respawn_monsters = ud . respawn_monsters = 1 ;
ud . m_respawn_items = ud . respawn_items = 1 ;
ud . m_respawn_inventory = ud . respawn_inventory = 1 ;
break ;
case ' r ' :
case ' R ' :
ud . m_recstat = 1 ;
initprintf ( " Demo record mode on. \n " ) ;
break ;
case ' s ' :
case ' S ' :
c + + ;
ud . m_player_skill = ud . player_skill = ( atol ( c ) % 5 ) ;
if ( ud . m_player_skill = = 4 )
2006-11-15 01:16:55 +00:00
ud . m_respawn_monsters = ud . respawn_monsters = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case ' t ' :
case ' T ' :
c + + ;
if ( * c = = ' 1 ' ) ud . m_respawn_monsters = 1 ;
else if ( * c = = ' 2 ' ) ud . m_respawn_items = 1 ;
else if ( * c = = ' 3 ' ) ud . m_respawn_inventory = 1 ;
else
{
ud . m_respawn_monsters = 1 ;
ud . m_respawn_items = 1 ;
ud . m_respawn_inventory = 1 ;
}
initprintf ( " Respawn on. \n " ) ;
break ;
case ' u ' :
case ' U ' :
CommandWeaponChoice = 1 ;
c + + ;
j = 0 ;
if ( * c )
{
initprintf ( " Using favorite weapon order(s). \n " ) ;
while ( * c )
2006-11-15 01:16:55 +00:00
{
2007-08-27 00:20:15 +00:00
g_player [ 0 ] . wchoice [ j ] = * c - ' 0 ' ;
2006-11-16 03:02:42 +00:00
c + + ;
j + + ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
while ( j < 10 )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
if ( j = = 9 )
2007-08-27 00:20:15 +00:00
g_player [ 0 ] . wchoice [ 9 ] = 1 ;
2006-11-16 03:02:42 +00:00
else
2007-08-27 00:20:15 +00:00
g_player [ 0 ] . wchoice [ j ] = 2 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j + + ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
else
{
initprintf ( " Using default weapon orders. \n " ) ;
2007-08-27 00:20:15 +00:00
g_player [ 0 ] . wchoice [ 0 ] = 3 ;
g_player [ 0 ] . wchoice [ 1 ] = 4 ;
g_player [ 0 ] . wchoice [ 2 ] = 5 ;
g_player [ 0 ] . wchoice [ 3 ] = 7 ;
g_player [ 0 ] . wchoice [ 4 ] = 8 ;
g_player [ 0 ] . wchoice [ 5 ] = 6 ;
g_player [ 0 ] . wchoice [ 6 ] = 0 ;
g_player [ 0 ] . wchoice [ 7 ] = 2 ;
g_player [ 0 ] . wchoice [ 8 ] = 9 ;
g_player [ 0 ] . wchoice [ 9 ] = 1 ;
2006-11-16 03:02:42 +00:00
}
break ;
case ' v ' :
case ' V ' :
c + + ;
ud . warp_on = 1 ;
ud . m_volume_number = ud . volume_number = atol ( c ) - 1 ;
break ;
case ' w ' :
case ' W ' :
ud . coords = 1 ;
break ;
case ' x ' :
case ' X ' :
c + + ;
if ( * c )
{
2007-02-28 09:12:41 +00:00
confilename = c ;
2006-11-16 03:02:42 +00:00
userconfiles = 1 ;
2007-02-28 09:12:41 +00:00
initprintf ( " Using CON file '%s'. \n " , confilename ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case ' 0 ' :
case ' 1 ' :
case ' 2 ' :
case ' 3 ' :
case ' 4 ' :
case ' 5 ' :
case ' 6 ' :
case ' 7 ' :
case ' 8 ' :
case ' 9 ' :
ud . warp_on = 2 + ( * c ) - ' 0 ' ;
break ;
case ' z ' :
case ' Z ' :
c + + ;
2007-08-27 06:46:31 +00:00
g_ScriptDebug = atol ( c ) ;
if ( ! g_ScriptDebug )
g_ScriptDebug = 1 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
i + + ;
}
}
}
2006-12-10 19:32:44 +00:00
static void Logo ( void )
2006-04-13 20:47:06 +00:00
{
2007-04-15 20:04:52 +00:00
int soundanm = 0 ;
2006-04-13 20:47:06 +00:00
long logoflags = GetGameVar ( " LOGO_FLAGS " , 255 , - 1 , - 1 ) ;
ready2send = 0 ;
KB_FlushKeyboardQueue ( ) ;
KB_ClearKeysDown ( ) ; // JBF
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
clearview ( 0L ) ;
IFISSOFTMODE palto ( 0 , 0 , 0 , 63 ) ;
flushperms ( ) ;
nextpage ( ) ;
2006-10-19 00:45:36 +00:00
if ( VOLUMEALL ) wm_setapptitle ( HEAD2 ) ;
else wm_setapptitle ( HEAD ) ;
2006-04-13 20:47:06 +00:00
MUSIC_StopSong ( ) ;
FX_StopAllSounds ( ) ; // JBF 20031228
clearsoundlocks ( ) ; // JBF 20031228
2007-08-26 10:35:52 +00:00
if ( ud . multimode < 2 & & ( logoflags & LOGO_FLAG_ENABLED ) & & ! g_NoLogo )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( VOLUMEALL & & ( logoflags & LOGO_FLAG_PLAYANIM ) )
{
2006-04-13 20:47:06 +00:00
2007-08-26 10:35:52 +00:00
if ( ! KB_KeyWaiting ( ) & & g_NoLogoAnim = = 0 )
2006-04-13 20:47:06 +00:00
{
getpackets ( ) ;
playanm ( " logo.anm " , 5 ) ;
IFISSOFTMODE palto ( 0 , 0 , 0 , 63 ) ;
KB_FlushKeyboardQueue ( ) ;
KB_ClearKeysDown ( ) ; // JBF
}
clearview ( 0L ) ;
nextpage ( ) ;
}
2007-08-25 22:02:40 +00:00
2006-04-13 20:47:06 +00:00
if ( logoflags & LOGO_FLAG_PLAYMUSIC )
2007-08-25 22:02:40 +00:00
{
music_select = - 1 ; // hack
2006-04-13 20:47:06 +00:00
playmusic ( & env_music_fn [ 0 ] [ 0 ] ) ;
2007-08-25 22:02:40 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
if ( ! NAM )
{
2006-07-22 00:53:20 +00:00
fadepal ( 0 , 0 , 0 , 0 , 64 , 7 ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = drealms;
2006-07-22 00:53:20 +00:00
//palto(0,0,0,63);
if ( logoflags & LOGO_FLAG_3DRSCREEN )
{
2007-08-27 06:46:31 +00:00
setgamepalette ( g_player [ myconnectindex ] . ps , drealms , 11 ) ; // JBF 20040308
2006-07-22 00:53:20 +00:00
rotatesprite ( 0 , 0 , 65536L , 0 , DREALMS , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
nextpage ( ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
totalclock = 0 ;
2006-12-12 04:31:51 +00:00
while ( totalclock < ( 120 * 7 ) & & ! KB_KeyWaiting ( ) & & ! MOUSE_GetButtons ( ) & LEFT_MOUSE )
2006-11-15 01:16:55 +00:00
{
2006-07-22 00:53:20 +00:00
handleevents ( ) ;
getpackets ( ) ;
2006-12-05 20:39:29 +00:00
if ( restorepalette )
{
2007-08-27 06:46:31 +00:00
setgamepalette ( g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > palette , 0 ) ;
2006-12-05 20:39:29 +00:00
restorepalette = 0 ;
}
2006-07-22 00:53:20 +00:00
}
2006-04-13 20:47:06 +00:00
}
2006-07-22 00:53:20 +00:00
KB_ClearKeysDown ( ) ; // JBF
2006-12-12 04:31:51 +00:00
MOUSE_ClearButton ( LEFT_MOUSE ) ;
2006-04-13 20:47:06 +00:00
}
2006-07-22 05:20:25 +00:00
2006-04-13 20:47:06 +00:00
fadepal ( 0 , 0 , 0 , 0 , 64 , 7 ) ;
clearview ( 0L ) ;
nextpage ( ) ;
if ( logoflags & LOGO_FLAG_TITLESCREEN )
{
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = titlepal;
setgamepalette ( g_player [ myconnectindex ] . ps , titlepal , 11 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
flushperms ( ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , BETASCREEN , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
KB_FlushKeyboardQueue ( ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
totalclock = 0 ;
2006-12-12 04:31:51 +00:00
while ( totalclock < ( 860 + 120 ) & & ! KB_KeyWaiting ( ) & & ! MOUSE_GetButtons ( ) & LEFT_MOUSE )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( 0 , 0 , 65536L , 0 , BETASCREEN , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( logoflags & LOGO_FLAG_DUKENUKEM )
{
2006-11-14 21:35:50 +00:00
if ( totalclock > 120 & & totalclock < ( 120 + 60 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( soundanm = = 0 )
2006-04-13 20:47:06 +00:00
{
soundanm = 1 ;
sound ( PIPEBOMB_EXPLODE ) ;
}
rotatesprite ( 160 < < 16 , 104 < < 16 , ( totalclock - 120 ) < < 10 , 0 , DUKENUKEM , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
2006-11-14 21:35:50 +00:00
else if ( totalclock > = ( 120 + 60 ) )
2006-04-13 20:47:06 +00:00
rotatesprite ( 160 < < 16 , ( 104 ) < < 16 , 60 < < 10 , 0 , DUKENUKEM , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-15 01:16:55 +00:00
}
else soundanm = 1 ;
2006-04-13 20:47:06 +00:00
if ( logoflags & LOGO_FLAG_THREEDEE )
{
2006-11-14 21:35:50 +00:00
if ( totalclock > 220 & & totalclock < ( 220 + 30 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( soundanm = = 1 )
2006-04-13 20:47:06 +00:00
{
soundanm = 2 ;
sound ( PIPEBOMB_EXPLODE ) ;
}
rotatesprite ( 160 < < 16 , ( 104 ) < < 16 , 60 < < 10 , 0 , DUKENUKEM , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-14 21:35:50 +00:00
rotatesprite ( 160 < < 16 , ( 129 ) < < 16 , ( totalclock - 220 ) < < 11 , 0 , THREEDEE , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
else if ( totalclock > = ( 220 + 30 ) )
2006-04-13 20:47:06 +00:00
rotatesprite ( 160 < < 16 , ( 129 ) < < 16 , 30 < < 11 , 0 , THREEDEE , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-15 01:16:55 +00:00
}
else soundanm = 2 ;
if ( PLUTOPAK & & ( logoflags & LOGO_FLAG_PLUTOPAKSPRITE ) )
2007-08-25 01:05:00 +00:00
{
// JBF 20030804
2006-11-14 21:35:50 +00:00
if ( totalclock > = 280 & & totalclock < 395 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( 160 < < 16 , ( 151 ) < < 16 , ( 410 - totalclock ) < < 12 , 0 , PLUTOPAKSPRITE + 1 , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-13 23:12:47 +00:00
if ( soundanm = = 2 )
2006-04-13 20:47:06 +00:00
{
soundanm = 3 ;
sound ( FLY_BY ) ;
}
}
2006-11-14 21:35:50 +00:00
else if ( totalclock > = 395 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( soundanm = = 3 )
2006-04-13 20:47:06 +00:00
{
soundanm = 4 ;
sound ( PIPEBOMB_EXPLODE ) ;
}
rotatesprite ( 160 < < 16 , ( 151 ) < < 16 , 30 < < 11 , 0 , PLUTOPAKSPRITE + 1 , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
}
OnEvent ( EVENT_LOGO , - 1 , screenpeek , - 1 ) ;
handleevents ( ) ;
getpackets ( ) ;
2006-12-05 20:39:29 +00:00
if ( restorepalette )
{
2007-08-27 06:46:31 +00:00
setgamepalette ( g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > palette , 0 ) ;
2006-12-05 20:39:29 +00:00
restorepalette = 0 ;
}
2006-04-13 20:47:06 +00:00
nextpage ( ) ;
}
}
KB_ClearKeysDown ( ) ; // JBF
2006-12-12 04:31:51 +00:00
MOUSE_ClearButton ( LEFT_MOUSE ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( ud . multimode > 1 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
setgamepalette ( g_player [ myconnectindex ] . ps , titlepal , 11 ) ;
2006-04-13 20:47:06 +00:00
rotatesprite ( 0 , 0 , 65536L , 0 , BETASCREEN , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( 160 < < 16 , ( 104 ) < < 16 , 60 < < 10 , 0 , DUKENUKEM , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( 160 < < 16 , ( 129 ) < < 16 , 30 < < 11 , 0 , THREEDEE , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( PLUTOPAK ) // JBF 20030804
rotatesprite ( 160 < < 16 , ( 151 ) < < 16 , 30 < < 11 , 0 , PLUTOPAKSPRITE + 1 , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
gametext ( 160 , 190 , " WAITING FOR PLAYERS " , 14 , 2 ) ;
nextpage ( ) ;
}
waitforeverybody ( ) ;
flushperms ( ) ;
clearview ( 0L ) ;
nextpage ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 0 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
sound ( NITEVISION_ONOFF ) ;
//palto(0,0,0,0);
clearview ( 0L ) ;
}
2006-12-10 19:32:44 +00:00
static void loadtmb ( void )
2006-04-13 20:47:06 +00:00
{
2006-11-16 23:06:16 +00:00
unsigned char tmb [ 8000 ] ;
2006-04-13 20:47:06 +00:00
long fil , l ;
fil = kopen4load ( " d3dtimbr.tmb " , 0 ) ;
2006-11-13 23:12:47 +00:00
if ( fil = = - 1 ) return ;
2006-04-13 20:47:06 +00:00
l = kfilelength ( fil ) ;
kread ( fil , ( char * ) tmb , l ) ;
MUSIC_RegisterTimbreBank ( tmb ) ;
kclose ( fil ) ;
}
2006-12-10 19:32:44 +00:00
static void freeconmem ( void )
2006-04-13 20:47:06 +00:00
{
2006-04-23 03:14:44 +00:00
int i ;
2006-12-10 21:53:33 +00:00
for ( i = ( MAXLEVELS * MAXVOLUMES ) - 1 ; i > = 0 ; i - - )
2006-12-04 22:05:30 +00:00
{
2007-08-26 11:28:32 +00:00
if ( map [ i ] . name ! = NULL )
Bfree ( map [ i ] . name ) ;
if ( map [ i ] . filename ! = NULL )
Bfree ( map [ i ] . filename ) ;
if ( map [ i ] . musicfn ! = NULL )
Bfree ( map [ i ] . musicfn ) ;
2006-12-04 22:05:30 +00:00
}
2006-12-10 21:53:33 +00:00
for ( i = MAXQUOTES - 1 ; i > = 0 ; i - - )
2006-04-23 03:14:44 +00:00
{
2006-11-13 23:12:47 +00:00
if ( fta_quotes [ i ] ! = NULL )
2006-04-23 03:14:44 +00:00
Bfree ( fta_quotes [ i ] ) ;
2006-11-13 23:12:47 +00:00
if ( redefined_quotes [ i ] ! = NULL )
2006-04-23 03:14:44 +00:00
Bfree ( redefined_quotes [ i ] ) ;
}
2006-04-25 04:35:39 +00:00
2006-12-10 21:53:33 +00:00
for ( i = iGameVarCount - 1 ; i > = 0 ; i - - )
2006-04-24 01:54:58 +00:00
{
2006-11-13 23:12:47 +00:00
if ( aGameVars [ i ] . szLabel ! = NULL )
2006-04-24 01:54:58 +00:00
Bfree ( aGameVars [ i ] . szLabel ) ;
2006-11-13 23:12:47 +00:00
if ( aDefaultGameVars [ i ] . szLabel ! = NULL )
2006-04-24 01:54:58 +00:00
Bfree ( aDefaultGameVars [ i ] . szLabel ) ;
2006-11-13 23:12:47 +00:00
if ( aGameVars [ i ] . plValues ! = NULL )
2006-04-24 18:52:29 +00:00
Bfree ( aGameVars [ i ] . plValues ) ;
2006-04-24 01:54:58 +00:00
}
2006-04-25 04:35:39 +00:00
2007-08-27 06:46:31 +00:00
for ( i = MAXPLAYERS - 1 ; i > = 0 ; i - - )
{
if ( g_player [ i ] . ps ! = NULL )
Bfree ( g_player [ i ] . ps ) ;
if ( g_player [ i ] . sync ! = NULL )
Bfree ( g_player [ i ] . sync ) ;
}
2006-11-13 23:12:47 +00:00
if ( label ! = NULL )
2006-04-24 18:52:29 +00:00
Bfree ( label ) ;
2006-11-13 23:12:47 +00:00
if ( labelcode ! = NULL )
2006-04-24 18:52:29 +00:00
Bfree ( labelcode ) ;
2007-08-29 04:01:21 +00:00
if ( script ! = NULL )
Bfree ( script ) ;
2006-04-13 20:47:06 +00:00
}
2006-07-01 02:01:18 +00:00
/*
= = = = = = = = = = = = = = = = = = =
=
= ShutDown
=
= = = = = = = = = = = = = = = = = = =
*/
2006-11-14 21:35:50 +00:00
void Shutdown ( void )
2006-07-01 02:01:18 +00:00
{
SoundShutdown ( ) ;
MusicShutdown ( ) ;
uninittimer ( ) ;
uninitengine ( ) ;
CONTROL_Shutdown ( ) ;
CONFIG_WriteSetup ( ) ;
KB_Shutdown ( ) ;
freeconmem ( ) ;
}
2006-04-13 20:47:06 +00:00
/*
= = = = = = = = = = = = = = = = = = =
=
= Startup
=
= = = = = = = = = = = = = = = = = = =
*/
2006-12-10 19:32:44 +00:00
static void compilecons ( void )
2006-04-13 20:47:06 +00:00
{
int i ;
label = ( char * ) & sprite [ 0 ] ; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816
labelcode = ( long * ) & sector [ 0 ] ; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
labeltype = ( long * ) & wall [ 0 ] ; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536
// if we compile for a V7 engine wall[] should be used for label names since it's bigger
2006-11-13 23:12:47 +00:00
if ( userconfiles = = 0 )
2006-04-13 20:47:06 +00:00
{
i = kopen4load ( confilename , 0 ) ;
if ( i ! = - 1 )
kclose ( i ) ;
else Bsprintf ( confilename , " GAME.CON " ) ;
}
loadefs ( confilename ) ;
2006-11-14 21:35:50 +00:00
if ( loadfromgrouponly )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( userconfiles = = 0 )
2006-04-13 20:47:06 +00:00
{
i = kopen4load ( " EDUKE.CON " , 1 ) ;
if ( i ! = - 1 )
{
Bsprintf ( confilename , " EDUKE.CON " ) ;
kclose ( i ) ;
}
else Bsprintf ( confilename , " GAME.CON " ) ;
}
loadefs ( confilename ) ;
}
2006-11-14 21:35:50 +00:00
if ( ( unsigned long ) labelcnt > sizeof ( sprite ) / 64 ) // see the arithmetic above for why
2006-04-13 20:47:06 +00:00
gameexit ( " Error: too many labels defined! " ) ;
else
{
char * newlabel ;
long * newlabelcode ;
newlabel = ( char * ) malloc ( labelcnt < < 6 ) ;
newlabelcode = ( long * ) malloc ( labelcnt * sizeof ( long ) ) ;
if ( ! newlabel | | ! newlabelcode )
{
gameexit ( " Error: out of memory retaining labels \n " ) ;
}
2006-11-14 21:35:50 +00:00
copybuf ( label , newlabel , ( labelcnt * 64 ) / 4 ) ;
2006-04-13 20:47:06 +00:00
copybuf ( labelcode , newlabelcode , ( labelcnt * sizeof ( long ) ) / 4 ) ;
label = newlabel ;
labelcode = newlabelcode ;
}
clearbufbyte ( & sprite [ 0 ] , sizeof ( sprite ) , 0 ) ;
clearbufbyte ( & sector [ 0 ] , sizeof ( sector ) , 0 ) ;
clearbufbyte ( & wall [ 0 ] , sizeof ( wall ) , 0 ) ;
OnEvent ( EVENT_INIT , - 1 , - 1 , - 1 ) ;
}
2006-12-10 06:49:01 +00:00
static void sanitizegametype ( )
2006-04-13 20:47:06 +00:00
{
// initprintf("ud.m_coop=%i before sanitization\n",ud.m_coop);
2006-11-15 01:16:55 +00:00
if ( ud . m_coop > = num_gametypes | | ud . m_coop < 0 )
{
2006-04-13 20:47:06 +00:00
ud . m_coop = 0 ;
}
Bsprintf ( tempbuf , " %s \n " , gametype_names [ ud . m_coop ] ) ;
initprintf ( tempbuf ) ;
2006-11-13 23:12:47 +00:00
if ( gametype_flags [ ud . m_coop ] & GAMETYPE_FLAG_ITEMRESPAWN )
2006-05-14 09:16:25 +00:00
ud . m_respawn_items = ud . m_respawn_inventory = 1 ;
2006-04-13 20:47:06 +00:00
// initprintf("ud.m_coop=%i after sanitisation\n",ud.m_coop);
}
2006-12-10 06:49:01 +00:00
static void genspriteremaps ( void )
2006-12-10 03:15:56 +00:00
{
long j , fp ;
signed char look_pos ;
char * lookfn = " lookup.dat " ;
fp = kopen4load ( lookfn , 0 ) ;
if ( fp ! = - 1 )
2007-08-27 06:46:31 +00:00
kread ( fp , ( char * ) & g_NumPalettes , 1 ) ;
2006-12-10 03:15:56 +00:00
else
gameexit ( " \n ERROR: File 'LOOKUP.DAT' not found. " ) ;
2007-08-27 06:46:31 +00:00
for ( j = 0 ; j < g_NumPalettes ; j + + )
2006-12-10 03:15:56 +00:00
{
kread ( fp , ( signed char * ) & look_pos , 1 ) ;
kread ( fp , tempbuf , 256 ) ;
makepalookup ( ( long ) look_pos , tempbuf , 0 , 0 , 0 , 1 ) ;
}
for ( j = 0 ; j < 256 ; j + + )
tempbuf [ j ] = j ;
2007-08-27 06:46:31 +00:00
g_NumPalettes + + ;
makepalookup ( g_NumPalettes , tempbuf , 15 , 15 , 15 , 1 ) ;
makepalookup ( g_NumPalettes + 1 , tempbuf , 15 , 0 , 0 , 1 ) ;
makepalookup ( g_NumPalettes + 2 , tempbuf , 0 , 15 , 0 , 1 ) ;
makepalookup ( g_NumPalettes + 3 , tempbuf , 0 , 0 , 15 , 1 ) ;
2006-12-10 03:15:56 +00:00
kread ( fp , & waterpal [ 0 ] , 768 ) ;
kread ( fp , & slimepal [ 0 ] , 768 ) ;
kread ( fp , & titlepal [ 0 ] , 768 ) ;
kread ( fp , & drealms [ 0 ] , 768 ) ;
kread ( fp , & endingpal [ 0 ] , 768 ) ;
palette [ 765 ] = palette [ 766 ] = palette [ 767 ] = 0 ;
slimepal [ 765 ] = slimepal [ 766 ] = slimepal [ 767 ] = 0 ;
waterpal [ 765 ] = waterpal [ 766 ] = waterpal [ 767 ] = 0 ;
kclose ( fp ) ;
}
2006-07-01 01:40:18 +00:00
extern int startwin_run ( void ) ;
2006-12-10 03:15:56 +00:00
static void SetupGameButtons ( void ) ;
2006-07-01 01:40:18 +00:00
2007-08-19 00:15:30 +00:00
static void Startup ( long argc , const char * * argv )
2006-04-13 20:47:06 +00:00
{
int i ;
2006-04-25 01:56:24 +00:00
compilecons ( ) ;
2006-07-27 01:51:06 +00:00
CONFIG_ReadKeys ( ) ; // we re-read the keys after compiling the CONs
2006-07-01 01:40:18 +00:00
2006-11-15 01:16:55 +00:00
if ( initengine ( ) )
{
2006-07-01 01:40:18 +00:00
wm_msgbox ( " Build Engine Initialisation Error " ,
" There was a problem initialising the Build engine: %s " , engineerrstr ) ;
2006-07-01 02:01:18 +00:00
freeconmem ( ) ;
2006-07-01 01:40:18 +00:00
exit ( 1 ) ;
}
2006-04-13 20:47:06 +00:00
setupdynamictostatic ( ) ;
if ( ud . multimode > 1 ) sanitizegametype ( ) ;
2007-08-27 00:20:15 +00:00
if ( g_NoSound ) ud . config . SoundToggle = 0 ;
if ( g_NoMusic ) ud . config . MusicToggle = 0 ;
2006-05-01 22:49:09 +00:00
2006-05-02 03:12:44 +00:00
if ( CommandName )
2006-05-01 22:49:09 +00:00
{
2006-05-09 04:24:44 +00:00
// Bstrncpy(myname, CommandName, 9);
// myname[10] = '\0';
Bstrcpy ( tempbuf , CommandName ) ;
2006-12-10 21:53:33 +00:00
while ( Bstrlen ( stripcolorcodes ( tempbuf ) ) > 10 )
2006-05-09 04:24:44 +00:00
tempbuf [ Bstrlen ( tempbuf ) - 1 ] = ' \0 ' ;
Bstrncpy ( myname , tempbuf , sizeof ( myname ) - 1 ) ;
myname [ sizeof ( myname ) ] = ' \0 ' ;
2006-05-01 22:49:09 +00:00
}
2006-11-15 01:16:55 +00:00
if ( CommandMap )
{
if ( VOLUMEONE )
{
2006-04-13 20:47:06 +00:00
initprintf ( " The -map option is available in the registered version only! \n " ) ;
boardfilename [ 0 ] = 0 ;
2006-11-15 01:16:55 +00:00
}
else
{
2007-05-01 04:37:08 +00:00
char * dot , * slash ;
2006-04-13 20:47:06 +00:00
2006-12-12 07:25:01 +00:00
boardfilename [ 0 ] = ' / ' ;
2006-12-12 08:33:11 +00:00
boardfilename [ 1 ] = 0 ;
2006-12-12 07:25:01 +00:00
Bstrcat ( boardfilename , CommandMap ) ;
2006-04-13 20:47:06 +00:00
dot = Bstrrchr ( boardfilename , ' . ' ) ;
slash = Bstrrchr ( boardfilename , ' / ' ) ;
if ( ! slash ) slash = Bstrrchr ( boardfilename , ' \\ ' ) ;
if ( ( ! slash & & ! dot ) | | ( slash & & dot < slash ) )
Bstrcat ( boardfilename , " .map " ) ;
2006-12-12 07:25:01 +00:00
Bcorrectfilename ( boardfilename , 0 ) ;
2007-05-01 04:37:08 +00:00
i = kopen4load ( boardfilename , 0 ) ;
if ( i ! = - 1 )
2006-04-13 20:47:06 +00:00
{
2007-05-01 04:37:08 +00:00
initprintf ( " Using level: '%s'. \n " , boardfilename ) ;
kclose ( i ) ;
2006-04-13 20:47:06 +00:00
}
2007-05-01 04:37:08 +00:00
else
2007-04-30 19:41:19 +00:00
{
2007-05-01 04:37:08 +00:00
initprintf ( " Level '%s' not found. \n " , boardfilename ) ;
boardfilename [ 0 ] = 0 ;
2007-04-30 19:41:19 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
2006-11-15 01:16:55 +00:00
if ( VOLUMEONE )
{
2006-04-13 20:47:06 +00:00
initprintf ( " *** You have run Duke Nukem 3D %ld times. *** \n \n " , ud . executions ) ;
2006-11-13 23:12:47 +00:00
if ( ud . executions > = 50 ) initprintf ( " IT IS NOW TIME TO UPGRADE TO THE COMPLETE VERSION!!! \n " ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
if ( CONTROL_Startup ( 1 , & GetTime , TICRATE ) )
{
2006-04-13 20:47:06 +00:00
uninitengine ( ) ;
exit ( 1 ) ;
}
SetupGameButtons ( ) ;
2006-05-21 00:05:50 +00:00
CONFIG_SetupMouse ( ) ;
CONFIG_SetupJoystick ( ) ;
2007-08-27 00:20:15 +00:00
CONTROL_JoystickEnabled = ( ud . config . UseJoystick & & CONTROL_JoyPresent ) ;
CONTROL_MouseEnabled = ( ud . config . UseMouse & & CONTROL_MousePresent ) ;
2006-05-21 00:05:50 +00:00
// JBF 20040215: evil and nasty place to do this, but joysticks are evil and nasty too
for ( i = 0 ; i < joynumaxes ; i + + )
2007-08-27 00:20:15 +00:00
setjoydeadzone ( i , ud . config . JoystickAnalogueDead [ i ] , ud . config . JoystickAnalogueSaturate [ i ] ) ;
2006-05-21 00:05:50 +00:00
inittimer ( TICRATE ) ;
2006-04-13 20:47:06 +00:00
//initprintf("* Hold Esc to Abort. *\n");
2006-04-25 22:50:57 +00:00
initprintf ( " Loading art header... \n " ) ;
2006-04-23 06:44:19 +00:00
if ( loadpics ( " tiles000.art " , MAXCACHE1DSIZE ) < 0 )
2006-04-13 20:47:06 +00:00
gameexit ( " Failed loading art. " ) ;
initprintf ( " Loading palette/lookups... \n " ) ;
genspriteremaps ( ) ;
readsavenames ( ) ;
tilesizx [ MIRROR ] = tilesizy [ MIRROR ] = 0 ;
2006-11-28 04:16:20 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
2007-08-27 00:20:15 +00:00
g_player [ i ] . playerreadyflag = 0 ;
2006-04-13 20:47:06 +00:00
2007-08-26 10:35:52 +00:00
if ( CommandNet )
2006-05-17 03:13:39 +00:00
{
2007-08-26 10:35:52 +00:00
setup_rancid_net ( CommandNet ) ;
2006-11-30 04:36:20 +00:00
if ( Bstrlen ( rancid_ip_strings [ MAXPLAYERS - 1 ] ) )
{
initprintf ( " rmnet: Using %s as sort IP \n " , rancid_ip_strings [ MAXPLAYERS - 1 ] ) ;
initprintf ( " rmnet: %d players \n " , rancid_players ) ;
}
2007-08-26 10:35:52 +00:00
CommandNet = NULL ;
2006-05-17 03:13:39 +00:00
}
2006-05-02 03:51:06 +00:00
2006-04-13 20:47:06 +00:00
//initmultiplayers(netparamcount,netparam, 0,0,0);
2006-11-15 01:16:55 +00:00
if ( initmultiplayersparms ( netparamcount , netparam ) )
{
2006-04-13 20:47:06 +00:00
initprintf ( " Waiting for players... \n " ) ;
2006-11-15 01:16:55 +00:00
while ( initmultiplayerscycle ( ) )
{
2006-04-13 20:47:06 +00:00
handleevents ( ) ;
2006-11-15 01:16:55 +00:00
if ( quitevent )
{
2006-04-13 20:47:06 +00:00
Shutdown ( ) ;
return ;
}
}
}
2006-05-07 03:27:41 +00:00
2006-04-13 20:47:06 +00:00
if ( netparam ) Bfree ( netparam ) ;
2006-11-15 01:16:55 +00:00
netparam = NULL ;
netparamcount = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( numplayers > 1 )
2006-04-13 20:47:06 +00:00
initprintf ( " Multiplayer initialized. \n " ) ;
screenpeek = myconnectindex ;
2006-11-13 23:12:47 +00:00
if ( networkmode = = 255 )
2006-04-13 20:47:06 +00:00
networkmode = 1 ;
}
2006-12-23 02:38:47 +00:00
void sendscore ( const char * s )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( numplayers > 1 )
2006-12-23 02:38:47 +00:00
genericmultifunction ( - 1 , ( char * ) s , strlen ( s ) + 1 , 5 ) ;
2006-04-13 20:47:06 +00:00
}
2007-01-12 22:42:19 +00:00
static void sendwchoice ( void )
2006-11-30 23:37:47 +00:00
{
int i , l ;
buf [ 0 ] = 10 ;
buf [ 1 ] = myconnectindex ;
l = 2 ;
for ( i = 0 ; i < 10 ; i + + )
{
2007-08-27 00:20:15 +00:00
g_player [ myconnectindex ] . wchoice [ i ] = g_player [ 0 ] . wchoice [ i ] ;
buf [ l + + ] = ( char ) g_player [ 0 ] . wchoice [ i ] ;
2006-11-30 23:37:47 +00:00
}
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
{
if ( i ! = myconnectindex ) sendpacket ( i , & buf [ 0 ] , l ) ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
}
2007-01-12 22:42:19 +00:00
static void sendplayerupdate ( void )
2006-04-13 20:47:06 +00:00
{
int i , l ;
2006-04-18 22:59:54 +00:00
buf [ 0 ] = 6 ;
buf [ 1 ] = myconnectindex ;
buf [ 2 ] = BYTEVERSION ;
l = 3 ;
2006-04-13 20:47:06 +00:00
2006-04-18 22:59:54 +00:00
//null terminated player name to send
2006-11-13 23:12:47 +00:00
for ( i = 0 ; myname [ i ] ; i + + ) buf [ l + + ] = Btoupper ( myname [ i ] ) ;
2006-04-18 22:59:54 +00:00
buf [ l + + ] = 0 ;
2007-08-27 06:46:31 +00:00
buf [ l + + ] = g_player [ myconnectindex ] . ps - > aim_mode = ud . mouseaiming ;
buf [ l + + ] = g_player [ myconnectindex ] . ps - > auto_aim = ud . config . AutoAim ;
buf [ l + + ] = g_player [ myconnectindex ] . ps - > weaponswitch = ud . weaponswitch ;
buf [ l + + ] = g_player [ myconnectindex ] . ps - > palookup = g_player [ myconnectindex ] . pcolor = ud . color ;
2006-04-13 20:47:06 +00:00
2007-08-27 00:20:15 +00:00
buf [ l + + ] = g_player [ myconnectindex ] . pteam = ud . team ;
2006-08-18 23:52:26 +00:00
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-18 22:59:54 +00:00
{
if ( i ! = myconnectindex ) sendpacket ( i , & buf [ 0 ] , l ) ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
}
2006-04-13 20:47:06 +00:00
2006-04-20 19:21:40 +00:00
void sendboardname ( void )
{
2006-12-14 08:50:18 +00:00
if ( numplayers > 1 )
2006-04-20 19:21:40 +00:00
{
int j ;
int ch ;
2006-12-12 08:33:11 +00:00
packbuf [ 0 ] = 9 ;
packbuf [ 1 ] = 0 ;
2006-04-20 19:21:40 +00:00
2006-12-12 07:25:01 +00:00
Bcorrectfilename ( boardfilename , 0 ) ;
2006-07-21 22:25:05 +00:00
j = Bstrlen ( boardfilename ) ;
2006-04-20 19:21:40 +00:00
boardfilename [ j ] = 0 ;
2006-12-12 08:33:11 +00:00
Bstrcat ( packbuf + 1 , boardfilename ) ;
2006-04-20 19:21:40 +00:00
2006-11-13 23:12:47 +00:00
for ( ch = connecthead ; ch > = 0 ; ch = connectpoint2 [ ch ] )
2006-04-20 19:21:40 +00:00
{
2006-12-12 08:33:11 +00:00
if ( ch ! = myconnectindex ) sendpacket ( ch , packbuf , j + 1 ) ;
2006-04-20 19:21:40 +00:00
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
}
}
2007-02-28 09:12:41 +00:00
void mpchangemap ( int volume , int level )
2006-12-12 08:46:32 +00:00
{
int i ;
2006-12-14 08:50:18 +00:00
packbuf [ 0 ] = 5 ;
packbuf [ 1 ] = ud . m_level_number = level ;
packbuf [ 2 ] = ud . m_volume_number = volume ;
packbuf [ 3 ] = ud . m_player_skill + 1 ;
packbuf [ 4 ] = ud . m_monsters_off ;
packbuf [ 5 ] = ud . m_respawn_monsters ;
packbuf [ 6 ] = ud . m_respawn_items ;
packbuf [ 7 ] = ud . m_respawn_inventory ;
packbuf [ 8 ] = ud . m_coop ;
packbuf [ 9 ] = ud . m_marker ;
packbuf [ 10 ] = ud . m_ffire ;
packbuf [ 11 ] = ud . m_noexits ;
2006-12-12 08:46:32 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
{
2006-12-14 08:50:18 +00:00
if ( i ! = myconnectindex ) sendpacket ( i , packbuf , 12 ) ;
2006-12-12 08:46:32 +00:00
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
}
2006-12-10 06:49:01 +00:00
static void getnames ( void )
2006-04-18 22:59:54 +00:00
{
int l ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( l = 0 ; ( unsigned ) l < sizeof ( myname ) - 1 ; l + + )
2007-08-27 00:20:15 +00:00
g_player [ myconnectindex ] . user_name [ l ] = Btoupper ( myname [ l ] ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( numplayers > 1 )
2006-04-18 22:59:54 +00:00
{
2006-11-30 23:37:47 +00:00
sendplayerupdate ( ) ;
sendwchoice ( ) ;
2006-04-20 19:21:40 +00:00
sendboardname ( ) ;
2006-04-13 20:47:06 +00:00
getpackets ( ) ;
waitforeverybody ( ) ;
}
2006-11-13 23:12:47 +00:00
if ( cp = = 1 & & numplayers < 2 )
2006-04-13 20:47:06 +00:00
gameexit ( " Please put the Duke Nukem 3D Atomic Edition CD in the CD-ROM drive. " ) ;
}
2006-11-30 23:37:47 +00:00
void updateplayer ( void )
2006-04-18 19:23:53 +00:00
{
2006-04-18 22:59:54 +00:00
int l ;
2006-11-13 23:12:47 +00:00
if ( ud . recstat ! = 0 )
2006-04-19 06:23:19 +00:00
return ;
2006-11-13 23:12:47 +00:00
for ( l = 0 ; ( unsigned ) l < sizeof ( myname ) - 1 ; l + + )
2007-08-27 00:20:15 +00:00
g_player [ myconnectindex ] . user_name [ l ] = Btoupper ( myname [ l ] ) ;
2006-04-18 19:23:53 +00:00
2006-12-14 08:50:18 +00:00
if ( numplayers > 1 )
2006-04-18 19:23:53 +00:00
{
2006-11-30 23:37:47 +00:00
sendplayerupdate ( ) ;
2007-08-27 06:46:31 +00:00
if ( sprite [ g_player [ myconnectindex ] . ps - > i ] . picnum = = APLAYER & & sprite [ g_player [ myconnectindex ] . ps - > i ] . pal ! = 1 )
sprite [ g_player [ myconnectindex ] . ps - > i ] . pal = g_player [ myconnectindex ] . pcolor ;
2006-04-18 19:23:53 +00:00
}
else
{
2006-08-18 23:52:26 +00:00
int j ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > aim_mode = ud . mouseaiming ;
g_player [ myconnectindex ] . ps - > auto_aim = ud . config . AutoAim ;
g_player [ myconnectindex ] . ps - > weaponswitch = ud . weaponswitch ;
g_player [ myconnectindex ] . ps - > palookup = g_player [ myconnectindex ] . pcolor = ud . color ;
j = g_player [ myconnectindex ] . ps - > team ;
2007-08-27 00:20:15 +00:00
g_player [ myconnectindex ] . pteam = ud . team ;
2006-08-18 23:52:26 +00:00
2007-08-27 06:46:31 +00:00
if ( sprite [ g_player [ myconnectindex ] . ps - > i ] . picnum = = APLAYER & & sprite [ g_player [ myconnectindex ] . ps - > i ] . pal ! = 1 )
sprite [ g_player [ myconnectindex ] . ps - > i ] . pal = g_player [ myconnectindex ] . pcolor ;
2006-04-18 19:23:53 +00:00
}
}
2006-12-10 06:49:01 +00:00
#if 0
2006-04-13 20:47:06 +00:00
void writestring ( long a1 , long a2 , long a3 , short a4 , long vx , long vy , long vz )
{
FILE * fp ;
2006-05-01 05:03:44 +00:00
fp = ( FILE * ) fopen ( " debug.txt " , " rt+ " ) ;
2006-04-13 20:47:06 +00:00
fprintf ( fp , " %ld %ld %ld %d %ld %ld %ld \n " , a1 , a2 , a3 , a4 , vx , vy , vz ) ;
fclose ( fp ) ;
}
2006-12-10 06:49:01 +00:00
# endif
2006-04-13 20:47:06 +00:00
2006-12-10 06:49:01 +00:00
#if 0
2006-04-13 20:47:06 +00:00
char testcd ( char * fn , long testsiz ) ;
// JBF: various hacks here
2006-12-10 03:15:56 +00:00
static void copyprotect ( void )
2006-04-13 20:47:06 +00:00
{
// FILE *fp;
// char idfile[256];
cp = 0 ;
# ifdef NOCOPYPROTECT
return ;
# endif
if ( VOLUMEONE ) return ;
2006-11-14 21:35:50 +00:00
if ( testcd ( IDFILENAME , IDFSIZE ) )
2006-04-13 20:47:06 +00:00
{
cp = 1 ;
return ;
}
}
2006-12-10 03:15:56 +00:00
# endif
2006-04-13 20:47:06 +00:00
void backtomenu ( void )
{
boardfilename [ 0 ] = 0 ;
if ( ud . recstat = = 1 ) closedemowrite ( ) ;
ud . warp_on = 0 ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_MENU ;
2006-04-13 20:47:06 +00:00
cmenu ( 0 ) ;
KB_FlushKeyboardQueue ( ) ;
2006-10-19 00:45:36 +00:00
if ( VOLUMEALL ) wm_setapptitle ( HEAD2 ) ;
else wm_setapptitle ( HEAD ) ;
2006-04-13 20:47:06 +00:00
}
2007-01-24 03:42:54 +00:00
int load_script ( const char * szScript )
2006-04-13 20:47:06 +00:00
{
FILE * fp = fopenfrompath ( szScript , " r " ) ;
2006-11-13 23:12:47 +00:00
if ( fp ! = NULL )
2006-04-13 20:47:06 +00:00
{
char line [ 255 ] ;
2007-02-05 01:33:08 +00:00
2006-04-13 20:47:06 +00:00
OSD_Printf ( " Executing \" %s \" \n " , szScript ) ;
2006-11-13 23:12:47 +00:00
while ( fgets ( line , sizeof ( line ) - 1 , fp ) ! = NULL )
2006-04-13 20:47:06 +00:00
OSD_Dispatch ( strtok ( line , " \r \n " ) ) ;
fclose ( fp ) ;
return 0 ;
}
return 1 ;
}
2007-08-19 00:15:30 +00:00
void app_main ( int argc , const char * * argv )
2006-04-13 20:47:06 +00:00
{
2006-08-19 01:30:40 +00:00
int i , j ;
2006-12-17 01:08:39 +00:00
char cwd [ BMAX_PATH ] ;
2007-01-26 00:28:44 +00:00
extern char datetimestring [ ] ;
2007-02-05 01:33:08 +00:00
2006-04-13 20:47:06 +00:00
# ifdef RENDERTYPEWIN
2006-11-15 01:16:55 +00:00
if ( win_checkinstance ( ) )
{
2006-04-13 20:47:06 +00:00
if ( ! wm_ynbox ( " EDuke32 " , " Another Build game is currently running. "
" Do you wish to continue starting this copy? " ) )
return ;
}
# endif
2006-12-08 16:45:12 +00:00
# ifdef RENDERTYPEWIN
backgroundidle = 0 ;
# endif
2006-04-13 20:47:06 +00:00
OSD_SetLogFile ( " eduke32.log " ) ;
2006-07-08 01:31:35 +00:00
wm_setapptitle ( HEAD2 ) ;
2007-01-26 00:28:44 +00:00
initprintf ( " %s (%s) \n " , apptitle , datetimestring ) ;
2006-07-08 01:31:35 +00:00
initprintf ( " Copyright (c) 1996, 2003 3D Realms Entertainment \n " ) ;
2007-03-04 19:52:57 +00:00
initprintf ( " Copyright (c) 2007 EDuke32 team \n " ) ;
2006-07-08 01:31:35 +00:00
2006-09-10 17:40:34 +00:00
# if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
2006-09-19 23:02:33 +00:00
addsearchpath ( " /usr/share/games/jfduke3d " ) ;
addsearchpath ( " /usr/local/share/games/jfduke3d " ) ;
2006-09-10 17:40:34 +00:00
addsearchpath ( " /usr/share/games/eduke32 " ) ;
addsearchpath ( " /usr/local/share/games/eduke32 " ) ;
# elif defined(__APPLE__)
2006-09-19 23:02:33 +00:00
addsearchpath ( " /Library/Application Support/JFDuke3D " ) ;
2006-09-10 17:40:34 +00:00
addsearchpath ( " /Library/Application Support/EDuke32 " ) ;
# endif
ud . multimode = 1 ;
checkcommandline ( argc , argv ) ;
2007-08-27 06:46:31 +00:00
g_player [ 0 ] . ps = ( player_struct * ) Bcalloc ( 1 , sizeof ( player_struct ) ) ;
g_player [ 0 ] . sync = ( input * ) Bcalloc ( 1 , sizeof ( input ) ) ;
2006-12-17 01:08:39 +00:00
if ( getcwd ( cwd , BMAX_PATH ) ) addsearchpath ( cwd ) ;
if ( CommandPaths )
2006-09-10 17:40:34 +00:00
{
struct strllist * s ;
2006-11-15 01:16:55 +00:00
while ( CommandPaths )
{
2006-09-10 17:40:34 +00:00
s = CommandPaths - > next ;
addsearchpath ( CommandPaths - > str ) ;
free ( CommandPaths - > str ) ;
free ( CommandPaths ) ;
CommandPaths = s ;
}
}
2006-07-01 01:40:18 +00:00
# if defined(_WIN32)
2006-04-13 20:47:06 +00:00
if ( ! access ( " user_profiles_enabled " , F_OK ) )
2006-07-01 01:40:18 +00:00
# else
2007-02-26 01:46:38 +00:00
if ( usecwd = = 0 & & access ( " user_profiles_disabled " , F_OK ) )
2006-04-13 20:47:06 +00:00
# endif
{
char * homedir ;
int asperr ;
2006-11-15 01:16:55 +00:00
if ( ( homedir = Bgethomedir ( ) ) )
{
2006-04-13 20:47:06 +00:00
Bsnprintf ( cwd , sizeof ( cwd ) , " %s/ "
# if defined(_WIN32)
" EDuke32 Settings "
# elif defined(__APPLE__)
" Library/Application Support/EDuke32 "
# else
" .eduke32 "
# endif
, homedir ) ;
asperr = addsearchpath ( cwd ) ;
2006-11-15 01:16:55 +00:00
if ( asperr = = - 2 )
{
2006-04-13 20:47:06 +00:00
if ( Bmkdir ( cwd , S_IRWXU ) = = 0 ) asperr = addsearchpath ( cwd ) ;
else asperr = - 1 ;
}
if ( ( asperr = = 0 ) )
chdir ( cwd ) ;
Bfree ( homedir ) ;
}
}
2006-10-29 20:18:04 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-08-10 02:10:24 +00:00
glusetexcache = glusetexcachecompression = - 1 ;
2006-12-14 03:34:55 +00:00
# endif
# ifdef _WIN32
2007-08-27 00:20:15 +00:00
ud . config . CheckForUpdates = - 1 ;
2006-12-14 03:34:55 +00:00
# endif
2006-08-10 02:10:24 +00:00
2006-07-19 17:35:11 +00:00
i = CONFIG_ReadSetup ( ) ;
2006-09-10 17:40:34 +00:00
if ( getenv ( " DUKE3DGRP " ) ) duke3dgrp = getenv ( " DUKE3DGRP " ) ;
2006-07-19 17:35:11 +00:00
2006-12-14 03:34:55 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-13 23:12:47 +00:00
if ( glusetexcache = = - 1 | | glusetexcachecompression = = - 1 )
2006-08-10 02:10:24 +00:00
{
2006-12-14 08:50:18 +00:00
i = wm_ynbox ( " Texture Caching " ,
2007-01-30 09:03:51 +00:00
" Would you like to enable the on-disk texture cache? This feature will use an undetermined amount of space "
" on your hard disk to store textures in your video card's native format, enabling them to load dramatically "
2007-01-24 03:42:54 +00:00
" faster after the first time they are loaded. \n \n "
" You will generally want to say 'yes' here, especially if using the HRP. " ) ;
2007-08-27 00:20:15 +00:00
if ( i ) ud . config . useprecache = glusetexcompr = glusetexcache = glusetexcachecompression = 1 ;
2006-08-10 02:10:24 +00:00
else glusetexcache = glusetexcachecompression = 0 ;
}
2006-10-29 20:18:04 +00:00
# endif
2006-08-10 02:10:24 +00:00
2006-12-14 03:34:55 +00:00
# ifdef _WIN32
2007-08-27 00:20:15 +00:00
if ( ud . config . CheckForUpdates = = - 1 )
2006-12-14 03:34:55 +00:00
{
2006-12-14 08:50:18 +00:00
i = wm_ynbox ( " Automatic Release Notification " ,
" Would you like EDuke32 to automatically check for new releases "
" at startup? " ) ;
2007-08-27 00:20:15 +00:00
ud . config . CheckForUpdates = 0 ;
if ( i ) ud . config . CheckForUpdates = 1 ;
2006-12-14 03:34:55 +00:00
}
2006-12-18 08:37:12 +00:00
2007-08-27 00:20:15 +00:00
if ( ud . config . CheckForUpdates = = 1 )
2006-12-14 04:13:19 +00:00
{
2007-08-27 00:20:15 +00:00
if ( time ( NULL ) - ud . config . LastUpdateCheck > UPDATEINTERVAL )
2006-12-14 04:13:19 +00:00
{
if ( getversionfromwebsite ( tempbuf ) )
{
2007-08-27 00:20:15 +00:00
ud . config . LastUpdateCheck = time ( NULL ) ;
2006-12-14 04:13:19 +00:00
if ( atol ( tempbuf ) > BUILDDATE )
{
if ( wm_ynbox ( " EDuke32 " , " A new version of EDuke32 is available. "
2006-12-18 08:37:12 +00:00
" Browse to http://eduke32.sourceforge.net now? " ) )
2006-12-14 04:13:19 +00:00
{
2006-12-18 08:37:12 +00:00
SHELLEXECUTEINFOA sinfo ;
2006-12-17 01:08:39 +00:00
char * p = " http://eduke32.sourceforge.net " ;
2006-12-18 08:37:12 +00:00
Bmemset ( & sinfo , 0 , sizeof ( sinfo ) ) ;
sinfo . cbSize = sizeof ( sinfo ) ;
sinfo . fMask = SEE_MASK_CLASSNAME ;
sinfo . lpVerb = " open " ;
sinfo . lpFile = p ;
sinfo . nShow = SW_SHOWNORMAL ;
sinfo . lpClass = " http " ;
if ( ! ShellExecuteExA ( & sinfo ) )
initprintf ( " update: error launching browser! \n " ) ;
2006-12-14 04:13:19 +00:00
CONFIG_SetupMouse ( ) ;
CONFIG_SetupJoystick ( ) ;
2006-12-18 08:37:12 +00:00
CONFIG_WriteSetup ( ) ;
2006-12-14 04:13:19 +00:00
gameexit ( " " ) ;
}
}
}
2006-12-15 01:09:25 +00:00
else initprintf ( " update: failed to check for updates \n " ) ;
2006-12-14 04:13:19 +00:00
}
}
2006-12-14 03:34:55 +00:00
# endif
2006-11-15 01:16:55 +00:00
if ( preinitengine ( ) )
{
2006-07-07 18:41:05 +00:00
wm_msgbox ( " Build Engine Initialisation Error " ,
" There was a problem initialising the Build engine: %s " , engineerrstr ) ;
exit ( 1 ) ;
}
2007-02-13 09:50:58 +00:00
initprintf ( " Using config file '%s'. \n " , setupfilename ) ;
2006-11-26 21:15:20 +00:00
2006-07-22 05:20:25 +00:00
ScanGroups ( ) ;
2007-08-25 01:05:00 +00:00
{
// try and identify the 'defaultduke3dgrp' in the set of GRPs.
2006-07-22 05:20:25 +00:00
// if it is found, set up the environment accordingly for the game it represents.
// if it is not found, choose the first GRP from the list of
struct grpfile * fg , * first = NULL ;
int i ;
2006-11-15 01:16:55 +00:00
for ( fg = foundgrps ; fg ; fg = fg - > next )
{
2006-07-22 05:20:25 +00:00
for ( i = 0 ; i < numgrpfiles ; i + + ) if ( fg - > crcval = = grpfiles [ i ] . crcval ) break ;
if ( i = = numgrpfiles ) continue ; // unrecognised grp file
fg - > game = grpfiles [ i ] . game ;
if ( ! first ) first = fg ;
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( fg - > name , defaultduke3dgrp ) )
{
2007-08-26 10:35:52 +00:00
g_GameType = grpfiles [ i ] . game ;
2006-07-22 05:20:25 +00:00
break ;
}
}
2006-11-15 01:16:55 +00:00
if ( ! fg & & first )
{
2006-07-22 05:20:25 +00:00
Bstrcpy ( defaultduke3dgrp , first - > name ) ;
2007-08-26 10:35:52 +00:00
g_GameType = first - > game ;
2006-07-22 05:20:25 +00:00
}
}
2007-02-28 09:12:41 +00:00
# if (defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2))
2007-08-27 00:20:15 +00:00
if ( i < 0 | | ( ! g_NoSetup & & ud . config . ForceSetup ) | | g_CommandSetup )
2006-11-15 01:16:55 +00:00
{
if ( quitevent | | ! startwin_run ( ) )
{
2006-07-07 18:41:05 +00:00
uninitengine ( ) ;
exit ( 0 ) ;
}
}
# endif
2006-07-22 05:20:25 +00:00
FreeGroups ( ) ;
2006-07-22 00:53:20 +00:00
2006-11-16 23:06:16 +00:00
if ( WW2GI )
{
// overwrite the default GRP and CON so that if the user chooses
// something different, they get what they asked for
Bsprintf ( defaultduke3dgrp , " ww2gi.grp " ) ;
2007-02-28 09:12:41 +00:00
Bsprintf ( defaultconfilename , " ww2gi.con " ) ;
2006-11-16 23:06:16 +00:00
Bsprintf ( gametype_names [ 0 ] , " GRUNTMATCH (SPAWN) " ) ;
Bsprintf ( gametype_names [ 2 ] , " GRUNTMATCH (NO SPAWN) " ) ;
}
else if ( NAM )
2006-11-15 01:16:55 +00:00
{
2006-07-22 05:20:25 +00:00
// overwrite the default GRP and CON so that if the user chooses
// something different, they get what they asked for
Bsprintf ( defaultduke3dgrp , " nam.grp " ) ;
2007-02-28 09:12:41 +00:00
Bsprintf ( defaultconfilename , " nam.con " ) ;
2006-07-22 05:49:55 +00:00
Bsprintf ( gametype_names [ 0 ] , " GRUNTMATCH (SPAWN) " ) ;
Bsprintf ( gametype_names [ 2 ] , " GRUNTMATCH (NO SPAWN) " ) ;
2006-07-22 02:54:07 +00:00
}
2007-03-24 23:17:56 +00:00
i = initgroupfile ( duke3dgrp ) ;
2007-02-25 21:11:59 +00:00
2007-03-24 23:17:56 +00:00
if ( i = = - 1 )
2007-02-25 21:11:59 +00:00
initprintf ( " Warning: could not find group file '%s'. \n " , duke3dgrp ) ;
2007-03-21 20:37:24 +00:00
else
initprintf ( " Using group file '%s' as main group file. \n " , duke3dgrp ) ;
2007-02-26 01:46:38 +00:00
2007-08-26 10:35:52 +00:00
if ( ! g_NoAutoLoad )
2007-07-04 09:15:08 +00:00
{
getfilenames ( " autoload " , " *.grp " ) ;
2007-08-25 01:05:00 +00:00
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s " , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
2007-07-04 09:15:08 +00:00
getfilenames ( " autoload " , " *.zip " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s " , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
getfilenames ( " autoload " , " *.pk3 " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s " , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
2007-02-26 01:46:38 +00:00
2007-07-04 09:15:08 +00:00
if ( i ! = - 1 )
autoloadgrps ( duke3dgrp ) ;
}
2007-03-24 23:17:56 +00:00
2006-11-24 04:25:13 +00:00
loadgroupfiles ( duke3ddef ) ;
2006-09-10 17:40:34 +00:00
{
struct strllist * s ;
2007-02-05 01:33:08 +00:00
2007-01-30 09:03:51 +00:00
pathsearchmode = 1 ;
2006-11-15 01:16:55 +00:00
while ( CommandGrps )
{
2006-09-10 17:40:34 +00:00
s = CommandGrps - > next ;
j = initgroupfile ( CommandGrps - > str ) ;
2007-02-13 09:50:58 +00:00
if ( j = = - 1 ) initprintf ( " Could not find group file '%s'. \n " , CommandGrps - > str ) ;
2006-11-15 01:16:55 +00:00
else
{
2006-09-10 17:40:34 +00:00
groupfile = j ;
2007-02-13 09:50:58 +00:00
initprintf ( " Using group file '%s'. \n " , CommandGrps - > str ) ;
2007-08-26 10:35:52 +00:00
if ( ! g_NoAutoLoad )
2007-07-04 09:15:08 +00:00
autoloadgrps ( CommandGrps - > str ) ;
2006-09-10 17:40:34 +00:00
}
2006-04-13 20:47:06 +00:00
2006-09-10 17:40:34 +00:00
free ( CommandGrps - > str ) ;
free ( CommandGrps ) ;
CommandGrps = s ;
}
2007-01-30 09:03:51 +00:00
pathsearchmode = 0 ;
}
i = kopen4load ( " DUKESW.BIN " , 1 ) ; // JBF 20030810
if ( i ! = - 1 )
{
2007-08-26 10:35:52 +00:00
g_Shareware = 1 ;
2007-01-30 09:03:51 +00:00
kclose ( i ) ;
2006-09-10 17:40:34 +00:00
}
2006-07-22 05:49:55 +00:00
2006-12-10 03:15:56 +00:00
#if 0
2006-09-10 17:40:34 +00:00
copyprotect ( ) ;
if ( cp ) return ;
2006-12-10 03:15:56 +00:00
# endif
2006-07-22 02:54:07 +00:00
2006-07-22 05:49:55 +00:00
if ( netparamcount > 0 ) _buildargc = ( argc - = netparamcount + 1 ) ; // crop off the net parameters
2006-04-13 20:47:06 +00:00
// gotta set the proper title after we compile the CONs if this is the full version
if ( VOLUMEALL ) wm_setapptitle ( HEAD2 ) ;
else wm_setapptitle ( HEAD ) ;
2006-04-16 03:42:36 +00:00
initprintf ( " \n " ) ;
2006-04-15 03:12:08 +00:00
2007-08-27 06:46:31 +00:00
if ( g_ScriptDebug )
initprintf ( " CON debugging activated (level %d). \n \n " , g_ScriptDebug ) ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
RegisterShutdownFunction ( Shutdown ) ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
if ( VOLUMEONE )
{
2006-04-13 20:47:06 +00:00
initprintf ( " Distribution of shareware Duke Nukem 3D is restricted in certain ways. \n " ) ;
initprintf ( " Please read LICENSE.DOC for more details. \n " ) ;
}
2006-11-28 04:16:20 +00:00
Startup ( argc , argv ) ; // a bunch of stuff including compiling cons
2006-08-19 01:30:40 +00:00
2007-08-27 06:46:31 +00:00
if ( numplayers > 1 )
ud . multimode = numplayers ;
2007-08-27 23:11:49 +00:00
for ( i = 1 ; i < ud . multimode ; i + + )
2007-08-27 06:46:31 +00:00
{
2007-08-27 23:11:49 +00:00
g_player [ i ] . ps = ( player_struct * ) Bcalloc ( 1 , sizeof ( player_struct ) ) ;
g_player [ i ] . sync = ( input * ) Bcalloc ( 1 , sizeof ( input ) ) ;
2007-08-27 06:46:31 +00:00
}
g_player [ myconnectindex ] . ps - > palette = ( char * ) & palette [ 0 ] ;
2006-11-28 04:16:20 +00:00
i = 1 ;
for ( j = numplayers ; j < ud . multimode ; j + + )
2006-08-19 01:30:40 +00:00
{
2007-08-27 00:20:15 +00:00
Bsprintf ( g_player [ j ] . user_name , " PLAYER %d " , j + 1 ) ;
2007-08-27 06:46:31 +00:00
g_player [ j ] . ps - > team = g_player [ j ] . pteam = i ;
g_player [ j ] . ps - > weaponswitch = 3 ;
g_player [ j ] . ps - > auto_aim = 0 ;
2006-11-28 04:16:20 +00:00
i = 1 - i ;
2006-08-19 01:30:40 +00:00
}
2006-04-13 20:47:06 +00:00
if ( quitevent ) return ;
2007-04-17 05:54:12 +00:00
if ( ! loaddefinitionsfile ( duke3ddef ) ) initprintf ( " Definitions file '%s' loaded. \n " , duke3ddef ) ;
2006-04-13 20:47:06 +00:00
// initprintf("numplayers=%i\n",numplayers);
2006-11-13 23:12:47 +00:00
if ( numplayers > 1 )
2006-04-13 20:47:06 +00:00
{
sendlogon ( ) ;
}
2006-11-13 23:12:47 +00:00
else if ( boardfilename [ 0 ] ! = 0 )
2006-04-13 20:47:06 +00:00
{
ud . m_level_number = 7 ;
ud . m_volume_number = 0 ;
ud . warp_on = 1 ;
}
getnames ( ) ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode > 1 )
2006-04-13 20:47:06 +00:00
{
playerswhenstarted = ud . multimode ;
2006-11-13 23:12:47 +00:00
if ( ud . warp_on = = 0 )
2006-04-13 20:47:06 +00:00
{
ud . m_monsters_off = 1 ;
ud . m_player_skill = 0 ;
}
}
ud . last_level = - 1 ;
RTS_Init ( ud . rtsname ) ;
2007-02-13 09:50:58 +00:00
if ( numlumps ) initprintf ( " Using .RTS file '%s' \n " , ud . rtsname ) ;
2006-04-13 20:47:06 +00:00
2006-12-11 21:18:21 +00:00
initprintf ( " Initializing OSD... \n " ) ;
OSD_SetFunctions (
# ifdef _WIN32
GAME_drawosdchar ,
GAME_drawosdstr ,
GAME_drawosdcursor ,
GAME_getcolumnwidth ,
GAME_getrowheight ,
# else
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
# endif
GAME_clearbackground ,
( int ( * ) ( void ) ) GetTime ,
GAME_onshowosd
) ;
OSD_SetParameters ( 0 , 2 , 0 , 0 , 4 , 0 ) ;
2007-04-17 05:54:12 +00:00
OSD_SetVersionString ( HEAD2 , 0 , 2 ) ;
2006-12-11 21:18:21 +00:00
registerosdcommands ( ) ;
2007-08-27 00:20:15 +00:00
if ( setgamemode ( ud . config . ScreenMode , ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP ) < 0 )
2006-04-13 20:47:06 +00:00
{
2006-04-16 03:42:36 +00:00
int i = 0 ;
int xres [ ] = { 800 , 640 , 320 } ;
int yres [ ] = { 600 , 480 , 240 } ;
int bpp [ ] = { 32 , 16 , 8 } ;
2006-06-09 01:28:39 +00:00
2006-04-25 04:35:39 +00:00
initprintf ( " Failure setting video mode %dx%dx%d %s! Attempting safer mode... \n " ,
2007-08-27 00:20:15 +00:00
ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP , ud . config . ScreenMode ? " fullscreen " : " windowed " ) ;
2006-06-09 01:28:39 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-11-15 01:16:55 +00:00
while ( setgamemode ( 0 , xres [ i ] , yres [ i ] , bpp [ i ] ) < 0 )
{
2006-04-25 22:50:57 +00:00
initprintf ( " Failure setting video mode %dx%dx%d windowed! Attempting safer mode... \n " , xres [ i ] , yres [ i ] , bpp [ i ] ) ;
2006-04-16 03:42:36 +00:00
i + + ;
}
2006-06-09 01:28:39 +00:00
# else
2006-11-15 01:16:55 +00:00
while ( setgamemode ( 0 , xres [ i ] , yres [ i ] , 8 ) < 0 )
{
2006-06-09 01:28:39 +00:00
initprintf ( " Failure setting video mode %dx%dx%d windowed! Attempting safer mode... \n " , xres [ i ] , yres [ i ] , 8 ) ;
i + + ;
}
# endif
2007-08-27 00:20:15 +00:00
ud . config . ScreenWidth = xres [ i ] ;
ud . config . ScreenHeight = yres [ i ] ;
ud . config . ScreenBPP = bpp [ i ] ;
2006-04-13 20:47:06 +00:00
}
initprintf ( " Checking music inits... \n " ) ;
MusicStartup ( ) ;
initprintf ( " Checking sound inits... \n " ) ;
SoundStartup ( ) ;
loadtmb ( ) ;
2006-11-15 01:16:55 +00:00
if ( VOLUMEONE )
{
2006-11-13 23:12:47 +00:00
if ( numplayers > 4 | | ud . multimode > 4 )
2006-04-13 20:47:06 +00:00
gameexit ( " The full version of Duke Nukem 3D supports 5 or more players. " ) ;
}
2007-08-27 06:46:31 +00:00
setbrightness ( ud . brightness > > 2 , & g_player [ myconnectindex ] . ps - > palette [ 0 ] , 0 ) ;
2006-04-13 20:47:06 +00:00
// ESCESCAPE;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
load_script ( " autoexec.cfg " ) ;
2006-11-13 23:12:47 +00:00
if ( ud . warp_on > 1 & & ud . multimode < 2 )
2006-04-13 20:47:06 +00:00
{
clearview ( 0L ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
2006-04-13 20:47:06 +00:00
//palto(0,0,0,0);
2007-08-27 06:46:31 +00:00
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 0 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
rotatesprite ( 320 < < 15 , 200 < < 15 , 65536L , 0 , LOADSCREEN , 0 , 0 , 2 + 8 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
menutext ( 160 , 105 , 0 , 0 , " LOADING SAVED GAME... " ) ;
nextpage ( ) ;
2007-01-24 03:42:54 +00:00
if ( loadplayer ( ud . warp_on - 2 ) )
2006-04-13 20:47:06 +00:00
ud . warp_on = 0 ;
}
// getpackets();
MAIN_LOOP_RESTART :
2006-11-13 23:12:47 +00:00
if ( ud . warp_on = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-12-04 02:10:18 +00:00
if ( ud . multimode > 1 & & boardfilename [ 0 ] ! = 0 )
{
2006-12-09 23:41:43 +00:00
ud . m_level_number = 7 ;
ud . m_volume_number = 0 ;
2006-12-10 06:49:01 +00:00
2006-12-04 02:10:18 +00:00
if ( ud . m_player_skill = = 4 )
ud . m_respawn_monsters = 1 ;
else ud . m_respawn_monsters = 0 ;
2006-04-13 20:47:06 +00:00
2006-12-04 02:10:18 +00:00
waitforeverybody ( ) ;
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
{
resetweapons ( i ) ;
resetinventory ( i ) ;
}
2006-04-13 20:47:06 +00:00
newgame ( ud . m_volume_number , ud . m_level_number , ud . m_player_skill ) ;
if ( enterlevel ( MODE_GAME ) ) backtomenu ( ) ;
}
2006-12-04 02:10:18 +00:00
else Logo ( ) ;
}
else if ( ud . warp_on = = 1 )
{
newgame ( ud . m_volume_number , ud . m_level_number , ud . m_player_skill ) ;
if ( enterlevel ( MODE_GAME ) ) backtomenu ( ) ;
}
else vscrn ( ) ;
2006-11-14 21:35:50 +00:00
if ( ud . warp_on = = 0 & & playback ( ) )
2006-04-13 20:47:06 +00:00
{
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2007-08-26 10:35:52 +00:00
g_NoLogoAnim = 1 ;
2006-04-13 20:47:06 +00:00
goto MAIN_LOOP_RESTART ;
}
2007-08-27 00:20:15 +00:00
ud . auto_run = ud . config . RunMode ;
ud . showweapons = ud . config . ShowOpponentWeapons ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > aim_mode = ud . mouseaiming ;
g_player [ myconnectindex ] . ps - > auto_aim = ud . config . AutoAim ;
g_player [ myconnectindex ] . ps - > weaponswitch = ud . weaponswitch ;
2007-08-27 00:20:15 +00:00
g_player [ myconnectindex ] . pteam = ud . team ;
2006-08-18 23:52:26 +00:00
2006-11-13 23:12:47 +00:00
if ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_TDM )
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > palookup = g_player [ myconnectindex ] . pcolor = getteampal ( g_player [ myconnectindex ] . pteam ) ;
2006-11-15 01:16:55 +00:00
else
{
2007-08-27 06:46:31 +00:00
if ( ud . color ) g_player [ myconnectindex ] . ps - > palookup = g_player [ myconnectindex ] . pcolor = ud . color ;
else g_player [ myconnectindex ] . ps - > palookup = g_player [ myconnectindex ] . pcolor ;
2006-08-21 21:00:54 +00:00
}
2006-04-13 20:47:06 +00:00
ud . warp_on = 0 ;
KB_KeyDown [ sc_Pause ] = 0 ; // JBF: I hate the pause key
2007-08-27 06:46:31 +00:00
while ( ! ( g_player [ myconnectindex ] . ps - > gm & MODE_END ) ) //The whole loop!!!!!!!!!!!!!!!!!!
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( handleevents ( ) )
2007-08-25 01:05:00 +00:00
{
// JBF
2006-11-15 01:16:55 +00:00
if ( quitevent )
{
2006-04-13 20:47:06 +00:00
KB_KeyDown [ sc_Escape ] = 1 ;
quitevent = 0 ;
}
}
AudioUpdate ( ) ;
OSD_DispatchQueued ( ) ;
2007-08-27 06:46:31 +00:00
if ( ud . recstat = = 2 | | ud . multimode > 1 | | ( ud . show_help = = 0 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) ! = MODE_MENU ) )
if ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
2006-11-14 21:35:50 +00:00
if ( moveloop ( ) ) continue ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_EOL | | g_player [ myconnectindex ] . ps - > gm & MODE_RESTART )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_EOL )
2006-04-13 20:47:06 +00:00
{
closedemowrite ( ) ;
ready2send = 0 ;
2006-11-13 23:12:47 +00:00
if ( display_bonus_screen = = 1 )
2006-05-02 05:20:36 +00:00
{
i = ud . screen_size ;
ud . screen_size = 0 ;
vscrn ( ) ;
ud . screen_size = i ;
dobonus ( 0 ) ;
}
2006-11-13 23:12:47 +00:00
if ( ud . eog )
2006-04-13 20:47:06 +00:00
{
ud . eog = 0 ;
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( ! VOLUMEALL )
{
2006-04-13 20:47:06 +00:00
doorders ( ) ;
}
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_MENU ;
2006-04-13 20:47:06 +00:00
cmenu ( 0 ) ;
probey = 0 ;
goto MAIN_LOOP_RESTART ;
}
else
{
ud . m_level_number = 0 ;
ud . level_number = 0 ;
}
}
}
display_bonus_screen = 1 ;
ready2send = 0 ;
2007-08-27 06:46:31 +00:00
if ( numplayers > 1 ) g_player [ myconnectindex ] . ps - > gm = MODE_GAME ;
if ( enterlevel ( g_player [ myconnectindex ] . ps - > gm ) )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
backtomenu ( ) ;
goto MAIN_LOOP_RESTART ;
}
continue ;
}
cheats ( ) ;
nonsharedkeys ( ) ;
2007-08-27 06:46:31 +00:00
if ( ( ud . show_help = = 0 & & ud . multimode < 2 & & ! ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) ) | | ud . multimode > 1 | | ud . recstat = = 2 )
2006-04-13 20:47:06 +00:00
i = min ( max ( ( totalclock - ototalclock ) * ( 65536L / TICSPERFRAME ) , 0 ) , 65536 ) ;
else
i = 65536 ;
2007-02-13 02:22:17 +00:00
if ( ud . statusbarmode = = 1 & & ( ud . statusbarscale = = 100 | | bpp = = 8 ) )
2007-02-13 01:28:50 +00:00
{
ud . statusbarmode = 0 ;
vscrn ( ) ;
}
2006-04-13 20:47:06 +00:00
displayrooms ( screenpeek , i ) ;
displayrest ( i ) ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . gotvote = = 0 & & voting ! = - 1 & & voting ! = myconnectindex )
2006-08-21 21:00:54 +00:00
{
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " %s^00 HAS CALLED A VOTE FOR MAP " , g_player [ voting ] . user_name ) ;
2006-08-21 07:43:45 +00:00
gametext ( 160 , 40 , tempbuf , 0 , 2 + 8 + 16 ) ;
2007-08-26 11:28:32 +00:00
Bsprintf ( tempbuf , " %s (E%dL%d) " , map [ vote_episode * MAXLEVELS + vote_map ] . name , vote_episode + 1 , vote_map + 1 ) ;
2006-08-21 07:43:45 +00:00
gametext ( 160 , 48 , tempbuf , 0 , 2 + 8 + 16 ) ;
gametext ( 160 , 70 , " PRESS F1 TO VOTE YES, F2 TO VOTE NO " , 0 , 2 + 8 + 16 ) ;
2006-08-21 21:00:54 +00:00
}
2006-06-09 01:28:39 +00:00
2006-11-14 21:35:50 +00:00
// if(KB_KeyPressed(sc_F))
2006-04-13 20:47:06 +00:00
// {
// KB_ClearKeyDown(sc_F);
// addplayer();
// }
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_DEMO )
2006-04-13 20:47:06 +00:00
goto MAIN_LOOP_RESTART ;
2006-11-13 23:12:47 +00:00
if ( debug_on ) caches ( ) ;
2006-04-13 20:47:06 +00:00
checksync ( ) ;
2006-11-15 01:16:55 +00:00
if ( VOLUMEONE )
{
2007-08-27 06:46:31 +00:00
if ( ud . show_help = = 0 & & show_shareware > 0 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = 0 )
2006-04-13 20:47:06 +00:00
rotatesprite ( ( 320 - 50 ) < < 16 , 9 < < 16 , 65536L , 0 , BETAVERSION , 0 , 0 , 2 + 8 + 16 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
nextpage ( ) ;
2007-08-27 06:46:31 +00:00
while ( ! ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) & & ready2send & & totalclock > = ototalclock + TICSPERFRAME )
2006-04-13 20:47:06 +00:00
faketimerhandler ( ) ;
}
gameexit ( " " ) ;
}
2007-01-12 22:42:19 +00:00
static int demo_version ;
2006-04-17 07:53:31 +00:00
2007-01-12 22:42:19 +00:00
static int opendemoread ( int which_demo ) // 0 = mine
2006-04-13 20:47:06 +00:00
{
char d [ 13 ] ;
char ver ;
2006-04-17 07:53:31 +00:00
int32 i ;
2006-04-13 20:47:06 +00:00
2006-07-21 22:25:05 +00:00
Bstrcpy ( d , " demo_.dmo " ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( which_demo = = 10 )
2006-04-13 20:47:06 +00:00
d [ 4 ] = ' x ' ;
else
d [ 4 ] = ' 0 ' + which_demo ;
ud . reccnt = 0 ;
2006-11-13 23:12:47 +00:00
if ( which_demo = = 1 & & firstdemofile [ 0 ] ! = 0 )
2006-04-13 20:47:06 +00:00
{
if ( ( recfilep = kopen4load ( firstdemofile , loadfromgrouponly ) ) = = - 1 ) return ( 0 ) ;
}
else
if ( ( recfilep = kopen4load ( d , loadfromgrouponly ) ) = = - 1 ) return ( 0 ) ;
if ( kread ( recfilep , & ud . reccnt , sizeof ( long ) ) ! = sizeof ( long ) ) goto corrupt ;
if ( kread ( recfilep , & ver , sizeof ( char ) ) ! = sizeof ( char ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
2006-11-15 01:16:55 +00:00
if ( ver ! = BYTEVERSION /*&& ver != 116 && ver != 117*/ )
2007-08-25 01:05:00 +00:00
{
/* old demo playback */
2006-11-14 21:35:50 +00:00
if ( ver = = BYTEVERSION_JF ) initprintf ( " Demo %s is for Regular edition. \n " , d ) ;
2006-04-13 20:47:06 +00:00
else if ( ver = = BYTEVERSION_JF + 1 ) initprintf ( " Demo %s is for Atomic edition. \n " , d ) ;
else if ( ver = = BYTEVERSION_JF + 2 ) initprintf ( " Demo %s is for Shareware version. \n " , d ) ;
else OSD_Printf ( " Demo %s is of an incompatible version (%d) . \ n " , d, ver) ;
kclose ( recfilep ) ;
ud . reccnt = 0 ;
2006-04-17 07:53:31 +00:00
demo_version = 0 ;
2006-04-13 20:47:06 +00:00
return 0 ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-04-18 00:43:32 +00:00
demo_version = ver ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " Demo %s is of version %d. \n " , d , ver ) ;
2006-04-13 20:47:06 +00:00
}
if ( kread ( recfilep , ( char * ) & ud . volume_number , sizeof ( char ) ) ! = sizeof ( char ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.volume_number: %d \n " , ud . volume_number ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( char * ) & ud . level_number , sizeof ( char ) ) ! = sizeof ( char ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.level_number: %d \n " , ud . level_number ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( char * ) & ud . player_skill , sizeof ( char ) ) ! = sizeof ( char ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.player_skill: %d \n " , ud . player_skill ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( char * ) & ud . m_coop , sizeof ( char ) ) ! = sizeof ( char ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.m_coop: %d \n " , ud . m_coop ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( char * ) & ud . m_ffire , sizeof ( char ) ) ! = sizeof ( char ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.m_ffire: %d \n " , ud . m_ffire ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( short * ) & ud . multimode , sizeof ( short ) ) ! = sizeof ( short ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.multimode: %d \n " , ud . multimode ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( short * ) & ud . m_monsters_off , sizeof ( short ) ) ! = sizeof ( short ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.m_monsters_off: %d \n " , ud . m_monsters_off ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( int32 * ) & ud . m_respawn_monsters , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.m_respawn_monsters: %d \n " , ud . m_respawn_monsters ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( int32 * ) & ud . m_respawn_items , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.m_respawn_items: %d \n " , ud . m_respawn_items ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( int32 * ) & ud . m_respawn_inventory , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.m_respawn_inventory: %d \n " , ud . m_respawn_inventory ) ;
2006-04-13 20:47:06 +00:00
if ( kread ( recfilep , ( int32 * ) & ud . playerai , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
OSD_Printf ( " ud.playerai: %d \n " , ud . playerai ) ;
if ( kread ( recfilep , ( int32 * ) & i , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2007-02-11 00:49:03 +00:00
if ( kread ( recfilep , ( char * ) boardfilename , sizeof ( boardfilename ) ) ! = sizeof ( boardfilename ) ) goto corrupt ;
2006-04-17 07:53:31 +00:00
2006-11-14 21:35:50 +00:00
if ( boardfilename [ 0 ] ! = 0 )
2006-04-13 20:47:06 +00:00
{
ud . m_level_number = 7 ;
ud . m_volume_number = 0 ;
}
2007-02-11 00:49:03 +00:00
if ( kread ( recfilep , ( int32 * ) & ud . m_noexits , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2006-11-15 01:16:55 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
{
2007-08-27 06:46:31 +00:00
if ( kread ( recfilep , ( char * ) g_player [ i ] . user_name , sizeof ( g_player [ i ] . user_name ) ) ! = sizeof ( g_player [ i ] . user_name ) ) goto corrupt ;
OSD_Printf ( " ud.user_name: %s \n " , g_player [ i ] . user_name ) ;
if ( kread ( recfilep , ( int32 * ) & g_player [ i ] . ps - > aim_mode , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
if ( kread ( recfilep , ( int32 * ) & g_player [ i ] . ps - > auto_aim , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ; // JBF 20031126
if ( kread ( recfilep , ( int32 * ) & g_player [ i ] . ps - > weaponswitch , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2007-08-27 00:20:15 +00:00
if ( kread ( recfilep , ( int32 * ) & g_player [ i ] . pcolor , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2007-08-27 06:46:31 +00:00
g_player [ i ] . ps - > palookup = g_player [ i ] . pcolor ;
2007-08-27 00:20:15 +00:00
if ( kread ( recfilep , ( int32 * ) & g_player [ i ] . pteam , sizeof ( int32 ) ) ! = sizeof ( int32 ) ) goto corrupt ;
2007-08-27 06:46:31 +00:00
g_player [ i ] . ps - > team = g_player [ i ] . pteam ;
2006-04-13 20:47:06 +00:00
}
ud . god = ud . cashman = ud . eog = ud . showallmap = 0 ;
2006-04-17 07:53:31 +00:00
ud . clipping = ud . scrollmode = ud . overhead_on = ud . pause_on = 0 ;
2006-04-13 20:47:06 +00:00
newgame ( ud . volume_number , ud . level_number , ud . player_skill ) ;
return ( 1 ) ;
corrupt :
2006-04-17 20:51:00 +00:00
OSD_Printf ( " Demo %d header is corrupt. \n " , which_demo ) ;
2006-04-13 20:47:06 +00:00
ud . reccnt = 0 ;
kclose ( recfilep ) ;
return 0 ;
}
void opendemowrite ( void )
{
char * d = " demo1.dmo " ;
long dummylong = 0 ;
char ver ;
short i ;
2006-11-13 23:12:47 +00:00
if ( ud . recstat = = 2 ) kclose ( recfilep ) ;
2006-04-13 20:47:06 +00:00
ver = BYTEVERSION ;
2006-04-15 03:12:08 +00:00
if ( ( frecfilep = fopen ( d , " wb " ) ) = = NULL ) return ;
2006-04-13 20:47:06 +00:00
fwrite ( & dummylong , 4 , 1 , frecfilep ) ;
fwrite ( & ver , sizeof ( char ) , 1 , frecfilep ) ;
fwrite ( ( char * ) & ud . volume_number , sizeof ( char ) , 1 , frecfilep ) ;
fwrite ( ( char * ) & ud . level_number , sizeof ( char ) , 1 , frecfilep ) ;
fwrite ( ( char * ) & ud . player_skill , sizeof ( char ) , 1 , frecfilep ) ;
fwrite ( ( char * ) & ud . m_coop , sizeof ( char ) , 1 , frecfilep ) ;
fwrite ( ( char * ) & ud . m_ffire , sizeof ( char ) , 1 , frecfilep ) ;
fwrite ( ( short * ) & ud . multimode , sizeof ( short ) , 1 , frecfilep ) ;
fwrite ( ( short * ) & ud . m_monsters_off , sizeof ( short ) , 1 , frecfilep ) ;
fwrite ( ( int32 * ) & ud . m_respawn_monsters , sizeof ( int32 ) , 1 , frecfilep ) ;
fwrite ( ( int32 * ) & ud . m_respawn_items , sizeof ( int32 ) , 1 , frecfilep ) ;
fwrite ( ( int32 * ) & ud . m_respawn_inventory , sizeof ( int32 ) , 1 , frecfilep ) ;
fwrite ( ( int32 * ) & ud . playerai , sizeof ( int32 ) , 1 , frecfilep ) ;
fwrite ( ( int32 * ) & ud . auto_run , sizeof ( int32 ) , 1 , frecfilep ) ;
fwrite ( ( char * ) boardfilename , sizeof ( boardfilename ) , 1 , frecfilep ) ;
2007-02-11 00:49:03 +00:00
fwrite ( ( int32 * ) & ud . m_noexits , sizeof ( int32 ) , 1 , frecfilep ) ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
{
2007-08-27 06:46:31 +00:00
fwrite ( ( char * ) & g_player [ i ] . user_name , sizeof ( g_player [ i ] . user_name ) , 1 , frecfilep ) ;
fwrite ( ( int32 * ) & g_player [ i ] . ps - > aim_mode , sizeof ( int32 ) , 1 , frecfilep ) ;
fwrite ( ( int32 * ) & g_player [ i ] . ps - > auto_aim , sizeof ( int32 ) , 1 , frecfilep ) ; // JBF 20031126
fwrite ( & g_player [ i ] . ps - > weaponswitch , sizeof ( int32 ) , 1 , frecfilep ) ;
2007-08-27 00:20:15 +00:00
fwrite ( & g_player [ i ] . pcolor , sizeof ( int32 ) , 1 , frecfilep ) ;
fwrite ( & g_player [ i ] . pteam , sizeof ( int32 ) , 1 , frecfilep ) ;
2006-04-13 20:47:06 +00:00
}
totalreccnt = 0 ;
ud . reccnt = 0 ;
}
2006-12-10 03:15:56 +00:00
static void record ( void )
2006-04-13 20:47:06 +00:00
{
short i ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
copybufbyte ( g_player [ i ] . sync , & recsync [ ud . reccnt ] , sizeof ( input ) ) ;
2006-04-13 20:47:06 +00:00
ud . reccnt + + ;
totalreccnt + + ;
if ( ud . reccnt > = RECSYNCBUFSIZ )
{
dfwrite ( recsync , sizeof ( input ) * ud . multimode , ud . reccnt / ud . multimode , frecfilep ) ;
ud . reccnt = 0 ;
}
}
}
void closedemowrite ( void )
{
if ( ud . recstat = = 1 )
{
if ( ud . reccnt > 0 )
{
dfwrite ( recsync , sizeof ( input ) * ud . multimode , ud . reccnt / ud . multimode , frecfilep ) ;
fseek ( frecfilep , SEEK_SET , 0L ) ;
fwrite ( & totalreccnt , sizeof ( long ) , 1 , frecfilep ) ;
ud . recstat = ud . m_recstat = 0 ;
}
fclose ( frecfilep ) ;
}
}
2007-01-12 22:42:19 +00:00
static int which_demo = 1 ;
static int in_menu = 0 ;
2006-04-13 20:47:06 +00:00
// extern long syncs[];
2006-12-10 03:15:56 +00:00
static long playback ( void )
2006-04-13 20:47:06 +00:00
{
2006-04-22 22:33:52 +00:00
long i , j , k , l ;
2007-02-12 07:58:03 +00:00
int foundemo = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( ready2send ) return 0 ;
2006-04-13 20:47:06 +00:00
RECHECK :
2007-08-27 06:46:31 +00:00
in_menu = g_player [ myconnectindex ] . ps - > gm & MODE_MENU ;
2006-04-13 20:47:06 +00:00
pub = NUMPAGES ;
pus = NUMPAGES ;
flushperms ( ) ;
2007-02-12 07:58:03 +00:00
if ( ud . multimode < 2 ) foundemo = opendemoread ( which_demo ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( foundemo = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( which_demo > 1 )
2006-04-13 20:47:06 +00:00
{
which_demo = 1 ;
goto RECHECK ;
}
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
2007-08-27 06:46:31 +00:00
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 1 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
drawbackground ( ) ;
menus ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
2006-04-13 20:47:06 +00:00
nextpage ( ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
ud . reccnt = 0 ;
}
else
{
ud . recstat = 2 ;
which_demo + + ;
2006-11-13 23:12:47 +00:00
if ( which_demo = = 10 ) which_demo = 1 ;
2006-04-13 20:47:06 +00:00
if ( enterlevel ( MODE_DEMO ) ) return 1 ;
}
2006-11-13 23:12:47 +00:00
if ( foundemo = = 0 | | in_menu | | KB_KeyWaiting ( ) | | numplayers > 1 )
2006-04-13 20:47:06 +00:00
{
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-04-13 20:47:06 +00:00
}
ready2send = 0 ;
i = 0 ;
KB_FlushKeyboardQueue ( ) ;
k = 0 ;
while ( ud . reccnt > 0 | | foundemo = = 0 )
{
2007-02-11 00:49:03 +00:00
if ( foundemo )
while ( totalclock > = ( lockclock + TICSPERFRAME ) )
2006-04-13 20:47:06 +00:00
{
2007-02-11 00:49:03 +00:00
if ( ( i = = 0 ) | | ( i > = RECSYNCBUFSIZ ) )
2006-04-13 20:47:06 +00:00
{
2007-02-11 00:49:03 +00:00
i = 0 ;
l = min ( ud . reccnt , RECSYNCBUFSIZ ) ;
if ( kdfread ( recsync , sizeof ( input ) * ud . multimode , l / ud . multimode , recfilep ) ! = l / ud . multimode )
2006-04-17 07:53:31 +00:00
{
2007-02-11 00:49:03 +00:00
OSD_Printf ( " Demo %d is corrupt. \n " , which_demo - 1 ) ;
foundemo = 0 ;
ud . reccnt = 0 ;
kclose ( recfilep ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2007-02-11 00:49:03 +00:00
goto RECHECK ;
2006-04-17 07:53:31 +00:00
}
}
2007-02-11 00:49:03 +00:00
for ( j = connecthead ; j > = 0 ; j = connectpoint2 [ j ] )
{
2007-08-27 06:46:31 +00:00
copybufbyte ( & recsync [ i ] , & inputfifo [ g_player [ j ] . movefifoend & ( MOVEFIFOSIZ - 1 ) ] [ j ] , sizeof ( input ) ) ;
2007-08-27 00:20:15 +00:00
g_player [ j ] . movefifoend + + ;
2007-02-11 00:49:03 +00:00
i + + ;
ud . reccnt - - ;
2006-04-13 20:47:06 +00:00
}
domovethings ( ) ;
}
2006-11-13 23:12:47 +00:00
if ( foundemo = = 0 )
2006-04-13 20:47:06 +00:00
drawbackground ( ) ;
else
{
nonsharedkeys ( ) ;
j = min ( max ( ( totalclock - lockclock ) * ( 65536 / TICSPERFRAME ) , 0 ) , 65536 ) ;
displayrooms ( screenpeek , j ) ;
displayrest ( j ) ;
2007-08-27 06:46:31 +00:00
if ( ud . multimode > 1 & & g_player [ myconnectindex ] . ps - > gm )
2006-04-13 20:47:06 +00:00
getpackets ( ) ;
2006-06-09 01:28:39 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . gotvote = = 0 & & voting ! = - 1 & & voting ! = myconnectindex )
2006-06-09 01:28:39 +00:00
gametext ( 160 , 60 , " PRESS F1 TO VOTE YES, F2 TO VOTE NO " , 0 , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
if ( ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) & & ( g_player [ myconnectindex ] . ps - > gm & MODE_EOL ) )
2006-04-13 20:47:06 +00:00
goto RECHECK ;
2007-08-27 06:46:31 +00:00
if ( KB_KeyPressed ( sc_Escape ) & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = 0 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE ) = = 0 )
2006-04-13 20:47:06 +00:00
{
KB_ClearKeyDown ( sc_Escape ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-04-13 20:47:06 +00:00
cmenu ( 0 ) ;
intomenusounds ( ) ;
}
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE )
2006-04-13 20:47:06 +00:00
{
typemode ( ) ;
2007-08-27 06:46:31 +00:00
if ( ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE ) ! = MODE_TYPE )
g_player [ myconnectindex ] . ps - > gm = MODE_MENU ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-13 23:12:47 +00:00
if ( ud . recstat ! = 2 )
2006-04-16 03:42:36 +00:00
menus ( ) ;
2006-11-14 21:35:50 +00:00
if ( ud . multimode > 1 & & current_menu ! = 20003 & & current_menu ! = 20005 & & current_menu ! = 210 )
2006-04-13 20:47:06 +00:00
{
ControlInfo noshareinfo ;
2006-11-14 21:35:50 +00:00
CONTROL_GetInput ( & noshareinfo ) ;
if ( BUTTON ( gamefunc_SendMessage ) )
2006-04-13 20:47:06 +00:00
{
KB_FlushKeyboardQueue ( ) ;
2006-11-14 21:35:50 +00:00
CONTROL_ClearButton ( gamefunc_SendMessage ) ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_TYPE ;
2006-04-13 20:47:06 +00:00
typebuf [ 0 ] = 0 ;
inputloc = 0 ;
}
}
}
operatefta ( ) ;
2006-11-13 23:12:47 +00:00
if ( ud . last_camsprite ! = ud . camerasprite )
2006-04-13 20:47:06 +00:00
{
ud . last_camsprite = ud . camerasprite ;
ud . camera_time = totalclock + ( TICRATE * 2 ) ;
}
2006-11-15 01:16:55 +00:00
if ( VOLUMEONE )
{
2007-08-27 06:46:31 +00:00
if ( ud . show_help = = 0 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = 0 )
2006-04-13 20:47:06 +00:00
rotatesprite ( ( 320 - 50 ) < < 16 , 9 < < 16 , 65536L , 0 , BETAVERSION , 0 , 0 , 2 + 8 + 16 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
handleevents ( ) ;
getpackets ( ) ;
nextpage ( ) ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm = = MODE_END | | g_player [ myconnectindex ] . ps - > gm = = MODE_GAME )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( foundemo )
2006-04-13 20:47:06 +00:00
kclose ( recfilep ) ;
return 0 ;
}
}
kclose ( recfilep ) ;
#if 0
{
unsigned long crcv ;
// sync checker
+ initcrc32table ( ) ;
crc32init ( & crcv ) ;
crc32block ( & crcv , ( unsigned char * ) wall , sizeof ( wall ) ) ;
crc32block ( & crcv , ( unsigned char * ) sector , sizeof ( sector ) ) ;
crc32block ( & crcv , ( unsigned char * ) sprite , sizeof ( sprite ) ) ;
crc32finish ( & crcv ) ;
initprintf ( " Checksum = %08X \n " , crcv ) ;
}
# endif
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) goto RECHECK ;
2006-04-13 20:47:06 +00:00
return 1 ;
}
2006-12-23 02:38:47 +00:00
static int moveloop ( )
2006-04-13 20:47:06 +00:00
{
2007-01-12 22:42:19 +00:00
int i ;
2006-04-13 20:47:06 +00:00
if ( numplayers > 1 )
2007-08-27 00:20:15 +00:00
while ( fakemovefifoplc < g_player [ myconnectindex ] . movefifoend ) fakedomovethings ( ) ;
2006-04-13 20:47:06 +00:00
getpackets ( ) ;
if ( numplayers < 2 ) bufferjitter = 0 ;
2007-08-27 00:20:15 +00:00
while ( g_player [ myconnectindex ] . movefifoend - movefifoplc > bufferjitter )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 00:20:15 +00:00
if ( movefifoplc = = g_player [ i ] . movefifoend ) break ;
2006-04-13 20:47:06 +00:00
if ( i > = 0 ) break ;
2006-11-14 21:35:50 +00:00
if ( domovethings ( ) ) return 1 ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2006-12-10 03:15:56 +00:00
static void fakedomovethingscorrect ( void )
2006-04-13 20:47:06 +00:00
{
long i ;
2007-08-27 00:20:15 +00:00
player_struct * p ;
2006-04-13 20:47:06 +00:00
if ( numplayers < 2 ) return ;
i = ( ( movefifoplc - 1 ) & ( MOVEFIFOSIZ - 1 ) ) ;
2007-08-27 06:46:31 +00:00
p = g_player [ myconnectindex ] . ps ;
2006-04-13 20:47:06 +00:00
if ( p - > posx = = myxbak [ i ] & & p - > posy = = myybak [ i ] & & p - > posz = = myzbak [ i ]
& & p - > horiz = = myhorizbak [ i ] & & p - > ang = = myangbak [ i ] ) return ;
2006-11-15 01:16:55 +00:00
myx = p - > posx ;
omyx = p - > oposx ;
myxvel = p - > posxv ;
myy = p - > posy ;
omyy = p - > oposy ;
myyvel = p - > posyv ;
myz = p - > posz ;
omyz = p - > oposz ;
myzvel = p - > poszv ;
myang = p - > ang ;
omyang = p - > oang ;
2006-04-13 20:47:06 +00:00
mycursectnum = p - > cursectnum ;
2006-11-15 01:16:55 +00:00
myhoriz = p - > horiz ;
omyhoriz = p - > ohoriz ;
myhorizoff = p - > horizoff ;
omyhorizoff = p - > ohorizoff ;
2006-04-13 20:47:06 +00:00
myjumpingcounter = p - > jumping_counter ;
myjumpingtoggle = p - > jumping_toggle ;
myonground = p - > on_ground ;
myhardlanding = p - > hard_landing ;
myreturntocenter = p - > return_to_center ;
fakemovefifoplc = movefifoplc ;
2007-08-27 00:20:15 +00:00
while ( fakemovefifoplc < g_player [ myconnectindex ] . movefifoend )
2006-04-13 20:47:06 +00:00
fakedomovethings ( ) ;
}
2006-12-10 03:15:56 +00:00
static void fakedomovethings ( void )
2006-04-13 20:47:06 +00:00
{
input * syn ;
2007-08-27 00:20:15 +00:00
player_struct * p ;
2006-04-13 20:47:06 +00:00
long i , j , k , doubvel , fz , cz , hz , lz , x , y ;
unsigned long sb_snum ;
short psect , psectlotag , tempsect , backcstat ;
char shrunk , spritebridge ;
syn = ( input * ) & inputfifo [ fakemovefifoplc & ( MOVEFIFOSIZ - 1 ) ] [ myconnectindex ] ;
2007-08-27 06:46:31 +00:00
p = g_player [ myconnectindex ] . ps ;
2006-04-13 20:47:06 +00:00
backcstat = sprite [ p - > i ] . cstat ;
sprite [ p - > i ] . cstat & = ~ 257 ;
sb_snum = syn - > bits ;
psect = mycursectnum ;
psectlotag = sector [ psect ] . lotag ;
spritebridge = 0 ;
shrunk = ( sprite [ p - > i ] . yrepeat < 32 ) ;
2006-11-14 21:35:50 +00:00
if ( ud . clipping = = 0 & & ( sector [ psect ] . floorpicnum = = MIRROR | | psect < 0 | | psect > = MAXSECTORS ) )
2006-04-13 20:47:06 +00:00
{
myx = omyx ;
myy = omyy ;
}
else
{
omyx = myx ;
omyy = myy ;
}
omyhoriz = myhoriz ;
omyhorizoff = myhorizoff ;
omyz = myz ;
omyang = myang ;
getzrange ( myx , myy , myz , psect , & cz , & hz , & fz , & lz , 163L , CLIPMASK0 ) ;
j = getflorzofslope ( psect , myx , myy ) ;
2006-11-14 21:35:50 +00:00
if ( ( lz & 49152 ) = = 16384 & & psectlotag = = 1 & & klabs ( myz - j ) > PHEIGHT + ( 16 < < 8 ) )
2006-04-13 20:47:06 +00:00
psectlotag = 0 ;
2006-11-14 21:35:50 +00:00
if ( p - > aim_mode = = 0 & & myonground & & psectlotag ! = 2 & & ( sector [ psect ] . floorstat & 2 ) )
2006-04-13 20:47:06 +00:00
{
x = myx + ( sintable [ ( myang + 512 ) & 2047 ] > > 5 ) ;
y = myy + ( sintable [ myang & 2047 ] > > 5 ) ;
tempsect = psect ;
2006-12-02 06:00:49 +00:00
updatesector ( x , y , & tempsect ) ;
2006-04-13 20:47:06 +00:00
if ( tempsect > = 0 )
{
k = getflorzofslope ( psect , x , y ) ;
if ( psect = = tempsect )
myhorizoff + = mulscale16 ( j - k , 160 ) ;
else if ( klabs ( getflorzofslope ( tempsect , x , y ) - k ) < = ( 4 < < 8 ) )
myhorizoff + = mulscale16 ( j - k , 160 ) ;
}
}
if ( myhorizoff > 0 ) myhorizoff - = ( ( myhorizoff > > 3 ) + 1 ) ;
else if ( myhorizoff < 0 ) myhorizoff + = ( ( ( - myhorizoff ) > > 3 ) + 1 ) ;
2006-11-13 23:12:47 +00:00
if ( hz > = 0 & & ( hz & 49152 ) = = 49152 )
2006-04-13 20:47:06 +00:00
{
hz & = ( MAXSPRITES - 1 ) ;
if ( sprite [ hz ] . statnum = = 1 & & sprite [ hz ] . extra > = 0 )
{
hz = 0 ;
cz = getceilzofslope ( psect , myx , myy ) ;
}
}
2006-11-13 23:12:47 +00:00
if ( lz > = 0 & & ( lz & 49152 ) = = 49152 )
2006-04-13 20:47:06 +00:00
{
j = lz & ( MAXSPRITES - 1 ) ;
if ( ( sprite [ j ] . cstat & 33 ) = = 33 )
{
psectlotag = 0 ;
spritebridge = 1 ;
}
2006-11-14 21:35:50 +00:00
if ( badguy ( & sprite [ j ] ) & & sprite [ j ] . xrepeat > 24 & & klabs ( sprite [ p - > i ] . z - sprite [ j ] . z ) < ( 84 < < 8 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
j = getangle ( sprite [ j ] . x - myx , sprite [ j ] . y - myy ) ;
2006-04-13 20:47:06 +00:00
myxvel - = sintable [ ( j + 512 ) & 2047 ] < < 4 ;
myyvel - = sintable [ j & 2047 ] < < 4 ;
}
}
2006-11-14 21:35:50 +00:00
if ( sprite [ p - > i ] . extra < = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( psectlotag = = 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( p - > on_warping_sector = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( klabs ( myz - fz ) > ( PHEIGHT > > 1 ) )
2006-04-13 20:47:06 +00:00
myz + = 348 ;
}
clipmove ( & myx , & myy , & myz , & mycursectnum , 0 , 0 , 164L , ( 4L < < 8 ) , ( 4L < < 8 ) , CLIPMASK0 ) ;
}
2006-12-02 06:00:49 +00:00
updatesector ( myx , myy , & mycursectnum ) ;
2006-04-13 20:47:06 +00:00
pushmove ( & myx , & myy , & myz , & mycursectnum , 128L , ( 4L < < 8 ) , ( 20L < < 8 ) , CLIPMASK0 ) ;
myhoriz = 100 ;
myhorizoff = 0 ;
goto ENDFAKEPROCESSINPUT ;
}
doubvel = TICSPERFRAME ;
2006-11-13 23:12:47 +00:00
if ( p - > on_crane > = 0 ) goto FAKEHORIZONLY ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( p - > one_eighty_count < 0 ) myang + = 128 ;
2006-04-13 20:47:06 +00:00
i = 40 ;
2006-11-14 21:35:50 +00:00
if ( psectlotag = = 2 )
2006-04-13 20:47:06 +00:00
{
myjumpingcounter = 0 ;
2006-11-14 21:35:50 +00:00
if ( sb_snum & 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( myzvel > 0 ) myzvel = 0 ;
2006-04-13 20:47:06 +00:00
myzvel - = 348 ;
2006-11-13 23:12:47 +00:00
if ( myzvel < - ( 256 * 6 ) ) myzvel = - ( 256 * 6 ) ;
2006-04-13 20:47:06 +00:00
}
else if ( sb_snum & ( 1 < < 1 ) )
{
2006-11-13 23:12:47 +00:00
if ( myzvel < 0 ) myzvel = 0 ;
2006-04-13 20:47:06 +00:00
myzvel + = 348 ;
2006-11-13 23:12:47 +00:00
if ( myzvel > ( 256 * 6 ) ) myzvel = ( 256 * 6 ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-13 23:12:47 +00:00
if ( myzvel < 0 )
2006-04-13 20:47:06 +00:00
{
myzvel + = 256 ;
2006-11-13 23:12:47 +00:00
if ( myzvel > 0 )
2006-04-13 20:47:06 +00:00
myzvel = 0 ;
}
2006-11-13 23:12:47 +00:00
if ( myzvel > 0 )
2006-04-13 20:47:06 +00:00
{
myzvel - = 256 ;
2006-11-13 23:12:47 +00:00
if ( myzvel < 0 )
2006-04-13 20:47:06 +00:00
myzvel = 0 ;
}
}
2006-11-13 23:12:47 +00:00
if ( myzvel > 2048 ) myzvel > > = 1 ;
2006-04-13 20:47:06 +00:00
myz + = myzvel ;
2006-11-14 21:35:50 +00:00
if ( myz > ( fz - ( 15 < < 8 ) ) )
2006-04-13 20:47:06 +00:00
myz + = ( ( fz - ( 15 < < 8 ) ) - myz ) > > 1 ;
2006-11-14 21:35:50 +00:00
if ( myz < ( cz + ( 4 < < 8 ) ) )
2006-04-13 20:47:06 +00:00
{
myz = cz + ( 4 < < 8 ) ;
myzvel = 0 ;
}
}
2006-11-13 23:12:47 +00:00
else if ( p - > jetpack_on )
2006-04-13 20:47:06 +00:00
{
myonground = 0 ;
myjumpingcounter = 0 ;
myhardlanding = 0 ;
2006-11-13 23:12:47 +00:00
if ( p - > jetpack_on < 11 )
2006-04-13 20:47:06 +00:00
myz - = ( p - > jetpack_on < < 7 ) ; //Goin up
2006-11-13 23:12:47 +00:00
if ( shrunk ) j = 512 ;
2006-04-13 20:47:06 +00:00
else j = 2048 ;
if ( sb_snum & 1 ) //A
myz - = j ;
if ( sb_snum & ( 1 < < 1 ) ) //Z
myz + = j ;
2006-11-14 21:35:50 +00:00
if ( shrunk = = 0 & & ( psectlotag = = 0 | | psectlotag = = 2 ) ) k = 32 ;
2006-04-13 20:47:06 +00:00
else k = 16 ;
2006-11-14 21:35:50 +00:00
if ( myz > ( fz - ( k < < 8 ) ) )
2006-04-13 20:47:06 +00:00
myz + = ( ( fz - ( k < < 8 ) ) - myz ) > > 1 ;
2006-11-14 21:35:50 +00:00
if ( myz < ( cz + ( 18 < < 8 ) ) )
2006-04-13 20:47:06 +00:00
myz = cz + ( 18 < < 8 ) ;
}
2006-11-14 21:35:50 +00:00
else if ( psectlotag ! = 2 )
2006-04-13 20:47:06 +00:00
{
if ( psectlotag = = 1 & & p - > spritebridge = = 0 )
{
2006-11-13 23:12:47 +00:00
if ( shrunk = = 0 ) i = 34 ;
2006-04-13 20:47:06 +00:00
else i = 12 ;
}
2006-11-14 21:35:50 +00:00
if ( myz < ( fz - ( i < < 8 ) ) & & ( floorspace ( psect ) | ceilingspace ( psect ) ) = = 0 ) //falling
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ( sb_snum & 3 ) = = 0 & & myonground & & ( sector [ psect ] . floorstat & 2 ) & & myz > = ( fz - ( i < < 8 ) - ( 16 < < 8 ) ) )
2006-04-13 20:47:06 +00:00
myz = fz - ( i < < 8 ) ;
else
{
myonground = 0 ;
myzvel + = ( gc + 80 ) ;
2006-11-13 23:12:47 +00:00
if ( myzvel > = ( 4096 + 2048 ) ) myzvel = ( 4096 + 2048 ) ;
2006-04-13 20:47:06 +00:00
}
}
else
{
2006-11-13 23:12:47 +00:00
if ( psectlotag ! = 1 & & psectlotag ! = 2 & & myonground = = 0 & & myzvel > ( 6144 > > 1 ) )
2006-04-13 20:47:06 +00:00
myhardlanding = myzvel > > 10 ;
myonground = 1 ;
2006-11-13 23:12:47 +00:00
if ( i = = 40 )
2006-04-13 20:47:06 +00:00
{
//Smooth on the ground
k = ( ( fz - ( i < < 8 ) ) - myz ) > > 1 ;
2006-11-14 21:35:50 +00:00
if ( klabs ( k ) < 256 ) k = 0 ;
2006-04-13 20:47:06 +00:00
myz + = k ; // ((fz-(i<<8))-myz)>>1;
myzvel - = 768 ; // 412;
2006-11-13 23:12:47 +00:00
if ( myzvel < 0 ) myzvel = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
else if ( myjumpingcounter = = 0 )
2006-04-13 20:47:06 +00:00
{
myz + = ( ( fz - ( i < < 7 ) ) - myz ) > > 1 ; //Smooth on the water
2006-11-13 23:12:47 +00:00
if ( p - > on_warping_sector = = 0 & & myz > fz - ( 16 < < 8 ) )
2006-04-13 20:47:06 +00:00
{
myz = fz - ( 16 < < 8 ) ;
myzvel > > = 1 ;
}
}
2006-11-14 21:35:50 +00:00
if ( sb_snum & 2 )
2006-04-13 20:47:06 +00:00
myz + = ( 2048 + 768 ) ;
2006-11-14 21:35:50 +00:00
if ( ( sb_snum & 1 ) = = 0 & & myjumpingtoggle = = 1 )
2006-04-13 20:47:06 +00:00
myjumpingtoggle = 0 ;
2006-11-14 21:35:50 +00:00
else if ( ( sb_snum & 1 ) & & myjumpingtoggle = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( myjumpingcounter = = 0 )
if ( ( fz - cz ) > ( 56 < < 8 ) )
2006-04-13 20:47:06 +00:00
{
myjumpingcounter = 1 ;
myjumpingtoggle = 1 ;
}
}
2006-11-14 21:35:50 +00:00
if ( myjumpingcounter & & ( sb_snum & 1 ) = = 0 )
2006-04-13 20:47:06 +00:00
myjumpingcounter = 0 ;
}
2006-11-13 23:12:47 +00:00
if ( myjumpingcounter )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ( sb_snum & 1 ) = = 0 & & myjumpingtoggle = = 1 )
2006-04-13 20:47:06 +00:00
myjumpingtoggle = 0 ;
2006-11-14 21:35:50 +00:00
if ( myjumpingcounter < ( 1024 + 256 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( psectlotag = = 1 & & myjumpingcounter > 768 )
2006-04-13 20:47:06 +00:00
{
myjumpingcounter = 0 ;
myzvel = - 512 ;
}
else
{
myzvel - = ( sintable [ ( 2048 - 128 + myjumpingcounter ) & 2047 ] ) / 12 ;
myjumpingcounter + = 180 ;
myonground = 0 ;
}
}
else
{
myjumpingcounter = 0 ;
myzvel = 0 ;
}
}
myz + = myzvel ;
2006-11-14 21:35:50 +00:00
if ( myz < ( cz + ( 4 < < 8 ) ) )
2006-04-13 20:47:06 +00:00
{
myjumpingcounter = 0 ;
2006-11-13 23:12:47 +00:00
if ( myzvel < 0 ) myxvel = myyvel = 0 ;
2006-04-13 20:47:06 +00:00
myzvel = 128 ;
myz = cz + ( 4 < < 8 ) ;
}
}
2006-11-14 21:35:50 +00:00
if ( p - > fist_incs | |
2006-04-13 20:47:06 +00:00
p - > transporter_hold > 2 | |
myhardlanding | |
p - > access_incs > 0 | |
p - > knee_incs > 0 | |
( p - > curr_weapon = = TRIPBOMB_WEAPON & &
p - > kickback_pic > 1 & &
2006-11-14 21:35:50 +00:00
p - > kickback_pic < 4 ) )
2006-04-13 20:47:06 +00:00
{
doubvel = 0 ;
myxvel = 0 ;
myyvel = 0 ;
}
2006-11-14 21:35:50 +00:00
else if ( syn - > avel ) //p->ang += syncangvel * constant
2007-08-25 01:05:00 +00:00
{
//ENGINE calculates angvel for you
2007-02-13 09:50:58 +00:00
long tempang = syn - > avel < < 1 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( psectlotag = = 2 )
2006-04-13 20:47:06 +00:00
myang + = ( tempang - ( tempang > > 3 ) ) * ksgn ( doubvel ) ;
else myang + = ( tempang ) * ksgn ( doubvel ) ;
myang & = 2047 ;
}
2006-11-14 21:35:50 +00:00
if ( myxvel | | myyvel | | syn - > fvel | | syn - > svel )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( p - > jetpack_on = = 0 & & p - > steroids_amount > 0 & & p - > steroids_amount < 400 )
2006-04-13 20:47:06 +00:00
doubvel < < = 1 ;
myxvel + = ( ( syn - > fvel * doubvel ) < < 6 ) ;
myyvel + = ( ( syn - > svel * doubvel ) < < 6 ) ;
2006-11-14 21:35:50 +00:00
if ( ( p - > curr_weapon = = KNEE_WEAPON & & p - > kickback_pic > 10 & & myonground ) | | ( myonground & & ( sb_snum & 2 ) ) )
2006-04-13 20:47:06 +00:00
{
myxvel = mulscale16 ( myxvel , p - > runspeed - 0x2000 ) ;
myyvel = mulscale16 ( myyvel , p - > runspeed - 0x2000 ) ;
}
else
{
2006-11-13 23:12:47 +00:00
if ( psectlotag = = 2 )
2006-04-13 20:47:06 +00:00
{
myxvel = mulscale16 ( myxvel , p - > runspeed - 0x1400 ) ;
myyvel = mulscale16 ( myyvel , p - > runspeed - 0x1400 ) ;
}
else
{
myxvel = mulscale16 ( myxvel , p - > runspeed ) ;
myyvel = mulscale16 ( myyvel , p - > runspeed ) ;
}
}
2006-11-14 21:35:50 +00:00
if ( abs ( myxvel ) < 2048 & & abs ( myyvel ) < 2048 )
2006-04-13 20:47:06 +00:00
myxvel = myyvel = 0 ;
2006-11-14 21:35:50 +00:00
if ( shrunk )
2006-04-13 20:47:06 +00:00
{
myxvel =
mulscale16 ( myxvel , ( p - > runspeed ) - ( p - > runspeed > > 1 ) + ( p - > runspeed > > 2 ) ) ;
myyvel =
mulscale16 ( myyvel , ( p - > runspeed ) - ( p - > runspeed > > 1 ) + ( p - > runspeed > > 2 ) ) ;
}
}
FAKEHORIZONLY :
2006-11-15 01:16:55 +00:00
if ( psectlotag = = 1 | | spritebridge = = 1 ) i = ( 4L < < 8 ) ;
else i = ( 20L < < 8 ) ;
2006-04-13 20:47:06 +00:00
clipmove ( & myx , & myy , & myz , & mycursectnum , myxvel , myyvel , 164L , 4L < < 8 , i , CLIPMASK0 ) ;
pushmove ( & myx , & myy , & myz , & mycursectnum , 164L , 4L < < 8 , 4L < < 8 , CLIPMASK0 ) ;
2006-11-14 21:35:50 +00:00
if ( p - > jetpack_on = = 0 & & psectlotag ! = 1 & & psectlotag ! = 2 & & shrunk )
2006-04-13 20:47:06 +00:00
myz + = 30 < < 8 ;
if ( ( sb_snum & ( 1 < < 18 ) ) | | myhardlanding )
myreturntocenter = 9 ;
if ( sb_snum & ( 1 < < 13 ) )
{
myreturntocenter = 9 ;
if ( sb_snum & ( 1 < < 5 ) ) myhoriz + = 6 ;
myhoriz + = 6 ;
}
else if ( sb_snum & ( 1 < < 14 ) )
{
myreturntocenter = 9 ;
if ( sb_snum & ( 1 < < 5 ) ) myhoriz - = 6 ;
myhoriz - = 6 ;
}
else if ( sb_snum & ( 1 < < 3 ) )
{
if ( sb_snum & ( 1 < < 5 ) ) myhoriz + = 6 ;
myhoriz + = 6 ;
}
else if ( sb_snum & ( 1 < < 4 ) )
{
if ( sb_snum & ( 1 < < 5 ) ) myhoriz - = 6 ;
myhoriz - = 6 ;
}
if ( myreturntocenter > 0 )
if ( ( sb_snum & ( 1 < < 13 ) ) = = 0 & & ( sb_snum & ( 1 < < 14 ) ) = = 0 )
{
myreturntocenter - - ;
myhoriz + = 33 - ( myhoriz / 3 ) ;
}
2006-11-13 23:12:47 +00:00
if ( p - > aim_mode )
2006-05-02 21:36:09 +00:00
myhoriz + = syn - > horz ;
2006-04-13 20:47:06 +00:00
else
{
2006-11-14 21:35:50 +00:00
if ( myhoriz > 95 & & myhoriz < 105 ) myhoriz = 100 ;
if ( myhorizoff > - 5 & & myhorizoff < 5 ) myhorizoff = 0 ;
2006-04-13 20:47:06 +00:00
}
if ( myhardlanding > 0 )
{
myhardlanding - - ;
myhoriz - = ( myhardlanding < < 4 ) ;
}
if ( myhoriz > 299 ) myhoriz = 299 ;
else if ( myhoriz < - 99 ) myhoriz = - 99 ;
2006-11-13 23:12:47 +00:00
if ( p - > knee_incs > 0 )
2006-04-13 20:47:06 +00:00
{
myhoriz - = 48 ;
myreturntocenter = 9 ;
}
ENDFAKEPROCESSINPUT :
2007-08-27 06:46:31 +00:00
OnEvent ( EVENT_FAKEDOMOVETHINGS , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 ) ;
2006-09-20 07:23:25 +00:00
2006-04-13 20:47:06 +00:00
myxbak [ fakemovefifoplc & ( MOVEFIFOSIZ - 1 ) ] = myx ;
myybak [ fakemovefifoplc & ( MOVEFIFOSIZ - 1 ) ] = myy ;
myzbak [ fakemovefifoplc & ( MOVEFIFOSIZ - 1 ) ] = myz ;
myangbak [ fakemovefifoplc & ( MOVEFIFOSIZ - 1 ) ] = myang ;
myhorizbak [ fakemovefifoplc & ( MOVEFIFOSIZ - 1 ) ] = myhoriz ;
fakemovefifoplc + + ;
sprite [ p - > i ] . cstat = backcstat ;
}
2006-12-23 02:38:47 +00:00
static int domovethings ( void )
2006-04-13 20:47:06 +00:00
{
2006-12-10 03:15:56 +00:00
int i , j ;
2006-04-13 20:47:06 +00:00
char ch ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 06:46:31 +00:00
if ( g_player [ i ] . sync - > bits & ( 1 < < 17 ) )
2006-04-13 20:47:06 +00:00
{
multiflag = 2 ;
2007-08-27 06:46:31 +00:00
multiwhat = ( g_player [ i ] . sync - > bits > > 18 ) & 1 ;
multipos = ( unsigned ) ( g_player [ i ] . sync - > bits > > 19 ) & 15 ;
2006-04-13 20:47:06 +00:00
multiwho = i ;
2006-11-14 21:35:50 +00:00
if ( multiwhat )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
saveplayer ( multipos ) ;
2006-04-13 20:47:06 +00:00
multiflag = 0 ;
2006-11-13 23:12:47 +00:00
if ( multiwho ! = myconnectindex )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
Bsprintf ( fta_quotes [ 122 ] , " %s^00 SAVED A MULTIPLAYER GAME " , & g_player [ multiwho ] . user_name [ 0 ] ) ;
FTA ( 122 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-04-23 02:20:42 +00:00
Bstrcpy ( fta_quotes [ 122 ] , " MULTIPLAYER GAME SAVED " ) ;
2007-08-27 06:46:31 +00:00
FTA ( 122 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
break ;
}
else
{
// waitforeverybody();
2006-11-14 21:35:50 +00:00
j = loadplayer ( multipos ) ;
2006-04-13 20:47:06 +00:00
multiflag = 0 ;
2006-11-13 23:12:47 +00:00
if ( j = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( multiwho ! = myconnectindex )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
Bsprintf ( fta_quotes [ 122 ] , " %s^00 LOADED A MULTIPLAYER GAME " , & g_player [ multiwho ] . user_name [ 0 ] ) ;
2007-08-27 06:46:31 +00:00
FTA ( 122 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-04-23 02:20:42 +00:00
Bstrcpy ( fta_quotes [ 122 ] , " MULTIPLAYER GAME LOADED " ) ;
2007-08-27 06:46:31 +00:00
FTA ( 122 , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
return 1 ;
}
}
}
ud . camerasprite = - 1 ;
lockclock + = TICSPERFRAME ;
2006-11-13 23:12:47 +00:00
if ( earthquaketime > 0 ) earthquaketime - - ;
if ( rtsplaying > 0 ) rtsplaying - - ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < MAXUSERQUOTES ; i + + )
2006-05-09 04:24:44 +00:00
if ( user_quote_time [ i ] )
{
user_quote_time [ i ] - - ;
if ( ! user_quote_time [ i ] ) pub = NUMPAGES ;
}
2006-11-13 23:12:47 +00:00
if ( ud . idplayers & & ud . multimode > 1 )
2006-05-09 04:24:44 +00:00
{
long sx , sy , sz ;
short sect , hw , hs ;
2007-08-27 06:46:31 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
if ( g_player [ i ] . ps - > holoduke_on ! = - 1 )
sprite [ g_player [ i ] . ps - > holoduke_on ] . cstat ^ = 256 ;
2006-05-09 04:24:44 +00:00
2007-08-27 06:46:31 +00:00
hitscan ( g_player [ screenpeek ] . ps - > posx , g_player [ screenpeek ] . ps - > posy , g_player [ screenpeek ] . ps - > posz , g_player [ screenpeek ] . ps - > cursectnum ,
sintable [ ( g_player [ screenpeek ] . ps - > ang + 512 ) & 2047 ] ,
sintable [ g_player [ screenpeek ] . ps - > ang & 2047 ] ,
( 100 - g_player [ screenpeek ] . ps - > horiz - g_player [ screenpeek ] . ps - > horizoff ) < < 11 , & sect , & hw , & hs , & sx , & sy , & sz , 0xffff0030 ) ;
2006-05-09 04:24:44 +00:00
2007-08-27 06:46:31 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
if ( g_player [ i ] . ps - > holoduke_on ! = - 1 )
sprite [ g_player [ i ] . ps - > holoduke_on ] . cstat ^ = 256 ;
2006-05-09 04:24:44 +00:00
2007-08-27 06:46:31 +00:00
if ( ! ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) & & sprite [ hs ] . picnum = = APLAYER & & sprite [ hs ] . yvel ! = screenpeek & & g_player [ sprite [ hs ] . yvel ] . ps - > dead_flag = = 0 )
2006-05-09 04:24:44 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ screenpeek ] . ps - > fta = = 0 | | g_player [ screenpeek ] . ps - > ftq = = 117 )
2006-05-09 04:24:44 +00:00
{
2007-08-27 06:46:31 +00:00
if ( ldist ( & sprite [ g_player [ screenpeek ] . ps - > i ] , & sprite [ hs ] ) < 9216 )
2006-05-09 04:24:44 +00:00
{
2007-08-27 00:20:15 +00:00
Bsprintf ( fta_quotes [ 117 ] , " %s " , & g_player [ sprite [ hs ] . yvel ] . user_name [ 0 ] ) ;
2007-08-27 06:46:31 +00:00
g_player [ screenpeek ] . ps - > fta = 12 , g_player [ screenpeek ] . ps - > ftq = 117 ;
2006-05-09 04:24:44 +00:00
}
2006-11-15 01:16:55 +00:00
}
2007-08-27 06:46:31 +00:00
else if ( g_player [ screenpeek ] . ps - > fta > 2 ) g_player [ screenpeek ] . ps - > fta - = 3 ;
2006-05-09 04:24:44 +00:00
}
}
2006-11-14 21:35:50 +00:00
if ( show_shareware > 0 )
2006-04-13 20:47:06 +00:00
{
show_shareware - - ;
2006-11-13 23:12:47 +00:00
if ( show_shareware = = 0 )
2006-04-13 20:47:06 +00:00
{
pus = NUMPAGES ;
pub = NUMPAGES ;
}
}
everyothertime + + ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 06:46:31 +00:00
copybufbyte ( & inputfifo [ movefifoplc & ( MOVEFIFOSIZ - 1 ) ] [ i ] , g_player [ i ] . sync , sizeof ( input ) ) ;
2006-04-13 20:47:06 +00:00
movefifoplc + + ;
updateinterpolations ( ) ;
j = - 1 ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( ( g_player [ i ] . sync - > bits & ( 1 < < 26 ) ) = = 0 )
2006-11-15 01:16:55 +00:00
{
j = i ;
continue ;
}
2006-04-13 20:47:06 +00:00
closedemowrite ( ) ;
if ( i = = myconnectindex ) gameexit ( " " ) ;
if ( screenpeek = = i )
{
screenpeek = connectpoint2 [ i ] ;
if ( screenpeek < 0 ) screenpeek = connecthead ;
}
if ( i = = connecthead ) connecthead = connectpoint2 [ connecthead ] ;
else connectpoint2 [ j ] = connectpoint2 [ i ] ;
numplayers - - ;
ud . multimode - - ;
if ( numplayers < 2 )
sound ( GENERIC_AMBIENCE17 ) ;
pub = NUMPAGES ;
pus = NUMPAGES ;
vscrn ( ) ;
2007-08-27 06:46:31 +00:00
quickkill ( g_player [ i ] . ps ) ;
deletesprite ( g_player [ i ] . ps - > i ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 00:20:15 +00:00
Bsprintf ( buf , " %s^00 is history! " , g_player [ i ] . user_name ) ;
2006-04-13 20:47:06 +00:00
adduserquote ( buf ) ;
2006-04-22 08:22:07 +00:00
Bstrcpy ( fta_quotes [ 116 ] , buf ) ;
2006-04-23 02:20:42 +00:00
2006-11-13 23:12:47 +00:00
if ( voting = = i )
2006-05-04 23:51:11 +00:00
{
2007-08-27 06:46:31 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
{
g_player [ i ] . vote = 0 ;
g_player [ i ] . gotvote = 0 ;
}
2006-05-04 23:51:11 +00:00
voting = - 1 ;
}
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > ftq = 116 , g_player [ myconnectindex ] . ps - > fta = 180 ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( j < 0 & & networkmode = = 0 )
gameexit ( " The server/master player just quit the game; disconnected. " ) ;
2006-04-13 20:47:06 +00:00
}
if ( ( numplayers > = 2 ) & & ( ( movefifoplc & 7 ) = = 7 ) )
{
ch = ( char ) ( randomseed & 255 ) ;
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 06:46:31 +00:00
ch + = ( ( g_player [ i ] . ps - > posx + g_player [ i ] . ps - > posy + g_player [ i ] . ps - > posz + g_player [ i ] . ps - > ang + g_player [ i ] . ps - > horiz ) & 255 ) ;
2007-08-27 00:20:15 +00:00
g_player [ myconnectindex ] . syncval [ g_player [ myconnectindex ] . syncvalhead & ( MOVEFIFOSIZ - 1 ) ] = ch ;
g_player [ myconnectindex ] . syncvalhead + + ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( ud . recstat = = 1 ) record ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( ud . pause_on = = 0 )
2006-04-13 20:47:06 +00:00
{
global_random = TRAND ;
movedummyplayers ( ) ; //ST 13
}
2006-11-13 23:12:47 +00:00
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ i ] . sync - > extbits & ( 1 < < 6 ) )
2006-08-31 19:05:23 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ i ] . ps - > team = g_player [ i ] . pteam ;
2006-11-13 23:12:47 +00:00
if ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_TDM )
2006-08-31 19:05:23 +00:00
{
2007-08-27 06:46:31 +00:00
hittype [ g_player [ i ] . ps - > i ] . picnum = APLAYERTOP ;
quickkill ( g_player [ i ] . ps ) ;
2006-08-31 19:05:23 +00:00
}
2006-09-10 17:40:34 +00:00
}
2006-11-13 23:12:47 +00:00
if ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_TDM )
2007-08-27 06:46:31 +00:00
g_player [ i ] . ps - > palookup = g_player [ i ] . pcolor = getteampal ( g_player [ i ] . ps - > team ) ;
2006-08-31 19:05:23 +00:00
2007-08-27 06:46:31 +00:00
if ( sprite [ g_player [ i ] . ps - > i ] . pal ! = 1 )
sprite [ g_player [ i ] . ps - > i ] . pal = g_player [ i ] . pcolor ;
2006-08-31 19:05:23 +00:00
2006-12-14 03:34:55 +00:00
sharedkeys ( i ) ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( ud . pause_on = = 0 )
2006-04-13 20:47:06 +00:00
{
processinput ( i ) ;
checksectors ( i ) ;
}
}
2006-11-14 21:35:50 +00:00
if ( ud . pause_on = = 0 )
2006-12-10 03:15:56 +00:00
moveobjects ( ) ;
2006-04-13 20:47:06 +00:00
fakedomovethingscorrect ( ) ;
2006-11-14 21:35:50 +00:00
if ( ( everyothertime & 1 ) = = 0 )
2006-04-13 20:47:06 +00:00
{
animatewalls ( ) ;
movecyclers ( ) ;
pan3dsound ( ) ;
}
2006-10-15 18:51:41 +00:00
//polymer invalidate
2006-10-29 20:18:04 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-10-15 18:51:41 +00:00
updatesectors = 1 ;
2006-10-29 20:18:04 +00:00
# endif
2006-10-15 18:51:41 +00:00
2006-04-13 20:47:06 +00:00
return 0 ;
}
2006-12-10 03:15:56 +00:00
static void doorders ( void )
2006-04-13 20:47:06 +00:00
{
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 1 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
KB_FlushKeyboardQueue ( ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , ORDERING , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
2006-11-15 01:16:55 +00:00
while ( ! KB_KeyWaiting ( ) )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
KB_FlushKeyboardQueue ( ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , ORDERING + 1 , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
2006-11-15 01:16:55 +00:00
while ( ! KB_KeyWaiting ( ) )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
KB_FlushKeyboardQueue ( ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , ORDERING + 2 , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
2006-11-15 01:16:55 +00:00
while ( ! KB_KeyWaiting ( ) )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
KB_FlushKeyboardQueue ( ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , ORDERING + 3 , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
2006-11-15 01:16:55 +00:00
while ( ! KB_KeyWaiting ( ) )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
}
2007-02-28 09:12:41 +00:00
void dobonus ( int bonusonly )
2006-04-13 20:47:06 +00:00
{
2007-01-12 22:42:19 +00:00
int t , tinc , gfx_offset ;
int i , y , xfragtotal , yfragtotal ;
int bonuscnt ;
2006-04-13 20:47:06 +00:00
int clockpad = 2 ;
char * lastmapname ;
2006-10-23 21:47:28 +00:00
int32 playerbest = - 1 ;
2007-01-12 22:42:19 +00:00
int breathe [ ] =
2007-08-25 01:05:00 +00:00
{
0 , 30 , VICTORY1 + 1 , 176 , 59 ,
30 , 60 , VICTORY1 + 2 , 176 , 59 ,
60 , 90 , VICTORY1 + 1 , 176 , 59 ,
90 , 120 , 0 , 176 , 59
} ;
2006-04-13 20:47:06 +00:00
2007-01-12 22:42:19 +00:00
int bossmove [ ] =
2007-08-25 01:05:00 +00:00
{
0 , 120 , VICTORY1 + 3 , 86 , 59 ,
220 , 260 , VICTORY1 + 4 , 86 , 59 ,
260 , 290 , VICTORY1 + 5 , 86 , 59 ,
290 , 320 , VICTORY1 + 6 , 86 , 59 ,
320 , 350 , VICTORY1 + 7 , 86 , 59 ,
350 , 380 , VICTORY1 + 8 , 86 , 59
} ;
2006-04-13 20:47:06 +00:00
2006-10-19 00:45:36 +00:00
if ( VOLUMEALL ) wm_setapptitle ( HEAD2 ) ;
else wm_setapptitle ( HEAD ) ;
2006-11-15 01:16:55 +00:00
if ( ud . volume_number = = 0 & & ud . last_level = = 8 & & boardfilename [ 0 ] )
{
2006-04-13 20:47:06 +00:00
lastmapname = Bstrrchr ( boardfilename , ' \\ ' ) ;
if ( ! lastmapname ) lastmapname = Bstrrchr ( boardfilename , ' / ' ) ;
if ( ! lastmapname ) lastmapname = boardfilename ;
2006-11-15 01:16:55 +00:00
}
2007-08-26 11:28:32 +00:00
else lastmapname = map [ ( ud . volume_number * MAXLEVELS ) + ud . last_level - 1 ] . name ;
2006-04-13 20:47:06 +00:00
bonuscnt = 0 ;
fadepal ( 0 , 0 , 0 , 0 , 64 , 7 ) ;
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
clearview ( 0L ) ;
nextpage ( ) ;
flushperms ( ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
FX_SetReverb ( 0L ) ;
2006-11-13 23:12:47 +00:00
if ( bonusonly ) goto FRAGBONUS ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( numplayers < 2 & & ud . eog & & ud . from_bonus = = 0 )
switch ( ud . volume_number )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
if ( ud . lockout = = 0 )
{
2007-08-27 06:46:31 +00:00
setgamepalette ( g_player [ myconnectindex ] . ps , endingpal , 11 ) ; // JBF 20040308
2006-11-16 03:02:42 +00:00
clearview ( 0L ) ;
rotatesprite ( 0 , 50 < < 16 , 65536L , 0 , VICTORY1 , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
nextpage ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = endingpal;
2006-11-16 03:02:42 +00:00
fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
KB_FlushKeyboardQueue ( ) ;
totalclock = 0 ;
tinc = 0 ;
while ( 1 )
2006-04-13 20:47:06 +00:00
{
clearview ( 0L ) ;
rotatesprite ( 0 , 50 < < 16 , 65536L , 0 , VICTORY1 , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
// boss
if ( totalclock > 390 & & totalclock < 780 )
for ( t = 0 ; t < 35 ; t + = 5 ) if ( bossmove [ t + 2 ] & & ( totalclock % 390 ) > bossmove [ t ] & & ( totalclock % 390 ) < = bossmove [ t + 1 ] )
{
if ( t = = 10 & & bonuscnt = = 1 )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
sound ( SHOTGUN_FIRE ) ;
sound ( SQUISHED ) ;
bonuscnt + + ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
rotatesprite ( bossmove [ t + 3 ] < < 16 , bossmove [ t + 4 ] < < 16 , 65536L , 0 , bossmove [ t + 2 ] , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
// Breathe
if ( totalclock < 450 | | totalclock > = 750 )
{
if ( totalclock > = 750 )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
rotatesprite ( 86 < < 16 , 59 < < 16 , 65536L , 0 , VICTORY1 + 8 , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( totalclock > = 750 & & bonuscnt = = 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sound ( DUKETALKTOBOSS ) ;
bonuscnt + + ;
}
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
}
for ( t = 0 ; t < 20 ; t + = 5 )
if ( breathe [ t + 2 ] & & ( totalclock % 120 ) > breathe [ t ] & & ( totalclock % 120 ) < = breathe [ t + 1 ] )
{
if ( t = = 5 & & bonuscnt = = 0 )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
sound ( BOSSTALKTODUKE ) ;
bonuscnt + + ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
rotatesprite ( breathe [ t + 3 ] < < 16 , breathe [ t + 4 ] < < 16 , 65536L , 0 , breathe [ t + 2 ] , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
handleevents ( ) ;
getpackets ( ) ;
nextpage ( ) ;
if ( KB_KeyWaiting ( ) ) break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
fadepal ( 0 , 0 , 0 , 0 , 64 , 1 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
KB_FlushKeyboardQueue ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 11 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
rotatesprite ( 0 , 0 , 65536L , 0 , 3292 , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
IFISSOFTMODE fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
else nextpage ( ) ;
2006-12-12 04:31:51 +00:00
while ( ! KB_KeyWaiting ( ) & & ! MOUSE_GetButtons ( ) & LEFT_MOUSE )
2006-11-16 03:02:42 +00:00
{
handleevents ( ) ;
getpackets ( ) ;
}
fadepal ( 0 , 0 , 0 , 0 , 64 , 1 ) ;
MUSIC_StopSong ( ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
break ;
case 1 :
MUSIC_StopSong ( ) ;
clearview ( 0L ) ;
nextpage ( ) ;
if ( ud . lockout = = 0 )
{
playanm ( " cineov2.anm " , 1 ) ;
KB_FlushKeyBoardQueue ( ) ;
2006-04-13 20:47:06 +00:00
clearview ( 0L ) ;
nextpage ( ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sound ( PIPEBOMB_EXPLODE ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
fadepal ( 0 , 0 , 0 , 0 , 64 , 1 ) ;
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
KB_FlushKeyboardQueue ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 11 ) ; // JBF 20040308
2006-11-16 03:02:42 +00:00
rotatesprite ( 0 , 0 , 65536L , 0 , 3293 , 0 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
IFISSOFTMODE fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
else nextpage ( ) ;
2006-12-12 04:31:51 +00:00
while ( ! KB_KeyWaiting ( ) & & ! MOUSE_GetButtons ( ) & LEFT_MOUSE )
2006-11-16 03:02:42 +00:00
{
handleevents ( ) ;
getpackets ( ) ;
}
IFISSOFTMODE fadepal ( 0 , 0 , 0 , 0 , 64 , 1 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 3 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
MUSIC_StopSong ( ) ;
clearview ( 0L ) ;
nextpage ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ud . lockout = = 0 )
{
KB_FlushKeyboardQueue ( ) ;
playanm ( " vol4e1.anm " , 8 ) ;
clearview ( 0L ) ;
nextpage ( ) ;
playanm ( " vol4e2.anm " , 10 ) ;
clearview ( 0L ) ;
nextpage ( ) ;
playanm ( " vol4e3.anm " , 11 ) ;
2006-04-13 20:47:06 +00:00
clearview ( 0L ) ;
nextpage ( ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
sound ( ENDSEQVOL3SND4 ) ;
KB_FlushKeyBoardQueue ( ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 11 ) ; // JBF 20040308
2006-11-16 03:02:42 +00:00
IFISSOFTMODE palto ( 0 , 0 , 0 , 63 ) ;
clearview ( 0L ) ;
menutext ( 160 , 60 , 0 , 0 , " THANKS TO ALL OUR " ) ;
menutext ( 160 , 60 + 16 , 0 , 0 , " FANS FOR GIVING " ) ;
menutext ( 160 , 60 + 16 + 16 , 0 , 0 , " US BIG HEADS. " ) ;
menutext ( 160 , 70 + 16 + 16 + 16 , 0 , 0 , " LOOK FOR A DUKE NUKEM 3D " ) ;
menutext ( 160 , 70 + 16 + 16 + 16 + 16 , 0 , 0 , " SEQUEL SOON. " ) ;
nextpage ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
fadepal ( 0 , 0 , 0 , 63 , 0 , - 3 ) ;
KB_FlushKeyboardQueue ( ) ;
2006-12-12 04:31:51 +00:00
while ( ! KB_KeyWaiting ( ) & & ! MOUSE_GetButtons ( ) & LEFT_MOUSE )
2006-11-16 03:02:42 +00:00
{
handleevents ( ) ;
getpackets ( ) ;
}
fadepal ( 0 , 0 , 0 , 0 , 64 , 3 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
clearview ( 0L ) ;
nextpage ( ) ;
2006-12-12 04:31:51 +00:00
MOUSE_ClearButton ( LEFT_MOUSE ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
playanm ( " DUKETEAM.ANM " , 4 ) ;
KB_FlushKeyBoardQueue ( ) ;
2006-12-12 04:31:51 +00:00
while ( ! KB_KeyWaiting ( ) & & ! MOUSE_GetButtons ( ) & LEFT_MOUSE )
2006-11-16 03:02:42 +00:00
{
handleevents ( ) ;
getpackets ( ) ;
}
clearview ( 0L ) ;
nextpage ( ) ;
IFISSOFTMODE palto ( 0 , 0 , 0 , 63 ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
KB_FlushKeyBoardQueue ( ) ;
2006-12-12 04:31:51 +00:00
MOUSE_ClearButton ( LEFT_MOUSE ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 2 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
MUSIC_StopSong ( ) ;
clearview ( 0L ) ;
nextpage ( ) ;
if ( ud . lockout = = 0 )
{
fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
playanm ( " cineov3.anm " , 2 ) ;
2006-11-15 01:16:55 +00:00
KB_FlushKeyBoardQueue ( ) ;
2006-11-16 03:02:42 +00:00
ototalclock = totalclock + 200 ;
while ( totalclock < ototalclock )
2006-11-15 01:16:55 +00:00
{
handleevents ( ) ;
getpackets ( ) ;
}
clearview ( 0L ) ;
nextpage ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
playanm ( " RADLOGO.ANM " , 3 ) ;
2006-11-15 01:16:55 +00:00
2006-12-12 04:31:51 +00:00
if ( ud . lockout = = 0 & & ! KB_KeyWaiting ( ) & & ! MOUSE_GetButtons ( ) & LEFT_MOUSE )
2006-11-16 03:02:42 +00:00
{
sound ( ENDSEQVOL3SND5 ) ;
while ( issoundplaying ( - 1 , ENDSEQVOL3SND5 ) )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
handleevents ( ) ;
getpackets ( ) ;
2006-11-15 01:16:55 +00:00
}
2006-12-12 04:31:51 +00:00
if ( KB_KeyWaiting ( ) | | MOUSE_GetButtons ( ) & LEFT_MOUSE ) goto ENDANM ;
2006-11-16 03:02:42 +00:00
sound ( ENDSEQVOL3SND6 ) ;
while ( issoundplaying ( - 1 , ENDSEQVOL3SND6 ) )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
handleevents ( ) ;
getpackets ( ) ;
2006-11-15 01:16:55 +00:00
}
2006-12-12 04:31:51 +00:00
if ( KB_KeyWaiting ( ) | | MOUSE_GetButtons ( ) & LEFT_MOUSE ) goto ENDANM ;
2006-11-16 03:02:42 +00:00
sound ( ENDSEQVOL3SND7 ) ;
while ( issoundplaying ( - 1 , ENDSEQVOL3SND7 ) )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-12-12 04:31:51 +00:00
if ( KB_KeyWaiting ( ) | | MOUSE_GetButtons ( ) & LEFT_MOUSE ) goto ENDANM ;
2006-11-16 03:02:42 +00:00
sound ( ENDSEQVOL3SND8 ) ;
while ( issoundplaying ( - 1 , ENDSEQVOL3SND8 ) )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-12-12 04:31:51 +00:00
if ( KB_KeyWaiting ( ) | | MOUSE_GetButtons ( ) & LEFT_MOUSE ) goto ENDANM ;
2006-11-16 03:02:42 +00:00
sound ( ENDSEQVOL3SND9 ) ;
while ( issoundplaying ( - 1 , ENDSEQVOL3SND9 ) )
2006-11-15 01:16:55 +00:00
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
}
2006-12-12 04:31:51 +00:00
MOUSE_ClearButton ( LEFT_MOUSE ) ;
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
totalclock = 0 ;
2006-12-12 04:31:51 +00:00
while ( ! KB_KeyWaiting ( ) & & totalclock < 120 & & ! MOUSE_GetButtons ( ) & LEFT_MOUSE )
2006-11-16 03:02:42 +00:00
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
ENDANM :
2006-12-12 04:31:51 +00:00
MOUSE_ClearButton ( LEFT_MOUSE ) ;
2006-11-16 03:02:42 +00:00
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
KB_FlushKeyBoardQueue ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
clearview ( 0L ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
FRAGBONUS :
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
setgamepalette ( g_player [ myconnectindex ] . ps , palette , 11 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
IFISSOFTMODE palto ( 0 , 0 , 0 , 63 ) ; // JBF 20031228
KB_FlushKeyboardQueue ( ) ;
2006-11-15 01:16:55 +00:00
totalclock = 0 ;
tinc = 0 ;
2006-04-13 20:47:06 +00:00
bonuscnt = 0 ;
MUSIC_StopSong ( ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2006-11-13 23:12:47 +00:00
if ( playerswhenstarted > 1 & & ( gametype_flags [ ud . coop ] & GAMETYPE_FLAG_SCORESHEET ) )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
if ( ! ( ud . config . MusicToggle = = 0 | | ud . config . MusicDevice < 0 ) )
2006-04-13 20:47:06 +00:00
sound ( BONUSMUSIC ) ;
rotatesprite ( 0 , 0 , 65536L , 0 , MENUSCREEN , 16 , 0 , 2 + 8 + 16 + 64 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
rotatesprite ( 160 < < 16 , 34 < < 16 , 65536L , 0 , INGAMEDUKETHREEDEE , 0 , 0 , 10 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( PLUTOPAK ) // JBF 20030804
rotatesprite ( ( 260 ) < < 16 , 36 < < 16 , 65536L , 0 , PLUTOPAKSPRITE + 2 , 0 , 0 , 2 + 8 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
gametext ( 160 , 58 + 2 , " MULTIPLAYER TOTALS " , 0 , 2 + 8 + 16 ) ;
2007-08-26 11:28:32 +00:00
gametext ( 160 , 58 + 10 , map [ ( ud . volume_number * MAXLEVELS ) + ud . last_level - 1 ] . name , 0 , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
gametext ( 160 , 165 , " PRESS ANY KEY TO CONTINUE " , 0 , 2 + 8 + 16 ) ;
t = 0 ;
minitext ( 23 , 80 , " NAME KILLS " , 8 , 2 + 8 + 16 + 128 ) ;
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < playerswhenstarted ; i + + )
2006-04-13 20:47:06 +00:00
{
2007-01-12 22:42:19 +00:00
Bsprintf ( tempbuf , " %-4d " , i + 1 ) ;
2006-04-13 20:47:06 +00:00
minitext ( 92 + ( i * 23 ) , 80 , tempbuf , 3 , 2 + 8 + 16 + 128 ) ;
}
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < playerswhenstarted ; i + + )
2006-04-13 20:47:06 +00:00
{
xfragtotal = 0 ;
2007-01-12 22:42:19 +00:00
Bsprintf ( tempbuf , " %d " , i + 1 ) ;
2006-04-13 20:47:06 +00:00
minitext ( 30 , 90 + t , tempbuf , 0 , 2 + 8 + 16 + 128 ) ;
2007-08-27 06:46:31 +00:00
minitext ( 38 , 90 + t , g_player [ i ] . user_name , g_player [ i ] . ps - > palookup , 2 + 8 + 16 + 128 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( y = 0 ; y < playerswhenstarted ; y + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( i = = y )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
Bsprintf ( tempbuf , " %-4d " , g_player [ y ] . ps - > fraggedself ) ;
2006-04-13 20:47:06 +00:00
minitext ( 92 + ( y * 23 ) , 90 + t , tempbuf , 2 , 2 + 8 + 16 + 128 ) ;
2007-08-27 06:46:31 +00:00
xfragtotal - = g_player [ y ] . ps - > fraggedself ;
2006-04-13 20:47:06 +00:00
}
else
{
2007-08-27 00:20:15 +00:00
Bsprintf ( tempbuf , " %-4d " , g_player [ i ] . frags [ y ] ) ;
2006-04-13 20:47:06 +00:00
minitext ( 92 + ( y * 23 ) , 90 + t , tempbuf , 0 , 2 + 8 + 16 + 128 ) ;
2007-08-27 00:20:15 +00:00
xfragtotal + = g_player [ i ] . frags [ y ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( myconnectindex = = connecthead )
2006-04-13 20:47:06 +00:00
{
2007-08-27 00:20:15 +00:00
Bsprintf ( tempbuf , " stats %d killed %d %d \n " , i + 1 , y + 1 , g_player [ i ] . frags [ y ] ) ;
2006-04-13 20:47:06 +00:00
sendscore ( tempbuf ) ;
}
}
2007-01-12 22:42:19 +00:00
Bsprintf ( tempbuf , " %-4d " , xfragtotal ) ;
2006-04-13 20:47:06 +00:00
minitext ( 101 + ( 8 * 23 ) , 90 + t , tempbuf , 2 , 2 + 8 + 16 + 128 ) ;
t + = 7 ;
}
2006-11-13 23:12:47 +00:00
for ( y = 0 ; y < playerswhenstarted ; y + + )
2006-04-13 20:47:06 +00:00
{
yfragtotal = 0 ;
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < playerswhenstarted ; i + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( i = = y )
2007-08-27 06:46:31 +00:00
yfragtotal + = g_player [ i ] . ps - > fraggedself ;
2007-08-27 00:20:15 +00:00
yfragtotal + = g_player [ i ] . frags [ y ] ;
2006-04-13 20:47:06 +00:00
}
2007-01-12 22:42:19 +00:00
Bsprintf ( tempbuf , " %-4d " , yfragtotal ) ;
2006-04-13 20:47:06 +00:00
minitext ( 92 + ( y * 23 ) , 96 + ( 8 * 7 ) , tempbuf , 2 , 2 + 8 + 16 + 128 ) ;
}
minitext ( 45 , 96 + ( 8 * 7 ) , " DEATHS " , 8 , 2 + 8 + 16 + 128 ) ;
nextpage ( ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
KB_FlushKeyboardQueue ( ) ;
2006-11-15 01:16:55 +00:00
while ( KB_KeyWaiting ( ) = = 0 )
{
handleevents ( ) ;
getpackets ( ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( bonusonly | | ud . multimode > 1 ) return ;
2006-04-13 20:47:06 +00:00
fadepal ( 0 , 0 , 0 , 0 , 64 , 7 ) ;
}
2006-11-13 23:12:47 +00:00
if ( bonusonly | | ud . multimode > 1 ) return ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
switch ( ud . volume_number )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 1 :
gfx_offset = 5 ;
break ;
default :
gfx_offset = 0 ;
break ;
2006-04-13 20:47:06 +00:00
}
rotatesprite ( 0 , 0 , 65536L , 0 , BONUSSCREEN + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
menutext ( 160 , 20 - 6 , 0 , 0 , lastmapname ) ;
menutext ( 160 , 36 - 6 , 0 , 0 , " COMPLETED " ) ;
gametext ( 160 , 192 , " PRESS ANY KEY TO CONTINUE " , 16 , 2 + 8 + 16 ) ;
2007-08-27 00:20:15 +00:00
if ( ! ( ud . config . MusicToggle = = 0 | | ud . config . MusicDevice < 0 ) )
2006-04-13 20:47:06 +00:00
sound ( BONUSMUSIC ) ;
nextpage ( ) ;
KB_FlushKeyboardQueue ( ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
bonuscnt = 0 ;
2006-11-15 01:16:55 +00:00
totalclock = 0 ;
tinc = 0 ;
2006-04-13 20:47:06 +00:00
2007-08-26 11:28:32 +00:00
playerbest = CONFIG_GetMapBestTime ( map [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . filename ) ;
2006-10-23 21:47:28 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > player_par < playerbest | | playerbest < 0 )
2006-10-23 21:47:28 +00:00
{
2007-08-27 06:46:31 +00:00
CONFIG_SetMapBestTime ( map [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . filename , g_player [ myconnectindex ] . ps - > player_par ) ;
2006-10-24 03:13:45 +00:00
// if(playerbest != -1)
2007-08-27 06:46:31 +00:00
// playerbest = g_player[myconnectindex].ps->player_par;
2006-10-23 21:47:28 +00:00
}
2006-04-13 20:47:06 +00:00
{
int ii , ij ;
2007-08-27 06:46:31 +00:00
for ( ii = g_player [ myconnectindex ] . ps - > player_par / ( 26 * 60 ) , ij = 1 ; ii > 9 ; ii / = 10 , ij + + ) ;
2006-04-13 20:47:06 +00:00
clockpad = max ( clockpad , ij ) ;
2006-11-15 01:16:55 +00:00
if ( ! ( ud . volume_number = = 0 & & ud . last_level - 1 = = 7 ) )
{
2007-08-26 11:28:32 +00:00
for ( ii = map [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . partime / ( 26 * 60 ) , ij = 1 ; ii > 9 ; ii / = 10 , ij + + ) ;
2006-10-24 03:13:45 +00:00
clockpad = max ( clockpad , ij ) ;
2006-11-15 01:16:55 +00:00
if ( ! NAM )
{
2007-08-26 11:28:32 +00:00
for ( ii = map [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . designertime / ( 26 * 60 ) , ij = 1 ; ii > 9 ; ii / = 10 , ij + + ) ;
2006-10-24 03:13:45 +00:00
clockpad = max ( clockpad , ij ) ;
}
}
2006-10-23 21:47:28 +00:00
if ( playerbest > 0 ) for ( ii = playerbest / ( 26 * 60 ) , ij = 1 ; ii > 9 ; ii / = 10 , ij + + ) ;
clockpad = max ( clockpad , ij ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
while ( 1 )
2006-04-13 20:47:06 +00:00
{
2006-10-23 21:47:28 +00:00
int yy = 0 , zz ;
2006-04-13 20:47:06 +00:00
handleevents ( ) ;
AudioUpdate ( ) ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_EOL )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( 0 , 0 , 65536L , 0 , BONUSSCREEN + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-11-14 21:35:50 +00:00
if ( totalclock > ( 1000000000L ) & & totalclock < ( 1000000320L ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
switch ( ( totalclock > > 4 ) % 15 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
if ( bonuscnt = = 6 )
{
bonuscnt + + ;
sound ( SHOTGUN_COCK ) ;
switch ( rand ( ) & 3 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
sound ( BONUS_SPEECH1 ) ;
break ;
case 1 :
sound ( BONUS_SPEECH2 ) ;
break ;
case 2 :
sound ( BONUS_SPEECH3 ) ;
break ;
case 3 :
sound ( BONUS_SPEECH4 ) ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
case 1 :
case 4 :
case 5 :
rotatesprite ( 199 < < 16 , 31 < < 16 , 65536L , 0 , BONUSSCREEN + 3 + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
break ;
case 2 :
case 3 :
rotatesprite ( 199 < < 16 , 31 < < 16 , 65536L , 0 , BONUSSCREEN + 4 + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
break ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-14 21:35:50 +00:00
else if ( totalclock > ( 10240 + 120L ) ) break ;
2006-04-13 20:47:06 +00:00
else
{
2006-11-14 21:35:50 +00:00
switch ( ( totalclock > > 5 ) & 3 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 1 :
case 3 :
rotatesprite ( 199 < < 16 , 31 < < 16 , 65536L , 0 , BONUSSCREEN + 1 + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
break ;
case 2 :
rotatesprite ( 199 < < 16 , 31 < < 16 , 65536L , 0 , BONUSSCREEN + 2 + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
break ;
2006-04-13 20:47:06 +00:00
}
}
menutext ( 160 , 20 - 6 , 0 , 0 , lastmapname ) ;
menutext ( 160 , 36 - 6 , 0 , 0 , " COMPLETED " ) ;
gametext ( 160 , 192 , " PRESS ANY KEY TO CONTINUE " , 16 , 2 + 8 + 16 ) ;
2006-11-14 21:35:50 +00:00
if ( totalclock > ( 60 * 3 ) )
2006-04-13 20:47:06 +00:00
{
2006-10-23 21:47:28 +00:00
yy = zz = 59 ;
2006-11-15 01:16:55 +00:00
gametext ( 10 , yy + 9 , " Your Time: " , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
if ( ! ( ud . volume_number = = 0 & & ud . last_level - 1 = = 7 ) )
{
gametext ( 10 , yy + 9 , " Par Time: " , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
if ( ! NAM )
{
gametext ( 10 , yy + 9 , " 3D Realms' Time: " , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
}
2006-11-13 23:12:47 +00:00
2006-10-24 03:13:45 +00:00
}
2006-11-15 01:16:55 +00:00
if ( playerbest > 0 )
{
2007-08-27 06:46:31 +00:00
gametext ( 10 , yy + 9 , g_player [ myconnectindex ] . ps - > player_par < playerbest ? " Prev Best Time: " : " Your Best Time: " , 0 , 2 + 8 + 16 ) ;
2006-11-15 01:16:55 +00:00
yy + = 10 ;
}
2006-10-23 21:47:28 +00:00
2006-11-13 23:12:47 +00:00
if ( bonuscnt = = 0 )
2006-04-13 20:47:06 +00:00
bonuscnt + + ;
2006-10-23 21:47:28 +00:00
yy = zz ;
2006-11-14 21:35:50 +00:00
if ( totalclock > ( 60 * 4 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( bonuscnt = = 1 )
2006-04-13 20:47:06 +00:00
{
bonuscnt + + ;
sound ( PIPEBOMB_EXPLODE ) ;
}
Bsprintf ( tempbuf , " %0*ld:%02ld " , clockpad ,
2007-08-27 06:46:31 +00:00
( g_player [ myconnectindex ] . ps - > player_par / ( 26 * 60 ) ) ,
( g_player [ myconnectindex ] . ps - > player_par / 26 ) % 60 ) ;
2006-10-24 03:13:45 +00:00
gametext ( ( 320 > > 2 ) + 71 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > player_par < playerbest )
2006-10-24 03:13:45 +00:00
gametext ( ( 320 > > 2 ) + 71 + ( clockpad * 24 ) , yy + 9 , " New record! " , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
if ( ! ( ud . volume_number = = 0 & & ud . last_level - 1 = = 7 ) )
{
2006-07-22 05:20:25 +00:00
Bsprintf ( tempbuf , " %0*ld:%02ld " , clockpad ,
2007-08-26 11:28:32 +00:00
( map [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . partime / ( 26 * 60 ) ) ,
( map [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . partime / 26 ) % 60 ) ;
2006-11-15 01:16:55 +00:00
gametext ( ( 320 > > 2 ) + 71 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-10-24 03:13:45 +00:00
2006-11-15 01:16:55 +00:00
if ( ! NAM )
{
2006-10-24 03:13:45 +00:00
Bsprintf ( tempbuf , " %0*ld:%02ld " , clockpad ,
2007-08-26 11:28:32 +00:00
( map [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . designertime / ( 26 * 60 ) ) ,
( map [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . designertime / 26 ) % 60 ) ;
2006-11-15 01:16:55 +00:00
gametext ( ( 320 > > 2 ) + 71 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-10-24 03:13:45 +00:00
}
2006-10-23 21:47:28 +00:00
}
2006-11-15 01:16:55 +00:00
if ( playerbest > 0 )
{
2006-10-23 21:47:28 +00:00
sprintf ( tempbuf , " %0*ld:%02ld " , clockpad ,
( playerbest / ( 26 * 60 ) ) ,
( playerbest / 26 ) % 60 ) ;
2006-11-15 01:16:55 +00:00
gametext ( ( 320 > > 2 ) + 71 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-07-22 00:53:20 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
2006-10-23 21:47:28 +00:00
zz = yy + = 5 ;
2006-11-14 21:35:50 +00:00
if ( totalclock > ( 60 * 6 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
gametext ( 10 , yy + 9 , " Enemies Killed: " , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
gametext ( 10 , yy + 9 , " Enemies Left: " , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( bonuscnt = = 2 )
2006-04-13 20:47:06 +00:00
{
bonuscnt + + ;
sound ( FLY_BY ) ;
}
2006-10-23 21:47:28 +00:00
yy = zz ;
2006-11-14 21:35:50 +00:00
if ( totalclock > ( 60 * 7 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( bonuscnt = = 3 )
2006-04-13 20:47:06 +00:00
{
bonuscnt + + ;
sound ( PIPEBOMB_EXPLODE ) ;
}
2007-08-27 06:46:31 +00:00
sprintf ( tempbuf , " %-3ld " , g_player [ myconnectindex ] . ps - > actors_killed ) ;
2006-11-15 01:16:55 +00:00
gametext ( ( 320 > > 2 ) + 70 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-11-14 21:35:50 +00:00
if ( ud . player_skill > 3 )
2006-04-13 20:47:06 +00:00
{
2006-10-23 21:47:28 +00:00
sprintf ( tempbuf , " N/A " ) ;
2006-11-15 01:16:55 +00:00
gametext ( ( 320 > > 2 ) + 70 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-04-13 20:47:06 +00:00
}
else
{
2007-08-27 06:46:31 +00:00
if ( ( g_player [ myconnectindex ] . ps - > max_actors_killed - g_player [ myconnectindex ] . ps - > actors_killed ) < 0 )
2006-10-23 21:47:28 +00:00
sprintf ( tempbuf , " %-3d " , 0 ) ;
2007-08-27 06:46:31 +00:00
else sprintf ( tempbuf , " %-3ld " , g_player [ myconnectindex ] . ps - > max_actors_killed - g_player [ myconnectindex ] . ps - > actors_killed ) ;
2006-11-15 01:16:55 +00:00
gametext ( ( 320 > > 2 ) + 70 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-04-13 20:47:06 +00:00
}
}
}
2006-10-23 21:47:28 +00:00
zz = yy + = 5 ;
2006-11-14 21:35:50 +00:00
if ( totalclock > ( 60 * 9 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
gametext ( 10 , yy + 9 , " Secrets Found: " , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
gametext ( 10 , yy + 9 , " Secrets Missed: " , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-11-13 23:12:47 +00:00
if ( bonuscnt = = 4 ) bonuscnt + + ;
2006-04-13 20:47:06 +00:00
2006-10-23 21:47:28 +00:00
yy = zz ;
2006-11-14 21:35:50 +00:00
if ( totalclock > ( 60 * 10 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( bonuscnt = = 5 )
2006-04-13 20:47:06 +00:00
{
bonuscnt + + ;
sound ( PIPEBOMB_EXPLODE ) ;
}
2007-08-27 06:46:31 +00:00
sprintf ( tempbuf , " %-3ld " , g_player [ myconnectindex ] . ps - > secret_rooms ) ;
2006-11-15 01:16:55 +00:00
gametext ( ( 320 > > 2 ) + 70 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > secret_rooms > 0 )
sprintf ( tempbuf , " %-3ld%% " , ( 100 * g_player [ myconnectindex ] . ps - > secret_rooms / g_player [ myconnectindex ] . ps - > max_secret_rooms ) ) ;
sprintf ( tempbuf , " %-3ld " , g_player [ myconnectindex ] . ps - > max_secret_rooms - g_player [ myconnectindex ] . ps - > secret_rooms ) ;
2006-11-15 01:16:55 +00:00
gametext ( ( 320 > > 2 ) + 70 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
yy + = 10 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-13 23:12:47 +00:00
if ( totalclock > 10240 & & totalclock < 10240 + 10240 )
2006-04-13 20:47:06 +00:00
totalclock = 1024 ;
2006-11-14 21:35:50 +00:00
if ( ( ( MOUSE_GetButtons ( ) & 7 ) | | KB_KeyWaiting ( ) ) & & totalclock > ( 60 * 2 ) ) // JBF 20030809
2006-04-13 20:47:06 +00:00
{
MOUSE_ClearButton ( 7 ) ;
2006-11-14 21:35:50 +00:00
if ( totalclock < ( 60 * 13 ) )
2006-04-13 20:47:06 +00:00
{
KB_FlushKeyboardQueue ( ) ;
totalclock = ( 60 * 13 ) ;
}
2006-11-14 21:35:50 +00:00
else if ( totalclock < ( 1000000000L ) )
2006-04-13 20:47:06 +00:00
totalclock = ( 1000000000L ) ;
}
}
else break ;
nextpage ( ) ;
}
}
2006-12-10 03:15:56 +00:00
static void cameratext ( short i )
2006-04-13 20:47:06 +00:00
{
char flipbits ;
long x , y ;
2006-11-13 23:12:47 +00:00
if ( ! T1 )
2006-04-13 20:47:06 +00:00
{
rotatesprite ( 24 < < 16 , 33 < < 16 , 65536L , 0 , CAMCORNER , 0 , 0 , 2 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
rotatesprite ( ( 320 - 26 ) < < 16 , 34 < < 16 , 65536L , 0 , CAMCORNER + 1 , 0 , 0 , 2 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
rotatesprite ( 22 < < 16 , 163 < < 16 , 65536L , 512 , CAMCORNER + 1 , 0 , 0 , 2 + 4 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
rotatesprite ( ( 310 - 10 ) < < 16 , 163 < < 16 , 65536L , 512 , CAMCORNER + 1 , 0 , 0 , 2 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
2006-11-13 23:12:47 +00:00
if ( totalclock & 16 )
2006-04-13 20:47:06 +00:00
rotatesprite ( 46 < < 16 , 32 < < 16 , 65536L , 0 , CAMLIGHT , 0 , 0 , 2 , windowx1 , windowy1 , windowx2 , windowy2 ) ;
}
else
{
flipbits = ( totalclock < < 1 ) & 48 ;
2006-11-13 23:12:47 +00:00
for ( x = 0 ; x < 394 ; x + = 64 )
for ( y = 0 ; y < 200 ; y + = 64 )
2006-04-13 20:47:06 +00:00
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , STATIC , 0 , 0 , 2 + flipbits , windowx1 , windowy1 , windowx2 , windowy2 ) ;
}
}
2006-12-10 03:15:56 +00:00
#if 0
2006-04-13 20:47:06 +00:00
void vglass ( long x , long y , short a , short wn , short n )
{
long z , zincs ;
short sect ;
sect = wall [ wn ] . nextsector ;
2006-11-13 23:12:47 +00:00
if ( sect = = - 1 ) return ;
2006-11-14 21:35:50 +00:00
zincs = ( sector [ sect ] . floorz - sector [ sect ] . ceilingz ) / n ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
for ( z = sector [ sect ] . ceilingz ; z < sector [ sect ] . floorz ; z + = zincs )
2006-04-13 20:47:06 +00:00
EGS ( sect , x , y , z - ( TRAND & 8191 ) , GLASSPIECES + ( z & ( TRAND % 3 ) ) , - 32 , 36 , 36 , a + 128 - ( TRAND & 255 ) , 16 + ( TRAND & 31 ) , 0 , - 1 , 5 ) ;
}
2006-12-10 03:15:56 +00:00
# endif
2006-04-13 20:47:06 +00:00
2007-02-28 09:12:41 +00:00
void lotsofglass ( int i , int wallnum , int n )
2006-04-13 20:47:06 +00:00
{
long j , xv , yv , z , x1 , y1 ;
2007-02-28 09:12:41 +00:00
short sect ;
int a ;
2007-03-01 00:50:59 +00:00
2006-04-13 20:47:06 +00:00
sect = - 1 ;
2006-11-13 23:12:47 +00:00
if ( wallnum < 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
for ( j = n - 1 ; j > = 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
a = SA - 256 + ( TRAND & 511 ) + 1024 ;
EGS ( SECT , SX , SY , SZ , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , 32 + ( TRAND & 63 ) , 1024 - ( TRAND & 1023 ) , i , 5 ) ;
}
return ;
}
j = n + 1 ;
x1 = wall [ wallnum ] . x ;
y1 = wall [ wallnum ] . y ;
xv = wall [ wall [ wallnum ] . point2 ] . x - x1 ;
yv = wall [ wall [ wallnum ] . point2 ] . y - y1 ;
x1 - = ksgn ( yv ) ;
y1 + = ksgn ( xv ) ;
xv / = j ;
yv / = j ;
2006-11-13 23:12:47 +00:00
for ( j = n ; j > 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
x1 + = xv ;
y1 + = yv ;
updatesector ( x1 , y1 , & sect ) ;
2006-11-13 23:12:47 +00:00
if ( sect > = 0 )
2006-04-13 20:47:06 +00:00
{
z = sector [ sect ] . floorz - ( TRAND & ( klabs ( sector [ sect ] . ceilingz - sector [ sect ] . floorz ) ) ) ;
2006-11-14 21:35:50 +00:00
if ( z < - ( 32 < < 8 ) | | z > ( 32 < < 8 ) )
2006-04-13 20:47:06 +00:00
z = SZ - ( 32 < < 8 ) + ( TRAND & ( ( 64 < < 8 ) - 1 ) ) ;
a = SA - 1024 ;
EGS ( SECT , x1 , y1 , z , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , 32 + ( TRAND & 63 ) , - ( TRAND & 1023 ) , i , 5 ) ;
}
}
}
2007-02-28 09:12:41 +00:00
void spriteglass ( int i , int n )
2006-04-13 20:47:06 +00:00
{
long j , k , a , z ;
2006-11-13 23:12:47 +00:00
for ( j = n ; j > 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
a = TRAND & 2047 ;
z = SZ - ( ( TRAND & 16 ) < < 8 ) ;
k = EGS ( SECT , SX , SY , z , GLASSPIECES + ( j % 3 ) , TRAND & 15 , 36 , 36 , a , 32 + ( TRAND & 63 ) , - 512 - ( TRAND & 2047 ) , i , 5 ) ;
sprite [ k ] . pal = sprite [ i ] . pal ;
}
}
2007-02-28 09:12:41 +00:00
void ceilingglass ( int i , int sectnum , int n )
2006-04-13 20:47:06 +00:00
{
long j , xv , yv , z , x1 , y1 ;
2007-02-28 09:12:41 +00:00
int a , s , startwall , endwall ;
2006-04-13 20:47:06 +00:00
startwall = sector [ sectnum ] . wallptr ;
endwall = startwall + sector [ sectnum ] . wallnum ;
2006-11-13 23:12:47 +00:00
for ( s = startwall ; s < ( endwall - 1 ) ; s + + )
2006-04-13 20:47:06 +00:00
{
x1 = wall [ s ] . x ;
y1 = wall [ s ] . y ;
xv = ( wall [ s + 1 ] . x - x1 ) / ( n + 1 ) ;
yv = ( wall [ s + 1 ] . y - y1 ) / ( n + 1 ) ;
2006-11-13 23:12:47 +00:00
for ( j = n ; j > 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
x1 + = xv ;
y1 + = yv ;
a = TRAND & 2047 ;
z = sector [ sectnum ] . ceilingz + ( ( TRAND & 15 ) < < 8 ) ;
EGS ( sectnum , x1 , y1 , z , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , ( TRAND & 31 ) , 0 , i , 5 ) ;
}
}
}
2007-02-28 09:12:41 +00:00
void lotsofcolourglass ( int i , int wallnum , int n )
2006-04-13 20:47:06 +00:00
{
long j , xv , yv , z , x1 , y1 ;
2007-02-28 09:12:41 +00:00
short sect = - 1 ;
int a , k ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( wallnum < 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
for ( j = n - 1 ; j > = 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
a = TRAND & 2047 ;
k = EGS ( SECT , SX , SY , SZ - ( TRAND & ( 63 < < 8 ) ) , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , 32 + ( TRAND & 63 ) , 1024 - ( TRAND & 2047 ) , i , 5 ) ;
sprite [ k ] . pal = TRAND & 15 ;
}
return ;
}
j = n + 1 ;
x1 = wall [ wallnum ] . x ;
y1 = wall [ wallnum ] . y ;
xv = ( wall [ wall [ wallnum ] . point2 ] . x - wall [ wallnum ] . x ) / j ;
yv = ( wall [ wall [ wallnum ] . point2 ] . y - wall [ wallnum ] . y ) / j ;
2006-11-13 23:12:47 +00:00
for ( j = n ; j > 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
x1 + = xv ;
y1 + = yv ;
updatesector ( x1 , y1 , & sect ) ;
z = sector [ sect ] . floorz - ( TRAND & ( klabs ( sector [ sect ] . ceilingz - sector [ sect ] . floorz ) ) ) ;
2006-11-14 21:35:50 +00:00
if ( z < - ( 32 < < 8 ) | | z > ( 32 < < 8 ) )
2006-04-13 20:47:06 +00:00
z = SZ - ( 32 < < 8 ) + ( TRAND & ( ( 64 < < 8 ) - 1 ) ) ;
a = SA - 1024 ;
k = EGS ( SECT , x1 , y1 , z , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , 32 + ( TRAND & 63 ) , - ( TRAND & 2047 ) , i , 5 ) ;
sprite [ k ] . pal = TRAND & 7 ;
}
}
2006-12-10 03:15:56 +00:00
static void SetupGameButtons ( void )
2006-04-13 20:47:06 +00:00
{
CONTROL_DefineFlag ( gamefunc_Move_Forward , false ) ;
CONTROL_DefineFlag ( gamefunc_Move_Backward , false ) ;
CONTROL_DefineFlag ( gamefunc_Turn_Left , false ) ;
CONTROL_DefineFlag ( gamefunc_Turn_Right , false ) ;
CONTROL_DefineFlag ( gamefunc_Strafe , false ) ;
CONTROL_DefineFlag ( gamefunc_Fire , false ) ;
CONTROL_DefineFlag ( gamefunc_Open , false ) ;
CONTROL_DefineFlag ( gamefunc_Run , false ) ;
CONTROL_DefineFlag ( gamefunc_AutoRun , false ) ;
CONTROL_DefineFlag ( gamefunc_Jump , false ) ;
CONTROL_DefineFlag ( gamefunc_Crouch , false ) ;
CONTROL_DefineFlag ( gamefunc_Look_Up , false ) ;
CONTROL_DefineFlag ( gamefunc_Look_Down , false ) ;
CONTROL_DefineFlag ( gamefunc_Look_Left , false ) ;
CONTROL_DefineFlag ( gamefunc_Look_Right , false ) ;
CONTROL_DefineFlag ( gamefunc_Strafe_Left , false ) ;
CONTROL_DefineFlag ( gamefunc_Strafe_Right , false ) ;
CONTROL_DefineFlag ( gamefunc_Aim_Up , false ) ;
CONTROL_DefineFlag ( gamefunc_Aim_Down , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_1 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_2 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_3 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_4 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_5 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_6 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_7 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_8 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_9 , false ) ;
CONTROL_DefineFlag ( gamefunc_Weapon_10 , false ) ;
CONTROL_DefineFlag ( gamefunc_Inventory , false ) ;
CONTROL_DefineFlag ( gamefunc_Inventory_Left , false ) ;
CONTROL_DefineFlag ( gamefunc_Inventory_Right , false ) ;
CONTROL_DefineFlag ( gamefunc_Holo_Duke , false ) ;
CONTROL_DefineFlag ( gamefunc_Jetpack , false ) ;
CONTROL_DefineFlag ( gamefunc_NightVision , false ) ;
CONTROL_DefineFlag ( gamefunc_MedKit , false ) ;
CONTROL_DefineFlag ( gamefunc_TurnAround , false ) ;
CONTROL_DefineFlag ( gamefunc_SendMessage , false ) ;
CONTROL_DefineFlag ( gamefunc_Map , false ) ;
CONTROL_DefineFlag ( gamefunc_Shrink_Screen , false ) ;
CONTROL_DefineFlag ( gamefunc_Enlarge_Screen , false ) ;
CONTROL_DefineFlag ( gamefunc_Center_View , false ) ;
CONTROL_DefineFlag ( gamefunc_Holster_Weapon , false ) ;
CONTROL_DefineFlag ( gamefunc_Show_Opponents_Weapon , false ) ;
CONTROL_DefineFlag ( gamefunc_Map_Follow_Mode , false ) ;
CONTROL_DefineFlag ( gamefunc_See_Coop_View , false ) ;
CONTROL_DefineFlag ( gamefunc_Mouse_Aiming , false ) ;
CONTROL_DefineFlag ( gamefunc_Toggle_Crosshair , false ) ;
CONTROL_DefineFlag ( gamefunc_Steroids , false ) ;
CONTROL_DefineFlag ( gamefunc_Quick_Kick , false ) ;
CONTROL_DefineFlag ( gamefunc_Next_Weapon , false ) ;
CONTROL_DefineFlag ( gamefunc_Previous_Weapon , false ) ;
}
/*
= = = = = = = = = = = = = = = = = = =
=
= GetTime
=
= = = = = = = = = = = = = = = = = = =
*/
long GetTime ( void )
{
return totalclock ;
}
2006-12-10 03:15:56 +00:00
#if 0
2006-04-13 20:47:06 +00:00
/*
= = = = = = = = = = = = = = = = = = =
=
= CenterCenter
=
= = = = = = = = = = = = = = = = = = =
*/
void CenterCenter ( void )
{
initprintf ( " Center the joystick and press a button \n " ) ;
}
/*
= = = = = = = = = = = = = = = = = = =
=
= UpperLeft
=
= = = = = = = = = = = = = = = = = = =
*/
void UpperLeft ( void )
{
initprintf ( " Move joystick to upper-left corner and press a button \n " ) ;
}
/*
= = = = = = = = = = = = = = = = = = =
=
= LowerRight
=
= = = = = = = = = = = = = = = = = = =
*/
void LowerRight ( void )
{
initprintf ( " Move joystick to lower-right corner and press a button \n " ) ;
}
/*
= = = = = = = = = = = = = = = = = = =
=
= CenterThrottle
=
= = = = = = = = = = = = = = = = = = =
*/
void CenterThrottle ( void )
{
initprintf ( " Center the throttle control and press a button \n " ) ;
}
/*
= = = = = = = = = = = = = = = = = = =
=
= CenterRudder
=
= = = = = = = = = = = = = = = = = = =
*/
void CenterRudder ( void )
{
initprintf ( " Center the rudder control and press a button \n " ) ;
}
2006-12-10 03:15:56 +00:00
# endif