2020-01-23 12:13:20 +00:00
//-------------------------------------------------------------------------
/*
Copyright ( C ) 2010 EDuke32 developers and contributors
Modified by Raze developers and contributors
This file was 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 .
*/
//-------------------------------------------------------------------------
# include "ns.h" // Must come before everything else!
# include "osdcmds.h"
# include "ns.h"
# include "build.h"
# include "names2.h"
# include "panel.h"
# include "game.h"
# include "mytypes.h"
# include "gamecontrol.h"
# include "gstrings.h"
# include "common.h"
2020-05-25 15:11:32 +00:00
# include "v_text.h"
# include "printf.h"
2020-01-23 12:13:20 +00:00
2020-08-05 15:07:19 +00:00
# include "misc.h"
2020-01-23 12:13:20 +00:00
# include "demo.h" // g_firstDemoFile[]
# include "menus.h"
# include "mapinfo.h"
BEGIN_SW_NS
2020-04-11 22:04:02 +00:00
static int osdcmd_map ( CCmdFuncPtr parm )
2020-01-23 12:13:20 +00:00
{
2020-01-28 10:20:30 +00:00
if ( parm - > numparms ! = 1 )
2020-01-23 12:13:20 +00:00
{
2020-07-14 12:00:27 +00:00
return CCMD_SHOWHELP ;
2020-01-23 12:13:20 +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-23 12:13:20 +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-23 12:13:20 +00:00
}
2020-01-28 10:20:30 +00:00
// Check if the map is already defined.
for ( int i = 0 ; i < 32 ; i + + )
2020-01-23 12:13:20 +00:00
{
2020-01-28 10:20:30 +00:00
if ( mapList [ i ] . labelName . CompareNoCase ( mapname ) = = 0 )
{
2020-08-12 20:24:51 +00:00
FStringf cheatcode ( " activatecheat swtrek%02d " , i ) ;
C_DoCommand ( cheatcode ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-28 10:20:30 +00:00
}
2020-01-23 12:13:20 +00:00
}
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-01-28 10:20:30 +00:00
2020-08-12 20:24:51 +00:00
static int osdcmd_god ( CCmdFuncPtr )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swgod " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-08-12 20:24:51 +00:00
static int osdcmd_noclip ( CCmdFuncPtr )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swghost " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-08-12 20:24:51 +00:00
int osdcmd_restartmap ( CCmdFuncPtr )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swstart " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-04-11 22:04:02 +00:00
int osdcmd_levelwarp ( CCmdFuncPtr parm )
2020-01-23 17:55:37 +00:00
{
2020-07-14 12:00:27 +00:00
if ( parm - > numparms ! = 1 ) return CCMD_SHOWHELP ;
2020-01-23 17:55:37 +00:00
2020-08-12 20:24:51 +00:00
char cheatcode [ ] = " activatecheat swtrek## " ;
2020-01-23 17:55:37 +00:00
for ( int i = 0 ; i < 2 ; i + + )
2020-08-12 20:24:51 +00:00
cheatcode [ 20 + i ] = parm - > parms [ 0 ] [ i ] ;
C_DoCommand ( cheatcode ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 17:55:37 +00:00
}
2020-01-23 12:13:20 +00:00
2020-04-11 22:04:02 +00:00
static int osdcmd_give ( CCmdFuncPtr parm )
2020-01-23 12:13:20 +00:00
{
int32_t i ;
2020-07-14 12:00:27 +00:00
if ( parm - > numparms ! = 1 ) return CCMD_SHOWHELP ;
2020-01-23 12:13:20 +00:00
2020-08-12 20:24:51 +00:00
if ( ! stricmp ( parm - > parms [ 0 ] , " all " ) )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swgimme " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-08-12 20:24:51 +00:00
else if ( ! stricmp ( parm - > parms [ 0 ] , " health " ) )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swmedic " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-08-12 20:24:51 +00:00
else if ( ! stricmp ( parm - > parms [ 0 ] , " weapons " ) )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swguns " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-08-12 20:24:51 +00:00
else if ( ! stricmp ( parm - > parms [ 0 ] , " ammo " ) )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swammo " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-08-12 20:24:51 +00:00
else if ( ! stricmp ( parm - > parms [ 0 ] , " armor " ) )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swarmor " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-08-12 20:24:51 +00:00
else if ( ! stricmp ( parm - > parms [ 0 ] , " keys " ) )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat swkeys " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-08-12 20:24:51 +00:00
else if ( ! stricmp ( parm - > parms [ 0 ] , " inventory " ) )
2020-01-23 12:13:20 +00:00
{
2020-08-12 20:24:51 +00:00
C_DoCommand ( " activatecheat switems " ) ;
2020-07-14 12:00:27 +00:00
return CCMD_OK ;
2020-01-23 12:13:20 +00:00
}
2020-07-14 12:00:27 +00:00
return CCMD_SHOWHELP ;
2020-01-23 12:13:20 +00:00
}
2020-07-11 13:09:39 +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 13:09:39 +00:00
Player - > oposx = Player - > posx = atoi ( parm - > parms [ 0 ] ) ;
Player - > oposy = Player - > posy = atoi ( parm - > parms [ 1 ] ) ;
Player - > oposz = Player - > posz = atoi ( parm - > parms [ 2 ] ) ;
2020-08-04 13:13:22 +00:00
if ( parm - > numparms > = 4 )
2020-08-04 12:33:17 +00:00
{
Player - > oq16ang = Player - > q16ang = Player - > camq16ang = fix16_from_int ( atoi ( parm - > parms [ 3 ] ) ) ;
}
if ( parm - > numparms = = 5 )
{
Player - > oq16horiz = Player - > q16horiz = Player - > camq16horiz = fix16_from_int ( atoi ( parm - > parms [ 4 ] ) ) ;
}
2020-07-11 13:09:39 +00:00
2020-08-04 08:04:44 +00:00
return CCMD_OK ;
2020-07-11 13:09:39 +00:00
}
2020-01-23 12:13:20 +00:00
int32_t registerosdcommands ( void )
{
2020-04-11 22:04:02 +00:00
C_RegisterFunction ( " map " , " map <mapfile>: loads the given map " , osdcmd_map ) ;
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 ) ;
2020-01-23 12:13:20 +00:00
2020-04-11 22:04:02 +00:00
C_RegisterFunction ( " noclip " , " noclip: toggles clipping mode " , osdcmd_noclip ) ;
2020-01-23 12:13:20 +00:00
2020-04-11 22:04:02 +00:00
C_RegisterFunction ( " levelwarp " , " levelwarp <num>: warp to level " , osdcmd_levelwarp ) ;
2020-01-23 12:13:20 +00:00
2020-04-11 22:04:02 +00:00
C_RegisterFunction ( " restartmap " , " restartmap: restarts the current map " , osdcmd_restartmap ) ;
2020-01-23 12:13:20 +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);
2020-01-23 12:13:20 +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 13:09:39 +00:00
2020-01-23 12:13:20 +00:00
return 0 ;
}
END_SW_NS