Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Ari

#1
Releases / Re: [1.1-1.3] Forced March
July 20, 2021, 05:37:09 PM
Compatible with 1.3
#2
Releases / [1.1-1.3] Forced March
October 14, 2020, 05:06:31 AM

Description
Allows you to select "Forced March" on a caravan to force them to ignore sleep. Useful for getting colonists around at night in emergencies, or when they are a night owl (night owls sleep at night on caravan). However, don't forget to turn off forced march before your colonists go crazy from exhaustion.

Requirements
- Harmony

Compatability
- Multiplayer compatible

Download
GitHub: https://github.com/AriAlavi/Rimworld-ForcedMarch
Steam: https://steamcommunity.com/sharedfiles/filedetails/?id=2257245929

#3
It seems like what I really needed to do was get a night of sleep. I fixed the problem quickly. I found a Rimworld modding guide and learned that the barckets should be configured differently for properties:

    [HarmonyPatch(typeof(Caravan))]
    [HarmonyPatch("NightResting", MethodType.Getter)]


Thanks for leading me back to the Harmony docuemtnation.
#4
I came to the conclusion that Harmony doesn't allow property changes because the property NightResting is declared as "public bool NightResting" and my patch is declared as "public static bool CaravanNightRestingPrefix(ref bool __result, Caravan __instance)" yet I get the following error when loading into the main menu:

Relevant part of error
System.ArgumentException: Undefined target method for patch method static System.Boolean ForcedMarch.CaravanNightRestUtilityPatch::CaravanNightRestingPrefix(System.Boolean& __result, RimWorld.Planet.Caravan __instance)

Whole error
Error in static constructor of ForcedMarch.HarmonyPatches: System.TypeInitializationException: The type initializer for 'ForcedMarch.HarmonyPatches' threw an exception. ---> HarmonyLib.HarmonyException: Patching exception in method null ---> System.ArgumentException: Undefined target method for patch method static System.Boolean ForcedMarch.CaravanNightRestUtilityPatch::CaravanNightRestingPrefix(System.Boolean& __result, RimWorld.Planet.Caravan __instance)
  at HarmonyLib.PatchClassProcessor.PatchWithAttributes (System.Reflection.MethodBase& lastOriginal) [0x0004d] in <20181e2d55204880a56a9120ef04a53d>:0
  at HarmonyLib.PatchClassProcessor.Patch () [0x00057] in <20181e2d55204880a56a9120ef04a53d>:0
   --- End of inner exception stack trace ---
  at HarmonyLib.PatchClassProcessor.ReportException (System.Exception exception, System.Reflection.MethodBase original) [0x00127] in <20181e2d55204880a56a9120ef04a53d>:0
  at HarmonyLib.PatchClassProcessor.Patch () [0x00082] in <20181e2d55204880a56a9120ef04a53d>:0
  at HarmonyLib.Harmony.<PatchAll>b__10_0 (System.Type type) [0x00007] in <20181e2d55204880a56a9120ef04a53d>:0
  at HarmonyLib.CollectionExtensions.Do[T] (System.Collections.Generic.IEnumerable`1[T] sequence, System.Action`1[T] action) [0x00014] in <20181e2d55204880a56a9120ef04a53d>:0
  at HarmonyLib.Harmony.PatchAll (System.Reflection.Assembly assembly) [0x00006] in <20181e2d55204880a56a9120ef04a53d>:0
  at ForcedMarch.HarmonyPatches..cctor () [0x0001e] in <ba3b30bebbbc40c5a1d320009e30cf94>:0
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(intptr)
  at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (System.RuntimeTypeHandle type) [0x0002a] in <567df3e0919241ba98db88bec4c6696f>:0
  at (wrapper dynamic-method) Verse.StaticConstructorOnStartupUtility.Verse.StaticConstructorOnStartupUtility.CallAll_Patch1()
Verse.Log:Error(String, Boolean)
Verse.StaticConstructorOnStartupUtility:Verse.StaticConstructorOnStartupUtility.CallAll_Patch1()
Verse.<>c:<DoPlayLoad>b__4_2()
Verse.LongEventHandler:ExecuteToExecuteWhenFinished()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()
Verse.LongEventHandler:LongEventsUpdate(Boolean&)
Verse.Root:Verse.Root.Update_Patch1(Root)
Verse.Root_Entry:Update()


Then I could not find anything in the documentation which may solve my problem and found no mention of properties so I assumed that properties were not supported by Harmony. If it is the case they are supported, may I please have a hint as to what I did wrong here? Ive also tried it without the (Caravan __instance) parameter and it lead to the same error.

This is the code that throws the error:
    [HarmonyPatch(typeof(Caravan), nameof(Caravan.NightResting))]
    public static class CaravanNightRestUtilityPatch
    {
        [HarmonyPrefix]
        public static bool CaravanNightRestingPrefix(ref bool __result, Caravan __instance)
        {
            __result = true;
            return true;
        }
    }


#5
Disclaimer: I'm not new to programming, but I am new to C#.

I want to modify just one getter function. It's in the class Rimworld.Planet::Caravan and the getter is public bool NightResting.

I tried to make use of Harmony to modify the function, but it seems that harmony is only for modifying methods, not properties.

Then I tried to modify "class CaravanNightRestUtility" through harmony. The class' methods influence the getter's value. But I realized that the methods of that class were not given the parameter required (class Caravan) to modify it in the way I wanted to modify it.

Then I tried to override "class CaravanNightRestUtility" through inheritance but the class is "sealed" (why???).

I briefly thought about inheriting the Caravan class and modifying that, before my linter told me it was referenced no less than 300 times in core. Yet it seems like the only option forward.

All I want is to modify a single getter, "Rimworld.Planet.Caravan.NightResting". I'd also settle for changing the parameters and implementation of a method of "Rimworld.Planet.Caravan.CaravanNightRestUtility". I've been at this for 6 hours and I don't want to change 300+ references. pls help :'(
#6
Rimlink

Rimlink provides complete synchronization of your game and config files with your friends' game files. It is made for Windows users only. (But if anyone wants to contribute support to another OS - the code is open source).

What is the purpose of Rimlink?(it's to prevent desyncs in multiplayer)
When there is a mismatch in mods downloaded, the multiplayer mod will not allow you to join your friend's server. If you are on a different version of Rimworld, you will be allowed to join the server but will suffer desyncs quickly. Additionally, if you have the same mods, but even slightly different mod configs, you will eventually encounter a desync if those mod configs affect the game's state in any way.

How is this different from Steam automatic downloads?
Firstly, there is a population of the game who preferred GoG over Steam who of course do not have access to steam's automatic downloads. There is also the problem that not all mods are found on the steam workshop. Finally, you may also only want a specific, outdated version of the mod which is not served on steam.

Every time I added a new mod it was a nightmare to make sure my friends had their mod file looking like mine so I started zipping up the whole folder and sending it to them. I did that one too many times before I broke, creating Rimlink.

How do I use Rimlink?
1. Port forward on port 5002 OR Make use of Hamachi (if making use of Hamachi, use Hamachi's IP and not your own)
2. Put rimlink.exe in your Rimworld directory and run as admin
3. If you generally host the Rimworld server, make sure you say (y)es when asked so
4. After the host has the rimlink tool running, then your friends can run the Rimlink tool in the same way, but saying (n)o when asked if they host Rimworld servers
5. Rimlink will make sure your friend's files and folders are 100% exactly the same as yours. It will download and remove files as needed for that to happen

Wait a second, .exe file? I don't trust that, and especially not with admin privileges.
Good. Don't trust random people on internet forms who have never made a post before to give you uninfected .exe files. For all you know there is a bitcoin miner in there. If you are technically inclined or have a friend who is, please consider compiling from the source code found on the GitHub page. There are various tools to do so, my favorite being auto-py-to-exe.

Download:
GitHub: https://github.com/AriAlavi/rimlink (If you are unfamiliar with GitHub, look for the releases section, click on the latest, and download rimlink.exe)

Made to prevent desync on Zenith's Multiplayer mod (now maintained by the community): https://github.com/rwmt/Multiplayer

License
Rimlink is licensed under GPL-3.0 making it free for all to download, modify, and redistribute so long as it is never made for-sale.