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

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 #include "network/netsockets.h"
36 
37 class CHost;
38 
39 /*----------------------------------------------------------------------------
40 -- Defines
41 ----------------------------------------------------------------------------*/
42 
44 #define NetworkProtocolMajorVersion StratagusMajorVersion
45 #define NetworkProtocolMinorVersion StratagusMinorVersion
47 #define NetworkProtocolPatchLevel StratagusPatchLevel
49 #define NetworkProtocolVersion \
51  (NetworkProtocolMajorVersion * 10000 + NetworkProtocolMinorVersion * 100 + \
52  NetworkProtocolPatchLevel)
53 
55 #define NetworkProtocolFormatString "%d.%d.%d"
56 #define NetworkProtocolFormatArgs(v) (v) / 10000, ((v) / 100) % 100, (v) % 100
58 
59 /*----------------------------------------------------------------------------
60 -- Declarations
61 ----------------------------------------------------------------------------*/
62 
67  ccs_unused = 0,
86 };
87 
88 /*----------------------------------------------------------------------------
89 -- Variables
90 ----------------------------------------------------------------------------*/
91 
92 extern int NetPlayers;
93 
95 
96 extern int NetConnectRunning;
97 extern int NetConnectType;
98 extern int NetLocalHostsSlot;
99 extern int NetLocalPlayerNumber;
100 
101 extern std::string NetworkMapName;
102 extern std::string NetworkMapFragmentName;
103 
106 
107 extern bool NoRandomPlacementMultiplayer;
108 
109 /*----------------------------------------------------------------------------
110 -- Functions
111 ----------------------------------------------------------------------------*/
112 
113 extern int FindHostIndexBy(const CHost &host);
114 extern void NetworkServerStartGame();
115 extern void NetworkGamePrepareGameSettings();
116 
117 extern int GetNetworkState();
118 
119 extern void NetworkInitClientConnect();
120 extern void NetworkInitServerConnect(int openslots);
121 extern int NetworkParseSetupEvent(const unsigned char *buf, int size, const CHost &host);
122 extern int NetworkSetupServerAddress(const std::string &serveraddr, int port);
123 extern void NetworkProcessClientRequest();
124 extern void NetworkProcessServerRequest();
125 extern void NetworkServerResyncClients();
126 extern void NetworkDetachFromServer();
127 
128 extern void NetworkSendICMessage(CUDPSocket &socket, const CHost &host, const CInitMessage_Header &msg);
129 
131 
132 #endif // !__NETCONNECT_H__
ccs_unused
@ ccs_unused
Definition: netconnect.h:67
ccs_incompatibleengine
@ ccs_incompatibleengine
Server has started game.
Definition: netconnect.h:83
NetworkMapName
std::string NetworkMapName
Player number of local client.
Definition: netconnect.cpp:111
ServerSetupState
CServerSetup ServerSetupState
Name of the map currently loading via ICMMapNeeded.
Definition: netconnect.cpp:115
NetworkSendICMessage
void NetworkSendICMessage(CUDPSocket &socket, const CHost &host, const CInitMessage_Header &msg)
Menu Loop: Client: Send GoodBye to the server and detach.
Definition: netconnect.cpp:241
ccs_connected
@ ccs_connected
New client.
Definition: netconnect.h:69
ccs_incompatibleluafiles
@ ccs_incompatibleluafiles
Incompatible engine version.
Definition: netconnect.h:84
ccs_async
@ ccs_async
Client is in sync with server.
Definition: netconnect.h:73
ccs_synced
@ ccs_synced
Has received non-matching map-info.
Definition: netconnect.h:72
CInitMessage_Header
Definition: net_message.h:200
ccs_badmap
@ ccs_badmap
Has received matching map-info.
Definition: netconnect.h:71
ccs_changed
@ ccs_changed
Server user has changed selection.
Definition: netconnect.h:74
CUDPSocket
Definition: netsockets.h:57
ccs_connecting
@ ccs_connecting
Unused.
Definition: netconnect.h:68
ccs_disconnected
@ ccs_disconnected
Client user wants to detach.
Definition: netconnect.h:76
ccs_nofreeslots
@ ccs_nofreeslots
Connection canceled by user.
Definition: netconnect.h:79
NetworkMapFragmentName
std::string NetworkMapFragmentName
Name of the map received with ICMMap.
Definition: netconnect.cpp:112
ccs_serverquits
@ ccs_serverquits
Server has no more free slots.
Definition: netconnect.h:80
NetworkParseSetupEvent
int NetworkParseSetupEvent(const unsigned char *buf, int size, const CHost &host)
Setup network connect state machine for the server.
Definition: netconnect.cpp:1617
PlayerMax
constexpr unsigned char PlayerMax
Definition: settings.h:62
CNetworkHost
Definition: net_message.h:54
NetworkInitServerConnect
void NetworkInitServerConnect(int openslots)
Setup network connect state machine for clients.
Definition: netconnect.cpp:1975
ccs_goahead
@ ccs_goahead
Server quits.
Definition: netconnect.h:81
ccs_unreachable
@ ccs_unreachable
Client has detached.
Definition: netconnect.h:77
ccs_detaching
@ ccs_detaching
Client user has made menu selection.
Definition: netconnect.h:75
NetConnectType
int NetConnectType
Network menu: Setup mode active.
Definition: netconnect.cpp:106
NetLocalHostsSlot
int NetLocalHostsSlot
Network menu: Setup mode active.
Definition: netconnect.cpp:107
FindHostIndexBy
int FindHostIndexBy(const CHost &host)
Disable the random placement of players in muliplayer mode.
Definition: netconnect.cpp:1666
NetworkSetupServerAddress
int NetworkSetupServerAddress(const std::string &serveraddr, int port)
Parse a network connect event.
Definition: netconnect.cpp:1947
NetworkProcessServerRequest
void NetworkProcessServerRequest()
Menu Loop: Send out client request messages.
Definition: netconnect.cpp:1679
net_message.h
LocalSetupState
CServerSetup LocalSetupState
Network menu: Multiplayer Server Menu selections state.
Definition: netconnect.cpp:116
NetLocalPlayerNumber
int NetLocalPlayerNumber
Network menu: Slot # in Hosts array of local client.
Definition: netconnect.cpp:108
_net_client_con_state_
_net_client_con_state_
Definition: netconnect.h:66
NetworkProcessClientRequest
void NetworkProcessClientRequest()
Menu: Setup the server IP.
Definition: netconnect.cpp:1654
ccs_usercanceled
@ ccs_usercanceled
Server is unreachable.
Definition: netconnect.h:78
NetworkServerResyncClients
void NetworkServerResyncClients()
Menu Loop: Send out server request messages.
Definition: netconnect.cpp:2009
netsockets.h
GetNetworkState
int GetNetworkState()
Definition: netconnect.cpp:1661
NetworkGamePrepareGameSettings
void NetworkGamePrepareGameSettings()
Server user has finally hit the start game button.
Definition: netconnect.cpp:2019
ccs_needmap
@ ccs_needmap
Incompatible lua files.
Definition: netconnect.h:85
NetConnectRunning
int NetConnectRunning
Host, port, and number of all players.
Definition: netconnect.cpp:105
NoRandomPlacementMultiplayer
bool NoRandomPlacementMultiplayer
Network menu: Multiplayer Client Menu selections local state.
Definition: netconnect.cpp:113
NetworkDetachFromServer
void NetworkDetachFromServer()
Menu Loop: Server: Mark clients state to send stateinfo message.
Definition: netconnect.cpp:1967
NetPlayers
int NetPlayers
Player number of local client.
Definition: netconnect.cpp:110
NetworkServerStartGame
void NetworkServerStartGame()
Definition: netconnect.cpp:1710
NetworkInitClientConnect
void NetworkInitClientConnect()
Definition: netconnect.cpp:1693
ccs_mapinfo
@ ccs_mapinfo
Has received slot info.
Definition: netconnect.h:70
Hosts
CNetworkHost Hosts[PlayerMax]
Network players.
Definition: netconnect.cpp:103
CServerSetup
Definition: net_message.h:107
CHost
Definition: netsockets.h:36
ccs_started
@ ccs_started
Server wants to start game.
Definition: netconnect.h:82
(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.