diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 8a9a928db..bbeb0562f 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1221,7 +1221,7 @@ void CCharacter::HandleBroadcast() char aBuftime[64]; int IntTime = (int)((float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed())); str_format(aBuftime, sizeof(aBuftime), "%s%d:%s%d", ((IntTime/60) > 9)?"":"0", IntTime/60, ((IntTime%60) > 9)?"":"0", IntTime%60); - GameServer()->SendBroadcast(aBuftime, m_pPlayer->GetCID()); + GameServer()->SendBroadcast(aBuftime, m_pPlayer->GetCID(), false); m_CpLastBroadcast = m_CpActive; m_LastBroadcast = Server()->Tick(); } diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 00069e4fb..4dbd882f4 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -398,11 +398,36 @@ void CGameContext::SendWeaponPickup(int ClientID, int Weapon) } -void CGameContext::SendBroadcast(const char *pText, int ClientID) +void CGameContext::SendBroadcast(const char *pText, int ClientID, bool IsImportant) { CNetMsg_Sv_Broadcast Msg; Msg.m_pMessage = pText; + + if(ClientID == -1) + { + dbg_assert(IsImportant, "broadcast messages to all players must be important"); + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); + + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(m_apPlayers[i]) + { + m_apPlayers[i]->m_LastBroadcastImportance = true; + m_apPlayers[i]->m_LastBroadcast = Server()->Tick(); + } + } + return; + } + + if(!m_apPlayers[ClientID]) + return; + + if(!IsImportant && m_apPlayers[ClientID]->m_LastBroadcastImportance && m_apPlayers[ClientID]->m_LastBroadcast > Server()->Tick() - Server()->TickSpeed() * 10) + return; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); + m_apPlayers[ClientID]->m_LastBroadcast = Server()->Tick(); + m_apPlayers[ClientID]->m_LastBroadcastImportance = IsImportant; } void CGameContext::StartVote(const char *pDesc, const char *pCommand, const char *pReason) diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index 724d94f98..54269fe1e 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -191,7 +191,7 @@ public: void SendChat(int ClientID, int Team, const char *pText, int SpamProtectionClientID = -1); void SendEmoticon(int ClientID, int Emoticon); void SendWeaponPickup(int ClientID, int Weapon); - void SendBroadcast(const char *pText, int ClientID); + void SendBroadcast(const char *pText, int ClientID, bool IsImportant = true); void List(int ClientID, const char* filter); diff --git a/src/game/server/player.h b/src/game/server/player.h index b36e91da4..e3b453370 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -181,6 +181,8 @@ public: void AfkVoteTimer(CNetObj_PlayerInput *NewTarget); int64 m_LastPlaytime; int64 m_LastEyeEmote; + int64 m_LastBroadcast; + bool m_LastBroadcastImportance; int m_LastTarget_x; int m_LastTarget_y; CNetObj_PlayerInput m_LastTarget;