refactor: modular build items and root part come from ModularBuildComponent

ModularBuildFinish hardcoded the item a finished build becomes (6416 for 3 parts, 8092 for 7) and the car chassis part (8129) that the every-part-swapped check skips. They now come from ModularBuildComponent: createdLOT, <numberOfParts> and the <ExamplePartLOT> of the <rootPart> module (new CDModularBuildComponentTable). Same results with the 1.10.64 cdclient; tests cover the xml parsing and the lookup.

Refs issue 691

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-16 20:50:12 -05:00
parent fc6a7fbd52
commit 7968dd0fb5
7 changed files with 155 additions and 6 deletions

View File

@@ -52,6 +52,7 @@
//CDB includes:
#include "CDClientManager.h"
#include "CDModularBuildComponentTable.h"
#include "CDEmoteTable.h"
//Component includes:
@@ -5474,6 +5475,8 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream& inStream, Entity*
auto* temp = inv->GetInventory(TEMP_MODELS);
std::vector<LOT> modList;
// The build this many parts make (3: a rocket, 7: a car), from ModularBuildComponent
const auto build = CDClientManager::GetTable<CDModularBuildComponentTable>()->GetByNumberOfParts(static_cast<uint32_t>(count));
auto& oldPartList = character->GetVar<std::string>(u"currentModifiedBuild");
bool everyPieceSwapped = !oldPartList.empty(); // If the player didn't put a build in initially, then they should not get this achievement.
if (count >= 3 && count < 8) {
@@ -5502,8 +5505,8 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream& inStream, Entity*
}
// Doing this check for 1 singular mission that needs to know when you've swapped every part out during a car modular build.
// since all 8129's are the same, skip checking that
if (mod != 8129) {
// Every build has the same root part (the car's chassis), so it is not checked
if (!build || mod != build->rootPartExampleLOT) {
if (oldPartList.find(GeneralUtils::UTF16ToWTF8(modToStr)) != std::string::npos) everyPieceSwapped = false;
}
@@ -5521,10 +5524,8 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream& inStream, Entity*
LWOOBJID newID = ObjectIDManager::GetPersistentID();
if (count == 3) {
inv->AddItem(6416, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newID);
} else if (count == 7) {
inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newID);
if (build) {
inv->AddItem(build->createdLOT, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newID);
}
auto* pCharacter = character->GetCharacter();