add m_ prefix to class members

Signed-off-by: iTrooz <hey@itrooz.fr>
This commit is contained in:
iTrooz
2024-11-29 14:14:24 +01:00
parent 4aaf7b9b09
commit 1477d64400
4 changed files with 20 additions and 20 deletions

View File

@ -13,19 +13,19 @@
// last bit // last bit
#define CONTINUE_BIT 0x80 #define CONTINUE_BIT 0x80
McClient::McClient(QObject *parent, QString domain, QString ip, short port): QObject(parent), domain(domain), ip(ip), port(port) {} McClient::McClient(QObject *parent, QString domain, QString ip, short port): QObject(parent), m_domain(domain), m_ip(ip), m_port(port) {}
QJsonObject McClient::getStatusDataBlocking() { QJsonObject McClient::getStatusDataBlocking() {
qDebug() << "Connecting to socket.."; qDebug() << "Connecting to socket..";
socket.connectToHost(ip, port); m_socket.connectToHost(m_ip, m_port);
if (!socket.waitForConnected()) { if (!m_socket.waitForConnected()) {
throw Exception("Failed to connect to socket"); throw Exception("Failed to connect to socket");
} }
qDebug() << "Connected to socket successfully"; qDebug() << "Connected to socket successfully";
sendRequest(); sendRequest();
if (!socket.waitForReadyRead()) { if (!m_socket.waitForReadyRead()) {
throw Exception("Socket didn't send anything to read"); throw Exception("Socket didn't send anything to read");
} }
return readResponse(); return readResponse();
@ -48,9 +48,9 @@ void McClient::sendRequest() {
QByteArray data; QByteArray data;
writeVarInt(data, 0x00); // packet ID writeVarInt(data, 0x00); // packet ID
writeVarInt(data, 0x760); // protocol version writeVarInt(data, 0x760); // protocol version
writeVarInt(data, domain.size()); // server address length writeVarInt(data, m_domain.size()); // server address length
writeString(data, domain.toStdString()); // server address writeString(data, m_domain.toStdString()); // server address
writeFixedInt(data, port, 2); // server port writeFixedInt(data, m_port, 2); // server port
writeVarInt(data, 0x01); // next state writeVarInt(data, 0x01); // next state
writePacketToSocket(data); // send handshake packet writePacketToSocket(data); // send handshake packet
@ -61,18 +61,18 @@ void McClient::sendRequest() {
void McClient::readBytesExactFromSocket(QByteArray &resp, int bytesToRead) { void McClient::readBytesExactFromSocket(QByteArray &resp, int bytesToRead) {
while (bytesToRead > 0) { while (bytesToRead > 0) {
qDebug() << bytesToRead << " bytes left to read"; qDebug() << bytesToRead << " bytes left to read";
if (!socket.waitForReadyRead()) { if (!m_socket.waitForReadyRead()) {
throw Exception("Read timeout or error"); throw Exception("Read timeout or error");
} }
QByteArray chunk = socket.read(bytesToRead); QByteArray chunk = m_socket.read(bytesToRead);
resp.append(chunk); resp.append(chunk);
bytesToRead -= chunk.size(); bytesToRead -= chunk.size();
} }
} }
QJsonObject McClient::readResponse() { QJsonObject McClient::readResponse() {
auto resp = socket.readAll(); auto resp = m_socket.readAll();
int length = readVarInt(resp); int length = readVarInt(resp);
// finish ready response // finish ready response
@ -159,8 +159,8 @@ void McClient::writePacketToSocket(QByteArray &data) {
dataWithSize.append(data); dataWithSize.append(data);
// write it to the socket // write it to the socket
socket.write(dataWithSize); m_socket.write(dataWithSize);
socket.flush(); m_socket.flush();
data.clear(); data.clear();
} }

View File

@ -13,10 +13,10 @@
class McClient : public QObject { class McClient : public QObject {
Q_OBJECT Q_OBJECT
QString domain; QString m_domain;
QString ip; QString m_ip;
short port; short m_port;
QTcpSocket socket; QTcpSocket m_socket;
public: public:
explicit McClient(QObject *parent, QString domain, QString ip, short port); explicit McClient(QObject *parent, QString domain, QString ip, short port);

View File

@ -5,10 +5,10 @@
#include "McResolver.h" #include "McResolver.h"
McResolver::McResolver(QObject *parent, QString domain, int port): QObject(parent), constrDomain(domain), constrPort(port) {} McResolver::McResolver(QObject *parent, QString domain, int port): QObject(parent), m_constrDomain(domain), m_constrPort(port) {}
void McResolver::ping() { void McResolver::ping() {
pingWithDomainSRV(constrDomain, constrPort); pingWithDomainSRV(m_constrDomain, m_constrPort);
} }
void McResolver::pingWithDomainSRV(QString domain, int port) { void McResolver::pingWithDomainSRV(QString domain, int port) {

View File

@ -8,8 +8,8 @@
class McResolver : public QObject { class McResolver : public QObject {
Q_OBJECT Q_OBJECT
QString constrDomain; QString m_constrDomain;
int constrPort; int m_constrPort;
public: public:
explicit McResolver(QObject *parent, QString domain, int port); explicit McResolver(QObject *parent, QString domain, int port);