Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions TShockAPI/Handlers/LandGolfBallInCupHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void OnReceive(object sender, LandGolfBallInCupEventArgs args)
return;
}

if (!Main.tile[args.TileX, args.TileY].active() && Main.tile[args.TileX, args.TileY].type != TileID.GolfHole)
if (!Main.tile[args.TileX, args.TileY].active() || Main.tile[args.TileX, args.TileY].type != TileID.GolfHole)
{
TShock.Log.ConsoleDebug(GetString($"LandGolfBallInCupHandler: Tile at packet position X:{args.TileX} Y:{args.TileY} is not a golf hole! - From {args.Player.Name}"));
args.Handled = true;
Expand All @@ -116,8 +116,22 @@ public void OnReceive(object sender, LandGolfBallInCupEventArgs args)
return;
}

var usedGolfBall = args.Player.RecentlyCreatedProjectiles.Any(e => GolfBallProjectileIDs.Contains(e.Type));
var usedGolfClub = args.Player.RecentlyCreatedProjectiles.Any(e => e.Type == ProjectileID.GolfClubHelper);
var usedGolfBall = false;
var usedGolfClub = false;
lock (args.Player.RecentlyCreatedProjectiles)
{
for (int i = 0; i < args.Player.RecentlyCreatedProjectiles.Count; i++)
{
var tracked = args.Player.RecentlyCreatedProjectiles[i];
if (!usedGolfBall && GolfBallProjectileIDs.Contains(tracked.Type))
usedGolfBall = true;
if (!usedGolfClub && tracked.Type == ProjectileID.GolfClubHelper)
usedGolfClub = true;
if (usedGolfBall && usedGolfClub)
break;
}
}

if (!usedGolfClub && !usedGolfBall)
{
TShock.Log.ConsoleDebug(GetString($"GolfPacketHandler: Player did not have create a golf club projectile the last 5 seconds! - From {args.Player.Name}"));
Expand Down