Skip to content

Commit

Permalink
Fix exception if mod metadata not fetched.
Browse files Browse the repository at this point in the history
If the mod metadata can't be fetched, such as if running from the wrong directory, an exception will be thrown when checking for DLC. This is not an correct exception.
Check for this case and log a more useful message.
  • Loading branch information
Gwindalmir committed Oct 12, 2021
1 parent 0373a7d commit cb8f2d6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions WorkshopToolCommon/Uploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public Uploader(WorkshopType type, string path, Options.UploadVerb options, stri
m_modId = WorkshopHelper.GetWorkshopIdFromMod(m_modPath);

// Fill defaults before assigning user-defined ones
FillPropertiesFromPublished();
if (m_modId.Length > 0 && m_modId.GetIds()[0] != 0 && !FillPropertiesFromPublished())
MySandboxGame.Log.WriteLineWarning("Mod has a published ID, but unable to look up properties. This is wrong.");

m_compile = options.Compile;
m_dryrun = options.DryRun;
Expand Down Expand Up @@ -387,7 +388,7 @@ bool FillPropertiesFromPublished()
}
return false;
}
return true;
return false;
}

ulong ParseOrGetWorkshopID(string idOrName)
Expand All @@ -413,7 +414,7 @@ ulong ParseOrGetWorkshopID(string idOrName)
// Mod must be published for that to work.
void ProcessDependencies(IEnumerable<string> deps, IEnumerable<string> add, IEnumerable<string> remove)
{
var existingDeps = m_workshopItems[m_modId[0]].Dependencies.ToList();
var existingDeps = m_workshopItems.GetValueOrDefault(m_modId.FirstOrDefault())?.Dependencies.ToList() ?? new List<ulong>();

// Check if the deps contains exactly one element, and that element is a 0 or "none",
// if so, set the result to a list of a single ulong value of 0
Expand Down Expand Up @@ -468,7 +469,7 @@ bool CheckDependency(MyWorkshopItem item)
void ProcessDLCs(IEnumerable<uint> dlcs, IEnumerable<uint> add, IEnumerable<uint> remove)
{
#if SE
var existingDeps = m_workshopItems[m_modId[0]].DLCs.ToList();
var existingDeps = m_workshopItems.GetValueOrDefault(m_modId.FirstOrDefault())?.DLCs.ToList() ?? new List<uint>();
var explicitDeps = dlcs?.ToList();
var depsToAdd = add?.ToList();
var depsToRemove = remove?.ToList();
Expand Down

0 comments on commit cb8f2d6

Please sign in to comment.