More surface loading stuff
This commit is contained in:
parent
6dc46a4289
commit
ab3c75cb5b
@ -15,10 +15,17 @@ namespace Components
|
||||
*bufferOut = ModelSurfs::BufferMap[buffer];
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
bool ModelSurfs::LoadXSurfaces(Game::XModel* model)
|
||||
{
|
||||
(model);
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
void ModelSurfs::ReleaseModelSurf(Game::XAssetHeader header)
|
||||
{
|
||||
Game::XModelSurfs* surfaces = header.surfaces;
|
||||
|
||||
(surfaces);
|
||||
}
|
||||
|
||||
@ -32,17 +39,24 @@ namespace Components
|
||||
ModelSurfs::BufferMap.clear();
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
void ModelSurfs::EndRecover()
|
||||
{
|
||||
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_XMODELSURFS, [] (Game::XAssetHeader header, void* /*userdata*/)
|
||||
{
|
||||
Game::XModelSurfs* surfaces = header.surfaces;
|
||||
|
||||
// TODO: Recreate all buffers here
|
||||
(surfaces);
|
||||
}, nullptr, false);
|
||||
}
|
||||
|
||||
void ModelSurfs::XModelSurfsFixup(Game::XModel* model)
|
||||
{
|
||||
if (!ModelSurfs::LoadXSurfaces(model))
|
||||
{
|
||||
Game::DB_XModelSurfsFixup(model);
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void ModelSurfs::GetIndexBufferStub()
|
||||
{
|
||||
__asm
|
||||
@ -82,6 +96,24 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void ModelSurfs::GetIndexBaseStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, [esp + 4h]
|
||||
cmp al, 0FFh
|
||||
|
||||
jne returnSafe
|
||||
|
||||
xor eax, eax
|
||||
retn
|
||||
|
||||
returnSafe:
|
||||
mov eax, 48C5F0h
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void ModelSurfs::GetVertexBufferStub()
|
||||
{
|
||||
__asm
|
||||
@ -112,6 +144,8 @@ namespace Components
|
||||
Renderer::OnDeviceRecoveryEnd(ModelSurfs::EndRecover);
|
||||
|
||||
// Install hooks
|
||||
Utils::Hook(0x47A6BD, ModelSurfs::XModelSurfsFixup, HOOK_CALL).Install()->Quick();
|
||||
Utils::Hook(0x558F12, ModelSurfs::GetIndexBaseStub, HOOK_CALL).Install()->Quick();
|
||||
Utils::Hook(0x5BC050, ModelSurfs::GetIndexBufferStub, HOOK_JUMP).Install()->Quick();
|
||||
Utils::Hook(0x558E70, ModelSurfs::GetIndexBufferStub2, HOOK_CALL).Install()->Quick();
|
||||
Utils::Hook(0x5BC050, ModelSurfs::GetVertexBufferStub, HOOK_JUMP).Install()->Quick();
|
||||
|
@ -18,6 +18,10 @@ namespace Components
|
||||
static IUnknown* GetBuffer(void* buffer);
|
||||
static void SetBuffer(char streamHandle, void* buffer, IUnknown** bufferOut, int* offsetOut);
|
||||
|
||||
static bool LoadXSurfaces(Game::XModel* model);
|
||||
static void XModelSurfsFixup(Game::XModel* model);
|
||||
|
||||
static void GetIndexBaseStub();
|
||||
static void GetIndexBufferStub();
|
||||
static void GetIndexBufferStub2();
|
||||
static void GetVertexBufferStub();
|
||||
|
@ -43,6 +43,7 @@ namespace Game
|
||||
DB_LoadXAssets_t DB_LoadXAssets = (DB_LoadXAssets_t)0x4E5930;
|
||||
DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed = (DB_ReadXFileUncompressed_t)0x4705E0;
|
||||
DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers = (DB_ReleaseXAssetHandler_t*)0x799AB8;
|
||||
DB_XModelSurfsFixup_t DB_XModelSurfsFixup = (DB_XModelSurfsFixup_t)0x5BAC50;
|
||||
|
||||
Dvar_RegisterBool_t Dvar_RegisterBool = (Dvar_RegisterBool_t)0x4CE1A0;
|
||||
Dvar_RegisterFloat_t Dvar_RegisterFloat = (Dvar_RegisterFloat_t)0x648440;
|
||||
|
@ -99,6 +99,9 @@ namespace Game
|
||||
typedef void(__cdecl * DB_ReleaseXAssetHandler_t)(XAssetHeader header);
|
||||
extern DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers;
|
||||
|
||||
typedef void(__cdecl * DB_XModelSurfsFixup_t)(XModel* model);
|
||||
extern DB_XModelSurfsFixup_t DB_XModelSurfsFixup;
|
||||
|
||||
typedef dvar_t* (__cdecl * Dvar_RegisterBool_t)(const char* name, bool default, int flags, const char* description);
|
||||
extern Dvar_RegisterBool_t Dvar_RegisterBool;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user