2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
2010-05-25 10:56:00 +00:00
Copyright ( C ) 2010 EDuke32 developers and contributors
2006-04-13 20:47:06 +00:00
2010-05-25 10:56:00 +00:00
This file is part of EDuke32 .
2006-04-13 20:47:06 +00:00
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"
2009-04-26 05:57:42 +00:00
2012-11-25 04:26:37 +00:00
# include "baselayer.h"
# include "renderlayer.h"
2012-11-05 02:49:08 +00:00
2006-04-13 20:47:06 +00:00
# include "scriplib.h"
# include "file_lib.h"
# include "mathutil.h"
# include "gamedefs.h"
# include "keyboard.h"
# include "mouse.h" // JBF 20030809
2012-06-03 16:11:22 +00:00
# include "joystick.h"
2006-04-13 20:47:06 +00:00
# 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"
2008-02-06 11:42:34 +00:00
# include "gamedef.h"
2008-03-09 08:14:12 +00:00
# include "kplib.h"
2009-12-05 09:22:43 +00:00
# include "crc32.h"
2008-12-02 10:44:39 +00:00
# include "hightile.h"
2010-05-07 20:45:40 +00:00
# include "control.h"
2009-12-05 09:22:43 +00:00
# include "quicklz.h"
2010-08-02 08:13:51 +00:00
# include "net.h"
# include "premap.h"
# include "gameexec.h"
# include "menus.h"
# include "savegame.h"
# include "anim.h"
# include "demo.h"
2012-03-26 22:03:20 +00:00
# include "common.h"
2012-06-03 16:09:33 +00:00
# include "common_game.h"
2012-06-03 16:11:22 +00:00
# include "input.h"
2012-11-15 14:28:04 +00:00
# include "compat.h"
2009-12-05 09:22:43 +00:00
2012-06-03 15:45:59 +00:00
# ifdef LUNATIC
2012-11-10 20:59:00 +00:00
# include "lunatic_game.h"
2011-09-20 19:12:24 +00:00
# endif
2010-01-24 23:33:17 +00:00
# if KRANDDEBUG
# define GAME_INLINE
# define GAME_STATIC
# else
# define GAME_INLINE inline
# define GAME_STATIC static
# endif
2006-12-14 08:50:18 +00:00
# ifdef _WIN32
2012-11-25 04:26:37 +00:00
# include "winlayer.h"
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <shellapi.h>
2009-01-09 09:29:17 +00:00
extern int32_t G_GetVersionFromWebsite ( char * buffer ) ;
2012-11-25 04:26:37 +00:00
# define UPDATEINTERVAL 604800 // 1w
# include "winbits.h"
2008-08-06 11:50:34 +00:00
# else
2009-01-09 09:29:17 +00:00
static int32_t usecwd = 0 ;
2012-11-25 04:26:37 +00:00
# ifndef GEKKO
# include <sys / ioctl.h>
# endif
2008-08-06 11:50:34 +00:00
# endif /* _WIN32 */
2010-01-16 23:08:17 +00:00
int32_t g_quitDeadline = 0 ;
2006-12-14 08:50:18 +00:00
2009-01-09 09:29:17 +00:00
int32_t g_cameraDistance = 0 , g_cameraClock = 0 ;
2010-01-16 23:08:17 +00:00
static int32_t g_quickExit ;
2009-01-09 09:29:17 +00:00
static int32_t g_commandSetup = 0 ;
int32_t g_noSetup = 0 ;
static int32_t g_noAutoLoad = 0 ;
static int32_t g_noSound = 0 ;
static int32_t g_noMusic = 0 ;
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
static const char * CommandMap = NULL ;
static const char * CommandName = NULL ;
2010-01-16 23:08:17 +00:00
int32_t g_forceWeaponChoice = 0 ;
2012-08-13 18:25:32 +00:00
int32_t g_fakeMultiMode = 0 ;
2010-05-07 20:45:40 +00:00
2008-09-15 02:47:02 +00:00
char boardfilename [ BMAX_PATH ] = { 0 } , currentboardfilename [ BMAX_PATH ] = { 0 } ;
2010-01-16 23:08:17 +00:00
static char g_rootDir [ BMAX_PATH ] ;
char g_modDir [ BMAX_PATH ] = " / " ;
2011-01-17 03:49:34 +00:00
2012-03-22 22:47:13 +00:00
uint8_t water_pal [ 768 ] , slime_pal [ 768 ] , title_pal [ 768 ] , dre_alms [ 768 ] , ending_pal [ 768 ] ;
2011-01-17 03:49:34 +00:00
2012-03-22 22:47:13 +00:00
uint8_t * basepaltable [ BASEPALCOUNT ] = { palette , water_pal , slime_pal , dre_alms , title_pal , ending_pal , NULL /*anim_pal*/ } ;
2011-01-17 03:49:34 +00:00
2012-03-22 22:47:47 +00:00
int8_t g_noFloorPal [ MAXPALOOKUPS ] ; // 1 if sprite pal should not be taken over from floor pal
2012-03-22 22:47:29 +00:00
2009-01-09 09:29:17 +00:00
int32_t voting = - 1 ;
int32_t vote_map = - 1 , vote_episode = - 1 ;
2006-05-04 03:14:49 +00:00
2010-01-16 23:08:17 +00:00
static int32_t g_Debug = 0 ;
2009-01-09 09:29:17 +00:00
static int32_t g_noLogoAnim = 0 ;
static int32_t g_noLogo = 0 ;
2006-07-26 01:10:33 +00:00
2012-06-03 16:09:33 +00:00
const char * defaultrtsfilename [ GAMECOUNT ] = { " DUKE.RTS " , " NAM.RTS " , " NAPALM.RTS " , " WW2GI.RTS " } ;
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
// g_gameNamePtr can point to one of: grpfiles[].name (string literal), string
// literal, malloc'd block (XXX: possible leak)
const char * g_gameNamePtr = NULL ;
// g_rtsNamePtr can point to an argv[] element
const char * g_rtsNamePtr = NULL ;
2011-07-21 22:39:29 +00:00
char * * g_scriptModules = NULL ;
2012-03-18 08:50:41 +00:00
int32_t g_scriptModulesNum = 0 ;
2011-07-21 22:39:29 +00:00
char * * g_defModules = NULL ;
2012-03-18 08:50:41 +00:00
int32_t g_defModulesNum = 0 ;
# ifdef HAVE_CLIPSHAPE_FEATURE
char * * g_clipMapFiles = NULL ;
int32_t g_clipMapFilesNum = 0 ;
# endif
2011-07-21 22:39:29 +00:00
2009-01-09 09:29:17 +00:00
extern int32_t lastvisinc ;
int32_t g_Shareware = 0 ;
2006-07-26 01:10:33 +00:00
2008-08-28 05:57:46 +00:00
# define MAXUSERQUOTES 6
2010-08-02 08:13:51 +00:00
int32_t quotebot , quotebotgoal ;
2009-01-09 09:29:17 +00:00
static int32_t user_quote_time [ MAXUSERQUOTES ] ;
2007-01-05 22:30:35 +00:00
static char user_quote [ MAXUSERQUOTES ] [ 178 ] ;
2006-07-26 01:10:33 +00:00
// char typebuflen,typebuf[41];
2010-06-22 21:50:01 +00:00
// This was 32 for a while, but I think lowering it to 24 will help things like the Dingoo.
// Ideally, we would look at our memory usage on our most cramped platform and figure out
// how much of that is needed for the underlying OS and things like SDL instead of guessing
2012-05-01 12:40:08 +00:00
# ifndef GEKKO
2010-06-22 21:50:01 +00:00
static int32_t MAXCACHE1DSIZE = ( 24 * 1048576 ) ;
2012-05-01 12:40:08 +00:00
# else
static int32_t MAXCACHE1DSIZE = ( 8 * 1048576 ) ;
# endif
2006-08-02 20:51:50 +00:00
2009-01-09 09:29:17 +00:00
int32_t tempwallptr ;
2006-07-26 01:10:33 +00:00
2009-01-09 09:29:17 +00:00
static int32_t nonsharedtimer ;
2006-07-26 01:10:33 +00:00
2009-12-05 09:22:43 +00:00
int32_t ticrandomseed ;
2009-01-09 09:29:17 +00:00
static void G_DrawCameraText ( int16_t i ) ;
2010-01-24 23:33:17 +00:00
GAME_STATIC GAME_INLINE int32_t G_MoveLoop ( void ) ;
2008-11-20 14:06:36 +00:00
static void G_DoOrderScreen ( void ) ;
2007-04-15 20:04:52 +00:00
2009-12-05 09:22:43 +00:00
# define quotepulseshade (sintable[(totalclock<<5)&2047]>>11)
2009-01-09 09:29:17 +00:00
int32_t althud_numbertile = 2930 ;
int32_t althud_numberpal = 0 ;
int32_t althud_shadows = 1 ;
int32_t althud_flashing = 1 ;
int32_t hud_glowingquotes = 1 ;
int32_t hud_showmapname = 1 ;
2008-09-15 02:47:02 +00:00
2009-01-09 09:29:17 +00:00
int32_t g_levelTextTime = 0 ;
2008-08-07 11:45:28 +00:00
2009-01-09 09:29:17 +00:00
int32_t r_maxfps = 0 ;
uint32_t g_frameDelay = 0 ;
2008-10-01 04:38:14 +00:00
2008-12-04 00:31:16 +00:00
# if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
2008-10-31 10:08:51 +00:00
extern char forcegl ;
# endif
2010-05-25 10:56:00 +00:00
void M32RunScript ( const char * s ) { UNREFERENCED_PARAMETER ( s ) ; } ; // needed for linking since it's referenced from build/src/osd.c
2010-05-22 23:41:18 +00:00
2010-10-17 14:49:39 +00:00
int32_t kopen4loadfrommod ( const char * filename , char searchfirst )
2008-08-20 08:39:07 +00:00
{
2012-05-28 18:15:22 +00:00
int32_t r = - 1 ;
if ( g_modDir [ 0 ] ! = ' / ' | | g_modDir [ 1 ] ! = 0 )
{
static char fn [ BMAX_PATH ] ;
2012-07-20 21:57:24 +00:00
Bsnprintf ( fn , sizeof ( fn ) , " %s/%s " , g_modDir , filename ) ;
2012-05-28 18:15:22 +00:00
r = kopen4load ( fn , searchfirst ) ;
}
2008-08-20 08:39:07 +00:00
2008-08-20 09:17:23 +00:00
if ( r < 0 )
2008-08-20 08:39:07 +00:00
r = kopen4load ( filename , searchfirst ) ;
2010-10-28 20:17:22 +00:00
2008-08-20 08:39:07 +00:00
return r ;
}
2012-06-03 16:09:33 +00:00
const char * G_DefaultRtsFile ( void )
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
{
2012-06-03 16:09:33 +00:00
if ( DUKE )
return defaultrtsfilename [ GAME_DUKE ] ;
else if ( WW2GI )
return defaultrtsfilename [ GAME_WW2GI ] ;
else if ( NAPALM )
{
2012-06-11 20:35:47 +00:00
if ( ! testkopen ( defaultrtsfilename [ GAME_NAPALM ] , 0 ) & & testkopen ( defaultrtsfilename [ GAME_NAM ] , 0 ) )
2012-06-03 16:09:33 +00:00
return defaultrtsfilename [ GAME_NAM ] ; // NAM/Napalm Sharing
else
return defaultrtsfilename [ GAME_NAPALM ] ;
}
else if ( NAM )
{
2012-06-11 20:35:47 +00:00
if ( ! testkopen ( defaultrtsfilename [ GAME_NAM ] , 0 ) & & testkopen ( defaultrtsfilename [ GAME_NAPALM ] , 0 ) )
2012-06-03 16:09:33 +00:00
return defaultrtsfilename [ GAME_NAPALM ] ; // NAM/Napalm Sharing
else
return defaultrtsfilename [ GAME_NAM ] ;
}
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
2012-06-03 16:09:33 +00:00
return defaultrtsfilename [ 0 ] ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
}
2010-08-02 08:13:51 +00:00
enum gametokens
2006-11-15 01:16:55 +00:00
{
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 ,
2008-02-21 05:11:41 +00:00
T_ALLOW = 2 ,
T_NOAUTOLOAD ,
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
T_INCLUDEDEFAULT ,
2008-03-08 05:23:15 +00:00
T_MUSIC ,
T_SOUND ,
T_FILE ,
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
T_ANIMSOUNDS ,
2012-03-22 22:47:29 +00:00
T_NOFLOORPALRANGE ,
2008-03-08 05:23:15 +00:00
T_ID
2006-07-26 01:10:33 +00:00
} ;
2006-04-13 20:47:06 +00:00
2012-05-05 22:24:02 +00:00
static int32_t sbarx ( int32_t x )
2006-04-13 20:47:06 +00:00
{
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 ) ;
}
2012-05-05 22:24:02 +00:00
static int32_t sbarxr ( int32_t x )
2008-08-07 07:52:36 +00:00
{
if ( ud . screen_size = = 4 /*|| ud.statusbarmode == 1*/ ) return ( 320l < < 16 ) - scale ( x < < 16 , ud . statusbarscale , 100 ) ;
return ( ( ( 320l < < 16 ) - scale ( 320l < < 16 , ud . statusbarscale , 100 ) ) > > 1 ) + scale ( x < < 16 , ud . statusbarscale , 100 ) ;
}
2012-05-05 22:24:02 +00:00
static int32_t sbary ( int32_t y )
2006-04-13 20:47:06 +00:00
{
return ( ( 200l < < 16 ) - scale ( 200l < < 16 , ud . statusbarscale , 100 ) + scale ( y < < 16 , ud . statusbarscale , 100 ) ) ;
}
2012-05-05 22:24:02 +00:00
static int32_t sbarsc ( int32_t sc )
2006-04-13 20:47:06 +00:00
{
return scale ( sc , ud . statusbarscale , 100 ) ;
}
2012-06-03 16:11:22 +00:00
int32_t textsc ( int32_t sc )
2008-10-11 09:20:04 +00:00
{
2008-10-11 11:50:02 +00:00
// prevent ridiculousness to a degree
2008-10-13 01:16:40 +00:00
if ( xdim < = 320 ) return sc ;
else if ( xdim < = 640 ) return scale ( sc , min ( 200 , ud . textscale ) , 100 ) ;
else if ( xdim < = 800 ) return scale ( sc , min ( 300 , ud . textscale ) , 100 ) ;
else if ( xdim < = 1024 ) return scale ( sc , min ( 350 , ud . textscale ) , 100 ) ;
2008-10-11 09:20:04 +00:00
return scale ( sc , ud . textscale , 100 ) ;
}
2009-01-09 09:29:17 +00:00
static void G_PatchStatusBar ( int32_t x1 , int32_t y1 , int32_t x2 , int32_t y2 )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t scl , tx , ty ;
int32_t clx1 , cly1 , clx2 , cly2 , clofx , clofy ;
2006-04-13 20:47:06 +00:00
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
}
2011-01-17 03:49:34 +00:00
void P_SetGamePalette ( DukePlayer_t * player , uint8_t palid , int32_t set )
2006-04-13 20:47:06 +00:00
{
2011-01-17 03:49:34 +00:00
if ( palid > = BASEPALCOUNT )
palid = BASEPAL ;
2010-03-02 22:49:26 +00:00
2012-08-22 22:48:21 +00:00
player - > palette = palid ;
2007-08-27 06:46:31 +00:00
if ( player ! = g_player [ screenpeek ] . ps )
2006-04-13 20:47:06 +00:00
return ;
2011-01-27 06:35:52 +00:00
setbrightness ( ud . brightness > > 2 , palid , set ) ;
2006-04-13 20:47:06 +00:00
}
2012-08-20 21:31:05 +00:00
2012-08-24 18:54:01 +00:00
// flags
// 4: small font, wrap strings?
2010-03-02 22:49:26 +00:00
int32_t G_PrintGameText ( int32_t f , int32_t tile , int32_t x , int32_t y , const char * t ,
int32_t s , int32_t p , int32_t o ,
int32_t x1 , int32_t y1 , int32_t x2 , int32_t y2 , int32_t z )
2006-04-13 20:47:06 +00:00
{
2010-03-02 22:49:26 +00:00
int32_t ac ;
2009-01-09 09:29:17 +00:00
char centre ;
2012-02-24 19:51:37 +00:00
const int32_t squishtext = ( ( f & 2 ) ! = 0 ) ;
2010-03-02 22:49:26 +00:00
int32_t shift = 16 , widthx = 320 ;
int32_t ox , oy , origx = x , origy = y ;
2008-07-22 10:56:22 +00:00
2010-03-02 22:49:26 +00:00
if ( t = = NULL )
return - 1 ;
2010-06-22 21:50:01 +00:00
if ( o & ROTATESPRITE_MAX )
2008-08-11 09:31:49 +00:00
{
widthx = 320 < < 16 ;
shift = 0 ;
}
2006-04-13 20:47:06 +00:00
2012-02-24 19:51:37 +00:00
centre = ( x = = ( widthx > > 1 ) ) ;
if ( centre )
2006-04-13 20:47:06 +00:00
{
2010-03-02 22:49:26 +00:00
const char * oldt = t ;
int32_t newx = 0 ;
2008-08-24 09:29:03 +00:00
do
2006-04-13 20:47:06 +00:00
{
2010-03-02 22:49:26 +00:00
int32_t i ;
if ( * t = = 32 )
2006-05-05 07:10:36 +00:00
{
2010-03-02 22:49:26 +00:00
newx + = ( ( ( ( f & 8 ) ? 8 : 5 ) - squishtext ) * z ) > > 16 ;
2006-08-15 17:15:23 +00:00
continue ;
2006-05-05 07:10:36 +00:00
}
2010-03-02 22:49:26 +00:00
if ( * t = = ' ^ ' & & isdigit ( * ( t + 1 ) ) )
2006-11-15 01:16:55 +00:00
{
2012-02-24 19:51:37 +00:00
t + + ;
if ( isdigit ( * ( t + 1 ) ) )
t + + ;
// t += 1 + isdigit(*(t+2)); // This code is wrong, see C99 6.5.16 #3
2006-11-15 01:16:55 +00:00
continue ;
}
2006-04-13 20:47:06 +00:00
2010-03-02 22:49:26 +00:00
ac = * t - ' ! ' + tile ;
2012-08-20 21:31:05 +00:00
if ( ac < tile | | ac > ( tile + 93 ) )
break ;
2010-03-02 22:49:26 +00:00
2012-02-24 19:51:37 +00:00
i = ( ( ( ( f & 8 ) ? 8 : tilesizx [ ac ] ) - squishtext ) * z ) > > 16 ;
newx + = i ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( * t > = ' 0 ' & & * t < = ' 9 ' )
2010-03-02 22:49:26 +00:00
newx - = i - ( ( 8 * z ) > > 16 ) ;
2006-04-13 20:47:06 +00:00
}
2008-08-24 09:29:03 +00:00
while ( * ( + + t ) ) ;
2006-04-13 20:47:06 +00:00
t = oldt ;
2010-03-02 22:49:26 +00:00
x = ( f & 4 ) ?
( xres > > 1 ) - textsc ( newx > > 1 ) :
2010-08-02 08:13:51 +00:00
( widthx > > 1 ) - ( ( o & ROTATESPRITE_MAX ) ? newx < < 15 : newx > > 1 ) ;
2006-04-13 20:47:06 +00:00
}
2010-03-02 22:49:26 +00:00
ox = x ;
oy = y ;
2008-08-24 09:29:03 +00:00
do
2006-04-13 20:47:06 +00:00
{
2010-03-02 22:49:26 +00:00
int32_t i ;
if ( * t = = 32 )
{
x + = ( ( ( ( f & 8 ) ? 8 : 5 ) - squishtext ) * z ) > > 16 ;
continue ;
}
2006-11-13 23:12:47 +00:00
if ( * t = = ' ^ ' & & isdigit ( * ( t + 1 ) ) )
2006-05-05 07:10:36 +00:00
{
2008-06-05 10:10:26 +00:00
char smallbuf [ 4 ] ;
2010-03-02 22:49:26 +00:00
2008-08-24 09:29:03 +00:00
if ( ! isdigit ( * ( + + t + 1 ) ) )
2006-05-05 07:10:36 +00:00
{
2008-08-24 09:29:03 +00:00
smallbuf [ 0 ] = * ( t ) ;
2006-05-05 07:10:36 +00:00
smallbuf [ 1 ] = ' \0 ' ;
2012-02-20 21:17:39 +00:00
p = Batoi ( smallbuf ) ;
2008-08-24 09:29:03 +00:00
continue ;
2006-05-05 07:10:36 +00:00
}
2010-03-02 22:49:26 +00:00
2008-08-24 09:29:03 +00:00
smallbuf [ 0 ] = * ( t + + ) ;
smallbuf [ 1 ] = * ( t ) ;
smallbuf [ 2 ] = ' \0 ' ;
2012-02-20 21:17:39 +00:00
p = Batoi ( smallbuf ) ;
2006-08-15 17:15:23 +00:00
continue ;
2006-05-05 07:10:36 +00:00
}
2006-04-13 20:47:06 +00:00
2010-03-02 22:49:26 +00:00
ac = * t - ' ! ' + tile ;
if ( ac < tile | | ac > ( tile + 93 ) )
2006-04-13 20:47:06 +00:00
break ;
2010-06-22 21:50:01 +00:00
if ( o & ROTATESPRITE_MAX )
2008-08-11 09:31:49 +00:00
{
2010-03-02 22:49:26 +00:00
ox = x + = ( x - ox ) < < 16 ;
oy = y + = ( y - oy ) < < 16 ;
2008-08-11 09:31:49 +00:00
}
2008-10-11 09:20:04 +00:00
2010-03-02 22:49:26 +00:00
if ( f & 4 )
2012-08-20 21:31:05 +00:00
{
rotatesprite ( textsc ( x < < shift ) , ( origy < < shift ) + textsc ( ( y - origy ) < < shift ) , textsc ( z ) ,
2010-08-02 08:13:51 +00:00
0 , ac , s , p , ( 8 | 16 | ( o & 1 ) | ( o & 32 ) ) , x1 , y1 , x2 , y2 ) ;
2012-08-20 21:31:05 +00:00
}
else
{
const int32_t orient = ( f & 1 ) ? ( 8 | 16 | ( o & 1 ) | ( o & 32 ) ) : ( 2 | o ) ;
rotatesprite ( x < < shift , y < < shift , z ,
0 , ac , s , p , orient , x1 , y1 , x2 , y2 ) ;
}
2010-03-02 22:49:26 +00:00
2012-08-20 21:31:05 +00:00
i = ( f & 8 ) ?
( ( 8 - squishtext ) * z ) > > 16 :
( ( tilesizx [ ac ] - squishtext ) * z ) > > 16 ;
x + = i ;
2008-07-07 06:44:41 +00:00
2012-08-20 21:31:05 +00:00
if ( * t > = ' 0 ' & & * t < = ' 9 ' )
x - = i - ( ( 8 * z ) > > 16 ) ;
2008-07-30 06:49:44 +00:00
2012-08-16 21:48:08 +00:00
// wrapping long strings doesn't work for precise coordinates due to overflow
// XXX: above comment obsolete?
if ( ( o & ROTATESPRITE_MAX ) = = 0 )
2008-10-11 09:20:04 +00:00
{
2010-03-02 22:49:26 +00:00
if ( ( ( f & 4 ) ? textsc ( x ) : x ) > ( ud . config . ScreenWidth - USERQUOTE_RIGHTOFFSET ) )
2012-08-16 21:48:08 +00:00
x = origx , y + = z > > 13 ;
2008-10-11 09:20:04 +00:00
}
2006-04-13 20:47:06 +00:00
}
2008-08-24 09:29:03 +00:00
while ( * ( + + t ) ) ;
2010-03-02 22:49:26 +00:00
return x ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
int32_t G_GameTextLen ( int32_t x , const char * t )
2008-07-20 11:03:57 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t ac ;
2008-07-20 11:03:57 +00:00
if ( t = = NULL )
return - 1 ;
2008-08-24 09:29:03 +00:00
do
2008-07-20 11:03:57 +00:00
{
if ( * t = = 32 )
{
x + = 5 ;
continue ;
}
2010-05-02 23:27:30 +00:00
ac = * t - ' ! ' + STARTALPHANUM ;
2008-07-20 11:03:57 +00:00
if ( ac < STARTALPHANUM | | ac > ( STARTALPHANUM + 93 ) )
break ;
2010-05-02 23:27:30 +00:00
x + = ( * t > = ' 0 ' & & * t < = ' 9 ' ) ? 8 : tilesizx [ ac ] ;
2008-07-20 11:03:57 +00:00
}
2008-08-24 09:29:03 +00:00
while ( * ( + + t ) ) ;
2010-05-02 23:27:30 +00:00
2008-10-11 09:20:04 +00:00
return ( textsc ( x ) ) ;
2008-07-20 11:03:57 +00:00
}
2008-07-19 00:50:20 +00:00
2012-05-05 22:24:02 +00:00
int32_t mpgametext ( int32_t y , const char * t , int32_t s , int32_t dabits )
2006-04-21 05:11:57 +00:00
{
2010-03-02 22:49:26 +00:00
return ( G_PrintGameText ( 4 , STARTALPHANUM , 5 , y , t , s , 0 , dabits , 0 , 0 , xdim - 1 , ydim - 1 , 65536 ) ) ;
2006-04-21 05:11:57 +00:00
}
2012-08-20 21:28:48 +00:00
// minitext_yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords,
// (sb&ROTATESPRITE_MAX) only.
static int32_t minitext_yofs = 0 ;
2009-01-09 09:29:17 +00:00
int32_t minitext_ ( int32_t x , int32_t y , const char * t , int32_t s , int32_t p , int32_t sb )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t ac ;
char ch , cmode ;
2006-04-13 20:47:06 +00:00
2010-06-22 21:50:01 +00:00
cmode = ( sb & ROTATESPRITE_MAX ) ! = 0 ;
2012-08-19 13:02:37 +00:00
sb & = ( ROTATESPRITE_MAX - 1 ) | RS_CENTERORIGIN ;
2006-04-13 20:47:06 +00:00
2011-06-25 16:37:10 +00:00
if ( t = = NULL )
{
OSD_Printf ( " minitext: NULL text! \n " ) ;
return 0 ;
}
2011-05-13 05:48:22 +00:00
2008-08-24 09:29:03 +00:00
do
2006-04-13 20:47:06 +00:00
{
2008-07-30 02:51:32 +00:00
if ( * t = = ' ^ ' & & isdigit ( * ( t + 1 ) ) )
{
char smallbuf [ 4 ] ;
2008-08-24 09:29:03 +00:00
if ( ! isdigit ( * ( + + t + 1 ) ) )
2008-07-30 02:51:32 +00:00
{
2008-08-24 09:29:03 +00:00
smallbuf [ 0 ] = * ( t ) ;
2008-07-30 02:51:32 +00:00
smallbuf [ 1 ] = ' \0 ' ;
2012-02-20 21:17:39 +00:00
p = Batoi ( smallbuf ) ;
2008-08-24 09:29:03 +00:00
continue ;
2008-07-30 02:51:32 +00:00
}
2008-08-24 09:29:03 +00:00
smallbuf [ 0 ] = * ( t + + ) ;
smallbuf [ 1 ] = * ( t ) ;
smallbuf [ 2 ] = ' \0 ' ;
2012-02-20 21:17:39 +00:00
p = Batoi ( smallbuf ) ;
2008-07-30 02:51:32 +00:00
continue ;
}
2006-04-13 20:47:06 +00:00
ch = Btoupper ( * t ) ;
2006-11-15 01:16:55 +00:00
if ( ch = = 32 )
{
x + = 5 ;
continue ;
}
2006-04-13 20:47:06 +00:00
else ac = ch - ' ! ' + MINIFONT ;
2012-08-20 21:28:48 +00:00
if ( cmode ) rotatesprite_fs ( sbarx ( x ) , minitext_yofs + sbary ( y ) , sbarsc ( 65536L ) , 0 , ac , s , p , sb ) ;
2012-02-02 17:35:05 +00:00
else rotatesprite_fs ( x < < 16 , y < < 16 , 65536L , 0 , ac , s , p , sb ) ;
2006-04-13 20:47:06 +00:00
x + = 4 ; // tilesizx[ac]+1;
}
2008-08-24 09:29:03 +00:00
while ( * ( + + t ) ) ;
2010-05-02 23:27:30 +00:00
2006-04-13 20:47:06 +00:00
return ( x ) ;
}
2008-11-20 14:06:36 +00:00
void G_AddUserQuote ( const char * daquote )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2006-04-13 20:47:06 +00:00
2009-02-19 16:47:54 +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 ) ;
2008-07-18 09:50:44 +00:00
OSD_Printf ( " %s \n " , 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 ;
}
2008-11-20 14:06:36 +00:00
void G_HandleSpecialKeys ( void )
2006-04-13 20:47:06 +00:00
{
2009-12-05 09:22:43 +00:00
// we need CONTROL_GetInput in order to pick up joystick button presses
if ( CONTROL_Started & & ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
{
ControlInfo noshareinfo ;
CONTROL_GetInput ( & noshareinfo ) ;
}
2010-05-07 20:45:40 +00:00
// CONTROL_ProcessBinds();
2008-06-29 10:40:37 +00:00
2011-02-25 21:50:19 +00:00
if ( g_networkMode ! = NET_DEDICATED_SERVER & & 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
{
2008-07-27 01:22:17 +00:00
OSD_Printf ( OSD_ERROR " 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 ) )
2008-11-20 14:06:36 +00:00
G_GameExit ( " Failed to recover from failure to set fullscreen video mode. \n " ) ;
2006-04-25 22:50:57 +00:00
}
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 ) ;
2008-11-20 14:06:36 +00:00
g_restorePalette = 1 ;
G_UpdateScreenArea ( ) ;
2006-04-25 22:50:57 +00:00
}
2008-06-30 11:01:58 +00:00
if ( KB_UnBoundKeyPressed ( sc_F12 ) )
2007-01-26 05:16:10 +00:00
{
2011-03-19 18:07:12 +00:00
char titlebuf [ 256 ] ;
Bsprintf ( titlebuf , HEAD2 " %s " , s_buildRev ) ;
2007-01-26 05:16:10 +00:00
KB_ClearKeyDown ( sc_F12 ) ;
2011-03-19 18:07:12 +00:00
screencapture ( " duke0000.tga " , 0 , titlebuf ) ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_SCREEN_SAVED , 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
2009-12-30 23:07:00 +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
2010-01-16 23:08:17 +00:00
if ( g_quickExit = = 0 & & KB_KeyPressed ( sc_LeftControl ) & & KB_KeyPressed ( sc_LeftAlt ) & & ( KB_KeyPressed ( sc_Delete ) | | KB_KeyPressed ( sc_End ) ) )
2006-04-13 20:47:06 +00:00
{
2010-01-16 23:08:17 +00:00
g_quickExit = 1 ;
2008-11-20 14:06:36 +00:00
G_GameExit ( " Quick Exit. " ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
}
2009-12-14 20:14:12 +00:00
void G_GameQuit ( void )
2009-12-05 09:22:43 +00:00
{
2009-12-30 23:07:00 +00:00
if ( numplayers < 2 )
G_GameExit ( " " ) ;
if ( g_gameQuit = = 0 )
2009-12-05 09:22:43 +00:00
{
2010-01-23 22:12:02 +00:00
g_gameQuit = 1 ;
g_quitDeadline = totalclock + 120 ;
g_netDisconnect = 1 ;
2009-12-05 09:22:43 +00:00
}
2010-01-16 23:08:17 +00:00
if ( ( totalclock > g_quitDeadline ) & & ( g_gameQuit = = 1 ) )
2009-12-05 09:22:43 +00:00
G_GameExit ( " Timed out. " ) ;
}
2010-08-02 08:13:51 +00:00
extern int32_t cacnum ;
extern cactype cac [ ] ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
static void G_ShowCacheLocks ( void )
2009-12-05 09:22:43 +00:00
{
2010-08-02 08:13:51 +00:00
int16_t i , k ;
2009-12-05 09:22:43 +00:00
2011-06-24 11:16:12 +00:00
if ( offscreenrendering )
return ;
2010-08-02 08:13:51 +00:00
k = 0 ;
for ( i = cacnum - 1 ; i > = 0 ; i - - )
if ( ( * cac [ i ] . lock ) > = 200 )
{
2011-06-24 11:16:12 +00:00
if ( k > = ydim - 12 )
break ;
2010-08-02 08:13:51 +00:00
Bsprintf ( tempbuf , " Locked- %d: Leng:%d, Lock:%d " , i , cac [ i ] . leng , * cac [ i ] . lock ) ;
printext256 ( 0L , k , 31 , - 1 , tempbuf , 1 ) ;
k + = 6 ;
}
2009-12-05 09:22:43 +00:00
2011-06-24 11:16:12 +00:00
if ( k < ydim - 12 )
k + = 6 ;
2009-12-17 11:17:48 +00:00
2010-08-02 08:13:51 +00:00
for ( i = 10 ; i > = 0 ; i - - )
if ( rts_lumplockbyte [ i ] > = 200 )
{
2011-06-24 11:16:12 +00:00
if ( k > = ydim - 12 )
break ;
2010-08-02 08:13:51 +00:00
Bsprintf ( tempbuf , " RTS Locked %d: " , i ) ;
2012-03-10 21:22:22 +00:00
printext256 ( 0 , k , 31 , - 1 , tempbuf , 1 ) ;
2010-08-02 08:13:51 +00:00
k + = 6 ;
}
2011-06-24 11:16:12 +00:00
if ( k > = ydim - 12 & & k < ydim - 6 )
2012-03-10 21:22:22 +00:00
printext256 ( 0 , k , 31 , - 1 , " (MORE . . .) " , 1 ) ;
// sounds
if ( xdim < 640 )
return ;
k = 18 ;
for ( i = 0 ; i < = g_maxSoundPos ; i + + )
if ( g_sounds [ i ] . num > 0 )
{
int32_t j , n = g_sounds [ i ] . num ;
for ( j = 0 ; j < n ; j + + )
{
if ( k > = ydim - 12 )
break ;
Bsprintf ( tempbuf , " snd #%d inst %d: voice %d, ow %d " , i , j ,
2012-03-10 21:22:44 +00:00
g_sounds [ i ] . SoundOwner [ j ] . voice , g_sounds [ i ] . SoundOwner [ j ] . ow ) ;
2012-03-10 21:22:22 +00:00
printext256 ( 240 , k , 31 , - 1 , tempbuf , 0 ) ;
k + = 9 ;
}
}
2010-08-02 08:13:51 +00:00
}
2009-12-17 11:17:48 +00:00
2010-08-02 08:13:51 +00:00
int32_t A_CheckInventorySprite ( spritetype * s )
{
2012-01-28 14:38:23 +00:00
switch ( DYNAMICTILEMAP ( s - > picnum ) )
2009-12-17 11:17:48 +00:00
{
2010-08-02 08:13:51 +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 ;
default :
return 0 ;
2009-12-17 11:17:48 +00:00
}
2009-12-05 09:22:43 +00:00
}
2012-08-16 21:48:08 +00:00
static void G_DrawTileGeneric ( int32_t x , int32_t y , int32_t zoom , int32_t tilenum ,
int32_t shade , int32_t orientation , int32_t p )
2009-12-05 09:22:43 +00:00
{
2012-08-16 21:48:08 +00:00
int32_t a = 0 ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
if ( orientation & 4 )
a = 1024 ;
2009-12-05 09:22:43 +00:00
2012-02-04 21:35:00 +00:00
rotatesprite_win ( ( orientation & ROTATESPRITE_MAX ) ? x : ( x < < 16 ) , ( orientation & ROTATESPRITE_MAX ) ? y : ( y < < 16 ) ,
2012-08-16 21:48:08 +00:00
zoom , a , tilenum , shade , p , 2 | orientation ) ;
2009-12-05 09:22:43 +00:00
}
2012-08-16 21:48:08 +00:00
void G_DrawTile ( int32_t x , int32_t y , int32_t tilenum , int32_t shade , int32_t orientation )
2009-12-05 09:22:43 +00:00
{
2012-08-16 21:48:08 +00:00
DukePlayer_t * ps = g_player [ screenpeek ] . ps ;
int32_t p = ps - > cursectnum > = 0 ? sector [ ps - > cursectnum ] . floorpal : 0 ;
2009-12-05 09:22:43 +00:00
2012-08-16 21:48:08 +00:00
G_DrawTileGeneric ( x , y , 65536 , tilenum , shade , orientation , p ) ;
}
2009-12-14 20:14:12 +00:00
2012-08-16 21:48:08 +00:00
void G_DrawTilePal ( int32_t x , int32_t y , int32_t tilenum , int32_t shade , int32_t orientation , int32_t p )
{
G_DrawTileGeneric ( x , y , 65536 , tilenum , shade , orientation , p ) ;
2010-08-02 08:13:51 +00:00
}
2009-12-14 20:14:12 +00:00
2010-08-02 08:13:51 +00:00
void G_DrawTileSmall ( int32_t x , int32_t y , int32_t tilenum , int32_t shade , int32_t orientation )
{
2012-08-16 21:48:08 +00:00
DukePlayer_t * ps = g_player [ screenpeek ] . ps ;
int32_t p = ps - > cursectnum > = 0 ? sector [ ps - > cursectnum ] . floorpal : 0 ;
2009-12-14 20:14:12 +00:00
2012-08-16 21:48:08 +00:00
G_DrawTileGeneric ( x , y , 32768 , tilenum , shade , orientation , p ) ;
2009-12-14 20:14:12 +00:00
}
2010-08-02 08:13:51 +00:00
void G_DrawTilePalSmall ( int32_t x , int32_t y , int32_t tilenum , int32_t shade , int32_t orientation , int32_t p )
2009-12-14 20:14:12 +00:00
{
2012-08-16 21:48:08 +00:00
G_DrawTileGeneric ( x , y , 32768 , tilenum , shade , orientation , p ) ;
2010-08-02 08:13:51 +00:00
}
2009-12-15 05:53:15 +00:00
2010-08-02 08:13:51 +00:00
# define POLYMOSTTRANS (1)
# define POLYMOSTTRANS2 (1|32)
2009-12-14 20:14:12 +00:00
2012-08-20 21:28:48 +00:00
// Draws inventory numbers in the HUD for both the full and mini status bars.
// yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords.
static void G_DrawInvNum ( int32_t x , int32_t yofs , int32_t y , char num1 , char ha , int32_t sbits )
2010-08-02 08:13:51 +00:00
{
2012-08-16 21:48:08 +00:00
char dabuf [ 16 ] ;
2012-02-04 21:34:22 +00:00
int32_t i , shd = ( x < 0 ) ;
2009-12-14 20:14:12 +00:00
2012-08-16 21:48:08 +00:00
const int32_t sbscale = sbarsc ( 65536 ) ;
2012-08-20 21:28:48 +00:00
const int32_t sby = yofs + sbary ( y ) , sbyp1 = yofs + sbary ( y + 1 ) ;
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
if ( shd ) x = - x ;
2009-12-14 20:14:12 +00:00
2012-08-16 21:48:08 +00:00
Bsprintf ( dabuf , " %d " , num1 ) ;
2010-08-02 08:13:51 +00:00
if ( num1 > 99 )
{
if ( shd & & ud . screen_size = = 4 & & getrendermode ( ) > = 3 & & althud_shadows )
2009-12-14 20:14:12 +00:00
{
2012-02-04 21:34:22 +00:00
for ( i = 0 ; i < = 2 ; i + + )
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + ( - 4 + 4 * i ) + 1 ) , sbyp1 , sbscale , 0 , THREEBYFIVE + dabuf [ i ] - ' 0 ' ,
ha , 4 , POLYMOSTTRANS | sbits ) ;
2010-08-02 08:13:51 +00:00
}
2012-02-04 21:34:22 +00:00
for ( i = 0 ; i < = 2 ; i + + )
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + ( - 4 + 4 * i ) ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ i ] - ' 0 ' , ha , 0 , sbits ) ;
2010-08-02 08:13:51 +00:00
return ;
}
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
if ( num1 > 9 )
{
if ( shd & & ud . screen_size = = 4 & & getrendermode ( ) > = 3 & & althud_shadows )
{
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 1 ) , sbyp1 , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 4 , POLYMOSTTRANS | sbits ) ;
rotatesprite_fs ( sbarx ( x + 4 + 1 ) , sbyp1 , sbscale , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 4 , POLYMOSTTRANS | sbits ) ;
2009-12-14 20:14:12 +00:00
}
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , sbits ) ;
rotatesprite_fs ( sbarx ( x + 4 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , sbits ) ;
2010-08-02 08:13:51 +00:00
return ;
2009-12-14 20:14:12 +00:00
}
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 4 + 1 ) , sbyp1 , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 4 , sbits ) ;
rotatesprite_fs ( sbarx ( x + 4 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , sbits ) ;
2009-12-14 20:14:12 +00:00
}
2010-08-02 08:13:51 +00:00
static void G_DrawWeapNum ( int16_t ind , int32_t x , int32_t y , int32_t num1 , int32_t num2 , int32_t ha )
2009-12-14 20:14:12 +00:00
{
2012-08-16 21:48:08 +00:00
char dabuf [ 16 ] ;
const int32_t sbscale = sbarsc ( 65536 ) ;
const int32_t sby = sbary ( y ) ;
2009-12-14 20:14:12 +00:00
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x - 7 ) , sby , sbscale , 0 , THREEBYFIVE + ind + 1 , ha - 10 , 7 , 10 ) ;
rotatesprite_fs ( sbarx ( x - 3 ) , sby , sbscale , 0 , THREEBYFIVE + 10 , ha , 0 , 10 ) ;
2009-12-14 20:14:12 +00:00
2010-08-02 08:13:51 +00:00
if ( VOLUMEONE & & ( ind > HANDBOMB_WEAPON | | ind < 0 ) )
2009-12-14 20:14:12 +00:00
{
2010-08-02 08:13:51 +00:00
minitextshade ( x + 1 , y - 4 , " ORDER " , 20 , 11 , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
return ;
2009-12-14 20:14:12 +00:00
}
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 9 ) , sby , sbscale , 0 , THREEBYFIVE + 11 , ha , 0 , 10 ) ;
2009-12-14 20:14:12 +00:00
2010-08-02 08:13:51 +00:00
if ( num1 > 99 ) num1 = 99 ;
if ( num2 > 99 ) num2 = 99 ;
2009-12-14 20:14:12 +00:00
2010-08-02 08:13:51 +00:00
Bsprintf ( dabuf , " %d " , num1 ) ;
if ( num1 > 9 )
2009-12-14 20:14:12 +00:00
{
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 4 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-08-02 08:13:51 +00:00
}
2012-08-16 21:48:08 +00:00
else rotatesprite_fs ( sbarx ( x + 4 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-07-19 15:14:00 +00:00
2010-08-02 08:13:51 +00:00
Bsprintf ( dabuf , " %d " , num2 ) ;
if ( num2 > 9 )
{
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 13 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 17 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-08-02 08:13:51 +00:00
return ;
2009-12-14 20:14:12 +00:00
}
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 13 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
2009-12-14 20:14:12 +00:00
}
2010-08-02 08:13:51 +00:00
static void G_DrawWeapNum2 ( char ind , int32_t x , int32_t y , int32_t num1 , int32_t num2 , char ha )
2010-07-22 20:29:09 +00:00
{
2012-08-16 21:48:08 +00:00
char dabuf [ 16 ] ;
const int32_t sbscale = sbarsc ( 65536 ) ;
const int32_t sby = sbary ( y ) ;
2010-07-22 20:29:09 +00:00
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x - 7 ) , sby , sbscale , 0 , THREEBYFIVE + ind + 1 , ha - 10 , 7 , 10 ) ;
rotatesprite_fs ( sbarx ( x - 4 ) , sby , sbscale , 0 , THREEBYFIVE + 10 , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 13 ) , sby , sbscale , 0 , THREEBYFIVE + 11 , ha , 0 , 10 ) ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
Bsprintf ( dabuf , " %d " , num1 ) ;
if ( num1 > 99 )
2010-07-22 20:29:09 +00:00
{
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 4 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 8 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 2 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-07-22 20:29:09 +00:00
}
2010-08-02 08:13:51 +00:00
else if ( num1 > 9 )
2010-07-22 20:29:09 +00:00
{
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 4 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 8 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-07-22 20:29:09 +00:00
}
2012-08-16 21:48:08 +00:00
else rotatesprite_fs ( sbarx ( x + 8 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-08-02 08:13:51 +00:00
Bsprintf ( dabuf , " %d " , num2 ) ;
if ( num2 > 99 )
2010-07-22 20:29:09 +00:00
{
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 17 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 21 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 25 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 2 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-07-22 20:29:09 +00:00
}
2010-08-02 08:13:51 +00:00
else if ( num2 > 9 )
2010-07-22 20:29:09 +00:00
{
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 17 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
rotatesprite_fs ( sbarx ( x + 21 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 1 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-08-02 08:13:51 +00:00
return ;
2010-07-22 20:29:09 +00:00
}
2010-08-02 08:13:51 +00:00
else
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( x + 25 ) , sby , sbscale , 0 , THREEBYFIVE + dabuf [ 0 ] - ' 0 ' , ha , 0 , 10 ) ;
2010-08-02 08:13:51 +00:00
}
2010-07-22 20:29:09 +00:00
2012-08-16 21:48:08 +00:00
static void G_DrawWeapAmounts ( const DukePlayer_t * p , int32_t x , int32_t y , int32_t u )
2010-08-02 08:13:51 +00:00
{
int32_t cw = p - > curr_weapon ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
if ( u & 4 )
{
if ( u ! = - 1 ) G_PatchStatusBar ( 88 , 178 , 88 + 37 , 178 + 6 ) ; //original code: (96,178,96+12,178+6);
G_DrawWeapNum2 ( PISTOL_WEAPON , x , y ,
p - > ammo_amount [ PISTOL_WEAPON ] , p - > max_ammo_amount [ PISTOL_WEAPON ] ,
12 - 20 * ( cw = = PISTOL_WEAPON ) ) ;
}
if ( u & 8 )
{
if ( u ! = - 1 ) G_PatchStatusBar ( 88 , 184 , 88 + 37 , 184 + 6 ) ; //original code: (96,184,96+12,184+6);
G_DrawWeapNum2 ( SHOTGUN_WEAPON , x , y + 6 ,
p - > ammo_amount [ SHOTGUN_WEAPON ] , p - > max_ammo_amount [ SHOTGUN_WEAPON ] ,
( ( ( p - > gotweapon & ( 1 < < SHOTGUN_WEAPON ) ) = = 0 ) * 9 ) + 12 - 18 *
( cw = = SHOTGUN_WEAPON ) ) ;
}
if ( u & 16 )
{
if ( u ! = - 1 ) G_PatchStatusBar ( 88 , 190 , 88 + 37 , 190 + 6 ) ; //original code: (96,190,96+12,190+6);
G_DrawWeapNum2 ( CHAINGUN_WEAPON , x , y + 12 ,
p - > ammo_amount [ CHAINGUN_WEAPON ] , p - > max_ammo_amount [ CHAINGUN_WEAPON ] ,
( ( ( p - > gotweapon & ( 1 < < CHAINGUN_WEAPON ) ) = = 0 ) * 9 ) + 12 - 18 *
( cw = = CHAINGUN_WEAPON ) ) ;
}
if ( u & 32 )
{
if ( u ! = - 1 ) G_PatchStatusBar ( 127 , 178 , 127 + 29 , 178 + 6 ) ; //original code: (135,178,135+8,178+6);
G_DrawWeapNum ( RPG_WEAPON , x + 39 , y ,
p - > ammo_amount [ RPG_WEAPON ] , p - > max_ammo_amount [ RPG_WEAPON ] ,
( ( ( p - > gotweapon & ( 1 < < RPG_WEAPON ) ) = = 0 ) * 9 ) + 12 - 19 *
( cw = = RPG_WEAPON ) ) ;
}
if ( u & 64 )
{
if ( u ! = - 1 ) G_PatchStatusBar ( 127 , 184 , 127 + 29 , 184 + 6 ) ; //original code: (135,184,135+8,184+6);
G_DrawWeapNum ( HANDBOMB_WEAPON , x + 39 , y + 6 ,
p - > ammo_amount [ HANDBOMB_WEAPON ] , p - > max_ammo_amount [ HANDBOMB_WEAPON ] ,
( ( ( ! p - > ammo_amount [ HANDBOMB_WEAPON ] ) | ( ( p - > gotweapon & ( 1 < < HANDBOMB_WEAPON ) ) = = 0 ) ) * 9 ) + 12 - 19 *
( ( cw = = HANDBOMB_WEAPON ) | | ( cw = = HANDREMOTE_WEAPON ) ) ) ;
}
if ( u & 128 )
{
if ( u ! = - 1 ) G_PatchStatusBar ( 127 , 190 , 127 + 29 , 190 + 6 ) ; //original code: (135,190,135+8,190+6);
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
if ( p - > subweapon & ( 1 < < GROW_WEAPON ) )
G_DrawWeapNum ( SHRINKER_WEAPON , x + 39 , y + 12 ,
p - > ammo_amount [ GROW_WEAPON ] , p - > max_ammo_amount [ GROW_WEAPON ] ,
( ( ( p - > gotweapon & ( 1 < < GROW_WEAPON ) ) = = 0 ) * 9 ) + 12 - 18 *
( cw = = GROW_WEAPON ) ) ;
else
G_DrawWeapNum ( SHRINKER_WEAPON , x + 39 , y + 12 ,
p - > ammo_amount [ SHRINKER_WEAPON ] , p - > max_ammo_amount [ SHRINKER_WEAPON ] ,
( ( ( p - > gotweapon & ( 1 < < SHRINKER_WEAPON ) ) = = 0 ) * 9 ) + 12 - 18 *
( cw = = SHRINKER_WEAPON ) ) ;
}
if ( u & 256 )
{
if ( u ! = - 1 ) G_PatchStatusBar ( 158 , 178 , 162 + 29 , 178 + 6 ) ; //original code: (166,178,166+8,178+6);
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
G_DrawWeapNum ( DEVISTATOR_WEAPON , x + 70 , y ,
p - > ammo_amount [ DEVISTATOR_WEAPON ] , p - > max_ammo_amount [ DEVISTATOR_WEAPON ] ,
( ( ( p - > gotweapon & ( 1 < < DEVISTATOR_WEAPON ) ) = = 0 ) * 9 ) + 12 - 18 *
( cw = = DEVISTATOR_WEAPON ) ) ;
}
if ( u & 512 )
2010-07-22 20:29:09 +00:00
{
2010-08-02 08:13:51 +00:00
if ( u ! = - 1 ) G_PatchStatusBar ( 158 , 184 , 162 + 29 , 184 + 6 ) ; //original code: (166,184,166+8,184+6);
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
G_DrawWeapNum ( TRIPBOMB_WEAPON , x + 70 , y + 6 ,
p - > ammo_amount [ TRIPBOMB_WEAPON ] , p - > max_ammo_amount [ TRIPBOMB_WEAPON ] ,
( ( ( p - > gotweapon & ( 1 < < TRIPBOMB_WEAPON ) ) = = 0 ) * 9 ) + 12 - 18 *
( cw = = TRIPBOMB_WEAPON ) ) ;
}
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
if ( u & 65536L )
{
if ( u ! = - 1 ) G_PatchStatusBar ( 158 , 190 , 162 + 29 , 190 + 6 ) ; //original code: (166,190,166+8,190+6);
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
G_DrawWeapNum ( - 1 , x + 70 , y + 12 ,
p - > ammo_amount [ FREEZE_WEAPON ] , p - > max_ammo_amount [ FREEZE_WEAPON ] ,
( ( ( p - > gotweapon & ( 1 < < FREEZE_WEAPON ) ) = = 0 ) * 9 ) + 12 - 18 *
( cw = = FREEZE_WEAPON ) ) ;
2010-07-22 20:29:09 +00:00
}
}
2012-08-20 21:28:48 +00:00
// yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords.
static void G_DrawDigiNum_ ( int32_t x , int32_t yofs , int32_t y , int32_t n , char s , int32_t cs )
2010-07-22 20:29:09 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t i , j = 0 , k , p , c ;
2011-10-30 19:46:51 +00:00
char b [ 12 ] ;
2010-07-22 20:29:09 +00:00
2011-10-30 19:46:51 +00:00
i = Bsprintf ( b , " %d " , n ) ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
for ( k = i - 1 ; k > = 0 ; k - - )
{
2012-03-28 19:45:25 +00:00
p = DIGITALNUM + b [ k ] - ' 0 ' ;
2010-08-02 08:13:51 +00:00
j + = tilesizx [ p ] + 1 ;
}
c = x - ( j > > 1 ) ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
j = 0 ;
for ( k = 0 ; k < i ; k + + )
2010-07-22 20:29:09 +00:00
{
2012-03-28 19:45:25 +00:00
p = DIGITALNUM + b [ k ] - ' 0 ' ;
2012-08-20 21:28:48 +00:00
rotatesprite_fs ( sbarx ( c + j ) , yofs + sbary ( y ) , sbarsc ( 65536 ) , 0 , p , s , 0 , cs ) ;
2010-08-02 08:13:51 +00:00
j + = tilesizx [ p ] + 1 ;
2010-07-22 20:29:09 +00:00
}
2010-08-02 08:13:51 +00:00
}
2012-08-20 21:28:48 +00:00
static inline void G_DrawDigiNum ( int32_t x , int32_t y , int32_t n , char s , int32_t cs )
{
G_DrawDigiNum_ ( x , 0 , y , n , s , cs ) ;
}
2010-08-02 08:13:51 +00:00
void G_DrawTXDigiNumZ ( int32_t starttile , int32_t x , int32_t y , int32_t n , int32_t s , int32_t pal ,
int32_t cs , int32_t x1 , int32_t y1 , int32_t x2 , int32_t y2 , int32_t z )
{
int32_t i , j = 0 , k , p , c ;
2011-10-30 19:46:51 +00:00
char b [ 12 ] ;
2010-08-02 08:13:51 +00:00
int32_t shift = ( cs & ROTATESPRITE_MAX ) ? 0 : 16 ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
//ltoa(n,b,10);
2011-10-30 19:46:51 +00:00
i = Bsprintf ( b , " %d " , n ) ;
2010-08-02 08:13:51 +00:00
for ( k = i - 1 ; k > = 0 ; k - - )
2010-07-22 20:29:09 +00:00
{
2011-10-30 19:46:51 +00:00
p = starttile + b [ k ] - ' 0 ' ;
2010-12-03 06:50:16 +00:00
j + = ( ( 1 + tilesizx [ p ] ) * z ) > > 16 ;
2010-07-22 20:29:09 +00:00
}
2010-08-02 08:13:51 +00:00
if ( cs & ROTATESPRITE_MAX ) j < < = 16 ;
c = x - ( j > > 1 ) ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
j = 0 ;
for ( k = 0 ; k < i ; k + + )
2010-07-22 20:29:09 +00:00
{
2011-10-30 19:46:51 +00:00
p = starttile + b [ k ] - ' 0 ' ;
2010-08-02 08:13:51 +00:00
rotatesprite ( ( c + j ) < < shift , y < < shift , z , 0 , p , s , pal , 2 | cs , x1 , y1 , x2 , y2 ) ;
2010-12-03 06:50:16 +00:00
j + = ( ( ( 1 + tilesizx [ p ] ) * z ) > > ( ( cs & ROTATESPRITE_MAX ) ? 0 : 16 ) ) ;
2010-07-22 20:29:09 +00:00
}
2010-08-02 08:13:51 +00:00
}
2012-03-28 19:45:25 +00:00
static void G_DrawAltDigiNum ( int32_t x , int32_t y , int32_t n , char s , int32_t cs )
2010-08-02 08:13:51 +00:00
{
int32_t i , j = 0 , k , p , c ;
2011-10-30 19:46:51 +00:00
char b [ 12 ] ;
2010-08-02 08:13:51 +00:00
int32_t rev = ( x < 0 ) ;
int32_t shd = ( y < 0 ) ;
2010-07-22 20:29:09 +00:00
2012-08-16 21:48:08 +00:00
const int32_t sbscale = sbarsc ( 65536 ) ;
2010-08-02 08:13:51 +00:00
if ( rev ) x = - x ;
if ( shd ) y = - y ;
2010-07-22 20:29:09 +00:00
2011-10-30 19:46:51 +00:00
i = Bsprintf ( b , " %d " , n ) ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
for ( k = i - 1 ; k > = 0 ; k - - )
2010-07-22 20:29:09 +00:00
{
2012-03-28 19:45:25 +00:00
p = althud_numbertile + b [ k ] - ' 0 ' ;
2010-08-02 08:13:51 +00:00
j + = tilesizx [ p ] + 1 ;
}
c = x - ( j > > 1 ) ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
if ( rev )
{
for ( k = 0 ; k < i ; k + + )
2010-07-22 20:29:09 +00:00
{
2012-03-28 19:45:25 +00:00
p = althud_numbertile + b [ k ] - ' 0 ' ;
2010-08-02 08:13:51 +00:00
if ( shd & & getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarxr ( c + j - 1 ) , sbary ( y + 1 ) , sbscale , 0 , p , s , 4 , cs | POLYMOSTTRANS2 ) ;
rotatesprite_fs ( sbarxr ( c + j ) , sbary ( y ) , sbscale , 0 , p , s , althud_numberpal , cs ) ;
2010-08-02 08:13:51 +00:00
j - = tilesizx [ p ] + 1 ;
2010-07-22 20:29:09 +00:00
}
2010-08-02 08:13:51 +00:00
return ;
}
2012-03-28 19:45:25 +00:00
2010-08-02 08:13:51 +00:00
j = 0 ;
for ( k = 0 ; k < i ; k + + )
{
2012-03-28 19:45:25 +00:00
p = althud_numbertile + b [ k ] - ' 0 ' ;
2010-08-02 08:13:51 +00:00
if ( shd & & getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( c + j + 1 ) , sbary ( y + 1 ) , sbscale , 0 , p , s , 4 , cs | POLYMOSTTRANS2 ) ;
rotatesprite_fs ( sbarx ( c + j ) , sbary ( y ) , sbscale , 0 , p , s , althud_numberpal , cs ) ;
2010-08-02 08:13:51 +00:00
j + = tilesizx [ p ] + 1 ;
2010-07-22 20:29:09 +00:00
}
}
2012-08-16 21:48:08 +00:00
static void G_DrawInventory ( const DukePlayer_t * p )
2009-12-05 09:22:43 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t n , j = 0 , xoff = 0 , y ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
n = ( p - > inv_amount [ GET_JETPACK ] > 0 ) < < 3 ;
if ( n & 8 ) j + + ;
n | = ( p - > inv_amount [ GET_SCUBA ] > 0 ) < < 5 ;
if ( n & 32 ) j + + ;
n | = ( p - > inv_amount [ GET_STEROIDS ] > 0 ) < < 1 ;
if ( n & 2 ) j + + ;
n | = ( p - > inv_amount [ GET_HOLODUKE ] > 0 ) < < 2 ;
if ( n & 4 ) j + + ;
n | = ( p - > inv_amount [ GET_FIRSTAID ] > 0 ) ;
if ( n & 1 ) j + + ;
n | = ( p - > inv_amount [ GET_HEATS ] > 0 ) < < 4 ;
if ( n & 16 ) j + + ;
n | = ( p - > inv_amount [ GET_BOOTS ] > 0 ) < < 6 ;
if ( n & 64 ) j + + ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
xoff = 160 - ( j * 11 ) ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
j = 0 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
y = 154 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
while ( j < = 9 )
{
if ( n & ( 1 < < j ) )
2010-01-23 22:12:02 +00:00
{
2010-08-02 08:13:51 +00:00
switch ( n & ( 1 < < j ) )
2010-01-23 22:12:02 +00:00
{
2010-08-02 08:13:51 +00:00
case 1 :
2012-02-04 21:35:00 +00:00
rotatesprite_win ( xoff < < 16 , y < < 16 , 65536L , 0 , FIRSTAID_ICON , 0 , 0 , 2 + 16 ) ;
2010-08-02 08:13:51 +00:00
break ;
case 2 :
2012-02-04 21:35:00 +00:00
rotatesprite_win ( ( xoff + 1 ) < < 16 , y < < 16 , 65536L , 0 , STEROIDS_ICON , 0 , 0 , 2 + 16 ) ;
2010-08-02 08:13:51 +00:00
break ;
case 4 :
2012-02-04 21:35:00 +00:00
rotatesprite_win ( ( xoff + 2 ) < < 16 , y < < 16 , 65536L , 0 , HOLODUKE_ICON , 0 , 0 , 2 + 16 ) ;
2010-08-02 08:13:51 +00:00
break ;
case 8 :
2012-02-04 21:35:00 +00:00
rotatesprite_win ( xoff < < 16 , y < < 16 , 65536L , 0 , JETPACK_ICON , 0 , 0 , 2 + 16 ) ;
2010-08-02 08:13:51 +00:00
break ;
case 16 :
2012-02-04 21:35:00 +00:00
rotatesprite_win ( xoff < < 16 , y < < 16 , 65536L , 0 , HEAT_ICON , 0 , 0 , 2 + 16 ) ;
2010-08-02 08:13:51 +00:00
break ;
case 32 :
2012-02-04 21:35:00 +00:00
rotatesprite_win ( xoff < < 16 , y < < 16 , 65536L , 0 , AIRTANK_ICON , 0 , 0 , 2 + 16 ) ;
2010-08-02 08:13:51 +00:00
break ;
case 64 :
2012-02-04 21:35:00 +00:00
rotatesprite_win ( xoff < < 16 , ( y - 1 ) < < 16 , 65536L , 0 , BOOT_ICON , 0 , 0 , 2 + 16 ) ;
2010-08-02 08:13:51 +00:00
break ;
2010-01-23 22:12:02 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
xoff + = 22 ;
2009-12-30 23:07:00 +00:00
2010-08-02 08:13:51 +00:00
if ( p - > inven_icon = = j + 1 )
2012-02-04 21:35:00 +00:00
rotatesprite_win ( ( xoff - 2 ) < < 16 , ( y + 19 ) < < 16 , 65536L , 1024 , ARROW , - 32 , 0 , 2 + 16 ) ;
2010-08-02 08:13:51 +00:00
}
2009-12-30 23:07:00 +00:00
2010-08-02 08:13:51 +00:00
j + + ;
}
}
2009-12-17 11:17:48 +00:00
2010-08-02 08:13:51 +00:00
void G_DrawFrags ( void )
{
int32_t i , j = 0 ;
2012-08-16 21:48:08 +00:00
const int32_t orient = 2 + 8 + 16 + 64 ;
2006-04-13 20:47:06 +00:00
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( i ) )
2012-08-16 21:48:08 +00:00
if ( i > j )
j = i ;
2009-12-15 05:53:15 +00:00
2012-08-16 21:48:08 +00:00
for ( i = 0 ; i < = ( j > > 2 ) ; i + + )
rotatesprite_fs ( 0 , ( 8 * i ) < < 16 , 65600 , 0 , FRAGBAR , 0 , 0 , orient ) ;
2009-12-15 05:53:15 +00:00
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( i ) )
2010-08-02 08:13:51 +00:00
{
2012-08-16 21:48:08 +00:00
const DukePlayer_t * ps = g_player [ i ] . ps ;
minitext ( 21 + ( 73 * ( i & 3 ) ) , 2 + ( ( i & 28 ) < < 1 ) , g_player [ i ] . user_name , ps - > palookup , 2 + 8 + 16 ) ;
Bsprintf ( tempbuf , " %d " , ps - > frag - ps - > fraggedself ) ;
minitext ( 17 + 50 + ( 73 * ( i & 3 ) ) , 2 + ( ( i & 28 ) < < 1 ) , tempbuf , ps - > palookup , 2 + 8 + 16 ) ;
2010-08-02 08:13:51 +00:00
}
}
2009-12-15 05:53:15 +00:00
2012-08-16 21:48:08 +00:00
static int32_t G_GetInvAmount ( const DukePlayer_t * p )
{
switch ( p - > inven_icon )
{
2012-11-04 23:41:05 +00:00
case ICON_FIRSTAID :
2012-08-16 21:48:08 +00:00
return p - > inv_amount [ GET_FIRSTAID ] ;
2012-11-04 23:41:05 +00:00
case ICON_STEROIDS :
2012-08-16 21:48:08 +00:00
return ( ( p - > inv_amount [ GET_STEROIDS ] + 3 ) > > 2 ) ;
2012-11-04 23:41:05 +00:00
case ICON_HOLODUKE :
2012-08-16 21:48:08 +00:00
return ( ( p - > inv_amount [ GET_HOLODUKE ] + 15 ) / 24 ) ;
2012-11-04 23:41:05 +00:00
case ICON_JETPACK :
2012-08-16 21:48:08 +00:00
return ( ( p - > inv_amount [ GET_JETPACK ] + 15 ) > > 4 ) ;
2012-11-04 23:41:05 +00:00
case ICON_HEATS :
2012-08-16 21:48:08 +00:00
return p - > inv_amount [ GET_HEATS ] / 12 ;
2012-11-04 23:41:05 +00:00
case ICON_SCUBA :
2012-08-16 21:48:08 +00:00
return ( ( p - > inv_amount [ GET_SCUBA ] + 63 ) > > 6 ) ;
2012-11-04 23:41:05 +00:00
case ICON_BOOTS :
2012-08-16 21:48:08 +00:00
return ( p - > inv_amount [ GET_BOOTS ] > > 1 ) ;
}
return - 1 ;
}
static int32_t G_GetInvOn ( const DukePlayer_t * p )
{
switch ( p - > inven_icon )
{
2012-11-04 23:41:05 +00:00
case ICON_HOLODUKE :
2012-08-16 21:48:08 +00:00
return p - > holoduke_on ;
2012-11-04 23:41:05 +00:00
case ICON_JETPACK :
2012-08-16 21:48:08 +00:00
return p - > jetpack_on ;
2012-11-04 23:41:05 +00:00
case ICON_HEATS :
2012-08-16 21:48:08 +00:00
return p - > heat_on ;
}
return 0x80000000 ;
}
2009-12-17 11:17:48 +00:00
2010-08-02 08:13:51 +00:00
static void G_DrawStatusBar ( int32_t snum )
{
2012-08-16 21:48:08 +00:00
const DukePlayer_t * const p = g_player [ snum ] . ps ;
2012-08-16 21:48:21 +00:00
int32_t i , j , o , u ;
2010-08-02 08:13:51 +00:00
int32_t permbit = 0 ;
2009-12-17 11:17:48 +00:00
2012-08-20 21:28:48 +00:00
const int32_t ss = g_fakeMultiMode ? 4 : ud . screen_size ;
2012-08-16 21:48:21 +00:00
const int32_t althud = g_fakeMultiMode ? 0 : ud . althud ;
2012-08-16 21:48:08 +00:00
const int32_t SBY = ( 200 - tilesizy [ BOTTOMSTATUSBAR ] ) ;
const int32_t sb15 = sbarsc ( 32768 ) , sb15h = sbarsc ( 49152 ) ;
const int32_t sb16 = sbarsc ( 65536 ) ;
static int32_t item_icons [ 8 ] ;
if ( ss < 4 )
return ;
if ( item_icons [ 0 ] = = 0 )
{
int32_t iicons [ 8 ] = { - 1 , FIRSTAID_ICON , STEROIDS_ICON , HOLODUKE_ICON ,
JETPACK_ICON , HEAT_ICON , AIRTANK_ICON , BOOT_ICON } ;
Bmemcpy ( item_icons , iicons , sizeof ( item_icons ) ) ;
}
2009-12-17 11:17:48 +00:00
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 ) pus = NUMPAGES ; // JBF 20040101: always redraw in GL
2010-07-22 20:29:09 +00:00
2012-08-16 21:48:23 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) & & ( ( GametypeFlags [ ud . coop ] & GAMETYPE_FRAGBAR ) | | g_fakeMultiMode ) )
2010-08-02 08:13:51 +00:00
{
if ( pus )
G_DrawFrags ( ) ;
else
{
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( i ) )
if ( g_player [ i ] . ps - > frag ! = sbar . frag [ i ] )
{
G_DrawFrags ( ) ;
break ;
}
2009-12-12 11:07:59 +00:00
2010-08-02 08:13:51 +00:00
}
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( i ) )
if ( i ! = myconnectindex )
sbar . frag [ i ] = g_player [ i ] . ps - > frag ;
2010-08-02 08:13:51 +00:00
}
2009-12-12 11:07:59 +00:00
2010-08-02 08:13:51 +00:00
if ( ss = = 4 ) //DRAW MINI STATUS BAR:
{
2012-08-16 21:48:21 +00:00
if ( althud )
2010-08-02 08:13:51 +00:00
{
2012-08-16 21:48:21 +00:00
// ALTERNATIVE STATUS BAR
2010-08-02 08:13:51 +00:00
static int32_t ammo_sprites [ MAX_WEAPONS ] ;
2009-12-12 11:07:59 +00:00
2012-08-16 21:48:08 +00:00
if ( ammo_sprites [ 0 ] = = 0 )
2010-01-23 22:12:02 +00:00
{
2010-08-02 08:13:51 +00:00
/* this looks stupid but it lets us initialize static memory to dynamic values
these values can be changed from the CONs with dynamic tile remapping
but we don ' t want to have to recreate the values in memory every time
the HUD is drawn */
2009-12-05 09:22:43 +00:00
2012-08-16 21:48:08 +00:00
int32_t asprites [ MAX_WEAPONS ] = { BOOTS , AMMO , SHOTGUNAMMO , BATTERYAMMO ,
RPGAMMO , HBOMBAMMO , CRYSTALAMMO , DEVISTATORAMMO ,
2010-08-02 08:13:51 +00:00
TRIPBOMBSPRITE , FREEZEAMMO + 1 , HBOMBAMMO , GROWAMMO
} ;
2012-08-16 21:48:08 +00:00
Bmemcpy ( ammo_sprites , asprites , sizeof ( ammo_sprites ) ) ;
2010-01-23 22:12:02 +00:00
}
2008-11-20 14:06:36 +00:00
2012-08-16 21:48:08 +00:00
// rotatesprite_fs(sbarx(5+1),sbary(200-25+1),sb15h,0,SIXPAK,0,4,10+16+1+32);
// rotatesprite_fs(sbarx(5),sbary(200-25),sb15h,0,SIXPAK,0,0,10+16);
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( 2 + 1 ) , sbary ( 200 - 21 + 1 ) , sb15h , 0 , COLA , 0 , 4 , 10 + 16 + 256 + POLYMOSTTRANS2 ) ;
rotatesprite_fs ( sbarx ( 2 ) , sbary ( 200 - 21 ) , sb15h , 0 , COLA , 0 , 0 , 10 + 16 + 256 ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( sprite [ p - > i ] . pal = = 1 & & p - > last_extra < 2 )
G_DrawAltDigiNum ( 40 , - ( 200 - 22 ) , 1 , - 16 , 10 + 16 + 256 ) ;
else if ( ! althud_flashing | | p - > last_extra > ( p - > max_player_health > > 2 ) | | totalclock & 32 )
2010-01-23 22:12:02 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t s = - 8 ;
if ( althud_flashing & & p - > last_extra > p - > max_player_health )
s + = ( sintable [ ( totalclock < < 5 ) & 2047 ] > > 10 ) ;
G_DrawAltDigiNum ( 40 , - ( 200 - 22 ) , p - > last_extra , s , 10 + 16 + 256 ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( 62 + 1 ) , sbary ( 200 - 25 + 1 ) , sb15h , 0 , SHIELD , 0 , 4 , 10 + 16 + POLYMOSTTRANS2 + 256 ) ;
rotatesprite_fs ( sbarx ( 62 ) , sbary ( 200 - 25 ) , sb15h , 0 , SHIELD , 0 , 0 , 10 + 16 + 256 ) ;
2009-12-12 11:07:59 +00:00
2010-01-23 22:12:02 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t lAmount = Gv_GetVarByLabel ( " PLR_MORALE " , - 1 , p - > i , snum ) ;
if ( lAmount = = - 1 ) lAmount = p - > inv_amount [ GET_SHIELD ] ;
G_DrawAltDigiNum ( 105 , - ( 200 - 22 ) , lAmount , - 16 , 10 + 16 + 256 ) ;
2010-07-22 20:29:09 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & althud_shadows )
{
2012-08-16 21:48:08 +00:00
if ( p - > got_access & 1 ) rotatesprite_fs ( sbarxr ( 39 - 1 ) , sbary ( 200 - 43 + 1 ) , sb15 , 0 , ACCESSCARD , 0 , 4 , 10 + 16 + POLYMOSTTRANS2 + 512 ) ;
if ( p - > got_access & 4 ) rotatesprite_fs ( sbarxr ( 34 - 1 ) , sbary ( 200 - 41 + 1 ) , sb15 , 0 , ACCESSCARD , 0 , 4 , 10 + 16 + POLYMOSTTRANS2 + 512 ) ;
if ( p - > got_access & 2 ) rotatesprite_fs ( sbarxr ( 29 - 1 ) , sbary ( 200 - 39 + 1 ) , sb15 , 0 , ACCESSCARD , 0 , 4 , 10 + 16 + POLYMOSTTRANS2 + 512 ) ;
2010-08-02 08:13:51 +00:00
}
2006-11-16 03:02:42 +00:00
2012-08-16 21:48:08 +00:00
if ( p - > got_access & 1 ) rotatesprite_fs ( sbarxr ( 39 ) , sbary ( 200 - 43 ) , sb15 , 0 , ACCESSCARD , 0 , 0 , 10 + 16 + 512 ) ;
if ( p - > got_access & 4 ) rotatesprite_fs ( sbarxr ( 34 ) , sbary ( 200 - 41 ) , sb15 , 0 , ACCESSCARD , 0 , 23 , 10 + 16 + 512 ) ;
if ( p - > got_access & 2 ) rotatesprite_fs ( sbarxr ( 29 ) , sbary ( 200 - 39 ) , sb15 , 0 , ACCESSCARD , 0 , 21 , 10 + 16 + 512 ) ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
i = ( p - > curr_weapon = = PISTOL_WEAPON ) ? 16384 : 32768 ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & althud_shadows )
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( sbarxr ( 57 - 1 ) , sbary ( 200 - 15 + 1 ) , sbarsc ( i ) , 0 , ammo_sprites [ p - > curr_weapon ] , 0 , 4 , 10 + POLYMOSTTRANS2 + 512 ) ;
rotatesprite_fs ( sbarxr ( 57 ) , sbary ( 200 - 15 ) , sbarsc ( i ) , 0 , ammo_sprites [ p - > curr_weapon ] , 0 , 0 , 10 + 512 ) ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
if ( p - > curr_weapon = = HANDREMOTE_WEAPON ) i = HANDBOMB_WEAPON ;
else i = p - > curr_weapon ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
if ( p - > curr_weapon ! = KNEE_WEAPON & &
( ! althud_flashing | | totalclock & 32 | | p - > ammo_amount [ i ] > ( p - > max_ammo_amount [ i ] / 10 ) ) )
G_DrawAltDigiNum ( - 20 , - ( 200 - 22 ) , p - > ammo_amount [ i ] , - 16 , 10 + 16 + 512 ) ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
o = 102 ;
permbit = 0 ;
2009-12-12 11:07:59 +00:00
2010-08-02 08:13:51 +00:00
if ( p - > inven_icon )
{
2012-08-16 21:48:08 +00:00
const int32_t orient = 10 + 16 + permbit + 256 ;
2012-11-04 23:41:05 +00:00
i = ( ( unsigned ) p - > inven_icon < ICON_MAX ) ? item_icons [ p - > inven_icon ] : - 1 ;
2010-08-02 08:13:51 +00:00
if ( i > = 0 )
2010-07-22 20:29:09 +00:00
{
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( 231 - o + 1 ) , sbary ( 200 - 21 - 2 + 1 ) , sb16 , 0 , i , 0 , 4 , orient + POLYMOSTTRANS2 ) ;
rotatesprite_fs ( sbarx ( 231 - o ) , sbary ( 200 - 21 - 2 ) , sb16 , 0 , i , 0 , 0 , orient ) ;
2010-07-22 20:29:09 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
minitext ( 292 - 30 - o + 1 , 190 - 3 + 1 , " % " , 4 , POLYMOSTTRANS + orient + ROTATESPRITE_MAX ) ;
minitext ( 292 - 30 - o , 190 - 3 , " % " , 6 , orient + ROTATESPRITE_MAX ) ;
i = G_GetInvAmount ( p ) ;
j = G_GetInvOn ( p ) ;
2006-12-10 06:49:01 +00:00
2012-08-20 21:28:48 +00:00
G_DrawInvNum ( - ( 284 - 30 - o ) , 0 , 200 - 6 - 3 , ( uint8_t ) i , 0 , 10 + permbit + 256 ) ;
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
if ( j > 0 )
{
if ( getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
minitext ( 288 - 30 - o + 1 , 180 - 3 + 1 , " On " , 4 , POLYMOSTTRANS + orient + ROTATESPRITE_MAX ) ;
minitext ( 288 - 30 - o , 180 - 3 , " On " , 0 , orient + ROTATESPRITE_MAX ) ;
2010-08-02 08:13:51 +00:00
}
else if ( ( uint32_t ) j ! = 0x80000000 )
{
if ( getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
minitext ( 284 - 30 - o + 1 , 180 - 3 + 1 , " Off " , 4 , POLYMOSTTRANS + orient + ROTATESPRITE_MAX ) ;
minitext ( 284 - 30 - o , 180 - 3 , " Off " , 2 , orient + ROTATESPRITE_MAX ) ;
2010-08-02 08:13:51 +00:00
}
2008-11-20 14:06:36 +00:00
2012-11-04 23:41:05 +00:00
if ( p - > inven_icon > = ICON_SCUBA )
2010-08-02 08:13:51 +00:00
{
if ( getrendermode ( ) > = 3 & & althud_shadows )
2012-08-16 21:48:08 +00:00
minitext ( 284 - 35 - o + 1 , 180 - 3 + 1 , " Auto " , 4 , POLYMOSTTRANS + orient + ROTATESPRITE_MAX ) ;
minitext ( 284 - 35 - o , 180 - 3 , " Auto " , 2 , orient + ROTATESPRITE_MAX ) ;
2010-08-02 08:13:51 +00:00
}
}
2010-01-23 22:12:02 +00:00
}
2012-08-16 21:48:21 +00:00
else
{
// ORIGINAL MINI STATUS BAR
2012-08-20 21:28:48 +00:00
int32_t orient = 2 + 8 + 16 + 256 , yofs = 0 , yofssh = 0 ;
if ( g_fakeMultiMode )
{
const int32_t sidebyside = ( ud . screen_size ! = 0 ) ;
if ( sidebyside & & snum = = 1 )
{
orient | = RS_CENTERORIGIN ;
}
else if ( ! sidebyside & & snum = = 0 )
{
yofs = - 100 ;
yofssh = yofs < < 16 ;
}
}
2009-08-28 23:08:00 +00:00
2012-08-20 21:28:48 +00:00
rotatesprite_fs ( sbarx ( 5 ) , yofssh + sbary ( 200 - 28 ) , sb16 , 0 , HEALTHBOX , 0 , 21 , orient ) ;
2012-08-16 21:48:21 +00:00
if ( p - > inven_icon )
2012-08-20 21:28:48 +00:00
rotatesprite_fs ( sbarx ( 69 ) , yofssh + sbary ( 200 - 30 ) , sb16 , 0 , INVENTORYBOX , 0 , 21 , orient ) ;
2009-12-17 11:17:48 +00:00
2012-08-16 21:48:26 +00:00
// health
2012-08-19 13:02:37 +00:00
{
int32_t health = ( sprite [ p - > i ] . pal = = 1 & & p - > last_extra < 2 ) ? 1 : p - > last_extra ;
2012-08-20 21:28:48 +00:00
G_DrawDigiNum_ ( 20 , yofssh , 200 - 17 , health , - 16 , orient ) ;
2012-08-19 13:02:37 +00:00
}
2006-12-10 06:49:01 +00:00
2012-08-20 21:28:48 +00:00
rotatesprite_fs ( sbarx ( 37 ) , yofssh + sbary ( 200 - 28 ) , sb16 , 0 , AMMOBOX , 0 , 21 , orient ) ;
2009-08-28 23:08:00 +00:00
2012-08-20 21:28:48 +00:00
if ( p - > curr_weapon = = HANDREMOTE_WEAPON )
i = HANDBOMB_WEAPON ;
else
i = p - > curr_weapon ;
G_DrawDigiNum_ ( 53 , yofssh , 200 - 17 , p - > ammo_amount [ i ] , - 16 , orient ) ;
2006-12-10 06:49:01 +00:00
2012-08-16 21:48:21 +00:00
o = 158 ;
permbit = 0 ;
if ( p - > inven_icon )
{
2012-08-19 13:02:37 +00:00
// orient |= permbit;
2010-08-02 08:13:51 +00:00
2012-11-04 23:41:05 +00:00
i = ( ( unsigned ) p - > inven_icon < ICON_MAX ) ? item_icons [ p - > inven_icon ] : - 1 ;
2012-08-16 21:48:21 +00:00
if ( i > = 0 )
2012-08-20 21:28:48 +00:00
rotatesprite_fs ( sbarx ( 231 - o ) , yofssh + sbary ( 200 - 21 ) , sb16 , 0 , i , 0 , 0 , orient ) ;
2012-08-16 21:48:08 +00:00
2012-08-19 13:02:37 +00:00
// scale by status bar size
orient | = ROTATESPRITE_MAX ;
2012-08-16 21:48:26 +00:00
2012-08-20 21:28:48 +00:00
minitext_yofs = yofssh ;
minitext ( 292 - 30 - o , 190 , " % " , 6 , orient ) ;
2012-08-16 21:48:08 +00:00
2012-08-16 21:48:21 +00:00
i = G_GetInvAmount ( p ) ;
j = G_GetInvOn ( p ) ;
2008-11-20 14:06:36 +00:00
2012-08-20 21:28:48 +00:00
G_DrawInvNum ( 284 - 30 - o , yofssh , 200 - 6 , ( uint8_t ) i , 0 , orient & ~ 16 ) ;
2012-08-16 21:48:08 +00:00
2012-08-16 21:48:21 +00:00
if ( j > 0 )
2012-08-20 21:28:48 +00:00
minitext ( 288 - 30 - o , 180 , " On " , 0 , orient ) ;
2012-08-16 21:48:21 +00:00
else if ( ( uint32_t ) j ! = 0x80000000 )
2012-08-20 21:28:48 +00:00
minitext ( 284 - 30 - o , 180 , " Off " , 2 , orient ) ;
2012-08-16 21:48:08 +00:00
2012-11-04 23:41:05 +00:00
if ( p - > inven_icon > = ICON_SCUBA )
2012-08-20 21:28:48 +00:00
minitext ( 284 - 35 - o , 180 , " Auto " , 2 , orient ) ;
minitext_yofs = 0 ;
2012-08-16 21:48:21 +00:00
}
2010-01-23 22:12:02 +00:00
}
2012-08-16 21:48:21 +00:00
2010-08-02 08:13:51 +00:00
return ;
2010-01-23 22:12:02 +00:00
}
2009-12-30 23:07:00 +00:00
2010-08-02 08:13:51 +00:00
//DRAW/UPDATE FULL STATUS BAR:
2009-12-30 23:07:00 +00:00
2010-08-02 08:13:51 +00:00
if ( pus )
2009-12-30 23:07:00 +00:00
{
2010-08-02 08:13:51 +00:00
pus = 0 ;
u = - 1 ;
}
else u = 0 ;
2009-12-30 23:07:00 +00:00
2010-08-02 08:13:51 +00:00
if ( sbar . frag [ myconnectindex ] ! = p - > frag )
2010-01-23 22:12:02 +00:00
{
2010-08-02 08:13:51 +00:00
sbar . frag [ myconnectindex ] = p - > frag ;
u | = 32768 ;
}
if ( sbar . got_access ! = p - > got_access )
{
sbar . got_access = p - > got_access ;
u | = 16384 ;
2010-01-23 22:12:02 +00:00
}
2009-12-30 23:07:00 +00:00
2010-08-02 08:13:51 +00:00
if ( sbar . last_extra ! = p - > last_extra )
{
sbar . last_extra = p - > last_extra ;
u | = 1 ;
}
2010-01-23 22:12:02 +00:00
2010-08-02 08:13:51 +00:00
{
int32_t lAmount = Gv_GetVarByLabel ( " PLR_MORALE " , - 1 , p - > i , snum ) ;
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
if ( lAmount = = - 1 )
2012-08-16 21:48:08 +00:00
lAmount = p - > inv_amount [ GET_SHIELD ] ;
2010-01-23 22:12:02 +00:00
2012-08-16 21:48:08 +00:00
if ( sbar . inv_amount [ GET_SHIELD ] ! = lAmount )
2010-01-23 22:12:02 +00:00
{
2012-08-16 21:48:08 +00:00
sbar . inv_amount [ GET_SHIELD ] = lAmount ;
u | = 2 ;
2010-01-23 22:12:02 +00:00
}
2009-12-30 23:07:00 +00:00
}
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
if ( sbar . curr_weapon ! = p - > curr_weapon )
2009-12-14 09:54:11 +00:00
{
2010-08-02 08:13:51 +00:00
sbar . curr_weapon = p - > curr_weapon ;
u | = ( 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 65536L ) ;
2009-12-14 09:54:11 +00:00
}
2010-08-02 08:13:51 +00:00
for ( i = 1 ; i < MAX_WEAPONS ; i + + )
2009-12-05 09:22:43 +00:00
{
2010-08-02 08:13:51 +00:00
if ( sbar . ammo_amount [ i ] ! = p - > ammo_amount [ i ] )
2009-12-05 09:22:43 +00:00
{
2010-08-02 08:13:51 +00:00
sbar . ammo_amount [ i ] = p - > ammo_amount [ i ] ;
if ( i < 9 )
u | = ( ( 2 < < i ) + 1024 ) ;
else u | = 65536L + 1024 ;
}
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
if ( ( sbar . gotweapon & ( 1 < < i ) ) ! = ( p - > gotweapon & ( 1 < < i ) ) )
{
if ( p - > gotweapon & ( 1 < < i ) )
sbar . gotweapon | = 1 < < i ;
else sbar . gotweapon & = ~ ( 1 < < i ) ;
2010-07-19 15:14:00 +00:00
2010-08-02 08:13:51 +00:00
if ( i < 9 )
u | = ( ( 2 < < i ) + 1024 ) ;
else u | = 65536L + 1024 ;
2009-12-05 09:22:43 +00:00
}
}
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
if ( sbar . inven_icon ! = p - > inven_icon )
2009-12-05 09:22:43 +00:00
{
2010-08-02 08:13:51 +00:00
sbar . inven_icon = p - > inven_icon ;
u | = ( 2048 + 4096 + 8192 ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( sbar . holoduke_on ! = p - > holoduke_on )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
sbar . holoduke_on = p - > holoduke_on ;
u | = ( 4096 + 8192 ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( sbar . jetpack_on ! = p - > jetpack_on )
2008-12-28 23:27:24 +00:00
{
2010-08-02 08:13:51 +00:00
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 ) ;
}
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
{
2012-08-16 21:48:08 +00:00
static const int32_t check_items [ ] = {
GET_FIRSTAID , GET_STEROIDS , GET_HOLODUKE , GET_JETPACK ,
GET_HEATS , GET_SCUBA , GET_BOOTS
} ;
for ( i = 0 ; i < ( int32_t ) sizeof ( check_items ) / ( int32_t ) sizeof ( check_items [ 0 ] ) ; i + + )
{
int32_t item = check_items [ i ] ;
if ( sbar . inv_amount [ item ] ! = p - > inv_amount [ item ] )
{
sbar . inv_amount [ item ] = p - > inv_amount [ item ] ;
u | = 8192 ;
}
}
2010-08-02 08:13:51 +00:00
}
2012-08-19 12:55:35 +00:00
#if 0
2012-08-16 21:48:08 +00:00
if ( u = = 0 )
return ;
2012-08-19 12:55:35 +00:00
# else
// FIXME: full status bar draws rectangles in the wrong places when it's
// updated partially.
u = - 1 ;
# endif
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
//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-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( u = = - 1 )
{
G_PatchStatusBar ( 0 , 0 , 320 , 200 ) ;
2012-08-19 12:54:30 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) & & ( GametypeFlags [ ud . coop ] & GAMETYPE_FRAGBAR ) )
2012-08-16 21:48:08 +00:00
rotatesprite_fs ( sbarx ( 277 + 1 ) , sbary ( SBY + 7 - 1 ) , sb16 , 0 , KILLSICON , 0 , 0 , 10 + 16 ) ;
2010-08-02 08:13:51 +00:00
}
2012-08-19 12:54:30 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) & & ( GametypeFlags [ ud . coop ] & GAMETYPE_FRAGBAR ) )
2010-08-02 08:13:51 +00:00
{
if ( u & 32768 )
2010-01-05 21:53:14 +00:00
{
2010-08-02 08:13:51 +00:00
if ( u ! = - 1 ) G_PatchStatusBar ( 276 , SBY + 17 , 299 , SBY + 17 + 10 ) ;
G_DrawDigiNum ( 287 , SBY + 17 , max ( p - > frag - p - > fraggedself , 0 ) , - 16 , 10 + 16 ) ;
2006-04-13 20:47:06 +00:00
}
2010-01-05 21:53:14 +00:00
}
2010-08-02 08:13:51 +00:00
else
2010-01-05 21:53:14 +00:00
{
2010-08-02 08:13:51 +00:00
if ( u & 16384 )
2010-01-05 21:53:14 +00:00
{
2010-08-02 08:13:51 +00:00
if ( u ! = - 1 ) G_PatchStatusBar ( 275 , SBY + 18 , 299 , SBY + 18 + 12 ) ;
2012-08-16 21:48:08 +00:00
if ( p - > got_access & 4 ) rotatesprite_fs ( sbarx ( 275 ) , sbary ( SBY + 16 ) , sb16 , 0 , ACCESS_ICON , 0 , 23 , 10 + 16 ) ;
if ( p - > got_access & 2 ) rotatesprite_fs ( sbarx ( 288 ) , sbary ( SBY + 16 ) , sb16 , 0 , ACCESS_ICON , 0 , 21 , 10 + 16 ) ;
if ( p - > got_access & 1 ) rotatesprite_fs ( sbarx ( 281 ) , sbary ( SBY + 23 ) , sb16 , 0 , ACCESS_ICON , 0 , 0 , 10 + 16 ) ;
2010-07-22 20:29:09 +00:00
}
}
2012-08-16 21:48:08 +00:00
if ( u & ( 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 65536L ) )
G_DrawWeapAmounts ( p , 96 , SBY + 16 , u ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( u & 1 )
2010-07-22 20:29:09 +00:00
{
2010-08-02 08:13:51 +00:00
if ( u ! = - 1 ) G_PatchStatusBar ( 20 , SBY + 17 , 43 , SBY + 17 + 11 ) ;
if ( sprite [ p - > i ] . pal = = 1 & & p - > last_extra < 2 )
G_DrawDigiNum ( 32 , SBY + 17 , 1 , - 16 , 10 + 16 ) ;
else G_DrawDigiNum ( 32 , SBY + 17 , p - > last_extra , - 16 , 10 + 16 ) ;
2010-07-22 20:29:09 +00:00
}
2010-08-02 08:13:51 +00:00
if ( u & 2 )
2010-07-22 20:29:09 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t lAmount = Gv_GetVarByLabel ( " PLR_MORALE " , - 1 , p - > i , snum ) ;
if ( u ! = - 1 ) G_PatchStatusBar ( 52 , SBY + 17 , 75 , SBY + 17 + 11 ) ;
if ( lAmount = = - 1 )
G_DrawDigiNum ( 64 , SBY + 17 , p - > inv_amount [ GET_SHIELD ] , - 16 , 10 + 16 ) ;
else
G_DrawDigiNum ( 64 , SBY + 17 , lAmount , - 16 , 10 + 16 ) ;
2010-07-22 20:29:09 +00:00
}
2010-05-19 10:02:35 +00:00
2010-08-02 08:13:51 +00:00
if ( u & 1024 )
2010-07-22 20:29:09 +00:00
{
2010-08-02 08:13:51 +00:00
if ( u ! = - 1 ) G_PatchStatusBar ( 196 , SBY + 17 , 219 , SBY + 17 + 11 ) ;
if ( p - > curr_weapon ! = KNEE_WEAPON )
2010-01-05 21:53:14 +00:00
{
2010-08-02 08:13:51 +00:00
if ( p - > curr_weapon = = HANDREMOTE_WEAPON ) i = HANDBOMB_WEAPON ;
else i = p - > curr_weapon ;
G_DrawDigiNum ( 230 - 22 , SBY + 17 , p - > ammo_amount [ i ] , - 16 , 10 + 16 ) ;
2010-01-05 21:53:14 +00:00
}
2010-07-22 20:29:09 +00:00
}
2009-12-12 11:07:59 +00:00
2010-08-02 08:13:51 +00:00
if ( u & ( 2048 + 4096 + 8192 ) )
2010-07-22 20:29:09 +00:00
{
2010-08-02 08:13:51 +00:00
if ( u ! = - 1 )
2010-01-05 21:53:14 +00:00
{
2010-08-02 08:13:51 +00:00
if ( u & ( 2048 + 4096 ) )
G_PatchStatusBar ( 231 , SBY + 13 , 265 , SBY + 13 + 18 ) ;
else
G_PatchStatusBar ( 250 , SBY + 24 , 261 , SBY + 24 + 6 ) ;
2010-07-05 19:33:29 +00:00
}
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
if ( p - > inven_icon )
{
o = 0 ;
// permbit = 128;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( u & ( 2048 + 4096 ) )
{
2012-11-04 23:41:05 +00:00
i = ( ( unsigned ) p - > inven_icon < ICON_MAX ) ? item_icons [ p - > inven_icon ] : - 1 ;
2012-08-16 21:48:08 +00:00
// XXX: i < 0?
rotatesprite_fs ( sbarx ( 231 - o ) , sbary ( SBY + 13 ) , sb16 , 0 , i , 0 , 0 , 10 + 16 + permbit ) ;
2010-08-02 08:13:51 +00:00
minitext ( 292 - 30 - o , SBY + 24 , " % " , 6 , 10 + 16 + permbit + ROTATESPRITE_MAX ) ;
2012-11-04 23:41:05 +00:00
if ( p - > inven_icon > = ICON_SCUBA ) minitext ( 284 - 35 - o , SBY + 14 , " Auto " , 2 , 10 + 16 + permbit + ROTATESPRITE_MAX ) ;
2010-08-02 08:13:51 +00:00
}
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
if ( u & ( 2048 + 4096 ) )
{
2012-08-16 21:48:08 +00:00
j = G_GetInvOn ( p ) ;
2012-03-26 05:07:12 +00:00
if ( j > 0 ) minitext ( 288 - 30 - o , SBY + 14 , " On " , 0 , 10 + 16 + permbit + ROTATESPRITE_MAX ) ;
else if ( ( uint32_t ) j ! = 0x80000000 ) minitext ( 284 - 30 - o , SBY + 14 , " Off " , 2 , 10 + 16 + permbit + ROTATESPRITE_MAX ) ;
2010-08-02 08:13:51 +00:00
}
2012-08-16 21:48:08 +00:00
2010-08-02 08:13:51 +00:00
if ( u & 8192 )
{
2012-08-16 21:48:08 +00:00
i = G_GetInvAmount ( p ) ;
2012-08-20 21:28:48 +00:00
G_DrawInvNum ( 284 - 30 - o , 0 , SBY + 28 , ( uint8_t ) i , 0 , 10 + permbit ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
}
2010-08-02 08:13:51 +00:00
# define COLOR_RED 248
# define COLOR_WHITE 31
# define LOW_FPS 30
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
static void G_PrintFPS ( void )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
// adapted from ZDoom because I like it better than what we had
// applicable ZDoom code available under GPL from csDoom
static int32_t FrameCount = 0 ;
static int32_t LastCount = 0 ;
static int32_t LastSec = 0 ;
static int32_t LastMS = 0 ;
int32_t ms = getticks ( ) ;
int32_t howlong = ms - LastMS ;
if ( howlong > = 0 )
{
int32_t thisSec = ms / 1000 ;
int32_t x = ( xdim < = 640 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . tickrate )
{
int32_t chars = Bsprintf ( tempbuf , " %d ms (%3u fps) " , howlong , LastCount ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
printext256 ( windowx2 - ( chars < < ( 3 - x ) ) + 1 , windowy1 + 2 , 0 , - 1 , tempbuf , x ) ;
printext256 ( windowx2 - ( chars < < ( 3 - x ) ) , windowy1 + 1 ,
( LastCount < LOW_FPS ) ? COLOR_RED : COLOR_WHITE , - 1 , tempbuf , x ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// lag meter
if ( g_netClientPeer )
{
chars = Bsprintf ( tempbuf , " %d +- %d ms " , ( g_netClientPeer - > lastRoundTripTime + g_netClientPeer - > roundTripTime ) / 2 ,
( g_netClientPeer - > lastRoundTripTimeVariance + g_netClientPeer - > roundTripTimeVariance ) / 2 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
printext256 ( windowx2 - ( chars < < ( 3 - x ) ) + 1 , windowy1 + 10 + 2 , 0 , - 1 , tempbuf , x ) ;
printext256 ( windowx2 - ( chars < < ( 3 - x ) ) , windowy1 + 10 + 1 , g_netClientPeer - > lastRoundTripTime > 200 ? COLOR_RED : COLOR_WHITE , - 1 , tempbuf , x ) ;
}
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( thisSec - LastSec )
{
g_currentFrameRate = LastCount = FrameCount / ( thisSec - LastSec ) ;
LastSec = thisSec ;
FrameCount = 0 ;
}
FrameCount + + ;
}
LastMS = ms ;
2006-04-13 20:47:06 +00:00
}
2012-03-04 20:14:32 +00:00
// yxaspect and viewingrange just before the 'main' drawrooms call
static int32_t dr_yxaspect , dr_viewingrange ;
2010-08-02 08:13:51 +00:00
static void G_PrintCoords ( int32_t snum )
2006-04-13 20:47:06 +00:00
{
2012-03-04 20:14:32 +00:00
const int32_t x = 250 ;
2010-08-02 08:13:51 +00:00
int32_t y = 16 ;
2012-10-03 15:29:10 +00:00
const DukePlayer_t * ps = g_player [ snum ] . ps ;
const int32_t sectnum = ps - > cursectnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( GametypeFlags [ ud . coop ] & GAMETYPE_FRAGBAR ) )
{
if ( ud . multimode > 4 )
y = 32 ;
2012-08-19 12:54:30 +00:00
else if ( g_netServer | | ud . multimode > 1 )
2010-08-02 08:13:51 +00:00
y = 24 ;
}
2012-10-03 15:29:10 +00:00
Bsprintf ( tempbuf , " XYZ= (%d,%d,%d) " , ps - > pos . x , ps - > pos . y , ps - > pos . z ) ;
2012-03-04 20:14:32 +00:00
printext256 ( x , y , 31 , - 1 , tempbuf , 0 ) ;
2012-10-03 15:29:10 +00:00
Bsprintf ( tempbuf , " A/H/HO= %d,%d,%d " , ps - > ang , ps - > horiz , ps - > horizoff ) ;
2012-03-04 20:14:32 +00:00
printext256 ( x , y + 9 , 31 , - 1 , tempbuf , 0 ) ;
2012-10-03 15:29:10 +00:00
Bsprintf ( tempbuf , " ZV= %d " , ps - > vel . z ) ;
2012-03-04 20:14:32 +00:00
printext256 ( x , y + 18 , 31 , - 1 , tempbuf , 0 ) ;
2012-10-03 15:29:10 +00:00
Bsprintf ( tempbuf , " OG= %d SBRIDGE=%d SBS=%d " , ps - > on_ground , ps - > spritebridge , ps - > sbs ) ;
2012-03-04 20:14:32 +00:00
printext256 ( x , y + 27 , 31 , - 1 , tempbuf , 0 ) ;
if ( sectnum > = 0 )
2012-11-15 14:28:04 +00:00
Bsprintf_nowarn ( tempbuf , " SECT= %d (LO=%d EX=%d) " , sectnum , sector [ sectnum ] . lotag , sector [ sectnum ] . extra ) ;
2012-03-04 20:14:32 +00:00
else
Bsprintf ( tempbuf , " SECT= %d " , sectnum ) ;
printext256 ( x , y + 36 , 31 , - 1 , tempbuf , 0 ) ;
// Bsprintf(tempbuf,"SEED= %d",randomseed);
// printext256(x,y+45,31,-1,tempbuf,0);
y - = 9 ;
y + = 7 ;
2012-10-03 15:29:10 +00:00
Bsprintf ( tempbuf , " THOLD= %d " , ps - > transporter_hold ) ;
2012-03-04 20:14:32 +00:00
printext256 ( x , y + 54 , 31 , - 1 , tempbuf , 0 ) ;
2011-07-27 19:59:09 +00:00
Bsprintf ( tempbuf , " GAMETIC= %d " , g_moveThingsCount ) ;
2012-03-04 20:14:32 +00:00
printext256 ( x , y + 63 , 31 , - 1 , tempbuf , 0 ) ;
y + = 7 ;
Bsprintf ( tempbuf , " VR=%.03f YX=%.03f " , ( double ) dr_viewingrange / 65536.0 , ( double ) dr_yxaspect / 65536.0 ) ;
printext256 ( x , y + 72 , 31 , - 1 , tempbuf , 0 ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-22 11:42:22 +00:00
2012-08-20 21:30:00 +00:00
// orientation flags depending on time that a quote has still to be displayed
static inline int32_t texto ( int32_t t )
2006-04-13 20:47:06 +00:00
{
2012-08-20 21:30:00 +00:00
if ( t > 4 ) return 2 + 8 + 16 ;
if ( t > 2 ) return 2 + 8 + 16 + 1 ;
return 2 + 8 + 16 + 1 + 32 ;
}
static int32_t calc_ybase ( int32_t begy )
{
int32_t k = begy ;
2008-08-07 07:52:36 +00:00
2012-08-21 17:39:00 +00:00
if ( GTFLAGS ( GAMETYPE_FRAGBAR ) & & ( ud . screen_size > 0 & & ! g_fakeMultiMode )
& & ( g_netServer | | ud . multimode > 1 ) )
2006-04-13 20:47:06 +00:00
{
2012-08-20 21:30:00 +00:00
int32_t i , j = 0 ;
2010-08-02 08:13:51 +00:00
k + = 8 ;
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( i ) )
2012-08-20 21:30:00 +00:00
if ( i > j )
j = i ;
2010-08-02 08:13:51 +00:00
if ( j > = 4 & & j < = 8 ) k + = 8 ;
else if ( j > 8 & & j < = 12 ) k + = 16 ;
else if ( j > 12 ) k + = 24 ;
2006-04-13 20:47:06 +00:00
}
2008-08-07 07:52:36 +00:00
2012-08-20 21:30:00 +00:00
return k ;
}
// this handles both multiplayer and item pickup message type text
// both are passed on to gametext
2012-08-20 21:32:11 +00:00
void G_PrintGameQuotes ( int32_t snum )
2012-08-20 21:30:00 +00:00
{
int32_t i , j , k ;
2012-08-20 21:32:11 +00:00
const DukePlayer_t * const ps = g_player [ snum ] . ps ;
2012-08-21 17:39:00 +00:00
const int32_t reserved_quote = ( ps - > ftq > = QUOTE_RESERVED & & ps - > ftq < = QUOTE_RESERVED3 ) ;
2012-08-24 18:54:01 +00:00
// NOTE: QUOTE_RESERVED4 is not included.
2012-08-20 21:30:00 +00:00
k = calc_ybase ( 1 ) ;
2012-08-21 17:39:00 +00:00
if ( ps - > fta > 1 & & ! reserved_quote )
2010-08-02 08:13:51 +00:00
{
2012-08-21 17:39:00 +00:00
k + = min ( 7 , ps - > fta ) ;
2006-04-13 20:47:06 +00:00
}
2012-08-20 21:30:00 +00:00
j = scale ( k , ydim , 200 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( i = MAXUSERQUOTES - 1 ; i > = 0 ; i - - )
2006-12-18 04:16:41 +00:00
{
2012-08-20 21:30:00 +00:00
int32_t sh , l ;
2012-02-04 21:34:22 +00:00
if ( user_quote_time [ i ] < = 0 )
continue ;
2012-08-21 17:39:00 +00:00
2010-08-02 08:13:51 +00:00
k = user_quote_time [ i ] ;
2012-02-04 21:34:22 +00:00
sh = hud_glowingquotes ? ( sintable [ ( ( totalclock + ( i < < 2 ) ) < < 5 ) & 2047 ] > > 11 ) : 0 ;
2012-08-20 21:30:00 +00:00
mpgametext ( j , user_quote [ i ] , sh , texto ( k ) ) ;
j + = textsc ( k > 4 ? 8 : ( k < < 1 ) ) ;
2012-02-04 21:34:22 +00:00
2012-08-20 21:30:00 +00:00
l = G_GameTextLen ( USERQUOTE_LEFTOFFSET , OSD_StripColors ( tempbuf , user_quote [ i ] ) ) ;
2010-08-02 08:13:51 +00:00
while ( l > ( ud . config . ScreenWidth - USERQUOTE_RIGHTOFFSET ) )
{
l - = ( ud . config . ScreenWidth - USERQUOTE_RIGHTOFFSET ) ;
2012-08-20 21:30:00 +00:00
j + = textsc ( k > 4 ? 8 : ( k < < 1 ) ) ;
2010-08-02 08:13:51 +00:00
}
}
2006-04-13 20:47:06 +00:00
2012-08-20 21:30:00 +00:00
if ( klabs ( quotebotgoal - quotebot ) < = 16 & & ud . screen_size < = 8 )
2010-08-02 08:13:51 +00:00
quotebot + = ksgn ( quotebotgoal - quotebot ) ;
else
quotebot = quotebotgoal ;
2006-04-13 20:47:06 +00:00
2012-08-21 17:39:00 +00:00
if ( ps - > fta < = 1 )
return ;
2006-04-13 20:47:06 +00:00
2012-08-20 21:30:00 +00:00
if ( ScriptQuotes [ ps - > ftq ] = = NULL )
2006-04-13 20:47:06 +00:00
{
2012-08-20 21:30:00 +00:00
OSD_Printf ( OSD_ERROR " %s %d null quote %d \n " , __FILE__ , __LINE__ , ps - > ftq ) ;
2006-12-18 04:16:41 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2012-08-20 21:30:00 +00:00
k = calc_ybase ( 0 ) ;
if ( k = = 0 )
{
2012-08-21 17:39:00 +00:00
if ( reserved_quote )
2012-08-20 21:30:00 +00:00
{
2012-08-21 17:39:00 +00:00
if ( ! g_fakeMultiMode )
k = 140 ; //quotebot-8-4;
else
k = 50 ;
2012-08-20 21:30:00 +00:00
}
else
{
2012-06-20 20:03:51 +00:00
# ifdef GEKKO
2012-08-20 21:30:00 +00:00
k = 16 ;
2012-06-20 20:03:51 +00:00
# else
2012-08-20 21:30:00 +00:00
k = 0 ;
2012-06-20 20:03:51 +00:00
# endif
2012-08-20 21:30:00 +00:00
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
2012-08-20 21:32:11 +00:00
{
int32_t pal = 0 ;
if ( g_fakeMultiMode )
{
pal = g_player [ snum ] . pcolor ;
if ( snum = = 1 )
{
const int32_t sidebyside = ( ud . screen_size ! = 0 ) ;
// NOTE: setting gametext's x -= 80 doesn't do the expected thing.
// Needs looking into.
if ( sidebyside )
k + = 9 ;
else
k + = 101 ;
}
}
gametextpalbits ( 160 , k , ScriptQuotes [ ps - > ftq ] ,
hud_glowingquotes ? quotepulseshade : 0 ,
pal , texto ( ps - > fta ) ) ;
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
void P_DoQuote ( int32_t q , DukePlayer_t * p )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t cq = 0 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( q & MAXQUOTES )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
cq = 1 ;
q & = ~ MAXQUOTES ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ScriptQuotes [ q ] = = NULL )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
OSD_Printf ( OSD_ERROR " %s %d null quote %d \n " , __FILE__ , __LINE__ , q ) ;
return ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ud . fta_on = = 0 )
return ;
2006-04-13 20:47:06 +00:00
2011-02-25 21:50:19 +00:00
if ( p - > fta > 0 & & q ! = QUOTE_RESERVED & & q ! = QUOTE_RESERVED2 )
if ( p - > ftq = = QUOTE_RESERVED | | p - > ftq = = QUOTE_RESERVED2 ) return ;
2006-12-18 08:37:12 +00:00
2010-08-02 08:13:51 +00:00
p - > fta = 100 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( p - > ftq ! = q )
2006-04-13 20:47:06 +00:00
{
2011-08-20 23:28:36 +00:00
if ( p = = g_player [ screenpeek ] . ps
& & Bstrcmp ( ScriptQuotes [ q ] , " " ) ) // avoid printing blank quotes
2010-08-02 08:13:51 +00:00
{
if ( cq ) OSD_Printf ( OSDTEXT_BLUE " %s \n " , ScriptQuotes [ q ] ) ;
else OSD_Printf ( " %s \n " , ScriptQuotes [ q ] ) ;
}
2006-12-18 04:16:41 +00:00
2010-08-02 08:13:51 +00:00
p - > ftq = q ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
pub = NUMPAGES ;
pus = NUMPAGES ;
2006-04-13 20:47:06 +00:00
}
2012-04-04 18:56:16 +00:00
////////// OFTEN-USED FEW-LINERS //////////
static void handle_events_while_no_input ( void )
{
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
while ( ! I_CheckInputWaiting ( ) )
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2012-04-04 18:56:16 +00:00
}
static int32_t play_sound_while_no_input ( int32_t soundnum )
{
S_PlaySound ( soundnum ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2012-04-04 18:56:16 +00:00
while ( S_CheckSoundPlaying ( - 1 , soundnum ) )
{
G_HandleAsync ( ) ;
2012-06-03 16:11:22 +00:00
if ( I_CheckInputWaiting ( ) )
{
I_ClearInputWaiting ( ) ;
2012-04-04 18:56:16 +00:00
return 1 ;
2012-06-03 16:11:22 +00:00
}
2012-04-04 18:56:16 +00:00
}
return 0 ;
}
//////////
2010-08-02 08:13:51 +00:00
void G_FadePalette ( int32_t r , int32_t g , int32_t b , int32_t e )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
setpalettefade ( r , g , b , e & 63 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// if (getrendermode() >= 3) pus = pub = NUMPAGES; // JBF 20040110: redraw the status bar next time
if ( ( e & 128 ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t tc ;
2011-08-17 18:52:54 +00:00
2010-08-02 08:13:51 +00:00
nextpage ( ) ;
2011-08-17 18:52:54 +00:00
tc = totalclock ;
while ( totalclock < tc + 4 )
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2012-04-04 18:56:50 +00:00
// START and END limits are always inclusive!
// STEP must evenly divide END-START, i.e. abs(end-start)%step == 0
2010-08-02 08:13:51 +00:00
void fadepal ( int32_t r , int32_t g , int32_t b , int32_t start , int32_t end , int32_t step )
{
2011-06-25 16:37:10 +00:00
if ( getrendermode ( ) > = 3 )
{
G_FadePalette ( r , g , b , end ) ;
return ;
}
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
2012-04-04 18:56:50 +00:00
// (end-start)/step + 1 iterations
do
2006-04-13 20:47:06 +00:00
{
2012-04-04 18:56:50 +00:00
if ( KB_KeyPressed ( sc_Space ) )
2010-08-02 08:13:51 +00:00
{
2012-04-04 18:56:50 +00:00
KB_ClearKeyDown ( sc_Space ) ;
setpalettefade ( r , g , b , end ) ; // have to set to end fade value if we break!
return ;
2010-08-02 08:13:51 +00:00
}
2012-04-04 18:56:31 +00:00
2012-04-04 18:56:50 +00:00
G_FadePalette ( r , g , b , start ) ;
start + = step ;
}
while ( start ! = end + step ) ;
2006-04-13 20:47:06 +00:00
}
2012-04-04 18:56:50 +00:00
// START and END limits are always inclusive!
2012-01-19 21:57:22 +00:00
static void fadepaltile ( int32_t r , int32_t g , int32_t b , int32_t start , int32_t end , int32_t step , int32_t tile )
2006-04-13 20:47:06 +00:00
{
2012-08-19 12:53:24 +00:00
// STEP must evenly divide END-START
Bassert ( klabs ( end - start ) % step = = 0 ) ;
clearallviews ( 0 ) ;
2012-04-04 18:56:31 +00:00
2012-04-04 18:56:50 +00:00
// (end-start)/step + 1 iterations
do
2006-04-13 20:47:06 +00:00
{
2012-04-04 18:56:50 +00:00
if ( KB_KeyPressed ( sc_Space ) )
2010-08-02 08:13:51 +00:00
{
2012-04-04 18:56:50 +00:00
KB_ClearKeyDown ( sc_Space ) ;
setpalettefade ( r , g , b , end ) ; // have to set to end fade value if we break!
return ;
2010-08-02 08:13:51 +00:00
}
2012-04-04 18:56:50 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , tile , 0 , 0 , 2 + 8 + 16 + ( ud . bgstretch ? 1024 : 0 ) ) ;
G_FadePalette ( r , g , b , start ) ;
start + = step ;
2006-04-13 20:47:06 +00:00
}
2012-04-04 18:56:50 +00:00
while ( start ! = end + step ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
static void G_DisplayExtraScreens ( void )
2008-08-07 07:52:36 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t flags = Gv_GetVarByLabel ( " LOGO_FLAGS " , 255 , - 1 , - 1 ) ;
2008-08-07 07:52:36 +00:00
2010-08-02 08:13:51 +00:00
S_StopMusic ( ) ;
FX_StopAllSounds ( ) ;
2008-08-07 07:52:36 +00:00
2010-08-02 08:13:51 +00:00
if ( ! VOLUMEALL | | flags & LOGO_SHAREWARESCREENS )
2008-08-07 07:52:36 +00:00
{
2010-08-02 08:13:51 +00:00
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
flushperms ( ) ;
//g_player[myconnectindex].ps->palette = palette;
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 1 ) ; // JBF 20040308
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , 3291 , 0 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-08-02 08:13:51 +00:00
fadepaltile ( 0 , 0 , 0 , 63 , 0 , - 7 , 3291 ) ;
2012-06-03 16:11:22 +00:00
while ( ! I_CheckAllInput ( ) )
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2008-08-07 07:52:36 +00:00
2012-04-04 18:56:50 +00:00
fadepaltile ( 0 , 0 , 0 , 0 , 63 , 7 , 3291 ) ;
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , 3290 , 0 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-08-02 08:13:51 +00:00
fadepaltile ( 0 , 0 , 0 , 63 , 0 , - 7 , 3290 ) ;
2012-06-03 16:11:22 +00:00
while ( ! I_CheckAllInput ( ) )
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2008-08-07 07:52:36 +00:00
}
2010-08-02 08:13:51 +00:00
if ( flags & LOGO_TENSCREEN )
2008-08-07 07:52:36 +00:00
{
2010-08-02 08:13:51 +00:00
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
flushperms ( ) ;
//g_player[myconnectindex].ps->palette = palette;
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 1 ) ; // JBF 20040308
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , TENSCREEN , 0 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-08-02 08:13:51 +00:00
fadepaltile ( 0 , 0 , 0 , 63 , 0 , - 7 , TENSCREEN ) ;
2012-06-03 16:11:22 +00:00
while ( ! I_CheckAllInput ( ) & & totalclock < 2400 )
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2012-06-03 16:11:22 +00:00
fadepaltile ( 0 , 0 , 0 , 0 , 63 , 7 , TENSCREEN ) ;
I_ClearAllInput ( ) ;
2008-08-07 07:52:36 +00:00
}
}
2010-08-02 08:13:51 +00:00
extern int32_t qsetmode ;
extern int32_t g_doQuickSave ;
2006-04-13 20:47:06 +00:00
2012-06-03 15:46:05 +00:00
void G_GameExit ( const char * msg )
2010-08-02 08:13:51 +00:00
{
2012-07-20 21:57:44 +00:00
# ifdef LUNATIC
El_PrintTimes ( ) ;
# endif
2012-06-03 15:46:05 +00:00
if ( * msg ! = 0 ) g_player [ myconnectindex ] . ps - > palette = BASEPAL ;
2006-04-13 20:47:06 +00:00
2012-09-05 17:25:31 +00:00
if ( ud . recstat = = 1 )
G_CloseDemoWrite ( ) ;
2010-08-02 08:13:51 +00:00
else if ( ud . recstat = = 2 )
2012-09-05 17:25:31 +00:00
MAYBE_FCLOSE_AND_NULL ( g_demo_filePtr ) ;
// JBF: fixes crash on demo playback
// PK: modified from original
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ! g_quickExit )
2006-04-13 20:47:06 +00:00
{
2012-06-03 15:46:05 +00:00
if ( playerswhenstarted > 1 & & g_player [ myconnectindex ] . ps - > gm & MODE_GAME & & GTFLAGS ( GAMETYPE_SCORESHEET ) & & * msg = = ' ' )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
G_BonusScreen ( 1 ) ;
setgamemode ( ud . config . ScreenMode , ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP ) ;
2006-04-13 20:47:06 +00:00
}
2012-06-03 15:46:05 +00:00
if ( * msg ! = 0 & & * ( msg + 1 ) ! = ' V ' & & * ( msg + 1 ) ! = ' Y ' )
2010-08-02 08:13:51 +00:00
G_DisplayExtraScreens ( ) ;
2006-04-13 20:47:06 +00:00
}
2012-06-03 15:46:05 +00:00
if ( * msg ! = 0 ) initprintf ( " %s \n " , msg ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( qsetmode = = 200 )
G_Shutdown ( ) ;
2006-04-13 20:47:06 +00:00
2012-06-03 15:46:05 +00:00
if ( * msg ! = 0 )
2006-04-13 20:47:06 +00:00
{
2012-06-03 15:46:05 +00:00
if ( ! ( msg [ 0 ] = = ' ' & & msg [ 1 ] = = 0 ) )
2010-08-02 08:13:51 +00:00
{
char titlebuf [ 256 ] ;
2011-03-04 09:29:03 +00:00
Bsprintf ( titlebuf , HEAD2 " %s " , s_buildRev ) ;
2012-06-03 15:46:05 +00:00
wm_msgbox ( titlebuf , " %s " , ( char * ) msg ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
uninitgroupfile ( ) ;
2006-08-10 02:10:24 +00:00
2012-06-03 16:08:27 +00:00
Bfflush ( NULL ) ;
2010-08-02 08:13:51 +00:00
exit ( 0 ) ;
}
2006-04-13 20:47:06 +00:00
2008-08-07 07:52:36 +00:00
2010-08-02 08:13:51 +00:00
static inline void G_MoveClouds ( void )
{
int32_t i ;
2010-06-22 21:50:01 +00:00
2011-11-26 22:40:54 +00:00
if ( totalclock < = cloudtotalclock & & totalclock > = ( cloudtotalclock - 7 ) )
2010-08-02 08:13:51 +00:00
return ;
2008-08-07 07:52:36 +00:00
2010-08-02 08:13:51 +00:00
cloudtotalclock = totalclock + 6 ;
2008-08-07 07:52:36 +00:00
2010-08-02 08:13:51 +00:00
for ( i = g_numClouds - 1 ; i > = 0 ; i - - )
{
cloudx [ i ] + = ( sintable [ ( g_player [ screenpeek ] . ps - > ang + 512 ) & 2047 ] > > 9 ) ;
cloudy [ i ] + = ( sintable [ g_player [ screenpeek ] . ps - > ang & 2047 ] > > 9 ) ;
2008-08-07 07:52:36 +00:00
2010-08-02 08:13:51 +00:00
sector [ clouds [ i ] ] . ceilingxpanning = cloudx [ i ] > > 6 ;
sector [ clouds [ i ] ] . ceilingypanning = cloudy [ i ] > > 6 ;
}
}
2008-08-07 07:52:36 +00:00
2010-08-02 08:13:51 +00:00
static void G_DrawOverheadMap ( int32_t cposx , int32_t cposy , int32_t czoom , int16_t cang )
{
int32_t i , j , k , l , x1 , y1 , x2 = 0 , y2 = 0 , x3 , y3 , x4 , y4 , ox , oy , xoff , yoff ;
int32_t dax , day , cosang , sinang , xspan , yspan , sprx , spry ;
int32_t xrepeat , yrepeat , z1 , z2 , startwall , endwall , tilenum , daang ;
int32_t xvect , yvect , xvect2 , yvect2 ;
int16_t p ;
char col ;
walltype * wal , * wal2 ;
spritetype * spr ;
2008-08-07 07:52:36 +00:00
2011-10-17 18:41:38 +00:00
int32_t tmpydim = ( xdim * 5 ) / 8 ;
setaspect ( 65536 , divscale16 ( tmpydim * 320 , xdim * 200 ) ) ;
2010-06-22 21:50:01 +00:00
2010-08-02 08:13:51 +00:00
xvect = sintable [ ( - cang ) & 2047 ] * czoom ;
yvect = sintable [ ( 1536 - cang ) & 2047 ] * czoom ;
xvect2 = mulscale16 ( xvect , yxaspect ) ;
yvect2 = mulscale16 ( yvect , yxaspect ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
//Draw red lines
for ( i = numsectors - 1 ; i > = 0 ; i - - )
{
if ( ! ( show2dsector [ i > > 3 ] & ( 1 < < ( i & 7 ) ) ) ) continue ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
startwall = sector [ i ] . wallptr ;
endwall = sector [ i ] . wallptr + sector [ i ] . wallnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
z1 = sector [ i ] . ceilingz ;
z2 = sector [ i ] . floorz ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( j = startwall , wal = & wall [ startwall ] ; j < endwall ; j + + , wal + + )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
k = wal - > nextwall ;
if ( k < 0 ) continue ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
//if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue;
//if ((k > j) && ((show2dwall[k>>3]&(1<<(k&7))) > 0)) continue;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( sector [ wal - > nextsector ] . ceilingz = = z1 )
if ( sector [ wal - > nextsector ] . floorz = = z2 )
if ( ( ( wal - > cstat | wall [ wal - > nextwall ] . cstat ) & ( 16 + 32 ) ) = = 0 ) continue ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
col = 139 ; //red
if ( ( wal - > cstat | wall [ wal - > nextwall ] . cstat ) & 1 ) col = 234 ; //magenta
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ! ( show2dsector [ wal - > nextsector > > 3 ] & ( 1 < < ( wal - > nextsector & 7 ) ) ) )
col = 24 ;
else continue ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
ox = wal - > x - cposx ;
oy = wal - > y - cposy ;
x1 = dmulscale16 ( ox , xvect , - oy , yvect ) + ( xdim < < 11 ) ;
y1 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) + ( ydim < < 11 ) ;
2006-08-10 02:10:24 +00:00
2010-08-02 08:13:51 +00:00
wal2 = & wall [ wal - > point2 ] ;
ox = wal2 - > x - cposx ;
oy = wal2 - > y - cposy ;
x2 = dmulscale16 ( ox , xvect , - oy , yvect ) + ( xdim < < 11 ) ;
y2 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) + ( ydim < < 11 ) ;
drawline256 ( x1 , y1 , x2 , y2 , col ) ;
}
2006-12-17 21:20:35 +00:00
}
2010-08-02 08:13:51 +00:00
//Draw sprites
k = g_player [ screenpeek ] . ps - > i ;
for ( i = numsectors - 1 ; i > = 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ! ( show2dsector [ i > > 3 ] & ( 1 < < ( i & 7 ) ) ) ) continue ;
for ( j = headspritesect [ i ] ; j > = 0 ; j = nextspritesect [ j ] )
//if ((show2dsprite[j>>3]&(1<<(j&7))) > 0)
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
spr = & sprite [ j ] ;
2006-11-13 23:12:47 +00:00
2010-08-02 08:13:51 +00:00
if ( j = = k | | ( spr - > cstat & 0x8000 ) | | spr - > cstat = = 257 | | spr - > xrepeat = = 0 ) continue ;
2006-11-13 23:12:47 +00:00
2010-08-02 08:13:51 +00:00
col = 71 ; //cyan
if ( spr - > cstat & 1 ) col = 234 ; //magenta
2006-08-10 02:10:24 +00:00
2010-08-02 08:13:51 +00:00
sprx = spr - > x ;
spry = spr - > y ;
2006-07-13 03:16:51 +00:00
2010-08-02 08:13:51 +00:00
if ( ( spr - > cstat & 257 ) ! = 0 ) switch ( spr - > cstat & 48 )
{
case 0 :
// break;
2006-07-13 03:16:51 +00:00
2010-08-02 08:13:51 +00:00
ox = sprx - cposx ;
oy = spry - cposy ;
x1 = dmulscale16 ( ox , xvect , - oy , yvect ) ;
y1 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
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 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
x3 = mulscale16 ( x2 , yxaspect ) ;
y3 = mulscale16 ( y2 , yxaspect ) ;
2006-08-10 02:10:24 +00:00
2010-08-02 08:13:51 +00:00
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
2010-08-02 08:13:51 +00:00
case 16 :
if ( spr - > picnum = = LASERLINE )
{
x1 = sprx ;
y1 = spry ;
tilenum = spr - > picnum ;
2012-11-17 19:46:28 +00:00
xoff = picanm [ tilenum ] . xofs + spr - > xoffset ;
2010-08-02 08:13:51 +00:00
if ( ( spr - > cstat & 4 ) > 0 ) xoff = - xoff ;
k = spr - > ang ;
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-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
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 ) ;
drawline256 ( x1 + ( xdim < < 11 ) , y1 + ( ydim < < 11 ) ,
x2 + ( xdim < < 11 ) , y2 + ( ydim < < 11 ) , col ) ;
}
break ;
case 32 :
tilenum = spr - > picnum ;
2012-11-17 19:46:28 +00:00
xoff = picanm [ tilenum ] . xofs + spr - > xoffset ;
yoff = picanm [ tilenum ] . yofs + spr - > yoffset ;
2010-08-02 08:13:51 +00:00
if ( ( spr - > cstat & 4 ) > 0 ) xoff = - xoff ;
if ( ( spr - > cstat & 8 ) > 0 ) yoff = - yoff ;
k = spr - > ang ;
cosang = sintable [ ( k + 512 ) & 2047 ] ;
2011-12-26 15:44:23 +00:00
sinang = sintable [ k & 2047 ] ;
2010-08-02 08:13:51 +00:00
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 ) ;
break ;
}
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
//Draw white lines
for ( i = numsectors - 1 ; i > = 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ! ( show2dsector [ i > > 3 ] & ( 1 < < ( i & 7 ) ) ) ) continue ;
startwall = sector [ i ] . wallptr ;
endwall = sector [ i ] . wallptr + sector [ i ] . wallnum ;
k = - 1 ;
for ( j = startwall , wal = & wall [ startwall ] ; j < endwall ; j + + , wal + + )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +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
{
2010-08-02 08:13:51 +00:00
x1 = x2 ;
y1 = y2 ;
2006-11-15 01:16:55 +00:00
}
else
{
2010-08-02 08:13:51 +00:00
ox = wal - > x - cposx ;
oy = wal - > y - cposy ;
x1 = dmulscale16 ( ox , xvect , - oy , yvect ) + ( xdim < < 11 ) ;
y1 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) + ( ydim < < 11 ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-13 23:12:47 +00:00
2010-08-02 08:13:51 +00:00
k = wal - > point2 ;
wal2 = & wall [ k ] ;
ox = wal2 - > x - cposx ;
oy = wal2 - > y - cposy ;
x2 = dmulscale16 ( ox , xvect , - oy , yvect ) + ( xdim < < 11 ) ;
y2 = dmulscale16 ( oy , xvect2 , ox , yvect2 ) + ( ydim < < 11 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
drawline256 ( x1 , y1 , x2 , y2 , 24 ) ;
2006-04-13 20:47:06 +00:00
}
}
2010-10-17 14:49:39 +00:00
setaspect_new ( ) ;
2008-07-31 10:35:23 +00:00
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( p ) )
2008-10-31 10:08:51 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ud . scrollmode & & p = = screenpeek ) continue ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +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 ;
if ( p = = screenpeek )
2008-10-31 10:08:51 +00:00
{
2010-08-02 08:13:51 +00:00
ox = 0 ;
oy = 0 ;
daang = 0 ;
}
x1 = mulscale ( ox , xvect , 16 ) - mulscale ( oy , yvect , 16 ) ;
y1 = mulscale ( oy , xvect2 , 16 ) + mulscale ( ox , yvect2 , 16 ) ;
2008-09-11 09:24:45 +00:00
2010-08-02 08:13:51 +00:00
if ( p = = screenpeek | | GTFLAGS ( GAMETYPE_OTHERPLAYERSINMAP ) )
{
if ( sprite [ g_player [ p ] . ps - > i ] . xvel > 16 & & g_player [ p ] . ps - > on_ground )
i = APLAYERTOP + ( ( totalclock > > 4 ) & 3 ) ;
else
i = APLAYERTOP ;
2008-09-11 09:24:45 +00:00
2010-08-02 08:13:51 +00:00
j = klabs ( g_player [ p ] . ps - > truefz - g_player [ p ] . ps - > pos . z ) > > 8 ;
j = mulscale ( czoom * ( sprite [ g_player [ p ] . ps - > i ] . yrepeat + j ) , yxaspect , 16 ) ;
2009-12-14 20:14:12 +00:00
2010-08-02 08:13:51 +00:00
if ( j < 22000 ) j = 22000 ;
else if ( j > ( 65536 < < 1 ) ) j = ( 65536 < < 1 ) ;
2008-09-11 09:24:45 +00:00
2012-02-04 21:35:00 +00:00
rotatesprite_win ( ( x1 < < 4 ) + ( xdim < < 15 ) , ( y1 < < 4 ) + ( ydim < < 15 ) , j , daang , i , sprite [ g_player [ p ] . ps - > i ] . shade ,
( g_player [ p ] . ps - > cursectnum > - 1 ) ? sector [ g_player [ p ] . ps - > cursectnum ] . floorpal : 0 , 0 ) ;
2006-06-19 19:28:49 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
# define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
palette_t CrosshairColors = { 255 , 255 , 255 , 0 } ;
palette_t DefaultCrosshairColors = { 0 , 0 , 0 , 0 } ;
int32_t g_crosshairSum = 0 ;
2008-11-20 14:06:36 +00:00
2010-08-02 08:13:51 +00:00
void G_GetCrosshairColor ( void )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
// use the brightest color in the original 8-bit tile
int32_t bri = 0 , j = 0 , i ;
int32_t ii ;
char * ptr = ( char * ) waloff [ CROSSHAIR ] ;
2008-08-28 05:57:46 +00:00
2010-08-02 08:13:51 +00:00
if ( DefaultCrosshairColors . f )
return ;
2008-08-28 05:57:46 +00:00
2010-08-02 08:13:51 +00:00
if ( waloff [ CROSSHAIR ] = = 0 )
2008-08-28 05:57:46 +00:00
{
2010-08-02 08:13:51 +00:00
loadtile ( CROSSHAIR ) ;
ptr = ( char * ) waloff [ CROSSHAIR ] ;
2008-08-28 05:57:46 +00:00
}
2010-08-02 08:13:51 +00:00
ii = tilesizx [ CROSSHAIR ] * tilesizy [ CROSSHAIR ] ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ii < = 0 ) return ;
do
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( * ptr ! = 255 )
2006-04-22 00:17:55 +00:00
{
2010-08-02 08:13:51 +00:00
i = curpalette [ ( int32_t ) * ptr ] . r + curpalette [ ( int32_t ) * ptr ] . g + curpalette [ ( int32_t ) * ptr ] . b ;
if ( i > j ) { j = i ; bri = * ptr ; }
2006-04-22 00:17:55 +00:00
}
2010-08-02 08:13:51 +00:00
ptr + + ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
while ( - - ii ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
Bmemcpy ( & CrosshairColors , & curpalette [ bri ] , sizeof ( palette_t ) ) ;
Bmemcpy ( & DefaultCrosshairColors , & curpalette [ bri ] , sizeof ( palette_t ) ) ;
DefaultCrosshairColors . f = 1 ; // this flag signifies that the color has been detected
}
2006-04-22 02:33:36 +00:00
2010-08-02 08:13:51 +00:00
void G_SetCrosshairColor ( int32_t r , int32_t g , int32_t b )
{
char * ptr = ( char * ) waloff [ CROSSHAIR ] ;
int32_t i , ii ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( DefaultCrosshairColors . f = = 0 | | g_crosshairSum = = r + ( g < < 1 ) + ( b < < 2 ) ) return ;
2006-12-23 02:38:47 +00:00
2010-08-02 08:13:51 +00:00
g_crosshairSum = r + ( g < < 1 ) + ( b < < 2 ) ;
CrosshairColors . r = r ;
CrosshairColors . g = g ;
CrosshairColors . b = b ;
2008-08-28 05:57:46 +00:00
2010-08-02 08:13:51 +00:00
if ( waloff [ CROSSHAIR ] = = 0 )
2008-08-28 05:57:46 +00:00
{
2010-08-02 08:13:51 +00:00
loadtile ( CROSSHAIR ) ;
ptr = ( char * ) waloff [ CROSSHAIR ] ;
2008-08-28 05:57:46 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
ii = tilesizx [ CROSSHAIR ] * tilesizy [ CROSSHAIR ] ;
if ( ii < = 0 ) return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) < 3 )
i = getclosestcol ( CrosshairColors . r > > 2 , CrosshairColors . g > > 2 , CrosshairColors . b > > 2 ) ;
else i = getclosestcol ( 63 , 63 , 63 ) ; // use white in GL so we can tint it to the right color
do
2008-09-15 02:47:02 +00:00
{
2010-08-02 08:13:51 +00:00
if ( * ptr ! = 255 )
* ptr = i ;
ptr + + ;
2008-09-15 02:47:02 +00:00
}
2010-08-02 08:13:51 +00:00
while ( - - ii ) ;
2012-03-29 21:17:03 +00:00
makepalookup ( CROSSHAIR_PAL , NULL , CrosshairColors . r > > 2 , CrosshairColors . g > > 2 , CrosshairColors . b > > 2 , 1 ) ;
2010-08-02 08:13:51 +00:00
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2011-09-28 20:30:24 +00:00
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
2010-08-02 08:13:51 +00:00
Bmemcpy ( & hictinting [ CROSSHAIR_PAL ] , & CrosshairColors , sizeof ( palette_t ) ) ;
hictinting [ CROSSHAIR_PAL ] . f = 9 ;
# endif
invalidatetile ( CROSSHAIR , - 1 , - 1 ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
# define SCORESHEETOFFSET -20
static void G_ShowScores ( void )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t t , i ;
2008-07-19 04:13:53 +00:00
2010-08-02 08:13:51 +00:00
if ( playerswhenstarted > 1 & & ( GametypeFlags [ ud . coop ] & GAMETYPE_SCORESHEET ) )
2008-07-19 04:13:53 +00:00
{
2012-03-26 05:07:12 +00:00
gametext ( 160 , SCORESHEETOFFSET + 58 + 2 , " Multiplayer Totals " , 0 , 2 + 8 + 16 ) ;
2010-08-02 08:13:51 +00:00
gametext ( 160 , SCORESHEETOFFSET + 58 + 10 , MapInfo [ ( ud . volume_number * MAXLEVELS ) + ud . last_level - 1 ] . name , 0 , 2 + 8 + 16 ) ;
2008-07-19 04:13:53 +00:00
2010-08-02 08:13:51 +00:00
t = 0 ;
2012-03-26 05:07:12 +00:00
minitext ( 70 , SCORESHEETOFFSET + 80 , " Name " , 8 , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
minitext ( 170 , SCORESHEETOFFSET + 80 , " Frags " , 8 , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
minitext ( 200 , SCORESHEETOFFSET + 80 , " Deaths " , 8 , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
minitext ( 235 , SCORESHEETOFFSET + 80 , " Ping " , 8 , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( i = playerswhenstarted - 1 ; i > = 0 ; i - - )
{
if ( ! g_player [ i ] . playerquitflag )
continue ;
2007-01-22 02:35:54 +00:00
2010-08-02 08:13:51 +00:00
minitext ( 70 , SCORESHEETOFFSET + 90 + t , g_player [ i ] . user_name , g_player [ i ] . ps - > palookup , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
Bsprintf ( tempbuf , " %-4d " , g_player [ i ] . ps - > frag ) ;
minitext ( 170 , SCORESHEETOFFSET + 90 + t , tempbuf , 2 , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
2006-12-09 23:41:43 +00:00
2010-08-02 08:13:51 +00:00
Bsprintf ( tempbuf , " %-4d " , g_player [ i ] . frags [ i ] + g_player [ i ] . ps - > fraggedself ) ;
minitext ( 200 , SCORESHEETOFFSET + 90 + t , tempbuf , 2 , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
2006-12-23 02:38:47 +00:00
2010-08-02 08:13:51 +00:00
Bsprintf ( tempbuf , " %-4d " , g_player [ i ] . ping ) ;
minitext ( 235 , SCORESHEETOFFSET + 90 + t , tempbuf , 2 , 2 + 8 + 16 + ROTATESPRITE_MAX ) ;
t + = 7 ;
}
2010-05-02 23:27:30 +00:00
}
}
2010-08-02 08:13:51 +00:00
# undef SCORESHEETOFFSET
2010-05-02 23:27:30 +00:00
2011-05-22 21:52:22 +00:00
# ifdef YAX_DEBUG
// ugh...
char m32_debugstr [ 64 ] [ 128 ] ;
int32_t m32_numdebuglines = 0 ;
static void M32_drawdebug ( void )
{
int i , col = getclosestcol ( 63 , 63 , 63 ) ;
int x = 4 , y = 8 ;
if ( m32_numdebuglines > 0 )
{
begindrawing ( ) ;
for ( i = 0 ; i < m32_numdebuglines & & y < ydim - 8 ; i + + , y + = 8 )
printext256 ( x , y , col , 0 , m32_debugstr [ i ] , xdim > 640 ? 0 : 1 ) ;
enddrawing ( ) ;
}
m32_numdebuglines = 0 ;
}
# endif
2012-08-22 22:48:21 +00:00
////////// TINT ACCUMULATOR //////////
typedef struct {
int32_t r , g , b ;
// f: 0-63 scale
int32_t maxf , sumf ;
} palaccum_t ;
# define PALACCUM_INITIALIZER { 0, 0, 0, 0, 0 }
/* For a picture frame F and n tints C_1, C_2, ... C_n weighted a_1, a_2,
* . . . a_n ( on a 0 - 1 scale ) , the faded frame is calculated as
*
* F_new : = ( 1 - max_i ( a_i ) ) * F + d * sum_i ( a_i ) , where
*
* d : = max_i ( a_i ) / sum_i ( a_i ) .
*
* This means that
* 1 ) tint application is independent of their order .
* 2 ) going from n + 1 to n tints is continuous .
*
* But note that for more than one tint , the composite tint will in general
* change its hue as the ratio of the weights of the individual ones changes .
*/
static void palaccum_add ( palaccum_t * pa , const palette_t * pal , int32_t f )
{
f = clamp ( f , 0 , 63 ) ;
if ( f = = 0 )
return ;
pa - > maxf = max ( pa - > maxf , f ) ;
pa - > sumf + = f ;
// TODO: we need to do away with this 0-63 scale weirdness someday.
pa - > r + = f * clamp ( pal - > r , 0 , 63 ) ;
pa - > g + = f * clamp ( pal - > g , 0 , 63 ) ;
pa - > b + = f * clamp ( pal - > b , 0 , 63 ) ;
}
static void G_FadePalaccum ( const palaccum_t * pa )
{
setpalettefade ( pa - > r / pa - > sumf , pa - > g / pa - > sumf , pa - > b / pa - > sumf , pa - > maxf ) ;
}
////////// DISPLAYREST //////////
2010-08-02 08:13:51 +00:00
void G_DisplayRest ( int32_t smoothratio )
2010-05-02 23:27:30 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t a , i , j ;
2012-08-22 22:48:21 +00:00
palaccum_t tint = PALACCUM_INITIALIZER ;
2010-05-02 23:27:30 +00:00
2012-08-13 18:25:56 +00:00
DukePlayer_t * const pp = g_player [ screenpeek ] . ps ;
2012-08-22 22:51:38 +00:00
DukePlayer_t * const pp2 = g_fakeMultiMode = = 2 ? g_player [ 1 ] . ps : NULL ;
2010-08-02 08:13:51 +00:00
int32_t cposx , cposy , cang ;
2006-04-13 20:47:06 +00:00
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
// this takes care of fullscreen tint for OpenGL
if ( getrendermode ( ) > = 3 )
2010-05-02 23:27:30 +00:00
{
2011-01-17 03:49:34 +00:00
if ( pp - > palette = = WATERPAL )
2010-05-02 23:27:30 +00:00
{
2012-05-20 07:25:25 +00:00
static const palette_t wp = { 224 , 192 , 255 , 0 } ;
2010-08-02 08:13:51 +00:00
Bmemcpy ( & hictinting [ MAXPALOOKUPS - 1 ] , & wp , sizeof ( palette_t ) ) ;
2010-05-02 23:27:30 +00:00
}
2011-01-17 03:49:34 +00:00
else if ( pp - > palette = = SLIMEPAL )
2010-05-02 23:27:30 +00:00
{
2012-05-20 07:25:25 +00:00
static const palette_t sp = { 208 , 255 , 192 , 0 } ;
2010-08-02 08:13:51 +00:00
Bmemcpy ( & hictinting [ MAXPALOOKUPS - 1 ] , & sp , sizeof ( palette_t ) ) ;
2010-05-02 23:27:30 +00:00
}
2010-08-02 08:13:51 +00:00
else
2010-05-02 23:27:30 +00:00
{
2010-08-02 08:13:51 +00:00
hictinting [ MAXPALOOKUPS - 1 ] . r = 255 ;
hictinting [ MAXPALOOKUPS - 1 ] . g = 255 ;
hictinting [ MAXPALOOKUPS - 1 ] . b = 255 ;
2010-05-02 23:27:30 +00:00
}
}
2012-02-02 17:34:30 +00:00
# endif // USE_OPENGL
2012-08-22 22:48:21 +00:00
palaccum_add ( & tint , & pp - > pals , pp - > pals . f ) ;
if ( pp2 )
palaccum_add ( & tint , & pp2 - > pals , pp2 - > pals . f ) ;
2012-02-09 22:43:06 +00:00
{
2012-08-22 22:48:21 +00:00
static const palette_t loogiepal = { 0 , 63 , 0 , 0 } ;
palaccum_add ( & tint , & loogiepal , pp - > loogcnt > > 1 ) ;
if ( pp2 )
palaccum_add ( & tint , & loogiepal , pp2 - > loogcnt > > 1 ) ;
2012-08-22 22:47:16 +00:00
}
2012-08-22 22:46:09 +00:00
if ( g_restorePalette )
2006-11-15 01:16:55 +00:00
{
2012-08-22 22:46:09 +00:00
// reset a normal palette
2011-05-29 12:30:38 +00:00
static uint32_t omovethingscnt ;
if ( g_restorePalette < 2 | | omovethingscnt + 1 = = g_moveThingsCount )
{
2012-08-22 22:49:27 +00:00
int32_t pal = pp - > palette ;
const int32_t opal = pal ;
if ( pp2 ) // splitscreen HACK: BASEPAL trumps all, then it's arbitrary.
pal = min ( pal , pp2 - > palette ) ;
2012-02-02 17:34:16 +00:00
// g_restorePalette < 0: reset tinting, too (e.g. when loading new game)
2012-08-22 22:49:27 +00:00
P_SetGamePalette ( pp , pal , 2 + ( g_restorePalette > 0 ) * 16 ) ;
if ( pp2 ) // keep first player's pal as its member!
pp - > palette = opal ;
2011-05-29 12:30:38 +00:00
g_restorePalette = 0 ;
}
else
{
// delay setting the palette by one game tic
omovethingscnt = g_moveThingsCount ;
}
2006-04-13 20:47:06 +00:00
}
2012-01-30 21:18:59 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . show_help )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
switch ( ud . show_help )
2006-04-20 22:18:56 +00:00
{
2010-08-02 08:13:51 +00:00
case 1 :
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , TEXTSTORY , 0 , 0 , 10 + 16 + 64 ) ;
2010-08-02 08:13:51 +00:00
break ;
case 2 :
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , F1HELP , 0 , 0 , 10 + 16 + 64 ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-20 22:18:56 +00:00
}
2006-04-13 20:47:06 +00:00
2012-06-03 16:11:22 +00:00
if ( I_ReturnTrigger ( ) )
2010-08-02 08:13:51 +00:00
{
2012-06-03 16:11:22 +00:00
I_ReturnTriggerClear ( ) ;
2010-08-02 08:13:51 +00:00
ud . show_help = 0 ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 )
{
ready2send = 1 ;
totalclock = ototalclock ;
}
G_UpdateScreenArea ( ) ;
}
2012-05-05 22:23:44 +00:00
2010-08-02 08:13:51 +00:00
return ;
2006-04-20 22:18:56 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
i = pp - > cursectnum ;
if ( i > - 1 )
2006-04-13 20:47:06 +00:00
{
2012-08-13 18:25:56 +00:00
const walltype * wal = & wall [ sector [ i ] . wallptr ] ;
2010-08-02 08:13:51 +00:00
show2dsector [ i > > 3 ] | = ( 1 < < ( i & 7 ) ) ;
for ( j = sector [ i ] . wallnum ; j > 0 ; j - - , wal + + )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +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-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
if ( ud . camerasprite = = - 1 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ud . overhead_on ! = 2 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( pp - > newowner > = 0 )
G_DrawCameraText ( pp - > newowner ) ;
else
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
P_DisplayWeapon ( screenpeek ) ;
2012-08-19 13:01:24 +00:00
if ( pp2 ) // HACK
2012-08-16 21:48:33 +00:00
P_DisplayWeapon ( 1 ) ;
2010-08-02 08:13:51 +00:00
if ( pp - > over_shoulder_on = = 0 )
P_DisplayScuba ( screenpeek ) ;
2012-08-19 13:01:24 +00:00
if ( pp2 & & pp2 - > over_shoulder_on = = 0 ) // HACK
P_DisplayScuba ( 1 ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
G_MoveClouds ( ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ud . overhead_on > 0 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
// smoothratio = min(max(smoothratio,0),65536);
2012-09-08 22:18:40 +00:00
smoothratio = calc_smoothratio ( totalclock , ototalclock ) ;
2010-08-02 08:13:51 +00:00
G_DoInterpolations ( smoothratio ) ;
2012-09-08 22:18:40 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . scrollmode = = 0 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( pp - > newowner = = - 1 & & ! ud . pause_on )
2007-08-25 01:05:00 +00:00
{
2012-08-19 13:02:43 +00:00
cposx = pp - > opos . x + mulscale16 ( pp - > pos . x - pp - > opos . x , smoothratio ) ;
cposy = pp - > opos . y + mulscale16 ( pp - > pos . y - pp - > opos . y , smoothratio ) ;
cang = pp - > oang + mulscale16 ( ( ( pp - > ang + 1024 - pp - > oang ) & 2047 ) - 1024 , smoothratio ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
else
2006-06-07 01:29:17 +00:00
{
2010-08-02 08:13:51 +00:00
cposx = pp - > opos . x ;
cposy = pp - > opos . y ;
cang = pp - > oang ;
2006-06-07 01:29:17 +00:00
}
}
else
{
2010-08-02 08:13:51 +00:00
if ( ! ud . pause_on )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +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
}
2010-08-02 08:13:51 +00:00
cposx = ud . folx ;
cposy = ud . foly ;
cang = ud . fola ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ud . overhead_on = = 2 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
clearview ( 0L ) ;
drawmapview ( cposx , cposy , pp - > zoom , cang ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
G_DrawOverheadMap ( cposx , cposy , pp - > zoom , cang ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
G_RestoreInterpolations ( ) ;
if ( ud . overhead_on = = 2 )
2006-05-05 01:20:19 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ud . screen_size > 0 ) a = 147 ;
else a = 179 ;
minitext ( 5 , a + 6 , EpisodeNames [ ud . volume_number ] , 0 , 2 + 8 + 16 + 256 ) ;
minitext ( 5 , a + 6 + 6 , MapInfo [ ud . volume_number * MAXLEVELS + ud . level_number ] . name , 0 , 2 + 8 + 16 + 256 ) ;
2006-05-05 01:20:19 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
if ( pp - > invdisptime > 0 ) G_DrawInventory ( pp ) ;
2006-04-13 20:47:06 +00:00
2012-05-16 00:45:10 +00:00
if ( VM_OnEvent ( EVENT_DISPLAYSBAR , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 , 0 ) = = 0 )
2010-08-02 08:13:51 +00:00
G_DrawStatusBar ( screenpeek ) ;
2006-04-13 20:47:06 +00:00
2012-08-16 21:48:26 +00:00
// HACK
2012-08-22 22:51:38 +00:00
if ( g_fakeMultiMode = = 2 )
2012-08-20 21:32:11 +00:00
{
2012-08-16 21:48:26 +00:00
G_DrawStatusBar ( 1 ) ;
2012-08-20 21:32:11 +00:00
G_PrintGameQuotes ( 1 ) ;
}
2012-08-16 21:48:26 +00:00
2012-08-20 21:32:11 +00:00
G_PrintGameQuotes ( screenpeek ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . show_level_text & & hud_showmapname & & g_levelTextTime > 1 )
2010-05-02 23:27:30 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t bits = 10 + 16 ;
2010-06-22 21:50:01 +00:00
2010-08-02 08:13:51 +00:00
if ( g_levelTextTime < 3 )
bits | = 1 + 32 ;
else if ( g_levelTextTime < 5 )
bits | = 1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( MapInfo [ ( ud . volume_number * MAXLEVELS ) + ud . level_number ] . name ! = NULL )
{
if ( currentboardfilename [ 0 ] ! = 0 & & ud . volume_number = = 0 & & ud . level_number = = 7 )
menutext_ ( 160 , 75 , - g_levelTextTime + 22 /*quotepulseshade*/ , 0 , currentboardfilename , bits ) ;
else menutext_ ( 160 , 75 , - g_levelTextTime + 22 /*quotepulseshade*/ , 0 , MapInfo [ ( ud . volume_number * MAXLEVELS ) + ud . level_number ] . name , bits ) ;
}
}
2006-04-13 20:47:06 +00:00
2012-06-03 16:11:22 +00:00
if ( I_EscapeTrigger ( ) & & ud . overhead_on = = 0
2010-08-02 08:13:51 +00:00
& & ud . show_help = = 0
& & g_player [ myconnectindex ] . ps - > newowner = = - 1 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = MODE_MENU & & g_currentMenu < 51 )
2006-04-13 20:47:06 +00:00
{
2012-06-03 16:11:22 +00:00
I_EscapeTriggerClear ( ) ;
S_PlaySound ( EXITMENUSOUND ) ;
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > gm & = ~ MODE_MENU ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 )
{
ready2send = 1 ;
totalclock = ototalclock ;
g_cameraClock = totalclock ;
g_cameraDistance = 65536L ;
}
walock [ TILE_SAVESHOT ] = 199 ;
G_UpdateScreenArea ( ) ;
}
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 )
{
2012-06-03 16:11:22 +00:00
I_EscapeTriggerClear ( ) ;
2010-08-02 08:13:51 +00:00
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
S_MenuSound ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 ) ready2send = 0 ;
2006-04-13 20:47:06 +00:00
2012-10-14 22:16:07 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) M_ChangeMenu ( 50 ) ;
else M_ChangeMenu ( MENU_MAIN ) ;
2010-08-02 08:13:51 +00:00
screenpeek = myconnectindex ;
2006-04-13 20:47:06 +00:00
}
}
2012-08-19 12:52:18 +00:00
# ifndef LUNATIC
// TODO: get rid of the other outer apScriptGameEvent checks, too
2010-08-02 08:13:51 +00:00
if ( apScriptGameEvent [ EVENT_DISPLAYREST ] )
2012-08-19 12:52:18 +00:00
# endif
2012-05-16 00:45:10 +00:00
VM_OnEvent ( EVENT_DISPLAYREST , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 , 0 ) ;
2010-08-02 08:13:51 +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
{
2012-07-05 17:55:15 +00:00
a = VM_OnEvent ( EVENT_DISPLAYCROSSHAIR , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 , 0 ) ;
if ( a = = 0 | | a > 1 )
2012-05-01 12:39:02 +00:00
{
int32_t x , y ;
2012-07-05 17:55:15 +00:00
if ( a = = 0 )
a = CROSSHAIR ;
2012-05-01 12:39:02 +00:00
# ifdef GEKKO
readmouseabsxy ( & x , & y ) ;
if ( x | | y )
{
x > > = 1 ;
y = ( y * 5 ) / 12 ;
}
else
# endif
{
x = 160 ;
y = 100 ;
}
rotatesprite_win ( ( x - ( g_player [ myconnectindex ] . ps - > look_ang > > 1 ) ) < < 16 , y < < 16 , scale ( 65536 , ud . crosshairscale , 100 ) ,
2012-05-25 05:13:41 +00:00
0 , a , 0 , CROSSHAIR_PAL , 2 + 1 ) ;
2012-05-01 12:39:02 +00:00
}
2010-08-02 08:13:51 +00:00
}
#if 0
if ( GametypeFlags [ ud . coop ] & GAMETYPE_TDM )
{
for ( i = 0 ; i < ud . multimode ; i + + )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( g_player [ i ] . ps - > team = = g_player [ myconnectindex ] . ps - > team )
{
j = min ( max ( ( G_GetAngleDelta ( getangle ( g_player [ i ] . ps - > pos . x - g_player [ myconnectindex ] . ps - > pos . x ,
g_player [ i ] . ps - > pos . y - g_player [ myconnectindex ] . ps - > pos . y ) , g_player [ myconnectindex ] . ps - > ang ) ) > > 1 , - 160 ) , 160 ) ;
2012-02-04 21:35:00 +00:00
rotatesprite_win ( ( 160 - j ) < < 16 , 100L < < 16 , 65536L , 0 , DUKEICON , 0 , 0 , 2 + 1 ) ;
2010-08-02 08:13:51 +00:00
}
}
}
# endif
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . pause_on = = 1 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = 0 )
2012-03-26 05:07:12 +00:00
menutext ( 160 , 100 , 0 , 0 , " Game Paused " ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . coords )
G_PrintCoords ( screenpeek ) ;
2006-04-13 20:47:06 +00:00
2011-05-22 21:52:22 +00:00
# ifdef YAX_DEBUG
M32_drawdebug ( ) ;
# endif
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
{
extern int32_t mdpause ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
mdpause = 0 ;
if ( ud . pause_on | | ( ud . recstat = = 2 & & ( g_demo_paused & & g_demo_goalCnt = = 0 ) ) | | ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU & & numplayers < 2 ) )
mdpause = 1 ;
}
# endif
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
G_PrintFPS ( ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
// JBF 20040124: display level stats in screen corner
if ( ( ud . overhead_on ! = 2 & & ud . levelstats ) & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = 0 )
{
2012-04-13 10:45:49 +00:00
const DukePlayer_t * myps = g_player [ myconnectindex ] . ps ;
2010-08-02 08:13:51 +00:00
if ( ud . screen_size = = 4 )
{
i = scale ( ud . althud ? tilesizy [ BIGALPHANUM ] + 10 : tilesizy [ INVENTORYBOX ] + 2 , ud . statusbarscale , 100 ) ;
// j = scale(scale(6,ud.config.ScreenWidth,320),ud.statusbarscale,100);
}
else if ( ud . screen_size > 2 )
{
i = scale ( tilesizy [ BOTTOMSTATUSBAR ] + 1 , ud . statusbarscale , 100 ) ;
// j = scale(2,ud.config.ScreenWidth,320);
}
else
{
i = 2 ;
// j = scale(2,ud.config.ScreenWidth,320);
}
j = scale ( 2 , ud . config . ScreenWidth , 320 ) ;
2006-11-16 03:02:42 +00:00
2012-04-13 10:45:49 +00:00
2010-08-02 08:13:51 +00:00
Bsprintf ( tempbuf , " T:^15%d:%02d.%02d " ,
2012-04-13 10:45:49 +00:00
( myps - > player_par / ( REALGAMETICSPERSEC * 60 ) ) ,
( myps - > player_par / REALGAMETICSPERSEC ) % 60 ,
( ( myps - > player_par % REALGAMETICSPERSEC ) * 33 ) / 10
2010-08-02 08:13:51 +00:00
) ;
2012-08-24 18:54:01 +00:00
G_PrintGameText ( 8 + 4 + 1 , STARTALPHANUM , j , scale ( 200 - i , ud . config . ScreenHeight , 200 ) - textsc ( 21 ) ,
2012-04-13 10:45:49 +00:00
tempbuf , 0 , 10 , 26 , 0 , 0 , xdim - 1 , ydim - 1 , 65536 ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . player_skill > 3 | | ( ( g_netServer | | ud . multimode > 1 ) & & ! GTFLAGS ( GAMETYPE_PLAYERSFRIENDLY ) ) )
Bsprintf ( tempbuf , " K:^15%d " , ( ud . multimode > 1 & & ! GTFLAGS ( GAMETYPE_PLAYERSFRIENDLY ) ) ?
2012-04-13 10:45:49 +00:00
myps - > frag - myps - > fraggedself : myps - > actors_killed ) ;
2010-08-02 08:13:51 +00:00
else
{
2012-04-13 10:45:49 +00:00
if ( myps - > actors_killed > = myps - > max_actors_killed )
Bsprintf ( tempbuf , " K:%d/%d " , myps - > actors_killed ,
myps - > max_actors_killed > myps - > actors_killed ?
myps - > max_actors_killed : myps - > actors_killed ) ;
2010-08-02 08:13:51 +00:00
else
2012-04-13 10:45:49 +00:00
Bsprintf ( tempbuf , " K:^15%d/%d " , myps - > actors_killed ,
myps - > max_actors_killed > myps - > actors_killed ?
myps - > max_actors_killed : myps - > actors_killed ) ;
2010-08-02 08:13:51 +00:00
}
2012-08-24 18:54:01 +00:00
G_PrintGameText ( 8 + 4 + 1 , STARTALPHANUM , j , scale ( 200 - i , ud . config . ScreenHeight , 200 ) - textsc ( 14 ) ,
2012-04-13 10:45:49 +00:00
tempbuf , 0 , 10 , 26 , 0 , 0 , xdim - 1 , ydim - 1 , 65536 ) ;
2006-04-13 20:47:06 +00:00
2012-04-13 10:45:49 +00:00
if ( myps - > secret_rooms = = myps - > max_secret_rooms )
Bsprintf ( tempbuf , " S:%d/%d " , myps - > secret_rooms , myps - > max_secret_rooms ) ;
else Bsprintf ( tempbuf , " S:^15%d/%d " , myps - > secret_rooms , myps - > max_secret_rooms ) ;
2012-08-24 18:54:01 +00:00
G_PrintGameText ( 8 + 4 + 1 , STARTALPHANUM , j , scale ( 200 - i , ud . config . ScreenHeight , 200 ) - textsc ( 7 ) ,
2012-04-13 10:45:49 +00:00
tempbuf , 0 , 10 , 26 , 0 , 0 , xdim - 1 , ydim - 1 , 65536 ) ;
2010-08-02 08:13:51 +00:00
}
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
if ( g_player [ myconnectindex ] . gotvote = = 0 & & voting ! = - 1 & & voting ! = myconnectindex )
{
2012-03-26 05:07:12 +00:00
Bsprintf ( tempbuf , " %s^00 has called a vote for map " , g_player [ voting ] . user_name ) ;
2010-08-02 08:13:51 +00:00
gametext ( 160 , 40 , tempbuf , 0 , 2 + 8 + 16 ) ;
Bsprintf ( tempbuf , " %s (E%dL%d) " , MapInfo [ vote_episode * MAXLEVELS + vote_map ] . name , vote_episode + 1 , vote_map + 1 ) ;
gametext ( 160 , 48 , tempbuf , 0 , 2 + 8 + 16 ) ;
2012-03-26 05:07:12 +00:00
gametext ( 160 , 70 , " Press F1 to Accept, F2 to Decline " , 0 , 2 + 8 + 16 ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2012-05-05 22:23:44 +00:00
if ( BUTTON ( gamefunc_Show_DukeMatch_Scores ) )
G_ShowScores ( ) ;
2006-04-13 20:47:06 +00:00
2012-05-05 22:23:44 +00:00
if ( g_Debug )
G_ShowCacheLocks ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( VOLUMEONE )
{
if ( ud . show_help = = 0 & & g_showShareware > 0 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) = = 0 )
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( ( 320 - 50 ) < < 16 , 9 < < 16 , 65536L , 0 , BETAVERSION , 0 , 0 , 2 + 8 + 16 + 128 ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2012-09-15 15:28:26 +00:00
if ( ! Demo_IsProfiling ( ) )
{
if ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE )
2012-10-28 22:27:53 +00:00
Net_SendMessage ( ) ;
2012-09-15 15:28:26 +00:00
else
M_DisplayMenus ( ) ;
}
2006-11-16 03:02:42 +00:00
2012-08-20 21:22:41 +00:00
{
static int32_t applied = 0 ;
2012-08-22 22:48:21 +00:00
if ( tint . maxf )
2012-08-20 21:22:41 +00:00
{
2012-08-22 22:48:21 +00:00
G_FadePalaccum ( & tint ) ;
2012-08-20 21:22:41 +00:00
applied = 1 ;
}
else if ( applied )
{
// be sure to always un-apply a tint.
setpalettefade ( 0 , 0 , 0 , 0 ) ;
applied = 0 ;
}
}
2010-08-02 08:13:51 +00:00
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
static void G_DoThirdPerson ( DukePlayer_t * pp , vec3_t * vect , int16_t * vsectnum , int32_t ang , int32_t horiz )
{
spritetype * sp = & sprite [ pp - > i ] ;
int32_t i , hx , hy ;
int32_t daang ;
int32_t bakcstat = sp - > cstat ;
2012-08-10 19:12:01 +00:00
hitdata_t hit ;
2010-08-02 08:13:51 +00:00
vec3_t n = { ( sintable [ ( ang + 1536 ) & 2047 ] > > 4 ) ,
( sintable [ ( ang + 1024 ) & 2047 ] > > 4 ) ,
( horiz - 100 ) * 128
} ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
sp - > cstat & = ( int16_t ) ~ 0x101 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
updatesectorz ( vect - > x , vect - > y , vect - > z , vsectnum ) ;
2012-08-10 19:12:01 +00:00
hitscan ( ( const vec3_t * ) vect , * vsectnum , n . x , n . y , n . z , & hit , CLIPMASK1 ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( * vsectnum < 0 )
{
sp - > cstat = bakcstat ;
return ;
}
2006-11-16 03:02:42 +00:00
2012-08-10 19:12:01 +00:00
hx = hit . pos . x - ( vect - > x ) ;
hy = hit . pos . y - ( vect - > y ) ;
2010-08-02 08:13:51 +00:00
if ( klabs ( n . x ) + klabs ( n . y ) > klabs ( hx ) + klabs ( hy ) )
{
2012-08-10 19:12:01 +00:00
* vsectnum = hit . sect ;
if ( hit . wall > = 0 )
2010-08-02 08:13:51 +00:00
{
2012-08-10 19:12:01 +00:00
daang = getangle ( wall [ wall [ hit . wall ] . point2 ] . x - wall [ hit . wall ] . x ,
wall [ wall [ hit . wall ] . point2 ] . y - wall [ hit . wall ] . y ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
i = n . x * sintable [ daang ] + n . y * sintable [ ( daang + 1536 ) & 2047 ] ;
if ( klabs ( n . x ) > klabs ( n . y ) ) hx - = mulscale28 ( n . x , i ) ;
else hy - = mulscale28 ( n . y , i ) ;
}
2012-08-10 19:12:01 +00:00
else if ( hit . sprite < 0 )
2010-08-02 08:13:51 +00:00
{
if ( klabs ( n . x ) > klabs ( n . y ) ) hx - = ( n . x > > 5 ) ;
else hy - = ( n . y > > 5 ) ;
}
if ( klabs ( n . x ) > klabs ( n . y ) ) i = divscale16 ( hx , n . x ) ;
else i = divscale16 ( hy , n . y ) ;
if ( i < g_cameraDistance ) g_cameraDistance = i ;
}
vect - > x + = mulscale16 ( n . x , g_cameraDistance ) ;
vect - > y + = mulscale16 ( n . y , g_cameraDistance ) ;
vect - > z + = mulscale16 ( n . z , g_cameraDistance ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
g_cameraDistance = min ( g_cameraDistance + ( ( totalclock - g_cameraClock ) < < 10 ) , 65536 ) ;
g_cameraClock = totalclock ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
updatesectorz ( vect - > x , vect - > y , vect - > z , vsectnum ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
sp - > cstat = bakcstat ;
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
//REPLACE FULLY
void G_DrawBackground ( void )
{
int32_t dapicnum ;
int32_t x , y , x1 , y1 , x2 , y2 , rx ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
flushperms ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
dapicnum = BIGHOLE ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( tilesizx [ dapicnum ] = = 0 | | tilesizy [ dapicnum ] = = 0 )
{
pus = pub = NUMPAGES ;
return ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
y1 = 0 ;
y2 = ydim ;
2012-04-04 18:57:20 +00:00
if ( ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) | | ud . recstat = = 2 )
2010-08-02 08:13:51 +00:00
{
if ( GametypeFlags [ ud . coop ] & GAMETYPE_FRAGBAR )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) ) y1 + = scale ( ydim , 8 , 200 ) ;
if ( ud . multimode > 4 ) y1 + = scale ( ydim , 8 , 200 ) ;
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
else
2006-04-13 20:47:06 +00:00
{
2012-05-16 00:45:10 +00:00
int32_t bgtile ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0 ) ;
2012-04-04 18:57:06 +00:00
2010-08-02 08:13:51 +00:00
// when not rendering a game, fullscreen wipe
# define MENUTILE (!getrendermode()?MENUSCREEN:LOADSCREEN)
// Gv_SetVar(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1);
2012-05-16 00:45:10 +00:00
bgtile = ( tilesizx [ MENUTILE ] = = 320 & & tilesizy [ MENUTILE ] = = 200 ? MENUTILE : BIGHOLE ) ;
2010-08-02 08:13:51 +00:00
if ( apScriptGameEvent [ EVENT_GETMENUTILE ] )
2012-05-16 00:45:10 +00:00
bgtile = VM_OnEvent ( EVENT_GETMENUTILE , - 1 , myconnectindex , - 1 , bgtile ) ;
2010-08-02 08:13:51 +00:00
if ( Gv_GetVarByLabel ( " MENU_TILE " , tilesizx [ MENUTILE ] = = 320 & & tilesizy [ MENUTILE ] = = 200 ? 0 : 1 , - 1 , - 1 ) )
2006-04-13 20:47:06 +00:00
{
2012-05-16 00:45:10 +00:00
for ( y = y1 ; y < y2 ; y + = tilesizy [ bgtile ] )
for ( x = 0 ; x < xdim ; x + = tilesizx [ bgtile ] )
rotatesprite_fs ( x < < 16 , y < < 16 , 65536L , 0 , bgtile , bpp = = 8 ? 16 : 8 , 0 , 8 + 16 + 64 ) ;
2006-04-13 20:47:06 +00:00
}
2012-05-16 00:45:10 +00:00
else rotatesprite_fs ( 320 < < 15 , 200 < < 15 , 65536L , 0 , bgtile , bpp = = 8 ? 16 : 8 , 0 , 2 + 8 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2008-08-07 13:23:08 +00:00
2010-08-02 08:13:51 +00:00
y2 = scale ( ydim , 200 - scale ( tilesizy [ BOTTOMSTATUSBAR ] , ud . statusbarscale , 100 ) , 200 ) ;
2008-08-07 13:23:08 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . screen_size > 8 )
{
// 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 , 0 , y1 , xdim - 1 , windowy1 - 1 ) ;
2008-08-08 01:54:43 +00:00
2010-08-02 08:13:51 +00:00
// sides
rx = windowx2 - windowx2 % tilesizx [ dapicnum ] ;
for ( y = windowy1 - windowy1 % tilesizy [ dapicnum ] ; y < windowy2 ; y + = tilesizy [ dapicnum ] )
for ( x = 0 ; x < windowx1 | | x + rx < xdim ; x + = tilesizx [ dapicnum ] )
{
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 , 0 , windowy1 , windowx1 - 1 , windowy2 - 1 ) ;
rotatesprite ( ( x + rx ) < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 , windowx2 , windowy1 , xdim - 1 , windowy2 - 1 ) ;
}
2008-08-08 01:54:43 +00:00
2010-08-02 08:13:51 +00:00
// 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 , 0 , windowy2 , xdim - 1 , y2 - 1 ) ;
2010-05-02 23:27:30 +00:00
}
2008-08-08 01:54:43 +00:00
2010-08-02 08:13:51 +00:00
// draw in the bits to the left and right of the non-fullsize status bar
if ( ud . screen_size > = 8 & & ud . statusbarmode = = 0 )
{
/*
y1 = y2 ;
x2 = ( xdim - scale ( xdim , ud . statusbarscale , 100 ) ) > > 1 ;
x1 = xdim - x2 ;
x1 - = x1 % tilesizx [ dapicnum ] ;
for ( y = y1 - y1 % tilesizy [ dapicnum ] ; y < y2 ; y + = tilesizy [ dapicnum ] )
for ( x = 0 ; x < x2 | | x1 + x < xdim ; x + = tilesizx [ dapicnum ] )
{
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 , 0 , y1 , x2 - 1 , ydim - 1 ) ;
rotatesprite ( ( x + x1 ) < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 , xdim - x2 , y1 , xdim - 1 , ydim - 1 ) ;
}
*/
// when not rendering a game, fullscreen wipe
x2 = ( xdim - scale ( ( int32_t ) ( ydim * 1.333333333333333333f ) , ud . statusbarscale , 100 ) ) > > 1 ;
for ( y = y2 - y2 % tilesizy [ dapicnum ] ; y < ydim ; y + = tilesizy [ dapicnum ] )
for ( x = 0 ; x < xdim > > 1 ; x + = tilesizx [ dapicnum ] )
{
rotatesprite ( x < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 , 0 , y2 , x2 , ydim - 1 ) ;
rotatesprite ( ( xdim - x ) < < 16 , y < < 16 , 65536L , 0 , dapicnum , 8 , 0 , 8 + 16 + 64 , xdim - x2 - 1 , y2 , xdim - 1 , ydim - 1 ) ;
}
2008-10-08 18:49:51 +00:00
2010-08-02 08:13:51 +00:00
}
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . screen_size > 8 )
2010-05-02 23:27:30 +00:00
{
2010-08-02 08:13:51 +00:00
y = 0 ;
if ( GametypeFlags [ ud . coop ] & GAMETYPE_FRAGBAR )
2008-08-07 23:32:18 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) ) y + = 8 ;
if ( ud . multimode > 4 ) y + = 8 ;
2008-10-13 01:16:40 +00:00
}
2008-08-08 01:54:43 +00:00
2010-08-02 08:13:51 +00:00
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 ) ;
2008-08-08 01:54:43 +00:00
2010-08-02 08:13:51 +00:00
for ( y = y1 + 4 ; y < y2 - 4 ; y + = 64 )
{
rotatesprite ( x1 < < 16 , y < < 16 , 65536L , 0 , VIEWBORDER , 0 , 0 , 8 + 16 + 64 , x1 , y1 , x2 , y2 ) ;
rotatesprite ( ( x2 + 1 ) < < 16 , ( y + 64 ) < < 16 , 65536L , 1024 , VIEWBORDER , 0 , 0 , 8 + 16 + 64 , x1 , y1 , x2 , y2 ) ;
}
2008-10-08 18:49:51 +00:00
2010-08-02 08:13:51 +00:00
for ( x = x1 + 4 ; x < x2 - 4 ; x + = 64 )
{
rotatesprite ( ( x + 64 ) < < 16 , y1 < < 16 , 65536L , 512 , VIEWBORDER , 0 , 0 , 8 + 16 + 64 , x1 , y1 , x2 , y2 ) ;
rotatesprite ( x < < 16 , ( y2 + 1 ) < < 16 , 65536L , 1536 , VIEWBORDER , 0 , 0 , 8 + 16 + 64 , x1 , y1 , x2 , y2 ) ;
}
2010-01-23 22:12:02 +00:00
2010-08-02 08:13:51 +00:00
rotatesprite ( x1 < < 16 , y1 < < 16 , 65536L , 0 , VIEWBORDER + 1 , 0 , 0 , 8 + 16 + 64 , x1 , y1 , x2 , y2 ) ;
rotatesprite ( ( x2 + 1 ) < < 16 , y1 < < 16 , 65536L , 512 , VIEWBORDER + 1 , 0 , 0 , 8 + 16 + 64 , x1 , y1 , x2 , y2 ) ;
rotatesprite ( ( x2 + 1 ) < < 16 , ( y2 + 1 ) < < 16 , 65536L , 1024 , VIEWBORDER + 1 , 0 , 0 , 8 + 16 + 64 , x1 , y1 , x2 , y2 ) ;
rotatesprite ( x1 < < 16 , ( y2 + 1 ) < < 16 , 65536L , 1536 , VIEWBORDER + 1 , 0 , 0 , 8 + 16 + 64 , x1 , y1 , x2 , y2 ) ;
2008-08-07 23:32:18 +00:00
}
2010-08-02 08:13:51 +00:00
pus = pub = NUMPAGES ;
}
2008-10-08 18:49:51 +00:00
2010-08-02 08:13:51 +00:00
static int32_t ror_sprite = - 1 ;
2008-10-08 18:49:51 +00:00
2010-08-02 08:13:51 +00:00
extern float r_ambientlight ;
2008-08-08 00:32:16 +00:00
2010-08-02 08:13:51 +00:00
char ror_protectedsectors [ MAXSECTORS ] ;
2012-01-19 21:57:22 +00:00
static int32_t drawing_ror = 0 ;
2008-08-07 13:23:08 +00:00
2012-01-19 21:57:22 +00:00
static void G_SE40 ( int32_t smoothratio )
2006-04-16 03:42:36 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ror_sprite ! = - 1 )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t x , y , z ;
int16_t sect ;
int32_t level = 0 ;
spritetype * sp = & sprite [ ror_sprite ] ;
int32_t sprite2 = sp - > yvel ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
if ( klabs ( sector [ sp - > sectnum ] . floorz - sp - > z ) < klabs ( sector [ sprite [ sprite2 ] . sectnum ] . floorz - sprite [ sprite2 ] . z ) )
level = 1 ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
x = ud . camera . x - sp - > x ;
y = ud . camera . y - sp - > y ;
z = ud . camera . z - ( level ? sector [ sp - > sectnum ] . floorz : sector [ sp - > sectnum ] . ceilingz ) ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
sect = sprite [ sprite2 ] . sectnum ;
updatesector ( sprite [ sprite2 ] . x + x , sprite [ sprite2 ] . y + y , & sect ) ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
if ( sect ! = - 1 )
{
int32_t renderz , picnum ;
int16_t backupstat [ MAXSECTORS ] ;
int32_t backupz [ MAXSECTORS ] ;
int32_t i ;
int32_t pix_diff , newz ;
// initprintf("drawing ror\n");
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
if ( level )
{
// renderz = sector[sprite[sprite2].sectnum].ceilingz;
renderz = sprite [ sprite2 ] . z - ( sprite [ sprite2 ] . yrepeat * tilesizy [ sprite [ sprite2 ] . picnum ] < < 1 ) ;
picnum = sector [ sprite [ sprite2 ] . sectnum ] . ceilingpicnum ;
sector [ sprite [ sprite2 ] . sectnum ] . ceilingpicnum = 562 ;
tilesizx [ 562 ] = tilesizy [ 562 ] = 0 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
pix_diff = klabs ( z ) > > 8 ;
newz = - ( ( pix_diff / 128 ) + 1 ) * ( 128 < < 8 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( i = 0 ; i < numsectors ; i + + )
{
backupstat [ i ] = sector [ i ] . ceilingstat ;
backupz [ i ] = sector [ i ] . ceilingz ;
if ( ! ror_protectedsectors [ i ] | | ( ror_protectedsectors [ i ] & & sp - > lotag = = 41 ) )
{
sector [ i ] . ceilingstat = 1 ;
sector [ i ] . ceilingz + = newz ;
}
}
}
else
{
// renderz = sector[sprite[sprite2].sectnum].floorz;
renderz = sprite [ sprite2 ] . z ;
picnum = sector [ sprite [ sprite2 ] . sectnum ] . floorpicnum ;
sector [ sprite [ sprite2 ] . sectnum ] . floorpicnum = 562 ;
tilesizx [ 562 ] = tilesizy [ 562 ] = 0 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
pix_diff = klabs ( z ) > > 8 ;
newz = ( ( pix_diff / 128 ) + 1 ) * ( 128 < < 8 ) ;
2009-10-01 05:05:19 +00:00
2010-08-02 08:13:51 +00:00
for ( i = 0 ; i < numsectors ; i + + )
{
backupstat [ i ] = sector [ i ] . floorstat ;
backupz [ i ] = sector [ i ] . floorz ;
if ( ! ror_protectedsectors [ i ] | | ( ror_protectedsectors [ i ] & & sp - > lotag = = 41 ) )
{
sector [ i ] . floorstat = 1 ;
sector [ i ] . floorz = + newz ;
}
}
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
# ifdef POLYMER
if ( getrendermode ( ) = = 4 )
polymer_setanimatesprites ( G_DoSpriteAnimations , ud . camera . x , ud . camera . y , ud . cameraang , smoothratio ) ;
# endif
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
drawrooms ( sprite [ sprite2 ] . x + x , sprite [ sprite2 ] . y + y ,
z + renderz , ud . cameraang , ud . camerahoriz , sect ) ;
drawing_ror = 1 + level ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// dupe the sprites touching the portal to the other sector
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( drawing_ror = = 2 ) // viewing from top
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t k = headspritesect [ sp - > sectnum ] ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
while ( k ! = - 1 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( sprite [ k ] . picnum ! = SECTOREFFECTOR & & ( sprite [ k ] . z > = sp - > z ) )
{
Bmemcpy ( ( spritetype * ) & tsprite [ spritesortcnt ] , ( spritetype * ) & sprite [ k ] , sizeof ( spritetype ) ) ;
tsprite [ spritesortcnt ] . x + = ( sprite [ sp - > yvel ] . x - sp - > x ) ;
tsprite [ spritesortcnt ] . y + = ( sprite [ sp - > yvel ] . y - sp - > y ) ;
tsprite [ spritesortcnt ] . z = tsprite [ spritesortcnt ] . z - sp - > z + actor [ sp - > yvel ] . ceilingz ;
tsprite [ spritesortcnt ] . sectnum = sprite [ sp - > yvel ] . sectnum ;
tsprite [ spritesortcnt ] . owner = k ;
//OSD_Printf("duped sprite of pic %d at %d %d %d\n",tsprite[spritesortcnt].picnum,tsprite[spritesortcnt].x,tsprite[spritesortcnt].y,tsprite[spritesortcnt].z);
spritesortcnt + + ;
}
k = nextspritesect [ k ] ;
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
G_DoSpriteAnimations ( ud . camera . x , ud . camera . y , ud . cameraang , smoothratio ) ;
drawmasks ( ) ;
if ( level )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
sector [ sprite [ sprite2 ] . sectnum ] . ceilingpicnum = picnum ;
for ( i = 0 ; i < numsectors ; i + + )
2006-04-19 23:48:43 +00:00
{
2010-08-02 08:13:51 +00:00
sector [ i ] . ceilingstat = backupstat [ i ] ;
sector [ i ] . ceilingz = backupz [ i ] ;
2006-04-19 23:48:43 +00:00
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
else
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
sector [ sprite [ sprite2 ] . sectnum ] . floorpicnum = picnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( i = 0 ; i < numsectors ; i + + )
{
sector [ i ] . floorstat = backupstat [ i ] ;
sector [ i ] . floorz = backupz [ i ] ;
}
2006-04-13 20:47:06 +00:00
}
}
}
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2011-12-28 20:33:40 +00:00
void G_HandleMirror ( int32_t x , int32_t y , int32_t z , int32_t a , int32_t horiz , int32_t smoothratio )
{
if ( ( gotpic [ MIRROR > > 3 ] & ( 1 < < ( MIRROR & 7 ) ) )
# ifdef POLYMER
& & ( getrendermode ( ) ! = 4 )
# endif
)
{
2012-09-02 14:04:16 +00:00
int32_t j , i = 0 , k , dst = INT32_MAX ;
2011-12-28 20:33:40 +00:00
2012-02-25 15:59:44 +00:00
if ( g_mirrorCount = = 0 )
{
// XXX: can we have g_mirrorCount==0 but gotpic'd MIRROR?
gotpic [ MIRROR > > 3 ] & = ~ ( 1 < < ( MIRROR & 7 ) ) ;
# ifdef DEBUGGINGAIDS
initprintf ( " Called G_HandleMirror() with g_mirrorCount==0! \n " ) ;
# endif
return ;
}
2011-12-28 20:33:40 +00:00
for ( k = g_mirrorCount - 1 ; k > = 0 ; k - - )
{
j = klabs ( wall [ g_mirrorWall [ k ] ] . x - x ) ;
j + = klabs ( wall [ g_mirrorWall [ k ] ] . y - y ) ;
if ( j < dst ) dst = j , i = k ;
}
2012-02-25 15:59:44 +00:00
if ( wall [ g_mirrorWall [ i ] ] . overpicnum ! = MIRROR )
{
// try to find a new mirror wall
int32_t startwall = sector [ g_mirrorSector [ i ] ] . wallptr ;
int32_t endwall = startwall + sector [ g_mirrorSector [ i ] ] . wallnum ;
for ( k = startwall ; k < endwall ; k + + )
{
j = wall [ k ] . nextwall ;
if ( j > = 0 & & ( wall [ j ] . cstat & 32 ) & & wall [ j ] . overpicnum = = MIRROR ) // cmp. premap.c
{
g_mirrorWall [ i ] = j ;
break ;
}
}
}
2011-12-28 20:33:40 +00:00
if ( wall [ g_mirrorWall [ i ] ] . overpicnum = = MIRROR )
{
int32_t tposx , tposy ;
int16_t tang ;
preparemirror ( x , y , z , a , horiz , g_mirrorWall [ i ] , g_mirrorSector [ i ] , & tposx , & tposy , & tang ) ;
j = visibility ;
visibility = ( j > > 1 ) + ( j > > 2 ) ;
if ( getrendermode ( ) = = 0 )
{
2012-07-06 15:36:46 +00:00
int32_t didmirror ;
2011-12-28 20:33:40 +00:00
yax_preparedrawrooms ( ) ;
2012-07-06 15:36:46 +00:00
didmirror = drawrooms ( tposx , tposy , z , tang , horiz , g_mirrorSector [ i ] + MAXSECTORS ) ;
2012-08-13 18:25:37 +00:00
yax_drawrooms ( G_DoSpriteAnimations , g_mirrorSector [ i ] , didmirror , smoothratio ) ;
2011-12-28 20:33:40 +00:00
}
# ifdef USE_OPENGL
else
2012-08-13 18:26:01 +00:00
drawrooms ( tposx , tposy , z , tang , horiz , g_mirrorSector [ i ] + MAXSECTORS ) ;
2011-12-28 20:33:40 +00:00
// XXX: Sprites don't get drawn with TROR/Polymost
# endif
display_mirror = 1 ;
G_DoSpriteAnimations ( tposx , tposy , tang , smoothratio ) ;
display_mirror = 0 ;
drawmasks ( ) ;
completemirror ( ) ; //Reverse screen x-wise in this function
visibility = j ;
}
2012-08-13 18:26:08 +00:00
if ( ! g_fakeMultiMode )
{
// HACK for splitscreen mod: this is so that mirrors will be drawn
// from showview commands. Ugly, because we'll attempt do draw mirrors
// each frame then. But it's better than not drawing them, I guess.
// XXX: fix the sequence of setting/clearing this bit. Right now,
// we always draw one frame without drawing the mirror, after which
// the bit gets set and drawn subsequently.
gotpic [ MIRROR > > 3 ] & = ~ ( 1 < < ( MIRROR & 7 ) ) ;
}
2011-12-28 20:33:40 +00:00
}
}
2010-08-02 08:13:51 +00:00
void G_DrawRooms ( int32_t snum , int32_t smoothratio )
{
2012-08-13 18:26:03 +00:00
int32_t i , dont_draw ;
2012-05-26 21:58:21 +00:00
DukePlayer_t * const p = g_player [ snum ] . ps ;
2008-09-15 02:47:02 +00:00
2010-10-17 14:49:39 +00:00
int32_t tmpyx = yxaspect , tmpvr = viewingrange ;
2011-02-25 21:50:19 +00:00
if ( g_networkMode = = NET_DEDICATED_SERVER ) return ;
2010-08-02 08:13:51 +00:00
if ( pub > 0 | | getrendermode ( ) > = 3 ) // JBF 20040101: redraw background always
2008-09-15 02:47:02 +00:00
{
2012-08-16 21:48:58 +00:00
if ( ud . screen_size > = 8 )
2010-08-02 08:13:51 +00:00
G_DrawBackground ( ) ;
pub = 0 ;
2008-09-15 02:47:02 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ud . overhead_on = = 2 | | ud . show_help | | ( p - > cursectnum = = - 1 & & getrendermode ( ) < 3 ) )
return ;
2006-04-13 20:47:06 +00:00
2010-10-17 14:49:39 +00:00
if ( r_usenewaspect )
{
newaspect_enable = 1 ;
setaspect_new ( ) ;
}
2012-05-26 21:58:21 +00:00
if ( ud . pause_on | | g_player [ snum ] . ps - > on_crane > - 1 )
smoothratio = 65536 ;
2012-11-10 14:11:10 +00:00
else
smoothratio = clamp ( ( totalclock - ototalclock ) * ( 65536 / 4 ) , 0 , 65536 ) ;
visibility = ( int32_t ) ( p - > visibility * ( numplayers > 1 ? 1.f : r_ambientlightrecip ) ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
ud . camerasect = p - > cursectnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
G_DoInterpolations ( smoothratio ) ;
G_AnimateCamSprite ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . camerasprite > = 0 )
2006-04-13 20:47:06 +00:00
{
2012-05-26 21:58:21 +00:00
spritetype * const s = & sprite [ ud . camerasprite ] ;
2010-08-02 08:13:51 +00:00
2012-05-26 21:58:21 +00:00
// XXX: what?
2010-08-02 08:13:51 +00:00
if ( s - > yvel < 0 ) s - > yvel = - 100 ;
else if ( s - > yvel > 199 ) s - > yvel = 300 ;
2012-05-26 21:58:21 +00:00
ud . cameraang = actor [ ud . camerasprite ] . tempang +
mulscale16 ( ( ( s - > ang + 1024 - actor [ ud . camerasprite ] . tempang ) & 2047 ) - 1024 , smoothratio ) ;
2010-08-02 08:13:51 +00:00
G_SE40 ( smoothratio ) ;
# ifdef POLYMER
if ( getrendermode ( ) = = 4 )
polymer_setanimatesprites ( G_DoSpriteAnimations , s - > x , s - > y , ud . cameraang , smoothratio ) ;
# endif
2011-05-07 18:23:34 +00:00
yax_preparedrawrooms ( ) ;
2010-08-02 08:13:51 +00:00
drawrooms ( s - > x , s - > y , s - > z - ( 4 < < 8 ) , ud . cameraang , s - > yvel , s - > sectnum ) ;
2012-08-13 18:25:37 +00:00
yax_drawrooms ( G_DoSpriteAnimations , s - > sectnum , 0 , smoothratio ) ;
2010-08-02 08:13:51 +00:00
G_DoSpriteAnimations ( s - > x , s - > y , ud . cameraang , smoothratio ) ;
drawmasks ( ) ;
2006-05-06 05:28:28 +00:00
}
2010-08-02 08:13:51 +00:00
else
2006-08-20 22:17:12 +00:00
{
2012-05-26 21:58:21 +00:00
int32_t j , fz , cz ;
int32_t tiltcx , tiltcy , tiltcs = 0 ; // JBF 20030807
const int32_t vr = divscale22 ( 1 , sprite [ p - > i ] . yrepeat + 28 ) ;
const int32_t software_screen_tilting =
2012-08-16 21:48:28 +00:00
( getrendermode ( ) = = 0 & & ( ( ud . screen_tilting & & p - > rotscrnang & & ! g_fakeMultiMode ) | | ! ud . detail ) ) ;
2010-10-17 14:49:39 +00:00
if ( ! r_usenewaspect )
{
2012-05-26 21:58:21 +00:00
setaspect ( vr , yxaspect ) ;
2010-10-17 14:49:39 +00:00
}
else
2006-08-20 22:17:12 +00:00
{
2012-05-26 21:58:21 +00:00
tmpvr = vr ;
2010-10-17 14:49:39 +00:00
tmpyx = ( 65536 * ydim * 8 ) / ( xdim * 5 ) ;
2011-08-10 11:47:23 +00:00
setaspect ( mulscale16 ( tmpvr , viewingrange ) , yxaspect ) ;
2006-08-20 22:17:12 +00:00
}
2006-12-09 23:41:43 +00:00
2010-08-02 08:13:51 +00:00
if ( g_screenCapture )
{
walock [ TILE_SAVESHOT ] = 199 ;
if ( waloff [ TILE_SAVESHOT ] = = 0 )
allocache ( & waloff [ TILE_SAVESHOT ] , 200 * 320 , & walock [ TILE_SAVESHOT ] ) ;
2012-03-29 21:16:20 +00:00
if ( getrendermode ( ) = = 0 )
2012-05-26 21:58:21 +00:00
setviewtotile ( TILE_SAVESHOT , 200 , 320 ) ;
2010-08-02 08:13:51 +00:00
}
2012-05-26 21:58:21 +00:00
else if ( software_screen_tilting )
2010-08-02 08:13:51 +00:00
{
2012-05-29 20:01:55 +00:00
int32_t oviewingrange = viewingrange ; // save it from setaspect()
2012-05-26 21:58:21 +00:00
const int16_t tang = ( ud . screen_tilting ) ? p - > rotscrnang : 0 ;
2006-12-09 23:41:43 +00:00
2012-05-26 21:58:24 +00:00
// To render a tilted screen in high quality, we need at least
// 640 pixels of *Y* dimension.
# if MAXYDIM >= 640
if ( xres > 320 | | yres > 240 )
{
tiltcs = 2 ;
tiltcx = 640 ;
tiltcy = 400 ;
}
else
# endif
2010-08-02 08:13:51 +00:00
{
// JBF 20030807: Increased tilted-screen quality
tiltcs = 1 ;
tiltcx = 320 ;
tiltcy = 200 ;
}
2006-06-19 19:28:49 +00:00
2012-05-26 21:58:29 +00:00
{
// If the view is rotated (not 0 or 180 degrees modulo 360 degrees),
// we render onto a square tile and display a portion of that
// rotated on-screen later on.
2012-11-15 14:28:41 +00:00
const int32_t viewtilexsiz = ( ( tang & 1023 ) ? tiltcx : tiltcy ) > > ( int ) ! ud . detail ;
const int32_t viewtileysiz = tiltcx > > ( int ) ! ud . detail ;
2012-05-26 21:58:29 +00:00
walock [ TILE_TILT ] = 255 ;
if ( waloff [ TILE_TILT ] = = 0 )
allocache ( & waloff [ TILE_TILT ] , viewtilexsiz * viewtileysiz , & walock [ TILE_TILT ] ) ;
setviewtotile ( TILE_TILT , viewtilexsiz , viewtileysiz ) ;
}
2010-08-02 08:13:51 +00:00
if ( ( tang & 1023 ) = = 512 )
{
//Block off unscreen section of 90ø tilted screen
2012-11-15 14:28:41 +00:00
j = ( ( tiltcx - ( 60 * tiltcs ) ) > > ( int ) ! ud . detail ) ;
for ( i = ( ( 60 * tiltcs ) > > ( int ) ! ud . detail ) - 1 ; i > = 0 ; i - - )
2010-08-02 08:13:51 +00:00
{
startumost [ i ] = 1 ;
startumost [ i + j ] = 1 ;
startdmost [ i ] = 0 ;
startdmost [ i + j ] = 0 ;
}
}
2007-03-11 00:47:32 +00:00
2010-08-02 08:13:51 +00:00
i = ( tang & 511 ) ;
2012-05-26 21:58:21 +00:00
if ( i > 256 )
i = 512 - i ;
2011-08-11 21:49:18 +00:00
i = sintable [ i + 512 ] * 8 + sintable [ i ] * 5 ;
2012-05-26 21:58:21 +00:00
2011-08-11 21:49:18 +00:00
// setaspect(i>>1, yxaspect);
setaspect ( mulscale16 ( oviewingrange , i > > 1 ) , yxaspect ) ;
2010-10-17 14:49:39 +00:00
tmpvr = i > > 1 ;
tmpyx = ( 65536 * ydim * 8 ) / ( xdim * 5 ) ;
2010-08-02 08:13:51 +00:00
}
2012-08-16 21:48:28 +00:00
else if ( getrendermode ( ) > 0 & & ( ud . screen_tilting & & ! g_fakeMultiMode ) /*&& (p->rotscrnang || p->orotscrnang)*/ )
2010-08-02 08:13:51 +00:00
{
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2012-05-26 21:58:21 +00:00
setrollangle ( p - > orotscrnang + mulscale16 ( ( ( p - > rotscrnang - p - > orotscrnang + 1024 ) & 2047 ) - 1024 , smoothratio ) ) ;
2006-12-01 22:34:32 +00:00
# endif
2010-08-02 08:13:51 +00:00
p - > orotscrnang = p - > rotscrnang ; // JBF: save it for next time
}
2006-11-15 01:16:55 +00:00
2012-11-10 14:11:10 +00:00
if ( p - > newowner < 0 )
2010-08-02 08:13:51 +00:00
{
2012-05-26 21:58:21 +00:00
vec3_t cam = { p - > opos . x + mulscale16 ( p - > pos . x - p - > opos . x , smoothratio ) ,
p - > opos . y + mulscale16 ( p - > pos . y - p - > opos . y , smoothratio ) ,
p - > opos . z + mulscale16 ( p - > pos . z - p - > opos . z , smoothratio )
2010-08-02 08:13:51 +00:00
} ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
Bmemcpy ( & ud . camera , & cam , sizeof ( vec3_t ) ) ;
2012-05-26 21:58:21 +00:00
ud . cameraang = p - > oang + mulscale16 ( ( ( p - > ang + 1024 - p - > oang ) & 2047 ) - 1024 , smoothratio ) ;
2012-11-10 14:11:10 +00:00
ud . cameraang + = p - > look_ang ;
2012-05-26 21:58:21 +00:00
ud . camerahoriz = p - > ohoriz + p - > ohorizoff
+ mulscale16 ( ( p - > horiz + p - > horizoff - p - > ohoriz - p - > ohorizoff ) , smoothratio ) ;
2010-08-02 08:13:51 +00:00
2012-11-10 14:11:10 +00:00
if ( ud . viewbob )
{
int32_t addz = ( p - > opyoff + mulscale16 ( p - > pyoff - p - > opyoff , smoothratio ) ) ;
if ( p - > over_shoulder_on )
addz > > = 3 ;
ud . camera . z + = addz ;
}
if ( p - > over_shoulder_on )
{
ud . camera . z - = 3072 ;
G_DoThirdPerson ( p , & ud . camera , & ud . camerasect , ud . cameraang , ud . camerahoriz ) ;
}
}
else
2008-07-30 06:43:23 +00:00
{
2012-11-10 14:11:10 +00:00
// looking through viewscreen
Bmemcpy ( & ud . camera , & p - > pos , sizeof ( vec3_t ) ) ;
2012-05-26 21:58:21 +00:00
ud . cameraang = p - > ang + p - > look_ang ;
2012-11-10 14:11:10 +00:00
ud . camerahoriz = 100 + sprite [ p - > newowner ] . shade ;
2010-08-02 08:13:51 +00:00
ud . camerasect = sprite [ p - > newowner ] . sectnum ;
2012-05-26 21:58:21 +00:00
smoothratio = 65536 ;
2008-07-30 06:43:23 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
cz = actor [ p - > i ] . ceilingz ;
fz = actor [ p - > i ] . floorz ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_earthquakeTime > 0 & & p - > on_ground = = 1 )
2008-07-30 05:41:03 +00:00
{
2010-08-02 08:13:51 +00:00
ud . camera . z + = 256 - ( ( ( g_earthquakeTime ) & 1 ) < < 9 ) ;
ud . cameraang + = ( 2 - ( ( g_earthquakeTime ) & 2 ) ) < < 2 ;
2008-07-30 05:41:03 +00:00
}
2012-05-26 21:58:21 +00:00
if ( sprite [ p - > i ] . pal = = 1 )
ud . camera . z - = ( 18 < < 8 ) ;
2008-08-28 05:57:46 +00:00
2012-11-10 14:11:10 +00:00
if ( p - > newowner < 0 & & p - > spritebridge = = 0 )
2010-08-02 08:13:51 +00:00
{
2012-08-20 21:23:48 +00:00
// NOTE: when shrunk, p->pos.z can be below the floor. This puts the
// camera into the sector again then.
2012-05-26 21:58:21 +00:00
if ( ud . camera . z < ( p - > truecz + ( 4 < < 8 ) ) )
ud . camera . z = cz + ( 4 < < 8 ) ;
else if ( ud . camera . z > ( p - > truefz - ( 4 < < 8 ) ) )
ud . camera . z = fz - ( 4 < < 8 ) ;
2010-08-02 08:13:51 +00:00
}
2010-05-02 23:27:30 +00:00
2012-01-19 23:17:03 +00:00
while ( ud . camerasect > = 0 ) // if, really
2010-08-02 08:13:51 +00:00
{
getzsofslope ( ud . camerasect , ud . camera . x , ud . camera . y , & cz , & fz ) ;
2011-05-07 18:23:34 +00:00
# ifdef YAX_ENABLE
2011-05-12 23:31:13 +00:00
if ( yax_getbunch ( ud . camerasect , YAX_CEILING ) > = 0 )
{
if ( ud . camera . z < cz )
2012-01-19 23:17:03 +00:00
{
2011-05-12 23:31:13 +00:00
updatesectorz ( ud . camera . x , ud . camera . y , ud . camera . z , & ud . camerasect ) ;
2012-01-19 23:17:03 +00:00
break ; // since ud.camerasect might have been updated to -1
// NOTE: fist discovered in WGR2 SVN r134, til' death level 1
// (Lochwood Hollow). A problem REMAINS with Polymost, maybe classic!
}
2011-05-12 23:31:13 +00:00
}
else
2011-05-07 18:23:34 +00:00
# endif
2012-05-26 21:58:21 +00:00
if ( ud . camera . z < cz + ( 4 < < 8 ) )
ud . camera . z = cz + ( 4 < < 8 ) ;
2011-05-12 23:31:13 +00:00
2011-05-07 18:23:34 +00:00
# ifdef YAX_ENABLE
2011-05-12 23:31:13 +00:00
if ( yax_getbunch ( ud . camerasect , YAX_FLOOR ) > = 0 )
{
if ( ud . camera . z > fz )
updatesectorz ( ud . camera . x , ud . camera . y , ud . camera . z , & ud . camerasect ) ;
}
else
2011-05-07 18:23:34 +00:00
# endif
2012-05-26 21:58:21 +00:00
if ( ud . camera . z > fz - ( 4 < < 8 ) )
ud . camera . z = fz - ( 4 < < 8 ) ;
2012-01-19 23:17:03 +00:00
break ;
2010-08-02 08:13:51 +00:00
}
2010-05-02 23:27:30 +00:00
2012-08-13 18:26:03 +00:00
dont_draw = 0 ;
2012-05-29 20:01:44 +00:00
// NOTE: might be rendering off-screen here, so CON commands that draw stuff
// like showview must cope with that situation or bail out!
2010-08-02 08:13:51 +00:00
if ( apScriptGameEvent [ EVENT_DISPLAYROOMS ] )
2012-08-13 18:26:03 +00:00
dont_draw = VM_OnEvent ( EVENT_DISPLAYROOMS , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 , 0 ) ;
2010-05-02 23:27:30 +00:00
2012-03-04 20:13:47 +00:00
ud . camerahoriz = clamp ( ud . camerahoriz , HORIZ_MIN , HORIZ_MAX ) ;
2012-08-13 18:26:03 +00:00
if ( dont_draw ! = 1 ) // event return values other than 0 and 1 are reserved
{
if ( dont_draw ! = 0 )
OSD_Printf ( OSD_ERROR " ERROR: EVENT_DISPLAYROOMS return value must be 0 or 1, "
" other values are reserved. \n " ) ;
G_HandleMirror ( ud . camera . x , ud . camera . y , ud . camera . z , ud . cameraang , ud . camerahoriz , smoothratio ) ;
2006-04-13 20:47:06 +00:00
2012-08-13 18:26:03 +00:00
G_SE40 ( smoothratio ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
# ifdef POLYMER
2012-08-13 18:26:03 +00:00
if ( getrendermode ( ) = = 4 )
polymer_setanimatesprites ( G_DoSpriteAnimations , ud . camera . x , ud . camera . y , ud . cameraang , smoothratio ) ;
2010-08-02 08:13:51 +00:00
# endif
2012-08-13 18:26:03 +00:00
// for G_PrintCoords
dr_viewingrange = viewingrange ;
dr_yxaspect = yxaspect ;
2010-08-02 08:13:51 +00:00
2012-08-13 18:26:03 +00:00
yax_preparedrawrooms ( ) ;
drawrooms ( ud . camera . x , ud . camera . y , ud . camera . z , ud . cameraang , ud . camerahoriz , ud . camerasect ) ;
yax_drawrooms ( G_DoSpriteAnimations , ud . camerasect , 0 , smoothratio ) ;
2012-03-04 20:14:32 +00:00
2012-08-13 18:26:03 +00:00
// dupe the sprites touching the portal to the other sector
2006-04-13 20:47:06 +00:00
2012-08-13 18:26:03 +00:00
if ( ror_sprite ! = - 1 )
2010-08-02 08:13:51 +00:00
{
2012-08-13 18:26:03 +00:00
spritetype * sp = & sprite [ ror_sprite ] ;
2006-04-13 20:47:06 +00:00
2012-08-13 18:26:03 +00:00
// viewing from bottom
if ( drawing_ror = = 1 )
2010-08-02 08:13:51 +00:00
{
2012-08-13 18:26:03 +00:00
int32_t k ;
2006-04-13 20:47:06 +00:00
2012-08-13 18:26:03 +00:00
for ( k = headspritesect [ sp - > sectnum ] ; k ! = - 1 ; k = nextspritesect [ k ] )
{
if ( sprite [ k ] . picnum ! = SECTOREFFECTOR & & ( sprite [ k ] . z > = sp - > z ) )
{
Bmemcpy ( & tsprite [ spritesortcnt ] , & sprite [ k ] , sizeof ( spritetype ) ) ;
tsprite [ spritesortcnt ] . x + = ( sprite [ sp - > yvel ] . x - sp - > x ) ;
tsprite [ spritesortcnt ] . y + = ( sprite [ sp - > yvel ] . y - sp - > y ) ;
tsprite [ spritesortcnt ] . z = tsprite [ spritesortcnt ] . z - sp - > z + actor [ sp - > yvel ] . ceilingz ;
tsprite [ spritesortcnt ] . sectnum = sprite [ sp - > yvel ] . sectnum ;
tsprite [ spritesortcnt ] . owner = k ;
//OSD_Printf("duped sprite of pic %d at %d %d %d\n",tsprite[spritesortcnt].picnum,tsprite[spritesortcnt].x,tsprite[spritesortcnt].y,tsprite[spritesortcnt].z);
spritesortcnt + + ;
}
2010-08-02 08:13:51 +00:00
}
}
}
2006-04-13 20:47:06 +00:00
2012-08-13 18:26:03 +00:00
G_DoSpriteAnimations ( ud . camera . x , ud . camera . y , ud . cameraang , smoothratio ) ;
2006-04-13 20:47:06 +00:00
2012-08-13 18:26:03 +00:00
drawing_ror = 0 ;
drawmasks ( ) ;
}
2006-04-13 20:47:06 +00:00
2012-03-29 21:16:20 +00:00
if ( g_screenCapture )
2010-08-02 08:13:51 +00:00
{
g_screenCapture = 0 ;
2012-03-29 21:16:20 +00:00
if ( getrendermode ( ) = = 0 )
{
setviewback ( ) ;
// walock[TILE_SAVESHOT] = 1;
}
# ifdef USE_OPENGL
else
{
// Save OpenGL screenshot with Duke3D palette
// NOTE: maybe need to move this to the engine...
begindrawing ( ) ;
{
2012-11-15 14:28:29 +00:00
palette_t * const frame = ( palette_t * const ) Bcalloc ( xdim * ydim , 4 ) ;
2012-03-29 21:16:20 +00:00
char * const pic = ( char * ) waloff [ TILE_SAVESHOT ] ;
int32_t x , y ;
const int32_t xf = divscale16 ( xdim , 320 ) ; // (xdim<<16)/320
const int32_t yf = divscale16 ( ydim , 200 ) ; // (ydim<<16)/200
if ( ! frame )
{
Bmemset ( pic , 0 , 320 * 200 ) ;
}
else
{
bglReadPixels ( 0 , 0 , xdim , ydim , GL_RGBA , GL_UNSIGNED_BYTE , frame ) ;
for ( y = 0 ; y < 200 ; y + + )
{
const int32_t base = mulscale16 ( 200 - y - 1 , yf ) * xdim ;
for ( x = 0 ; x < 320 ; x + + )
{
const palette_t * pix = & frame [ base + mulscale16 ( x , xf ) ] ;
pic [ 320 * y + x ] = getclosestcol ( pix - > r > > 2 , pix - > g > > 2 , pix - > b > > 2 ) ;
}
}
Bfree ( frame ) ;
}
}
enddrawing ( ) ;
}
# endif
2010-08-02 08:13:51 +00:00
}
2012-05-26 21:58:21 +00:00
else if ( software_screen_tilting )
2010-08-02 08:13:51 +00:00
{
2012-05-26 21:58:21 +00:00
const int16_t tang = ( ud . screen_tilting ) ? p - > rotscrnang : 0 ;
2010-08-02 08:13:51 +00:00
2012-05-26 21:58:21 +00:00
setviewback ( ) ;
2012-11-17 19:46:28 +00:00
picanm [ TILE_TILT ] . xofs = picanm [ TILE_TILT ] . yofs = 0 ;
2012-05-26 21:58:21 +00:00
i = ( tang & 511 ) ;
if ( i > 256 )
i = 512 - i ;
i = sintable [ i + 512 ] * 8 + sintable [ i ] * 5 ;
if ( ud . detail )
i > > = 1 ;
i > > = ( tiltcs - 1 ) ; // JBF 20030807
rotatesprite_win ( 160 < < 16 , 100 < < 16 , i , tang + 512 , TILE_TILT , 0 , 0 , 4 + 2 + 64 ) ;
walock [ TILE_TILT ] = 199 ;
2010-08-02 08:13:51 +00:00
}
}
G_RestoreInterpolations ( ) ;
if ( totalclock < lastvisinc )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
if ( klabs ( p - > visibility - ud . const_visibility ) > 8 )
p - > visibility + = ( ud . const_visibility - p - > visibility ) > > 2 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
else p - > visibility = ud . const_visibility ;
2010-10-17 14:49:39 +00:00
if ( r_usenewaspect )
{
newaspect_enable = 0 ;
setaspect ( tmpvr , tmpyx ) ;
}
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
static void G_DumpDebugInfo ( void )
{
int32_t i , j , x ;
// FILE * fp=fopen("condebug.log","w");
2012-01-01 04:14:06 +00:00
VM_ScriptInfo ( ) ;
OSD_Printf ( " \n " ) ;
2010-08-02 08:13:51 +00:00
OSD_Printf ( " Current gamevar values: \n " ) ;
for ( i = 0 ; i < MAX_WEAPONS ; i + + )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
for ( j = 0 ; j < numplayers ; j + + )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
OSD_Printf ( " Player %d \n \n " , j ) ;
OSD_Printf ( " WEAPON%d_CLIP % " PRIdPTR " \n " , i , aplWeaponClip [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_RELOAD % " PRIdPTR " \n " , i , aplWeaponReload [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_FIREDELAY % " PRIdPTR " \n " , i , aplWeaponFireDelay [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_TOTALTIME % " PRIdPTR " \n " , i , aplWeaponTotalTime [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_HOLDDELAY % " PRIdPTR " \n " , i , aplWeaponHoldDelay [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_FLAGS % " PRIdPTR " \n " , i , aplWeaponFlags [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_SHOOTS % " PRIdPTR " \n " , i , aplWeaponShoots [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_SPAWNTIME % " PRIdPTR " \n " , i , aplWeaponSpawnTime [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_SPAWN % " PRIdPTR " \n " , i , aplWeaponSpawn [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_SHOTSPERBURST % " PRIdPTR " \n " , i , aplWeaponShotsPerBurst [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_WORKSLIKE % " PRIdPTR " \n " , i , aplWeaponWorksLike [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_INITIALSOUND % " PRIdPTR " \n " , i , aplWeaponInitialSound [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_FIRESOUND % " PRIdPTR " \n " , i , aplWeaponFireSound [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_SOUND2TIME % " PRIdPTR " \n " , i , aplWeaponSound2Time [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_SOUND2SOUND % " PRIdPTR " \n " , i , aplWeaponSound2Sound [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_RELOADSOUND1 % " PRIdPTR " \n " , i , aplWeaponReloadSound1 [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_RELOADSOUND2 % " PRIdPTR " \n " , i , aplWeaponReloadSound2 [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_SELECTSOUND % " PRIdPTR " \n " , i , aplWeaponSelectSound [ i ] [ j ] ) ;
OSD_Printf ( " WEAPON%d_FLASHCOLOR % " PRIdPTR " \n " , i , aplWeaponFlashColor [ i ] [ j ] ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
OSD_Printf ( " \n " ) ;
2007-01-16 03:19:04 +00:00
}
2012-11-15 14:28:04 +00:00
2010-08-02 08:13:51 +00:00
for ( x = 0 ; x < MAXSTATUS ; x + + )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
j = headspritestat [ x ] ;
while ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2012-11-15 14:28:04 +00:00
OSD_Printf_nowarn ( " Sprite %d (%d,%d,%d) (picnum: %d) \n " , j , sprite [ j ] . x , sprite [ j ] . y , sprite [ j ] . z , sprite [ j ] . picnum ) ;
2010-08-02 08:13:51 +00:00
for ( i = 0 ; i < g_gameVarCount ; i + + )
{
if ( aGameVars [ i ] . dwFlags & ( GAMEVAR_PERACTOR ) )
{
if ( aGameVars [ i ] . val . plValues [ j ] ! = aGameVars [ i ] . lDefault )
{
OSD_Printf ( " gamevar %s " , aGameVars [ i ] . szLabel ) ;
OSD_Printf ( " % " PRIdPTR " " , aGameVars [ i ] . val . plValues [ j ] ) ;
OSD_Printf ( " GAMEVAR_PERACTOR " ) ;
if ( aGameVars [ i ] . dwFlags ! = GAMEVAR_PERACTOR )
{
OSD_Printf ( " // " ) ;
if ( aGameVars [ i ] . dwFlags & ( GAMEVAR_SYSTEM ) )
{
OSD_Printf ( " (system) " ) ;
}
}
OSD_Printf ( " \n " ) ;
}
}
}
OSD_Printf ( " \n " ) ;
j = nextspritestat [ j ] ;
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
Gv_DumpValues ( ) ;
// fclose(fp);
2012-10-01 17:52:30 +00:00
saveboard ( " debug.map " , & g_player [ myconnectindex ] . ps - > pos , g_player [ myconnectindex ] . ps - > ang ,
g_player [ myconnectindex ] . ps - > cursectnum ) ;
2010-08-02 08:13:51 +00:00
}
2008-09-26 17:20:10 +00:00
2012-05-26 21:58:21 +00:00
int32_t A_InsertSprite ( int32_t whatsect , int32_t s_x , int32_t s_y , int32_t s_z , int32_t s_pn , int32_t s_s ,
int32_t s_xr , int32_t s_yr , int32_t s_a , int32_t s_ve , int32_t s_zv , int32_t s_ow , int32_t s_ss )
2010-08-02 08:13:51 +00:00
{
int32_t p , i = insertsprite ( whatsect , s_ss ) ;
spritetype * s = & sprite [ i ] ;
2012-11-09 22:31:02 +00:00
spritetype spr_temp ;
memset ( & spr_temp , 0 , sizeof ( spritetype ) ) ;
spr_temp . x = s_x ;
spr_temp . y = s_y ;
spr_temp . z = s_z ;
spr_temp . picnum = s_pn ;
spr_temp . shade = s_s ;
spr_temp . xrepeat = s_xr ;
spr_temp . yrepeat = s_yr ;
spr_temp . sectnum = whatsect ;
spr_temp . statnum = s_ss ;
spr_temp . ang = s_a ;
spr_temp . owner = s_ow ;
spr_temp . xvel = s_ve ;
spr_temp . zvel = s_zv ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( i < 0 )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
G_DumpDebugInfo ( ) ;
2012-11-15 14:28:04 +00:00
OSD_Printf_nowarn ( " Failed spawning pic %d spr from pic %d spr %d at x:%d,y:%d,z:%d,sect:%d \n " ,
2010-08-02 08:13:51 +00:00
s_pn , sprite [ s_ow ] . picnum , s_ow , s_x , s_y , s_z , whatsect ) ;
G_GameExit ( " Too many sprites spawned. " ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
Bmemcpy ( s , & spr_temp , sizeof ( spritetype ) ) ;
Bmemset ( & actor [ i ] , 0 , sizeof ( actor_t ) ) ;
Bmemcpy ( & actor [ i ] . bposx , s , sizeof ( vec3_t ) ) ; // update bposx/y/z
2006-04-13 20:47:06 +00:00
2011-12-25 15:33:24 +00:00
if ( ( unsigned ) s_ow < MAXSPRITES )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
actor [ i ] . picnum = sprite [ s_ow ] . picnum ;
actor [ i ] . floorz = actor [ s_ow ] . floorz ;
actor [ i ] . ceilingz = actor [ s_ow ] . ceilingz ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
actor [ i ] . actorstayput = actor [ i ] . extra = actor [ i ] . lightId = - 1 ;
actor [ i ] . owner = s_ow ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// sprpos[i].ang = sprpos[i].oldang = sprite[i].ang;
2006-04-13 20:47:06 +00:00
2012-10-30 15:54:35 +00:00
if ( g_tile [ s_pn ] . execPtr )
2010-08-02 08:13:51 +00:00
{
2012-10-30 15:54:35 +00:00
s - > extra = * g_tile [ s_pn ] . execPtr ;
T5 = * ( g_tile [ s_pn ] . execPtr + 1 ) ;
T2 = * ( g_tile [ s_pn ] . execPtr + 2 ) ;
2012-06-03 15:46:08 +00:00
# ifdef LUNATIC
2012-08-06 20:00:29 +00:00
set_action_members ( i ) ;
set_move_members ( i ) ;
2012-06-03 15:46:08 +00:00
# endif
2012-10-30 15:54:35 +00:00
s - > hitag = * ( g_tile [ s_pn ] . execPtr + 3 ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( show2dsector [ SECT > > 3 ] & ( 1 < < ( SECT & 7 ) ) ) show2dsprite [ i > > 3 ] | = ( 1 < < ( i & 7 ) ) ;
else show2dsprite [ i > > 3 ] & = ~ ( 1 < < ( i & 7 ) ) ;
2006-04-13 20:47:06 +00:00
2011-12-25 15:33:24 +00:00
Bmemset ( & spriteext [ i ] , 0 , sizeof ( spriteext_t ) ) ;
Bmemset ( & spritesmooth [ i ] , 0 , sizeof ( spritesmooth_t ) ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
A_ResetVars ( i ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( apScriptGameEvent [ EVENT_EGS ] )
{
extern int32_t block_deletesprite ;
int32_t pl = A_FindPlayer ( s , & p ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
block_deletesprite + + ;
2012-05-16 00:45:10 +00:00
VM_OnEvent ( EVENT_EGS , i , pl , p , 0 ) ;
2010-08-02 08:13:51 +00:00
block_deletesprite - - ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
return ( i ) ;
}
2011-06-29 19:57:05 +00:00
# ifdef YAX_ENABLE
void Yax_SetBunchZs ( int32_t sectnum , int32_t cf , int32_t daz )
{
int32_t i , bunchnum = yax_getbunch ( sectnum , cf ) ;
if ( bunchnum < 0 | | bunchnum > = numyaxbunches )
return ;
for ( SECTORS_OF_BUNCH ( bunchnum , YAX_CEILING , i ) )
SECTORFLD ( i , z , YAX_CEILING ) = daz ;
for ( SECTORS_OF_BUNCH ( bunchnum , YAX_FLOOR , i ) )
SECTORFLD ( i , z , YAX_FLOOR ) = daz ;
}
static void Yax_SetBunchInterpolation ( int32_t sectnum , int32_t cf )
{
int32_t i , bunchnum = yax_getbunch ( sectnum , cf ) ;
if ( bunchnum < 0 | | bunchnum > = numyaxbunches )
return ;
for ( SECTORS_OF_BUNCH ( bunchnum , YAX_CEILING , i ) )
G_SetInterpolation ( & sector [ i ] . ceilingz ) ;
for ( SECTORS_OF_BUNCH ( bunchnum , YAX_FLOOR , i ) )
G_SetInterpolation ( & sector [ i ] . floorz ) ;
}
# else
# define Yax_SetBunchInterpolation(sectnum, cf)
# endif
2010-08-02 08:13:51 +00:00
int32_t A_Spawn ( int32_t j , int32_t pn )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t i , s , startwall , endwall , sect , clostest = 0 ;
int32_t x , y , d , p ;
spritetype * sp ;
if ( j > = 0 )
2009-07-04 09:28:21 +00:00
{
2010-08-02 08:13:51 +00:00
i = A_InsertSprite ( sprite [ j ] . sectnum , sprite [ j ] . x , sprite [ j ] . y , sprite [ j ] . z
, pn , 0 , 0 , 0 , 0 , 0 , 0 , j , 0 ) ;
actor [ i ] . picnum = sprite [ j ] . picnum ;
}
else
{
i = pn ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
Bmemset ( & actor [ i ] , 0 , sizeof ( actor_t ) ) ;
Bmemcpy ( & actor [ i ] . bposx , & sprite [ i ] , sizeof ( vec3_t ) ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
actor [ i ] . picnum = PN ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( PN = = SECTOREFFECTOR & & SLT = = 50 )
actor [ i ] . picnum = OW ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
OW = actor [ i ] . owner = i ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
actor [ i ] . floorz = sector [ SECT ] . floorz ;
actor [ i ] . ceilingz = sector [ SECT ] . ceilingz ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
actor [ i ] . actorstayput = actor [ i ] . lightId = actor [ i ] . extra = - 1 ;
if ( PN ! = SPEAKER & & PN ! = LETTER & & PN ! = DUCK & & PN ! = TARGET & & PN ! = TRIPBOMB & & PN ! = VIEWSCREEN & & PN ! = VIEWSCREEN2 & & ( CS & 48 ) )
if ( ! ( PN > = CRACK1 & & PN < = CRACK4 ) )
{
if ( SS = = 127 ) goto SPAWN_END ;
if ( A_CheckSwitchTile ( i ) = = 1 & & ( CS & 16 ) )
2009-07-04 09:28:21 +00:00
{
2010-08-02 08:13:51 +00:00
if ( PN ! = ACCESSSWITCH & & PN ! = ACCESSSWITCH2 & & sprite [ i ] . pal )
2009-07-04 09:28:21 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ( ( ! g_netServer & & ud . multimode < 2 ) ) | | ( ( g_netServer | | ud . multimode > 1 ) & & ! GTFLAGS ( GAMETYPE_DMSWITCHES ) ) )
{
sprite [ i ] . xrepeat = sprite [ i ] . yrepeat = 0 ;
SLT = SHT = 0 ;
sprite [ i ] . cstat = 32768 ;
goto SPAWN_END ;
}
2009-07-04 09:28:21 +00:00
}
2010-08-02 08:13:51 +00:00
CS | = 257 ;
if ( sprite [ i ] . pal & & PN ! = ACCESSSWITCH & & PN ! = ACCESSSWITCH2 )
sprite [ i ] . pal = 0 ;
goto SPAWN_END ;
2009-07-04 09:28:21 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( SHT )
2009-07-04 09:28:21 +00:00
{
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_FALLER ) ;
2010-08-02 08:13:51 +00:00
CS | = 257 ;
SH = g_impactDamage ;
goto SPAWN_END ;
2009-07-04 09:28:21 +00:00
}
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
s = PN ;
2010-05-16 22:53:08 +00:00
2010-08-02 08:13:51 +00:00
if ( CS & 1 ) CS | = 256 ;
2006-04-13 20:47:06 +00:00
2012-10-30 15:54:35 +00:00
if ( g_tile [ s ] . execPtr )
2010-08-02 08:13:51 +00:00
{
2012-10-30 15:54:35 +00:00
SH = * ( g_tile [ s ] . execPtr ) ;
T5 = * ( g_tile [ s ] . execPtr + 1 ) ;
T2 = * ( g_tile [ s ] . execPtr + 2 ) ;
2012-06-03 15:46:08 +00:00
# ifdef LUNATIC
2012-08-06 20:00:29 +00:00
set_action_members ( i ) ;
set_move_members ( i ) ;
2012-06-03 15:46:08 +00:00
# endif
2012-10-30 15:54:35 +00:00
if ( * ( g_tile [ s ] . execPtr + 3 ) & & SHT = = 0 )
SHT = * ( g_tile [ s ] . execPtr + 3 ) ;
2010-08-02 08:13:51 +00:00
}
else T2 = T5 = 0 ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sp = & sprite [ i ] ;
sect = sp - > sectnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
//some special cases that can't be handled through the dynamictostatic system.
2012-08-07 13:09:00 +00:00
if ( ( sp - > picnum > = BOLT1 & & sp - > picnum < = BOLT1 + 3 ) | |
( sp - > picnum > = SIDEBOLT1 & & sp - > picnum < = SIDEBOLT1 + 3 ) )
2010-08-02 08:13:51 +00:00
{
T1 = sp - > xrepeat ;
T2 = sp - > yrepeat ;
sp - > yvel = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2010-08-02 08:13:51 +00:00
}
2012-08-07 13:09:00 +00:00
else if ( ( sp - > picnum > = CAMERA1 & & sp - > picnum < = CAMERA1 + 4 ) | |
sp - > picnum = = CAMERAPOLE | | sp - > picnum = = GENERICPOLE )
2010-08-02 08:13:51 +00:00
{
if ( sp - > picnum ! = GENERICPOLE )
{
sp - > extra = 1 ;
2006-04-13 20:47:06 +00:00
2012-11-24 09:11:30 +00:00
sp - > cstat & = 32768 ;
if ( g_damageCameras ) sp - > cstat | = 257 ;
2010-08-02 08:13:51 +00:00
}
if ( ( ! g_netServer & & ud . multimode < 2 ) & & sp - > pal ! = 0 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
}
else
{
sp - > pal = 0 ;
if ( ! ( sp - > picnum = = CAMERAPOLE | | sp - > picnum = = GENERICPOLE ) )
{
sp - > picnum = CAMERA1 ;
changespritestat ( i , STAT_ACTOR ) ;
}
}
}
2012-01-28 14:38:23 +00:00
else switch ( DYNAMICTILEMAP ( sp - > picnum ) )
2010-08-02 08:13:51 +00:00
{
default :
2012-10-30 15:54:35 +00:00
if ( g_tile [ sp - > picnum ] . execPtr )
2010-08-02 08:13:51 +00:00
{
if ( j = = - 1 & & sp - > lotag > ud . player_skill )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// Init the size
if ( sp - > xrepeat = = 0 | | sp - > yrepeat = = 0 )
sp - > xrepeat = sp - > yrepeat = 1 ;
2012-10-30 15:54:35 +00:00
if ( A_CheckSpriteTileFlags ( sp - > picnum , SPRITE_BADGUY ) )
2010-08-02 08:13:51 +00:00
{
if ( ud . monsters_off = = 1 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2009-07-04 09:28:21 +00:00
}
2010-08-02 08:13:51 +00:00
A_Fall ( i ) ;
2012-10-30 15:54:35 +00:00
if ( A_CheckSpriteTileFlags ( sp - > picnum , SPRITE_BADGUYSTAYPUT ) )
2010-08-02 08:13:51 +00:00
actor [ i ] . actorstayput = sp - > sectnum ;
g_player [ myconnectindex ] . ps - > max_actors_killed + + ;
sp - > clipdist = 80 ;
if ( j > = 0 )
{
if ( sprite [ j ] . picnum = = RESPAWN )
actor [ i ] . tempang = sprite [ i ] . pal = sprite [ j ] . pal ;
changespritestat ( i , STAT_ACTOR ) ;
}
else changespritestat ( i , STAT_ZOMBIEACTOR ) ;
}
else
{
sp - > clipdist = 40 ;
sp - > owner = i ;
changespritestat ( i , STAT_ACTOR ) ;
2009-07-04 09:28:21 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
actor [ i ] . timetosleep = 0 ;
2009-07-04 09:28:21 +00:00
2010-08-02 08:13:51 +00:00
if ( j > = 0 )
sp - > ang = sprite [ j ] . ang ;
}
break ;
case FOF__STATIC :
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
case WATERSPLASH2__STATIC :
if ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
setsprite ( i , ( vec3_t * ) & sprite [ j ] ) ;
sp - > xrepeat = sp - > yrepeat = 8 + ( krand ( ) & 7 ) ;
}
else sp - > xrepeat = sp - > yrepeat = 16 + ( krand ( ) & 15 ) ;
sp - > shade = - 16 ;
sp - > cstat | = 128 ;
if ( j > = 0 )
{
2012-10-14 20:41:21 +00:00
if ( sector [ sprite [ j ] . sectnum ] . lotag = = ST_2_UNDERWATER )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > z = getceilzofslope ( SECT , SX , SY ) + ( 16 < < 8 ) ;
sp - > cstat | = 8 ;
2006-04-13 20:47:06 +00:00
}
2012-10-14 20:41:21 +00:00
else if ( sector [ sprite [ j ] . sectnum ] . lotag = = ST_1_ABOVE_WATER )
2010-08-02 08:13:51 +00:00
sp - > z = getflorzofslope ( SECT , SX , SY ) ;
}
if ( sector [ sect ] . floorpicnum = = FLOORSLIME | |
sector [ sect ] . ceilingpicnum = = FLOORSLIME )
sp - > pal = 7 ;
case DOMELITE__STATIC :
if ( sp - > picnum = = DOMELITE )
sp - > cstat | = 257 ;
case NEON1__STATIC :
case NEON2__STATIC :
case NEON3__STATIC :
case NEON4__STATIC :
case NEON5__STATIC :
case NEON6__STATIC :
if ( sp - > picnum ! = WATERSPLASH2 )
sp - > cstat | = 257 ;
case NUKEBUTTON__STATIC :
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 :
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
case TONGUE__STATIC :
if ( j > = 0 )
sp - > ang = sprite [ j ] . ang ;
sp - > z - = 38 < < 8 ;
sp - > zvel = 256 - ( krand ( ) & 511 ) ;
sp - > xvel = 64 - ( krand ( ) & 127 ) ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_PROJECTILE ) ;
2010-08-02 08:13:51 +00:00
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 - PHEIGHT ;
2009-07-04 09:28:21 +00:00
}
else
{
2010-08-02 08:13:51 +00:00
if ( sprite [ j ] . statnum = = STAT_PROJECTILE )
sp - > xrepeat = sp - > yrepeat = 8 ;
else
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = 48 ;
sp - > yrepeat = 64 ;
if ( sprite [ j ] . statnum = = STAT_PLAYER | | A_CheckEnemySprite ( & sprite [ j ] ) )
sp - > z - = ( 32 < < 8 ) ;
2006-04-13 20:47:06 +00:00
}
2009-07-04 09:28:21 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sp - > shade = - 127 ;
sp - > cstat = 128 | 2 ;
sp - > ang = sprite [ j ] . ang ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sp - > xvel = 128 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
A_SetSprite ( i , CLIPMASK0 ) ;
setsprite ( i , ( vec3_t * ) sp ) ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +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
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2006-10-29 20:18:04 +00:00
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case LASERLINE__STATIC :
sp - > yrepeat = 6 ;
sp - > xrepeat = 32 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_tripbombLaserMode = = 1 )
sp - > cstat = 16 + 2 ;
else if ( g_tripbombLaserMode = = 0 | | g_tripbombLaserMode = = 2 )
sp - > cstat = 16 ;
else
{
sp - > xrepeat = 0 ;
sp - > yrepeat = 0 ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( j > = 0 ) sp - > ang = actor [ j ] . t_data [ 5 ] + 512 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2009-12-30 23:07:00 +00:00
2010-08-02 08:13:51 +00:00
case FORCESPHERE__STATIC :
if ( j = = - 1 )
{
2012-11-18 19:01:34 +00:00
sp - > cstat = 32768 ;
2010-08-02 08:13:51 +00:00
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
}
else
{
sp - > xrepeat = sp - > yrepeat = 1 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
}
break ;
2010-05-16 22:53:08 +00:00
2010-08-02 08:13:51 +00:00
case BLOOD__STATIC :
sp - > xrepeat = sp - > yrepeat = 16 ;
sp - > z - = ( 26 < < 8 ) ;
if ( j > = 0 & & sprite [ j ] . pal = = 6 )
sp - > pal = 6 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
case BLOODPOOL__STATIC :
case PUKE__STATIC :
{
int16_t s1 ;
s1 = sp - > sectnum ;
2010-05-16 22:53:08 +00:00
2010-08-02 08:13:51 +00:00
updatesector ( sp - > x + 108 , sp - > y + 108 , & s1 ) ;
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
{
updatesector ( sp - > x - 108 , sp - > y - 108 , & s1 ) ;
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
{
updatesector ( sp - > x + 108 , sp - > y - 108 , & s1 ) ;
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
{
updatesector ( sp - > x - 108 , sp - > y + 108 , & s1 ) ;
if ( s1 > = 0 & & sector [ s1 ] . floorz ! = sector [ sp - > sectnum ] . floorz )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
}
2010-05-16 22:53:08 +00:00
2010-08-02 08:13:51 +00:00
}
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
}
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
}
else
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2007-02-26 01:46:38 +00:00
}
2006-04-13 20:47:06 +00:00
2012-10-14 20:41:21 +00:00
if ( sector [ SECT ] . lotag = = ST_1_ABOVE_WATER )
2006-04-13 20:47:06 +00:00
{
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( j > = 0 & & sp - > picnum ! = PUKE )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( sprite [ j ] . pal = = 1 )
sp - > pal = 1 ;
else if ( sprite [ j ] . pal ! = 6 & & sprite [ j ] . picnum ! = NUKEBARREL & & sprite [ j ] . picnum ! = TIRE )
{
if ( sprite [ j ] . picnum = = FECES )
sp - > pal = 7 ; // Brown
else sp - > pal = 2 ; // Red
}
else sp - > pal = 0 ; // green
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( sprite [ j ] . picnum = = TIRE )
sp - > shade = 127 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
sp - > cstat | = 32 ;
case FECES__STATIC :
if ( j > = 0 )
sp - > xrepeat = sp - > yrepeat = 1 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case BLOODSPLAT1__STATIC :
case BLOODSPLAT2__STATIC :
case BLOODSPLAT3__STATIC :
case BLOODSPLAT4__STATIC :
sp - > cstat | = 16 ;
sp - > xrepeat = 7 + ( krand ( ) & 7 ) ;
sp - > yrepeat = 7 + ( krand ( ) & 7 ) ;
sp - > z - = ( 16 < < 8 ) ;
if ( j > = 0 & & sprite [ j ] . pal = = 6 )
sp - > pal = 6 ;
A_AddToDeleteQueue ( i ) ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2007-02-13 01:28:50 +00:00
2010-08-02 08:13:51 +00:00
case TRIPBOMB__STATIC :
if ( sp - > lotag > ud . player_skill )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
sp - > xrepeat = 4 ;
sp - > yrepeat = 5 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sp - > owner = sp - > hitag = i ;
2010-05-16 22:53:08 +00:00
2010-08-02 08:13:51 +00:00
sp - > xvel = 16 ;
A_SetSprite ( i , CLIPMASK0 ) ;
actor [ i ] . t_data [ 0 ] = 17 ;
actor [ i ] . t_data [ 2 ] = 0 ;
actor [ i ] . t_data [ 5 ] = sp - > ang ;
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
break ;
2009-07-04 09:28:21 +00:00
2010-08-02 08:13:51 +00:00
case SPACEMARINE__STATIC :
sp - > extra = 20 ;
sp - > cstat | = 257 ;
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
break ;
2009-07-04 09:28:21 +00:00
2010-08-02 08:13:51 +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 :
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_DEFAULT ) ;
2010-08-02 08:13:51 +00:00
break ;
case FEMMAG1__STATIC :
case FEMMAG2__STATIC :
sp - > cstat & = ~ 257 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_DEFAULT ) ;
2010-08-02 08:13:51 +00:00
break ;
case DUKETAG__STATIC :
case SIGN1__STATIC :
case SIGN2__STATIC :
if ( ( ! g_netServer & & ud . multimode < 2 ) & & sp - > pal )
2009-07-04 09:28:21 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
}
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 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_DEFAULT ) ;
2010-08-02 08:13:51 +00:00
break ;
case FOOTPRINTS__STATIC :
case FOOTPRINTS2__STATIC :
case FOOTPRINTS3__STATIC :
case FOOTPRINTS4__STATIC :
if ( j > = 0 )
{
int16_t s1 = sp - > sectnum ;
2009-07-04 09:28:21 +00:00
2010-08-02 08:13:51 +00:00
updatesector ( sp - > x + 84 , sp - > y + 84 , & s1 ) ;
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
2009-07-04 09:28:21 +00:00
{
2010-08-02 08:13:51 +00:00
updatesector ( sp - > x - 84 , sp - > y - 84 , & s1 ) ;
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
2009-07-04 09:28:21 +00:00
{
2010-08-02 08:13:51 +00:00
updatesector ( sp - > x + 84 , sp - > y - 84 , & s1 ) ;
if ( s1 > = 0 & & sector [ s1 ] . floorz = = sector [ sp - > sectnum ] . floorz )
{
updatesector ( sp - > x - 84 , sp - > y + 84 , & s1 ) ;
if ( s1 > = 0 & & sector [ s1 ] . floorz ! = sector [ sp - > sectnum ] . floorz )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
}
}
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
break ;
}
2009-07-04 09:28:21 +00:00
}
2010-08-02 08:13:51 +00:00
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
break ;
}
}
else
{
sp - > xrepeat = sp - > yrepeat = 0 ;
break ;
2009-07-04 09:28:21 +00:00
}
2010-08-02 08:13:51 +00:00
sp - > cstat = 32 + ( ( g_player [ sprite [ j ] . yvel ] . ps - > footprintcount & 1 ) < < 2 ) ;
sp - > ang = sprite [ j ] . ang ;
2009-07-04 09:28:21 +00:00
}
2010-08-02 08:13:51 +00:00
sp - > z = sector [ sect ] . floorz ;
2012-10-14 20:41:21 +00:00
if ( sector [ sect ] . lotag ! = ST_1_ABOVE_WATER & & sector [ sect ] . lotag ! = ST_2_UNDERWATER )
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 32 ;
2010-05-16 22:53:08 +00:00
2010-08-02 08:13:51 +00:00
A_AddToDeleteQueue ( i ) ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case PODFEM1__STATIC :
sp - > extra < < = 1 ;
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 NAKED1__STATIC :
case STATUE__STATIC :
case TOUGHGAL__STATIC :
sp - > yvel = sp - > hitag ;
sp - > hitag = - 1 ;
case BLOODYPOLE__STATIC :
sp - > cstat | = 257 ;
sp - > clipdist = 32 ;
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case QUEBALL__STATIC :
case STRIPEBALL__STATIC :
sp - > cstat = 256 ;
sp - > clipdist = 8 ;
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
break ;
case DUKELYINGDEAD__STATIC :
if ( j > = 0 & & sprite [ j ] . picnum = = APLAYER )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sprite [ j ] . xrepeat ;
sp - > yrepeat = sprite [ j ] . yrepeat ;
sp - > shade = sprite [ j ] . shade ;
sp - > pal = g_player [ sprite [ j ] . yvel ] . ps - > palookup ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +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 BLIMP__STATIC :
sp - > cstat | = 257 ;
sp - > clipdist = 128 ;
changespritestat ( i , STAT_ACTOR ) ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case RESPAWNMARKERRED__STATIC :
sp - > xrepeat = sp - > yrepeat = 24 ;
if ( j > = 0 ) sp - > z = actor [ j ] . floorz ; // -(1<<4);
changespritestat ( i , STAT_ACTOR ) ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case MIKE__STATIC :
sp - > yvel = sp - > hitag ;
sp - > hitag = 0 ;
changespritestat ( i , STAT_ACTOR ) ;
break ;
case WEATHERWARN__STATIC :
changespritestat ( i , STAT_ACTOR ) ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +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 ) ;
A_AddToDeleteQueue ( i ) ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2009-02-19 09:39:19 +00:00
2010-08-02 08:13:51 +00:00
case MONEY__STATIC :
case MAIL__STATIC :
case PAPER__STATIC :
actor [ i ] . t_data [ 0 ] = krand ( ) & 2047 ;
sp - > cstat = krand ( ) & 12 ;
sp - > xrepeat = sp - > yrepeat = 8 ;
sp - > ang = krand ( ) & 2047 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-11-14 19:58:59 +00:00
2010-08-02 08:13:51 +00:00
case VIEWSCREEN__STATIC :
case VIEWSCREEN2__STATIC :
sp - > owner = i ;
sp - > lotag = sp - > extra = 1 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case SHELL__STATIC : //From the player
case SHOTGUNSHELL__STATIC :
if ( j > = 0 )
{
int32_t snum , a ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( sprite [ j ] . picnum = = APLAYER )
{
snum = sprite [ j ] . yvel ;
a = g_player [ snum ] . ps - > ang - ( krand ( ) & 63 ) + 8 ; //Fine tune
2009-07-12 01:55:34 +00:00
2010-08-02 08:13:51 +00:00
T1 = krand ( ) & 1 ;
sp - > z = ( 3 < < 8 ) + g_player [ snum ] . ps - > pyoff + g_player [ snum ] . ps - > pos . z -
( ( g_player [ snum ] . ps - > horizoff + g_player [ snum ] . ps - > horiz - 100 ) < < 4 ) ;
if ( sp - > picnum = = SHOTGUNSHELL )
sp - > z + = ( 3 < < 8 ) ;
sp - > zvel = - ( krand ( ) & 255 ) ;
}
else
{
a = sp - > ang ;
sp - > z = sprite [ j ] . z - PHEIGHT + ( 3 < < 8 ) ;
}
2008-07-30 02:51:32 +00:00
2010-08-02 08:13:51 +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
2010-08-02 08:13:51 +00:00
sp - > shade = - 8 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( sp - > yvel = = 1 | | NAM )
{
sp - > ang = a + 512 ;
sp - > xvel = 30 ;
}
else
{
sp - > ang = a - 512 ;
sp - > xvel = 20 ;
}
sp - > xrepeat = sp - > yrepeat = 4 ;
2007-03-11 00:47:32 +00:00
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case RESPAWN__STATIC :
sp - > extra = 66 - 13 ;
case MUSICANDSFX__STATIC :
if ( ( ! g_netServer & & ud . multimode < 2 ) & & sp - > pal = = 1 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
}
2012-11-18 19:01:34 +00:00
sp - > cstat = 32768 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_FX ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case EXPLOSION2__STATIC :
if ( sp - > yrepeat > 32 )
{
G_AddGameLight ( 0 , i , ( ( sp - > yrepeat * tilesizy [ sp - > picnum ] ) < < 1 ) , 32768 , 255 + ( 95 < < 8 ) , PR_LIGHT_PRIO_MAX_GAME ) ;
actor [ i ] . lightcount = 2 ;
}
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
2010-08-02 08:13:51 +00:00
if ( j > = 0 )
{
sp - > ang = sprite [ j ] . ang ;
sp - > shade = - 64 ;
sp - > cstat = 128 | ( krand ( ) & 4 ) ;
}
2008-02-06 11:42:34 +00:00
2010-08-02 08:13:51 +00:00
if ( sp - > picnum = = EXPLOSION2 | | sp - > picnum = = EXPLOSION2BOT )
{
sp - > xrepeat = sp - > yrepeat = 48 ;
sp - > shade = - 127 ;
sp - > cstat | = 128 ;
}
else if ( sp - > picnum = = SHRINKEREXPLOSION )
sp - > xrepeat = sp - > yrepeat = 32 ;
else if ( sp - > picnum = = SMALLSMOKE )
{
// 64 "money"
sp - > xrepeat = sp - > yrepeat = 24 ;
}
else if ( sp - > picnum = = BURNING | | sp - > picnum = = BURNING2 )
sp - > xrepeat = sp - > yrepeat = 4 ;
2009-12-14 05:23:29 +00:00
2010-08-02 08:13:51 +00:00
sp - > cstat | = 8192 ;
2008-11-16 00:48:02 +00:00
2010-08-02 08:13:51 +00:00
if ( j > = 0 )
{
x = getflorzofslope ( sp - > sectnum , sp - > x , sp - > y ) ;
if ( sp - > z > x - ( 12 < < 8 ) )
sp - > z = x - ( 12 < < 8 ) ;
}
2008-02-06 11:42:34 +00:00
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case PLAYERONWATER__STATIC :
if ( j > = 0 )
{
sp - > xrepeat = sprite [ j ] . xrepeat ;
sp - > yrepeat = sprite [ j ] . yrepeat ;
sp - > zvel = 128 ;
2012-10-14 20:41:21 +00:00
if ( sector [ sp - > sectnum ] . lotag ! = ST_2_UNDERWATER )
2010-08-02 08:13:51 +00:00
sp - > cstat | = 32768 ;
}
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_DUMMYPLAYER ) ;
2010-08-02 08:13:51 +00:00
break ;
2009-08-28 23:08:00 +00:00
2010-08-02 08:13:51 +00:00
case APLAYER__STATIC :
sp - > xrepeat = sp - > yrepeat = 0 ;
sp - > cstat = 32768 ;
2012-08-13 18:25:32 +00:00
if ( ( ! g_netServer & & ud . multimode < 2 ) | |
( ( GametypeFlags [ ud . coop ] & GAMETYPE_COOPSPAWN ) / GAMETYPE_COOPSPAWN ) ! = sp - > lotag )
2010-08-02 08:13:51 +00:00
changespritestat ( i , STAT_MISC ) ;
else
changespritestat ( i , STAT_PLAYER ) ;
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 ;
2008-11-20 14:06:36 +00:00
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2009-10-07 06:47:35 +00:00
2010-08-02 08:13:51 +00:00
case CRANE__STATIC :
2009-07-12 01:55:34 +00:00
2010-08-02 08:13:51 +00:00
sp - > cstat | = 64 | 257 ;
2009-10-07 06:47:35 +00:00
2010-08-02 08:13:51 +00:00
sp - > picnum + = 2 ;
sp - > z = sector [ sect ] . ceilingz + ( 48 < < 8 ) ;
T5 = tempwallptr ;
2008-11-20 14:06:36 +00:00
2010-08-02 08:13:51 +00:00
msx [ tempwallptr ] = sp - > x ;
msy [ tempwallptr ] = sp - > y ;
msx [ tempwallptr + 2 ] = sp - > z ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
s = headspritestat [ STAT_DEFAULT ] ;
while ( s > = 0 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( sprite [ s ] . picnum = = CRANEPOLE & & SHT = = ( sprite [ s ] . hitag ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
msy [ tempwallptr + 2 ] = s ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
T2 = sprite [ s ] . sectnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sprite [ s ] . xrepeat = 48 ;
sprite [ s ] . yrepeat = 128 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
msx [ tempwallptr + 1 ] = sprite [ s ] . x ;
msy [ tempwallptr + 1 ] = sprite [ s ] . y ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sprite [ s ] . x = sp - > x ;
sprite [ s ] . y = sp - > y ;
sprite [ s ] . z = sp - > z ;
sprite [ s ] . shade = sp - > shade ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
setsprite ( s , ( vec3_t * ) & sprite [ s ] ) ;
2006-11-16 03:02:42 +00:00
break ;
}
2010-08-02 08:13:51 +00:00
s = nextspritestat [ s ] ;
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
tempwallptr + = 3 ;
sp - > owner = - 1 ;
sp - > extra = 8 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case TRASH__STATIC :
sp - > ang = krand ( ) & 2047 ;
sp - > xrepeat = sp - > yrepeat = 24 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
case WATERDRIP__STATIC :
if ( j > = 0 & & ( sprite [ j ] . statnum = = STAT_PLAYER | | sprite [ j ] . statnum = = STAT_ACTOR ) )
{
sp - > shade = 32 ;
if ( sprite [ j ] . pal ! = 1 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > pal = 2 ;
sp - > z - = ( 18 < < 8 ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
else sp - > z - = ( 13 < < 8 ) ;
sp - > ang = getangle ( g_player [ 0 ] . ps - > pos . x - sp - > x , g_player [ 0 ] . ps - > pos . y - sp - > y ) ;
sp - > xvel = 48 - ( krand ( ) & 31 ) ;
A_SetSprite ( i , CLIPMASK0 ) ;
}
else if ( j = = - 1 )
{
sp - > z + = ( 4 < < 8 ) ;
T1 = sp - > z ;
T2 = krand ( ) & 127 ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
case WATERDRIPSPLASH__STATIC :
sp - > xrepeat = sp - > yrepeat = 24 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case PLUG__STATIC :
sp - > lotag = 9999 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case TOUCHPLATE__STATIC :
T3 = sector [ sect ] . floorz ;
2012-10-14 20:41:21 +00:00
if ( sector [ sect ] . lotag ! = ST_1_ABOVE_WATER & & sector [ sect ] . lotag ! = ST_2_UNDERWATER )
2010-08-02 08:13:51 +00:00
sector [ sect ] . floorz = sp - > z ;
if ( sp - > pal & & ( g_netServer | | ud . multimode > 1 ) )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
case WATERBUBBLEMAKER__STATIC :
if ( sp - > hitag & & sp - > picnum = = WATERBUBBLEMAKER )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
// JBF 20030913: Pisses off X_Move(), eg. in bobsp2
2012-11-15 14:28:04 +00:00
OSD_Printf_nowarn ( OSD_ERROR " WARNING: WATERBUBBLEMAKER %d @ %d,%d with hitag!=0. Applying fixup. \n " ,
2010-08-02 08:13:51 +00:00
i , sp - > x , sp - > y ) ;
sp - > hitag = 0 ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
sp - > cstat | = 32768 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case MASTERSWITCH__STATIC :
if ( sp - > picnum = = MASTERSWITCH )
sp - > cstat | = 32768 ;
sp - > yvel = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case TARGET__STATIC :
case DUCK__STATIC :
case LETTER__STATIC :
sp - > extra = 1 ;
sp - > cstat | = 257 ;
changespritestat ( i , STAT_ACTOR ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case OCTABRAINSTAYPUT__STATIC :
case LIZTROOPSTAYPUT__STATIC :
case PIGCOPSTAYPUT__STATIC :
case LIZMANSTAYPUT__STATIC :
case BOSS1STAYPUT__STATIC :
case PIGCOPDIVE__STATIC :
case COMMANDERSTAYPUT__STATIC :
case BOSS4STAYPUT__STATIC :
actor [ 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 )
sp - > extra = 1 ;
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 )
2006-11-16 03:02:42 +00:00
{
2012-01-28 14:38:23 +00:00
switch ( DYNAMICTILEMAP ( sp - > picnum ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
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
}
2012-10-30 15:54:35 +00:00
else
{
switch ( DYNAMICTILEMAP ( 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 :
if ( g_scriptVersion = = 13 )
default :
sp - > extra < < = 1 ;
break ;
}
}
2006-04-13 20:47:06 +00:00
2012-10-30 15:54:35 +00:00
if ( sp - > picnum = = BOSS4STAYPUT | | sp - > picnum = = BOSS1 | | sp - > picnum = = BOSS2 | |
sp - > picnum = = BOSS1STAYPUT | | sp - > picnum = = BOSS3 | | sp - > picnum = = BOSS4 )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
if ( j > = 0 & & sprite [ j ] . picnum = = RESPAWN )
sp - > pal = sprite [ j ] . pal ;
if ( sp - > pal )
{
sp - > clipdist = 80 ;
sp - > xrepeat = sp - > yrepeat = 40 ;
}
else
{
sp - > xrepeat = sp - > yrepeat = 80 ;
sp - > clipdist = 164 ;
}
2006-11-16 03:02:42 +00:00
}
else
{
2010-08-02 08:13:51 +00:00
if ( sp - > picnum ! = SHARK )
{
sp - > xrepeat = sp - > yrepeat = 40 ;
sp - > clipdist = 80 ;
}
else
{
sp - > xrepeat = sp - > yrepeat = 60 ;
sp - > clipdist = 40 ;
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( j > = 0 ) sp - > lotag = 0 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( ( sp - > lotag > ud . player_skill ) | | ud . monsters_off = = 1 )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
else
{
2010-08-02 08:13:51 +00:00
A_Fall ( i ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( sp - > picnum = = RAT )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > ang = krand ( ) & 2047 ;
sp - > xrepeat = sp - > yrepeat = 48 ;
sp - > cstat = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
else
{
2010-08-02 08:13:51 +00:00
sp - > cstat | = 257 ;
if ( sp - > picnum ! = SHARK )
g_player [ myconnectindex ] . ps - > max_actors_killed + + ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( sp - > picnum = = ORGANTIC ) sp - > cstat | = 128 ;
if ( j > = 0 )
{
actor [ i ] . timetosleep = 0 ;
A_PlayAlertSound ( i ) ;
changespritestat ( i , STAT_ACTOR ) ;
}
else changespritestat ( i , STAT_ZOMBIEACTOR ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( sp - > picnum = = ROTATEGUN )
sp - > zvel = 0 ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case LOCATORS__STATIC :
sp - > cstat | = 32768 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_LOCATOR ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case ACTIVATORLOCKED__STATIC :
case ACTIVATOR__STATIC :
2012-11-18 19:01:34 +00:00
sp - > cstat = 32768 ;
2010-08-02 08:13:51 +00:00
if ( sp - > picnum = = ACTIVATORLOCKED )
sector [ sp - > sectnum ] . lotag | = 16384 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_ACTIVATOR ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case DOORSHOCK__STATIC :
sp - > cstat | = 1 + 256 ;
sp - > shade = - 12 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case OOZ__STATIC :
case OOZ2__STATIC :
sp - > shade = - 12 ;
if ( j > = 0 )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
if ( sprite [ j ] . picnum = = NUKEBARREL )
sp - > pal = 8 ;
A_AddToDeleteQueue ( i ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
changespritestat ( i , STAT_ACTOR ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
A_GetZLimits ( i ) ;
j = ( actor [ i ] . floorz - actor [ i ] . ceilingz ) > > 9 ;
sp - > yrepeat = j ;
sp - > xrepeat = 25 - ( j > > 1 ) ;
sp - > cstat | = ( krand ( ) & 4 ) ;
2006-04-13 20:47:06 +00:00
2010-05-02 23:27:30 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case REACTOR2__STATIC :
case REACTOR__STATIC :
sp - > extra = g_impactDamage ;
CS | = 257 ;
2012-08-21 17:40:05 +00:00
if ( ( ! g_netServer & & ud . multimode < 2 ) & & sp - > pal ! = 0 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
changespritestat ( i , STAT_MISC ) ;
break ;
}
2010-08-02 08:13:51 +00:00
sp - > pal = 0 ;
SS = - 17 ;
2009-04-24 06:04:13 +00:00
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case HEAVYHBOMB__STATIC :
if ( j > = 0 )
sp - > owner = j ;
else sp - > owner = i ;
sp - > xrepeat = sp - > yrepeat = 9 ;
sp - > yvel = 4 ;
CS | = 257 ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & sp - > pal ! = 0 )
2006-11-16 03:02:42 +00:00
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
sp - > pal = 0 ;
SS = - 17 ;
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
case RECON__STATIC :
if ( sp - > lotag > ud . player_skill )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
goto SPAWN_END ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > max_actors_killed + + ;
actor [ i ] . t_data [ 5 ] = 0 ;
if ( ud . monsters_off = = 1 )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
sp - > extra = 130 ;
CS | = 256 ; // Make it hitable
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
if ( ( ! g_netServer & & ud . multimode < 2 ) & & sp - > pal ! = 0 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
}
sp - > pal = 0 ;
SS = - 17 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case ATOMICHEALTH__STATIC :
case STEROIDS__STATIC :
case HEATSENSOR__STATIC :
case SHIELD__STATIC :
case AIRTANK__STATIC :
case TRIPBOMBSPRITE__STATIC :
case JETPACK__STATIC :
case HOLODUKE__STATIC :
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
case FIRSTGUNSPRITE__STATIC :
case CHAINGUNSPRITE__STATIC :
case SHOTGUNSPRITE__STATIC :
case RPGSPRITE__STATIC :
case SHRINKERSPRITE__STATIC :
case FREEZESPRITE__STATIC :
case DEVISTATORSPRITE__STATIC :
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
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 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j > = 0 )
{
2010-08-02 08:13:51 +00:00
sp - > lotag = 0 ;
sp - > z - = ( 32 < < 8 ) ;
sp - > zvel = - 1024 ;
A_SetSprite ( i , CLIPMASK0 ) ;
sp - > cstat = krand ( ) & 4 ;
}
else
{
sp - > owner = i ;
sp - > cstat = 0 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( ( ! g_netServer & & ud . multimode < 2 ) & & sp - > pal ! = 0 ) | | ( sp - > lotag > ud . player_skill ) )
2006-11-16 03:02:42 +00:00
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
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
2010-08-02 08:13:51 +00:00
sp - > pal = 0 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case ACCESSCARD__STATIC :
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
if ( sp - > picnum = = ATOMICHEALTH )
2006-11-16 03:02:42 +00:00
sp - > cstat | = 128 ;
2010-08-02 08:13:51 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) & & ! GTFLAGS ( GAMETYPE_ACCESSCARDSPRITES ) & & sp - > picnum = = ACCESSCARD )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
else
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
if ( sp - > picnum = = AMMO )
sp - > xrepeat = sp - > yrepeat = 16 ;
else sp - > xrepeat = sp - > yrepeat = 32 ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
sp - > shade = - 17 ;
2009-10-01 05:05:19 +00:00
2010-08-02 08:13:51 +00:00
if ( j > = 0 ) changespritestat ( i , STAT_ACTOR ) ;
else
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
A_Fall ( i ) ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
break ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
case WATERFOUNTAIN__STATIC :
SLT = 1 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
case TREE1__STATIC :
case TREE2__STATIC :
case TIRE__STATIC :
case CONE__STATIC :
case BOX__STATIC :
CS = 257 ; // Make it hitable
sprite [ i ] . extra = 1 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case FLOORFLAME__STATIC :
sp - > shade = - 127 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2010-08-02 08:13:51 +00:00
break ;
case BOUNCEMINE__STATIC :
sp - > owner = i ;
sp - > cstat | = 1 + 256 ; //Make it hitable
sp - > xrepeat = sp - > yrepeat = 24 ;
sp - > shade = - 127 ;
sp - > extra = g_impactDamage < < 2 ;
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
break ;
case STEAM__STATIC :
2006-11-16 03:02:42 +00:00
if ( j > = 0 )
{
2010-08-02 08:13:51 +00:00
sp - > ang = sprite [ j ] . ang ;
sp - > cstat = 16 + 128 + 2 ;
sp - > xrepeat = sp - > yrepeat = 1 ;
sp - > xvel = - 8 ;
A_SetSprite ( i , CLIPMASK0 ) ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
case CEILINGSTEAM__STATIC :
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case SECTOREFFECTOR__STATIC :
sp - > cstat | = 32768 ;
2006-11-16 03:02:42 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
2010-08-02 08:13:51 +00:00
switch ( sp - > lotag )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
case 40 :
case 41 :
sp - > cstat = 32 ;
sp - > xrepeat = sp - > yrepeat = 64 ;
changespritestat ( i , STAT_EFFECTOR ) ;
for ( j = 0 ; j < MAXSPRITES ; j + + )
if ( sprite [ j ] . picnum = = SECTOREFFECTOR & & ( sprite [ j ] . lotag = = 40 | | sprite [ j ] . lotag = = 41 ) & &
sprite [ j ] . hitag = = sp - > hitag & & i ! = j )
{
// initprintf("found ror match\n");
sp - > yvel = j ;
break ;
}
goto SPAWN_END ;
break ;
case 46 :
ror_protectedsectors [ sp - > sectnum ] = 1 ;
2012-05-06 21:01:52 +00:00
/* XXX: fall-through intended? */
2012-10-14 20:41:21 +00:00
case SE_49_POINT_LIGHT :
case SE_50_SPOT_LIGHT :
2010-08-02 08:13:51 +00:00
{
int32_t j , nextj ;
2006-04-13 20:47:06 +00:00
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_SPRITE_SECT ( headspritesect [ sp - > sectnum ] , j , nextj ) )
if ( sprite [ j ] . picnum = = ACTIVATOR | | sprite [ j ] . picnum = = ACTIVATORLOCKED )
actor [ i ] . flags | = SPRITE_USEACTIVATOR ;
2010-08-02 08:13:51 +00:00
}
2012-05-06 21:01:52 +00:00
changespritestat ( i , sp - > lotag = = 46 ? STAT_EFFECTOR : STAT_LIGHT ) ;
2010-08-02 08:13:51 +00:00
goto SPAWN_END ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
sp - > yvel = sector [ sect ] . extra ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
switch ( sp - > lotag )
{
2012-08-26 22:16:08 +00:00
case SE_28_LIGHTNING :
2010-08-02 08:13:51 +00:00
T6 = 65 ; // Delay for lightning
break ;
2012-09-08 22:18:44 +00:00
case SE_7_TELEPORT : // Transporters!!!!
case SE_23_ONE_WAY_TELEPORT : // XPTR END
if ( sp - > lotag ! = SE_23_ONE_WAY_TELEPORT )
2010-08-02 08:13:51 +00:00
{
for ( j = 0 ; j < MAXSPRITES ; j + + )
if ( sprite [ j ] . statnum < MAXSTATUS & & sprite [ j ] . picnum = = SECTOREFFECTOR & &
2012-09-08 22:18:44 +00:00
( sprite [ j ] . lotag = = SE_7_TELEPORT | | sprite [ j ] . lotag = = SE_23_ONE_WAY_TELEPORT ) & & i ! = j & & sprite [ j ] . hitag = = SHT )
2010-08-02 08:13:51 +00:00
{
OW = j ;
break ;
}
}
else OW = i ;
2006-04-13 20:47:06 +00:00
2012-10-14 20:41:17 +00:00
T5 = ( sector [ sect ] . floorz = = SZ ) ; // ONFLOORZ
2010-08-02 08:13:51 +00:00
sp - > cstat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_TRANSPORT ) ;
2010-08-02 08:13:51 +00:00
goto SPAWN_END ;
2012-09-08 22:18:44 +00:00
case SE_1_PIVOT :
2010-08-02 08:13:51 +00:00
sp - > owner = - 1 ;
T1 = 1 ;
break ;
2012-09-08 22:18:44 +00:00
case SE_18_INCREMENTAL_SECTOR_RISE_FALL :
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( sp - > ang = = 512 )
{
T2 = sector [ sect ] . ceilingz ;
if ( sp - > pal )
sector [ sect ] . ceilingz = sp - > z ;
}
else
{
T2 = sector [ sect ] . floorz ;
if ( sp - > pal )
sector [ sect ] . floorz = sp - > z ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sp - > hitag < < = 2 ;
break ;
2012-09-08 22:18:44 +00:00
case SE_19_EXPLOSION_LOWERS_CEILING :
2010-08-02 08:13:51 +00:00
sp - > owner = - 1 ;
break ;
2012-08-26 22:16:08 +00:00
case SE_25_PISTON : // Pistons
2010-08-02 08:13:51 +00:00
T4 = sector [ sect ] . ceilingz ;
T5 = 1 ;
sector [ sect ] . ceilingz = sp - > z ;
G_SetInterpolation ( & sector [ sect ] . ceilingz ) ;
break ;
2012-09-08 22:18:44 +00:00
case SE_35 :
2010-08-02 08:13:51 +00:00
sector [ sect ] . ceilingz = sp - > z ;
break ;
2012-08-26 22:16:08 +00:00
case SE_27_DEMO_CAM :
2010-08-02 08:13:51 +00:00
if ( ud . recstat = = 1 )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 64 ;
sp - > cstat & = 32768 ;
}
break ;
2012-09-08 22:18:44 +00:00
case SE_12_LIGHT_SWITCH :
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
T2 = sector [ sect ] . floorshade ;
T3 = sector [ sect ] . ceilingshade ;
break ;
2006-11-15 01:16:55 +00:00
2012-09-08 22:18:44 +00:00
case SE_13_EXPLOSIVE :
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
T1 = sector [ sect ] . ceilingz ;
T2 = sector [ sect ] . floorz ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
if ( klabs ( T1 - sp - > z ) < klabs ( T2 - sp - > z ) )
sp - > owner = 1 ;
else sp - > owner = 0 ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
if ( sp - > ang = = 512 )
{
if ( sp - > owner )
sector [ sect ] . ceilingz = sp - > z ;
else
sector [ sect ] . floorz = sp - > z ;
2011-06-26 21:59:42 +00:00
# ifdef YAX_ENABLE
{
int16_t cf = ! sp - > owner , bn = yax_getbunch ( sect , cf ) ;
int32_t jj , daz = SECTORFLD ( sect , z , cf ) ;
if ( bn > = 0 )
{
for ( SECTORS_OF_BUNCH ( bn , cf , jj ) )
{
SECTORFLD ( jj , z , cf ) = daz ;
SECTORFLD ( jj , stat , cf ) & = ~ 256 ;
SECTORFLD ( jj , stat , cf ) | = 128 + 512 + 2048 ;
}
for ( SECTORS_OF_BUNCH ( bn , ! cf , jj ) )
{
SECTORFLD ( jj , z , ! cf ) = daz ;
SECTORFLD ( jj , stat , ! cf ) & = ~ 256 ;
SECTORFLD ( jj , stat , ! cf ) | = 128 + 512 + 2048 ;
}
}
}
# endif
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
else
sector [ sect ] . ceilingz = sector [ sect ] . floorz = sp - > z ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( sector [ sect ] . ceilingstat & 1 )
{
sector [ sect ] . ceilingstat ^ = 1 ;
T4 = 1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ! sp - > owner & & sp - > ang = = 512 )
{
sector [ sect ] . ceilingstat ^ = 1 ;
T4 = 0 ;
}
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
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 ) )
{
sector [ sect ] . ceilingpicnum =
sector [ x ] . ceilingpicnum ;
sector [ sect ] . ceilingshade =
sector [ x ] . ceilingshade ;
break ; //Leave earily
}
}
}
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
2012-08-26 22:16:08 +00:00
case SE_17_WARP_ELEVATOR :
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
T3 = sector [ sect ] . floorz ; //Stopping loc
j = nextsectorneighborz ( sect , sector [ sect ] . floorz , - 1 , - 1 ) ;
2012-08-26 22:17:14 +00:00
if ( j > = 0 )
{
T4 = sector [ j ] . ceilingz ;
2012-09-12 09:48:31 +00:00
}
else
{
// use elevator sector's ceiling as heuristic
T4 = sector [ sect ] . ceilingz ;
2010-08-02 08:13:51 +00:00
2012-09-12 09:48:31 +00:00
OSD_Printf ( OSD_ERROR " WARNING: SE17 sprite %d using own sector's ceilingz to "
" determine when to warp. Sector %d adjacent to a door? \n " , i , sect ) ;
2012-08-26 22:17:14 +00:00
}
2012-09-12 09:48:31 +00:00
j = nextsectorneighborz ( sect , sector [ sect ] . ceilingz , 1 , 1 ) ;
if ( j > = 0 )
T5 = sector [ j ] . floorz ;
else
2012-08-26 22:17:14 +00:00
{
// XXX: we should return to the menu for this and similar failures
2012-11-15 14:28:04 +00:00
Bsprintf_nowarn ( tempbuf , " SE 17 (warp elevator) setup failed: sprite %d at (%d, %d) " ,
2012-08-26 22:17:14 +00:00
i , sprite [ i ] . x , sprite [ i ] . y ) ;
G_GameExit ( tempbuf ) ;
}
2010-08-02 08:13:51 +00:00
if ( numplayers < 2 & & ! g_netServer )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
G_SetInterpolation ( & sector [ sect ] . floorz ) ;
G_SetInterpolation ( & sector [ sect ] . ceilingz ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
case SE_24_CONVEYOR :
2010-08-02 08:13:51 +00:00
sp - > yvel < < = 1 ;
2012-08-26 22:16:08 +00:00
case SE_36_PROJ_SHOOTER :
2006-04-13 20:47:06 +00:00
break ;
2010-08-02 08:13:51 +00:00
2012-09-08 22:18:44 +00:00
case SE_20_STRETCH_BRIDGE :
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t q ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
//find the two most clostest wall x's and y's
2012-09-02 14:04:16 +00:00
q = INT32_MAX ;
2010-08-02 08:13:51 +00:00
for ( s = startwall ; s < endwall ; s + + )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
x = wall [ s ] . x ;
y = wall [ s ] . y ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
d = FindDistance2D ( sp - > x - x , sp - > y - y ) ;
if ( d < q )
{
q = d ;
clostest = s ;
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
T2 = clostest ;
2006-04-13 20:47:06 +00:00
2012-09-02 14:04:16 +00:00
q = INT32_MAX ;
2010-08-02 08:13:51 +00:00
for ( s = startwall ; s < endwall ; s + + )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
x = wall [ s ] . x ;
y = wall [ s ] . y ;
d = FindDistance2D ( sp - > x - x , sp - > y - y ) ;
if ( d < q & & s ! = T2 )
{
q = d ;
clostest = s ;
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +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
2012-09-12 09:45:14 +00:00
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT :
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
T4 = sector [ sect ] . floorshade ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sector [ sect ] . floorshade = sp - > shade ;
sector [ sect ] . ceilingshade = sp - > shade ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sp - > owner = sector [ sect ] . ceilingpal < < 8 ;
sp - > owner | = sector [ sect ] . floorpal ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
//fix all the walls;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +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
2012-08-26 22:16:08 +00:00
case SE_31_FLOOR_RISE_FALL :
2011-06-29 19:57:05 +00:00
{
2010-08-02 08:13:51 +00:00
T2 = sector [ sect ] . floorz ;
// T3 = sp->hitag;
2011-06-29 19:57:05 +00:00
if ( sp - > ang ! = 1536 )
{
sector [ sect ] . floorz = sp - > z ;
Yax_SetBunchZs ( sect , YAX_FLOOR , sp - > z ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +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
2010-08-02 08:13:51 +00:00
G_SetInterpolation ( & sector [ sect ] . floorz ) ;
2011-06-29 19:57:05 +00:00
Yax_SetBunchInterpolation ( sect , YAX_FLOOR ) ;
}
break ;
2010-06-26 08:51:42 +00:00
2012-08-26 22:16:08 +00:00
case SE_32_CEILING_RISE_FALL :
2011-06-29 19:57:05 +00:00
{
2010-08-02 08:13:51 +00:00
T2 = sector [ sect ] . ceilingz ;
T3 = sp - > hitag ;
2011-06-29 19:57:05 +00:00
if ( sp - > ang ! = 1536 )
{
sector [ sect ] . ceilingz = sp - > z ;
Yax_SetBunchZs ( sect , YAX_CEILING , sp - > z ) ;
}
2010-06-26 08:51:42 +00:00
2010-08-02 08:13:51 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
for ( s = startwall ; s < endwall ; s + + )
if ( wall [ s ] . hitag = = 0 ) wall [ s ] . hitag = 9999 ;
G_SetInterpolation ( & sector [ sect ] . ceilingz ) ;
2011-06-29 19:57:05 +00:00
Yax_SetBunchInterpolation ( sect , YAX_CEILING ) ;
}
break ;
2010-05-02 23:27:30 +00:00
2012-09-12 09:45:14 +00:00
case SE_4_RANDOM_LIGHTS : //Flashing lights
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
T3 = sector [ sect ] . floorshade ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
sp - > owner = sector [ sect ] . ceilingpal < < 8 ;
sp - > owner | = sector [ sect ] . floorpal ;
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-15 01:16:55 +00:00
break ;
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_9_DOWN_OPEN_DOOR_LIGHTS :
2010-08-02 08:13:51 +00:00
if ( sector [ sect ] . lotag & &
labs ( sector [ sect ] . ceilingz - sp - > z ) > 1024 )
sector [ sect ] . lotag | = 32768 ; //If its open
2012-09-08 22:18:44 +00:00
case SE_8_UP_OPEN_DOOR_LIGHTS :
2010-08-02 08:13:51 +00:00
//First, get the ceiling-floor shade
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
T1 = sector [ sect ] . floorshade ;
T2 = sector [ sect ] . ceilingshade ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
for ( s = startwall ; s < endwall ; s + + )
if ( wall [ s ] . shade > T3 )
T3 = wall [ s ] . shade ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
T4 = 1 ; //Take Out;
2006-11-16 03:02:42 +00:00
2006-04-13 20:47:06 +00:00
break ;
2012-09-08 22:18:44 +00:00
case SE_11_SWINGING_DOOR : //Pivitor rotater
2010-08-02 08:13:51 +00:00
if ( sp - > ang > 1024 ) T4 = 2 ;
else T4 = - 2 ;
2012-09-08 22:18:44 +00:00
case SE_0_ROTATING_SECTOR :
case SE_2_EARTHQUAKE : //Earthquakemakers
case SE_5 : //Boss Creature
case SE_6_SUBWAY : //Subway
case SE_14_SUBWAY_CAR : //Caboos
case SE_15_SLIDING_DOOR : //Subwaytype sliding door
2012-08-26 22:16:08 +00:00
case SE_16_REACTOR : //That rotating blocker reactor thing
case SE_26 : //ESCELATOR
case SE_30_TWO_WAY_TRAIN : //No rotational subways
2010-08-02 08:13:51 +00:00
if ( sp - > lotag = = 0 )
{
2012-08-26 22:16:08 +00:00
if ( sector [ sect ] . lotag = = ST_30_ROTATE_RISE_BRIDGE )
2010-08-02 08:13:51 +00:00
{
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
2010-08-02 08:13:51 +00:00
for ( j = MAXSPRITES - 1 ; j > = 0 ; j - - )
{
if ( sprite [ j ] . statnum < MAXSTATUS )
if ( sprite [ j ] . picnum = = SECTOREFFECTOR & &
sprite [ j ] . lotag = = 1 & &
sprite [ j ] . hitag = = sp - > hitag )
{
if ( sp - > ang = = 512 )
{
sp - > x = sprite [ j ] . x ;
sp - > y = sprite [ j ] . y ;
}
break ;
}
}
if ( j = = - 1 )
{
2012-11-15 14:28:04 +00:00
OSD_Printf_nowarn ( OSD_ERROR " Found lonely Sector Effector (lotag 0) at (%d,%d) \n " , sp - > x , sp - > y ) ;
2010-08-02 08:13:51 +00:00
changespritestat ( i , STAT_ACTOR ) ;
if ( apScriptGameEvent [ EVENT_SPAWN ] )
{
int32_t pl = A_FindPlayer ( & sprite [ i ] , & p ) ;
2012-05-16 00:45:10 +00:00
VM_OnEvent ( EVENT_SPAWN , i , pl , p , 0 ) ;
2010-08-02 08:13:51 +00:00
}
return i ;
}
sp - > owner = j ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +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 )
{
2012-11-15 14:28:04 +00:00
Bsprintf_nowarn ( tempbuf , " Too many moving sectors at (%d,%d). \n " , wall [ s ] . x , wall [ s ] . y ) ;
2010-08-02 08:13:51 +00:00
G_GameExit ( tempbuf ) ;
}
}
2011-06-26 21:59:42 +00:00
2012-09-08 22:18:44 +00:00
if ( sp - > lotag = = SE_30_TWO_WAY_TRAIN | | sp - > lotag = = SE_6_SUBWAY | | sp - > lotag = = SE_14_SUBWAY_CAR | | sp - > lotag = = SE_5 )
2010-08-02 08:13:51 +00:00
{
2011-06-26 21:59:42 +00:00
# ifdef YAX_ENABLE
int32_t outerwall = - 1 ;
# endif
2010-08-02 08:13:51 +00:00
startwall = sector [ sect ] . wallptr ;
endwall = startwall + sector [ sect ] . wallnum ;
2006-11-16 03:02:42 +00:00
2012-11-15 14:28:18 +00:00
if ( sector [ sect ] . hitag = = UINT16_MAX )
2010-08-02 08:13:51 +00:00
sp - > extra = 0 ;
else sp - > extra = 1 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
sector [ sect ] . hitag = i ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
j = 0 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +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 )
{
2011-06-26 21:59:42 +00:00
# ifdef YAX_ENABLE
outerwall = wall [ s ] . nextwall ;
# endif
2010-08-02 08:13:51 +00:00
s = wall [ s ] . nextsector ;
j = 1 ;
break ;
}
}
2011-06-26 21:59:42 +00:00
# ifdef YAX_ENABLE
actor [ i ] . t_data [ 9 ] = - 1 ;
2006-11-16 03:02:42 +00:00
2011-06-26 21:59:42 +00:00
if ( outerwall > = 0 )
{
2011-09-15 17:02:35 +00:00
int32_t uppersect = yax_vnextsec ( outerwall , YAX_CEILING ) ;
2011-06-26 21:59:42 +00:00
2011-09-15 17:02:35 +00:00
if ( uppersect > = 0 )
2011-06-26 21:59:42 +00:00
{
2011-09-15 17:02:35 +00:00
int32_t jj ;
2011-07-01 17:15:07 +00:00
for ( jj = headspritesect [ uppersect ] ; jj > = 0 ; jj = nextspritesect [ jj ] )
if ( sprite [ jj ] . picnum = = SECTOREFFECTOR & & sprite [ jj ] . lotag = = sp - > lotag )
break ;
if ( jj < 0 )
{
2011-09-15 17:02:35 +00:00
Sect_SetInterpolation ( uppersect ) ;
actor [ i ] . t_data [ 9 ] = uppersect ;
2011-07-01 17:15:07 +00:00
}
2011-06-26 21:59:42 +00:00
}
}
# endif
2010-08-02 08:13:51 +00:00
if ( j = = 0 )
2009-07-04 09:28:21 +00:00
{
2012-11-15 14:28:04 +00:00
Bsprintf_nowarn ( tempbuf , " Subway found no zero'd sectors with locators \n at (%d,%d). \n " , sp - > x , sp - > y ) ;
2010-08-02 08:13:51 +00:00
G_GameExit ( tempbuf ) ;
2009-07-04 09:28:21 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sp - > owner = - 1 ;
T1 = s ;
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
if ( sp - > lotag ! = SE_30_TWO_WAY_TRAIN )
2010-08-02 08:13:51 +00:00
T4 = sp - > hitag ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
else if ( sp - > lotag = = SE_16_REACTOR )
2010-08-02 08:13:51 +00:00
T4 = sector [ sect ] . ceilingz ;
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
else if ( sp - > lotag = = SE_26 )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
T4 = sp - > x ;
T5 = sp - > y ;
if ( sp - > shade = = sector [ sect ] . floorshade ) //UP
sp - > zvel = - 256 ;
2006-11-16 03:02:42 +00:00
else
2010-08-02 08:13:51 +00:00
sp - > zvel = 256 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sp - > shade = 0 ;
}
2012-10-14 20:41:21 +00:00
else if ( sp - > lotag = = SE_2_EARTHQUAKE )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
T6 = sector [ sp - > sectnum ] . floorheinum ;
sector [ sp - > sectnum ] . floorheinum = 0 ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
switch ( sp - > lotag )
{
2012-09-08 22:18:44 +00:00
case SE_6_SUBWAY :
case SE_14_SUBWAY_CAR :
2010-08-02 08:13:51 +00:00
j = A_CallSound ( sect , i ) ;
if ( j = = - 1 ) j = SUBWAY ;
actor [ i ] . lastvx = j ;
2012-08-26 22:16:08 +00:00
case SE_30_TWO_WAY_TRAIN :
2010-08-02 08:13:51 +00:00
if ( g_netServer | | numplayers > 1 ) break ;
2012-09-08 22:18:44 +00:00
case SE_0_ROTATING_SECTOR :
case SE_1_PIVOT :
case SE_5 :
case SE_11_SWINGING_DOOR :
case SE_15_SLIDING_DOOR :
2012-08-26 22:16:08 +00:00
case SE_16_REACTOR :
case SE_26 :
2011-07-01 17:15:07 +00:00
Sect_SetInterpolation ( sprite [ i ] . sectnum ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
changespritestat ( i , STAT_EFFECTOR ) ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case SEENINE__STATIC :
case OOZFILTER__STATIC :
sp - > shade = - 16 ;
if ( sp - > xrepeat < = 8 )
{
2012-11-18 19:01:34 +00:00
sp - > cstat = 32768 ;
2010-08-02 08:13:51 +00:00
sp - > xrepeat = sp - > yrepeat = 0 ;
}
else sp - > cstat = 1 + 256 ;
sp - > extra = g_impactDamage < < 2 ;
sp - > owner = i ;
2006-04-13 20:47:06 +00:00
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +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 = g_impactDamage < < 2 ;
}
else
{
sp - > cstat | = ( sp - > cstat & 48 ) ? 1 : 17 ;
sp - > extra = 1 ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( ! g_netServer & & ud . multimode < 2 ) & & sp - > pal ! = 0 )
{
sp - > xrepeat = sp - > yrepeat = 0 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
}
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
sp - > pal = 0 ;
sp - > owner = i ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2010-08-02 08:13:51 +00:00
sp - > xvel = 8 ;
A_SetSprite ( i , CLIPMASK0 ) ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case TOILET__STATIC :
case STALL__STATIC :
sp - > lotag = 1 ;
sp - > cstat | = 257 ;
sp - > clipdist = 8 ;
sp - > owner = i ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
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 ;
A_Fall ( 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 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_MISC ) ;
2010-08-02 08:13:51 +00:00
}
else
{
if ( sp - > picnum = = EGG )
sp - > clipdist = 24 ;
sp - > cstat = 257 | ( krand ( ) & 4 ) ;
changespritestat ( i , STAT_ZOMBIEACTOR ) ;
}
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case TOILETWATER__STATIC :
sp - > shade = - 16 ;
2012-05-05 22:24:33 +00:00
changespritestat ( i , STAT_STANDABLE ) ;
2010-08-02 08:13:51 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
SPAWN_END :
if ( apScriptGameEvent [ EVENT_SPAWN ] )
{
int32_t pl = A_FindPlayer ( & sprite [ i ] , & p ) ;
2012-05-16 00:45:10 +00:00
VM_OnEvent ( EVENT_SPAWN , i , pl , p , 0 ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// spawning is technically not allowed to fail in BUILD, so we just hide whatever
// the client spawns with SPRITE_NULL because the server will send it anyway
2012-10-14 22:16:07 +00:00
/*
2010-08-02 08:13:51 +00:00
if ( g_netClient & & j > = 0 )
{
int32_t zz ;
for ( zz = 0 ; ( unsigned ) zz < ( sizeof ( g_netStatnums ) / sizeof ( g_netStatnums [ 0 ] ) ) ; zz + + )
if ( sprite [ i ] . statnum = = g_netStatnums [ zz ] )
{
actor [ i ] . flags | = SPRITE_NULL ;
return i ;
}
}
2012-10-14 22:16:07 +00:00
*/
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
return i ;
}
2006-04-13 20:47:06 +00:00
2012-09-12 09:45:14 +00:00
static int32_t G_MaybeTakeOnFloorPal ( spritetype * datspr , int32_t sect )
2012-03-22 22:47:29 +00:00
{
int32_t dapal = sector [ sect ] . floorpal ;
if ( dapal & & ! g_noFloorPal [ dapal ] & & dapal < g_numRealPalettes
& & ! A_CheckSpriteFlags ( datspr - > owner , SPRITE_NOPAL ) )
{
datspr - > pal = dapal ;
return 1 ;
}
return 0 ;
}
2012-08-06 20:00:31 +00:00
static int32_t getofs_viewtype5 ( const spritetype * s , spritetype * t , int32_t a )
{
int32_t k = ( ( ( s - > ang + 3072 + 128 - a ) & 2047 ) > > 8 ) & 7 ;
if ( k > 4 )
{
k = 8 - k ;
t - > cstat | = 4 ;
}
else t - > cstat & = ~ 4 ;
return k ;
}
static int32_t getofs_viewtype7 ( const spritetype * s , spritetype * t , int32_t a )
{
int32_t k = ( ( s - > ang + 3072 + 128 - a ) & 2047 ) / 170 ;
if ( k > 6 )
{
k = 12 - k ;
t - > cstat | = 4 ;
}
else t - > cstat & = ~ 4 ;
return k ;
}
2012-09-12 09:45:14 +00:00
static int32_t G_CheckAdultTile ( int32_t pic )
2012-08-06 20:00:31 +00:00
{
switch ( pic )
{
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 :
case 4946 :
case 4947 :
case 693 :
case 2254 :
case 4560 :
case 4561 :
case 4562 :
case 4498 :
case 4957 :
return 1 ;
}
return 0 ;
}
2012-08-13 18:26:11 +00:00
static void G_DoEventAnimSprites ( int32_t j )
{
if ( display_mirror ) tsprite [ j ] . statnum = TSPR_MIRROR ;
if ( ( unsigned ) tsprite [ j ] . owner < MAXSPRITES & & spriteext [ tsprite [ j ] . owner ] . flags & SPREXT_TSPRACCESS )
{
spriteext [ tsprite [ j ] . owner ] . tspr = & tsprite [ j ] ;
VM_OnEvent ( EVENT_ANIMATESPRITES , tsprite [ j ] . owner , myconnectindex , - 1 , 0 ) ;
}
}
2010-08-02 08:13:51 +00:00
#if 0 // def _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.
//#pragma auto_inline(off)
# pragma optimize("g",off)
# endif
2012-08-13 18:25:40 +00:00
void G_DoSpriteAnimations ( int32_t ourx , int32_t oury , int32_t oura , int32_t smoothratio )
2010-08-02 08:13:51 +00:00
{
int32_t i , j , k , p , sect ;
2012-06-03 15:46:08 +00:00
intptr_t l ;
2010-08-02 08:13:51 +00:00
spritetype * s , * t ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ! spritesortcnt ) return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
ror_sprite = - 1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( j = spritesortcnt - 1 ; j > = 0 ; j - - )
{
t = & tsprite [ j ] ;
i = t - > owner ;
s = & sprite [ i ] ;
2006-04-13 20:47:06 +00:00
2012-01-28 14:38:23 +00:00
switch ( DYNAMICTILEMAP ( s - > picnum ) )
2010-08-02 08:13:51 +00:00
{
case SECTOREFFECTOR__STATIC :
if ( s - > lotag = = 40 | | s - > lotag = = 41 )
{
t - > cstat = 32768 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ror_sprite = = - 1 ) ror_sprite = i ;
}
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
if ( t - > lotag = = SE_27_DEMO_CAM & & ud . recstat = = 1 )
2010-08-02 08:13:51 +00:00
{
t - > picnum = 11 + ( ( totalclock > > 3 ) & 1 ) ;
t - > cstat | = 128 ;
}
else
t - > xrepeat = t - > yrepeat = 0 ;
break ;
}
}
2006-11-13 23:12:47 +00:00
2010-08-02 08:13:51 +00:00
for ( j = spritesortcnt - 1 ; j > = 0 ; j - - )
{
t = & tsprite [ j ] ;
i = t - > owner ;
s = & sprite [ t - > owner ] ;
2006-04-13 20:47:06 +00:00
2012-10-14 22:16:07 +00:00
/*
2010-08-02 08:13:51 +00:00
if ( A_CheckSpriteFlags ( i , SPRITE_NULL ) )
{
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
}
2012-10-14 22:16:07 +00:00
*/
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( t - > picnum < GREENSLIME | | t - > picnum > GREENSLIME + 7 )
2012-01-28 14:38:23 +00:00
switch ( DYNAMICTILEMAP ( t - > picnum ) )
2010-08-02 08:13:51 +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 :
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( t - > picnum , t - > pal ) > = 0 & & ! ( spriteext [ i ] . flags & SPREXT_NOTMD ) )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
t - > cstat & = ~ 4 ;
break ;
}
# endif
2012-08-13 18:25:40 +00:00
k = getofs_viewtype5 ( t , t , oura ) ;
2010-08-02 08:13:51 +00:00
t - > picnum = s - > picnum + k ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
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 ;
continue ;
}
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 ) ) | | ( A_CheckEnemySprite ( t ) & & t - > extra > 0 ) | | t - > statnum = = STAT_PLAYER )
continue ;
}
2006-04-13 20:47:06 +00:00
2011-04-14 20:48:08 +00:00
if ( A_CheckSpriteFlags ( t - > owner , SPRITE_NOSHADE ) | | ( t - > cstat & 2048 ) )
2010-08-02 08:13:51 +00:00
l = sprite [ t - > owner ] . shade ;
else
{
if ( sector [ t - > sectnum ] . ceilingstat & 1 )
l = sector [ t - > sectnum ] . ceilingshade ;
else
l = sector [ t - > sectnum ] . floorshade ;
if ( l < - 127 ) l = - 127 ;
2012-08-06 20:00:31 +00:00
// if (l > 128) l = 127;
2010-08-02 08:13:51 +00:00
}
t - > shade = l ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( j = spritesortcnt - 1 ; j > = 0 ; j - - ) //Between drawrooms() and drawmasks()
{
2012-06-03 15:46:08 +00:00
int32_t switchpic ;
2012-08-06 20:00:29 +00:00
int32_t t_data3 ;
2012-06-03 15:46:08 +00:00
# ifndef LUNATIC
2012-08-06 20:00:29 +00:00
int32_t t_data4 ;
2012-06-03 15:46:08 +00:00
# else
2012-08-06 20:00:29 +00:00
int32_t startframe , viewtype ;
2012-05-18 12:46:10 +00:00
# endif
2010-08-02 08:13:51 +00:00
//is the perfect time to animate sprites
t = & tsprite [ j ] ;
i = t - > owner ;
s = ( i < 0 ? & tsprite [ j ] : & sprite [ i ] ) ;
2006-04-13 20:47:06 +00:00
2012-09-12 09:45:14 +00:00
if ( ud . lockout & & G_CheckAdultTile ( DYNAMICTILEMAP ( s - > picnum ) ) )
2012-08-06 20:00:31 +00:00
{
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
}
if ( s - > picnum = = NATURALLIGHTNING )
2010-08-02 08:13:51 +00:00
{
t - > shade = - 127 ;
t - > cstat | = 8192 ;
}
2006-04-13 20:47:06 +00:00
2012-08-06 20:00:31 +00:00
if ( t - > statnum = = TSPR_TEMP )
continue ;
2010-08-02 08:13:51 +00:00
if ( s - > statnum ! = STAT_ACTOR & & s - > picnum = = APLAYER & & g_player [ s - > yvel ] . ps - > newowner = = - 1 & & s - > owner > = 0 )
{
t - > x - = mulscale16 ( 65536 - smoothratio , g_player [ s - > yvel ] . ps - > pos . x - g_player [ s - > yvel ] . ps - > opos . x ) ;
t - > y - = mulscale16 ( 65536 - smoothratio , g_player [ s - > yvel ] . ps - > pos . y - g_player [ s - > yvel ] . ps - > opos . y ) ;
// dirty hack
if ( g_player [ s - > yvel ] . ps - > dead_flag ) t - > z = g_player [ s - > yvel ] . ps - > opos . z ;
t - > z + = mulscale16 ( smoothratio , g_player [ s - > yvel ] . ps - > pos . z - g_player [ s - > yvel ] . ps - > opos . z ) -
( g_player [ s - > yvel ] . ps - > dead_flag ? 0 : PHEIGHT ) + PHEIGHT ;
}
else if ( ( s - > statnum = = STAT_DEFAULT & & s - > picnum ! = CRANEPOLE ) | | s - > statnum = = STAT_PLAYER | |
s - > statnum = = STAT_STANDABLE | | s - > statnum = = STAT_PROJECTILE | | s - > statnum = = STAT_MISC | | s - > statnum = = STAT_ACTOR )
{
t - > x - = mulscale16 ( 65536 - smoothratio , s - > x - actor [ i ] . bposx ) ;
t - > y - = mulscale16 ( 65536 - smoothratio , s - > y - actor [ i ] . bposy ) ;
t - > z - = mulscale16 ( 65536 - smoothratio , s - > z - actor [ i ] . bposz ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sect = s - > sectnum ;
2012-08-06 20:00:29 +00:00
Bassert ( i > = 0 ) ;
2012-05-18 12:46:10 +00:00
t_data3 = T4 ;
2012-08-06 20:00:29 +00:00
# ifndef LUNATIC
2012-05-18 12:46:10 +00:00
t_data4 = T5 ; // SACTION
# else
2012-08-06 20:00:29 +00:00
startframe = actor [ i ] . ac . startframe ;
viewtype = actor [ i ] . ac . viewtype ;
2012-05-18 12:46:10 +00:00
# endif
2010-08-02 08:13:51 +00:00
switchpic = s - > picnum ;
//some special cases because dynamictostatic system can't handle addition to constants
2012-08-06 20:00:31 +00:00
if ( ( s - > picnum > = SCRAP6 ) & & ( s - > picnum < = SCRAP6 + 7 ) )
2010-08-02 08:13:51 +00:00
switchpic = SCRAP5 ;
2012-08-06 20:00:31 +00:00
else if ( ( s - > picnum = = MONEY + 1 ) | | ( s - > picnum = = MAIL + 1 ) | | ( s - > picnum = = PAPER + 1 ) )
2010-08-02 08:13:51 +00:00
switchpic - - ;
2006-04-13 20:47:06 +00:00
2012-01-28 14:38:23 +00:00
switch ( DYNAMICTILEMAP ( switchpic ) )
2010-08-02 08:13:51 +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 ;
continue ;
}
break ;
case TRIPBOMB__STATIC :
continue ;
case FORCESPHERE__STATIC :
2012-09-12 09:46:21 +00:00
if ( t - > statnum = = STAT_MISC )
2010-08-02 08:13:51 +00:00
{
int16_t sqa , sqb ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sqa =
getangle (
sprite [ s - > owner ] . x - g_player [ screenpeek ] . ps - > pos . x ,
sprite [ s - > owner ] . y - g_player [ screenpeek ] . ps - > pos . y ) ;
sqb =
getangle (
sprite [ s - > owner ] . x - t - > x ,
sprite [ s - > owner ] . y - t - > y ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( klabs ( G_GetAngleDelta ( sqa , sqb ) ) > 512 )
if ( ldist ( & sprite [ s - > owner ] , t ) < ldist ( & sprite [ g_player [ screenpeek ] . ps - > i ] , & sprite [ s - > owner ] ) )
t - > xrepeat = t - > yrepeat = 0 ;
}
continue ;
case BURNING__STATIC :
case BURNING2__STATIC :
if ( sprite [ s - > owner ] . statnum = = STAT_PLAYER )
{
if ( display_mirror = = 0 & & sprite [ s - > owner ] . yvel = = screenpeek & & g_player [ sprite [ s - > owner ] . yvel ] . ps - > over_shoulder_on = = 0 )
t - > xrepeat = 0 ;
else
{
2012-08-13 18:25:40 +00:00
t - > ang = getangle ( ourx - t - > x , oury - t - > y ) ;
2010-08-02 08:13:51 +00:00
t - > x = sprite [ s - > owner ] . x + ( sintable [ ( t - > ang + 512 ) & 2047 ] > > 10 ) ;
t - > y = sprite [ s - > owner ] . y + ( sintable [ t - > ang & 2047 ] > > 10 ) ;
}
}
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +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 & & actor [ OW ] . t_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
2010-08-02 08:13:51 +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 :
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( t - > picnum , t - > pal ) > = 0 & &
! ( spriteext [ i ] . flags & SPREXT_NOTMD ) )
{
int32_t v = getangle ( t - > xvel , t - > zvel > > 4 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
spriteext [ i ] . pitch = ( v > 1023 ? v - 2048 : v ) ;
t - > cstat & = ~ 4 ;
break ;
}
# endif
2012-08-13 18:25:40 +00:00
k = getofs_viewtype7 ( s , t , getangle ( s - > x - ourx , s - > y - oury ) ) ;
2010-08-02 08:13:51 +00:00
t - > picnum = RPG + k ;
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case RECON__STATIC :
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( t - > picnum , t - > pal ) > = 0 & & ! ( spriteext [ i ] . flags & SPREXT_NOTMD ) )
{
t - > cstat & = ~ 4 ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
}
# endif
2012-08-13 18:25:40 +00:00
k = getofs_viewtype7 ( s , t , getangle ( s - > x - ourx , s - > y - oury ) ) ;
2006-04-13 20:47:06 +00:00
2012-08-06 20:00:31 +00:00
// RECON_T4
2012-08-06 20:00:29 +00:00
if ( klabs ( t_data3 ) > 64 )
k + = 7 ; // tilted recon car
2010-08-02 08:13:51 +00:00
t - > picnum = RECON + k ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case APLAYER__STATIC :
p = s - > yvel ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( t - > pal = = 1 ) t - > z - = ( 18 < < 8 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_player [ p ] . ps - > over_shoulder_on > 0 & & g_player [ p ] . ps - > newowner < 0 )
{
2012-08-13 18:25:40 +00:00
t - > ang = g_player [ p ] . ps - > ang +
mulscale16 ( ( ( ( g_player [ p ] . ps - > ang + 1024 - g_player [ p ] . ps - > oang ) & 2047 ) - 1024 ) ,
smoothratio ) ;
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( bpp > 8 & & usemodels & & md_tilehasmodel ( t - > picnum , t - > pal ) > = 0 )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
static int32_t targetang = 0 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_player [ p ] . sync - > extbits & ( 1 < < 1 ) )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
if ( g_player [ p ] . sync - > extbits & ( 1 < < 2 ) ) targetang + = 16 ;
else if ( g_player [ p ] . sync - > extbits & ( 1 < < 3 ) ) targetang - = 16 ;
else if ( targetang > 0 ) targetang - = targetang > > 2 ;
else if ( targetang < 0 ) targetang + = ( - targetang ) > > 2 ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
else
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
if ( g_player [ p ] . sync - > extbits & ( 1 < < 2 ) ) targetang - = 16 ;
else if ( g_player [ p ] . sync - > extbits & ( 1 < < 3 ) ) targetang + = 16 ;
else if ( targetang > 0 ) targetang - = targetang > > 2 ;
else if ( targetang < 0 ) targetang + = ( - targetang ) > > 2 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
targetang = clamp ( targetang , - 128 , 128 ) ;
t - > ang + = targetang ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
else
# endif
t - > cstat | = 2 ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) & & ( display_mirror | | screenpeek ! = p | | s - > owner = = - 1 ) )
{
2012-08-06 20:00:31 +00:00
if ( ud . showweapons & & sprite [ g_player [ p ] . ps - > i ] . extra > 0 & & g_player [ p ] . ps - > curr_weapon > 0
& & spritesortcnt < MAXSPRITESONSCREEN )
2010-08-02 08:13:51 +00:00
{
2012-08-06 20:00:31 +00:00
spritetype * const newt = & tsprite [ spritesortcnt ] ;
int32_t curweap = g_player [ p ] . ps - > curr_weapon ;
2006-04-13 20:47:06 +00:00
2012-08-06 20:00:31 +00:00
Bmemcpy ( newt , t , sizeof ( spritetype ) ) ;
2006-04-13 20:47:06 +00:00
2012-08-06 20:00:31 +00:00
newt - > statnum = TSPR_TEMP ;
/*
newt - > yrepeat = ( t - > yrepeat > > 3 ) ;
if ( t - > yrepeat < 4 ) t - > yrepeat = 4 ;
*/
2006-04-13 20:47:06 +00:00
2012-08-06 20:00:31 +00:00
newt - > cstat = newt - > pal = 0 ;
2006-04-13 20:47:06 +00:00
2012-08-06 20:00:31 +00:00
newt - > picnum = ( curweap = = GROW_WEAPON ? GROWSPRITEICON : WeaponPickupSprites [ curweap ] ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( s - > owner > = 0 )
2012-08-06 20:00:31 +00:00
newt - > z = g_player [ p ] . ps - > pos . z - ( 12 < < 8 ) ;
else
newt - > z = s - > z - ( 51 < < 8 ) ;
2006-04-13 20:47:06 +00:00
2012-08-06 20:00:31 +00:00
if ( newt - > picnum = = HEAVYHBOMB )
newt - > xrepeat = newt - > yrepeat = 10 ;
2010-08-02 08:13:51 +00:00
else
2012-08-06 20:00:31 +00:00
newt - > xrepeat = newt - > yrepeat = 16 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
spritesortcnt + + ;
2006-04-13 20:47:06 +00:00
}
2012-08-06 20:00:31 +00:00
if ( g_player [ p ] . sync - > extbits & ( 1 < < 7 ) & & ! ud . pause_on & & spritesortcnt < MAXSPRITESONSCREEN )
2006-04-13 20:47:06 +00:00
{
2012-08-06 20:00:31 +00:00
spritetype * const newt = & tsprite [ spritesortcnt ] ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
Bmemcpy ( newt , t , sizeof ( spritetype ) ) ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
newt - > statnum = TSPR_TEMP ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
newt - > yrepeat = ( t - > yrepeat > > 3 ) ;
if ( newt - > yrepeat < 4 ) newt - > yrepeat = 4 ;
newt - > cstat = 0 ;
newt - > picnum = RESPAWNMARKERGREEN ;
2010-08-02 08:13:51 +00:00
if ( s - > owner > = 0 )
2012-08-06 20:00:31 +00:00
newt - > z = g_player [ p ] . ps - > pos . z - ( 20 < < 8 ) ;
2006-11-16 03:02:42 +00:00
else
2012-08-06 20:00:31 +00:00
newt - > z = s - > z - ( 96 < < 8 ) ;
newt - > xrepeat = newt - > yrepeat = 32 ;
newt - > pal = 20 ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
spritesortcnt + + ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( s - > owner = = - 1 )
2006-11-16 03:02:42 +00:00
{
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( s - > picnum , t - > pal ) > = 0 & & ! ( spriteext [ i ] . flags & SPREXT_NOTMD ) )
{
k = 0 ;
t - > cstat & = ~ 4 ;
}
else
# endif
2012-08-13 18:25:40 +00:00
k = getofs_viewtype5 ( s , t , oura ) ;
2006-04-13 20:47:06 +00:00
2012-10-14 20:41:21 +00:00
if ( sector [ s - > sectnum ] . lotag = = ST_2_UNDERWATER ) k + = 1795 - 1405 ;
2010-08-02 08:13:51 +00:00
else if ( ( actor [ i ] . floorz - s - > z ) > ( 64 < < 8 ) ) k + = 60 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
t - > picnum + = k ;
t - > pal = g_player [ p ] . ps - > palookup ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
goto PALONLY ;
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
2012-10-14 20:41:21 +00:00
if ( g_player [ p ] . ps - > on_crane = = - 1 & & ( sector [ s - > sectnum ] . lotag & 0x7ff ) ! = 1 ) // ST_1_ABOVE_WATER ?
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
l = s - > z - actor [ g_player [ p ] . ps - > i ] . floorz + ( 3 < < 8 ) ;
if ( l > 1024 & & s - > yrepeat > 32 & & s - > extra > 0 )
s - > yoffset = ( int8_t ) ( l / ( s - > yrepeat < < 2 ) ) ;
else s - > yoffset = 0 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_player [ p ] . ps - > newowner > - 1 )
2006-11-16 03:02:42 +00:00
{
2012-08-06 20:00:29 +00:00
// Display APLAYER sprites with action PSTAND when viewed through
// a camera. Not implemented for Lunatic.
2012-06-03 15:46:08 +00:00
# ifndef LUNATIC
2012-10-30 15:54:35 +00:00
const intptr_t * aplayer_scr = g_tile [ APLAYER ] . execPtr ;
2012-08-06 20:00:29 +00:00
// [0]=strength, [1]=actionofs, [2]=moveofs
2012-06-03 15:46:08 +00:00
2012-08-06 20:00:29 +00:00
t_data4 = aplayer_scr [ 1 ] ;
2012-06-03 15:46:08 +00:00
# endif
2012-08-06 20:00:29 +00:00
t_data3 = 0 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +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 )
if ( ( ! g_netServer & & ud . multimode < 2 ) | | ( ( g_netServer | | ud . multimode > 1 ) & & p = = screenpeek ) )
{
if ( getrendermode ( ) = = 4 )
t - > cstat | = 16384 ;
else
{
t - > owner = - 1 ;
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
}
2006-04-13 20:47:06 +00:00
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( s - > picnum , t - > pal ) > = 0 & & ! ( spriteext [ i ] . flags & SPREXT_NOTMD ) )
{
k = 0 ;
t - > cstat & = ~ 4 ;
}
else
# endif
2012-08-13 18:25:40 +00:00
k = getofs_viewtype5 ( s , t , oura ) ;
2008-02-06 11:42:34 +00:00
2012-10-14 20:41:21 +00:00
if ( sector [ t - > sectnum ] . lotag = = ST_2_UNDERWATER ) k + = 1795 - 1405 ;
2010-08-02 08:13:51 +00:00
else if ( ( actor [ i ] . floorz - s - > z ) > ( 64 < < 8 ) ) k + = 60 ;
2009-12-14 20:14:12 +00:00
2010-08-02 08:13:51 +00:00
t - > picnum + = k ;
t - > pal = g_player [ p ] . ps - > palookup ;
}
PALONLY :
2012-09-12 09:45:14 +00:00
G_MaybeTakeOnFloorPal ( t , sect ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( s - > owner = = - 1 ) continue ;
2008-08-24 03:19:40 +00:00
2010-08-02 08:13:51 +00:00
if ( t - > z > actor [ i ] . floorz & & t - > xrepeat < 32 )
t - > z = actor [ i ] . floorz ;
2009-07-04 09:28:21 +00:00
2010-08-02 08:13:51 +00:00
break ;
2009-07-04 09:28:21 +00:00
2010-08-02 08:13:51 +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 )
2009-07-04 09:28:21 +00:00
{
2010-08-02 08:13:51 +00:00
t - > xrepeat = t - > yrepeat = 0 ;
continue ;
2009-07-04 09:28:21 +00:00
}
2010-08-02 08:13:51 +00:00
if ( t - > pal = = 6 ) t - > shade = - 120 ;
case SCRAP1__STATIC :
case SCRAP2__STATIC :
case SCRAP3__STATIC :
case SCRAP4__STATIC :
case SCRAP5__STATIC :
if ( actor [ i ] . picnum = = BLIMP & & t - > picnum = = SCRAP1 & & s - > yvel > = 0 )
t - > picnum = s - > yvel ;
else t - > picnum + = T1 ;
t - > shade - = 6 ;
2009-07-04 09:28:21 +00:00
2012-09-12 09:45:14 +00:00
G_MaybeTakeOnFloorPal ( t , sect ) ;
2010-08-02 08:13:51 +00:00
break ;
case WATERBUBBLE__STATIC :
if ( sector [ t - > sectnum ] . floorpicnum = = FLOORSLIME )
2009-07-04 09:28:21 +00:00
{
2010-08-02 08:13:51 +00:00
t - > pal = 7 ;
break ;
2009-07-04 09:28:21 +00:00
}
2010-08-02 08:13:51 +00:00
default :
2012-09-12 09:45:14 +00:00
G_MaybeTakeOnFloorPal ( t , sect ) ;
2009-07-04 09:28:21 +00:00
break ;
}
2007-03-08 21:07:10 +00:00
2012-10-30 15:54:35 +00:00
if ( g_tile [ s - > picnum ] . execPtr )
2009-12-14 20:14:12 +00:00
{
2010-08-02 08:13:51 +00:00
/*
if ( ud . angleinterpolation )
{
if ( sprpos [ i ] . ang ! = sprpos [ i ] . oldang )
t - > ang = ( sprpos [ i ] . oldang + ( mulscale16 ( ( int32_t ) ( sprpos [ i ] . angdif ) , smoothratio ) * sprpos [ i ] . angdir ) ) & 2047 ;
else
t - > ang = sprpos [ i ] . ang ;
}
*/
2012-03-11 17:37:50 +00:00
2012-06-03 15:46:08 +00:00
# ifndef LUNATIC
2012-05-18 12:46:10 +00:00
if ( ( unsigned ) t_data4 + 2 > = ( unsigned ) g_scriptSize )
2011-12-21 18:40:47 +00:00
goto skip ;
2012-06-03 15:46:08 +00:00
l = script [ t_data4 + 2 ] ;
2012-05-18 12:46:10 +00:00
# else
2012-08-06 20:00:29 +00:00
l = viewtype ;
2012-05-18 12:46:10 +00:00
# endif
2009-12-14 20:14:12 +00:00
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( s - > picnum , t - > pal ) > = 0 & & ! ( spriteext [ i ] . flags & SPREXT_NOTMD ) )
2006-04-13 20:47:06 +00:00
{
2011-03-04 08:50:58 +00:00
k = 0 ;
t - > cstat & = ~ 4 ;
}
else
2006-11-16 03:02:42 +00:00
# endif
2011-03-04 08:50:58 +00:00
switch ( l )
2011-06-25 16:37:10 +00:00
{
2011-03-04 08:50:58 +00:00
case 2 :
2012-08-13 18:25:40 +00:00
k = ( ( ( s - > ang + 3072 + 128 - oura ) & 2047 ) > > 8 ) & 1 ;
2011-03-04 08:50:58 +00:00
break ;
2006-04-13 20:47:06 +00:00
2011-03-04 08:50:58 +00:00
case 3 :
case 4 :
2012-08-13 18:25:40 +00:00
k = ( ( ( s - > ang + 3072 + 128 - oura ) & 2047 ) > > 7 ) & 7 ;
2011-03-04 08:50:58 +00:00
if ( k > 3 )
{
t - > cstat | = 4 ;
k = 7 - k ;
}
else t - > cstat & = ~ 4 ;
break ;
2006-04-13 20:47:06 +00:00
2011-03-04 08:50:58 +00:00
case 5 :
2012-08-13 18:25:40 +00:00
k = getofs_viewtype5 ( s , t , getangle ( s - > x - ourx , s - > y - oury ) ) ;
2011-03-04 08:50:58 +00:00
break ;
case 7 :
2012-08-13 18:25:40 +00:00
k = getofs_viewtype7 ( s , t , getangle ( s - > x - ourx , s - > y - oury ) ) ;
2011-03-04 08:50:58 +00:00
break ;
case 8 :
2012-08-13 18:25:40 +00:00
k = ( ( ( s - > ang + 3072 + 128 - oura ) & 2047 ) > > 8 ) & 7 ;
2011-03-04 08:50:58 +00:00
t - > cstat & = ~ 4 ;
break ;
default :
k = 0 ;
break ;
2011-06-25 16:37:10 +00:00
}
2012-03-11 17:37:50 +00:00
2012-06-03 15:46:08 +00:00
# ifndef LUNATIC
2012-08-06 20:00:29 +00:00
t - > picnum + = k + script [ t_data4 ] + l * t_data3 ;
2012-05-18 12:46:10 +00:00
# else
2012-08-06 20:00:29 +00:00
t - > picnum + = k + startframe + l * t_data3 ;
2012-05-18 12:46:10 +00:00
# endif
2012-03-11 17:37:50 +00:00
2012-04-13 10:46:04 +00:00
if ( l > 0 )
while ( tilesizx [ t - > picnum ] = = 0 & & t - > picnum > 0 )
2011-06-25 16:37:10 +00:00
t - > picnum - = l ; //Hack, for actors
2010-08-02 08:13:51 +00:00
2011-03-04 08:50:58 +00:00
if ( actor [ i ] . dispicnum > = 0 )
actor [ i ] . dispicnum = t - > picnum ;
2006-04-13 20:47:06 +00:00
}
2011-05-12 23:31:13 +00:00
// else if (display_mirror == 1)
// t->cstat |= 4;
2011-06-25 16:37:10 +00:00
/* completemirror() already reverses the drawn frame, so the above isn't necessary.
* Even Polymost ' s and Polymer ' s mirror seems to function correctly this way . */
2006-04-13 20:47:06 +00:00
2012-06-03 15:46:08 +00:00
# ifndef LUNATIC
2011-03-04 08:50:58 +00:00
skip :
2012-06-03 15:46:08 +00:00
# endif
2012-08-22 22:49:27 +00:00
// XXX: currently, for the splitscreen mod, sprites will be pal6-colored iff the first
// player has nightvision on. We should pass stuff like "from which player is this view
// supposed to be" as parameters ("drawing context") instead of relying on globals.
2010-08-02 08:13:51 +00:00
if ( g_player [ screenpeek ] . ps - > inv_amount [ GET_HEATS ] > 0 & & g_player [ screenpeek ] . ps - > heat_on & &
( A_CheckEnemySprite ( s ) | | A_CheckSpriteFlags ( t - > owner , SPRITE_NVG ) | | s - > picnum = = APLAYER | | s - > statnum = = STAT_DUMMYPLAYER ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
t - > pal = 6 ;
t - > shade = 0 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( s - > statnum = = STAT_DUMMYPLAYER | | A_CheckEnemySprite ( s ) | | A_CheckSpriteFlags ( t - > owner , SPRITE_SHADOW ) | | ( s - > picnum = = APLAYER & & s - > owner > = 0 ) )
2011-12-21 18:42:49 +00:00
if ( t - > statnum ! = TSPR_TEMP & & s - > picnum ! = EXPLOSION2 & & s - > picnum ! = HANGLIGHT & & s - > picnum ! = DOMELITE & & s - > picnum ! = HOTMEAT )
{
if ( actor [ i ] . dispicnum < 0 )
2010-08-02 08:13:51 +00:00
{
2012-01-12 20:48:00 +00:00
// a negative actor[i].dispicnum used to mean 'no floor shadow please' but
// that was a bad hack since the value could propagate to sprite[].picnum
OSD_Printf ( OSD_ERROR " actor[%d].dispicnum = %d \n " , i , actor [ i ] . dispicnum ) ;
2011-12-21 18:42:49 +00:00
actor [ i ] . dispicnum + + ;
continue ;
}
2012-01-12 20:48:00 +00:00
if ( actor [ i ] . flags & SPRITE_NOFLOORSHADOW )
continue ;
if ( ud . shadows & & spritesortcnt < ( MAXSPRITESONSCREEN - 2 ) & & getrendermode ( ) ! = 4 )
2011-12-21 18:42:49 +00:00
{
2012-08-06 20:00:31 +00:00
int32_t daz ;
2006-04-13 20:47:06 +00:00
2012-09-12 09:46:21 +00:00
if ( ( sector [ sect ] . lotag & 0xff ) > 2 | | s - > statnum = = STAT_PROJECTILE | | s - > statnum = = STAT_MISC
| | s - > picnum = = DRONE | | s - > picnum = = COMMANDER )
2011-12-21 18:42:49 +00:00
daz = sector [ sect ] . floorz ;
else
daz = actor [ i ] . floorz ;
2006-11-16 03:02:42 +00:00
2012-08-06 20:00:31 +00:00
if ( ( s - > z - daz ) < ( 8 < < 8 ) & & g_player [ screenpeek ] . ps - > pos . z < daz )
{
//int32_t xrep, yrep;
spritetype * const newt = & tsprite [ spritesortcnt ] ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
Bmemcpy ( newt , t , sizeof ( spritetype ) ) ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
newt - > statnum = TSPR_TEMP ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
newt - > yrepeat = ( t - > yrepeat > > 3 ) ;
if ( t - > yrepeat < 4 ) t - > yrepeat = 4 ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
newt - > shade = 127 ;
newt - > cstat | = 2 ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
newt - > z = daz ;
newt - > pal = 4 ;
/*
xrep = newt - > xrepeat ; // - (klabs(daz-t->z)>>11);
newt - > xrepeat = xrep ;
yrep = newt - > yrepeat ; // - (klabs(daz-t->z)>>11);
newt - > yrepeat = yrep ;
*/
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2012-08-06 20:00:31 +00:00
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( t - > picnum , t - > pal ) > = 0 )
{
newt - > yrepeat = 0 ;
// 512:trans reverse
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
newt - > cstat | = ( 512 + 1024 ) ;
}
else if ( getrendermode ( ) > = 3 )
{
int32_t ii ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
ii = getangle ( newt - > x - g_player [ screenpeek ] . ps - > pos . x ,
newt - > y - g_player [ screenpeek ] . ps - > pos . y ) ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
newt - > x + = sintable [ ( ii + 2560 ) & 2047 ] > > 9 ;
newt - > y + = sintable [ ( ii + 2048 ) & 2047 ] > > 9 ;
2011-12-21 18:42:49 +00:00
}
2012-08-06 20:00:31 +00:00
# endif
spritesortcnt + + ;
}
2006-04-13 20:47:06 +00:00
}
2011-12-21 18:42:49 +00:00
}
2006-04-13 20:47:06 +00:00
2012-01-28 14:38:23 +00:00
switch ( DYNAMICTILEMAP ( s - > picnum ) )
2010-08-02 08:13:51 +00:00
{
case LASERLINE__STATIC :
2012-10-14 20:41:21 +00:00
if ( sector [ t - > sectnum ] . lotag = = ST_2_UNDERWATER ) t - > pal = 8 ;
2010-08-02 08:13:51 +00:00
t - > z = sprite [ s - > owner ] . z - ( 3 < < 8 ) ;
if ( g_tripbombLaserMode = = 2 & & g_player [ screenpeek ] . ps - > heat_on = = 0 )
t - > yrepeat = 0 ;
case EXPLOSION2__STATIC :
case EXPLOSION2BOT__STATIC :
case FREEZEBLAST__STATIC :
2006-11-16 03:02:42 +00:00
case ATOMICHEALTH__STATIC :
2010-08-02 08:13:51 +00:00
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 )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
g_player [ screenpeek ] . ps - > visibility = - 127 ;
lastvisinc = totalclock + 32 ;
//g_restorePalette = 1; // JBF 20040101: why?
2006-11-16 03:02:42 +00:00
}
2010-08-02 08:13:51 +00:00
t - > shade = - 127 ;
t - > cstat | = 8192 ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case FIRE__STATIC :
case FIRE2__STATIC :
2011-03-05 03:57:15 +00:00
t - > cstat | = 128 ;
2010-08-02 08:13:51 +00:00
case BURNING__STATIC :
case BURNING2__STATIC :
if ( sprite [ s - > owner ] . picnum ! = TREE1 & & sprite [ s - > owner ] . picnum ! = TREE2 )
2011-04-07 01:16:29 +00:00
t - > z = actor [ t - > owner ] . floorz ;
2010-08-02 08:13:51 +00:00
t - > shade = - 127 ;
case SMALLSMOKE__STATIC :
t - > cstat | = 8192 ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case COOLEXPLOSION1__STATIC :
t - > shade = - 127 ;
t - > cstat | = 8192 ;
t - > picnum + = ( s - > shade > > 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
case PLAYERONWATER__STATIC :
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( s - > picnum , s - > pal ) > = 0 & & ! ( spriteext [ i ] . flags & SPREXT_NOTMD ) )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
k = 0 ;
2006-11-16 03:02:42 +00:00
t - > cstat & = ~ 4 ;
}
2010-08-02 08:13:51 +00:00
else
2006-11-16 03:02:42 +00:00
# endif
2012-08-13 18:25:40 +00:00
k = getofs_viewtype5 ( t , t , oura ) ;
2010-08-02 08:13:51 +00:00
t - > picnum = s - > picnum + k + ( ( T1 < 4 ) * 5 ) ;
t - > shade = sprite [ s - > owner ] . shade ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case WATERSPLASH2__STATIC :
2012-08-06 20:00:31 +00:00
// WATERSPLASH_T2
2012-08-06 20:00:29 +00:00
t - > picnum = WATERSPLASH2 + T2 ;
2010-08-02 08:13:51 +00:00
break ;
case SHELL__STATIC :
t - > picnum = s - > picnum + ( T1 & 1 ) ;
case SHOTGUNSHELL__STATIC :
t - > cstat | = 12 ;
if ( T1 > 2 ) t - > cstat & = ~ 16 ;
else if ( T1 > 1 ) t - > cstat & = ~ 4 ;
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 ( ! actor [ s - > owner ] . dispicnum )
t - > picnum = actor [ i ] . t_data [ 1 ] ;
else t - > picnum = actor [ s - > owner ] . dispicnum ;
2011-07-21 22:39:29 +00:00
2012-09-12 09:45:14 +00:00
if ( ! G_MaybeTakeOnFloorPal ( t , sect ) )
2012-03-22 22:47:29 +00:00
t - > pal = sprite [ s - > owner ] . pal ;
2011-07-21 22:39:29 +00:00
2010-08-02 08:13:51 +00:00
t - > shade = sprite [ s - > owner ] . shade ;
t - > ang = sprite [ s - > owner ] . ang ;
t - > cstat = 2 | sprite [ s - > owner ] . cstat ;
}
}
break ;
2007-12-20 19:14:38 +00:00
2010-08-02 08:13:51 +00:00
case CAMERA1__STATIC :
case RAT__STATIC :
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( getrendermode ( ) > = 3 & & usemodels & & md_tilehasmodel ( s - > picnum , s - > pal ) > = 0 & & ! ( spriteext [ i ] . flags & SPREXT_NOTMD ) )
2006-11-16 03:02:42 +00:00
{
t - > cstat & = ~ 4 ;
break ;
}
2006-05-12 21:55:05 +00:00
# endif
2012-08-13 18:25:40 +00:00
k = getofs_viewtype5 ( t , t , oura ) ;
2010-08-02 08:13:51 +00:00
t - > picnum = s - > picnum + k ;
2006-11-16 03:02:42 +00:00
break ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
actor [ i ] . dispicnum = t - > picnum ;
// why?
/*
if ( sector [ t - > sectnum ] . floorpicnum = = MIRROR )
t - > xrepeat = t - > yrepeat = 0 ;
*/
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( apScriptGameEvent [ EVENT_ANIMATESPRITES ] )
{
2012-08-13 18:26:13 +00:00
for ( j = spritesortcnt - 1 ; j > = 0 ; j - - )
2012-08-13 18:26:11 +00:00
G_DoEventAnimSprites ( j ) ;
2010-08-02 08:13:51 +00:00
}
}
#if 0 // def _MSC_VER
//#pragma auto_inline()
# pragma optimize("",on)
2009-04-29 19:43:51 +00:00
# endif
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:34 +00:00
// KEEPINSYNC game.h: enum cheatindex_t
2010-08-02 08:13:51 +00:00
char CheatStrings [ ] [ MAXCHEATLEN ] =
{
" 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
" cgs " , // 26
} ;
2006-04-13 20:47:06 +00:00
2012-02-09 22:43:40 +00:00
static void doinvcheat ( int32_t invidx , int32_t defaultnum , int32_t event )
2010-08-02 08:13:51 +00:00
{
2012-05-18 12:46:25 +00:00
defaultnum = VM_OnEvent ( event , g_player [ myconnectindex ] . ps - > i , myconnectindex , - 1 , defaultnum ) ;
if ( defaultnum > = 0 )
g_player [ myconnectindex ] . ps - > inv_amount [ invidx ] = defaultnum ;
2012-02-09 22:43:40 +00:00
}
2006-05-09 04:24:44 +00:00
2012-02-09 22:43:40 +00:00
static void G_CheatGetInv ( void )
{
doinvcheat ( GET_STEROIDS , 400 , EVENT_CHEATGETSTEROIDS ) ;
doinvcheat ( GET_HEATS , 1200 , EVENT_CHEATGETHEAT ) ;
doinvcheat ( GET_BOOTS , 200 , EVENT_CHEATGETBOOT ) ;
doinvcheat ( GET_SHIELD , 100 , EVENT_CHEATGETSHIELD ) ;
doinvcheat ( GET_SCUBA , 6400 , EVENT_CHEATGETSCUBA ) ;
doinvcheat ( GET_HOLODUKE , 2400 , EVENT_CHEATGETHOLODUKE ) ;
doinvcheat ( GET_JETPACK , 1600 , EVENT_CHEATGETJETPACK ) ;
doinvcheat ( GET_FIRSTAID , g_player [ myconnectindex ] . ps - > max_player_health , EVENT_CHEATGETFIRSTAID ) ;
2010-08-02 08:13:51 +00:00
}
2006-05-09 04:24:44 +00:00
2012-04-13 10:45:49 +00:00
static void end_cheat ( void )
{
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2012-11-17 16:48:11 +00:00
KB_FlushKeyboardQueue ( ) ;
2012-04-13 10:45:49 +00:00
}
2012-01-19 21:57:22 +00:00
static int8_t cheatbuf [ MAXCHEATLEN ] , cheatbuflen ;
2006-05-09 04:24:44 +00:00
2010-08-02 08:13:51 +00:00
GAME_STATIC void G_DoCheats ( void )
{
int32_t ch , i , j , k = 0 , weapon ;
2012-04-13 10:45:49 +00:00
static int32_t vol1inited = 0 ;
2010-08-02 08:13:51 +00:00
char consolecheat = 0 ; // JBF 20030914
2006-05-09 04:24:44 +00:00
2010-08-02 08:13:51 +00:00
if ( osdcmd_cheatsinfo_stat . cheatnum ! = - 1 )
{
// JBF 20030914
k = osdcmd_cheatsinfo_stat . cheatnum ;
osdcmd_cheatsinfo_stat . cheatnum = - 1 ;
consolecheat = 1 ;
}
2009-08-28 23:08:00 +00:00
2010-08-02 08:13:51 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & ( MODE_TYPE | MODE_MENU ) )
return ;
2006-11-16 03:02:42 +00:00
2012-04-13 10:45:49 +00:00
if ( VOLUMEONE & & ! vol1inited )
2010-08-02 08:13:51 +00:00
{
Bstrcpy ( CheatStrings [ 2 ] , " scotty## " ) ;
Bstrcpy ( CheatStrings [ 6 ] , " <RESERVED> " ) ;
2012-04-13 10:45:49 +00:00
vol1inited = 1 ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( consolecheat & & numplayers < 2 & & ud . recstat = = 0 )
goto FOUNDCHEAT ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_player [ myconnectindex ] . ps - > cheat_phase = = 1 )
{
while ( KB_KeyWaiting ( ) )
{
2012-11-17 16:48:11 +00:00
ch = Btolower ( KB_GetCh ( ) ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ! ( ( ch > = ' a ' & & ch < = ' z ' ) | | ( ch > = ' 0 ' & & ch < = ' 9 ' ) ) )
{
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
2012-04-13 10:46:04 +00:00
// P_DoQuote(QUOTE_46,g_player[myconnectindex].ps);
2010-08-02 08:13:51 +00:00
return ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
cheatbuf [ cheatbuflen + + ] = ( int8_t ) ch ;
cheatbuf [ cheatbuflen ] = 0 ;
2012-04-13 10:46:04 +00:00
// KB_ClearKeysDown();
2010-08-02 08:13:51 +00:00
if ( cheatbuflen > MAXCHEATLEN )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
return ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( k = 0 ; k < NUMCHEATCODES ; k + + )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
for ( j = 0 ; j < cheatbuflen ; j + + )
{
if ( cheatbuf [ j ] = = CheatStrings [ k ] [ j ] | | ( CheatStrings [ k ] [ j ] = = ' # ' & & ch > = ' 0 ' & & ch < = ' 9 ' ) )
{
if ( CheatStrings [ k ] [ j + 1 ] = = 0 ) goto FOUNDCHEAT ;
if ( j = = cheatbuflen - 1 ) return ;
}
else break ;
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
return ;
2009-05-28 02:55:46 +00:00
2010-08-02 08:13:51 +00:00
FOUNDCHEAT :
{
switch ( k )
{
case CHEAT_WEAPONS :
j = 0 ;
2009-04-24 04:02:39 +00:00
2010-08-02 08:13:51 +00:00
if ( VOLUMEONE )
j = 6 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( weapon = PISTOL_WEAPON ; weapon < MAX_WEAPONS - j ; weapon + + )
{
P_AddAmmo ( weapon , g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > max_ammo_amount [ weapon ] ) ;
g_player [ myconnectindex ] . ps - > gotweapon | = ( 1 < < weapon ) ;
2009-04-24 04:02:39 +00:00
}
2006-04-13 20:47:06 +00:00
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_ALL_WEAPONS , g_player [ myconnectindex ] . ps ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_INVENTORY :
G_CheatGetInv ( ) ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_ALL_INV , g_player [ myconnectindex ] . ps ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_KEYS :
g_player [ myconnectindex ] . ps - > got_access = 7 ;
2012-11-17 16:48:11 +00:00
KB_FlushKeyboardQueue ( ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_DEBUG :
g_Debug = 1 - g_Debug ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
G_DumpDebugInfo ( ) ;
2012-03-26 05:07:12 +00:00
Bsprintf ( tempbuf , " Gamevars dumped to log " ) ;
2010-08-02 08:13:51 +00:00
G_AddUserQuote ( tempbuf ) ;
2012-03-26 05:07:12 +00:00
Bsprintf ( tempbuf , " Map dumped to debug.map " ) ;
2010-08-02 08:13:51 +00:00
G_AddUserQuote ( tempbuf ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
break ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_CLIP :
2012-03-11 17:38:50 +00:00
ud . noclip = 1 - ud . noclip ;
P_DoQuote ( QUOTE_CHEAT_NOCLIP - ! ud . noclip , g_player [ myconnectindex ] . ps ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_RESERVED2 :
2012-06-03 16:12:44 +00:00
g_player [ myconnectindex ] . ps - > player_par = 0 ;
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_EOL ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_ALLEN :
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_ALLEN , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
KB_ClearKeyDown ( sc_N ) ;
return ;
2007-03-22 18:28:41 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_CORNHOLIO :
case CHEAT_KROZ :
2012-02-09 22:43:55 +00:00
case CHEAT_COMEGETSOME :
2012-04-13 10:45:49 +00:00
{
const int32_t pi = g_player [ myconnectindex ] . ps - > i ;
2010-08-02 08:13:51 +00:00
ud . god = 1 - ud . god ;
2007-12-20 19:14:38 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . god )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
pus = 1 ;
pub = 1 ;
2012-04-13 10:45:49 +00:00
sprite [ pi ] . cstat = 257 ;
2006-04-13 20:47:06 +00:00
2012-04-13 10:45:49 +00:00
actor [ pi ] . t_data [ 0 ] = 0 ;
actor [ pi ] . t_data [ 1 ] = 0 ;
actor [ pi ] . t_data [ 2 ] = 0 ;
actor [ pi ] . t_data [ 3 ] = 0 ;
actor [ pi ] . t_data [ 4 ] = 0 ;
actor [ pi ] . t_data [ 5 ] = 0 ;
2006-04-13 20:47:06 +00:00
2012-04-13 10:45:49 +00:00
sprite [ pi ] . hitag = 0 ;
sprite [ pi ] . lotag = 0 ;
sprite [ pi ] . pal = g_player [ myconnectindex ] . ps - > palookup ;
2006-09-07 17:46:00 +00:00
2012-02-09 22:43:55 +00:00
if ( k ! = CHEAT_COMEGETSOME )
{
P_DoQuote ( QUOTE_CHEAT_GODMODE_ON , g_player [ myconnectindex ] . ps ) ;
}
else
{
2012-03-26 05:07:12 +00:00
Bstrcpy ( ScriptQuotes [ QUOTE_RESERVED4 ] , " Come Get Some! " ) ;
2006-04-13 20:47:06 +00:00
2012-02-09 22:43:55 +00:00
S_PlaySound ( DUKE_GETWEAPON2 ) ;
P_DoQuote ( QUOTE_RESERVED4 , g_player [ myconnectindex ] . ps ) ;
G_CheatGetInv ( ) ;
for ( weapon = PISTOL_WEAPON ; weapon < MAX_WEAPONS ; weapon + + )
g_player [ myconnectindex ] . ps - > gotweapon | = ( 1 < < weapon ) ;
2006-04-13 20:47:06 +00:00
2012-02-09 22:43:55 +00:00
for ( weapon = PISTOL_WEAPON ; weapon < ( MAX_WEAPONS ) ; weapon + + )
P_AddAmmo ( weapon , g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > max_ammo_amount [ weapon ] ) ;
g_player [ myconnectindex ] . ps - > got_access = 7 ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
}
else
{
2012-04-13 10:45:49 +00:00
sprite [ pi ] . extra = g_player [ myconnectindex ] . ps - > max_player_health ;
actor [ pi ] . extra = - 1 ;
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > last_extra = g_player [ myconnectindex ] . ps - > max_player_health ;
2012-02-09 22:43:55 +00:00
P_DoQuote ( QUOTE_CHEAT_GODMODE_OFF , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2012-04-13 10:45:49 +00:00
sprite [ pi ] . extra = g_player [ myconnectindex ] . ps - > max_player_health ;
actor [ pi ] . extra = 0 ;
2012-02-09 22:43:55 +00:00
if ( k ! = CHEAT_COMEGETSOME )
g_player [ myconnectindex ] . ps - > dead_flag = 0 ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2012-04-13 10:45:49 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_STUFF :
j = 0 ;
2006-08-29 08:07:06 +00:00
2010-08-02 08:13:51 +00:00
if ( VOLUMEONE )
j = 6 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( weapon = PISTOL_WEAPON ; weapon < MAX_WEAPONS - j ; weapon + + )
g_player [ myconnectindex ] . ps - > gotweapon | = ( 1 < < weapon ) ;
2006-04-13 20:47:06 +00:00
2012-04-13 10:45:49 +00:00
for ( weapon = PISTOL_WEAPON ; weapon < MAX_WEAPONS - j ; weapon + + )
2010-08-02 08:13:51 +00:00
P_AddAmmo ( weapon , g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > max_ammo_amount [ weapon ] ) ;
2012-04-13 10:45:49 +00:00
2010-08-02 08:13:51 +00:00
G_CheatGetInv ( ) ;
2012-04-13 10:45:49 +00:00
g_player [ myconnectindex ] . ps - > got_access = 7 ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_EVERYTHING , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
2012-04-13 10:45:49 +00:00
// P_DoQuote(QUOTE_21,g_player[myconnectindex].ps);
2012-11-04 23:41:05 +00:00
g_player [ myconnectindex ] . ps - > inven_icon = ICON_FIRSTAID ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_SCOTTY :
case CHEAT_SKILL :
if ( k = = CHEAT_SCOTTY )
{
i = Bstrlen ( CheatStrings [ k ] ) - 3 + VOLUMEONE ;
if ( ! consolecheat )
2006-11-16 03:02:42 +00:00
{
2010-08-02 08:13:51 +00:00
// JBF 20030914
int16_t volnume , levnume ;
if ( VOLUMEALL )
{
volnume = cheatbuf [ i ] - ' 0 ' ;
levnume = ( cheatbuf [ i + 1 ] - ' 0 ' ) * 10 + ( cheatbuf [ i + 2 ] - ' 0 ' ) ;
}
else
{
volnume = cheatbuf [ i ] - ' 0 ' ;
levnume = cheatbuf [ i + 1 ] - ' 0 ' ;
}
2008-08-24 03:19:40 +00:00
2010-08-02 08:13:51 +00:00
volnume - - ;
levnume - - ;
2009-01-18 07:32:35 +00:00
2010-08-02 08:13:51 +00:00
if ( ( VOLUMEONE & & volnume > 0 ) | | volnume > g_numVolumes - 1 | |
levnume > = MAXLEVELS | | MapInfo [ volnume * MAXLEVELS + levnume ] . filename = = NULL )
{
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
}
2009-01-18 07:32:35 +00:00
2010-08-02 08:13:51 +00:00
ud . m_volume_number = ud . volume_number = volnume ;
ud . m_level_number = ud . level_number = levnume ;
}
else
{
// JBF 20030914
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 ( CheatStrings [ k ] ) - 1 ;
ud . m_player_skill = ud . player_skill = cheatbuf [ i ] - ' 1 ' ;
}
2012-10-28 22:27:53 +00:00
/*if (numplayers > 1 && g_netServer)
2010-08-02 08:13:51 +00:00
Net_NewGame ( ud . m_volume_number , ud . m_level_number ) ;
2012-10-28 22:27:53 +00:00
else */ g_player [ myconnectindex ] . ps - > gm | = MODE_RESTART ;
2006-04-13 20:47:06 +00:00
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-11-15 01:16:55 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_COORDS :
ud . coords = 1 - ud . coords ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_VIEW :
if ( g_player [ myconnectindex ] . ps - > over_shoulder_on )
g_player [ myconnectindex ] . ps - > over_shoulder_on = 0 ;
else
{
g_player [ myconnectindex ] . ps - > over_shoulder_on = 1 ;
g_cameraDistance = 0 ;
g_cameraClock = totalclock ;
}
2011-02-25 21:50:19 +00:00
// P_DoQuote(QUOTE_CHEATS_DISABLED,g_player[myconnectindex].ps);
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_TIME :
2011-02-25 21:50:19 +00:00
// P_DoQuote(QUOTE_21,g_player[myconnectindex].ps);
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_UNLOCK :
if ( VOLUMEONE ) return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( i = numsectors - 1 ; i > = 0 ; i - - ) //Unlock
{
j = sector [ i ] . lotag ;
if ( j = = - 1 | | j = = 32767 ) continue ;
if ( ( j & 0x7fff ) > 2 )
{
if ( j & ( 0xffff - 16384 ) )
sector [ i ] . lotag & = ( 0xffff - 16384 ) ;
G_OperateSectors ( i , g_player [ myconnectindex ] . ps - > i ) ;
}
}
G_OperateForceFields ( g_player [ myconnectindex ] . ps - > i , - 1 ) ;
2006-04-13 20:47:06 +00:00
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_UNLOCK , g_player [ myconnectindex ] . ps ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_CASHMAN :
ud . cashman = 1 - ud . cashman ;
KB_ClearKeyDown ( sc_N ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_ITEMS :
G_CheatGetInv ( ) ;
2012-04-13 10:45:49 +00:00
g_player [ myconnectindex ] . ps - > got_access = 7 ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_EVERYTHING , g_player [ myconnectindex ] . ps ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_SHOWMAP : // SHOW ALL OF THE MAP TOGGLE;
2012-04-13 10:45:49 +00:00
ud . showallmap = ! ud . showallmap ;
for ( i = 0 ; i < ( MAXSECTORS > > 3 ) ; i + + )
show2dsector [ i ] = ud . showallmap * 255 ;
for ( i = 0 ; i < ( MAXWALLS > > 3 ) ; i + + )
show2dwall [ i ] = ud . showallmap * 255 ;
2012-07-20 21:57:59 +00:00
P_DoQuote ( ud . showallmap ? QUOTE_SHOW_MAP_ON : QUOTE_SHOW_MAP_OFF ,
2012-04-13 10:45:49 +00:00
g_player [ myconnectindex ] . ps ) ;
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_TODD :
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_TODD , g_player [ myconnectindex ] . ps ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_RATE :
ud . tickrate = ! ud . tickrate ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_BETA :
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_BETA , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
KB_ClearKeyDown ( sc_H ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_HYPER :
g_player [ myconnectindex ] . ps - > inv_amount [ GET_STEROIDS ] = 399 ;
g_player [ myconnectindex ] . ps - > inv_amount [ GET_HEATS ] = 1200 ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEAT_STEROIDS , g_player [ myconnectindex ] . ps ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_MONSTERS :
{
2012-08-07 13:08:57 +00:00
const char * s [ ] = { " On " , " Off " , " On (2) " } ;
2011-02-25 21:50:19 +00:00
if ( + + g_noEnemies = = 3 )
g_noEnemies = 0 ;
2006-04-13 20:47:06 +00:00
2012-08-07 13:08:57 +00:00
Bsprintf ( ScriptQuotes [ QUOTE_RESERVED4 ] , " Monsters: %s " , s [ g_noEnemies ] ) ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_RESERVED4 , g_player [ myconnectindex ] . ps ) ;
2012-04-13 10:45:49 +00:00
end_cheat ( ) ;
2010-08-02 08:13:51 +00:00
return ;
}
2012-04-13 10:45:49 +00:00
2010-08-02 08:13:51 +00:00
case CHEAT_RESERVED :
case CHEAT_RESERVED3 :
ud . eog = 1 ;
2012-06-03 16:12:44 +00:00
g_player [ myconnectindex ] . ps - > player_par = 0 ;
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_EOL ;
2012-11-17 16:48:11 +00:00
KB_FlushKeyboardQueue ( ) ;
2010-08-02 08:13:51 +00:00
return ;
}
}
}
}
else
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( KB_KeyPressed ( ( uint8_t ) CheatKeys [ 0 ] ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( g_player [ myconnectindex ] . ps - > cheat_phase > = 0 & & numplayers < 2 & & ud . recstat = = 0 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( CheatKeys [ 0 ] = = CheatKeys [ 1 ] )
KB_ClearKeyDown ( ( uint8_t ) CheatKeys [ 0 ] ) ;
g_player [ myconnectindex ] . ps - > cheat_phase = - 1 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( KB_KeyPressed ( ( uint8_t ) CheatKeys [ 1 ] ) )
{
if ( g_player [ myconnectindex ] . ps - > cheat_phase = = - 1 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ud . player_skill = = 4 )
2006-04-13 20:47:06 +00:00
{
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CHEATS_DISABLED , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
}
else
{
g_player [ myconnectindex ] . ps - > cheat_phase = 1 ;
2011-02-25 21:50:19 +00:00
// P_DoQuote(QUOTE_25,g_player[myconnectindex].ps);
2010-08-02 08:13:51 +00:00
cheatbuflen = 0 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
KB_FlushKeyboardQueue ( ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
else if ( g_player [ myconnectindex ] . ps - > cheat_phase ! = 0 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > cheat_phase = 0 ;
KB_ClearKeyDown ( ( uint8_t ) CheatKeys [ 0 ] ) ;
KB_ClearKeyDown ( ( uint8_t ) CheatKeys [ 1 ] ) ;
}
}
}
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
void G_HandleLocalKeys ( void )
{
int32_t i , ch ;
int32_t j ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// CONTROL_ProcessBinds();
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . recstat = = 2 )
{
ControlInfo noshareinfo ;
CONTROL_GetInput ( & noshareinfo ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_player [ myconnectindex ] . gotvote = = 0 & & voting ! = - 1 & & voting ! = myconnectindex )
{
if ( KB_UnBoundKeyPressed ( sc_F1 ) | | KB_UnBoundKeyPressed ( sc_F2 ) | | ud . autovote )
{
2012-03-26 05:07:12 +00:00
G_AddUserQuote ( " Vote Cast " ) ;
2012-10-28 22:27:53 +00:00
Net_SendMapVote ( KB_UnBoundKeyPressed ( sc_F1 ) | | ud . autovote ? ud . autovote - 1 : 0 ) ;
2010-08-02 08:13:51 +00:00
KB_ClearKeyDown ( sc_F1 ) ;
KB_ClearKeyDown ( sc_F2 ) ;
}
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( ! ALT_IS_PRESSED & & ud . overhead_on = = 0 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_TYPE ) = = 0 )
{
if ( BUTTON ( gamefunc_Enlarge_Screen ) )
{
CONTROL_ClearButton ( gamefunc_Enlarge_Screen ) ;
if ( ! SHIFTS_IS_PRESSED )
{
if ( ud . screen_size > 0 )
S_PlaySound ( THUD ) ;
if ( getrendermode ( ) > = 3 & & ud . screen_size = = 8 & & ud . statusbarmode = = 0 )
ud . statusbarmode = 1 ;
else ud . screen_size - = 4 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . statusbarscale = = 100 & & ud . statusbarmode = = 1 )
{
ud . statusbarmode = 0 ;
ud . screen_size - = 4 ;
}
}
else
{
ud . statusbarscale + = 4 ;
G_SetStatusBarScale ( ud . statusbarscale ) ;
}
G_UpdateScreenArea ( ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( BUTTON ( gamefunc_Shrink_Screen ) )
{
CONTROL_ClearButton ( gamefunc_Shrink_Screen ) ;
if ( ! SHIFTS_IS_PRESSED )
{
if ( ud . screen_size < 64 ) S_PlaySound ( THUD ) ;
if ( getrendermode ( ) > = 3 & & ud . screen_size = = 8 & & ud . statusbarmode = = 1 )
ud . statusbarmode = 0 ;
else ud . screen_size + = 4 ;
}
else
{
ud . statusbarscale - = 4 ;
if ( ud . statusbarscale < 37 )
ud . statusbarscale = 37 ;
G_SetStatusBarScale ( ud . statusbarscale ) ;
}
G_UpdateScreenArea ( ) ;
}
}
2006-04-13 20:47:06 +00:00
2012-04-13 10:46:04 +00:00
if ( g_player [ myconnectindex ] . ps - > cheat_phase = = 1 | | ( g_player [ myconnectindex ] . ps - > gm & ( MODE_MENU | MODE_TYPE ) ) )
return ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( BUTTON ( gamefunc_See_Coop_View ) & & ( GTFLAGS ( GAMETYPE_COOPVIEW ) | | ud . recstat = = 2 ) )
{
CONTROL_ClearButton ( gamefunc_See_Coop_View ) ;
screenpeek = connectpoint2 [ screenpeek ] ;
if ( screenpeek = = - 1 ) screenpeek = 0 ;
2012-02-02 17:34:16 +00:00
g_restorePalette = - 1 ;
2010-08-02 08:13:51 +00:00
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) & & BUTTON ( gamefunc_Show_Opponents_Weapon ) )
{
CONTROL_ClearButton ( gamefunc_Show_Opponents_Weapon ) ;
ud . config . ShowOpponentWeapons = ud . showweapons = 1 - ud . showweapons ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_WEAPON_MODE_OFF - ud . showweapons , g_player [ screenpeek ] . ps ) ;
2010-08-02 08:13:51 +00:00
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( BUTTON ( gamefunc_Toggle_Crosshair ) )
{
CONTROL_ClearButton ( gamefunc_Toggle_Crosshair ) ;
ud . crosshair = ! ud . crosshair ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_CROSSHAIR_OFF - ud . crosshair , g_player [ screenpeek ] . ps ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . overhead_on & & BUTTON ( gamefunc_Map_Follow_Mode ) )
{
CONTROL_ClearButton ( gamefunc_Map_Follow_Mode ) ;
ud . scrollmode = 1 - ud . scrollmode ;
if ( ud . scrollmode )
{
ud . folx = g_player [ screenpeek ] . ps - > opos . x ;
ud . foly = g_player [ screenpeek ] . ps - > opos . y ;
ud . fola = g_player [ screenpeek ] . ps - > oang ;
}
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_MAP_FOLLOW_OFF + ud . scrollmode , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( KB_UnBoundKeyPressed ( sc_ScrollLock ) )
{
KB_ClearKeyDown ( sc_ScrollLock ) ;
2007-08-27 06:46:31 +00:00
2010-08-02 08:13:51 +00:00
switch ( ud . recstat )
{
case 0 :
2011-05-07 18:23:34 +00:00
if ( SHIFTS_IS_PRESSED )
G_OpenDemoWrite ( ) ;
2010-08-02 08:13:51 +00:00
break ;
case 1 :
G_CloseDemoWrite ( ) ;
break ;
}
}
2007-08-27 06:46:31 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . recstat = = 2 )
{
if ( KB_KeyPressed ( sc_Space ) )
{
KB_ClearKeyDown ( sc_Space ) ;
2006-12-17 21:20:35 +00:00
2010-08-02 08:13:51 +00:00
g_demo_paused = ! g_demo_paused ;
g_demo_rewind = 0 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( g_demo_paused )
{
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
}
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( KB_KeyPressed ( sc_Tab ) )
{
KB_ClearKeyDown ( sc_Tab ) ;
g_demo_showStats = ! g_demo_showStats ;
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
#if 0
if ( KB_KeyPressed ( sc_kpad_Plus ) )
{
if ( g_timerTicsPerSecond ! = 240 )
{
uninittimer ( ) ;
inittimer ( 240 ) ;
g_timerTicsPerSecond = 240 ;
}
}
else if ( KB_KeyPressed ( sc_kpad_Minus ) )
{
if ( g_timerTicsPerSecond ! = 60 )
{
uninittimer ( ) ;
inittimer ( 60 ) ;
g_timerTicsPerSecond = 60 ;
}
}
else if ( g_timerTicsPerSecond ! = 120 )
{
uninittimer ( ) ;
inittimer ( 120 ) ;
g_timerTicsPerSecond = 120 ;
}
# endif
2006-12-18 08:37:12 +00:00
2010-08-02 08:13:51 +00:00
if ( KB_KeyPressed ( sc_kpad_6 ) )
{
KB_ClearKeyDown ( sc_kpad_6 ) ;
2012-11-15 14:28:41 +00:00
j = ( 15 < < ( int ) ALT_IS_PRESSED ) < < ( 2 * ( int ) SHIFTS_IS_PRESSED ) ;
2012-09-08 22:18:40 +00:00
g_demo_goalCnt = g_demo_paused ? g_demo_cnt + 1 : g_demo_cnt + REALGAMETICSPERSEC * j ;
2010-08-02 08:13:51 +00:00
g_demo_rewind = 0 ;
2006-12-18 08:37:12 +00:00
2010-08-02 08:13:51 +00:00
if ( g_demo_goalCnt > g_demo_totalCnt )
g_demo_goalCnt = 0 ;
else
2012-09-05 17:25:26 +00:00
Demo_PrepareWarp ( ) ;
2010-08-02 08:13:51 +00:00
}
else if ( KB_KeyPressed ( sc_kpad_4 ) )
{
KB_ClearKeyDown ( sc_kpad_4 ) ;
2012-11-15 14:28:41 +00:00
j = ( 15 < < ( int ) ALT_IS_PRESSED ) < < ( 2 * ( int ) SHIFTS_IS_PRESSED ) ;
2012-09-08 22:18:40 +00:00
g_demo_goalCnt = g_demo_paused ? g_demo_cnt - 1 : g_demo_cnt - REALGAMETICSPERSEC * j ;
2010-08-02 08:13:51 +00:00
g_demo_rewind = 1 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( g_demo_goalCnt < = 0 )
g_demo_goalCnt = 1 ;
2006-11-16 03:02:42 +00:00
2012-09-05 17:25:26 +00:00
Demo_PrepareWarp ( ) ;
2010-08-02 08:13:51 +00:00
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
#if 0
2012-09-08 22:18:26 +00:00
// Enter a game from within a demo.
2010-08-02 08:13:51 +00:00
if ( KB_KeyPressed ( sc_Return ) & & ud . multimode = = 1 )
{
KB_ClearKeyDown ( sc_Return ) ;
g_demo_cnt = g_demo_goalCnt = ud . reccnt = ud . pause_on = ud . recstat = ud . m_recstat = 0 ;
2012-09-08 22:18:26 +00:00
// XXX: probably redundant; this stuff needs an API anyway:
kclose ( g_demo_recFilePtr ) ; g_demo_recFilePtr = - 1 ;
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_GAME ;
2012-09-08 22:18:26 +00:00
ready2send = 1 ; // TODO: research this weird variable
2010-08-02 08:13:51 +00:00
screenpeek = myconnectindex ;
// g_demo_paused=0;
}
# endif
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( SHIFTS_IS_PRESSED | | ALT_IS_PRESSED )
{
i = 0 ;
j = sc_F1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
do
{
if ( KB_UnBoundKeyPressed ( j ) )
{
KB_ClearKeyDown ( j ) ;
i = j - sc_F1 + 1 ;
}
}
while ( + + j < sc_F11 ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( i )
{
if ( SHIFTS_IS_PRESSED )
{
2011-02-25 21:50:19 +00:00
if ( i = = 5 & & g_player [ myconnectindex ] . ps - > fta > 0 & & g_player [ myconnectindex ] . ps - > ftq = = QUOTE_MUSIC )
2010-08-02 08:13:51 +00:00
{
i = ( VOLUMEALL ? MAXVOLUMES * MAXLEVELS : 6 ) ;
g_musicIndex = ( g_musicIndex + 1 ) % i ;
2012-06-04 22:01:45 +00:00
while ( MapInfo [ g_musicIndex ] . musicfn = = NULL )
2010-08-02 08:13:51 +00:00
{
g_musicIndex + + ;
if ( g_musicIndex > = i )
g_musicIndex = 0 ;
2006-11-16 03:02:42 +00:00
}
2012-06-04 22:01:45 +00:00
if ( MapInfo [ g_musicIndex ] . musicfn ! = NULL )
2006-11-16 03:02:42 +00:00
{
2012-06-04 22:01:45 +00:00
if ( S_PlayMusic ( & MapInfo [ g_musicIndex ] . musicfn [ 0 ] , g_musicIndex ) )
Bsprintf ( ScriptQuotes [ QUOTE_MUSIC ] , " Playing %s " , & MapInfo [ g_musicIndex ] . alt_musicfn [ 0 ] ) ;
2010-08-02 08:13:51 +00:00
else
2012-06-04 22:01:45 +00:00
Bsprintf ( ScriptQuotes [ QUOTE_MUSIC ] , " Playing %s " , & MapInfo [ g_musicIndex ] . musicfn [ 0 ] ) ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_MUSIC , g_player [ myconnectindex ] . ps ) ;
2006-11-16 03:02:42 +00:00
}
return ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
G_AddUserQuote ( ud . ridecule [ i - 1 ] ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
ch = 0 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
tempbuf [ ch ] = PACKET_MESSAGE ;
tempbuf [ ch + 1 ] = 255 ;
tempbuf [ ch + 2 ] = 0 ;
Bstrcat ( tempbuf + 2 , ud . ridecule [ i - 1 ] ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
i = 2 + strlen ( ud . ridecule [ i - 1 ] ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
tempbuf [ i + + ] = myconnectindex ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_netClient )
enet_peer_send ( g_netClientPeer , CHAN_CHAT , enet_packet_create ( tempbuf , i , 0 ) ) ;
else if ( g_netServer )
enet_host_broadcast ( g_netServer , CHAN_CHAT , enet_packet_create ( tempbuf , i , 0 ) ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
pus = NUMPAGES ;
pub = NUMPAGES ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . lockout = = 0 )
if ( ud . config . SoundToggle & & ALT_IS_PRESSED & & ( RTS_NumSounds ( ) > 0 ) & & g_RTSPlaying = = 0 & & ( ud . config . VoiceToggle & 1 ) )
{
FX_PlayAuto3D ( ( char * ) RTS_GetSound ( i - 1 ) , RTS_SoundLength ( i - 1 ) , 0 , 0 , 0 , 255 , - i ) ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
g_RTSPlaying = 7 ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) )
{
tempbuf [ 0 ] = PACKET_RTS ;
tempbuf [ 1 ] = i ;
tempbuf [ 2 ] = myconnectindex ;
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
if ( g_netClient )
enet_peer_send ( g_netClientPeer , CHAN_CHAT , enet_packet_create ( tempbuf , 3 , 0 ) ) ;
else if ( g_netServer )
enet_host_broadcast ( g_netServer , CHAN_CHAT , enet_packet_create ( tempbuf , 3 , 0 ) ) ;
}
2006-11-16 03:02:42 +00:00
2010-08-02 08:13:51 +00:00
pus = NUMPAGES ;
pub = NUMPAGES ;
2006-11-16 03:02:42 +00:00
return ;
}
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
if ( ! ALT_IS_PRESSED & & ! SHIFTS_IS_PRESSED )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ( g_netServer | | ud . multimode > 1 ) & & BUTTON ( gamefunc_SendMessage ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
KB_FlushKeyboardQueue ( ) ;
CONTROL_ClearButton ( gamefunc_SendMessage ) ;
g_player [ myconnectindex ] . ps - > gm | = MODE_TYPE ;
typebuf [ 0 ] = 0 ;
inputloc = 0 ;
}
2012-06-03 16:11:22 +00:00
if ( KB_UnBoundKeyPressed ( sc_F1 ) /* || (ud.show_help && I_AdvanceTrigger())*/ )
2010-08-02 08:13:51 +00:00
{
KB_ClearKeyDown ( sc_F1 ) ;
2012-10-14 22:16:07 +00:00
M_ChangeMenu ( 400 ) ;
2010-08-02 08:13:51 +00:00
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
if ( ( ! g_netServer & & ud . multimode < 2 ) )
2007-02-28 09:12:41 +00:00
{
2010-08-02 08:13:51 +00:00
ready2send = 0 ;
totalclock = ototalclock ;
screenpeek = myconnectindex ;
2007-03-01 00:50:59 +00:00
}
2010-08-02 08:13:51 +00:00
/*
2012-08-06 20:00:31 +00:00
I_AdvanceTriggerClear ( ) ;
ud . show_help + + ;
2010-08-02 08:13:51 +00:00
2012-08-06 20:00:31 +00:00
if ( ud . show_help > 2 )
{
ud . show_help = 0 ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 ) ready2send = 1 ;
G_UpdateScreenArea ( ) ;
}
else
{
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 )
{
ready2send = 0 ;
totalclock = ototalclock ;
}
}
2010-08-02 08:13:51 +00:00
*/
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
// if((!net_server && ud.multimode < 2))
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ud . recstat ! = 2 & & KB_UnBoundKeyPressed ( sc_F2 ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
KB_ClearKeyDown ( sc_F2 ) ;
FAKE_F2 :
if ( sprite [ g_player [ myconnectindex ] . ps - > i ] . extra < = 0 )
2006-04-13 20:47:06 +00:00
{
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_SAVE_DEAD , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2012-10-14 22:16:07 +00:00
M_ChangeMenu ( 350 ) ;
2010-08-02 08:13:51 +00:00
g_screenCapture = 1 ;
G_DrawRooms ( myconnectindex , 65536 ) ;
//savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100);
g_screenCapture = 0 ;
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
// setview(0,0,xdim-1,ydim-1);
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
if ( ( ! g_netServer & & ud . multimode < 2 ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
ready2send = 0 ;
totalclock = ototalclock ;
screenpeek = myconnectindex ;
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
if ( KB_UnBoundKeyPressed ( sc_F3 ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
KB_ClearKeyDown ( sc_F3 ) ;
FAKE_F3 :
2012-10-14 22:16:07 +00:00
M_ChangeMenu ( 300 ) ;
2010-08-02 08:13:51 +00:00
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
// setview(0,0,xdim-1,ydim-1);
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 )
{
ready2send = 0 ;
totalclock = ototalclock ;
}
screenpeek = myconnectindex ;
2008-11-20 14:06:36 +00:00
}
}
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
if ( KB_UnBoundKeyPressed ( sc_F4 ) & & ud . config . FXDevice > = 0 )
{
KB_ClearKeyDown ( sc_F4 ) ;
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 )
{
ready2send = 0 ;
totalclock = ototalclock ;
}
2012-10-14 22:16:07 +00:00
M_ChangeMenu ( MENU_SOUND_INGAME ) ;
2008-06-30 07:30:48 +00:00
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( KB_UnBoundKeyPressed ( sc_F6 ) | | g_doQuickSave = = 1 ) & & ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
2006-05-04 04:18:55 +00:00
{
2010-08-02 08:13:51 +00:00
KB_ClearKeyDown ( sc_F6 ) ;
g_doQuickSave = 0 ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
if ( g_lastSaveSlot = = - 1 ) goto FAKE_F2 ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
KB_FlushKeyboardQueue ( ) ;
2006-05-04 04:18:55 +00:00
2010-08-02 08:13:51 +00:00
if ( sprite [ g_player [ myconnectindex ] . ps - > i ] . extra < = 0 )
{
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_SAVE_DEAD , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
return ;
}
g_screenCapture = 1 ;
G_DrawRooms ( myconnectindex , 65536 ) ;
//savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100);
g_screenCapture = 0 ;
if ( g_lastSaveSlot > = 0 )
{
/* inputloc = Bstrlen(&ud.savegame[g_lastSaveSlot][0]);
g_currentMenu = 360 + g_lastSaveSlot ;
probey = g_lastSaveSlot ; */
2012-09-05 17:25:43 +00:00
G_SavePlayerMaybeMulti ( g_lastSaveSlot ) ;
2010-08-02 08:13:51 +00:00
}
2006-05-04 04:18:55 +00:00
}
2010-08-02 08:13:51 +00:00
if ( KB_UnBoundKeyPressed ( sc_F7 ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
KB_ClearKeyDown ( sc_F7 ) ;
if ( g_player [ myconnectindex ] . ps - > over_shoulder_on )
g_player [ myconnectindex ] . ps - > over_shoulder_on = 0 ;
else
2007-02-13 01:28:50 +00:00
{
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > over_shoulder_on = 1 ;
g_cameraDistance = 0 ;
g_cameraClock = totalclock ;
}
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_VIEW_MODE_OFF + g_player [ myconnectindex ] . ps - > over_shoulder_on , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
}
2007-02-13 01:28:50 +00:00
2010-08-02 08:13:51 +00:00
if ( KB_UnBoundKeyPressed ( sc_F5 ) & & ud . config . MusicDevice > = 0 )
{
KB_ClearKeyDown ( sc_F5 ) ;
2012-06-04 22:01:45 +00:00
if ( MapInfo [ g_musicIndex ] . alt_musicfn ! = NULL )
Bstrcpy ( ScriptQuotes [ QUOTE_MUSIC ] , & MapInfo [ g_musicIndex ] . alt_musicfn [ 0 ] ) ;
else if ( MapInfo [ g_musicIndex ] . musicfn ! = NULL )
2010-08-02 08:13:51 +00:00
{
2012-06-04 22:01:45 +00:00
Bstrcpy ( ScriptQuotes [ QUOTE_MUSIC ] , & MapInfo [ g_musicIndex ] . musicfn [ 0 ] ) ;
2012-03-26 05:07:12 +00:00
Bstrcat ( ScriptQuotes [ QUOTE_MUSIC ] , " . Use SHIFT-F5 to change. " ) ;
2007-02-13 01:28:50 +00:00
}
2011-02-25 21:50:19 +00:00
else ScriptQuotes [ QUOTE_MUSIC ] [ 0 ] = ' \0 ' ;
P_DoQuote ( QUOTE_MUSIC , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
}
if ( KB_UnBoundKeyPressed ( sc_F8 ) )
{
KB_ClearKeyDown ( sc_F8 ) ;
ud . fta_on = ! ud . fta_on ;
2011-02-25 21:50:19 +00:00
if ( ud . fta_on ) P_DoQuote ( QUOTE_MESSAGES_ON , g_player [ myconnectindex ] . ps ) ;
2007-02-13 01:28:50 +00:00
else
{
2010-08-02 08:13:51 +00:00
ud . fta_on = 1 ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_MESSAGES_OFF , g_player [ myconnectindex ] . ps ) ;
2010-08-02 08:13:51 +00:00
ud . fta_on = 0 ;
2007-02-13 01:28:50 +00:00
}
2006-04-13 20:47:06 +00:00
}
2007-02-13 01:28:50 +00:00
2010-08-02 08:13:51 +00:00
if ( ( KB_UnBoundKeyPressed ( sc_F9 ) | | g_doQuickSave = = 2 ) & & ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
KB_ClearKeyDown ( sc_F9 ) ;
g_doQuickSave = 0 ;
if ( g_lastSaveSlot = = - 1 ) goto FAKE_F3 ;
if ( g_lastSaveSlot > = 0 )
2007-02-13 01:28:50 +00:00
{
2010-08-02 08:13:51 +00:00
KB_FlushKeyboardQueue ( ) ;
KB_ClearKeysDown ( ) ;
FX_StopAllSounds ( ) ;
2012-10-30 15:54:35 +00:00
S_ClearSoundLocks ( ) ;
2010-08-02 08:13:51 +00:00
2012-09-05 17:25:43 +00:00
G_LoadPlayerMaybeMulti ( g_lastSaveSlot ) ;
2007-02-13 01:28:50 +00:00
}
2010-08-02 08:13:51 +00:00
}
if ( KB_UnBoundKeyPressed ( sc_F10 ) )
{
KB_ClearKeyDown ( sc_F10 ) ;
2012-10-14 22:16:07 +00:00
M_ChangeMenu ( 500 ) ;
2010-08-02 08:13:51 +00:00
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 )
2007-02-13 01:28:50 +00:00
{
2010-08-02 08:13:51 +00:00
ready2send = 0 ;
totalclock = ototalclock ;
2007-02-13 01:28:50 +00:00
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ud . overhead_on ! = 0 )
{
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
j = totalclock - nonsharedtimer ;
nonsharedtimer + = j ;
if ( BUTTON ( gamefunc_Enlarge_Screen ) )
g_player [ myconnectindex ] . ps - > zoom + = mulscale6 ( j , max ( g_player [ myconnectindex ] . ps - > zoom , 256 ) ) ;
if ( BUTTON ( gamefunc_Shrink_Screen ) )
g_player [ myconnectindex ] . ps - > zoom - = mulscale6 ( j , max ( g_player [ myconnectindex ] . ps - > zoom , 256 ) ) ;
2011-12-25 15:33:24 +00:00
if ( g_player [ myconnectindex ] . ps - > zoom > 2048 )
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > zoom = 2048 ;
2011-12-25 15:33:24 +00:00
if ( g_player [ myconnectindex ] . ps - > zoom < 48 )
2010-08-02 08:13:51 +00:00
g_player [ myconnectindex ] . ps - > zoom = 48 ;
}
2006-04-13 20:47:06 +00:00
}
2012-06-03 16:11:22 +00:00
if ( I_EscapeTrigger ( ) & & ud . overhead_on & & g_player [ myconnectindex ] . ps - > newowner = = - 1 )
2006-04-13 20:47:06 +00:00
{
2012-06-03 16:11:22 +00:00
I_EscapeTriggerClear ( ) ;
2010-08-02 08:13:51 +00:00
ud . last_overhead = ud . overhead_on ;
ud . overhead_on = 0 ;
ud . scrollmode = 0 ;
G_UpdateScreenArea ( ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( BUTTON ( gamefunc_AutoRun ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
CONTROL_ClearButton ( gamefunc_AutoRun ) ;
ud . auto_run = 1 - ud . auto_run ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_RUN_MODE_OFF + ud . auto_run , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( BUTTON ( gamefunc_Map ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
CONTROL_ClearButton ( gamefunc_Map ) ;
if ( ud . last_overhead ! = ud . overhead_on & & ud . last_overhead )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
ud . overhead_on = ud . last_overhead ;
ud . last_overhead = 0 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
else
2010-01-24 23:33:17 +00:00
{
2010-08-02 08:13:51 +00:00
ud . overhead_on + + ;
if ( ud . overhead_on = = 3 ) ud . overhead_on = 0 ;
ud . last_overhead = ud . overhead_on ;
2010-01-24 23:33:17 +00:00
}
2010-08-02 08:13:51 +00:00
g_restorePalette = 1 ;
G_UpdateScreenArea ( ) ;
2010-01-24 23:33:17 +00:00
}
2010-08-02 08:13:51 +00:00
if ( KB_UnBoundKeyPressed ( sc_F11 ) )
2009-10-25 23:25:38 +00:00
{
2010-08-02 08:13:51 +00:00
KB_ClearKeyDown ( sc_F11 ) ;
2012-10-14 22:16:07 +00:00
M_ChangeMenu ( 232 ) ;
2010-08-02 08:13:51 +00:00
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ud . recstat ! = 2 )
2009-11-01 20:30:09 +00:00
{
2010-08-02 08:13:51 +00:00
ready2send = 0 ;
totalclock = ototalclock ;
2009-11-01 20:30:09 +00:00
}
2010-08-02 08:13:51 +00:00
}
}
2009-11-01 20:30:09 +00:00
2010-08-02 08:13:51 +00:00
static void G_ShowParameterHelp ( void )
{
2012-07-01 22:11:33 +00:00
const char * s = " Usage: eduke32 [files] [options] \n "
2010-08-02 08:13:51 +00:00
" Example: eduke32 -q4 -a -m -tx -map nukeland.map \n \n "
2011-06-23 15:41:08 +00:00
" Files can be *.grp/zip/con/def/rts \n "
2010-08-02 08:13:51 +00:00
" \n "
" -cfg [file.cfg] \t Use an alternate configuration file \n "
2012-03-26 05:05:57 +00:00
# ifdef HAVE_CLIPSHAPE_FEATURE
" -clipmap [file.map] \t Load an additional clipping map for use with clipshape \n "
# endif
2010-08-02 08:13:51 +00:00
" -connect [host] \t Connect to a multiplayer game \n "
" -c# \t \t Use MP mode #, 1 = Dukematch, 2 = Coop, 3 = Dukematch(no spawn) \n "
2012-10-01 17:52:40 +00:00
" -d[file.edm or demonum] \t Play a demo \n "
2012-03-26 05:05:57 +00:00
" -g[file.grp] \t Load additional game data \n "
" -h[file.def] \t Load an alternate definitions file \n "
2010-08-02 08:13:51 +00:00
" -j[dir] \t \t Adds a directory to EDuke32's search list \n "
" -l# \t \t Warp to level #, see -v \n "
" -map [file.map] \t Loads a map \n "
2012-03-26 05:05:57 +00:00
" -mh [file.def] \t Include an additional definitions module \n "
2011-07-21 22:39:29 +00:00
" -mx [file.con] \t Include an additional CON script module \n "
2010-08-02 08:13:51 +00:00
" -m \t \t Disable monsters \n "
2012-06-03 16:09:33 +00:00
" -nam \t \t Run in NAM compatibility mode \n "
" -napalm \t \t Run in Napalm compatibility mode \n "
2012-03-26 05:05:57 +00:00
" -rts [file.rts] \t Load a custom Remote Ridicule sound bank \n "
2010-08-02 08:13:51 +00:00
" -r \t \t Record demo \n "
" -s# \t \t Set skill level (1-4) \n "
" -server \t \t Start a multiplayer game for other players to join \n "
2012-11-25 04:26:37 +00:00
# if defined _WIN32 || (defined RENDERTYPESDL && ((defined __APPLE__ && defined OSX_STARTUPWINDOW) || defined HAVE_GTK2))
2010-08-02 08:13:51 +00:00
" -setup/nosetup \t Enables/disables startup window \n "
# endif
" -t# \t \t Set respawn mode: 1 = Monsters, 2 = Items, 3 = Inventory, x = All \n "
# if !defined(_WIN32)
" -usecwd \t \t Read game data and configuration file from working directory \n "
# endif
" -u######### \t User's favorite weapon order (default: 3425689071) \n "
" -v# \t \t Warp to volume #, see -l \n "
2012-06-03 16:09:33 +00:00
" -ww2gi \t \t Run in WWII GI compatibility mode \n "
2010-08-02 08:13:51 +00:00
" -x[game.con] \t Load custom CON script \n "
" -# \t \t Load and run a game from slot # (0-9) \n "
// "\n-?/--help\tDisplay this help message and exit\n"
" \n See eduke32 -debughelp for debug parameters "
;
# if defined RENDERTYPEWIN
2011-03-04 09:29:03 +00:00
Bsnprintf ( tempbuf , sizeof ( tempbuf ) , HEAD2 " %s " , s_buildRev ) ;
2012-03-05 07:25:24 +00:00
wm_msgbox ( tempbuf , " %s " , s ) ;
2010-08-02 08:13:51 +00:00
# else
initprintf ( " %s \n " , s ) ;
# endif
}
2009-10-25 23:25:38 +00:00
2010-08-02 08:13:51 +00:00
static void G_ShowDebugHelp ( void )
{
2012-07-01 22:11:33 +00:00
const char * s = " Usage: eduke32 [files] [options] \n "
2010-08-02 08:13:51 +00:00
" \n "
" -a \t \t Use fake player AI (fake multiplayer only) \n "
" -cachesize # \t Sets cache size, in Kb \n "
" -game_dir [dir] \t Duke3d_w32 compatibility option, see -j \n "
" -gamegrp \t Selects which file to use as main grp \n "
" -name [name] \t Player name in multiplay \n "
" -noautoload \t Disable loading content from autoload dir \n "
2011-11-10 21:47:26 +00:00
# ifdef _WIN32
2011-07-21 22:39:29 +00:00
" -nodinput \t \t Disable DirectInput (joystick) support \n "
2011-11-10 21:47:26 +00:00
# endif
2010-08-02 08:13:51 +00:00
" -nologo \t \t Skip the logo anim \n "
" -ns/-nm \t \t Disable sound or music \n "
" -q# \t \t Fake multiplayer with # (2-8) players \n "
" -z#/-condebug \t Enable line-by-line CON compile debugging at level # \n "
2010-09-27 21:52:04 +00:00
" -conversion YYYYMMDD \t Selects CON script version for compatibility with older mods \n "
2010-08-02 08:13:51 +00:00
;
# if defined RENDERTYPEWIN
2011-03-04 09:29:03 +00:00
Bsnprintf ( tempbuf , sizeof ( tempbuf ) , HEAD2 " %s " , s_buildRev ) ;
2012-03-05 07:25:24 +00:00
wm_msgbox ( tempbuf , " %s " , s ) ;
2010-08-02 08:13:51 +00:00
# else
initprintf ( " %s \n " , s ) ;
2010-01-24 23:33:17 +00:00
# endif
2010-08-02 08:13:51 +00:00
}
2009-10-25 23:25:38 +00:00
2011-02-25 21:50:19 +00:00
static char * S_OggifyFilename ( char * destname , char * OGGname , const char * origname )
2010-08-02 08:13:51 +00:00
{
if ( ! origname )
return destname ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
destname = ( char * ) Brealloc ( destname , Bstrlen ( OGGname ) + Bstrlen ( origname ) + 1 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ! destname )
return NULL ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
Bstrcpy ( destname , * OGGname ? OGGname : origname ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( * OGGname & & OGGname [ Bstrlen ( OGGname ) - 1 ] = = ' / ' )
{
while ( * origname = = ' / ' )
origname + + ;
Bstrcat ( destname , origname ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( OGGname = Bstrchr ( destname , ' . ' ) ) )
Bstrcpy ( OGGname , " .ogg " ) ;
else Bstrcat ( destname , " .ogg " ) ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
return destname ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
static int32_t S_DefineSound ( int32_t ID , char * name )
{
if ( ID > = MAXSOUNDS )
return 1 ;
2012-01-10 23:44:35 +00:00
g_sounds [ ID ] . filename1 = S_OggifyFilename ( g_sounds [ ID ] . filename1 , name , g_sounds [ ID ] . filename ) ;
2010-08-02 08:13:51 +00:00
// initprintf("(%s)(%s)(%s)\n",g_sounds[ID].filename1,name,g_sounds[ID].filename);
// S_LoadSound(ID);
return 0 ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
static int32_t S_DefineMusic ( char * ID , char * name )
{
int32_t lev , ep ;
int32_t sel = MAXVOLUMES * MAXLEVELS ;
char b1 , b2 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ! ID )
return 1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ! Bstrcmp ( ID , " intro " ) )
{
ID = EnvMusicFilename [ 0 ] ;
}
else if ( ! Bstrcmp ( ID , " briefing " ) )
{
sel + + ;
ID = EnvMusicFilename [ 1 ] ;
}
else if ( ! Bstrcmp ( ID , " loading " ) )
{
sel + = 2 ;
ID = EnvMusicFilename [ 2 ] ;
}
else
{
sscanf ( ID , " %c%d%c%d " , & b1 , & ep , & b2 , & lev ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( Btoupper ( b1 ) ! = ' E ' | | Btoupper ( b2 ) ! = ' L ' | | - - lev > = MAXLEVELS | | - - ep > = MAXVOLUMES )
return 1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
sel = ( ep * MAXLEVELS ) + lev ;
ID = MapInfo [ sel ] . musicfn ;
}
2006-04-13 20:47:06 +00:00
2011-02-25 21:50:19 +00:00
MapInfo [ sel ] . alt_musicfn = S_OggifyFilename ( MapInfo [ sel ] . alt_musicfn , name , ID ) ;
2010-08-02 08:13:51 +00:00
// initprintf("%-15s | ",ID);
// initprintf("%3d %2d %2d | %s\n",sel,ep,lev,MapInfo[sel].alt_musicfn);
// S_PlayMusic(ID,sel);
return 0 ;
}
2006-04-13 20:47:06 +00:00
2012-01-10 23:44:35 +00:00
static int32_t parsedefinitions_game ( scriptfile * script , int32_t preload ) ;
2011-07-21 22:39:29 +00:00
2012-07-01 22:11:33 +00:00
static void parsedefinitions_game_include ( const char * fn , scriptfile * script , const char * cmdtokptr , const int32_t preload )
2011-07-21 22:39:29 +00:00
{
scriptfile * included = scriptfile_fromfile ( fn ) ;
if ( ! included )
{
if ( ! Bstrcasecmp ( cmdtokptr , " null " ) | | script = = NULL ) // this is a bit overboard to prevent unused parameter warnings
{
// initprintf("Warning: Failed including %s as module\n", fn);
}
/*
else
{
initprintf ( " Warning: Failed including %s on line %s:%d \n " ,
fn , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
}
*/
}
else
{
parsedefinitions_game ( included , preload ) ;
scriptfile_close ( included ) ;
}
}
2012-01-10 23:44:35 +00:00
static int32_t parsedefinitions_game ( scriptfile * script , int32_t preload )
2010-08-02 08:13:51 +00:00
{
int32_t tokn ;
char * cmdtokptr ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
static const tokenlist tokens [ ] =
{
{ " include " , T_INCLUDE } ,
{ " #include " , T_INCLUDE } ,
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
{ " includedefault " , T_INCLUDEDEFAULT } ,
{ " #includedefault " , T_INCLUDEDEFAULT } ,
2010-08-02 08:13:51 +00:00
{ " loadgrp " , T_LOADGRP } ,
{ " cachesize " , T_CACHESIZE } ,
{ " noautoload " , T_NOAUTOLOAD } ,
{ " music " , T_MUSIC } ,
{ " sound " , T_SOUND } ,
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
# ifdef USE_LIBVPX
{ " animsounds " , T_ANIMSOUNDS } ,
# endif
2012-03-22 22:47:29 +00:00
{ " nofloorpalrange " , T_NOFLOORPALRANGE } ,
2010-08-02 08:13:51 +00:00
} ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
static const tokenlist sound_musictokens [ ] =
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
{ " id " , T_ID } ,
{ " file " , T_FILE } ,
} ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
while ( 1 )
{
tokn = getatoken ( script , tokens , sizeof ( tokens ) / sizeof ( tokenlist ) ) ;
cmdtokptr = script - > ltextptr ;
switch ( tokn )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
case T_LOADGRP :
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
char * fn ;
2010-06-22 21:50:01 +00:00
2010-08-02 08:13:51 +00:00
pathsearchmode = 1 ;
if ( ! scriptfile_getstring ( script , & fn ) & & preload )
2010-06-22 21:50:01 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t j = initgroupfile ( fn ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( j = = - 1 )
2012-03-26 05:05:57 +00:00
initprintf ( " Could not find file \" %s \" . \n " , fn ) ;
2010-08-02 08:13:51 +00:00
else
2006-04-13 20:47:06 +00:00
{
2012-03-26 05:05:57 +00:00
initprintf ( " Using file \" %s \" as game data. \n " , fn ) ;
2010-08-02 08:13:51 +00:00
if ( ! g_noAutoLoad & & ! ud . config . NoAutoLoad )
G_DoAutoload ( fn ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
pathsearchmode = 0 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
break ;
case T_CACHESIZE :
{
int32_t j ;
if ( scriptfile_getnumber ( script , & j ) | | ! preload ) break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( j > 0 ) MAXCACHE1DSIZE = j < < 10 ;
}
break ;
case T_INCLUDE :
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
char * fn ;
if ( ! scriptfile_getstring ( script , & fn ) )
2011-07-21 22:39:29 +00:00
parsedefinitions_game_include ( fn , script , cmdtokptr , preload ) ;
2010-08-02 08:13:51 +00:00
break ;
}
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
case T_INCLUDEDEFAULT :
{
2012-06-03 16:09:33 +00:00
parsedefinitions_game_include ( G_DefaultDefFile ( ) , script , cmdtokptr , preload ) ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
break ;
}
2010-08-02 08:13:51 +00:00
case T_NOAUTOLOAD :
if ( preload )
g_noAutoLoad = 1 ;
break ;
case T_MUSIC :
{
char * tinttokptr = script - > ltextptr ;
2012-03-28 19:41:39 +00:00
char * ID = NULL , * fn = " " ;
2010-08-02 08:13:51 +00:00
char * musicend ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( scriptfile_getbraces ( script , & musicend ) ) break ;
while ( script - > textptr < musicend )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
switch ( getatoken ( script , sound_musictokens , sizeof ( sound_musictokens ) / sizeof ( tokenlist ) ) )
{
case T_ID :
scriptfile_getstring ( script , & ID ) ;
break ;
case T_FILE :
scriptfile_getstring ( script , & fn ) ;
break ;
}
}
if ( ! preload )
{
if ( ID = = NULL )
{
initprintf ( " Error: missing ID for music definition near line %s:%d \n " , script - > filename , scriptfile_getlinum ( script , tinttokptr ) ) ;
break ;
}
2006-04-13 20:47:06 +00:00
2012-03-28 19:41:39 +00:00
if ( check_file_exist ( fn ) )
break ;
2010-08-02 08:13:51 +00:00
if ( S_DefineMusic ( ID , fn ) )
initprintf ( " Error: invalid music ID on line %s:%d \n " , script - > filename , scriptfile_getlinum ( script , tinttokptr ) ) ;
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
break ;
2006-04-13 20:47:06 +00:00
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
# ifdef USE_LIBVPX
case T_ANIMSOUNDS :
{
char * otokptr = script - > ltextptr ;
char * animsoundsend = NULL ;
2012-02-04 14:29:41 +00:00
int32_t animnum , numpairs = 0 , allocsz = 4 , bad = 1 , lastframenum = INT32_MIN ;
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
static const tokenlist hardcoded_anim_tokens [ ] =
{
{ " cineov2 " , 0 } ,
{ " cineov3 " , 1 } ,
{ " RADLOGO " , 2 } ,
{ " DUKETEAM " , 3 } ,
{ " logo " , 4 } ,
{ " vol41a " , 5 } ,
{ " vol42a " , 6 } ,
{ " vol4e1 " , 7 } ,
{ " vol43a " , 8 } ,
{ " vol4e2 " , 9 } ,
{ " vol4e3 " , 10 } ,
// NUM_HARDCODED_ANIMS
} ;
animnum = getatoken ( script , hardcoded_anim_tokens , NUM_HARDCODED_ANIMS ) ;
if ( ( unsigned ) animnum > = NUM_HARDCODED_ANIMS )
initprintf ( " Error: expected a hardcoded anim file name (sans extension) on line %s:%d \n " ,
script - > filename , scriptfile_getlinum ( script , otokptr ) ) ;
if ( scriptfile_getbraces ( script , & animsoundsend ) ) break ;
if ( anim_hi_sounds [ animnum ] )
{
initprintf ( " Warning: overwriting already defined hi-anim %s's sounds on line %s:%d \n " ,
hardcoded_anim_tokens [ animnum ] . text , script - > filename ,
scriptfile_getlinum ( script , otokptr ) ) ;
Bfree ( anim_hi_sounds [ animnum ] ) ;
anim_hi_numsounds [ animnum ] = 0 ;
}
if ( ! preload )
2012-11-15 14:28:29 +00:00
anim_hi_sounds [ animnum ] = ( uint16_t * ) Bcalloc ( allocsz , 2 * sizeof ( anim_hi_sounds [ 0 ] ) ) ;
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
while ( script - > textptr < animsoundsend )
{
int32_t framenum , soundnum ;
if ( preload )
{
// dummy
getatoken ( script , hardcoded_anim_tokens , NUM_HARDCODED_ANIMS ) ;
continue ;
}
2012-01-15 22:38:54 +00:00
// HACK: we've reached the end of the list
// (hack because it relies on knowledge of
// how scriptfile_* preprocesses the text)
if ( animsoundsend - script - > textptr = = 1 )
break ;
// would produce error when it encounters the closing '}'
// without the above hack
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
if ( scriptfile_getnumber ( script , & framenum ) ) break ;
bad = 1 ;
if ( anim_hi_sounds [ animnum ] = = NULL ) // Bcalloc check
break ;
if ( scriptfile_getsymbol ( script , & soundnum ) ) break ;
// frame numbers start at 1 for us
if ( framenum < = 0 )
{
initprintf ( " Error: frame number must be greater zero on line %s:%d \n " ,
script - > filename , scriptfile_getlinum ( script , script - > ltextptr ) ) ;
break ;
}
if ( framenum < lastframenum )
{
initprintf ( " Error: frame numbers must be in (not necessarily strictly) "
" ascending order (line %s:%d) \n " ,
script - > filename , scriptfile_getlinum ( script , script - > ltextptr ) ) ;
break ;
}
lastframenum = framenum ;
if ( ( unsigned ) soundnum > = MAXSOUNDS )
{
initprintf ( " Error: sound number #%d invalid on line %s:%d \n " , soundnum ,
script - > filename , scriptfile_getlinum ( script , script - > ltextptr ) ) ;
break ;
}
if ( numpairs > = allocsz )
{
void * newptr ;
allocsz * = 2 ;
newptr = Brealloc ( anim_hi_sounds [ animnum ] , allocsz * 2 * sizeof ( anim_hi_sounds [ 0 ] ) ) ;
if ( ! newptr ) break ;
2012-11-15 14:28:36 +00:00
anim_hi_sounds [ animnum ] = ( uint16_t * ) newptr ;
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
}
bad = 0 ;
anim_hi_sounds [ animnum ] [ 2 * numpairs ] = framenum ;
anim_hi_sounds [ animnum ] [ 2 * numpairs + 1 ] = soundnum ;
numpairs + + ;
}
if ( ! preload )
{
if ( ! bad )
{
anim_hi_numsounds [ animnum ] = numpairs ;
2012-03-26 05:05:57 +00:00
initprintf ( " Defined sound sequence for hi-anim \" %s \" with %d frame/sound pairs \n " ,
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
hardcoded_anim_tokens [ animnum ] . text , numpairs ) ;
}
else
{
Bfree ( anim_hi_sounds [ animnum ] ) ;
anim_hi_sounds [ animnum ] = NULL ;
2012-03-26 05:05:57 +00:00
initprintf ( " Failed defining sound sequence for hi-anim \" %s \" . \n " ,
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
hardcoded_anim_tokens [ animnum ] . text ) ;
}
}
}
break ;
# endif // defined USE_LIBVPX
2012-03-22 22:47:29 +00:00
case T_NOFLOORPALRANGE :
{
int32_t b , e , i ;
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
2012-03-22 22:47:29 +00:00
if ( scriptfile_getnumber ( script , & b ) ) break ;
if ( scriptfile_getnumber ( script , & e ) ) break ;
b = max ( b , 1 ) ;
2012-03-24 15:59:39 +00:00
e = min ( e , MAXPALOOKUPS - 1 ) ;
2012-03-22 22:47:29 +00:00
for ( i = b ; i < = e ; i + + )
g_noFloorPal [ i ] = 1 ;
}
break ;
2010-08-02 08:13:51 +00:00
case T_SOUND :
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
char * tinttokptr = script - > ltextptr ;
2012-03-28 19:41:39 +00:00
char * fn = " " ;
2010-08-02 08:13:51 +00:00
int32_t num = - 1 ;
char * musicend ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( scriptfile_getbraces ( script , & musicend ) ) break ;
while ( script - > textptr < musicend )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
switch ( getatoken ( script , sound_musictokens , sizeof ( sound_musictokens ) / sizeof ( tokenlist ) ) )
{
case T_ID :
scriptfile_getsymbol ( script , & num ) ;
break ;
case T_FILE :
scriptfile_getstring ( script , & fn ) ;
break ;
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ! preload )
{
if ( num = = - 1 )
{
initprintf ( " Error: missing ID for sound definition near line %s:%d \n " , script - > filename , scriptfile_getlinum ( script , tinttokptr ) ) ;
break ;
}
2006-04-13 20:47:06 +00:00
2012-03-28 19:41:39 +00:00
if ( check_file_exist ( fn ) )
break ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( S_DefineSound ( num , fn ) )
initprintf ( " Error: invalid sound ID on line %s:%d \n " , script - > filename , scriptfile_getlinum ( script , tinttokptr ) ) ;
2008-03-09 08:14:12 +00:00
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
break ;
case T_EOF :
return ( 0 ) ;
default :
break ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
}
return 0 ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
static int32_t loaddefinitions_game ( const char * fn , int32_t preload )
{
scriptfile * script ;
2011-07-21 22:39:29 +00:00
int32_t i ;
2006-04-13 20:47:06 +00:00
2012-06-03 19:20:41 +00:00
script = scriptfile_fromfile ( fn ) ;
2010-08-02 08:13:51 +00:00
if ( ! script ) return - 1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
parsedefinitions_game ( script , preload ) ;
2006-04-16 03:42:36 +00:00
2011-07-21 22:39:29 +00:00
for ( i = 0 ; i < g_defModulesNum ; + + i )
parsedefinitions_game_include ( g_defModules [ i ] , NULL , " null " , preload ) ;
2010-08-02 08:13:51 +00:00
scriptfile_close ( script ) ;
scriptfile_clearsymbols ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
return 0 ;
}
2006-04-13 20:47:06 +00:00
2012-03-25 22:00:42 +00:00
2010-08-02 08:13:51 +00:00
static void G_CheckCommandLine ( int32_t argc , const char * * argv )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
int16_t i = 1 , j ;
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
const char * c , * k ;
2006-07-26 01:10:33 +00:00
2010-08-02 08:13:51 +00:00
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 ;
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 ;
2008-03-08 05:23:15 +00:00
2012-03-25 13:54:46 +00:00
# ifdef HAVE_CLIPSHAPE_FEATURE
2012-03-18 08:50:41 +00:00
// pre-form the default 10 clipmaps
for ( j = ' 0 ' ; j < = ' 9 ' ; + + j )
{
2012-03-25 13:54:46 +00:00
char clipshape [ 16 ] = " _clipshape0.map " ;
2012-03-18 08:50:41 +00:00
clipshape [ 10 ] = j ;
g_clipMapFiles = ( char * * ) Brealloc ( g_clipMapFiles , ( g_clipMapFilesNum + 1 ) * sizeof ( char * ) ) ;
2012-03-18 23:18:32 +00:00
g_clipMapFiles [ g_clipMapFilesNum ] = Bstrdup ( clipshape ) ;
2012-03-18 08:50:41 +00:00
+ + g_clipMapFilesNum ;
}
2012-03-25 13:54:46 +00:00
# endif
2012-03-18 08:50:41 +00:00
2010-08-02 08:13:51 +00:00
if ( argc > 1 )
2008-03-08 05:23:15 +00:00
{
2010-08-02 08:13:51 +00:00
initprintf ( " Application parameters: " ) ;
while ( i < argc )
initprintf ( " %s " , argv [ i + + ] ) ;
initprintf ( " \n " ) ;
2006-12-04 02:10:18 +00:00
2010-08-02 08:13:51 +00:00
i = 1 ;
2011-02-25 21:50:19 +00:00
do
2006-11-16 03:02:42 +00:00
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
const char * const oc = argv [ i ] ;
2012-04-04 18:58:33 +00:00
int32_t shortopt = 0 , ignored_short_opt = 0 ;
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
c = oc ;
2010-10-28 20:17:22 +00:00
if ( ( * c = = ' - ' )
# ifdef _WIN32
2011-02-25 21:50:19 +00:00
| | ( * c = = ' / ' )
2010-10-28 20:17:22 +00:00
# endif
2011-02-25 21:50:19 +00:00
)
2006-07-26 01:10:33 +00:00
{
2012-04-04 18:58:33 +00:00
shortopt = 0 ;
2010-08-02 08:13:51 +00:00
if ( ! Bstrcasecmp ( c + 1 , " ? " ) | | ! Bstrcasecmp ( c + 1 , " help " ) | | ! Bstrcasecmp ( c + 1 , " -help " ) )
2007-03-21 20:37:24 +00:00
{
2010-08-02 08:13:51 +00:00
G_ShowParameterHelp ( ) ;
exit ( 0 ) ;
2007-03-21 20:37:24 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ! Bstrcasecmp ( c + 1 , " debughelp " ) | | ! Bstrcasecmp ( c + 1 , " -debughelp " ) )
2007-02-26 01:46:38 +00:00
{
2010-08-02 08:13:51 +00:00
G_ShowDebugHelp ( ) ;
exit ( 0 ) ;
2007-02-26 01:46:38 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ! Bstrcasecmp ( c + 1 , " grp " ) | | ! Bstrcasecmp ( c + 1 , " g " ) )
2007-01-22 02:35:54 +00:00
{
if ( argc > i + 1 )
{
2008-11-20 14:06:36 +00:00
G_AddGroup ( argv [ i + 1 ] ) ;
2007-01-22 02:35:54 +00:00
i + + ;
}
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " game_dir " ) )
{
if ( argc > i + 1 )
{
2012-09-05 17:25:40 +00:00
Bstrncpyz ( g_modDir , argv [ i + 1 ] , sizeof ( g_modDir ) ) ;
2008-11-20 14:06:36 +00:00
G_AddPath ( argv [ i + 1 ] ) ;
2007-01-22 02:35:54 +00:00
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 )
{
2012-06-03 16:09:33 +00:00
clearGrpNamePtr ( ) ;
g_grpNamePtr = dup_filename ( argv [ i + 1 ] ) ;
2007-07-04 09:15:08 +00:00
i + + ;
}
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nam " ) )
{
2012-06-03 16:09:33 +00:00
g_gameType = GAMEFLAG_NAM ;
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " napalm " ) )
{
g_gameType = GAMEFLAG_NAM | GAMEFLAG_NAPALM ;
2006-11-16 23:06:16 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " ww2gi " ) )
{
2012-06-03 16:09:33 +00:00
g_gameType = GAMEFLAG_WW2GI ;
2006-07-22 05:20:25 +00:00
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " setup " ) )
{
2008-11-20 14:06:36 +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 " ) )
{
2008-11-20 14:06:36 +00:00
g_noSetup = 1 ;
g_commandSetup = 0 ;
2007-04-28 21:24:36 +00:00
i + + ;
continue ;
}
2012-11-25 04:26:37 +00:00
# if defined RENDERTYPEWIN
2010-11-23 22:30:27 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nodinput " ) )
{
initprintf ( " DirectInput (joystick) support disabled \n " ) ;
di_disabled = 1 ;
i + + ;
continue ;
}
# endif
2007-07-04 09:15:08 +00:00
if ( ! Bstrcasecmp ( c + 1 , " noautoload " ) )
{
initprintf ( " Autoload disabled \n " ) ;
2008-11-20 14:06:36 +00:00
g_noAutoLoad = 1 ;
2007-07-04 09:15:08 +00:00
i + + ;
continue ;
}
2010-03-12 05:50:30 +00:00
if ( ! Bstrcasecmp ( c + 1 , " net " ) )
{
G_GameExit ( " EDuke32 no longer supports legacy networking. \n \n "
2010-08-02 08:13:51 +00:00
" If using YANG or other launchers that only support legacy netplay, download an older build of EDuke32. "
" Otherwise, run the following: \n \n "
" eduke32 -server \n \n "
" Other clients can then connect by typing \" connect [host] \" in the console. \n \n "
" EDuke32 will now close. " ) ;
2010-03-12 05:50:30 +00:00
}
2009-12-12 11:07:59 +00:00
if ( ! Bstrcasecmp ( c + 1 , " port " ) )
2006-11-15 01:16:55 +00:00
{
2009-12-12 11:07:59 +00:00
if ( argc > i + 1 )
{
2012-02-20 21:17:39 +00:00
g_netPort = Batoi ( argv [ i + 1 ] ) ;
2009-12-12 11:07:59 +00:00
i + + ;
}
2006-05-03 04:16:08 +00:00
i + + ;
continue ;
}
2009-12-05 09:22:43 +00:00
if ( ! Bstrcasecmp ( c + 1 , " server " ) )
{
2011-02-25 21:50:19 +00:00
g_networkMode = NET_SERVER ;
g_noSetup = g_noLogo = TRUE ;
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " dedicated " ) )
{
g_networkMode = NET_DEDICATED_SERVER ;
2009-12-05 09:22:43 +00:00
g_noSetup = g_noLogo = TRUE ;
2008-11-22 02:59:25 +00:00
i + + ;
continue ;
}
2009-12-05 09:22:43 +00:00
if ( ! Bstrcasecmp ( c + 1 , " connect " ) )
2006-11-15 01:16:55 +00:00
{
2009-12-05 09:22:43 +00:00
if ( argc > i + 1 )
{
2012-06-03 19:20:41 +00:00
Net_Connect ( argv [ i + 1 ] ) ;
2009-12-30 23:07:00 +00:00
g_noSetup = g_noLogo = TRUE ;
2009-12-05 09:22:43 +00:00
i + + ;
}
2006-04-13 20:47:06 +00:00
i + + ;
continue ;
}
2009-12-17 11:17:48 +00:00
if ( ! Bstrcasecmp ( c + 1 , " password " ) )
{
if ( argc > i + 1 )
{
2012-03-28 19:43:21 +00:00
Bstrncpyz ( g_netPassword , argv [ i + 1 ] , sizeof ( g_netPassword ) ) ;
2009-12-17 11:17:48 +00:00
i + + ;
}
i + + ;
continue ;
}
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " name " ) )
{
if ( argc > i + 1 )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
CommandName = 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 )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
CommandMap = argv [ i + 1 ] ;
2006-04-13 20:47:06 +00:00
i + + ;
}
i + + ;
continue ;
}
2011-06-23 15:41:08 +00:00
if ( ! Bstrcasecmp ( c + 1 , " rts " ) )
{
if ( argc > i + 1 )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
g_rtsNamePtr = argv [ i + 1 ] ;
Bstrncpyz ( ud . rtsname , g_rtsNamePtr , sizeof ( ud . rtsname ) ) ;
initprintf ( " Using RTS file \" %s \" . \n " , ud . rtsname ) ;
2011-06-23 15:41:08 +00:00
i + + ;
}
i + + ;
continue ;
}
2011-07-21 22:39:29 +00:00
if ( ! Bstrcasecmp ( c + 1 , " mx " ) )
{
if ( argc > i + 1 )
{
g_scriptModules = ( char * * ) Brealloc ( g_scriptModules , ( g_scriptModulesNum + 1 ) * sizeof ( char * ) ) ;
2012-03-20 19:28:22 +00:00
g_scriptModules [ g_scriptModulesNum ] = Bstrdup ( argv [ i + 1 ] ) ;
2011-07-21 22:39:29 +00:00
+ + g_scriptModulesNum ;
i + + ;
}
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " mh " ) )
{
if ( argc > i + 1 )
{
g_defModules = ( char * * ) Brealloc ( g_defModules , ( g_defModulesNum + 1 ) * sizeof ( char * ) ) ;
2012-03-20 19:28:22 +00:00
g_defModules [ g_defModulesNum ] = Bstrdup ( argv [ i + 1 ] ) ;
2011-07-21 22:39:29 +00:00
+ + g_defModulesNum ;
i + + ;
}
i + + ;
continue ;
}
2012-03-25 13:54:46 +00:00
# ifdef HAVE_CLIPSHAPE_FEATURE
2012-03-18 08:50:41 +00:00
if ( ! Bstrcasecmp ( c + 1 , " clipmap " ) )
{
if ( argc > i + 1 )
{
g_clipMapFiles = ( char * * ) Brealloc ( g_clipMapFiles , ( g_clipMapFilesNum + 1 ) * sizeof ( char * ) ) ;
2012-03-18 23:18:32 +00:00
g_clipMapFiles [ g_clipMapFilesNum ] = Bstrdup ( argv [ i + 1 ] ) ;
2012-03-18 08:50:41 +00:00
+ + g_clipMapFilesNum ;
i + + ;
}
i + + ;
continue ;
}
2012-03-25 13:54:46 +00:00
# endif
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( c + 1 , " condebug " ) )
{
2008-11-20 14:06:36 +00:00
g_scriptDebug = 1 ;
2006-04-13 20:47:06 +00:00
i + + ;
continue ;
}
2010-09-27 21:52:04 +00:00
if ( ! Bstrcasecmp ( c + 1 , " conversion " ) )
{
if ( argc > i + 1 )
{
2012-06-03 19:20:41 +00:00
uint32_t j = Batol ( argv [ i + 1 ] ) ;
2010-09-27 21:52:04 +00:00
if ( j > = 10000000 & & j < = 99999999 )
{
g_scriptDateVersion = j ;
initprintf ( " CON script date version: %d \n " , j ) ;
}
else
initprintf ( " CON script date version must be specified as YYYYMMDD, ignoring. \n " ) ;
i + + ;
}
i + + ;
continue ;
}
2007-04-17 05:54:12 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nologo " ) )
{
2008-11-20 14:06:36 +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
2008-07-10 02:45:24 +00:00
if ( ! Bstrcasecmp ( c + 1 , " cachesize " ) )
{
if ( argc > i + 1 )
{
2012-06-03 19:20:41 +00:00
uint32_t j = Batol ( argv [ i + 1 ] ) ;
2008-07-10 02:45:24 +00:00
MAXCACHE1DSIZE = j < < 10 ;
initprintf ( " Cache size: %dkB \n " , j ) ;
i + + ;
}
i + + ;
continue ;
}
2008-09-15 02:47:02 +00:00
if ( ! Bstrcasecmp ( c + 1 , " noinstancechecking " ) )
{
i + + ;
continue ;
}
2008-12-04 00:31:16 +00:00
# if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
2008-10-31 10:08:51 +00:00
if ( ! Bstrcasecmp ( c + 1 , " forcegl " ) )
{
forcegl = 1 ;
i + + ;
continue ;
}
# endif
2006-04-13 20:47:06 +00:00
}
2010-10-28 20:17:22 +00:00
if ( ( * c = = ' - ' )
# ifdef _WIN32
2011-02-25 21:50:19 +00:00
| | ( * c = = ' / ' )
2010-10-28 20:17:22 +00:00
# endif
2011-02-25 21:50:19 +00:00
)
2006-04-13 20:47:06 +00:00
{
2012-04-04 18:58:33 +00:00
shortopt = 1 ;
2006-04-13 20:47:06 +00:00
c + + ;
2009-08-28 23:08:00 +00:00
switch ( Btolower ( * c ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case ' a ' :
ud . playerai = 1 ;
initprintf ( " Other player AI. \n " ) ;
break ;
case ' c ' :
c + + ;
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 - - ;
break ;
case ' d ' :
2012-09-24 21:09:27 +00:00
{
2012-11-15 14:28:36 +00:00
char * colon = ( char * ) Bstrchr ( c , ' : ' ) ;
2012-09-24 21:09:27 +00:00
int32_t framespertic = - 1 , numrepeats = 1 ;
2006-11-16 03:02:42 +00:00
c + + ;
2012-09-24 21:09:27 +00:00
if ( colon & & colon ! = c )
{
// -d<filename>:<num>[,<num>]
// profiling options
* ( colon + + ) = 0 ;
Bsscanf ( colon , " %u,%u " , & framespertic , & numrepeats ) ;
}
2012-10-01 17:52:40 +00:00
Demo_SetFirst ( c ) ;
2012-09-24 21:09:27 +00:00
if ( framespertic < 0 )
{
initprintf ( " Play demo %s. \n " , g_firstDemoFile ) ;
}
else
{
framespertic = clamp ( framespertic , 0 , 8 ) + 1 ;
// TODO: repeat count and gathering statistics.
initprintf ( " Profile demo %s, %d frames/gametic, repeated 1x. \n " , g_firstDemoFile ,
framespertic - 1 ) ;
Demo_PlayFirst ( framespertic , 1 ) ;
g_noLogo = 1 ;
}
2006-11-16 03:02:42 +00:00
break ;
2012-09-24 21:09:27 +00:00
}
2006-11-16 03:02:42 +00:00
case ' g ' :
c + + ;
2012-04-04 18:58:33 +00:00
if ( * c )
G_AddGroup ( c ) ;
2006-11-16 03:02:42 +00:00
break ;
case ' h ' :
c + + ;
if ( * c )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
clearDefNamePtr ( ) ;
g_defNamePtr = dup_filename ( c ) ;
2012-03-26 05:05:57 +00:00
initprintf ( " Using DEF file \" %s \" . \n " , g_defNamePtr ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case ' j ' :
c + + ;
2012-04-04 18:58:33 +00:00
if ( * c )
G_AddPath ( c ) ;
2006-11-16 03:02:42 +00:00
break ;
case ' l ' :
ud . warp_on = 1 ;
c + + ;
2012-02-20 21:17:39 +00:00
ud . m_level_number = ud . level_number = ( Batoi ( c ) - 1 ) % MAXLEVELS ;
2006-11-16 03:02:42 +00:00
break ;
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 ' :
c + + ;
if ( * c = = ' s ' | | * c = = ' S ' )
{
2008-11-20 14:06:36 +00:00
g_noSound = 2 ;
2006-11-16 03:02:42 +00:00
initprintf ( " Sound off. \n " ) ;
}
else if ( * c = = ' m ' | | * c = = ' M ' )
{
2008-11-20 14:06:36 +00:00
g_noMusic = 1 ;
2006-11-16 03:02:42 +00:00
initprintf ( " Music off. \n " ) ;
}
else
{
2008-11-22 11:42:22 +00:00
G_ShowParameterHelp ( ) ;
2006-11-16 03:02:42 +00:00
exit ( - 1 ) ;
}
break ;
case ' q ' :
2012-08-13 18:25:32 +00:00
if ( * ( + + c ) = = 0 )
{
ud . multimode = 1 ;
initprintf ( " Fake multiplayer mode: expected number after -q, falling back to 1 player. \n " ) ;
}
else
{
2012-08-16 21:48:13 +00:00
int32_t numpl = Batoi ( c ) ;
2012-08-13 18:25:32 +00:00
2012-08-16 21:48:13 +00:00
if ( numpl < 2 | | numpl > MAXPLAYERS )
{
initprintf ( " Fake multiplayer mode: expected 2-%d players, falling back to 1. \n " ,
MAXPLAYERS ) ;
}
else
{
ud . multimode = numpl ;
initprintf ( " Fake multiplayer mode: %d players. \n " , ud . multimode ) ;
2012-08-22 22:51:38 +00:00
g_fakeMultiMode = numpl ;
2012-08-16 21:48:13 +00:00
}
2012-08-13 18:25:32 +00:00
}
2012-08-16 21:48:13 +00:00
2006-11-16 03:02:42 +00:00
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 ' :
ud . m_recstat = 1 ;
initprintf ( " Demo record mode on. \n " ) ;
break ;
case ' s ' :
c + + ;
2012-02-20 21:17:39 +00:00
ud . m_player_skill = ud . player_skill = ( Batoi ( c ) % 5 ) ;
2006-11-16 03:02:42 +00:00
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 ' :
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 ' :
2010-01-16 23:08:17 +00:00
g_forceWeaponChoice = 1 ;
2006-11-16 03:02:42 +00:00
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 ' :
c + + ;
ud . warp_on = 1 ;
2012-02-20 21:17:39 +00:00
ud . m_volume_number = ud . volume_number = Batoi ( c ) - 1 ;
2006-11-16 03:02:42 +00:00
break ;
case ' w ' :
ud . coords = 1 ;
break ;
case ' x ' :
c + + ;
if ( * c )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
clearScriptNamePtr ( ) ;
g_scriptNamePtr = dup_filename ( c ) ;
2012-03-26 05:05:57 +00:00
initprintf ( " Using CON file \" %s \" . \n " , g_scriptNamePtr ) ;
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 ' :
c + + ;
2012-02-20 21:17:39 +00:00
g_scriptDebug = Batoi ( c ) ;
2008-11-20 14:06:36 +00:00
if ( ! g_scriptDebug )
g_scriptDebug = 1 ;
2006-11-16 03:02:42 +00:00
break ;
2012-04-04 18:58:33 +00:00
default :
ignored_short_opt = 1 ;
break ;
2006-04-13 20:47:06 +00:00
}
}
2008-07-07 22:03:11 +00:00
else
{
2012-04-04 18:58:33 +00:00
shortopt = 0 ;
2009-03-23 15:36:59 +00:00
k = Bstrrchr ( c , ' . ' ) ;
2008-07-07 22:03:11 +00:00
if ( k )
{
2008-09-30 13:08:57 +00:00
if ( ! Bstrcasecmp ( k , " .map " ) )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
CommandMap = argv [ i + + ] ;
2008-09-30 13:08:57 +00:00
continue ;
}
2008-12-13 07:23:13 +00:00
if ( ! Bstrcasecmp ( k , " .grp " ) | | ! Bstrcasecmp ( k , " .zip " ) | | ! Bstrcasecmp ( k , " .pk3 " ) )
2008-07-07 22:03:11 +00:00
{
2008-11-20 14:06:36 +00:00
G_AddGroup ( argv [ i + + ] ) ;
2008-07-07 22:03:11 +00:00
continue ;
}
if ( ! Bstrcasecmp ( k , " .con " ) )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
clearScriptNamePtr ( ) ;
g_scriptNamePtr = dup_filename ( argv [ i + + ] ) ;
2012-03-26 05:05:57 +00:00
initprintf ( " Using CON file \" %s \" . \n " , g_scriptNamePtr ) ;
2008-07-07 22:03:11 +00:00
continue ;
}
2010-08-02 08:13:51 +00:00
if ( ! Bstrcasecmp ( k , " .def " ) )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
clearDefNamePtr ( ) ;
g_defNamePtr = dup_filename ( argv [ i + + ] ) ;
2012-03-26 05:05:57 +00:00
initprintf ( " Using DEF file \" %s \" . \n " , g_defNamePtr ) ;
2010-08-02 08:13:51 +00:00
continue ;
}
2011-06-23 15:41:08 +00:00
if ( ! Bstrcasecmp ( k , " .rts " ) )
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
g_rtsNamePtr = argv [ i + + ] ;
Bstrncpyz ( ud . rtsname , g_rtsNamePtr , sizeof ( ud . rtsname ) ) ;
initprintf ( " Using RTS file \" %s \" . \n " , ud . rtsname ) ;
2011-06-23 15:41:08 +00:00
continue ;
}
2010-08-02 08:13:51 +00:00
}
2008-08-20 08:39:07 +00:00
}
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
2012-04-04 18:58:33 +00:00
if ( ! shortopt | | ignored_short_opt )
initprintf ( " Warning: ignored application parameter \" %s \" . \n " , oc ) ;
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
2010-08-02 08:13:51 +00:00
i + + ;
2008-08-20 08:39:07 +00:00
}
2011-02-25 21:50:19 +00:00
while ( i < argc ) ;
2008-08-20 08:39:07 +00:00
}
2006-12-12 08:46:32 +00:00
}
2010-08-02 08:13:51 +00:00
static void G_DisplayLogo ( void )
2006-04-18 19:23:53 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t soundanm = 0 ;
int32_t logoflags = Gv_GetVarByLabel ( " LOGO_FLAGS " , 255 , - 1 , - 1 ) ;
2006-04-19 06:23:19 +00:00
2010-08-02 08:13:51 +00:00
ready2send = 0 ;
2006-08-18 23:52:26 +00:00
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2009-01-13 04:40:56 +00:00
2010-08-02 08:13:51 +00:00
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2010-08-02 08:13:51 +00:00
G_FadePalette ( 0 , 0 , 0 , 63 ) ;
2006-08-18 23:52:26 +00:00
2010-08-02 08:13:51 +00:00
flushperms ( ) ;
nextpage ( ) ;
2006-04-18 19:23:53 +00:00
2010-05-07 20:45:40 +00:00
Bsprintf ( tempbuf , " %s - " APPNAME , g_gameNamePtr ) ;
2008-07-22 09:05:34 +00:00
wm_setapptitle ( tempbuf ) ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
S_StopMusic ( ) ;
FX_StopAllSounds ( ) ; // JBF 20031228
S_ClearSoundLocks ( ) ; // JBF 20031228
if ( ( ! g_netServer & & ud . multimode < 2 ) & & ( logoflags & LOGO_ENABLED ) & & ! g_noLogo )
2010-05-02 23:27:30 +00:00
{
2010-08-02 08:13:51 +00:00
if ( VOLUMEALL & & ( logoflags & LOGO_PLAYANIM ) )
{
2010-05-02 23:27:30 +00:00
2012-06-03 16:11:22 +00:00
if ( ! I_CheckAllInput ( ) & & g_noLogoAnim = = 0 )
2010-08-02 08:13:51 +00:00
{
Net_GetPackets ( ) ;
G_PlayAnim ( " logo.anm " , 5 ) ;
G_FadePalette ( 0 , 0 , 0 , 63 ) ;
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2010-08-02 08:13:51 +00:00
}
2010-05-02 23:27:30 +00:00
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2010-08-02 08:13:51 +00:00
nextpage ( ) ;
2012-11-24 09:11:50 +00:00
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
2010-08-02 08:13:51 +00:00
}
if ( logoflags & LOGO_PLAYMUSIC )
2010-05-02 23:27:30 +00:00
{
2010-08-02 08:13:51 +00:00
g_musicIndex = - 1 ; // hack
S_PlayMusic ( & EnvMusicFilename [ 0 ] [ 0 ] , MAXVOLUMES * MAXLEVELS ) ;
2010-05-02 23:27:30 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ! NAM )
2010-05-02 23:27:30 +00:00
{
2010-08-02 08:13:51 +00:00
//g_player[myconnectindex].ps->palette = drealms;
//G_FadePalette(0,0,0,63);
if ( logoflags & LOGO_3DRSCREEN )
2010-05-02 23:27:30 +00:00
{
2012-08-19 12:53:24 +00:00
clearallviews ( 0 ) ;
2012-04-04 18:57:06 +00:00
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , DREALMSPAL , 8 + 2 + 1 ) ; // JBF 20040308
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
2010-08-02 08:13:51 +00:00
flushperms ( ) ;
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , DREALMS , 0 , 0 , 2 + 8 + 16 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-08-02 08:13:51 +00:00
nextpage ( ) ;
fadepaltile ( 0 , 0 , 0 , 63 , 0 , - 7 , DREALMS ) ;
totalclock = 0 ;
2012-06-03 16:11:22 +00:00
while ( totalclock < ( 120 * 7 ) & & ! I_CheckInputWaiting ( ) )
2010-08-02 08:13:51 +00:00
{
2012-08-19 12:53:24 +00:00
clearallviews ( 0 ) ;
2012-04-04 18:57:06 +00:00
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , DREALMS , 0 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2010-08-02 08:13:51 +00:00
if ( g_restorePalette )
{
P_SetGamePalette ( g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > palette , 0 ) ;
g_restorePalette = 0 ;
}
nextpage ( ) ;
}
2012-04-04 18:56:50 +00:00
fadepaltile ( 0 , 0 , 0 , 0 , 63 , 7 , DREALMS ) ;
2010-05-02 23:27:30 +00:00
}
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2010-08-02 08:13:51 +00:00
}
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2010-08-02 08:13:51 +00:00
nextpage ( ) ;
if ( logoflags & LOGO_TITLESCREEN )
{
2012-08-19 12:53:24 +00:00
clearallviews ( 0 ) ;
2012-04-04 18:57:06 +00:00
2010-08-02 08:13:51 +00:00
//g_player[myconnectindex].ps->palette = titlepal;
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , TITLEPAL , 8 + 2 + 1 ) ; // JBF 20040308
2010-08-02 08:13:51 +00:00
flushperms ( ) ;
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , BETASCREEN , 0 , 0 , 2 + 8 + 16 ) ;
2010-08-02 08:13:51 +00:00
KB_FlushKeyboardQueue ( ) ;
fadepaltile ( 0 , 0 , 0 , 63 , 0 , - 7 , BETASCREEN ) ;
totalclock = 0 ;
2012-06-03 16:11:22 +00:00
while ( totalclock < ( 860 + 120 ) & & ! I_CheckInputWaiting ( ) )
2010-05-02 23:27:30 +00:00
{
2012-08-19 12:53:24 +00:00
clearallviews ( 0 ) ;
2012-04-04 18:57:06 +00:00
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , BETASCREEN , 0 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-08-02 08:13:51 +00:00
if ( logoflags & LOGO_DUKENUKEM )
{
if ( totalclock > 120 & & totalclock < ( 120 + 60 ) )
{
if ( soundanm = = 0 )
{
soundanm + + ;
S_PlaySound ( PIPEBOMB_EXPLODE ) ;
}
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 160 < < 16 , 104 < < 16 , ( totalclock - 120 ) < < 10 , 0 , DUKENUKEM , 0 , 0 , 2 + 8 ) ;
2010-08-02 08:13:51 +00:00
}
else if ( totalclock > = ( 120 + 60 ) )
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 160 < < 16 , ( 104 ) < < 16 , 60 < < 10 , 0 , DUKENUKEM , 0 , 0 , 2 + 8 ) ;
2010-08-02 08:13:51 +00:00
}
else soundanm + + ;
if ( logoflags & LOGO_THREEDEE )
{
if ( totalclock > 220 & & totalclock < ( 220 + 30 ) )
{
if ( soundanm = = 1 )
{
soundanm + + ;
S_PlaySound ( PIPEBOMB_EXPLODE ) ;
}
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 160 < < 16 , ( 104 ) < < 16 , 60 < < 10 , 0 , DUKENUKEM , 0 , 0 , 2 + 8 ) ;
rotatesprite_fs ( 160 < < 16 , ( 129 ) < < 16 , ( totalclock - 220 ) < < 11 , 0 , THREEDEE , 0 , 0 , 2 + 8 ) ;
2010-08-02 08:13:51 +00:00
}
else if ( totalclock > = ( 220 + 30 ) )
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 160 < < 16 , ( 129 ) < < 16 , 30 < < 11 , 0 , THREEDEE , 0 , 0 , 2 + 8 ) ;
2010-08-02 08:13:51 +00:00
}
else soundanm + + ;
if ( PLUTOPAK & & ( logoflags & LOGO_PLUTOPAKSPRITE ) )
{
// JBF 20030804
if ( totalclock > = 280 & & totalclock < 395 )
{
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 160 < < 16 , ( 151 ) < < 16 , ( 410 - totalclock ) < < 12 , 0 , PLUTOPAKSPRITE + 1 , 0 , 0 , 2 + 8 ) ;
2010-08-02 08:13:51 +00:00
if ( soundanm = = 2 )
{
soundanm + + ;
S_PlaySound ( FLY_BY ) ;
}
}
else if ( totalclock > = 395 )
{
if ( soundanm = = 3 )
{
soundanm + + ;
S_PlaySound ( PIPEBOMB_EXPLODE ) ;
}
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 160 < < 16 , ( 151 ) < < 16 , 30 < < 11 , 0 , PLUTOPAKSPRITE + 1 , 0 , 0 , 2 + 8 ) ;
2010-08-02 08:13:51 +00:00
}
}
2012-05-16 00:45:10 +00:00
VM_OnEvent ( EVENT_LOGO , - 1 , screenpeek , - 1 , 0 ) ;
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2010-08-02 08:13:51 +00:00
if ( g_restorePalette )
{
P_SetGamePalette ( g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > palette , 0 ) ;
g_restorePalette = 0 ;
}
nextpage ( ) ;
2010-05-02 23:27:30 +00:00
}
}
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2010-05-02 23:27:30 +00:00
}
2010-08-02 08:13:51 +00:00
flushperms ( ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2010-08-02 08:13:51 +00:00
nextpage ( ) ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
//g_player[myconnectindex].ps->palette = palette;
2011-01-17 03:49:34 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 0 ) ; // JBF 20040308
2010-08-02 08:13:51 +00:00
S_PlaySound ( NITEVISION_ONOFF ) ;
//G_FadePalette(0,0,0,0);
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2008-05-10 01:29:37 +00:00
}
2010-08-02 08:13:51 +00:00
static void G_Cleanup ( void )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t i ;
2007-02-05 01:33:08 +00:00
2010-08-02 08:13:51 +00:00
for ( i = ( MAXLEVELS * ( MAXVOLUMES + 1 ) ) - 1 ; i > = 0 ; i - - ) // +1 volume for "intro", "briefing" music
2008-09-15 02:47:02 +00:00
{
2010-08-02 08:13:51 +00:00
if ( MapInfo [ i ] . name ! = NULL ) Bfree ( MapInfo [ i ] . name ) ;
if ( MapInfo [ i ] . filename ! = NULL ) Bfree ( MapInfo [ i ] . filename ) ;
if ( MapInfo [ i ] . musicfn ! = NULL ) Bfree ( MapInfo [ i ] . musicfn ) ;
if ( MapInfo [ i ] . alt_musicfn ! = NULL ) Bfree ( MapInfo [ i ] . alt_musicfn ) ;
if ( MapInfo [ i ] . savedstate ! = NULL ) G_FreeMapState ( i ) ;
2008-09-15 02:47:02 +00:00
}
2010-08-02 08:13:51 +00:00
for ( i = MAXQUOTES - 1 ; i > = 0 ; i - - )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ScriptQuotes [ i ] ! = NULL ) Bfree ( ScriptQuotes [ i ] ) ;
if ( ScriptQuoteRedefinitions [ i ] ! = NULL ) Bfree ( ScriptQuoteRedefinitions [ i ] ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +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 ) ;
}
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
for ( i = MAXSOUNDS - 1 ; i > = 0 ; i - - )
{
if ( g_sounds [ i ] . filename ! = NULL ) Bfree ( g_sounds [ i ] . filename ) ;
if ( g_sounds [ i ] . filename1 ! = NULL ) Bfree ( g_sounds [ i ] . filename1 ) ;
}
2006-12-08 16:45:12 +00:00
2010-08-02 08:13:51 +00:00
if ( label ! = NULL & & label ! = ( char * ) & sprite [ 0 ] ) Bfree ( label ) ;
2011-12-09 19:08:05 +00:00
if ( labelcode ! = NULL & & labelcode ! = ( int32_t * ) & sector [ 0 ] ) Bfree ( labelcode ) ;
2010-08-02 08:13:51 +00:00
if ( script ! = NULL ) Bfree ( script ) ;
if ( bitptr ! = NULL ) Bfree ( bitptr ) ;
2006-07-08 01:31:35 +00:00
2010-08-02 08:13:51 +00:00
// if (MusicPtr != NULL) Bfree(MusicPtr);
2006-07-08 01:31:35 +00:00
2010-08-02 08:13:51 +00:00
hash_free ( & h_gamevars ) ;
hash_free ( & h_arrays ) ;
hash_free ( & h_labels ) ;
hash_free ( & h_gamefuncs ) ;
}
2006-09-10 17:40:34 +00:00
2010-08-02 08:13:51 +00:00
/*
= = = = = = = = = = = = = = = = = = =
=
= ShutDown
=
= = = = = = = = = = = = = = = = = = =
*/
2006-09-10 17:40:34 +00:00
2010-08-02 08:13:51 +00:00
void G_Shutdown ( void )
{
2011-03-04 08:50:58 +00:00
CONFIG_WriteSetup ( 0 ) ;
2010-08-02 08:13:51 +00:00
S_SoundShutdown ( ) ;
S_MusicShutdown ( ) ;
CONTROL_Shutdown ( ) ;
KB_Shutdown ( ) ;
uninitengine ( ) ;
G_Cleanup ( ) ;
2012-06-03 16:08:27 +00:00
Bfflush ( NULL ) ;
2010-08-02 08:13:51 +00:00
}
2010-03-12 05:50:30 +00:00
2010-08-02 08:13:51 +00:00
/*
= = = = = = = = = = = = = = = = = = =
=
= G_Startup
=
= = = = = = = = = = = = = = = = = = =
*/
2006-09-10 17:40:34 +00:00
2010-08-02 08:13:51 +00:00
static void G_CompileScripts ( void )
{
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
int32_t psm = pathsearchmode ;
2008-10-31 10:08:51 +00:00
2010-08-02 08:13:51 +00:00
label = ( char * ) & sprite [ 0 ] ; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816
2011-12-04 21:20:17 +00:00
labelcode = ( int32_t * ) & sector [ 0 ] ; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
2011-12-04 21:19:57 +00:00
labeltype = ( int32_t * ) & wall [ 0 ] ; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536
2010-08-02 08:13:51 +00:00
2012-06-03 16:09:33 +00:00
if ( g_scriptNamePtr ! = NULL )
Bcorrectfilename ( g_scriptNamePtr , 0 ) ;
2010-08-02 08:13:51 +00:00
// if we compile for a V7 engine wall[] should be used for label names since it's bigger
pathsearchmode = 1 ;
2012-06-03 16:09:33 +00:00
C_Compile ( G_ConFile ( ) ) ;
2006-12-17 01:08:39 +00:00
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
if ( g_loadFromGroupOnly ) // g_loadFromGroupOnly is true only when compiling fails and internal defaults are utilized
2012-06-03 16:09:33 +00:00
C_Compile ( G_ConFile ( ) ) ;
2006-09-10 17:40:34 +00:00
2010-08-02 08:13:51 +00:00
if ( ( uint32_t ) g_numLabels > MAXSPRITES * sizeof ( spritetype ) / 64 ) // see the arithmetic above for why
G_GameExit ( " Error: too many labels defined! " ) ;
2012-03-28 19:45:25 +00:00
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
char * newlabel ;
2011-12-04 21:20:17 +00:00
int32_t * newlabelcode ;
2006-04-13 20:47:06 +00:00
2012-11-15 14:28:29 +00:00
newlabel = ( char * ) Bmalloc ( g_numLabels < < 6 ) ;
newlabelcode = ( int32_t * ) Bmalloc ( g_numLabels * sizeof ( int32_t ) ) ;
2010-08-02 08:13:51 +00:00
if ( ! newlabel | | ! newlabelcode )
G_GameExit ( " Error: out of memory retaining labels \n " ) ;
2011-12-04 21:20:17 +00:00
Bmemcpy ( newlabel , label , g_numLabels * 64 ) ;
Bmemcpy ( newlabelcode , labelcode , g_numLabels * sizeof ( int32_t ) ) ;
2010-08-02 08:13:51 +00:00
label = newlabel ;
labelcode = newlabelcode ;
2006-04-13 20:47:06 +00:00
}
2012-03-28 19:45:25 +00:00
Bmemset ( sprite , 0 , MAXSPRITES * sizeof ( spritetype ) ) ;
Bmemset ( sector , 0 , MAXSECTORS * sizeof ( sectortype ) ) ;
Bmemset ( wall , 0 , MAXWALLS * sizeof ( walltype ) ) ;
2006-04-13 20:47:06 +00:00
2012-05-16 00:45:10 +00:00
VM_OnEvent ( EVENT_INIT , - 1 , - 1 , - 1 , 0 ) ;
2010-08-02 08:13:51 +00:00
pathsearchmode = psm ;
}
static inline void G_CheckGametype ( void )
{
ud . m_coop = clamp ( ud . m_coop , 0 , g_numGametypes - 1 ) ;
2010-11-23 22:30:27 +00:00
initprintf ( " %s \n " , GametypeNames [ ud . m_coop ] ) ;
2010-08-02 08:13:51 +00:00
if ( GametypeFlags [ ud . m_coop ] & GAMETYPE_ITEMRESPAWN )
ud . m_respawn_items = ud . m_respawn_inventory = 1 ;
}
static void G_LoadExtraPalettes ( void )
{
2012-03-20 18:31:37 +00:00
int32_t j , fp ;
uint8_t tmpbyte ;
2010-08-02 08:13:51 +00:00
2012-03-20 18:31:37 +00:00
fp = kopen4loadfrommod ( " lookup.dat " , 0 ) ;
2010-08-02 08:13:51 +00:00
if ( fp ! = - 1 )
2012-03-20 18:31:37 +00:00
kread ( fp , & tmpbyte , 1 ) ;
2010-08-02 08:13:51 +00:00
else
G_GameExit ( " \n ERROR: File 'lookup.dat' not found. " ) ;
2012-03-20 18:31:37 +00:00
g_numRealPalettes = tmpbyte ;
2010-08-02 08:13:51 +00:00
for ( j = g_numRealPalettes + 1 ; j < MAXPALOOKUPS ; j + + )
2012-03-29 21:17:03 +00:00
makepalookup ( j , NULL , 0 , 0 , 0 , 1 ) ;
2010-08-02 08:13:51 +00:00
for ( j = g_numRealPalettes - 1 ; j > = 0 ; j - - )
2008-12-31 09:07:49 +00:00
{
2012-03-20 18:31:37 +00:00
uint8_t look_pos ;
kread ( fp , & look_pos , 1 ) ;
kread ( fp , tempbuf , 256 ) ;
makepalookup ( look_pos , tempbuf , 0 , 0 , 0 , 1 ) ;
2008-12-31 09:07:49 +00:00
}
2008-08-25 02:33:25 +00:00
2010-08-02 08:13:51 +00:00
g_numRealPalettes + + ;
2012-03-29 21:17:03 +00:00
makepalookup ( g_numRealPalettes , NULL , 15 , 15 , 15 , 1 ) ;
makepalookup ( g_numRealPalettes + 1 , NULL , 15 , 0 , 0 , 1 ) ;
makepalookup ( g_numRealPalettes + 2 , NULL , 0 , 15 , 0 , 1 ) ;
makepalookup ( g_numRealPalettes + 3 , NULL , 0 , 0 , 15 , 1 ) ;
2006-08-10 02:10:24 +00:00
2011-01-17 03:49:34 +00:00
kread ( fp , & water_pal [ 0 ] , 768 ) ;
kread ( fp , & slime_pal [ 0 ] , 768 ) ;
kread ( fp , & title_pal [ 0 ] , 768 ) ;
kread ( fp , & dre_alms [ 0 ] , 768 ) ;
kread ( fp , & ending_pal [ 0 ] , 768 ) ;
2009-03-14 02:55:39 +00:00
2010-08-02 08:13:51 +00:00
palette [ 765 ] = palette [ 766 ] = palette [ 767 ] = 0 ;
2011-01-17 03:49:34 +00:00
slime_pal [ 765 ] = slime_pal [ 766 ] = slime_pal [ 767 ] = 0 ;
water_pal [ 765 ] = water_pal [ 766 ] = water_pal [ 767 ] = 0 ;
2006-12-18 08:37:12 +00:00
2010-08-02 08:13:51 +00:00
kclose ( fp ) ;
}
2008-10-02 17:45:44 +00:00
2010-08-02 08:13:51 +00:00
extern int32_t startwin_run ( void ) ;
static void G_SetupGameButtons ( void ) ;
2006-12-14 04:13:19 +00:00
2010-08-02 08:13:51 +00:00
static void G_Startup ( void )
{
int32_t i ;
2006-12-18 08:37:12 +00:00
2010-08-02 08:13:51 +00:00
inittimer ( TICRATE ) ;
2006-12-18 08:37:12 +00:00
2010-08-02 08:13:51 +00:00
initcrc32table ( ) ;
2009-03-14 02:55:39 +00:00
2010-08-02 08:13:51 +00:00
G_CompileScripts ( ) ;
2009-03-14 02:55:39 +00:00
2010-08-02 08:13:51 +00:00
if ( initengine ( ) )
2006-11-15 01:16:55 +00:00
{
2008-02-24 00:46:57 +00:00
wm_msgbox ( " Build Engine Initialization Error " ,
" There was a problem initializing the Build engine: %s " , engineerrstr ) ;
2010-08-02 08:13:51 +00:00
G_Cleanup ( ) ;
2011-07-20 23:04:20 +00:00
ERRprintf ( " G_Startup: There was a problem initializing the Build engine: %s \n " , engineerrstr ) ;
2010-10-17 14:49:39 +00:00
exit ( 6 ) ;
2006-07-07 18:41:05 +00:00
}
2011-06-25 16:37:10 +00:00
2011-01-27 06:35:52 +00:00
setbasepaltable ( basepaltable , BASEPALCOUNT ) ;
2006-07-07 18:41:05 +00:00
2010-08-02 08:13:51 +00:00
G_InitDynamicTiles ( ) ;
2006-11-26 21:15:20 +00:00
2011-12-25 15:33:24 +00:00
if ( g_netServer | | ud . multimode > 1 ) G_CheckGametype ( ) ;
2006-07-22 05:20:25 +00:00
2010-08-02 08:13:51 +00:00
if ( g_noSound ) ud . config . SoundToggle = 0 ;
if ( g_noMusic ) ud . config . MusicToggle = 0 ;
if ( CommandName )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
// Bstrncpy(szPlayerName, CommandName, 9);
// szPlayerName[10] = '\0';
Bstrcpy ( tempbuf , CommandName ) ;
2006-07-07 18:41:05 +00:00
2010-08-02 08:13:51 +00:00
while ( Bstrlen ( OSD_StripColors ( tempbuf , tempbuf ) ) > 10 )
tempbuf [ Bstrlen ( tempbuf ) - 1 ] = ' \0 ' ;
2006-07-22 00:53:20 +00:00
2012-03-28 19:43:21 +00:00
Bstrncpyz ( szPlayerName , tempbuf , sizeof ( szPlayerName ) ) ;
2010-08-02 08:13:51 +00:00
}
if ( CommandMap )
2006-11-16 23:06:16 +00:00
{
2010-08-02 08:13:51 +00:00
if ( VOLUMEONE )
2008-12-13 07:23:13 +00:00
{
2010-08-02 08:13:51 +00:00
initprintf ( " The -map option is available in the registered version only! \n " ) ;
boardfilename [ 0 ] = 0 ;
2008-12-13 07:23:13 +00:00
}
else
{
2010-08-02 08:13:51 +00:00
char * dot , * slash ;
2008-12-13 07:23:13 +00:00
2010-08-02 08:13:51 +00:00
boardfilename [ 0 ] = ' / ' ;
boardfilename [ 1 ] = 0 ;
Bstrcat ( boardfilename , CommandMap ) ;
2006-07-22 02:54:07 +00:00
2010-08-02 08:13:51 +00:00
dot = Bstrrchr ( boardfilename , ' . ' ) ;
slash = Bstrrchr ( boardfilename , ' / ' ) ;
if ( ! slash ) slash = Bstrrchr ( boardfilename , ' \\ ' ) ;
2009-06-24 08:20:10 +00:00
2010-08-02 08:13:51 +00:00
if ( ( ! slash & & ! dot ) | | ( slash & & dot < slash ) )
Bstrcat ( boardfilename , " .map " ) ;
2009-06-24 08:20:10 +00:00
2010-08-02 08:13:51 +00:00
Bcorrectfilename ( boardfilename , 0 ) ;
i = kopen4loadfrommod ( boardfilename , 0 ) ;
if ( i ! = - 1 )
2009-06-24 08:20:10 +00:00
{
2012-03-26 05:05:57 +00:00
initprintf ( " Using level: \" %s \" . \n " , boardfilename ) ;
2010-08-02 08:13:51 +00:00
kclose ( i ) ;
2009-06-24 08:20:10 +00:00
}
2010-08-02 08:13:51 +00:00
else
2008-12-17 01:59:36 +00:00
{
2012-03-26 05:05:57 +00:00
initprintf ( " Level \" %s \" not found. \n " , boardfilename ) ;
2010-08-02 08:13:51 +00:00
boardfilename [ 0 ] = 0 ;
2008-12-17 01:59:36 +00:00
}
}
}
2007-02-26 01:46:38 +00:00
2010-08-02 08:13:51 +00:00
if ( VOLUMEONE )
2007-07-04 09:15:08 +00:00
{
2010-08-02 08:13:51 +00:00
initprintf ( " *** You have run Duke Nukem 3D %d times. *** \n \n " , ud . executions ) ;
2008-12-13 07:23:13 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . executions > = 50 )
2008-12-13 07:23:13 +00:00
{
2010-08-02 08:13:51 +00:00
initprintf ( " IT IS NOW TIME TO UPGRADE TO THE COMPLETE VERSION!!! \n " ) ;
# ifdef WIN32
Bsprintf ( tempbuf , " You have run Duke Nukem 3D shareware %d times. It is now time to upgrade to the complete version! \n \n "
" Purchase Duke Nukem 3D for $5.99 now? \n " , ud . executions ) ;
2012-03-05 07:25:24 +00:00
if ( wm_ynbox ( " Upgrade to the full version of Duke Nukem 3D " , " %s " , tempbuf ) )
2008-12-13 07:23:13 +00:00
{
2010-08-02 08:13:51 +00:00
SHELLEXECUTEINFOA sinfo ;
2011-07-05 04:56:51 +00:00
char * p = " http://www.gog.com/en/gamecard/duke_nukem_3d_atomic_edition/?pp=6c1e671f9af5b46d9c1a52067bdf0e53685674f7 " ;
2010-08-02 08:13:51 +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 ) )
G_GameExit ( " Error launching default system browser! " ) ;
2008-12-13 07:23:13 +00:00
}
2010-08-02 08:13:51 +00:00
# endif
2008-12-13 07:23:13 +00:00
}
2010-08-02 08:13:51 +00:00
}
2007-02-26 01:46:38 +00:00
2010-08-02 08:13:51 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
2011-03-05 03:57:15 +00:00
g_player [ i ] . pingcnt = 0 ;
2010-08-02 08:13:51 +00:00
if ( quitevent )
{
G_Shutdown ( ) ;
return ;
2007-07-04 09:15:08 +00:00
}
2007-03-24 23:17:56 +00:00
2010-08-02 08:13:51 +00:00
Net_GetPackets ( ) ;
if ( numplayers > 1 )
initprintf ( " Multiplayer initialized. \n " ) ;
2008-08-18 07:20:36 +00:00
{
2010-11-23 22:30:27 +00:00
char * cwd ;
2008-12-13 07:23:13 +00:00
2012-03-28 19:45:25 +00:00
if ( g_modDir [ 0 ] ! = ' / ' & & ( cwd = getcwd ( NULL , 0 ) ) )
2008-12-13 07:23:13 +00:00
{
2010-08-02 08:13:51 +00:00
chdir ( g_modDir ) ;
2012-03-26 05:05:57 +00:00
// initprintf("g_rootDir \"%s\"\nmod \"%s\"\ncwd \"%s\"\n",g_rootDir,mod_dir,cwd);
2010-08-02 08:13:51 +00:00
if ( loadpics ( " tiles000.art " , MAXCACHE1DSIZE ) < 0 )
2008-12-13 07:23:13 +00:00
{
2010-08-02 08:13:51 +00:00
chdir ( cwd ) ;
if ( loadpics ( " tiles000.art " , MAXCACHE1DSIZE ) < 0 )
G_GameExit ( " Failed loading art. " ) ;
2008-12-13 07:23:13 +00:00
}
2010-08-02 08:13:51 +00:00
chdir ( cwd ) ;
2010-12-19 02:04:59 +00:00
free ( cwd ) ;
2008-12-13 07:23:13 +00:00
}
2010-08-02 08:13:51 +00:00
else if ( loadpics ( " tiles000.art " , MAXCACHE1DSIZE ) < 0 )
G_GameExit ( " Failed loading art. " ) ;
2008-08-18 07:20:36 +00:00
}
2008-08-17 11:40:27 +00:00
2012-11-10 14:11:17 +00:00
// Make the fullscreen nuke logo background non-fullbright. Has to be
// after dynamic tile remapping (from C_Compile) and loading tiles.
2012-11-17 19:46:28 +00:00
picanm [ LOADSCREEN ] . sf | = PICANM_NOFULLBRIGHT_BIT ;
2012-11-10 14:11:17 +00:00
2010-08-02 08:13:51 +00:00
// initprintf("Loading palette/lookups...\n");
G_LoadExtraPalettes ( ) ;
ReadSaveGameHeaders ( ) ;
tilesizx [ MIRROR ] = tilesizy [ MIRROR ] = 0 ;
screenpeek = myconnectindex ;
2012-06-03 16:08:27 +00:00
Bfflush ( NULL ) ;
2010-08-02 08:13:51 +00:00
}
void G_UpdatePlayerFromMenu ( void )
{
if ( ud . recstat ! = 0 )
return ;
2006-11-24 04:25:13 +00:00
2010-08-02 08:13:51 +00:00
if ( numplayers > 1 )
2006-09-10 17:40:34 +00:00
{
2010-08-02 08:13:51 +00:00
Net_SendClientInfo ( ) ;
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 ;
}
else
{
/*int32_t j = g_player[myconnectindex].ps->team;*/
2007-02-05 01:33:08 +00:00
2012-08-19 13:02:43 +00:00
// CODEDUP_UD_TO_GPLAYER
2010-08-02 08:13:51 +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 ;
g_player [ myconnectindex ] . pteam = ud . team ;
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 ;
}
}
void G_BackToMenu ( void )
{
boardfilename [ 0 ] = 0 ;
if ( ud . recstat = = 1 ) G_CloseDemoWrite ( ) ;
ud . warp_on = 0 ;
g_player [ myconnectindex ] . ps - > gm = MODE_MENU ;
2012-10-14 22:16:07 +00:00
M_ChangeMenu ( MENU_MAIN ) ;
2010-08-02 08:13:51 +00:00
KB_FlushKeyboardQueue ( ) ;
Bsprintf ( tempbuf , " %s - " APPNAME , g_gameNamePtr ) ;
wm_setapptitle ( tempbuf ) ;
}
2012-01-19 21:57:22 +00:00
static int32_t G_EndOfLevel ( void )
2010-08-02 08:13:51 +00:00
{
2011-01-17 03:49:34 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 0 ) ;
2010-08-02 08:13:51 +00:00
P_UpdateScreenPal ( g_player [ myconnectindex ] . ps ) ;
if ( g_player [ myconnectindex ] . ps - > gm & MODE_EOL )
{
G_CloseDemoWrite ( ) ;
ready2send = 0 ;
if ( ud . display_bonus_screen = = 1 )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
int32_t i = ud . screen_size ;
ud . screen_size = 0 ;
G_UpdateScreenArea ( ) ;
ud . screen_size = i ;
G_BonusScreen ( 0 ) ;
}
if ( ud . eog )
{
ud . eog = 0 ;
if ( ( ! g_netServer & & ud . multimode < 2 ) )
{
if ( ! VOLUMEALL )
G_DoOrderScreen ( ) ;
g_player [ myconnectindex ] . ps - > gm = MODE_MENU ;
2012-10-14 22:16:07 +00:00
M_ChangeMenu ( MENU_MAIN ) ;
2010-08-02 08:13:51 +00:00
probey = 0 ;
return 2 ;
}
2006-11-15 01:16:55 +00:00
else
{
2010-08-02 08:13:51 +00:00
ud . m_level_number = 0 ;
ud . level_number = 0 ;
2006-09-10 17:40:34 +00:00
}
}
2007-01-30 09:03:51 +00:00
}
2010-08-02 08:13:51 +00:00
ud . display_bonus_screen = 1 ;
ready2send = 0 ;
if ( numplayers > 1 ) g_player [ myconnectindex ] . ps - > gm = MODE_GAME ;
if ( G_EnterLevel ( g_player [ myconnectindex ] . ps - > gm ) )
{
G_BackToMenu ( ) ;
return 2 ;
}
Net_WaitForServer ( ) ;
return 1 ;
2007-01-30 09:03:51 +00:00
2010-08-02 08:13:51 +00:00
}
void app_crashhandler ( void )
{
G_CloseDemoWrite ( ) ;
VM_ScriptInfo ( ) ;
G_GameQuit ( ) ;
}
2012-05-28 18:15:19 +00:00
# ifdef _WIN32
// See FILENAME_CASE_CHECK in cache1d.c
static int32_t check_filename_casing ( void )
{
return ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) ;
}
# endif
2012-05-01 12:40:08 +00:00
# ifdef GEKKO
void L2Enhance ( ) ;
void CON_EnableGecko ( int channel , int safe ) ;
bool fatInit ( uint32_t cacheSize , bool setAsDefaultDevice ) ;
# endif
2012-06-26 19:49:59 +00:00
# ifdef LUNATIC
const char * g_sizes_of_what [ ] = {
" sectortype " , " walltype " , " spritetype " ,
" actor_t " , " DukePlayer_t " , " playerdata_t " , " user_defs " } ;
int32_t g_sizes_of [ ] = {
sizeof ( sectortype ) , sizeof ( walltype ) , sizeof ( spritetype ) ,
sizeof ( actor_t ) , sizeof ( DukePlayer_t ) , sizeof ( playerdata_t ) , sizeof ( user_defs ) } ;
# endif
2012-03-28 19:45:25 +00:00
int32_t app_main ( int32_t argc , const char * * argv )
2010-08-02 08:13:51 +00:00
{
int32_t i = 0 , j ;
char cwd [ BMAX_PATH ] ;
// extern char datetimestring[];
# ifdef NEDMALLOC
ENetCallbacks callbacks = { Bmalloc , Bfree , NULL } ;
# else
ENetCallbacks callbacks = { NULL , NULL , NULL } ;
# endif
2012-06-03 19:20:23 +00:00
Bassert ( sizeof ( actor_t ) = = 128 ) ;
2012-10-14 22:16:07 +00:00
Bassert ( offsetof ( actor_t , lightId ) = = sizeof ( netactor_t ) ) ;
2012-07-25 18:56:11 +00:00
Bassert ( sizeof ( DukePlayer_t ) % 4 = = 0 ) ;
2012-06-03 15:46:08 +00:00
2012-11-05 02:49:08 +00:00
initialize_globals ( ) ;
2012-05-01 12:40:08 +00:00
# ifdef GEKKO
L2Enhance ( ) ;
CON_EnableGecko ( 1 , 1 ) ;
printf ( " Console started \n " ) ;
fatInit ( 28 , true ) ;
# endif
2012-11-25 04:26:37 +00:00
# ifdef _WIN32
2010-08-02 08:13:51 +00:00
if ( argc > 1 )
2007-01-30 09:03:51 +00:00
{
2010-08-02 08:13:51 +00:00
for ( ; i < argc ; i + + )
{
2012-03-28 19:45:25 +00:00
if ( Bstrcasecmp ( " -noinstancechecking " , argv [ i ] ) = = 0 )
2010-08-02 08:13:51 +00:00
break ;
}
}
2011-02-25 21:50:19 +00:00
2010-08-02 08:13:51 +00:00
if ( i = = argc & & win_checkinstance ( ) )
{
if ( ! wm_ynbox ( " EDuke32 " , " Another Build game is currently running. "
" Do you wish to continue starting this copy? " ) )
2010-10-17 14:49:39 +00:00
return 3 ;
2006-09-10 17:40:34 +00:00
}
2010-08-02 08:13:51 +00:00
# endif
2006-07-22 05:49:55 +00:00
2010-08-02 08:13:51 +00:00
if ( enet_initialize_with_callbacks ( ENET_VERSION , & callbacks ) ! = 0 )
initprintf ( " An error occurred while initializing ENet. \n " ) ;
else atexit ( enet_deinitialize ) ;
2006-04-13 20:47:06 +00:00
2012-11-25 04:26:37 +00:00
# ifdef _WIN32
2010-08-02 08:13:51 +00:00
backgroundidle = 0 ;
2008-07-22 09:05:34 +00:00
2012-05-28 18:15:19 +00:00
{
extern int32_t ( * check_filename_casing_fn ) ( void ) ;
check_filename_casing_fn = check_filename_casing ;
}
2010-08-02 08:13:51 +00:00
tempbuf [ GetModuleFileName ( NULL , g_rootDir , BMAX_PATH ) ] = 0 ;
Bcorrectfilename ( g_rootDir , 1 ) ;
//chdir(g_rootDir);
# else
getcwd ( g_rootDir , BMAX_PATH ) ;
strcat ( g_rootDir , " / " ) ;
# endif
OSD_SetParameters ( 0 , 0 , 0 , 12 , 2 , 12 ) ;
OSD_SetLogFile ( " eduke32.log " ) ;
OSD_SetFunctions (
GAME_drawosdchar ,
GAME_drawosdstr ,
GAME_drawosdcursor ,
GAME_getcolumnwidth ,
GAME_getrowheight ,
GAME_clearbackground ,
( int32_t ( * ) ( void ) ) GetTime ,
GAME_onshowosd
) ;
Bstrcpy ( tempbuf , APPNAME ) ;
wm_setapptitle ( tempbuf ) ;
2011-08-10 11:47:23 +00:00
//initprintf("sizeof(mapstate_t)=%d\n", (int32_t)sizeof(mapstate_t));
2006-04-13 20:47:06 +00:00
2012-11-15 14:28:11 +00:00
initprintf ( HEAD2 " %s %s \n " , s_buildRev ,
# ifdef __cplusplus
" C++ build "
# else
" "
# endif
) ;
2011-03-04 10:09:12 +00:00
initprintf ( " Compiled %s \n " , __DATE__ " " __TIME__ ) ;
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
# if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
addsearchpath ( " /usr/share/games/jfduke3d " ) ;
addsearchpath ( " /usr/local/share/games/jfduke3d " ) ;
addsearchpath ( " /usr/share/games/eduke32 " ) ;
addsearchpath ( " /usr/local/share/games/eduke32 " ) ;
# elif defined(__APPLE__)
addsearchpath ( " /Library/Application Support/JFDuke3D " ) ;
addsearchpath ( " /Library/Application Support/EDuke32 " ) ;
# endif
2010-07-22 20:29:09 +00:00
2012-03-25 22:00:27 +00:00
g_numSkills = 4 ;
2010-08-02 08:13:51 +00:00
ud . multimode = 1 ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
// this needs to happen before G_CheckCommandLine because G_GameExit accesses g_player[0]
g_player [ 0 ] . ps = ( DukePlayer_t * ) Bcalloc ( 1 , sizeof ( DukePlayer_t ) ) ;
g_player [ 0 ] . sync = ( input_t * ) Bcalloc ( 1 , sizeof ( input_t ) ) ;
2009-12-05 09:22:43 +00:00
2010-08-02 08:13:51 +00:00
G_CheckCommandLine ( argc , argv ) ;
2007-08-27 06:46:31 +00:00
2010-08-02 08:13:51 +00:00
# if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
if ( forcegl ) initprintf ( " GL driver blacklist disabled. \n " ) ;
# endif
2010-07-22 20:29:09 +00:00
2010-08-02 08:13:51 +00:00
if ( getcwd ( cwd , BMAX_PATH ) )
2007-08-27 06:46:31 +00:00
{
2010-08-02 08:13:51 +00:00
addsearchpath ( cwd ) ;
# if defined(__APPLE__)
/* Dirty hack on OS X to also look for gamedata inside the application bundle - rhoenie 08/08 */
char seekinappcontainer [ BMAX_PATH ] ;
Bsnprintf ( seekinappcontainer , sizeof ( seekinappcontainer ) , " %s/EDuke32.app/ " , cwd ) ;
addsearchpath ( seekinappcontainer ) ;
# endif
2007-08-27 06:46:31 +00:00
}
2010-08-02 08:13:51 +00:00
if ( CommandPaths )
2006-08-19 01:30:40 +00:00
{
2010-08-02 08:13:51 +00:00
struct strllist * s ;
while ( CommandPaths )
{
s = CommandPaths - > next ;
2011-09-01 18:37:53 +00:00
i = addsearchpath ( CommandPaths - > str ) ;
if ( i < 0 )
{
initprintf ( " Failed adding %s for game data: %s \n " , CommandPaths - > str ,
i = = - 1 ? " not a directory " : " no such directory " ) ;
}
2009-06-13 21:06:45 +00:00
2010-08-02 08:13:51 +00:00
Bfree ( CommandPaths - > str ) ;
Bfree ( CommandPaths ) ;
CommandPaths = s ;
}
2008-03-08 09:04:01 +00:00
}
2009-01-10 07:38:50 +00:00
2010-08-02 08:13:51 +00:00
# if defined(_WIN32)
if ( ! access ( " user_profiles_enabled " , F_OK ) )
# else
if ( usecwd = = 0 & & access ( " user_profiles_disabled " , F_OK ) )
# endif
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
char * homedir ;
int32_t asperr ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( homedir = Bgethomedir ( ) ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
Bsnprintf ( cwd , sizeof ( cwd ) , " %s/ "
# if defined(_WIN32)
" EDuke32 Settings "
# elif defined(__APPLE__)
" Library/Application Support/EDuke32 "
2012-05-01 12:40:08 +00:00
# elif defined(GEKKO)
" apps/eduke32 "
2010-08-02 08:13:51 +00:00
# else
" .eduke32 "
# endif
, homedir ) ;
asperr = addsearchpath ( cwd ) ;
if ( asperr = = - 2 )
{
if ( Bmkdir ( cwd , S_IRWXU ) = = 0 ) asperr = addsearchpath ( cwd ) ;
else asperr = - 1 ;
}
if ( asperr = = 0 )
chdir ( cwd ) ;
Bfree ( homedir ) ;
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
// used with binds for fast function lookup
hash_init ( & h_gamefuncs ) ;
for ( i = NUMGAMEFUNCTIONS - 1 ; i > = 0 ; i - - )
2008-10-18 12:37:26 +00:00
{
2010-08-02 08:13:51 +00:00
char * str = Bstrtolower ( Bstrdup ( gamefunctions [ i ] ) ) ;
hash_add ( & h_gamefuncs , gamefunctions [ i ] , i , 0 ) ;
hash_add ( & h_gamefuncs , str , i , 0 ) ;
Bfree ( str ) ;
2008-10-18 12:37:26 +00:00
}
2009-07-09 02:29:48 +00:00
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
glusetexcache = - 1 ;
# endif
2008-10-18 12:37:26 +00:00
2010-08-02 08:13:51 +00:00
i = CONFIG_ReadSetup ( ) ;
2011-06-23 15:41:08 +00:00
2012-06-03 16:09:33 +00:00
// CODEDUP astub.c
if ( g_grpNamePtr = = NULL )
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
const char * cp = getenv ( " DUKE3DGRP " ) ;
if ( cp )
{
clearGrpNamePtr ( ) ;
g_grpNamePtr = dup_filename ( cp ) ;
initprintf ( " Using \" %s \" as main GRP file \n " , g_grpNamePtr ) ;
}
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
}
2008-10-18 12:37:26 +00:00
2010-08-02 08:13:51 +00:00
# ifdef _WIN32
2009-04-29 19:43:51 +00:00
2012-02-20 21:17:39 +00:00
// initprintf("build %d\n",(uint8_t)Batoi(BUILDDATE));
2009-04-29 19:43:51 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . config . CheckForUpdates = = 1 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( time ( NULL ) - ud . config . LastUpdateCheck > UPDATEINTERVAL )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
initprintf ( " Checking for updates... \n " ) ;
if ( G_GetVersionFromWebsite ( tempbuf ) )
2008-08-26 19:50:34 +00:00
{
2012-02-20 21:17:39 +00:00
initprintf ( " Current version is %d " , Batoi ( tempbuf ) ) ;
2010-08-02 08:13:51 +00:00
ud . config . LastUpdateCheck = time ( NULL ) ;
2012-02-20 21:17:39 +00:00
if ( Batoi ( tempbuf ) > atoi ( s_buildDate ) )
2008-09-12 02:07:44 +00:00
{
2010-08-02 08:13:51 +00:00
if ( wm_ynbox ( " EDuke32 " , " A new version of EDuke32 is available. "
" Browse to http://eduke32.sourceforge.net now? " ) )
{
SHELLEXECUTEINFOA sinfo ;
char * p = " http://eduke32.sourceforge.net " ;
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 " ) ;
}
2008-09-12 02:07:44 +00:00
}
2010-08-02 08:13:51 +00:00
else initprintf ( " ... no updates available \n " ) ;
2008-08-26 19:50:34 +00:00
}
2010-08-02 08:13:51 +00:00
else initprintf ( " update: failed to check for updates \n " ) ;
2006-04-16 03:42:36 +00:00
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
# endif
2006-04-13 20:47:06 +00:00
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
if ( glusetexcache = = - 1 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
ud . config . useprecache = glusetexcompr = 1 ;
glusetexcache = 2 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
# endif
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( preinitengine ( ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
wm_msgbox ( " Build Engine Initialization Error " ,
" There was a problem initializing the Build engine: %s " , engineerrstr ) ;
2011-07-20 23:04:20 +00:00
ERRprintf ( " app_main: There was a problem initializing the Build engine: %s \n " , engineerrstr ) ;
2010-10-17 14:49:39 +00:00
exit ( 2 ) ;
2010-08-02 08:13:51 +00:00
}
2006-12-10 06:49:01 +00:00
2010-08-02 08:13:51 +00:00
if ( Bstrcmp ( setupfilename , SETUPFILENAME ) )
2012-03-26 05:05:57 +00:00
initprintf ( " Using config file \" %s \" . \n " , setupfilename ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
ScanGroups ( ) ;
{
2012-06-03 16:09:33 +00:00
// try and identify the 'defaultgamegrp' in the set of GRPs.
2010-08-02 08:13:51 +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
struct grpfile * fg , * first = NULL ;
int32_t i ;
for ( fg = foundgrps ; fg ; fg = fg - > next )
{
2012-03-26 22:03:40 +00:00
for ( i = 0 ; i < NUMGRPFILES ; i + + ) if ( fg - > crcval = = grpfiles [ i ] . crcval ) break ;
if ( i = = NUMGRPFILES ) continue ; // unrecognised grp file
2010-08-02 08:13:51 +00:00
fg - > game = grpfiles [ i ] . game ;
if ( ! first ) first = fg ;
2012-06-03 16:09:33 +00:00
if ( ! Bstrcasecmp ( fg - > name , G_DefaultGrpFile ( ) ) )
2006-12-04 02:10:18 +00:00
{
2010-08-02 08:13:51 +00:00
g_gameType = grpfiles [ i ] . game ;
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
g_gameNamePtr = grpfiles [ i ] . name ;
2010-08-02 08:13:51 +00:00
break ;
2006-12-04 02:10:18 +00:00
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
if ( ! fg & & first )
2009-08-28 23:08:00 +00:00
{
2012-06-03 16:09:33 +00:00
if ( g_grpNamePtr = = NULL )
{
clearGrpNamePtr ( ) ;
g_grpNamePtr = dup_filename ( first - > name ) ;
}
2010-08-02 08:13:51 +00:00
g_gameType = first - > game ;
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
g_gameNamePtr = grpfiles [ 0 ] . name ;
2009-08-28 23:08:00 +00:00
}
2010-08-02 08:13:51 +00:00
else if ( ! fg ) g_gameNamePtr = " Unknown GRP " ;
2006-12-04 02:10:18 +00:00
}
2012-11-25 04:26:37 +00:00
# if (defined _WIN32 || (defined RENDERTYPESDL && ((defined __APPLE__ && defined OSX_STARTUPWINDOW) || defined HAVE_GTK2)))
2010-08-02 08:13:51 +00:00
if ( i < 0 | | ( ! g_noSetup & & ( ud . configversion ! = BYTEVERSION_JF | | ud . config . ForceSetup ) ) | | g_commandSetup )
{
if ( quitevent | | ! startwin_run ( ) )
{
uninitengine ( ) ;
exit ( 0 ) ;
}
2006-12-04 02:10:18 +00:00
}
2010-08-02 08:13:51 +00:00
# endif
2010-05-22 23:41:18 +00:00
2010-08-02 08:13:51 +00:00
FreeGroups ( ) ;
2006-08-18 23:52:26 +00:00
2010-08-02 08:13:51 +00:00
if ( WW2GI | | NAM )
2006-11-15 01:16:55 +00:00
{
2012-06-03 16:09:33 +00:00
Bstrcpy ( GametypeNames [ 0 ] , " GruntMatch (Spawn) " ) ;
Bstrcpy ( GametypeNames [ 2 ] , " GruntMatch (No Spawn) " ) ;
2010-08-02 08:13:51 +00:00
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_modDir [ 0 ] ! = ' / ' )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
char cwd [ BMAX_PATH ] ;
2010-05-02 23:27:30 +00:00
2010-08-02 08:13:51 +00:00
Bstrcat ( g_rootDir , g_modDir ) ;
addsearchpath ( g_rootDir ) ;
// addsearchpath(mod_dir);
if ( getcwd ( cwd , BMAX_PATH ) )
2010-05-07 20:45:40 +00:00
{
2010-08-02 08:13:51 +00:00
Bsprintf ( cwd , " %s/%s " , cwd , g_modDir ) ;
if ( ! Bstrcmp ( g_rootDir , cwd ) )
{
if ( addsearchpath ( cwd ) = = - 2 )
if ( Bmkdir ( cwd , S_IRWXU ) = = 0 ) addsearchpath ( cwd ) ;
}
2010-05-07 20:45:40 +00:00
}
2010-05-08 20:15:24 +00:00
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
Bsprintf ( tempbuf , " %s/%s " , g_modDir , TEXCACHEFILE ) ;
Bstrcpy ( TEXCACHEFILE , tempbuf ) ;
# endif
}
2008-07-03 07:37:41 +00:00
2010-08-02 08:13:51 +00:00
{
2012-06-03 16:09:33 +00:00
const char * grpfile = G_GrpFile ( ) ;
if ( ( i = initgroupfile ( grpfile ) ) = = - 1 )
initprintf ( " Warning: could not find main data file \" %s \" ! \n " , grpfile ) ;
else
initprintf ( " Using \" %s \" as main game data file. \n " , grpfile ) ;
if ( ! g_noAutoLoad & & ! ud . config . NoAutoLoad )
{
G_LoadGroupsInDir ( " autoload " ) ;
2009-12-05 09:22:43 +00:00
2012-06-03 16:09:33 +00:00
if ( i ! = - 1 )
G_DoAutoload ( grpfile ) ;
}
2010-08-02 08:13:51 +00:00
}
if ( g_modDir [ 0 ] ! = ' / ' )
2012-03-28 19:42:32 +00:00
G_LoadGroupsInDir ( g_modDir ) ;
2010-05-05 07:31:38 +00:00
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
// CODEDUP astub.c
2012-06-03 16:09:33 +00:00
if ( g_defNamePtr = = NULL )
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
{
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
const char * tmpptr = getenv ( " DUKE3DDEF " ) ;
if ( tmpptr )
{
clearDefNamePtr ( ) ;
g_defNamePtr = dup_filename ( tmpptr ) ;
initprintf ( " Using \" %s \" as definitions file \n " , g_defNamePtr ) ;
}
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
}
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
2010-08-02 08:13:51 +00:00
flushlogwindow = 0 ;
2012-06-03 16:09:33 +00:00
loaddefinitions_game ( G_DefFile ( ) , TRUE ) ;
2010-08-02 08:13:51 +00:00
// flushlogwindow = 1;
2010-05-04 23:40:49 +00:00
2010-08-02 08:13:51 +00:00
{
struct strllist * s ;
2010-05-04 23:40:49 +00:00
2010-08-02 08:13:51 +00:00
pathsearchmode = 1 ;
while ( CommandGrps )
{
s = CommandGrps - > next ;
2010-05-04 23:40:49 +00:00
2010-08-02 08:13:51 +00:00
if ( ( j = initgroupfile ( CommandGrps - > str ) ) = = - 1 )
2012-03-26 05:05:57 +00:00
initprintf ( " Could not find file \" %s \" . \n " , CommandGrps - > str ) ;
2010-05-04 23:40:49 +00:00
else
2010-08-02 08:13:51 +00:00
{
g_groupFileHandle = j ;
2012-03-26 05:05:57 +00:00
initprintf ( " Using file \" %s \" as game data. \n " , CommandGrps - > str ) ;
2010-08-02 08:13:51 +00:00
if ( ! g_noAutoLoad & & ! ud . config . NoAutoLoad )
G_DoAutoload ( CommandGrps - > str ) ;
}
2010-05-04 23:40:49 +00:00
2010-08-02 08:13:51 +00:00
Bfree ( CommandGrps - > str ) ;
Bfree ( CommandGrps ) ;
CommandGrps = s ;
2010-05-04 23:40:49 +00:00
}
2010-08-02 08:13:51 +00:00
pathsearchmode = 0 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
i = kopen4load ( " DUKESW.BIN " , 1 ) ; // JBF 20030810
if ( i ! = - 1 )
{
g_Shareware = 1 ;
kclose ( i ) ;
}
2006-04-17 07:53:31 +00:00
2010-08-02 08:13:51 +00:00
// gotta set the proper title after we compile the CONs if this is the full version
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
Bsprintf ( tempbuf , " %s - " APPNAME , g_gameNamePtr ) ;
wm_setapptitle ( tempbuf ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_scriptDebug )
initprintf ( " CON debugging activated (level %d). \n " , g_scriptDebug ) ;
2006-04-13 20:47:06 +00:00
2011-02-25 21:50:19 +00:00
if ( g_networkMode = = NET_SERVER | | g_networkMode = = NET_DEDICATED_SERVER )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
ENetAddress address = { ENET_HOST_ANY , g_netPort } ;
g_netServer = enet_host_create ( & address , MAXPLAYERS , CHAN_MAX , 0 , 0 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_netServer = = NULL )
initprintf ( " An error occurred while trying to create an ENet server host. \n " ) ;
else initprintf ( " Multiplayer server initialized \n " ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
numplayers = 1 ;
2012-08-13 18:25:32 +00:00
if ( ! g_fakeMultiMode )
{
connectpoint2 [ 0 ] = - 1 ;
}
else
{
playerswhenstarted = ud . multimode ;
for ( i = 0 ; i < ud . multimode - 1 ; i + + )
connectpoint2 [ i ] = i + 1 ;
connectpoint2 [ ud . multimode - 1 ] = - 1 ;
for ( i = 1 ; i < ud . multimode ; i + + )
g_player [ i ] . playerquitflag = 1 ;
}
2007-02-11 00:49:03 +00:00
2010-08-02 08:13:51 +00:00
Net_GetPackets ( ) ;
2007-10-24 06:48:13 +00:00
2010-08-02 08:13:51 +00:00
G_Startup ( ) ; // a bunch of stuff including compiling cons
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
g_player [ 0 ] . playerquitflag = 1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
2010-01-24 23:33:17 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ! g_player [ i ] . ps ) g_player [ i ] . ps = ( DukePlayer_t * ) Bcalloc ( 1 , sizeof ( DukePlayer_t ) ) ;
if ( ! g_player [ i ] . sync ) g_player [ i ] . sync = ( input_t * ) Bcalloc ( 1 , sizeof ( input_t ) ) ;
2010-01-24 23:33:17 +00:00
}
2006-04-13 20:47:06 +00:00
2011-01-17 03:49:34 +00:00
g_player [ myconnectindex ] . ps - > palette = BASEPAL ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
i = 1 ;
for ( j = numplayers ; j < ud . multimode ; j + + )
{
Bsprintf ( g_player [ j ] . user_name , " PLAYER %d " , j + 1 ) ;
g_player [ j ] . ps - > team = g_player [ j ] . pteam = i ;
g_player [ j ] . ps - > weaponswitch = 3 ;
g_player [ j ] . ps - > auto_aim = 0 ;
i = 1 - i ;
}
2006-04-13 20:47:06 +00:00
2010-10-17 14:49:39 +00:00
if ( quitevent ) return 4 ;
2006-04-13 20:47:06 +00:00
2010-01-24 23:33:17 +00:00
{
2012-07-01 22:11:33 +00:00
const char * defsfile = G_DefFile ( ) ;
2012-06-03 16:09:33 +00:00
if ( ! loaddefinitionsfile ( defsfile ) )
{
initprintf ( " Definitions file \" %s \" loaded. \n " , defsfile ) ;
loaddefinitions_game ( defsfile , FALSE ) ;
}
2010-01-24 23:33:17 +00:00
}
2011-07-21 22:39:29 +00:00
for ( i = 0 ; i < g_defModulesNum ; + + i )
2012-01-05 20:48:05 +00:00
Bfree ( g_defModules [ i ] ) ;
Bfree ( g_defModules ) ;
g_defModules = NULL ;
2011-07-21 22:39:29 +00:00
2010-08-02 08:13:51 +00:00
if ( numplayers = = 1 & & boardfilename [ 0 ] ! = 0 )
2008-09-14 21:25:23 +00:00
{
2010-08-02 08:13:51 +00:00
ud . m_level_number = 7 ;
ud . m_volume_number = 0 ;
ud . warp_on = 1 ;
2010-01-16 23:08:17 +00:00
}
2010-08-02 08:13:51 +00:00
// getnames();
2010-01-24 23:33:17 +00:00
2011-12-25 15:33:24 +00:00
if ( g_netServer | | ud . multimode > 1 )
2010-01-24 23:33:17 +00:00
{
2010-08-02 08:13:51 +00:00
if ( ud . warp_on = = 0 )
{
ud . m_monsters_off = 1 ;
ud . m_player_skill = 0 ;
}
2010-01-24 23:33:17 +00:00
}
2010-08-02 08:13:51 +00:00
playerswhenstarted = ud . multimode ;
ud . last_level = 0 ;
2010-01-24 23:33:17 +00:00
2012-06-03 16:09:33 +00:00
// the point of this block is to avoid overwriting the default in the cfg while asserting our selection
2012-03-05 07:24:34 +00:00
if ( g_rtsNamePtr = = NULL & &
2012-06-03 16:09:33 +00:00
( ! Bstrcasecmp ( ud . rtsname , defaultrtsfilename [ GAME_DUKE ] ) | |
! Bstrcasecmp ( ud . rtsname , defaultrtsfilename [ GAME_WW2GI ] ) | |
! Bstrcasecmp ( ud . rtsname , defaultrtsfilename [ GAME_NAM ] ) | |
! Bstrcasecmp ( ud . rtsname , defaultrtsfilename [ GAME_NAPALM ] ) ) )
2010-08-02 08:13:51 +00:00
{
2012-03-05 07:24:34 +00:00
// ud.last_level is used as a flag here to reset the string to default after load
2012-06-03 16:09:33 +00:00
ud . last_level = ( Bstrcpy ( ud . rtsname , G_DefaultRtsFile ( ) ) = = ud . rtsname ) ;
2010-08-02 08:13:51 +00:00
}
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
RTS_Init ( ud . rtsname ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
if ( rts_numlumps )
2012-03-26 05:05:57 +00:00
initprintf ( " Using RTS file \" %s \" . \n " , ud . rtsname ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . last_level )
2012-06-03 16:09:33 +00:00
Bstrcpy ( ud . rtsname , defaultrtsfilename [ 0 ] ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
ud . last_level = - 1 ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
initprintf ( " Initializing OSD... \n " ) ;
2010-01-24 23:33:17 +00:00
2011-03-04 09:29:03 +00:00
Bsprintf ( tempbuf , HEAD2 " %s " , s_buildRev ) ;
2010-08-02 08:13:51 +00:00
OSD_SetVersion ( tempbuf , 10 , 0 ) ;
registerosdcommands ( ) ;
2010-01-24 23:33:17 +00:00
2011-02-25 21:50:19 +00:00
if ( g_networkMode ! = NET_DEDICATED_SERVER )
2010-01-24 23:33:17 +00:00
{
2012-11-15 14:28:47 +00:00
if ( CONTROL_Startup ( controltype_keyboardandmouse , & GetTime , TICRATE ) )
2011-02-25 21:50:19 +00:00
{
2011-07-20 23:04:20 +00:00
ERRprintf ( " There was an error initializing the CONTROL system. \n " ) ;
2011-02-25 21:50:19 +00:00
uninitengine ( ) ;
exit ( 5 ) ;
}
2010-01-24 23:33:17 +00:00
2011-02-25 21:50:19 +00:00
G_SetupGameButtons ( ) ;
CONFIG_SetupMouse ( ) ;
CONFIG_SetupJoystick ( ) ;
2010-08-02 08:13:51 +00:00
2011-02-25 21:50:19 +00:00
CONTROL_JoystickEnabled = ( ud . config . UseJoystick & & CONTROL_JoyPresent ) ;
CONTROL_MouseEnabled = ( ud . config . UseMouse & & CONTROL_MousePresent ) ;
2010-08-02 08:13:51 +00:00
2011-02-25 21:50:19 +00:00
// JBF 20040215: evil and nasty place to do this, but joysticks are evil and nasty too
for ( i = 0 ; i < joynumaxes ; i + + )
setjoydeadzone ( i , ud . config . JoystickAnalogueDead [ i ] , ud . config . JoystickAnalogueSaturate [ i ] ) ;
}
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
char * ptr = Bstrdup ( setupfilename ) , * p = strtok ( ptr , " . " ) ;
if ( ! Bstrcmp ( setupfilename , SETUPFILENAME ) )
Bsprintf ( tempbuf , " settings.cfg " ) ;
else Bsprintf ( tempbuf , " %s_settings.cfg " , p ) ;
OSD_Exec ( tempbuf ) ;
Bfree ( ptr ) ;
2006-04-13 20:47:06 +00:00
}
2010-01-24 23:33:17 +00:00
2012-03-18 08:50:41 +00:00
# ifdef HAVE_CLIPSHAPE_FEATURE
if ( ( i = clipmapinfo_load ( ) ) > 0 )
2010-10-31 19:54:03 +00:00
initprintf ( " There was an error loading the sprite clipping map (status %d). \n " , i ) ;
2012-03-18 08:50:41 +00:00
for ( i = 0 ; i < g_clipMapFilesNum ; + + i )
Bfree ( g_clipMapFiles [ i ] ) ;
Bfree ( g_clipMapFiles ) ;
g_clipMapFiles = NULL ;
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
# endif
2010-10-28 20:17:22 +00:00
2010-08-02 08:13:51 +00:00
OSD_Exec ( " autoexec.cfg " ) ;
2010-01-24 23:33:17 +00:00
2012-06-03 15:45:59 +00:00
# ifdef LUNATIC
2011-09-20 19:12:24 +00:00
i = El_CreateState ( & g_ElState , " test " ) ;
if ( i )
{
initprintf ( " Lunatic: Error initializing global ELua state (code %d) \n " , i ) ;
}
else
{
2012-11-10 20:59:00 +00:00
i = L_RunOnce ( & g_ElState , " defs.ilua " ) ;
2011-09-20 19:12:24 +00:00
if ( i )
{
initprintf ( " Lunatic: Error preparing global ELua state (code %d) \n " , i ) ;
El_DestroyState ( & g_ElState ) ;
}
}
# endif
2011-02-25 21:50:19 +00:00
if ( g_networkMode ! = NET_DEDICATED_SERVER )
2006-04-13 20:47:06 +00:00
{
2011-02-25 21:50:19 +00:00
if ( setgamemode ( ud . config . ScreenMode , ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP ) < 0 )
{
int32_t i = 0 ;
int32_t xres [ ] = { ud . config . ScreenWidth , 800 , 640 , 320 } ;
int32_t yres [ ] = { ud . config . ScreenHeight , 600 , 480 , 240 } ;
int32_t bpp [ ] = { 32 , 16 , 8 } ;
2006-04-13 20:47:06 +00:00
2011-02-25 21:50:19 +00:00
initprintf ( " Failure setting video mode %dx%dx%d %s! Attempting safer mode... \n " ,
ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP , ud . config . ScreenMode ? " fullscreen " : " windowed " ) ;
2010-01-24 23:33:17 +00:00
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-08-02 08:13:51 +00:00
{
2011-02-25 21:50:19 +00:00
int32_t j = 0 ;
while ( setgamemode ( 0 , xres [ i ] , yres [ i ] , bpp [ j ] ) < 0 )
2010-08-02 08:13:51 +00:00
{
2011-02-25 21:50:19 +00:00
initprintf ( " Failure setting video mode %dx%dx%d windowed! Attempting safer mode... \n " , xres [ i ] , yres [ i ] , bpp [ i ] ) ;
if ( + + j = = 3 )
{
if ( + + i = = 4 )
G_GameExit ( " Unable to set failsafe video mode! " ) ;
j = 0 ;
}
2010-08-02 08:13:51 +00:00
}
}
# else
2011-02-25 21:50:19 +00:00
while ( setgamemode ( 0 , xres [ i ] , yres [ i ] , 8 ) < 0 )
{
initprintf ( " Failure setting video mode %dx%dx%d windowed! Attempting safer mode... \n " , xres [ i ] , yres [ i ] , 8 ) ;
i + + ;
}
2010-08-02 08:13:51 +00:00
# endif
2011-02-25 21:50:19 +00:00
ud . config . ScreenWidth = xres [ i ] ;
ud . config . ScreenHeight = yres [ i ] ;
ud . config . ScreenBPP = bpp [ i ] ;
}
2010-08-02 08:13:51 +00:00
2011-02-25 21:50:19 +00:00
setbrightness ( ud . brightness > > 2 , g_player [ myconnectindex ] . ps - > palette , 0 ) ;
2010-01-24 23:33:17 +00:00
2011-02-25 21:50:19 +00:00
S_MusicStartup ( ) ;
S_SoundStartup ( ) ;
}
2010-08-02 08:13:51 +00:00
// loadtmb();
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . warp_on > 1 & & ( ! g_netServer & & ud . multimode < 2 ) )
{
clearview ( 0L ) ;
//g_player[myconnectindex].ps->palette = palette;
//G_FadePalette(0,0,0,0);
2011-01-17 03:49:34 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 0 ) ; // JBF 20040308
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 320 < < 15 , 200 < < 15 , 65536L , 0 , LOADSCREEN , 0 , 0 , 2 + 8 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-08-02 08:13:51 +00:00
menutext ( 160 , 105 , 0 , 0 , " LOADING SAVED GAME... " ) ;
nextpage ( ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
if ( G_LoadPlayer ( ud . warp_on - 2 ) )
ud . warp_on = 0 ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
// getpackets();
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
MAIN_LOOP_RESTART :
2010-01-24 23:33:17 +00:00
2011-02-25 21:50:19 +00:00
if ( g_networkMode ! = NET_DEDICATED_SERVER )
{
G_GetCrosshairColor ( ) ;
G_SetCrosshairColor ( CrosshairColors . r , CrosshairColors . g , CrosshairColors . b ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ud . warp_on = = 0 )
{
if ( ( g_netServer | | ud . multimode > 1 ) & & boardfilename [ 0 ] ! = 0 )
{
ud . m_level_number = 7 ;
ud . m_volume_number = 0 ;
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
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( i ) )
2010-08-02 08:13:51 +00:00
{
P_ResetWeapons ( i ) ;
P_ResetInventory ( i ) ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
G_NewGame ( ud . m_volume_number , ud . m_level_number , ud . m_player_skill ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
if ( G_EnterLevel ( MODE_GAME ) ) G_BackToMenu ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
Net_WaitForServer ( ) ;
}
2011-02-25 21:50:19 +00:00
else if ( g_networkMode ! = NET_DEDICATED_SERVER )
G_DisplayLogo ( ) ;
2006-04-13 20:47:06 +00:00
2011-02-25 21:50:19 +00:00
if ( g_networkMode ! = NET_DEDICATED_SERVER )
2006-04-13 20:47:06 +00:00
{
2011-02-25 21:50:19 +00:00
if ( G_PlaybackDemo ( ) )
{
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
g_noLogoAnim = 1 ;
goto MAIN_LOOP_RESTART ;
}
2006-04-13 20:47:06 +00:00
}
}
2010-08-02 08:13:51 +00:00
else if ( ud . warp_on = = 1 )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
G_NewGame ( ud . m_volume_number , ud . m_level_number , ud . m_player_skill ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( G_EnterLevel ( MODE_GAME ) ) G_BackToMenu ( ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
else G_UpdateScreenArea ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// G_GameExit(" "); ///
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
// ud.auto_run = ud.config.RunMode;
ud . showweapons = ud . config . ShowOpponentWeapons ;
2012-08-19 13:02:43 +00:00
// CODEDUP_UD_TO_GPLAYER
2010-08-02 08:13:51 +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 ] . pteam = ud . team ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( GametypeFlags [ ud . coop ] & GAMETYPE_TDM )
g_player [ myconnectindex ] . ps - > palookup = g_player [ myconnectindex ] . pcolor = G_GetTeamPalette ( g_player [ myconnectindex ] . pteam ) ;
else
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +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 ;
}
2009-11-01 20:30:09 +00:00
2010-08-02 08:13:51 +00:00
ud . warp_on = 0 ;
KB_KeyDown [ sc_Pause ] = 0 ; // JBF: I hate the pause key
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
do //main loop
{
static uint32_t nextrender = 0 , framewaiting = 0 ;
uint32_t j ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
if ( handleevents ( ) & & quitevent )
{
KB_KeyDown [ sc_Escape ] = 1 ;
quitevent = 0 ;
}
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
sampletimer ( ) ;
Net_GetPackets ( ) ;
2009-11-01 20:30:09 +00:00
2010-08-02 08:13:51 +00:00
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
2012-11-17 16:47:47 +00:00
CONTROL_BindsEnabled = g_player [ myconnectindex ] . ps - > gm & ( MODE_GAME | MODE_DEMO ) ;
2010-01-24 23:33:17 +00:00
2011-02-25 22:50:59 +00:00
# ifndef _WIN32
2011-02-25 21:50:19 +00:00
// stdin -> OSD input for dedicated server
if ( g_networkMode = = NET_DEDICATED_SERVER )
{
2012-05-20 07:25:25 +00:00
int32_t nb ;
2011-02-25 21:50:19 +00:00
char ch ;
static uint32_t bufpos = 0 ;
static char buf [ 128 ] ;
2012-05-01 12:40:08 +00:00
# ifndef GEKKO
2012-05-20 07:25:25 +00:00
int32_t flag = 1 ;
2011-02-25 21:50:19 +00:00
ioctl ( 0 , FIONBIO , & flag ) ;
2012-05-01 12:40:08 +00:00
# endif
2011-02-25 21:50:19 +00:00
if ( ( nb = read ( 0 , & ch , 1 ) ) > 0 & & bufpos < sizeof ( buf ) )
{
if ( ch ! = ' \n ' )
buf [ bufpos + + ] = ch ;
2011-06-25 16:37:10 +00:00
2011-02-25 21:50:19 +00:00
if ( ch = = ' \n ' | | bufpos > = sizeof ( buf ) )
{
buf [ bufpos ] = 0 ;
OSD_Dispatch ( buf ) ;
bufpos = 0 ;
}
}
}
else
2011-02-25 22:50:59 +00:00
# endif
2011-02-25 21:50:19 +00:00
{
MUSIC_Update ( ) ;
G_HandleLocalKeys ( ) ;
}
2010-08-02 08:13:51 +00:00
OSD_DispatchQueued ( ) ;
2010-01-24 23:33:17 +00:00
2011-02-25 21:50:19 +00:00
if ( ( ( g_netClient | | g_netServer ) | | ! ( g_player [ myconnectindex ] . ps - > gm & ( MODE_MENU | MODE_DEMO ) ) ) & & totalclock > = ototalclock + TICSPERFRAME )
2010-08-02 08:13:51 +00:00
{
2011-02-25 21:50:19 +00:00
if ( g_networkMode ! = NET_DEDICATED_SERVER )
{
CONTROL_ProcessBinds ( ) ;
getinput ( myconnectindex ) ;
}
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
avg . fvel + = loc . fvel ;
avg . svel + = loc . svel ;
avg . avel + = loc . avel ;
avg . horz + = loc . horz ;
avg . bits | = loc . bits ;
avg . extbits | = loc . extbits ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
Bmemcpy ( & inputfifo [ 0 ] [ myconnectindex ] , & avg , sizeof ( input_t ) ) ;
Bmemset ( & avg , 0 , sizeof ( input_t ) ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
do
{
2011-03-03 06:57:42 +00:00
int32_t clockbeforetic ;
2010-08-02 08:13:51 +00:00
sampletimer ( ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
if ( ready2send = = 0 ) break ;
2010-01-24 23:33:17 +00:00
2009-01-18 07:32:35 +00:00
ototalclock + = TICSPERFRAME ;
2009-10-25 23:25:38 +00:00
2011-03-03 06:57:42 +00:00
clockbeforetic = totalclock ;
2010-08-02 08:13:51 +00:00
if ( ( ( ud . show_help = = 0 & & ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) ! = MODE_MENU ) | | ud . recstat = = 2 | | ( g_netServer | | ud . multimode > 1 ) ) & &
2011-03-04 08:50:58 +00:00
( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
2011-03-03 06:57:42 +00:00
G_MoveLoop ( ) ;
2011-06-25 16:37:10 +00:00
2011-03-03 06:57:42 +00:00
sampletimer ( ) ;
2011-06-25 16:37:10 +00:00
2011-03-04 08:50:58 +00:00
if ( totalclock - clockbeforetic > = TICSPERFRAME )
{
2011-03-03 06:57:42 +00:00
// computing a tic takes longer than a tic, so we're slowing
// the game down. rather than tightly spinning here, go draw
// a frame since we're fucked anyway
break ;
}
2009-10-25 23:25:38 +00:00
}
2011-02-25 21:50:19 +00:00
while ( ( ( g_netClient | | g_netServer ) | | ! ( g_player [ myconnectindex ] . ps - > gm & ( MODE_MENU | MODE_DEMO ) ) ) & & totalclock > = ototalclock + TICSPERFRAME ) ;
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
}
2010-01-24 23:33:17 +00:00
2010-08-02 08:13:51 +00:00
G_DoCheats ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & ( MODE_EOL | MODE_RESTART ) )
{
switch ( G_EndOfLevel ( ) )
2009-10-25 23:25:38 +00:00
{
2010-08-02 08:13:51 +00:00
case 1 : continue ;
case 2 : goto MAIN_LOOP_RESTART ;
2009-10-25 23:25:38 +00:00
}
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
2011-02-25 21:50:19 +00:00
if ( g_networkMode = = NET_DEDICATED_SERVER )
{
idle ( ) ;
goto skipframe ;
}
2010-08-02 08:13:51 +00:00
if ( framewaiting )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
framewaiting - - ;
if ( ud . statusbarmode = = 1 & & ( ud . statusbarscale = = 100 | | ! getrendermode ( ) ) )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
ud . statusbarmode = 0 ;
G_UpdateScreenArea ( ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
nextpage ( ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
j = getticks ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( r_maxfps = = 0 | | j > = nextrender )
2006-04-13 20:47:06 +00:00
{
2010-08-02 08:13:51 +00:00
if ( j > nextrender + g_frameDelay )
nextrender = j ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
nextrender + = g_frameDelay ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
if ( ( ud . show_help = = 0 & & ( ! g_netServer & & ud . multimode < 2 ) & & ! ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) ) | |
( g_netServer | | ud . multimode > 1 ) | | ud . recstat = = 2 )
2012-09-08 22:18:40 +00:00
i = calc_smoothratio ( totalclock , ototalclock ) ;
2010-08-02 08:13:51 +00:00
else
i = 65536 ;
G_DrawRooms ( screenpeek , i ) ;
if ( getrendermode ( ) > = 3 )
G_DrawBackground ( ) ;
2011-12-08 03:56:38 +00:00
G_DisplayRest ( i ) ;
2010-08-02 08:13:51 +00:00
framewaiting + + ;
2006-04-13 20:47:06 +00:00
}
2011-02-25 21:50:19 +00:00
skipframe :
2010-08-02 08:13:51 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_DEMO )
goto MAIN_LOOP_RESTART ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
while ( 1 ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
G_GameExit ( " " ) ;
2010-10-17 14:49:39 +00:00
return 0 ; // not reached (duh)
2006-04-13 20:47:06 +00:00
}
2010-01-24 23:33:17 +00:00
GAME_STATIC GAME_INLINE int32_t G_MoveLoop ( )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
Net_GetPackets ( ) ;
2006-04-13 20:47:06 +00:00
2010-07-22 20:29:09 +00:00
return G_DoMoveThings ( ) ;
2006-04-13 20:47:06 +00:00
}
2010-08-02 08:13:51 +00:00
int32_t G_DoMoveThings ( void )
2006-04-13 20:47:06 +00:00
{
2011-03-04 08:50:58 +00:00
int32_t i ;
2006-04-13 20:47:06 +00:00
ud . camerasprite = - 1 ;
lockclock + = TICSPERFRAME ;
2012-08-06 20:00:31 +00:00
// Moved lower so it is restored correctly by demo diffs:
//if (g_earthquakeTime > 0) g_earthquakeTime--;
2008-11-20 14:06:36 +00:00
if ( g_RTSPlaying > 0 ) g_RTSPlaying - - ;
2006-04-13 20:47:06 +00:00
2009-02-19 16:47:54 +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 ] - - ;
2008-10-11 09:20:04 +00:00
if ( user_quote_time [ i ] > ud . msgdisptime )
user_quote_time [ i ] = ud . msgdisptime ;
2006-05-09 04:24:44 +00:00
if ( ! user_quote_time [ i ] ) pub = NUMPAGES ;
}
2012-08-19 13:02:43 +00:00
// Name display when aiming at opponents
if ( ud . idplayers & & ( g_netServer | | ud . multimode > 1 ) & & ! g_fakeMultiMode )
2006-05-09 04:24:44 +00:00
{
2012-08-10 19:12:01 +00:00
hitdata_t hit ;
2012-08-06 20:00:31 +00:00
DukePlayer_t * const p = g_player [ screenpeek ] . ps ;
2006-05-09 04:24:44 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
2007-08-27 06:46:31 +00:00
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
2012-08-06 20:00:31 +00:00
hitscan ( ( vec3_t * ) p , p - > cursectnum ,
sintable [ ( p - > ang + 512 ) & 2047 ] ,
sintable [ p - > ang & 2047 ] ,
2012-08-10 19:12:01 +00:00
( 100 - p - > horiz - p - > horizoff ) < < 11 , & hit , 0xffff0030 ) ;
2006-05-09 04:24:44 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
2007-08-27 06:46:31 +00:00
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
2012-08-10 19:12:01 +00:00
if ( ( hit . sprite > = 0 ) & & ! ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) & &
sprite [ hit . sprite ] . picnum = = APLAYER & & sprite [ hit . sprite ] . yvel ! = screenpeek & &
g_player [ sprite [ hit . sprite ] . yvel ] . ps - > dead_flag = = 0 )
2006-05-09 04:24:44 +00:00
{
2012-08-06 20:00:31 +00:00
if ( p - > fta = = 0 | | p - > ftq = = QUOTE_RESERVED3 )
2006-05-09 04:24:44 +00:00
{
2012-08-10 19:12:01 +00:00
if ( ldist ( & sprite [ p - > i ] , & sprite [ hit . sprite ] ) < 9216 )
2006-05-09 04:24:44 +00:00
{
2012-08-10 19:12:01 +00:00
Bsprintf ( ScriptQuotes [ QUOTE_RESERVED3 ] , " %s " , & g_player [ sprite [ hit . sprite ] . yvel ] . user_name [ 0 ] ) ;
2012-08-06 20:00:31 +00:00
p - > fta = 12 , p - > ftq = QUOTE_RESERVED3 ;
2006-05-09 04:24:44 +00:00
}
2006-11-15 01:16:55 +00:00
}
2012-08-06 20:00:31 +00:00
else if ( p - > fta > 2 ) p - > fta - = 3 ;
2006-05-09 04:24:44 +00:00
}
}
2008-11-20 14:06:36 +00:00
if ( g_showShareware > 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
g_showShareware - - ;
if ( g_showShareware = = 0 )
2006-04-13 20:47:06 +00:00
{
pus = NUMPAGES ;
pub = NUMPAGES ;
}
}
2012-08-16 21:48:21 +00:00
// Moved lower so it is restored correctly by diffs:
// everyothertime++;
2006-04-13 20:47:06 +00:00
2010-01-16 23:08:17 +00:00
if ( g_netServer | | g_netClient )
2009-12-05 09:22:43 +00:00
randomseed = ticrandomseed ;
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( i ) )
2012-08-06 20:00:31 +00:00
Bmemcpy ( g_player [ i ] . sync , & inputfifo [ ( g_netServer & & myconnectindex = = i ) ] [ i ] ,
2012-02-18 22:14:45 +00:00
sizeof ( input_t ) ) ;
2009-12-05 09:22:43 +00:00
2008-11-20 14:06:36 +00:00
G_UpdateInterpolations ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
/*
j = - 1 ;
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( i ) )
2006-11-15 01:16:55 +00:00
{
2010-08-02 08:13:51 +00:00
if ( g_player [ i ] . playerquitflag = = 0 | | TEST_SYNC_KEY ( g_player [ i ] . sync - > bits , SK_GAMEQUIT ) = = 0 )
{
j = i ;
continue ;
}
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
G_CloseDemoWrite ( ) ;
2006-04-13 20:47:06 +00:00
2010-08-02 08:13:51 +00:00
g_player [ i ] . playerquitflag = 0 ;
}
*/
2008-11-17 00:38:26 +00:00
2008-11-20 14:06:36 +00:00
g_moveThingsCount + + ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( ud . recstat = = 1 ) G_DemoRecord ( ) ;
2006-04-13 20:47:06 +00:00
2010-02-13 21:46:42 +00:00
everyothertime + + ;
if ( g_earthquakeTime > 0 ) g_earthquakeTime - - ;
2006-11-14 21:35:50 +00:00
if ( ud . pause_on = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
g_globalRandom = krand ( ) ;
A_MoveDummyPlayers ( ) ; //ST 13
2006-04-13 20:47:06 +00:00
}
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( 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 ;
2008-11-20 14:06:36 +00:00
if ( GametypeFlags [ ud . coop ] & GAMETYPE_TDM )
2006-08-31 19:05:23 +00:00
{
2010-05-02 23:27:30 +00:00
actor [ g_player [ i ] . ps - > i ] . picnum = APLAYERTOP ;
2008-11-20 14:06:36 +00:00
P_QuickKill ( g_player [ i ] . ps ) ;
2006-08-31 19:05:23 +00:00
}
2006-09-10 17:40:34 +00:00
}
2008-11-20 14:06:36 +00:00
if ( GametypeFlags [ ud . coop ] & GAMETYPE_TDM )
g_player [ i ] . ps - > palookup = g_player [ i ] . pcolor = G_GetTeamPalette ( 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
2012-05-15 23:39:48 +00:00
P_HandleSharedKeys ( 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
{
2010-05-04 23:40:49 +00:00
P_ProcessInput ( i ) ;
2009-02-28 07:44:54 +00:00
P_CheckSectors ( i ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-14 21:35:50 +00:00
if ( ud . pause_on = = 0 )
2008-11-20 14:06:36 +00:00
G_MoveWorld ( ) ;
2006-04-13 20:47:06 +00:00
2009-12-05 09:22:43 +00:00
// Net_CorrectPrediction();
2006-04-13 20:47:06 +00:00
2010-07-22 20:29:09 +00:00
if ( g_netServer )
2012-10-28 22:27:53 +00:00
Net_SendServerUpdates ( ) ;
2010-07-22 20:29:09 +00:00
2006-11-14 21:35:50 +00:00
if ( ( everyothertime & 1 ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
G_AnimateWalls ( ) ;
A_MoveCyclers ( ) ;
2010-07-22 20:29:09 +00:00
2012-10-28 22:27:53 +00:00
// Map updates are disabled for now
// if (g_netServer && (everyothertime % 10) == 0)
// Net_SendMapUpdate();
2010-01-05 21:53:14 +00:00
}
2010-01-16 23:08:17 +00:00
if ( g_netClient ) //Slave
2012-10-28 22:27:53 +00:00
Net_SendClientUpdate ( ) ;
2006-10-15 18:51:41 +00:00
2006-04-13 20:47:06 +00:00
return 0 ;
}
2008-11-20 14:06:36 +00:00
static void G_DoOrderScreen ( void )
2006-04-13 20:47:06 +00:00
{
2012-04-13 10:45:49 +00:00
int32_t i ;
2006-04-13 20:47:06 +00:00
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 1 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
2012-04-13 10:45:49 +00:00
for ( i = 0 ; i < 4 ; i + + )
{
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2012-04-13 10:45:49 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , ORDERING + i , 0 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
2012-06-03 16:11:22 +00:00
while ( ! I_CheckAllInput ( ) )
2012-04-13 10:45:49 +00:00
G_HandleAsync ( ) ;
}
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2006-04-13 20:47:06 +00:00
}
2012-04-04 18:56:16 +00:00
2009-01-09 09:29:17 +00:00
void G_BonusScreen ( int32_t bonusonly )
2006-04-13 20:47:06 +00:00
{
2011-10-17 18:42:10 +00:00
int32_t t , /*tinc,*/ gfx_offset ;
2009-01-09 09:29:17 +00:00
int32_t i , y , xfragtotal , yfragtotal ;
int32_t bonuscnt ;
int32_t clockpad = 2 ;
2006-04-13 20:47:06 +00:00
char * lastmapname ;
2009-01-09 09:29:17 +00:00
int32_t playerbest = - 1 ;
2006-10-23 21:47:28 +00:00
2009-01-09 09:29:17 +00:00
int32_t breathe [ ] =
2007-08-25 01:05:00 +00:00
{
2011-10-02 07:18:49 +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
2007-08-25 01:05:00 +00:00
} ;
2006-04-13 20:47:06 +00:00
2009-01-09 09:29:17 +00:00
int32_t bossmove [ ] =
2007-08-25 01:05:00 +00:00
{
2011-10-02 07:18:49 +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 ,
350 , 380 , VICTORY1 + 8 , 86 , 59 // duplicate row to alleviate overflow in the for loop below "boss"
2007-08-25 01:05:00 +00:00
} ;
2006-04-13 20:47:06 +00:00
2011-02-25 21:50:19 +00:00
if ( g_networkMode = = NET_DEDICATED_SERVER )
return ;
2010-05-07 20:45:40 +00:00
Bsprintf ( tempbuf , " %s - " APPNAME , g_gameNamePtr ) ;
2008-07-22 09:05:34 +00:00
wm_setapptitle ( tempbuf ) ;
2006-10-19 00:45:36 +00:00
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
}
2010-06-22 21:50:01 +00:00
else
{
lastmapname = MapInfo [ ( ud . volume_number * MAXLEVELS ) + ud . last_level - 1 ] . name ;
if ( ! lastmapname ) // this isn't right but it's better than no name at all
lastmapname = MapInfo [ ( ud . m_volume_number * MAXLEVELS ) + ud . last_level - 1 ] . name ;
}
2006-04-13 20:47:06 +00:00
bonuscnt = 0 ;
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
2006-04-13 20:47:06 +00:00
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-04-13 20:47:06 +00:00
nextpage ( ) ;
flushperms ( ) ;
FX_StopAllSounds ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
2006-04-13 20:47:06 +00:00
FX_SetReverb ( 0L ) ;
2012-11-17 16:47:47 +00:00
CONTROL_BindsEnabled = 1 ; // so you can use your screenshot bind on the score screens
2006-04-13 20:47:06 +00:00
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 )
{
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , ENDINGPAL , 8 + 2 + 1 ) ; // JBF 20040308
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 50 < < 16 , 65536L , 0 , VICTORY1 , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-16 03:02:42 +00:00
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 ) ;
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2006-11-16 03:02:42 +00:00
totalclock = 0 ;
2011-10-17 18:42:10 +00:00
// tinc = 0;
2006-11-16 03:02:42 +00:00
while ( 1 )
2006-04-13 20:47:06 +00:00
{
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 50 < < 16 , 65536L , 0 , VICTORY1 , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
// boss
if ( totalclock > 390 & & totalclock < 780 )
2009-02-19 16:47:54 +00:00
for ( t = 0 ; t < 35 ; t + = 5 ) if ( bossmove [ t + 2 ] & & ( totalclock % 390 ) > bossmove [ t ] & & ( totalclock % 390 ) < = bossmove [ t + 1 ] )
2006-11-16 03:02:42 +00:00
{
if ( t = = 10 & & bonuscnt = = 1 )
2006-11-15 01:16:55 +00:00
{
2008-11-20 14:06:36 +00:00
S_PlaySound ( SHOTGUN_FIRE ) ;
S_PlaySound ( SQUISHED ) ;
2006-11-16 03:02:42 +00:00
bonuscnt + + ;
2006-11-15 01:16:55 +00:00
}
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( bossmove [ t + 3 ] < < 16 , bossmove [ t + 4 ] < < 16 , 65536L , 0 , bossmove [ t + 2 ] , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-16 03:02:42 +00:00
}
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
{
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 86 < < 16 , 59 < < 16 , 65536L , 0 , VICTORY1 + 8 , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-16 03:02:42 +00:00
if ( totalclock > = 750 & & bonuscnt = = 2 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
S_PlaySound ( DUKETALKTOBOSS ) ;
2006-11-16 03:02:42 +00:00
bonuscnt + + ;
}
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
}
2009-02-19 16:47:54 +00:00
for ( t = 0 ; t < 20 ; t + = 5 )
2006-11-16 03:02:42 +00:00
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
{
2008-11-20 14:06:36 +00:00
S_PlaySound ( BOSSTALKTODUKE ) ;
2006-11-16 03:02:42 +00:00
bonuscnt + + ;
2006-11-15 01:16:55 +00:00
}
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( breathe [ t + 3 ] < < 16 , breathe [ t + 4 ] < < 16 , 65536L , 0 , breathe [ t + 2 ] , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
}
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
2012-06-03 16:11:22 +00:00
if ( I_CheckAllInput ( ) ) 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
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 1 ) ;
2006-04-13 20:47:06 +00:00
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
I_ClearInputWaiting ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 8 + 2 + 1 ) ; // JBF 20040308
2006-04-13 20:47:06 +00:00
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , 3292 , 0 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-05-02 23:27:30 +00:00
fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
2012-04-04 18:56:16 +00:00
handle_events_while_no_input ( ) ;
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 1 ) ;
2009-07-27 05:33:12 +00:00
S_StopMusic ( ) ;
2006-11-16 03:02:42 +00:00
FX_StopAllSounds ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
2006-11-16 03:02:42 +00:00
break ;
2012-04-04 18:56:16 +00:00
2006-11-16 03:02:42 +00:00
case 1 :
2009-07-27 05:33:12 +00:00
S_StopMusic ( ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
if ( ud . lockout = = 0 )
{
2008-11-20 14:06:36 +00:00
G_PlayAnim ( " cineov2.anm " , 1 ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-04-13 20:47:06 +00:00
nextpage ( ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
S_PlaySound ( PIPEBOMB_EXPLODE ) ;
2006-04-13 20:47:06 +00:00
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 1 ) ;
2006-11-16 03:02:42 +00:00
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 8 + 2 + 1 ) ; // JBF 20040308
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , 3293 , 0 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2010-05-02 23:27:30 +00:00
fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
2012-04-04 18:56:16 +00:00
handle_events_while_no_input ( ) ;
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 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 :
setview ( 0 , 0 , xdim - 1 , ydim - 1 ) ;
2006-04-13 20:47:06 +00:00
2009-07-27 05:33:12 +00:00
S_StopMusic ( ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ud . lockout = = 0 )
{
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2008-11-20 14:06:36 +00:00
G_PlayAnim ( " vol4e1.anm " , 8 ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
2008-11-20 14:06:36 +00:00
G_PlayAnim ( " vol4e2.anm " , 10 ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
2008-11-20 14:06:36 +00:00
G_PlayAnim ( " vol4e3.anm " , 11 ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-04-13 20:47:06 +00:00
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 ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
S_PlaySound ( ENDSEQVOL3SND4 ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
//g_player[myconnectindex].ps->palette = palette;
2012-04-04 18:57:20 +00:00
G_FadePalette ( 0 , 0 , 0 , 0 ) ;
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 8 + 2 + 1 ) ; // JBF 20040308
2012-04-04 18:57:20 +00:00
// G_FadePalette(0,0,0,63);
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2012-03-26 05:07:12 +00:00
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. " ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
fadepal ( 0 , 0 , 0 , 63 , 0 , - 3 ) ;
2012-04-04 18:57:20 +00:00
nextpage ( ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2012-04-04 18:56:16 +00:00
handle_events_while_no_input ( ) ;
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 3 ) ;
2006-04-13 20:47:06 +00:00
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
G_PlayAnim ( " DUKETEAM.ANM " , 4 ) ;
2006-11-16 03:02:42 +00:00
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2012-04-04 18:56:16 +00:00
handle_events_while_no_input ( ) ;
2006-11-16 03:02:42 +00:00
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
2010-05-02 23:27:30 +00:00
G_FadePalette ( 0 , 0 , 0 , 63 ) ;
2006-11-16 03:02:42 +00:00
FX_StopAllSounds ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
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 :
2009-07-27 05:33:12 +00:00
S_StopMusic ( ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-11-16 03:02:42 +00:00
nextpage ( ) ;
if ( ud . lockout = = 0 )
{
fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
2008-11-20 14:06:36 +00:00
G_PlayAnim ( " cineov3.anm " , 2 ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2006-11-16 03:02:42 +00:00
ototalclock = totalclock + 200 ;
while ( totalclock < ototalclock )
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2006-11-15 01:16:55 +00:00
nextpage ( ) ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
FX_StopAllSounds ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
G_PlayAnim ( " RADLOGO.ANM " , 3 ) ;
2006-11-15 01:16:55 +00:00
2012-06-03 16:11:22 +00:00
if ( ud . lockout = = 0 & & ! I_CheckInputWaiting ( ) )
2006-11-16 03:02:42 +00:00
{
2012-04-04 18:56:16 +00:00
if ( play_sound_while_no_input ( ENDSEQVOL3SND5 ) ) goto ENDANM ;
if ( play_sound_while_no_input ( ENDSEQVOL3SND6 ) ) goto ENDANM ;
if ( play_sound_while_no_input ( ENDSEQVOL3SND7 ) ) goto ENDANM ;
if ( play_sound_while_no_input ( ENDSEQVOL3SND8 ) ) goto ENDANM ;
if ( play_sound_while_no_input ( ENDSEQVOL3SND9 ) ) goto ENDANM ;
2006-11-16 03:02:42 +00:00
}
2012-04-04 18:56:16 +00:00
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2006-11-16 03:02:42 +00:00
totalclock = 0 ;
2012-03-04 09:29:05 +00:00
if ( PLUTOPAK )
2006-11-16 03:02:42 +00:00
{
2012-06-03 16:11:22 +00:00
while ( totalclock < 120 & & ! I_CheckInputWaiting ( ) )
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2012-03-04 09:29:05 +00:00
}
else
{
2012-04-04 18:56:16 +00:00
handle_events_while_no_input ( ) ;
2012-03-04 09:29:05 +00:00
}
2006-11-16 03:02:42 +00:00
2006-04-13 20:47:06 +00:00
ENDANM :
2012-03-04 09:29:05 +00:00
if ( ! PLUTOPAK )
{
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
S_PlaySound ( ENDSEQVOL3SND4 ) ;
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2012-03-04 09:29:05 +00:00
nextpage ( ) ;
G_PlayAnim ( " DUKETEAM.ANM " , 4 ) ;
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2012-04-04 18:56:16 +00:00
handle_events_while_no_input ( ) ;
2012-03-04 09:29:05 +00:00
2012-08-19 12:53:24 +00:00
clearallviews ( 0L ) ;
2012-03-04 09:29:05 +00:00
nextpage ( ) ;
G_FadePalette ( 0 , 0 , 0 , 63 ) ;
}
2012-06-03 16:11:22 +00:00
I_ClearInputWaiting ( ) ;
2006-11-16 03:02:42 +00:00
FX_StopAllSounds ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
2006-04-13 20:47:06 +00:00
2012-08-19 12:53:24 +00:00
clearallviews ( 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;
2012-09-24 21:09:31 +00:00
P_SetGamePalette ( g_player [ myconnectindex ] . ps , BASEPAL , 8 + 2 + 1 ) ; // JBF 20040308
2010-05-02 23:27:30 +00:00
G_FadePalette ( 0 , 0 , 0 , 63 ) ; // JBF 20031228
2006-04-13 20:47:06 +00:00
KB_FlushKeyboardQueue ( ) ;
2006-11-15 01:16:55 +00:00
totalclock = 0 ;
2011-10-17 18:42:10 +00:00
// tinc = 0;
2006-04-13 20:47:06 +00:00
bonuscnt = 0 ;
2009-07-27 05:33:12 +00:00
S_StopMusic ( ) ;
2006-04-13 20:47:06 +00:00
FX_StopAllSounds ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( playerswhenstarted > 1 & & ( GametypeFlags [ ud . coop ] & GAMETYPE_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 ) )
2008-11-20 14:06:36 +00:00
S_PlaySound ( BONUSMUSIC ) ;
2006-04-13 20:47:06 +00:00
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , MENUSCREEN , 16 , 0 , 2 + 8 + 16 + 64 + ( ud . bgstretch ? 1024 : 0 ) ) ;
rotatesprite_fs ( 160 < < 16 , 34 < < 16 , 65536L , 0 , INGAMEDUKETHREEDEE , 0 , 0 , 10 ) ;
2006-04-13 20:47:06 +00:00
if ( PLUTOPAK ) // JBF 20030804
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( ( 260 ) < < 16 , 36 < < 16 , 65536L , 0 , PLUTOPAKSPRITE + 2 , 0 , 0 , 2 + 8 ) ;
2012-03-26 05:07:12 +00:00
gametext ( 160 , 58 + 2 , " Multiplayer Totals " , 0 , 2 + 8 + 16 ) ;
2008-11-20 14:06:36 +00:00
gametext ( 160 , 58 + 10 , MapInfo [ ( ud . volume_number * MAXLEVELS ) + ud . last_level - 1 ] . name , 0 , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
2012-03-26 05:07:12 +00:00
gametext ( 160 , 165 , " Press any key or button to continue " , quotepulseshade , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
t = 0 ;
2012-03-26 05:07:12 +00:00
minitext ( 23 , 80 , " Name Kills " , 8 , 2 + 8 + 16 + 128 ) ;
2009-02-19 16:47:54 +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 ) ;
}
2009-02-19 16:47:54 +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
2009-02-19 16:47:54 +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
}
}
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 ;
}
2009-02-19 16:47:54 +00:00
for ( y = 0 ; y < playerswhenstarted ; y + + )
2006-04-13 20:47:06 +00:00
{
yfragtotal = 0 ;
2009-02-19 16:47:54 +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 ) ;
}
2012-03-26 05:07:12 +00:00
minitext ( 45 , 96 + ( 8 * 7 ) , " Deaths " , 8 , 2 + 8 + 16 + 128 ) ;
2006-04-13 20:47:06 +00:00
nextpage ( ) ;
fadepal ( 0 , 0 , 0 , 63 , 0 , - 7 ) ;
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2008-11-14 19:55:48 +00:00
2006-11-15 01:16:55 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t tc = totalclock ;
2012-06-03 16:11:22 +00:00
while ( I_CheckAllInput ( ) = = 0 )
2008-11-14 19:55:48 +00:00
{
2008-11-20 14:06:36 +00:00
// continue after 10 seconds...
if ( totalclock > tc + ( 120 * 10 ) ) break ;
2012-04-04 18:56:16 +00:00
G_HandleAsync ( ) ;
2008-11-14 19:55:48 +00:00
}
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2010-01-16 23:08:17 +00:00
if ( bonusonly | | ( g_netServer | | ud . multimode > 1 ) ) return ;
2006-04-13 20:47:06 +00:00
2012-04-04 18:56:50 +00:00
fadepal ( 0 , 0 , 0 , 0 , 63 , 7 ) ;
2006-04-13 20:47:06 +00:00
}
2010-01-16 23:08:17 +00:00
if ( bonusonly | | ( g_netServer | | 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
}
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , BONUSSCREEN + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-04-13 20:47:06 +00:00
2010-06-22 21:50:01 +00:00
if ( lastmapname )
menutext ( 160 , 20 - 6 , 0 , 0 , lastmapname ) ;
2012-03-26 05:07:12 +00:00
menutext ( 160 , 36 - 6 , 0 , 0 , " Completed " ) ;
2006-04-13 20:47:06 +00:00
2012-03-26 05:07:12 +00:00
gametext ( 160 , 192 , " Press any key or button to continue " , quotepulseshade , 2 + 8 + 16 ) ;
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 ) )
2008-11-20 14:06:36 +00:00
S_PlaySound ( BONUSMUSIC ) ;
2006-04-13 20:47:06 +00:00
nextpage ( ) ;
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
2006-04-13 20:47:06 +00:00
fadepal ( 0 , 0 , 0 , 63 , 0 , - 1 ) ;
bonuscnt = 0 ;
2006-11-15 01:16:55 +00:00
totalclock = 0 ;
2011-10-17 18:42:10 +00:00
// tinc = 0;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
playerbest = CONFIG_GetMapBestTime ( MapInfo [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . filename ) ;
2006-10-23 21:47:28 +00:00
2012-06-03 16:12:44 +00:00
if ( g_player [ myconnectindex ] . ps - > player_par > 0 & & ( g_player [ myconnectindex ] . ps - > player_par < playerbest | | playerbest < 0 ) )
2008-11-20 14:06:36 +00:00
CONFIG_SetMapBestTime ( MapInfo [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . filename , g_player [ myconnectindex ] . ps - > player_par ) ;
2006-10-23 21:47:28 +00:00
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t ii , ij ;
2006-04-13 20:47:06 +00:00
2010-05-02 23:27:30 +00:00
for ( ii = g_player [ myconnectindex ] . ps - > player_par / ( REALGAMETICSPERSEC * 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 ) )
{
2010-05-02 23:27:30 +00:00
for ( ii = MapInfo [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . partime / ( REALGAMETICSPERSEC * 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 )
{
2010-05-02 23:27:30 +00:00
for ( ii = MapInfo [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . designertime / ( REALGAMETICSPERSEC * 60 ) , ij = 1 ; ii > 9 ; ii / = 10 , ij + + ) ;
2006-10-24 03:13:45 +00:00
clockpad = max ( clockpad , ij ) ;
}
}
2010-05-02 23:27:30 +00:00
if ( playerbest > 0 ) for ( ii = playerbest / ( REALGAMETICSPERSEC * 60 ) , ij = 1 ; ii > 9 ; ii / = 10 , ij + + ) ;
2006-10-23 21:47:28 +00:00
clockpad = max ( clockpad , ij ) ;
2006-04-13 20:47:06 +00:00
}
2010-11-23 22:30:27 +00:00
do
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t yy = 0 , zz ;
2006-10-23 21:47:28 +00:00
2012-04-04 18:56:31 +00:00
G_HandleAsync ( ) ;
2009-07-27 10:46:42 +00:00
MUSIC_Update ( ) ;
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
{
2012-08-19 12:53:24 +00:00
clearallviews ( 0 ) ;
2012-04-04 18:57:06 +00:00
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 0 , 0 , 65536L , 0 , BONUSSCREEN + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-04-13 20:47:06 +00:00
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 + + ;
2008-11-20 14:06:36 +00:00
S_PlaySound ( SHOTGUN_COCK ) ;
2006-11-16 03:02:42 +00:00
switch ( rand ( ) & 3 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
2008-11-20 14:06:36 +00:00
S_PlaySound ( BONUS_SPEECH1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
2008-11-20 14:06:36 +00:00
S_PlaySound ( BONUS_SPEECH2 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
2008-11-20 14:06:36 +00:00
S_PlaySound ( BONUS_SPEECH3 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-11-20 14:06:36 +00:00
S_PlaySound ( BONUS_SPEECH4 ) ;
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 1 :
case 4 :
case 5 :
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 199 < < 16 , 31 < < 16 , 65536L , 0 , BONUSSCREEN + 3 + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
case 3 :
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 199 < < 16 , 31 < < 16 , 65536L , 0 , BONUSSCREEN + 4 + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-16 03:02:42 +00:00
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 :
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 199 < < 16 , 31 < < 16 , 65536L , 0 , BONUSSCREEN + 1 + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
2012-02-02 17:35:05 +00:00
rotatesprite_fs ( 199 < < 16 , 31 < < 16 , 65536L , 0 , BONUSSCREEN + 2 + gfx_offset , 0 , 0 , 2 + 8 + 16 + 64 + 128 + ( ud . bgstretch ? 1024 : 0 ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
2010-06-22 21:50:01 +00:00
if ( lastmapname )
menutext ( 160 , 20 - 6 , 0 , 0 , lastmapname ) ;
2012-03-26 05:07:12 +00:00
menutext ( 160 , 36 - 6 , 0 , 0 , " Completed " ) ;
2006-04-13 20:47:06 +00:00
2012-03-26 05:07:12 +00:00
gametext ( 160 , 192 , " Press any key or button to continue " , quotepulseshade , 2 + 8 + 16 ) ;
2006-04-13 20:47:06 +00:00
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 ;
2012-06-03 16:12:44 +00:00
2006-11-15 01:16:55 +00:00
gametext ( 10 , yy + 9 , " Your Time: " , 0 , 2 + 8 + 16 ) ;
2012-06-03 16:12:44 +00:00
2006-11-15 01:16:55 +00:00
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 )
{
2012-06-03 16:12:44 +00:00
gametext ( 10 , yy + 9 , ( g_player [ myconnectindex ] . ps - > player_par > 0 & & 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 + + ;
2008-11-20 14:06:36 +00:00
S_PlaySound ( PIPEBOMB_EXPLODE ) ;
2006-04-13 20:47:06 +00:00
}
2012-06-03 16:12:44 +00:00
if ( g_player [ myconnectindex ] . ps - > player_par > 0 )
{
Bsprintf ( tempbuf , " %0*d:%02d.%02d " , clockpad ,
( g_player [ myconnectindex ] . ps - > player_par / ( REALGAMETICSPERSEC * 60 ) ) ,
( g_player [ myconnectindex ] . ps - > player_par / REALGAMETICSPERSEC ) % 60 ,
( ( g_player [ myconnectindex ] . ps - > player_par % REALGAMETICSPERSEC ) * 33 ) / 10
) ;
gametext ( ( 320 > > 2 ) + 71 , yy + 9 , tempbuf , 0 , 2 + 8 + 16 ) ;
if ( g_player [ myconnectindex ] . ps - > player_par < playerbest )
gametext ( ( 320 > > 2 ) + 89 + ( clockpad * 24 ) , yy + 9 , " New record! " , 0 , 2 + 8 + 16 ) ;
}
else
gametextpalbits ( ( 320 > > 2 ) + 71 , yy + 9 , " Cheated! " , 0 , 2 , 2 + 8 + 16 ) ;
2006-10-24 03:13:45 +00:00
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 ) )
{
2007-12-12 17:42:14 +00:00
Bsprintf ( tempbuf , " %0*d:%02d " , clockpad ,
2010-05-02 23:27:30 +00:00
( MapInfo [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . partime / ( REALGAMETICSPERSEC * 60 ) ) ,
( MapInfo [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . partime / REALGAMETICSPERSEC ) % 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 )
{
2007-12-12 17:42:14 +00:00
Bsprintf ( tempbuf , " %0*d:%02d " , clockpad ,
2010-05-02 23:27:30 +00:00
( MapInfo [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . designertime / ( REALGAMETICSPERSEC * 60 ) ) ,
( MapInfo [ ud . volume_number * MAXLEVELS + ud . last_level - 1 ] . designertime / REALGAMETICSPERSEC ) % 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 )
{
2009-02-02 01:49:14 +00:00
Bsprintf ( tempbuf , " %0*d:%02d.%02d " , clockpad ,
2010-05-02 23:27:30 +00:00
( playerbest / ( REALGAMETICSPERSEC * 60 ) ) ,
( playerbest / REALGAMETICSPERSEC ) % 60 ,
( ( playerbest % REALGAMETICSPERSEC ) * 33 ) / 10
2009-02-19 09:39:19 +00:00
) ;
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 + + ;
2008-11-20 14:06:36 +00:00
S_PlaySound ( FLY_BY ) ;
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 * 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 + + ;
2008-11-20 14:06:36 +00:00
S_PlaySound ( PIPEBOMB_EXPLODE ) ;
2006-04-13 20:47:06 +00:00
}
2009-02-02 01:49:14 +00:00
Bsprintf ( tempbuf , " %-3d " , 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
{
2009-02-02 01:49:14 +00:00
Bsprintf ( 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 )
2009-02-02 01:49:14 +00:00
Bsprintf ( tempbuf , " %-3d " , 0 ) ;
else Bsprintf ( tempbuf , " %-3d " , 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 + + ;
2008-11-20 14:06:36 +00:00
S_PlaySound ( PIPEBOMB_EXPLODE ) ;
2006-04-13 20:47:06 +00:00
}
2009-02-02 01:49:14 +00:00
Bsprintf ( tempbuf , " %-3d " , 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 )
2009-02-02 01:49:14 +00:00
Bsprintf ( tempbuf , " %-3d%% " , ( 100 * g_player [ myconnectindex ] . ps - > secret_rooms / g_player [ myconnectindex ] . ps - > max_secret_rooms ) ) ;
Bsprintf ( tempbuf , " %-3d " , 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 ;
2012-06-03 16:11:22 +00:00
if ( I_CheckAllInput ( ) & & totalclock > ( 60 * 2 ) ) // JBF 20030809
2006-04-13 20:47:06 +00:00
{
2012-06-03 16:11:22 +00:00
I_ClearAllInput ( ) ;
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 ) ;
}
}
2010-11-23 22:30:27 +00:00
else
break ;
2012-05-16 00:45:10 +00:00
VM_OnEvent ( EVENT_DISPLAYBONUSSCREEN , g_player [ screenpeek ] . ps - > i , screenpeek , - 1 , 0 ) ;
2006-04-13 20:47:06 +00:00
nextpage ( ) ;
}
2010-11-23 22:30:27 +00:00
while ( 1 ) ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
static void G_DrawCameraText ( int16_t i )
2006-04-13 20:47:06 +00:00
{
char flipbits ;
2009-01-09 09:29:17 +00:00
int32_t x , y ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ! T1 )
2006-04-13 20:47:06 +00:00
{
2012-02-04 21:35:00 +00:00
rotatesprite_win ( 24 < < 16 , 33 < < 16 , 65536L , 0 , CAMCORNER , 0 , 0 , 2 ) ;
rotatesprite_win ( ( 320 - 26 ) < < 16 , 34 < < 16 , 65536L , 0 , CAMCORNER + 1 , 0 , 0 , 2 ) ;
rotatesprite_win ( 22 < < 16 , 163 < < 16 , 65536L , 512 , CAMCORNER + 1 , 0 , 0 , 2 + 4 ) ;
rotatesprite_win ( ( 310 - 10 ) < < 16 , 163 < < 16 , 65536L , 512 , CAMCORNER + 1 , 0 , 0 , 2 ) ;
2006-11-13 23:12:47 +00:00
if ( totalclock & 16 )
2012-02-04 21:35:00 +00:00
rotatesprite_win ( 46 < < 16 , 32 < < 16 , 65536L , 0 , CAMLIGHT , 0 , 0 , 2 ) ;
2006-04-13 20:47:06 +00:00
}
else
{
flipbits = ( totalclock < < 1 ) & 48 ;
2009-02-19 16:47:54 +00:00
for ( x = 0 ; x < 394 ; x + = 64 )
for ( y = 0 ; y < 200 ; y + = 64 )
2012-02-04 21:35:00 +00:00
rotatesprite_win ( x < < 16 , y < < 16 , 65536L , 0 , STATIC , 0 , 0 , 2 + flipbits ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-12-10 03:15:56 +00:00
#if 0
2009-01-09 09:29:17 +00:00
void vglass ( int32_t x , int32_t y , short a , short wn , short n )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t z , zincs ;
2006-04-13 20:47:06 +00:00
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
2009-02-19 16:47:54 +00:00
for ( z = sector [ sect ] . ceilingz ; z < sector [ sect ] . floorz ; z + = zincs )
2008-11-20 14:06:36 +00:00
A_InsertSprite ( sect , x , y , z - ( krand ( ) & 8191 ) , GLASSPIECES + ( z & ( krand ( ) % 3 ) ) , - 32 , 36 , 36 , a + 128 - ( krand ( ) & 255 ) , 16 + ( krand ( ) & 31 ) , 0 , - 1 , 5 ) ;
2006-04-13 20:47:06 +00:00
}
2006-12-10 03:15:56 +00:00
# endif
2006-04-13 20:47:06 +00:00
2009-01-09 09:29:17 +00:00
void A_SpawnWallGlass ( int32_t i , int32_t wallnum , int32_t n )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t j , xv , yv , z , x1 , y1 ;
int16_t sect ;
int32_t 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
{
2009-02-19 16:47:54 +00:00
for ( j = n - 1 ; j > = 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
a = SA - 256 + ( krand ( ) & 511 ) + 1024 ;
A_InsertSprite ( SECT , SX , SY , SZ , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , 32 + ( krand ( ) & 63 ) , 1024 - ( krand ( ) & 1023 ) , i , 5 ) ;
2006-04-13 20:47:06 +00:00
}
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 ;
2009-02-19 16:47:54 +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
{
2008-11-20 14:06:36 +00:00
z = sector [ sect ] . floorz - ( krand ( ) & ( klabs ( sector [ sect ] . ceilingz - sector [ sect ] . floorz ) ) ) ;
2006-11-14 21:35:50 +00:00
if ( z < - ( 32 < < 8 ) | | z > ( 32 < < 8 ) )
2008-11-20 14:06:36 +00:00
z = SZ - ( 32 < < 8 ) + ( krand ( ) & ( ( 64 < < 8 ) - 1 ) ) ;
2006-04-13 20:47:06 +00:00
a = SA - 1024 ;
2008-11-20 14:06:36 +00:00
A_InsertSprite ( SECT , x1 , y1 , z , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , 32 + ( krand ( ) & 63 ) , - ( krand ( ) & 1023 ) , i , 5 ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2009-01-09 09:29:17 +00:00
void A_SpawnGlass ( int32_t i , int32_t n )
2006-04-13 20:47:06 +00:00
{
2010-11-23 22:30:27 +00:00
for ( ; n > 0 ; n - - )
2006-04-13 20:47:06 +00:00
{
2010-11-23 22:30:27 +00:00
int32_t k = A_InsertSprite ( SECT , SX , SY , SZ - ( ( krand ( ) & 16 ) < < 8 ) , GLASSPIECES + ( n % 3 ) ,
2011-02-25 21:50:19 +00:00
krand ( ) & 15 , 36 , 36 , krand ( ) & 2047 , 32 + ( krand ( ) & 63 ) , - 512 - ( krand ( ) & 2047 ) , i , 5 ) ;
2006-04-13 20:47:06 +00:00
sprite [ k ] . pal = sprite [ i ] . pal ;
}
}
2009-01-09 09:29:17 +00:00
void A_SpawnCeilingGlass ( int32_t i , int32_t sectnum , int32_t n )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t j , xv , yv , z , x1 , y1 , a , s ;
int32_t startwall = sector [ sectnum ] . wallptr ;
int32_t endwall = startwall + sector [ sectnum ] . wallnum ;
2006-04-13 20:47:06 +00:00
2009-02-19 16:47:54 +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 ) ;
2009-02-19 16:47:54 +00:00
for ( j = n ; j > 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
x1 + = xv ;
y1 + = yv ;
2008-11-20 14:06:36 +00:00
a = krand ( ) & 2047 ;
z = sector [ sectnum ] . ceilingz + ( ( krand ( ) & 15 ) < < 8 ) ;
A_InsertSprite ( sectnum , x1 , y1 , z , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , ( krand ( ) & 31 ) , 0 , i , 5 ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2009-01-09 09:29:17 +00:00
void A_SpawnRandomGlass ( int32_t i , int32_t wallnum , int32_t n )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t j , xv , yv , z , x1 , y1 ;
int16_t sect = - 1 ;
int32_t 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
{
2009-02-19 16:47:54 +00:00
for ( j = n - 1 ; j > = 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
a = krand ( ) & 2047 ;
k = A_InsertSprite ( SECT , SX , SY , SZ - ( krand ( ) & ( 63 < < 8 ) ) , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , 32 + ( krand ( ) & 63 ) , 1024 - ( krand ( ) & 2047 ) , i , 5 ) ;
sprite [ k ] . pal = krand ( ) & 15 ;
2006-04-13 20:47:06 +00:00
}
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 ;
2009-02-19 16:47:54 +00:00
for ( j = n ; j > 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
x1 + = xv ;
y1 + = yv ;
updatesector ( x1 , y1 , & sect ) ;
2008-11-20 14:06:36 +00:00
z = sector [ sect ] . floorz - ( krand ( ) & ( klabs ( sector [ sect ] . ceilingz - sector [ sect ] . floorz ) ) ) ;
2006-11-14 21:35:50 +00:00
if ( z < - ( 32 < < 8 ) | | z > ( 32 < < 8 ) )
2008-11-20 14:06:36 +00:00
z = SZ - ( 32 < < 8 ) + ( krand ( ) & ( ( 64 < < 8 ) - 1 ) ) ;
2006-04-13 20:47:06 +00:00
a = SA - 1024 ;
2008-11-20 14:06:36 +00:00
k = A_InsertSprite ( SECT , x1 , y1 , z , GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , a , 32 + ( krand ( ) & 63 ) , - ( krand ( ) & 2047 ) , i , 5 ) ;
sprite [ k ] . pal = krand ( ) & 7 ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
static void G_SetupGameButtons ( void )
2006-04-13 20:47:06 +00:00
{
2009-04-26 05:57:42 +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 ) ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
int32_t GetTime ( void )
2006-04-13 20:47:06 +00:00
{
return totalclock ;
}