Wondering in general how IDs are stored in a large massively multiplayer online game.
From what I can imagine, it seems that each "game entity" would have a globally unique ID (GUID). Say there are 10 people connected to the game. The game server then spawns any new game entity, and sends the GUID (along with the entity data) to the clients. The clients never create entities directly. Actually no, the client maybe can also create game entities that are unique to the view of that specific client. So if player 1 is viewing a screen, then they might see game entity x, in addition to game entities a, b, c, etc. Then player 2 sees game entities a, b, c, and y, but not x. Not sure if these "dynamic" game entities are created on the client or server, so that is the first part of the question.
Then given these GUIDs, say there is tracking (analytics) that goes on. Say the game company wants to track when a player defeats a game entity. So it saves to the backend/server database "player 1 defeats game entity 123asdf....GUID". But if game entities are constantly spawned and then destroyed/cleared (by hiding or maybe they have a temporary/ephemeral existence), then the database would have GUIDs for a lot of non-existent game entities. So I'm wondering if this is how it's done, or if these ephemeral game entities have metadata permanently stored to the database beyond their GUID, or if they are never saved to the DB, etc.
Then there is the problem of having lots of game entities (particles) on the screen. If each particle of say 1 million particles has a GUID, and you shoot (if it's like asteroids game) one of them, then the DB saves "player 1 destroyed GUID x at timestamp y". But the GUIDs have to be unique across the game server. So if 10,000 people are playing asteroids, and each asteroid has a GUID, the problem is how to guarantee the GUID is unique, and also secure (if that's a concern).
Then there is the issue of offline playing. Say you play offline, but then sync your data occasionally. Then GUIDs need to be generated on the client, and could be tampered with (and be insecure). Ideally the GUIDs would be generated on the server so we know how they are constructed and that they are secure.
Basically, I am wondering how GUIDs work in a MMO.
- If all game entities have a unique GUID.
- If ephemeral game entities have unique GUIDs.
- If there are non-ephemeral (persistent) game entities that have GUIDs.
- If tracking/analytics tracks both ephemeral and persistent game entities.
- How GUIDs are guaranteed to be unique.
- How GUIDs work if the player is playing offline.