MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / buildPlayerResponse

Method buildPlayerResponse

source/server/StarServerQueryThread.cpp:152–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void ServerQueryThread::buildPlayerResponse() {
153 int64_t now = Time::monotonicMilliseconds();
154 if (now < m_lastPlayersResponse + responseCacheTime) {
155 return;
156 }
157
158 auto clientIds = m_universe->clientIdsAndCreationTime();
159 uint8_t cnt = (uint8_t)clientIds.count();
160 int32_t kills = 0; // Not currently supported
161
162 m_playersResponse.clear();
163 m_playersResponse << A2S_HEAD_INT << A2S_PLAYER_REPLY << cnt;
164
165 uint8_t i = 0;
166 for (auto& pair : clientIds) {
167 auto timeConnected = float(now - pair.second) / 1000.f;
168 m_playersResponse << i++ << m_universe->clientNick(pair.first) << kills << timeConnected;
169 }
170
171 m_lastPlayersResponse = now;
172}
173
174void ServerQueryThread::buildRuleResponse() {
175 int64_t now = Time::monotonicMilliseconds();

Callers

nothing calls this directly

Calls 4

countMethod · 0.45
clearMethod · 0.45
clientNickMethod · 0.45

Tested by

no test coverage detected