2019-08-27 06:08:18 +00:00
//-------------------------------------------------------------------------
/*
Copyright ( C ) 2010 EDuke32 developers and contributors
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 . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*/
//-------------------------------------------------------------------------
2019-11-22 23:11:37 +00:00
# include "ns.h"
2019-08-27 06:08:18 +00:00
# include "compat.h"
# include "build.h"
2019-08-31 09:08:38 +00:00
# include "common.h"
2019-08-27 06:08:18 +00:00
# include "exhumed.h"
2020-07-11 23:22:43 +00:00
# include "player.h"
2019-11-26 15:37:47 +00:00
# include "view.h"
2020-01-28 10:20:30 +00:00
# include "mapinfo.h"
2019-08-27 06:08:18 +00:00
2019-11-22 23:11:37 +00:00
BEGIN_PS_NS
2020-04-11 22:04:02 +00:00
static int osdcmd_god ( CCmdFuncPtr UNUSED ( parm ) )
2020-01-06 21:03:16 +00:00
{
UNREFERENCED_CONST_PARAMETER ( parm ) ;
if ( ! nNetPlayerCount & & ! bInDemo )
{
DoPassword ( 3 ) ;
}
else
2020-04-11 21:45:45 +00:00
Printf ( " god: Not in a single-player game. \n " ) ;
2020-01-06 21:03:16 +00:00
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-06 21:03:16 +00:00
}
2020-04-11 22:04:02 +00:00
static int osdcmd_noclip ( CCmdFuncPtr UNUSED ( parm ) )
2020-01-06 21:03:16 +00:00
{
UNREFERENCED_CONST_PARAMETER ( parm ) ;
if ( ! nNetPlayerCount & & ! bInDemo )
{
DoPassword ( 6 ) ;
}
else
{
2020-04-11 21:45:45 +00:00
Printf ( " noclip: Not in a single-player game. \n " ) ;
2020-01-06 21:03:16 +00:00
}
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-06 21:03:16 +00:00
}
2020-04-11 22:04:02 +00:00
static int osdcmd_map ( CCmdFuncPtr parm )
2020-01-28 10:20:30 +00:00
{
if ( parm - > numparms ! = 1 )
{
2020-07-14 12:00:27 +00:00
return CCMD_SHOWHELP ;
2020-01-28 10:20:30 +00:00
}
2020-01-30 19:25:52 +00:00
FString mapname = parm - > parms [ 0 ] ;
2020-07-26 21:59:29 +00:00
FString mapfilename = mapname ;
DefaultExtension ( mapfilename , " .map " ) ;
2020-01-30 19:25:52 +00:00
2020-07-26 21:59:29 +00:00
if ( ! fileSystem . FindFile ( mapfilename ) )
2020-01-28 10:20:30 +00:00
{
2020-07-26 21:59:29 +00:00
Printf ( TEXTCOLOR_RED " map: file \" %s \" not found. \n " , mapfilename . GetChars ( ) ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-28 10:20:30 +00:00
}
// Check if the map is already defined.
for ( int i = 0 ; i < = ISDEMOVER ? 4 : 32 ; i + + )
{
if ( mapList [ i ] . labelName . CompareNoCase ( mapname ) = = 0 )
{
levelnew = i ;
levelnum = i ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-28 10:20:30 +00:00
}
}
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-28 10:20:30 +00:00
}
2020-04-11 22:04:02 +00:00
static int osdcmd_changelevel ( CCmdFuncPtr parm )
2020-01-06 21:03:16 +00:00
{
char * p ;
2020-07-14 12:00:27 +00:00
if ( parm - > numparms ! = 1 ) return CCMD_SHOWHELP ;
2020-01-06 21:03:16 +00:00
int nLevel = strtol ( parm - > parms [ 0 ] , & p , 10 ) ;
2020-07-14 12:00:27 +00:00
if ( p [ 0 ] ) return CCMD_SHOWHELP ;
2020-01-06 21:03:16 +00:00
2020-07-14 12:00:27 +00:00
if ( nLevel < 0 ) return CCMD_SHOWHELP ;
2020-01-06 21:03:16 +00:00
int nMaxLevels ;
if ( ! ISDEMOVER ) {
nMaxLevels = 32 ;
}
else {
nMaxLevels = 4 ;
}
if ( nLevel > nMaxLevels )
{
2020-04-11 21:45:45 +00:00
Printf ( " changelevel: invalid level number \n " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_SHOWHELP ;
2020-01-06 21:03:16 +00:00
}
levelnew = nLevel ;
levelnum = nLevel ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-06 21:03:16 +00:00
}
2020-07-11 23:22:43 +00:00
static int osdcmd_warptocoords ( CCmdFuncPtr parm )
{
2020-08-04 12:33:17 +00:00
if ( parm - > numparms < 3 | | parm - > numparms > 5 )
2020-08-04 08:04:44 +00:00
return CCMD_SHOWHELP ;
2020-07-11 23:22:43 +00:00
Player * nPlayer = & PlayerList [ nLocalPlayer ] ;
spritetype * pSprite = & sprite [ nPlayer - > nSprite ] ;
nPlayer - > opos . x = pSprite - > x = atoi ( parm - > parms [ 0 ] ) ;
nPlayer - > opos . y = pSprite - > y = atoi ( parm - > parms [ 1 ] ) ;
nPlayer - > opos . z = pSprite - > z = atoi ( parm - > parms [ 2 ] ) ;
2020-08-04 13:13:22 +00:00
if ( parm - > numparms > = 4 )
2020-08-04 12:33:17 +00:00
{
nPlayer - > q16angle = fix16_from_int ( atoi ( parm - > parms [ 3 ] ) ) ;
}
if ( parm - > numparms = = 5 )
{
nPlayer - > q16horiz = fix16_from_int ( atoi ( parm - > parms [ 4 ] ) ) ;
}
2020-07-11 23:22:43 +00:00
2020-08-04 08:04:44 +00:00
return CCMD_OK ;
2020-07-11 23:22:43 +00:00
}
2019-08-27 06:08:18 +00:00
int32_t registerosdcommands ( void )
{
//if (VOLUMEONE)
2020-04-11 22:04:02 +00:00
C_RegisterFunction ( " changelevel " , " changelevel <level>: warps to the given level " , osdcmd_changelevel ) ;
C_RegisterFunction ( " map " , " map <mapname>: loads the given map " , osdcmd_map ) ;
// C_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
2019-08-27 06:08:18 +00:00
//}
2020-04-11 22:04:02 +00:00
//C_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
2019-08-27 06:08:18 +00:00
2020-04-11 22:04:02 +00:00
//C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
C_RegisterFunction ( " god " , " god: toggles god mode " , osdcmd_god ) ;
//C_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);
2019-08-27 06:08:18 +00:00
2020-04-11 22:04:02 +00:00
C_RegisterFunction ( " noclip " , " noclip: toggles clipping mode " , osdcmd_noclip ) ;
//C_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);
//C_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound);
2019-08-27 06:08:18 +00:00
2020-04-11 22:04:02 +00:00
//C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
2019-08-27 06:08:18 +00:00
2020-08-04 12:33:17 +00:00
C_RegisterFunction ( " warptocoords " , " warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates " , osdcmd_warptocoords ) ;
2020-07-11 23:22:43 +00:00
2019-08-27 06:08:18 +00:00
return 0 ;
}
2019-08-31 09:08:38 +00:00
2019-11-22 23:11:37 +00:00
END_PS_NS