From b189fbf2600ab1f246f6e2d354c116a60de8ecbc Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Thu, 17 Jun 2021 23:56:51 -0400 Subject: [PATCH] Fix flat api crash. --- dll/flat.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/dll/flat.cpp b/dll/flat.cpp index 534e4a5..b15dd67 100644 --- a/dll/flat.cpp +++ b/dll/flat.cpp @@ -1144,12 +1144,28 @@ STEAMAPI_API bool SteamAPI_ISteamUtils_IsSteamChinaLauncher( ISteamUtils* self ) STEAMAPI_API bool SteamAPI_ISteamUtils_InitFilterText( ISteamUtils* self, uint32 unFilterOptions ) { - return (self)->InitFilterText(unFilterOptions); + //Note: older function only has less arguments + int test1 = ((char *)self - (char*)get_steam_client()->steam_utils); + int test2 = ((char *)self - (char*)get_steam_client()->steam_gameserver_utils); + auto ptr = get_steam_client()->steam_gameserver_utils; + if (test1 >= 0 && (test2 < 0 || test1 < test2)) { + ptr = get_steam_client()->steam_utils; + } + + return (ptr)->InitFilterText(unFilterOptions); } -int SteamAPI_ISteamUtils_FilterText( ISteamUtils* self, ETextFilteringContext eContext, uint64_steamid sourceSteamID, const char * pchInputMessage, char * pchOutFilteredText, uint32 nByteSizeOutFilteredText ) +STEAMAPI_API int SteamAPI_ISteamUtils_FilterText( ISteamUtils* self, ETextFilteringContext eContext, uint64_steamid sourceSteamID, const char * pchInputMessage, char * pchOutFilteredText, uint32 nByteSizeOutFilteredText ) { - return (self)->FilterText(eContext, sourceSteamID, pchInputMessage, pchOutFilteredText, nByteSizeOutFilteredText); + //Note: older function only has less arguments + int test1 = ((char *)self - (char*)get_steam_client()->steam_utils); + int test2 = ((char *)self - (char*)get_steam_client()->steam_gameserver_utils); + auto ptr = get_steam_client()->steam_gameserver_utils; + if (test1 >= 0 && (test2 < 0 || test1 < test2)) { + ptr = get_steam_client()->steam_utils; + } + + return (ptr)->FilterText(eContext, sourceSteamID, pchInputMessage, pchOutFilteredText, nByteSizeOutFilteredText); } STEAMAPI_API ESteamIPv6ConnectivityState SteamAPI_ISteamUtils_GetIPv6ConnectivityState( ISteamUtils* self, ESteamIPv6ConnectivityProtocol eProtocol )