Closed dkollmann closed 1 year ago
For this I detect textures and assign a "special role" to them.
How are you detecting the texture to assign it a role?
SetTexture()
call? Try logging the address of the SurfaceX that you assign the role to and then logging all the SetTexture()
calls to see the game ever calls SetTexture on that surface.SetTexture()
function? From the code above it looks like the wrong one. There are two SetTexture functions. This game only calls the one that looks like this: HRESULT m_IDirect3DDeviceX::SetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7 lpSurface)
The role is correctly assigned, which the texture replacement already uses.
I cannot see any SetTexture for that surface. Here is what the log lists for the surface 1A2AA0F0.
It is a dynamic texture, the shadow of the hand, that is why I need to prevent the game from locking it, otherwise it would be replaced again.
3636 20:01:39.461 m_IDirectDrawSurfaceX::IsLost (1A2AA0F0)
3636 20:01:39.461 m_IDirect3DDevice9Ex::TestCooperativeLevel (09220420)
3636 20:01:39.461 m_IDirectDrawSurfaceX::Lock2 (1A2AA0F0)
3636 20:01:39.461 m_IDirect3DDevice9Ex::TestCooperativeLevel (09220420)
3636 20:01:39.461 m_IDirect3DDevice9Ex::TestCooperativeLevel (09220420)
3636 20:01:39.461 m_IDirectDrawSurfaceX::LockD39Surface (1A2AA0F0) prevent lock of hand decal!
3636 20:01:39.461 m_IDirectDrawSurfaceX::LockD39Surface (1A2AA0F0) prevent lock of hand decal!
3636 20:01:39.461 m_IDirectDrawSurfaceX::Lock2 Error: failed to lock surface texture. is Texture Size: 32x32 Format: D3DFMT_A4R4G4B4 dwCaps: 0x10405008 IsLocked: 0 IsInDC: 0
3636 20:01:39.461 m_IDirectDrawSurfaceX::Unlock (1A2AA0F0)
3636 20:01:39.461 m_IDirect3DDevice9Ex::TestCooperativeLevel (09220420)
3636 20:01:39.461 m_IDirect3DTexture9::UnlockRect (1A2D0E68)
3636 20:01:39.461 m_IDirect3DDevice9Ex::TestCooperativeLevel (09220420)
3636 20:01:39.461 m_IDirectDrawSurfaceX::Blt (092DA7A0)
3636 20:01:39.461 m_IDirect3DDevice9Ex::TestCooperativeLevel (09220420)
3636 20:01:39.461 m_IDirect3DDevice9Ex::TestCooperativeLevel (09220420)
3636 20:01:39.461 m_IDirectDrawSurfaceX::QueryInterface (1A2AA0F0) IID_GetInterfaceX
Okay I found it. It is handled through blitting.
HRESULT m_IDirectDrawSurfaceX::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx, bool isSkipScene)
{
...
// Get source surface
m_IDirectDrawSurfaceX* lpDDSrcSurfaceX = (m_IDirectDrawSurfaceX*)lpDDSrcSurface;
if (!lpDDSrcSurfaceX)
{
lpDDSrcSurfaceX = this;
}
else
{
lpDDSrcSurfaceX->QueryInterface(IID_GetInterfaceX, (LPVOID*)&lpDDSrcSurfaceX);
}
// Handle special roles
if(lpDDSrcSurfaceX->SpecialRole == SurfaceSpecialRole::HandDecal)
{
Logging::LogDebug() << __FUNCTION__ << " (" << this << ") skipped hand decal blitting!";
hr = DDERR_GENERIC;
break;
}
...
}
Okay I found it. It is handled through blitting.
LOL. Yeah, that is the other option I was going to say but left off for some reason. I wonder why the game author chose to blit the hand texture rather than just using SetTexture.
I am sure there was a good reason for it. In 1999. :p
Hello guys, I am now at the point where I have to make some game specific hacks. For this I detect textures and assign a "special role" to them.
Replacing the texture is already working...
however, I would rather like to skip the geometry alltogether.
So my idea was to store the "special role" of the current texture, but I cannot find it.
Any suggestions? Thank you