Spielerando

After loading, new objects get the same number as saved ones and mix up

Every pet, arrow and cart in an online game needs a number that messages can point at. When a save is loaded, the counters that hand out those numbers can start in the wrong place, and two different things answer to the same name.

Why this works

A name must never point to two things, and a counter that forgets its past will repeat itself. Trusting the larger of what was written down and what is actually there survives a crash in either order. Giving each owner a counter avoids asking everyone.

When not to use it

Skip it in a single-player game or when nothing outside the game ever names an object: a plain running number or a random long id is simpler. Use random ids too when owners must not guess each other's numbers.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • A diagram of every state
  • 26 lines of example code with 5 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "After loading, new objects get the same number as saved ones and mix up" (read_entry object-numbers-after-loading) in my game. Build it step by step, and show me how you checked that it works.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP