@@ -441,7 +441,7 @@ void MultiAddonManager::OnAddonDownloaded(DownloadItemResult_t *pResult)
441
441
if (pResult->m_eResult == k_EResultOK)
442
442
Message (" Addon %lli downloaded successfully\n " , pResult->m_nPublishedFileId );
443
443
else
444
- Panic (" %s: Addon %lli download failed with status %i\n " , __func__ , pResult->m_nPublishedFileId , pResult->m_eResult );
444
+ Panic (" Addon %lli download failed with status %i\n " , pResult->m_nPublishedFileId , pResult->m_eResult );
445
445
446
446
// This download isn't triggered by us, don't do anything
447
447
if (!m_DownloadQueue.Check (pResult->m_nPublishedFileId ))
@@ -674,43 +674,28 @@ void* FASTCALL Hook_HostStateRequest(void *a1, void **pRequest)
674
674
return g_pfnHostStateRequest (a1, pRequest);
675
675
676
676
// This offset hasn't changed in 6 years so it should be safe
677
- CUtlString *psNextMap = (CUtlString *)(pRequest + 5 );
678
677
CUtlString *psAddonString = (CUtlString *)(pRequest + 11 );
679
678
680
- std::string sExtraAddonString = VectorToString (g_MultiAddonManager.m_ExtraAddons );
681
-
682
- static std::string sCurrentMap = psNextMap->Get ();
683
-
684
- // If reloading the same map after a match or from vote, the addon string is not cleared so we have to do this ourselves...
685
- // Also if this happens to be a different workshop item but with the same map name then the string will be cleared anyway
686
- if (psNextMap->IsEqual_CaseSensitive (sCurrentMap .c_str ()))
687
- {
688
- std::string sCurrentWorkshopMap = g_MultiAddonManager.GetCurrentWorkshopMap ();
679
+ CUtlVector<std::string> vecAddons;
680
+ StringToVector (psAddonString->Get (), vecAddons);
689
681
690
- if (sCurrentWorkshopMap .empty ())
691
- psAddonString->Clear ();
692
- else
693
- psAddonString->Set (sCurrentWorkshopMap .c_str ());
694
- }
695
- else
696
- {
697
- sCurrentMap = psNextMap->Get ();
698
- }
682
+ // Clear the string just in case it wasn't somehow, like when reloading the map
683
+ psAddonString->Clear ();
699
684
700
- Message ( " %s: appending \" %s \" to addon string \" %s \"\n " , __func__, sExtraAddonString . c_str (), psAddonString-> Get () );
685
+ std:: string sExtraAddonString = VectorToString (g_MultiAddonManager. m_ExtraAddons );
701
686
702
- // Addons are simply comma-delimited, can have any number of them
703
- // The original addon string is the current workshop map
704
- // If it's empty, it means we're on a default map
705
- if (!psAddonString->IsEmpty ())
687
+ // If it's empty or the first addon in the string is ours, it means we're on a default map
688
+ if (vecAddons.Count () == 0 || g_MultiAddonManager.m_ExtraAddons .HasElement (vecAddons[0 ]))
706
689
{
707
- g_MultiAddonManager.SetCurrentWorkshopMap (psAddonString->Get ());
708
- psAddonString->Format (" %s,%s" , psAddonString->Get (), sExtraAddonString .c_str ());
690
+ Message (" %s: setting addon string to \" %s\"\n " , __func__, sExtraAddonString .c_str ());
691
+ psAddonString->Set (sExtraAddonString .c_str ());
692
+ g_MultiAddonManager.ClearCurrentWorkshopMap ();
709
693
}
710
694
else
711
695
{
712
- g_MultiAddonManager.ClearCurrentWorkshopMap ();
713
- psAddonString->Set (sExtraAddonString .c_str ());
696
+ Message (" %s: appending \" %s\" to addon string \" %s\"\n " , __func__, sExtraAddonString .c_str (), vecAddons[0 ].c_str ());
697
+ psAddonString->Format (" %s,%s" , vecAddons[0 ].c_str (), sExtraAddonString .c_str ());
698
+ g_MultiAddonManager.SetCurrentWorkshopMap (vecAddons[0 ].c_str ());
714
699
}
715
700
716
701
return g_pfnHostStateRequest (a1, pRequest);
0 commit comments