Conversation
This PR fixes rwmt#556 and synchronizes the last step in "Drop pod raid at location..." debug option that utilizes the `Targeter.BeginTarget` method. This method isn't used elsewhere in the debug system, but it is invoked by certain other systems. It basically takes a action and invokes it on mouse click. I implemented the fix in a similiar fession to the other `DebugSource`. The main challenge I faced was ensuring that my prefix is executed _only_ when `Targeter.BeginTarget` is called from the `DebugActionsIncidents.ExecuteDropPodRaidAtLocation` method. To achieve this, I used a bit of reflection to check where the action was created. I'm not entirely sure if this is the optimal approach. Feedback on better alternatives is welcome.
Ignore that for now - I might already have a better solution |
|
Never mind - I was thinking the guard below might be sufficient, but after reviewing other patches for Targeter.BeginTargeting, I noticed that the patch Feedback.CancelBeginTargeting is also used in a synced command.
The PR works as-is, but the current guard could be considered a bit hacky. I'm open to feedback again :) |
|
It could use an alternative, it's a very slow and ugly hack. |
|
I've been thinking about it a bit more. Idea A:
I want to use this flag to guard my patch instead of relying on reflection. Idea BAnother idea could be to check whether the currently executed cmd type is CommandType.DebugTools. I haven’t looked into it in detail yet, but it should work, shouldn’t be too hard to implement, and might be useful in the future. |
|
Idea B sounds really promising. |
Tracking the currently executing command type allows me to run the Targeter.BeginTargeting prefix only when it's executed within DebugToolCmd. Additionally, this change made some of the logic that checks whether a cmd is currently running redundant, so I removed it."
|
Yep it is good to go, I just tested it quickly again merged into dev.
This still happens. I did not report it so far. I've written it down this time - so I won't forget it. |
Label: 1.6, fix
Additional Notes on the "Drop pod raid at location..." Debug Option:
This debug option was introduced with RimWorld 1.6.
While testing this the PR, I encountered consistent crashes when setting the raid points above approximately 750. This issue occurs even in an unmodded version of the game and has been confirmed by SirWilliams.
I haven’t yet found an existing bug report about this on the RimWorld Discord, though I didn’t search extensively. If no report surfaces, I plan to report the issue myself.
Reproduce mentioned crash:
PR
This PR fixes #556 and synchronizes the final step in the "Drop pod raid at location..." debug option, which uses the Targeter.BeginTarget method. While this method doesn't appear to be used elsewhere in the debug system, it is invoked by other parts of the game. Essentially, it takes an Action and executes it when the user clicks on a target.
I implemented the fix in a similar fashion to the other 'DebugSource' enums.
The main challenge I faced was ensuring that my prefix runs only when
Targeter.BeginTargetis invoked from within theDebugActionsIncidents.ExecuteDropPodRaidAtLocationmethod - or at the very least, from somewhere within theDebugActionsIncidentsclass. To achieve this, I used a bit of reflection to check in which class the action was created viaActionIsCreatedInDebugActionsIncidents(shown below). I'm not entirely sure if this is an acceptable approach.Feedback on better alternatives is welcome.
Test
The fix was tested primarily on dev
Targeter.BeginTargetviaDebugSync.ReadCmd. I was not able to trigger this path naturally through regular gameplay in a reasonable amount of time.