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

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

Closed
DrLecteur opened this issue Mar 31, 2023 · 14 comments
Closed

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

DrLecteur opened this issue Mar 31, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@DrLecteur
Copy link

  • OS: Windows 11
  • Valheim Game Version: 0.214.305 (displayed IG as .0214.305)
  • V+ Mod Version: 0.9.9.13

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]

@DrLecteur DrLecteur added the bug Something isn't working label Mar 31, 2023
@AzumattDev
Copy link

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
Copy link

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
Copy link

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
Copy link

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

@Grantapher
Copy link

From what I could tell it was still covered by:

/// <summary>
/// Alter server player limit
/// </summary>
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> il = instructions.ToList();
for (int i = 0; i < il.Count; i++)
{
if (il[i].Calls(method_ZNet_GetNrOfPlayers))
{
il[i + 1].operand = Configuration.Current.Server.maxPlayers;
return il.AsEnumerable();
}
}
ZLog.LogError("Failed to alter server player limit (ZNet.RPC_PeerInfo.Transpiler)");
return instructions;
}
}

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

@AzumattDev
Copy link

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

@Grantapher
Copy link

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
Copy link

This seems to work.

[HarmonyPatch(typeof(ZPlayFabMatchmaking), "CreateLobby")]
public static class ZPlayFabMatchmaking_CreateLobby_Transpiler
{
/// <summary>
/// Alter playfab server player limit
/// Must be between 2 and 32
/// </summary>
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
if (!Configuration.Current.Server.IsEnabled) return instructions;
try
{
var ldc = instructions.Single(inst => inst.LoadsConstant() && inst.OperandIs(10U));
ldc.operand = Helper.Clamp(Configuration.Current.Server.maxPlayers, 2, 32);
}
catch (Exception)
{
ZLog.LogError("Failed to alter lobby player limit (ZPlayFabMatchmaking_CreateLobby_Transpiler)");
}
return instructions;
}
}
[HarmonyPatch(typeof(ZPlayFabMatchmaking), "CreateAndJoinNetwork")]
public static class ZPlayFabMatchmaking_CreateAndJoinNetwork_Transpiler
{
/// <summary>
/// Alter playfab network configuration player limit
/// Must be between 2 and 32
/// </summary>
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
if (!Configuration.Current.Server.IsEnabled) return instructions;
try
{
var ldc = instructions.Single(inst => inst.LoadsConstant() && inst.OperandIs(10U));
ldc.operand = Helper.Clamp(Configuration.Current.Server.maxPlayers, 2, 32);
}
catch (Exception)
{
ZLog.LogError("Failed to alter network player limit (ZPlayFabMatchmaking_CreateAndJoinNetwork_Transpiler)");
}
return instructions;
}
}

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

@AzumattDev
Copy link

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

@AzumattDev
Copy link

AzumattDev commented Apr 1, 2023

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
Copy link

ersan commented Apr 1, 2023

This seems to work.

[HarmonyPatch(typeof(ZPlayFabMatchmaking), "CreateLobby")]
public static class ZPlayFabMatchmaking_CreateLobby_Transpiler
{
/// <summary>
/// Alter playfab server player limit
/// Must be between 2 and 32
/// </summary>
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
if (!Configuration.Current.Server.IsEnabled) return instructions;
try
{
var ldc = instructions.Single(inst => inst.LoadsConstant() && inst.OperandIs(10U));
ldc.operand = Helper.Clamp(Configuration.Current.Server.maxPlayers, 2, 32);
}
catch (Exception)
{
ZLog.LogError("Failed to alter lobby player limit (ZPlayFabMatchmaking_CreateLobby_Transpiler)");
}
return instructions;
}
}
[HarmonyPatch(typeof(ZPlayFabMatchmaking), "CreateAndJoinNetwork")]
public static class ZPlayFabMatchmaking_CreateAndJoinNetwork_Transpiler
{
/// <summary>
/// Alter playfab network configuration player limit
/// Must be between 2 and 32
/// </summary>
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
if (!Configuration.Current.Server.IsEnabled) return instructions;
try
{
var ldc = instructions.Single(inst => inst.LoadsConstant() && inst.OperandIs(10U));
ldc.operand = Helper.Clamp(Configuration.Current.Server.maxPlayers, 2, 32);
}
catch (Exception)
{
ZLog.LogError("Failed to alter network player limit (ZPlayFabMatchmaking_CreateAndJoinNetwork_Transpiler)");
}
return instructions;
}
}

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
Copy link
Author

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
Copy link

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

@Grantapher
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants