From 9645009b28b217159f41e4a123692aace405a4ee Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 24 Jun 2021 18:49:26 +1000 Subject: [PATCH] - Fix `-map` command-line argument not working. * Fixes #441. --- source/core/cheats.cpp | 6 ------ source/core/mainloop.cpp | 4 ++++ source/core/mapinfo.cpp | 7 +++++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/core/cheats.cpp b/source/core/cheats.cpp index 013a145fc..d35aa7525 100644 --- a/source/core/cheats.cpp +++ b/source/core/cheats.cpp @@ -435,12 +435,6 @@ CCMD(map) auto map = FindMapByName(mapname); 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); } if (map) diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 3db1e65fe..6dbf14db9 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -681,6 +681,10 @@ void MainLoop () if (userConfig.CommandMap.IsNotEmpty()) { auto maprecord = FindMapByName(userConfig.CommandMap); + if (maprecord == nullptr) + { + maprecord = SetupUserMap(userConfig.CommandMap, g_gameType & GAMEFLAG_DUKE? "dethtoll.mid" : nullptr); + } userConfig.CommandMap = ""; if (maprecord) { diff --git a/source/core/mapinfo.cpp b/source/core/mapinfo.cpp index fb38e0d2c..17039c045 100644 --- a/source/core/mapinfo.cpp +++ b/source/core/mapinfo.cpp @@ -38,6 +38,7 @@ #include "raze_music.h" #include "filesystem.h" #include "printf.h" +#include "gamecontrol.h" #include "raze_sound.h" FString gSkillNames[MAXSKILLS]; @@ -203,6 +204,12 @@ MapRecord *AllocateMap() 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) { if (map->fileName.CompareNoCase(boardfilename) == 0)