Fix assertion failure in RequestContentList with many GRFs
This commit is contained in:
@@ -248,15 +248,18 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
|
||||
this->Connect();
|
||||
|
||||
assert(cv->Length() < 255);
|
||||
assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
|
||||
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? /*sizeof(ContentInfo::md5sum)*/16 : 0)));
|
||||
const uint max_per_packet = min<uint>(255, (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
|
||||
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? /*sizeof(ContentInfo::md5sum)*/16 : 0))) - 1;
|
||||
|
||||
uint offset = 0;
|
||||
|
||||
while (cv->Length() > offset) {
|
||||
Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID);
|
||||
p->Send_uint8(cv->Length());
|
||||
const uint to_send = min<uint>(cv->Length() - offset, max_per_packet);
|
||||
p->Send_uint8(to_send);
|
||||
|
||||
for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) {
|
||||
const ContentInfo *ci = *iter;
|
||||
for (uint i = 0; i < to_send; i++) {
|
||||
const ContentInfo *ci = (*cv)[offset + i];
|
||||
p->Send_uint8((byte)ci->type);
|
||||
p->Send_uint32(ci->unique_id);
|
||||
if (!send_md5sum) continue;
|
||||
@@ -268,6 +271,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
|
||||
this->SendPacket(p);
|
||||
|
||||
offset += to_send;
|
||||
}
|
||||
|
||||
for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) {
|
||||
ContentInfo *ci = *iter;
|
||||
bool found = false;
|
||||
|
Reference in New Issue
Block a user