Подгонка
This commit is contained in:
@@ -131,6 +131,7 @@ coro<std::unique_ptr<Net::AsyncSocket>> ServerSession::asyncInitGameProtocol(asi
|
||||
|
||||
void ServerSession::shutdown(EnumDisconnect type) {
|
||||
IsGoingShutdown = true;
|
||||
Socket->closeRead();
|
||||
Net::Packet packet;
|
||||
packet << (uint8_t) ToServer::L1::System
|
||||
<< (uint8_t) ToServer::L2System::Disconnect
|
||||
@@ -206,11 +207,11 @@ coro<> ServerSession::run() {
|
||||
co_await readPacket(*Socket);
|
||||
}
|
||||
} catch(const std::exception &exc) {
|
||||
if(const auto *errc = dynamic_cast<const boost::system::system_error*>(&exc);
|
||||
errc && errc->code() == boost::asio::error::operation_aborted)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
// if(const auto *errc = dynamic_cast<const boost::system::system_error*>(&exc);
|
||||
// errc && errc->code() == boost::asio::error::operation_aborted)
|
||||
// {
|
||||
// co_return;
|
||||
// }
|
||||
|
||||
TOS::Logger("ServerSession").warn() << exc.what();
|
||||
}
|
||||
@@ -387,7 +388,7 @@ coro<> ServerSession::rP_Content(Net::AsyncSocket &sock) {
|
||||
cube.Right.Z = co_await sock.read<uint8_t>();
|
||||
}
|
||||
|
||||
auto packet = std::make_unique<PP_Content_ChunkVoxels>(
|
||||
PP_Content_ChunkVoxels *packet = new PP_Content_ChunkVoxels(
|
||||
ToClient::L1::Content,
|
||||
(uint8_t) ToClient::L2Content::ChunkVoxels,
|
||||
wcId,
|
||||
@@ -395,7 +396,7 @@ coro<> ServerSession::rP_Content(Net::AsyncSocket &sock) {
|
||||
std::move(cubes)
|
||||
);
|
||||
|
||||
while(!NetInputPackets.push(std::move(packet)));
|
||||
while(!NetInputPackets.push(packet));
|
||||
|
||||
LOG.info() << "Приняты воксели чанка " << int(wcId) << " / " << pos.X << ":" << pos.Y << ":" << pos.Z << " Вокселей " << cubes.size();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class ServerSession : public AsyncObject, public IServerSession, public ISurface
|
||||
glm::quat Quat;
|
||||
} Camera;
|
||||
|
||||
boost::lockfree::spsc_queue<std::unique_ptr<ParsedPacket>> NetInputPackets;
|
||||
boost::lockfree::spsc_queue<ParsedPacket*> NetInputPackets;
|
||||
|
||||
//
|
||||
glm::vec3 PYR = glm::vec3(0), PYR_Offset = glm::vec3(0);
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
void shutdown(EnumDisconnect type);
|
||||
|
||||
bool isConnected() {
|
||||
return IsConnected;
|
||||
return Socket->isAlive() && IsConnected;
|
||||
}
|
||||
|
||||
void waitShutdown() {
|
||||
|
||||
@@ -80,7 +80,6 @@ Vulkan::Vulkan(asio::io_context &ioc)
|
||||
getSettingsNext() = getBestSettings();
|
||||
reInit();
|
||||
|
||||
addImGUIFont(LV::getResource("default.ttf")->makeView());
|
||||
Game.ImGuiInterfaces.push_back(&Vulkan::gui_MainMenu);
|
||||
|
||||
Game.MainThread = std::thread([&]() {
|
||||
@@ -93,6 +92,7 @@ Vulkan::Vulkan(asio::io_context &ioc)
|
||||
Vulkan::~Vulkan()
|
||||
{
|
||||
Game.UseLock.wait_no_use();
|
||||
Game.MainThread.join();
|
||||
|
||||
for(std::shared_ptr<IVulkanDependent> dependent : ROS_Dependents)
|
||||
dependent->free(this);
|
||||
@@ -105,8 +105,6 @@ Vulkan::~Vulkan()
|
||||
glfwDestroyWindow(Graphics.Window);
|
||||
Graphics.Window = nullptr;
|
||||
}
|
||||
|
||||
Game.MainThread.join();
|
||||
}
|
||||
|
||||
void Vulkan::run()
|
||||
@@ -122,9 +120,7 @@ void Vulkan::run()
|
||||
|
||||
|
||||
double prevTime = glfwGetTime();
|
||||
while(!NeedShutdown
|
||||
|| (Game.Session && Game.Session->isConnected())
|
||||
|| (Game.Server && Game.Server->GS.isAlive()))
|
||||
while(!NeedShutdown)
|
||||
{
|
||||
float dTime = glfwGetTime()-prevTime;
|
||||
prevTime = glfwGetTime();
|
||||
@@ -142,13 +138,16 @@ void Vulkan::run()
|
||||
if(!NeedShutdown && glfwWindowShouldClose(Graphics.Window)) {
|
||||
NeedShutdown = true;
|
||||
|
||||
if(Game.Session) {
|
||||
if(Game.Session)
|
||||
Game.Session->shutdown(EnumDisconnect::ByInterface);
|
||||
}
|
||||
|
||||
if(Game.Server) {
|
||||
Game.Server->GS.shutdown("Завершение работы из-за остановки клиента");
|
||||
}
|
||||
|
||||
Game.RSession = nullptr;
|
||||
Game.Session = nullptr;
|
||||
Game.Server = nullptr;
|
||||
}
|
||||
|
||||
if(Game.Session) {
|
||||
@@ -428,12 +427,6 @@ void Vulkan::run()
|
||||
|
||||
vkDestroySemaphore(Graphics.Device, SemaphoreImageAcquired, nullptr);
|
||||
vkDestroySemaphore(Graphics.Device, SemaphoreDrawComplete, nullptr);
|
||||
|
||||
Graphics.ThisThread = std::thread::id();
|
||||
|
||||
Game.Session = nullptr;
|
||||
Game.RSession = nullptr;
|
||||
Game.Server = nullptr;
|
||||
}
|
||||
|
||||
void Vulkan::glfwCallbackError(int error, const char *description)
|
||||
@@ -1856,6 +1849,7 @@ void Vulkan::reInit()
|
||||
{
|
||||
checkLibrary();
|
||||
initNextSettings();
|
||||
addImGUIFont(LV::getResource("default.ttf")->makeView());
|
||||
}
|
||||
|
||||
bool Vulkan::needFullVulkanRebuild()
|
||||
@@ -1899,12 +1893,15 @@ void Vulkan::addImGUIFont(std::string_view view) {
|
||||
fontConfig.OversampleV = 1;
|
||||
|
||||
auto &io = ImGui::GetIO();
|
||||
uint8_t *fontPtr = new uint8_t[view.size()];
|
||||
uint8_t *fontPtr = (uint8_t*) malloc(view.size());
|
||||
if(!fontPtr)
|
||||
MAKE_ERROR("Not enough memory");
|
||||
|
||||
std::copy(view.begin(), view.end(), fontPtr);
|
||||
try{
|
||||
io.Fonts->AddFontFromMemoryTTF(fontPtr, view.size(), 16.0f, &fontConfig, io.Fonts->GetGlyphRangesCyrillic());
|
||||
} catch(...) {
|
||||
delete[] fontPtr;
|
||||
free(fontPtr);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user