Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(statebag): only try to erase if the key existed before #2937

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
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 RedM Issues/PRs related to RedM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant