# network_type.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
    00012 #ifndef NETWORK_TYPE_H
    00013 #define NETWORK_TYPE_H
    00014
    00015 #include "core/game.h"
    00016
    00017 #ifdef ENABLE_NETWORK
    00018
    00020 static const uint MAX_CLIENTS = 255;
    00021
    00027 static const uint MAX_CLIENT_SLOTS = 256;
    00028
    00032 enum NetworkVehicleType {
    00033   NETWORK_VEH_TRAIN = 0,
    00034   NETWORK_VEH_LORRY,
    00035   NETWORK_VEH_BUS,
    00036   NETWORK_VEH_PLANE,
    00037   NETWORK_VEH_SHIP,
    00038
    00039   NETWORK_VEH_END
    00040 };
    00041
    00043 enum ClientID {
    00044   INVALID_CLIENT_ID = 0,
    00045   CLIENT_ID_SERVER  = 1,
    00046   CLIENT_ID_FIRST   = 2,
    00047 };
    00048
    00050 typedef uint8 ClientIndex;
    00051
    00053 typedef uint8 AdminIndex;
    00054
    00056 static const AdminIndex MAX_ADMINS = 16;
    00058 static const AdminIndex INVALID_ADMIN_ID = UINT8_MAX;
    00059
    00061 struct NetworkCompanyStats {
    00062   uint16 num_vehicle[NETWORK_VEH_END];
    00063   uint16 num_station[NETWORK_VEH_END];
    00064   bool ai;
    00065 };
    00066
    00068 struct NetworkCompanyState {
    00069   char password[NETWORK_PASSWORD_LENGTH];
    00070   uint16 months_empty;
    00071 };
    00072
    00073 struct NetworkClientInfo;
    00074
    00075 enum NetworkPasswordType {
    00076   NETWORK_GAME_PASSWORD,
    00077   NETWORK_COMPANY_PASSWORD,
    00078 };
    00079
    00080 enum DestType {
    00081   DESTTYPE_BROADCAST,
    00082   DESTTYPE_TEAM,
    00083   DESTTYPE_CLIENT,
    00084 };
    00085
    00087 enum NetworkAction {
    00088   NETWORK_ACTION_JOIN,
    00089   NETWORK_ACTION_LEAVE,
    00090   NETWORK_ACTION_SERVER_MESSAGE,
    00091   NETWORK_ACTION_CHAT,
    00092   NETWORK_ACTION_CHAT_COMPANY,
    00093   NETWORK_ACTION_CHAT_CLIENT,
    00094   NETWORK_ACTION_GIVE_MONEY,
    00095   NETWORK_ACTION_NAME_CHANGE,
    00096   NETWORK_ACTION_COMPANY_SPECTATOR,
    00097   NETWORK_ACTION_COMPANY_JOIN,
    00098   NETWORK_ACTION_COMPANY_NEW,
    00099 };
    00100
    00101 enum NetworkErrorCode {
    00102   NETWORK_ERROR_GENERAL, // Try to use this one like never
    00103
    00104   /* Signals from clients */
    00105   NETWORK_ERROR_DESYNC,
    00106   NETWORK_ERROR_SAVEGAME_FAILED,
    00107   NETWORK_ERROR_CONNECTION_LOST,
    00108   NETWORK_ERROR_ILLEGAL_PACKET,
    00109   NETWORK_ERROR_NEWGRF_MISMATCH,
    00110
    00111   /* Signals from servers */
    00112   NETWORK_ERROR_NOT_AUTHORIZED,
    00113   NETWORK_ERROR_NOT_EXPECTED,
    00114   NETWORK_ERROR_WRONG_REVISION,
    00115   NETWORK_ERROR_NAME_IN_USE,
    00116   NETWORK_ERROR_WRONG_PASSWORD,
    00117   NETWORK_ERROR_COMPANY_MISMATCH, // Happens in CLIENT_COMMAND
    00118   NETWORK_ERROR_KICKED,
    00119   NETWORK_ERROR_CHEATER,
    00120   NETWORK_ERROR_FULL,
    00121   NETWORK_ERROR_TOO_MANY_COMMANDS,
    00122 };
    00123
    00124 #endif /* ENABLE_NETWORK */
    00125 #endif /* NETWORK_TYPE_H */