# HG changeset patch # User unC0Rr # Date 1542891120 -3600 # Node ID 0ae9885e153558669794efe48937efc3f32d94bb # Parent 645e4591361f789e678e8a8d90dac1145b70504a Support new message format in frontend diff -r 645e4591361f -r 0ae9885e1535 qmlfrontend/game_config.cpp --- a/qmlfrontend/game_config.cpp Thu Nov 22 13:40:58 2018 +0100 +++ b/qmlfrontend/game_config.cpp Thu Nov 22 13:52:00 2018 +0100 @@ -1,5 +1,7 @@ #include "game_config.h" +#include + GameConfig::GameConfig() {} const char** GameConfig::argv() const { @@ -54,9 +56,20 @@ } void GameConfig::cfgAppend(const QByteArray& cmd) { - Q_ASSERT(cmd.size() < 256); + Q_ASSERT(cmd.size() <= 49215); - quint8 len = cmd.size(); - m_cfg.append(QByteArray::fromRawData(reinterpret_cast(&len), 1) + - cmd); + if (cmd.size() < 64) { + quint8 len = static_cast(cmd.size()); + m_cfg.append( + QByteArray::fromRawData(reinterpret_cast(&len), 1)); + } else { + quint16 size = static_cast(cmd.size()) - 64; + size = (size / 256 + 64) * 256 + size & 0xff; + quint16 size_be = qToBigEndian(size); + + m_cfg.append( + QByteArray::fromRawData(reinterpret_cast(&size_be), 2)); + } + + m_cfg.append(cmd); }