-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.1.3: Detour checks, short hash fix
- Added checks to detours that ensure correct parameters, return type, etc. - Added automatic fix for short hash collision errors - Added Chinese translation
- Loading branch information
UnlimitedHugs
committed
Dec 23, 2016
1 parent
b0cb447
commit a14bd31
Showing
11 changed files
with
469 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<VersionData> | ||
<overrideVersion>2.1.2</overrideVersion> | ||
<overrideVersion>2.1.3</overrideVersion> | ||
<gitHubRepository>UnlimitedHugs/RimworldHugsLib</gitHubRepository> | ||
</VersionData> |
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using HugsLib.Utils; | ||
using Verse; | ||
|
||
namespace HugsLib.Core { | ||
/** | ||
* A fix for Defs that ended up being assigned a duplicate short hash. | ||
* Looks through all defs and when a collision is detected assigns a new short has to the Def. | ||
* This is a temporary fix for a vanilla issue. | ||
*/ | ||
public class ShortHashCollisionResolver { | ||
public static void ResolveCollisions() { | ||
var seenHashes = new HashSet<ushort>(); | ||
var defsToRehash = new List<Def>(); | ||
foreach (Type current in GenDefDatabase.AllDefTypesWithDatabases()) { | ||
var type = typeof(DefDatabase<>).MakeGenericType(current); | ||
var property = type.GetProperty("AllDefs"); | ||
var getMethod = property.GetGetMethod(); | ||
var allDefsInDatabase = (IEnumerable)getMethod.Invoke(null, null); | ||
defsToRehash.Clear(); | ||
foreach (Def def in allDefsInDatabase) { | ||
if (seenHashes.Contains(def.shortHash)) { | ||
defsToRehash.Add(def); | ||
} else { | ||
seenHashes.Add(def.shortHash); | ||
} | ||
} | ||
defsToRehash.SortBy(d => d.defName); | ||
for (int i = 0; i < defsToRehash.Count; i++) { | ||
var def = defsToRehash[i]; | ||
def.shortHash = 0; | ||
InjectedDefHasher.GiveShortHasToDef(def); | ||
Log.Message(def.defName+" "+def.shortHash); | ||
} | ||
seenHashes.Clear(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.