Update to 12.0-RC1

This commit is contained in:
dP
2021-09-26 20:30:12 +03:00
parent c9765f712f
commit 4eb8b29dbf
173 changed files with 31125 additions and 9485 deletions

View File

@@ -68,7 +68,11 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
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());
for (uint i = 0; i < dependency_count; i++) {
ContentID dependency_cid = (ContentID)p->Recv_uint32();
ci->dependencies.push_back(dependency_cid);
this->reverse_dependency_map.insert({ dependency_cid, ci->id });
}
uint tag_count = p->Recv_uint8();
ci->tags.reserve(tag_count);
@@ -168,8 +172,10 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
this->infos.push_back(ci);
/* Incoming data means that we might need to reconsider dependencies */
for (ContentInfo *ici : this->infos) {
this->CheckDependencyState(ici);
ConstContentVector parents;
this->ReverseLookupTreeDependency(parents, ci);
for (const ContentInfo *ici : parents) {
this->CheckDependencyState(const_cast<ContentInfo *>(ici));
}
this->OnReceiveContentInfo(ci);
@@ -201,7 +207,20 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentType type)
Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_LIST);
p->Send_uint8 ((byte)type);
p->Send_uint32(_openttd_newgrf_version);
p->Send_uint32(0xffffffff);
p->Send_uint8 (1);
p->Send_string("vanilla");
p->Send_string(_openttd_content_version);
/* Patchpacks can extend the list with one. In BaNaNaS metadata you can
* add a branch in the 'compatibility' list, to filter on this. If you want
* your patchpack to be mentioned in the BaNaNaS web-interface, create an
* issue on https://github.com/OpenTTD/bananas-api asking for this.
p->Send_string("patchpack"); // Or what-ever the name of your patchpack is.
p->Send_string(_openttd_content_version_patchpack);
*/
this->SendPacket(p);
}
@@ -833,7 +852,7 @@ void ClientNetworkContentSocketHandler::DownloadContentInfo(ContentID cid)
* @param cid the ContentID to search for
* @return the ContentInfo or nullptr if not found
*/
ContentInfo *ClientNetworkContentSocketHandler::GetContent(ContentID cid)
ContentInfo *ClientNetworkContentSocketHandler::GetContent(ContentID cid) const
{
for (ContentInfo *ci : this->infos) {
if (ci->id == cid) return ci;
@@ -923,15 +942,10 @@ void ClientNetworkContentSocketHandler::ToggleSelectedState(const ContentInfo *c
*/
void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVector &parents, const ContentInfo *child) const
{
for (const ContentInfo *ci : this->infos) {
if (ci == child) continue;
auto range = this->reverse_dependency_map.equal_range(child->id);
for (auto &dependency : ci->dependencies) {
if (dependency == child->id) {
parents.push_back(ci);
break;
}
}
for (auto iter = range.first; iter != range.second; ++iter) {
parents.push_back(GetContent(iter->second));
}
}
@@ -1056,6 +1070,7 @@ void ClientNetworkContentSocketHandler::Clear()
this->infos.clear();
this->requested.clear();
this->reverse_dependency_map.clear();
}
/*** CALLBACK ***/