Skip to content

Commit

Permalink
Merge pull request #8 from NotestQ/master
Browse files Browse the repository at this point in the history
Fix Culture dependent string conversions
  • Loading branch information
RugbugRedfern authored May 17, 2024
2 parents 381c671 + 4eca57e commit 6db6a9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions MyceliumNetworkingForCW/MyceliumNetwork.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Steamworks;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -372,7 +373,7 @@ public static void SetLobbyData(string key, object value)
RugLogger.LogWarning($"Accessing lobby data for unregistered key '{key}'. This might not exist.");
}

if(!SteamMatchmaking.SetLobbyData(Lobby, key, value.ToString()))
if (!SteamMatchmaking.SetLobbyData(Lobby, key, (string)Convert.ChangeType(value, typeof(string), CultureInfo.InvariantCulture)))
{
RugLogger.LogError("Error setting lobby data.");
}
Expand Down Expand Up @@ -424,7 +425,7 @@ public static T GetLobbyData<T>(string key)

try
{
return (T)Convert.ChangeType(value, typeof(T));
return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
}
catch(Exception ex)
{
Expand Down Expand Up @@ -452,7 +453,7 @@ public static void SetPlayerData(string key, object value)
RugLogger.LogWarning($"Accessing player data for unregistered key '{key}'. This might not exist.");
}

SteamMatchmaking.SetLobbyMemberData(Lobby, key.ToString(), value.ToString());
SteamMatchmaking.SetLobbyMemberData(Lobby, key.ToString(), (string)Convert.ChangeType(value, typeof(string), CultureInfo.InvariantCulture));
}

/// <summary>
Expand Down Expand Up @@ -503,7 +504,7 @@ public static T GetPlayerData<T>(CSteamID player, string key)
{
try
{
return (T)Convert.ChangeType(value, typeof(T));
return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
}
catch(Exception ex)
{
Expand Down
12 changes: 6 additions & 6 deletions MyceliumNetworkingForCW/MyceliumNetworkingForCW.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@

<!-- References - Game Assemblies -->
<ItemGroup Condition="$(CI) != 'true'">
<Reference Include="Assembly-CSharp" Publicize="true" Private="false">
<HintPath>$(ManagedDirectory)Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Steamworks.NET" Private="false">
<HintPath>$(ManagedDirectory)com.rlabrecque.steamworks.net.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp" Publicize="true" Private="false">
<HintPath>$(ManagedDirectory)Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Steamworks.NET" Private="false">
<HintPath>$(ManagedDirectory)com.rlabrecque.steamworks.net.dll</HintPath>
</Reference>
</ItemGroup>

<!-- Package References - Game Assemblies -->
Expand Down

0 comments on commit 6db6a9a

Please sign in to comment.