mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
The produced QByteArray was missing the null terminating character, since QByteArray::append() only added up to and not including '\0'. This was also the reason why sometimes planes did not change their aircraft models properly.
39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
/* Copyright (C) 2014
|
|
* swift project community / contributors
|
|
*
|
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
* contained in the LICENSE file.
|
|
*/
|
|
#include "multiplayerpacketparser.h"
|
|
|
|
namespace BlackSimPlugin
|
|
{
|
|
namespace Fs9
|
|
{
|
|
namespace Private
|
|
{
|
|
QByteArray readValue(const QByteArray &data, QString &val)
|
|
{
|
|
val = QString(data);
|
|
|
|
// Up to know all packets with string data, had the string payload at the end
|
|
// of the packet. Therefore there should not be any data after the string.
|
|
// Remove the assert, if this will change in the future.
|
|
QByteArray leftOver = data.mid(val.size() + 1);
|
|
Q_ASSERT(leftOver.isEmpty());
|
|
|
|
return leftOver;
|
|
}
|
|
|
|
QByteArray writeValue(QByteArray data, const QString &value)
|
|
{
|
|
data.append(qPrintable(value), value.size() + 1);
|
|
return data;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|