HOMEBLOGDEVLOG

Move to company id instead of company index

Adam C. Clifton
10 Mar 2026

It's a bit weird that we can create and remove companies, but companies are also referenced by their index. So in theory we could try to action a company, but in the mean time an earlier company was deleted, and suddenly our index is wrong.

The straightforward fix for this is to give each company a unique id, then we can always safely reference them by it.

It's a little wacky with our as everything needs to be defined as the action is created, which for creating CPU opponents, means the player needs to generate that id and not the server. If it was just the server it would be easy and we could just have a variable we increment by 1 every time. Since it's just for CPU opponents in a game, and there's only going to be like 4, I think it's fine to let the player pick a random number as the id.

There's definitely more controlled things we could do, but its just not worth the effort currently.

Previous: Fixup operator handling
Next: Setup auto post to mastodon
© Numbat Logic Pty Ltd 2014 - 2026