From 1d5c71eb9b839048be0380d265eb2e045c879166 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 5 Nov 2022 17:09:26 -0700 Subject: [PATCH 1/2] Fix Pet Taming causing seg fault (#818) * Fix Pet Taming * Fix Pet Taming * fix pet taming path loading just make it go to build file since the asset managet handles intermediate steps there is never res in the path in the live db, so no need to check * special case BrickModels to uppercase if unpacked remove redundent variable Co-authored-by: Aaron Kimbrell --- dCommon/dClient/AssetManager.cpp | 14 +++++++++----- dGame/dComponents/PetComponent.cpp | 16 +--------------- dGame/dUtilities/BrickDatabase.cpp | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/dCommon/dClient/AssetManager.cpp b/dCommon/dClient/AssetManager.cpp index 2b6f84e3..0cb2db31 100644 --- a/dCommon/dClient/AssetManager.cpp +++ b/dCommon/dClient/AssetManager.cpp @@ -67,6 +67,8 @@ bool AssetManager::HasFile(const char* name) { auto fixedName = std::string(name); std::transform(fixedName.begin(), fixedName.end(), fixedName.begin(), [](uint8_t c) { return std::tolower(c); }); + // Special case for unpacked client have BrickModels in upper case + if (this->m_AssetBundleType == eAssetBundleType::Unpacked) GeneralUtils::ReplaceInString(fixedName, "brickmodels", "BrickModels"); std::replace(fixedName.begin(), fixedName.end(), '\\', '/'); if (std::filesystem::exists(m_ResPath / fixedName)) return true; @@ -92,17 +94,19 @@ bool AssetManager::GetFile(const char* name, char** data, uint32_t* len) { auto fixedName = std::string(name); std::transform(fixedName.begin(), fixedName.end(), fixedName.begin(), [](uint8_t c) { return std::tolower(c); }); std::replace(fixedName.begin(), fixedName.end(), '\\', '/'); // On the off chance someone has the wrong slashes, force forward slashes - auto realPathName = fixedName; - if (std::filesystem::exists(m_ResPath / realPathName)) { + // Special case for unpacked client have BrickModels in upper case + if (this->m_AssetBundleType == eAssetBundleType::Unpacked) GeneralUtils::ReplaceInString(fixedName, "brickmodels", "BrickModels"); + + if (std::filesystem::exists(m_ResPath / fixedName)) { FILE* file; #ifdef _WIN32 - fopen_s(&file, (m_ResPath / realPathName).string().c_str(), "rb"); + fopen_s(&file, (m_ResPath / fixedName).string().c_str(), "rb"); #elif __APPLE__ // macOS has 64bit file IO by default - file = fopen((m_ResPath / realPathName).string().c_str(), "rb"); + file = fopen((m_ResPath / fixedName).string().c_str(), "rb"); #else - file = fopen64((m_ResPath / realPathName).string().c_str(), "rb"); + file = fopen64((m_ResPath / fixedName).string().c_str(), "rb"); #endif fseek(file, 0, SEEK_END); *len = ftell(file); diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 8863f9be..0b136a5c 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -194,21 +194,7 @@ void PetComponent::OnUse(Entity* originator) { return; } - auto lxfAsset = std::string(result.getStringField(0)); - - std::vector lxfAssetSplit = GeneralUtils::SplitString(lxfAsset, '\\'); - - lxfAssetSplit.erase(lxfAssetSplit.begin()); - - buildFile = "res/BrickModels"; - - for (auto part : lxfAssetSplit) { - std::transform(part.begin(), part.end(), part.begin(), [](unsigned char c) { - return std::tolower(c); - }); - - buildFile += "/" + part; - } + buildFile = std::string(result.getStringField(0)); PetPuzzleData data; data.buildFile = buildFile; diff --git a/dGame/dUtilities/BrickDatabase.cpp b/dGame/dUtilities/BrickDatabase.cpp index 4e873278..c36a1097 100644 --- a/dGame/dUtilities/BrickDatabase.cpp +++ b/dGame/dUtilities/BrickDatabase.cpp @@ -18,7 +18,7 @@ std::vector& BrickDatabase::GetBricks(const std::string& lxfmlPath) { return cached->second; } - AssetMemoryBuffer buffer = Game::assetManager->GetFileAsBuffer(("client/" + lxfmlPath).c_str()); + AssetMemoryBuffer buffer = Game::assetManager->GetFileAsBuffer((lxfmlPath).c_str()); std::istream file(&buffer); if (!file.good()) { return emptyCache; From 9c58ea5c415bf64d7972fc5408d8ef4e554185e9 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Sat, 5 Nov 2022 19:09:39 -0500 Subject: [PATCH 2/2] add 1261 to the disable landing animation switch case (#819) --- dGame/dComponents/CharacterComponent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index d425c066..424be0ac 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -47,6 +47,7 @@ bool CharacterComponent::LandingAnimDisabled(int zoneID) { case 1202: case 1203: case 1204: + case 1261: case 1301: case 1302: case 1303: