From 48ba151d980e7859565d84f1700278cd3b246735 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 3 May 2020 20:58:12 -0400 Subject: [PATCH 1/5] Rather than showing random added skins, show random other players in the server on the signpost! --- src/p_mobj.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 2838e9388..499ff4ff3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8981,13 +8981,39 @@ void P_MobjThinker(mobj_t *mobj) { if (ticstilimpact <= 8) { - newskin = ((skin_t*)mobj->target->skin)-skins; + newskin = mobj->target->player->skin; newcolor = mobj->target->player->skincolor; } else { - newskin = leveltime % numskins; - newcolor = skins[newskin].prefcolor; + UINT8 plist[MAXPLAYERS]; + UINT8 plistlen = 0; + UINT8 i; + + memset(plist, 0, sizeof(plist)); + + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].spectator) + { + plist[plistlen] = i; + plistlen++; + } + } + + if (plistlen <= 1) + { + // Default to the winner + newskin = mobj->target->player->skin; + newcolor = mobj->target->player->skincolor; + } + else + { + // Pick another player in the server! + player_t *p = &players[plist[P_RandomKey(plistlen)]]; + newskin = p->skin; + newcolor = p->skincolor; + } } } } From cc87418db8ad422089fb101f98742cae16ab1d87 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 3 May 2020 21:26:57 -0400 Subject: [PATCH 2/5] Handling code clean-up - Cleans up multiple FixedMul instances, ensuring only fixed_t numbers are ever passed in. - Prevents speed values from overflowing by giving it a maximum. This both gives you more control when moving above 200% top speed, and fixes the bug which corrupted your turn inputs (turning wrong direction, turning without pressing anything, etc) when moving too fast. --- src/k_kart.c | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ee4a94efe..59ec3a83d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6721,54 +6721,65 @@ boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y) // turndir is the direction the controls are telling us to turn, -1 if turning right and 1 if turning left static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer) { - INT16 basedrift, driftangle; + INT16 basedrift, driftadjust; fixed_t driftweight = player->kartweight*14; // 12 - // If they aren't drifting or on the ground this doesn't apply if (player->kartstuff[k_drift] == 0 || !P_IsObjectOnGround(player->mo)) + { + // If they aren't drifting or on the ground, this doesn't apply return 0; + } if (player->kartstuff[k_driftend] != 0) - return -266*player->kartstuff[k_drift]; // Drift has ended and we are tweaking their angle back a bit + { + // Drift has ended and we are tweaking their angle back a bit + return -266*player->kartstuff[k_drift]; + } - //basedrift = 90*player->kartstuff[k_drift]; // 450 - //basedrift = 93*player->kartstuff[k_drift] - driftweight*3*player->kartstuff[k_drift]/10; // 447 - 303 - basedrift = 83*player->kartstuff[k_drift] - (driftweight - 14)*player->kartstuff[k_drift]/5; // 415 - 303 - driftangle = abs((252 - driftweight)*player->kartstuff[k_drift]/5); + basedrift = (83 * player->kartstuff[k_drift]) - (((driftweight - 14) * player->kartstuff[k_drift]) / 5); // 415 - 303 + driftadjust = abs((252 - driftweight) * player->kartstuff[k_drift] / 5); if (player->kartstuff[k_tiregrease] > 0) // Buff drift-steering while in greasemode + { basedrift += (basedrift / greasetics) * player->kartstuff[k_tiregrease]; + } - return basedrift + FixedMul(driftangle, countersteer); + return basedrift + (FixedMul(driftadjust * FRACUNIT, countersteer) / FRACUNIT); } INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) { - fixed_t p_maxspeed = FixedMul(K_GetKartSpeed(player, false), 3*FRACUNIT); - fixed_t adjustangle = FixedDiv((p_maxspeed>>16) - (player->speed>>16), (p_maxspeed>>16) + player->kartweight); + fixed_t p_maxspeed = K_GetKartSpeed(player, false); + fixed_t p_speed = min(player->speed, (p_maxspeed * 2)); + fixed_t weightadjust = FixedDiv((p_maxspeed * 3) - p_speed, (p_maxspeed * 3) + (player->kartweight * FRACUNIT)); if (player->spectator) + { return turnvalue; + } if (player->kartstuff[k_drift] != 0 && P_IsObjectOnGround(player->mo)) { + fixed_t countersteer = FixedDiv(turnvalue*FRACUNIT, KART_FULLTURN*FRACUNIT); + // If we're drifting we have a completely different turning value - if (player->kartstuff[k_driftend] == 0) + + if (player->kartstuff[k_driftend] != 0) { - // 800 is the max set in g_game.c with angleturn - fixed_t countersteer = FixedDiv(turnvalue*FRACUNIT, 800*FRACUNIT); - turnvalue = K_GetKartDriftValue(player, countersteer); + countersteer = FRACUNIT; } - else - turnvalue = (INT16)(turnvalue + K_GetKartDriftValue(player, FRACUNIT)); + + turnvalue = K_GetKartDriftValue(player, countersteer); return turnvalue; } - turnvalue = FixedMul(turnvalue, adjustangle); // Weight has a small effect on turning - if (EITHERSNEAKER(player) || player->kartstuff[k_invincibilitytimer] || player->kartstuff[k_growshrinktimer] > 0) - turnvalue = FixedMul(turnvalue, (5*FRACUNIT)/4); + { + turnvalue = 5*turnvalue/4; + } + + turnvalue = FixedMul(turnvalue * FRACUNIT, weightadjust) / FRACUNIT; // Weight has a small effect on turning return turnvalue; } From 77ddf635a5e0895354a10a3c7e7a6bc2fa9bff42 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 18 Dec 2019 15:34:55 -0800 Subject: [PATCH 3/5] Use a random port when connecting (cherry picked from commit f584b61c93a97e1a9852f306acba673ced21e03a) --- src/d_clisrv.c | 2 +- src/d_net.h | 2 ++ src/i_tcp.c | 14 ++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3347091a3..8a04bcca7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -81,7 +81,7 @@ boolean server = true; // true or false but !server == client #define client (!server) boolean nodownload = false; -static boolean serverrunning = false; +boolean serverrunning = false; INT32 serverplayer = 0; char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support) diff --git a/src/d_net.h b/src/d_net.h index eb657eec1..e9b2f5dbf 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -41,6 +41,8 @@ extern SINT8 nodetoplayer4[MAXNETNODES]; // Say the numplayer for this node if a extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game +extern boolean serverrunning; + INT32 Net_GetFreeAcks(boolean urgent); void Net_AckTicker(void); diff --git a/src/i_tcp.c b/src/i_tcp.c index f58aa22bc..74144d5ed 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -924,6 +924,7 @@ static boolean UDP_Socket(void) #ifdef HAVE_IPV6 const INT32 b_ipv6 = M_CheckParm("-ipv6"); #endif + const char *serv; for (s = 0; s < mysocketses; s++) @@ -939,11 +940,16 @@ static boolean UDP_Socket(void) hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; + if (serverrunning) + serv = port_name; + else + serv = NULL;/* any port */ + if (M_CheckParm("-bindaddr")) { while (M_IsNextParm()) { - gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai); + gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -964,7 +970,7 @@ static boolean UDP_Socket(void) } else { - gaie = I_getaddrinfo("0.0.0.0", port_name, &hints, &ai); + gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -997,7 +1003,7 @@ static boolean UDP_Socket(void) { while (M_IsNextParm()) { - gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai); + gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -1018,7 +1024,7 @@ static boolean UDP_Socket(void) } else { - gaie = I_getaddrinfo("::", port_name, &hints, &ai); + gaie = I_getaddrinfo("::", serv, &hints, &ai); if (gaie == 0) { runp = ai; From 5c0566d90624ba6b555ea130b436fa465f8d4783 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 18 Dec 2019 15:43:29 -0800 Subject: [PATCH 4/5] Use a pointer for port_name Using strcpy is stupid because we don't know how long the argument would be. There's no need for a buffer anyway. (cherry picked from commit 4e321012894b2aa87e312597f19be26b30545a8b) --- src/i_tcp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 74144d5ed..d7f767ba9 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -246,7 +246,7 @@ static size_t numbans = 0; static boolean SOCK_bannednode[MAXNETNODES+1]; /// \note do we really need the +1? static boolean init_tcp_driver = false; -static char port_name[8] = DEFAULTPORT; +static const char *port_name = DEFAULTPORT; #ifndef NONET @@ -1485,10 +1485,11 @@ boolean I_InitTcpNetwork(void) // Combined -udpport and -clientport into -port // As it was really redundant having two seperate parms that does the same thing { - if (M_IsNextParm()) - strcpy(port_name, M_GetNextParm()); - else - strcpy(port_name, "0"); + /* + If it's NULL, that's okay! Because then + we'll get a random port from getaddrinfo. + */ + port_name = M_GetNextParm(); } // parse network game options, From 8cb58fb394b038b2bf914c5eb88f981285788a9f Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 18 Dec 2019 15:47:47 -0800 Subject: [PATCH 5/5] -clientport (it's back!) and -serverport, which is an alias to -port If you ever need to, you can change the client port number. (cherry picked from commit 843d9b9f0a345330d97c579e94f208eb2b65c156) --- src/i_tcp.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index d7f767ba9..1f1cf4f22 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -246,7 +246,8 @@ static size_t numbans = 0; static boolean SOCK_bannednode[MAXNETNODES+1]; /// \note do we really need the +1? static boolean init_tcp_driver = false; -static const char *port_name = DEFAULTPORT; +static const char *serverport_name = DEFAULTPORT; +static const char *clientport_name;/* any port */ #ifndef NONET @@ -941,9 +942,9 @@ static boolean UDP_Socket(void) hints.ai_protocol = IPPROTO_UDP; if (serverrunning) - serv = port_name; + serv = serverport_name; else - serv = NULL;/* any port */ + serv = clientport_name; if (M_CheckParm("-bindaddr")) { @@ -985,8 +986,8 @@ static boolean UDP_Socket(void) #ifdef HAVE_MINIUPNPC if (UPNP_support) { - I_UPnP_rem(port_name, "UDP"); - I_UPnP_add(NULL, port_name, "UDP"); + I_UPnP_rem(serverport_name, "UDP"); + I_UPnP_add(NULL, serverport_name, "UDP"); } #endif } @@ -1481,16 +1482,19 @@ boolean I_InitTcpNetwork(void) if (!I_InitTcpDriver()) return false; - if (M_CheckParm("-port")) + if (M_CheckParm("-port") || M_CheckParm("-serverport")) // Combined -udpport and -clientport into -port // As it was really redundant having two seperate parms that does the same thing + /* Sorry Steel, I'm adding these back. But -udpport is a stupid name. */ { /* If it's NULL, that's okay! Because then we'll get a random port from getaddrinfo. */ - port_name = M_GetNextParm(); + serverport_name = M_GetNextParm(); } + if (M_CheckParm("-clientport")) + clientport_name = M_GetNextParm(); // parse network game options, if (M_CheckParm("-server") || dedicated)