fix(ViewPlayer): Make "never wanted" feature independent for each player (#316)

Co-authored-by: Yimura <andreas.maerten@scarlet.be>
This commit is contained in:
mentolixite 2022-07-05 22:35:32 +02:00 committed by GitHub
parent a286d84e1b
commit 6a4ee2b282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 7 deletions

View File

@ -134,7 +134,11 @@ namespace big
while (g_running)
{
looped::player_never_wanted();
g_player_service->iterate([](const player_entry &entry)
{
looped::player_never_wanted(entry.second);
});
looped::player_spectate();
script::get_current()->yield();

View File

@ -1,6 +1,9 @@
#pragma once
#include "common.hpp"
#include "services/players/player_service.hpp"
namespace big
{
class looped {
@ -16,7 +19,7 @@ namespace big
static void tunables_disable_phone();
static void tunables_no_idle_kick();
static void player_never_wanted();
static void player_never_wanted(const player_ptr &player);
static void player_spectate();
static void protections_replay_interface();

View File

@ -4,11 +4,11 @@
namespace big
{
void looped::player_never_wanted()
void looped::player_never_wanted(const player_ptr &player)
{
if (g->player.player_never_wanted && g_player_service->get_selected()->is_valid())
if (player->never_wanted)
{
globals::clear_wanted_player(g_player_service->get_selected()->id());
globals::clear_wanted_player(player->id());
}
}
}

View File

@ -87,7 +87,6 @@ namespace big
struct player {
int character_slot = 1;
bool player_never_wanted = false;
int set_level = 130;
bool spectating = false;
};

View File

@ -36,6 +36,8 @@ namespace big
[[nodiscard]] bool is_host() const;
[[nodiscard]] bool is_valid() const;
bool never_wanted = false;
protected:
bool equals(const CNetGamePlayer* net_game_player) const;

View File

@ -6,6 +6,7 @@ namespace big
class player;
using player_ptr = std::shared_ptr<player>;
using player_entry = std::pair<std::string, player_ptr>;
using players = std::map<std::string, player_ptr>;
class player_service final
@ -43,6 +44,9 @@ namespace big
players& players()
{ return m_players; }
void iterate(const std::function< void(const player_entry &entry) > func)
{ for (const auto &iter : m_players) func(iter); }
void set_selected(player_ptr plyr);
};

View File

@ -41,7 +41,7 @@ namespace big
ImGui::SameLine();
ImGui::Checkbox("Never Wanted", &g->player.player_never_wanted);
ImGui::Checkbox("Never Wanted", &g_player_service->get_selected()->never_wanted);
components::button("Give Health", [] {
g_pickup_service->give_player_health(g_player_service->get_selected()->id());