feat(PlayerDB): notify when player is online (#1386)
This commit is contained in:
parent
70efa40afe
commit
1b389d44a7
@ -51,11 +51,12 @@ namespace big
|
|||||||
bool block_join = false;
|
bool block_join = false;
|
||||||
int block_join_reason = 1;
|
int block_join_reason = 1;
|
||||||
bool is_modder = false;
|
bool is_modder = false;
|
||||||
|
bool notify_online = false;
|
||||||
std::unordered_set<int> infractions;
|
std::unordered_set<int> infractions;
|
||||||
std::optional<CommandAccessLevel> command_access_level = std::nullopt;
|
std::optional<CommandAccessLevel> command_access_level = std::nullopt;
|
||||||
PlayerOnlineStatus online_state = PlayerOnlineStatus::UNKNOWN;
|
PlayerOnlineStatus online_state = PlayerOnlineStatus::UNKNOWN;
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(persistent_player, name, rockstar_id, block_join, block_join_reason, is_modder, infractions, command_access_level)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(persistent_player, name, rockstar_id, block_join, block_join_reason, is_modder, notify_online, infractions, command_access_level)
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -137,12 +137,6 @@ namespace big
|
|||||||
return m_selected;
|
return m_selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void player_database_service::invalidate_player_states()
|
|
||||||
{
|
|
||||||
for (auto& item : m_players)
|
|
||||||
item.second->online_state = PlayerOnlineStatus::UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
void player_database_service::start_update_loop()
|
void player_database_service::start_update_loop()
|
||||||
{
|
{
|
||||||
if (!g.player_db.update_player_online_states)
|
if (!g.player_db.update_player_online_states)
|
||||||
@ -168,7 +162,6 @@ namespace big
|
|||||||
|
|
||||||
void player_database_service::update_player_states()
|
void player_database_service::update_player_states()
|
||||||
{
|
{
|
||||||
invalidate_player_states();
|
|
||||||
const auto player_count = m_players.size();
|
const auto player_count = m_players.size();
|
||||||
|
|
||||||
std::vector<std::vector<rage::rlGamerHandle>> gamer_handle_buckets;
|
std::vector<std::vector<rage::rlGamerHandle>> gamer_handle_buckets;
|
||||||
@ -198,9 +191,17 @@ namespace big
|
|||||||
{
|
{
|
||||||
if (const auto& it = m_players.find(bucket[i].m_rockstar_id); it != m_players.end())
|
if (const auto& it = m_players.find(bucket[i].m_rockstar_id); it != m_players.end())
|
||||||
{
|
{
|
||||||
it->second->online_state = PlayerOnlineStatus::OFFLINE;
|
|
||||||
if (online[i] == 1)
|
if (online[i] == 1)
|
||||||
|
{
|
||||||
|
if (it->second->online_state == PlayerOnlineStatus::OFFLINE && it->second->notify_online)
|
||||||
|
{
|
||||||
|
g_notification_service->push_success("Player DB", std::format("{} is now online!", it->second->name));
|
||||||
|
}
|
||||||
it->second->online_state = PlayerOnlineStatus::ONLINE;
|
it->second->online_state = PlayerOnlineStatus::ONLINE;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it->second->online_state = PlayerOnlineStatus::OFFLINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ namespace big
|
|||||||
|
|
||||||
void start_update_loop();
|
void start_update_loop();
|
||||||
void update_player_states();
|
void update_player_states();
|
||||||
void invalidate_player_states();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline player_database_service* g_player_database_service;
|
inline player_database_service* g_player_database_service;
|
||||||
|
@ -96,7 +96,8 @@ namespace big
|
|||||||
|
|
||||||
if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, ¤t_player->rockstar_id)
|
if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, ¤t_player->rockstar_id)
|
||||||
|| ImGui::Checkbox("IS_MODDER"_T.data(), ¤t_player->is_modder)
|
|| ImGui::Checkbox("IS_MODDER"_T.data(), ¤t_player->is_modder)
|
||||||
|| ImGui::Checkbox("BLOCK_JOIN"_T.data(), ¤t_player->block_join))
|
|| ImGui::Checkbox("BLOCK_JOIN"_T.data(), ¤t_player->block_join)
|
||||||
|
|| ImGui::Checkbox("Notify When Online", ¤t_player->notify_online))
|
||||||
{
|
{
|
||||||
if (current_player->rockstar_id != selected->rockstar_id)
|
if (current_player->rockstar_id != selected->rockstar_id)
|
||||||
g_player_database_service->update_rockstar_id(selected->rockstar_id, current_player->rockstar_id);
|
g_player_database_service->update_rockstar_id(selected->rockstar_id, current_player->rockstar_id);
|
||||||
|
Reference in New Issue
Block a user