equal
deleted
inserted
replaced
1 #include "game_config.h" |
1 #include "game_config.h" |
|
2 |
|
3 #include <QtEndian> |
2 |
4 |
3 GameConfig::GameConfig() {} |
5 GameConfig::GameConfig() {} |
4 |
6 |
5 const char** GameConfig::argv() const { |
7 const char** GameConfig::argv() const { |
6 m_argv.resize(m_arguments.size()); |
8 m_argv.resize(m_arguments.size()); |
52 "eammreinf 1311110312111111123114111111111111111211111111111111111111"); |
54 "eammreinf 1311110312111111123114111111111111111211111111111111111111"); |
53 cfgAppend("eammstore"); |
55 cfgAppend("eammstore"); |
54 } |
56 } |
55 |
57 |
56 void GameConfig::cfgAppend(const QByteArray& cmd) { |
58 void GameConfig::cfgAppend(const QByteArray& cmd) { |
57 Q_ASSERT(cmd.size() < 256); |
59 Q_ASSERT(cmd.size() <= 49215); |
58 |
60 |
59 quint8 len = cmd.size(); |
61 if (cmd.size() < 64) { |
60 m_cfg.append(QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1) + |
62 quint8 len = static_cast<quint8>(cmd.size()); |
61 cmd); |
63 m_cfg.append( |
|
64 QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1)); |
|
65 } else { |
|
66 quint16 size = static_cast<quint16>(cmd.size()) - 64; |
|
67 size = (size / 256 + 64) * 256 + size & 0xff; |
|
68 quint16 size_be = qToBigEndian(size); |
|
69 |
|
70 m_cfg.append( |
|
71 QByteArray::fromRawData(reinterpret_cast<const char*>(&size_be), 2)); |
|
72 } |
|
73 |
|
74 m_cfg.append(cmd); |
62 } |
75 } |