From cad9d77295510ab868db2155be512178603c68bb Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 18 Sep 2024 10:56:28 -0700
Subject: [PATCH] Updated to the latest version of SDL
---
examples/voipchat.c | 16 ++++++++--------
src/SDL_net.c | 16 ++++++++--------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/examples/voipchat.c b/examples/voipchat.c
index baa7942..c08504e 100644
--- a/examples/voipchat.c
+++ b/examples/voipchat.c
@@ -100,8 +100,8 @@ static void SendClientAudioToServer(void)
static void mainloop(void)
{
- const SDL_bool is_client = (server_addr != NULL) ? SDL_TRUE : SDL_FALSE;
- SDL_bool done = SDL_FALSE;
+ const bool is_client = (server_addr != NULL) ? true : false;
+ bool done = false;
Uint64 last_send_ticks = 0;
if (is_client) {
@@ -109,7 +109,7 @@ static void mainloop(void)
}
while (!done) {
- SDL_bool activity = SDL_FALSE;
+ bool activity = false;
const Uint64 now = SDL_GetTicks();
SDL_Event event;
SDLNet_Datagram *dgram = NULL;
@@ -117,7 +117,7 @@ static void mainloop(void)
while (((rc = SDLNet_ReceiveDatagram(sock, &dgram)) == 0) && (dgram != NULL)) {
SDL_Log("%s: got %d-byte datagram from %s:%d", is_client ? "CLIENT" : "SERVER", (int) dgram->buflen, SDLNet_GetAddressString(dgram->addr), (int) dgram->port);
- activity = SDL_TRUE;
+ activity = true;
if (!is_client) { /* we're the server? */
Voice *voice = FindVoiceByAddr(dgram->addr, dgram->port);
Voice *i;
@@ -187,7 +187,7 @@ static void mainloop(void)
}
while (SDL_PollEvent(&event)) {
- activity = SDL_TRUE;
+ activity = true;
switch (event.type) {
case SDL_EVENT_QUIT:
done = 1;
@@ -220,7 +220,7 @@ static void mainloop(void)
while (SDL_GetAudioStreamAvailable(capture_stream) > max_datagram) {
SendClientAudioToServer();
last_send_ticks = now;
- activity = SDL_TRUE;
+ activity = true;
}
}
@@ -247,14 +247,14 @@ static void mainloop(void)
static void run_voipchat(int argc, char **argv)
{
const char *hostname = NULL;
- SDL_bool is_server = SDL_FALSE;
+ bool is_server = false;
int simulate_failure = 0;
int i;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (SDL_strcmp(arg, "--server") == 0) {
- is_server = SDL_TRUE;
+ is_server = true;
} else if ((SDL_strcmp(arg, "--port") == 0) && (i < (argc-1))) {
server_port = (Uint16) SDL_atoi(argv[++i]);
} else if ((SDL_strcmp(arg, "--simulate-failure") == 0) && (i < (argc-1))) {
diff --git a/src/SDL_net.c b/src/SDL_net.c
index b73be1c..34b6cc2 100644
--- a/src/SDL_net.c
+++ b/src/SDL_net.c
@@ -808,12 +808,12 @@ static int MakeSocketNonblocking(Socket handle)
#endif
}
-static SDL_bool WouldBlock(const int err)
+static bool WouldBlock(const int err)
{
#ifdef _WIN32
- return (err == WSAEWOULDBLOCK) ? SDL_TRUE : SDL_FALSE;
+ return (err == WSAEWOULDBLOCK) ? true : false;
#else
- return ((err == EWOULDBLOCK) || (err == EAGAIN) || (err == EINPROGRESS)) ? SDL_TRUE : SDL_FALSE;
+ return ((err == EWOULDBLOCK) || (err == EAGAIN) || (err == EINPROGRESS)) ? true : false;
#endif
}
@@ -1490,7 +1490,7 @@ int SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram)
}
}
- const SDL_bool create_fromaddr = (!fromaddr) ? SDL_TRUE : SDL_FALSE;
+ const bool create_fromaddr = (!fromaddr) ? true : false;
if (create_fromaddr) {
fromaddr = CreateSDLNetAddrFromSockAddr((struct sockaddr *) &from, fromlen);
if (!fromaddr) {
@@ -1598,7 +1598,7 @@ int SDLNet_WaitUntilInputAvailable(void **vsockets, int numsockets, int timeoutm
int retval = 0;
const Uint64 endtime = (timeoutms > 0) ? (SDL_GetTicks() + timeoutms) : 0;
- while (SDL_TRUE) {
+ while (true) {
SDL_memset(pfds, '\0', sizeof (*pfds) * numsockets);
for (int i = 0; i < numsockets; i++) {
@@ -1643,9 +1643,9 @@ int SDLNet_WaitUntilInputAvailable(void **vsockets, int numsockets, int timeoutm
for (int i = 0; i < numsockets; i++) {
SDLNet_GenericSocket *sock = sockets[i];
const struct pollfd *pfd = &pfds[i];
- const SDL_bool failed = ((pfd->revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) ? SDL_TRUE : SDL_FALSE;
- const SDL_bool writable = (pfd->revents & POLLOUT) ? SDL_TRUE : SDL_FALSE;
- const SDL_bool readable = (pfd->revents & POLLIN) ? SDL_TRUE : SDL_FALSE;
+ const bool failed = ((pfd->revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) ? true : false;
+ const bool writable = (pfd->revents & POLLOUT) ? true : false;
+ const bool readable = (pfd->revents & POLLIN) ? true : false;
if (readable || failed) {
retval++;