# core.h

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00014 #ifndef NETWORK_CORE_H
    00015 #define NETWORK_CORE_H
    00016
    00017 #include "os_abstraction.h"
    00018 #include "../../newgrf_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 Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf);
    00079   void Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf);
    00080   void Send_CompanyInformation(Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats);
    00081 };
    00082
    00083 #endif /* ENABLE_NETWORK */
    00084
    00085 #endif /* NETWORK_CORE_H */