# HG changeset patch # User Teemu Piippo # Date 1418341024 -7200 # Node ID cffa2777d917cc6e0844b13ff6cb91c7657309d1 # Parent 3874575d924dc0ac514b2d875ca9861470e34bb9 - now able to login diff -r 3874575d924d -r cffa2777d917 sources/format.h --- 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 -FORMAT_OVERLOAD (const List&) +template +FORMAT_OVERLOAD (const Container&) { String result; diff -r 3874575d924d -r cffa2777d917 sources/list.h --- 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>; - template - Vector (Args ...args) : - Super (args...) {} + Vector() {} + Vector (int numvalues) : Super (numvalues) {} + Vector (const Vector& a) : Super (a) {} + Vector (std::initializer_list&& a) : Super (a) {} + Vector (T* data, size_t length) : Super (std::vector (data, data + length)) {} auto data() -> T* { diff -r 3874575d924d -r cffa2777d917 sources/md5.cpp --- 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]); } } diff -r 3874575d924d -r cffa2777d917 sources/network/bytestream.cpp --- 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; diff -r 3874575d924d -r cffa2777d917 sources/network/bytestream.h --- 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& 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; METHOD write (const unsigned char* val, unsigned int length) -> void; METHOD write_buffer (const Bytestream& other) -> void; METHOD write_buffer (const Vector& 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 +{ + return Vector (m_data, m_writtenLength); +} diff -r 3874575d924d -r cffa2777d917 sources/network/rconsession.cpp --- 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();