From dbebf5055211608443094a2d573eaea0df8f5d72 Mon Sep 17 00:00:00 2001 From: DrSocalkwe3n Date: Sun, 4 Jan 2026 20:18:02 +0600 Subject: [PATCH] =?UTF-8?q?codex-5.2:=20=D0=BB=D0=BE=D0=B3=D0=B3=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=B0=D1=87=D0=B8=20=D1=80=D0=B5=D1=81=D1=83=D1=80?= =?UTF-8?q?=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Client/AssetsManager.cpp | 42 ++++++++++++++++++++++++++++++++++- Src/Client/ServerSession.cpp | 43 ++++++++++++++++++++++++++++++++++-- Src/Server/GameServer.cpp | 21 ++++++++++++++++++ Src/Server/RemoteClient.cpp | 7 ++++++ 4 files changed, 110 insertions(+), 3 deletions(-) diff --git a/Src/Client/AssetsManager.cpp b/Src/Client/AssetsManager.cpp index 4e80171..4f5d26f 100644 --- a/Src/Client/AssetsManager.cpp +++ b/Src/Client/AssetsManager.cpp @@ -12,6 +12,19 @@ namespace LV::Client { namespace { +static const char* assetTypeName(EnumAssets type) { + switch(type) { + case EnumAssets::Nodestate: return "nodestate"; + case EnumAssets::Model: return "model"; + case EnumAssets::Texture: return "texture"; + case EnumAssets::Particle: return "particle"; + case EnumAssets::Animation: return "animation"; + case EnumAssets::Sound: return "sound"; + case EnumAssets::Font: return "font"; + default: return "unknown"; + } +} + static const char* enumAssetsToDirectory(LV::EnumAssets value) { switch(value) { case LV::EnumAssets::Nodestate: return "nodestate"; @@ -789,6 +802,14 @@ void AssetsManager::pushReads(std::vector reads) { for(ResourceKey& key : reads) { std::optional pack = findPackResource(key.Type, key.Domain, key.Key); if(pack && pack->Hash == key.Hash) { + LOG.debug() << "Pack hit type=" << assetTypeName(key.Type) + << " id=" << key.Id + << " key=" << key.Domain << ':' << key.Key + << " hash=" << int(key.Hash[0]) << '.' + << int(key.Hash[1]) << '.' + << int(key.Hash[2]) << '.' + << int(key.Hash[3]) + << " size=" << pack->Res.size(); ReadyReads.emplace_back(std::move(key), pack->Res); continue; } @@ -817,8 +838,27 @@ std::vector>> Asse auto iter = PendingReadsByHash.find(hash); if(iter == PendingReadsByHash.end()) continue; - for(ResourceKey& key : iter->second) + for(ResourceKey& key : iter->second) { + if(res) { + LOG.debug() << "Cache hit type=" << assetTypeName(key.Type) + << " id=" << key.Id + << " key=" << key.Domain << ':' << key.Key + << " hash=" << int(hash[0]) << '.' + << int(hash[1]) << '.' + << int(hash[2]) << '.' + << int(hash[3]) + << " size=" << res->size(); + } else { + LOG.debug() << "Cache miss type=" << assetTypeName(key.Type) + << " id=" << key.Id + << " key=" << key.Domain << ':' << key.Key + << " hash=" << int(hash[0]) << '.' + << int(hash[1]) << '.' + << int(hash[2]) << '.' + << int(hash[3]); + } out.emplace_back(std::move(key), res); + } PendingReadsByHash.erase(iter); } diff --git a/Src/Client/ServerSession.cpp b/Src/Client/ServerSession.cpp index 2902b8f..dd1690a 100644 --- a/Src/Client/ServerSession.cpp +++ b/Src/Client/ServerSession.cpp @@ -474,6 +474,13 @@ void ServerSession::update(GlobalTime gTime, float dTime) { if(idx < 128) { LOG.debug() << "Send ResourceRequest count=" << needRequest.size(); } + for(const auto& hash : needRequest) { + LOG.debug() << "Client request hash=" + << int(hash[0]) << '.' + << int(hash[1]) << '.' + << int(hash[2]) << '.' + << int(hash[3]); + } Net::Packet p; p << (uint8_t) ToServer::L1::System << (uint8_t) ToServer::L2System::ResourceRequest; @@ -611,6 +618,15 @@ void ServerSession::update(GlobalTime gTime, float dTime) { << int(firstDebug.Hash[2]) << '.' << int(firstDebug.Hash[3]); } + for(const auto& entry : needToLoad) { + LOG.debug() << "Client wants type=" << assetTypeName(entry.Type) + << " id=" << entry.Id + << " key=" << entry.Domain << ':' << entry.Key + << " hash=" << int(entry.Hash[0]) << '.' + << int(entry.Hash[1]) << '.' + << int(entry.Hash[2]) << '.' + << int(entry.Hash[3]); + } AM->pushReads(std::move(needToLoad)); } @@ -1523,6 +1539,15 @@ coro<> ServerSession::rP_AssetsInitSend(Net::AsyncSocket &sock) { type, localId, std::move(domain), std::move(key), std::u8string(size, '\0'), 0 }; + LOG.debug() << "Server started sending type=" << assetTypeName(type) + << " id=" << localId + << " key=" << AsyncContext.AssetsLoading[hash].Domain << ':' + << AsyncContext.AssetsLoading[hash].Key + << " hash=" << int(hash[0]) << '.' + << int(hash[1]) << '.' + << int(hash[2]) << '.' + << int(hash[3]) + << " size=" << size; co_return; } @@ -1564,14 +1589,28 @@ coro<> ServerSession::rP_AssetsNextSend(Net::AsyncSocket &sock) { } } + const EnumAssets type = al.Type; + const ResourceId id = al.Id; + const std::string domain = al.Domain; + const std::string key = al.Key; + const size_t resSize = al.Data.size(); + AsyncContext.LoadedAssets.lock()->emplace_back(AssetEntry{ - .Type = al.Type, - .Id = al.Id, + .Type = type, + .Id = id, .Domain = std::move(al.Domain), .Key = std::move(al.Key), .Res = std::move(al.Data), .Hash = hash }); + LOG.debug() << "Client received type=" << assetTypeName(type) + << " id=" << id + << " key=" << domain << ':' << key + << " hash=" << int(hash[0]) << '.' + << int(hash[1]) << '.' + << int(hash[2]) << '.' + << int(hash[3]) + << " size=" << resSize; } AsyncContext.AssetsLoading.erase(AsyncContext.AssetsLoading.find(hash)); diff --git a/Src/Server/GameServer.cpp b/Src/Server/GameServer.cpp index c4298bd..e682ae0 100644 --- a/Src/Server/GameServer.cpp +++ b/Src/Server/GameServer.cpp @@ -2474,6 +2474,19 @@ void GameServer::stepSyncContent() { } // Оповещаем о двоичных ресурсах по запросу + auto assetTypeName = [](EnumAssets type) { + switch(type) { + case EnumAssets::Nodestate: return "nodestate"; + case EnumAssets::Model: return "model"; + case EnumAssets::Texture: return "texture"; + case EnumAssets::Particle: return "particle"; + case EnumAssets::Animation: return "animation"; + case EnumAssets::Sound: return "sound"; + case EnumAssets::Font: return "font"; + default: return "unknown"; + } + }; + std::vector binaryResources; for(const Hash_t& hash : full.Hashes) { std::optional< @@ -2484,6 +2497,14 @@ void GameServer::stepSyncContent() { continue; auto& [type, id, media] = *result; + LOG.debug() << "Server sending type=" << assetTypeName(type) + << " id=" << id + << " key=" << media->Domain << ':' << media->Key + << " hash=" << int(media->Hash[0]) << '.' + << int(media->Hash[1]) << '.' + << int(media->Hash[2]) << '.' + << int(media->Hash[3]) + << " size=" << media->Resource->size(); Resource resource(*media->Resource); binaryResources.push_back(AssetBinaryInfo{ .Data = std::move(resource), diff --git a/Src/Server/RemoteClient.cpp b/Src/Server/RemoteClient.cpp index 6af8c05..6509e48 100644 --- a/Src/Server/RemoteClient.cpp +++ b/Src/Server/RemoteClient.cpp @@ -472,6 +472,13 @@ coro<> RemoteClient::rP_System(Net::AsyncSocket &sock) { LOG.debug() << "ResourceRequest count=" << count; } } + for(const auto& hash : hashes) { + LOG.debug() << "Client requested hash=" + << int(hash[0]) << '.' + << int(hash[1]) << '.' + << int(hash[2]) << '.' + << int(hash[3]); + } co_return; } case ToServer::L2System::ReloadMods: