diff --git a/src/states/sha1.cpp b/src/states/sha1.cpp index 5d9fe7d..874a962 100644 --- a/src/states/sha1.cpp +++ b/src/states/sha1.cpp @@ -110,7 +110,7 @@ bool SHA1::iterate(float delta) { float& timer = std::get(*it); timer += delta; - if (timer >= 15.f) { + if (timer >= 10.f) { it = _queue_requested_chunk.erase(it); } else { it++; @@ -257,7 +257,7 @@ bool SHA1::onFT1ReceiveInitSHA1Info(uint32_t, uint32_t, const uint8_t*, size_t, void SHA1::onFT1ReceiveDataSHA1Info(uint32_t, uint32_t, uint8_t, size_t, const uint8_t*, size_t) { // no, in this state we have init - assert(false && "ft should have said dropped this for us!"); + assert(false && "ft should have dropped this for us!"); } void SHA1::onFT1SendDataSHA1Info(uint32_t group_number, uint32_t peer_number, uint8_t transfer_id, size_t data_offset, uint8_t* data, size_t data_size) { diff --git a/src/tox_client.cpp b/src/tox_client.cpp index 75d97f6..d85e024 100644 --- a/src/tox_client.cpp +++ b/src/tox_client.cpp @@ -197,8 +197,9 @@ ToxClient::~ToxClient(void) { } bool ToxClient::iterate(void) { - // HACK: hardcoded 5ms sleep in main - float time_delta {0.005f}; + auto new_time = std::chrono::high_resolution_clock::now(); + const float time_delta {std::chrono::duration(new_time - _last_time).count()}; + _last_time = new_time; tox_iterate(_tox, this); NGC_FT1_iterate(_tox, _ft1_ctx, time_delta); diff --git a/src/tox_client.hpp b/src/tox_client.hpp index 9ffd20d..fa7a9a6 100644 --- a/src/tox_client.hpp +++ b/src/tox_client.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -73,6 +74,8 @@ struct ToxClient { NGC_EXT_CTX* _ext_ctx {nullptr}; NGC_FT1* _ft1_ctx {nullptr}; + std::chrono::time_point _last_time {std::chrono::high_resolution_clock::now()}; + std::string _self_name; std::string _tox_profile_path;