_________ __ __
/ _____// |_____________ _/ |______ ____ __ __ ______
\_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
/ \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
/_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
\/ \/ \//_____/ \/
______________________ ______________________
T H E W A R B E G I N S
Stratagus - A free fantasy real time strategy game engine
#include <iostream>#include <fstream>#include <set>#include <vector>#include <functional>#include <algorithm>#include <array>#include <utility>#include <random>#include "game.h"#include "online_service.h"#include "stratagus.h"#include "netconnect.h"#include "interface.h"#include "map.h"#include "network.h"#include "parameters.h"#include "player.h"#include "script.h"#include "settings.h"#include "version.h"#include "video.h"#include "mdns.h"Classes | |
| struct | NetworkState |
| class | CServer |
| class | CClient |
netconnect.cpp - The network high level connection code. | |
| #define | CLIENT_LIVE_BEAT 60 |
| #define | CLIENT_IS_DEAD 300 |
| CNetworkHost | Hosts [PlayerMax] |
| Network players. More... | |
| int | NetConnectRunning = 0 |
| Host, ports, and assigned player numbers of all players. More... | |
| int | NetConnectType = 0 |
| 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... | |
| int | NetPlayers |
| Player number of local client. More... | |
| std::string | NetworkMapName |
| How many network players. More... | |
| std::string | NetworkMapFragmentName |
| Name of the map received with ICMMap. More... | |
| bool | NoRandomPlacementMultiplayer = false |
| Name of the map currently loading via ICMMapNeeded. More... | |
| CServerSetup | ServerSetupState |
| Disable the random placement of players in muliplayer mode. More... | |
| CServerSetup | LocalSetupState |
| Network menu: Multiplayer Server Menu selections state. More... | |
| MDNS | MdnsService |
| static CServer | Server |
| static CClient | Client |
| static const char * | ncconstatenames [] |
| static const char * | icmsgsubtypenames [] |
| template<typename T > | |
| static void | NetworkSendICMessage (CUDPSocket &socket, const CHost &host, const T &msg) |
| void | NetworkSendICMessage (CUDPSocket &socket, const CHost &host, const CInitMessage_Header &msg) |
| Menu Loop: Client: Send GoodBye to the server and detach. More... | |
| template<typename T > | |
| static void | NetworkSendICMessage_Log (CUDPSocket &socket, const CHost &host, const T &msg) |
| static void | NetworkSendICMessage_Log (CUDPSocket &socket, const CHost &host, const CInitMessage_Header &msg) |
| static bool | IsLocalSetupInSync (const CServerSetup &state1, const CServerSetup &state2, int index) |
| static bool | IsSafeMapName (const char *mapname) |
| static int | CheckVersions (const CInitMessage_Hello &msg, CUDPSocket &socket, const CHost &host) |
| int | NetworkParseSetupEvent (const unsigned char *buf, int size, const CHost &host) |
| Setup network connect state machine for the server. More... | |
| void | NetworkProcessClientRequest () |
| Menu: Setup the server IP. More... | |
| int | GetNetworkState () |
| int | FindHostIndexBy (const CHost &host) |
| Disable the random placement of players in muliplayer mode. More... | |
| void | NetworkProcessServerRequest () |
| Menu Loop: Send out client request messages. More... | |
| void | NetworkInitClientConnect () |
| void | NetworkServerStartGame () |
| int | NetworkSetupServerAddress (const std::string &serveraddr, int port) |
| Parse a network connect event. More... | |
| void | NetworkDetachFromServer () |
| Menu Loop: Server: Mark clients state to send stateinfo message. More... | |
| void | NetworkInitServerConnect (int openslots) |
| Setup network connect state machine for clients. More... | |
| void | NetworkServerResyncClients () |
| Menu Loop: Send out server request messages. More... | |
| void | NetworkGamePrepareGameSettings () |
| Server user has finally hit the start game button. More... | |
| static int | CclNoRandomPlacementMultiplayer (lua_State *l) |
| static int | CclUsesRandomPlacementMultiplayer (lua_State *l) |
| static int | CclNetworkDiscoverServers (lua_State *l) |
| void | NetworkCclRegister () |
| #define CLIENT_IS_DEAD 300 |
| #define CLIENT_LIVE_BEAT 60 |
|
static |
|
static |
Controls Randomization of Player position in Multiplayer mode. Without arguments, disables randomization. Otherwise, sets the NoRandomization flag to the boolean argument value.
| l | Lua state. |
|
static |
Return if player positions in multiplayer mode are randomized.
| l | Lua state. |
|
static |
Check if the Stratagus version and Network Protocol match
| msg | message received |
| host | host which send the message |
| int FindHostIndexBy | ( | const CHost & | host | ) |
Disable the random placement of players in muliplayer mode.
| int GetNetworkState | ( | ) |
|
static |
|
static |
Check if the map name looks safe.
A map name looks safe when there are no special characters and no .. or // sequences. This way only real valid maps from the map directory will be loaded.
| void NetworkCclRegister | ( | ) |
| 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 copy of server settings to game settings.
| 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)
| buf | Packet received |
| size | size of the received packet. |
| host | host which send the message |
| 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 NetworkSendICMessage | ( | CUDPSocket & | socket, |
| const CHost & | host, | ||
| const CInitMessage_Header & | msg | ||
| ) |
Menu Loop: Client: Send GoodBye to the server and detach.
|
static |
Send an InitConfig message across the Network
| host | Host to send to (network byte order). |
| port | Port of host to send to (network byte order). |
| msg | The message to send |
|
static |
|
static |
| 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. (This is run on the server)
| int NetworkSetupServerAddress | ( | const std::string & | serveraddr, |
| int | port | ||
| ) |
Parse a network connect event.
Setup the IP-Address of the network server to connect to
| serveraddr | the serveraddress the user has entered |
|
static |
| CNetworkHost Hosts[PlayerMax] |
Network players.
|
static |
| CServerSetup LocalSetupState |
Network menu: Multiplayer Server Menu selections state.
| MDNS MdnsService |
|
static |
| int NetConnectRunning = 0 |
Host, ports, and assigned player numbers of all players.
Host, port, and number of all players.
| int NetConnectType = 0 |
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.
| std::string NetworkMapFragmentName |
Name of the map received with ICMMap.
| std::string NetworkMapName |
How many network players.
Player number of local client.
| bool NoRandomPlacementMultiplayer = false |
Name of the map currently loading via ICMMapNeeded.
Network menu: Multiplayer Client Menu selections local state.
|
static |
| CServerSetup ServerSetupState |
Disable the random placement of players in muliplayer mode.
Name of the map currently loading via ICMMapNeeded.
1.8.17
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.