Skip to content

Conversation

@TheNormalnij
Copy link
Member

@TheNormalnij TheNormalnij commented Oct 3, 2024

This PR:

  • Removes dirty VTBL hacks in CEntitySAInterface. All hacks are replaced with virtual methods.
  • Fixes class hierarchy in CEntitySAInterface and CCameraSAInterface with CPlaceableSAInterface.

Current state: testing.

Comment on lines 211 to 216
void CCameraSA::SetMatrix(CMatrix* matrix)
{
CMatrix_Padded* pCamMatrix = GetInterface()->Placeable.matrix;
CMatrix_Padded* pCamMatrix = GetInterface()->matrix;
if (pCamMatrix)
{
pCamMatrix->vFront = matrix->vFront;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code had no effect previously. matrix was always nullptr because Placeable was misplaced

Comment on lines 168 to 198
// Initialize doors depending on the vehicle type.
DWORD dwOffset = 0;

switch (static_cast<VehicleClass>(GetVehicleInterface()->m_vehicleClass))
{
case VehicleClass::AUTOMOBILE:
case VehicleClass::MONSTER_TRUCK:
case VehicleClass::QUAD:
case VehicleClass::HELI:
case VehicleClass::PLANE:
case VehicleClass::TRAILER:
{
dwOffset = 1464;
}
case VehicleClass::TRAIN:
{
dwOffset = 1496;
}
default:
break;
}

if (dwOffset != 0)
{
for (unsigned int i = 0; i < sizeof(m_doors) / sizeof(m_doors[0]); ++i)
{
DWORD dwInterface = (DWORD)GetInterface();
DWORD dwDoorAddress = dwInterface + 1464 + i * 24;
DWORD dwDoorAddress = dwInterface + dwOffset + i * 24;
m_doors[i].SetInterface((CDoorSAInterface*)dwDoorAddress);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was bugged. The game uses wrong door array positions for CTrain.
It causes train desync issues

@FileEX
Copy link
Member

FileEX commented Oct 3, 2024

On this topic, I think we should get rid of two duplicate classes like CMatrix_Padded and CMatrixSAInterface. Only CMatrixSAInterface should remain. In addition, the CMatrix_Padded class is incomplete

@TheNormalnij
Copy link
Member Author

TheNormalnij commented Oct 3, 2024

On this topic, I think we should get rid of two duplicate classes like CMatrix_Padded and CMatrixSAInterface. Only CMatrixSAInterface should remain. In addition, the CMatrix_Padded class is incomplete

CMatrix_Padded and CMatrixSAInterface are different classes. CMatrix_Padded

@FileEX
Copy link
Member

FileEX commented Oct 3, 2024

On this topic, I think we should get rid of two duplicate classes like CMatrix_Padded and CMatrixSAInterface. Only CMatrixSAInterface should remain. In addition, the CMatrix_Padded class is incomplete

CMatrix_Padded and CMatrixSAInterface are different classes. CMatrix_Padded

You are right, so CMatrix_Padded should inherit CMatrixSAInterface, because now CMatrix_Paddes is the wrong size

@TheNormalnij TheNormalnij marked this pull request as ready for review October 26, 2024 00:59
assert(static_cast<std::size_t*>(pEntity->GetVTBL())[CEntity_DeleteRwObject_VTBL_OFFSET] != 0x00534030);
#endif
pSectorEntry = (DWORD*)pSectorEntry[1];
continue;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check should be removed but not in this PR

@Dutchman101 Dutchman101 requested review from botder and tederis October 26, 2024 02:09
@Dutchman101
Copy link
Member

Dutchman101 commented Feb 8, 2025

@TheNormalnij Please resolve conflicts.

Would it be a good idea to just test its stability in a nightly build soon? A bunch of code reviews have passed, and there seems to be no further feedback after that.

@TheNormalnij
Copy link
Member Author

@TheNormalnij Please resolve conflicts.

Would it be a good idea to just test its stability in a nightly build soon? A bunch of code reviews have passed, and there seems to be no further feedback after that.

Updated.
I'd test it in a nightly build first

@Dutchman101 Dutchman101 merged commit 61d1caf into multitheftauto:master Mar 1, 2025
6 checks passed
@Dutchman101
Copy link
Member

Alright, in a few days we will call for testers, along with for other changes.

MTABot pushed a commit that referenced this pull request Mar 1, 2025
61d1caf Fix class hierarchy. Remove VTBL hacks (#3766)
@botder botder added this to the 1.6.1 milestone Mar 2, 2025
@botder botder added the refactor label Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants