ParsedPacket
This commit is contained in:
@@ -128,6 +128,8 @@ public:
|
||||
} Registry;
|
||||
|
||||
virtual ~IServerSession();
|
||||
|
||||
virtual void atFreeDrawTime() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ServerSession.hpp"
|
||||
#include "Client/Abstract.hpp"
|
||||
#include "Common/Abstract.hpp"
|
||||
#include "Common/Net.hpp"
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/this_coro.hpp>
|
||||
@@ -13,6 +14,18 @@
|
||||
|
||||
namespace LV::Client {
|
||||
|
||||
ParsedPacket::~ParsedPacket() = default;
|
||||
|
||||
struct PP_Content_ChunkVoxels : public ParsedPacket {
|
||||
WorldId_c Id;
|
||||
Pos::GlobalChunk Pos;
|
||||
std::vector<VoxelCube> Cubes;
|
||||
|
||||
PP_Content_ChunkVoxels(ToClient::L1 l1, uint8_t l2, WorldId_c id, Pos::GlobalChunk pos, std::vector<VoxelCube> &&cubes)
|
||||
: ParsedPacket(l1, l2), Id(id), Pos(pos), Cubes(std::move(cubes))
|
||||
{}
|
||||
};
|
||||
|
||||
using namespace TOS;
|
||||
|
||||
ServerSession::~ServerSession() {
|
||||
@@ -174,6 +187,10 @@ void ServerSession::onJoystick() {
|
||||
|
||||
}
|
||||
|
||||
void ServerSession::atFreeDrawTime() {
|
||||
|
||||
}
|
||||
|
||||
coro<> ServerSession::run() {
|
||||
auto useLock = UseLock.lock();
|
||||
|
||||
@@ -363,6 +380,16 @@ coro<> ServerSession::rP_Content(Net::AsyncSocket &sock) {
|
||||
cube.Right.Z = co_await sock.read<uint8_t>();
|
||||
}
|
||||
|
||||
auto packet = std::make_unique<PP_Content_ChunkVoxels>(
|
||||
ToClient::L1::Content,
|
||||
(uint8_t) ToClient::L2Content::ChunkVoxels,
|
||||
wcId,
|
||||
pos,
|
||||
std::move(cubes)
|
||||
);
|
||||
|
||||
while(!NetInputPackets.push(std::move(packet)));
|
||||
|
||||
LOG.info() << "Приняты воксели чанка " << int(wcId) << " / " << pos.X << ":" << pos.Y << ":" << pos.Z << " Вокселей " << cubes.size();
|
||||
|
||||
co_return;
|
||||
|
||||
@@ -7,10 +7,22 @@
|
||||
#include "Common/Packets.hpp"
|
||||
#include <TOSLib.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <memory>
|
||||
#include <boost/lockfree/spsc_queue.hpp>
|
||||
|
||||
|
||||
namespace LV::Client {
|
||||
|
||||
struct ParsedPacket {
|
||||
ToClient::L1 Level1;
|
||||
uint8_t Level2;
|
||||
|
||||
ParsedPacket(ToClient::L1 l1, uint8_t l2)
|
||||
: Level1(l1), Level2(l2)
|
||||
{}
|
||||
virtual ~ParsedPacket();
|
||||
};
|
||||
|
||||
class ServerSession : public AsyncObject, public IServerSession, public ISurfaceEventListener {
|
||||
std::unique_ptr<Net::AsyncSocket> Socket;
|
||||
IRenderSession *RS = nullptr;
|
||||
@@ -23,10 +35,12 @@ class ServerSession : public AsyncObject, public IServerSession, public ISurface
|
||||
glm::quat Quat;
|
||||
} Camera;
|
||||
|
||||
boost::lockfree::spsc_queue<std::unique_ptr<ParsedPacket>> NetInputPackets;
|
||||
|
||||
public:
|
||||
// Нужен сокет, на котором только что был согласован игровой протокол (asyncInitGameProtocol)
|
||||
ServerSession(asio::io_context &ioc, std::unique_ptr<Net::AsyncSocket> &&socket, IRenderSession *rs = nullptr)
|
||||
: AsyncObject(ioc), Socket(std::move(socket)), RS(rs)
|
||||
: AsyncObject(ioc), Socket(std::move(socket)), RS(rs), NetInputPackets(1024)
|
||||
{
|
||||
assert(Socket.get());
|
||||
co_spawn(run());
|
||||
@@ -63,6 +77,8 @@ public:
|
||||
virtual void onKeyboardBtn(int btn, int state) override;
|
||||
virtual void onJoystick() override;
|
||||
|
||||
virtual void atFreeDrawTime() override;
|
||||
|
||||
private:
|
||||
coro<> run();
|
||||
void protocolError();
|
||||
|
||||
@@ -1163,14 +1163,6 @@ void Vulkan::checkLibrary()
|
||||
bool canContinue = true;
|
||||
|
||||
// Необходимый функционал
|
||||
if(!device.DeviceFeatures.depthBounds)
|
||||
{
|
||||
report << "\t*depthBounds: "
|
||||
<< device.DeviceFeatures.depthBounds
|
||||
<< '\n';
|
||||
canContinue = false;
|
||||
}
|
||||
|
||||
if(!device.DeviceFeatures.geometryShader)
|
||||
{
|
||||
report << "\t*geometryShader: "
|
||||
@@ -1179,14 +1171,6 @@ void Vulkan::checkLibrary()
|
||||
canContinue = false;
|
||||
}
|
||||
|
||||
if(!device.DeviceFeatures.dualSrcBlend)
|
||||
{
|
||||
report << "\t*geometryShader: "
|
||||
<< device.DeviceFeatures.imageCubeArray
|
||||
<< '\n';
|
||||
canContinue = false;
|
||||
}
|
||||
|
||||
// Проверка наличия необходимых расширений
|
||||
for(auto ext : NeedExtensions)
|
||||
if(std::find_if(device.Extensions.begin(), device.Extensions.end(), [&](const vkDeviceExtension &obj) { return obj.ExtensionName == ext; }) == device.Extensions.end())
|
||||
@@ -1428,10 +1412,7 @@ void Vulkan::initNextSettings()
|
||||
.features = {0}
|
||||
};
|
||||
|
||||
features.features.depthBounds = true;
|
||||
features.features.geometryShader = true;
|
||||
features.features.dualSrcBlend = true;
|
||||
features.features.shaderInt16 = true;
|
||||
|
||||
feat11.uniformAndStorageBuffer16BitAccess = true;
|
||||
feat11.storageBuffer16BitAccess = true;
|
||||
|
||||
Reference in New Issue
Block a user