I had a very weird problem today
It's hard to figure out the communication between the server and the client and then send the data to the client
Debugging and follow-up found that the data is OK and then the display pit came. The displayed data is completely wrong
Continue to F12, the problem is here
BYTE res = *(BYTE *)protocol->data;
result->kill = res;
What's the problem? The value of res is 4 and copied to result->m_kill, and then the value of kill also becomes 4
But when I used this variable, I found that it would automatically become 512, my God, did this Nima hit a ghost?
Then I use a global variable to get the value of res and find that it will not change
So it is determined that it is the result object, but this object is a custom data class with only assignment operations in it. And the variable kill is also an integer
That's weird, what's the problem?
Finally, I asked the master, and the master told me that he forgot to restore when he was doing byte alignment. . . That is, #pragma pack(1) is not followed by #pragma pack()
Omg. . . . The specific byte alignment will cause this situation. You can go to Baidu to continue the code.