mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 19:49:19 +02:00
more deltatime hacking
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user