Commit 9e8dbeeb authored by Chen Bill's avatar Chen Bill

workaround: use STOC_HS_PlayerEnter_size

parent 6faa54a3
...@@ -818,11 +818,11 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) { ...@@ -818,11 +818,11 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break; break;
} }
case STOC_HS_PLAYER_ENTER: { case STOC_HS_PLAYER_ENTER: {
if (len < 1 + (int)sizeof(STOC_HS_PlayerEnter)) if (len < 1 + STOC_HS_PlayerEnter_size)
return; return;
soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER); soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER);
STOC_HS_PlayerEnter packet; STOC_HS_PlayerEnter packet;
std::memcpy(&packet, pdata, sizeof packet); std::memcpy(&packet, pdata, STOC_HS_PlayerEnter_size);
const auto* pkt = &packet; const auto* pkt = &packet;
if(pkt->pos > 3) if(pkt->pos > 3)
break; break;
......
...@@ -158,10 +158,11 @@ constexpr int SIZE_STOC_CHAT = (LEN_CHAT_PLAYER + LEN_CHAT_MSG) * sizeof(uint16_ ...@@ -158,10 +158,11 @@ constexpr int SIZE_STOC_CHAT = (LEN_CHAT_PLAYER + LEN_CHAT_MSG) * sizeof(uint16_
struct STOC_HS_PlayerEnter { struct STOC_HS_PlayerEnter {
uint16_t name[20]; uint16_t name[20];
unsigned char pos; unsigned char pos;
unsigned char padding; // only for padding // byte padding[1]
}; };
check_trivially_copyable(STOC_HS_PlayerEnter); check_trivially_copyable(STOC_HS_PlayerEnter);
static_assert(sizeof(STOC_HS_PlayerEnter) == 42, "size mismatch: STOC_HS_PlayerEnter"); //static_assert(sizeof(STOC_HS_PlayerEnter) == 42, "size mismatch: STOC_HS_PlayerEnter");
constexpr int STOC_HS_PlayerEnter_size = 41; //workwround
struct STOC_HS_PlayerChange { struct STOC_HS_PlayerChange {
//pos<<4 | state //pos<<4 | state
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment