Commits

Ryan Kistner committed 627c24b

try/catch feature, minidumps I'll do later

Comments (0)

Files changed (8)

Open Steamworks/Steamclient.h

 S_API ISteamMatchmakingServers* STEAM_CALL SteamMatchmakingServers();
 
 
+// sets whether or not Steam_RunCallbacks() should do a try {} catch (...) {} around calls to issuing callbacks
+S_API void SteamAPI_SetTryCatchCallbacks( bool bTryCatchCallbacks );
+
 S_API void STEAM_CALL SteamAPI_RunCallbacks();
 
 // functions used by the utility CCallback objects to receive callbacks

steam_api/apitest/apitest.vcproj

 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				Optimization="2"
+				Optimization="3"
+				InlineFunctionExpansion="2"
 				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
 				AdditionalIncludeDirectories="&quot;../../Open Steamworks&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
 				RuntimeLibrary="2"

steam_api/apitest/main.cpp

 	void OnLobbyMatchListCallback( LobbyMatchList_t *pLobbyMatchList, bool bIOFailure )
 	{
 		std::cout << "qq " << pLobbyMatchList->m_nLobbiesMatching << " " << bIOFailure << std::endl;
+
 	}
 
 	STEAM_CALLBACK( CLobbyBrowser, OnLobbyMatchListCallback, LobbyMatchList_t, m_CallbackLobbyMatchList );
 void CLobbyBrowser::OnLobbyMatchListCallback( LobbyMatchList_t *pLobbyMatchList )
 {
 	std::cout << "qq regular callback " << pLobbyMatchList->m_nLobbiesMatching << std::endl;
+
+	throw new std::exception("qq");
 }
 
 int main(int argc, char *argv[])
 	SteamAPICall_t hSteamAPICall = ((ISteamMatchmaking007 *)SteamMatchmaking())->RequestLobbyList();
 	qq.m_SteamCallResultLobbyMatchList.Set(hSteamAPICall, &qq, &CLobbyBrowser::OnLobbyMatchListCallback );
 
+	SteamAPI_SetTryCatchCallbacks(true);
 
-	while(true)
+	for(int i = 0; i < 100; i++)
 	{
 		SteamAPI_RunCallbacks();
 		Sleep(100);

steam_api/callbacks.cpp

 			if(bGameServer && !(callback->m_nCallbackFlags & CCallbackBase::k_ECallbackFlagsGameServer))
 				continue;
 
-			callback->Run(callbackMsg.m_pubParam);
+			if(callbackTryCatch)
+			{
+
+				try {
+					callback->Run(callbackMsg.m_pubParam);
+				} catch(...) {};
+
+			} else {
+				callback->Run(callbackMsg.m_pubParam);
+			}
 		}
 
 		provider.Steam_FreeLastCallback(pipe);
 S_API HSteamUser STEAM_CALL Steam_GetHSteamUserCurrent()
 {
 	return callbackmanager.currentUser;
+}
+
+
+S_API void SteamAPI_SetTryCatchCallbacks( bool bTryCatchCallbacks )
+{
+	callbackmanager.callbackTryCatch = bTryCatchCallbacks;
 }

steam_api/callbacks.h

 
 	void Cleanup();
 
+	bool callbackTryCatch;
 	HSteamUser currentUser;
 private:
 	void RunAPICallbacks(HSteamPipe pipe, SteamAPICallCompleted_t *call);
 	typedef boost::unordered_map<SteamAPICall_t, CCallbackBase *> APICallsMap;
 	APICallsMap apicalls;
 
-	bool callbackTryCatch;
-
 	CallbackProvider provider;
 };
 
 S_API void STEAM_CALL Steam_RunCallbacks( HSteamPipe hSteamPipe, bool bGameServerCallbacks );
 S_API void STEAM_CALL Steam_RegisterInterfaceFuncs(void *hModule);
 
-S_API HSteamUser STEAM_CALL Steam_GetHSteamUserCurrent();
+S_API HSteamUser STEAM_CALL Steam_GetHSteamUserCurrent();
+
+S_API void SteamAPI_SetTryCatchCallbacks( bool bTryCatchCallbacks );

steam_api/steam_api.cpp

 S_API HSteamUser STEAM_CALL GetHSteamUser()
 {
 	return SteamAPI_GetHSteamUser();
+}
+
+
+S_API void STEAM_CALL SteamAPI_WriteMiniDump( uint32 uStructuredExceptionCode, void* pvExceptionInfo, uint32 uBuildID )
+{
+	std::cerr << "TODO: SteamAPI_WriteMiniDump" << std::endl;
+}
+
+S_API void STEAM_CALL SteamAPI_SetMiniDumpComment( const char *pchMsg )
+{
+	std::cerr << "TODO: SteamAPI_SEtMiniDumpComment" << std::endl;
 }

steam_api/steam_api.h

 S_API HSteamUser STEAM_CALL SteamAPI_GetHSteamUser();
 S_API HSteamUser STEAM_CALL GetHSteamUser();
 
-S_API void STEAM_CALL SteamAPI_RunCallbacks();
+S_API void STEAM_CALL SteamAPI_RunCallbacks();
+
+S_API void STEAM_CALL SteamAPI_WriteMiniDump( uint32 uStructuredExceptionCode, void* pvExceptionInfo, uint32 uBuildID );
+S_API void STEAM_CALL SteamAPI_SetMiniDumpComment( const char *pchMsg );

steam_api/steam_api.vcproj

 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				Optimization="2"
+				Optimization="3"
+				InlineFunctionExpansion="2"
 				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
 				AdditionalIncludeDirectories="&quot;../Open Steamworks&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;STEAM_API_EXPORTS"
 				RuntimeLibrary="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
 				TargetMachine="1"
+				Profile="true"
 			/>
 			<Tool
 				Name="VCALinkTool"