Skip to content

Commit

Permalink
asdasd
Browse files Browse the repository at this point in the history
  • Loading branch information
WtzLAS committed Dec 24, 2023
1 parent 4172869 commit 5197b6a
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions NorthstarDLL/shared/kcpintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,15 @@ std::pair<std::shared_ptr<NetSink>, std::shared_ptr<NetSource>> connectionInitDe
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));
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()));
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));

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()));
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>(kcp), std::static_pointer_cast<NetSource>(mux));
}
return std::make_pair(std::static_pointer_cast<NetSink>(fec), std::static_pointer_cast<NetSource>(mux));
}

std::pair<std::shared_ptr<NetSink>, std::shared_ptr<NetSource>> NetManager::initAndBind(const NetContext& ctx)
Expand Down Expand Up @@ -609,6 +599,11 @@ FecLayer::~FecLayer()

int FecLayer::sendto(NetBuffer&& buf, const NetContext& ctx, const NetSink* top)
{
if (!Cvar_kcp_fec->GetBool())
{
return bottom.lock()->sendto(std::move(buf), ctx, this);
}

auto encoded = encode(buf);
for (auto& nBuf : encoded)
{
Expand Down Expand Up @@ -999,7 +994,8 @@ void updateThreadPayload(std::stop_token stoken, KcpLayer* layer)
std::unique_lock<std::mutex> lk1(layer->cbMutex);
ikcp_update(layer->cb, iclock());
auto current = iclock();
if (itimediff(current, lastStatsSync) >= 100) {
if (itimediff(current, lastStatsSync) >= 100)
{
auto ng = NetGraphSink::instance();
std::shared_lock lk2(ng->windowsMutex);
std::get<0>(ng->windows[layer->remoteAddr]).sync(layer->cb);
Expand Down

0 comments on commit 5197b6a

Please sign in to comment.