AccessData(steam_id) refactor
Assign result to a variable in places, where it is used more than once
This commit is contained in:
parent
c4a122e52e
commit
c03943c1a7
@ -191,8 +191,6 @@ void reportall()
|
||||
patch.Patch();
|
||||
patched_report = true;
|
||||
}
|
||||
player_info_s local;
|
||||
g_IEngine->GetPlayerInfo(g_pLocalPlayer->entity_idx, &local);
|
||||
for (int i = 1; i < g_IEngine->GetMaxClients(); i++)
|
||||
{
|
||||
CachedEntity *ent = ENTITY(i);
|
||||
|
@ -113,18 +113,19 @@ void Load()
|
||||
#if ENABLE_VISUALS
|
||||
rgba_t Color(unsigned steamid)
|
||||
{
|
||||
if (AccessData(steamid).state == k_EState::DEVELOPER)
|
||||
const auto &pl = AccessData(steamid);
|
||||
if (pl.state == k_EState::DEVELOPER)
|
||||
return colors::RainbowCurrent();
|
||||
if (AccessData(steamid).state == k_EState::CAT)
|
||||
else if (pl.state == k_EState::CAT)
|
||||
return colors::RainbowCurrent();
|
||||
if (AccessData(steamid).color.a)
|
||||
{
|
||||
return AccessData(steamid).color;
|
||||
}
|
||||
else
|
||||
{
|
||||
return k_Colors[static_cast<int>(AccessData(steamid).state)];
|
||||
}
|
||||
else if (pl.color.a)
|
||||
return pl.color;
|
||||
|
||||
int state = static_cast<int>(pl.state);
|
||||
if (state < sizeof(k_Colors) / sizeof(*k_Colors))
|
||||
return k_Colors[state];
|
||||
|
||||
return colors::empty;
|
||||
}
|
||||
|
||||
rgba_t Color(CachedEntity *player)
|
||||
|
@ -48,21 +48,20 @@ void dispatchUserMessage(bf_read &buffer, int type)
|
||||
steamID = info.friendsID;
|
||||
if (eid == LOCAL_E->m_IDX)
|
||||
was_local_player = true;
|
||||
if (*vote_kickn)
|
||||
if (playerlist::AccessData(info.friendsID).state != playerlist::k_EState::RAGE && playerlist::AccessData(info.friendsID).state != playerlist::k_EState::DEFAULT)
|
||||
g_IEngine->ClientCmd_Unrestricted("vote option2");
|
||||
if (*vote_kicky)
|
||||
if (playerlist::AccessData(info.friendsID).state == playerlist::k_EState::RAGE || playerlist::AccessData(info.friendsID).state == playerlist::k_EState::DEFAULT)
|
||||
g_IEngine->ClientCmd_Unrestricted("vote option1");
|
||||
if (*party_say)
|
||||
if (*vote_kickn || *vote_kicky)
|
||||
{
|
||||
if (g_IEngine->GetPlayerInfo(caller, &info2))
|
||||
{
|
||||
// because tf2 is stupid and doesn't have escape characters,
|
||||
// use the greek question marks instead. big brain.
|
||||
// Clang-format why, TODO: Don't use format func
|
||||
g_IEngine->ExecuteClientCmd(format("say_party [CAT] votekick called: ", boost::replace_all_copy((std::string) info2.name, ";", ";"), " => ", boost::replace_all_copy((std::string) info.name, ";", ";"), " (", reason, ")").c_str());
|
||||
}
|
||||
auto &pl = playerlist::AccessData(info.friendsID);
|
||||
if (*vote_kickn && pl.state != playerlist::k_EState::RAGE && pl.state != playerlist::k_EState::DEFAULT)
|
||||
g_IEngine->ClientCmd_Unrestricted("vote option2");
|
||||
else if (*vote_kicky && pl.state == playerlist::k_EState::RAGE || pl.state == playerlist::k_EState::DEFAULT)
|
||||
g_IEngine->ClientCmd_Unrestricted("vote option1");
|
||||
}
|
||||
if (*party_say && g_IEngine->GetPlayerInfo(caller, &info2))
|
||||
{
|
||||
// because tf2 is stupid and doesn't have escape characters,
|
||||
// use the greek question marks instead. big brain.
|
||||
// Clang-format why, TODO: Don't use format func
|
||||
g_IEngine->ExecuteClientCmd(format("say_party [CAT] votekick called: ", boost::replace_all_copy((std::string) info2.name, ";", ";"), " => ", boost::replace_all_copy((std::string) info.name, ";", ";"), " (", reason, ")").c_str());
|
||||
}
|
||||
logging::Info("Vote called to kick %s [U:1:%u] for %s", name, steamID, reason);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user