fix(ViewPlayer): Make "never wanted" feature independent for each player (#316)
Co-authored-by: Yimura <andreas.maerten@scarlet.be>
This commit is contained in:
parent
a286d84e1b
commit
6a4ee2b282
@ -134,7 +134,11 @@ namespace big
|
|||||||
|
|
||||||
while (g_running)
|
while (g_running)
|
||||||
{
|
{
|
||||||
looped::player_never_wanted();
|
g_player_service->iterate([](const player_entry &entry)
|
||||||
|
{
|
||||||
|
looped::player_never_wanted(entry.second);
|
||||||
|
});
|
||||||
|
|
||||||
looped::player_spectate();
|
looped::player_spectate();
|
||||||
|
|
||||||
script::get_current()->yield();
|
script::get_current()->yield();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
|
#include "services/players/player_service.hpp"
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
class looped {
|
class looped {
|
||||||
@ -16,7 +19,7 @@ namespace big
|
|||||||
static void tunables_disable_phone();
|
static void tunables_disable_phone();
|
||||||
static void tunables_no_idle_kick();
|
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 player_spectate();
|
||||||
|
|
||||||
static void protections_replay_interface();
|
static void protections_replay_interface();
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
namespace big
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,6 @@ namespace big
|
|||||||
|
|
||||||
struct player {
|
struct player {
|
||||||
int character_slot = 1;
|
int character_slot = 1;
|
||||||
bool player_never_wanted = false;
|
|
||||||
int set_level = 130;
|
int set_level = 130;
|
||||||
bool spectating = false;
|
bool spectating = false;
|
||||||
};
|
};
|
||||||
|
@ -36,6 +36,8 @@ namespace big
|
|||||||
[[nodiscard]] bool is_host() const;
|
[[nodiscard]] bool is_host() const;
|
||||||
[[nodiscard]] bool is_valid() const;
|
[[nodiscard]] bool is_valid() const;
|
||||||
|
|
||||||
|
bool never_wanted = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool equals(const CNetGamePlayer* net_game_player) const;
|
bool equals(const CNetGamePlayer* net_game_player) const;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ namespace big
|
|||||||
class player;
|
class player;
|
||||||
|
|
||||||
using player_ptr = std::shared_ptr<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>;
|
using players = std::map<std::string, player_ptr>;
|
||||||
|
|
||||||
class player_service final
|
class player_service final
|
||||||
@ -43,6 +44,9 @@ namespace big
|
|||||||
players& players()
|
players& players()
|
||||||
{ return m_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);
|
void set_selected(player_ptr plyr);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@ namespace big
|
|||||||
|
|
||||||
ImGui::SameLine();
|
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", [] {
|
components::button("Give Health", [] {
|
||||||
g_pickup_service->give_player_health(g_player_service->get_selected()->id());
|
g_pickup_service->give_player_health(g_player_service->get_selected()->id());
|
||||||
|
Reference in New Issue
Block a user