Skip to content

Commit

Permalink
RwGlobals and RwDevice stup in Renderware.h
Browse files Browse the repository at this point in the history
  • Loading branch information
forkerer committed Nov 10, 2024
1 parent ca847bb commit 83b210d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Client/multiplayer_sa/CMultiplayerSA_DeviceSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ struct RwSubSystemInfo
};

#define FUNC_rwDeviceSystemRequest 0x7F2AB0
using rwDeviceSystemRequest = RwSubSystemInfo*(__cdecl*)(void* device, uint32_t requestId, RwSubSystemInfo* pOut, void* pInOut, uint32_t numIn);
using rwDeviceSystemRequest = RwSubSystemInfo*(__cdecl*)(RwDevice* device, std::int32_t requestId, RwSubSystemInfo* pOut, void* pInOut, std::int32_t numIn);
static RwSubSystemInfo* RwEngineGetSubSystemInfo_Hooked(RwSubSystemInfo* subSystemInfo, int32_t subSystemIndex)
{
static auto rwDeviceSystemRequestFunc = (rwDeviceSystemRequest)(FUNC_rwDeviceSystemRequest);
auto devicePointer = *(uint32_t*)(0xC97B24);
auto result = rwDeviceSystemRequestFunc((void*)(devicePointer + 0x10), 14, subSystemInfo, nullptr, subSystemIndex);
if (result == nullptr)
auto rwGlobals = *(RwGlobals**)(0xC97B24);
auto rwDeviceSystemRequestFunc = (rwDeviceSystemRequest)(FUNC_rwDeviceSystemRequest);
auto result = rwDeviceSystemRequestFunc(&rwGlobals->dOpenDevice, 14, subSystemInfo, nullptr, subSystemIndex);
if (!result)
return nullptr;

auto pDxDevice = *(IDirect3D9**)0xC97C20;
if (pDxDevice == nullptr)
if (!pDxDevice)
return subSystemInfo;

D3DADAPTER_IDENTIFIER9 identifier;
Expand Down
46 changes: 46 additions & 0 deletions Client/sdk/game/RenderWare.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,49 @@ struct RwError
{
int err1, err2;
};

/*****************************************************************************/
/** RenderWare Globals **/
/*****************************************************************************/

typedef bool (*RwSystemFunc)(std::int32_t, void*, void*, std::int32_t);
struct RwDevice
{
float gammaCorrection;
RwSystemFunc fpSystem;
float zBufferNear;
float zBufferFar;
// RwRenderStateSetFunction fpRenderStateSet;
// RwRenderStateGetFunction fpRenderStateGet;
// RwIm2DRenderLineFunction fpIm2DRenderLine;
// RwIm2DRenderTriangleFunction fpIm2DRenderTriangle;
// RwIm2DRenderPrimitiveFunction fpIm2DRenderPrimitive;
// RwIm2DRenderIndexedPrimitiveFunction fpIm2DRenderIndexedPrimitive;
// RwIm3DRenderLineFunction fpIm3DRenderLine;
// RwIm3DRenderTriangleFunction fpIm3DRenderTriangle;
// RwIm3DRenderPrimitiveFunction fpIm3DRenderPrimitive;
// RwIm3DRenderIndexedPrimitiveFunction fpIm3DRenderIndexedPrimitive;
};
// static_assert(sizeof(RwDevice) == 0x38, "Incorrect class size: RwGlobals");

typedef bool (*RwStandardFunc)(void*, void*, std::int32_t);
struct RwGlobals
{
void* curCamera;
void* curWorld;
std::uint16_t renderFrame;
std::uint16_t lightFrame;
std::uint16_t pad[2];
RwDevice dOpenDevice;
RwStandardFunc stdFunc[29];
// RwLinkList dirtyFrameList;
// RwFileFunctions fileFuncs;
// RwStringFunctions stringFuncs;
// RwMemoryFunctions memoryFuncs;
// RwMemoryAllocFn memoryAlloc;
// RwMemoryFreeFn memoryFree;
// RwMetrics* metrics;
// RwEngineStatus engineStatus;
// RwUInt32 resArenaInitSize;
};
//static_assert(sizeof(RwGlobals) == 0x158, "Incorrect class size: RwGlobals");

0 comments on commit 83b210d

Please sign in to comment.