# HG changeset patch # User Teemu Piippo # Date 1469199143 -10800 # Node ID de7574d292ad616ccb013e70819cb1fec3387d55 # Parent 42bb299242184f06b07ff0c7fdf5f53f46f862f4 Added the ByteArray typedef for Vector diff -r 42bb29924218 -r de7574d292ad sources/list.h --- a/sources/list.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/list.h Fri Jul 22 17:52:23 2016 +0300 @@ -399,4 +399,6 @@ } }; +typedef Vector ByteArray; + END_ZFC_NAMESPACE diff -r 42bb29924218 -r de7574d292ad sources/mystring.cpp --- a/sources/mystring.cpp Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/mystring.cpp Fri Jul 22 17:52:23 2016 +0300 @@ -565,7 +565,7 @@ * \param bytes Bytes to use for construction * \returns the resulting string. */ -String String::fromBytes(const Vector& bytes) +String String::fromBytes(const ByteArray& bytes) { return String(reinterpret_cast&>(bytes)); } diff -r 42bb29924218 -r de7574d292ad sources/mystring.h --- a/sources/mystring.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/mystring.h Fri Jul 22 17:52:23 2016 +0300 @@ -108,7 +108,7 @@ static String fromNumber(unsigned int a); static String fromNumber(unsigned long int a); static String fromNumber(double a); - static String fromBytes(const Vector& bytes); + static String fromBytes(const ByteArray& bytes); String operator+(const String& data) const; String operator+(const char* data) const; diff -r 42bb29924218 -r de7574d292ad sources/network/bytestream.cpp --- a/sources/network/bytestream.cpp Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/bytestream.cpp Fri Jul 22 17:52:23 2016 +0300 @@ -36,7 +36,7 @@ * \brief Constructs a byte cursor. The cursor is placed to the beginning of the stream. * \param data */ -Bytestream::Bytestream(Vector& data) : +Bytestream::Bytestream(ByteArray& data) : m_data(data), m_position(0) {} @@ -66,7 +66,7 @@ /*! * \returns an iterator to the current data position. */ -Vector::Iterator Bytestream::getCurrentIterator() +ByteArray::Iterator Bytestream::getCurrentIterator() { return m_data.begin() + m_position; } @@ -129,7 +129,7 @@ */ String Bytestream::readString() { - Vector::Iterator stringEndIterator; + ByteArray::Iterator stringEndIterator; // Where's the end of the string? for (stringEndIterator = getCurrentIterator(); *stringEndIterator != '\0'; ++stringEndIterator) @@ -158,10 +158,10 @@ * \param length Amount of bytes to read. * \returns the read buffer. */ -Vector Bytestream::readBuffer(int length) +ByteArray Bytestream::readBuffer(int length) { ensureReadSpace(length); - Vector result(length); + ByteArray result(length); memcpy(result.data(), m_data.data() + m_position, length); m_position += length; return result; diff -r 42bb29924218 -r de7574d292ad sources/network/bytestream.h --- a/sources/network/bytestream.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/bytestream.h Fri Jul 22 17:52:23 2016 +0300 @@ -57,12 +57,12 @@ class Bytestream { public: - Bytestream(Vector& data); + Bytestream(ByteArray& data); int bytesLeft() const; - Vector::Iterator getCurrentIterator(); + ByteArray::Iterator getCurrentIterator(); int position() const; - Vector readBuffer(int length); + ByteArray readBuffer(int length); int8_t readByte(); int32_t readLong(); int16_t readShort(); @@ -71,7 +71,7 @@ void rewind(); void seek(int position); void write(const unsigned char* val, unsigned int length); - void writeBuffer(const Vector& other); + void writeBuffer(const ByteArray& other); void writeByte(int8_t value); void writeDouble(double val); void writeFloat(float value); @@ -80,7 +80,7 @@ void writeString(const String& string); private: - Vector& m_data; + ByteArray& m_data; int m_position; int8_t read(); diff -r 42bb29924218 -r de7574d292ad sources/network/rconsession.cpp --- a/sources/network/rconsession.cpp Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/rconsession.cpp Fri Jul 22 17:52:23 2016 +0300 @@ -79,7 +79,7 @@ // ------------------------------------------------------------------------------------------------- // -void RCONSession::send(const Vector& packet) +void RCONSession::send(const ByteArray& packet) { m_socket.send(m_address, packet); } @@ -283,7 +283,7 @@ void RCONSession::sendPassword() { m_interface->print("Authenticating...\n"); - Vector message; + ByteArray message; Bytestream stream(message); stream.writeByte(CLRC_PASSWORD); stream.writeString((m_salt + m_password).md5()); @@ -322,7 +322,7 @@ if (m_state != RCON_CONNECTED or commandString.isEmpty()) return false; - Vector message; + ByteArray message; Bytestream stream(message); stream.writeByte(CLRC_COMMAND); stream.writeString(commandString); @@ -365,7 +365,7 @@ { if (m_serverProtocol >= 4) { - Vector message; + ByteArray message; Bytestream stream(message); stream.writeByte(CLRC_TABCOMPLETE); stream.writeString(part); diff -r 42bb29924218 -r de7574d292ad sources/network/rconsession.h --- a/sources/network/rconsession.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/rconsession.h Fri Jul 22 17:52:23 2016 +0300 @@ -107,7 +107,7 @@ bool isActive() const; void processServerUpdates(Bytestream& packet); void requestTabCompletion(const String& part); - void send(const Vector& packet); + void send(const ByteArray& packet); bool sendCommand(const String& commandString); void sendHello(); void sendPassword(); diff -r 42bb29924218 -r de7574d292ad sources/network/udpsocket.cpp --- a/sources/network/udpsocket.cpp Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/udpsocket.cpp Fri Jul 22 17:52:23 2016 +0300 @@ -135,13 +135,13 @@ decodedPacket, length, &decodedLength); datagram.address.host = ntohl (claddr.sin_addr.s_addr); datagram.address.port = ntohs (claddr.sin_port); - datagram.message = Vector(decodedPacket, decodedLength); + datagram.message = ByteArray(decodedPacket, decodedLength); return true; } // ------------------------------------------------------------------------------------------------- // -bool UDPSocket::send (const IPAddress& address, const Vector& data) +bool UDPSocket::send (const IPAddress& address, const ByteArray& data) { int encodedlength = sizeof HuffmanBuffer; HUFFMAN_Encode (data.data(), reinterpret_cast (HuffmanBuffer), data.size(), &encodedlength); diff -r 42bb29924218 -r de7574d292ad sources/network/udpsocket.h --- a/sources/network/udpsocket.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/udpsocket.h Fri Jul 22 17:52:23 2016 +0300 @@ -38,7 +38,7 @@ struct Datagram { - Vector message; + ByteArray message; IPAddress address; }; @@ -52,7 +52,7 @@ bool bind (unsigned short port); bool read (Datagram& datagram); - bool send (const IPAddress& address, const Vector& data); + bool send (const IPAddress& address, const ByteArray& data); bool set_blocking (bool a); const String& error_string() const { return m_error; } int file_descriptor() const { return m_socket; }