~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/network/network_type.h

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: network_type.h 15242 2009-01-23 22:18:06Z rubidium $ */
 
2
 
 
3
/** @file network_type.h Types used for networking. */
 
4
 
 
5
#ifndef NETWORK_TYPE_H
 
6
#define NETWORK_TYPE_H
 
7
 
 
8
#ifdef ENABLE_NETWORK
 
9
 
 
10
#include "../company_type.h"
 
11
#include "../economy_type.h"
 
12
#include "core/config.h"
 
13
#include "core/game.h"
 
14
 
 
15
enum {
 
16
        /** How many clients can we have */
 
17
        MAX_CLIENTS = 255,
 
18
 
 
19
        /** The number of bits per pool client block */
 
20
        NCI_BITS_PER_POOL_BLOCK = 3, // => 8 items per block
 
21
        /**
 
22
         * The number of slots; must be a multiple of (1 << NCI_BITS_PER_POOL_BLOCK)
 
23
         * and be at least 1 more than MAX_CLIENTS. It must furthermore be less than
 
24
         * or equal to 256 as client indices (sent over the network) are 8 bits.
 
25
         * It needs 1 more for the dedicated server.
 
26
         */
 
27
        MAX_CLIENT_SLOTS = 256,
 
28
 
 
29
        /** Maximum number of internet interfaces supported. */
 
30
        MAX_INTERFACES = 9,
 
31
 
 
32
        /** How many vehicle/station types we put over the network */
 
33
        NETWORK_VEHICLE_TYPES = 5,
 
34
        NETWORK_STATION_TYPES = 5,
 
35
};
 
36
 
 
37
/** 'Unique' identifier to be given to clients */
 
38
enum ClientID {
 
39
        INVALID_CLIENT_ID = 0, ///< Client is not part of anything
 
40
        CLIENT_ID_SERVER  = 1, ///< Servers always have this ID
 
41
        CLIENT_ID_FIRST   = 2, ///< The first client ID
 
42
};
 
43
 
 
44
/** Indices into the client tables */
 
45
typedef uint8 ClientIndex;
 
46
 
 
47
/** Simple calculated statistics of a company */
 
48
struct NetworkCompanyStats {
 
49
        uint16 num_vehicle[NETWORK_VEHICLE_TYPES];      ///< How many vehicles are there of this type?
 
50
        uint16 num_station[NETWORK_STATION_TYPES];      ///< How many stations are there of this type?
 
51
        bool ai;                                        ///< Is this company an AI
 
52
};
 
53
 
 
54
/** Some state information of a company, especially for servers */
 
55
struct NetworkCompanyState {
 
56
        char password[NETWORK_PASSWORD_LENGTH];         ///< The password for the company
 
57
        uint16 months_empty;                            ///< How many months the company is empty
 
58
};
 
59
 
 
60
struct NetworkClientInfo;
 
61
 
 
62
enum NetworkPasswordType {
 
63
        NETWORK_GAME_PASSWORD,
 
64
        NETWORK_COMPANY_PASSWORD,
 
65
};
 
66
 
 
67
enum DestType {
 
68
        DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All)
 
69
        DESTTYPE_TEAM,      ///< Send message/notice to everyone playing the same company (Team)
 
70
        DESTTYPE_CLIENT,    ///< Send message/notice to only a certain client (Private)
 
71
};
 
72
 
 
73
/** Actions that can be used for NetworkTextMessage */
 
74
enum NetworkAction {
 
75
        NETWORK_ACTION_JOIN,
 
76
        NETWORK_ACTION_LEAVE,
 
77
        NETWORK_ACTION_SERVER_MESSAGE,
 
78
        NETWORK_ACTION_CHAT,
 
79
        NETWORK_ACTION_CHAT_COMPANY,
 
80
        NETWORK_ACTION_CHAT_CLIENT,
 
81
        NETWORK_ACTION_GIVE_MONEY,
 
82
        NETWORK_ACTION_NAME_CHANGE,
 
83
        NETWORK_ACTION_COMPANY_SPECTATOR,
 
84
        NETWORK_ACTION_COMPANY_JOIN,
 
85
        NETWORK_ACTION_COMPANY_NEW,
 
86
};
 
87
 
 
88
/** Messages the server can give */
 
89
enum NetworkServerMessage {
 
90
        NETWORK_SERVER_MESSAGE_GAME_PAUSED_PLAYERS,        ///< Game paused (not enough players)
 
91
        NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_PLAYERS,      ///< Game unpaused (enough players)
 
92
        NETWORK_SERVER_MESSAGE_GAME_PAUSED_CONNECT,        ///< Game paused (connecting client)
 
93
        NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT,      ///< Game unpaused (client connected)
 
94
        NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT_FAIL, ///< Game unpaused (client failed to connect)
 
95
        NETWORK_SERVER_MESSAGE_END
 
96
};
 
97
 
 
98
enum NetworkErrorCode {
 
99
        NETWORK_ERROR_GENERAL, // Try to use this one like never
 
100
 
 
101
        /* Signals from clients */
 
102
        NETWORK_ERROR_DESYNC,
 
103
        NETWORK_ERROR_SAVEGAME_FAILED,
 
104
        NETWORK_ERROR_CONNECTION_LOST,
 
105
        NETWORK_ERROR_ILLEGAL_PACKET,
 
106
        NETWORK_ERROR_NEWGRF_MISMATCH,
 
107
 
 
108
        /* Signals from servers */
 
109
        NETWORK_ERROR_NOT_AUTHORIZED,
 
110
        NETWORK_ERROR_NOT_EXPECTED,
 
111
        NETWORK_ERROR_WRONG_REVISION,
 
112
        NETWORK_ERROR_NAME_IN_USE,
 
113
        NETWORK_ERROR_WRONG_PASSWORD,
 
114
        NETWORK_ERROR_COMPANY_MISMATCH, // Happens in CLIENT_COMMAND
 
115
        NETWORK_ERROR_KICKED,
 
116
        NETWORK_ERROR_CHEATER,
 
117
        NETWORK_ERROR_FULL,
 
118
};
 
119
 
 
120
#endif /* ENABLE_NETWORK */
 
121
#endif /* NETWORK_TYPE_H */