[Download]: Add field to JSON endpoint (#846)
This commit is contained in:
parent
b550438cd8
commit
237959e442
@ -432,23 +432,27 @@ namespace Components
|
|||||||
for (auto i = 0; i < Game::MAX_CLIENTS; ++i)
|
for (auto i = 0; i < Game::MAX_CLIENTS; ++i)
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, nlohmann::json> playerInfo;
|
std::unordered_map<std::string, nlohmann::json> playerInfo;
|
||||||
|
// Insert default values
|
||||||
playerInfo["score"] = 0;
|
playerInfo["score"] = 0;
|
||||||
playerInfo["ping"] = 0;
|
playerInfo["ping"] = 0;
|
||||||
playerInfo["name"] = "";
|
playerInfo["name"] = "";
|
||||||
|
playerInfo["test_client"] = 0;
|
||||||
|
|
||||||
if (Dedicated::IsRunning())
|
if (Dedicated::IsRunning())
|
||||||
{
|
{
|
||||||
if (Game::svs_clients[i].header.state < Game::CS_CONNECTED) continue;
|
if (Game::svs_clients[i].header.state < Game::CS_ACTIVE) continue;
|
||||||
|
if (!Game::svs_clients[i].gentity || !Game::svs_clients[i].gentity->client) continue;
|
||||||
|
|
||||||
playerInfo["score"] = Game::SV_GameClientNum_Score(i);
|
playerInfo["score"] = Game::SV_GameClientNum_Score(i);
|
||||||
playerInfo["ping"] = Game::svs_clients[i].ping;
|
playerInfo["ping"] = Game::svs_clients[i].ping;
|
||||||
playerInfo["name"] = Game::svs_clients[i].name;
|
playerInfo["name"] = Game::svs_clients[i].name;
|
||||||
|
playerInfo["test_client"] = Game::svs_clients[i].bIsTestClient;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Score and ping are irrelevant
|
// Score and ping are irrelevant
|
||||||
const auto* name = Game::PartyHost_GetMemberName(Game::g_lobbyData, i);
|
const auto* name = Game::PartyHost_GetMemberName(Game::g_lobbyData, i);
|
||||||
if (name == nullptr || *name == '\0') continue;
|
if (!name || !*name) continue;
|
||||||
|
|
||||||
playerInfo["name"] = name;
|
playerInfo["name"] = name;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ namespace Components
|
|||||||
|
|
||||||
const auto* client = Game::svs_clients[i].gentity->client;
|
const auto* client = Game::svs_clients[i].gentity->client;
|
||||||
const auto team = client->sess.cs.team;
|
const auto team = client->sess.cs.team;
|
||||||
if (team == Game::TEAM_SPECTATOR)
|
if (Game::svs_clients[i].bIsTestClient || team == Game::TEAM_SPECTATOR)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
// Score and ping are irrelevant
|
// Score and ping are irrelevant
|
||||||
const auto* namePtr = Game::PartyHost_GetMemberName(reinterpret_cast<Game::PartyData*>(0x1081C00), i);
|
const auto* namePtr = Game::PartyHost_GetMemberName(reinterpret_cast<Game::PartyData*>(0x1081C00), i);
|
||||||
if (!namePtr || !namePtr[0]) continue;
|
if (!namePtr || !*namePtr) continue;
|
||||||
|
|
||||||
name = namePtr;
|
name = namePtr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user