Skip to content

feat: varying block durations.#47

Open
TrippleAWap wants to merge 30 commits intoSandertv:masterfrom
TrippleAWap:master
Open

feat: varying block durations.#47
TrippleAWap wants to merge 30 commits intoSandertv:masterfrom
TrippleAWap:master

Conversation

@TrippleAWap
Copy link
Contributor

@TrippleAWap TrippleAWap commented Jan 14, 2026

Introduces extra Block methods allowing for varying block durations.

TrippleAWap and others added 19 commits January 3, 2026 15:32
…ients.

Client IDs are now generated as negative int64 values using an atomic uint64 counter, aligning with vanilla client behavior. Additionally, the number of MTU discovery attempts per size is increased from 3 to 4 to match vanilla clients.
…imics vanilla behavior.

Adds a check to ensure that vanilla clients provide a negative client GUID during OPEN_CONNECTION_REQUEST_2 handling. Returns an error if the client GUID is not negative, improving protocol compliance.
Replaces all uses of the timestamp() function with timeSinceStart() to better reflect its purpose as milliseconds since system start, not Unix epoch. Updates related comments and documentation in ConnectedPing and ConnectedPong to clarify the meaning of PingTime and PongTime. Also simplifies .gitignore and adds .gitattributes for LF normalization.
Sorry for all the commits, I'm tired and on a new keyboard 😭
Clarify that startTime could be the system or the client start time.
This is dependent on which device you're playing on.
The startTime variable is now set to the current time instead of a randomized past time.

This simplifies initialization and removes the dependency on the math/rand/v2 package.
Introduces systemStart and lastConnectedPong fields to Conn for tracking system/client uptime and the latest ConnectedPong message. Adds methods to retrieve uptime and last pong, updates handler logic to set systemStart and store ConnectedPong, and provides a SetUptime function for manual uptime adjustment.
Renamed the unexported effectiveMTU method to EffectiveMTU and updated all usages. Added a WaitForPacket method to Conn and connection handlers, allowing registration of handlers for specific packet IDs and waiting for their arrival. Updated handler implementations to support this mechanism.
Introduces Conn.RaknetLatency to measure round-trip time using ConnectedPing/Pong. Enhances listener blocking by allowing custom block durations and refines block expiration logic. Adds logging for connection request times.
Introduces BlockDuration allowing for varying block durations.
Renamed BlockDuration to BlockFor and refactored internal methods for clarity. Added BlockUntil and blockUntil methods to allow blocking until a specific time, improving flexibility in blocking logic.
Updated blockUntil to return early if the 'until' time is zero or already in the past, preventing unnecessary blocking logic for expired deadlines.
TrippleAWap and others added 3 commits January 19, 2026 15:23
Co-authored-by: هـ <didntpot@protonmail.com>
Updated the blockFor method to return early if the duration is less than or equal to zero, preventing unnecessary blocking for zero durations.
@TrippleAWap TrippleAWap requested a review from didntpot January 19, 2026 22:30
Eliminated the BlockUntil method from Listener and security, inlining the block duration logic directly into blockFor. This simplifies the code by reducing indirection and removing unused methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants