@@ -264,13 +264,13 @@ void *MultiAddonManager::OnMetamodQuery(const char *iface, int *ret)
264
264
return &g_AddonManagerInterface;
265
265
}
266
266
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 )
268
268
{
269
269
// The workshop on a dedicated server is stored relative to the working directory for whatever reason
270
270
static CBufferStringGrowable<MAX_PATH> s_sWorkingDir;
271
271
ExecuteOnce (g_pFullFileSystem->GetSearchPath (" EXECUTABLE_PATH" , GET_SEARCH_PATH_ALL, s_sWorkingDir, 1 ));
272
272
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 " );
274
274
}
275
275
276
276
bool g_bAddonMountDownload = false ;
@@ -296,13 +296,24 @@ bool MultiAddonManager::MountAddon(const char *pszAddon, bool bAddToTail = false
296
296
DownloadAddon (pszAddon, false , true );
297
297
}
298
298
299
- char path [MAX_PATH];
300
- BuildAddonPath (pszAddon, path , sizeof (path ));
299
+ char pszPath [MAX_PATH];
300
+ BuildAddonPath (pszAddon, pszPath , sizeof (pszPath ));
301
301
302
- if (!g_pFullFileSystem->FileExists (path ))
302
+ if (!g_pFullFileSystem->FileExists (pszPath ))
303
303
{
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 );
306
317
}
307
318
308
319
if (m_MountedAddons.Find (pszAddon) != -1 )
@@ -311,9 +322,9 @@ bool MultiAddonManager::MountAddon(const char *pszAddon, bool bAddToTail = false
311
322
return false ;
312
323
}
313
324
314
- Message (" Adding search path: %s\n " , path );
325
+ Message (" Adding search path: %s\n " , pszPath );
315
326
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);
317
328
m_MountedAddons.AddToTail (pszAddon);
318
329
319
330
return true ;
0 commit comments