From f9c0ee865f34d6c7dd5e16a1f76b5f5388cbf9e2 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 23:50:44 +0100 Subject: [PATCH] make those ternaries a little prettier lul --- src/d_net.c | 8 +++++++- src/hardware/hw_main.cpp | 6 ++++-- src/i_net.h | 4 ++-- src/i_tcp.c | 11 ++++++----- src/r_bsp.cpp | 6 ++++-- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index ba70cb7c1..59b31a1fb 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -492,6 +492,7 @@ void Net_AckTicker(void) ackpak[i].acknum = 0; continue; } + DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime, NODETIMEOUT, I_GetTime())); memcpy(netbuffer, ackpak[i].pak.raw, ackpak[i].length); @@ -1224,7 +1225,7 @@ void D_SetDoomcom(void) if (doomcom) return; - doomcom = Z_Calloc(sizeof (doomcom_t), PU_STATIC, NULL); + doomcom = Z_Calloc(sizeof(doomcom_t), PU_STATIC, NULL); doomcom->id = DOOMCOM_ID; doomcom->numslots = doomcom->numnodes = 1; } @@ -1266,6 +1267,7 @@ boolean D_CheckNetGame(void) ret = true; if (client && netgame) netgame = false; + server = true; // WTF? server always true??? // no! The deault mode is server. Client is set elsewhere // when the client executes connect command. @@ -1301,6 +1303,7 @@ boolean D_CheckNetGame(void) if (doomcom->id != DOOMCOM_ID) I_Error("Doomcom buffer invalid!"); + if (doomcom->numnodes > MAXNETNODES) I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES); @@ -1309,14 +1312,17 @@ boolean D_CheckNetGame(void) { char filename[21]; INT32 k = doomcom->consoleplayer - 1; + if (M_IsNextParm()) k = atoi(M_GetNextParm()) - 1; + while (!debugfile && k < MAXPLAYERS) { k++; sprintf(filename, "debug%d.txt", k); debugfile = fopen(va("%s" PATHSEP "%s", srb2home, filename), "w"); } + if (debugfile) CONS_Printf(M_GetText("debug output to: %s\n"), va("%s" PATHSEP "%s", srb2home, filename)); else diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index fbf7a6a76..9f1a90769 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2500,8 +2500,10 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) // Find the corners of the box // that define the edges from current viewpoint. - const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) + - (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); + const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : + viewx < bspcoord[BOXRIGHT] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP] ? 0 : + viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; diff --git a/src/i_net.h b/src/i_net.h index e811908f2..112fd706e 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -80,6 +80,8 @@ typedef struct #define DOOMCOM_DATA(d) (doomdata_t *)&(d)->data +extern doomcom_t *doomcom; + #ifdef HOLEPUNCH typedef struct { @@ -91,8 +93,6 @@ typedef struct #define HOLEPUNCH_DATA(d) (holepunch_t *)&(d)->data #endif -extern doomcom_t *doomcom; - /** \brief return packet in doomcom struct */ extern boolean (*I_NetGet)(void); diff --git a/src/i_tcp.c b/src/i_tcp.c index 98a03f841..982b327d0 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -568,13 +568,12 @@ void Command_Numnodes(void) #ifdef HOLEPUNCH /* not one of the reserved "local" addresses */ -static boolean -is_external_address (UINT32 p) +static boolean is_external_address(UINT32 p) { UINT8 a = (p & 255); UINT8 b = ((p >> 8) & 255); - if (p == (UINT32)~0)/* 255.255.255.255 */ + if (p == (UINT32)~0) /* 255.255.255.255 */ return 0; switch (a) @@ -584,7 +583,7 @@ is_external_address (UINT32 p) case 127: return false; case 172: - return (b & ~15) != 16;/* 16 - 31 */ + return (b & ~15) != 16; /* 16 - 31 */ case 192: return b != 168; default: @@ -763,6 +762,7 @@ static void SOCK_Send(void) if (myfamily[i] == broadcastaddress[j].any.sa_family) { c = SOCK_SendToAddr(mysockets[i], &broadcastaddress[j]); + if (c == ERRSOCKET) { e = errno; @@ -780,6 +780,7 @@ static void SOCK_Send(void) if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family) { c = SOCK_SendToAddr(mysockets[i], &clientaddress[doomcom->remotenode]); + if (c == ERRSOCKET) { e = errno; @@ -792,6 +793,7 @@ static void SOCK_Send(void) else { c = SOCK_SendToAddr(nodesocket[doomcom->remotenode], &clientaddress[doomcom->remotenode]); + if (c == ERRSOCKET) { e = errno; @@ -1060,7 +1062,6 @@ static boolean UDP_Socket(void) #endif const char *serv; - for (s = 0; s < mysocketses; s++) mysockets[s] = ERRSOCKET; for (s = 0; s < MAXNETNODES+1; s++) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index ac9ab081b..a256f69b2 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -520,8 +520,10 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) // Find the corners of the box // that define the edges from current viewpoint. - boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + - (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); + const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : + viewx < bspcoord[BOXRIGHT] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP] ? 0 : + viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true;