Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
NetServer.cpp File Reference
#include "precompiled.h"
#include "NetServer.h"
#include "NetClient.h"
#include "NetEnet.h"
#include "NetMessage.h"
#include "NetSession.h"
#include "NetServerTurnManager.h"
#include "NetStats.h"
#include "lib/external_libraries/enet.h"
#include "lib/types.h"
#include "network/StunClient.h"
#include "ps/CLogger.h"
#include "ps/ConfigDB.h"
#include "ps/GUID.h"
#include "ps/Hashing.h"
#include "ps/Profile.h"
#include "ps/Threading.h"
#include "scriptinterface/ScriptContext.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/JSON.h"
#include "simulation2/Simulation2.h"
#include "simulation2/system/TurnManager.h"
#include <miniupnpc/miniwget.h>
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#include <miniupnpc/upnperrors.h>
#include <set>
#include <string>
Include dependency graph for NetServer.cpp:

Macros

#define MAX_CLIENTS   41
 Number of peers to allocate for the enet host. More...
 
#define DEFAULT_SERVER_NAME   L"Unnamed Server"
 

Functions

static CStr DebugName (CNetServerSession *session)
 

Variables

constexpr int CHANNEL_COUNT = 1
 
constexpr int FAILED_PASSWORD_TRIES_BEFORE_BAN = 3
 
static const int HOST_SERVICE_TIMEOUT = 50
 enet_host_service timeout (msecs). More...
 
constexpr u32 NETWORK_BAD_PING = DEFAULT_TURN_LENGTH * COMMAND_DELAY_MP / 2
 Once ping goes above turn length * command delay, the game will start 'freezing' for other clients while we catch up. More...
 
CNetServerg_NetServer = NULL
 Global network server for the standard game. More...
 

Macro Definition Documentation

◆ DEFAULT_SERVER_NAME

#define DEFAULT_SERVER_NAME   L"Unnamed Server"

◆ MAX_CLIENTS

#define MAX_CLIENTS   41

Number of peers to allocate for the enet host.

Limited by ENET_PROTOCOL_MAXIMUM_PEER_ID (4096).

At most 8 players, 32 observers and 1 temporary connection to send the "server full" disconnect-reason.

Function Documentation

◆ DebugName()

static CStr DebugName ( CNetServerSession session)
static

Variable Documentation

◆ CHANNEL_COUNT

constexpr int CHANNEL_COUNT = 1
constexpr

◆ FAILED_PASSWORD_TRIES_BEFORE_BAN

constexpr int FAILED_PASSWORD_TRIES_BEFORE_BAN = 3
constexpr

◆ g_NetServer

CNetServer* g_NetServer = NULL

Global network server for the standard game.

◆ HOST_SERVICE_TIMEOUT

const int HOST_SERVICE_TIMEOUT = 50
static

enet_host_service timeout (msecs).

Smaller numbers may hurt performance; larger numbers will hurt latency responding to messages from game thread.

◆ NETWORK_BAD_PING

constexpr u32 NETWORK_BAD_PING = DEFAULT_TURN_LENGTH * COMMAND_DELAY_MP / 2
constexpr

Once ping goes above turn length * command delay, the game will start 'freezing' for other clients while we catch up.

Since commands are sent client -> server -> client, divide by 2. (duplicated in NetServer.cpp to avoid having to fetch the constants in a header file)