author | truebrain |
Fri, 18 Jul 2008 10:15:16 +0000 | |
branch | noai |
changeset 11168 | 3842648184cd |
parent 11111 | 1b984dab8cec |
permissions | -rw-r--r-- |
10829 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file network_internal.h Variables and function used internally. */ |
|
4 |
||
5 |
#ifndef NETWORK_TYPE_H |
|
6 |
#define NETWORK_TYPE_H |
|
7 |
||
8 |
#ifdef ENABLE_NETWORK |
|
9 |
||
10 |
#include "../player_type.h" |
|
11 |
#include "../economy_type.h" |
|
12 |
#include "core/config.h" |
|
13 |
#include "core/game.h" |
|
14 |
||
15 |
enum { |
|
16 |
/** |
|
17 |
* How many clients can we have? Like.. MAX_PLAYERS - 1 is the amount of |
|
18 |
* players that can really play.. so.. a max of 4 spectators.. gives us.. |
|
19 |
* MAX_PLAYERS + 3 |
|
20 |
*/ |
|
21 |
MAX_CLIENTS = MAX_PLAYERS + 3, |
|
22 |
||
23 |
/** Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1 */ |
|
24 |
MAX_CLIENT_INFO = MAX_CLIENTS + 1, |
|
25 |
||
26 |
/** Maximum number of internet interfaces supported. */ |
|
27 |
MAX_INTERFACES = 9, |
|
28 |
||
29 |
/** How many vehicle/station types we put over the network */ |
|
30 |
NETWORK_VEHICLE_TYPES = 5, |
|
31 |
NETWORK_STATION_TYPES = 5, |
|
32 |
||
33 |
NETWORK_SERVER_INDEX = 1, |
|
34 |
NETWORK_EMPTY_INDEX = 0, |
|
35 |
}; |
|
36 |
||
37 |
struct NetworkPlayerInfo { |
|
38 |
char company_name[NETWORK_NAME_LENGTH]; ///< Company name |
|
39 |
char password[NETWORK_PASSWORD_LENGTH]; ///< The password for the player |
|
40 |
Year inaugurated_year; ///< What year the company started in |
|
41 |
Money company_value; ///< The company value |
|
42 |
Money money; ///< The amount of money the company has |
|
43 |
Money income; ///< How much did the company earned last year |
|
44 |
uint16 performance; ///< What was his performance last month? |
|
45 |
bool use_password; ///< Is there a password |
|
46 |
uint16 num_vehicle[NETWORK_VEHICLE_TYPES]; ///< How many vehicles are there of this type? |
|
47 |
uint16 num_station[NETWORK_STATION_TYPES]; ///< How many stations are there of this type? |
|
48 |
char players[NETWORK_PLAYERS_LENGTH]; ///< The players that control this company (Name1, name2, ..) |
|
49 |
uint16 months_empty; ///< How many months the company is empty |
|
11111
1b984dab8cec
(svn r13669) [NoAI] -Fix: allow clients only to join non-AI controlled companies in multiplayer
truebrain
parents:
10829
diff
changeset
|
50 |
bool ai; ///< Is this company an AI |
10829 | 51 |
}; |
52 |
||
53 |
struct NetworkClientInfo { |
|
54 |
uint16 client_index; ///< Index of the client (same as ClientState->index) |
|
55 |
char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< Name of the client |
|
56 |
byte client_lang; ///< The language of the client |
|
57 |
PlayerID client_playas; ///< As which player is this client playing (PlayerID) |
|
58 |
uint32 client_ip; ///< IP-address of the client (so he can be banned) |
|
59 |
Date join_date; ///< Gamedate the player has joined |
|
60 |
char unique_id[NETWORK_UNIQUE_ID_LENGTH]; ///< Every play sends an unique id so we can indentify him |
|
61 |
}; |
|
62 |
||
63 |
enum NetworkPasswordType { |
|
64 |
NETWORK_GAME_PASSWORD, |
|
65 |
NETWORK_COMPANY_PASSWORD, |
|
66 |
}; |
|
67 |
||
68 |
enum DestType { |
|
69 |
DESTTYPE_BROADCAST, ///< Send message/notice to all players (All) |
|
70 |
DESTTYPE_TEAM, ///< Send message/notice to everyone playing the same company (Team) |
|
71 |
DESTTYPE_CLIENT, ///< Send message/notice to only a certain player (Private) |
|
72 |
}; |
|
73 |
||
74 |
/** Actions that can be used for NetworkTextMessage */ |
|
75 |
enum NetworkAction { |
|
76 |
NETWORK_ACTION_JOIN, |
|
77 |
NETWORK_ACTION_LEAVE, |
|
78 |
NETWORK_ACTION_SERVER_MESSAGE, |
|
79 |
NETWORK_ACTION_CHAT, |
|
80 |
NETWORK_ACTION_CHAT_COMPANY, |
|
81 |
NETWORK_ACTION_CHAT_CLIENT, |
|
82 |
NETWORK_ACTION_GIVE_MONEY, |
|
83 |
NETWORK_ACTION_NAME_CHANGE, |
|
84 |
}; |
|
85 |
||
86 |
enum NetworkErrorCode { |
|
87 |
NETWORK_ERROR_GENERAL, // Try to use this one like never |
|
88 |
||
89 |
/* Signals from clients */ |
|
90 |
NETWORK_ERROR_DESYNC, |
|
91 |
NETWORK_ERROR_SAVEGAME_FAILED, |
|
92 |
NETWORK_ERROR_CONNECTION_LOST, |
|
93 |
NETWORK_ERROR_ILLEGAL_PACKET, |
|
94 |
NETWORK_ERROR_NEWGRF_MISMATCH, |
|
95 |
||
96 |
/* Signals from servers */ |
|
97 |
NETWORK_ERROR_NOT_AUTHORIZED, |
|
98 |
NETWORK_ERROR_NOT_EXPECTED, |
|
99 |
NETWORK_ERROR_WRONG_REVISION, |
|
100 |
NETWORK_ERROR_NAME_IN_USE, |
|
101 |
NETWORK_ERROR_WRONG_PASSWORD, |
|
102 |
NETWORK_ERROR_PLAYER_MISMATCH, // Happens in CLIENT_COMMAND |
|
103 |
NETWORK_ERROR_KICKED, |
|
104 |
NETWORK_ERROR_CHEATER, |
|
105 |
NETWORK_ERROR_FULL, |
|
106 |
}; |
|
107 |
||
108 |
#endif /* ENABLE_NETWORK */ |
|
109 |
#endif /* NETWORK_TYPE_H */ |