mas-bandwidth / yojimbo

A network library for client/server games written in C++
BSD 3-Clause "New" or "Revised" License
2.46k stars 239 forks source link

Proper fix for single message type issue when sending block messages #107

Closed FredGithub closed 5 years ago

FredGithub commented 5 years ago

As discussed on pull request #102, this is a proper fix for the bug when sending block messages when there is only one message type, as reported in issue #77. I put back the use of __builtin_clz.

I included basic tests. I wanted to go further and actually test that the message type is not serialized when there is only one message type (because redundant), but I didn't know how to do it. So instead I just tested basic message sending/receiving in all 3 cases:

FredGithub commented 5 years ago

Fixed bits_required when min == max and added a test for it. Let me know if the test was overkill...

gafferongames commented 5 years ago

Looks good! Thanks!