290 |
290 |
291 // If PacketSize changes of size, you have to change the 2 packet->size |
291 // If PacketSize changes of size, you have to change the 2 packet->size |
292 // lines below matching the size of packet->size/PacketSize! |
292 // lines below matching the size of packet->size/PacketSize! |
293 // (the line: 'p->size = (uint16)p->buffer[0];' and below) |
293 // (the line: 'p->size = (uint16)p->buffer[0];' and below) |
294 assert_compile(sizeof(PacketSize) == 2); |
294 assert_compile(sizeof(PacketSize) == 2); |
|
295 |
|
296 |
|
297 /** |
|
298 * Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet |
|
299 * @param p the packet to write the data to |
|
300 * @param c the configuration to write the GRF ID and MD5 checksum from |
|
301 */ |
|
302 void NetworkSend_GRFIdentifier(Packet *p, const GRFConfig *c) |
|
303 { |
|
304 uint j; |
|
305 NetworkSend_uint32(p, c->grfid); |
|
306 for (j = 0; j < sizeof(c->md5sum); j++) { |
|
307 NetworkSend_uint8 (p, c->md5sum[j]); |
|
308 } |
|
309 } |
|
310 |
|
311 /** |
|
312 * Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet |
|
313 * @param p the packet to read the data from |
|
314 * @param c the configuration to write the GRF ID and MD5 checksum to |
|
315 */ |
|
316 void NetworkRecv_GRFIdentifier(NetworkClientState *cs, Packet *p, GRFConfig *c) |
|
317 { |
|
318 uint j; |
|
319 c->grfid = NetworkRecv_uint32(cs, p); |
|
320 for (j = 0; j < sizeof(c->md5sum); j++) { |
|
321 c->md5sum[j] = NetworkRecv_uint8(cs, p); |
|
322 } |
|
323 } |
|
324 |
295 |
325 |
296 Packet *NetworkRecv_Packet(NetworkClientState *cs, NetworkRecvStatus *status) |
326 Packet *NetworkRecv_Packet(NetworkClientState *cs, NetworkRecvStatus *status) |
297 { |
327 { |
298 ssize_t res; |
328 ssize_t res; |
299 Packet *p; |
329 Packet *p; |