src/network/network_internal.h
author rubidium
Tue, 30 Sep 2008 20:39:50 +0000
changeset 10207 c291a21b304e
parent 9896 19aa91881726
permissions -rw-r--r--
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
     1
/* $Id$ */
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
     2
9111
48ce04029fe4 (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: 8790
diff changeset
     3
/** @file network_internal.h Variables and function used internally. */
48ce04029fe4 (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: 8790
diff changeset
     4
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
     5
#ifndef NETWORK_INTERNAL_H
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
     6
#define NETWORK_INTERNAL_H
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
     7
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
     8
#ifdef ENABLE_NETWORK
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
     9
9428
1ba05b499957 (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: 9420
diff changeset
    10
#include "network.h"
1ba05b499957 (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: 9420
diff changeset
    11
#include "network_func.h"
1ba05b499957 (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: 9420
diff changeset
    12
#include "core/os_abstraction.h"
1ba05b499957 (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: 9420
diff changeset
    13
#include "core/core.h"
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    14
#include "core/config.h"
9428
1ba05b499957 (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: 9420
diff changeset
    15
#include "core/packet.h"
1ba05b499957 (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: 9420
diff changeset
    16
#include "core/tcp.h"
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    17
8789
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    18
/**
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    19
 * If this line is enable, every frame will have a sync test
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    20
 *  this is not needed in normal games. Normal is like 1 sync in 100
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    21
 *  frames. You can enable this if you have a lot of desyncs on a certain
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    22
 *  game.
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    23
 * Remember: both client and server have to be compiled with this
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    24
 *  option enabled to make it to work. If one of the two has it disabled
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    25
 *  nothing will happen.
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    26
 */
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    27
//#define ENABLE_NETWORK_SYNC_EVERY_FRAME
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    28
8789
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    29
/**
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    30
 * In theory sending 1 of the 2 seeds is enough to check for desyncs
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    31
 *   so in theory, this next define can be left off.
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    32
 */
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    33
//#define NETWORK_SEND_DOUBLE_SEED
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    34
9428
1ba05b499957 (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: 9420
diff changeset
    35
enum MapPacket {
1ba05b499957 (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: 9420
diff changeset
    36
	MAP_PACKET_START,
1ba05b499957 (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: 9420
diff changeset
    37
	MAP_PACKET_NORMAL,
1ba05b499957 (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: 9420
diff changeset
    38
	MAP_PACKET_END,
8790
4a7a796b3976 (svn r12501) -Codechange: split signs.h.
rubidium
parents: 8789
diff changeset
    39
};
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    40
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    41
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    42
enum NetworkJoinStatus {
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    43
	NETWORK_JOIN_STATUS_CONNECTING,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    44
	NETWORK_JOIN_STATUS_AUTHORIZING,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    45
	NETWORK_JOIN_STATUS_WAITING,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    46
	NETWORK_JOIN_STATUS_DOWNLOADING,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    47
	NETWORK_JOIN_STATUS_PROCESSING,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    48
	NETWORK_JOIN_STATUS_REGISTERING,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    49
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    50
	NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    51
};
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    52
8789
48c8f086b823 (svn r12499) -Codechange: some coding style tweaks for network_internal.h.
rubidium
parents: 8730
diff changeset
    53
/** Language ids for server_lang and client_lang. Do NOT modify the order. */
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    54
enum NetworkLanguage {
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    55
	NETLANG_ANY = 0,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    56
	NETLANG_ENGLISH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    57
	NETLANG_GERMAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    58
	NETLANG_FRENCH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    59
	NETLANG_BRAZILIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    60
	NETLANG_BULGARIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    61
	NETLANG_CHINESE,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    62
	NETLANG_CZECH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    63
	NETLANG_DANISH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    64
	NETLANG_DUTCH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    65
	NETLANG_ESPERANTO,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    66
	NETLANG_FINNISH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    67
	NETLANG_HUNGARIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    68
	NETLANG_ICELANDIC,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    69
	NETLANG_ITALIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    70
	NETLANG_JAPANESE,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    71
	NETLANG_KOREAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    72
	NETLANG_LITHUANIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    73
	NETLANG_NORWEGIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    74
	NETLANG_POLISH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    75
	NETLANG_PORTUGUESE,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    76
	NETLANG_ROMANIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    77
	NETLANG_RUSSIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    78
	NETLANG_SLOVAK,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    79
	NETLANG_SLOVENIAN,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    80
	NETLANG_SPANISH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    81
	NETLANG_SWEDISH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    82
	NETLANG_TURKISH,
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    83
	NETLANG_UKRAINIAN,
8730
525e63adca4f (svn r12407) -Add [FS#1866]: more language flags for servers
glx
parents: 8276
diff changeset
    84
	NETLANG_AFRIKAANS,
525e63adca4f (svn r12407) -Add [FS#1866]: more language flags for servers
glx
parents: 8276
diff changeset
    85
	NETLANG_CROATIAN,
525e63adca4f (svn r12407) -Add [FS#1866]: more language flags for servers
glx
parents: 8276
diff changeset
    86
	NETLANG_CATALAN,
525e63adca4f (svn r12407) -Add [FS#1866]: more language flags for servers
glx
parents: 8276
diff changeset
    87
	NETLANG_ESTONIAN,
525e63adca4f (svn r12407) -Add [FS#1866]: more language flags for servers
glx
parents: 8276
diff changeset
    88
	NETLANG_GALICIAN,
525e63adca4f (svn r12407) -Add [FS#1866]: more language flags for servers
glx
parents: 8276
diff changeset
    89
	NETLANG_GREEK,
525e63adca4f (svn r12407) -Add [FS#1866]: more language flags for servers
glx
parents: 8276
diff changeset
    90
	NETLANG_LATVIAN,
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    91
	NETLANG_COUNT
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    92
};
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    93
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9896
diff changeset
    94
extern NetworkCompanyInfo _network_company_info[MAX_COMPANIES];
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    95
9428
1ba05b499957 (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: 9420
diff changeset
    96
extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
1ba05b499957 (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: 9420
diff changeset
    97
extern uint32 _frame_counter_max; // To where we may go with our clients
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
    98
9428
1ba05b499957 (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: 9420
diff changeset
    99
extern uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   100
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   101
// networking settings
9428
1ba05b499957 (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: 9420
diff changeset
   102
extern uint32 _broadcast_list[MAX_INTERFACES + 1];
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   103
9428
1ba05b499957 (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: 9420
diff changeset
   104
extern uint32 _network_server_bind_ip;
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   105
9428
1ba05b499957 (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: 9420
diff changeset
   106
extern uint32 _sync_seed_1, _sync_seed_2;
1ba05b499957 (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: 9420
diff changeset
   107
extern uint32 _sync_frame;
1ba05b499957 (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: 9420
diff changeset
   108
extern bool _network_first_time;
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   109
// Vars needed for the join-GUI
9428
1ba05b499957 (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: 9420
diff changeset
   110
extern NetworkJoinStatus _network_join_status;
1ba05b499957 (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: 9420
diff changeset
   111
extern uint8 _network_join_waiting;
1ba05b499957 (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: 9420
diff changeset
   112
extern uint16 _network_join_kbytes;
1ba05b499957 (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: 9420
diff changeset
   113
extern uint16 _network_join_kbytes_total;
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   114
9428
1ba05b499957 (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: 9420
diff changeset
   115
extern uint32 _network_last_host_ip;
1ba05b499957 (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: 9420
diff changeset
   116
extern uint8 _network_reconnect;
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   117
9428
1ba05b499957 (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: 9420
diff changeset
   118
extern bool _network_udp_server;
1ba05b499957 (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: 9420
diff changeset
   119
extern uint16 _network_udp_broadcast;
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   120
9428
1ba05b499957 (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: 9420
diff changeset
   121
extern uint8 _network_advertise_retries;
1ba05b499957 (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: 9420
diff changeset
   122
1ba05b499957 (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: 9420
diff changeset
   123
// following externs are instantiated at network.cpp
1ba05b499957 (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: 9420
diff changeset
   124
extern CommandPacket *_local_command_queue;
1ba05b499957 (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: 9420
diff changeset
   125
1ba05b499957 (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: 9420
diff changeset
   126
// Here we keep track of the clients
1ba05b499957 (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: 9420
diff changeset
   127
//  (and the client uses [0] for his own communication)
1ba05b499957 (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: 9420
diff changeset
   128
extern NetworkTCPSocketHandler _clients[MAX_CLIENTS];
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   129
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   130
void NetworkTCPQueryServer(const char* host, unsigned short port);
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   131
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   132
void NetworkAddServer(const char *b);
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   133
void NetworkRebuildHostList();
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   134
void UpdateNetworkGameWindow(bool unselect);
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   135
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   136
bool IsNetworkCompatibleVersion(const char *version);
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   137
9428
1ba05b499957 (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: 9420
diff changeset
   138
void NetworkExecuteCommand(CommandPacket *cp);
1ba05b499957 (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: 9420
diff changeset
   139
void NetworkAddCommandQueue(NetworkTCPSocketHandler *cs, CommandPacket *cp);
1ba05b499957 (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: 9420
diff changeset
   140
1ba05b499957 (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: 9420
diff changeset
   141
// from network.c
1ba05b499957 (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: 9420
diff changeset
   142
void NetworkCloseClient(NetworkTCPSocketHandler *cs);
1ba05b499957 (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: 9420
diff changeset
   143
void CDECL NetworkTextMessage(NetworkAction action, ConsoleColour color, bool self_send, const char *name, const char *str, ...);
1ba05b499957 (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: 9420
diff changeset
   144
void NetworkGetClientName(char *clientname, size_t size, const NetworkTCPSocketHandler *cs);
1ba05b499957 (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: 9420
diff changeset
   145
uint NetworkCalculateLag(const NetworkTCPSocketHandler *cs);
1ba05b499957 (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: 9420
diff changeset
   146
byte NetworkGetCurrentLanguageIndex();
1ba05b499957 (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: 9420
diff changeset
   147
NetworkTCPSocketHandler *NetworkFindClientStateFromIndex(uint16 client_index);
1ba05b499957 (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: 9420
diff changeset
   148
char* GetNetworkErrorMsg(char* buf, NetworkErrorCode err, const char* last);
1ba05b499957 (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: 9420
diff changeset
   149
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
1ba05b499957 (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: 9420
diff changeset
   150
1ba05b499957 (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: 9420
diff changeset
   151
#define DEREF_CLIENT(i) (&_clients[i])
1ba05b499957 (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: 9420
diff changeset
   152
// This returns the NetworkClientInfo from a NetworkClientState
1ba05b499957 (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: 9420
diff changeset
   153
#define DEREF_CLIENT_INFO(cs) (&_network_client_info[cs - _clients])
1ba05b499957 (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: 9420
diff changeset
   154
1ba05b499957 (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: 9420
diff changeset
   155
// Macros to make life a bit more easier
1ba05b499957 (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: 9420
diff changeset
   156
#define DEF_CLIENT_RECEIVE_COMMAND(type) NetworkRecvStatus NetworkPacketReceive_ ## type ## _command(Packet *p)
1ba05b499957 (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: 9420
diff changeset
   157
#define DEF_CLIENT_SEND_COMMAND(type) void NetworkPacketSend_ ## type ## _command()
1ba05b499957 (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: 9420
diff changeset
   158
#define DEF_CLIENT_SEND_COMMAND_PARAM(type) void NetworkPacketSend_ ## type ## _command
1ba05b499957 (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: 9420
diff changeset
   159
#define DEF_SERVER_RECEIVE_COMMAND(type) void NetworkPacketReceive_ ## type ## _command(NetworkTCPSocketHandler *cs, Packet *p)
1ba05b499957 (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: 9420
diff changeset
   160
#define DEF_SERVER_SEND_COMMAND(type) void NetworkPacketSend_ ## type ## _command(NetworkTCPSocketHandler *cs)
1ba05b499957 (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: 9420
diff changeset
   161
#define DEF_SERVER_SEND_COMMAND_PARAM(type) void NetworkPacketSend_ ## type ## _command
1ba05b499957 (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: 9420
diff changeset
   162
1ba05b499957 (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: 9420
diff changeset
   163
#define SEND_COMMAND(type) NetworkPacketSend_ ## type ## _command
1ba05b499957 (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: 9420
diff changeset
   164
#define RECEIVE_COMMAND(type) NetworkPacketReceive_ ## type ## _command
1ba05b499957 (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: 9420
diff changeset
   165
1ba05b499957 (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: 9420
diff changeset
   166
#define FOR_ALL_CLIENTS(cs) for (cs = _clients; cs != endof(_clients) && cs->IsConnected(); cs++)
1ba05b499957 (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: 9420
diff changeset
   167
8276
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   168
#endif /* ENABLE_NETWORK */
245f1b131d64 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server.
rubidium
parents:
diff changeset
   169
#endif /* NETWORK_INTERNAL_H */