Fix TendSelf/TendPatient reservation conflict in CompTend - #4653
Open
WhiteGiverMa wants to merge 2 commits into
Open
Fix TendSelf/TendPatient reservation conflict in CompTend#4653WhiteGiverMa wants to merge 2 commits into
WhiteGiverMa wants to merge 2 commits into
Conversation
When CompTend assigns a TendSelf job to a pawn, it never checks whether another pawn has already reserved that pawn for TendPatient. Both jobs call pawn.Reserve(Deliveree, ...) with maxPawns=1 on the same target, causing the second Reserve() to fail and spam LogCouldNotReserveError red errors in combat. Reproduction: capture a prisoner, injure them, send a doctor to tend them. The prisoner (non-player faction, thus eligible for CompTend) will simultaneously try to TendSelf, triggering the reservation conflict. Fix: before creating the TendSelf job, iterate ReservationManager. ReservationsReadOnly to check if any other pawn has already reserved the target.
|
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-28738024820.zip |
Contributor
|
Thanks! Can you provide some reproduction steps and a corresponding Player.log? |
4 tasks
|
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-29979168696.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additions
Changes
CompTend.TryGiveTacticalJob()now checksReservationManager.ReservationsReadOnlybefore creating aTendSelfjob. If another pawn has already reserved the target (e.g., a doctor performingTendPatient), the assignment is skipped and the cooldown counter (lastTendJobCheckedAt) is updated.References
Reasoning
CompTendsimultaneously assigns aTendSelfjob while a doctor pawn may already be tending them viaTendPatient. Both jobs callpawn.Reserve(Deliveree, ...)throughJobDriver_TendPatient.TryMakePreToilReservationswithmaxPawns: 1on the same target, causingLogCouldNotReserveErrorred error spam in the console.ReservationsReadOnlydirectly rather than usingIsReservedByAnyoneOf(target, faction)to cover cross-faction scenarios (e.g., a player-faction doctor tending a prisoner from a different faction).Alternatives
TryGiveTacticalJobsprefix instead (the caller):IsReservedByAnyoneOf(target, pawn.Faction):ReservationsReadOnlywith explicit iteration covers all cases.Testing
Note: fix verified through a local Harmony prefix patch (same logic, built and deployed). In-game testing pending.