Skip to content

Commit

Permalink
asdad
Browse files Browse the repository at this point in the history
  • Loading branch information
WtzLAS committed Dec 24, 2023
1 parent ec242e0 commit 7388486
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
28 changes: 21 additions & 7 deletions NorthstarDLL/shared/kcpintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ConVar* Cvar_kcp_timer_resolution;
ConVar* Cvar_kcp_select_timeout;
ConVar* Cvar_kcp_conn_timeout;
ConVar* Cvar_kcp_fec;
ConVar* Cvar_kcp_fec_timeout;
ConVar* Cvar_kcp_fec_rx_multi;
ConVar* Cvar_kcp_fec_autotune;
Expand Down Expand Up @@ -131,6 +132,8 @@ ON_DLL_LOAD_RELIESON("engine.dll", WSAHOOKS, ConVar, (CModule module))

Cvar_kcp_conn_timeout = new ConVar("kcp_conn_timeout", "5000", FCVAR_NONE, "miliseconds before a connection is dropped.");

Cvar_kcp_fec = new ConVar("kcp_fec", "1", FCVAR_NONE, "whether to enable FEC or not.");

Cvar_kcp_fec_timeout = new ConVar(
"kcp_fec_timeout", "5000", FCVAR_NONE, "miliseconds before FEC drops unused packets, higher is better but consumes more memory.");

Expand Down Expand Up @@ -264,20 +267,31 @@ NetManager* NetManager::instance()

std::pair<std::shared_ptr<NetSink>, std::shared_ptr<NetSource>> connectionInitDefault(const SOCKET& s, const sockaddr_in6& addr)
{
std::shared_ptr<FecLayer> fec =
std::shared_ptr<FecLayer>(new FecLayer(Cvar_kcp_fec_send_data_shards->GetInt(), Cvar_kcp_fec_send_parity_shards->GetInt(), 1, 1));
std::shared_ptr<KcpLayer> kcp = std::shared_ptr<KcpLayer>(new KcpLayer({s, addr}));
std::shared_ptr<MuxLayer> mux = std::shared_ptr<MuxLayer>(new MuxLayer());

mux->bindTop(0, std::static_pointer_cast<NetSink>(GameSink::instance()));
mux->bindTop(1, std::static_pointer_cast<NetSink>(NetGraphSink::instance()));
mux->bindBottom(std::static_pointer_cast<NetSource>(kcp));
kcp->bindTop(std::static_pointer_cast<NetSink>(mux));
kcp->bindBottom(std::static_pointer_cast<NetSource>(fec));
fec->bindTop(std::static_pointer_cast<NetSink>(kcp));
fec->bindBottom(std::static_pointer_cast<NetSource>(UdpSource::instance()));
if (Cvar_kcp_fec->GetBool())
{
std::shared_ptr<FecLayer> fec = std::shared_ptr<FecLayer>(
new FecLayer(Cvar_kcp_fec_send_data_shards->GetInt(), Cvar_kcp_fec_send_parity_shards->GetInt(), 3, 2));

kcp->bindTop(std::static_pointer_cast<NetSink>(mux));
kcp->bindBottom(std::static_pointer_cast<NetSource>(fec));
fec->bindTop(std::static_pointer_cast<NetSink>(kcp));
fec->bindBottom(std::static_pointer_cast<NetSource>(UdpSource::instance()));

return std::make_pair(std::static_pointer_cast<NetSink>(fec), std::static_pointer_cast<NetSource>(mux));
}
else
{
kcp->bindTop(std::static_pointer_cast<NetSink>(mux));
kcp->bindBottom(std::static_pointer_cast<NetSource>(UdpSource::instance()));

return std::make_pair(std::static_pointer_cast<NetSink>(fec), std::static_pointer_cast<NetSource>(mux));
return std::make_pair(std::static_pointer_cast<NetSink>(kcp), std::static_pointer_cast<NetSource>(mux));
}
}

std::pair<std::shared_ptr<NetSink>, std::shared_ptr<NetSource>> NetManager::initAndBind(const NetContext& ctx)
Expand Down
3 changes: 2 additions & 1 deletion NorthstarDLL/shared/kcpintegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ static inline IINT64 itimediff64(IINT64 later, IINT64 earlier)
extern ConVar* Cvar_kcp_timer_resolution;
extern ConVar* Cvar_kcp_select_timeout;
extern ConVar* Cvar_kcp_conn_timeout;
extern ConVar* Cvar_kcp_fec;
extern ConVar* Cvar_kcp_fec_timeout;
extern ConVar* Cvar_kcp_fec_autotune;
extern ConVar* Cvar_kcp_fec_rx_multi;
extern ConVar* Cvar_kcp_fec_autotune;
extern ConVar* Cvar_kcp_fec_send_data_shards;
extern ConVar* Cvar_kcp_fec_send_parity_shards;

Expand Down

0 comments on commit 7388486

Please sign in to comment.