mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-24 12:15:16 +00:00
Add a flag to only send udp if client has received udp packets
This commit is contained in:
parent
2f5ed106fa
commit
1fd02147b6
2 changed files with 5 additions and 2 deletions
|
@ -37,6 +37,7 @@ class SocketClient : public SocketBase {
|
|||
private:
|
||||
int maxBufSize = 100;
|
||||
|
||||
bool has_recv_udp;
|
||||
s32 udp_socket;
|
||||
sockaddr udp_addr;
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ bool SocketClient::SEND(Packet *packet) {
|
|||
int valread = 0;
|
||||
|
||||
int fd = -1;
|
||||
if (packet->mType != PLAYERINF && packet->mType != HACKCAPINF && packet->mType != HOLEPUNCH) {
|
||||
if ((packet->mType != PLAYERINF && packet->mType != HACKCAPINF && packet->mType != HOLEPUNCH) || !this->has_recv_udp) {
|
||||
Logger::log("Sending packet: %s\n", packetNames[packet->mType]);
|
||||
fd = this->socket_log_socket;
|
||||
} else {
|
||||
|
@ -196,7 +196,8 @@ bool SocketClient::RECV() {
|
|||
if (fd == -1) {
|
||||
return true;
|
||||
}
|
||||
if (index == 1) {
|
||||
|
||||
if (index == 1) {
|
||||
int result = nn::socket::Recv(fd, headerBuf, sizeof(headerBuf), this->sock_flags);
|
||||
if (result < headerSize){
|
||||
return true;
|
||||
|
@ -224,6 +225,7 @@ if (index == 1) {
|
|||
|
||||
if(mPacketQueue.size() < maxBufSize - 1) {
|
||||
mPacketQueue.pushBack(packet);
|
||||
this->has_recv_udp = true;
|
||||
} else {
|
||||
free(packetBuf);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue