Fix multiplayer not working

This commit is contained in:
UnknownShadow200 2021-05-23 15:27:42 +10:00
parent 3e828d09af
commit 355f35c719
2 changed files with 8 additions and 10 deletions

View File

@ -283,7 +283,9 @@ cc_result Socket_GetError(cc_socket s, cc_result* result) {
cc_result Socket_Connect(cc_socket s, const cc_string* ip, int port) {
char addr[NATIVE_STR_LEN];
Platform_EncodeUtf8(addr, ip);
return interop_SocketConnect(s, addr, port);
/* returned result is negative for error */
return -interop_SocketConnect(s, addr, port);
}
cc_result Socket_Read(cc_socket s, cc_uint8* data, cc_uint32 count, cc_uint32* modified) {

View File

@ -204,11 +204,7 @@ mergeInto(LibraryManager.library, {
var sock = this.sockets[fd];
if (!sock) return this.EBADF;
var bytes = 0;
if (sock.recv_queue.length) {
bytes = sock.recv_queue[0].data.length;
}
return bytes;
return sock.recv_queue.length;
},
getError:function(fd) {
var sock = this.sockets[fd];
@ -277,8 +273,8 @@ mergeInto(LibraryManager.library, {
sock.recv_queue.unshift(packet);
}
HEAPU8.set(msg.buffer, dst);
return msg.buffer.byteLength;
HEAPU8.set(msg, dst);
return msg.byteLength;
}
};
},