codex-5.2: Отладка сети со стороны клиента

This commit is contained in:
2026-01-05 02:25:51 +06:00
parent 6c7a6df8f6
commit 2b2be796e9
33 changed files with 49 additions and 926 deletions

View File

@@ -177,6 +177,9 @@ struct AssetEntry {
*/
class IServerSession {
public:
// Включить логирование входящих сетевых пакетов на клиенте.
bool DebugLogPackets = false;
// Используемые двоичные ресурсы
std::unordered_map<EnumAssets, std::unordered_map<ResourceId, AssetEntry>> Assets;

View File

@@ -38,6 +38,26 @@ const char* assetTypeName(EnumAssets type) {
}
}
const char* toClientPacketName(ToClient type) {
switch(type) {
case ToClient::Init: return "Init";
case ToClient::Disconnect: return "Disconnect";
case ToClient::AssetsBindDK: return "AssetsBindDK";
case ToClient::AssetsBindHH: return "AssetsBindHH";
case ToClient::AssetsInitSend: return "AssetsInitSend";
case ToClient::AssetsNextSend: return "AssetsNextSend";
case ToClient::DefinitionsUpdate: return "DefinitionsUpdate";
case ToClient::ChunkVoxels: return "ChunkVoxels";
case ToClient::ChunkNodes: return "ChunkNodes";
case ToClient::ChunkLightPrism: return "ChunkLightPrism";
case ToClient::RemoveRegion: return "RemoveRegion";
case ToClient::Tick: return "Tick";
case ToClient::TestLinkCameraToEntity: return "TestLinkCameraToEntity";
case ToClient::TestUnlinkCamera: return "TestUnlinkCamera";
default: return "Unknown";
}
}
}
ServerSession::ServerSession(asio::io_context &ioc, std::unique_ptr<Net::AsyncSocket>&& socket)
@@ -875,6 +895,8 @@ void ServerSession::update(GlobalTime gTime, float dTime) {
}
result.Chunks_ChangeOrAdd = std::move(chunks_Changed);
for(auto& [wId, regions] : regions_Lost_Result)
result.Chunks_Lost[wId] = std::vector<Pos::GlobalRegion>(regions.begin(), regions.end());
{
@@ -1233,6 +1255,11 @@ void ServerSession::protocolError() {
coro<> ServerSession::readPacket(Net::AsyncSocket &sock) {
uint8_t first = co_await sock.read<uint8_t>();
if(DebugLogPackets) {
ToClient type = static_cast<ToClient>(first);
LOG.debug() << "Recv packet=" << toClientPacketName(type) << " id=" << int(first);
}
switch((ToClient) first) {
case ToClient::Init:
co_return;

View File

@@ -2291,6 +2291,8 @@ void Vulkan::gui_ConnectedToServer() {
double chunksKb = double(Game.Session->getVisibleCompressedChunksBytes()) / 1024.0;
ImGui::Text("chunks compressed: %.1f KB", chunksKb);
ImGui::Checkbox("Логи сетевых пакетов", &Game.Session->DebugLogPackets);
if(ImGui::Button("Delimeter"))
LOG.debug();

View File

@@ -57,6 +57,10 @@ AssetsPreloader::Out_reloadResources AssetsPreloader::reloadResources(const Asse
try {
ReloadStatus secondStatus;
return _reloadResources(instances, status ? *status : secondStatus);
} catch(const std::exception& exc) {
LOG.error() << exc.what();
assert(!"reloadResources: здесь не должно быть ошибок");
std::unreachable();
} catch(...) {
assert(!"reloadResources: здесь не должно быть ошибок");
std::unreachable();

View File

@@ -44,6 +44,15 @@ namespace js = boost::json;
namespace LV::Server {
template <typename T, size_t N>
bool hasAnyBindings(const std::array<std::vector<T>, N>& data) {
for(const auto& list : data) {
if(!list.empty())
return true;
}
return false;
}
std::string ModInfo::dump() const {
js::object obj;
@@ -1694,7 +1703,7 @@ void GameServer::reloadMods() {
{
AssetsPreloader::Out_bakeId baked = Content.AM.bakeIdTables();
if(!baked.IdToDK.empty()) {
if(hasAnyBindings(baked.IdToDK)) {
packetsToSend.push_back(RemoteClient::makePacket_informateAssets_DK(baked.IdToDK));
}
}
@@ -2487,7 +2496,7 @@ void GameServer::stepSyncContent() {
std::vector<Net::Packet> packetsToAll;
{
AssetsPreloader::Out_bakeId baked = Content.AM.bakeIdTables();
if(!baked.IdToDK.empty()) {
if(hasAnyBindings(baked.IdToDK)) {
packetsToAll.push_back(RemoteClient::makePacket_informateAssets_DK(baked.IdToDK));
}
}

View File

@@ -389,10 +389,8 @@ void RemoteClient::NetworkAndResource_t::prepareWorldRemove(WorldId_t worldId)
void RemoteClient::prepareCameraSetEntity(ServerEntityId_t entityId) {
auto lock = NetworkAndResource.lock();
ClientEntityId_t cId = lock->ReMapEntities.toClient(entityId);
lock->checkPacketBorder(8);
lock->NextPacket << (uint8_t) ToClient::TestLinkCameraToEntity
<< cId;
lock->checkPacketBorder(4);
lock->NextPacket << (uint8_t) ToClient::TestLinkCameraToEntity;
}
ResourceRequest RemoteClient::pushPreparedPackets() {

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "acacia_planks.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "frame.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "grass.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "jungle_planks.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "oak_planks.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "tropical_rainforest_wood.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "willow_wood.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "xnether_blue_wood.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,81 +0,0 @@
{
"textures": {
"default": "xnether_purple_wood.png"
},
"cuboids": [
{
"from": [
-0.5,
-0.5,
-0.5
],
"to": [
0.5,
0.5,
0.5
],
"faces": {
"down": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
1,
1
],
"texture": "default",
"cullface": "east"
}
}
}
]
}

View File

@@ -1,14 +0,0 @@
{
"meta==0": {
"model": "node/grass.json"
},
"meta==1": {
"model": "node/oak_planks.json"
},
"meta==2": {
"model": "node/jungle_planks.json"
},
"meta==3": {
"model": "node/acacia_planks.json"
}
}

View File

@@ -1,14 +0,0 @@
{
"meta==0": {
"model": "node/tropical_rainforest_wood.json"
},
"meta==1": {
"model": "node/willow_wood.json"
},
"meta==2": {
"model": "node/xnether_blue_wood.json"
},
"meta==3": {
"model": "node/xnether_purple_wood.json"
}
}

View File

@@ -1,14 +0,0 @@
{
"meta==0": {
"model": "node/frame.json"
},
"meta==1": {
"model": "node/grass.json"
},
"meta==2": {
"model": "node/oak_planks.json"
},
"meta==3": {
"model": "node/acacia_planks.json"
}
}

View File

@@ -1,14 +0,0 @@
{
"meta==0": {
"model": "node/jungle_planks.json"
},
"meta==1": {
"model": "node/tropical_rainforest_wood.json"
},
"meta==2": {
"model": "node/willow_wood.json"
},
"meta==3": {
"model": "node/xnether_blue_wood.json"
}
}

View File

@@ -1,14 +0,0 @@
{
"meta==0": {
"model": "node/oak_planks.json"
},
"meta==1": {
"model": "node/jungle_planks.json"
},
"meta==2": {
"model": "node/acacia_planks.json"
},
"meta==3": {
"model": "node/willow_wood.json"
}
}

View File

@@ -1,14 +0,0 @@
{
"meta==0": {
"model": "node/grass.json"
},
"meta==1": {
"model": "node/frame.json"
},
"meta==2": {
"model": "node/xnether_purple_wood.json"
},
"meta==3": {
"model": "node/tropical_rainforest_wood.json"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -1,98 +0,0 @@
-- parent = default:air
--
-- hasHalfTransparency
-- collideBox = {}
-- plantLike = {}
-- nodebox = {}
local node_template = {
parent = "default:normal" or node_template,
render = {
has_half_transparency = false
},
collision = {
},
events = {
},
node_advancement_factory = function(world_id, node_pos)
local node_advancement = {
onLoad = function(data)
end,
onSave = function()
return {}
end
}
return node_advancement
end
}
local instance = {}
--[[
Движок автоматически подгружает ассеты из папки assets
В этом методе можно зарегистрировать ассеты из иных источников
Состояния нод, частицы, анимации, модели, текстуры, звуки, шрифты
]]--
function instance.assetsInit()
end
--[[
*preInit. События для регистрации определений игрового контента
Ноды, воксели, миры, порталы, сущности, предметы
]]--
function instance.lowPreInit()
end
--[[
До вызова preInit будет выполнена регистрация
контента из файлов в папке content
]]--
function instance.preInit()
local node_air = {}
node_air.hasHalfTransparency = false
node_air.collideBox = nil
node_air.render = nil
core.register_node('test0', {})
core.register_node('test1', {})
core.register_node('test2', {})
core.register_node('test3', {})
core.register_node('test4', {})
core.register_node('test5', {})
end
function instance.highPreInit()
end
--[[
На этом этапе можно наложить изменения
на зарегистрированный другими модами контент
]]--
function instance.init()
end
function instance.postInit()
end
function instance.preDeInit()
end
function instance.deInit()
end
function instance.postDeInit()
core.unregister_node('test0')
core.unregister_node('test1')
core.unregister_node('test2')
core.unregister_node('test3')
core.unregister_node('test4')
core.unregister_node('test5')
end
return instance

View File

@@ -1,9 +0,0 @@
{
"id": "test",
"name": "Test Mod",
"description": "Это тестовый мод",
"depends": [],
"optional_depends": [],
"author": "DrSocalkwe3n",
"version": [0, 0, 0, 1]
}