____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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"
#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. | |
Definition in file netconnect.h.
| #define NetworkDefaultPort 6660 |
| #define NetworkProtocolFormatArgs | ( | v | ) | (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:
(NetworkProtocolMajorVersion * 10000 + NetworkProtocolMinorVersion * 100 + \ NetworkProtocolPatchLevel)
Definition at line 47 of file netconnect.h.
Referenced by CheckVersions(), ClientParseConnecting(), and NetworkSendICMessage().
| typedef struct _network_state_ NetworkState |
Connect state information of network systems active in current game.
| enum _ic_message_subtype_ |
Network init config message subtypes (menu state machine).
Definition at line 147 of file netconnect.h.
Network Client connect states
Definition at line 177 of file netconnect.h.
| 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 | ) |
Setup network connect state machine for clients.
Setup Network connect state machine for clients
Definition at line 403 of file netconnect.cpp.
References ccs_connecting, CServerSetup::Clear(), GetTicks(), CNetworkHost::Host, ICMServerQuit, LastStateMsgType, NetConnectRunning, NetLastPacketSent, NetLocalState, NetStateMsgCnt, NetworkPort, NetworkServerPort, PlayerMax, CNetworkHost::PlyNr, and CNetworkHost::Port.
Referenced by tolua_stratagus_NetworkInitClientConnect00().
| 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)
| buf | Packet received | |
| size | size of the received packet. |
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 | ) |
Menu Loop: Send out client request messages.
Client Menu Loop: Send out client request messages
Definition at line 912 of file netconnect.cpp.
References _C_, ccs_async, ccs_badmap, ccs_changed, ccs_connected, ccs_connecting, ccs_detaching, ccs_disconnected, ccs_goahead, ccs_mapinfo, ccs_started, ccs_synced, ccs_unreachable, ccs_usercanceled, DebugPrint, CInitMessage::Hosts, ICMConfig, ICMGo, ICMGoodBye, ICMHello, ICMMap, ICMMapUidMismatch, ICMResync, ICMSeeYou, ICMState, ICMWaiting, CMap::Info, LocalPlayerName, Map, CMapInfo::MapUID, CInitMessage::MapUID, MessageInitHello, NetClientCheckLocalState(), NetConnectRunning, NetLocalState, NetStateMsgCnt, NetworkSendICMessage(), NetworkSendRateLimitedClientMessage(), NetworkServerIP, NetworkServerPort, CNetworkHost::PlyName, CInitMessage::State, CInitMessage::SubType, CInitMessage::Type, and CInitMessage::u.
Referenced by MenuScreen::logic(), and tolua_stratagus_NetworkProcessClientRequest00().
| 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 | ) |
Server user has finally hit the start game button.
Server user has finally hit the start game button
Definition at line 517 of file netconnect.cpp.
References _C_, Assert, CServerSetup::CompOpt, DebugPrint, CInitMessage::Deserialize(), CNetworkHost::Host, CInitMessage::Hosts, CInitMessage::HostsCount, ICMConfig, ICMGo, ICMState, CMap::Info, CServerSetup::LastFrame, Map, CMapInfo::MapUID, CInitMessage::MapUID, MessageInitHello, MessageInitReply, MyRand, NetLastHost, NetLastPort, NetLocalPlayerNumber, NetPlayers, NetRecvUDP(), NetSocketReady(), NetworkFildes, NetworkSendICMessage(), NIPQUAD, NoRandomPlacementMultiplayer, PlayerComputer, PlayerMax, PlayerPerson, CMapInfo::PlayerType, CNetworkHost::PlyName, CNetworkHost::PlyNr, CNetworkHost::Port, CInitMessage::Size(), CInitMessage::State, CInitMessage::SubType, CInitMessage::Type, and CInitMessage::u.
Referenced by tolua_stratagus_NetworkServerStartGame00().
| int NetworkSetupServerAddress | ( | const std::string & | serveraddr | ) |
Menu: Setup the server IP.
Setup the IP-Address of the network server to connect to
| serveraddr | the serveraddress the user has entered |
Definition at line 384 of file netconnect.cpp.
References _C_, DebugPrint, INADDR_NONE, NetResolveHost(), NetworkServerIP, and NIPQUAD.
Referenced by tolua_stratagus_NetworkSetupServerAddress00().
| CNetworkHost Hosts[PlayerMax] |
Host, port, and number of all players.
Definition at line 75 of file netconnect.cpp.
Referenced by InitNetwork2(), NetworkBroadcast(), NetworkEvent(), NetworkRecover(), NetworkRemovePlayer(), NetworkSendSelection(), NetworkSyncCommands(), tolua_get_stratagus_Hosts(), and tolua_set_stratagus_Hosts().
| int HostsCount |
Number of hosts.
Definition at line 74 of file netconnect.cpp.
Referenced by ExitNetwork1(), InitNetwork2(), NetworkBroadcast(), NetworkEvent(), NetworkRecover(), NetworkRemovePlayer(), NetworkSendSelection(), and NetworkSyncCommands().
| std::string LocalPlayerName |
Name of local player.
Name, Version, Copyright
Definition at line 224 of file stratagus.cpp.
Referenced by CclGetLocalPlayerName(), CclSetLocalPlayerName(), ClientParseAsync(), ClientParseConnecting(), ClientParseSynced(), CreateGame(), main(), NetworkConnectSetupGame(), NetworkInitServerConnect(), NetworkProcessClientRequest(), and ServerParseHello().
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: Setup mode active.
Definition at line 77 of file netconnect.cpp.
Referenced by ClientParseBadMap(), ClientParseConnecting(), ClientParseStarted(), MenuScreen::logic(), NetworkEvent(), NetworkExitClientConnect(), NetworkExitServerConnect(), NetworkInitClientConnect(), NetworkInitServerConnect(), NetworkParseMenuPacket(), NetworkParseSetupEvent(), NetworkProcessClientRequest(), NetworkServerResyncClients(), and StartMap().
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 |
Network menu: Local Server/Client connect state.
Definition at line 79 of file netconnect.cpp.
Referenced by ClientParseAsync(), ClientParseConnected(), ClientParseConnecting(), ClientParseDetaching(), ClientParseGoAhead(), ClientParseMapInfo(), ClientParseSynced(), GetNetworkState(), NetClientCheckLocalState(), NetworkDetachFromServer(), NetworkInitClientConnect(), NetworkParseMenuPacket(), NetworkParseSetupEvent(), NetworkProcessClientRequest(), and NetworkSendRateLimitedClientMessage().
| int NetPlayers |
Network players.
Definition at line 66 of file netconnect.cpp.
Referenced by ApplyReplaySettings(), CleanReplayLog(), ClientParseSynced(), CreatePlayer(), ExitNetwork1(), NetworkExitClientConnect(), NetworkGamePrepareGameSettings(), and NetworkServerStartGame().
| NetworkState NetStates[PlayerMax] |
| std::string NetworkArg |
| int NetworkPort |
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().
1.5.6