src/network/network_type.h
author belugas
Mon, 30 Jun 2008 16:59:35 +0000
changeset 11107 6db1c5112e97
parent 10792 95b6eb9fcc9e
child 11153 cee0888d135a
permissions -rw-r--r--
(svn r13665) -Fix[FS#2119]: Wrong PlayerID used for sending a message to.Patch by Yexo
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2153
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2153
diff changeset
     2
10429
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 9286
diff changeset
     3
/** @file network_internal.h Variables and function used internally. */
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 9286
diff changeset
     4
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
     5
#ifndef NETWORK_TYPE_H
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
     6
#define NETWORK_TYPE_H
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
     7
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
     8
#ifdef ENABLE_NETWORK
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
     9
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8743
diff changeset
    10
#include "../player_type.h"
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8743
diff changeset
    11
#include "../economy_type.h"
5720
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5339
diff changeset
    12
#include "core/config.h"
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5339
diff changeset
    13
#include "core/game.h"
2153
91e89aa8c299 (svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents: 2079
diff changeset
    14
9285
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    15
enum {
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    16
	/**
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    17
	 * How many clients can we have? Like.. MAX_PLAYERS - 1 is the amount of
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    18
	 *  players that can really play.. so.. a max of 4 spectators.. gives us..
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    19
	 *  MAX_PLAYERS + 3
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    20
	 */
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    21
	MAX_CLIENTS = MAX_PLAYERS + 3,
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    22
9285
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    23
	/** Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1 */
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    24
	MAX_CLIENT_INFO = MAX_CLIENTS + 1,
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    25
9285
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    26
	/** Maximum number of internet interfaces supported. */
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    27
	MAX_INTERFACES = 9,
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    28
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    29
	/** How many vehicle/station types we put over the network */
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    30
	NETWORK_VEHICLE_TYPES = 5,
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    31
	NETWORK_STATION_TYPES = 5,
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    32
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    33
	NETWORK_SERVER_INDEX = 1,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    34
	NETWORK_EMPTY_INDEX  = 0,
9286
d446bf9f4a68 (svn r12501) -Codechange: split signs.h.
rubidium
parents: 9285
diff changeset
    35
};
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    36
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    37
struct NetworkPlayerInfo {
9285
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    38
	char company_name[NETWORK_NAME_LENGTH];         ///< Company name
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    39
	char password[NETWORK_PASSWORD_LENGTH];         ///< The password for the player
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    40
	Year inaugurated_year;                          ///< What year the company started in
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    41
	Money company_value;                            ///< The company value
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    42
	Money money;                                    ///< The amount of money the company has
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    43
	Money income;                                   ///< How much did the company earned last year
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    44
	uint16 performance;                             ///< What was his performance last month?
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    45
	bool use_password;                              ///< Is there a password
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    46
	uint16 num_vehicle[NETWORK_VEHICLE_TYPES];      ///< How many vehicles are there of this type?
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    47
	uint16 num_station[NETWORK_STATION_TYPES];      ///< How many stations are there of this type?
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    48
	char players[NETWORK_PLAYERS_LENGTH];           ///< The players that control this company (Name1, name2, ..)
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    49
	uint16 months_empty;                            ///< How many months the company is empty
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    50
};
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    51
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    52
struct NetworkClientInfo {
9285
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    53
	uint16 client_index;                            ///< Index of the client (same as ClientState->index)
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    54
	char client_name[NETWORK_CLIENT_NAME_LENGTH];   ///< Name of the client
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    55
	byte client_lang;                               ///< The language of the client
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    56
	PlayerID client_playas;                         ///< As which player is this client playing (PlayerID)
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    57
	uint32 client_ip;                               ///< IP-address of the client (so he can be banned)
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    58
	Date join_date;                                 ///< Gamedate the player has joined
036f39374081 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 9226
diff changeset
    59
	char unique_id[NETWORK_UNIQUE_ID_LENGTH];       ///< Every play sends an unique id so we can indentify him
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    60
};
211
2954c4b30525 (svn r212) -Fix: Network-gui fixes (sign_de)
darkvater
parents:
diff changeset
    61
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    62
enum NetworkPasswordType {
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    63
	NETWORK_GAME_PASSWORD,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    64
	NETWORK_COMPANY_PASSWORD,
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    65
};
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    66
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    67
enum DestType {
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    68
	DESTTYPE_BROADCAST, ///< Send message/notice to all players (All)
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    69
	DESTTYPE_TEAM,      ///< Send message/notice to everyone playing the same company (Team)
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    70
	DESTTYPE_CLIENT,    ///< Send message/notice to only a certain player (Private)
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    71
};
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
    72
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    73
/** Actions that can be used for NetworkTextMessage */
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    74
enum NetworkAction {
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    75
	NETWORK_ACTION_JOIN,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    76
	NETWORK_ACTION_LEAVE,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    77
	NETWORK_ACTION_SERVER_MESSAGE,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    78
	NETWORK_ACTION_CHAT,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    79
	NETWORK_ACTION_CHAT_COMPANY,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    80
	NETWORK_ACTION_CHAT_CLIENT,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    81
	NETWORK_ACTION_GIVE_MONEY,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    82
	NETWORK_ACTION_NAME_CHANGE,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    83
};
3041
105098f42dfa (svn r3621) - Codechange: Only define the server and bans list if network is enabled. Preparatory work for saving patches/settings to savegame.
Darkvater
parents: 2944
diff changeset
    84
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    85
enum NetworkErrorCode {
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    86
	NETWORK_ERROR_GENERAL, // Try to use this one like never
4038
b23bbe44d1ba (svn r5298) Hide function declarations and remove function stubs which aren't needed in the !ENABLE_NETWORK case
tron
parents: 4034
diff changeset
    87
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    88
	/* Signals from clients */
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    89
	NETWORK_ERROR_DESYNC,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    90
	NETWORK_ERROR_SAVEGAME_FAILED,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    91
	NETWORK_ERROR_CONNECTION_LOST,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    92
	NETWORK_ERROR_ILLEGAL_PACKET,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    93
	NETWORK_ERROR_NEWGRF_MISMATCH,
4830
0ff2a14e90be (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4829
diff changeset
    94
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    95
	/* Signals from servers */
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    96
	NETWORK_ERROR_NOT_AUTHORIZED,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    97
	NETWORK_ERROR_NOT_EXPECTED,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    98
	NETWORK_ERROR_WRONG_REVISION,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
    99
	NETWORK_ERROR_NAME_IN_USE,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
   100
	NETWORK_ERROR_WRONG_PASSWORD,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
   101
	NETWORK_ERROR_PLAYER_MISMATCH, // Happens in CLIENT_COMMAND
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
   102
	NETWORK_ERROR_KICKED,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
   103
	NETWORK_ERROR_CHEATER,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
   104
	NETWORK_ERROR_FULL,
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
   105
};
6504
5578f2fa1a73 (svn r8949) -Codechange: only test the first NETWORK_REVISION_LENGTH - 1 characters when determining network compatability. This makes it possible to have 'long' branch names while still being able to play network games.
rubidium
parents: 6210
diff changeset
   106
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 239
diff changeset
   107
#endif /* ENABLE_NETWORK */
10792
95b6eb9fcc9e (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 10784
diff changeset
   108
#endif /* NETWORK_TYPE_H */