-
-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix class hierarchy. Remove VTBL hacks #3766
base: master
Are you sure you want to change the base?
Fix class hierarchy. Remove VTBL hacks #3766
Conversation
void CCameraSA::SetMatrix(CMatrix* matrix) | ||
{ | ||
CMatrix_Padded* pCamMatrix = GetInterface()->Placeable.matrix; | ||
CMatrix_Padded* pCamMatrix = GetInterface()->matrix; | ||
if (pCamMatrix) | ||
{ | ||
pCamMatrix->vFront = matrix->vFront; |
There was a problem hiding this comment.
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
Client/game_sa/CVehicleSA.cpp
Outdated
// 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); | ||
} | ||
} |
There was a problem hiding this comment.
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
On this topic, I think we should get rid of two duplicate classes like |
|
You are right, so CMatrix_Padded should inherit CMatrixSAInterface, because now CMatrix_Paddes is the wrong size |
{ | ||
// Log info | ||
OutputDebugString(SString("Entity 0x%08x (with model %d) at ARRAY_StreamSectors[%d,%d] is invalid\n", pEntity, pEntity->m_nModelIndex, | ||
i / 2 % NUM_StreamSectorRows, i / 2 / NUM_StreamSectorCols)); | ||
// Assert in debug | ||
#if MTA_DEBUG | ||
assert(pEntity->vtbl->DeleteRwObject == 0x00534030); | ||
assert(static_cast<std::size_t*>(pEntity->GetVTBL())[CEntity_DeleteRwObject_VTBL_OFFSET] != 0x00534030); | ||
#endif | ||
pSectorEntry = (DWORD*)pSectorEntry[1]; | ||
continue; |
There was a problem hiding this comment.
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
This PR:
CEntitySAInterface
. All hacks are replaced with virtual methods.Current state: testing.