From ec1aeaf384a3a3b3e6ae1707c4cd369bf9ae651d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 28 Apr 2017 11:39:47 +0200 Subject: [PATCH] - allow changing to the current map by using "*" as argument. Implemented for 'map', 'changemap' and 'recordmap'. --- src/c_cmds.cpp | 9 ++++++--- src/g_level.cpp | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index b45210053..f1085555a 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -364,11 +364,14 @@ CCMD (changemap) if (argv.argc() > 1) { + const char *mapname = argv[1]; + if (!strcmp(mapname, "*")) mapname = level.MapName.GetChars(); + try { - if (!P_CheckMapData(argv[1])) + if (!P_CheckMapData(mapname)) { - Printf ("No map %s\n", argv[1]); + Printf ("No map %s\n", mapname); } else { @@ -381,7 +384,7 @@ CCMD (changemap) { Net_WriteByte (DEM_CHANGEMAP); } - Net_WriteString (argv[1]); + Net_WriteString (mapname); } } catch(CRecoverableError &error) diff --git a/src/g_level.cpp b/src/g_level.cpp index 4139362c3..3367a348b 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -182,11 +182,14 @@ CCMD (map) } if (argv.argc() > 1) { + const char *mapname = argv[1]; + if (!strcmp(mapname, "*")) mapname = level.MapName.GetChars(); + try { - if (!P_CheckMapData(argv[1])) + if (!P_CheckMapData(mapname)) { - Printf ("No map %s\n", argv[1]); + Printf ("No map %s\n", mapname); } else { @@ -200,7 +203,7 @@ CCMD (map) deathmatch = true; multiplayernext = true; } - G_DeferedInitNew (argv[1]); + G_DeferedInitNew (mapname); } } catch(CRecoverableError &error) @@ -229,11 +232,14 @@ CCMD(recordmap) } if (argv.argc() > 2) { + const char *mapname = argv[2]; + if (!strcmp(mapname, "*")) mapname = level.MapName.GetChars(); + try { - if (!P_CheckMapData(argv[2])) + if (!P_CheckMapData(mapname)) { - Printf("No map %s\n", argv[2]); + Printf("No map %s\n", mapname); } else { @@ -247,7 +253,7 @@ CCMD(recordmap) deathmatch = true; multiplayernext = true; } - G_DeferedInitNew(argv[2]); + G_DeferedInitNew(mapname); gameaction = ga_recordgame; newdemoname = argv[1]; newdemomap = argv[2];