I think its because the protocol is now using an unsigned char, whilst we're using a signed one, to represent the window ID.
Suggested to ➀ use an unsigned counter and ➁ avoid all the modulos?
Code:
m_WindowID = (++m_WindowIDCounter) % 127
(assume the counter has incremented to 127)
signed Counter = 127 (0111 1111)
signed ID = 0
protocol unsigned ID = 0
okay
Counter++
signed Counter = -128 (1000 0000)
signed ID = -1
protocol unsigned ID = 255
mismatch!
...
signed Counter = -125 (1000 0011)
signed ID = -125 (C modulo operation on a negative number is negative: -125 % 127 = -125)
protocol unsigned ID = 131
mismatch!
Suggested to ➀ use an unsigned counter and ➁ avoid all the modulos?