Lots of new optimizations utilizing prepatcher
To start, this mod now requires Prepatcher and Fishery. New optimizations include: gene ticking improvements, world object improvements, hediff optimizations, world pawn gc optimizations, better mothballing, dds support, ContentFinder caching, additions and changes to reflection caching, as well as various other additions. Multiplayer support has been improved too, but should be considered highly experimental. The WorkGiver_DoBill bug is fixed in this build. Multiple patches aiming to improve RimWorld's load time have been added too.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2023 bradson
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// crashes to desktop somehow
|
||||
/*using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using PerformanceFish.Prepatching;
|
||||
|
||||
namespace PerformanceFish;
|
||||
|
||||
public class DefDatabasePatches : ClassWithFishPrepatches
|
||||
{
|
||||
public class GetNamedPatch : FishPrepatch
|
||||
{
|
||||
public override MethodBase TargetMethodBase { get; } = methodof(DefDatabase<Def>.GetNamed);
|
||||
|
||||
public override void Transpiler(ILProcessor ilProcessor, ModuleDefinition module)
|
||||
=> ilProcessor.ReplaceBodyWith(GetNamed<Def>);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T? GetNamed<T>(string defName, bool errorOnFail = true) where T : Def
|
||||
{
|
||||
var value = DefDatabase<T>.defsByName.TryGetValue(defName);
|
||||
|
||||
if (errorOnFail && value is null)
|
||||
LogMissingDef<T>(defName);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void LogMissingDef<T>(string defName) where T : Def
|
||||
=> Log.Error($"Failed to find {typeof(T)} named {defName}. There are {
|
||||
DefDatabase<T>.defsList.Count} defs of this type loaded.");
|
||||
}
|
||||
|
||||
public class GetByShortHashPatch : FishPrepatch
|
||||
{
|
||||
public override MethodBase TargetMethodBase { get; } = methodof(DefDatabase<Def>.GetByShortHash);
|
||||
|
||||
public override void Transpiler(ILProcessor ilProcessor, ModuleDefinition module)
|
||||
=> ilProcessor.ReplaceBodyWith(GetByShortHash<Def>);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T? GetByShortHash<T>(ushort shortHash) where T : Def
|
||||
=> DefDatabase<T>.defsByShortHash.TryGetValue(shortHash);
|
||||
}
|
||||
}*/
|
||||
Reference in New Issue
Block a user