MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / get_resource_retrieval_progress

Method get_resource_retrieval_progress

src/ResourceManager.cpp:80–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80float ResourceManager::get_resource_retrieval_progress(const NetworkingObjects::NetObjID& id) {
81 auto resourceClientID = resourcesBeingRetrieved.find(id);
82 if(resourceClientID == resourcesBeingRetrieved.end())
83 return 0.0f;
84 if(world.netServer) {
85 std::weak_ptr<NetServer::ClientData> clientIDToLookFor = resourceClientID->second;
86 if(clientIDToLookFor.expired()) {
87 resourcesBeingRetrieved.erase(resourceClientID);
88 return 0.0f;
89 }
90 auto progressBytes = clientIDToLookFor.lock()->get_progress_into_fragmented_message(RESOURCE_COMMAND_CHANNEL);
91 if(progressBytes.totalBytes == 0)
92 return 0.0f;
93 return static_cast<float>(progressBytes.downloadedBytes) / static_cast<float>(progressBytes.totalBytes);
94 }
95 else if(world.netClient) {
96 NetLibrary::DownloadProgress progressBytes = world.netClient->get_progress_into_fragmented_message(RESOURCE_COMMAND_CHANNEL);
97 if(progressBytes.totalBytes == 0)
98 return 0.0f;
99 return static_cast<float>(progressBytes.downloadedBytes) / static_cast<float>(progressBytes.totalBytes);
100 }
101 return 0.0f;
102}
103
104void ResourceManager::update() {
105 for(auto& [k, v] : displays)

Callers 1

drawMethod · 0.80

Calls 6

expiredMethod · 0.80
lockMethod · 0.80
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected