From 212cfde1865f84c9b8a4986fb5ecdd00bb43c6f1 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 27 Jan 2020 22:29:47 -0500 Subject: [PATCH] - add levelwarp cheat to Redneck and Duke --- source/blood/src/osdcmd.cpp | 5 +++-- source/duke3d/src/osdcmds.cpp | 35 +++++++++++++++++++++++++++++++++++ source/rr/src/osdcmds.cpp | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index 34ea77d6f..be1585662 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -2,8 +2,9 @@ /* Copyright (C) 2010-2019 EDuke32 developers and contributors Copyright (C) 2019 Nuke.YKT +Copyright (C) 2020 Raze developers and contributors -This file is part of NBlood. +This file was part of NBlood. NBlood is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 @@ -245,7 +246,7 @@ static int osdcmd_levelwarp(osdcmdptr_t parm) int m = atoi(parm->parms[1]); if (e == 0 || m == 0) { - Printf("Invalid level!: E%sM%s\n", parm->parms[0], parm->parms[1]); + Printf(OSD_ERROR "Invalid level!: E%sM%s\n", parm->parms[0], parm->parms[1]); return OSDCMD_OK; } LevelWarp(e - 1, m - 1); diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index 59c8c59a2..e118be8ac 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -38,6 +38,39 @@ BEGIN_DUKE_NS struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat = { -1, 0, 0 }; +static int osdcmd_levelwarp(osdcmdptr_t parm) +{ + if (parm->numparms != 2) + return OSDCMD_SHOWHELP; + int e = atoi(parm->parms[0]); + int m = atoi(parm->parms[1]); + if (e == 0 || m == 0) + { + Printf(OSD_ERROR "Invalid level!: E%sL%s\n", parm->parms[0], parm->parms[1]); + return OSDCMD_OK; + } + + osdcmd_cheatsinfo_stat.cheatnum = -1; + ud.m_volume_number = e - 1; + m_level_number = m - 1; + + ud.m_monsters_off = ud.monsters_off = 0; + + ud.m_respawn_items = 0; + ud.m_respawn_inventory = 0; + + ud.multimode = 1; + + if (g_player[myconnectindex].ps->gm & MODE_GAME) + { + G_NewGame(ud.m_volume_number, m_level_number, ud.m_player_skill); + g_player[myconnectindex].ps->gm = MODE_RESTART; + } + else G_NewGame_EnterLevel(); + + return OSDCMD_OK; +} + static int osdcmd_map(osdcmdptr_t parm) { char filename[BMAX_PATH]; @@ -691,6 +724,8 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip); + OSD_RegisterFunction("levelwarp","levelwarp : warp to episode 'e' and map 'm'", osdcmd_levelwarp); + OSD_RegisterFunction("printtimes", "printtimes: prints VM timing statistics", osdcmd_printtimes); diff --git a/source/rr/src/osdcmds.cpp b/source/rr/src/osdcmds.cpp index d6109b5e8..70de75d3e 100644 --- a/source/rr/src/osdcmds.cpp +++ b/source/rr/src/osdcmds.cpp @@ -1,6 +1,7 @@ //------------------------------------------------------------------------- /* Copyright (C) 2010 EDuke32 developers and contributors +Copyright (C) 2020 Raze developers and contributors This file is part of EDuke32. @@ -35,6 +36,39 @@ BEGIN_RR_NS struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat = { -1, 0, 0 }; +static int osdcmd_levelwarp(osdcmdptr_t parm) +{ + if (parm->numparms != 2) + return OSDCMD_SHOWHELP; + int e = atoi(parm->parms[0]); + int m = atoi(parm->parms[1]); + if (e == 0 || m == 0) + { + Printf(OSD_ERROR "Invalid level!: E%sL%s\n", parm->parms[0], parm->parms[1]); + return OSDCMD_OK; + } + + osdcmd_cheatsinfo_stat.cheatnum = -1; + ud.m_volume_number = e - 1; + m_level_number = m - 1; + + ud.m_monsters_off = ud.monsters_off = 0; + + ud.m_respawn_items = 0; + ud.m_respawn_inventory = 0; + + ud.multimode = 1; + + if (g_player[myconnectindex].ps->gm & MODE_GAME) + { + G_NewGame(ud.m_volume_number, m_level_number, ud.m_player_skill); + g_player[myconnectindex].ps->gm = MODE_RESTART; + } + else G_NewGame_EnterLevel(); + + return OSDCMD_OK; +} + static int osdcmd_map(osdcmdptr_t parm) { char filename[BMAX_PATH]; @@ -523,6 +557,7 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("map","map : loads the given user map", osdcmd_map); OSD_RegisterFunction("demo","demo : starts the given demo", osdcmd_demo); } + OSD_RegisterFunction("levelwarp","levelwarp : warp to episode 'e' and map 'm'", osdcmd_levelwarp); #if !defined NETCODE_DISABLE OSD_RegisterFunction("connect","connect: connects to a multiplayer game", osdcmd_connect);