mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-07 06:46:43 +00:00
(svn r8459) -Codechange: move (Send|Recv)GRFIdentifier to NetworkSocketHandler, so it can also be used the TCP socket handler.
This commit is contained in:
parent
7feba09d9f
commit
291b7925ee
@ -5,6 +5,8 @@
|
|||||||
#include "../../stdafx.h"
|
#include "../../stdafx.h"
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
#include "os_abstraction.h"
|
#include "os_abstraction.h"
|
||||||
|
#include "core.h"
|
||||||
|
#include "packet.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file core.cpp Functions used to initialize/shut down the core network
|
* @file core.cpp Functions used to initialize/shut down the core network
|
||||||
@ -88,4 +90,33 @@ void NetworkCoreShutdown(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet
|
||||||
|
* @param p the packet to write the data to
|
||||||
|
* @param grf the GRFIdentifier to serialize
|
||||||
|
*/
|
||||||
|
void NetworkSocketHandler::Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf)
|
||||||
|
{
|
||||||
|
uint 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 grf the GRFIdentifier to deserialize
|
||||||
|
*/
|
||||||
|
void NetworkSocketHandler::Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf)
|
||||||
|
{
|
||||||
|
uint j;
|
||||||
|
grf->grfid = NetworkRecv_uint32(this, p);
|
||||||
|
for (j = 0; j < sizeof(grf->md5sum); j++) {
|
||||||
|
grf->md5sum[j] = NetworkRecv_uint8(this, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
|
|
||||||
#include "os_abstraction.h"
|
#include "os_abstraction.h"
|
||||||
|
#include "../../newgrf_config.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file core.h Base for all network types (UDP and TCP)
|
* @file core.h Base for all network types (UDP and TCP)
|
||||||
@ -27,6 +28,9 @@ typedef enum {
|
|||||||
NETWORK_RECV_STATUS_CLOSE_QUERY, ///< Done quering the server
|
NETWORK_RECV_STATUS_CLOSE_QUERY, ///< Done quering the server
|
||||||
} NetworkRecvStatus;
|
} NetworkRecvStatus;
|
||||||
|
|
||||||
|
/** Forward declaration due to circular dependencies */
|
||||||
|
class Packet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SocketHandler for all network sockets in OpenTTD.
|
* SocketHandler for all network sockets in OpenTTD.
|
||||||
*/
|
*/
|
||||||
@ -66,6 +70,9 @@ public:
|
|||||||
* @return true when the current client has quit, false otherwise
|
* @return true when the current client has quit, false otherwise
|
||||||
*/
|
*/
|
||||||
bool HasClientQuit() { return this->has_quit; }
|
bool HasClientQuit() { return this->has_quit; }
|
||||||
|
|
||||||
|
void Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf);
|
||||||
|
void Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
@ -143,35 +143,6 @@ void NetworkUDPSocketHandler::ReceivePackets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet
|
|
||||||
* @param p the packet to write the data to
|
|
||||||
* @param grf the GRFIdentifier to serialize
|
|
||||||
*/
|
|
||||||
void NetworkUDPSocketHandler::Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf)
|
|
||||||
{
|
|
||||||
uint 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 grf the GRFIdentifier to deserialize
|
|
||||||
*/
|
|
||||||
void NetworkUDPSocketHandler::Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf)
|
|
||||||
{
|
|
||||||
uint j;
|
|
||||||
grf->grfid = NetworkRecv_uint32(this, p);
|
|
||||||
for (j = 0; j < sizeof(grf->md5sum); j++) {
|
|
||||||
grf->md5sum[j] = NetworkRecv_uint8(this, p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes the NetworkGameInfo struct to the packet
|
* Serializes the NetworkGameInfo struct to the packet
|
||||||
* @param p the packet to write the data to
|
* @param p the packet to write the data to
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
#include "../../newgrf_config.h"
|
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,10 +130,7 @@ public:
|
|||||||
void SendPacket(Packet *p, const struct sockaddr_in *recv);
|
void SendPacket(Packet *p, const struct sockaddr_in *recv);
|
||||||
void ReceivePackets();
|
void ReceivePackets();
|
||||||
|
|
||||||
void Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf);
|
|
||||||
void Send_NetworkGameInfo(Packet *p, const NetworkGameInfo *info);
|
void Send_NetworkGameInfo(Packet *p, const NetworkGameInfo *info);
|
||||||
|
|
||||||
void Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf);
|
|
||||||
void Recv_NetworkGameInfo(Packet *p, NetworkGameInfo *info);
|
void Recv_NetworkGameInfo(Packet *p, NetworkGameInfo *info);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user