Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doorstop does not work on Valheim #10

Closed
BlueAmulet opened this issue Feb 10, 2021 · 4 comments
Closed

Doorstop does not work on Valheim #10

BlueAmulet opened this issue Feb 10, 2021 · 4 comments

Comments

@BlueAmulet
Copy link

Valheim is a 64bit Unity 2019.4.16 game.
With Doorstop_x64_3.0.2.2, the game just crashes immediately
With Doorstop_x64_3.1.0.0, the game starts, but the targetAssembly appears to not be running at all
I have tested with BepInEx (with the newer 3.1.0.0 dll) and the example Doorstop.dll (moved to the game folder per the path in doorstop_config.ini), doorstop_is_alive.txt did not appear
I have tested Doorstop as winhttp.dll and version.dll, neither worked
Doorstop itself appears to work, setting redirectOutputLog=true does result in an output_log.txt, just not the targetAssembly

@ghorsington
Copy link
Member

ghorsington commented Feb 10, 2021

Greetings!

Doorstop and BepInEx are known to work with Valheim. The problem is that current builds of the game come with stripped mono base class library assemblies. In other words, some unused code was removed from game assemblies. In case of Valheim, many types used by BepInEx (and even example assembly in this repo) are stripped away which. Doorstop itself does its job fine.

At the moment, the fix is to restore the stripped assemblies by taking them directly from Unity Editor 2019.4.16.
I already did that as an example for Valheim:

unstripped_managed.7z

Simply extract this archive into Valheim_Data\Managed folder and overwrite when asked. After that BepInEx will indeed boot:

image


In general, I would suggest to contact the game developer and ask them to disable assembly stripping when building. Assembly stripping is not enabled by default in Unity which means that a developer for Valheim explicitly enabled it.

If you are a Unity game developer (or if you contact a developer for a Unity game): There are many reasons why assembly unstripping is not a good option for Unity games. Here is a list of them:

  • It does not actually save enough space to matter -- for example, Valheim's Managed folder is 6.71 MB right now (with stripping). When stripping is disabled, the folder size goes up to just 16.1 MB. If just a 10 MB difference still sounds like a lot, the difference is just about 1% of the entire game size (about 1 GB). If you want to optimize your game size for stripping to really matter, optimize your assets first.
  • Steam downloads games compressed (and games are often downloaded in archives). Managed IL assemblies are often surprisingly compressible -- with LZMA, the size of the unstripped Managed folder becomes about 4.3 MB. The size of the compressed and stripped Managed folder of Valheim is in turn 2.0 MB using LZMA. In other words, instead of downloading 10 MB you're downloading about 2 MB more. At the same time, most other assets like images and audio are much less compressible. As such, if you want to really save size, optimize your assets and not assemblies.
  • By stripping you're creating a nuisance for modders which can affect game popularity -- there is evidence that game modders add value to the game. As such, one can say that by hindering modding you're shooting yourself in the foot, especially when a game is in early access. In this case this is especially sad, since instead of having to do something to encourage modding, you have to not do something (that is, stripping) to make modding easier. To me it sounds like an easy decision: you're adding value to your game by simply not doing something you're doing.
  • In the end you're not preventing modding -- unstripping assemblies is a fairly easy process of grabbing them from Unity Editor. At most, you're just creating a nuisance for modders. And before you think about turning to using Il2Cpp thinking it will stop modding: BepInEx supports modding Il2Cpp games fine.

All in all, if you're a developer, please do not enable assembly unstripping in Unity. If you are unsure how, it is extremely easy to do in Player settings:

image


I will close this issue as it is confirmed not to be Doorstop one. I'll however also pin this one for other Valheim modders to see until the developer stop shipping their assemblies stripped.

@ghorsington ghorsington pinned this issue Feb 10, 2021
@opl-
Copy link

opl- commented Feb 12, 2021

It seems that the unstripped_managed.7z file you sent is missing some dlls from it that prevent using MonoMod with the game. In my case, as a Linux user, the missing dlls were System.Security.dll, System.Numerics.dll, and Mono.Posix.dll. Someone else running on Windows apparently has copied all files from Unity and didn't find System.Security.dll nor Mono.Posix.dll in there, so it's possible Windows uses slightly different dlls.

As I already have mono installed, I was able to find the aforementioned files under /usr/lib/mono/4.5/. I'm including them below for the convenience of anyone reading, but feel free to get them yourself from a source more trustworthy than a random stranger online. missing-unstripped-linux.zip

@BlueAmulet
Copy link
Author

In the Windows Unity installation they're in 2019.4.16f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5

@ghorsington
Copy link
Member

It seems that the unstripped_managed.7z file you sent is missing some dlls from it that prevent using MonoMod with the game.

Thanks for the info. I updated the archive in the original message to include those missing DLLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants