- Fix -map command-line argument not working.

* Fixes #441.
This commit is contained in:
Mitchell Richters 2021-06-24 18:49:26 +10:00
parent 6018213c71
commit 9645009b28
3 changed files with 11 additions and 6 deletions

View file

@ -435,12 +435,6 @@ CCMD(map)
auto map = FindMapByName(mapname); auto map = FindMapByName(mapname);
if (map == nullptr) if (map == nullptr)
{ {
// got a user map
if (g_gameType & GAMEFLAG_SHAREWARE)
{
Printf(PRINT_BOLD, "Cannot use user maps in shareware.\n");
return;
}
map = SetupUserMap(mapfilename, g_gameType & GAMEFLAG_DUKE? "dethtoll.mid" : nullptr); map = SetupUserMap(mapfilename, g_gameType & GAMEFLAG_DUKE? "dethtoll.mid" : nullptr);
} }
if (map) if (map)

View file

@ -681,6 +681,10 @@ void MainLoop ()
if (userConfig.CommandMap.IsNotEmpty()) if (userConfig.CommandMap.IsNotEmpty())
{ {
auto maprecord = FindMapByName(userConfig.CommandMap); auto maprecord = FindMapByName(userConfig.CommandMap);
if (maprecord == nullptr)
{
maprecord = SetupUserMap(userConfig.CommandMap, g_gameType & GAMEFLAG_DUKE? "dethtoll.mid" : nullptr);
}
userConfig.CommandMap = ""; userConfig.CommandMap = "";
if (maprecord) if (maprecord)
{ {

View file

@ -38,6 +38,7 @@
#include "raze_music.h" #include "raze_music.h"
#include "filesystem.h" #include "filesystem.h"
#include "printf.h" #include "printf.h"
#include "gamecontrol.h"
#include "raze_sound.h" #include "raze_sound.h"
FString gSkillNames[MAXSKILLS]; FString gSkillNames[MAXSKILLS];
@ -203,6 +204,12 @@ MapRecord *AllocateMap()
MapRecord* SetupUserMap(const char* boardfilename, const char *defaultmusic) MapRecord* SetupUserMap(const char* boardfilename, const char *defaultmusic)
{ {
if (g_gameType & GAMEFLAG_SHAREWARE)
{
Printf(PRINT_BOLD, "Cannot use user maps in shareware.\n");
return nullptr;
}
for (auto& map : mapList) for (auto& map : mapList)
{ {
if (map->fileName.CompareNoCase(boardfilename) == 0) if (map->fileName.CompareNoCase(boardfilename) == 0)