Skip to content

Commit

Permalink
implement wzcmd status message
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsupermanhd committed Sep 27, 2024
1 parent 9045591 commit 0e34eb1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/stdinreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,39 @@ int cmdInputThreadFunc(void *)
}
});
}
else if(!strncmpl(line, "status"))
{
wzAsyncExecOnMainThread([] {
std::string statusString = "WZSTATUS: 0 ";
statusString += time(NULL);
for (uint32_t i = 0; i < MAX_CONNECTED_PLAYERS; i++)
{
auto player = NetPlay.players[i];
if (!isHumanPlayer(i))
{
continue;
}
std::string playerName = NetPlay.players[i].name;

statusString += " ";
if (player.isSpectator)
{
statusString += "spec";
}
else
{
statusString += player.position;
}
statusString += " ";
statusString += base64Encode(std::vector<unsigned char>(playerName.begin(), playerName.end()));
statusString += " ";
statusString += player.IPtextAddress;
statusString += " ";
statusString += base64Encode(getMultiStats(i).identity.toBytes(EcKey::Public));
}
wz_command_interface_output((statusString + "\n").c_str());

Check failure on line 1094 in src/stdinreader.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [Clang]

format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]

Check failure on line 1094 in src/stdinreader.cpp

View workflow job for this annotation

GitHub Actions / Alpine :LATEST [GCC]

format not a string literal and no format arguments [-Werror=format-security]

Check failure on line 1094 in src/stdinreader.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 [Clang]

format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]

Check failure on line 1094 in src/stdinreader.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 20.04 [GCC]

format not a string literal and no format arguments [-Werror=format-security]

Check failure on line 1094 in src/stdinreader.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 [GCC]

format not a string literal and no format arguments [-Werror=format-security]

Check failure on line 1094 in src/stdinreader.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 24.04 [Clang]

format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
});
}
else if(!strncmpl(line, "shutdown now"))
{
inexit = true;
Expand Down

0 comments on commit 0e34eb1

Please sign in to comment.