Skip to content

Commit

Permalink
added a cheat enabler for method injector
Browse files Browse the repository at this point in the history
  • Loading branch information
ash47 committed Jan 5, 2018
1 parent 8481a92 commit e51c179
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Binary file modified MethodInjector/.vs/MethodInjector/v14/.suo
Binary file not shown.
23 changes: 20 additions & 3 deletions MethodInjector/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static void Main(string[] args)
bool enableDevTools = true;
bool enableInstantBuild = true;
bool allowFreeBuildings = true;
bool enableCheats = true;

try
{
Expand Down Expand Up @@ -92,6 +93,10 @@ static void Main(string[] args)
allowFreeBuildings = isEnabled;
break;

case "allowcheats":
enableCheats = isEnabled;
break;

default:
Console.WriteLine("Unknown config: " + lineConfig[0]);
break;
Expand All @@ -107,6 +112,12 @@ static void Main(string[] args)
Perform patching
*/

// Allow cheats
if(enableCheats)
{
ReplaceMethod("ZX.ZXGame", "get_CheatsEnabled", BindingFlags.Static | BindingFlags.Public);
}

// Allow hacked save games to be loaded
if(allowModifiedSaveGames)
{
Expand All @@ -119,7 +130,7 @@ Perform patching
ReplaceMethod("ZX.ZXGame", "get_IsDevelopmentVersion", BindingFlags.Static | BindingFlags.Public);
ReplaceMethod("ZX.ZXGame", "get_IsBetaPrivateVersion", BindingFlags.Static | BindingFlags.Public);
}
ReplaceMethod("ZX.ZXGame", "get_IsSteam", BindingFlags.Static | BindingFlags.Public);
ReplaceMethod("ZX.ZXSteam", "ValidateSteamLicense", BindingFlags.Static | BindingFlags.Public);

// Instant Build
if (enableInstantBuild)
Expand Down Expand Up @@ -269,6 +280,12 @@ public static void ReplaceMethod(string className, string methodName, BindingFla
LogMessage("Successfully replaced: " + className + " :: " + methodName);
}

// Enable cheats
public static bool get_CheatsEnabled()
{
return true;
}

// Replacement for can pay resources
public bool CanPayResources(object ignoreThis)
{
Expand All @@ -295,9 +312,9 @@ public static bool get_IsDevelopmentVersion()
}

// Returns if this is a steam build
public static bool get_IsSteam()
public static bool ValidateSteamLicense(object ignoreMe)
{
return false;
return true;
}

// Returns that this is a private build
Expand Down
3 changes: 2 additions & 1 deletion MethodInjector/config.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
allowModifiedSaveGames=true
enableDevTools=true
enableInstantBuild=true
allowFreeBuildings=true
allowFreeBuildings=true
allowCheats=true

0 comments on commit e51c179

Please sign in to comment.