@@ -798,7 +798,10 @@ static void LoadNextMap()
798798 SERVER_COMMAND (UTIL_VarArgs (" map \" %s\"\n " , mapName.c_str ()));
799799}
800800
801- static void LoadAllMaps ()
801+ // If modOnly is set to false all maps from the base game plus the mod will be
802+ // loaded. If set to true, only the maps present in the mod maps directory will
803+ // be loaded.
804+ static void LoadMaps (bool modOnly)
802805{
803806 if (!g_MapsToLoad.empty ())
804807 {
@@ -809,7 +812,13 @@ static void LoadAllMaps()
809812
810813 FileFindHandle_t handle = FILESYSTEM_INVALID_FIND_HANDLE;
811814
812- const char * fileName = g_pFileSystem->FindFirst (" maps/*.bsp" , &handle);
815+ const char * fileName = nullptr ;
816+ if (modOnly) {
817+ auto dir = std::string (FileSystem_GetModDirectoryName ()) + " /maps/*.bsp" ;
818+ fileName = g_pFileSystem->FindFirst (dir.c_str (), &handle);
819+ } else {
820+ fileName = g_pFileSystem->FindFirst (" maps/*.bsp" , &handle);
821+ }
813822
814823 if (fileName != nullptr )
815824 {
@@ -866,11 +875,23 @@ static void LoadAllMaps()
866875 }
867876}
868877
878+ static void LoadModMaps ()
879+ {
880+ LoadMaps (true );
881+ }
882+
883+ static void LoadAllMaps ()
884+ {
885+ LoadMaps (false );
886+ }
887+
869888void InitMapLoadingUtils ()
870889{
890+ g_engfuncs.pfnAddServerCommand (" sv_load_mod_maps" , &LoadModMaps);
871891 g_engfuncs.pfnAddServerCommand (" sv_load_all_maps" , &LoadAllMaps);
892+
872893 // Escape hatch in case the command is executed in error.
873- g_engfuncs.pfnAddServerCommand (" sv_stop_loading_all_maps " , []()
894+ g_engfuncs.pfnAddServerCommand (" sv_stop_loading_maps " , []()
874895 { g_MapsToLoad.clear (); });
875896}
876897
0 commit comments