From e0de78eecfbc8898b028f191326e87f647d6aa5b Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 9 Jun 2022 20:08:22 +0200 Subject: Added group icons to wreck labels --- Snapshot.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'Snapshot.cpp') diff --git a/Snapshot.cpp b/Snapshot.cpp index 99cf400..5d76e73 100644 --- a/Snapshot.cpp +++ b/Snapshot.cpp @@ -5,11 +5,13 @@ #include #include #include +#include #include #include #include "Killmail.h" +#include "Owner.h" using json = nlohmann::json; @@ -24,7 +26,8 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(LongVector3, x, y, z) Snapshot::Snapshot(const char* filename) : - m_killmails {} + m_killmails {}, + m_teams {} { if (!FileExists(filename)) throw "File does not exist"; @@ -38,6 +41,14 @@ Snapshot::Snapshot(const char* filename) : dump.at("killmails").get_to(m_killmails); for (auto& km : m_killmails) km.group = group_lookup[km.ship]; + int team = 0; + for (const auto& members : dump.at("teams")) { + for (const auto& entry : members) { + const auto id = entry.get(); + m_teams[id] = team; + } + ++team; + } UnloadFileText(text); } @@ -49,6 +60,25 @@ Snapshot::killmails() const } +int +Snapshot::team(const Owner& owner) const +{ + auto find = [this](long int id) -> int { + if (id < 0) + return -1; + const auto search = m_teams.find(id); + if (search == m_teams.end()) + return -1; + return search->second; + }; + int id; + if ((id = find(owner.faction)) != -1) return id; + if ((id = find(owner.alliance)) != -1) return id; + if ((id = find(owner.corporation)) != -1) return id; + return -1; +} + + void from_json(const json& j, tm& d) { -- cgit v1.1