Change clock to system clock, fix bugs
This commit is contained in:
1 parent
f967807296
commit
e0a60dcd6f
4 files changed
+28
-27
No files matched your search
+8
-6
@@ -242,7 +242,7 @@ namespace ZL
|
||||
if (newVel != Environment::shipSelectedVelocity) {
|
||||
Environment::shipSelectedVelocity = newVel;
|
||||
auto now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()
|
||||
std::chrono::system_clock::now().time_since_epoch()
|
||||
).count();
|
||||
std::string msg = "VEL:" + std::to_string(now_ms) + ":" + std::to_string(Environment::shipSelectedVelocity);
|
||||
networkClient->Send(msg);
|
||||
@@ -634,7 +634,7 @@ namespace ZL
|
||||
if (pingTimer >= 1000.0f) {
|
||||
|
||||
auto now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()
|
||||
std::chrono::system_clock::now().time_since_epoch()
|
||||
).count();
|
||||
|
||||
// 1. Извлекаем кватернион из матрицы поворота
|
||||
@@ -707,12 +707,14 @@ namespace ZL
|
||||
int discreteAngle = static_cast<int>(radians * 180.0f / M_PI);
|
||||
if (discreteAngle < 0) discreteAngle += 360;
|
||||
|
||||
std::cout << "OUTPUT discreteAngle=" << discreteAngle << std::endl;
|
||||
|
||||
// 3. Проверяем, изменились ли параметры значимо для отправки на сервер
|
||||
if (discreteAngle != Environment::lastSentAngle || discreteMag != Environment::lastSentMagnitude) {
|
||||
Environment::lastSentAngle = discreteAngle;
|
||||
Environment::lastSentMagnitude = discreteMag;
|
||||
auto now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()
|
||||
std::chrono::system_clock::now().time_since_epoch()
|
||||
).count();
|
||||
|
||||
// Формируем сетевой пакет
|
||||
@@ -776,7 +778,7 @@ namespace ZL
|
||||
Environment::lastSentAngle = discreteAngle;
|
||||
Environment::lastSentMagnitude = discreteMag;
|
||||
auto now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()
|
||||
std::chrono::system_clock::now().time_since_epoch()
|
||||
).count();
|
||||
|
||||
// Формируем сетевой пакет
|
||||
@@ -809,7 +811,7 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "shipVelocity=" << Environment::shipVelocity << " delta=" << delta << std::endl;
|
||||
//std::cout << "shipVelocity=" << Environment::shipVelocity << " delta=" << delta << std::endl;
|
||||
// Движение вперед (существующая логика)
|
||||
if (fabs(Environment::shipVelocity) > 0.01f)
|
||||
{
|
||||
@@ -1102,7 +1104,7 @@ namespace ZL
|
||||
|
||||
void Game::extrapolateRemotePlayers() {
|
||||
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
auto now = std::chrono::system_clock::now();
|
||||
|
||||
latestRemotePlayers = networkClient->getRemotePlayers();
|
||||
|
||||
|
||||
Reference in new issue
Block a user