codex-5.2: логгирование передачи ресурсов
This commit is contained in:
@@ -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<ResourceKey> reads) {
|
||||
for(ResourceKey& key : reads) {
|
||||
std::optional<PackResource> 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<std::pair<AssetsManager::ResourceKey, std::optional<Resource>>> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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<AssetBinaryInfo> 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),
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user