actual time delta

This commit is contained in:
Green Sky 2023-01-18 18:31:00 +01:00
parent 365edc35e9
commit 9f8f681e18
No known key found for this signature in database
3 changed files with 8 additions and 4 deletions

View File

@ -110,7 +110,7 @@ bool SHA1::iterate(float delta) {
float& timer = std::get<float>(*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) {

View File

@ -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<float>(new_time - _last_time).count()};
_last_time = new_time;
tox_iterate(_tox, this);
NGC_FT1_iterate(_tox, _ft1_ctx, time_delta);

View File

@ -8,6 +8,7 @@
#include <ngc_ext.h>
#include <ngc_ft1.h>
#include <chrono>
#include <string>
#include <string_view>
#include <map>
@ -73,6 +74,8 @@ struct ToxClient {
NGC_EXT_CTX* _ext_ctx {nullptr};
NGC_FT1* _ft1_ctx {nullptr};
std::chrono::time_point<std::chrono::high_resolution_clock> _last_time {std::chrono::high_resolution_clock::now()};
std::string _self_name;
std::string _tox_profile_path;