Network Time (#724)

* fix(NativeHooks): Fix softlock when loading Cayo Perico
* fear(netTime): Try to modify time remotely
* fix(timeSync): Make it work more consistently
* feat(netTime): net time sync for all!
This commit is contained in:
maybegreat48
2022-12-19 17:39:06 +00:00
committed by GitHub
parent 292a45f0a1
commit 1dda472562
14 changed files with 189 additions and 4 deletions
@@ -6,6 +6,7 @@
#include "util/spam.hpp"
#include "util/kick.hpp"
#include <network/Network.hpp>
#include <network/netTime.hpp>
namespace big
{
@@ -218,6 +219,26 @@ namespace big
break;
}
case rage::eNetMessage::MsgNetTimeSync:
{
if (player)
{
int action = buffer.Read<int>(2);
uint32_t counter = buffer.Read<uint32_t>(32);
uint32_t token = buffer.Read<uint32_t>(32);
uint32_t timestamp = buffer.Read<uint32_t>(32);
uint32_t time_diff = (*g_pointers->m_network_time)->m_time_offset + frame->m_timestamp;
if (action == 0)
{
player->player_time_value = timestamp;
player->player_time_value_received_time = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now());
if (!player->time_difference || time_diff > player->time_difference.value())
player->time_difference = time_diff;
}
}
break;
}
}
}
}