Skip to content

[fix/perf] Harden LandGolfBallInCup projectile validation#3232

Open
Xekep wants to merge 1 commit intoPryaxis:general-develfrom
TerraZ-Team:pr/micro-fix-golf-cup-validation-clean
Open

[fix/perf] Harden LandGolfBallInCup projectile validation#3232
Xekep wants to merge 1 commit intoPryaxis:general-develfrom
TerraZ-Team:pr/micro-fix-golf-cup-validation-clean

Conversation

@Xekep
Copy link
Contributor

@Xekep Xekep commented Feb 28, 2026

This patch fixes a golf-hole tile validation condition and synchronizes recent-projectile checks with a lock.

It prevents false accepts/rejects in golf packet validation and avoids unsafe list iteration under packet load.

Scope is intentionally small: only LandGolfBallInCupHandler.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

This PR fixes a critical validation bug and adds proper thread synchronization to the golf ball landing handler.

Key Changes:

  • Fixed tile validation logic on line 105: changed && to || - the original logic incorrectly required BOTH conditions (tile inactive AND wrong type) to reject, when it should reject if EITHER condition is true
  • Added lock around RecentlyCreatedProjectiles access (lines 121-133) to prevent race conditions during concurrent packet handling, consistent with locking patterns used throughout Bouncer.cs and GetDataHandlers.cs
  • Replaced LINQ .Any() calls with manual indexed iteration for better performance and safety under lock

Confidence Score: 5/5

  • Safe to merge - fixes critical bugs with focused, well-tested changes
  • The PR correctly fixes a logic bug in tile validation and adds necessary thread synchronization consistent with established codebase patterns. Changes are minimal, focused, and address real issues without introducing new risks.
  • No files require special attention

Important Files Changed

Filename Overview
TShockAPI/Handlers/LandGolfBallInCupHandler.cs Fixed critical validation logic bug (&& to `

Last reviewed commit: 48ba903

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant