mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 15:07:28 +00:00
Add checks to AssetBuffers before they are used (#820)
* add checks to buffers before they are used to avoid crashing * address feedback
This commit is contained in:
parent
7c2437173b
commit
1eff3ae454
@ -344,6 +344,11 @@ void Item::DisassembleModel() {
|
||||
std::string lxfmlPath = "BrickModels/" + GeneralUtils::SplitString(renderAssetSplit.back(), '.').at(0) + ".lxfml";
|
||||
auto buffer = Game::assetManager->GetFileAsBuffer(lxfmlPath.c_str());
|
||||
|
||||
if (!buffer.m_Success) {
|
||||
Game::logger->Log("Item", "Failed to load %s to disassemble model into bricks, check that this file exists", lxfmlPath.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
std::istream file(&buffer);
|
||||
|
||||
result.finalize();
|
||||
|
@ -19,6 +19,11 @@ std::vector<Brick>& BrickDatabase::GetBricks(const std::string& lxfmlPath) {
|
||||
}
|
||||
|
||||
AssetMemoryBuffer buffer = Game::assetManager->GetFileAsBuffer((lxfmlPath).c_str());
|
||||
|
||||
if (!buffer.m_Success) {
|
||||
return emptyCache;
|
||||
}
|
||||
|
||||
std::istream file(&buffer);
|
||||
if (!file.good()) {
|
||||
return emptyCache;
|
||||
|
@ -584,6 +584,12 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (args[0].find("\\") != std::string::npos) return;
|
||||
|
||||
auto buf = Game::assetManager->GetFileAsBuffer(("macros/" + args[0] + ".scm").c_str());
|
||||
|
||||
if (!buf.m_Success){
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Unknown macro! Is the filename right?");
|
||||
return;
|
||||
}
|
||||
|
||||
std::istream infile(&buf);
|
||||
|
||||
if (infile.good()) {
|
||||
|
@ -42,6 +42,12 @@ void Zone::LoadZoneIntoMemory() {
|
||||
if (m_ZoneFilePath == "ERR") return;
|
||||
|
||||
AssetMemoryBuffer buffer = Game::assetManager->GetFileAsBuffer(m_ZoneFilePath.c_str());
|
||||
|
||||
if (!buffer.m_Success) {
|
||||
Game::logger->Log("Zone", "Failed to load %s", m_ZoneFilePath.c_str());
|
||||
throw std::runtime_error("Aborting Zone loading due to no Zone File.");
|
||||
}
|
||||
|
||||
std::istream file(&buffer);
|
||||
if (file) {
|
||||
BinaryIO::BinaryRead(file, m_ZoneFileFormatVersion);
|
||||
@ -265,7 +271,10 @@ std::vector<LUTriggers::Trigger*> Zone::LoadLUTriggers(std::string triggerFile,
|
||||
|
||||
auto buffer = Game::assetManager->GetFileAsBuffer((m_ZonePath + triggerFile).c_str());
|
||||
|
||||
if (!buffer.m_Success) return lvlTriggers;
|
||||
if (!buffer.m_Success) {
|
||||
Game::logger->Log("Zone", "Failed to load %s from disk. Skipping loading triggers", (m_ZonePath + triggerFile).c_str());
|
||||
return lvlTriggers;
|
||||
}
|
||||
|
||||
std::istream file(&buffer);
|
||||
std::stringstream data;
|
||||
|
Loading…
Reference in New Issue
Block a user