Skip to content

Commit

Permalink
Ignorerad command small optimization (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
d3m37r4 authored and s1lentq committed Dec 25, 2019
1 parent 1f615d3 commit 7b0dab9
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg
if (!pPlayer)
continue;

// ignorerad command
if (pPlayer->m_bIgnoreRadio)
continue;

// are we a regular player? (not spectator)
if (pPlayer->IsPlayer())
{
Expand Down Expand Up @@ -401,46 +405,43 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg

if (bSend)
{
// ignorerad command
if (!pPlayer->m_bIgnoreRadio)
{
MESSAGE_BEGIN(MSG_ONE, gmsgSendAudio, nullptr, pEntity->pev);
WRITE_BYTE(ENTINDEX(edict()));
WRITE_STRING(msg_id);
WRITE_SHORT(pitch);
MESSAGE_END();
MESSAGE_BEGIN(MSG_ONE, gmsgSendAudio, nullptr, pEntity->pev);
WRITE_BYTE(ENTINDEX(edict()));
WRITE_STRING(msg_id);
WRITE_SHORT(pitch);
MESSAGE_END();

// radio message icon
if (msg_verbose)
// radio message icon
if (msg_verbose)
{
// search the place name where is located the player
const char *placeName = nullptr;
if (AreRunningCZero() && TheBotPhrases)
{
// search the place name where is located the player
const char *placeName = nullptr;
if (AreRunningCZero() && TheBotPhrases)
Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin);
const BotPhraseList *placeList = TheBotPhrases->GetPlaceList();
for (auto phrase : *placeList)
{
Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin);
const BotPhraseList *placeList = TheBotPhrases->GetPlaceList();
for (auto phrase : *placeList)
if (phrase->GetID() == playerPlace)
{
if (phrase->GetID() == playerPlace)
{
placeName = phrase->GetName();
break;
}
placeName = phrase->GetName();
break;
}
}
if (placeName)
ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio_location", STRING(pev->netname), placeName, msg_verbose);
else
ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio", STRING(pev->netname), msg_verbose);
}
if (placeName)
ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio_location", STRING(pev->netname), placeName, msg_verbose);
else
ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio", STRING(pev->netname), msg_verbose);
}

// icon over the head for teammates
// icon over the head for teammates
#ifdef REGAMEDLL_ADD
if (showIcon && show_radioicon.value)
if (showIcon && show_radioicon.value)
#else
if (showIcon)
if (showIcon)
#endif
{
{
// put an icon over this guys head to show that he used the radio
MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, nullptr, pEntity->pev);
WRITE_BYTE(TE_PLAYERATTACHMENT);
Expand All @@ -449,7 +450,6 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg
WRITE_SHORT(g_sModelIndexRadio); // short (model index) of tempent
WRITE_SHORT(15); // short (life * 10 ) e.g. 40 = 4 seconds
MESSAGE_END();
}
}
}
}
Expand Down

0 comments on commit 7b0dab9

Please sign in to comment.