From e8e3667fa9c9ab6d7ac82733464951099b617abd Mon Sep 17 00:00:00 2001 From: DrSocalkwe3n Date: Wed, 20 Aug 2025 12:00:25 +0600 Subject: [PATCH] * --- Src/Client/Abstract.hpp | 3 +++ Src/Client/ServerSession.cpp | 30 +++++++++++++++--------------- Src/Client/Vulkan/Vulkan.cpp | 18 +++++++++++++++--- Src/Common/Abstract.hpp | 1 + Src/Server/AssetsManager.hpp | 2 +- Src/Server/GameServer.cpp | 28 ++++++++++++++++------------ 6 files changed, 51 insertions(+), 31 deletions(-) diff --git a/Src/Client/Abstract.hpp b/Src/Client/Abstract.hpp index 0ecba78..a8c0f36 100644 --- a/Src/Client/Abstract.hpp +++ b/Src/Client/Abstract.hpp @@ -131,6 +131,9 @@ struct DefItemInfo { }; +struct DefVoxel_t {}; +struct DefNode_t {}; + /* Интерфейс обработчика сессии с сервером */ class IServerSession { struct ArrayHasher { diff --git a/Src/Client/ServerSession.cpp b/Src/Client/ServerSession.cpp index a2c3931..57729ef 100644 --- a/Src/Client/ServerSession.cpp +++ b/Src/Client/ServerSession.cpp @@ -622,24 +622,24 @@ coro<> ServerSession::rP_Definition(Net::AsyncSocket &sock) { } case ToClient::L2Definition::Node: { - DefNodeId id; - DefNode_t def; - id = co_await sock.read(); - def.DrawType = (DefNode_t::EnumDrawType) co_await sock.read(); - for(int iter = 0; iter < 6; iter++) { - auto &pl = def.Texs[iter].Pipeline; - pl.resize(co_await sock.read()); - co_await sock.read((std::byte*) pl.data(), pl.size()); - } + // DefNodeId id; + // DefNode_t def; + // id = co_await sock.read(); + // def.DrawType = (DefNode_t::EnumDrawType) co_await sock.read(); + // for(int iter = 0; iter < 6; iter++) { + // auto &pl = def.Texs[iter].Pipeline; + // pl.resize(co_await sock.read()); + // co_await sock.read((std::byte*) pl.data(), pl.size()); + // } - PP_Definition_Node *packet = new PP_Definition_Node( - id, - def - ); + // PP_Definition_Node *packet = new PP_Definition_Node( + // id, + // def + // ); - while(!NetInputPackets.push(packet)); + // while(!NetInputPackets.push(packet)); - co_return; + // co_return; } case ToClient::L2Definition::FreeNode: { diff --git a/Src/Client/Vulkan/Vulkan.cpp b/Src/Client/Vulkan/Vulkan.cpp index 6bcbdab..cf61873 100644 --- a/Src/Client/Vulkan/Vulkan.cpp +++ b/Src/Client/Vulkan/Vulkan.cpp @@ -2231,12 +2231,24 @@ void Vulkan::gui_ConnectedToServer() { std::string text = std::to_string(ImGui::GetIO().Framerate); ImGui::Text(text.c_str()); if(ImGui::Button("Выйти")) { - Game.RSession->pushStage(EnumRenderStage::Shutdown); - Game.Session->shutdown(EnumDisconnect::ByInterface); + try { + if(Game.Session) + Game.Session->shutdown(EnumDisconnect::ByInterface); + } catch(const std::exception &exc) { + LOG.error() << "Game.Session->shutdown: " << exc.what(); + } + Game.RSession = nullptr; - Game.Session = nullptr; + Game.ImGuiInterfaces.pop_back(); + int mode = glfwGetInputMode(Graphics.Window, GLFW_CURSOR); + if(mode != GLFW_CURSOR_NORMAL) + glfwSetInputMode(Graphics.Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } + ImGui::End(); + + if(!Game.RSession) + return; } if(Game.Session->isConnected()) diff --git a/Src/Common/Abstract.hpp b/Src/Common/Abstract.hpp index 0266eb1..2a435ca 100644 --- a/Src/Common/Abstract.hpp +++ b/Src/Common/Abstract.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace LV { diff --git a/Src/Server/AssetsManager.hpp b/Src/Server/AssetsManager.hpp index df9668d..9b5aba5 100644 --- a/Src/Server/AssetsManager.hpp +++ b/Src/Server/AssetsManager.hpp @@ -93,7 +93,7 @@ private: std::vector>> Table[(int) EnumAssets::MAX_ENUM]; // Распаршенные ресурсы, для использования сервером - std::vector>> Table_NodeState; + // std::vector>> Table_NodeState; std::vector>> Table_Model; // Связь домены -> {ключ -> идентификатор} diff --git a/Src/Server/GameServer.cpp b/Src/Server/GameServer.cpp index 27a0923..cc4a6fd 100644 --- a/Src/Server/GameServer.cpp +++ b/Src/Server/GameServer.cpp @@ -1651,12 +1651,12 @@ void GameServer::initLuaPre() { Content.CM.registerBase(type, CurrentModId, *result[2], profile); }; - core.set_function("register_voxel", [&](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Voxel, key, profile); }); - core.set_function("register_node", [&](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Node, key, profile); }); - core.set_function("register_world", [&](const std::string& key, const sol::table& profile) { reg(EnumDefContent::World, key, profile); }); - core.set_function("register_portal", [&](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Portal, key, profile); }); - core.set_function("register_entity", [&](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Entity, key, profile); }); - core.set_function("register_item", [&](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Item, key, profile); }); + core.set_function("register_voxel", [reg](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Voxel, key, profile); }); + core.set_function("register_node", [reg](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Node, key, profile); }); + core.set_function("register_world", [reg](const std::string& key, const sol::table& profile) { reg(EnumDefContent::World, key, profile); }); + core.set_function("register_portal", [reg](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Portal, key, profile); }); + core.set_function("register_entity", [reg](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Entity, key, profile); }); + core.set_function("register_item", [reg](const std::string& key, const sol::table& profile) { reg(EnumDefContent::Item, key, profile); }); } void GameServer::initLua() { @@ -2364,9 +2364,11 @@ void GameServer::stepSyncContent() { Pos::bvec4u cPos = (node >> 4) & 0x3; Pos::bvec16u nPos = node & 0xf; - auto ®ion = Expanse.Worlds[0]->Regions[rPos]; - region->Nodes[cPos.pack()][nPos.pack()].NodeId = 4; - region->IsChunkChanged_Nodes |= 1ull << cPos.pack(); + auto region = Expanse.Worlds[0]->Regions.find(rPos); + if(region != Expanse.Worlds[0]->Regions.end()) { + region->second->Nodes[cPos.pack()][nPos.pack()].NodeId = 4; + region->second->IsChunkChanged_Nodes |= 1ull << cPos.pack(); + } } while(!remoteClient->Break.empty()) { @@ -2377,9 +2379,11 @@ void GameServer::stepSyncContent() { Pos::bvec4u cPos = (node >> 4) & 0x3; Pos::bvec16u nPos = node & 0xf; - auto ®ion = Expanse.Worlds[0]->Regions[rPos]; - region->Nodes[cPos.pack()][nPos.pack()].NodeId = 0; - region->IsChunkChanged_Nodes |= 1ull << cPos.pack(); + auto region = Expanse.Worlds[0]->Regions.find(rPos); + if(region != Expanse.Worlds[0]->Regions.end()) { + region->second->Nodes[cPos.pack()][nPos.pack()].NodeId = 0; + region->second->IsChunkChanged_Nodes |= 1ull << cPos.pack(); + } } }