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

@ -294,13 +294,13 @@ void Item::UseNonEquip(Item* item) {
const auto type = static_cast<eItemType>(info->itemType); const auto type = static_cast<eItemType>(info->itemType);
if (type == eItemType::MOUNT) { if (type == eItemType::MOUNT) {
if (Game::zoneManager->GetMountsAllowed()){ if (Game::zoneManager->GetMountsAllowed()) {
playerInventoryComponent->HandlePossession(this); playerInventoryComponent->HandlePossession(this);
} else { } else {
ChatPackets::SendSystemMessage(playerEntity->GetSystemAddress(), u"Mounts are not allowed in this zone"); ChatPackets::SendSystemMessage(playerEntity->GetSystemAddress(), u"Mounts are not allowed in this zone");
} }
} else if (type == eItemType::PET_INVENTORY_ITEM && subKey != LWOOBJID_EMPTY ) { } else if (type == eItemType::PET_INVENTORY_ITEM && subKey != LWOOBJID_EMPTY) {
if (Game::zoneManager->GetPetsAllowed()){ if (Game::zoneManager->GetPetsAllowed()) {
const auto& databasePet = playerInventoryComponent->GetDatabasePet(subKey); const auto& databasePet = playerInventoryComponent->GetDatabasePet(subKey);
if (databasePet.lot != LOT_NULL) { if (databasePet.lot != LOT_NULL) {
playerInventoryComponent->SpawnPet(this); playerInventoryComponent->SpawnPet(this);
@ -410,12 +410,19 @@ void Item::DisassembleModel(uint32_t numToDismantle) {
} }
std::string renderAsset = std::string(result.getStringField(0)); 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)); std::string lxfmlFolderName = std::string(result.getStringField(1));
if (!lxfmlFolderName.empty()) lxfmlFolderName.insert(0, "/");
std::vector<std::string> renderAssetSplit = GeneralUtils::SplitString(renderAsset, '\\'); std::vector<std::string> renderAssetSplit = GeneralUtils::SplitString(renderAsset, '/');
if (renderAssetSplit.size() == 0) return; 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()); auto buffer = Game::assetManager->GetFileAsBuffer(lxfmlPath.c_str());
if (!buffer.m_Success) { if (!buffer.m_Success) {
@ -461,8 +468,8 @@ void Item::DisassembleModel(uint32_t numToDismantle) {
auto* model = scene->FirstChildElement("Model"); auto* model = scene->FirstChildElement("Model");
if (!model) return; if (!model) return;
auto* group = model->FirstChildElement("Group"); bricks = model->FirstChildElement("Group");
if (!group) return; if (!bricks) return;
} }
auto* currentBrick = bricks->FirstChildElement(searchTerm.c_str()); auto* currentBrick = bricks->FirstChildElement(searchTerm.c_str());
@ -486,7 +493,7 @@ void Item::DisassembleModel(uint32_t numToDismantle) {
auto* brickIDTable = CDClientManager::Instance().GetTable<CDBrickIDTableTable>(); auto* brickIDTable = CDClientManager::Instance().GetTable<CDBrickIDTableTable>();
// Second iteration actually distributes the bricks // Second iteration actually distributes the bricks
for (const auto&[part, count] : parts) { for (const auto& [part, count] : parts) {
const auto partLocal = part; const auto partLocal = part;
const auto brickID = brickIDTable->Query([&](const CDBrickIDTable& entry) { const auto brickID = brickIDTable->Query([&](const CDBrickIDTable& entry) {
return entry.LEGOBrickID == partLocal; return entry.LEGOBrickID == partLocal;