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

feat: entity session id #582

Merged
merged 5 commits into from
Sep 26, 2024
Merged

feat: entity session id #582

merged 5 commits into from
Sep 26, 2024

Conversation

Manason
Copy link
Member

@Manason Manason commented Sep 25, 2024

We need a stable vehicle identifier that works for both NPC and player owned vehicles. vehicleid already represents player owned vehicles, so overloading it could cause issues with scripts relying on this behavior. netId would not be stable for persisted vehicles, which have their entities deleted and spawned.

Therefore this PR is introducing a sessionId, which will be incremented starting by 1 to guarantee uniqueness. This will be set via a new export CreateSessionId on the vehicle's state bag, which acquires a lock to guarantee that no two vehicles are assigned the same id. This will be persisted during vehicle persistence.

Also sneaking in a fix to persist vehicleid during vehicle persistence as I realize we never did that before.

While this is being introduced for vehicles, it is being introduced as a generic feature that could be used for any entity. This may prove useful for other applications which want a unique id to reference when those entities may be deleted and re-created.

@Manason Manason changed the title feat: vehicle session id feat: entity session id Sep 25, 2024
server/main.lua Outdated Show resolved Hide resolved
@Manason Manason merged commit 1fa9edf into main Sep 26, 2024
4 checks passed
@Manason Manason deleted the feat-vehicle-session-id branch September 26, 2024 15:29
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