# core.h

Go to the documentation of this file.

    00001 /* $Id: core.h 18809 2010-01-15 16:41:15Z rubidium $ */
    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 "../../newgrf_config.h"
    00018
    00019 #ifdef ENABLE_NETWORK
    00020
    00021 bool NetworkCoreInitialize();
    00022 void NetworkCoreShutdown();
    00023
    00025 enum NetworkRecvStatus {
    00026   NETWORK_RECV_STATUS_OKAY,
    00027   NETWORK_RECV_STATUS_DESYNC,
    00028   NETWORK_RECV_STATUS_NEWGRF_MISMATCH,
    00029   NETWORK_RECV_STATUS_SAVEGAME,
    00030   NETWORK_RECV_STATUS_CONN_LOST,
    00031   NETWORK_RECV_STATUS_MALFORMED_PACKET,
    00032   NETWORK_RECV_STATUS_SERVER_ERROR,
    00033   NETWORK_RECV_STATUS_SERVER_FULL,
    00034   NETWORK_RECV_STATUS_SERVER_BANNED,
    00035   NETWORK_RECV_STATUS_CLOSE_QUERY,
    00036 };
    00037
    00039 struct Packet;
    00040
    00044 class NetworkSocketHandler {
    00045   bool has_quit;
    00046 public:
    00048   NetworkSocketHandler() { this->has_quit = false; }
    00049
    00051   virtual ~NetworkSocketHandler() { this->Close(); }
    00052
    00054   virtual void Close() {}
    00055
    00062   virtual NetworkRecvStatus CloseConnection(bool error = true) { this->has_quit = true; return NETWORK_RECV_STATUS_OKAY; }
    00063
    00070   bool HasClientQuit() const { return this->has_quit; }
    00071
    00075   void Reopen() { this->has_quit = false; }
    00076
    00077   void Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf);
    00078   void Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf);
    00079   void Send_CompanyInformation(Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats);
    00080 };
    00081
    00082 #endif /* ENABLE_NETWORK */
    00083
    00084 #endif /* NETWORK_CORE_H */