This commit is contained in:
JohnCorby 2023-06-10 00:08:33 -07:00
parent 0121a527e6
commit c54fd1039e
2 changed files with 15 additions and 10 deletions

View File

@ -1,4 +1,5 @@
using Steamworks; using HarmonyLib;
using Steamworks;
using System; using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@ -63,20 +64,24 @@ public static class Program
case 0: case 0:
var owned = SteamApps.BIsDlcInstalled((AppId_t)1622100U); var owned = SteamApps.BIsDlcInstalled((AppId_t)1622100U);
Log($"dlc owned: {owned}"); Log($"dlc owned: {owned}");
exitCode = owned ? 1 : 0; exitCode = owned ? 1 : 0;
break; break;
// earn achievement // earn achievement
case 1: case 1:
Log("Earn " + type); var achievementType = (Achievements.Type)arg;
if (!SteamUserStats.SetAchievement(Achievements.s_names[type])) Log("Earn " + achievementType);
// for some reason even with unsafe code turned on it throws a FieldAccessException
var s_names = (string[])AccessTools.Field(typeof(Achievements), "s_names").GetValue(null);
if (!SteamUserStats.SetAchievement(s_names[(int)achievementType]))
{ {
LogError("Unable to grant achievement \"" + Achievements.s_names[type] + "\""); LogError("Unable to grant achievement \"" + s_names[(int)achievementType] + "\"");
}
else
{
exitCode = 0;
} }
SteamUserStats.StoreStats(); SteamUserStats.StoreStats();
exitCode = 0;
break; break;
} }

View File

@ -70,9 +70,9 @@ public static class Interop
}); });
process!.WaitForExit(); process!.WaitForExit();
Log($"output:\n{process.StandardOutput.ReadToEnd()}"); Log($"StandardOutput:\n{process.StandardOutput.ReadToEnd()}");
LogError($"error:\n{process.StandardError.ReadToEnd()}"); LogError($"StandardError:\n{process.StandardError.ReadToEnd()}");
Log($"exit code: {process.ExitCode}"); Log($"ExitCode: {process.ExitCode}");
return process.ExitCode; return process.ExitCode;
} }