For my multiplayer RTS game, I need to send over the ID's of a player's units selected in a single integer.
For every player, there are 16 units, each with an integer ID between 1-16 (inclusive), and all units of a player have a unique ID.
If anywhere from 1 to 16 units can be selected, what's an efficient way of compressing the units' IDs into 1 integer to send over the network? Then, when this integer reaches another client, how can it be translated back to a list of unit ID's?