1
0
Fork 0
mirror of https://github.com/Detanup01/gbe_fork.git synced 2025-08-05 07:05:34 +02:00

Merge pull request #317 from otavepto/patch/itf-code

Fix return code for `CreateInterface()`
This commit is contained in:
Detanup01 2025-08-02 21:12:56 +02:00 committed by GitHub
commit 6fb99e9d6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 (pReturnCode) {
// https://github.com/ValveSoftware/source-sdk-2013/blob/57a8b644af418c691f1fba45791019cf2367dedd/src/public/tier1/interface.h#L156-L160
if (ptr) {
if (pReturnCode) *pReturnCode = 1;
*pReturnCode = 0; // IFACE_OK
} else {
if (pReturnCode) *pReturnCode = 0;
*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
}
}