Codechange: Use Recv/Send_bytes for md5sum. (#12602)

Use existing functions to handle serialisation of arrays instead of indexed for-loop.
master
Peter Nelson 1 month ago committed by GitHub
parent 1424a184d8
commit 532ce1a907
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -375,9 +375,7 @@ void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfo
void SerializeGRFIdentifier(Packet &p, const GRFIdentifier &grf)
{
p.Send_uint32(grf.grfid);
for (size_t j = 0; j < grf.md5sum.size(); j++) {
p.Send_uint8(grf.md5sum[j]);
}
p.Send_bytes(grf.md5sum);
}
/**
@ -388,9 +386,7 @@ void SerializeGRFIdentifier(Packet &p, const GRFIdentifier &grf)
void DeserializeGRFIdentifier(Packet &p, GRFIdentifier &grf)
{
grf.grfid = p.Recv_uint32();
for (size_t j = 0; j < grf.md5sum.size(); j++) {
grf.md5sum[j] = p.Recv_uint8();
}
p.Recv_bytes(grf.md5sum);
}
/**

@ -63,9 +63,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet &p)
ci->description = p.Recv_string(NETWORK_CONTENT_DESC_LENGTH, SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE);
ci->unique_id = p.Recv_uint32();
for (size_t j = 0; j < ci->md5sum.size(); j++) {
ci->md5sum[j] = p.Recv_uint8();
}
p.Recv_bytes(ci->md5sum);
uint dependency_count = p.Recv_uint8();
ci->dependencies.reserve(dependency_count);
@ -276,10 +274,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
p->Send_uint8((uint8_t)ci->type);
p->Send_uint32(ci->unique_id);
if (!send_md5sum) continue;
for (size_t j = 0; j < ci->md5sum.size(); j++) {
p->Send_uint8(ci->md5sum[j]);
}
p->Send_bytes(ci->md5sum);
}
this->SendPacket(std::move(p));

Loading…
Cancel
Save