Skip to content

Commit 14fefbb

Browse files
authored
Fixes Transport pod exception (#619)
* Fix: World Object Faction Context Push On Ticks World object have changed their tick system in 1.6. Therefore the faction context was not correctly pushed anymore. Same as for things in: #616 * Fix: Syncing Action For Transport Pod Launch This is needed for correct transport pod behaviour
1 parent cd9e3e9 commit 14fefbb

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

Source/Client/MultiplayerStatic.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,15 @@ void TryPatch(MethodBase original, HarmonyMethod prefix = null, HarmonyMethod po
421421
var thingMethods = new[]
422422
{
423423
("SpawnSetup", Type.EmptyTypes),
424-
("Tick", Type.EmptyTypes)
424+
("Tick", Type.EmptyTypes),
425+
("TickInterval", [typeof(int)]),
425426
};
426427

427428
foreach (Type t in typeof(WorldObject).AllSubtypesAndSelf())
428429
{
429430
foreach ((string m, Type[] args) in thingMethods)
430431
{
431-
MethodInfo method = t.GetMethod(m, BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly, null, args, null);
432+
MethodInfo method = t.GetMethod(m, BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.NonPublic, null, args, null);
432433
if (method != null)
433434
TryPatch(method, prefix, finalizer: finalizer);
434435
}

Source/Client/Syncing/Dict/SyncDictRimWorld.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -949,23 +949,31 @@ public static class SyncDictRimWorld
949949
}, true // Implicit
950950
},
951951
{
952-
(ByteWriter data, Action<PlanetTile, TransportersArrivalAction> action) =>
953-
{
954-
WriteSync<object>(data, action.Target);
955-
data.WriteString(action.Method.Name);
952+
(ByteWriter data, Action<PlanetTile, TransportersArrivalAction> action) => {
953+
var method = action.Method;
954+
var target = action.Target;
955+
956+
var t = target.GetType();
957+
WriteSync(data, t);
958+
WriteSyncObject(data, target, t);
959+
960+
data.WriteString(method.Name);
956961
},
957-
(ByteReader data) =>
958-
{
959-
// ReadSyncObject can infer the type from the data stream.
960-
object target = ReadSync<object>(data);
962+
(ByteReader data) => {
963+
964+
object target = null;
965+
Type targetType = null;
966+
967+
targetType = ReadSync<Type>(data);
968+
target = ReadSyncObject(data, targetType);
969+
961970
string methodName = data.ReadString();
962971

963-
// Use the ReadSync helper for arrays.
964-
Type[] parameterTypes = ReadSync<Type[]>(data);
965-
if (target == null || methodName == null)
972+
var declaringType = target?.GetType();
973+
if (declaringType == null || methodName == null)
966974
return null;
967975

968-
System.Reflection.MethodInfo method = AccessTools.Method(target.GetType(), methodName, parameterTypes);
976+
var method = AccessTools.Method(declaringType , methodName);
969977
if (method == null) return null;
970978

971979
return (Action<PlanetTile, TransportersArrivalAction>) Delegate.CreateDelegate(typeof(Action<PlanetTile, TransportersArrivalAction>), target, method);

0 commit comments

Comments
 (0)