valheimPlus / ValheimPlus

A HarmonyX Mod aimed at improving the gameplay and quality of life of the game Valheim.
http://valheim.plus
GNU Affero General Public License v3.0
963 stars 238 forks source link

[BUG] V+ not working with Xbox Gamepass Valheim #806

Closed DrLecteur closed 1 year ago

DrLecteur commented 1 year ago

V+ is crashing at launch

Troubleshooting I tried to install BepInEx 5.4.2101 and 5.4.2102. V+ works with neither

LogOutput - REDACTED.log valheim_plus.cfg.txt

Mods : [PlantEverything 1.13.3] [Craft From Containers 3.0.1] [Jotunn 2.11.2] [BoneAppetit 3.2.2] [Quick Stack - Store - Sort - Trash - Restock 1.3.8] [Better Archery 1.9.0] [Valheim Plus 0.9.9.13] [Epic Loot 0.9.9] [Equipment and Quick Slots 2.1.2] [Extended Item Data Framework 1.0.11]

AzumattDev commented 1 year ago

They would have to patch that and check for the backend before attempting to access steam information. In short, patch that method only when the backend is steam. Don't patch it if it's not.

Grantapher commented 1 year ago

quoting relevant convo from #803:

I have issue making it work. I'm a gamepass player (game version is 0.214.305 displayed as 0.214.300) Bepix 5.4.21.0 V+ 0.9.9.13

V+ is crashing :

[Info   :Valheim Plus] Configuration file loaded succesfully.
[Error  : Unity Log] TypeLoadException: Could not load type Steamworks.SteamGameServer, assembly_steamworks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null while decoding custom attribute: (null)
Stack trace:
System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.RuntimeType.GetCustomAttributes (System.Boolean inherit) (at <695d1cc93cca45069c528c15c9fdd749>:0)
HarmonyLib.HarmonyMethodExtensions.GetFromType (System.Type type) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.PatchClassProcessor..ctor (HarmonyLib.Harmony instance, System.Type type, System.Boolean allowUnannotatedType) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.PatchClassProcessor..ctor (HarmonyLib.Harmony instance, System.Type type) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Harmony.CreateClassProcessor (System.Type type) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Harmony.<PatchAll>b__11_0 (System.Type type) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.CollectionExtensions.Do[T] (System.Collections.Generic.IEnumerable`1[T] sequence, System.Action`1[T] action) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Harmony.PatchAll (System.Reflection.Assembly assembly) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Harmony.PatchAll () (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
ValheimPlus.ValheimPlusPlugin.Awake () (at <c57ae90247c4442f8e530d257f7432e4>:0)
UnityEngine.GameObject:AddComponent(Type)
BepInEx.Bootstrap.Chainloader:Start()
UnityEngine.UI.Image:OnCanvasHierarchyChanged()
Grantapher commented 1 year ago

I updated the mod to only load the steamworks patch if the assembly exists in 86d8a35. I updated the release 0.9.9.13 with this fix, so re-installing that should work.

AzumattDev commented 1 year ago

Nice, would still mean that you didn't patch Playfab lobbies and therefore Crossplay is still limited to 10 players.

Grantapher commented 1 year ago

From what I could tell it was still covered by:

https://github.com/valheimPlus/ValheimPlus/blob/24fd70709f5b48affcb337a9ddb1d185330e4d3a/ValheimPlus/GameClasses/ZNet.cs#L55-L76

It seems like Valheim devs hard-coded it into the Valheim files, but I'm not certain if there are other checks elsewhere.

AzumattDev commented 1 year ago

ZPlayFabMatchmaking has hard-coded value of 10. Though there are a few more checks than that I think.

Grantapher commented 1 year ago

Ah yes I do see that now. I would be surprised if there were more checks in playfab that weren't at least configured in the valheim assembly though.

I did verify that setting maxPlayers to 1 would reject new joiners even in play fab, so there is at least that. But yes, more of these constants will need to be transpiled unfortunately.

Grantapher commented 1 year ago

This seems to work.

https://github.com/valheimPlus/ValheimPlus/blob/6097ec88b7dd8dd178eafadb198d28924874d96d/ValheimPlus/GameClasses/ZPlayFabMatchmaking.cs#L9-L58

Will probably have to park it until a .14 release though. Plus I'm not sure if that transpiler is resilient enough.

AzumattDev commented 1 year ago

Yeah, that's very similar to what I had to to in MaxPlayerCount

AzumattDev commented 1 year ago

Though, I didn't think to patch CreateAndJoinNetwork. I will have to do the same.

EDIT: Not even sure your patch for that is working

ersan commented 1 year ago

This seems to work.

https://github.com/valheimPlus/ValheimPlus/blob/6097ec88b7dd8dd178eafadb198d28924874d96d/ValheimPlus/GameClasses/ZPlayFabMatchmaking.cs#L9-L58

Will probably have to park it until a .14 release though. Plus I'm not sure if that transpiler is resilient enough.

I pinged you on Discord, but the release you uploaded has .14 as the version in your DLL despite being tagged as .13 - causing issues with people joining dedicated servers.

DrLecteur commented 1 year ago

I tested it, and it works for gamepass. I close the issue as resolved but maybe other user have issue with your fix, as claimed by Ersan

Grantapher commented 1 year ago

@ersan you're correct I uploaded a dev version with .14 on accident. I have re-uploaded the release with the correct version.

Grantapher commented 1 year ago

EDIT: Not even sure your patch for that is working

I verified that it was being applied (to something in that method at least) since there was no log. But yeah I don't have enough folks to test over 11+ connections.