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 "menus.h"
# include "mapinfo.h"
2020-08-12 22:04:55 +00:00
# include "jsector.h"
2020-08-16 12:54:33 +00:00
# include "network.h"
2020-01-23 12:13:20 +00:00
BEGIN_SW_NS
2020-08-16 12:54:33 +00:00
static void levelwarp ( MapRecord * maprec )
{
if ( CommEnabled )
return ;
auto pp = & Player [ myconnectindex ] ;
if ( Skill > = 3 )
{
PutStringInfo ( pp , GStrings ( " TXTS_TOOSKILLFUL " ) ) ;
return ;
}
if ( TEST ( pp - > Flags , PF_DEAD ) )
return ;
NextLevel = maprec ;
ExitLevel = TRUE ;
sprintf ( ds , " %s %s " , GStrings ( " TXT_ENTERING " ) , maprec - > DisplayName ( ) ) ;
PutStringInfo ( pp , ds ) ;
}
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.
2020-08-16 12:39:18 +00:00
auto maprec = FindMapByName ( mapname ) ;
2020-08-16 12:54:33 +00:00
if ( maprec ) levelwarp ( maprec ) ;
else
2020-01-23 12:13:20 +00:00
{
2020-08-16 12:54:33 +00:00
maprec = SetupUserMap ( mapfilename ) ;
if ( maprec ) levelwarp ( maprec ) ;
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-08-16 12:54:33 +00:00
auto maprec = FindMapByLevelNum ( atoi ( parm - > parms [ 0 ] ) ) ;
if ( maprec ) levelwarp ( maprec ) ;
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-08-12 22:04:55 +00:00
static int osdcmd_bunny ( CCmdFuncPtr parm )
{
PLAYERp pp = Player + myconnectindex ;
if ( CommEnabled )
return CCMD_OK ;
pp - > BunnyMode = ! pp - > BunnyMode ;
if ( pp - > BunnyMode )
PutStringInfo ( pp , " Bunny rockets enabled! " ) ;
else
PutStringInfo ( pp , " Bunny rockets disabled! " ) ;
return CCMD_OK ;
}
static int osdcmd_mirror ( CCmdFuncPtr parm )
{
char base [ 80 ] ;
int16_t op1 = 0 ;
if ( parm - > numparms < 1 )
{
return CCMD_SHOWHELP ;
}
if ( op1 < 0 | | op1 > 9 )
{
Printf ( " Mirror number is out of range! " ) ;
return CCMD_OK ;
}
Printf ( " camera is the ST1 sprite used as the view spot " ) ;
Printf ( " camspite is the SpriteNum of the drawtotile tile in editart " ) ;
Printf ( " camspic is the tile number of the drawtotile in editart " ) ;
Printf ( " iscamera is whether or not this mirror is a camera type " ) ;
Printf ( " " ) ;
Printf ( " mirror[%d].mirrorwall = %d " , op1 , mirror [ op1 ] . mirrorwall ) ;
Printf ( " mirror[%d].mirrorsector = %d " , op1 , mirror [ op1 ] . mirrorsector ) ;
Printf ( " mirror[%d].camera = %d " , op1 , mirror [ op1 ] . camera ) ;
Printf ( " mirror[%d].camsprite = %d " , op1 , mirror [ op1 ] . camsprite ) ;
Printf ( " mirror[%d].campic = %d " , op1 , mirror [ op1 ] . campic ) ;
Printf ( " mirror[%d].iscamera = %d " , op1 , mirror [ op1 ] . ismagic ) ;
return CCMD_OK ;
}
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-08-12 22:04:55 +00:00
C_RegisterFunction ( " bunny " , " bunny: toggles bunny rocket mode " , osdcmd_bunny ) ;
C_RegisterFunction ( " mirror " , " mirror [mirrornum]: print mirror debug info " , osdcmd_mirror ) ;
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