_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
netconnect.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2008 by Lutz Sammer, Andreas Arens, and Jimmy Salmon
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 
29 #ifndef __NETCONNECT_H__
30 #define __NETCONNECT_H__
31 
33 
34 #include "net_message.h"
35 
36 class CHost;
37 
38 /*----------------------------------------------------------------------------
39 -- Defines
40 ----------------------------------------------------------------------------*/
41 
43 #define NetworkProtocolMajorVersion StratagusMajorVersion
44 #define NetworkProtocolMinorVersion StratagusMinorVersion
46 #define NetworkProtocolPatchLevel StratagusPatchLevel
48 #define NetworkProtocolVersion \
50  (NetworkProtocolMajorVersion * 10000 + NetworkProtocolMinorVersion * 100 + \
51  NetworkProtocolPatchLevel)
52 
54 #define NetworkProtocolFormatString "%d.%d.%d"
55 #define NetworkProtocolFormatArgs(v) (v) / 10000, ((v) / 100) % 100, (v) % 100
57 
58 /*----------------------------------------------------------------------------
59 -- Declarations
60 ----------------------------------------------------------------------------*/
61 
66  ccs_unused = 0,
84 };
85 
86 /*----------------------------------------------------------------------------
87 -- Variables
88 ----------------------------------------------------------------------------*/
89 
90 extern int NetPlayers;
91 
92 extern int HostsCount;
94 
95 extern int NetConnectRunning;
96 extern int NetConnectType;
97 extern int NetLocalHostsSlot;
98 extern int NetLocalPlayerNumber;
99 
102 
103 /*----------------------------------------------------------------------------
104 -- Functions
105 ----------------------------------------------------------------------------*/
106 
107 extern int FindHostIndexBy(const CHost &host);
108 extern void NetworkServerStartGame();
109 extern void NetworkGamePrepareGameSettings();
110 
111 extern int GetNetworkState();
112 
113 extern void NetworkInitClientConnect();
114 extern void NetworkInitServerConnect(int openslots);
115 extern int NetworkParseSetupEvent(const unsigned char *buf, int size, const CHost &host);
116 extern int NetworkSetupServerAddress(const std::string &serveraddr, int port);
117 extern void NetworkProcessClientRequest();
118 extern void NetworkProcessServerRequest();
119 extern void NetworkServerResyncClients();
120 extern void NetworkDetachFromServer();
121 
123 
124 #endif // !__NETCONNECT_H__
void NetworkServerStartGame()
Definition: netconnect.cpp:1470
CServerSetup LocalSetupState
Network menu: Multiplayer Server Menu selections state.
Definition: netconnect.cpp:93
int HostsCount
Network players.
Definition: netconnect.cpp:80
Incompatible engine version.
Definition: netconnect.h:83
CNetworkHost Hosts[PlayerMax]
Number of hosts.
Definition: netconnect.cpp:81
Definition: net_message.h:72
Server has started game.
Definition: netconnect.h:82
Server quits.
Definition: netconnect.h:80
Client is in sync with server.
Definition: netconnect.h:72
Client user has made menu selection.
Definition: netconnect.h:74
int NetConnectRunning
Host, port, and number of all players.
Definition: netconnect.cpp:83
#define PlayerMax
Definition: stratagus.h:157
int NetworkParseSetupEvent(const unsigned char *buf, int size, const CHost &host)
Setup network connect state machine for the server.
Definition: netconnect.cpp:1380
int GetNetworkState()
Definition: netconnect.cpp:1424
Unused.
Definition: netconnect.h:67
int FindHostIndexBy(const CHost &host)
Network menu: Multiplayer Client Menu selections local state.
Definition: netconnect.cpp:1429
void NetworkDetachFromServer()
Menu Loop: Server: Mark clients state to send stateinfo message.
Definition: netconnect.cpp:1744
Has received non-matching map-info.
Definition: netconnect.h:71
Definition: net_message.h:52
int NetworkSetupServerAddress(const std::string &serveraddr, int port)
Parse a network connect event.
Definition: netconnect.cpp:1724
Definition: netsockets.h:36
Server is unreachable.
Definition: netconnect.h:77
Server user has changed selection.
Definition: netconnect.h:73
Server has no more free slots.
Definition: netconnect.h:79
void NetworkServerResyncClients()
Menu Loop: Send out server request messages.
Definition: netconnect.cpp:1775
Connection canceled by user.
Definition: netconnect.h:78
void NetworkInitServerConnect(int openslots)
Setup network connect state machine for clients.
Definition: netconnect.cpp:1752
int NetPlayers
Player number of local client.
Definition: netconnect.cpp:88
void NetworkInitClientConnect()
Definition: netconnect.cpp:1454
_net_client_con_state_
Definition: netconnect.h:65
CServerSetup ServerSetupState
Player number of local client.
Definition: netconnect.cpp:92
int NetLocalHostsSlot
Network menu: Setup mode active.
Definition: netconnect.cpp:85
Server wants to start game.
Definition: netconnect.h:81
int NetLocalPlayerNumber
Network menu: Slot # in Hosts array of local client.
Definition: netconnect.cpp:86
void NetworkProcessClientRequest()
Menu: Setup the server IP.
Definition: netconnect.cpp:1417
void NetworkGamePrepareGameSettings()
Server user has finally hit the start game button.
Definition: netconnect.cpp:1785
New client.
Definition: netconnect.h:68
Has received slot info.
Definition: netconnect.h:69
int NetConnectType
Network menu: Setup mode active.
Definition: netconnect.cpp:84
Definition: netconnect.h:66
Client user wants to detach.
Definition: netconnect.h:75
Has received matching map-info.
Definition: netconnect.h:70
void NetworkProcessServerRequest()
Menu Loop: Send out client request messages.
Definition: netconnect.cpp:1442
Client has detached.
Definition: netconnect.h:76
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.