OpenTTD
network_internal.h
Go to the documentation of this file.
1 /* $Id: network_internal.h 26488 2014-04-23 21:19:54Z rubidium $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef NETWORK_INTERNAL_H
13 #define NETWORK_INTERNAL_H
14 
15 #include "network_func.h"
16 #include "core/tcp_game.h"
17 
18 #include "../command_type.h"
19 
20 #ifdef ENABLE_NETWORK
21 
22 #ifdef RANDOM_DEBUG
23 
32 #define ENABLE_NETWORK_SYNC_EVERY_FRAME
33 
38 #define NETWORK_SEND_DOUBLE_SEED
39 #endif /* RANDOM_DEBUG */
40 
48 #ifdef DEBUG_DUMP_COMMANDS
49 extern bool _ddc_fastforward;
50 #else
51 #define _ddc_fastforward (false)
52 #endif /* DEBUG_DUMP_COMMANDS */
53 
54 typedef class ServerNetworkGameSocketHandler NetworkClientSocket;
55 
58  NETWORK_JOIN_STATUS_CONNECTING,
59  NETWORK_JOIN_STATUS_AUTHORIZING,
60  NETWORK_JOIN_STATUS_WAITING,
61  NETWORK_JOIN_STATUS_DOWNLOADING,
62  NETWORK_JOIN_STATUS_PROCESSING,
63  NETWORK_JOIN_STATUS_REGISTERING,
64 
65  NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
66  NETWORK_JOIN_STATUS_END,
67 };
68 
71  NETLANG_ANY = 0,
72  NETLANG_ENGLISH,
73  NETLANG_GERMAN,
74  NETLANG_FRENCH,
75  NETLANG_BRAZILIAN,
76  NETLANG_BULGARIAN,
77  NETLANG_CHINESE,
78  NETLANG_CZECH,
79  NETLANG_DANISH,
80  NETLANG_DUTCH,
81  NETLANG_ESPERANTO,
82  NETLANG_FINNISH,
83  NETLANG_HUNGARIAN,
84  NETLANG_ICELANDIC,
85  NETLANG_ITALIAN,
86  NETLANG_JAPANESE,
87  NETLANG_KOREAN,
88  NETLANG_LITHUANIAN,
89  NETLANG_NORWEGIAN,
90  NETLANG_POLISH,
91  NETLANG_PORTUGUESE,
92  NETLANG_ROMANIAN,
93  NETLANG_RUSSIAN,
94  NETLANG_SLOVAK,
95  NETLANG_SLOVENIAN,
96  NETLANG_SPANISH,
97  NETLANG_SWEDISH,
98  NETLANG_TURKISH,
99  NETLANG_UKRAINIAN,
100  NETLANG_AFRIKAANS,
101  NETLANG_CROATIAN,
102  NETLANG_CATALAN,
103  NETLANG_ESTONIAN,
104  NETLANG_GALICIAN,
105  NETLANG_GREEK,
106  NETLANG_LATVIAN,
107  NETLANG_COUNT
108 };
109 
110 extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
111 extern uint32 _frame_counter_max; // To where we may go with our clients
112 extern uint32 _frame_counter;
113 
114 extern uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
115 
116 /* networking settings */
118 
119 extern uint32 _sync_seed_1;
120 #ifdef NETWORK_SEND_DOUBLE_SEED
121 extern uint32 _sync_seed_2;
122 #endif
123 extern uint32 _sync_frame;
124 extern bool _network_first_time;
125 /* Vars needed for the join-GUI */
127 extern uint8 _network_join_waiting;
128 extern uint32 _network_join_bytes;
129 extern uint32 _network_join_bytes_total;
130 
131 extern uint8 _network_reconnect;
132 
133 extern bool _network_udp_server;
134 extern uint16 _network_udp_broadcast;
135 
136 extern uint8 _network_advertise_retries;
137 
138 extern CompanyMask _network_company_passworded;
139 
140 void NetworkTCPQueryServer(NetworkAddress address);
141 
142 void GetBindAddresses(NetworkAddressList *addresses, uint16 port);
143 void NetworkAddServer(const char *b);
144 void NetworkRebuildHostList();
146 
147 bool IsNetworkCompatibleVersion(const char *version);
148 
149 /* From network_command.cpp */
158  uint32 frame;
159  bool my_cmd;
160 };
161 
165 void NetworkSyncCommandQueue(NetworkClientSocket *cs);
166 
167 void NetworkError(StringID error_string);
168 void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const char *name, const char *str = "", int64 data = 0);
169 uint NetworkCalculateLag(const NetworkClientSocket *cs);
171 bool NetworkFindName(char *new_name, const char *last);
172 const char *GenerateCompanyPasswordHash(const char *password, const char *password_server_id, uint32 password_game_seed);
173 
174 #endif /* ENABLE_NETWORK */
175 #endif /* NETWORK_INTERNAL_H */