mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use Recv/Send_bytes for md5sum. (#12602)
Use existing functions to handle serialisation of arrays instead of indexed for-loop.pull/12605/head
parent
1424a184d8
commit
532ce1a907
|
@ -375,9 +375,7 @@ void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfo
|
||||||
void SerializeGRFIdentifier(Packet &p, const GRFIdentifier &grf)
|
void SerializeGRFIdentifier(Packet &p, const GRFIdentifier &grf)
|
||||||
{
|
{
|
||||||
p.Send_uint32(grf.grfid);
|
p.Send_uint32(grf.grfid);
|
||||||
for (size_t j = 0; j < grf.md5sum.size(); j++) {
|
p.Send_bytes(grf.md5sum);
|
||||||
p.Send_uint8(grf.md5sum[j]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -388,9 +386,7 @@ void SerializeGRFIdentifier(Packet &p, const GRFIdentifier &grf)
|
||||||
void DeserializeGRFIdentifier(Packet &p, GRFIdentifier &grf)
|
void DeserializeGRFIdentifier(Packet &p, GRFIdentifier &grf)
|
||||||
{
|
{
|
||||||
grf.grfid = p.Recv_uint32();
|
grf.grfid = p.Recv_uint32();
|
||||||
for (size_t j = 0; j < grf.md5sum.size(); j++) {
|
p.Recv_bytes(grf.md5sum);
|
||||||
grf.md5sum[j] = p.Recv_uint8();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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->description = p.Recv_string(NETWORK_CONTENT_DESC_LENGTH, SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE);
|
||||||
|
|
||||||
ci->unique_id = p.Recv_uint32();
|
ci->unique_id = p.Recv_uint32();
|
||||||
for (size_t j = 0; j < ci->md5sum.size(); j++) {
|
p.Recv_bytes(ci->md5sum);
|
||||||
ci->md5sum[j] = p.Recv_uint8();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint dependency_count = p.Recv_uint8();
|
uint dependency_count = p.Recv_uint8();
|
||||||
ci->dependencies.reserve(dependency_count);
|
ci->dependencies.reserve(dependency_count);
|
||||||
|
@ -276,10 +274,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||||
p->Send_uint8((uint8_t)ci->type);
|
p->Send_uint8((uint8_t)ci->type);
|
||||||
p->Send_uint32(ci->unique_id);
|
p->Send_uint32(ci->unique_id);
|
||||||
if (!send_md5sum) continue;
|
if (!send_md5sum) continue;
|
||||||
|
p->Send_bytes(ci->md5sum);
|
||||||
for (size_t j = 0; j < ci->md5sum.size(); j++) {
|
|
||||||
p->Send_uint8(ci->md5sum[j]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SendPacket(std::move(p));
|
this->SendPacket(std::move(p));
|
||||||
|
|
Loading…
Reference in New Issue