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) {
break;
}
case STOC_HS_PLAYER_ENTER: {
if (len < 1 + (int)sizeof(STOC_HS_PlayerEnter))
if (len < 1 + STOC_HS_PlayerEnter_size)
return;
soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER);
STOC_HS_PlayerEnter packet;
std::memcpy(&packet, pdata, sizeof packet);
std::memcpy(&packet, pdata, STOC_HS_PlayerEnter_size);
const auto* pkt = &packet;
if(pkt->pos > 3)
break;
......
......@@ -158,10 +158,11 @@ constexpr int SIZE_STOC_CHAT = (LEN_CHAT_PLAYER + LEN_CHAT_MSG) * sizeof(uint16_
struct STOC_HS_PlayerEnter {
uint16_t name[20];
unsigned char pos;
unsigned char padding; // only for padding
// byte padding[1]
};
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 {
//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