Files
@ r9427:177da75469a5
Branch filter:
Location: cpp/openttd-patchpack/source/src/network/network_internal.h
r9427:177da75469a5
6.3 KiB
text/x-c
(svn r13342) -Fix: smallvec.h/sortlist_type.h didn't include everything they needed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | /* $Id$ */
/** @file network_internal.h Variables and function used internally. */
#ifndef NETWORK_INTERNAL_H
#define NETWORK_INTERNAL_H
#ifdef ENABLE_NETWORK
#include "../player_type.h"
#include "../economy_type.h"
#include "core/config.h"
#include "core/game.h"
/**
* If this line is enable, every frame will have a sync test
* this is not needed in normal games. Normal is like 1 sync in 100
* frames. You can enable this if you have a lot of desyncs on a certain
* game.
* Remember: both client and server have to be compiled with this
* option enabled to make it to work. If one of the two has it disabled
* nothing will happen.
*/
//#define ENABLE_NETWORK_SYNC_EVERY_FRAME
/**
* In theory sending 1 of the 2 seeds is enough to check for desyncs
* so in theory, this next define can be left off.
*/
//#define NETWORK_SEND_DOUBLE_SEED
enum {
/**
* How many clients can we have? Like.. MAX_PLAYERS - 1 is the amount of
* players that can really play.. so.. a max of 4 spectators.. gives us..
* MAX_PLAYERS + 3
*/
MAX_CLIENTS = MAX_PLAYERS + 3,
/** Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1 */
MAX_CLIENT_INFO = MAX_CLIENTS + 1,
/** Maximum number of internet interfaces supported. */
MAX_INTERFACES = 9,
/** How many vehicle/station types we put over the network */
NETWORK_VEHICLE_TYPES = 5,
NETWORK_STATION_TYPES = 5,
};
struct NetworkPlayerInfo {
char company_name[NETWORK_NAME_LENGTH]; ///< Company name
char password[NETWORK_PASSWORD_LENGTH]; ///< The password for the player
Year inaugurated_year; ///< What year the company started in
Money company_value; ///< The company value
Money money; ///< The amount of money the company has
Money income; ///< How much did the company earned last year
uint16 performance; ///< What was his performance last month?
bool use_password; ///< Is there a password
uint16 num_vehicle[NETWORK_VEHICLE_TYPES]; ///< How many vehicles are there of this type?
uint16 num_station[NETWORK_STATION_TYPES]; ///< How many stations are there of this type?
char players[NETWORK_PLAYERS_LENGTH]; ///< The players that control this company (Name1, name2, ..)
uint16 months_empty; ///< How many months the company is empty
};
struct NetworkClientInfo {
uint16 client_index; ///< Index of the client (same as ClientState->index)
char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< Name of the client
byte client_lang; ///< The language of the client
PlayerID client_playas; ///< As which player is this client playing (PlayerID)
uint32 client_ip; ///< IP-address of the client (so he can be banned)
Date join_date; ///< Gamedate the player has joined
char unique_id[NETWORK_UNIQUE_ID_LENGTH]; ///< Every play sends an unique id so we can indentify him
};
enum NetworkJoinStatus {
NETWORK_JOIN_STATUS_CONNECTING,
NETWORK_JOIN_STATUS_AUTHORIZING,
NETWORK_JOIN_STATUS_WAITING,
NETWORK_JOIN_STATUS_DOWNLOADING,
NETWORK_JOIN_STATUS_PROCESSING,
NETWORK_JOIN_STATUS_REGISTERING,
NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
};
/** Language ids for server_lang and client_lang. Do NOT modify the order. */
enum NetworkLanguage {
NETLANG_ANY = 0,
NETLANG_ENGLISH,
NETLANG_GERMAN,
NETLANG_FRENCH,
NETLANG_BRAZILIAN,
NETLANG_BULGARIAN,
NETLANG_CHINESE,
NETLANG_CZECH,
NETLANG_DANISH,
NETLANG_DUTCH,
NETLANG_ESPERANTO,
NETLANG_FINNISH,
NETLANG_HUNGARIAN,
NETLANG_ICELANDIC,
NETLANG_ITALIAN,
NETLANG_JAPANESE,
NETLANG_KOREAN,
NETLANG_LITHUANIAN,
NETLANG_NORWEGIAN,
NETLANG_POLISH,
NETLANG_PORTUGUESE,
NETLANG_ROMANIAN,
NETLANG_RUSSIAN,
NETLANG_SLOVAK,
NETLANG_SLOVENIAN,
NETLANG_SPANISH,
NETLANG_SWEDISH,
NETLANG_TURKISH,
NETLANG_UKRAINIAN,
NETLANG_AFRIKAANS,
NETLANG_CROATIAN,
NETLANG_CATALAN,
NETLANG_ESTONIAN,
NETLANG_GALICIAN,
NETLANG_GREEK,
NETLANG_LATVIAN,
NETLANG_COUNT
};
VARDEF NetworkGameInfo _network_game_info;
VARDEF NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
VARDEF NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
VARDEF uint16 _network_own_client_index;
VARDEF uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
VARDEF uint32 _frame_counter_max; // To where we may go with our clients
VARDEF uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
// networking settings
VARDEF uint32 _broadcast_list[MAX_INTERFACES + 1];
VARDEF uint32 _network_server_bind_ip;
VARDEF bool _is_network_server; // Does this client wants to be a network-server?
VARDEF uint16 _redirect_console_to_client;
VARDEF uint32 _sync_seed_1, _sync_seed_2;
VARDEF uint32 _sync_frame;
VARDEF bool _network_first_time;
// Vars needed for the join-GUI
VARDEF NetworkJoinStatus _network_join_status;
VARDEF uint8 _network_join_waiting;
VARDEF uint16 _network_join_kbytes;
VARDEF uint16 _network_join_kbytes_total;
VARDEF uint32 _network_last_host_ip;
VARDEF uint8 _network_reconnect;
VARDEF bool _network_udp_server;
VARDEF uint16 _network_udp_broadcast;
VARDEF bool _network_need_advertise;
VARDEF uint32 _network_last_advertise_frame;
VARDEF uint8 _network_advertise_retries;
void NetworkTCPQueryServer(const char* host, unsigned short port);
byte NetworkSpectatorCount();
VARDEF char *_network_host_list[10];
VARDEF char *_network_ban_list[25];
void ParseConnectionString(const char **player, const char **port, char *connection_string);
void NetworkUpdateClientInfo(uint16 client_index);
void NetworkAddServer(const char *b);
void NetworkRebuildHostList();
bool NetworkChangeCompanyPassword(byte argc, char *argv[]);
void NetworkPopulateCompanyInfo();
void UpdateNetworkGameWindow(bool unselect);
void CheckMinPlayers();
void NetworkStartDebugLog(const char *hostname, uint16 port);
void NetworkUDPCloseAll();
void NetworkGameLoop();
void NetworkUDPGameLoop();
bool NetworkServerStart();
bool NetworkClientConnectGame(const char *host, uint16 port);
void NetworkReboot();
void NetworkDisconnect();
bool IsNetworkCompatibleVersion(const char *version);
#endif /* ENABLE_NETWORK */
#endif /* NETWORK_INTERNAL_H */
|