|
@@ -63,15 +63,15 @@ bool ClientNetworkContentSocketHandler::
|
|
|
|
|
|
ci->unique_id = p->Recv_uint32();
|
|
|
for (uint j = 0; j < sizeof(ci->md5sum); j++) {
|
|
|
ci->md5sum[j] = p->Recv_uint8();
|
|
|
}
|
|
|
|
|
|
ci->dependency_count = p->Recv_uint8();
|
|
|
ci->dependencies = MallocT<ContentID>(ci->dependency_count);
|
|
|
for (uint i = 0; i < ci->dependency_count; i++) ci->dependencies[i] = (ContentID)p->Recv_uint32();
|
|
|
uint dependency_count = p->Recv_uint8();
|
|
|
ci->dependencies.reserve(dependency_count);
|
|
|
for (uint i = 0; i < dependency_count; i++) ci->dependencies.push_back((ContentID)p->Recv_uint32());
|
|
|
|
|
|
uint tag_count = p->Recv_uint8();
|
|
|
ci->tags.reserve(tag_count);
|
|
|
for (uint i = 0; i < tag_count; i++) ci->tags.push_back(p->Recv_string(NETWORK_CONTENT_TAG_LENGTH));
|
|
|
|
|
|
if (!ci->IsValid()) {
|
|
@@ -924,14 +924,14 @@ void ClientNetworkContentSocketHandler::
|
|
|
*/
|
|
|
void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVector &parents, const ContentInfo *child) const
|
|
|
{
|
|
|
for (const ContentInfo *ci : this->infos) {
|
|
|
if (ci == child) continue;
|
|
|
|
|
|
for (uint i = 0; i < ci->dependency_count; i++) {
|
|
|
if (ci->dependencies[i] == child->id) {
|
|
|
for (auto &dependency : ci->dependencies) {
|
|
|
if (dependency == child->id) {
|
|
|
parents.push_back(ci);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -966,16 +966,16 @@ void ClientNetworkContentSocketHandler::
|
|
|
void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
|
|
|
{
|
|
|
if (ci->IsSelected() || ci->state == ContentInfo::ALREADY_HERE) {
|
|
|
/* Selection is easy; just walk all children and set the
|
|
|
* autoselected state. That way we can see what we automatically
|
|
|
* selected and thus can unselect when a dependency is removed. */
|
|
|
for (uint i = 0; i < ci->dependency_count; i++) {
|
|
|
ContentInfo *c = this->GetContent(ci->dependencies[i]);
|
|
|
for (auto &dependency : ci->dependencies) {
|
|
|
ContentInfo *c = this->GetContent(dependency);
|
|
|
if (c == nullptr) {
|
|
|
this->DownloadContentInfo(ci->dependencies[i]);
|
|
|
this->DownloadContentInfo(dependency);
|
|
|
} else if (c->state == ContentInfo::UNSELECTED) {
|
|
|
c->state = ContentInfo::AUTOSELECTED;
|
|
|
this->CheckDependencyState(c);
|
|
|
}
|
|
|
}
|
|
|
return;
|
|
@@ -992,16 +992,16 @@ void ClientNetworkContentSocketHandler::
|
|
|
for (const ContentInfo *c : parents) {
|
|
|
if (!c->IsSelected()) continue;
|
|
|
|
|
|
this->Unselect(c->id);
|
|
|
}
|
|
|
|
|
|
for (uint i = 0; i < ci->dependency_count; i++) {
|
|
|
const ContentInfo *c = this->GetContent(ci->dependencies[i]);
|
|
|
for (auto &dependency : ci->dependencies) {
|
|
|
const ContentInfo *c = this->GetContent(dependency);
|
|
|
if (c == nullptr) {
|
|
|
DownloadContentInfo(ci->dependencies[i]);
|
|
|
DownloadContentInfo(dependency);
|
|
|
continue;
|
|
|
}
|
|
|
if (c->state != ContentInfo::AUTOSELECTED) continue;
|
|
|
|
|
|
/* Only unselect when WE are the only parent. */
|
|
|
parents.clear();
|