2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
2007-02-08 04:19:39 +00:00
Copyright ( C ) 1996 , 2003 - 3 D Realms Entertainment
Copyright ( C ) 2000 , 2003 - Matt Saettler ( EDuke Enhancements )
Copyright ( C ) 2004 , 2007 - EDuke32 developers
2006-04-13 20:47:06 +00:00
This file is part of EDuke32
EDuke32 is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
//-------------------------------------------------------------------------
2006-12-21 12:53:11 +00:00
# include "compat.h"
2006-04-13 20:47:06 +00:00
# include "osdcmds.h"
# include "osd.h"
# include "baselayer.h"
# include "duke3d.h"
# include "crc32.h"
# include <ctype.h>
2008-06-30 07:30:48 +00:00
extern int voting , doquicksave ;
2006-04-13 20:47:06 +00:00
struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat ;
2006-12-14 03:34:55 +00:00
static inline int osdcmd_quit ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( parm ) ;
2006-04-20 22:18:56 +00:00
sendquit ( ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_echo ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
int i ;
2006-11-15 01:16:55 +00:00
for ( i = 0 ; i < parm - > numparms ; i + + )
{
2006-04-13 20:47:06 +00:00
if ( i > 0 ) OSD_Printf ( " " ) ;
OSD_Printf ( " %s " , parm - > parms [ i ] ) ;
}
OSD_Printf ( " \n " ) ;
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_changelevel ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
2006-04-22 22:33:52 +00:00
int volume = 0 , level ;
2006-04-13 20:47:06 +00:00
char * p ;
2006-11-15 01:16:55 +00:00
if ( ! VOLUMEONE )
{
2006-04-13 20:47:06 +00:00
if ( parm - > numparms ! = 2 ) return OSDCMD_SHOWHELP ;
volume = strtol ( parm - > parms [ 0 ] , & p , 10 ) - 1 ;
if ( p [ 0 ] ) return OSDCMD_SHOWHELP ;
level = strtol ( parm - > parms [ 1 ] , & p , 10 ) - 1 ;
if ( p [ 0 ] ) return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-04-13 20:47:06 +00:00
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
level = strtol ( parm - > parms [ 0 ] , & p , 10 ) - 1 ;
if ( p [ 0 ] ) return OSDCMD_SHOWHELP ;
}
if ( volume < 0 ) return OSDCMD_SHOWHELP ;
if ( level < 0 ) return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
if ( ! VOLUMEONE )
{
if ( volume > num_volumes )
{
2007-12-12 17:42:14 +00:00
OSD_Printf ( " changelevel: invalid volume number (range 1-%d) \n " , num_volumes ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
}
2007-08-27 06:46:31 +00:00
if ( level > MAXLEVELS | | map [ volume * MAXLEVELS + level ] . filename = = NULL )
2006-11-15 01:16:55 +00:00
{
2007-08-27 06:46:31 +00:00
OSD_Printf ( " changelevel: invalid level number \n " ) ;
return OSDCMD_SHOWHELP ;
2006-04-13 20:47:06 +00:00
}
2006-12-12 08:33:11 +00:00
if ( numplayers > 1 )
{
if ( myconnectindex = = connecthead & & networkmode = = 0 )
2006-12-12 08:46:32 +00:00
mpchangemap ( volume , level ) ;
2006-12-12 08:33:11 +00:00
else if ( voting = = - 1 )
{
ud . m_volume_number = volume ;
ud . m_level_number = level ;
2007-01-26 05:16:10 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > i )
2006-12-12 08:33:11 +00:00
{
int i ;
2007-01-26 05:16:10 +00:00
2007-08-27 06:46:31 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
{
g_player [ i ] . vote = 0 ;
g_player [ i ] . gotvote = 0 ;
}
g_player [ myconnectindex ] . vote = g_player [ myconnectindex ] . gotvote = 1 ;
2006-12-12 08:33:11 +00:00
voting = myconnectindex ;
tempbuf [ 0 ] = 18 ;
tempbuf [ 1 ] = 1 ;
tempbuf [ 2 ] = myconnectindex ;
tempbuf [ 3 ] = ud . m_volume_number ;
tempbuf [ 4 ] = ud . m_level_number ;
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
{
if ( i ! = myconnectindex ) sendpacket ( i , tempbuf , 5 ) ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
}
if ( ( gametype_flags [ ud . m_coop ] & GAMETYPE_FLAG_PLAYERSFRIENDLY ) & & ! ( gametype_flags [ ud . m_coop ] & GAMETYPE_FLAG_TDM ) )
ud . m_noexits = 0 ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-12-12 08:33:11 +00:00
cmenu ( 603 ) ;
}
return OSDCMD_OK ;
}
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
// in-game behave like a cheat
osdcmd_cheatsinfo_stat . cheatnum = 2 ;
osdcmd_cheatsinfo_stat . volume = volume ;
osdcmd_cheatsinfo_stat . level = level ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-04-13 20:47:06 +00:00
// out-of-game behave like a menu command
osdcmd_cheatsinfo_stat . cheatnum = - 1 ;
ud . m_volume_number = volume ;
ud . m_level_number = level ;
ud . m_monsters_off = ud . monsters_off = 0 ;
ud . m_respawn_items = 0 ;
ud . m_respawn_inventory = 0 ;
ud . multimode = 1 ;
newgame ( ud . m_volume_number , ud . m_level_number , ud . m_player_skill ) ;
if ( enterlevel ( MODE_GAME ) ) backtomenu ( ) ;
}
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_map ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
int i ;
char filename [ 256 ] ;
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
2006-12-12 08:33:11 +00:00
#if 0
2006-12-04 04:08:14 +00:00
if ( numplayers > 1 )
{
OSD_Printf ( " Command not allowed in multiplayer \n " ) ;
return OSDCMD_OK ;
}
2006-12-12 08:33:11 +00:00
# endif
strcpy ( filename , parm - > parms [ 0 ] ) ;
2006-11-14 21:35:50 +00:00
if ( strchr ( filename , ' . ' ) = = 0 )
2006-04-13 20:47:06 +00:00
strcat ( filename , " .map " ) ;
2006-11-15 01:16:55 +00:00
if ( ( i = kopen4load ( filename , 0 ) ) < 0 )
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " map: file \" %s \" not found. \n " , filename ) ;
return OSDCMD_OK ;
}
kclose ( i ) ;
2006-12-12 08:33:11 +00:00
boardfilename [ 0 ] = ' / ' ;
boardfilename [ 1 ] = 0 ;
strcat ( boardfilename , filename ) ;
if ( numplayers > 1 )
{
if ( myconnectindex = = connecthead & & networkmode = = 0 )
{
sendboardname ( ) ;
2007-01-26 05:16:10 +00:00
mpchangemap ( 0 , 7 ) ;
2006-12-12 08:33:11 +00:00
}
else if ( voting = = - 1 )
{
sendboardname ( ) ;
2007-01-26 05:16:10 +00:00
2006-12-12 08:33:11 +00:00
ud . m_volume_number = 0 ;
ud . m_level_number = 7 ;
2007-01-26 05:16:10 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > i )
2006-12-12 08:33:11 +00:00
{
int i ;
2007-01-26 05:16:10 +00:00
2007-08-27 06:46:31 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
{
g_player [ i ] . vote = 0 ;
g_player [ i ] . gotvote = 0 ;
}
g_player [ myconnectindex ] . vote = g_player [ myconnectindex ] . gotvote = 1 ;
2006-12-12 08:33:11 +00:00
voting = myconnectindex ;
tempbuf [ 0 ] = 18 ;
tempbuf [ 1 ] = 1 ;
tempbuf [ 2 ] = myconnectindex ;
tempbuf [ 3 ] = ud . m_volume_number ;
tempbuf [ 4 ] = ud . m_level_number ;
for ( i = connecthead ; i > = 0 ; i = connectpoint2 [ i ] )
{
if ( i ! = myconnectindex ) sendpacket ( i , tempbuf , 5 ) ;
if ( ( ! networkmode ) & & ( myconnectindex ! = connecthead ) ) break ; //slaves in M/S mode only send to master
}
}
if ( ( gametype_flags [ ud . m_coop ] & GAMETYPE_FLAG_PLAYERSFRIENDLY ) & & ! ( gametype_flags [ ud . m_coop ] & GAMETYPE_FLAG_TDM ) )
ud . m_noexits = 0 ;
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_MENU ;
2006-12-12 08:33:11 +00:00
cmenu ( 603 ) ;
}
return OSDCMD_OK ;
}
2006-04-13 20:47:06 +00:00
2007-01-26 05:16:10 +00:00
osdcmd_cheatsinfo_stat . cheatnum = - 1 ;
ud . m_volume_number = 0 ;
ud . m_level_number = 7 ;
2006-12-12 07:25:01 +00:00
2007-01-26 05:16:10 +00:00
ud . m_monsters_off = ud . monsters_off = 0 ;
2006-04-13 20:47:06 +00:00
2007-01-26 05:16:10 +00:00
ud . m_respawn_items = 0 ;
ud . m_respawn_inventory = 0 ;
2006-04-13 20:47:06 +00:00
2007-01-26 05:16:10 +00:00
ud . multimode = 1 ;
2006-04-13 20:47:06 +00:00
2007-01-26 05:16:10 +00:00
newgame ( ud . m_volume_number , ud . m_level_number , ud . m_player_skill ) ;
if ( enterlevel ( MODE_GAME ) ) backtomenu ( ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_god ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( parm ) ;
2007-08-27 06:46:31 +00:00
if ( numplayers = = 1 & & g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
osdcmd_cheatsinfo_stat . cheatnum = 0 ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " god: Not in a single-player game. \n " ) ;
}
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_noclip ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( parm ) ;
2007-08-27 06:46:31 +00:00
if ( numplayers = = 1 & & g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
osdcmd_cheatsinfo_stat . cheatnum = 20 ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " noclip: Not in a single-player game. \n " ) ;
}
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_fileinfo ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
unsigned int crc , length ;
2006-04-13 20:47:06 +00:00
int i , j ;
char buf [ 256 ] ;
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
if ( ( i = kopen4load ( ( char * ) parm - > parms [ 0 ] , 0 ) ) < 0 )
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " fileinfo: File \" %s \" not found. \n " , parm - > parms [ 0 ] ) ;
return OSDCMD_OK ;
}
length = kfilelength ( i ) ;
crc32init ( & crc ) ;
2006-11-15 01:16:55 +00:00
do
{
2006-04-13 20:47:06 +00:00
j = kread ( i , buf , 256 ) ;
2006-11-18 08:13:33 +00:00
crc32block ( & crc , ( unsigned char * ) buf , j ) ;
2006-11-15 01:16:55 +00:00
}
while ( j = = 256 ) ;
2006-04-13 20:47:06 +00:00
crc32finish ( & crc ) ;
kclose ( i ) ;
OSD_Printf ( " fileinfo: %s \n "
" File size: %d \n "
" CRC-32: %08X \n " ,
parm - > parms [ 0 ] , length , crc ) ;
return OSDCMD_OK ;
}
2007-01-24 21:24:35 +00:00
static int osdcmd_rate ( const osdfuncparm_t * parm )
{
int i ;
2007-01-26 05:16:10 +00:00
2007-01-24 21:24:35 +00:00
if ( parm - > numparms = = 0 )
{
OSD_Printf ( " \" rate \" is \" %d \" \n " , packetrate ) ;
return OSDCMD_SHOWHELP ;
}
else if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
i = Batol ( parm - > parms [ 0 ] ) ;
if ( i > = 40 & & i < = 1000 )
{
packetrate = i ;
OSD_Printf ( " rate %d \n " , packetrate ) ;
}
else OSD_Printf ( " rate: value out of range \n " ) ;
return OSDCMD_OK ;
}
2007-01-26 05:16:10 +00:00
static int osdcmd_restartsound ( const osdfuncparm_t * parm )
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( parm ) ;
2007-01-26 05:16:10 +00:00
SoundShutdown ( ) ;
MusicShutdown ( ) ;
initprintf ( " Checking music inits... \n " ) ;
MusicStartup ( ) ;
initprintf ( " Checking sound inits... \n " ) ;
SoundStartup ( ) ;
FX_StopAllSounds ( ) ;
clearsoundlocks ( ) ;
2007-08-27 00:20:15 +00:00
if ( ud . config . MusicToggle = = 1 )
2007-02-13 01:28:50 +00:00
{
2007-08-27 06:46:31 +00:00
if ( ud . recstat ! = 2 & & g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
2007-02-13 01:28:50 +00:00
{
2007-08-26 11:28:32 +00:00
if ( map [ ( unsigned char ) music_select ] . musicfn ! = NULL )
2008-04-01 09:06:29 +00:00
playmusic ( & map [ ( unsigned char ) music_select ] . musicfn [ 0 ] , music_select ) ;
2007-02-13 01:28:50 +00:00
}
2008-04-01 09:06:29 +00:00
else playmusic ( & env_music_fn [ 0 ] [ 0 ] , MAXVOLUMES * MAXLEVELS ) ;
2007-02-13 01:28:50 +00:00
}
2007-01-26 05:16:10 +00:00
return OSDCMD_OK ;
}
2006-04-13 20:47:06 +00:00
static int osdcmd_restartvid ( const osdfuncparm_t * parm )
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( parm ) ;
2006-04-13 20:47:06 +00:00
resetvideomode ( ) ;
2007-08-27 00:20:15 +00:00
if ( setgamemode ( ud . config . ScreenMode , ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP ) )
2006-04-13 20:47:06 +00:00
gameexit ( " restartvid: Reset failed... \n " ) ;
2007-08-27 00:20:15 +00:00
onvideomodechange ( ud . config . ScreenBPP > 8 ) ;
2006-04-13 20:47:06 +00:00
vscrn ( ) ;
return OSDCMD_OK ;
}
static int osdcmd_vidmode ( const osdfuncparm_t * parm )
{
2007-08-27 00:20:15 +00:00
int newbpp = ud . config . ScreenBPP , newwidth = ud . config . ScreenWidth ,
newheight = ud . config . ScreenHeight , newfs = ud . config . ScreenMode ;
2006-04-13 20:47:06 +00:00
if ( parm - > numparms < 1 | | parm - > numparms > 4 ) return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
switch ( parm - > numparms )
{
2006-11-16 03:02:42 +00:00
case 1 : // bpp switch
newbpp = Batol ( parm - > parms [ 0 ] ) ;
break ;
case 2 : // res switch
newwidth = Batol ( parm - > parms [ 0 ] ) ;
newheight = Batol ( parm - > parms [ 1 ] ) ;
break ;
case 3 : // res & bpp switch
case 4 :
newwidth = Batol ( parm - > parms [ 0 ] ) ;
newheight = Batol ( parm - > parms [ 1 ] ) ;
newbpp = Batol ( parm - > parms [ 2 ] ) ;
if ( parm - > numparms = = 4 )
newfs = ( Batol ( parm - > parms [ 3 ] ) ! = 0 ) ;
break ;
2006-11-15 01:16:55 +00:00
}
if ( setgamemode ( newfs , newwidth , newheight , newbpp ) )
{
2006-04-13 20:47:06 +00:00
initprintf ( " vidmode: Mode change failed! \n " ) ;
2007-08-27 00:20:15 +00:00
if ( setgamemode ( ud . config . ScreenMode , ud . config . ScreenWidth , ud . config . ScreenHeight , ud . config . ScreenBPP ) )
2006-04-13 20:47:06 +00:00
gameexit ( " vidmode: Reset failed! \n " ) ;
}
2007-08-27 00:20:15 +00:00
ud . config . ScreenBPP = newbpp ;
ud . config . ScreenWidth = newwidth ;
ud . config . ScreenHeight = newheight ;
ud . config . ScreenMode = newfs ;
onvideomodechange ( ud . config . ScreenBPP > 8 ) ;
2006-04-13 20:47:06 +00:00
vscrn ( ) ;
return OSDCMD_OK ;
}
static int osdcmd_setstatusbarscale ( const osdfuncparm_t * parm )
{
2006-11-15 01:16:55 +00:00
if ( parm - > numparms = = 0 )
{
2006-04-30 21:14:12 +00:00
OSD_Printf ( " \" cl_statusbarscale \" is \" %d \" \n " , ud . statusbarscale ) ;
return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
}
else if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
2006-04-13 20:47:06 +00:00
setstatusbarscale ( Batol ( parm - > parms [ 0 ] ) ) ;
2006-04-30 21:14:12 +00:00
OSD_Printf ( " cl_statusbarscale %d \n " , ud . statusbarscale ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
static int osdcmd_spawn ( const osdfuncparm_t * parm )
{
2007-12-12 17:42:14 +00:00
int x = 0 , y = 0 , z = 0 ;
2006-04-13 20:47:06 +00:00
unsigned short cstat = 0 , picnum = 0 ;
unsigned char pal = 0 ;
short ang = 0 ;
short set = 0 , idx ;
2007-08-27 06:46:31 +00:00
if ( numplayers > 1 | | ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " spawn: Can't spawn sprites in multiplayer games or demos \n " ) ;
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
switch ( parm - > numparms )
{
2006-11-16 03:02:42 +00:00
case 7 : // x,y,z
x = Batol ( parm - > parms [ 4 ] ) ;
y = Batol ( parm - > parms [ 5 ] ) ;
z = Batol ( parm - > parms [ 6 ] ) ;
set | = 8 ;
case 4 : // ang
ang = Batol ( parm - > parms [ 3 ] ) & 2047 ;
set | = 4 ;
case 3 : // cstat
cstat = ( unsigned short ) Batol ( parm - > parms [ 2 ] ) ;
set | = 2 ;
case 2 : // pal
pal = ( unsigned char ) Batol ( parm - > parms [ 1 ] ) ;
set | = 1 ;
case 1 : // tile number
if ( isdigit ( parm - > parms [ 0 ] [ 0 ] ) )
{
picnum = ( unsigned short ) Batol ( parm - > parms [ 0 ] ) ;
}
else
{
int i , j ;
for ( j = 0 ; j < 2 ; j + + )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
for ( i = 0 ; i < labelcnt ; i + + )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
if (
( j = = 0 & & ! Bstrcmp ( label + ( i < < 6 ) , parm - > parms [ 0 ] ) ) | |
( j = = 1 & & ! Bstrcasecmp ( label + ( i < < 6 ) , parm - > parms [ 0 ] ) )
)
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
picnum = ( unsigned short ) labelcode [ i ] ;
break ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
if ( i < labelcnt ) break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
if ( i = = labelcnt )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
OSD_Printf ( " spawn: Invalid tile label given \n " ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2006-11-16 03:02:42 +00:00
}
if ( picnum > = MAXTILES )
{
OSD_Printf ( " spawn: Invalid tile number \n " ) ;
return OSDCMD_OK ;
}
break ;
default :
return OSDCMD_SHOWHELP ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 06:46:31 +00:00
idx = spawn ( g_player [ myconnectindex ] . ps - > i , ( short ) picnum ) ;
2006-04-13 20:47:06 +00:00
if ( set & 1 ) sprite [ idx ] . pal = ( char ) pal ;
if ( set & 2 ) sprite [ idx ] . cstat = ( short ) cstat ;
if ( set & 4 ) sprite [ idx ] . ang = ang ;
2006-11-15 01:16:55 +00:00
if ( set & 8 )
{
if ( setsprite ( idx , x , y , z ) < 0 )
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " spawn: Sprite can't be spawned into null space \n " ) ;
deletesprite ( idx ) ;
}
}
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_setvar ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
int i , varval ;
char varname [ 256 ] ;
if ( parm - > numparms ! = 2 ) return OSDCMD_SHOWHELP ;
2006-12-04 04:08:14 +00:00
if ( numplayers > 1 )
2006-04-13 20:47:06 +00:00
{
OSD_Printf ( " Command not allowed in multiplayer \n " ) ;
return OSDCMD_OK ;
}
2007-12-20 19:14:38 +00:00
strcpy ( varname , parm - > parms [ 1 ] ) ;
varval = Batol ( varname ) ;
for ( i = 0 ; i < iGameVarCount ; i + + )
if ( aGameVars [ i ] . szLabel ! = NULL )
if ( Bstrcmp ( varname , aGameVars [ i ] . szLabel ) = = 0 )
varval = GetGameVarID ( i , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
2007-12-20 19:14:38 +00:00
strcpy ( varname , parm - > parms [ 0 ] ) ;
2006-11-13 23:12:47 +00:00
for ( i = 0 ; i < iGameVarCount ; i + + )
if ( aGameVars [ i ] . szLabel ! = NULL )
if ( Bstrcmp ( varname , aGameVars [ i ] . szLabel ) = = 0 )
2007-08-27 06:46:31 +00:00
SetGameVarID ( i , varval , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-15 03:12:08 +00:00
return OSDCMD_OK ;
2006-04-16 03:42:36 +00:00
}
2006-04-15 03:12:08 +00:00
2007-12-20 19:14:38 +00:00
static int osdcmd_setactorvar ( const osdfuncparm_t * parm )
{
int i , varval , ID ;
char varname [ 256 ] ;
if ( parm - > numparms ! = 3 ) return OSDCMD_SHOWHELP ;
if ( numplayers > 1 )
{
OSD_Printf ( " Command not allowed in multiplayer \n " ) ;
return OSDCMD_OK ;
}
ID = Batol ( parm - > parms [ 0 ] ) ;
if ( ID > = MAXSPRITES )
{
OSD_Printf ( " Invalid sprite ID \n " ) ;
return OSDCMD_OK ;
}
varval = Batol ( parm - > parms [ 2 ] ) ;
strcpy ( varname , parm - > parms [ 2 ] ) ;
varval = Batol ( varname ) ;
for ( i = 0 ; i < iGameVarCount ; i + + )
if ( aGameVars [ i ] . szLabel ! = NULL )
if ( Bstrcmp ( varname , aGameVars [ i ] . szLabel ) = = 0 )
varval = GetGameVarID ( i , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
strcpy ( varname , parm - > parms [ 1 ] ) ;
for ( i = 0 ; i < iGameVarCount ; i + + )
if ( aGameVars [ i ] . szLabel ! = NULL )
if ( Bstrcmp ( varname , aGameVars [ i ] . szLabel ) = = 0 )
SetGameVarID ( i , varval , ID , - 1 ) ;
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_addpath ( const osdfuncparm_t * parm )
2006-04-15 03:12:08 +00:00
{
char pathname [ BMAX_PATH ] ;
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
strcpy ( pathname , parm - > parms [ 0 ] ) ;
addsearchpath ( pathname ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_initgroupfile ( const osdfuncparm_t * parm )
2006-05-23 23:43:18 +00:00
{
char file [ BMAX_PATH ] ;
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
strcpy ( file , parm - > parms [ 0 ] ) ;
initgroupfile ( file ) ;
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_cmenu ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
if ( numplayers > 1 )
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " cmenu: disallowed in multiplayer \n " ) ;
return OSDCMD_OK ;
2006-11-15 01:16:55 +00:00
}
else
{
2006-04-13 20:47:06 +00:00
cmenu ( Batol ( parm - > parms [ 0 ] ) ) ;
}
return OSDCMD_OK ;
}
2008-06-30 01:03:51 +00:00
cvarmappings cvar [ ] =
2007-08-25 01:05:00 +00:00
{
{ " crosshair " , " crosshair: enable/disable crosshair " , ( void * ) & ud . crosshair , CVAR_INT , 0 , 0 , 3 } ,
2006-05-05 01:20:19 +00:00
2008-06-30 01:03:51 +00:00
{ " cl_autoaim " , " cl_autoaim: enable/disable weapon autoaim " , ( void * ) & ud . config . AutoAim , CVAR_INT | CVAR_MULTI , 0 , 0 , 2 } ,
2007-08-25 01:05:00 +00:00
{ " cl_automsg " , " cl_automsg: enable/disable automatically sending messages to all players " , ( void * ) & ud . automsg , CVAR_BOOL , 0 , 0 , 1 } ,
2008-06-30 01:03:51 +00:00
{ " cl_autovote " , " cl_autovote: enable/disable automatic voting " , ( void * ) & ud . autovote , CVAR_INT | CVAR_MULTI , 0 , 0 , 2 } ,
2006-05-05 01:20:19 +00:00
2007-03-24 23:17:56 +00:00
2007-08-25 01:05:00 +00:00
{ " cl_deathmessages " , " cl_deathmessages: enable/disable multiplayer death messages " , ( void * ) & ud . deathmsgs , CVAR_BOOL , 0 , 0 , 1 } ,
{ " cl_democams " , " cl_democams: enable/disable demo playback cameras " , ( void * ) & ud . democams , CVAR_BOOL , 0 , 0 , 1 } ,
2006-05-05 01:20:19 +00:00
2007-08-25 01:05:00 +00:00
{ " cl_idplayers " , " cl_idplayers: enable/disable name display when aiming at opponents " , ( void * ) & ud . idplayers , CVAR_BOOL , 0 , 0 , 1 } ,
2006-05-05 22:39:34 +00:00
2007-08-25 01:05:00 +00:00
{ " cl_messagetime " , " cl_messagetime: length of time to display multiplayer chat messages \n " , ( void * ) & ud . msgdisptime , CVAR_INT , 0 , 0 , 3600 } ,
2006-05-05 01:20:19 +00:00
2007-08-25 01:05:00 +00:00
{ " cl_showcoords " , " cl_showcoords: show your position in the game world " , ( void * ) & ud . coords , CVAR_BOOL , 0 , 0 , 1 } ,
2007-02-26 01:46:38 +00:00
2007-08-25 01:05:00 +00:00
{ " cl_viewbob " , " cl_viewbob: enable/disable player head bobbing \n " , ( void * ) & ud . viewbob , CVAR_BOOL , 0 , 0 , 1 } ,
2006-05-05 01:20:19 +00:00
2007-08-25 01:05:00 +00:00
{ " cl_weaponsway " , " cl_weaponsway: enable/disable player weapon swaying \n " , ( void * ) & ud . weaponsway , CVAR_BOOL , 0 , 0 , 1 } ,
2008-06-30 01:03:51 +00:00
{ " cl_weaponswitch " , " cl_weaponswitch: enable/disable auto weapon switching " , ( void * ) & ud . weaponswitch , CVAR_INT | CVAR_MULTI , 0 , 0 , 3 } ,
2007-08-25 01:05:00 +00:00
{ " cl_angleinterpolation " , " cl_angleinterpolation: enable/disable angle interpolation " , ( void * ) & ud . angleinterpolation , CVAR_INT , 0 , 0 , 256 } ,
2008-07-02 04:56:42 +00:00
{ " in_mousebias " , " in_mousebias: emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time \n " , ( void * ) & ud . config . MouseBias , CVAR_INT , 0 , 0 , 32 } ,
{ " in_mousefilter " , " in_mousefilter: amount of mouse movement to filter out \n " , ( void * ) & ud . config . MouseFilter , CVAR_INT , 0 , 0 , 512 } ,
{ " in_smoothinput " , " in_smoothinput: enable/disable input smoothing \n " , ( void * ) & ud . config . SmoothInput , CVAR_BOOL , 0 , 0 , 1 } ,
2006-05-22 07:11:30 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2007-08-25 01:05:00 +00:00
{ " r_anamorphic " , " r_anamorphic: enable/disable widescreen mode " , ( void * ) & glwidescreen , CVAR_BOOL , 0 , 0 , 1 } ,
{ " r_projectionhack " , " r_projectionhack: enable/disable projection hack " , ( void * ) & glprojectionhacks , CVAR_BOOL , 0 , 0 , 1 } ,
2008-05-10 01:29:37 +00:00
# ifdef POLYMER
2007-08-25 01:05:00 +00:00
// polymer cvars
2008-04-02 09:29:58 +00:00
{ " pr_occlusionculling " , " pr_occlusionculling: insert description that noone will ever read " , ( void * ) & pr_occlusionculling , CVAR_INT , 0 , 0 , 512 } ,
2007-08-25 01:05:00 +00:00
{ " pr_fov " , " pr_fov: sets the field of vision in build angle " , ( void * ) & pr_fov , CVAR_INT , 0 , 0 , 1023 } ,
2008-04-04 08:07:11 +00:00
{ " pr_billboardingmode " , " pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode " , ( void * ) & pr_billboardingmode , CVAR_INT , 0 , 0 , 1 } ,
2007-08-25 01:05:00 +00:00
{ " pr_verbosity " , " pr_verbosity: verbosity level of the polymer renderer " , ( void * ) & pr_verbosity , CVAR_INT , 0 , 0 , 3 } ,
{ " pr_wireframe " , " pr_wireframe: toggles wireframe mode " , ( void * ) & pr_wireframe , CVAR_INT , 0 , 0 , 1 } ,
2008-05-24 09:37:09 +00:00
{ " pr_vbos " , " pr_vbos: contols Vertex Buffer Object usage. 0: no VBOs. 1: VBOs for map data. 2: VBOs for model data. " , ( void * ) & pr_vbos , CVAR_INT , 0 , 0 , 2 } ,
2008-06-06 14:00:12 +00:00
{ " pr_gpusmoothing " , " pr_gpusmoothing: toggles model animation interpolation " , ( void * ) & pr_gpusmoothing , CVAR_INT , 0 , 0 , 1 } ,
2008-05-10 01:29:37 +00:00
# endif
2006-05-22 07:11:30 +00:00
# endif
2008-07-02 22:45:04 +00:00
{ " r_drawweapon " , " r_drawweapon: enable/disable weapon drawing " , ( void * ) & ud . drawweapon , CVAR_INT , 0 , 0 , 2 } ,
{ " r_showfps " , " r_showfps: show the frame rate counter " , ( void * ) & ud . tickrate , CVAR_BOOL , 0 , 0 , 1 } ,
2007-08-27 00:20:15 +00:00
{ " r_precache " , " r_precache: enable/disable the pre-level caching routine " , ( void * ) & ud . config . useprecache , CVAR_BOOL , 0 , 0 , 1 } ,
{ " snd_ambience " , " snd_ambience: enables/disables ambient sounds " , ( void * ) & ud . config . AmbienceToggle , CVAR_BOOL , 0 , 0 , 1 } ,
{ " snd_duketalk " , " snd_duketalk: enables/disables Duke's speech " , ( void * ) & ud . config . VoiceToggle , CVAR_INT , 0 , 0 , 2 } ,
{ " snd_fxvolume " , " snd_fxvolume: volume of sound effects " , ( void * ) & ud . config . FXVolume , CVAR_INT , 0 , 0 , 255 } ,
{ " snd_mixrate " , " snd_mixrate: sound mixing rate " , ( void * ) & ud . config . MixRate , CVAR_INT , 0 , 0 , 48000 } ,
{ " snd_musvolume " , " snd_musvolume: volume of midi music " , ( void * ) & ud . config . MusicVolume , CVAR_INT , 0 , 0 , 255 } ,
{ " snd_numbits " , " snd_numbits: sound bits " , ( void * ) & ud . config . NumBits , CVAR_INT , 0 , 8 , 16 } ,
{ " snd_numchannels " , " snd_numchannels: the number of sound channels " , ( void * ) & ud . config . NumChannels , CVAR_INT , 0 , 0 , 2 } ,
{ " snd_numvoices " , " snd_numvoices: the number of concurrent sounds " , ( void * ) & ud . config . NumVoices , CVAR_INT , 0 , 0 , 32 } ,
{ " snd_reversestereo " , " snd_reversestereo: reverses the stereo channels " , ( void * ) & ud . config . ReverseStereo , CVAR_BOOL , 0 , 0 , 16 } ,
2007-08-25 01:05:00 +00:00
} ;
2007-02-08 04:19:39 +00:00
2006-12-14 03:34:55 +00:00
static int osdcmd_cvar_set ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
int showval = ( parm - > numparms = = 0 ) ;
unsigned int i ;
2008-06-30 01:03:51 +00:00
for ( i = 0 ; i < sizeof ( cvar ) / sizeof ( cvarmappings ) ; i + + )
2006-11-15 01:16:55 +00:00
{
if ( ! Bstrcasecmp ( parm - > name , cvar [ i ] . name ) )
{
2008-06-30 01:03:51 +00:00
if ( ( cvar [ i ] . type & CVAR_NOMULTI ) & & numplayers > 1 )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
// sound the alarm
OSD_Printf ( " Cvar \" %s \" locked in multiplayer. \n " , cvar [ i ] . name ) ;
return OSDCMD_OK ;
2006-11-15 01:16:55 +00:00
}
else
switch ( cvar [ i ] . type & 0x7f )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
case CVAR_INT :
case CVAR_UNSIGNEDINT :
case CVAR_BOOL :
{
int val ;
if ( showval )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
OSD_Printf ( " \" %s \" is \" %d \" \n %s \n " , cvar [ i ] . name , * ( int * ) cvar [ i ] . var , ( char * ) cvar [ i ] . helpstr ) ;
return OSDCMD_OK ;
2006-11-13 23:12:47 +00:00
}
2006-11-16 03:02:42 +00:00
val = atoi ( parm - > parms [ 0 ] ) ;
if ( cvar [ i ] . type = = CVAR_BOOL ) val = val ! = 0 ;
if ( val < cvar [ i ] . min | | val > cvar [ i ] . max )
{
OSD_Printf ( " %s value out of range \n " , cvar [ i ] . name ) ;
return OSDCMD_OK ;
}
* ( int * ) cvar [ i ] . var = val ;
OSD_Printf ( " %s %d " , cvar [ i ] . name , val ) ;
}
break ;
case CVAR_STRING :
{
if ( showval )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
OSD_Printf ( " \" %s \" is \" %s \" \n %s \n " , cvar [ i ] . name , ( char * ) cvar [ i ] . var , ( char * ) cvar [ i ] . helpstr ) ;
return OSDCMD_OK ;
2006-11-13 23:12:47 +00:00
}
2006-11-16 03:02:42 +00:00
else
{
Bstrncpy ( ( char * ) cvar [ i ] . var , parm - > parms [ 0 ] , cvar [ i ] . extra - 1 ) ;
( ( char * ) cvar [ i ] . var ) [ cvar [ i ] . extra - 1 ] = 0 ;
OSD_Printf ( " %s %s " , cvar [ i ] . name , ( char * ) cvar [ i ] . var ) ;
}
}
break ;
default :
2006-11-13 23:12:47 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2008-06-30 01:03:51 +00:00
if ( cvar [ i ] . type & CVAR_MULTI )
2006-11-30 23:37:47 +00:00
updateplayer ( ) ;
2006-04-13 20:47:06 +00:00
}
}
OSD_Printf ( " \n " ) ;
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_sensitivity ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( parm - > numparms ! = 1 )
{
2006-04-30 21:14:12 +00:00
OSD_Printf ( " \" sensitivity \" is \" %d \" \n " , CONTROL_GetMouseSensitivity ( ) ) ;
return OSDCMD_SHOWHELP ;
2006-04-13 20:47:06 +00:00
}
2006-04-30 00:40:41 +00:00
CONTROL_SetMouseSensitivity ( atoi ( parm - > parms [ 0 ] ) ) ;
OSD_Printf ( " sensitivity %d \n " , CONTROL_GetMouseSensitivity ( ) ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_gamma ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( parm - > numparms ! = 1 )
{
2006-04-30 21:14:12 +00:00
OSD_Printf ( " \" gamma \" \" %d \" \n " , ud . brightness > > 2 ) ;
return OSDCMD_SHOWHELP ;
2006-04-13 20:47:06 +00:00
}
ud . brightness = atoi ( parm - > parms [ 0 ] ) < < 2 ;
2007-08-27 06:46:31 +00:00
setbrightness ( ud . brightness > > 2 , & g_player [ screenpeek ] . ps - > palette [ 0 ] , 0 ) ;
2006-04-30 21:14:12 +00:00
OSD_Printf ( " gamma %d \n " , ud . brightness > > 2 ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_give ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
int i ;
2007-08-27 06:46:31 +00:00
if ( numplayers = = 1 & & g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
2006-11-15 01:16:55 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ myconnectindex ] . ps - > dead_flag ! = 0 )
2006-11-15 01:16:55 +00:00
{
2006-07-23 21:12:46 +00:00
OSD_Printf ( " give: Cannot give while dead. \n " ) ;
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
2006-04-13 20:47:06 +00:00
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " all " ) )
{
2006-04-13 20:47:06 +00:00
osdcmd_cheatsinfo_stat . cheatnum = 1 ;
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " health " ) )
{
2007-08-27 23:11:49 +00:00
sprite [ g_player [ myconnectindex ] . ps - > i ] . extra = g_player [ myconnectindex ] . ps - > max_player_health < < 1 ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " weapons " ) )
{
2006-04-13 20:47:06 +00:00
osdcmd_cheatsinfo_stat . cheatnum = 21 ;
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " ammo " ) )
{
2006-04-13 20:47:06 +00:00
for ( i = PISTOL_WEAPON ; i < MAX_WEAPONS - ( VOLUMEONE ? 6 : 1 ) ; i + + )
{
2007-08-27 23:11:49 +00:00
addammo ( i , g_player [ myconnectindex ] . ps , g_player [ myconnectindex ] . ps - > max_ammo_amount [ i ] ) ;
2006-04-13 20:47:06 +00:00
}
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " armor " ) )
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > shield_amount = 100 ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " keys " ) )
{
2006-04-13 20:47:06 +00:00
osdcmd_cheatsinfo_stat . cheatnum = 23 ;
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " inventory " ) )
{
2006-04-13 20:47:06 +00:00
osdcmd_cheatsinfo_stat . cheatnum = 22 ;
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
}
else
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " give: Not in a single-player game. \n " ) ;
return OSDCMD_OK ;
}
return OSDCMD_SHOWHELP ;
}
void onvideomodechange ( int newmode )
{
char * pal ;
2006-11-15 01:16:55 +00:00
if ( newmode )
{
2007-08-27 06:46:31 +00:00
if ( g_player [ screenpeek ] . ps - > palette = = palette | |
g_player [ screenpeek ] . ps - > palette = = waterpal | |
g_player [ screenpeek ] . ps - > palette = = titlepal | |
g_player [ screenpeek ] . ps - > palette = = animpal | |
g_player [ screenpeek ] . ps - > palette = = endingpal | |
g_player [ screenpeek ] . ps - > palette = = drealms | |
g_player [ screenpeek ] . ps - > palette = = slimepal )
pal = g_player [ screenpeek ] . ps - > palette ;
2006-12-05 20:39:29 +00:00
else
pal = palette ;
2006-11-15 01:16:55 +00:00
}
else
{
2007-08-27 06:46:31 +00:00
pal = g_player [ screenpeek ] . ps - > palette ;
2006-04-13 20:47:06 +00:00
}
setbrightness ( ud . brightness > > 2 , pal , 0 ) ;
restorepalette = 1 ;
}
2006-12-14 03:34:55 +00:00
static int osdcmd_usemousejoy ( const osdfuncparm_t * parm )
2006-05-21 00:05:50 +00:00
{
int showval = ( parm - > numparms < 1 ) ;
2008-07-02 04:56:42 +00:00
if ( ! Bstrcasecmp ( parm - > name , " in_mouse " ) )
2006-11-15 01:16:55 +00:00
{
if ( showval )
{
2008-07-02 04:56:42 +00:00
OSD_Printf ( " in_mouse is %d \n " , ud . config . UseMouse ) ;
2006-11-15 01:16:55 +00:00
}
else
{
2007-08-27 00:20:15 +00:00
ud . config . UseMouse = ( atoi ( parm - > parms [ 0 ] ) ! = 0 ) ;
CONTROL_MouseEnabled = ( ud . config . UseMouse & & CONTROL_MousePresent ) ;
2006-05-21 00:05:50 +00:00
}
return OSDCMD_OK ;
}
2008-07-02 04:56:42 +00:00
else if ( ! Bstrcasecmp ( parm - > name , " in_joystick " ) )
2006-11-15 01:16:55 +00:00
{
if ( showval )
{
2008-07-02 04:56:42 +00:00
OSD_Printf ( " in_joystick is %d \n " , ud . config . UseJoystick ) ;
2006-11-15 01:16:55 +00:00
}
else
{
2007-08-27 00:20:15 +00:00
ud . config . UseJoystick = ( atoi ( parm - > parms [ 0 ] ) ! = 0 ) ;
CONTROL_JoystickEnabled = ( ud . config . UseJoystick & & CONTROL_JoyPresent ) ;
2006-05-21 00:05:50 +00:00
}
return OSDCMD_OK ;
}
return OSDCMD_SHOWHELP ;
}
2006-05-17 03:13:39 +00:00
2006-12-14 03:34:55 +00:00
static int osdcmd_name ( const osdfuncparm_t * parm )
2006-05-09 04:24:44 +00:00
{
if ( parm - > numparms ! = 1 )
{
OSD_Printf ( " \" name \" is \" %s \" \n " , myname ) ;
return OSDCMD_SHOWHELP ;
}
Bstrcpy ( tempbuf , parm - > parms [ 0 ] ) ;
2006-12-10 21:53:33 +00:00
while ( Bstrlen ( stripcolorcodes ( tempbuf ) ) > 10 )
2006-05-09 04:24:44 +00:00
tempbuf [ Bstrlen ( tempbuf ) - 1 ] = ' \0 ' ;
Bstrncpy ( myname , tempbuf , sizeof ( myname ) - 1 ) ;
2008-06-04 08:58:02 +00:00
myname [ sizeof ( myname ) - 1 ] = ' \0 ' ;
2006-05-09 04:24:44 +00:00
OSD_Printf ( " name %s \n " , myname ) ;
2006-11-30 23:37:47 +00:00
updateplayer ( ) ;
2006-05-09 04:24:44 +00:00
return OSDCMD_OK ;
}
2008-06-29 10:40:37 +00:00
static int osdcmd_button ( const osdfuncparm_t * parm )
{
char * p = ( char * ) parm - > name + 9 ; // skip "gamefunc_"
2008-07-03 07:37:41 +00:00
// if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game
2008-06-30 09:00:33 +00:00
extinput [ CONFIG_FunctionNameToNum ( p ) ] = 1 ; // FIXME
2008-06-29 10:40:37 +00:00
return OSDCMD_OK ;
}
2008-01-04 01:04:35 +00:00
static int osdcmd_bind ( const osdfuncparm_t * parm )
{
2008-06-29 10:40:37 +00:00
int i , j ;
2008-01-04 01:04:35 +00:00
2008-01-04 02:07:25 +00:00
if ( parm - > numparms = = 1 & & ! Bstrcasecmp ( parm - > parms [ 0 ] , " showkeys " ) )
2008-01-04 01:04:35 +00:00
{
2008-05-10 01:29:37 +00:00
for ( i = 0 ; keynames [ i ] . name ; i + + ) OSD_Printf ( " %s \n " , keynames [ i ] . name ) ;
2008-06-30 19:06:05 +00:00
for ( i = 0 ; i < MAXMOUSEBUTTONS ; i + + ) OSD_Printf ( " %s \n " , mousenames [ i ] ) ;
2008-01-04 01:04:35 +00:00
return OSDCMD_OK ;
}
2008-06-29 11:59:43 +00:00
2008-01-04 01:04:35 +00:00
if ( parm - > numparms = = 0 )
{
2008-07-02 22:45:04 +00:00
int j = 0 ;
OSD_Printf ( " Current key bindings: \n " ) ;
2008-06-30 19:06:05 +00:00
for ( i = 0 ; i < MAXBOUNDKEYS ; i + + )
2008-07-03 07:37:41 +00:00
if ( boundkeys [ i ] . cmd [ 0 ] )
2008-07-02 22:45:04 +00:00
{
j + + ;
2008-07-03 07:37:41 +00:00
OSD_Printf ( " %-11s = %s \n " , boundkeys [ i ] . key , boundkeys [ i ] . cmd ) ;
2008-07-02 22:45:04 +00:00
}
2008-06-30 19:06:05 +00:00
for ( i = 0 ; i < MAXMOUSEBUTTONS ; i + + )
2008-07-03 07:37:41 +00:00
if ( mousebind [ i ] . cmd [ 0 ] )
2008-07-02 22:45:04 +00:00
{
j + + ;
2008-07-03 07:37:41 +00:00
OSD_Printf ( " %-11s = %s \n " , mousebind [ i ] . key , mousebind [ i ] . cmd ) ;
2008-07-02 22:45:04 +00:00
}
if ( j = = 0 )
OSD_Printf ( " No binds found. \n " ) ;
2008-01-04 01:04:35 +00:00
return OSDCMD_OK ;
}
2008-06-29 11:33:51 +00:00
for ( i = 0 ; keynames [ i ] . name ; i + + )
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , keynames [ i ] . name ) )
break ;
2008-06-30 19:06:05 +00:00
2008-07-01 11:14:18 +00:00
if ( ! keynames [ i ] . name )
2008-06-30 19:06:05 +00:00
{
for ( i = 0 ; i < MAXMOUSEBUTTONS ; i + + )
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , mousenames [ i ] ) )
break ;
if ( i > = MAXMOUSEBUTTONS )
return OSDCMD_SHOWHELP ;
if ( parm - > numparms < 2 )
{
2008-07-03 07:37:41 +00:00
OSD_Printf ( " %-11s = %s \n " , mousenames [ i ] , mousebind [ i ] . cmd ) ;
2008-06-30 19:06:05 +00:00
return OSDCMD_OK ;
}
j = 1 ;
2008-07-03 07:37:41 +00:00
mousebind [ i ] . repeat = 1 ;
2008-06-30 19:06:05 +00:00
if ( parm - > numparms > = 2 & & ! Bstrcasecmp ( parm - > parms [ j ] , " norepeat " ) )
{
mousebind [ i ] . repeat = 0 ;
j + + ;
}
2008-07-03 07:37:41 +00:00
Bstrcpy ( tempbuf , parm - > parms [ j + + ] ) ;
for ( ; j < parm - > numparms ; j + + )
{
Bstrcat ( tempbuf , " " ) ;
Bstrcat ( tempbuf , parm - > parms [ j + + ] ) ;
}
Bstrncpy ( mousebind [ i ] . cmd , tempbuf , MAXBINDSTRINGLENGTH - 1 ) ;
2008-06-30 19:06:05 +00:00
mousebind [ i ] . key = mousenames [ i ] ;
if ( ! osdexecscript )
OSD_Printf ( " %s \n " , parm - > raw ) ;
return OSDCMD_OK ;
}
2008-01-04 01:04:35 +00:00
2008-06-29 11:59:43 +00:00
if ( parm - > numparms < 2 )
{
2008-07-03 07:37:41 +00:00
OSD_Printf ( " %-11s = %s \n " , keynames [ i ] . name , boundkeys [ keynames [ i ] . id ] . cmd ) ;
2008-06-29 11:59:43 +00:00
return OSDCMD_OK ;
}
2008-06-29 10:40:37 +00:00
j = 1 ;
2008-07-03 07:37:41 +00:00
boundkeys [ keynames [ i ] . id ] . repeat = 1 ;
2008-06-29 12:13:10 +00:00
if ( parm - > numparms > = 2 & & ! Bstrcasecmp ( parm - > parms [ j ] , " norepeat " ) )
2008-06-29 10:40:37 +00:00
{
2008-06-29 12:13:10 +00:00
boundkeys [ keynames [ i ] . id ] . repeat = 0 ;
2008-06-29 10:40:37 +00:00
j + + ;
}
2008-07-03 07:37:41 +00:00
Bstrcpy ( tempbuf , parm - > parms [ j + + ] ) ;
for ( ; j < parm - > numparms ; j + + )
{
Bstrcat ( tempbuf , " " ) ;
Bstrcat ( tempbuf , parm - > parms [ j + + ] ) ;
}
Bstrncpy ( boundkeys [ keynames [ i ] . id ] . cmd , tempbuf , MAXBINDSTRINGLENGTH - 1 ) ;
2008-01-04 01:04:35 +00:00
boundkeys [ keynames [ i ] . id ] . key = keynames [ i ] . name ;
2008-06-30 07:30:48 +00:00
if ( ! osdexecscript )
2008-06-29 12:53:18 +00:00
OSD_Printf ( " %s \n " , parm - > raw ) ;
2008-01-04 01:04:35 +00:00
return OSDCMD_OK ;
}
2008-06-30 07:30:48 +00:00
static int osdcmd_unbindall ( const osdfuncparm_t * parm )
{
int i ;
UNREFERENCED_PARAMETER ( parm ) ;
2008-06-30 19:06:05 +00:00
for ( i = 0 ; i < MAXBOUNDKEYS ; i + + )
2008-07-03 07:37:41 +00:00
if ( boundkeys [ i ] . cmd [ 0 ] )
boundkeys [ i ] . cmd [ 0 ] = 0 ;
2008-06-30 19:06:05 +00:00
for ( i = 0 ; i < MAXMOUSEBUTTONS ; i + + )
2008-07-03 07:37:41 +00:00
if ( mousebind [ i ] . cmd [ 0 ] )
mousebind [ i ] . cmd [ 0 ] = 0 ;
2008-06-30 07:30:48 +00:00
OSD_Printf ( " unbound all keys \n " ) ;
return OSDCMD_OK ;
}
2008-06-29 11:33:51 +00:00
static int osdcmd_unbind ( const osdfuncparm_t * parm )
{
2008-06-29 11:59:43 +00:00
int i ;
2008-06-29 11:33:51 +00:00
if ( parm - > numparms < 1 ) return OSDCMD_SHOWHELP ;
for ( i = 0 ; keynames [ i ] . name ; i + + )
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , keynames [ i ] . name ) )
break ;
2008-06-30 19:06:05 +00:00
if ( ! keynames [ i ] . name )
{
for ( i = 0 ; i < MAXMOUSEBUTTONS ; i + + )
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , mousenames [ i ] ) )
break ;
if ( i > = MAXMOUSEBUTTONS )
return OSDCMD_SHOWHELP ;
mousebind [ i ] . repeat = 0 ;
2008-07-03 07:37:41 +00:00
mousebind [ i ] . cmd [ 0 ] = 0 ;
2008-07-01 10:33:13 +00:00
OSD_Printf ( " unbound %s \n " , mousenames [ i ] ) ;
2008-06-30 19:06:05 +00:00
return OSDCMD_OK ;
}
2008-06-29 11:33:51 +00:00
boundkeys [ keynames [ i ] . id ] . repeat = 0 ;
2008-07-03 07:37:41 +00:00
boundkeys [ keynames [ i ] . id ] . cmd [ 0 ] = 0 ;
2008-06-29 11:33:51 +00:00
OSD_Printf ( " unbound key %s \n " , keynames [ i ] . name ) ;
return OSDCMD_OK ;
}
2008-06-30 07:30:48 +00:00
static int osdcmd_quicksave ( const osdfuncparm_t * parm )
{
UNREFERENCED_PARAMETER ( parm ) ;
if ( ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
OSD_Printf ( " quicksave: not in a game. \n " ) ;
else doquicksave = 1 ;
return OSDCMD_OK ;
}
static int osdcmd_quickload ( const osdfuncparm_t * parm )
{
UNREFERENCED_PARAMETER ( parm ) ;
if ( ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
OSD_Printf ( " quickload: not in a game. \n " ) ;
else doquicksave = 2 ;
return OSDCMD_OK ;
}
2008-07-03 07:37:41 +00:00
static int osdcmd_screenshot ( const osdfuncparm_t * parm )
{
UNREFERENCED_PARAMETER ( parm ) ;
KB_ClearKeysDown ( ) ;
screencapture ( " duke0000.tga " , 0 ) ;
return OSDCMD_OK ;
}
2006-04-13 20:47:06 +00:00
int registerosdcommands ( void )
{
unsigned int i ;
osdcmd_cheatsinfo_stat . cheatnum = - 1 ;
2006-11-15 01:16:55 +00:00
for ( i = 0 ; i < sizeof ( cvar ) / sizeof ( cvar [ 0 ] ) ; i + + )
{
2006-04-13 20:47:06 +00:00
OSD_RegisterFunction ( cvar [ i ] . name , cvar [ i ] . helpstr , osdcmd_cvar_set ) ;
}
2006-11-15 01:16:55 +00:00
if ( VOLUMEONE )
2006-04-13 20:47:06 +00:00
OSD_RegisterFunction ( " changelevel " , " changelevel <level>: warps to the given level " , osdcmd_changelevel ) ;
2006-11-15 01:16:55 +00:00
else
{
2006-04-13 20:47:06 +00:00
OSD_RegisterFunction ( " changelevel " , " changelevel <volume> <level>: warps to the given level " , osdcmd_changelevel ) ;
OSD_RegisterFunction ( " map " , " map <mapfile>: loads the given user map " , osdcmd_map ) ;
}
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " addpath " , " addpath <path>: adds path to game filesystem " , osdcmd_addpath ) ;
2008-06-30 07:30:48 +00:00
OSD_RegisterFunction ( " bind " , " bind <key> <string>: associates a keypress with a string of console input. Type \" bind showkeys \" for a list of keys and \" listsymbols \" for a list of valid console commands. " , osdcmd_bind ) ;
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " cl_statusbarscale " , " cl_statusbarscale: changes the status bar scale " , osdcmd_setstatusbarscale ) ;
2006-04-13 20:47:06 +00:00
OSD_RegisterFunction ( " cmenu " , " cmenu <#>: jumps to menu " , osdcmd_cmenu ) ;
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " echo " , " echo [text]: echoes text to the console " , osdcmd_echo ) ;
OSD_RegisterFunction ( " fileinfo " , " fileinfo <file>: gets a file's information " , osdcmd_fileinfo ) ;
2008-06-30 07:30:48 +00:00
for ( i = 0 ; i < NUMGAMEFUNCTIONS ; i + + )
{
char * t ;
Bsprintf ( tempbuf , " gamefunc_%s " , gamefunctions [ i ] ) ;
t = Bstrdup ( tempbuf ) ;
Bstrcat ( tempbuf , " : game button " ) ;
OSD_RegisterFunction ( t , Bstrdup ( tempbuf ) , osdcmd_button ) ;
}
2006-04-13 20:47:06 +00:00
OSD_RegisterFunction ( " gamma " , " gamma <value>: changes brightness " , osdcmd_gamma ) ;
OSD_RegisterFunction ( " give " , " give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item " , osdcmd_give ) ;
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " god " , " god: toggles god mode " , osdcmd_god ) ;
2008-07-02 04:56:42 +00:00
OSD_RegisterFunction ( " in_joystick " , " in_joystick: enables input from the joystick if it is present " , osdcmd_usemousejoy ) ;
OSD_RegisterFunction ( " in_mouse " , " in_mouse: enables input from the mouse if it is present " , osdcmd_usemousejoy ) ;
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " initgroupfile " , " initgroupfile <path>: adds a grp file into the game filesystem " , osdcmd_initgroupfile ) ;
2006-05-09 04:24:44 +00:00
OSD_RegisterFunction ( " name " , " name: change your multiplayer nickname " , osdcmd_name ) ;
2006-04-13 20:47:06 +00:00
OSD_RegisterFunction ( " noclip " , " noclip: toggles clipping mode " , osdcmd_noclip ) ;
2008-06-30 07:30:48 +00:00
OSD_RegisterFunction ( " quicksave " , " quicksave: performs a quick save " , osdcmd_quicksave ) ;
OSD_RegisterFunction ( " quickload " , " quickload: performs a quick load " , osdcmd_quickload ) ;
2006-04-13 20:47:06 +00:00
OSD_RegisterFunction ( " quit " , " quit: exits the game immediately " , osdcmd_quit ) ;
2007-01-26 00:28:44 +00:00
OSD_RegisterFunction ( " rate " , " rate: sets the multiplayer packet send rate, in packets/sec " , osdcmd_rate ) ;
2008-02-24 00:46:57 +00:00
OSD_RegisterFunction ( " restartsound " , " restartsound: reinitializes the sound system " , osdcmd_restartsound ) ;
OSD_RegisterFunction ( " restartvid " , " restartvid: reinitializes the video mode " , osdcmd_restartvid ) ;
2006-04-13 20:47:06 +00:00
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " sensitivity " , " sensitivity <value>: changes the mouse sensitivity " , osdcmd_sensitivity ) ;
OSD_RegisterFunction ( " setvar " , " setvar <gamevar> <value>: sets the value of a gamevar " , osdcmd_setvar ) ;
2007-12-20 19:14:38 +00:00
OSD_RegisterFunction ( " setvarvar " , " setvar <gamevar> <gamevar>: sets the value of a gamevar " , osdcmd_setvar ) ;
OSD_RegisterFunction ( " setactorvar " , " setactorvar <actorID> <gamevar> <value>: sets the value of a gamevar " , osdcmd_setactorvar ) ;
2008-07-03 07:37:41 +00:00
OSD_RegisterFunction ( " screenshot " , " screenshot: takes a screenshot. See r_scrcaptureformat. " , osdcmd_screenshot ) ;
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " spawn " , " spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties " , osdcmd_spawn ) ;
2008-06-30 07:30:48 +00:00
OSD_RegisterFunction ( " unbind " , " unbind <key>: unbinds a key. " , osdcmd_unbind ) ;
OSD_RegisterFunction ( " unbindall " , " unbindall: unbinds all keys. " , osdcmd_unbindall ) ;
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " vidmode " , " vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode " , osdcmd_vidmode ) ;
2006-05-17 03:13:39 +00:00
2006-04-13 20:47:06 +00:00
//baselayer_onvideomodechange = onvideomodechange;
return 0 ;
}