Skip to content

Commit

Permalink
asdadsad
Browse files Browse the repository at this point in the history
  • Loading branch information
WtzLAS committed Dec 20, 2023
1 parent dd88023 commit fe16e9b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions NorthstarDLL/shared/kcpintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ ON_DLL_LOAD_RELIESON("engine.dll", WSAHOOKS, ConVar, (CModule module))
Cvar_kcp_fec_send_parity_shards = new ConVar("kcp_fec_send_parity_shards", "2", FCVAR_NONE, "number of FEC parity shards.");
}

NetBuffer::NetBuffer(std::vector<char>&& buf)
{
inner = std::move(buf);
currentOffset = 0;
}

NetBuffer::NetBuffer(const char* buf, int len, int headerExtraLen)
{
inner = std::vector<char>(headerExtraLen + len, 0);
Expand Down Expand Up @@ -996,8 +1002,21 @@ int KcpLayer::input(const NetBuffer& buf, const NetContext& ctx)
{
NS::log::NEW_NET.get()->error("[KCP] input {}: error {}", ctx, result);
}
auto peeksize = ikcp_peeksize(cb);
while (peeksize >= 0)
{
if (peeksize >= 0)
{
NetBuffer buf(std::move(std::vector<char>(peeksize)));
auto recvsize = ikcp_recv(cb, buf.data(), peeksize);
buf.resize(recvsize, 0);
top->input(buf, ctx);
}
peeksize = ikcp_peeksize(cb);
}
std::unique_lock<std::mutex> lk(updateCvMutex);
updateCv.notify_all();

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion NorthstarDLL/shared/kcpintegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ struct NetBuffer
size_t currentOffset;

inline NetBuffer() : NetBuffer(std::vector<char>()) {}
inline NetBuffer(std::vector<char>&& buf) : NetBuffer(buf.data(), buf.size()) {}
NetBuffer(std::vector<char>&& buf);
inline NetBuffer(const std::vector<char>& buf) : NetBuffer(buf.data(), buf.size()) {}
inline NetBuffer(const char* buf, const int len) : NetBuffer(buf, len, NET_BUFFER_DEFAULT_HEADER_EXTRA_LEN) {}
NetBuffer(const char* buf, const int len, const int headerExtraLen);
Expand Down

0 comments on commit fe16e9b

Please sign in to comment.