diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-01-05 15:21:27 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-01-05 15:21:27 +1100 |
commit | c47bceb3f3ea0d041f3a6cb053f932c00c39f396 (patch) | |
tree | c8ab3e3c8b3443f3bdcb3d5d2c77b9a7b2f7675d /source/server | |
parent | 9bc12f5f97f6774e6eeeb3ef577e026cc8d03357 (diff) |
add time played support to server query results
Diffstat (limited to 'source/server')
-rw-r--r-- | source/server/StarServerQueryThread.cpp | 10 | ||||
-rw-r--r-- | source/server/StarServerQueryThread.hpp | 11 |
2 files changed, 12 insertions, 9 deletions
diff --git a/source/server/StarServerQueryThread.cpp b/source/server/StarServerQueryThread.cpp index 2011f42..441fa63 100644 --- a/source/server/StarServerQueryThread.cpp +++ b/source/server/StarServerQueryThread.cpp @@ -107,6 +107,8 @@ bool ServerQueryThread::processPacket(HostAddressWithPort const& address, char c << A2S_TYPE_DEDICATED // dedicated #ifdef STAR_SYSTEM_FAMILY_WINDOWS << A2S_ENV_WINDOWS // os +#elif defined(STAR_SYSTEM_MACOS) + << A2S_ENV_MAC // os #else << A2S_ENV_LINUX // os #endif @@ -153,17 +155,17 @@ void ServerQueryThread::buildPlayerResponse() { return; } - auto clientIds = m_universe->clientIds(); + auto clientIds = m_universe->clientIdsAndCreationTime(); uint8_t cnt = (uint8_t)clientIds.count(); int32_t kills = 0; // Not currently supported - float timeConnected = 60; // Not supported defaults to 1min m_playersResponse.clear(); m_playersResponse << A2S_HEAD_INT << A2S_PLAYER_REPLY << cnt; uint8_t i = 0; - for (auto clientId : clientIds) { - m_playersResponse << i++ << m_universe->clientNick(clientId) << kills << timeConnected; + for (auto& pair : clientIds) { + auto timeConnected = float(now - pair.second) / 1000.f; + m_playersResponse << i++ << m_universe->clientNick(pair.first) << kills << timeConnected; } m_lastPlayersResponse = now; diff --git a/source/server/StarServerQueryThread.hpp b/source/server/StarServerQueryThread.hpp index 54ab93f..d45e1a9 100644 --- a/source/server/StarServerQueryThread.hpp +++ b/source/server/StarServerQueryThread.hpp @@ -42,11 +42,12 @@ private: static const uint8_t A2S_EDF_TAGS = 0x20; static const uint8_t A2S_EDF_STV = 0x40; static const uint8_t A2S_EDF_PORT = 0x80; - static const uint8_t A2S_ENV_WINDOWS = 'W'; - static const uint8_t A2S_ENV_LINUX = 'L'; - static const uint8_t A2S_TYPE_DEDICATED = 'D'; - static const uint8_t A2S_TYPE_LISTEN = 'L'; - static const uint8_t A2S_TYPE_TV = 'P'; + static const uint8_t A2S_ENV_WINDOWS = 'w'; + static const uint8_t A2S_ENV_LINUX = 'l'; + static const uint8_t A2S_ENV_MAC = 'm'; + static const uint8_t A2S_TYPE_DEDICATED = 'd'; + static const uint8_t A2S_TYPE_LISTEN = 'l'; + static const uint8_t A2S_TYPE_TV = 'p'; static const uint8_t A2S_VAC_OFF = 0x00; static const uint8_t A2S_VAC_ON = 0x01; static constexpr const char* A2S_INFO_REQUEST_STRING = "Source Engine Query"; |