Multiplayer icon indicating copy to clipboard operation
Multiplayer copied to clipboard

Fixed extracting relics from reliquary

Open SokyranTheDragon opened this issue 3 years ago • 8 comments

This is going to also fix all things using the CompThingContainer ThingComp, which presumably also have the same issue. However, I don't think it's used in the game (except for being the base for CompRelicContainer). I'm not aware of any mods using this feature either, so I cannot check if it's true or not.

SokyranTheDragon avatar Jan 24 '22 02:01 SokyranTheDragon

I think it's just missing the context. Give it a try with ISyncMethod SetContext(SyncContext.MapSelected)

notfood avatar Jan 24 '22 02:01 notfood

Well, there are float menu options that are fixed by this. The one I set up the SyncDelegate for is fine. The problematic option would have the lambdaOrdinal parameter equal to 16 (extract relic to storage area). The problem with syncing it is that the delegate would require syncing Job, which doesn't have a SyncWorker, and is causing an error.

SokyranTheDragon avatar Jan 24 '22 15:01 SokyranTheDragon

ISyncDelegate offers the same option. It should work with the context, it gives you the selected thing they are right clicking.

notfood avatar Jan 24 '22 16:01 notfood

I'm aware of this. The issue however is with creating the ISyncDelegate. It contains a field with a type that we can't sync. See the included error:

https://gist.github.com/SokyranTheDragon/2b9325fdf6c96f69e3b9e9d3fdee2aa7

SokyranTheDragon avatar Jan 24 '22 16:01 SokyranTheDragon

I'll let this sit a bit more. I'm not convinced that it can't be dealt on the float menu itself.

notfood avatar Jan 27 '22 05:01 notfood

Honestly, I wouldn't be surprised. However, I wasn't able to accomplish that. The job creation seems to be synced fine for the most part, just during syncing it somehow loses one of the important fields (and we end up with a null Thing).

If you're not a fan of my workaround, and we aren't able to fix it, we could at the very least merge in the SyncDelegate.Lambda part, as this one is working fine.

SokyranTheDragon avatar Jan 27 '22 17:01 SokyranTheDragon

After looking into it more, I believe the issue is that while syncing the Job parameter (using ExposeParameter for sync methods Pawn_JobTracker.TryTakeOrderedJob or Pawn_JobTracker.TryTakeOrderedJobPrioritizedWork), it's not being able to sync the thing that's supposed to be extracted.

My guess as to why that is would be that it's stored inside of CompRelicContainer/CompThingContainer, and potential solution would be to try and identify why that is, and try to fix that. I believe this approach wouldn't require syncing anything in FloatMenuMakerMap. I'll admit, that I'm unsure of how to approach this.

The solution I've applied is a workaround - since we have access to the CompRelicContainer/CompThingContainer, I've just decided to get the target, which failed to sync, right out of that comp. I admit it's not the best solution, but it works.

A third solution I've identified. This would require creating the sync delegate. However, the catch is that it would either require either making a sync worker for job - which again, could potentially end up with the same issue that exists right now (see first solution I mentioned), or not syncing the job (specifying which fields to sync) and then creating it in PreInvoke. I think this would be possibly the worst solution for this, and require the most amount of work.

SokyranTheDragon avatar Feb 05 '22 23:02 SokyranTheDragon

To continue on the first/cleanest solution: looking through the decompiler, looks like trying to read the Thing from the LoadedObjectDirectoryallObjectsByLoadID fails, as it's not there. It's causing the following warning:

Could not resolve reference to object with loadID Thing_RelicInertPendant1073741836 of type Verse.Thing. Was it compressed away, destroyed, had no ID number, or not saved/loaded right? curParent=ExtractRelic (Job_-56) A=Thing_Reliquary1073755562 C=(111, 0, 116) curPathRelToParent=/targetB

Again, I have no idea what to do about this.

SokyranTheDragon avatar Feb 06 '22 00:02 SokyranTheDragon

Fixed by #307

SokyranTheDragon avatar Oct 08 '22 18:10 SokyranTheDragon