# network_internal.h

Go to the documentation of this file.

    00001 /* $Id: network_internal.h 26370 2014-02-23 19:32:32Z frosch $ */
    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_INTERNAL_H
    00013 #define NETWORK_INTERNAL_H
    00014
    00015 #include "network_func.h"
    00016 #include "core/tcp_game.h"
    00017
    00018 #include "../command_type.h"
    00019
    00020 #ifdef ENABLE_NETWORK
    00021
    00022 #ifdef RANDOM_DEBUG
    00023
    00032 #define ENABLE_NETWORK_SYNC_EVERY_FRAME
    00033
    00038 #define NETWORK_SEND_DOUBLE_SEED
    00039 #endif /* RANDOM_DEBUG */
    00040
    00048 #ifdef DEBUG_DUMP_COMMANDS
    00049 extern bool _ddc_fastforward;
    00050 #else
    00051 #define _ddc_fastforward (false)
    00052 #endif /* DEBUG_DUMP_COMMANDS */
    00053
    00054 typedef class ServerNetworkGameSocketHandler NetworkClientSocket;
    00055
    00057 enum NetworkJoinStatus {
    00058   NETWORK_JOIN_STATUS_CONNECTING,
    00059   NETWORK_JOIN_STATUS_AUTHORIZING,
    00060   NETWORK_JOIN_STATUS_WAITING,
    00061   NETWORK_JOIN_STATUS_DOWNLOADING,
    00062   NETWORK_JOIN_STATUS_PROCESSING,
    00063   NETWORK_JOIN_STATUS_REGISTERING,
    00064
    00065   NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
    00066   NETWORK_JOIN_STATUS_END,
    00067 };
    00068
    00070 enum NetworkLanguage {
    00071   NETLANG_ANY = 0,
    00072   NETLANG_ENGLISH,
    00073   NETLANG_GERMAN,
    00074   NETLANG_FRENCH,
    00075   NETLANG_BRAZILIAN,
    00076   NETLANG_BULGARIAN,
    00077   NETLANG_CHINESE,
    00078   NETLANG_CZECH,
    00079   NETLANG_DANISH,
    00080   NETLANG_DUTCH,
    00081   NETLANG_ESPERANTO,
    00082   NETLANG_FINNISH,
    00083   NETLANG_HUNGARIAN,
    00084   NETLANG_ICELANDIC,
    00085   NETLANG_ITALIAN,
    00086   NETLANG_JAPANESE,
    00087   NETLANG_KOREAN,
    00088   NETLANG_LITHUANIAN,
    00089   NETLANG_NORWEGIAN,
    00090   NETLANG_POLISH,
    00091   NETLANG_PORTUGUESE,
    00092   NETLANG_ROMANIAN,
    00093   NETLANG_RUSSIAN,
    00094   NETLANG_SLOVAK,
    00095   NETLANG_SLOVENIAN,
    00096   NETLANG_SPANISH,
    00097   NETLANG_SWEDISH,
    00098   NETLANG_TURKISH,
    00099   NETLANG_UKRAINIAN,
    00100   NETLANG_AFRIKAANS,
    00101   NETLANG_CROATIAN,
    00102   NETLANG_CATALAN,
    00103   NETLANG_ESTONIAN,
    00104   NETLANG_GALICIAN,
    00105   NETLANG_GREEK,
    00106   NETLANG_LATVIAN,
    00107   NETLANG_COUNT
    00108 };
    00109
    00110 extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
    00111 extern uint32 _frame_counter_max; // To where we may go with our clients
    00112 extern uint32 _frame_counter;
    00113
    00114 extern uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
    00115
    00116 /* networking settings */
    00117 extern NetworkAddressList _broadcast_list;
    00118
    00119 extern uint32 _sync_seed_1;
    00120 #ifdef NETWORK_SEND_DOUBLE_SEED
    00121 extern uint32 _sync_seed_2;
    00122 #endif
    00123 extern uint32 _sync_frame;
    00124 extern bool _network_first_time;
    00125 /* Vars needed for the join-GUI */
    00126 extern NetworkJoinStatus _network_join_status;
    00127 extern uint8 _network_join_waiting;
    00128 extern uint32 _network_join_bytes;
    00129 extern uint32 _network_join_bytes_total;
    00130
    00131 extern uint8 _network_reconnect;
    00132
    00133 extern bool _network_udp_server;
    00134 extern uint16 _network_udp_broadcast;
    00135
    00136 extern uint8 _network_advertise_retries;
    00137
    00138 extern CompanyMask _network_company_passworded;
    00139
    00140 void NetworkTCPQueryServer(NetworkAddress address);
    00141
    00142 void GetBindAddresses(NetworkAddressList *addresses, uint16 port);
    00143 void NetworkAddServer(const char *b);
    00144 void NetworkRebuildHostList();
    00145 void UpdateNetworkGameWindow();
    00146
    00147 bool IsNetworkCompatibleVersion(const char *version);
    00148
    00149 /* From network_command.cpp */
    00153 struct CommandPacket : CommandContainer {
    00155   CommandPacket() : next(NULL), company(INVALID_COMPANY), frame(0), my_cmd(false) {}
    00156   CommandPacket *next;
    00157   CompanyID company;
    00158   uint32 frame;
    00159   bool my_cmd;
    00160 };
    00161
    00162 void NetworkDistributeCommands();
    00163 void NetworkExecuteLocalCommandQueue();
    00164 void NetworkFreeLocalCommandQueue();
    00165 void NetworkSyncCommandQueue(NetworkClientSocket *cs);
    00166
    00167 void NetworkError(StringID error_string);
    00168 void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const char *name, const char *str = "", int64 data = 0);
    00169 uint NetworkCalculateLag(const NetworkClientSocket *cs);
    00170 StringID GetNetworkErrorMsg(NetworkErrorCode err);
    00171 bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
    00172 const char *GenerateCompanyPasswordHash(const char *password, const char *password_server_id, uint32 password_game_seed);
    00173
    00174 #endif /* ENABLE_NETWORK */
    00175 #endif /* NETWORK_INTERNAL_H */