From 29a5999a446c9094b653f2fec2fc865f8350bd4b Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 8 Apr 2019 15:48:20 -0700 Subject: [PATCH 01/16] "NEWPING" might as well be the only ping --- src/d_clisrv.c | 12 --------- src/d_clisrv.h | 8 ------ src/d_net.c | 66 ++++---------------------------------------------- src/d_netcmd.c | 4 --- src/d_netcmd.h | 2 -- src/doomdef.h | 3 --- 6 files changed, 5 insertions(+), 90 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a4416b1dc..99d0eff71 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -83,11 +83,9 @@ tic_t jointimeout = (10*TICRATE); static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? -#ifdef NEWPING UINT16 pingmeasurecount = 1; UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone. UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values. -#endif SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) UINT8 playerpernode[MAXNETNODES]; // used specialy for scplitscreen @@ -2883,12 +2881,10 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) HU_AddChatText(va("\x82*%s has been kicked (Go away)", player_names[pnum]), false); kickreason = KR_KICK; break; -#ifdef NEWPING case KICK_MSG_PING_HIGH: HU_AddChatText(va("\x82*%s left the game (Broke ping limit)", player_names[pnum]), false); kickreason = KR_PINGLIMIT; break; -#endif case KICK_MSG_CON_FAIL: HU_AddChatText(va("\x82*%s left the game (Synch Failure)", player_names[pnum]), false); kickreason = KR_SYNCH; @@ -2961,10 +2957,8 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) D_StartTitle(); if (msg == KICK_MSG_CON_FAIL) M_StartMessage(M_GetText("Server closed connection\n(synch failure)\nPress ESC\n"), NULL, MM_NOTHING); -#ifdef NEWPING else if (msg == KICK_MSG_PING_HIGH) M_StartMessage(M_GetText("Server closed connection\n(Broke ping limit)\nPress ESC\n"), NULL, MM_NOTHING); -#endif else if (msg == KICK_MSG_BANNED) M_StartMessage(M_GetText("You have been banned by the server\n\nPress ESC\n"), NULL, MM_NOTHING); else if (msg == KICK_MSG_CUSTOM_KICK) @@ -4188,7 +4182,6 @@ static void HandlePacketFromPlayer(SINT8 node) resynch_local_inprogress = true; CL_AcknowledgeResynch(&netbuffer->u.resynchpak); break; -#ifdef NEWPING case PT_PING: // Only accept PT_PING from the server. if (node != servernode) @@ -4216,7 +4209,6 @@ static void HandlePacketFromPlayer(SINT8 node) } break; -#endif case PT_SERVERCFG: break; case PT_FILEFRAGMENT: @@ -4730,7 +4722,6 @@ void TryRunTics(tic_t realtics) } } -#ifdef NEWPING static inline void PingUpdate(void) { INT32 i; @@ -4788,7 +4779,6 @@ static inline void PingUpdate(void) pingmeasurecount = 1; //Reset count } -#endif void NetUpdate(void) { @@ -4813,7 +4803,6 @@ void NetUpdate(void) gametime = nowtime; -#ifdef NEWPING if (server) { if (netgame && !(gametime % 255)) @@ -4824,7 +4813,6 @@ void NetUpdate(void) realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i])); pingmeasurecount++; } -#endif if (client) maketic = neededtic; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 52ca1701d..1656b8e8a 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -73,9 +73,7 @@ typedef enum PT_LOGIN, // Login attempt from the client. -#ifdef NEWPING PT_PING, // Packet sent to tell clients the other client's latency to server. -#endif NUMPACKETTYPE } packettype_t; @@ -425,9 +423,7 @@ typedef struct msaskinfo_pak msaskinfo; // 22 bytes plrinfo playerinfo[MAXPLAYERS]; // 1152 bytes (I'd say 36~38) plrconfig playerconfig[MAXPLAYERS]; // (up to) 896 bytes (welp they ARE) -#ifdef NEWPING UINT32 pingtable[MAXPLAYERS]; // 128 bytes -#endif } u; // This is needed to pack diff packet types data together } ATTRPACK doomdata_t; @@ -461,9 +457,7 @@ extern consvar_t cv_playbackspeed; #define KICK_MSG_PLAYER_QUIT 3 #define KICK_MSG_TIMEOUT 4 #define KICK_MSG_BANNED 5 -#ifdef NEWPING #define KICK_MSG_PING_HIGH 6 -#endif #define KICK_MSG_CUSTOM_KICK 7 #define KICK_MSG_CUSTOM_BAN 8 @@ -488,11 +482,9 @@ extern SINT8 servernode; void Command_Ping_f(void); extern tic_t connectiontimeout; extern tic_t jointimeout; -#ifdef NEWPING extern UINT16 pingmeasurecount; extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS]; -#endif extern consvar_t cv_joinnextround, cv_allownewplayer, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; diff --git a/src/d_net.c b/src/d_net.c index 9f68c187c..347474f52 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -185,22 +185,10 @@ typedef struct UINT8 nextacknum; UINT8 flags; -#ifndef NEWPING - // jacobson tcp timeout evaluation algorithm (Karn variation) - fixed_t ping; - fixed_t varping; - INT32 timeout; // computed with ping and varping -#endif } node_t; static node_t nodes[MAXNETNODES]; -#ifndef NEWPING -#define PINGDEFAULT ((200*TICRATE*FRACUNIT)/1000) -#define VARPINGDEFAULT ((50*TICRATE*FRACUNIT)/1000) -#define TIMEOUT(p,v) (p+4*v+FRACUNIT/2)>>FRACBITS; -#else -#define NODETIMEOUT 14 //What the above boiled down to... -#endif +#define NODETIMEOUT 14 #ifndef NONET // return <0 if a < b (mod 256) @@ -320,19 +308,7 @@ static UINT8 GetAcktosend(INT32 node) static void RemoveAck(INT32 i) { INT32 node = ackpak[i].destinationnode; -#ifndef NEWPING - fixed_t trueping = (I_GetTime() - ackpak[i].senttime)<>FRACBITS,(double)FIXED_TO_FLOAT(nodes[node].ping),(double)FIXED_TO_FLOAT(nodes[node].varping),nodes[node].timeout)); -#else DEBFILE(va("Remove ack %d\n",ackpak[i].acknum)); -#endif ackpak[i].acknum = 0; if (nodes[node].flags & NF_CLOSE) Net_CloseConnection(node); @@ -519,11 +495,7 @@ void Net_AckTicker(void) { const INT32 nodei = ackpak[i].destinationnode; node_t *node = &nodes[nodei]; -#ifdef NEWPING if (ackpak[i].acknum && ackpak[i].senttime + NODETIMEOUT < I_GetTime()) -#else - if (ackpak[i].acknum && ackpak[i].senttime + node->timeout < I_GetTime()) -#endif { if (ackpak[i].resentnum > 10 && (node->flags & NF_CLOSE)) { @@ -534,13 +506,8 @@ void Net_AckTicker(void) ackpak[i].acknum = 0; continue; } -#ifdef NEWPING DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime, NODETIMEOUT, I_GetTime())); -#else - DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime, - node->timeout, I_GetTime())); -#endif M_Memcpy(netbuffer, ackpak[i].pak.raw, ackpak[i].length); ackpak[i].senttime = I_GetTime(); ackpak[i].resentnum++; @@ -658,11 +625,6 @@ void Net_WaitAllAckReceived(UINT32 timeout) static void InitNode(node_t *node) { node->acktosend_head = node->acktosend_tail = 0; -#ifndef NEWPING - node->ping = PINGDEFAULT; - node->varping = VARPINGDEFAULT; - node->timeout = TIMEOUT(node->ping, node->varping); -#endif node->firstacktosend = 0; node->nextacknum = 1; node->remotefirstack = 0; @@ -843,9 +805,7 @@ static const char *packettypename[NUMPACKETTYPE] = "CLIENTJOIN", "NODETIMEOUT", "RESYNCHING", -#ifdef NEWPING "PING" -#endif }; static void DebugPrintpacket(const char *header) @@ -1386,28 +1346,12 @@ boolean D_CheckNetGame(void) void Command_Ping_f(void) { -#ifndef NEWPING - if(server) + INT32 i; + for (i = 0; i < MAXPLAYERS;i++) { -#endif - INT32 i; - for (i = 0; i < MAXPLAYERS;i++) - { -#ifndef NEWPING - const INT32 node = playernode[i]; - if (playeringame[i] && node != 0) - CONS_Printf(M_GetText("%.2d : %s\n %d tics, %d ms.\n"), i, player_names[i], - GetLag(node), G_TicsToMilliseconds(GetLag(node))); -#else - if (playeringame[i] && i != 0) - CONS_Printf(M_GetText("%.2d : %s\n %d ms\n"), i, player_names[i], playerpingtable[i]); -#endif - } -#ifndef NEWPING + if (playeringame[i] && i != 0) + CONS_Printf(M_GetText("%.2d : %s\n %d ms\n"), i, player_names[i], playerpingtable[i]); } - else - CONS_Printf(M_GetText("Only the server can use this.\n")); -#endif } void D_CloseConnection(void) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1e69d371e..4fb309600 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -340,9 +340,7 @@ static CV_PossibleValue_t nettimeout_cons_t[] = {{TICRATE/7, "MIN"}, {60*TICRATE consvar_t cv_nettimeout = {"nettimeout", "350", CV_CALL|CV_SAVE, nettimeout_cons_t, NetTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t jointimeout_cons_t[] = {{5*TICRATE, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}}; consvar_t cv_jointimeout = {"jointimeout", "350", CV_CALL|CV_SAVE, jointimeout_cons_t, JoinTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL}; -#ifdef NEWPING consvar_t cv_maxping = {"maxping", "0", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; consvar_t cv_inttime = {"inttime", "10", CV_NETVAR, inttime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -573,9 +571,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_skipmapcheck); CV_RegisterVar(&cv_sleep); -#ifdef NEWPING CV_RegisterVar(&cv_maxping); -#endif #ifdef SEENAMES CV_RegisterVar(&cv_allowseenames); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 5076c8afa..01858dee6 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -107,9 +107,7 @@ extern consvar_t cv_ringslinger, cv_soundtest; extern consvar_t cv_specialrings, cv_powerstones, cv_matchboxes, cv_competitionboxes; -#ifdef NEWPING extern consvar_t cv_maxping; -#endif extern consvar_t cv_skipmapcheck; diff --git a/src/doomdef.h b/src/doomdef.h index 8d44d0896..1085e350e 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -561,9 +561,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Polyobject fake flat code #define POLYOBJECTS_PLANES -/// Improved way of dealing with ping values and a ping limit. -#define NEWPING - /// See name of player in your crosshair #define SEENAMES From 3ffa84a77b552d109c177996ccf530fce973d8c1 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 8 Apr 2019 15:57:23 -0700 Subject: [PATCH 02/16] Replace ping command with a condensed and sorted version --- src/d_net.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 347474f52..cbfef7726 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1344,13 +1344,72 @@ boolean D_CheckNetGame(void) return ret; } +struct pingcell +{ + INT32 num; + INT32 ms; +}; + +static int pingcellcmp(const void *va, const void *vb) +{ + const struct pingcell *a, *b; + a = va; + b = vb; + return ( a->ms - b->ms ); +} + +/* +New ping command formatted nicely to present ping in +ascending order. And with equally spaced columns. +The caller's ping is presented at the bottom too, for +convenience. +*/ + void Command_Ping_f(void) { + struct pingcell pingv[MAXPLAYERS]; + INT32 pingc; + + int name_width = 0; + int ms_width = 0; + + int n; INT32 i; - for (i = 0; i < MAXPLAYERS;i++) + + pingc = 0; + for (i = 1; i < MAXPLAYERS; ++i) + if (playeringame[i]) { - if (playeringame[i] && i != 0) - CONS_Printf(M_GetText("%.2d : %s\n %d ms\n"), i, player_names[i], playerpingtable[i]); + n = strlen(player_names[i]); + if (n > name_width) + name_width = n; + + n = playerpingtable[i]; + if (n > ms_width) + ms_width = n; + + pingv[pingc].num = i; + pingv[pingc].ms = playerpingtable[i]; + pingc++; + } + + if (ms_width < 10) ms_width = 1; + else if (ms_width < 100) ms_width = 2; + else ms_width = 3; + + qsort(pingv, pingc, sizeof (struct pingcell), &pingcellcmp); + + for (i = 0; i < pingc; ++i) + { + CONS_Printf("%02d : %-*s %*d ms\n", + pingv[i].num, + name_width, player_names[pingv[i].num], + ms_width, pingv[i].ms); + } + + if (!server && playeringame[consoleplayer]) + { + CONS_Printf("\nYour ping is %d ms\n", playerpingtable[consoleplayer]); } } From 602c66d173d6ae1b50bf2bfc0d7f64d128beb420 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Mar 2019 22:00:47 -0700 Subject: [PATCH 03/16] Grab mouse on window focus Window focus does not necessarily imply mouse movement. --- src/sdl/i_video.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f5c7e3714..b90b5c868 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -357,6 +357,14 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) return 0; } +static void SDLdoGrabMouse(void) +{ + SDL_ShowCursor(SDL_DISABLE); + SDL_SetWindowGrab(window, SDL_TRUE); + if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful + wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore? +} + static void SDLdoUngrabMouse(void) { SDL_ShowCursor(SDL_ENABLE); @@ -579,6 +587,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) if (cv_usemouse.value) I_StartupMouse(); } //else firsttimeonmouse = SDL_FALSE; + + if (USE_MOUSEINPUT) + SDLdoGrabMouse(); } else if (!mousefocus && !kbfocus) { @@ -655,9 +666,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) // -- Monster Iestyn if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) { - SDL_SetWindowGrab(window, SDL_TRUE); - if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful - wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore? + SDLdoGrabMouse(); } } } @@ -1056,7 +1065,7 @@ void I_StartupMouse(void) else firsttimeonmouse = SDL_FALSE; if (cv_usemouse.value) - return; + SDLdoGrabMouse(); else SDLdoUngrabMouse(); } From 135619af8b4e98d8d434d7a7c64827b6e6b1186c Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 Apr 2019 23:42:28 -0700 Subject: [PATCH 04/16] Add a command to increment cvars --- src/command.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/command.c b/src/command.c index cfb36f02f..c23f0e8f3 100644 --- a/src/command.c +++ b/src/command.c @@ -49,6 +49,7 @@ static void COM_Exec_f(void); static void COM_Wait_f(void); static void COM_Help_f(void); static void COM_Toggle_f(void); +static void COM_Add_f(void); static void CV_EnforceExecVersion(void); static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr); @@ -291,6 +292,7 @@ void COM_Init(void) COM_AddCommand("wait", COM_Wait_f); COM_AddCommand("help", COM_Help_f); COM_AddCommand("toggle", COM_Toggle_f); + COM_AddCommand("add", COM_Add_f); RegisterNetXCmd(XD_NETVAR, Got_NetVar); } @@ -816,6 +818,27 @@ static void COM_Toggle_f(void) CV_AddValue(cvar, +1); } +/** Command variant of CV_AddValue + */ +static void COM_Add_f(void) +{ + consvar_t *cvar; + + if (COM_Argc() != 3) + { + CONS_Printf(M_GetText("Add : Add to the value of a cvar. Negative values work too!\n")); + return; + } + cvar = CV_FindVar(COM_Argv(1)); + if (!cvar) + { + CONS_Alert(CONS_NOTICE, M_GetText("%s is not a cvar\n"), COM_Argv(1)); + return; + } + + CV_AddValue(cvar, atoi(COM_Argv(2))); +} + // ========================================================================= // VARIABLE SIZE BUFFERS // ========================================================================= From f0ee901160f1752f2d731181dcaa68c8d651135c Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 4 Jul 2019 17:48:17 -0700 Subject: [PATCH 05/16] Support adding to CV_FLOAT cvars with the Add command --- src/command.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/command.c b/src/command.c index c23f0e8f3..a54735389 100644 --- a/src/command.c +++ b/src/command.c @@ -836,7 +836,10 @@ static void COM_Add_f(void) return; } - CV_AddValue(cvar, atoi(COM_Argv(2))); + if (( cvar->flags & CV_FLOAT )) + CV_Set(cvar, va("%f", FIXED_TO_FLOAT (cvar->value) + atof(COM_Argv(2)))); + else + CV_AddValue(cvar, atoi(COM_Argv(2))); } // ========================================================================= From a24814c2fca51adedc1c562ce2464ab6cccf2f9e Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 Apr 2019 23:50:29 -0700 Subject: [PATCH 06/16] Add a "-noaudio" parm to cover "-nomusic" and "-nosound" --- src/d_main.c | 26 +++++++++++++++++++------- src/s_sound.c | 6 +++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 37637edd6..68eb7cc77 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1248,16 +1248,28 @@ void D_SRB2Main(void) { CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n"); } - if (M_CheckParm("-nosound")) + if (M_CheckParm("-noaudio")) // combines -nosound and -nomusic + { sound_disabled = true; - if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic - midi_disabled = digital_disabled = true; + digital_disabled = true; + midi_disabled = true; + } else { - if (M_CheckParm("-nomidimusic")) - midi_disabled = true; // WARNING: DOS version initmusic in I_StartupSound - if (M_CheckParm("-nodigmusic")) - digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound + if (M_CheckParm("-nosound")) + sound_disabled = true; + if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic + { + digital_disabled = true; + midi_disabled = true; + } + else + { + if (M_CheckParm("-nomidimusic")) + midi_disabled = true; // WARNING: DOS version initmusic in I_StartupSound + if (M_CheckParm("-nodigmusic")) + digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound + } } I_StartupSound(); I_InitMusic(); diff --git a/src/s_sound.c b/src/s_sound.c index 299e4b889..1a719d972 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2202,7 +2202,7 @@ static void Command_RestartAudio_f(void) void GameSounds_OnChange(void) { - if (M_CheckParm("-nosound")) + if (M_CheckParm("-nosound") || M_CheckParm("-noaudio")) return; if (sound_disabled) @@ -2220,7 +2220,7 @@ void GameSounds_OnChange(void) void GameDigiMusic_OnChange(void) { - if (M_CheckParm("-nomusic")) + if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio")) return; else if (M_CheckParm("-nodigmusic")) return; @@ -2262,7 +2262,7 @@ void GameDigiMusic_OnChange(void) void GameMIDIMusic_OnChange(void) { - if (M_CheckParm("-nomusic")) + if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio")) return; else if (M_CheckParm("-nomidimusic")) return; From 43ca2c1b30b5cea8b131c4e8caa36d6e52f9f34f Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 14 Apr 2019 21:14:01 -0700 Subject: [PATCH 07/16] Support splitscreen PLAYERINFO and don't expose clients' IP addresses --- src/d_clisrv.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 99d0eff71..7e9be993e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1323,33 +1323,13 @@ static void SV_SendPlayerInfo(INT32 node) continue; } - netbuffer->u.playerinfo[i].node = (UINT8)playernode[i]; + netbuffer->u.playerinfo[i].node = i; strncpy(netbuffer->u.playerinfo[i].name, (const char *)&player_names[i], MAXPLAYERNAME+1); netbuffer->u.playerinfo[i].name[MAXPLAYERNAME] = '\0'; //fetch IP address - { - const char *claddress; - UINT32 numericaddress[4]; - - memset(netbuffer->u.playerinfo[i].address, 0, 4); - if (playernode[i] == 0) - { - //127.0.0.1 - netbuffer->u.playerinfo[i].address[0] = 127; - netbuffer->u.playerinfo[i].address[3] = 1; - } - else if (playernode[i] > 0 && I_GetNodeAddress && (claddress = I_GetNodeAddress(playernode[i])) != NULL) - { - if (sscanf(claddress, "%d.%d.%d.%d", &numericaddress[0], &numericaddress[1], &numericaddress[2], &numericaddress[3]) < 4) - goto badaddress; - netbuffer->u.playerinfo[i].address[0] = (UINT8)numericaddress[0]; - netbuffer->u.playerinfo[i].address[1] = (UINT8)numericaddress[1]; - netbuffer->u.playerinfo[i].address[2] = (UINT8)numericaddress[2]; - netbuffer->u.playerinfo[i].address[3] = (UINT8)numericaddress[3]; - } - } - badaddress: + //No, don't do that, you fuckface. + memset(netbuffer->u.playerinfo[i].address, 0, 4); if (G_GametypeHasTeams()) { From 12540dca320659a5f5169b4dcea94bf97791e7ca Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 11 Mar 2019 12:50:01 -0700 Subject: [PATCH 08/16] Make "Focus lost" HUD overlay optional --- src/m_menu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index c0b02a5b7..8d3dad741 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -387,6 +387,8 @@ static void Dummymares_OnChange(void); // CONSOLE VARIABLES AND THEIR POSSIBLE VALUES GO HERE. // ========================================================================== +consvar_t cv_showfocuslost = {"showfocuslost", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL }; + static CV_PossibleValue_t map_cons_t[] = { {1,"MIN"}, {NUMMAPS, "MAX"} @@ -1230,6 +1232,7 @@ static menuitem_t OP_VideoOptionsMenu[] = {IT_HEADER, NULL, "Diagnostic", NULL, 180}, {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 186}, {IT_STRING | IT_CVAR, NULL, "Clear Before Redraw", &cv_homremoval, 191}, + {IT_STRING | IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 196}, }; static menuitem_t OP_VideoModeMenu[] = @@ -3322,7 +3325,7 @@ void M_Drawer(void) } // focus lost notification goes on top of everything, even the former everything - if (window_notinfocus) + if (window_notinfocus && cv_showfocuslost.value) { M_DrawTextBox((BASEVIDWIDTH/2) - (60), (BASEVIDHEIGHT/2) - (16), 13, 2); if (gamestate == GS_LEVEL && (P_AutoPause() || paused)) @@ -3547,6 +3550,8 @@ void M_Init(void) { int i; + CV_RegisterVar(&cv_showfocuslost); + CV_RegisterVar(&cv_nextmap); CV_RegisterVar(&cv_newgametype); CV_RegisterVar(&cv_chooseskin); From 5ac8a26814bb43c5e91ab77af9a2e546b0ef50e4 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 11 Mar 2019 14:57:11 -0700 Subject: [PATCH 09/16] Miscellaneous window de-focus options Music pausing is now optional. Sounds may be paused--on by default. The game itself being paused in off-line mode is now optional. (showfocuslost now loads from config.) --- src/d_netcmd.c | 2 ++ src/g_game.c | 2 ++ src/g_game.h | 2 ++ src/m_menu.c | 42 +++++++++++++------------------- src/m_menu.h | 1 + src/p_user.c | 2 +- src/s_sound.c | 62 +++++++++++++++++++++++++++++++++++++++++------ src/s_sound.h | 6 +++++ src/sdl/i_video.c | 9 ++++++- 9 files changed, 94 insertions(+), 34 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4fb309600..bbe6b28d2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -736,6 +736,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_chasefreelook); CV_RegisterVar(&cv_chasefreelook2); CV_RegisterVar(&cv_tutorialprompt); + CV_RegisterVar(&cv_showfocuslost); + CV_RegisterVar(&cv_pauseifunfocused); // g_input.c CV_RegisterVar(&cv_sideaxis); diff --git a/src/g_game.c b/src/g_game.c index 6c31ce9e3..92b8de96e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -361,6 +361,8 @@ consvar_t cv_chatbacktint = {"chatbacktint", "On", CV_SAVE, CV_OnOff, NULL, 0, N static CV_PossibleValue_t consolechat_cons_t[] = {{0, "Window"}, {1, "Console"}, {2, "Window (Hidden)"}, {0, NULL}}; consvar_t cv_consolechat = {"chatmode", "Window", CV_SAVE, consolechat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +// Pause game upon window losing focus +consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_crosshair = {"crosshair", "Cross", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_crosshair2 = {"crosshair2", "Cross", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/g_game.h b/src/g_game.h index df1301dd7..198cbc396 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -59,6 +59,8 @@ extern boolean pausebreakkey; extern boolean promptactive; +extern consvar_t cv_pauseifunfocused; + // used in game menu extern consvar_t cv_tutorialprompt; extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection, cv_compactscoreboard; diff --git a/src/m_menu.c b/src/m_menu.c index 8d3dad741..13e5bfc4f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1326,22 +1326,25 @@ static menuitem_t OP_OpenGLColorMenu[] = static menuitem_t OP_SoundOptionsMenu[] = { - {IT_HEADER, NULL, "Game Audio", NULL, 0}, // 0 // ScrollMenu offsets - {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 13}, // 6 - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 23}, // 11 + {IT_HEADER, NULL, "Game Audio", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 6}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 11}, - {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 43}, // 21 - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 53}, // 26 + {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 21}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 26}, - {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 73}, // 36 - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 83}, // 41 + {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 36}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 41}, - {IT_HEADER, NULL, "Accessibility", NULL, 103}, // 50 - {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 115}, // 56 - {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 125}, // 62 + {IT_HEADER, NULL, "Accessibility", NULL, 50}, + {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 56}, + {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 61}, + + {IT_STRING | IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 71}, + {IT_STRING | IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 76}, #ifdef HAVE_MIXERX - {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 143}, + {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 86}, #endif }; @@ -1964,18 +1967,9 @@ menu_t OP_ColorOptionsDef = 0, NULL }; -menu_t OP_SoundOptionsDef = -{ - MN_OP_MAIN + (MN_OP_SOUND << 6), - "M_SOUND", - sizeof (OP_SoundOptionsMenu)/sizeof (menuitem_t), - &OP_MainDef, - OP_SoundOptionsMenu, - M_DrawGenericMenu, - 30, 30, - 0, - NULL -}; +menu_t OP_SoundOptionsDef = DEFAULTSCROLLMENUSTYLE( + MN_OP_MAIN + (MN_OP_SOUND << 6), + "M_SOUND", OP_SoundOptionsMenu, &OP_MainDef, 30, 30); #ifdef HAVE_MIXERX menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE(MN_OP_MAIN + (MN_OP_SOUND << 6), "M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); #endif @@ -3550,8 +3544,6 @@ void M_Init(void) { int i; - CV_RegisterVar(&cv_showfocuslost); - CV_RegisterVar(&cv_nextmap); CV_RegisterVar(&cv_newgametype); CV_RegisterVar(&cv_chooseskin); diff --git a/src/m_menu.h b/src/m_menu.h index 05962d2b1..d568a1b53 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -374,6 +374,7 @@ typedef struct extern description_t description[MAXSKINS]; +extern consvar_t cv_showfocuslost; extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort; extern CV_PossibleValue_t gametype_cons_t[]; diff --git a/src/p_user.c b/src/p_user.c index 3f4d08222..c65d7b6cc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -191,7 +191,7 @@ boolean P_AutoPause(void) if (netgame || modeattacking || gamestate == GS_TITLESCREEN) return false; - return (menuactive || window_notinfocus); + return (menuactive || ( window_notinfocus && cv_pauseifunfocused.value )); } // diff --git a/src/s_sound.c b/src/s_sound.c index 1a719d972..e68a25ec9 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -60,6 +60,9 @@ static void GameMIDIMusic_OnChange(void); static void GameSounds_OnChange(void); static void GameDigiMusic_OnChange(void); +static void PlayMusicIfUnfocused_OnChange(void); +static void PlaySoundIfUnfocused_OnChange(void); + static void ModFilter_OnChange(void); static lumpnum_t S_GetMusicLumpNum(const char *mname); @@ -117,6 +120,9 @@ consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_O consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlayMusicIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playsoundifunfocused = {"playsoundsifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlaySoundIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; + #ifdef HAVE_OPENMPT static CV_PossibleValue_t interpolationfilter_cons_t[] = {{0, "Default"}, {1, "None"}, {2, "Linear"}, {4, "Cubic"}, {8, "Windowed sinc"}, {0, NULL}}; consvar_t cv_modfilter = {"modfilter", "0", CV_SAVE|CV_CALL, interpolationfilter_cons_t, ModFilter_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -290,6 +296,9 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_miditimiditypath); #endif + CV_RegisterVar(&cv_playmusicifunfocused); + CV_RegisterVar(&cv_playsoundifunfocused); + COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); @@ -2018,6 +2027,24 @@ void S_ResumeAudio(void) S_AdjustMusicStackTics(); } +void S_DisableSound(void) +{ + if (sound_started && !sound_disabled) + { + sound_disabled = true; + S_StopSounds(); + } +} + +void S_EnableSound(void) +{ + if (sound_started && sound_disabled) + { + sound_disabled = false; + S_InitSfxChannels(cv_soundvolume.value); + } +} + void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) { if (digvolume < 0) @@ -2207,15 +2234,11 @@ void GameSounds_OnChange(void) if (sound_disabled) { - sound_disabled = false; - S_InitSfxChannels(cv_soundvolume.value); - S_StartSound(NULL, sfx_strpst); + if (!( cv_playsoundifunfocused.value && window_notinfocus )) + S_EnableSound(); } else - { - sound_disabled = true; - S_StopSounds(); - } + S_DisableSound(); } void GameDigiMusic_OnChange(void) @@ -2308,3 +2331,28 @@ void ModFilter_OnChange(void) openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); } #endif + +static void PlayMusicIfUnfocused_OnChange(void) +{ + if (window_notinfocus) + { + if (cv_playmusicifunfocused.value) + S_PauseAudio(); + else + S_ResumeAudio(); + } +} + +static void PlaySoundIfUnfocused_OnChange(void) +{ + if (!cv_gamesounds.value) + return; + + if (window_notinfocus) + { + if (cv_playsoundifunfocused.value) + S_DisableSound(); + else + S_EnableSound(); + } +} diff --git a/src/s_sound.h b/src/s_sound.h index 48128527c..f4a986585 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -44,6 +44,8 @@ extern consvar_t cv_resetmusicbyheader; extern consvar_t cv_gamedigimusic; extern consvar_t cv_gamemidimusic; extern consvar_t cv_gamesounds; +extern consvar_t cv_playmusicifunfocused; +extern consvar_t cv_playsoundifunfocused; #ifdef HAVE_OPENMPT extern consvar_t cv_modfilter; @@ -244,6 +246,10 @@ void S_StopMusic(void); void S_PauseAudio(void); void S_ResumeAudio(void); +// Enable and disable sound effects +void S_EnableSound(void); +void S_DisableSound(void); + // // Music Fading // diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index b90b5c868..f760e79bd 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -580,7 +580,11 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) // Tell game we got focus back, resume music if necessary window_notinfocus = false; if (!paused) + { S_ResumeAudio(); //resume it + if (cv_gamesounds.value) + S_EnableSound(); + } if (!firsttimeonmouse) { @@ -595,7 +599,10 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { // Tell game we lost focus, pause music window_notinfocus = true; - S_PauseAudio(); + if (!cv_playmusicifunfocused.value) + S_PauseAudio(); + if (!cv_playsoundifunfocused.value) + S_DisableSound(); if (!disable_mouse) { From 923f43f88707cd46a7b84a87f24fadd59fd01e30 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 16 Mar 2019 15:42:18 -0700 Subject: [PATCH 10/16] Move change viewpoint control checking so it doesn't take precedence Notably over chat. --- src/g_game.c | 118 +++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 92b8de96e..246fb965a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1715,65 +1715,6 @@ static INT32 camtoggledelay, camtoggledelay2 = 0; // boolean G_Responder(event_t *ev) { - // allow spy mode changes even during the demo - if (gamestate == GS_LEVEL && ev->type == ev_keydown - && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) - { - if (splitscreen || !netgame) - displayplayer = consoleplayer; - else - { - // spy mode - do - { - displayplayer++; - if (displayplayer == MAXPLAYERS) - displayplayer = 0; - - if (!playeringame[displayplayer]) - continue; - - if (players[displayplayer].spectator) - continue; - - if (G_GametypeHasTeams()) - { - if (players[consoleplayer].ctfteam - && players[displayplayer].ctfteam != players[consoleplayer].ctfteam) - continue; - } - else if (gametype == GT_HIDEANDSEEK) - { - if (players[consoleplayer].pflags & PF_TAGIT) - continue; - } - // Other Tag-based gametypes? - else if (G_TagGametype()) - { - if (!players[consoleplayer].spectator - && (players[consoleplayer].pflags & PF_TAGIT) != (players[displayplayer].pflags & PF_TAGIT)) - continue; - } - else if (G_GametypeHasSpectators() && G_RingSlingerGametype()) - { - if (!players[consoleplayer].spectator) - continue; - } - - break; - } while (displayplayer != consoleplayer); - - // change statusbar also if playing back demo - if (singledemo) - ST_changeDemoView(); - - // tell who's the view - CONS_Printf(M_GetText("Viewpoint: %s\n"), player_names[displayplayer]); - - return true; - } - } - // any other key pops up menu if in demos if (gameaction == ga_nothing && !singledemo && ((demoplayback && !modeattacking && !titledemo) || gamestate == GS_TITLESCREEN)) @@ -1850,6 +1791,65 @@ boolean G_Responder(event_t *ev) if (HU_Responder(ev)) return true; // chat ate the event + // allow spy mode changes even during the demo + if (gamestate == GS_LEVEL && ev->type == ev_keydown + && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) + { + if (splitscreen || !netgame) + displayplayer = consoleplayer; + else + { + // spy mode + do + { + displayplayer++; + if (displayplayer == MAXPLAYERS) + displayplayer = 0; + + if (!playeringame[displayplayer]) + continue; + + if (players[displayplayer].spectator) + continue; + + if (G_GametypeHasTeams()) + { + if (players[consoleplayer].ctfteam + && players[displayplayer].ctfteam != players[consoleplayer].ctfteam) + continue; + } + else if (gametype == GT_HIDEANDSEEK) + { + if (players[consoleplayer].pflags & PF_TAGIT) + continue; + } + // Other Tag-based gametypes? + else if (G_TagGametype()) + { + if (!players[consoleplayer].spectator + && (players[consoleplayer].pflags & PF_TAGIT) != (players[displayplayer].pflags & PF_TAGIT)) + continue; + } + else if (G_GametypeHasSpectators() && G_RingSlingerGametype()) + { + if (!players[consoleplayer].spectator) + continue; + } + + break; + } while (displayplayer != consoleplayer); + + // change statusbar also if playing back demo + if (singledemo) + ST_changeDemoView(); + + // tell who's the view + CONS_Printf(M_GetText("Viewpoint: %s\n"), player_names[displayplayer]); + + return true; + } + } + // update keys current state G_MapEventsToControls(ev); From 39baca89d3707077aa243f4f66c30cf0a2b4cfea Mon Sep 17 00:00:00 2001 From: james Date: Wed, 6 Feb 2019 17:24:13 -0800 Subject: [PATCH 11/16] Do not start sound system when disabled --- src/d_main.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 68eb7cc77..41fa98408 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1244,10 +1244,6 @@ void D_SRB2Main(void) sound_disabled = true; midi_disabled = digital_disabled = true; } - else - { - CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n"); - } if (M_CheckParm("-noaudio")) // combines -nosound and -nomusic { sound_disabled = true; @@ -1271,9 +1267,17 @@ void D_SRB2Main(void) digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound } } - I_StartupSound(); - I_InitMusic(); - S_InitSfxChannels(cv_soundvolume.value); + if (!( sound_disabled && digital_disabled +#ifndef NO_MIDI + && midi_disabled +#endif + )) + { + CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n"); + I_StartupSound(); + I_InitMusic(); + S_InitSfxChannels(cv_soundvolume.value); + } CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); From aa9f19512cf54edbf6275993c0a75e12009d7dd9 Mon Sep 17 00:00:00 2001 From: james Date: Sat, 9 Feb 2019 18:10:54 -0800 Subject: [PATCH 12/16] Use less confusing player sorting key names --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 13e5bfc4f..cb33105d9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -409,7 +409,7 @@ static CV_PossibleValue_t serversort_cons_t[] = { {1,"Modified State"}, {2,"Most Players"}, {3,"Least Players"}, - {4,"Max Players"}, + {4,"Max Player Slots"}, {5,"Gametype"}, {0,NULL} }; From 0b314a82bb13e675f6d3fdf93184cece63ed7dbd Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 2 Mar 2019 15:56:44 -0800 Subject: [PATCH 13/16] Use long double suffix --- src/doomdef.h | 6 +++++- src/hardware/hw_bsp.c | 2 +- src/hardware/hw_dll.h | 3 --- src/r_plane.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 1085e350e..676c86e0d 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -509,13 +509,17 @@ INT32 I_GetKey(void); // Max gamepad/joysticks that can be detected/used. #define MAX_JOYSTICKS 4 +#ifndef M_PIl +#define M_PIl 3.1415926535897932384626433832795029L +#endif + // Floating point comparison epsilons from float.h #ifndef FLT_EPSILON #define FLT_EPSILON 1.1920928955078125e-7f #endif #ifndef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 +#define DBL_EPSILON 2.2204460492503131e-16l #endif // An assert-type mechanism. diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 483932492..9e454bcd5 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -201,7 +201,7 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, // (do not accept hit with the extensions) num = (v2x - v1x)*v2dy + (v1y - v2y)*v2dx; frac = num / den; - if (frac < 0.0 || frac > 1.0) + if (frac < 0.0l || frac > 1.0l) return NULL; // now get the frac along the BSP line diff --git a/src/hardware/hw_dll.h b/src/hardware/hw_dll.h index 452e9037c..3fa5852d8 100644 --- a/src/hardware/hw_dll.h +++ b/src/hardware/hw_dll.h @@ -61,9 +61,6 @@ typedef void (*I_Error_t) (const char *error, ...) FUNCIERROR; // ========================================================================== // Constants -#ifndef M_PIl -#define M_PIl 3.1415926535897932384626433832795029L -#endif #define DEGREE (0.017453292519943295769236907684883l) // 2*PI/360 void DBG_Printf(const char *lpFmt, ...) /*FUNCPRINTF*/; diff --git a/src/r_plane.c b/src/r_plane.c index 34debeea7..619ade89d 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -1102,7 +1102,7 @@ void R_DrawSinglePlane(visplane_t *pl) temp = P_GetZAt(pl->slope, pl->viewx, pl->viewy); zeroheight = FIXED_TO_FLOAT(temp); -#define ANG2RAD(angle) ((float)((angle)*M_PI)/ANGLE_180) +#define ANG2RAD(angle) ((float)((angle)*M_PIl)/ANGLE_180) // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in From d86be51472723992efbd2d7e130f382e3569621a Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 11 Aug 2019 12:32:57 -0700 Subject: [PATCH 14/16] Toggle ping and FPS counters with HUD --- src/sdl/i_video.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f760e79bd..ed371d349 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1180,8 +1180,11 @@ void I_FinishUpdate(void) if (cv_closedcaptioning.value) SCR_ClosedCaptions(); - if (cv_ticrate.value) - SCR_DisplayTicRate(); + if (st_overlay) + { + if (cv_ticrate.value) + SCR_DisplayTicRate(); + } if (rendermode == render_soft && screens[0]) { From 52c5d492154af3e8dad14fa524058aba0974b1fc Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 11 Aug 2019 12:35:06 -0700 Subject: [PATCH 15/16] Apply HUD translucency to ping and FPS counters --- src/screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screen.c b/src/screen.c index 547036a60..9939aff93 100644 --- a/src/screen.c +++ b/src/screen.c @@ -421,9 +421,9 @@ void SCR_DisplayTicRate(void) else if (totaltics == TICRATE) ticcntcolor = V_GREENMAP; V_DrawString(vid.width-(72*vid.dupx), h, - V_YELLOWMAP|V_NOSCALESTART, "FPS:"); + V_YELLOWMAP|V_NOSCALESTART|V_HUDTRANS, "FPS:"); V_DrawString(vid.width-(40*vid.dupx), h, - ticcntcolor|V_NOSCALESTART, va("%02d/%02u", totaltics, TICRATE)); + ticcntcolor|V_NOSCALESTART|V_HUDTRANS, va("%02d/%02u", totaltics, TICRATE)); lasttic = ontic; } From 9162ba87cc49db03f565be85fcece5c305cfb6e0 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 23 Oct 2019 15:24:34 -0700 Subject: [PATCH 16/16] Revert sound and music window focus related toggles This partially reverts commit 5ac8a26814bb43c5e91ab77af9a2e546b0ef50e4. --- src/m_menu.c | 40 +++++++++++++++++------------- src/s_sound.c | 62 ++++++----------------------------------------- src/s_sound.h | 6 ----- src/sdl/i_video.c | 9 +------ 4 files changed, 31 insertions(+), 86 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index cb33105d9..42f92daee 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1326,25 +1326,22 @@ static menuitem_t OP_OpenGLColorMenu[] = static menuitem_t OP_SoundOptionsMenu[] = { - {IT_HEADER, NULL, "Game Audio", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 6}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 11}, + {IT_HEADER, NULL, "Game Audio", NULL, 0}, // 0 // ScrollMenu offsets + {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 13}, // 6 + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 23}, // 11 - {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 21}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 26}, + {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 43}, // 21 + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 53}, // 26 - {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 36}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 41}, + {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 73}, // 36 + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 83}, // 41 - {IT_HEADER, NULL, "Accessibility", NULL, 50}, - {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 56}, - {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 61}, - - {IT_STRING | IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 71}, - {IT_STRING | IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 76}, + {IT_HEADER, NULL, "Accessibility", NULL, 103}, // 50 + {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 115}, // 56 + {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 125}, // 62 #ifdef HAVE_MIXERX - {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 86}, + {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 143}, #endif }; @@ -1967,9 +1964,18 @@ menu_t OP_ColorOptionsDef = 0, NULL }; -menu_t OP_SoundOptionsDef = DEFAULTSCROLLMENUSTYLE( - MN_OP_MAIN + (MN_OP_SOUND << 6), - "M_SOUND", OP_SoundOptionsMenu, &OP_MainDef, 30, 30); +menu_t OP_SoundOptionsDef = +{ + MN_OP_MAIN + (MN_OP_SOUND << 6), + "M_SOUND", + sizeof (OP_SoundOptionsMenu)/sizeof (menuitem_t), + &OP_MainDef, + OP_SoundOptionsMenu, + M_DrawGenericMenu, + 30, 30, + 0, + NULL +}; #ifdef HAVE_MIXERX menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE(MN_OP_MAIN + (MN_OP_SOUND << 6), "M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); #endif diff --git a/src/s_sound.c b/src/s_sound.c index e68a25ec9..1a719d972 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -60,9 +60,6 @@ static void GameMIDIMusic_OnChange(void); static void GameSounds_OnChange(void); static void GameDigiMusic_OnChange(void); -static void PlayMusicIfUnfocused_OnChange(void); -static void PlaySoundIfUnfocused_OnChange(void); - static void ModFilter_OnChange(void); static lumpnum_t S_GetMusicLumpNum(const char *mname); @@ -120,9 +117,6 @@ consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_O consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlayMusicIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playsoundifunfocused = {"playsoundsifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlaySoundIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; - #ifdef HAVE_OPENMPT static CV_PossibleValue_t interpolationfilter_cons_t[] = {{0, "Default"}, {1, "None"}, {2, "Linear"}, {4, "Cubic"}, {8, "Windowed sinc"}, {0, NULL}}; consvar_t cv_modfilter = {"modfilter", "0", CV_SAVE|CV_CALL, interpolationfilter_cons_t, ModFilter_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -296,9 +290,6 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_miditimiditypath); #endif - CV_RegisterVar(&cv_playmusicifunfocused); - CV_RegisterVar(&cv_playsoundifunfocused); - COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); @@ -2027,24 +2018,6 @@ void S_ResumeAudio(void) S_AdjustMusicStackTics(); } -void S_DisableSound(void) -{ - if (sound_started && !sound_disabled) - { - sound_disabled = true; - S_StopSounds(); - } -} - -void S_EnableSound(void) -{ - if (sound_started && sound_disabled) - { - sound_disabled = false; - S_InitSfxChannels(cv_soundvolume.value); - } -} - void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) { if (digvolume < 0) @@ -2234,11 +2207,15 @@ void GameSounds_OnChange(void) if (sound_disabled) { - if (!( cv_playsoundifunfocused.value && window_notinfocus )) - S_EnableSound(); + sound_disabled = false; + S_InitSfxChannels(cv_soundvolume.value); + S_StartSound(NULL, sfx_strpst); } else - S_DisableSound(); + { + sound_disabled = true; + S_StopSounds(); + } } void GameDigiMusic_OnChange(void) @@ -2331,28 +2308,3 @@ void ModFilter_OnChange(void) openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); } #endif - -static void PlayMusicIfUnfocused_OnChange(void) -{ - if (window_notinfocus) - { - if (cv_playmusicifunfocused.value) - S_PauseAudio(); - else - S_ResumeAudio(); - } -} - -static void PlaySoundIfUnfocused_OnChange(void) -{ - if (!cv_gamesounds.value) - return; - - if (window_notinfocus) - { - if (cv_playsoundifunfocused.value) - S_DisableSound(); - else - S_EnableSound(); - } -} diff --git a/src/s_sound.h b/src/s_sound.h index f4a986585..48128527c 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -44,8 +44,6 @@ extern consvar_t cv_resetmusicbyheader; extern consvar_t cv_gamedigimusic; extern consvar_t cv_gamemidimusic; extern consvar_t cv_gamesounds; -extern consvar_t cv_playmusicifunfocused; -extern consvar_t cv_playsoundifunfocused; #ifdef HAVE_OPENMPT extern consvar_t cv_modfilter; @@ -246,10 +244,6 @@ void S_StopMusic(void); void S_PauseAudio(void); void S_ResumeAudio(void); -// Enable and disable sound effects -void S_EnableSound(void); -void S_DisableSound(void); - // // Music Fading // diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index ed371d349..be6017aa9 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -580,11 +580,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) // Tell game we got focus back, resume music if necessary window_notinfocus = false; if (!paused) - { S_ResumeAudio(); //resume it - if (cv_gamesounds.value) - S_EnableSound(); - } if (!firsttimeonmouse) { @@ -599,10 +595,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { // Tell game we lost focus, pause music window_notinfocus = true; - if (!cv_playmusicifunfocused.value) - S_PauseAudio(); - if (!cv_playsoundifunfocused.value) - S_DisableSound(); + S_PauseAudio(); if (!disable_mouse) {