From a53d3d6a6e0b04f2b9c473179c583698de0d57a6 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 28 Sep 2023 20:35:41 -0400 Subject: [PATCH] - add 'mapinfo' ccmd --- src/console/c_cmds.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/console/c_cmds.cpp b/src/console/c_cmds.cpp index 6e21cfcc285..9afa8c7762b 100644 --- a/src/console/c_cmds.cpp +++ b/src/console/c_cmds.cpp @@ -1270,3 +1270,85 @@ CCMD(dumpactors) } } } + +const char* testlocalised(const char* in) +{ + const char *out = GStrings.GetLanguageString(in, FStringTable::default_table); + if (in[0] == '$') + out = GStrings.GetLanguageString(in + 1, FStringTable::default_table); + if (out) + return out; + return in; +} + +CCMD (mapinfo) +{ + level_info_t *myLevel = nullptr; + if (players[consoleplayer].mo && players[consoleplayer].mo->Level) + myLevel = players[consoleplayer].mo->Level->info; + + if (argv.argc() > 1) + { + if (P_CheckMapData(argv[1])) + myLevel = FindLevelInfo(argv[1]); + else + { + Printf("Mapname '%s' not found\n", argv[1]); + return; + } + } + + if (!myLevel) + { + Printf("Not in a level\n"); + return; + } + + Printf("[ Map Info For: '%s' ]\n\n", myLevel->MapName); + + if (myLevel->LevelName.IsNotEmpty()) + Printf(" LevelName: %s\n", testlocalised(myLevel->LevelName)); + + if (myLevel->AuthorName.IsNotEmpty()) + Printf(" AuthorName: %s\n", testlocalised(myLevel->AuthorName)); + + if (myLevel->levelnum) + Printf(" LevelNum: %i\n", myLevel->levelnum); + + if (myLevel->NextMap.IsNotEmpty()) + Printf(" Next: %s\n", myLevel->NextMap); + + if (myLevel->NextSecretMap.IsNotEmpty()) + Printf(" SecretNext: %s\n", myLevel->NextSecretMap); + + if (myLevel->Music.IsNotEmpty()) + Printf(" Music: %s\n", testlocalised(myLevel->Music)); + + Printf(" PixelStretch: %f\n", myLevel->pixelstretch); + + if (myLevel->RedirectType.GetChars()) + Printf(" Redirect (Item): %s\n", myLevel->RedirectType.GetChars()); + + if (myLevel->RedirectMapName.IsNotEmpty()) + Printf(" Redirect (Map): %s\n", myLevel->RedirectMapName); + + if (myLevel->RedirectCVAR.GetChars()) + Printf("CVAR_Redirect (CVAR): %s\n", myLevel->RedirectCVAR.GetChars()); + + if (myLevel->RedirectCVARMapName.IsNotEmpty()) + Printf(" CVAR_Redirect (Map): %s\n", myLevel->RedirectCVARMapName); + + Printf(" LightMode: %i\n", (int8_t)myLevel->lightmode); + + if (players[consoleplayer].mo && players[consoleplayer].mo->Level) + { + level_info_t *check = myLevel->CheckLevelRedirect(); + if (check) + Printf("Level IS currently being redirected to '%s'!\n", check->MapName); + else + Printf("Level is currently NOT being redirected!\n"); + } + else + Printf("Level redirection is currently not being tested - not in game!\n"); +} +