2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
2010-05-25 10:56:00 +00:00
Copyright ( C ) 2010 EDuke32 developers and contributors
2007-02-08 04:19:39 +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
2014-07-20 08:55:56 +00:00
Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2006-04-13 20:47:06 +00:00
*/
//-------------------------------------------------------------------------
2019-09-21 18:59:54 +00:00
# include "ns.h" // Must come before everything else!
2018-11-18 19:03:40 +00:00
# include "cheats.h"
# include "cmdline.h"
# include "demo.h" // g_firstDemoFile[]
2006-04-13 20:47:06 +00:00
# include "duke3d.h"
2010-08-02 08:13:51 +00:00
# include "menus.h"
2018-11-18 19:03:40 +00:00
# include "osdcmds.h"
2008-07-25 04:33:33 +00:00
# include "osdfuncs.h"
2018-03-08 03:55:41 +00:00
# include "savegame.h"
2018-11-18 19:03:40 +00:00
# include "sbar.h"
2006-04-13 20:47:06 +00:00
2019-03-01 08:51:50 +00:00
# include "vfs.h"
2019-09-21 20:53:00 +00:00
BEGIN_DUKE_NS
2006-04-13 20:47:06 +00:00
struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat ;
2008-07-27 21:33:28 +00:00
float r_ambientlight = 1.0 , r_ambientlightrecip = 1.0 ;
2006-04-13 20:47:06 +00:00
2015-03-24 10:49:03 +00:00
uint32_t cl_cheatmask ;
2018-11-18 18:06:15 +00:00
static inline int osdcmd_quit ( osdcmdptr_t UNUSED ( parm ) )
2006-04-13 20:47:06 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2014-03-01 11:41:29 +00:00
OSD_ShowDisplay ( 0 ) ;
2009-12-14 20:14:12 +00:00
G_GameQuit ( ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_changelevel ( osdcmdptr_t parm )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t 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 )
{
2016-08-27 01:42:01 +00:00
if ( volume > g_volumeCnt )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
OSD_Printf ( " changelevel: invalid volume number (range 1-%d) \n " , g_volumeCnt ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
}
2016-08-27 01:42:01 +00:00
if ( level > MAXLEVELS | | g_mapInfo [ 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 )
{
2017-06-27 02:24:14 +00:00
/*
2010-01-16 23:08:17 +00:00
if ( g_netServer )
2008-11-20 14:06:36 +00:00
Net_NewGame ( 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
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2007-01-26 05:16:10 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
2007-08-27 06:46:31 +00:00
{
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 ;
2009-01-10 07:38:50 +00:00
tempbuf [ 0 ] = PACKET_MAP_VOTE_INITIATE ;
2008-11-20 14:06:36 +00:00
tempbuf [ 1 ] = myconnectindex ;
tempbuf [ 2 ] = ud . m_volume_number ;
tempbuf [ 3 ] = ud . m_level_number ;
2006-12-12 08:33:11 +00:00
2010-01-21 10:02:04 +00:00
enet_peer_send ( g_netClientPeer , CHAN_GAMESTATE , enet_packet_create ( tempbuf , 4 , ENET_PACKET_FLAG_RELIABLE ) ) ;
2006-12-12 08:33:11 +00:00
}
2017-10-15 23:10:18 +00:00
if ( ( g_gametypeFlags [ ud . m_coop ] & GAMETYPE_PLAYERSFRIENDLY ) & & ! ( g_gametypeFlags [ ud . m_coop ] & GAMETYPE_TDM ) )
2006-12-12 08:33:11 +00:00
ud . m_noexits = 0 ;
2014-11-17 07:39:12 +00:00
M_OpenMenu ( myconnectindex ) ;
2016-11-01 01:35:32 +00:00
Menu_Change ( MENU_NETWAITVOTES ) ;
2006-12-12 08:33:11 +00:00
}
2017-06-27 02:24:14 +00:00
*/
2006-12-12 08:33:11 +00:00
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
2012-09-08 22:18:34 +00:00
osdcmd_cheatsinfo_stat . cheatnum = CHEAT_SCOTTY ;
2006-04-13 20:47:06 +00:00
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 ;
2016-08-27 01:42:01 +00:00
ud . m_volume_number = volume ;
ud . m_level_number = level ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
ud . m_monsters_off = 0 ;
ud . monsters_off = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
ud . m_respawn_items = 0 ;
2006-04-13 20:47:06 +00:00
ud . m_respawn_inventory = 0 ;
2016-08-27 01:42:01 +00:00
ud . multimode = 1 ;
2006-04-13 20:47:06 +00:00
2013-07-13 21:04:52 +00:00
G_NewGame_EnterLevel ( ) ;
2006-04-13 20:47:06 +00:00
}
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_map ( osdcmdptr_t parm )
2006-04-13 20:47:06 +00:00
{
2012-03-28 19:42:16 +00:00
char filename [ BMAX_PATH ] ;
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:31 +00:00
const int32_t wildcardp = parm - > numparms = = 1 & &
( Bstrchr ( parm - > parms [ 0 ] , ' * ' ) ! = NULL ) ;
if ( parm - > numparms ! = 1 | | wildcardp )
2008-08-17 11:07:28 +00:00
{
2012-03-28 19:42:16 +00:00
CACHE1D_FIND_REC * r ;
fnlist_t fnlist = FNLIST_INITIALIZER ;
2009-01-09 09:29:17 +00:00
int32_t maxwidth = 0 ;
2008-08-17 11:07:28 +00:00
2012-09-08 22:18:31 +00:00
if ( wildcardp )
maybe_append_ext ( filename , sizeof ( filename ) , parm - > parms [ 0 ] , " .map " ) ;
else
Bstrcpy ( filename , " *.MAP " ) ;
fnlist_getnames ( & fnlist , " / " , filename , - 1 , 0 ) ;
2008-08-17 11:07:28 +00:00
2012-03-28 19:42:16 +00:00
for ( r = fnlist . findfiles ; r ; r = r - > next )
2018-10-16 06:09:54 +00:00
maxwidth = max < int > ( maxwidth , Bstrlen ( r - > name ) ) ;
2008-08-17 11:07:28 +00:00
if ( maxwidth > 0 )
{
2018-10-07 05:23:05 +00:00
int32_t x = 0 ;
2008-08-17 11:07:28 +00:00
maxwidth + = 3 ;
OSD_Printf ( OSDTEXT_RED " Map listing: \n " ) ;
2012-03-28 19:42:16 +00:00
for ( r = fnlist . findfiles ; r ; r = r - > next )
2008-08-17 11:07:28 +00:00
{
OSD_Printf ( " %-*s " , maxwidth , r - > name ) ;
x + = maxwidth ;
if ( x > OSD_GetCols ( ) - maxwidth )
{
x = 0 ;
OSD_Printf ( " \n " ) ;
}
}
if ( x ) OSD_Printf ( " \n " ) ;
2012-03-28 19:42:16 +00:00
OSD_Printf ( OSDTEXT_RED " Found %d maps \n " , fnlist . numfiles ) ;
2008-08-17 11:07:28 +00:00
}
2012-03-28 19:42:16 +00:00
fnlist_clearnames ( & fnlist ) ;
2008-08-17 11:07:28 +00:00
return OSDCMD_SHOWHELP ;
}
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:31 +00:00
maybe_append_ext ( filename , sizeof ( filename ) , parm - > parms [ 0 ] , " .map " ) ;
2006-04-13 20:47:06 +00:00
2019-03-01 08:51:50 +00:00
buildvfs_kfd ii ;
if ( ( ii = kopen4loadfrommod ( filename , 0 ) ) = = buildvfs_kfd_invalid )
2006-11-15 01:16:55 +00:00
{
2008-07-27 01:22:17 +00:00
OSD_Printf ( OSD_ERROR " map: file \" %s \" not found. \n " , filename ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2019-03-01 08:51:50 +00:00
kclose ( ii ) ;
2006-04-13 20:47:06 +00:00
2006-12-12 08:33:11 +00:00
boardfilename [ 0 ] = ' / ' ;
boardfilename [ 1 ] = 0 ;
strcat ( boardfilename , filename ) ;
if ( numplayers > 1 )
{
2017-06-27 02:24:14 +00:00
/*
2010-01-16 23:08:17 +00:00
if ( g_netServer )
2006-12-12 08:33:11 +00:00
{
2008-11-20 14:06:36 +00:00
Net_SendUserMapName ( ) ;
ud . m_volume_number = 0 ;
ud . m_level_number = 7 ;
Net_NewGame ( ud . m_volume_number , ud . m_level_number ) ;
2006-12-12 08:33:11 +00:00
}
else if ( voting = = - 1 )
{
2008-11-20 14:06:36 +00:00
Net_SendUserMapName ( ) ;
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
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2007-01-26 05:16:10 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXPLAYERS ; i + + )
2007-08-27 06:46:31 +00:00
{
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 ;
2009-01-10 07:38:50 +00:00
tempbuf [ 0 ] = PACKET_MAP_VOTE_INITIATE ;
2008-11-20 14:06:36 +00:00
tempbuf [ 1 ] = myconnectindex ;
tempbuf [ 2 ] = ud . m_volume_number ;
tempbuf [ 3 ] = ud . m_level_number ;
2006-12-12 08:33:11 +00:00
2010-01-21 10:02:04 +00:00
enet_peer_send ( g_netClientPeer , CHAN_GAMESTATE , enet_packet_create ( tempbuf , 4 , ENET_PACKET_FLAG_RELIABLE ) ) ;
2006-12-12 08:33:11 +00:00
}
2017-10-15 23:10:18 +00:00
if ( ( g_gametypeFlags [ ud . m_coop ] & GAMETYPE_PLAYERSFRIENDLY ) & & ! ( g_gametypeFlags [ ud . m_coop ] & GAMETYPE_TDM ) )
2006-12-12 08:33:11 +00:00
ud . m_noexits = 0 ;
2014-11-17 07:39:12 +00:00
M_OpenMenu ( myconnectindex ) ;
2016-11-01 01:35:32 +00:00
Menu_Change ( MENU_NETWAITVOTES ) ;
2006-12-12 08:33:11 +00:00
}
2017-06-27 02:24:14 +00:00
*/
2006-12-12 08:33:11 +00:00
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
2018-11-18 18:12:06 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
{
G_NewGame ( ud . m_volume_number , ud . m_level_number , ud . m_player_skill ) ;
g_player [ myconnectindex ] . ps - > gm = MODE_RESTART ;
}
else G_NewGame_EnterLevel ( ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2012-09-15 15:28:26 +00:00
// demo <demonum or demofn> [<prof>]
//
// To profile a demo ("timedemo mode"), <prof> can be given in the range 0-8,
// which will start to replay it as fast as possible, rendering <prof> frames
// for each gametic.
//
// Notes:
// * The demos should be recorded with demorec_diffs set to 0, so that the
// game state updates are actually computed.
2012-09-15 15:28:30 +00:00
// * Currently, the profiling can only be aborted on SDL 1.2 builds by
// pressing any key.
2012-09-15 15:28:26 +00:00
// * With <prof> greater than 1, interpolation should be calculated properly,
// though this has not been verified by looking at the frames.
// * When testing whether a change in the source has an effect on performance,
// the variance of the run times MUST be taken into account (that is, the
// replaying must be performed multiple times for the old and new versions,
// etc.)
2018-11-18 18:06:15 +00:00
static int osdcmd_demo ( osdcmdptr_t parm )
2012-09-08 22:18:37 +00:00
{
if ( numplayers > 1 )
{
OSD_Printf ( " Command not allowed in multiplayer \n " ) ;
return OSDCMD_OK ;
}
if ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
{
OSD_Printf ( " demo: Must not be in a game. \n " ) ;
return OSDCMD_OK ;
}
2012-09-15 15:28:26 +00:00
if ( parm - > numparms ! = 1 & & parm - > numparms ! = 2 )
2012-09-08 22:18:37 +00:00
return OSDCMD_SHOWHELP ;
{
2012-09-15 15:28:26 +00:00
int32_t prof = parm - > numparms = = 2 ? Batoi ( parm - > parms [ 1 ] ) : - 1 ;
2012-09-08 22:18:37 +00:00
2012-10-01 17:52:40 +00:00
Demo_SetFirst ( parm - > parms [ 0 ] ) ;
2012-09-24 21:09:27 +00:00
Demo_PlayFirst ( clamp ( prof , - 1 , 8 ) + 1 , 0 ) ;
2012-09-08 22:18:37 +00:00
}
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_activatecheat ( osdcmdptr_t parm )
2017-07-05 05:38:08 +00:00
{
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
if ( numplayers = = 1 & & g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
osdcmd_cheatsinfo_stat . cheatnum = Batoi ( parm - > parms [ 0 ] ) ;
else
OSD_Printf ( " activatecheat: Not in a single-player game. \n " ) ;
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_god ( osdcmdptr_t UNUSED ( parm ) )
2006-04-13 20:47:06 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2007-08-27 06:46:31 +00:00
if ( numplayers = = 1 & & g_player [ myconnectindex ] . ps - > gm & MODE_GAME )
2012-09-08 22:18:34 +00:00
osdcmd_cheatsinfo_stat . cheatnum = CHEAT_CORNHOLIO ;
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 ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_noclip ( osdcmdptr_t UNUSED ( parm ) )
2006-04-13 20:47:06 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2012-09-08 22:18:37 +00:00
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
{
2012-09-08 22:18:34 +00:00
osdcmd_cheatsinfo_stat . cheatnum = CHEAT_CLIP ;
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 ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_restartsound ( osdcmdptr_t UNUSED ( parm ) )
2007-01-26 05:16:10 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2008-11-20 14:06:36 +00:00
S_SoundShutdown ( ) ;
S_MusicShutdown ( ) ;
2007-01-26 05:16:10 +00:00
2008-11-20 14:06:36 +00:00
S_MusicStartup ( ) ;
S_SoundStartup ( ) ;
2007-01-26 05:16:10 +00:00
FX_StopAllSounds ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
2007-01-26 05:16:10 +00:00
2015-02-11 05:22:00 +00:00
if ( ud . config . MusicToggle )
2014-09-07 18:10:09 +00:00
S_RestartMusic ( ) ;
2007-02-13 01:28:50 +00:00
2007-01-26 05:16:10 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_music ( osdcmdptr_t parm )
2014-09-07 18:10:13 +00:00
{
if ( parm - > numparms = = 1 )
{
int32_t sel = G_GetMusicIdx ( parm - > parms [ 0 ] ) ;
if ( sel = = - 1 )
return OSDCMD_SHOWHELP ;
if ( sel = = - 2 )
{
OSD_Printf ( " %s is not a valid episode/level number pair \n " , parm - > parms [ 0 ] ) ;
return OSDCMD_OK ;
}
2018-01-29 11:13:43 +00:00
if ( ! S_TryPlayLevelMusic ( sel ) )
2014-09-07 18:10:13 +00:00
{
2018-01-29 11:13:43 +00:00
G_PrintCurrentMusic ( ) ;
2014-09-07 18:10:13 +00:00
}
else
{
OSD_Printf ( " No music defined for %s \n " , parm - > parms [ 0 ] ) ;
}
return OSDCMD_OK ;
}
return OSDCMD_SHOWHELP ;
}
2018-11-18 18:06:15 +00:00
int osdcmd_restartvid ( osdcmdptr_t UNUSED ( parm ) )
2006-04-13 20:47:06 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2018-04-12 21:02:51 +00:00
videoResetMode ( ) ;
2018-11-18 18:13:02 +00:00
if ( videoSetGameMode ( ud . setup . fullscreen , ud . setup . xdim , ud . setup . ydim , ud . setup . bpp , ud . detail ) )
2008-11-20 14:06:36 +00:00
G_GameExit ( " restartvid: Reset failed... \n " ) ;
2018-11-18 18:13:02 +00:00
onvideomodechange ( ud . setup . bpp > 8 ) ;
2008-11-20 14:06:36 +00:00
G_UpdateScreenArea ( ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
int osdcmd_restartmap ( osdcmdptr_t UNUSED ( parm ) )
2015-12-23 04:05:55 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2015-12-23 04:05:55 +00:00
if ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME & & ud . multimode = = 1 )
g_player [ myconnectindex ] . ps - > gm = MODE_RESTART ;
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_vidmode ( osdcmdptr_t parm )
2006-04-13 20:47:06 +00:00
{
2018-11-18 18:13:02 +00:00
int32_t newbpp = ud . setup . bpp , newwidth = ud . setup . xdim ,
newheight = ud . setup . ydim , newfs = ud . setup . fullscreen ;
2012-02-04 14:30:17 +00:00
int32_t tmp ;
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
2012-02-04 14:30:17 +00:00
tmp = Batol ( parm - > parms [ 0 ] ) ;
if ( ! ( tmp = = 8 | | tmp = = 16 | | tmp = = 32 ) )
return OSDCMD_SHOWHELP ;
newbpp = tmp ;
2006-11-16 03:02:42 +00:00
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 ] ) ;
2012-02-04 14:30:17 +00:00
tmp = Batol ( parm - > parms [ 2 ] ) ;
if ( ! ( tmp = = 8 | | tmp = = 16 | | tmp = = 32 ) )
return OSDCMD_SHOWHELP ;
newbpp = tmp ;
2006-11-16 03:02:42 +00:00
if ( parm - > numparms = = 4 )
newfs = ( Batol ( parm - > parms [ 3 ] ) ! = 0 ) ;
break ;
2006-11-15 01:16:55 +00:00
}
2018-07-14 21:36:44 +00:00
if ( videoSetGameMode ( newfs , newwidth , newheight , newbpp , upscalefactor ) )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
initprintf ( " vidmode: Mode change failed! \n " ) ;
2018-11-18 18:13:02 +00:00
if ( videoSetGameMode ( ud . setup . fullscreen , ud . setup . xdim , ud . setup . ydim , ud . setup . bpp , upscalefactor ) )
2008-11-20 14:06:36 +00:00
G_GameExit ( " vidmode: Reset failed! \n " ) ;
2006-04-13 20:47:06 +00:00
}
2018-11-18 18:13:02 +00:00
ud . setup . bpp = newbpp ;
ud . setup . xdim = newwidth ;
ud . setup . ydim = newheight ;
ud . setup . fullscreen = newfs ;
onvideomodechange ( ud . setup . bpp > 8 ) ;
2008-11-20 14:06:36 +00:00
G_UpdateScreenArea ( ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2014-03-15 14:10:45 +00:00
# ifdef LUNATIC
// Returns: INT32_MIN if no such CON label, its value else.
LUNATIC_CB int32_t ( * El_GetLabelValue ) ( const char * label ) ;
# endif
2018-11-18 18:06:15 +00:00
static int osdcmd_spawn ( osdcmdptr_t parm )
2006-04-13 20:47:06 +00:00
{
2014-03-15 14:10:45 +00:00
int32_t picnum = 0 ;
uint16_t cstat = 0 ;
2009-01-09 09:29:17 +00:00
char pal = 0 ;
int16_t ang = 0 ;
int16_t set = 0 , idx ;
2009-01-13 12:23:18 +00:00
vec3_t vect ;
2006-04-13 20:47:06 +00:00
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
2009-01-13 12:23:18 +00:00
vect . x = Batol ( parm - > parms [ 4 ] ) ;
vect . y = Batol ( parm - > parms [ 5 ] ) ;
vect . z = Batol ( parm - > parms [ 6 ] ) ;
2006-11-16 03:02:42 +00:00
set | = 8 ;
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2006-11-16 03:02:42 +00:00
case 4 : // ang
ang = Batol ( parm - > parms [ 3 ] ) & 2047 ;
set | = 4 ;
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2006-11-16 03:02:42 +00:00
case 3 : // cstat
2009-01-09 09:29:17 +00:00
cstat = ( uint16_t ) Batol ( parm - > parms [ 2 ] ) ;
2006-11-16 03:02:42 +00:00
set | = 2 ;
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2006-11-16 03:02:42 +00:00
case 2 : // pal
2009-01-09 09:29:17 +00:00
pal = ( uint8_t ) Batol ( parm - > parms [ 1 ] ) ;
2006-11-16 03:02:42 +00:00
set | = 1 ;
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2006-11-16 03:02:42 +00:00
case 1 : // tile number
if ( isdigit ( parm - > parms [ 0 ] [ 0 ] ) )
{
2014-03-15 14:10:45 +00:00
picnum = Batol ( parm - > parms [ 0 ] ) ;
2006-11-16 03:02:42 +00:00
}
else
{
2014-03-15 14:10:45 +00:00
int32_t i ;
# ifdef LUNATIC
2016-08-27 01:42:01 +00:00
i = g_labelCnt ;
2014-03-15 14:10:45 +00:00
picnum = El_GetLabelValue ( parm - > parms [ 0 ] ) ;
if ( picnum ! = INT32_MIN )
i = ! i ;
# else
int32_t j ;
2006-11-16 03:02:42 +00:00
for ( j = 0 ; j < 2 ; j + + )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
for ( i = 0 ; i < g_labelCnt ; i + + )
2006-11-15 01:16:55 +00:00
{
2014-03-15 14:10:45 +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
{
2014-03-15 14:10:45 +00:00
picnum = labelcode [ i ] ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
2014-03-15 14:10:45 +00:00
2016-08-27 01:42:01 +00:00
if ( i < g_labelCnt )
2014-03-15 14:10:45 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2014-03-15 14:10:45 +00:00
# endif
2016-08-27 01:42:01 +00:00
if ( i = = g_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
}
2014-03-15 14:10:45 +00:00
if ( ( uint32_t ) picnum > = MAXUSERTILES )
2006-11-16 03:02:42 +00:00
{
OSD_Printf ( " spawn: Invalid tile number \n " ) ;
return OSDCMD_OK ;
}
break ;
2014-03-15 14:10:45 +00:00
2006-11-16 03:02:42 +00:00
default :
return OSDCMD_SHOWHELP ;
2006-04-13 20:47:06 +00:00
}
2014-03-15 14:10:45 +00:00
idx = A_Spawn ( g_player [ myconnectindex ] . ps - > i , picnum ) ;
2009-01-09 09:29:17 +00:00
if ( set & 1 ) sprite [ idx ] . pal = ( uint8_t ) pal ;
if ( set & 2 ) sprite [ idx ] . cstat = ( int16_t ) cstat ;
2006-04-13 20:47:06 +00:00
if ( set & 4 ) sprite [ idx ] . ang = ang ;
2006-11-15 01:16:55 +00:00
if ( set & 8 )
{
2009-01-13 12:23:18 +00:00
if ( setsprite ( idx , & vect ) < 0 )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
OSD_Printf ( " spawn: Sprite can't be spawned into null space \n " ) ;
2012-03-11 17:38:13 +00:00
A_DeleteSprite ( idx ) ;
2006-04-13 20:47:06 +00:00
}
}
return OSDCMD_OK ;
}
2013-01-20 21:17:06 +00:00
# if !defined LUNATIC
2018-11-18 18:06:15 +00:00
static int osdcmd_setvar ( osdcmdptr_t parm )
2006-04-13 20:47:06 +00:00
{
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 ;
}
2019-08-04 02:52:18 +00:00
if ( parm - > numparms ! = 2 )
return OSDCMD_SHOWHELP ;
2018-11-18 18:06:07 +00:00
int i = hash_find ( & h_gamevars , parm - > parms [ 1 ] ) ;
2018-12-15 01:37:34 +00:00
int const newValue = ( i = = - 1 ) ? Batol ( parm - > parms [ 1 ] ) : Gv_GetVar ( i , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2018-11-18 18:06:07 +00:00
if ( ( i = hash_find ( & h_gamevars , parm - > parms [ 0 ] ) ) > = 0 )
2019-08-04 02:52:18 +00:00
{
2018-12-15 01:37:34 +00:00
Gv_SetVar ( i , newValue , g_player [ myconnectindex ] . ps - > i , myconnectindex ) ;
2006-04-13 20:47:06 +00:00
2019-08-04 02:52:18 +00:00
OSD_Printf ( " Variable \" %s \" now has value %d (input: %d) \n " , aGameVars [ i ] . szLabel ,
Gv_GetVar ( i , g_player [ myconnectindex ] . ps - > i , myconnectindex ) , newValue ) ;
}
else
{
OSD_Printf ( " setvar: \" %s \" is not a game variable! \n " , parm - > parms [ 0 ] ) ;
return OSDCMD_SHOWHELP ;
}
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
2018-11-18 18:06:15 +00:00
static int osdcmd_addlogvar ( osdcmdptr_t parm )
2008-07-23 20:09:22 +00:00
{
if ( numplayers > 1 )
{
OSD_Printf ( " Command not allowed in multiplayer \n " ) ;
return OSDCMD_OK ;
}
2019-08-04 02:52:18 +00:00
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2018-11-18 18:06:07 +00:00
int const i = hash_find ( & h_gamevars , parm - > parms [ 0 ] ) ;
2008-08-25 10:43:24 +00:00
if ( i > = 0 )
2018-12-15 01:37:34 +00:00
OSD_Printf ( " Variable \" %s \" has value %d, default %d \n " , parm - > parms [ 0 ] , Gv_GetVar ( i , g_player [ screenpeek ] . ps - > i , screenpeek ) , ( int ) aGameVars [ i ] . defaultValue ) ;
2019-08-04 02:52:18 +00:00
else
{
OSD_Printf ( " addlogvar: %s is not a game variable! \n " , parm - > parms [ 0 ] ) ;
return OSDCMD_SHOWHELP ;
}
2018-11-18 18:06:07 +00:00
2008-07-23 20:09:22 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_setactorvar ( osdcmdptr_t parm )
2007-12-20 19:14:38 +00:00
{
if ( numplayers > 1 )
{
OSD_Printf ( " Command not allowed in multiplayer \n " ) ;
return OSDCMD_OK ;
}
2019-08-04 02:52:18 +00:00
if ( parm - > numparms ! = 3 )
return OSDCMD_SHOWHELP ;
2018-11-18 18:06:07 +00:00
int16_t const spriteNum = Batol ( parm - > parms [ 0 ] ) ;
2018-10-07 05:23:05 +00:00
if ( ( unsigned ) spriteNum > = MAXSPRITES )
2007-12-20 19:14:38 +00:00
{
2019-08-04 02:52:18 +00:00
OSD_Printf ( " setactorvar: Invalid sprite number! \n " ) ;
2007-12-20 19:14:38 +00:00
return OSDCMD_OK ;
}
2018-10-07 05:23:05 +00:00
// get value to set
2018-11-18 18:06:07 +00:00
int i = hash_find ( & h_gamevars , parm - > parms [ 2 ] ) ;
2018-12-15 01:37:34 +00:00
int const newValue = ( i > = 0 ) ? Gv_GetVar ( i , g_player [ myconnectindex ] . ps - > i , myconnectindex ) : Batol ( parm - > parms [ 2 ] ) ;
2007-12-20 19:14:38 +00:00
2018-11-18 18:06:07 +00:00
if ( ( i = hash_find ( & h_gamevars , parm - > parms [ 1 ] ) ) > = 0 )
2019-08-04 02:52:18 +00:00
{
2018-12-15 01:37:34 +00:00
Gv_SetVar ( i , newValue , spriteNum , myconnectindex ) ;
2018-10-07 05:23:05 +00:00
2019-08-04 02:52:18 +00:00
OSD_Printf ( " Variable \" %s \" for sprite %d value is now %d (input: %d) \n " , aGameVars [ i ] . szLabel , spriteNum ,
Gv_GetVar ( i , g_player [ myconnectindex ] . ps - > i , myconnectindex ) , newValue ) ;
}
else
{
OSD_Printf ( " setactorvar: %s is not a game variable! \n " , parm - > parms [ 1 ] ) ;
return OSDCMD_SHOWHELP ;
}
2007-12-20 19:14:38 +00:00
return OSDCMD_OK ;
}
2013-11-04 22:56:03 +00:00
# else
2018-11-18 18:06:15 +00:00
static int osdcmd_lua ( osdcmdptr_t parm )
2013-11-04 22:56:03 +00:00
{
// Should be used like
// lua "lua code..."
// (the quotes making the whole string passed as one argument)
int32_t ret ;
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
if ( ! L_IsInitialized ( & g_ElState ) )
{
OSD_Printf ( " Lua state is not initialized. \n " ) ;
return OSDCMD_OK ;
}
// TODO: "=<expr>" as shorthand for "print(<expr>)", like in the
// stand-alone Lua interpreter?
// TODO: reserve some table to explicitly store stuff on the top level, for
// debugging convenience?
// For the 'lua' OSD command, don't make errors appear on-screen:
el_addNewErrors = 0 ;
2016-01-27 07:30:23 +00:00
ret = L_RunString ( & g_ElState , parm - > parms [ 0 ] , - 1 , " console " ) ;
2013-11-04 22:56:03 +00:00
el_addNewErrors = 1 ;
if ( ret ! = 0 )
OSD_Printf ( " Error running the Lua code (error code %d) \n " , ret ) ;
return OSDCMD_OK ;
}
2013-01-20 21:17:06 +00:00
# endif
2007-12-20 19:14:38 +00:00
2018-11-18 18:06:15 +00:00
static int osdcmd_addpath ( osdcmdptr_t parm )
2006-04-15 03:12:08 +00:00
{
2018-11-18 18:06:07 +00:00
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2006-04-15 03:12:08 +00:00
2018-11-18 18:06:07 +00:00
addsearchpath ( parm - > parms [ 0 ] ) ;
2006-04-15 03:12:08 +00:00
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_initgroupfile ( osdcmdptr_t parm )
2006-05-23 23:43:18 +00:00
{
2018-11-18 18:06:07 +00:00
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2006-05-23 23:43:18 +00:00
2018-11-18 18:06:07 +00:00
initgroupfile ( parm - > parms [ 0 ] ) ;
2006-05-23 23:43:18 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_cmenu ( osdcmdptr_t parm )
2006-04-13 20:47:06 +00:00
{
2018-11-18 18:06:07 +00:00
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
if ( numplayers > 1 )
{
2018-11-18 18:06:07 +00:00
OSD_Printf ( " Command not allowed in multiplayer \n " ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
2006-11-15 01:16:55 +00:00
}
2018-11-18 18:06:07 +00:00
2018-12-15 01:38:32 +00:00
if ( ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) ! = MODE_MENU )
Menu_Open ( myconnectindex ) ;
2018-11-18 18:06:07 +00:00
Menu_Change ( Batol ( parm - > parms [ 0 ] ) ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2018-10-16 06:08:36 +00:00
2006-11-16 03:02:42 +00:00
2018-11-18 18:06:15 +00:00
static int osdcmd_crosshaircolor ( osdcmdptr_t parm )
2009-04-29 06:20:07 +00:00
{
if ( parm - > numparms ! = 3 )
{
OSD_Printf ( " crosshaircolor: r:%d g:%d b:%d \n " , CrosshairColors . r , CrosshairColors . g , CrosshairColors . b ) ;
return OSDCMD_SHOWHELP ;
2006-04-13 20:47:06 +00:00
}
2018-11-18 18:06:07 +00:00
uint8_t const r = Batol ( parm - > parms [ 0 ] ) ;
uint8_t const g = Batol ( parm - > parms [ 1 ] ) ;
uint8_t const b = Batol ( parm - > parms [ 2 ] ) ;
2009-04-29 06:20:07 +00:00
G_SetCrosshairColor ( r , g , b ) ;
2015-10-20 07:15:01 +00:00
if ( ! OSD_ParsingScript ( ) )
OSD_Printf ( " %s \n " , parm - > raw ) ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_give ( osdcmdptr_t parm )
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
2008-08-12 12:50:20 +00:00
if ( numplayers ! = 1 | | ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) = = 0 | |
2008-08-19 11:05:21 +00:00
g_player [ myconnectindex ] . ps - > dead_flag ! = 0 )
2006-11-15 01:16:55 +00:00
{
2008-08-12 12:50:20 +00:00
OSD_Printf ( " give: Cannot give while dead or not in a single-player game. \n " ) ;
return OSDCMD_OK ;
}
2006-11-15 01:16:55 +00:00
2008-08-12 12:50:20 +00:00
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
2006-11-15 01:16:55 +00:00
2008-08-12 12:50:20 +00:00
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " all " ) )
{
2012-09-08 22:18:34 +00:00
osdcmd_cheatsinfo_stat . cheatnum = CHEAT_STUFF ;
2008-08-12 12:50:20 +00:00
return OSDCMD_OK ;
2006-11-15 01:16:55 +00:00
}
2008-08-12 12:50:20 +00:00
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " health " ) )
{
sprite [ g_player [ myconnectindex ] . ps - > i ] . extra = g_player [ myconnectindex ] . ps - > max_player_health < < 1 ;
return OSDCMD_OK ;
}
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " weapons " ) )
{
2012-09-08 22:18:34 +00:00
osdcmd_cheatsinfo_stat . cheatnum = CHEAT_WEAPONS ;
2008-08-12 12:50:20 +00:00
return OSDCMD_OK ;
}
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " ammo " ) )
{
2009-02-19 16:47:54 +00:00
for ( i = MAX_WEAPONS - ( VOLUMEONE ? 6 : 1 ) - 1 ; i > = PISTOL_WEAPON ; i - - )
2016-08-27 01:40:46 +00:00
P_AddAmmo ( g_player [ myconnectindex ] . ps , i , g_player [ myconnectindex ] . ps - > max_ammo_amount [ i ] ) ;
2008-08-12 12:50:20 +00:00
return OSDCMD_OK ;
}
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " armor " ) )
{
2009-12-15 05:53:15 +00:00
g_player [ myconnectindex ] . ps - > inv_amount [ GET_SHIELD ] = 100 ;
2008-08-12 12:50:20 +00:00
return OSDCMD_OK ;
}
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " keys " ) )
{
2012-09-08 22:18:34 +00:00
osdcmd_cheatsinfo_stat . cheatnum = CHEAT_KEYS ;
2008-08-12 12:50:20 +00:00
return OSDCMD_OK ;
}
else if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " inventory " ) )
2006-11-15 01:16:55 +00:00
{
2012-09-08 22:18:34 +00:00
osdcmd_cheatsinfo_stat . cheatnum = CHEAT_INVENTORY ;
2006-04-13 20:47:06 +00:00
return OSDCMD_OK ;
}
return OSDCMD_SHOWHELP ;
}
2009-01-09 09:29:17 +00:00
void onvideomodechange ( int32_t newmode )
2006-04-13 20:47:06 +00:00
{
2011-01-17 03:49:34 +00:00
uint8_t palid ;
2006-04-13 20:47:06 +00:00
2012-11-06 23:06:44 +00:00
// XXX?
if ( ! newmode | | g_player [ screenpeek ] . ps - > palette < BASEPALCOUNT )
2011-01-17 03:49:34 +00:00
palid = g_player [ screenpeek ] . ps - > palette ;
2012-11-06 23:06:44 +00:00
else
palid = BASEPAL ;
2006-04-13 20:47:06 +00:00
2009-06-06 22:30:53 +00:00
# ifdef POLYMER
2018-04-12 21:03:12 +00:00
if ( videoGetRenderMode ( ) = = REND_POLYMER )
2009-06-06 22:30:53 +00:00
{
int32_t i = 0 ;
while ( i < MAXSPRITES )
{
2010-05-02 23:27:30 +00:00
if ( actor [ i ] . lightptr )
2009-06-06 22:30:53 +00:00
{
2010-05-02 23:27:30 +00:00
polymer_deletelight ( actor [ i ] . lightId ) ;
actor [ i ] . lightptr = NULL ;
actor [ i ] . lightId = - 1 ;
2009-06-06 22:30:53 +00:00
}
i + + ;
}
}
# endif
2018-04-12 21:03:12 +00:00
videoSetPalette ( ud . brightness > > 2 , palid , 0 ) ;
2012-02-02 17:34:16 +00:00
g_restorePalette = - 1 ;
2016-12-26 06:01:24 +00:00
g_crosshairSum = - 1 ;
2006-04-13 20:47:06 +00:00
}
2018-11-18 18:06:15 +00:00
static int osdcmd_button ( osdcmdptr_t parm )
2008-06-29 10:40:37 +00:00
{
2018-11-18 18:08:53 +00:00
static char const s_gamefunc_ [ ] = " gamefunc_ " ;
int constexpr strlen_gamefunc_ = ARRAY_SIZE ( s_gamefunc_ ) - 1 ;
char const * p = parm - > name + strlen_gamefunc_ ;
2008-07-03 07:37:41 +00:00
// if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game
2018-11-18 18:08:53 +00:00
CONTROL_ButtonFlags [ CONFIG_FunctionNameToNum ( p ) ] = 1 ; // FIXME
2008-06-29 10:40:37 +00:00
return OSDCMD_OK ;
}
2012-11-18 15:44:18 +00:00
const char * const ConsoleButtons [ ] =
2012-07-01 22:11:33 +00:00
{
" mouse1 " , " mouse2 " , " mouse3 " , " mouse4 " , " mwheelup " ,
" mwheeldn " , " mouse5 " , " mouse6 " , " mouse7 " , " mouse8 "
} ;
2008-07-04 01:15:32 +00:00
2018-11-18 18:06:15 +00:00
static int osdcmd_bind ( osdcmdptr_t parm )
2008-01-04 01:04:35 +00:00
{
2012-11-06 23:06:44 +00:00
if ( parm - > numparms = = 1 & & ! Bstrcasecmp ( parm - > parms [ 0 ] , " showkeys " ) )
2008-01-04 01:04:35 +00:00
{
2019-08-21 03:02:10 +00:00
for ( auto & s : sctokeylut )
OSD_Printf ( " %s \n " , s . key ) ;
2018-11-18 18:05:32 +00:00
for ( auto ConsoleButton : ConsoleButtons )
OSD_Printf ( " %s \n " , ConsoleButton ) ;
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 )
{
2018-11-18 18:05:32 +00:00
int j = 0 ;
2008-07-02 22:45:04 +00:00
OSD_Printf ( " Current key bindings: \n " ) ;
2012-11-18 15:44:18 +00:00
2018-11-18 18:05:32 +00:00
for ( int i = 0 ; i < MAXBOUNDKEYS + MAXMOUSEBUTTONS ; i + + )
2012-11-18 15:44:18 +00:00
if ( CONTROL_KeyIsBound ( i ) )
2008-07-02 22:45:04 +00:00
{
j + + ;
2012-11-17 16:47:47 +00:00
OSD_Printf ( " %-9s %s \" %s \" \n " , CONTROL_KeyBinds [ i ] . key , CONTROL_KeyBinds [ i ] . repeat ? " " : " norepeat " ,
2012-11-17 16:47:58 +00:00
CONTROL_KeyBinds [ i ] . cmdstr ) ;
2008-07-02 22:45:04 +00:00
}
2008-07-04 01:15:32 +00:00
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 ;
}
2018-11-18 18:05:32 +00:00
int i , j , repeat ;
2018-11-18 18:08:38 +00:00
for ( i = 0 ; i < ARRAY_SSIZE ( sctokeylut ) ; i + + )
{
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , sctokeylut [ i ] . key ) )
2008-06-29 11:33:51 +00:00
break ;
2018-11-18 18:08:38 +00:00
}
2008-06-30 19:06:05 +00:00
2018-11-18 18:08:38 +00:00
// didn't find the key
if ( i = = ARRAY_SSIZE ( sctokeylut ) )
2008-06-30 19:06:05 +00:00
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXMOUSEBUTTONS ; i + + )
2009-01-10 07:38:50 +00:00
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , ConsoleButtons [ i ] ) )
2008-06-30 19:06:05 +00:00
break ;
2018-11-18 18:08:38 +00:00
2008-06-30 19:06:05 +00:00
if ( i > = MAXMOUSEBUTTONS )
return OSDCMD_SHOWHELP ;
if ( parm - > numparms < 2 )
{
2017-07-05 05:42:54 +00:00
if ( CONTROL_KeyBinds [ MAXBOUNDKEYS + i ] . cmdstr & & CONTROL_KeyBinds [ MAXBOUNDKEYS + i ] . key )
OSD_Printf ( " %-9s %s \" %s \" \n " , ConsoleButtons [ i ] , CONTROL_KeyBinds [ MAXBOUNDKEYS + i ] . repeat ? " " : " norepeat " ,
CONTROL_KeyBinds [ MAXBOUNDKEYS + i ] . cmdstr ) ;
else OSD_Printf ( " %s is unbound \n " , ConsoleButtons [ i ] ) ;
2008-06-30 19:06:05 +00:00
return OSDCMD_OK ;
}
j = 1 ;
2008-07-03 07:37:41 +00:00
2012-11-18 15:44:18 +00:00
repeat = 1 ;
2018-10-25 23:29:38 +00:00
if ( ! Bstrcasecmp ( parm - > parms [ j ] , " norepeat " ) )
2008-06-30 19:06:05 +00:00
{
2012-11-18 15:44:18 +00:00
repeat = 0 ;
2008-06-30 19:06:05 +00:00
j + + ;
}
2008-07-03 07:37:41 +00:00
Bstrcpy ( tempbuf , parm - > parms [ j + + ] ) ;
2009-02-19 16:47:54 +00:00
for ( ; j < parm - > numparms ; j + + )
2008-07-03 07:37:41 +00:00
{
Bstrcat ( tempbuf , " " ) ;
Bstrcat ( tempbuf , parm - > parms [ j + + ] ) ;
}
2012-11-17 16:47:58 +00:00
2012-11-18 15:44:18 +00:00
CONTROL_BindMouse ( i , tempbuf , repeat , ConsoleButtons [ i ] ) ;
2008-07-03 07:37:41 +00:00
2008-07-07 12:35:21 +00:00
if ( ! OSD_ParsingScript ( ) )
2008-06-30 19:06:05 +00:00
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 )
{
2018-11-18 18:08:38 +00:00
if ( CONTROL_KeyIsBound ( sctokeylut [ i ] . sc ) )
OSD_Printf ( " %-9s %s \" %s \" \n " , sctokeylut [ i ] . key , CONTROL_KeyBinds [ sctokeylut [ i ] . sc ] . repeat ? " " : " norepeat " ,
CONTROL_KeyBinds [ sctokeylut [ i ] . sc ] . cmdstr ) ;
else OSD_Printf ( " %s is unbound \n " , sctokeylut [ i ] . key ) ;
2015-10-20 07:15:01 +00:00
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
2012-11-18 15:44:18 +00:00
repeat = 1 ;
2018-10-25 23:29:38 +00:00
if ( ! Bstrcasecmp ( parm - > parms [ j ] , " norepeat " ) )
2008-06-29 10:40:37 +00:00
{
2012-11-18 15:44:18 +00:00
repeat = 0 ;
2008-06-29 10:40:37 +00:00
j + + ;
}
2008-07-03 07:37:41 +00:00
Bstrcpy ( tempbuf , parm - > parms [ j + + ] ) ;
2009-02-19 16:47:54 +00:00
for ( ; j < parm - > numparms ; j + + )
2008-07-03 07:37:41 +00:00
{
Bstrcat ( tempbuf , " " ) ;
Bstrcat ( tempbuf , parm - > parms [ j + + ] ) ;
}
2012-11-17 16:47:58 +00:00
2018-11-18 18:08:38 +00:00
CONTROL_BindKey ( sctokeylut [ i ] . sc , tempbuf , repeat , sctokeylut [ i ] . key ) ;
2010-05-02 23:27:30 +00:00
2018-11-18 18:05:32 +00:00
char * cp = tempbuf ;
2010-05-07 20:45:40 +00:00
2018-11-18 18:05:32 +00:00
// Populate the keyboard config menu based on the bind.
// Take care of processing one-to-many bindings properly, too.
2018-11-18 18:06:07 +00:00
static char const s_gamefunc_ [ ] = " gamefunc_ " ;
int constexpr strlen_gamefunc_ = ARRAY_SIZE ( s_gamefunc_ ) - 1 ;
2012-11-06 23:06:40 +00:00
2018-11-18 18:05:32 +00:00
while ( ( cp = Bstrstr ( cp , s_gamefunc_ ) ) )
{
cp + = strlen_gamefunc_ ;
2012-11-06 23:06:40 +00:00
2018-11-18 18:05:32 +00:00
char * semi = Bstrchr ( cp , ' ; ' ) ;
2012-11-06 23:06:40 +00:00
2018-11-18 18:05:32 +00:00
if ( semi )
* semi = 0 ;
2012-11-06 23:06:40 +00:00
2018-11-18 18:05:32 +00:00
j = CONFIG_FunctionNameToNum ( cp ) ;
2012-11-06 23:06:40 +00:00
2018-11-18 18:05:32 +00:00
if ( semi )
cp = semi + 1 ;
if ( j ! = - 1 )
{
ud . config . KeyboardKeys [ j ] [ 1 ] = ud . config . KeyboardKeys [ j ] [ 0 ] ;
2018-11-18 18:08:38 +00:00
ud . config . KeyboardKeys [ j ] [ 0 ] = sctokeylut [ i ] . sc ;
// CONTROL_MapKey(j, sctokeylut[i].sc, ud.config.KeyboardKeys[j][0]);
2012-11-08 17:00:31 +00:00
2018-11-18 18:05:32 +00:00
if ( j = = gamefunc_Show_Console )
2018-11-18 18:08:38 +00:00
OSD_CaptureKey ( sctokeylut [ i ] . sc ) ;
2010-05-07 20:45:40 +00:00
}
}
2010-05-02 23:27:30 +00:00
2008-07-07 12:35:21 +00:00
if ( ! OSD_ParsingScript ( ) )
2008-06-29 12:53:18 +00:00
OSD_Printf ( " %s \n " , parm - > raw ) ;
2010-05-02 23:27:30 +00:00
2008-01-04 01:04:35 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_unbindall ( osdcmdptr_t UNUSED ( parm ) )
2008-06-30 07:30:48 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2008-06-30 07:30:48 +00:00
2018-11-18 18:05:32 +00:00
for ( int i = 0 ; i < MAXBOUNDKEYS ; + + i )
2012-11-18 15:44:18 +00:00
CONTROL_FreeKeyBind ( i ) ;
2010-05-07 20:45:40 +00:00
2018-11-18 18:05:32 +00:00
for ( int i = 0 ; i < MAXMOUSEBUTTONS ; + + i )
2012-11-18 15:44:18 +00:00
CONTROL_FreeMouseBind ( i ) ;
2010-05-07 20:45:40 +00:00
2018-11-18 18:05:32 +00:00
for ( auto & KeyboardKey : ud . config . KeyboardKeys )
KeyboardKey [ 0 ] = KeyboardKey [ 1 ] = 0xff ;
2010-05-07 20:45:40 +00:00
if ( ! OSD_ParsingScript ( ) )
OSD_Printf ( " unbound all controls \n " ) ;
2008-06-30 07:30:48 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_unbind ( osdcmdptr_t parm )
2008-06-29 11:33:51 +00:00
{
2018-11-18 18:05:32 +00:00
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2010-05-07 20:45:40 +00:00
2019-08-21 03:02:10 +00:00
for ( auto & ConsoleKey : sctokeylut )
2008-06-30 19:06:05 +00:00
{
2018-11-18 18:08:38 +00:00
if ( ConsoleKey . key & & ! Bstrcasecmp ( parm - > parms [ 0 ] , ConsoleKey . key ) )
2018-11-18 18:05:32 +00:00
{
2018-11-18 18:08:38 +00:00
CONTROL_FreeKeyBind ( ConsoleKey . sc ) ;
OSD_Printf ( " unbound key %s \n " , ConsoleKey . key ) ;
2018-11-18 18:05:32 +00:00
return OSDCMD_OK ;
}
2008-06-30 19:06:05 +00:00
}
2010-05-07 20:45:40 +00:00
2018-11-18 18:05:32 +00:00
for ( int i = 0 ; i < MAXMOUSEBUTTONS ; i + + )
{
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , ConsoleButtons [ i ] ) )
{
CONTROL_FreeMouseBind ( i ) ;
OSD_Printf ( " unbound %s \n " , ConsoleButtons [ i ] ) ;
return OSDCMD_OK ;
}
}
2010-05-07 20:45:40 +00:00
2018-11-18 18:05:32 +00:00
return OSDCMD_SHOWHELP ;
2008-06-29 11:33:51 +00:00
}
2019-03-20 11:24:25 +00:00
static int osdcmd_unbound ( osdcmdptr_t parm )
{
if ( parm - > numparms ! = 1 )
return OSDCMD_OK ;
int const gameFunc = CONFIG_FunctionNameToNum ( parm - > parms [ 0 ] ) ;
if ( gameFunc ! = - 1 )
ud . config . KeyboardKeys [ gameFunc ] [ 0 ] = 0 ;
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_quicksave ( osdcmdptr_t UNUSED ( parm ) )
2008-06-30 07:30:48 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2008-06-30 07:30:48 +00:00
if ( ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
OSD_Printf ( " quicksave: not in a game. \n " ) ;
2008-11-20 14:06:36 +00:00
else g_doQuickSave = 1 ;
2008-06-30 07:30:48 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_quickload ( osdcmdptr_t UNUSED ( parm ) )
2008-06-30 07:30:48 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2008-06-30 07:30:48 +00:00
if ( ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
OSD_Printf ( " quickload: not in a game. \n " ) ;
2008-11-20 14:06:36 +00:00
else g_doQuickSave = 2 ;
2008-06-30 07:30:48 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_screenshot ( osdcmdptr_t parm )
2008-07-03 07:37:41 +00:00
{
2008-07-04 01:15:32 +00:00
// KB_ClearKeysDown();
2017-06-24 21:17:46 +00:00
# ifndef EDUKE32_STANDALONE
2017-07-18 20:53:00 +00:00
static const char * fn = " duke0000.png " ;
2017-04-24 04:35:01 +00:00
# else
2017-07-18 20:53:00 +00:00
static const char * fn = " capt0000.png " ;
2017-04-24 04:35:01 +00:00
# endif
2017-07-18 20:53:00 +00:00
if ( parm - > numparms = = 1 & & ! Bstrcasecmp ( parm - > parms [ 0 ] , " tga " ) )
2018-04-12 21:03:47 +00:00
videoCaptureScreenTGA ( fn , 0 ) ;
else videoCaptureScreen ( fn , 0 ) ;
2017-07-18 20:53:00 +00:00
2008-07-03 07:37:41 +00:00
return OSDCMD_OK ;
}
2013-06-20 18:31:48 +00:00
#if 0
2018-11-18 18:06:15 +00:00
static int osdcmd_savestate ( osdcmdptr_t UNUSED ( parm ) )
2008-07-16 09:27:08 +00:00
{
UNREFERENCED_PARAMETER ( parm ) ;
2013-05-19 19:29:26 +00:00
G_SaveMapState ( ) ;
2008-07-16 09:27:08 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_restorestate ( osdcmdptr_t UNUSED ( parm ) )
2008-07-16 09:27:08 +00:00
{
UNREFERENCED_PARAMETER ( parm ) ;
2013-05-19 19:29:26 +00:00
G_RestoreMapState ( ) ;
2008-07-16 09:27:08 +00:00
return OSDCMD_OK ;
}
2013-05-19 19:29:23 +00:00
# endif
2008-07-16 09:27:08 +00:00
2011-03-19 18:07:12 +00:00
# ifdef DEBUGGINGAIDS
2018-11-18 18:06:15 +00:00
static int osdcmd_inittimer ( osdcmdptr_t parm )
2008-11-05 11:49:13 +00:00
{
if ( parm - > numparms ! = 1 )
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( " %dHz timer \n " , g_timerTicsPerSecond ) ;
2008-11-05 11:49:13 +00:00
return OSDCMD_SHOWHELP ;
}
2013-02-16 18:52:56 +00:00
G_InitTimer ( Batol ( parm - > parms [ 0 ] ) ) ;
2008-11-05 11:49:13 +00:00
OSD_Printf ( " %s \n " , parm - > raw ) ;
return OSDCMD_OK ;
}
2011-03-19 18:07:12 +00:00
# endif
2008-11-05 11:49:13 +00:00
2018-03-08 00:29:41 +00:00
# if !defined NETCODE_DISABLE
2019-03-21 09:27:43 +00:00
static int osdcmd_name ( osdcmdptr_t parm )
{
char namebuf [ 32 ] ;
if ( parm - > numparms ! = 1 )
{
OSD_Printf ( " \" name \" is \" %s \" \n " , szPlayerName ) ;
return OSDCMD_SHOWHELP ;
}
Bstrcpy ( tempbuf , parm - > parms [ 0 ] ) ;
while ( Bstrlen ( OSD_StripColors ( namebuf , tempbuf ) ) > 10 )
tempbuf [ Bstrlen ( tempbuf ) - 1 ] = ' \0 ' ;
Bstrncpy ( szPlayerName , tempbuf , sizeof ( szPlayerName ) - 1 ) ;
szPlayerName [ sizeof ( szPlayerName ) - 1 ] = ' \0 ' ;
OSD_Printf ( " name %s \n " , szPlayerName ) ;
Net_SendClientInfo ( ) ;
return OSDCMD_OK ;
}
2019-03-21 09:27:53 +00:00
static int osdcmd_dumpmapstate ( osdfuncparm_t const * const )
2019-03-21 09:27:43 +00:00
{
// this command takes no parameters
DumpMapStateHistory ( ) ;
return OSDCMD_OK ;
}
2019-03-21 09:27:53 +00:00
static int osdcmd_playerinfo ( osdfuncparm_t const * const )
2019-03-21 09:27:43 +00:00
{
OSD_Printf ( " Your player index is %d. \n " , myconnectindex ) ;
for ( int32_t playerIndex = 0 ; playerIndex < MAXPLAYERS ; playerIndex + + )
{
if ( g_player [ playerIndex ] . ps = = nullptr )
{
OSD_Printf ( " g_player[%d]: ps unallocated. \n " , playerIndex ) ;
}
else
{
OSD_Printf ( " g_player[%d]: ps->i is %d. \n " , playerIndex , g_player [ playerIndex ] . ps - > i ) ;
}
}
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_disconnect ( osdcmdptr_t UNUSED ( parm ) )
2009-12-14 05:23:29 +00:00
{
2017-06-27 02:24:14 +00:00
UNREFERENCED_CONST_PARAMETER ( parm ) ;
2009-12-14 09:54:11 +00:00
g_netDisconnect = 1 ;
2009-12-14 05:23:29 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_connect ( osdcmdptr_t parm )
2009-12-14 05:23:29 +00:00
{
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
Net_Connect ( parm - > parms [ 0 ] ) ;
G_BackToMenu ( ) ;
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_password ( osdcmdptr_t parm )
2009-12-14 20:14:12 +00:00
{
if ( parm - > numparms < 1 )
{
2010-01-16 23:08:17 +00:00
Bmemset ( g_netPassword , 0 , sizeof ( g_netPassword ) ) ;
2009-12-14 20:14:12 +00:00
return OSDCMD_OK ;
}
2016-01-11 05:05:25 +00:00
Bstrncpy ( g_netPassword , ( parm - > raw ) + 9 , sizeof ( g_netPassword ) - 1 ) ;
2009-12-14 20:14:12 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_listplayers ( osdcmdptr_t parm )
2009-12-15 05:53:15 +00:00
{
2010-08-02 08:13:51 +00:00
ENetPeer * currentPeer ;
2009-12-17 11:17:48 +00:00
char ipaddr [ 32 ] ;
2009-12-15 05:53:15 +00:00
2011-02-25 21:50:19 +00:00
if ( parm & & parm - > numparms ! = 0 )
2009-12-15 05:53:15 +00:00
return OSDCMD_SHOWHELP ;
2010-01-16 23:08:17 +00:00
if ( ! g_netServer )
2009-12-15 05:53:15 +00:00
{
initprintf ( " You are not the server. \n " ) ;
return OSDCMD_OK ;
}
2011-02-25 21:50:19 +00:00
initprintf ( " Connected clients: \n " ) ;
2010-01-16 23:08:17 +00:00
for ( currentPeer = g_netServer - > peers ;
2010-01-23 22:12:02 +00:00
currentPeer < & g_netServer - > peers [ g_netServer - > peerCount ] ;
+ + currentPeer )
2009-12-15 05:53:15 +00:00
{
if ( currentPeer - > state ! = ENET_PEER_STATE_CONNECTED )
continue ;
2009-12-17 11:17:48 +00:00
enet_address_get_host_ip ( & currentPeer - > address , ipaddr , sizeof ( ipaddr ) ) ;
initprintf ( " %x %s %s \n " , currentPeer - > address . host , ipaddr ,
2010-01-23 22:12:02 +00:00
g_player [ ( intptr_t ) currentPeer - > data ] . user_name ) ;
2009-12-15 05:53:15 +00:00
}
2013-12-31 11:51:54 +00:00
2009-12-15 05:53:15 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_kick ( osdcmdptr_t parm )
2009-12-17 11:17:48 +00:00
{
2010-08-02 08:13:51 +00:00
ENetPeer * currentPeer ;
2009-12-17 11:17:48 +00:00
uint32_t hexaddr ;
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2010-01-16 23:08:17 +00:00
if ( ! g_netServer )
2009-12-17 11:17:48 +00:00
{
initprintf ( " You are not the server. \n " ) ;
return OSDCMD_OK ;
}
2010-01-16 23:08:17 +00:00
for ( currentPeer = g_netServer - > peers ;
2010-01-23 22:12:02 +00:00
currentPeer < & g_netServer - > peers [ g_netServer - > peerCount ] ;
+ + currentPeer )
2009-12-17 11:17:48 +00:00
{
if ( currentPeer - > state ! = ENET_PEER_STATE_CONNECTED )
continue ;
2011-02-12 13:25:24 +00:00
sscanf ( parm - > parms [ 0 ] , " % " SCNx32 " " , & hexaddr ) ;
2009-12-17 11:17:48 +00:00
if ( currentPeer - > address . host = = hexaddr )
{
initprintf ( " Kicking %x (%s) \n " , currentPeer - > address . host ,
2010-01-23 22:12:02 +00:00
g_player [ ( intptr_t ) currentPeer - > data ] . user_name ) ;
enet_peer_disconnect ( currentPeer , DISC_KICKED ) ;
2009-12-17 11:17:48 +00:00
return OSDCMD_OK ;
}
}
initprintf ( " Player %s not found! \n " , parm - > parms [ 0 ] ) ;
2011-02-25 21:50:19 +00:00
osdcmd_listplayers ( NULL ) ;
2013-12-31 11:51:54 +00:00
2009-12-17 11:17:48 +00:00
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_kickban ( osdcmdptr_t parm )
2009-12-17 11:17:48 +00:00
{
2010-08-02 08:13:51 +00:00
ENetPeer * currentPeer ;
2009-12-17 11:17:48 +00:00
uint32_t hexaddr ;
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2010-01-16 23:08:17 +00:00
if ( ! g_netServer )
2009-12-17 11:17:48 +00:00
{
initprintf ( " You are not the server. \n " ) ;
return OSDCMD_OK ;
}
2010-01-16 23:08:17 +00:00
for ( currentPeer = g_netServer - > peers ;
2010-01-23 22:12:02 +00:00
currentPeer < & g_netServer - > peers [ g_netServer - > peerCount ] ;
+ + currentPeer )
2009-12-17 11:17:48 +00:00
{
if ( currentPeer - > state ! = ENET_PEER_STATE_CONNECTED )
continue ;
2011-02-12 13:25:24 +00:00
sscanf ( parm - > parms [ 0 ] , " % " SCNx32 " " , & hexaddr ) ;
2010-08-02 08:13:51 +00:00
2010-05-07 20:45:40 +00:00
// TODO: implement banning logic
2009-12-17 11:17:48 +00:00
if ( currentPeer - > address . host = = hexaddr )
{
char ipaddr [ 32 ] ;
enet_address_get_host_ip ( & currentPeer - > address , ipaddr , sizeof ( ipaddr ) ) ;
initprintf ( " Host %s is now banned. \n " , ipaddr ) ;
initprintf ( " Kicking %x (%s) \n " , currentPeer - > address . host ,
2010-01-23 22:12:02 +00:00
g_player [ ( intptr_t ) currentPeer - > data ] . user_name ) ;
enet_peer_disconnect ( currentPeer , DISC_BANNED ) ;
2009-12-17 11:17:48 +00:00
return OSDCMD_OK ;
}
}
initprintf ( " Player %s not found! \n " , parm - > parms [ 0 ] ) ;
2011-02-25 21:50:19 +00:00
osdcmd_listplayers ( NULL ) ;
2013-12-31 11:51:54 +00:00
2009-12-17 11:17:48 +00:00
return OSDCMD_OK ;
}
2013-12-31 11:51:54 +00:00
# endif
2009-12-17 11:17:48 +00:00
2018-11-18 18:06:15 +00:00
static int osdcmd_purgesaves ( osdcmdptr_t UNUSED ( parm ) )
2018-03-08 03:55:41 +00:00
{
UNREFERENCED_CONST_PARAMETER ( parm ) ;
G_DeleteOldSaves ( ) ;
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_printtimes ( osdcmdptr_t UNUSED ( parm ) )
2018-03-08 00:29:41 +00:00
{
UNREFERENCED_CONST_PARAMETER ( parm ) ;
char buf [ 32 ] ;
int32_t maxlen = 0 ;
int32_t haveev = 0 , haveac = 0 ;
2018-11-18 18:06:07 +00:00
static char const s_event_ [ ] = " EVENT_ " ;
int constexpr strlen_event_ = ARRAY_SIZE ( s_event_ ) - 1 ;
2018-03-08 00:29:41 +00:00
2018-11-18 18:06:07 +00:00
for ( auto & EventName : EventNames )
2018-03-08 00:29:41 +00:00
{
2018-11-18 18:06:07 +00:00
int const len = Bstrlen ( EventName + strlen_event_ ) ;
2018-11-18 18:07:15 +00:00
Bassert ( len < ARRAY_SSIZE ( buf ) ) ;
2018-03-08 00:29:41 +00:00
maxlen = max ( len , maxlen ) ;
}
for ( int i = 0 ; i < MAXEVENTS ; i + + )
if ( g_eventCalls [ i ] )
{
2018-11-18 18:06:07 +00:00
int32_t n = Bsprintf ( buf , " %s " , EventNames [ i ] + strlen_event_ ) ;
2018-03-08 00:29:41 +00:00
if ( ! haveev )
{
haveev = 1 ;
2018-03-08 05:15:05 +00:00
OSD_Printf ( " \n event times: event, total calls, total time [ms], mean time/call [us] \n " ) ;
2018-03-08 00:29:41 +00:00
}
2018-03-08 02:39:21 +00:00
buf [ n ] = 0 ;
2018-03-08 00:29:41 +00:00
2018-03-08 05:15:05 +00:00
OSD_Printf ( " %17s, %8d, %10.3f, %10.3f, \n " ,
2018-03-08 00:29:41 +00:00
buf , g_eventCalls [ i ] , g_eventTotalMs [ i ] ,
1000 * g_eventTotalMs [ i ] / g_eventCalls [ i ] ) ;
}
for ( int i = 0 ; i < MAXTILES ; i + + )
if ( g_actorCalls [ i ] )
{
if ( ! haveac )
{
haveac = 1 ;
2018-03-08 05:15:05 +00:00
OSD_Printf ( " \n actor times: tile, total calls, total time [ms], {min,mean,max} time/call [us] \n " ) ;
2018-03-08 00:29:41 +00:00
}
buf [ 0 ] = 0 ;
for ( int ii = 0 ; ii < g_labelCnt ; ii + + )
{
2018-03-08 02:39:21 +00:00
if ( labelcode [ ii ] = = i & & labeltype [ ii ] & LABEL_ACTOR )
2018-03-08 00:29:41 +00:00
{
Bstrcpy ( buf , label + ( ii < < 6 ) ) ;
break ;
}
}
2018-03-08 02:39:21 +00:00
if ( ! buf [ 0 ] ) Bsprintf ( buf , " %d " , i ) ;
2018-03-08 00:29:41 +00:00
2018-03-08 05:15:05 +00:00
OSD_Printf ( " %17s, %8d, %9.3f, %9.3f, %9.3f, %9.3f, \n " ,
2018-03-08 00:29:41 +00:00
buf , g_actorCalls [ i ] , g_actorTotalMs [ i ] ,
1000 * g_actorMinMs [ i ] ,
1000 * g_actorTotalMs [ i ] / g_actorCalls [ i ] ,
1000 * g_actorMaxMs [ i ] ) ;
}
return OSDCMD_OK ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_cvar_set_game ( osdcmdptr_t parm )
2009-04-29 19:43:51 +00:00
{
2018-11-18 18:06:07 +00:00
int const r = osdcmd_cvar_set ( parm ) ;
2009-04-29 19:43:51 +00:00
2010-05-07 20:45:40 +00:00
if ( r ! = OSDCMD_OK ) return r ;
2018-07-14 21:36:44 +00:00
if ( ! Bstrcasecmp ( parm - > name , " r_upscalefactor " ) )
{
if ( in3dmode ( ) )
{
videoSetGameMode ( fullscreen , xres , yres , bpp , ud . detail ) ;
}
}
else if ( ! Bstrcasecmp ( parm - > name , " r_size " ) )
2013-01-17 21:59:11 +00:00
{
ud . statusbarmode = ( ud . screen_size < 8 ) ;
G_UpdateScreenArea ( ) ;
}
2018-12-15 01:40:14 +00:00
else if ( ! Bstrcasecmp ( parm - > name , " r_maxfps " ) | | ! Bstrcasecmp ( parm - > name , " r_maxfpsoffset " ) )
2009-04-29 19:43:51 +00:00
{
2017-06-24 06:31:12 +00:00
if ( r_maxfps ! = 0 ) r_maxfps = clamp ( r_maxfps , 30 , 1000 ) ;
2019-01-12 00:21:53 +00:00
g_frameDelay = calcFrameDelay ( r_maxfps + r_maxfpsoffset ) ;
2010-05-07 20:45:40 +00:00
}
else if ( ! Bstrcasecmp ( parm - > name , " r_ambientlight " ) )
{
2010-05-25 10:56:00 +00:00
if ( r_ambientlight = = 0 )
r_ambientlightrecip = 256.f ;
else r_ambientlightrecip = 1.f / r_ambientlight ;
2010-05-07 20:45:40 +00:00
}
else if ( ! Bstrcasecmp ( parm - > name , " in_mouse " ) )
{
2018-11-18 18:13:02 +00:00
CONTROL_MouseEnabled = ( ud . setup . usemouse & & CONTROL_MousePresent ) ;
2010-05-07 20:45:40 +00:00
}
else if ( ! Bstrcasecmp ( parm - > name , " in_joystick " ) )
{
2018-11-18 18:13:02 +00:00
CONTROL_JoystickEnabled = ( ud . setup . usejoystick & & CONTROL_JoyPresent ) ;
2010-05-07 20:45:40 +00:00
}
else if ( ! Bstrcasecmp ( parm - > name , " vid_gamma " ) )
{
2010-07-03 08:53:57 +00:00
ud . brightness = GAMMA_CALC ;
2010-05-07 20:45:40 +00:00
ud . brightness < < = 2 ;
2018-04-12 21:03:12 +00:00
videoSetPalette ( ud . brightness > > 2 , g_player [ myconnectindex ] . ps - > palette , 0 ) ;
2010-05-07 20:45:40 +00:00
}
2012-05-05 22:23:44 +00:00
else if ( ! Bstrcasecmp ( parm - > name , " vid_brightness " ) | | ! Bstrcasecmp ( parm - > name , " vid_contrast " ) )
2010-05-07 20:45:40 +00:00
{
2018-04-12 21:03:12 +00:00
videoSetPalette ( ud . brightness > > 2 , g_player [ myconnectindex ] . ps - > palette , 0 ) ;
2010-05-07 20:45:40 +00:00
}
2013-04-14 06:42:36 +00:00
else if ( ! Bstrcasecmp ( parm - > name , " hud_scale " )
| | ! Bstrcasecmp ( parm - > name , " hud_statusbarmode " )
| | ! Bstrcasecmp ( parm - > name , " r_rotatespritenowidescreen " ) )
2010-05-07 20:45:40 +00:00
{
G_UpdateScreenArea ( ) ;
}
else if ( ! Bstrcasecmp ( parm - > name , " skill " ) )
{
if ( numplayers > 1 )
2009-04-29 19:43:51 +00:00
return r ;
2011-04-07 01:16:29 +00:00
ud . player_skill = ud . m_player_skill ;
2009-04-29 19:43:51 +00:00
}
2010-05-09 22:12:29 +00:00
else if ( ! Bstrcasecmp ( parm - > name , " color " ) )
{
2018-10-25 23:33:58 +00:00
ud . color = G_CheckPlayerColor ( ud . color ) ;
2010-05-09 22:12:29 +00:00
g_player [ 0 ] . ps - > palookup = g_player [ 0 ] . pcolor = ud . color ;
}
2014-04-07 06:17:25 +00:00
else if ( ! Bstrcasecmp ( parm - > name , " osdscale " ) )
{
2014-10-25 03:25:35 +00:00
osdrscale = 1.f / osdscale ;
2014-04-07 06:17:25 +00:00
if ( xdim & & ydim )
OSD_ResizeDisplay ( xdim , ydim ) ;
2015-03-24 00:39:52 +00:00
}
else if ( ! Bstrcasecmp ( parm - > name , " wchoice " ) )
{
if ( parm - > numparms = = 1 )
{
if ( g_forceWeaponChoice ) // rewrite ud.wchoice because osdcmd_cvar_set already changed it
{
int j = 0 ;
while ( j < 10 )
{
ud . wchoice [ j ] = g_player [ myconnectindex ] . wchoice [ j ] + ' 0 ' ;
j + + ;
}
ud . wchoice [ j ] = 0 ;
}
else
{
char const * c = parm - > parms [ 0 ] ;
if ( * c )
{
int j = 0 ;
while ( * c & & j < 10 )
{
g_player [ myconnectindex ] . wchoice [ j ] = * c - ' 0 ' ;
c + + ;
j + + ;
}
while ( j < 10 )
{
if ( j = = 9 )
g_player [ myconnectindex ] . wchoice [ 9 ] = 1 ;
else
g_player [ myconnectindex ] . wchoice [ j ] = 2 ;
j + + ;
}
}
}
g_forceWeaponChoice = 0 ;
}
2014-04-07 06:17:25 +00:00
2015-03-24 00:39:52 +00:00
/* Net_SendClientInfo();*/
2014-04-07 06:17:25 +00:00
}
2010-05-09 22:12:29 +00:00
return r ;
}
2018-11-18 18:06:15 +00:00
static int osdcmd_cvar_set_multi ( osdcmdptr_t parm )
2010-05-09 22:12:29 +00:00
{
2018-11-18 18:06:07 +00:00
int const r = osdcmd_cvar_set_game ( parm ) ;
2010-05-09 22:12:29 +00:00
if ( r ! = OSDCMD_OK ) return r ;
G_UpdatePlayerFromMenu ( ) ;
2009-04-29 19:43:51 +00:00
return r ;
}
2009-01-09 09:29:17 +00:00
int32_t registerosdcommands ( void )
2006-04-13 20:47:06 +00:00
{
2017-06-27 02:24:14 +00:00
static osdcvardata_t cvars_game [ ] =
2009-04-29 06:20:07 +00:00
{
2019-06-25 18:34:52 +00:00
{ " benchmarkmode " , " Set the benchmark mode (0: off, 1: performance test, 2: generate reference screenshots for correctness testing) " , ( void * ) & g_BenchmarkMode , CVAR_INT | CVAR_NOSAVE , 0 , 2 } ,
2013-05-17 03:43:20 +00:00
{ " crosshair " , " enable/disable crosshair " , ( void * ) & ud . crosshair , CVAR_BOOL , 0 , 1 } ,
2010-05-02 23:27:30 +00:00
2014-09-30 04:03:17 +00:00
{ " cl_autoaim " , " enable/disable weapon autoaim " , ( void * ) & ud . config . AutoAim , CVAR_INT | CVAR_MULTI , 0 , 3 } ,
2013-05-17 03:43:20 +00:00
{ " cl_automsg " , " enable/disable automatically sending messages to all players " , ( void * ) & ud . automsg , CVAR_BOOL , 0 , 1 } ,
{ " cl_autorun " , " enable/disable autorun " , ( void * ) & ud . auto_run , CVAR_BOOL , 0 , 1 } ,
2018-07-21 00:17:57 +00:00
{ " cl_autosave " , " enable/disable autosaves " , ( void * ) & ud . autosave , CVAR_BOOL , 0 , 1 } ,
{ " cl_autosavedeletion " , " enable/disable automatic deletion of autosaves " , ( void * ) & ud . autosavedeletion , CVAR_BOOL , 0 , 1 } ,
{ " cl_maxautosaves " , " number of autosaves to keep before deleting the oldest " , ( void * ) & ud . maxautosaves , CVAR_INT , 1 , 100 } ,
2013-05-17 03:43:20 +00:00
{ " cl_autovote " , " enable/disable automatic voting " , ( void * ) & ud . autovote , CVAR_INT , 0 , 2 } ,
2010-05-02 23:27:30 +00:00
2015-03-24 10:49:03 +00:00
{ " cl_cheatmask " , " configure what cheats show in the cheats menu " , ( void * ) & cl_cheatmask , CVAR_UINT , 0 , ~ 0 } ,
2013-05-17 03:43:20 +00:00
{ " cl_obituaries " , " enable/disable multiplayer death messages " , ( void * ) & ud . obituaries , CVAR_BOOL , 0 , 1 } ,
{ " cl_democams " , " enable/disable demo playback cameras " , ( void * ) & ud . democams , CVAR_BOOL , 0 , 1 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " cl_idplayers " , " enable/disable name display when aiming at opponents " , ( void * ) & ud . idplayers , CVAR_BOOL , 0 , 1 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " cl_runmode " , " enable/disable modernized run key operation " , ( void * ) & ud . runkey_mode , CVAR_BOOL , 0 , 1 } ,
2012-10-14 14:43:37 +00:00
2014-03-30 20:36:00 +00:00
{ " cl_showcoords " , " show your position in the game world " , ( void * ) & ud . coords , CVAR_INT , 0 ,
# ifdef USE_OPENGL
2
# else
1
# endif
} ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " cl_viewbob " , " enable/disable player head bobbing " , ( void * ) & ud . viewbob , CVAR_BOOL , 0 , 1 } ,
2010-05-09 22:12:29 +00:00
2013-05-17 03:43:20 +00:00
{ " cl_weaponsway " , " enable/disable player weapon swaying " , ( void * ) & ud . weaponsway , CVAR_BOOL , 0 , 1 } ,
{ " cl_weaponswitch " , " enable/disable auto weapon switching " , ( void * ) & ud . weaponswitch , CVAR_INT | CVAR_MULTI , 0 , 7 } ,
2010-05-02 23:27:30 +00:00
2014-02-16 19:16:05 +00:00
{ " color " , " changes player palette " , ( void * ) & ud . color , CVAR_INT | CVAR_MULTI , 0 , MAXPALOOKUPS - 1 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " crosshairscale " , " changes the size of the crosshair " , ( void * ) & ud . crosshairscale , CVAR_INT , 10 , 100 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " demorec_diffs " , " enable/disable diff recording in demos " , ( void * ) & demorec_diffs_cvar , CVAR_BOOL , 0 , 1 } ,
{ " demorec_force " , " enable/disable forced demo recording " , ( void * ) & demorec_force_cvar , CVAR_BOOL | CVAR_NOSAVE , 0 , 1 } ,
2010-08-02 08:13:51 +00:00
{
2013-05-17 03:43:20 +00:00
" demorec_difftics " , " sets game tic interval after which a diff is recorded " ,
2012-09-08 22:18:40 +00:00
( void * ) & demorec_difftics_cvar , CVAR_INT , 2 , 60 * REALGAMETICSPERSEC
2010-08-02 08:13:51 +00:00
} ,
2019-05-19 03:54:29 +00:00
{ " demorec_diffcompress " , " Compression method for diffs. (0: none, 1: KSLZW) " , ( void * ) & demorec_diffcompress_cvar , CVAR_BOOL , 0 , 1 } ,
{ " demorec_synccompress " , " Compression method for input. (0: none, 1: KSLZW) " , ( void * ) & demorec_synccompress_cvar , CVAR_BOOL , 0 , 1 } ,
2013-05-17 03:43:20 +00:00
{ " demorec_seeds " , " enable/disable recording of random seed for later sync checking " , ( void * ) & demorec_seeds_cvar , CVAR_BOOL , 0 , 1 } ,
{ " demoplay_diffs " , " enable/disable application of diffs in demo playback " , ( void * ) & demoplay_diffs , CVAR_BOOL , 0 , 1 } ,
{ " demoplay_showsync " , " enable/disable display of sync status " , ( void * ) & demoplay_showsync , CVAR_BOOL , 0 , 1 } ,
2019-09-02 05:55:15 +00:00
{ " fov " , " change the field of view " , ( void * ) & ud . fov , CVAR_INT , 60 , 140 } ,
2019-02-18 22:02:33 +00:00
2018-01-26 04:34:57 +00:00
{ " hud_althud " , " enable/disable alternate mini-hud " , ( void * ) & ud . althud , CVAR_BOOL , 0 , 1 } ,
2018-01-29 11:14:20 +00:00
{ " hud_custom " , " change the custom hud " , ( void * ) & ud . statusbarcustom , CVAR_INT , 0 , ud . statusbarrange } ,
2018-01-26 04:34:57 +00:00
{ " hud_position " , " aligns the status bar to the bottom/top " , ( void * ) & ud . hudontop , CVAR_BOOL , 0 , 1 } ,
2013-05-17 03:43:20 +00:00
{ " hud_bgstretch " , " enable/disable background image stretching in wide resolutions " , ( void * ) & ud . bgstretch , CVAR_BOOL , 0 , 1 } ,
{ " hud_messagetime " , " length of time to display multiplayer chat messages " , ( void * ) & ud . msgdisptime , CVAR_INT , 0 , 3600 } ,
2016-01-27 07:30:18 +00:00
{ " hud_numbertile " , " first tile in alt hud number set " , ( void * ) & althud_numbertile , CVAR_INT , 0 , MAXUSERTILES - 10 } ,
{ " hud_numberpal " , " pal for alt hud numbers " , ( void * ) & althud_numberpal , CVAR_INT , 0 , MAXPALOOKUPS - 1 } ,
2013-05-17 03:43:20 +00:00
{ " hud_shadows " , " enable/disable althud shadows " , ( void * ) & althud_shadows , CVAR_BOOL , 0 , 1 } ,
{ " hud_flashing " , " enable/disable althud flashing " , ( void * ) & althud_flashing , CVAR_BOOL , 0 , 1 } ,
{ " hud_glowingquotes " , " enable/disable \" glowing \" quote text " , ( void * ) & hud_glowingquotes , CVAR_BOOL , 0 , 1 } ,
2019-09-02 05:55:27 +00:00
{ " hud_scale " , " changes the hud scale " , ( void * ) & ud . statusbarscale , CVAR_INT | CVAR_FUNCPTR , 50 , 100 } ,
2013-05-17 03:43:20 +00:00
{ " hud_showmapname " , " enable/disable map name display on load " , ( void * ) & hud_showmapname , CVAR_BOOL , 0 , 1 } ,
{ " hud_stats " , " enable/disable level statistics display " , ( void * ) & ud . levelstats , CVAR_BOOL , 0 , 1 } ,
{ " hud_textscale " , " sets multiplayer chat message size " , ( void * ) & ud . textscale , CVAR_INT , 100 , 400 } ,
{ " hud_weaponscale " , " changes the weapon scale " , ( void * ) & ud . weaponscale , CVAR_INT , 10 , 100 } ,
{ " hud_statusbarmode " , " change overlay mode of status bar " , ( void * ) & ud . statusbarmode , CVAR_BOOL | CVAR_FUNCPTR , 0 , 1 } ,
2015-02-11 05:22:32 +00:00
# ifdef EDUKE32_TOUCH_DEVICES
{ " hud_hidestick " , " hide the touch input stick " , ( void * ) & droidinput . hideStick , CVAR_BOOL , 0 , 1 } ,
# endif
2018-11-18 18:13:02 +00:00
{ " in_joystick " , " enables input from the joystick if it is present " , ( void * ) & ud . setup . usejoystick , CVAR_BOOL | CVAR_FUNCPTR , 0 , 1 } ,
{ " in_mouse " , " enables input from the mouse if it is present " , ( void * ) & ud . setup . usemouse , CVAR_BOOL | CVAR_FUNCPTR , 0 , 1 } ,
2013-05-17 03:43:20 +00:00
{ " in_aimmode " , " 0:toggle, 1:hold to aim " , ( void * ) & ud . mouseaiming , CVAR_BOOL , 0 , 1 } ,
2010-08-02 08:13:51 +00:00
{
2013-05-17 03:43:20 +00:00
" in_mousebias " , " emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time " ,
2010-08-02 08:13:51 +00:00
( void * ) & ud . config . MouseBias , CVAR_INT , 0 , 32
} ,
2013-05-17 03:43:20 +00:00
{ " in_mousedeadzone " , " amount of mouse movement to filter out " , ( void * ) & ud . config . MouseDeadZone , CVAR_INT , 0 , 512 } ,
{ " in_mouseflip " , " invert vertical mouse movement " , ( void * ) & ud . mouseflip , CVAR_BOOL , 0 , 1 } ,
2014-12-06 21:05:36 +00:00
{ " in_mousemode " , " toggles vertical mouse view " , ( void * ) & g_myAimMode , CVAR_BOOL , 0 , 1 } ,
2013-05-17 03:43:20 +00:00
{ " in_mousesmoothing " , " enable/disable mouse input smoothing " , ( void * ) & ud . config . SmoothInput , CVAR_BOOL , 0 , 1 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " mus_enabled " , " enables/disables music " , ( void * ) & ud . config . MusicToggle , CVAR_BOOL , 0 , 1 } ,
2014-12-06 21:05:36 +00:00
{ " mus_volume " , " controls music volume " , ( void * ) & ud . config . MusicVolume , CVAR_INT , 0 , 255 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " osdhightile " , " enable/disable hires art replacements for console text " , ( void * ) & osdhightile , CVAR_BOOL , 0 , 1 } ,
2014-09-30 04:13:14 +00:00
{ " osdscale " , " adjust console text size " , ( void * ) & osdscale , CVAR_FLOAT | CVAR_FUNCPTR , 1 , 4 } ,
2010-05-09 22:12:29 +00:00
2014-04-17 20:00:24 +00:00
{ " r_camrefreshdelay " , " minimum delay between security camera sprite updates, 120 = 1 second " , ( void * ) & ud . camera_time , CVAR_INT , 1 , 240 } ,
2013-05-17 03:43:20 +00:00
{ " r_drawweapon " , " enable/disable weapon drawing " , ( void * ) & ud . drawweapon , CVAR_INT , 0 , 2 } ,
2018-05-08 17:32:11 +00:00
{ " r_showfps " , " show the frame rate counter " , ( void * ) & ud . showfps , CVAR_INT , 0 , 3 } ,
2019-01-12 00:22:10 +00:00
{ " r_showfpsperiod " , " time in seconds before averaging min and max stats for r_showfps 2+ " , ( void * ) & ud . frameperiod , CVAR_INT , 0 , 5 } ,
2013-05-17 03:43:20 +00:00
{ " r_shadows " , " enable/disable sprite and model shadows " , ( void * ) & ud . shadows , CVAR_BOOL , 0 , 1 } ,
{ " r_size " , " change size of viewable area " , ( void * ) & ud . screen_size , CVAR_INT | CVAR_FUNCPTR , 0 , 64 } ,
{ " r_rotatespritenowidescreen " , " pass bit 1024 to all CON rotatesprite calls " , ( void * ) & g_rotatespriteNoWidescreen , CVAR_BOOL | CVAR_FUNCPTR , 0 , 1 } ,
2018-07-14 21:36:44 +00:00
{ " r_upscalefactor " , " increase performance by rendering at upscalefactor less than the screen resolution and upscale to the full resolution in the software renderer " , ( void * ) & ud . detail , CVAR_INT | CVAR_FUNCPTR , 1 , 16 } ,
2013-05-17 03:43:20 +00:00
{ " r_precache " , " enable/disable the pre-level caching routine " , ( void * ) & ud . config . useprecache , CVAR_BOOL , 0 , 1 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " r_ambientlight " , " sets the global map light level " , ( void * ) & r_ambientlight , CVAR_FLOAT | CVAR_FUNCPTR , 0 , 10 } ,
{ " r_maxfps " , " limit the frame rate " , ( void * ) & r_maxfps , CVAR_INT | CVAR_FUNCPTR , 0 , 1000 } ,
2018-12-15 01:40:14 +00:00
{ " r_maxfpsoffset " , " menu-controlled offset for r_maxfps " , ( void * ) & r_maxfpsoffset , CVAR_INT | CVAR_FUNCPTR , - 10 , 10 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " sensitivity " , " changes the mouse sensitivity " , ( void * ) & CONTROL_MouseSensitivity , CVAR_FLOAT | CVAR_FUNCPTR , 0 , 25 } ,
2010-05-02 23:27:30 +00:00
2018-02-17 00:06:01 +00:00
{ " skill " , " changes the game skill setting " , ( void * ) & ud . m_player_skill , CVAR_INT | CVAR_FUNCPTR | CVAR_NOSAVE /*|CVAR_NOMULTI*/ , 0 , 5 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " snd_ambience " , " enables/disables ambient sounds " , ( void * ) & ud . config . AmbienceToggle , CVAR_BOOL , 0 , 1 } ,
{ " snd_enabled " , " enables/disables sound effects " , ( void * ) & ud . config . SoundToggle , CVAR_BOOL , 0 , 1 } ,
2018-10-25 23:32:50 +00:00
{ " snd_fxvolume " , " controls volume for sound effects " , ( void * ) & ud . config . FXVolume , CVAR_INT , 0 , 255 } ,
2013-05-17 03:43:20 +00:00
{ " snd_mixrate " , " sound mixing rate " , ( void * ) & ud . config . MixRate , CVAR_INT , 0 , 48000 } ,
{ " snd_numchannels " , " the number of sound channels " , ( void * ) & ud . config . NumChannels , CVAR_INT , 0 , 2 } ,
2018-07-01 04:51:19 +00:00
{ " snd_numvoices " , " the number of concurrent sounds " , ( void * ) & ud . config . NumVoices , CVAR_INT , 1 , 128 } ,
2016-01-27 07:30:18 +00:00
{ " snd_reversestereo " , " reverses the stereo channels " , ( void * ) & ud . config . ReverseStereo , CVAR_BOOL , 0 , 1 } ,
2017-06-27 02:24:14 +00:00
{ " snd_speech " , " enables/disables player speech " , ( void * ) & ud . config . VoiceToggle , CVAR_INT , 0 , 5 } ,
2010-05-02 23:27:30 +00:00
2013-05-17 03:43:20 +00:00
{ " team " , " change team in multiplayer " , ( void * ) & ud . team , CVAR_INT | CVAR_MULTI , 0 , 3 } ,
2010-05-02 23:27:30 +00:00
2015-02-11 05:22:32 +00:00
# ifdef EDUKE32_TOUCH_DEVICES
2016-01-27 07:30:18 +00:00
{ " touch_sens_move_x " , " touch input sensitivity for moving forward/back " , ( void * ) & droidinput . forward_sens , CVAR_FLOAT , 1 , 9 } ,
2015-03-24 00:39:52 +00:00
{ " touch_sens_move_y " , " touch input sensitivity for strafing " , ( void * ) & droidinput . strafe_sens , CVAR_FLOAT , 1 , 9 } ,
{ " touch_sens_look_x " , " touch input sensitivity for turning left/right " , ( void * ) & droidinput . yaw_sens , CVAR_FLOAT , 1 , 9 } ,
{ " touch_sens_look_y " , " touch input sensitivity for looking up/down " , ( void * ) & droidinput . pitch_sens , CVAR_FLOAT , 1 , 9 } ,
2019-05-19 03:54:29 +00:00
{ " touch_invert " , " invert look up/down touch input " , ( void * ) & droidinput . invertLook , CVAR_BOOL , 0 , 1 } ,
2015-02-11 05:22:32 +00:00
# endif
2018-04-12 21:02:51 +00:00
{ " vid_gamma " , " adjusts gamma component of gamma ramp " , ( void * ) & g_videoGamma , CVAR_FLOAT | CVAR_FUNCPTR , 0 , 10 } ,
{ " vid_contrast " , " adjusts contrast component of gamma ramp " , ( void * ) & g_videoContrast , CVAR_FLOAT | CVAR_FUNCPTR , 0 , 10 } ,
{ " vid_brightness " , " adjusts brightness component of gamma ramp " , ( void * ) & g_videoBrightness , CVAR_FLOAT | CVAR_FUNCPTR , 0 , 10 } ,
2015-03-24 00:39:52 +00:00
{ " wchoice " , " sets weapon autoselection order " , ( void * ) ud . wchoice , CVAR_STRING | CVAR_FUNCPTR , 0 , MAX_WEAPONS } ,
2009-04-29 06:20:07 +00:00
} ;
2009-04-30 01:07:08 +00:00
osdcmd_cheatsinfo_stat . cheatnum = - 1 ;
2018-11-18 18:05:32 +00:00
for ( auto & cv : cvars_game )
2006-11-15 01:16:55 +00:00
{
2018-11-18 18:05:32 +00:00
switch ( cv . flags & ( CVAR_FUNCPTR | CVAR_MULTI ) )
2010-05-02 23:27:30 +00:00
{
2018-11-18 18:05:32 +00:00
case CVAR_FUNCPTR :
OSD_RegisterCvar ( & cv , osdcmd_cvar_set_game ) ; break ;
case CVAR_MULTI :
case CVAR_FUNCPTR | CVAR_MULTI :
OSD_RegisterCvar ( & cv , osdcmd_cvar_set_multi ) ; break ;
default :
OSD_RegisterCvar ( & cv , osdcmd_cvar_set ) ; break ;
2010-05-02 23:27:30 +00:00
}
2006-04-13 20:47:06 +00:00
}
2019-03-21 09:27:43 +00:00
# if !defined NETCODE_DISABLE
OSD_RegisterFunction ( " connect " , " connect: connects to a multiplayer game " , osdcmd_connect ) ;
OSD_RegisterFunction ( " disconnect " , " disconnect: disconnects from the local multiplayer game " , osdcmd_disconnect ) ;
OSD_RegisterFunction ( " dumpmapstates " , " Dumps current snapshots to CL/Srv_MapStates.bin " , osdcmd_dumpmapstate ) ;
OSD_RegisterFunction ( " kick " , " kick <id>: kicks a multiplayer client. See listplayers. " , osdcmd_kick ) ;
OSD_RegisterFunction ( " kickban " , " kickban <id>: kicks a multiplayer client and prevents them from reconnecting. See listplayers. " , osdcmd_kickban ) ;
OSD_RegisterFunction ( " listplayers " , " listplayers: lists currently connected multiplayer clients " , osdcmd_listplayers ) ;
OSD_RegisterFunction ( " name " , " name: change your multiplayer nickname " , osdcmd_name ) ;
OSD_RegisterFunction ( " password " , " password: sets multiplayer game password " , osdcmd_password ) ;
OSD_RegisterFunction ( " playerinfo " , " Prints information about the current player " , osdcmd_playerinfo ) ;
# endif
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 ) ;
2008-10-23 20:19:30 +00:00
OSD_RegisterFunction ( " map " , " map <mapfile>: loads the given user map " , osdcmd_map ) ;
2012-09-08 22:18:37 +00:00
OSD_RegisterFunction ( " demo " , " demo <demofile or demonum>: starts the given demo " , osdcmd_demo ) ;
2006-04-13 20:47:06 +00:00
}
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " addpath " , " addpath <path>: adds path to game filesystem " , osdcmd_addpath ) ;
2018-10-16 06:08:36 +00:00
OSD_RegisterFunction ( " bind " , R " (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-04-13 20:47:06 +00:00
OSD_RegisterFunction ( " cmenu " , " cmenu <#>: jumps to menu " , osdcmd_cmenu ) ;
2009-04-29 19:43:51 +00:00
OSD_RegisterFunction ( " crosshaircolor " , " crosshaircolor: changes the crosshair color " , osdcmd_crosshaircolor ) ;
2018-11-18 18:05:32 +00:00
for ( auto & func : gamefunctions )
2008-06-30 07:30:48 +00:00
{
2018-11-18 18:05:32 +00:00
if ( func [ 0 ] = = ' \0 ' )
2017-06-17 11:41:59 +00:00
continue ;
2012-11-08 17:00:31 +00:00
// if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue;
2008-11-20 14:06:36 +00:00
2018-11-18 18:05:32 +00:00
Bsprintf ( tempbuf , " gamefunc_%s " , func ) ;
2018-11-18 18:06:07 +00:00
char * const t = Bstrtolower ( Xstrdup ( tempbuf ) ) ;
2018-11-18 18:05:32 +00:00
Bstrcat ( tempbuf , " : game button " ) ;
2018-11-18 18:06:07 +00:00
2014-05-30 00:02:19 +00:00
OSD_RegisterFunction ( t , Xstrdup ( tempbuf ) , osdcmd_button ) ;
2008-06-30 07:30:48 +00:00
}
2006-04-13 20:47:06 +00:00
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 ) ;
2017-07-05 05:38:08 +00:00
OSD_RegisterFunction ( " activatecheat " , " activatecheat <id>: activates a cheat code " , osdcmd_activatecheat ) ;
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " initgroupfile " , " initgroupfile <path>: adds a grp file into the game filesystem " , osdcmd_initgroupfile ) ;
2011-03-19 18:07:12 +00:00
# ifdef DEBUGGINGAIDS
OSD_RegisterFunction ( " inittimer " , " debug " , osdcmd_inittimer ) ;
2013-12-31 11:51:54 +00:00
# endif
2014-09-07 18:10:13 +00:00
OSD_RegisterFunction ( " music " , " music E<ep>L<lev>: change music " , osdcmd_music ) ;
2018-03-08 00:29:41 +00:00
2006-04-13 20:47:06 +00:00
OSD_RegisterFunction ( " noclip " , " noclip: toggles clipping mode " , osdcmd_noclip ) ;
2018-03-08 00:29:41 +00:00
OSD_RegisterFunction ( " printtimes " , " printtimes: prints VM timing statistics " , osdcmd_printtimes ) ;
2009-12-14 20:14:12 +00:00
2018-07-01 04:51:25 +00:00
OSD_RegisterFunction ( " purgesaves " , " purgesaves: deletes obsolete and unreadable save files " , osdcmd_purgesaves ) ;
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 ) ;
2008-07-07 08:04:12 +00:00
OSD_RegisterFunction ( " exit " , " exit: exits the game immediately " , osdcmd_quit ) ;
2006-04-13 20:47:06 +00:00
2015-12-23 04:05:55 +00:00
OSD_RegisterFunction ( " restartmap " , " restartmap: restarts the current map " , osdcmd_restartmap ) ;
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 ) ;
2013-01-20 21:17:06 +00:00
# if !defined LUNATIC
2008-07-23 20:09:22 +00:00
OSD_RegisterFunction ( " addlogvar " , " addlogvar <gamevar>: prints the value of a gamevar " , osdcmd_addlogvar ) ;
2006-05-23 23:43:18 +00:00
OSD_RegisterFunction ( " setvar " , " setvar <gamevar> <value>: sets the value of a gamevar " , osdcmd_setvar ) ;
2008-10-23 20:19:30 +00:00
OSD_RegisterFunction ( " setvarvar " , " setvarvar <gamevar1> <gamevar2>: sets the value of <gamevar1> to <gamevar2> " , osdcmd_setvar ) ;
OSD_RegisterFunction ( " setactorvar " , " setactorvar <actor#> <gamevar> <value>: sets the value of <actor#>'s <gamevar> to <value> " , osdcmd_setactorvar ) ;
2013-11-04 22:56:03 +00:00
# else
OSD_RegisterFunction ( " lua " , " lua \" Lua code... \" : runs Lunatic code " , osdcmd_lua ) ;
2013-01-20 21:17:06 +00:00
# endif
2017-07-18 20:53:00 +00:00
OSD_RegisterFunction ( " screenshot " , " screenshot [format]: takes a screenshot. " , osdcmd_screenshot ) ;
2008-07-03 07:37:41 +00:00
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-10-23 20:19:30 +00:00
OSD_RegisterFunction ( " unbind " , " unbind <key>: unbinds a key " , osdcmd_unbind ) ;
OSD_RegisterFunction ( " unbindall " , " unbindall: unbinds all keys " , osdcmd_unbindall ) ;
2019-03-20 11:24:25 +00:00
OSD_RegisterFunction ( " unbound " , NULL , osdcmd_unbound ) ;
2008-06-30 07:30:48 +00:00
2008-10-23 20:19:30 +00:00
OSD_RegisterFunction ( " vidmode " , " vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode " , osdcmd_vidmode ) ;
2013-08-12 15:18:19 +00:00
# ifdef USE_OPENGL
baselayer_osdcmd_vidmode_func = osdcmd_vidmode ;
2013-05-19 19:29:23 +00:00
# endif
2018-12-08 00:40:39 +00:00
2006-04-13 20:47:06 +00:00
return 0 ;
}
2019-09-21 20:53:00 +00:00
END_DUKE_NS