when rotating the fleet, ships goes out of sync in term of speed letting the player spam a direction to build up speed infinitely #72
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implemented and pushed in
d68aac6.A fast series of tiny taps on the pivot control could each individually queue the minimum pivot step, stacking up to a rotation rate faster than holding the control down - an exploit around the intended hold-to-rotate speed cap. Added a per-direction cooldown (
PIVOT_TAP_COOLDOWN, derived from the existingPIVOT_MIN_STEP/PIVOT_SPEED) so a tap in the same direction can't be repeated faster than a held rotation would achieve. Tracked separately for CW/CCW so a legitimate quick direction-reversal (tap right, immediately tap left) still isn't throttled by the other direction's cooldown.Tests: extended
tests/test_pivot_controls.gd(bash tests/run_tests.sh pivot_controls) with a spam-immunity assertion - 5 rapid same-direction taps produce ~0 additional rotation beyond the first.Reopening the record on this one: the fix I closed this with was not a fix. The pivot cooldown throttled how often the exploit could be triggered and never touched the cause. The reporter confirmed the behaviour was still there. Actually fixed in
67cb853.The cause
Fleet.stop()did:_assign_slot_targets()refillsfleet_velocityon the next steer, so every press-release cycle added a whole cruise velocity to the ship's own, decaying only ataccelerationin between. Tap faster than that bleeds it off and they stack without limit. Ships fell out of sync because each bled off at a rate set by its own distance to its slot - which is exactly the "goes out of sync in term of speed" in the title.Measured against the pre-fix code, spamming a direction while pivoting:
42x faster than flying honestly, with a vessel at 48x its own top speed. Note
fastest vessel 0.0xon the honest leg - that is the bug's other half showing through.Why it was there
ship.velocitywas not the ship's real motion. Ship snapped to its slot every tick and zeroed it, so a vessel cruising at full speed reported zero, and the truth lived in a second field that callers had to add back in.stop()was compensating for that lie. Everything else - the frame-rate-dependent behaviour, the "pause then it moves again" stutter this code had already been patched for - came from the same place.The fix
Fixed at the root rather than by clamping the symptom, along the lines the reporter suggested (simplify how the fleet and vessels move together):
fleet_velocityis now fed forward into the steering instead of carried alongside it. The ship aims to travel at its slot's velocity plus a correction closing the gap, so holding formation costs no error andvelocityis always true world motion.Fleet.stop()injects nothing; it reports that the slot has halted.Test
tests/test_fleet_speed_bounded.gd, verified to fail against the previous code with the numbers above. It covers: no vessel exceeds its own top speed however hard a direction is spammed; spamming cannot cover more ground than honestly holding the stick; both hold while the formation is being pivoted, the case this ticket names; and the fleet stays together rather than fanning out. Speeds are tracked as a ratio of each vessel's own limit, so a mixed fleet is judged per vessel.One knock-on worth recording: making
velocityhonest changedtest_space_time_distorder.gd's baseline from "formation lag 0.0" to 51.6 - the old zero was the teleport-snap lying about a ship that was in fact moving. That test also now clears the asteroid and enemy groups at setup (the idiomtest_ship_lab.gdalready uses); silencing the spawners was never enough, and losing the distorder vessel to a rock resets the multiplier correctly, which it had been reporting three stages later as a failed scene swap.Full suite green at 94/94.