Commit 94891313 by Anselme

the client now tries to reduce latency + bug fixes

parent 18104195
......@@ -13,6 +13,8 @@
#include "playerentity.h"
#include "menu.h"
#define MAX_ACCEPTED_PING_VARIANCE 0.05
Graphics::Graphics(int w, int h) :
m_main_player(nullptr),
m_zoomLevel(2)
......@@ -95,13 +97,6 @@ void Graphics::renderMap(sf::RenderWindow &window, MapKoban& map)
if(currentTick - m_current_turn_tick > REFRESH_TIME)
{
// if(m_main_player != nullptr) // temp debug code
// {
// std::stringstream ss;
// ss << "turn:" << m_current_turn;
// setMessage(ss.str());
// }
// increment turn
m_current_turn++;
m_current_turn_tick += REFRESH_TIME;
......@@ -202,6 +197,11 @@ void Graphics::renderMenu(sf::RenderWindow &window, Menu* menu)
void Graphics::addTurn(const MapDiff& diff)
{
float now = m_clock->getElapsedTime().asSeconds();
float delta = std::min(abs(now - m_current_turn_tick), abs(now - m_current_turn_tick + REFRESH_TIME));
if(delta > MAX_ACCEPTED_PING_VARIANCE)
m_current_turn_tick = now + MAX_ACCEPTED_PING_VARIANCE/4;
m_current_turn = diff.turn_id;
m_diffs.push_back(diff);
}
......
......@@ -273,6 +273,7 @@ void Menu::textInsert(sf::Uint32 character)
case '\n':
case '\r':
case '\t':
case '\e':
return;
}
m_textStr.insert(m_textCursor, character);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment