Fri, 12 Dec 2014 01:37:04 +0200
- now able to login
--- a/sources/format.h Fri Dec 12 00:55:51 2014 +0200 +++ b/sources/format.h Fri Dec 12 01:37:04 2014 +0200 @@ -33,8 +33,8 @@ #include "basics.h" #include "geometry.h" -#define FORMAT_OVERLOAD(T) \ - inline FUNCTION make_format_argument (T a) -> String +#define FORMAT_OVERLOAD(...) \ + inline FUNCTION make_format_argument (__VA_ARGS__ a) -> String // // ------------------------------------------------------------------------------------------------- @@ -57,8 +57,8 @@ return result; } -template<typename T> -FORMAT_OVERLOAD (const List<T>&) +template<typename T, typename C> +FORMAT_OVERLOAD (const Container<T, C>&) { String result;
--- a/sources/list.h Fri Dec 12 00:55:51 2014 +0200 +++ b/sources/list.h Fri Dec 12 01:37:04 2014 +0200 @@ -110,9 +110,11 @@ public: using Super = Container<T, std::vector<T>>; - template<typename... Args> - Vector (Args ...args) : - Super (args...) {} + Vector() {} + Vector (int numvalues) : Super (numvalues) {} + Vector (const Vector<T>& a) : Super (a) {} + Vector (std::initializer_list<T>&& a) : Super (a) {} + Vector (T* data, size_t length) : Super (std::vector<T> (data, data + length)) {} auto data() -> T* {
--- a/sources/md5.cpp Fri Dec 12 00:55:51 2014 +0200 +++ b/sources/md5.cpp Fri Dec 12 01:37:04 2014 +0200 @@ -301,7 +301,7 @@ for (i = 0; i < 16; i++) { - sprintf (checksum + i * 2, "%02X", signature[i]); + sprintf (checksum + i * 2, "%02x", signature[i]); } }
--- a/sources/network/bytestream.cpp Fri Dec 12 00:55:51 2014 +0200 +++ b/sources/network/bytestream.cpp Fri Dec 12 01:37:04 2014 +0200 @@ -47,7 +47,6 @@ Bytestream::Bytestream (const unsigned char* data, unsigned long length) : m_data (nullptr) { - m_data = nullptr; init (data, length); } @@ -61,6 +60,21 @@ // ------------------------------------------------------------------------------------------------- // +Bytestream::Bytestream (const Bytestream& other) : + m_data (nullptr) +{ + init (other.data(), other.written_length()); +} + +// ------------------------------------------------------------------------------------------------- +METHOD Bytestream::operator= (const Bytestream& other) -> Bytestream& +{ + init (other.data(), other.written_length()); + return *this; +} + +// ------------------------------------------------------------------------------------------------- +// Bytestream::~Bytestream() { delete m_data;
--- a/sources/network/bytestream.h Fri Dec 12 00:55:51 2014 +0200 +++ b/sources/network/bytestream.h Fri Dec 12 01:37:04 2014 +0200 @@ -44,6 +44,7 @@ Bytestream (unsigned long length = 0x800); Bytestream (const unsigned char* data, unsigned long length); Bytestream (const Vector<unsigned char>& bytes); + Bytestream (const Bytestream& other); ~Bytestream(); inline METHOD allocated_size() const -> unsigned long; @@ -62,6 +63,7 @@ METHOD resize (unsigned long length) -> void; inline METHOD rewind() -> void; inline METHOD seek (unsigned long pos) -> void; + inline METHOD to_vector() const -> Vector<unsigned char>; METHOD write (const unsigned char* val, unsigned int length) -> void; METHOD write_buffer (const Bytestream& other) -> void; METHOD write_buffer (const Vector<unsigned char>& other) -> void; @@ -75,6 +77,7 @@ inline METHOD operator[] (unsigned long idx) -> unsigned char&; inline METHOD operator[] (unsigned long idx) const -> unsigned char; + METHOD operator= (const Bytestream& other) -> Bytestream&; private: unsigned char* m_data; @@ -174,3 +177,11 @@ { return m_data; } + +// ------------------------------------------------------------------------------------------------- +// +inline METHOD +Bytestream::to_vector() const -> Vector<unsigned char> +{ + return Vector<unsigned char> (m_data, m_writtenLength); +}
--- a/sources/network/rconsession.cpp Fri Dec 12 00:55:51 2014 +0200 +++ b/sources/network/rconsession.cpp Fri Dec 12 01:37:04 2014 +0200 @@ -87,14 +87,12 @@ METHOD RCONSession::handle_packet (Bytestream& packet, const IPAddress& from) -> void { - print ("Handling packet of %1 bytes\n", packet.written_length()); + print ("Processing packet of %1 bytes\n", packet.written_length()); bool ok = true; while (packet.bytes_left() > 0) { - print ("%1/%2 bytes left\n", packet.bytes_left(), packet.written_length()); int header = packet.read_byte (&ok); - print ("recieved HEADER with %1\n", header); switch (ServerResponse (header)) { @@ -195,6 +193,7 @@ print ("sending password...\n"); Bytestream packet; packet.write_byte (CLRC_PASSWORD); + print ("password: %1\nsalt: %2\nhashed password: %3\n", m_password, m_salt, (m_salt + m_password).md5()); packet.write_string ((m_salt + m_password).md5()); send (packet); bump_last_ping();