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

netconnect.h File Reference
#include "net_message.h"
#include "network/netsockets.h"

Go to the source code of this file.

netconnect.h - The network connection setup header file.

#define NetworkProtocolMajorVersion   StratagusMajorVersion
 Network protocol major version. More...
 
#define NetworkProtocolMinorVersion   StratagusMinorVersion
 Network protocol minor version (maximum 99) More...
 
#define NetworkProtocolPatchLevel   StratagusPatchLevel
 Network protocol patch level (maximum 99) More...
 
#define NetworkProtocolVersion
 Network protocol version (1,2,3) -> 10203. More...
 
#define NetworkProtocolFormatString   "%d.%d.%d"
 Network protocol printf format string. More...
 
#define NetworkProtocolFormatArgs(v)   (v) / 10000, ((v) / 100) % 100, (v) % 100
 Network protocol printf format arguments. More...
 
enum  _net_client_con_state_ {
  ccs_unused = 0, ccs_connecting, ccs_connected, ccs_mapinfo,
  ccs_badmap, ccs_synced, ccs_async, ccs_changed,
  ccs_detaching, ccs_disconnected, ccs_unreachable, ccs_usercanceled,
  ccs_nofreeslots, ccs_serverquits, ccs_goahead, ccs_started,
  ccs_incompatibleengine, ccs_incompatibleluafiles, ccs_needmap
}
 
int NetPlayers
 Player number of local client. More...
 
CNetworkHost Hosts [PlayerMax]
 Network players. More...
 
int NetConnectRunning
 Host, port, and number of all players. More...
 
int NetConnectType
 Network menu: Setup mode active. More...
 
int NetLocalHostsSlot
 Network menu: Setup mode active. More...
 
int NetLocalPlayerNumber
 Network menu: Slot # in Hosts array of local client. More...
 
std::string NetworkMapName
 Player number of local client. More...
 
std::string NetworkMapFragmentName
 Name of the map received with ICMMap. More...
 
CServerSetup ServerSetupState
 Name of the map currently loading via ICMMapNeeded. More...
 
CServerSetup LocalSetupState
 Network menu: Multiplayer Server Menu selections state. More...
 
bool NoRandomPlacementMultiplayer
 Network menu: Multiplayer Client Menu selections local state. More...
 
int FindHostIndexBy (const CHost &host)
 Disable the random placement of players in muliplayer mode. More...
 
void NetworkServerStartGame ()
 
void NetworkGamePrepareGameSettings ()
 Server user has finally hit the start game button. More...
 
int GetNetworkState ()
 
void NetworkInitClientConnect ()
 
void NetworkInitServerConnect (int openslots)
 Setup network connect state machine for clients. More...
 
int NetworkParseSetupEvent (const unsigned char *buf, int size, const CHost &host)
 Setup network connect state machine for the server. More...
 
int NetworkSetupServerAddress (const std::string &serveraddr, int port)
 Parse a network connect event. More...
 
void NetworkProcessClientRequest ()
 Menu: Setup the server IP. More...
 
void NetworkProcessServerRequest ()
 Menu Loop: Send out client request messages. More...
 
void NetworkServerResyncClients ()
 Menu Loop: Send out server request messages. More...
 
void NetworkDetachFromServer ()
 Menu Loop: Server: Mark clients state to send stateinfo message. More...
 
void NetworkSendICMessage (CUDPSocket &socket, const CHost &host, const CInitMessage_Header &msg)
 Menu Loop: Client: Send GoodBye to the server and detach. More...
 

Macro Definition Documentation

◆ NetworkProtocolFormatArgs

#define NetworkProtocolFormatArgs (   v)    (v) / 10000, ((v) / 100) % 100, (v) % 100

Network protocol printf format arguments.

◆ NetworkProtocolFormatString

#define NetworkProtocolFormatString   "%d.%d.%d"

Network protocol printf format string.

◆ NetworkProtocolMajorVersion

#define NetworkProtocolMajorVersion   StratagusMajorVersion

Network protocol major version.

◆ NetworkProtocolMinorVersion

#define NetworkProtocolMinorVersion   StratagusMinorVersion

Network protocol minor version (maximum 99)

◆ NetworkProtocolPatchLevel

#define NetworkProtocolPatchLevel   StratagusPatchLevel

Network protocol patch level (maximum 99)

◆ NetworkProtocolVersion

#define NetworkProtocolVersion
Value:
NetworkProtocolPatchLevel)

Network protocol version (1,2,3) -> 10203.

Enumeration Type Documentation

◆ _net_client_con_state_

Network Client connect states

Enumerator
ccs_unused 
ccs_connecting 

Unused.

ccs_connected 

New client.

ccs_mapinfo 

Has received slot info.

ccs_badmap 

Has received matching map-info.

ccs_synced 

Has received non-matching map-info.

ccs_async 

Client is in sync with server.

ccs_changed 

Server user has changed selection.

ccs_detaching 

Client user has made menu selection.

ccs_disconnected 

Client user wants to detach.

ccs_unreachable 

Client has detached.

ccs_usercanceled 

Server is unreachable.

ccs_nofreeslots 

Connection canceled by user.

ccs_serverquits 

Server has no more free slots.

ccs_goahead 

Server quits.

ccs_started 

Server wants to start game.

ccs_incompatibleengine 

Server has started game.

ccs_incompatibleluafiles 

Incompatible engine version.

ccs_needmap 

Incompatible lua files.

Function Documentation

◆ FindHostIndexBy()

int FindHostIndexBy ( const CHost host)

Disable the random placement of players in muliplayer mode.

◆ GetNetworkState()

int GetNetworkState ( )

◆ NetworkDetachFromServer()

void NetworkDetachFromServer ( )

Menu Loop: Server: Mark clients state to send stateinfo message.

Terminate and detach Network connect state machine for the client

◆ NetworkGamePrepareGameSettings()

void NetworkGamePrepareGameSettings ( )

Server user has finally hit the start game button.

Multiplayer network game final copy of server settings to game settings.

◆ NetworkInitClientConnect()

void NetworkInitClientConnect ( )

Setup Network connect state machine for clients

◆ NetworkInitServerConnect()

void NetworkInitServerConnect ( int  openslots)

Setup network connect state machine for clients.

Setup Network connect state machine for the server

◆ NetworkParseSetupEvent()

int NetworkParseSetupEvent ( const unsigned char *  buf,
int  size,
const CHost host 
)

Setup network connect state machine for the server.

Parse a setup event. (Command type <= MessageInitEvent)

Parameters
bufPacket received
sizesize of the received packet.
hosthost which send the message
Returns
1 if packet is an InitConfig message, 0 otherwise

◆ NetworkProcessClientRequest()

void NetworkProcessClientRequest ( )

Menu: Setup the server IP.

Client Menu Loop: Send out client request messages

◆ NetworkProcessServerRequest()

void NetworkProcessServerRequest ( )

Menu Loop: Send out client request messages.

Server Menu Loop: Send out server request messages

◆ NetworkSendICMessage()

void NetworkSendICMessage ( CUDPSocket socket,
const CHost host,
const CInitMessage_Header msg 
)

Menu Loop: Client: Send GoodBye to the server and detach.

◆ NetworkServerResyncClients()

void NetworkServerResyncClients ( )

Menu Loop: Send out server request messages.

Notify state change by menu user to connected clients

◆ NetworkServerStartGame()

void NetworkServerStartGame ( )

Server user has finally hit the start game button. (This is run on the server)

◆ NetworkSetupServerAddress()

int NetworkSetupServerAddress ( const std::string &  serveraddr,
int  port 
)

Parse a network connect event.

Setup the IP-Address of the network server to connect to

Parameters
serveraddrthe serveraddress the user has entered
Returns
True, if error; otherwise false.

Variable Documentation

◆ Hosts

Network players.

◆ LocalSetupState

CServerSetup LocalSetupState

Network menu: Multiplayer Server Menu selections state.

◆ NetConnectRunning

int NetConnectRunning

Host, port, and number of all players.

Host, port, and number of all players.

◆ NetConnectType

int NetConnectType

Network menu: Setup mode active.

◆ NetLocalHostsSlot

int NetLocalHostsSlot

Network menu: Setup mode active.

◆ NetLocalPlayerNumber

int NetLocalPlayerNumber

Network menu: Slot # in Hosts array of local client.

◆ NetPlayers

int NetPlayers

Player number of local client.

◆ NetworkMapFragmentName

std::string NetworkMapFragmentName

Name of the map received with ICMMap.

◆ NetworkMapName

std::string NetworkMapName

Player number of local client.

Player number of local client.

◆ NoRandomPlacementMultiplayer

bool NoRandomPlacementMultiplayer

Network menu: Multiplayer Client Menu selections local state.

Network menu: Multiplayer Client Menu selections local state.

◆ ServerSetupState

CServerSetup ServerSetupState

Name of the map currently loading via ICMMapNeeded.

Name of the map currently loading via ICMMapNeeded.

NetworkProtocolMinorVersion
#define NetworkProtocolMinorVersion
Network protocol minor version (maximum 99)
Definition: netconnect.h:46
NetworkProtocolMajorVersion
#define NetworkProtocolMajorVersion
Network protocol major version.
Definition: netconnect.h:44
(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.