equal
deleted
inserted
replaced
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 } |