File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,8 +55,7 @@ class DuelClient {
5555 template <typename ST >
5656 static void SendPacketToServer (unsigned char proto, const ST & st) {
5757 auto p = duel_client_write;
58- if (sizeof (ST ) > MAX_DATA_SIZE )
59- return ;
58+ static_assert (sizeof (ST ) <= MAX_DATA_SIZE , " Packet size is too large." );
6059 buffer_write<uint16_t >(p, (uint16_t )(1 + sizeof (ST )));
6160 buffer_write<uint8_t >(p, proto);
6261 std::memcpy (p, &st, sizeof (ST ));
Original file line number Diff line number Diff line change @@ -43,8 +43,7 @@ class NetServer {
4343 template <typename ST >
4444 static void SendPacketToPlayer (DuelPlayer* dp, unsigned char proto, const ST & st) {
4545 auto p = net_server_write;
46- if (sizeof (ST ) > MAX_DATA_SIZE )
47- return ;
46+ static_assert (sizeof (ST ) <= MAX_DATA_SIZE , " Packet size is too large." );
4847 buffer_write<uint16_t >(p, (uint16_t )(1 + sizeof (ST )));
4948 buffer_write<uint8_t >(p, proto);
5049 std::memcpy (p, &st, sizeof (ST ));
You can’t perform that action at this time.
0 commit comments