Fix comment and reduce branching in TF2_IsPlayerInCondition.
This commit is contained in:
parent
e127a55b0a
commit
9b3b2eb23e
@ -529,43 +529,49 @@ stock int TF2_GetPlayerConditionFlags(int client)
|
|||||||
*/
|
*/
|
||||||
stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
|
stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
|
||||||
{
|
{
|
||||||
// Conditions are stored across two netprops now, one for each 32-bit segment.
|
// Conditions are stored across multiple netprops now, one for each 32-bit segment.
|
||||||
if (view_as<int>(cond) < 32)
|
int iCond = view_as<int>(cond);
|
||||||
|
switch (iCond / 32)
|
||||||
{
|
{
|
||||||
int bit = 1 << view_as<int>(cond);
|
case 0:
|
||||||
if ((GetEntProp(client, Prop_Send, "m_nPlayerCond") & bit) == bit)
|
|
||||||
{
|
{
|
||||||
return true;
|
int bit = 1 << iCond;
|
||||||
}
|
if ((GetEntProp(client, Prop_Send, "m_nPlayerCond") & bit) == bit)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ((GetEntProp(client, Prop_Send, "_condition_bits") & bit) == bit)
|
if ((GetEntProp(client, Prop_Send, "_condition_bits") & bit) == bit)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
case 1:
|
||||||
else if (view_as<int>(cond) < 64)
|
|
||||||
{
|
|
||||||
int bit = (1 << (view_as<int>(cond) - 32));
|
|
||||||
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx") & bit) == bit)
|
|
||||||
{
|
{
|
||||||
return true;
|
int bit = (1 << (iCond - 32));
|
||||||
|
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx") & bit) == bit)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
case 2:
|
||||||
else if (view_as<int>(cond) < 96)
|
|
||||||
{
|
|
||||||
int bit = (1 << (view_as<int>(cond) - 64));
|
|
||||||
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit)
|
|
||||||
{
|
{
|
||||||
return true;
|
int bit = (1 << (iCond - 64));
|
||||||
|
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
case 3:
|
||||||
else
|
|
||||||
{
|
|
||||||
int bit = (1 << (view_as<int>(cond) - 96));
|
|
||||||
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx3") & bit) == bit)
|
|
||||||
{
|
{
|
||||||
return true;
|
int bit = (1 << (iCond - 96));
|
||||||
|
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx3") & bit) == bit)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
ThrowError("Invalid TFCond value %d", iCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user