Skip to content

fixe the issue where players recently fired bullets would be saved to an invalid index - #3308

Closed
Controllerdestiny wants to merge 2 commits into
Pryaxis:general-develfrom
Controllerdestiny:proj
Closed

Controllerdestiny wants to merge 2 commits into
Pryaxis:general-develfrom
Controllerdestiny:proj

Conversation

@Controllerdestiny

Copy link
Copy Markdown

This will cause an invalid index to be stored when creating bullets, and using the RecentlyCreatedProjectiles code may have potential issues, just like the portal detection in Bouncer.

           var index = TShock.Utils.SearchProjectile(ident, owner, key.Generation);

			// Cattiva's dig ability can bypass build permissions via vanilla exploit in Terraria v1.4.5
			// Block ai[0] == 3 (dig state)
			if (type == ProjectileID.PalworldMinionCattiva && ai[0] == 3f)
			{
				TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleProjectileNew rejected Palworld Minion Cattiva dig sync {0}", args.Player.Name));
				return true;
			}

			if (OnNewProjectile(args.Data, ident, pos, vel, knockback, dmg, owner, type, ident, args.Player, ai, key.Generation))
				return true;

			lock (args.Player.RecentlyCreatedProjectiles)
			{
				if (!args.Player.RecentlyCreatedProjectiles.Any(p => p.Index == index))
				if (!args.Player.RecentlyCreatedProjectiles.Any(p => p.Index == ident))
				{
					args.Player.RecentlyCreatedProjectiles.Add(new GetDataHandlers.ProjectileStruct()
					{
						Index = index,
						Index = ident,
						Type = type,
						CreatedAt = DateTime.Now
					});
				}
			}

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces resolved projectile indices with packet-local identities when dispatching and recording newly created projectiles, and exposes a dash-control bit in the player-update model.

  • Changes new-projectile event and recent-projectile identity handling.
  • Adds ControlDash to ControlSet.
  • Leaves recent-projectile consumers operating in a different identity domain, producing a blocking correctness issue.

Confidence Score: 4/5

This PR is not safe to merge until recent-projectile tracking uses an identity representation consistent with its Main.projectile consumers and kill handling.

The changed creation path stores an owner-scoped packet identity where several existing checks require a server-global projectile index, causing those checks to inspect unrelated projectile state and leaving kill tracking inconsistent.

Files Needing Attention: TShockAPI/GetDataHandlers.cs

Important Files Changed

Filename Overview
TShockAPI/GetDataHandlers.cs Replaces resolved projectile indices with packet identities, leaving RecentlyCreatedProjectiles inconsistent with its consumers and kill handling.
TShockAPI/Models/PlayerUpdate/ControlSet.cs Adds a bit-backed ControlDash property; no concrete regression was established.

Reviews (1): Last reviewed commit: "fixed the issue where players recently f..." | Re-trigger Greptile

Comment on lines +3360 to +3364
if (!args.Player.RecentlyCreatedProjectiles.Any(p => p.Index == ident))
{
args.Player.RecentlyCreatedProjectiles.Add(new GetDataHandlers.ProjectileStruct()
{
Index = index,
Index = ident,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Projectile identity domains conflict

ident is the owner-scoped value from ProjectileKey.Index, but ProjectileStruct.Index is documented and consumed as an index into Main.projectile. When those values differ, the rope, portal, liquid, and fishing checks inspect an unrelated projectile. Kill handling also searches recent entries using the resolved server index, while generation reuse is deduplicated using only ident. As a result, legitimate projectile-backed actions can be rejected or unrelated actions can be accepted.

Knowledge Base Used:

@Controllerdestiny Controllerdestiny closed this by deleting the head repository Sep 10, 2026
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