network.h
author ludde
Fri, 15 Jul 2005 18:43:39 +0000
changeset 2071 37c57d697d9b
parent 1812 5b4d1af6b904
child 2079 5afd2e7fc3bd
permissions -rw-r--r--
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
Change: Made code a little bit more readable by putting _selected_item in a local var with a shorter name.
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
     1
#ifndef NETWORK_H
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
     2
#define NETWORK_H
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
     3
663
3236ec743f75 (svn r1098) -Fix: server without revision build doesn't care about the client's version. Also moved all revision things where it belongs (network.c)
darkvater
parents: 662
diff changeset
     4
#define NOREV_STRING "norev000"
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
     5
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
     6
#ifdef ENABLE_NETWORK
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
     7
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
     8
// If this line is enable, every frame will have a sync test
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
     9
//  this is not needed in normal games. Normal is like 1 sync in 100
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    10
//  frames. You can enable this if you have a lot of desyncs on a certain
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    11
//  game.
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    12
// Remember: both client and server have to be compiled with this
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    13
//  option enabled to make it to work. If one of the two has it disabled
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    14
//  nothing will happen.
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    15
//#define ENABLE_NETWORK_SYNC_EVERY_FRAME
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    16
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    17
// In theory sending 1 of the 2 seeds is enough to check for desyncs
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    18
//   so in theory, this next define can be left off.
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    19
//#define NETWORK_SEND_DOUBLE_SEED
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    20
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    21
// How many clients can we have? Like.. MAX_PLAYERS - 1 is the amount of
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    22
//  players that can really play.. so.. a max of 4 spectators.. gives us..
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    23
//  MAX_PLAYERS + 3
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    24
#define MAX_CLIENTS (MAX_PLAYERS + 3)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    25
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    26
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    27
// Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    28
#define MAX_CLIENT_INFO (MAX_CLIENTS + 1)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    29
668
346853c8b513 (svn r1106) -Add: [Network] Added master-server protocol and advertise to
truelight
parents: 663
diff changeset
    30
/* Stuff for the master-server */
346853c8b513 (svn r1106) -Add: [Network] Added master-server protocol and advertise to
truelight
parents: 663
diff changeset
    31
#define NETWORK_MASTER_SERVER_PORT 3978
346853c8b513 (svn r1106) -Add: [Network] Added master-server protocol and advertise to
truelight
parents: 663
diff changeset
    32
#define NETWORK_MASTER_SERVER_HOST "master.openttd.org"
346853c8b513 (svn r1106) -Add: [Network] Added master-server protocol and advertise to
truelight
parents: 663
diff changeset
    33
#define NETWORK_MASTER_SERVER_WELCOME_MESSAGE "OpenTTDRegister"
346853c8b513 (svn r1106) -Add: [Network] Added master-server protocol and advertise to
truelight
parents: 663
diff changeset
    34
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    35
#define NETWORK_DEFAULT_PORT 3979
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    36
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    37
#define MAX_INTERFACES 9
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    38
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    39
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    40
// How many vehicle/station types we put over the network
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    41
#define NETWORK_VEHICLE_TYPES 5
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    42
#define NETWORK_STATION_TYPES 5
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    43
1026
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    44
enum {
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    45
	NETWORK_NAME_LENGTH        = 80,
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    46
	NETWORK_HOSTNAME_LENGTH    = 80,
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    47
	NETWORK_REVISION_LENGTH    = 10,
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    48
	NETWORK_PASSWORD_LENGTH    = 20,
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    49
	NETWORK_PLAYERS_LENGTH     = 200,
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    50
	NETWORK_CLIENT_NAME_LENGTH = 25,
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    51
	NETWORK_RCONCOMMAND_LENGTH = 500,
2071
37c57d697d9b (svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents: 1812
diff changeset
    52
37c57d697d9b (svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents: 1812
diff changeset
    53
	NETWORK_NUM_LANGUAGES      = 4,
1026
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    54
};
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    55
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    56
// This is the struct used by both client and server
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    57
//  some fields will be empty on the client (like game_password) by default
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    58
//  and only filled with data a player enters.
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
    59
typedef struct NetworkGameInfo {
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    60
	char server_name[NETWORK_NAME_LENGTH];					// Server name
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    61
	char hostname[NETWORK_HOSTNAME_LENGTH];					// Hostname of the server (if any)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    62
	char server_revision[NETWORK_REVISION_LENGTH];	// The SVN version number the server is using (e.g.: 'r304')
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    63
																									//  It even shows a SVN version in release-version, so
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    64
																									//  it is easy to compare if a server is of the correct version
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    65
	byte server_lang;																// Language of the server (we should make a nice table for this)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    66
	byte use_password;															// Is set to != 0 if it uses a password
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    67
	char server_password[NETWORK_PASSWORD_LENGTH];	// On the server: the game password, on the client: != "" if server has password
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    68
	byte clients_max;																// Max clients allowed on server
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    69
	byte clients_on;																// Current count of clients on server
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    70
	byte spectators_on;															// How many spectators do we have?
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    71
	uint16 game_date;																// Current date
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    72
	uint16 start_date;															// When the game started
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    73
	char map_name[NETWORK_NAME_LENGTH];							// Map which is played ["random" for a randomized map]
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    74
	uint16 map_width;																// Map width
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    75
	uint16 map_height;															// Map height
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    76
	byte map_set;																		// Graphical set
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    77
	bool dedicated;																	// Is this a dedicated server?
1026
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
    78
	char rcon_password[NETWORK_PASSWORD_LENGTH];		// RCon password for the server. "" if rcon is disabled
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
    79
} NetworkGameInfo;
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
    80
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    81
typedef struct NetworkPlayerInfo {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    82
	char company_name[NETWORK_NAME_LENGTH];					// Company name
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    83
	char password[NETWORK_PASSWORD_LENGTH];					// The password for the player
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    84
	byte inaugurated_year;													// What year the company started in
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    85
	int64 company_value;														// The company value
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    86
	int64 money;																		// The amount of money the company has
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    87
	int64 income;																		// How much did the company earned last year
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    88
	uint16 performance;															// What was his performance last month?
1011
2587838541bf (svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents: 841
diff changeset
    89
	byte use_password;													// 0: No password 1: There is a password
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    90
	uint16 num_vehicle[NETWORK_VEHICLE_TYPES];			// How many vehicles are there of this type?
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    91
	uint16 num_station[NETWORK_STATION_TYPES];			// How many stations are there of this type?
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    92
	char players[NETWORK_PLAYERS_LENGTH];						// The players that control this company (Name1, name2, ..)
690
9f449a6b133e (svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents: 670
diff changeset
    93
	uint16 months_empty;														// How many months the company is empty
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    94
} NetworkPlayerInfo;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    95
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    96
typedef struct NetworkClientInfo {
1804
7810fc0aa941 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1739
diff changeset
    97
	uint16 client_index;                          /// Index of the client (same as ClientState->index)
7810fc0aa941 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1739
diff changeset
    98
	char client_name[NETWORK_CLIENT_NAME_LENGTH]; /// Name of the client
7810fc0aa941 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1739
diff changeset
    99
	byte client_lang;                             /// The language of the client
7810fc0aa941 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1739
diff changeset
   100
	byte client_playas;                           /// As which player is this client playing (PlayerID)
7810fc0aa941 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1739
diff changeset
   101
	uint32 client_ip;                             /// IP-address of the client (so he can be banned)
7810fc0aa941 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1739
diff changeset
   102
	uint16 join_date;                             /// Gamedate the player has joined
7810fc0aa941 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1739
diff changeset
   103
	char unique_id[NETWORK_NAME_LENGTH];          /// Every play sends an unique id so we can indentify him
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   104
} NetworkClientInfo;
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
   105
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
   106
typedef struct NetworkGameList {
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   107
	NetworkGameInfo info;
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
   108
	uint32 ip;
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
   109
	uint16 port;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   110
	bool online;																		// False if the server did not respond (default status)
738
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 716
diff changeset
   111
	bool manually;																	// True if the server was added manually
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   112
	struct NetworkGameList *next;
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
   113
} NetworkGameList;
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
   114
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   115
typedef enum {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   116
	NETWORK_JOIN_STATUS_CONNECTING,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   117
	NETWORK_JOIN_STATUS_AUTHORIZING,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   118
	NETWORK_JOIN_STATUS_WAITING,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   119
	NETWORK_JOIN_STATUS_DOWNLOADING,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   120
	NETWORK_JOIN_STATUS_PROCESSING,
670
7c58dc46609c (svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents: 668
diff changeset
   121
	NETWORK_JOIN_STATUS_REGISTERING,
239
23958632a582 (svn r240) -Fix: desync on subsidy generation
signde
parents: 228
diff changeset
   122
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   123
	NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   124
} NetworkJoinStatus;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   125
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   126
// language ids for server_lang and client_lang
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   127
typedef enum {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   128
	NETLANG_ANY = 0,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   129
	NETLANG_ENGLISH = 1,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   130
	NETLANG_GERMAN = 2,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   131
	NETLANG_FRENCH = 3,
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   132
} NetworkLanguage;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   133
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   134
VARDEF NetworkGameList *_network_game_list;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   135
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   136
VARDEF NetworkGameInfo _network_game_info;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   137
VARDEF NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   138
VARDEF NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   139
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   140
VARDEF char _network_player_name[NETWORK_NAME_LENGTH];
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   141
VARDEF char _network_default_ip[NETWORK_HOSTNAME_LENGTH];
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   142
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   143
VARDEF uint16 _network_own_client_index;
602
9bbe42a9e3ed (svn r1026) -Add: [Network] Added unique id, so in network, each client has an
truelight
parents: 600
diff changeset
   144
VARDEF char _network_unique_id[NETWORK_NAME_LENGTH]; // Our own unique ID
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   145
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   146
VARDEF uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   147
VARDEF uint32 _frame_counter_max; // To where we may go with our clients
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   148
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   149
// networking settings
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   150
VARDEF uint32 _network_ip_list[MAX_INTERFACES + 1]; // Network IPs
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   151
VARDEF uint16 _network_game_count;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   152
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   153
VARDEF uint16 _network_lobby_company_count;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   154
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   155
VARDEF uint _network_server_port;
629
ce914eb4023d (svn r1059) -Fix: [Console] Renamed 'set port' to 'set server_port'
truelight
parents: 627
diff changeset
   156
/* We use bind_ip and bind_ip_host, where bind_ip_host is the readable form of
ce914eb4023d (svn r1059) -Fix: [Console] Renamed 'set port' to 'set server_port'
truelight
parents: 627
diff changeset
   157
    bind_ip_host, and bind_ip the numeric value, because we want a nice number
ce914eb4023d (svn r1059) -Fix: [Console] Renamed 'set port' to 'set server_port'
truelight
parents: 627
diff changeset
   158
    in the openttd.cfg, but we wants to use the uint32 internally.. */
ce914eb4023d (svn r1059) -Fix: [Console] Renamed 'set port' to 'set server_port'
truelight
parents: 627
diff changeset
   159
VARDEF uint32 _network_server_bind_ip;
ce914eb4023d (svn r1059) -Fix: [Console] Renamed 'set port' to 'set server_port'
truelight
parents: 627
diff changeset
   160
VARDEF char _network_server_bind_ip_host[NETWORK_HOSTNAME_LENGTH];
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   161
VARDEF bool _is_network_server; // Does this client wants to be a network-server?
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   162
VARDEF char _network_server_name[NETWORK_NAME_LENGTH];
1026
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
   163
VARDEF char _network_server_password[NETWORK_PASSWORD_LENGTH];
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
   164
VARDEF char _network_rcon_password[NETWORK_PASSWORD_LENGTH];
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
   165
1602
08783e4287dc (svn r2106) -Fix: improved the network-join algoritm, it is now a bit more stable
truelight
parents: 1441
diff changeset
   166
VARDEF uint16 _network_max_join_time;             //! Time a client can max take to join
08783e4287dc (svn r2106) -Fix: improved the network-join algoritm, it is now a bit more stable
truelight
parents: 1441
diff changeset
   167
VARDEF bool _network_pause_on_join;               //! Pause the game when a client tries to join (more chance of succeeding join)
08783e4287dc (svn r2106) -Fix: improved the network-join algoritm, it is now a bit more stable
truelight
parents: 1441
diff changeset
   168
1026
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1011
diff changeset
   169
VARDEF uint16 _redirect_console_to_client;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   170
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   171
VARDEF uint16 _network_sync_freq;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   172
VARDEF uint8 _network_frame_freq;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   173
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   174
VARDEF uint32 _sync_seed_1, _sync_seed_2;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   175
VARDEF uint32 _sync_frame;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   176
VARDEF bool _network_first_time;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   177
// Vars needed for the join-GUI
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   178
VARDEF NetworkJoinStatus _network_join_status;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   179
VARDEF uint8 _network_join_waiting;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   180
VARDEF uint16 _network_join_kbytes;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   181
VARDEF uint16 _network_join_kbytes_total;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   182
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   183
VARDEF char _network_last_host[NETWORK_HOSTNAME_LENGTH];
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   184
VARDEF short _network_last_port;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   185
VARDEF uint32 _network_last_host_ip;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   186
VARDEF uint8 _network_reconnect;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   187
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   188
VARDEF bool _network_udp_server;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   189
VARDEF uint16 _network_udp_broadcast;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   190
764
68b398e2b780 (svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents: 738
diff changeset
   191
VARDEF byte _network_lan_internet;
68b398e2b780 (svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents: 738
diff changeset
   192
668
346853c8b513 (svn r1106) -Add: [Network] Added master-server protocol and advertise to
truelight
parents: 663
diff changeset
   193
VARDEF bool _network_advertise;
346853c8b513 (svn r1106) -Add: [Network] Added master-server protocol and advertise to
truelight
parents: 663
diff changeset
   194
VARDEF uint16 _network_last_advertise_date;
764
68b398e2b780 (svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents: 738
diff changeset
   195
VARDEF uint8 _network_advertise_retries;
668
346853c8b513 (svn r1106) -Add: [Network] Added master-server protocol and advertise to
truelight
parents: 663
diff changeset
   196
690
9f449a6b133e (svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents: 670
diff changeset
   197
VARDEF bool _network_autoclean_companies;
9f449a6b133e (svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents: 670
diff changeset
   198
VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months
9f449a6b133e (svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents: 670
diff changeset
   199
VARDEF uint8 _network_autoclean_protected;   // Unprotect a company after X months
9f449a6b133e (svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents: 670
diff changeset
   200
785
e9ca2bcc9c8f (svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
truelight
parents: 774
diff changeset
   201
VARDEF uint16 _network_restart_game_date;    // If this year is reached, the server automaticly restarts
e9ca2bcc9c8f (svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
truelight
parents: 774
diff changeset
   202
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1093
diff changeset
   203
NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info);
1812
5b4d1af6b904 (svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents: 1804
diff changeset
   204
void CSleep(int milliseconds);
774
258c11431acb (svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents: 773
diff changeset
   205
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   206
#endif /* ENABLE_NETWORK */
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   207
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   208
// Those variables must always be registered!
774
258c11431acb (svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents: 773
diff changeset
   209
#define MAX_SAVED_SERVERS 10
258c11431acb (svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents: 773
diff changeset
   210
VARDEF char *_network_host_list[MAX_SAVED_SERVERS];
841
8f0a68c6f43b (svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents: 793
diff changeset
   211
#define MAX_BANS 25
8f0a68c6f43b (svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents: 793
diff changeset
   212
VARDEF char *_network_ban_list[MAX_BANS];
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   213
VARDEF bool _networking;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   214
VARDEF bool _network_available;  // is network mode available?
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   215
VARDEF bool _network_server; // network-server is active
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   216
VARDEF bool _network_dedicated; // are we a dedicated server?
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   217
VARDEF byte _network_playas; // an id to play as..
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
   218
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1093
diff changeset
   219
void ParseConnectionString(const char **player, const char **port, char *connection_string);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   220
void NetworkUpdateClientInfo(uint16 client_index);
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1093
diff changeset
   221
void NetworkAddServer(const char *b);
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1026
diff changeset
   222
void NetworkRebuildHostList(void);
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1602
diff changeset
   223
bool NetworkChangeCompanyPassword(byte argc, char *argv[]);
228
f65dec6727d9 (svn r229) -Fix: Some more const stuff fixed .(Tron)
darkvater
parents: 211
diff changeset
   224
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
   225
#endif /* NETWORK_H */