Skip to content

Commit b85de9b

Browse files
committed
show reasons on the scoreboard
1 parent 5330789 commit b85de9b

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

tf2_bot_detector/ModeratorLogic.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ namespace
7676

7777
void ReloadConfigFiles() override;
7878

79+
PlayerListJSON* GetPlayerList() { return &m_PlayerList; }
80+
7981
private:
8082
IWorldState* m_World = nullptr;
8183
const Settings* m_Settings = nullptr;
@@ -171,6 +173,26 @@ namespace
171173
}
172174
}
173175

176+
// lazy and dumb function to make a string list of marked files
177+
std::string listMarkFiles(PlayerMarks& marks) {
178+
PlayerAttributesList attribute{ 0 };
179+
std::vector<std::string> files;
180+
181+
for (const auto& mark : marks.m_Marks)
182+
{
183+
// push file names into a nice vector so we can return
184+
if (std::find(files.begin(), files.end(), mark.m_FileName) != files.end()) {
185+
files.push_back(mark.m_FileName);
186+
}
187+
}
188+
189+
std::ostringstream oss;
190+
std::copy(files.begin(), files.end() - 1, std::ostream_iterator<std::string>(oss, ","));
191+
oss << files.back();
192+
193+
return oss.str();
194+
}
195+
174196
// lazy and dumb function to convert player marks to string
175197
std::string marksToString(PlayerMarks& marks) {
176198
PlayerAttributesList attribute{ 0 };
@@ -690,7 +712,7 @@ void ModeratorLogic::HandleConnectingMarkedPlayers(const std::vector<Cheater>& c
690712
username.replace(pos, 1, "");
691713
}
692714

693-
chatMsg.fmt("[tf2bd] WARN: Marked Player ({}) Joining ({} - {}).", username, marksToString(marks), marks.m_Marks.front().m_FileName);
715+
chatMsg.fmt("[tf2bd] WARN: Marked Player ({}) Joining {} ({} - {}).", username, marksToString(marks), marks.m_Marks.front().m_FileName);
694716
}
695717
else
696718
{
@@ -994,6 +1016,8 @@ bool ModeratorLogic::InitiateVotekick(const IPlayer& player, KickReason reason,
9941016
m_LastVoteCallTime = tfbd_clock_t::now();
9951017
}
9961018

1019+
//m_ActionManager->QueueAction<ChatMessageAction>("[tf2bd] votekicking ", ChatMessageType::PartyChat);
1020+
9971021
return true;
9981022
}
9991023

tf2_bot_detector/ModeratorLogic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace tf2_bot_detector
2020
class Settings;
2121
class SteamID;
2222
class IWorldState;
23+
class PlayerListJSON;
2324

2425
struct VoteCooldown
2526
{
@@ -65,6 +66,8 @@ namespace tf2_bot_detector
6566
virtual size_t GetRuleCount() const = 0;
6667

6768
virtual void ReloadConfigFiles() = 0;
69+
70+
virtual PlayerListJSON* GetPlayerList() = 0;
6871
};
6972
}
7073

tf2_bot_detector/UI/MainWindow.Scoreboard.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include <string_view>
1818

19+
#include "nlohmann/json.hpp"
20+
1921
using namespace std::chrono_literals;
2022
using namespace std::string_view_literals;
2123
using namespace tf2_bot_detector;
@@ -917,10 +919,20 @@ void MainWindow::DrawPlayerTooltipBody(IPlayer& player, TeamShareResult teamShar
917919
{
918920
ImGui::NewLine();
919921
ImGui::TextFmt("Player {} marked in playerlist(s):{}", player, playerAttribs);
920-
//ImGui::NewLine();
921-
//ImGui::Text("Reasons: ");
922-
//for (auto& [fileName, found] : m_PlayerList.FindPlayerData(steamid)) {
922+
ImGui::NewLine();
923+
ImGui::Text("Reasons: ");
924+
for (auto& [fileName, data] : GetModLogic().GetPlayerList()->FindPlayerData(player.GetSteamID())) {
925+
if (data.m_Proof.empty()) {
926+
continue;
927+
}
923928

929+
std::string proofs = "";
930+
for (auto p : data.m_Proof) {
931+
proofs += p.dump() + " ";
932+
}
933+
934+
ImGui::TextFmt(" {}: {}", fileName, proofs);
935+
}
924936
}
925937
}
926938

0 commit comments

Comments
 (0)