From 084fc056a70e1a841259db6938d3dc09e38ba06d Mon Sep 17 00:00:00 2001
From: WPMGPRoSToTeMa <wpmgprostotema@live.ru>
Date: Wed, 15 Jun 2016 21:23:49 +0300
Subject: [PATCH] Added rh_update_user_info Updated ReHLDS API Fixed platform
 toolset in msvc for WinXP

---
 .../extra/amxmodx/scripting/include/reapi.inc |  4 ++--
 .../scripting/include/reapi_engine.inc        | 11 +++++++++-
 reapi/include/cssdk/engine/rehlds_api.h       |  5 +++--
 reapi/msvc/reapi.vcxproj                      |  4 ++--
 reapi/src/natives/natives_misc.cpp            | 20 ++++++++++++++++++-
 reapi/src/reapi_version.inc                   |  2 +-
 6 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/reapi/extra/amxmodx/scripting/include/reapi.inc b/reapi/extra/amxmodx/scripting/include/reapi.inc
index dc3aec5..dad921f 100644
--- a/reapi/extra/amxmodx/scripting/include/reapi.inc
+++ b/reapi/extra/amxmodx/scripting/include/reapi.inc
@@ -85,7 +85,7 @@ enum HookChain
 * @return 		Returns a handle to the hook. Use EnableHookChain/DisableHookChain to toggle the forward on or off.
 *
 */
-native HookChain:RegisterHookChain(any:function_id, const callback[], post = 0);
+native HookChain:RegisterHookChain({EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules}:function_id, const callback[], post = 0);
 
 /*
 * Stops a hook from triggering.
@@ -192,4 +192,4 @@ public __reapi_version_check(const majorVersion, const minorVersion)
 		set_fail_state(temp);
 		return;
 	}
-}
+}
\ No newline at end of file
diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc
index ec74bc9..dc6b420 100644
--- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc
+++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc
@@ -73,8 +73,17 @@ native rh_reset_mapname();
 * @param flags		Emit flags
 * @param pitch		Sound pitch
 * @param emitFlags	Additional Emit2 flags, look at the defines like SND_EMIT2_*
-
+*
 * @return		1 if successfully sounds are emitted, 0 otherwise
 *
 */
 native rh_emit_sound2(const entity, const recipient, const channel, const sample[], Float:vol = VOL_NORM, Float:attn = ATTN_NORM, const flags = 0, const pitch = PITCH_NORM, emitFlags = 0, const Float:origin[3] = {0.0,0.0,0.0});
+
+/*
+* Forces an userinfo update
+*
+* @param playerEntIndex    Player entity index (starts from 1)
+*
+* @noreturn
+*/
+native rh_update_user_info(playerEntIndex);
\ No newline at end of file
diff --git a/reapi/include/cssdk/engine/rehlds_api.h b/reapi/include/cssdk/engine/rehlds_api.h
index 0e3ada2..3e7fb2a 100644
--- a/reapi/include/cssdk/engine/rehlds_api.h
+++ b/reapi/include/cssdk/engine/rehlds_api.h
@@ -35,7 +35,7 @@
 #include "model.h"
 
 #define REHLDS_API_VERSION_MAJOR 2
-#define REHLDS_API_VERSION_MINOR 12
+#define REHLDS_API_VERSION_MINOR 13
 
 //Steam_NotifyClientConnect hook
 typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@@ -280,6 +280,7 @@ struct RehldsFuncs_t {
 	void(*Steam_NotifyClientDisconnect)(IGameClient* cl);
 	void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch);
 	bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin);
+	void (* SV_UpdateUserInfo)(IGameClient *pGameClient);
 };
 
 class IRehldsApi {
@@ -295,4 +296,4 @@ public:
 	virtual IRehldsFlightRecorder* GetFlightRecorder() = 0;
 };
 
-#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"
+#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"
\ No newline at end of file
diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj
index 48982c6..80c5114 100644
--- a/reapi/msvc/reapi.vcxproj
+++ b/reapi/msvc/reapi.vcxproj
@@ -283,13 +283,13 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
+    <PlatformToolset>v120_xp</PlatformToolset>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
+    <PlatformToolset>v120_xp</PlatformToolset>
     <WholeProgramOptimization>true</WholeProgramOptimization>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp
index 7b4cd20..9e4b353 100644
--- a/reapi/src/natives/natives_misc.cpp
+++ b/reapi/src/natives/natives_misc.cpp
@@ -993,7 +993,7 @@ cell AMX_NATIVE_CALL rg_set_user_team(AMX *amx, cell *params)
 				pPlayer->m_bHasDefuser = false;
 				pPlayer->pev->body = 0;
 
-				MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev);
+				MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
 					WRITE_BYTE(STATUSICON_HIDE);
 					WRITE_STRING("defuser");
 				MESSAGE_END();
@@ -1552,12 +1552,30 @@ cell AMX_NATIVE_CALL rh_emit_sound2(AMX *amx, cell *params)
 	);
 }
 
+// TODO: should we duplicate documentation for native here and in include?
+cell AMX_NATIVE_CALL rh_update_user_info(AMX *amx, cell *params)
+{
+	enum args_e { arg_count, arg_playerEntIndex };
+
+	CBasePlayer *pPlayer = getPrivate<CBasePlayer>(params[arg_playerEntIndex]);
+	if (pPlayer != nullptr && pPlayer->has_disconnected) {
+		MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_playerEntIndex]);
+		return FALSE;
+	}
+
+	CAmxArgs args(amx, params);
+	g_RehldsFuncs->SV_UpdateUserInfo(args[arg_playerEntIndex]);
+
+	return TRUE;
+}
+
 AMX_NATIVE_INFO Misc_Natives_RH[] =
 {
 	{ "rh_set_mapname", rh_set_mapname },
 	{ "rh_get_mapname", rh_get_mapname },
 	{ "rh_reset_mapname", rh_reset_mapname },
 	{ "rh_emit_sound2", rh_emit_sound2 },
+	{ "rh_update_user_info", rh_update_user_info },
 
 	{ nullptr, nullptr }
 };
diff --git a/reapi/src/reapi_version.inc b/reapi/src/reapi_version.inc
index 9adc920..4ccf35a 100644
--- a/reapi/src/reapi_version.inc
+++ b/reapi/src/reapi_version.inc
@@ -5,4 +5,4 @@
 
 // reapi version
 #define REAPI_VERSION_MAJOR 3
-#define REAPI_VERSION_MINOR 0
+#define REAPI_VERSION_MINOR 1