Skip to content

Commit

Permalink
Patch BattletechPerformanceFix json and finish #8.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheep-y committed Aug 23, 2018
1 parent fcc7fb1 commit 889f742
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/DataProcess.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BattleTech;
using BattleTech.Data;
using Harmony;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -38,6 +39,15 @@ public override void ModStarts () {
}
}

public override void GameStarts () {
// Patch with authorization - https://github.com/Sheep-y/BattleTech_Turbine/issues/8
if ( BattleMod.FoundMod( "BattletechPerformanceFix.Control" ) ) {
Type DontStripComments = AppDomain.CurrentDomain.GetAssemblies().Select( e => e.GetType( "BattletechPerformanceFix.DontStripComments" ) ).FirstOrDefault( e => e != null );
if ( DontStripComments != null )
Patch( DontStripComments, "HBSStripCommentsMirror", Static, "Override_StripComments", null );
}
}

public static string Unescape ( string value ) {
if ( value.StartsWith( "\"" ) && value.EndsWith( "\"" ) ) {
value = value.Substring( 1, value.Length - 2 );
Expand All @@ -50,6 +60,7 @@ public static string Unescape ( string value ) {

private static bool commentDetected;

[ HarmonyPriority( Priority.LowerThanNormal ) ]
public static bool Override_StripComments ( ref string __result, string json ) { try {
commentDetected = false;
__result = StripComments( json );
Expand Down

0 comments on commit 889f742

Please sign in to comment.