Skip to content

Prevent using get_me with input#22

Merged
orsinium merged 4 commits intomainfrom
me-type
Feb 28, 2026
Merged

Prevent using get_me with input#22
orsinium merged 4 commits intomainfrom
me-type

Conversation

@orsinium
Copy link
Member

@orsinium orsinium commented Feb 23, 2026

  1. Make get_me return a new Me type instead of Peer.
  2. This type can be used only with get_settings or for equality comparison with Peer.

While you can, if you really want, convert Me to Peer by iterating over Peers and picking the one that equals to Me (or going through into_u8 -> from_u8), it would require deliberately going out of your way to shoot yourself in the foot. So, the change should prevent the most common pitfalls, like read_pad(get_me()).

See firefly-zero/firefly-runtime#9.

Copy link

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea this'll prevent most issues. I'm still curious where one would need comparisons between Peer and Me outside of render, but that likely just means checking the catalog games' sources and chatting with the authors

@orsinium
Copy link
Member Author

I'm still curious where one would need comparisons between Peer and Me outside of render

Probably nowhere. I just don't see an easy way to enforce "you can compare these two types but only when called from render". I could use a marker passed from render for it (or just pass Me into render, as you suggested initially) but that's too messy.

@oli-obk
Copy link

oli-obk commented Feb 23, 2026

Yea considering this is usually a trivially noticeable bug in multiplayer and has lots of docs pointing ppl away from making such bugs, I don't think any "security" level kinds of protection are necessary

@orsinium orsinium merged commit b96a076 into main Feb 28, 2026
@orsinium orsinium deleted the me-type branch February 28, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants