____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

netconnect.h File Reference

The network connection setup header file. More...

#include <string>
#include "SDL.h"

Go to the source code of this file.

Classes

class  CNetworkHost
struct  _network_state_
class  CServerSetup
class  CInitMessage

Defines

#define NetworkProtocolMajorVersion   StratagusMajorVersion
 < Network protocol major version
#define NetworkProtocolMinorVersion   StratagusMinorVersion
 Network protocol patch level (maximal 99).
#define NetworkProtocolPatchLevel   StratagusPatchLevel
 Network protocol version (1,2,3) -> 10203.
#define NetworkProtocolVersion
 Network protocol printf format string.
#define NetworkProtocolFormatString   "%d.%d.%d"
 Network protocol printf format arguments.
#define NetworkProtocolFormatArgs(v)   (v) / 10000, ((v) / 100) % 100, (v) % 100
#define NetworkDefaultPort   6660
 Default communication port.

Typedefs

typedef struct _network_state_ NetworkState

Enumerations

enum  _ic_message_subtype_ {
  ICMHello, ICMConfig, ICMEngineMismatch, ICMProtocolMismatch,
  ICMEngineConfMismatch, ICMMapUidMismatch, ICMGameFull, ICMWelcome,
  ICMWaiting, ICMMap, ICMState, ICMResync,
  ICMServerQuit, ICMGoodBye, ICMSeeYou, ICMGo,
  ICMAYT, ICMIAH
}
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_incompatiblenetwork
}

Functions

void NetworkServerStartGame (void)
 Server user has finally hit the start game button.
void NetworkGamePrepareGameSettings (void)
void NetworkConnectSetupGame (void)
 Assign Player slot, evaluate Setup state..
void NetworkInitClientConnect (void)
 Setup network connect state machine for clients.
void NetworkExitClientConnect (void)
 Terminate network connect state machine for clients.
void NetworkInitServerConnect (int openslots)
 Setup network connect state machine for the server.
void NetworkExitServerConnect (void)
 Terminate network connect state machine for the server.
int NetworkParseSetupEvent (const unsigned char *buf, int size)
 Parse a network connect event.
int NetworkSetupServerAddress (const std::string &serveraddr)
 Menu: Setup the server IP.
void NetworkProcessClientRequest (void)
 Menu Loop: Send out client request messages.
void NetworkProcessServerRequest (void)
 Menu Loop: Send out server request messages.
void NetworkServerResyncClients (void)
 Menu Loop: Server: Mark clients state to send stateinfo message.
void NetworkDetachFromServer (void)
 Menu Loop: Client: Send GoodBye to the server and detach.

Variables

std::string NetworkArg
 Network command line argument.
int NetPlayers
 Network players.
int NetworkPort
 Local network port to use.
std::string LocalPlayerName
 Name of local player.
int HostsCount
 Number of hosts.
CNetworkHost Hosts [PlayerMax]
 Host, port, and number of all players.
int NetConnectRunning
 Network menu: Setup mode active.
NetworkState NetStates [PlayerMax]
 Network menu: Server: Client Host states.
unsigned char NetLocalState
 Network menu: Local Server/Client connect state.
int NetLocalHostsSlot
 Network menu: Slot # in Hosts array of local client.
int NetLocalPlayerNumber
 Player number of local client.
CServerSetup ServerSetupState
 Network menu: Multiplayer Server Menu selections state.
CServerSetup LocalSetupState
 Network menu: Multiplayer Client Menu selections local state.


Detailed Description

The network connection setup header file.

Definition in file netconnect.h.


Define Documentation

#define NetworkDefaultPort   6660

Default communication port.

Definition at line 56 of file netconnect.h.

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

Definition at line 54 of file netconnect.h.

Referenced by CheckVersions(), and ClientParseConnecting().

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

Network protocol printf format arguments.

Definition at line 52 of file netconnect.h.

Referenced by CheckVersions(), and ClientParseConnecting().

#define NetworkProtocolMajorVersion   StratagusMajorVersion

< Network protocol major version

Network protocol minor version (maximal 99)

Definition at line 41 of file netconnect.h.

Referenced by StartReplay().

#define NetworkProtocolMinorVersion   StratagusMinorVersion

Network protocol patch level (maximal 99).

Definition at line 43 of file netconnect.h.

Referenced by StartReplay().

#define NetworkProtocolPatchLevel   StratagusPatchLevel

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

Definition at line 45 of file netconnect.h.

Referenced by StartReplay().

#define NetworkProtocolVersion

Value:

Network protocol printf format string.

Definition at line 47 of file netconnect.h.

Referenced by CheckVersions(), ClientParseConnecting(), and NetworkSendICMessage().


Typedef Documentation

typedef struct _network_state_ NetworkState

Connect state information of network systems active in current game.


Enumeration Type Documentation

Network init config message subtypes (menu state machine).

Enumerator:
ICMHello  Client Request.
ICMConfig  Setup message configure clients.
ICMEngineMismatch  Stratagus engine version doesn't match.
ICMProtocolMismatch  Network protocol version doesn't match.
ICMEngineConfMismatch  Engine configuration isn't identical.
ICMMapUidMismatch  MAP UID doesn't match.
ICMGameFull  No player slots available.
ICMWelcome  Acknowledge for new client connections.
ICMWaiting  Client has received Welcome and is waiting for Map/State.
ICMMap  MapInfo (and Mapinfo Ack).
ICMState  StateInfo.
ICMResync  Ack StateInfo change.
ICMServerQuit  Server has quit game.
ICMGoodBye  Client wants to leave game.
ICMSeeYou  Client has left game.
ICMGo  Client is ready to run.
ICMAYT  Server asks are you there.
ICMIAH  Client answers I am here.

Definition at line 147 of file netconnect.h.

Network Client connect states

Enumerator:
ccs_unused  Unused.
ccs_connecting  New client.
ccs_connected  Has received slot info.
ccs_mapinfo  Has received matching map-info.
ccs_badmap  Has received non-matching map-info.
ccs_synced  Client is in sync with server.
ccs_async  Server user has changed selection.
ccs_changed  Client user has made menu selection.
ccs_detaching  Client user wants to detach.
ccs_disconnected  Client has detached.
ccs_unreachable  Server is unreachable.
ccs_usercanceled  Connection canceled by user.
ccs_nofreeslots  Server has no more free slots.
ccs_serverquits  Server quits.
ccs_goahead  Server wants to start game.
ccs_started  Server has started game.
ccs_incompatibleengine  Incompatible engine version.
ccs_incompatiblenetwork  Incompatible netowrk version.

Definition at line 177 of file netconnect.h.


Function Documentation

void NetworkConnectSetupGame ( void   ) 

Assign Player slot, evaluate Setup state..

Assign player slots and names in a network game..

Definition at line 888 of file netconnect.cpp.

References CInitMessage::HostsCount, LocalPlayerName, Players, CNetworkHost::PlyNr, CPlayer::SetName(), and ThisPlayer.

Referenced by InitNetwork2().

void NetworkDetachFromServer ( void   ) 

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

Terminate and detach Network connect state machine for the client

Definition at line 435 of file netconnect.cpp.

References ccs_detaching, NetLocalState, and NetStateMsgCnt.

Referenced by tolua_stratagus_NetworkDetachFromServer00().

void NetworkExitClientConnect ( void   ) 

Terminate network connect state machine for clients.

Terminate Network connect state machine for clients

Definition at line 426 of file netconnect.cpp.

References NetConnectRunning, and NetPlayers.

void NetworkExitServerConnect ( void   ) 

Terminate network connect state machine for the server.

Terminate Network connect state machine for the server

Definition at line 472 of file netconnect.cpp.

References _C_, DebugPrint, ICMServerQuit, MessageInitReply, NetConnectRunning, NetworkInitServerConnect(), NetworkSendICMessage(), NIPQUAD, PlayerMax, CInitMessage::SubType, and CInitMessage::Type.

void NetworkGamePrepareGameSettings ( void   ) 

Multiplayer network game final player type setup.

Definition at line 821 of file netconnect.cpp.

Referenced by tolua_stratagus_NetworkGamePrepareGameSettings00().

void NetworkInitClientConnect ( void   ) 

void NetworkInitServerConnect ( int  openslots  ) 

Setup network connect state machine for the server.

Setup Network connect state machine for the server

Definition at line 444 of file netconnect.cpp.

References ccs_unused, CServerSetup::Clear(), CServerSetup::CompOpt, CNetworkHost::Host, LocalPlayerName, NetConnectRunning, PlayerMax, CNetworkHost::PlyName, CNetworkHost::PlyNr, CNetworkHost::Port, and _network_state_::State.

Referenced by NetworkExitServerConnect(), and tolua_stratagus_NetworkInitServerConnect00().

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

Parse a network connect event.

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

Parameters:
buf Packet received
size size of the received packet.
Returns:
1 if packet is an InitConfig message, 0 otherwise

Definition at line 2047 of file netconnect.cpp.

References ccs_started, CInitMessage::Deserialize(), IfaceStateMenu, InterfaceState, MessageInitConfig, NetConnectRunning, NetLocalState, NetworkParseMenuPacket(), CInitMessage::Size(), and CInitMessage::Type.

Referenced by NetworkEvent().

void NetworkProcessClientRequest ( void   ) 

void NetworkProcessServerRequest ( void   ) 

Menu Loop: Send out server request messages.

Server Menu Loop: Send out server request messages

Definition at line 1076 of file netconnect.cpp.

References _C_, CLIENT_IS_DEAD, CLIENT_LIVE_BEAT, DebugPrint, FrameCounter, GameRunning, ICMAYT, KickDeadClient(), CServerSetup::LastFrame, CInitMessage::MapUID, MessageInitReply, NetworkSendICMessage(), NIPQUAD, PlayerMax, CInitMessage::SubType, and CInitMessage::Type.

Referenced by MenuScreen::logic().

void NetworkServerResyncClients ( void   ) 

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

Notify state change by menu user to connected clients

Definition at line 501 of file netconnect.cpp.

References ccs_async, ccs_synced, NetConnectRunning, PlayerMax, _network_state_::State, and CInitMessage::State.

Referenced by tolua_stratagus_NetworkServerResyncClients00().

void NetworkServerStartGame ( void   ) 

int NetworkSetupServerAddress ( const std::string &  serveraddr  ) 

Menu: Setup the server IP.

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

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

Definition at line 384 of file netconnect.cpp.

References _C_, DebugPrint, INADDR_NONE, NetResolveHost(), NetworkServerIP, and NIPQUAD.

Referenced by tolua_stratagus_NetworkSetupServerAddress00().


Variable Documentation

CNetworkHost Hosts[PlayerMax]

std::string LocalPlayerName

Network menu: Multiplayer Client Menu selections local state.

Definition at line 98 of file netconnect.cpp.

Referenced by tolua_get_LocalSetupState(), and tolua_set_LocalSetupState().

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

Definition at line 80 of file netconnect.cpp.

Referenced by ClientParseAsync(), ClientParseConnecting(), NetClientCheckLocalState(), tolua_get_NetLocalHostsSlot(), and tolua_set_NetLocalHostsSlot().

Player number of local client.

Definition at line 81 of file netconnect.cpp.

Referenced by ApplyReplaySettings(), ClientParseSynced(), CreatePlayer(), and NetworkServerStartGame().

unsigned char NetLocalState

NetworkState NetStates[PlayerMax]

Network menu: Server: Client Host states.

Definition at line 78 of file netconnect.cpp.

std::string NetworkArg

Network command line argument.

Definition at line 65 of file netconnect.cpp.

Referenced by main().

Local network port to use.

Definition at line 67 of file netconnect.cpp.

Referenced by InitNetwork1(), main(), and NetworkInitClientConnect().

Network menu: Multiplayer Server Menu selections state.

Client and server selection state for Multiplayer clients

Definition at line 97 of file netconnect.cpp.

Referenced by tolua_get_ServerSetupState(), and tolua_set_ServerSetupState().


Generated on Sat Feb 21 00:28:18 2009 for Bos Wars by  doxygen 1.5.6