Commits

Ryan Kistner  committed 4a23cae

Seems more likely this is what its doing, rather than iterating a list of registered providers

  • Participants
  • Parent commits 748d3e3

Comments (0)

Files changed (3)

File steam_api/callbacks.cpp

 #include "stdafx.h"
 #include "callbacks.h"
 
-void CallbackManager::AddCallbackProvider(HMODULE module)
+CallbackManager callbackmanager;
+
+void CallbackProvider::ResolveExports()
 {
-	CallbackProvider provider(module);
-	
-    ProviderVector::const_iterator iter = std::find(providers.begin(), providers.end(), provider);
+	getcallback = (SteamBGetCallbackFn)GetProcAddress(module, "Steam_BGetCallback");
+	freelastcallback = (SteamFreeLastCallbackFn)GetProcAddress(module, "Steam_FreeLastCallback");
+	getapicallresult = (SteamGetAPICallResultFn)GetProcAddress(module, "Steam_GetAPICallResult");
+}
 
-	if(iter != providers.end())
+void CallbackProvider::Set(HMODULE mod)
+{
+	if(module == mod)
 		return;
 
-	provider.ResolveExports();
-	providers.push_back(provider);
+	module = mod;
+	ResolveExports();
+}
+
+void CallbackManager::SetCallbackProvider(HMODULE module)
+{
+	provider.Set(module);
+}
+
+S_API void STEAM_CALL Steam_RegisterInterfaceFuncs(void *hModule)
+{
+	callbackmanager.SetCallbackProvider((HMODULE)hModule);
 }

File steam_api/callbacks.h

 class CallbackProvider
 {
 public:
-	CallbackProvider(HMODULE module) : module(module) {};
-	CallbackProvider(const CallbackProvider& other) : module(other.module), getcallback(other.getcallback), freelastcallback(other.freelastcallback), getapicallresult(other.getapicallresult) {};
-
-	void ResolveExports()
-	{
-		getcallback = (SteamBGetCallbackFn)GetProcAddress(module, "Steam_BGetCallback");
-		freelastcallback = (SteamFreeLastCallbackFn)GetProcAddress(module, "Steam_FreeLastCallback");
-		getapicallresult = (SteamGetAPICallResultFn)GetProcAddress(module, "Steam_GetAPICallResult");
-	}
-
-	bool operator==( const CallbackProvider& y) { return this->module == y.module; }
+	void Set(HMODULE mod);
+	void ResolveExports();
 private:
 	HMODULE module;
 	SteamBGetCallbackFn getcallback;
 	SteamGetAPICallResultFn getapicallresult;
 };
 
-
-
 class CallbackManager
 {
 public:
-	void AddCallbackProvider(HMODULE module);
+	void SetCallbackProvider(HMODULE module);
 private:
 	bool callbackTryCatch;
 
-	typedef std::vector<CallbackProvider> ProviderVector;
-	ProviderVector providers;
-} callbackmanager;
+	CallbackProvider provider;
+};
+
+extern CallbackManager callbackmanager;
+
+S_API void STEAM_CALL Steam_RegisterInterfaceFuncs(void *hModule);

File steam_api/steam_api.cpp

 #include "stdafx.h"
 #include "interfaces.h"
+#include "callbacks.h"
 
 CSteamAPILoader loader;
 CreateInterfaceFn clientFactory = NULL;
 	if(user == NULL)
 		return false;
 
+	Steam_RegisterInterfaceFuncs(loader.GetSteamModule());
+
 	return true;
 }