From 8c98d44620de16870385292bec6cad0cddd197e6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 16 Aug 2020 14:54:33 +0200 Subject: [PATCH] - handle console-based map changes directly instead of the cheat handler. This allows handling user maps again. --- source/blood/src/osdcmd.cpp | 2 +- source/sw/src/osdcmds.cpp | 40 +++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index d103af652..b2c425b1b 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -65,7 +65,7 @@ static int osdcmd_map(CCmdFuncPtr parm) else { // Map has not been defined. Treat as user map. - StartLevel(SetupUserMap(mapname)); + StartLevel(SetupUserMap(mapfilename)); } return CCMD_OK; diff --git a/source/sw/src/osdcmds.cpp b/source/sw/src/osdcmds.cpp index 5fb0d3e88..e903dca3a 100644 --- a/source/sw/src/osdcmds.cpp +++ b/source/sw/src/osdcmds.cpp @@ -45,9 +45,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "menus.h" #include "mapinfo.h" #include "jsector.h" +#include "network.h" BEGIN_SW_NS +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); +} + + static int osdcmd_map(CCmdFuncPtr parm) { if (parm->numparms != 1) @@ -66,11 +90,11 @@ static int osdcmd_map(CCmdFuncPtr parm) // Check if the map is already defined. auto maprec = FindMapByName(mapname); - if (maprec) + if (maprec) levelwarp(maprec); + else { - // This needs to be done better... - FStringf cheatcode("activatecheat swtrek%02d", maprec->levelNumber); - C_DoCommand(cheatcode); + maprec = SetupUserMap(mapfilename); + if (maprec) levelwarp(maprec); } return CCMD_OK; } @@ -96,12 +120,8 @@ int osdcmd_restartmap(CCmdFuncPtr) 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); + auto maprec = FindMapByLevelNum(atoi(parm->parms[0])); + if (maprec) levelwarp(maprec); return CCMD_OK; }