Skip to content

Commit

Permalink
fix: general issues with dismantling
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC committed Nov 18, 2023
1 parent 7f623d3 commit 109f27e
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions dGame/dInventory/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,13 @@ void Item::UseNonEquip(Item* item) {

const auto type = static_cast<eItemType>(info->itemType);
if (type == eItemType::MOUNT) {
if (Game::zoneManager->GetMountsAllowed()){
if (Game::zoneManager->GetMountsAllowed()) {
playerInventoryComponent->HandlePossession(this);
} else {
ChatPackets::SendSystemMessage(playerEntity->GetSystemAddress(), u"Mounts are not allowed in this zone");
}
} else if (type == eItemType::PET_INVENTORY_ITEM && subKey != LWOOBJID_EMPTY ) {
if (Game::zoneManager->GetPetsAllowed()){
} else if (type == eItemType::PET_INVENTORY_ITEM && subKey != LWOOBJID_EMPTY) {
if (Game::zoneManager->GetPetsAllowed()) {
const auto& databasePet = playerInventoryComponent->GetDatabasePet(subKey);
if (databasePet.lot != LOT_NULL) {
playerInventoryComponent->SpawnPet(this);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand All @@ -486,7 +493,7 @@ void Item::DisassembleModel(uint32_t numToDismantle) {
auto* brickIDTable = CDClientManager::Instance().GetTable<CDBrickIDTableTable>();

// Second iteration actually distributes the bricks
for (const auto&[part, count] : parts) {
for (const auto& [part, count] : parts) {
const auto partLocal = part;
const auto brickID = brickIDTable->Query([&](const CDBrickIDTable& entry) {
return entry.LEGOBrickID == partLocal;
Expand Down

0 comments on commit 109f27e

Please sign in to comment.