16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 11:39:19 +02:00

more deltatime hacking

This commit is contained in:
milek7
2019-01-19 14:05:51 +01:00
parent 1314f09c4d
commit 4f4f7e6afc
2 changed files with 16 additions and 11 deletions

View File

@@ -32,6 +32,8 @@ double GetTime()
double GetDeltaTime() double GetDeltaTime()
{ // czas symulacji (stoi gdy pauza) { // czas symulacji (stoi gdy pauza)
if (override_delta != -1.0f)
return override_delta;
return DeltaTime; return DeltaTime;
} }
@@ -79,10 +81,7 @@ void UpdateTimers(bool pause)
else else
DeltaTime = 0.0; // wszystko stoi, bo czas nie płynie DeltaTime = 0.0; // wszystko stoi, bo czas nie płynie
if (override_delta != -1.0f) fSimulationTime += GetDeltaTime();
DeltaTime = override_delta;
fSimulationTime += DeltaTime;
oldCount = count; oldCount = count;
// Keep track of the time lapse and frame count // Keep track of the time lapse and frame count

View File

@@ -174,6 +174,8 @@ eu07_application::run() {
// //
// trivia: being client and server is possible // trivia: being client and server is possible
double frameStartTime = Timer::GetTime();
bool nextloop = true; bool nextloop = true;
while (nextloop) while (nextloop)
{ {
@@ -229,6 +231,14 @@ eu07_application::run() {
double sync = generate_sync(); double sync = generate_sync();
// if we're the server
if (m_network && m_network->servers)
{
// send delta, sync, and commands we just executed to clients
double delta = Timer::GetDeltaTime();
m_network->servers->push_delta(delta, sync, commands_to_exec);
}
// if we're slave // if we're slave
if (m_network && m_network->client) if (m_network && m_network->client)
{ {
@@ -236,14 +246,10 @@ eu07_application::run() {
if (sync != slave_sync) { if (sync != slave_sync) {
WriteLog("net: DESYNC!", logtype::net); WriteLog("net: DESYNC!", logtype::net);
} }
}
// if we're the server // set total delta for rendering code
if (m_network && m_network->servers) double totalDelta = Timer::GetTime() - frameStartTime;
{ Timer::set_delta_override(totalDelta);
// send delta, sync, and commands we just executed to clients
double delta = Timer::GetDeltaTime();
m_network->servers->push_delta(delta, sync, commands_to_exec);
} }
} }