Skip to content

Conversation

@AvarianKnight
Copy link
Contributor

@AvarianKnight AvarianKnight commented Nov 15, 2024

Since we would always check for the Nil value at the start of the if chain we would always send this to the server or client.

This changes the behavior to only erase if the key existed in the first place, and if it didn't then we will just do an early return so we don't replicate the data (and possibly hit the rate limiter).

Goal of this PR

Reduce the amount of packets sent to the server whenever the state bag doesn't already exist

How is this PR achieving the goal

Fix the checks to take into account that the key could not exist

This PR applies to the following area(s)

FiveM, RedM, Server

Successfully tested on

Game builds: ..

Platforms: Windows, Linux

Checklist

This hasn't been tested

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

Fixes an oversight in PR #2717

@github-actions github-actions bot added RedM Issues/PRs related to RedM triage Needs a preliminary assessment to determine the urgency and required action labels Nov 15, 2024
- since we would always check for the `Nil` packet at the start of the `if` chain we would *always* send this to the server or client. This changes the behavior to only erase if the key existed in the first place, and if it didn't then we will just do an eaerly return so we don't replicate the data.
- fixes an oversight in PR citizenfx#2717
@AvarianKnight AvarianKnight force-pushed the fix/state-bag-nil-check branch from e63f25d to 681387c Compare January 24, 2025 01:11
@github-actions github-actions bot added invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Jan 24, 2025
@prikolium-cfx prikolium-cfx added the ready-to-merge This PR is enqueued for merging label Jun 23, 2025
@prikolium-cfx prikolium-cfx merged commit 4458ea9 into citizenfx:master Jun 24, 2025
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged ready-to-merge This PR is enqueued for merging RedM Issues/PRs related to RedM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants