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

Implement strongly typed IDs to differentiate between database ID and instance ID #173

Open
MeikelLP opened this issue Oct 4, 2024 · 0 comments
Assignees
Labels
area/game The game app is affected type/enhancement Improve an existing feature

Comments

@MeikelLP
Copy link
Owner

MeikelLP commented Oct 4, 2024

see https://andrewlock.net/using-strongly-typed-entity-ids-to-avoid-primitive-obsession-part-1/

Most of the IDs of any sort are uints in QCX. Sadly this type does cover multiple use cases:

  • Instance IDs: Entities on the server (mobs, players, npcs) all have their unique ID which identifies them on the server (this ID does not persist)
  • Database IDs: Some entities are tracked in the database (i.e. players). They obviously have a unique key (primary key)

It's not clear which use case the type uint represents in each case. Mistakes can be made easily. To prevent this we can implement custom ID types which are still uints but you have to explicitly cast them to change one to another - making transitions very clear - if ever needed.

@MeikelLP MeikelLP added type/enhancement Improve an existing feature area/game The game app is affected labels Oct 4, 2024
@WoozChucky WoozChucky self-assigned this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/game The game app is affected type/enhancement Improve an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants