mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-10-23 00:27:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c39216c44 | ||
|
|
5efd264355 |
No files matched your search
+1
-1
@@ -129,7 +129,7 @@ private:
|
||||
static inline std::mutex mShutdownHandlersMutex {};
|
||||
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
||||
|
||||
static inline Version mVersion { 3, 9, 4 };
|
||||
static inline Version mVersion { 3, 9, 3 };
|
||||
};
|
||||
|
||||
/// Used to static_assert in std::visit
|
||||
|
||||
@@ -53,10 +53,7 @@ public:
|
||||
|
||||
io_context& IoCtx() { return mIoCtxPoller.IoCtx(); }
|
||||
|
||||
uint64_t GetServerTimeMS() const { return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - TimeSyncStart).count();}
|
||||
double GetServerTime() const { return std::chrono::duration<double>(std::chrono::steady_clock::now() - TimeSyncStart).count(); }
|
||||
private:
|
||||
std::chrono::time_point<std::chrono::steady_clock> TimeSyncStart;
|
||||
TIoPollThread mIoCtxPoller;
|
||||
TClientSet mClients;
|
||||
mutable RWMutex mClientsMutex;
|
||||
|
||||
@@ -1012,14 +1012,6 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, TLuaStateI
|
||||
}
|
||||
MPTable.set_function("Get", &LuaAPI::MP::Get);
|
||||
|
||||
MPTable.set_function("GetServerTimeMS", [this](const sol::this_state ts) {
|
||||
return make_object(sol::state_view(ts), this->mEngine->Server().GetServerTimeMS());
|
||||
});
|
||||
|
||||
MPTable.set_function("GetServerTime", [this](const sol::this_state ts) {
|
||||
return make_object(sol::state_view(ts), this->mEngine->Server().GetServerTime());
|
||||
});
|
||||
|
||||
auto UtilTable = StateView.create_named_table("Util");
|
||||
UtilTable.set_function("LogDebug", [this](sol::variadic_args args) {
|
||||
std::string ToPrint = "";
|
||||
|
||||
+7
-1
@@ -198,7 +198,13 @@ void TNetwork::UDPServerMain() {
|
||||
if (Client->GetID() == ID) {
|
||||
if (Client->GetUDPAddr() == boost::asio::ip::udp::endpoint { } && !Client->IsUDPConnected() && !Client->GetMagic().empty()) {
|
||||
if (Data.size() != 66) {
|
||||
beammp_debugf("Invalid size for UDP value. IP: {} ID: {}", remote_client_ep.address().to_string(), ID);
|
||||
beammp_debugf("Invalid size for UDP value. IP: {} ID: {}, Size: {}", remote_client_ep.address().to_string(), ID, Data.size());
|
||||
std::stringstream hexData;
|
||||
for (auto c : Data) {
|
||||
hexData << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(c);
|
||||
hexData << " ";
|
||||
}
|
||||
beammp_debug(hexData.str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,12 +123,6 @@ TEST_CASE("GetPidVid") {
|
||||
TServer::TServer(const std::vector<std::string_view>& Arguments) {
|
||||
beammp_info("BeamMP Server v" + Application::ServerVersionString());
|
||||
Application::SetSubsystemStatus("Server", Application::Status::Starting);
|
||||
std::mt19937_64 TimeSyncRandomDevice(std::random_device{}());
|
||||
|
||||
TimeSyncStart = std::chrono::steady_clock::now()
|
||||
- std::chrono::duration_cast<std::chrono::steady_clock::duration>(
|
||||
std::chrono::duration<double>(std::uniform_real_distribution<double>(0.0, 2592000.0)(TimeSyncRandomDevice))
|
||||
);
|
||||
Application::SetSubsystemStatus("Server", Application::Status::Good);
|
||||
}
|
||||
|
||||
@@ -216,24 +210,6 @@ void TServer::GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uin
|
||||
return;
|
||||
}
|
||||
switch (Code) {
|
||||
case 't':
|
||||
if (!udp && Packet.size() == 9) {
|
||||
auto Time = GetServerTimeMS();
|
||||
|
||||
std::vector<uint8_t> ServerTime(sizeof(uint64_t));
|
||||
std::memcpy(ServerTime.data(), &Time, sizeof(uint64_t));
|
||||
|
||||
auto Data = Packet;
|
||||
|
||||
beammp_debugf("Sending server time {} to client '{}' ({}), client time: {}", Time, LockedClient->GetName(), LockedClient->GetID(), reinterpret_cast<uint64_t>(Data.data()));
|
||||
|
||||
Data.insert(Data.end(), ServerTime.begin(), ServerTime.end());
|
||||
|
||||
if (!Network.Respond(*LockedClient, Data, true)) {
|
||||
Network.DisconnectClient(*LockedClient, "Failed to send time");
|
||||
}
|
||||
}
|
||||
return;
|
||||
case 'H': // initial connection
|
||||
if (udp) {
|
||||
beammp_debugf("Received 'H' packet over UDP from client '{}' ({}), ignoring it", LockedClient->GetName(), LockedClient->GetID());
|
||||
|
||||
Reference in new issue
Block a user