Optimize CBasePlayer::SendWeatherInfo (#159)

* Optimize CBasePlayer::SendWeatherInfo
This commit is contained in:
In-line 2017-07-06 21:41:20 +04:00 committed by Dmitry Novikov
parent 09e714e339
commit 419603ff52

View File

@ -6751,27 +6751,28 @@ void CBasePlayer::SendHostageIcons()
void CBasePlayer::SendWeatherInfo()
{
CBaseEntity *pPoint = UTIL_FindEntityByClassname(NULL, "env_rain");
CBaseEntity *pPoint2 = UTIL_FindEntityByClassname(NULL, "func_rain");
CBaseEntity *pEnt;
if (pPoint || pPoint2)
auto SendReceiveW = [&](BYTE byte)
{
MESSAGE_BEGIN(MSG_ONE, gmsgReceiveW, NULL, pev);
WRITE_BYTE(1); // rainy weather
WRITE_BYTE(byte);
MESSAGE_END();
}
else
{
pPoint = UTIL_FindEntityByClassname(NULL, "env_snow");
pPoint2 = UTIL_FindEntityByClassname(NULL, "func_snow");
};
if (pPoint || pPoint2)
{
MESSAGE_BEGIN(MSG_ONE, gmsgReceiveW, NULL, pev);
WRITE_BYTE(2); // snowy weather
MESSAGE_END();
}
}
/* Rain */
if ((pEnt = UTIL_FindEntityByClassname(NULL, "env_rain")))
return SendReceiveW(1);
if ((pEnt = UTIL_FindEntityByClassname(NULL, "func_rain")))
return SendReceiveW(1);
/* Snow */
if ((pEnt = UTIL_FindEntityByClassname(NULL, "env_snow")))
return SendReceiveW(2);
if ((pEnt = UTIL_FindEntityByClassname(NULL, "func_snow")))
return SendReceiveW(2);
}
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, UpdateClientData)