Fix Complete Overhaul (#934)

Check your pointers :)
This commit is contained in:
David Markowitz 2022-12-31 11:44:09 -08:00 committed by GitHub
parent 737eaba54d
commit 09157506bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -28,6 +28,7 @@
#include "GameConfig.h"
#include "RocketLaunchLupComponent.h"
#include "eUnequippableActiveType.h"
#include "RacingTaskParam.h"
#include <sstream>
#include <future>
@ -5482,7 +5483,8 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
auto* temp = inv->GetInventory(TEMP_MODELS);
std::vector<LOT> modList;
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) {
std::u16string modules;
@ -5490,7 +5492,8 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
uint32_t mod;
inStream->Read(mod);
modList.push_back(mod);
modules += u"1:" + (GeneralUtils::to_u16string(mod));
auto modToStr = GeneralUtils::to_u16string(mod);
modules += u"1:" + (modToStr);
if (k + 1 != count) modules += u"+";
if (temp->GetLotCount(mod) > 0) {
@ -5498,6 +5501,13 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
} else {
inv->RemoveItem(mod, 1);
}
// 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) {
if (oldPartList.find(GeneralUtils::UTF16ToWTF8(modToStr)) != std::string::npos) everyPieceSwapped = false;
}
}
const auto moduleAssembly = new LDFData<std::u16string>(u"assemblyPartLOTs", modules);
@ -5516,6 +5526,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) {
if (missionComponent != nullptr) {
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, entity->GetLOT(), entity->GetObjectID());
if (count >= 7 && everyPieceSwapped) missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, LWOOBJID_EMPTY, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_MODULAR_BUILDING);
}
}
}

View File

@ -347,6 +347,15 @@ void Item::Disassemble(const eInventoryType inventoryType) {
if (data->GetKey() == u"assemblyPartLOTs") {
auto modStr = data->GetValueAsString();
// This shouldn't be null but always check your pointers.
if (GetInventory()) {
auto inventoryComponent = GetInventory()->GetComponent();
if (inventoryComponent) {
auto entity = inventoryComponent->GetParent();
if (entity) entity->SetVar<std::string>(u"currentModifiedBuild", modStr);
}
}
std::vector<LOT> modArray;
std::stringstream ssData(modStr);