(svn r8316) -Codechange: move the GRF ID and MD5 checksum from GRFConfig to GRFIdentifier so it can be reused.
authorrubidium
Sun, 21 Jan 2007 17:29:38 +0000
changeset 5765 27dbbe543fcf
parent 5764 c30289780789
child 5766 1980eef57c7d
(svn r8316) -Codechange: move the GRF ID and MD5 checksum from GRFConfig to GRFIdentifier so it can be reused.
src/network/core/udp.cpp
src/network/core/udp.h
src/newgrf_config.cpp
src/newgrf_config.h
--- a/src/network/core/udp.cpp	Sun Jan 21 17:09:32 2007 +0000
+++ b/src/network/core/udp.cpp	Sun Jan 21 17:29:38 2007 +0000
@@ -149,29 +149,29 @@
 
 /**
  * Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet
- * @param p the packet to write the data to
- * @param c the configuration to write the GRF ID and MD5 checksum from
+ * @param p   the packet to write the data to
+ * @param grf the GRFIdentifier to serialize
  */
-void NetworkUDPSocketHandler::Send_GRFIdentifier(Packet *p, const GRFConfig *c)
+void NetworkUDPSocketHandler::Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf)
 {
 	uint j;
-	NetworkSend_uint32(p, c->grfid);
-	for (j = 0; j < sizeof(c->md5sum); j++) {
-		NetworkSend_uint8 (p, c->md5sum[j]);
+	NetworkSend_uint32(p, grf->grfid);
+	for (j = 0; j < sizeof(grf->md5sum); j++) {
+		NetworkSend_uint8 (p, grf->md5sum[j]);
 	}
 }
 
 /**
  * Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet
- * @param p  the packet to read the data from
- * @param c  the configuration to write the GRF ID and MD5 checksum to
+ * @param p   the packet to read the data from
+ * @param grf the GRFIdentifier to deserialize
  */
-void NetworkUDPSocketHandler::Recv_GRFIdentifier(Packet *p, GRFConfig *c)
+void NetworkUDPSocketHandler::Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf)
 {
 	uint j;
-	c->grfid = NetworkRecv_uint32(this, p);
-	for (j = 0; j < sizeof(c->md5sum); j++) {
-		c->md5sum[j] = NetworkRecv_uint8(this, p);
+	grf->grfid = NetworkRecv_uint32(this, p);
+	for (j = 0; j < sizeof(grf->md5sum); j++) {
+		grf->md5sum[j] = NetworkRecv_uint8(this, p);
 	}
 }
 
--- a/src/network/core/udp.h	Sun Jan 21 17:09:32 2007 +0000
+++ b/src/network/core/udp.h	Sun Jan 21 17:29:38 2007 +0000
@@ -129,10 +129,10 @@
 	void SendPacket(Packet *p, const struct sockaddr_in *recv);
 	void ReceivePackets();
 
-	void Send_GRFIdentifier(Packet *p, const GRFConfig *c);
+	void Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf);
 	void Send_NetworkGameInfo(Packet *p, const NetworkGameInfo *info);
 
-	void Recv_GRFIdentifier(Packet *p, GRFConfig *c);
+	void Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf);
 	void Recv_NetworkGameInfo(Packet *p, NetworkGameInfo *info);
 };
 
--- a/src/newgrf_config.cpp	Sun Jan 21 17:09:32 2007 +0000
+++ b/src/newgrf_config.cpp	Sun Jan 21 17:29:38 2007 +0000
@@ -352,10 +352,8 @@
 
 /** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */
 typedef struct UnknownGRF UnknownGRF;
-struct UnknownGRF {
+struct UnknownGRF : public GRFIdentifier {
 	UnknownGRF *next;
-	uint32 grfid;
-	uint8  md5sum[16];
 	char   name[NETWORK_GRF_NAME_LENGTH];
 };
 
--- a/src/newgrf_config.h	Sun Jan 21 17:09:32 2007 +0000
+++ b/src/newgrf_config.h	Sun Jan 21 17:29:38 2007 +0000
@@ -15,14 +15,17 @@
 	GCF_COPY,      ///< The data is copied from a grf in _all_grfs
 } GCF_Flags;
 
-typedef struct GRFConfig {
+typedef struct GRFIdentifier {
+	uint32 grfid;
+	uint8 md5sum[16];
+} GRF;
+
+typedef struct GRFConfig : public GRFIdentifier {
 	char *filename;
 	char *name;
 	char *info;
-	uint32 grfid;
 
 	uint8 flags;
-	uint8 md5sum[16];
 	uint32 param[0x80];
 	uint8 num_params;