fix: general issues with dismantling (#1304)

This commit is contained in:
David Markowitz 2023-11-17 23:15:47 -08:00 committed by GitHub
parent 98822d400f
commit 57e3a4f4ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -410,12 +410,19 @@ void Item::DisassembleModel(uint32_t numToDismantle) {
}
std::string renderAsset = std::string(result.getStringField(0));
// normalize path slashes
for (auto& c : renderAsset) {
if (c == '\\') c = '/';
}
std::string lxfmlFolderName = std::string(result.getStringField(1));
if (!lxfmlFolderName.empty()) lxfmlFolderName.insert(0, "/");
std::vector<std::string> renderAssetSplit = GeneralUtils::SplitString(renderAsset, '\\');
if (renderAssetSplit.size() == 0) return;
std::vector<std::string> renderAssetSplit = GeneralUtils::SplitString(renderAsset, '/');
if (renderAssetSplit.empty()) return;
std::string lxfmlPath = "BrickModels/" + lxfmlFolderName + "/" + GeneralUtils::SplitString(renderAssetSplit.back(), '.').at(0) + ".lxfml";
std::string lxfmlPath = "BrickModels" + lxfmlFolderName + "/" + GeneralUtils::SplitString(renderAssetSplit.back(), '.').at(0) + ".lxfml";
auto buffer = Game::assetManager->GetFileAsBuffer(lxfmlPath.c_str());
if (!buffer.m_Success) {
@ -461,8 +468,8 @@ void Item::DisassembleModel(uint32_t numToDismantle) {
auto* model = scene->FirstChildElement("Model");
if (!model) return;
auto* group = model->FirstChildElement("Group");
if (!group) return;
bricks = model->FirstChildElement("Group");
if (!bricks) return;
}
auto* currentBrick = bricks->FirstChildElement(searchTerm.c_str());