From 3669b9898680a41beceec4ce30b353f4684389e7 Mon Sep 17 00:00:00 2001
From: Scott Ehlert <ds@alliedmods.net>
Date: Tue, 4 May 2010 22:49:46 -0400
Subject: [PATCH] Fixed SendConVarValue() on TF2, DOD:S, L4D, and L4D2 (bug
 4273, r=dvander, a=blocking).

---
 core/smn_console.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/core/smn_console.cpp b/core/smn_console.cpp
index 5b6e790e..2b76d53e 100644
--- a/core/smn_console.cpp
+++ b/core/smn_console.cpp
@@ -2,7 +2,7 @@
  * vim: set ts=4 :
  * =============================================================================
  * SourceMod
- * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
+ * Copyright (C) 2004-2010 AlliedModders LLC.  All rights reserved.
  * =============================================================================
  *
  * This program is free software; you can redistribute it and/or modify it under
@@ -46,6 +46,12 @@
 #include "Logger.h"
 #include "ConsoleDetours.h"
 
+#if SOURCE_ENGINE >= SE_ORANGEBOXVALVE
+#define NETMSG_BITS 6
+#else
+#define NETMSG_BITS 5
+#endif
+
 #if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
 #define NET_SETCONVAR	6
 #else
@@ -189,7 +195,7 @@ static void ReplicateConVar(ConVar *pConVar)
 	char data[256];
 	bf_write buffer(data, sizeof(data));
 
-	buffer.WriteUBitLong(NET_SETCONVAR, 5);
+	buffer.WriteUBitLong(NET_SETCONVAR, NETMSG_BITS);
 	buffer.WriteByte(1);
 	buffer.WriteString(pConVar->GetName());
 	buffer.WriteString(pConVar->GetString());
@@ -1299,7 +1305,7 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
 	char data[256];
 	bf_write buffer(data, sizeof(data));
 
-	buffer.WriteUBitLong(NET_SETCONVAR, 5);
+	buffer.WriteUBitLong(NET_SETCONVAR, NETMSG_BITS);
 	buffer.WriteByte(1);
 	buffer.WriteString(pConVar->GetName());
 	buffer.WriteString(value);