_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          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 File Reference
#include "net_message.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
}
 
int NetPlayers
 Player number of local client. More...
 
int HostsCount
 Network players. More...
 
CNetworkHost Hosts [PlayerMax]
 Number of hosts. 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...
 
CServerSetup ServerSetupState
 Player number of local client. More...
 
CServerSetup LocalSetupState
 Network menu: Multiplayer Server Menu selections state. More...
 
int FindHostIndexBy (const CHost &host)
 Network menu: Multiplayer Client Menu selections local state. 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...
 

Macro Definition Documentation

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

Network protocol printf format arguments.

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

Network protocol printf format string.

#define NetworkProtocolMajorVersion   StratagusMajorVersion

Network protocol major version.

#define NetworkProtocolMinorVersion   StratagusMinorVersion

Network protocol minor version (maximum 99)

#define NetworkProtocolPatchLevel   StratagusPatchLevel

Network protocol patch level (maximum 99)

#define NetworkProtocolVersion
Value:
#define NetworkProtocolMinorVersion
Network protocol minor version (maximum 99)
Definition: netconnect.h:45
#define NetworkProtocolPatchLevel
Network protocol patch level (maximum 99)
Definition: netconnect.h:47
#define NetworkProtocolMajorVersion
Network protocol major version.
Definition: netconnect.h:43

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

Enumeration Type Documentation

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.

Incompatible lua files

Function Documentation

int FindHostIndexBy ( const CHost host)

Network menu: Multiplayer Client Menu selections local state.

int GetNetworkState ( )
void NetworkDetachFromServer ( )

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

Terminate and detach Network connect state machine for the client

void NetworkGamePrepareGameSettings ( )

Server user has finally hit the start game button.

Multiplayer network game final race and player type setup.

void NetworkInitClientConnect ( )

Setup Network connect state machine for clients

void NetworkInitServerConnect ( int  openslots)

Setup network connect state machine for clients.

Setup Network connect state machine for the server

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
void NetworkProcessClientRequest ( )

Menu: Setup the server IP.

Client Menu Loop: Send out client request messages

void NetworkProcessServerRequest ( )

Menu Loop: Send out client request messages.

Server Menu Loop: Send out server request messages

void NetworkServerResyncClients ( )

Menu Loop: Send out server request messages.

Notify state change by menu user to connected clients

void NetworkServerStartGame ( )

Server user has finally hit the start game button

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

Number of hosts.

int HostsCount

Network players.

CServerSetup LocalSetupState

Network menu: Multiplayer Server Menu selections state.

int NetConnectRunning

Host, port, and number of all players.

Host, port, and number of all players.

int NetConnectType

Network menu: Setup mode active.

int NetLocalHostsSlot

Network menu: Setup mode active.

int NetLocalPlayerNumber

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

int NetPlayers

Player number of local client.

CServerSetup ServerSetupState

Player number of local client.

Player number of local client.

(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.