about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2020-03-29 18:12:10 +0200
committeraszlig <aszlig@nix.build>2020-03-29 18:21:31 +0200
commitd4ddb4b1079d3b58e93142184b9bcf57bb596ead (patch)
tree126d29ec2fcc64ca8eb861c8b00864a7c04e6b26 /pkgs/games
parent4edfc23056e5a1598293eb62749d46655e6102f9 (diff)
invisigun-heroes: Get nick name from environment
Since the player's nick name is retrieved via Steam we don't get any
nick name via the DRM-free version.

To cope with this, the nick name is now determined by looking at the
INVISIGUN_NICKNAME and USER if the former is not defined. If people
don't want their local user name to be displayed to others, there is a
setting in the options menu to disable this behaviour.

The reason why I patched the call to Tools::FilterText (which is used
sanitise the nick name) instead of a more specific one is because the
more specific one is optimized out in the build:

  IL_0000:  ldarg.0
  IL_0001:  call string class Tools::'?????????'(valuetype '?????????')
  IL_0006:  call string class Tools::FilterText(string)
  IL_000b:  ret

So the only way to patch out the call in IL_0001 would be to use
addresses/offsets, which is bound to break in the next upstream version.

However, since the output is essentially wrapped in Tools::FilterText, I
decided to patch that one instead and we simply throw away the argument.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/itch/invisigun-heroes.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkgs/games/itch/invisigun-heroes.nix b/pkgs/games/itch/invisigun-heroes.nix
index df531d09..9b3683fb 100644
--- a/pkgs/games/itch/invisigun-heroes.nix
+++ b/pkgs/games/itch/invisigun-heroes.nix
@@ -18,12 +18,22 @@ buildUnity rec {
 
   buildPhase = ''
     cat > nix-support.cs <<EOF
+    using System;
     using UnityEngine;
 
     public class NixSupport {
       public static string GetFullPathStub(string _ignore) {
         return Application.persistentDataPath;
       }
+
+      public static string GetNickName(string _ignore) {
+        string envar;
+        envar = Environment.GetEnvironmentVariable("INVISIGUN_NICKNAME");
+        if (envar != null) return envar;
+        envar = Environment.GetEnvironmentVariable("USER");
+        if (envar != null) return envar;
+        return "";
+      }
     }
     EOF
 
@@ -37,6 +47,13 @@ buildUnity rec {
       'System.String System.IO.Path::GetFullPath(System.String)' \
       'System.String NixSupport::GetFullPathStub(System.String)' \
       FileManagerAdapter_Desktop::ApplicationPath
+
+    monogame-patcher replace-call \
+      -i Invisigun_Data/Managed/Assembly-CSharp.dll \
+      -a Invisigun_Data/Managed/NixSupport.dll \
+      'System.String Tools::FilterText(System.String)' \
+      'System.String NixSupport::GetNickName(System.String)' \
+      Tools::GetNickname
   '';
 
   sandbox.paths.required = [ "$XDG_DATA_HOME/Invisigun Reloaded" ];