raze/source/sw/src/osdcmds.cpp

197 lines
5 KiB
C++
Raw Normal View History

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"
#include "v_text.h"
#include "printf.h"
2020-01-23 12:13:20 +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
{
if (parm->numparms != 1)
2020-01-23 12:13:20 +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];
FString mapfilename = mapname;
DefaultExtension(mapfilename, ".map");
2020-01-30 19:25:52 +00:00
if (!fileSystem.FindFile(mapfilename))
2020-01-23 12:13:20 +00:00
{
Printf(TEXTCOLOR_RED "map: file \"%s\" not found.\n", mapfilename.GetChars());
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
// Check if the map is already defined.
for (int i = 0; i < 32; i++)
2020-01-23 12:13:20 +00:00
{
if (mapList[i].labelName.CompareNoCase(mapname) == 0)
{
FStringf cheatcode("activatecheat swtrek%02d", i);
C_DoCommand(cheatcode);
return CCMD_OK;
}
2020-01-23 12:13:20 +00:00
}
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
static int osdcmd_god(CCmdFuncPtr)
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swgod");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
static int osdcmd_noclip(CCmdFuncPtr)
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swghost");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
int osdcmd_restartmap(CCmdFuncPtr)
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swstart");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
2020-04-11 22:04:02 +00:00
int osdcmd_levelwarp(CCmdFuncPtr parm)
{
if (parm->numparms != 1) return CCMD_SHOWHELP;
char cheatcode[] = "activatecheat swtrek##";
for (int i = 0; i < 2; i++)
cheatcode[20+i] = parm->parms[0][i];
C_DoCommand(cheatcode);
return CCMD_OK;
}
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;
if (parm->numparms != 1) return CCMD_SHOWHELP;
2020-01-23 12:13:20 +00:00
if (!stricmp(parm->parms[0], "all"))
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swgimme");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
else if (!stricmp(parm->parms[0], "health"))
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swmedic");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
else if (!stricmp(parm->parms[0], "weapons"))
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swguns");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
else if (!stricmp(parm->parms[0], "ammo"))
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swammo");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
else if (!stricmp(parm->parms[0], "armor"))
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swarmor");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
else if (!stricmp(parm->parms[0], "keys"))
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat swkeys");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
else if (!stricmp(parm->parms[0], "inventory"))
2020-01-23 12:13:20 +00:00
{
C_DoCommand("activatecheat switems");
return CCMD_OK;
2020-01-23 12:13:20 +00:00
}
return CCMD_SHOWHELP;
2020-01-23 12:13:20 +00:00
}
static int osdcmd_warptocoords(CCmdFuncPtr parm)
{
if (parm->numparms < 3 || parm->numparms > 5)
return CCMD_SHOWHELP;
Player->oposx = Player->posx = atoi(parm->parms[0]);
Player->oposy = Player->posy = atoi(parm->parms[1]);
Player->oposz = Player->posz = atoi(parm->parms[2]);
if (parm->numparms >= 4)
{
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]));
}
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-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
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
2020-01-23 12:13:20 +00:00
return 0;
}
END_SW_NS