Skip to content

Modfile upload silently fails when no platforms are defined and the game is set to not accept cross-platform mods. #24

@akela-morse

Description

@akela-morse

When creating a new Mod via the method described in the documentation, if no platforms are specified, the Modfile request silently fails, and the Mod is uploaded without any files.

Image

Tracking down the issue, it seems to originate from this code:

https://github.com/modio/modio-unity/blob/main/Modio/Mods/Builder/ModfileBuilder.cs#L114

string[] platformStrings = Platforms.Select(GetPlatformHeader).ToArray();

Platforms is null, so an ArgumentNullException is thrown; however, in the upper stack, no error will be returned.

Adding platforms to the Modfile fixes this problem, but another error is raised (code 14037) later if the game is set to not accept cross-platform mods.

In this scenario, it's possible to work around the problem by providing an empty array to the ModfileBuilder like so:

var builder = Mod.Create()
  .SetName(name)
  .SetSummary(description)
  .SetLogo(thumbnail, ImageFormat.Jpg)
  .EditModfile()
  .SetPlatforms(Array.Empty<ModfileBuilder.Platform>())    // <-- Provide an empty array here
  .SetSourceDirectoryPath(modFiles)
  .FinishModfile();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions