[1.0] Smart Medicine

Started by Uuugggg, February 22, 2018, 02:29:07 PM

Previous topic - Next topic

Uuugggg

Yeh, I've had enough of dealing with the settings code there, it's always nulling my arrays

considering it makes no sense that it would work the second time and not the first.

Harry_Dicks

#31
Quote from: Uuugggg on March 06, 2018, 04:48:35 PM
considering it makes no sense that it would work the second time and not the first.
I know it sounds crazy, but I promise this is what's happening. I even went back in with a new, fresh copy of your mod, turning everything else off except for HugsLib, ModSwitch, JecsTools, and your mod. And it happened again still, and the same result was that after the error pops, when I went back to the mod options menu, the new icons are now located down below for me to interact with.

Also, since I've had my settings configured in such a way, I've been getting this error now. Is there a setting that I can change to remove this error, or will this be anything to worry about? I'm not really sure how it will affect my game :-[ Or could this be related to the display error I had pop earlier? This error is popping up at the game's launch, just going into the main menu.

SaveableFromNode exception: System.InvalidCastException: Cannot cast from source type to destination type.
  at (wrapper managed-to-native) object:__icall_wrapper_mono_object_castclass (object,intptr)
  at Verse.ScribeExtractor.SaveableFromNode[Settings] (System.Xml.XmlNode subNode, System.Object[] ctorArgs) [0x00000] in <filename unknown>:0
Subnode:
<ModSettings Class="SmartMedicine.Settings"><distanceToUseFromOther>6</distanceToUseFromOther><minimalMedicineForNonUrgent>False</minimalMedicineForNonUrgent><noMedicineForNonUrgent>True</noMedicineForNonUrgent><goodEnoughDowngradeFactor>0.6521739</goodEnoughDowngradeFactor><stockUpOnMedicine>True</stockUpOnMedicine><stockUpCapacity>5</stockUpCapacity><stockUpList><li>3</li><li>2</li><li>1</li></stockUpList><fieldTendingAlways>True</fieldTendingAlways></ModSettings>
Verse.Log:Error(String)
Verse.ScribeExtractor:SaveableFromNode(XmlNode, Object[])
Verse.Scribe_Deep:Look(Settings&, Boolean, String, Object[])
Verse.Scribe_Deep:Look(Settings&, String, Object[])
Verse.LoadedModManager:ReadModSettings(String, String)
Verse.Mod:GetSettings()
Safely_Hidden_Away.Mod:.ctor(ModContentPack)
System.Reflection.MonoCMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoCMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MonoCMethod:Invoke(BindingFlags, Binder, Object[], CultureInfo)
System.Activator:CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[])
System.Activator:CreateInstance(Type, Object[], Object[])
System.Activator:CreateInstance(Type, Object[])
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__1()

Uuugggg

O_o no clue what's going on there.

I'd say delete the config files and relaunch... but the config is printed in the error there and looks fine

Harry_Dicks

That's what I was originally doing that caused the first error I was posting about ::)

Anyway, when I don't have my settings on this particular configuration, I get no error. However, I will delete my settings, and everything will be fine, but then when I switch back to these settings then I will get this recurring error. I'm sure there might be some other tests I could do, but I want to say I am fairly confident that I did try running only this mod and I had those issues, but I am not 100% sure of this - I might have been only messing with the other issue. Messing around with so many mods for so many days makes it all become just one big blur.

I'll try to get around to doing this to confirm. If this ends up being the case, then this error could possibly be being caused by these particular settings, no?

Kori

I experienced the same problem as Harry.
The first time I clicked on a particular option I got this error. When I went back and tried the same thing again, it worked.

Uuugggg

Alright, here's the issue:

If your config file is blank, it still goes through the loading process and sets defaults.

If you don't even have a config file, it doesn't do that. So there are some null arrays there. It then saves your config, and initializes the array.

So... the defaults need to be saved in two places in code. Ehhh. Fine.

Harry_Dicks

#36
I figured out where that odd error I was getting was coming from: I had an extra mod settings file saved in my config from where I had your mod under a separate name. Ah well, sorry for the confusion.

Anyway, I would like to submit a request, if you don't mind. The ability to let pawns carry a drug with them. This way we can always have our "combat stim" on hand. Go Juice, flake, yayo, or whatever you could have from mods. It would be really awesome if there was something similar to how you can select what medicines you allow doctors to carry, but you could also select what drugs pawns could carry as well.

Taking it one step further, like you had mentioned earlier, would be letting the player differentiate what pawns can carry what drugs/medicines. Of course, I know all of this could take a lot of work. Either way, I just wanted to put the idea out there, as you seemed to have been on such an awesome spree lately, tackling a lot of pawn inventory issues.

If this is beyond the scope or direction that you want to take this mod, I understand. However, maybe you could consider something like a "Smart Drugs" mod in the future then? :)

PS-BTW I had just had my first raid on my new map, and was watching my doctor patch up the other colonists after the fight. It was really nice watching him (who carried 5 regular and 5 herbal medicine) use his on hand herbal medicine for the captured prisoner with heavy wounds, no medicine for one colonist with light wounds, and then used the medicine from my other doctor's inventory for her dire wounds.

Lethe

>"Multiple Reservations
This hardly deserves an entire section since it was actually easy to implement and it should be in the base game. But now multiple doctors can reserve the same stack."

Hmmm...do you think you could extend this behavior to the rest of the game? A multiple reservations extension mod that allows different pawns to all harmoniously work with one stack of X good/material/item. It's high time our rimworld-ers learned the importance of sharing.

Uuugggg

Oh, my, no.

Things are reserved in a hundred places, and you'd need to know how many you're reserving each time, and the code to edit that would not be pretty. It's not feasible in some cases.

Medicine, though, is only reserved a few places, so I went in and fixed that. My code was reserving and checking reservations already, so it was a small change.

Now, if I had control over source code, it'd be doable. I can only imagine 1.0 has this coming.

coldcell

I'm having the problem as above, but mine isn't consistent and ticking/unticking the options don't seem to always work 100%. Many times my doctors will just "Standing" beside the patient. It may be conflicting with Fluffy's Work Tab because of the many sub-jobs added by that mod.

However just wanna say +1 this mod because the idea is awesome.

Vlad0mi3r

Can it be confirmed that there is no issue with Fluffy's work tab? This mod is awesome but I don't think I can play without Fluffy's work tab any more.
Mods I would recommend:
Mending, Fertile Fields, Smokeleaf Industries and the Giddy Up series.

The Mod you must have:
https://ludeon.com/forums/index.php?topic=40545.msg403503#msg403503

Uuugggg

You bet, I use Fluffy's Work Tab.

The job to stock up is not even work anymore, actually, so there's definitely no conflict with the work tab.

Vlad0mi3r

Mods I would recommend:
Mending, Fertile Fields, Smokeleaf Industries and the Giddy Up series.

The Mod you must have:
https://ludeon.com/forums/index.php?topic=40545.msg403503#msg403503

Marsunpaisti

#43
Hi! I'm getting this error every now and then causing pauses, and I'm 90% sure its this mod causing it. It just happened when a visiting caravan member got injured so perhaps it has something to do with it.

EDIT: Actually now I think it happens when any non-colonist gets hurt. Just after a siege it started occurring again. My ghetto fix is to reload the save with the mod disabled and then re-enable and it wont happen again until later.

Error in WorldPawnGCTick(): System.NullReferenceException: Object reference not set to an instance of an object
at Verse.Map.get_ParentHolder () <0x0000c>
at Verse.ThingOwnerUtility.AnyParentIs<RimWorld.Planet.TravelingTransportPods> (Verse.Thing) <0x00087>
at (wrapper dynamic-method) RimWorld.PawnUtility.IsTravelingInTransportPodWorldObject_Patch1 (Verse.Pawn) <0x0001d>
at RimWorld.Planet.WorldPawnGC.GetCriticalPawnReason (Verse.Pawn) <0x000da>
at RimWorld.Planet.WorldPawnGC/<AccumulatePawnGCData>c__Iterator0.MoveNext () <0x000db>
at RimWorld.Planet.WorldPawnGC/<PawnGCPass>c__Iterator1.MoveNext () <0x0016b>
at RimWorld.Planet.WorldPawnGC.WorldPawnGCTick () <0x000d3>
at RimWorld.Planet.WorldPawns.WorldPawnsTick () <0x00260>

Verse.Log:Error(String)
RimWorld.Planet.WorldPawns:WorldPawnsTick()
RimWorld.Planet.World:WorldTick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Update()

Uuugggg