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

Topics - Prince Kasta

#1
Help / Error when loading a saved dictionary
August 08, 2019, 02:01:30 PM
Keys count does not match the values count while loading a dictionary (maybe keys and values were resolved during different passes?). Some elements will be skipped. keys=5, values=0, label=resourcePool

That is how it is in the save file

                                                <keys>
<li>Faction_4</li>
<li>Faction_5</li>
<li>Faction_6</li>
<li>Faction_7</li>
<li>Faction_8</li>
</keys>
<values>
<li>5800</li>
<li>6300</li>
<li>4100</li>
<li>4000</li>
<li>6900</li>
</values>


The code in the World Comp's exposedata:

            List<Faction> factions= new List<Faction>();
            List<int> ints = new List<int>();
           
            Scribe_Collections.Look(ref resourcePool, "resourcePool", LookMode.Reference, LookMode.Value, ref factions, ref ints);


The problem is in the LoadSaveMode.ResolvingCrossRefs pass, the Key list's count isn't the same as the values's list.
#2
I'm using FindPath to find a path between two world objects, the error appears the third time the method is run and won't repeat again until a full restart of the game.




How to fix this/Is there a better way to find a path?




WorldPathPool leak: more paths than caravans. Force-recovering.
Verse.Log:Error(String, Boolean)
Verse.Log:ErrorOnce(String, Int32, Boolean)
RimWorld.Planet.WorldPathPool:GetEmptyWorldPath()
RimWorld.Planet.WorldPathFinder:FinalizedPath(Int32)
RimWorld.Planet.WorldPathFinder:FindPath(Int32, Int32, Caravan, Func`2)


I'm dumb, an earlier use of a WorldPath object was the culprit as I didn't dispose of it properly.

#3

Exception ticking Klein (at (85, 0, 115)): System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
  at System.Collections.Generic.Dictionary`2[RimWorld.Faction,Verse.PawnDestinationReservationManager+PawnDestinationSet].get_Item (RimWorld.Faction key) [0x00000] in <filename unknown>:0
  at Verse.PawnDestinationReservationManager.ReleaseClaimedBy (Verse.Pawn p, Verse.AI.Job job) [0x00000] in <filename unknown>:0
  at Verse.Pawn.ClearReservationsForJob (Verse.AI.Job job) [0x00000] in <filename unknown>:0
  at Verse.AI.Pawn_JobTracker.CleanupCurrentJob (JobCondition condition, Boolean releaseReservations, Boolean cancelBusyStancesSoft) [0x00000] in <filename unknown>:0
  at Verse.AI.Pawn_JobTracker.EndCurrentJob (JobCondition condition, Boolean startNewJob) [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.EndJobWith (JobCondition condition) [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.TryActuallyStartNextToil () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.ReadyForNextToil () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.TryActuallyStartNextToil () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.ReadyForNextToil () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.Notify_PatherArrived () [0x00000] in <filename unknown>:0
  at Verse.AI.Pawn_PathFollower.PatherArrived () [0x00000] in <filename unknown>:0
  at Verse.AI.Pawn_PathFollower.TryEnterNextPathCell () [0x00000] in <filename unknown>:0
  at Verse.AI.Pawn_PathFollower.PatherTick () [0x00000] in <filename unknown>:0
  at Verse.Pawn.Tick () [0x00000] in <filename unknown>:0
  at Verse.TickList.Tick () [0x00000] in <filename unknown>:0
Verse.Log:Error(String, Boolean)
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Update()

This I think leads to the next error of

Klein with job GotoWander (Job_465) A=(85, 0, 115) tried to get CurToil with curToilIndex=2 but only has 2 toils.
Verse.Log:Error(String, Boolean)
Verse.AI.JobDriver:get_CurToil()
Verse.AI.JobDriver:DriverTick()
Verse.AI.Pawn_JobTracker:JobTrackerTick()
Verse.Pawn:Tick()
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Update()


I'm trying to spawn the pawns as defenders in an outpost.

It looks like the pawns aren't added to some dictionary but I can't figure out how to fix it, I tried map.pawnDestinationReservationManager.RegisterFaction() on the sites' map but then it says it's already registered.

Edit: doing map.mapPawns.UpdateRegistryForPawn(p) for each pawn appeared to have solved the issue
#4
First time trying to mod, I want to modify prices when dealing with specific conditions but I can't find a way to change anything including where I think the price calculation is done (TradeUtility.GetPricePlayerBuy/Sell, right?)
I tried to create a Harmony pre/post fix for those methods but it doesn't seem to trigger when I test trades
with this code.


       [HarmonyPatch(typeof(TradeUtility), "GetPricePlayerSell", null)]
        public static class TradeUtility_GetPricePlayerSell_PrePostfix_Patch
        {
            public static void PreFix(float __result)
            {
                Log.Warning("PreFix");
            }
            public static void PostFix(float __result)
            {
                Log.Warning("PostFix");
            }
        }
        [HarmonyPatch(typeof(TradeUtility), "GetPricePlayerBuy", null)]
        public static class TradeUtility_GetPricePlayerBuy_PrePostfix_Patch
        {
            public static void PreFix(float __result)
            {
                Log.Warning("PreFix2");
            }
            public static void PostFix(float __result)
            {
                Log.Warning("PostFix2");
            }
        }

My other harmony patch for something else works correctly and these patches show up when I log all harmony patches in the debug console. Are they not the correct methods to do this?
Related things that I could find seem to be readonly.
Is what I'm trying to do possible, if so how?
#5
Help / Help making a new Gizmo/Button
October 20, 2018, 07:27:10 AM
I want to add a button to the caravan world map that will create an event.
I tried going through Allow Tool and Tmagic's source codes but I couldn't figure where they create them.

Is there a good example or a tutorial of creating one?