@@ -264,13 +264,13 @@ void *MultiAddonManager::OnMetamodQuery(const char *iface, int *ret)
264264	return  &g_AddonManagerInterface;
265265}
266266
267- void  MultiAddonManager::BuildAddonPath (const  char  *pszAddon, char  *buf, size_t  len)
267+ void  MultiAddonManager::BuildAddonPath (const  char  *pszAddon, char  *buf, size_t  len,  bool  bLegacy =  false )
268268{
269269	//  The workshop on a dedicated server is stored relative to the working directory for whatever reason
270270	static  CBufferStringGrowable<MAX_PATH> s_sWorkingDir;
271271	ExecuteOnce (g_pFullFileSystem->GetSearchPath (" EXECUTABLE_PATH"  , GET_SEARCH_PATH_ALL, s_sWorkingDir, 1 ));
272272
273- 	V_snprintf (buf, len, " %ssteamapps/workshop/content/730/%s/%s.vpk"  , s_sWorkingDir.Get (), pszAddon, pszAddon);
273+ 	V_snprintf (buf, len, " %ssteamapps/workshop/content/730/%s/%s%s .vpk"  , s_sWorkingDir.Get (), pszAddon, pszAddon, bLegacy ?  " "  :  " _dir "  );
274274}
275275
276276bool  g_bAddonMountDownload = false ;
@@ -296,13 +296,24 @@ bool MultiAddonManager::MountAddon(const char *pszAddon, bool bAddToTail = false
296296		DownloadAddon (pszAddon, false , true );
297297	}
298298
299- 	char  path [MAX_PATH];
300- 	BuildAddonPath (pszAddon, path , sizeof (path ));
299+ 	char  pszPath [MAX_PATH];
300+ 	BuildAddonPath (pszAddon, pszPath , sizeof (pszPath ));
301301
302- 	if  (!g_pFullFileSystem->FileExists (path ))
302+ 	if  (!g_pFullFileSystem->FileExists (pszPath ))
303303	{
304- 		Panic (" %s: Addon %s not found at %s\n "  , __func__, pszAddon, path);
305- 		return  false ;
304+ 		//  This might be a legacy addon (before mutli-chunk was introduced), try again without the _dir
305+ 		BuildAddonPath (pszAddon, pszPath, sizeof (pszPath), true );
306+ 
307+ 		if  (!g_pFullFileSystem->FileExists (pszPath))
308+ 		{
309+ 			Panic (" %s: Addon %s not found at %s\n "  , __func__, pszAddon, pszPath);
310+ 			return  false ;
311+ 		}
312+ 	}
313+ 	else 
314+ 	{
315+ 		//  We still need it without _dir anyway because the filesystem will append suffixes if needed
316+ 		BuildAddonPath (pszAddon, pszPath, sizeof (pszPath), true );
306317	}
307318
308319	if  (m_MountedAddons.Find (pszAddon) != -1 )
@@ -311,9 +322,9 @@ bool MultiAddonManager::MountAddon(const char *pszAddon, bool bAddToTail = false
311322		return  false ;
312323	}
313324
314- 	Message (" Adding search path: %s\n "  , path );
325+ 	Message (" Adding search path: %s\n "  , pszPath );
315326
316- 	g_pFullFileSystem->AddSearchPath (path , " GAME"  , bAddToTail ? PATH_ADD_TO_TAIL : PATH_ADD_TO_HEAD, SEARCH_PATH_PRIORITY_VPK);
327+ 	g_pFullFileSystem->AddSearchPath (pszPath , " GAME"  , bAddToTail ? PATH_ADD_TO_TAIL : PATH_ADD_TO_HEAD, SEARCH_PATH_PRIORITY_VPK);
317328	m_MountedAddons.AddToTail (pszAddon);
318329
319330	return  true ;
0 commit comments