Skip to content

Commit

Permalink
add a try catch for loading worlds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kade-github committed May 23, 2024
1 parent 29d83f9 commit e3f3736
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/Game/WorldManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,25 @@ std::vector<Data::World> WorldManager::GetWorlds()

zstr::ifstream is_p(path + "/world.frim", std::ios::binary);

std::stringstream buffer;
try {
std::stringstream buffer;

buffer << is_p.rdbuf();
buffer << is_p.rdbuf();

msgpack::unpacked upd = msgpack::unpack(buffer.str().data(), buffer.str().size());
msgpack::unpacked upd = msgpack::unpack(buffer.str().data(), buffer.str().size());

is_p.close();
is_p.close();

upd.get().convert(_world);
upd.get().convert(_world);

_world._path = path;
_world._path = path;

worlds.push_back(_world);
worlds.push_back(_world);
}
catch (const std::exception& e)
{
Game::instance->log->Write("Error loading world: " + path + " - " + e.what());
}
}
}

Expand Down

0 comments on commit e3f3736

Please sign in to comment.