diff --git a/r5dev/common/netmessages.cpp b/r5dev/common/netmessages.cpp index 80082de8..d977429b 100644 --- a/r5dev/common/netmessages.cpp +++ b/r5dev/common/netmessages.cpp @@ -12,6 +12,7 @@ #include "tier1/cvar.h" #include "engine/net.h" #include "common/netmessages.h" +#include "game/shared/usermessages.h" /////////////////////////////////////////////////////////////////////////////////// // re-implementation of 'SVC_Print::Process' @@ -39,21 +40,24 @@ bool SVC_Print::ProcessImpl() /////////////////////////////////////////////////////////////////////////////////// bool SVC_UserMessage::ProcessImpl() { - bf_read buf = m_DataIn; - int type = buf.ReadByte(); - - if (type == HUD_PRINTCONSOLE || - type == HUD_PRINTCENTER) + if (m_nMsgType == UserMessages_t::TextMsg) { - char text[MAX_USER_MSG_DATA]; - int len; + bf_read buf = m_DataIn; + byte type = byte(buf.ReadByte()); - buf.ReadString(text, sizeof(text), false, &len); - Assert(len < sizeof(text)); - - if (len >= NET_MIN_MESSAGE && len < sizeof(text)) + if (type == HUD_PRINTCONSOLE || + type == HUD_PRINTCENTER) { - DevMsg(eDLL_T::SERVER, text[len-1] == '\n' ? "%s" : "%s\n", text); + char text[MAX_USER_MSG_DATA]; + int len; + + buf.ReadString(text, sizeof(text), false, &len); + Assert(len < sizeof(text)); + + if (len && len < sizeof(text)) + { + DevMsg(eDLL_T::SERVER, text[len - 1] == '\n' ? "%s" : "%s\n", text); + } } } @@ -107,11 +111,26 @@ bool ShouldReplayMessage(const CNetMessage* msg) // be broadcasted to the target client. This happens for the // same reason as the 'net_StringCmd' above. case NetMessageType::svc_Print: - case NetMessageType::svc_UserMessage: + { return false; - default: + } + case NetMessageType::svc_UserMessage: + { + SVC_UserMessage* userMsg = (SVC_UserMessage*)msg; + + // Just don't replay console prints. + if (userMsg->m_nMsgType == UserMessages_t::TextMsg) + { + return false; + } + return true; } + default: + { + return true; + } + } } void V_NetMessages::Attach() const diff --git a/r5dev/game/CMakeLists.txt b/r5dev/game/CMakeLists.txt index 4138ea05..f1890eb9 100644 --- a/r5dev/game/CMakeLists.txt +++ b/r5dev/game/CMakeLists.txt @@ -21,6 +21,7 @@ add_sources( SOURCE_GROUP "Shared" "shared/takedamageinfo.h" "shared/usercmd.cpp" "shared/usercmd.h" + "shared/usermessages.h" "shared/util_shared.cpp" "shared/util_shared.h" "shared/vscript_shared.cpp" diff --git a/r5dev/game/shared/usermessages.h b/r5dev/game/shared/usermessages.h new file mode 100644 index 00000000..20f4af97 --- /dev/null +++ b/r5dev/game/shared/usermessages.h @@ -0,0 +1,69 @@ +#ifndef USERMESSAGES_H +#define USERMESSAGES_H + +//----------------------------------------------------------------------------- +// Enumerated in the same order, as the order of registration in 'RegisterUserMessages' !!! +//----------------------------------------------------------------------------- +enum UserMessages_t +{ + Geiger = 0, + Train, + HudText, + SayText, + AnnounceText, + TextMsg, + HudMsg, + ResetHUD, + ItemPickup, + ShowMenu, + Shake, + Fade, + VGUIMenu, + Rumble, + Damage, + VoiceMask, + RequestState, + WeapProjFireCB, + PredSVEvent, + CreditsMsg, + LogoTimeMsg, + AchievementEvent, + UpdateJalopyRadar, + CurrentTimescale, + DesiredTimescale, + CreditsPortalMsg, + InventoryFlash, + IndicatorFlash, + ControlHelperAnimate, + TakePhoto, + Flash, + HudPingIndicator, + OpenRadialMenu, + AddLocator, + MPMapCompleted, + MPMapIncomplete, + MPMapCompletedData, + MPTauntEarned, + MPTauntUnlocked, + MPTauntLocked, + MPAllTauntsLocked, + PortalFX_Surface, + ChangePaintColor, + StartSurvey, + ApplyHitBoxDamageEffect, + SetMixLayerTriggerFactor, + TransitionFade, + HudElemSetVisibility, + HudElemLabelSetText, + HudElemImageSet, + HudElemSetColor, + HudElemSetColorBG, + RemoteUntypedFunctionCall, + RemoteFunctionCall, + RemoteFunctionCallsChecksum, + PlayerNotifyDidDamage, + RemoteBulletFired, + RemoteWeaponReload, +}; + +#endif // USERMESSAGES_H