Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00014 #ifndef NETWORK_CORE_CORE_H
00015 #define NETWORK_CORE_CORE_H
00016
00017 #include "../../newgrf_config.h"
00018 #include "config.h"
00019
00020 #ifdef ENABLE_NETWORK
00021
00022 bool NetworkCoreInitialize();
00023 void NetworkCoreShutdown();
00024
00026 enum NetworkRecvStatus {
00027 NETWORK_RECV_STATUS_OKAY,
00028 NETWORK_RECV_STATUS_DESYNC,
00029 NETWORK_RECV_STATUS_NEWGRF_MISMATCH,
00030 NETWORK_RECV_STATUS_SAVEGAME,
00031 NETWORK_RECV_STATUS_CONN_LOST,
00032 NETWORK_RECV_STATUS_MALFORMED_PACKET,
00033 NETWORK_RECV_STATUS_SERVER_ERROR,
00034 NETWORK_RECV_STATUS_SERVER_FULL,
00035 NETWORK_RECV_STATUS_SERVER_BANNED,
00036 NETWORK_RECV_STATUS_CLOSE_QUERY,
00037 };
00038
00040 struct Packet;
00041
00045 class NetworkSocketHandler {
00046 bool has_quit;
00047 public:
00049 NetworkSocketHandler() { this->has_quit = false; }
00050
00052 virtual ~NetworkSocketHandler() { this->Close(); }
00053
00055 virtual void Close() {}
00056
00063 virtual NetworkRecvStatus CloseConnection(bool error = true) { this->has_quit = true; return NETWORK_RECV_STATUS_OKAY; }
00064
00071 bool HasClientQuit() const { return this->has_quit; }
00072
00076 void Reopen() { this->has_quit = false; }
00077
00078 void SendGRFIdentifier(Packet *p, const GRFIdentifier *grf);
00079 void ReceiveGRFIdentifier(Packet *p, GRFIdentifier *grf);
00080 void SendCompanyInformation(Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats, uint max_len = NETWORK_COMPANY_NAME_LENGTH);
00081 };
00082
00083 #endif
00084
00085 #endif