r5sdk/r5dev/codecs/bink/bink_impl.cpp
Kawe Mazidjatari a618990937 Detour code refactor
This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files.
Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer.

TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
2023-01-25 02:26:52 +01:00

31 lines
932 B
C++

#include "core/stdafx.h"
#include "codecs/bink/bink_impl.h"
//-----------------------------------------------------------------------------
// Purpose: opens bik video by handle, and logs any error caused during loading
// Input : hBinkFile -
// nFlags -
// Output : pointer to bik video structure, null if failed
//-----------------------------------------------------------------------------
void* BinkOpen(HANDLE hBinkFile, UINT32 nFlags)
{
void* pHandle = v_BinkOpen(hBinkFile, nFlags);
if (!pHandle)
{
// Retrieve BinkOpen error using the DLL's exported function "BinkGetError()".
Error(eDLL_T::VIDEO, NO_ERROR, "%s: %s\n", __FUNCTION__, v_BinkGetError());
}
return pHandle;
}
///////////////////////////////////////////////////////////////////////////////
void BinkCore::Attach() const
{
DetourAttach(&v_BinkOpen, &BinkOpen);
}
void BinkCore::Detach() const
{
DetourDetach(&v_BinkOpen, &BinkOpen);
}