fix return code for CreateInterface()

This commit is contained in:
a
2025-08-02 21:42:54 +03:00
parent 02477b8f15
commit ce9ae52eb7
2 changed files with 12 additions and 8 deletions

View File

@@ -1358,10 +1358,13 @@ STEAMCLIENT_API void* CreateInterface( const char *pName, int *pReturnCode )
{
PRINT_DEBUG("%s %p", pName, pReturnCode);
auto ptr = create_client_interface(pName);
if (ptr) {
if (pReturnCode) *pReturnCode = 1;
} else {
if (pReturnCode) *pReturnCode = 0;
if (pReturnCode) {
// https://github.com/ValveSoftware/source-sdk-2013/blob/57a8b644af418c691f1fba45791019cf2367dedd/src/public/tier1/interface.h#L156-L160
if (ptr) {
*pReturnCode = 0; // IFACE_OK
} else {
*pReturnCode = 1; // IFACE_FAILED
}
}
return ptr;
}

View File

@@ -14,22 +14,23 @@ extern "C" __declspec( dllexport ) void* __cdecl CreateInterface( const char *p
auto steam_api = LoadLibraryA(DLL_NAME);
if (!steam_api) {
if (pReturnCode) *pReturnCode = 0;
if (pReturnCode) *pReturnCode = 1; // IFACE_FAILED
return nullptr;
}
auto create_interface = (fn_create_interface_t)GetProcAddress(steam_api, "SteamInternal_CreateInterface");
// https://github.com/ValveSoftware/source-sdk-2013/blob/57a8b644af418c691f1fba45791019cf2367dedd/src/public/tier1/interface.h#L156-L160
if (!create_interface) {
if (pReturnCode) *pReturnCode = 0;
if (pReturnCode) *pReturnCode = 1; // IFACE_FAILED
return nullptr;
}
auto ptr = create_interface(pName);
if (pReturnCode) {
if (ptr) {
*pReturnCode = 1;
*pReturnCode = 0; // IFACE_OK
} else {
*pReturnCode = 0;
*pReturnCode = 1; // IFACE_FAILED
}
}