1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-01 23:25:09 +02:00

support native windows binary compilation

* add winsock2 to globals.c

* add winsocket2 compatibility to main function

* add winsocket2 to packets.c

* and winsocket2 to procedures.c

* add winsocket 2 compatibility to tools.c

* add winsocket2 to varnum.c

* add mingw64 linker options to build.sh

* fix build

* style nitpicks

* remove old_fd

* update compilation instructions for windows

---------

Co-authored-by: p2r3 <41925384+p2r3@users.noreply.github.com>
This commit is contained in:
jcfb
2025-09-14 15:11:56 +01:00
committed by GitHub
parent f6333429eb
commit 26f068bc09
8 changed files with 115 additions and 16 deletions

View File

@@ -2,6 +2,9 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef _WIN32
#include <winsock2.h>
#endif
#include "globals.h"
#include "tools.h"
@@ -181,9 +184,14 @@ void disconnectClient (int *client_fd, int cause) {
client_count --;
setClientState(*client_fd, STATE_NONE);
handlePlayerDisconnect(*client_fd);
#ifdef _WIN32
closesocket(*client_fd);
printf("Disconnected client %d, cause: %d, errno: %d\n", *client_fd, cause, WSAGetLastError());
#else
close(*client_fd);
*client_fd = -1;
printf("Disconnected client %d, cause: %d, errno: %d\n\n", *client_fd, cause, errno);
#endif
*client_fd = -1;
}
uint8_t serverSlotToClientSlot (int window_id, uint8_t slot) {