qmlfrontend/game_config.cpp
changeset 14280 61bc44de2b4c
parent 14279 0ae9885e1535
equal deleted inserted replaced
14279:0ae9885e1535 14280:61bc44de2b4c
    56 }
    56 }
    57 
    57 
    58 void GameConfig::cfgAppend(const QByteArray& cmd) {
    58 void GameConfig::cfgAppend(const QByteArray& cmd) {
    59   Q_ASSERT(cmd.size() <= 49215);
    59   Q_ASSERT(cmd.size() <= 49215);
    60 
    60 
       
    61   QByteArray sizeBytes;
    61   if (cmd.size() < 64) {
    62   if (cmd.size() < 64) {
    62     quint8 len = static_cast<quint8>(cmd.size());
    63     quint8 len = static_cast<quint8>(cmd.size());
    63     m_cfg.append(
    64     sizeBytes = QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1);
    64         QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1));
       
    65   } else {
    65   } else {
    66     quint16 size = static_cast<quint16>(cmd.size()) - 64;
    66     quint16 size = static_cast<quint16>(cmd.size()) - 64;
    67     size = (size / 256 + 64) * 256 + size & 0xff;
    67     size = (size / 256 + 64) * 256 + size & 0xff;
    68     quint16 size_be = qToBigEndian(size);
    68     quint16 size_be = qToBigEndian(size);
    69 
    69 
    70     m_cfg.append(
    70     sizeBytes =
    71         QByteArray::fromRawData(reinterpret_cast<const char*>(&size_be), 2));
    71         QByteArray::fromRawData(reinterpret_cast<const char*>(&size_be), 2);
    72   }
    72   }
    73 
    73 
    74   m_cfg.append(cmd);
    74   m_cfg.append(sizeBytes + cmd);
    75 }
    75 }