From 4eda095262d31b2752a19aa42d60fa9423184702 Mon Sep 17 00:00:00 2001 From: BCG2000 Date: Sun, 30 May 2021 07:52:41 -0300 Subject: [PATCH 1/6] Fix #2166, fix #2167: Use parent model ID of non-standard vehicle model Make CClientVehicleManager::GetMaxPassengerCount() and CVehicleNames::GetVehicleTypeName() use parent model ID if used on a vehicle added with engineRequestModel(). --- Client/mods/deathmatch/logic/CClientVehicleManager.cpp | 4 ++++ Client/mods/deathmatch/logic/CVehicleNames.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Client/mods/deathmatch/logic/CClientVehicleManager.cpp b/Client/mods/deathmatch/logic/CClientVehicleManager.cpp index ec34dd77cb3..f17af772947 100644 --- a/Client/mods/deathmatch/logic/CClientVehicleManager.cpp +++ b/Client/mods/deathmatch/logic/CClientVehicleManager.cpp @@ -470,6 +470,10 @@ eClientVehicleType CClientVehicleManager::GetVehicleType(unsigned long ulModel) unsigned char CClientVehicleManager::GetMaxPassengerCount(unsigned long ulModel) { + // Use parent model ID for non-standard vehicle model IDs. + if ((ulModel < 400 || ulModel > 611) && IsValidModel(ulModel)) + ulModel = g_pGame->GetModelInfo(ulModel)->GetParentID(); + // Valid model? if (IsStandardModel(ulModel)) { diff --git a/Client/mods/deathmatch/logic/CVehicleNames.cpp b/Client/mods/deathmatch/logic/CVehicleNames.cpp index 5ae0d79d9e9..32bcc3e7e6f 100644 --- a/Client/mods/deathmatch/logic/CVehicleNames.cpp +++ b/Client/mods/deathmatch/logic/CVehicleNames.cpp @@ -287,6 +287,10 @@ unsigned int CVehicleNames::GetVehicleModel(const char* szName) const char* CVehicleNames::GetVehicleTypeName(unsigned long ulModel) { + // Use parent model ID for non-standard vehicle model IDs. + if ((ulModel < 400 || ulModel > 611) && CClientVehicleManager::IsValidModel(ulModel)) + ulModel = g_pGame->GetModelInfo(ulModel)->GetParentID(); + // Check whether the model is valid if ((IsValidModel(ulModel) || IsModelTrailer(ulModel)) && ((ulModel - 400) < NUMELMS(ucVehicleTypes))) { From 853ba669f81a6daba0c7ec4ee4d32c0f4610675b Mon Sep 17 00:00:00 2001 From: BCG2000 Date: Mon, 25 Oct 2021 13:48:09 -0200 Subject: [PATCH 2/6] Update CNetAPI.cpp Fix door and damage sync of vehicles added with engineRequestModel(). --- Client/mods/deathmatch/logic/CNetAPI.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CNetAPI.cpp b/Client/mods/deathmatch/logic/CNetAPI.cpp index d88c826e659..a63d7ff553f 100644 --- a/Client/mods/deathmatch/logic/CNetAPI.cpp +++ b/Client/mods/deathmatch/logic/CNetAPI.cpp @@ -1547,9 +1547,15 @@ void CNetAPI::WriteVehiclePuresync(CClientPed* pPlayerModel, CClientVehicle* pVe pPlayerModel->GetControllerState(ControllerState); WriteFullKeysync(ControllerState, BitStream); + // Use parent model ID for non-standard vehicle model IDs. + // This avoids a mismatch between client and server, ensuring doors and damage sync correctly. + int iModelID = pVehicle->GetModel(); + if (iModelID < 400 || iModelID > 611) + iModelID = pVehicle->m_pModelInfo->GetParentID(); + // Write the clientside model if (BitStream.Version() >= 0x05F) - BitStream.Write((int)pVehicle->GetModel()); + BitStream.Write(iModelID); // Grab the vehicle position CVector vecPosition; From 2bda0a8db43343999583bbdb8d448ddb86a83f72 Mon Sep 17 00:00:00 2001 From: BCG2000 Date: Mon, 25 Oct 2021 13:50:44 -0200 Subject: [PATCH 3/6] Update CNetAPI.cpp --- Client/mods/deathmatch/logic/CNetAPI.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Client/mods/deathmatch/logic/CNetAPI.cpp b/Client/mods/deathmatch/logic/CNetAPI.cpp index a63d7ff553f..d88c826e659 100644 --- a/Client/mods/deathmatch/logic/CNetAPI.cpp +++ b/Client/mods/deathmatch/logic/CNetAPI.cpp @@ -1547,15 +1547,9 @@ void CNetAPI::WriteVehiclePuresync(CClientPed* pPlayerModel, CClientVehicle* pVe pPlayerModel->GetControllerState(ControllerState); WriteFullKeysync(ControllerState, BitStream); - // Use parent model ID for non-standard vehicle model IDs. - // This avoids a mismatch between client and server, ensuring doors and damage sync correctly. - int iModelID = pVehicle->GetModel(); - if (iModelID < 400 || iModelID > 611) - iModelID = pVehicle->m_pModelInfo->GetParentID(); - // Write the clientside model if (BitStream.Version() >= 0x05F) - BitStream.Write(iModelID); + BitStream.Write((int)pVehicle->GetModel()); // Grab the vehicle position CVector vecPosition; From 21c8b104195d71f85485ef77bdac3e44f78e24c3 Mon Sep 17 00:00:00 2001 From: BCG2000 Date: Mon, 25 Oct 2021 13:51:49 -0200 Subject: [PATCH 4/6] Fix door and damage sync of vehicles added with engineRequestModel() --- Client/mods/deathmatch/logic/CNetAPI.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CNetAPI.cpp b/Client/mods/deathmatch/logic/CNetAPI.cpp index d88c826e659..a63d7ff553f 100644 --- a/Client/mods/deathmatch/logic/CNetAPI.cpp +++ b/Client/mods/deathmatch/logic/CNetAPI.cpp @@ -1547,9 +1547,15 @@ void CNetAPI::WriteVehiclePuresync(CClientPed* pPlayerModel, CClientVehicle* pVe pPlayerModel->GetControllerState(ControllerState); WriteFullKeysync(ControllerState, BitStream); + // Use parent model ID for non-standard vehicle model IDs. + // This avoids a mismatch between client and server, ensuring doors and damage sync correctly. + int iModelID = pVehicle->GetModel(); + if (iModelID < 400 || iModelID > 611) + iModelID = pVehicle->m_pModelInfo->GetParentID(); + // Write the clientside model if (BitStream.Version() >= 0x05F) - BitStream.Write((int)pVehicle->GetModel()); + BitStream.Write(iModelID); // Grab the vehicle position CVector vecPosition; From 1fba2cfd4e0bfa9ec39a1613eb6b67f5f561083a Mon Sep 17 00:00:00 2001 From: BCG2000 Date: Mon, 25 Oct 2021 14:08:12 -0200 Subject: [PATCH 5/6] Update CNetAPI.cpp --- Client/mods/deathmatch/logic/CNetAPI.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Client/mods/deathmatch/logic/CNetAPI.cpp b/Client/mods/deathmatch/logic/CNetAPI.cpp index a63d7ff553f..d88c826e659 100644 --- a/Client/mods/deathmatch/logic/CNetAPI.cpp +++ b/Client/mods/deathmatch/logic/CNetAPI.cpp @@ -1547,15 +1547,9 @@ void CNetAPI::WriteVehiclePuresync(CClientPed* pPlayerModel, CClientVehicle* pVe pPlayerModel->GetControllerState(ControllerState); WriteFullKeysync(ControllerState, BitStream); - // Use parent model ID for non-standard vehicle model IDs. - // This avoids a mismatch between client and server, ensuring doors and damage sync correctly. - int iModelID = pVehicle->GetModel(); - if (iModelID < 400 || iModelID > 611) - iModelID = pVehicle->m_pModelInfo->GetParentID(); - // Write the clientside model if (BitStream.Version() >= 0x05F) - BitStream.Write(iModelID); + BitStream.Write((int)pVehicle->GetModel()); // Grab the vehicle position CVector vecPosition; From 5258f20723b41c00dda7a029b8ee3913d8382ee0 Mon Sep 17 00:00:00 2001 From: BCG2000 Date: Mon, 25 Oct 2021 14:08:55 -0200 Subject: [PATCH 6/6] Fix door and damage sync of vehicles added with engineRequestModel() --- Client/mods/deathmatch/logic/CNetAPI.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CNetAPI.cpp b/Client/mods/deathmatch/logic/CNetAPI.cpp index d88c826e659..c346cf8dfbe 100644 --- a/Client/mods/deathmatch/logic/CNetAPI.cpp +++ b/Client/mods/deathmatch/logic/CNetAPI.cpp @@ -1547,9 +1547,15 @@ void CNetAPI::WriteVehiclePuresync(CClientPed* pPlayerModel, CClientVehicle* pVe pPlayerModel->GetControllerState(ControllerState); WriteFullKeysync(ControllerState, BitStream); + // Use parent model ID for non-standard vehicle model IDs. + // This avoids a mismatch between client and server, ensuring doors and damage sync correctly. + int iModelID = pVehicle->GetModel(); + if (iModelID < 400 || iModelID > 611) + iModelID = pVehicle->GetModelInfo()->GetParentID(); + // Write the clientside model if (BitStream.Version() >= 0x05F) - BitStream.Write((int)pVehicle->GetModel()); + BitStream.Write(iModelID); // Grab the vehicle position CVector vecPosition;