ctm / mb2-doc

Mb2, poker software
https://devctm.com
7 stars 2 forks source link

Never blindly assume a nick is known #1446

Closed ctm closed 1 week ago

ctm commented 1 week ago

Make it so that the code that accesses ShareablePlayers returns something like "UNKNOWN" rather than doing anything that could panic.

Although it hasn't ever bitten us (as far as I remember), it is unacceptable to panic if there's not an entry in players. While looking for the "pop-in chat bug" (#1443), I noticed that LogLine::chat_or_action contains let nick = players.get(&player_id).unwrap().as_ref();, which is super embarrassing.

ctm commented 1 week ago

I'm moving ShareablePlayers from mb2_text to mb2_commands and making inner private. Then I'm passing &ShareablePlayers around instead of Ref<HashMap<PlayerId, Nick>>. ShareablePlayers already had a player_name method that returns "UNKNOWN" instead of panicking. The esoteric uses of inner will be moved into ShareablePlayers itself.

This is tedious.

ctm commented 1 week ago

Done. Deploying now.