Skip to content

Commit fa2fff2

Browse files
committed
Replace unsafe Matrix4/D3DMATRIX casts in TerrainTex for GeneralsMD
1 parent cbb3ae7 commit fa2fff2

File tree

1 file changed

+11
-5
lines changed
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient

1 file changed

+11
-5
lines changed

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,14 +716,20 @@ void LightMapTerrainTextureClass::Apply(unsigned int stage)
716716

717717
D3DXMATRIX inv;
718718
float det;
719-
D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView);
719+
D3DXMATRIX d3dCurView(
720+
curView[0][0], curView[0][1], curView[0][2], curView[0][3],
721+
curView[1][0], curView[1][1], curView[1][2], curView[1][3],
722+
curView[2][0], curView[2][1], curView[2][2], curView[2][3],
723+
curView[3][0], curView[3][1], curView[3][2], curView[3][3]
724+
);
725+
D3DXMatrixInverse(&inv, &det, &d3dCurView);
720726
D3DXMATRIX scale;
721727
D3DXMatrixScaling(&scale, STRETCH_FACTOR, STRETCH_FACTOR,1);
722728
inv *=scale;
723729
if (stage==0) {
724-
DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, *((Matrix4x4*)&inv));
730+
DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, inv);
725731
} if (stage==1) {
726-
DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, *((Matrix4x4*)&inv));
732+
DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, inv);
727733
}
728734

729735

@@ -999,7 +1005,7 @@ void CloudMapTerrainTextureClass::Apply(unsigned int stage)
9991005
DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
10001006
DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
10011007

1002-
DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, *((Matrix4x4*)&inv));
1008+
DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, inv);
10031009

10041010
// Disable 3rd stage just in case.
10051011
DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
@@ -1018,7 +1024,7 @@ void CloudMapTerrainTextureClass::Apply(unsigned int stage)
10181024
DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAARG1, D3DTA_CURRENT );
10191025
DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
10201026

1021-
DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, *((Matrix4x4*)&inv));
1027+
DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, inv);
10221028
}
10231029
#endif
10241030
}

0 commit comments

Comments
 (0)