Отлавливание ошибок
This commit is contained in:
@@ -84,7 +84,11 @@ Vulkan::Vulkan(asio::io_context &ioc)
|
|||||||
|
|
||||||
Game.MainThread = std::thread([&]() {
|
Game.MainThread = std::thread([&]() {
|
||||||
auto useLock = Game.UseLock.lock();
|
auto useLock = Game.UseLock.lock();
|
||||||
run();
|
try {
|
||||||
|
run();
|
||||||
|
} catch(const std::exception &exc) {
|
||||||
|
LOG.error() << "Vulkan::run: " << exc.what();
|
||||||
|
}
|
||||||
GuardLock.reset();
|
GuardLock.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -138,16 +142,31 @@ void Vulkan::run()
|
|||||||
if(!NeedShutdown && glfwWindowShouldClose(Graphics.Window)) {
|
if(!NeedShutdown && glfwWindowShouldClose(Graphics.Window)) {
|
||||||
NeedShutdown = true;
|
NeedShutdown = true;
|
||||||
|
|
||||||
if(Game.Session)
|
try {
|
||||||
Game.Session->shutdown(EnumDisconnect::ByInterface);
|
if(Game.Session)
|
||||||
|
Game.Session->shutdown(EnumDisconnect::ByInterface);
|
||||||
if(Game.Server) {
|
} catch(const std::exception &exc) {
|
||||||
Game.Server->GS.shutdown("Завершение работы из-за остановки клиента");
|
LOG.error() << "Game.Session->shutdown: " << exc.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.RSession = nullptr;
|
try {
|
||||||
Game.Session = nullptr;
|
if(Game.Server)
|
||||||
Game.Server = nullptr;
|
Game.Server->GS.shutdown("Завершение работы из-за остановки клиента");
|
||||||
|
} catch(const std::exception &exc) {
|
||||||
|
LOG.error() << "Game.Server->GS.shutdown: " << exc.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
try { Game.RSession = nullptr; } catch(const std::exception &exc) {
|
||||||
|
LOG.error() << "Game.RSession = nullptr: " << exc.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
try { Game.Session = nullptr; } catch(const std::exception &exc) {
|
||||||
|
LOG.error() << "Game.Session = nullptr: " << exc.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
try { Game.Server = nullptr; } catch(const std::exception &exc) {
|
||||||
|
LOG.error() << "Game.Server = nullptr: " << exc.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Game.Session) {
|
if(Game.Session) {
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ class Buffer;
|
|||||||
|
|
||||||
class Vulkan : public AsyncObject {
|
class Vulkan : public AsyncObject {
|
||||||
private:
|
private:
|
||||||
|
Logger LOG = "Vulkan";
|
||||||
|
|
||||||
struct vkInstanceLayer {
|
struct vkInstanceLayer {
|
||||||
std::string LayerName = "nullptr", Description = "nullptr";
|
std::string LayerName = "nullptr", Description = "nullptr";
|
||||||
uint32_t SpecVersion = -2, ImplementationVersion = -2;
|
uint32_t SpecVersion = -2, ImplementationVersion = -2;
|
||||||
@@ -351,7 +353,6 @@ public:
|
|||||||
return std::this_thread::get_id() == Graphics.ThisThread;
|
return std::this_thread::get_id() == Graphics.ThisThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown() { NeedShutdown = true; }
|
|
||||||
void addImGUIFont(std::string_view view);
|
void addImGUIFont(std::string_view view);
|
||||||
|
|
||||||
void gui_MainMenu();
|
void gui_MainMenu();
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ coro<void> Server::run() {
|
|||||||
// TODO: std::cout << exc.what() << std::endl;
|
// TODO: std::cout << exc.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Lock.cancel();
|
||||||
IsAlive.store(false);
|
IsAlive.store(false);
|
||||||
IsAlive.notify_all();
|
IsAlive.notify_all();
|
||||||
Lock.cancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ void RemoteClient::shutdown(EnumDisconnect type, const std::string reason) {
|
|||||||
void RemoteClient::prepareChunkUpdate_Voxels(WorldId_t worldId, Pos::GlobalChunk chunkPos,
|
void RemoteClient::prepareChunkUpdate_Voxels(WorldId_t worldId, Pos::GlobalChunk chunkPos,
|
||||||
const std::vector<VoxelCube> &voxels)
|
const std::vector<VoxelCube> &voxels)
|
||||||
{
|
{
|
||||||
WorldId_c wcId = ResRemap.Worlds.toClient(worldId);
|
WorldId_c wcId = worldId ? ResRemap.Worlds.toClient(worldId) : 0;
|
||||||
assert(wcId != WorldId_c(-1));
|
assert(wcId != WorldId_c(-1)); // Пока ожидается, что игрок не будет одновременно наблюдать 256 миров
|
||||||
|
|
||||||
// Перебиндить идентификаторы вокселей
|
// Перебиндить идентификаторы вокселей
|
||||||
std::vector<DefVoxelId_t> NeedVoxels;
|
std::vector<DefVoxelId_t> NeedVoxels;
|
||||||
|
|||||||
Reference in New Issue
Block a user