From 15dc57c4ba55124afb8e3f9fa057c1ded681335a Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 11:49:05 -0700 Subject: [PATCH 01/43] Allow name in kartdebugitem --- src/d_netcmd.c | 8 +++++++- src/d_player.h | 43 ++++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 51ec3b980..3171e6dd1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -378,7 +378,13 @@ consvar_t cv_karteliminatelast = {"karteliminatelast", "Yes", CV_NETVAR|CV_CHEAT consvar_t cv_kartusepwrlv = {"kartusepwrlv", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t kartdebugitem_cons_t[] = {{-1, "MIN"}, {NUMKARTITEMS-1, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t kartdebugitem_cons_t[] = +{ +#define X( name, n ) { n, #name } + KART_ITEM_ITERATOR, +#undef X + {0} +}; consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/d_player.h b/src/d_player.h index 697c0356c..853c0511b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -197,27 +197,32 @@ typedef enum NUMPOWERS } powertype_t; +#define KART_ITEM_ITERATOR \ + X (SAD, -1),\ + X (NONE, 0),\ + X (SNEAKER, 2),\ + X (ROCKETSNEAKER, 3),\ + X (INVINCIBILITY, 4),\ + X (BANANA, 5),\ + X (EGGMAN, 6),\ + X (ORBINAUT, 7),\ + X (JAWZ, 8),\ + X (MINE, 9),\ + X (BALLHOG, 10),\ + X (SPB, 11),\ + X (GROW, 12),\ + X (SHRINK, 13),\ + X (THUNDERSHIELD, 14),\ + X (HYUDORO, 15),\ + X (POGOSPRING, 16),\ + X (SUPERRING, 17),\ + X (KITCHENSINK, 18) + typedef enum { - KITEM_SAD = -1, - KITEM_NONE = 0, - KITEM_SNEAKER, - KITEM_ROCKETSNEAKER, - KITEM_INVINCIBILITY, - KITEM_BANANA, - KITEM_EGGMAN, - KITEM_ORBINAUT, - KITEM_JAWZ, - KITEM_MINE, - KITEM_BALLHOG, - KITEM_SPB, - KITEM_GROW, - KITEM_SHRINK, - KITEM_THUNDERSHIELD, - KITEM_HYUDORO, - KITEM_POGOSPRING, - KITEM_SUPERRING, - KITEM_KITCHENSINK, +#define X( name, n ) KITEM_ ## name + KART_ITEM_ITERATOR, +#undef X NUMKARTITEMS, From d337d96ffd435fe08cbb5ca82b778bdb6e8eed44 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 11:51:09 -0700 Subject: [PATCH 02/43] Comment for clarification --- src/d_player.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/d_player.h b/src/d_player.h index 853c0511b..e4fb2214d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -197,6 +197,11 @@ typedef enum NUMPOWERS } powertype_t; +/* +To use: #define X( name, number ) +Do with it whatever you want. +Run this macro, then #undef X afterward +*/ #define KART_ITEM_ITERATOR \ X (SAD, -1),\ X (NONE, 0),\ From 2a330f19765380a22b06b10d74e9adf126f0babb Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 12:33:25 -0700 Subject: [PATCH 03/43] Oops --- src/d_player.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index e4fb2214d..d270e567c 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -205,27 +205,27 @@ Run this macro, then #undef X afterward #define KART_ITEM_ITERATOR \ X (SAD, -1),\ X (NONE, 0),\ - X (SNEAKER, 2),\ - X (ROCKETSNEAKER, 3),\ - X (INVINCIBILITY, 4),\ - X (BANANA, 5),\ - X (EGGMAN, 6),\ - X (ORBINAUT, 7),\ - X (JAWZ, 8),\ - X (MINE, 9),\ - X (BALLHOG, 10),\ - X (SPB, 11),\ - X (GROW, 12),\ - X (SHRINK, 13),\ - X (THUNDERSHIELD, 14),\ - X (HYUDORO, 15),\ - X (POGOSPRING, 16),\ - X (SUPERRING, 17),\ - X (KITCHENSINK, 18) + X (SNEAKER, 1),\ + X (ROCKETSNEAKER, 2),\ + X (INVINCIBILITY, 3),\ + X (BANANA, 4),\ + X (EGGMAN, 5),\ + X (ORBINAUT, 6),\ + X (JAWZ, 7),\ + X (MINE, 8),\ + X (BALLHOG, 9),\ + X (SPB, 10),\ + X (GROW, 11),\ + X (SHRINK, 12),\ + X (THUNDERSHIELD, 13),\ + X (HYUDORO, 14),\ + X (POGOSPRING, 15),\ + X (SUPERRING, 16),\ + X (KITCHENSINK, 17) typedef enum { -#define X( name, n ) KITEM_ ## name +#define X( name, n ) KITEM_ ## name = n KART_ITEM_ITERATOR, #undef X From 833c8e2bed176aaae00900930e1f808122186532 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 12:39:38 -0700 Subject: [PATCH 04/43] Give item command --- src/d_netcmd.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ src/d_netcmd.h | 7 +-- src/k_kart.c | 1 + 3 files changed, 132 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3171e6dd1..89140f3c6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -68,6 +68,7 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum); static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum); static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum); static void Got_PickVotecmd(UINT8 **cp, INT32 playernum); +static void Got_GiveItemcmd(UINT8 **cp, INT32 playernum); static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum); #ifdef DELFILE static void Got_Delfilecmd(UINT8 **cp, INT32 playernum); @@ -190,6 +191,8 @@ static void Command_Archivetest_f(void); #endif #endif +static void Command_KartGiveItem_f(void); + // ========================================================================= // CLIENT VARIABLES // ========================================================================= @@ -388,6 +391,17 @@ static CV_PossibleValue_t kartdebugitem_cons_t[] = consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebug_giveitem = { + "kartdebug_giveitem", + /* :mhm: */ +#ifdef DEVELOP + "Yes", +#else + "No", +#endif + CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, + CV_YesNo, +}; consvar_t cv_kartdebugshrink = {"kartdebugshrink", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugdistribution = {"kartdebugdistribution", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebughuddrop = {"kartdebughuddrop", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -568,6 +582,8 @@ void D_RegisterServerCommands(void) RegisterNetXCmd(XD_MODIFYVOTE, Got_ModifyVotecmd); RegisterNetXCmd(XD_PICKVOTE, Got_PickVotecmd); + RegisterNetXCmd(XD_GIVEITEM, Got_GiveItemcmd); + // Remote Administration CV_RegisterVar(&cv_dummyjoinpassword); COM_AddCommand("joinpassword", Command_ChangeJoinPassword_f); @@ -626,6 +642,8 @@ void D_RegisterServerCommands(void) #endif #endif + COM_AddCommand("kartgiveitem", Command_KartGiveItem_f); + // for master server connection AddMServCommands(); @@ -5299,6 +5317,41 @@ static void Got_PickVotecmd(UINT8 **cp, INT32 playernum) Y_SetupVoteFinish(pick, level); } +static void Got_GiveItemcmd(UINT8 **cp, INT32 playernum) +{ + int item; + int amt; + + INT32 *kartstuff; + + item = READSINT8 (*cp); + amt = READUINT8 (*cp); + + if ( + ( netgame && ! cv_kartdebug_giveitem.value ) || + ( item < KITEM_SAD || item >= NUMKARTITEMS ) + ) + { + CONS_Alert(CONS_WARNING, + M_GetText ("Illegal give item received from %s\n"), + player_names[playernum]); + if (server) + { + XBOXSTATIC UINT8 buf[2]; + + buf[0] = (UINT8)playernum; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + return; + } + + kartstuff = players[playernum].kartstuff; + + kartstuff[k_itemtype] = item; + kartstuff[k_itemamount] = amt; +} + /** Prints the number of displayplayers[0]. * * \todo Possibly remove this; it was useful for debugging at one point. @@ -5462,6 +5515,80 @@ static void Command_Archivetest_f(void) #endif #endif +/** Give yourself an, optional quantity or one of, an item. + * + * \sa cv_kartdebug_giveitem +*/ +static void Command_KartGiveItem_f(void) +{ + char buf[2]; + + int ac; + const char *name; + int item; + + const char * str; + + int i; + + /* Allow always in local games. */ + if (! netgame || cv_kartdebug_giveitem.value) + { + ac = COM_Argc(); + if (ac < 2) + { + CONS_Printf( +"kartgiveitem [amount]: Give yourself an item\n" + ); + } + else + { + item = NUMKARTITEMS; + + name = COM_Argv(1); + + if (isdigit(*name) || *name == '-') + { + item = atoi(name); + } + else + { + for (i = 0; ( str = kartdebugitem_cons_t[i].strvalue ); ++i) + { + if (strcasecmp(name, str) == 0) + { + item = kartdebugitem_cons_t[i].value; + break; + } + } + } + + if (item < NUMKARTITEMS) + { + buf[0] = item; + + if (ac > 2) + buf[1] = atoi(COM_Argv(2)); + else + buf[1] = 1;/* default to one quantity */ + + SendNetXCmd(XD_GIVEITEM, buf, 2); + } + else + { + CONS_Alert(CONS_WARNING, + "No item matches '%s'\n", + name); + } + } + } + else + { + CONS_Alert(CONS_NOTICE, + "The server does not allow this.\n"); + } +} + /** Makes a change to ::cv_forceskin take effect immediately. * * \sa Command_SetForcedSkin_f, cv_forceskin, forcedskin diff --git a/src/d_netcmd.h b/src/d_netcmd.h index d1f28665c..1e84c67bb 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -125,7 +125,7 @@ extern consvar_t cv_kartusepwrlv; extern consvar_t cv_votetime; -extern consvar_t cv_kartdebugitem, cv_kartdebugamount, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; +extern consvar_t cv_kartdebugitem, cv_kartdebugamount, cv_kartdebug_giveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; extern consvar_t cv_kartdebugcheckpoint, cv_kartdebugnodes, cv_kartdebugcolorize; extern consvar_t cv_itemfinder; @@ -179,9 +179,10 @@ typedef enum XD_PICKVOTE, // 24 XD_REMOVEPLAYER,// 25 XD_POWERLEVEL, // 26 + XD_GIVEITEM, // 27 #ifdef HAVE_BLUA - XD_LUACMD, // 27 - XD_LUAVAR, // 28 + XD_LUACMD, // 28 + XD_LUAVAR, // 29 #endif MAXNETXCMD } netxcmd_t; diff --git a/src/k_kart.c b/src/k_kart.c index 230662d2a..6eb4b9f9d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -585,6 +585,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartdebugitem); CV_RegisterVar(&cv_kartdebugamount); CV_RegisterVar(&cv_kartdebugshrink); + CV_RegisterVar(&cv_kartdebug_giveitem); CV_RegisterVar(&cv_kartdebugdistribution); CV_RegisterVar(&cv_kartdebughuddrop); From 392aec38f88975c92570b704d1626f49d181f692 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 13:11:14 -0700 Subject: [PATCH 05/43] Rename kartdebug_giveitem to kartallowgiveitem --- src/d_netcmd.c | 10 +++++----- src/d_netcmd.h | 2 +- src/k_kart.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 89140f3c6..378bf9fb6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -391,8 +391,8 @@ static CV_PossibleValue_t kartdebugitem_cons_t[] = consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebug_giveitem = { - "kartdebug_giveitem", +consvar_t cv_kartallowgiveitem = { + "kartallowgiveitem", /* :mhm: */ #ifdef DEVELOP "Yes", @@ -5328,7 +5328,7 @@ static void Got_GiveItemcmd(UINT8 **cp, INT32 playernum) amt = READUINT8 (*cp); if ( - ( netgame && ! cv_kartdebug_giveitem.value ) || + ( netgame && ! cv_kartallowgiveitem.value ) || ( item < KITEM_SAD || item >= NUMKARTITEMS ) ) { @@ -5517,7 +5517,7 @@ static void Command_Archivetest_f(void) /** Give yourself an, optional quantity or one of, an item. * - * \sa cv_kartdebug_giveitem + * \sa cv_kartallowgiveitem */ static void Command_KartGiveItem_f(void) { @@ -5532,7 +5532,7 @@ static void Command_KartGiveItem_f(void) int i; /* Allow always in local games. */ - if (! netgame || cv_kartdebug_giveitem.value) + if (! netgame || cv_kartallowgiveitem.value) { ac = COM_Argc(); if (ac < 2) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 1e84c67bb..e6be9296d 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -125,7 +125,7 @@ extern consvar_t cv_kartusepwrlv; extern consvar_t cv_votetime; -extern consvar_t cv_kartdebugitem, cv_kartdebugamount, cv_kartdebug_giveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; +extern consvar_t cv_kartdebugitem, cv_kartdebugamount, cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; extern consvar_t cv_kartdebugcheckpoint, cv_kartdebugnodes, cv_kartdebugcolorize; extern consvar_t cv_itemfinder; diff --git a/src/k_kart.c b/src/k_kart.c index 6eb4b9f9d..a7e94dcbc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -585,7 +585,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartdebugitem); CV_RegisterVar(&cv_kartdebugamount); CV_RegisterVar(&cv_kartdebugshrink); - CV_RegisterVar(&cv_kartdebug_giveitem); + CV_RegisterVar(&cv_kartallowgiveitem); CV_RegisterVar(&cv_kartdebugdistribution); CV_RegisterVar(&cv_kartdebughuddrop); From 803884c55a87fe72348e625017307671a1d238f4 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 13:12:22 -0700 Subject: [PATCH 06/43] Remove kartdebugitem --- src/d_netcmd.c | 1 - src/d_netcmd.h | 2 +- src/k_kart.c | 20 ++------------------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 378bf9fb6..c35d492fd 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -388,7 +388,6 @@ static CV_PossibleValue_t kartdebugitem_cons_t[] = #undef X {0} }; -consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartallowgiveitem = { diff --git a/src/d_netcmd.h b/src/d_netcmd.h index e6be9296d..f3efd12ea 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -125,7 +125,7 @@ extern consvar_t cv_kartusepwrlv; extern consvar_t cv_votetime; -extern consvar_t cv_kartdebugitem, cv_kartdebugamount, cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; +extern consvar_t cv_kartdebugamount, cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; extern consvar_t cv_kartdebugcheckpoint, cv_kartdebugnodes, cv_kartdebugcolorize; extern consvar_t cv_itemfinder; diff --git a/src/k_kart.c b/src/k_kart.c index a7e94dcbc..196fbaecb 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -582,7 +582,6 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartusepwrlv); CV_RegisterVar(&cv_votetime); - CV_RegisterVar(&cv_kartdebugitem); CV_RegisterVar(&cv_kartdebugamount); CV_RegisterVar(&cv_kartdebugshrink); CV_RegisterVar(&cv_kartallowgiveitem); @@ -1121,21 +1120,6 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) } // SPECIAL CASE No. 2: - // Give a debug item instead if specified - if (cv_kartdebugitem.value != 0 && !modeattacking) - { - K_KartGetItemResult(player, cv_kartdebugitem.value); - player->kartstuff[k_itemamount] = cv_kartdebugamount.value; - player->karthud[khud_itemblink] = TICRATE; - player->karthud[khud_itemblinkmode] = 2; - player->kartstuff[k_itemroulette] = 0; - player->kartstuff[k_roulettetype] = 0; - if (P_IsDisplayPlayer(player)) - S_StartSound(NULL, sfx_dbgsal); - return; - } - - // SPECIAL CASE No. 3: // Record Attack / alone mashing behavior if (modeattacking || pingame == 1) { @@ -1186,7 +1170,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) return; } - // SPECIAL CASE No. 4: + // SPECIAL CASE No. 3: // Being in ring debt occasionally forces Super Ring on you if you mashed if (mashed && player->kartstuff[k_rings] < 0 && cv_superring.value) { @@ -1204,7 +1188,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) } } - // SPECIAL CASE No. 5: + // SPECIAL CASE No. 4: // Force SPB onto 2nd if they get too far behind if (player->kartstuff[k_position] == 2 && pdis > (DISTVAR*6) && spbplace == -1 && !indirectitemcooldown && !dontforcespb From 22cb7451e925857067d32bad8f7f318c6ecf8d0c Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Oct 2019 13:35:07 -0700 Subject: [PATCH 07/43] ...Also remove kartdebugamount --- src/d_netcmd.c | 2 -- src/d_netcmd.h | 2 +- src/k_kart.c | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c35d492fd..d7c1ffd28 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -388,8 +388,6 @@ static CV_PossibleValue_t kartdebugitem_cons_t[] = #undef X {0} }; -static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; -consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartallowgiveitem = { "kartallowgiveitem", /* :mhm: */ diff --git a/src/d_netcmd.h b/src/d_netcmd.h index f3efd12ea..ccd903daf 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -125,7 +125,7 @@ extern consvar_t cv_kartusepwrlv; extern consvar_t cv_votetime; -extern consvar_t cv_kartdebugamount, cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; +extern consvar_t cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; extern consvar_t cv_kartdebugcheckpoint, cv_kartdebugnodes, cv_kartdebugcolorize; extern consvar_t cv_itemfinder; diff --git a/src/k_kart.c b/src/k_kart.c index 196fbaecb..64b206097 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -582,7 +582,6 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartusepwrlv); CV_RegisterVar(&cv_votetime); - CV_RegisterVar(&cv_kartdebugamount); CV_RegisterVar(&cv_kartdebugshrink); CV_RegisterVar(&cv_kartallowgiveitem); CV_RegisterVar(&cv_kartdebugdistribution); From 4a973e29066dcab3110572059f4171bfb109ae40 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 21 Mar 2020 15:56:38 -0700 Subject: [PATCH 08/43] Revert "...Also remove kartdebugamount" This reverts commit 22cb7451e925857067d32bad8f7f318c6ecf8d0c. --- src/d_netcmd.c | 2 ++ src/d_netcmd.h | 2 +- src/k_kart.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d7c1ffd28..c35d492fd 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -388,6 +388,8 @@ static CV_PossibleValue_t kartdebugitem_cons_t[] = #undef X {0} }; +static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; +consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartallowgiveitem = { "kartallowgiveitem", /* :mhm: */ diff --git a/src/d_netcmd.h b/src/d_netcmd.h index ccd903daf..f3efd12ea 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -125,7 +125,7 @@ extern consvar_t cv_kartusepwrlv; extern consvar_t cv_votetime; -extern consvar_t cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; +extern consvar_t cv_kartdebugamount, cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; extern consvar_t cv_kartdebugcheckpoint, cv_kartdebugnodes, cv_kartdebugcolorize; extern consvar_t cv_itemfinder; diff --git a/src/k_kart.c b/src/k_kart.c index 64b206097..196fbaecb 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -582,6 +582,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartusepwrlv); CV_RegisterVar(&cv_votetime); + CV_RegisterVar(&cv_kartdebugamount); CV_RegisterVar(&cv_kartdebugshrink); CV_RegisterVar(&cv_kartallowgiveitem); CV_RegisterVar(&cv_kartdebugdistribution); From c3b967468a49fdc33884262353747242b6004e7f Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 21 Mar 2020 15:56:40 -0700 Subject: [PATCH 09/43] Revert "Remove kartdebugitem" This reverts commit 803884c55a87fe72348e625017307671a1d238f4. --- src/d_netcmd.c | 1 + src/d_netcmd.h | 2 +- src/k_kart.c | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c35d492fd..378bf9fb6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -388,6 +388,7 @@ static CV_PossibleValue_t kartdebugitem_cons_t[] = #undef X {0} }; +consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartallowgiveitem = { diff --git a/src/d_netcmd.h b/src/d_netcmd.h index f3efd12ea..e6be9296d 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -125,7 +125,7 @@ extern consvar_t cv_kartusepwrlv; extern consvar_t cv_votetime; -extern consvar_t cv_kartdebugamount, cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; +extern consvar_t cv_kartdebugitem, cv_kartdebugamount, cv_kartallowgiveitem, cv_kartdebugshrink, cv_kartdebugdistribution, cv_kartdebughuddrop; extern consvar_t cv_kartdebugcheckpoint, cv_kartdebugnodes, cv_kartdebugcolorize; extern consvar_t cv_itemfinder; diff --git a/src/k_kart.c b/src/k_kart.c index 196fbaecb..a7e94dcbc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -582,6 +582,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartusepwrlv); CV_RegisterVar(&cv_votetime); + CV_RegisterVar(&cv_kartdebugitem); CV_RegisterVar(&cv_kartdebugamount); CV_RegisterVar(&cv_kartdebugshrink); CV_RegisterVar(&cv_kartallowgiveitem); @@ -1120,6 +1121,21 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) } // SPECIAL CASE No. 2: + // Give a debug item instead if specified + if (cv_kartdebugitem.value != 0 && !modeattacking) + { + K_KartGetItemResult(player, cv_kartdebugitem.value); + player->kartstuff[k_itemamount] = cv_kartdebugamount.value; + player->karthud[khud_itemblink] = TICRATE; + player->karthud[khud_itemblinkmode] = 2; + player->kartstuff[k_itemroulette] = 0; + player->kartstuff[k_roulettetype] = 0; + if (P_IsDisplayPlayer(player)) + S_StartSound(NULL, sfx_dbgsal); + return; + } + + // SPECIAL CASE No. 3: // Record Attack / alone mashing behavior if (modeattacking || pingame == 1) { @@ -1170,7 +1186,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) return; } - // SPECIAL CASE No. 3: + // SPECIAL CASE No. 4: // Being in ring debt occasionally forces Super Ring on you if you mashed if (mashed && player->kartstuff[k_rings] < 0 && cv_superring.value) { @@ -1188,7 +1204,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) } } - // SPECIAL CASE No. 4: + // SPECIAL CASE No. 5: // Force SPB onto 2nd if they get too far behind if (player->kartstuff[k_position] == 2 && pdis > (DISTVAR*6) && spbplace == -1 && !indirectitemcooldown && !dontforcespb From 530cac8673f251ef64369a4e6d136e0a06135f9d Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 19:53:46 -0800 Subject: [PATCH 10/43] Hey it's audio- ....resynching... --- src/i_sound.h | 2 ++ src/s_sound.c | 4 ++++ src/s_sound.h | 2 ++ src/sdl/mixer_sound.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/src/i_sound.h b/src/i_sound.h index 9a5c2930a..422cfb8ff 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -158,6 +158,8 @@ UINT32 I_GetSongLoopPoint(void); boolean I_SetSongPosition(UINT32 position); UINT32 I_GetSongPosition(void); +void I_UpdateSongLagThreshold (void); + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ diff --git a/src/s_sound.c b/src/s_sound.c index 21b668f28..3d8fd6925 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -120,6 +120,8 @@ consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, 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}; +consvar_t cv_music_resync_threshold = {"music_resync_threshold", "100", CV_SAVE|CV_CALL, CV_Unsigned, I_UpdateSongLagThreshold}; + #define S_MAX_VOLUME 127 // when to clip out sounds @@ -283,6 +285,8 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_playmusicifunfocused); CV_RegisterVar(&cv_playsoundifunfocused); + CV_RegisterVar(&cv_music_resync_threshold); + COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); diff --git a/src/s_sound.h b/src/s_sound.h index 2a904faff..bef91bfb6 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -36,6 +36,8 @@ extern consvar_t cv_gamesounds; extern consvar_t cv_playmusicifunfocused; extern consvar_t cv_playsoundifunfocused; +extern consvar_t cv_music_resync_threshold; + #ifdef SNDSERV extern consvar_t sndserver_cmd, sndserver_arg; #endif diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 1617da2a3..260dd3125 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -13,6 +13,12 @@ #if defined(HAVE_SDL) && defined(HAVE_MIXER) && SOUND==SOUND_MIXER +/* +Just for hu_stopped. I promise I didn't +write netcode into the sound code, OKAY? +*/ +#include "../d_clisrv.h" + #include "../sounds.h" #include "../s_sound.h" #include "../i_sound.h" @@ -74,12 +80,16 @@ UINT8 sound_started = false; +static UINT32 stutter_threshold; + static Mix_Music *music; static UINT8 music_volume, sfx_volume, internal_volume; static float loop_point; static float song_length; // length in seconds static boolean songpaused; +static UINT32 music_end_bytes; static UINT32 music_bytes; +static UINT32 music_stutter_bytes; static boolean is_looping; // fading @@ -101,6 +111,8 @@ static void var_cleanup(void) loop_point = song_length =\ music_bytes = fading_source = fading_target =\ fading_timer = fading_duration = 0; + music_end_bytes = 0; + music_stutter_bytes = 0; songpaused = is_looping =\ is_fading = false; @@ -554,6 +566,8 @@ static void do_fading_callback(void) static void count_music_bytes(int chan, void *stream, int len, void *udata) { + UINT32 bytes; + (void)chan; (void)stream; (void)udata; @@ -561,12 +575,35 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) return; music_bytes += len; + if (hu_stopped) + { + music_stutter_bytes += len; + } + else + { + if (music_stutter_bytes >= stutter_threshold) + { + /* + This would be after looping. If we're too near to the start of the + file, subtracting the delta will just underflow. + */ + if (music_stutter_bytes > music_bytes) + { + /* We already know where the end is because we looped. */ + bytes = ( music_end_bytes - ( music_stutter_bytes - music_bytes )); + } + else + bytes = ( music_bytes - music_stutter_bytes ); + I_SetSongPosition((int)( bytes/4/44100.0*1000 )); + } + } } static void music_loop(void) { if (is_looping) { + music_end_bytes = music_bytes; Mix_PlayMusic(music, 0); Mix_SetMusicPosition(loop_point); music_bytes = loop_point*44100.0L*4; //assume 44.1khz, 4-byte length (see I_GetSongPosition) @@ -848,6 +885,8 @@ boolean I_SetSongPosition(UINT32 position) // NOT if position input is greater than song length. music_bytes = 0; + music_stutter_bytes = 0; + return true; } } @@ -892,6 +931,12 @@ UINT32 I_GetSongPosition(void) // 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4 } +void +I_UpdateSongLagThreshold (void) +{ + stutter_threshold = cv_music_resync_threshold.value/1000.0*(4*44100); +} + /// ------------------------ /// Music Playback /// ------------------------ From 1e5041375c46ad83cf829a5eeed0835bc9e94075 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 20:25:23 -0800 Subject: [PATCH 11/43] Menu option for music resync --- src/m_menu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index d5084dff2..a3dac710d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1377,6 +1377,8 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, + + {IT_STRING|IT_CVAR, NULL, "Music Resynch Threshold (MS)", &cv_music_resync_threshold, 150}, }; static menuitem_t OP_DataOptionsMenu[] = From 04d71125389d56812fe7945afa3ae4e7eafb9679 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 20:40:12 -0800 Subject: [PATCH 12/43] Limit music resync threshold to one second --- src/s_sound.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 3d8fd6925..a2c987d0e 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -120,7 +120,16 @@ consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, 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}; -consvar_t cv_music_resync_threshold = {"music_resync_threshold", "100", CV_SAVE|CV_CALL, CV_Unsigned, I_UpdateSongLagThreshold}; +static CV_PossibleValue_t music_resync_threshold_cons_t[] = { + {0, "MIN"}, + {1000, "MAX"}, + + {0} +}; +consvar_t cv_music_resync_threshold = { + "music_resync_threshold", "100", CV_SAVE|CV_CALL, + music_resync_threshold_cons_t, I_UpdateSongLagThreshold +}; #define S_MAX_VOLUME 127 From 7d1012e85e28f58dc7a7c4c67f99743981f67e46 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 21:00:08 -0800 Subject: [PATCH 13/43] More intuitive menu for music resync option --- src/m_menu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index a3dac710d..f5d34fc0a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1378,7 +1378,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_CVAR, NULL, "Music Resynch Threshold (MS)", &cv_music_resync_threshold, 150}, + {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music Resynch Threshold", &cv_music_resync_threshold, 150}, }; static menuitem_t OP_DataOptionsMenu[] = @@ -6417,12 +6417,23 @@ static void M_DrawSkyRoom(void) (midi_disabled ? warningflags : highlightflags), (midi_disabled ? "OFF" : "ON"));*/ + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, + currentMenu->y+currentMenu->menuitems[12].alphaKey, + highlightflags, + ( (cv_music_resync_threshold.value) ? + va("%s MS", cv_music_resync_threshold.string) : "OFF" )); + if (itemOn == 0) lengthstring = 8*(sound_disabled ? 3 : 2); else if (itemOn == 2) lengthstring = 8*(digital_disabled ? 3 : 2); /*else if (itemOn == 5) lengthstring = 8*(midi_disabled ? 3 : 2);*/ + else if (itemOn == 12) + { + lengthstring = 8*( (cv_music_resync_threshold.value) ? + strlen(cv_music_resync_threshold.string) + 3 : 3 ); + } } for (i = 0; i < currentMenu->numitems; ++i) From d1dce97d15279339f38d9f08da13c882ad589bc8 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 21:03:25 -0800 Subject: [PATCH 14/43] Don't resync if it's disabled --- src/sdl/mixer_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 260dd3125..1590496ff 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -579,7 +579,7 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) { music_stutter_bytes += len; } - else + else if (stutter_threshold) { if (music_stutter_bytes >= stutter_threshold) { From e9c0e65e0efa458d3ce7a391af7bf906cc850034 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 28 Nov 2019 17:09:06 -0800 Subject: [PATCH 15/43] Only resync music if in a level --- src/sdl/mixer_sound.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 1590496ff..52610575e 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -564,17 +564,11 @@ static void do_fading_callback(void) /// Music Hooks /// ------------------------ -static void count_music_bytes(int chan, void *stream, int len, void *udata) +static void +Countstutter (int len) { UINT32 bytes; - (void)chan; - (void)stream; - (void)udata; - - if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) - return; - music_bytes += len; if (hu_stopped) { music_stutter_bytes += len; @@ -599,6 +593,20 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) } } +static void count_music_bytes(int chan, void *stream, int len, void *udata) +{ + (void)chan; + (void)stream; + (void)udata; + + if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) + return; + music_bytes += len; + + if (gamestate == GS_LEVEL) + Countstutter(len); +} + static void music_loop(void) { if (is_looping) From 8524c3749dd9b598751db52e82469c515c17d54d Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 28 Nov 2019 22:05:49 -0800 Subject: [PATCH 16/43] Fade level music back in after Invincibility and Grow Cvars are invincibilitymusicfade and growmusicfade. Both measure milliseconds. --- src/d_netcmd.c | 3 +++ src/g_game.c | 3 +++ src/g_game.h | 3 +++ src/p_user.c | 9 ++++++++- src/s_sound.c | 18 ++++++++++++++++++ src/s_sound.h | 3 +++ 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 404d7f181..3498c7cfc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -985,6 +985,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_soundtest); + CV_RegisterVar(&cv_invincmusicfade); + CV_RegisterVar(&cv_growmusicfade); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/g_game.c b/src/g_game.c index 7bd183664..49af6e509 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -529,6 +529,9 @@ consvar_t cv_fireaxis4 = {"joyaxis4_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NU consvar_t cv_driftaxis4 = {"joyaxis4_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; + #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" diff --git a/src/g_game.h b/src/g_game.h index de482fe7f..62bffbc7f 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -118,6 +118,9 @@ extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_deadzone4; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; +extern consvar_t cv_invincmusicfade; +extern consvar_t cv_growmusicfade; + typedef enum { AXISNONE = 0, diff --git a/src/p_user.c b/src/p_user.c index 666855f53..c79c74b8f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1244,10 +1244,16 @@ void P_RestoreMusic(player_t *player) // Item - Grow if (wantedmus == 2) + { S_ChangeMusicInternal("kgrow", true); + S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); + } // Item - Invincibility else if (wantedmus == 1) + { S_ChangeMusicInternal("kinvnc", true); + S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); + } else { #if 0 @@ -1256,7 +1262,8 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value)) S_SpeedMusic(1.2f); #endif - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, + S_GetRestoreMusicFadeIn()); } } } diff --git a/src/s_sound.c b/src/s_sound.c index a2c987d0e..8f9223bc4 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1563,6 +1563,7 @@ static char music_name[7]; // up to 6-character name static void *music_data; static UINT16 music_flags; static boolean music_looping; +static consvar_t *music_refade_cv; static char queue_name[7]; static UINT16 queue_flags; @@ -1946,6 +1947,8 @@ static void S_UnloadMusic(void) music_name[0] = 0; music_flags = 0; music_looping = false; + + music_refade_cv = 0; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) @@ -2167,6 +2170,21 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) } } +void +S_SetRestoreMusicFadeInCvar (consvar_t *cv) +{ + music_refade_cv = cv; +} + +int +S_GetRestoreMusicFadeIn (void) +{ + if (music_refade_cv) + return music_refade_cv->value; + else + return 0; +} + /// ------------------------ /// Music Fading /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index bef91bfb6..c082b3dd6 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -186,6 +186,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 #define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0) #define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) +void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +int S_GetRestoreMusicFadeIn (void); + // Stops the music. void S_StopMusic(void); From 911dd5733406d0f2d3c5af0da82579e71fff4965 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 01:56:44 -0800 Subject: [PATCH 17/43] Restore level music to where it left off Toggleable via the resume cvar. --- src/d_netcmd.c | 2 ++ src/doomstat.h | 1 + src/g_game.c | 2 ++ src/g_game.h | 2 ++ src/p_user.c | 10 +++++++++- src/s_sound.c | 3 +++ 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3498c7cfc..5cca6637f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -988,6 +988,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); + CV_RegisterVar(&cv_resume); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/doomstat.h b/src/doomstat.h index f4f7acfd0..c65d368d5 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -34,6 +34,7 @@ extern INT16 gamemap; extern char mapmusname[7]; extern UINT16 mapmusflags; extern UINT32 mapmusposition; +extern UINT32 mapmusresume; #define MUSIC_TRACKMASK 0x0FFF // ----************ #define MUSIC_RELOADRESET 0x8000 // *--------------- #define MUSIC_FORCERESET 0x4000 // -*-------------- diff --git a/src/g_game.c b/src/g_game.c index 49af6e509..31baf6b3d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -80,6 +80,7 @@ static void G_DoStartVote(void); char mapmusname[7]; // Music name UINT16 mapmusflags; // Track and reset bit UINT32 mapmusposition; // Position to jump to +UINT32 mapmusresume; INT16 gamemap = 1; INT16 maptol; @@ -532,6 +533,7 @@ consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_con consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" diff --git a/src/g_game.h b/src/g_game.h index 62bffbc7f..c5b3e5dc3 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -121,6 +121,8 @@ extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_gu extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; +extern consvar_t cv_resume; + typedef enum { AXISNONE = 0, diff --git a/src/p_user.c b/src/p_user.c index c79c74b8f..7172bebd1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1188,6 +1188,8 @@ boolean P_EndingMusic(player_t *player) // void P_RestoreMusic(player_t *player) { + UINT32 position; + if (!P_IsLocalPlayer(player)) // Only applies to a local player return; @@ -1262,8 +1264,14 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value)) S_SpeedMusic(1.2f); #endif - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, + if (mapmusresume && cv_resume.value) + position = mapmusresume; + else + position = mapmusposition; + + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); + mapmusresume = 0; } } } diff --git a/src/s_sound.c b/src/s_sound.c index 8f9223bc4..036462edb 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2073,6 +2073,9 @@ void S_StopMusic(void) || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; + if (strcasecmp(music_name, mapmusname) == 0) + mapmusresume = I_GetSongPosition(); + if (I_SongPaused()) I_ResumeSong(); From 7023ccc239a0cb9c08bf26c2f718d1d5676a819f Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 02:55:45 -0800 Subject: [PATCH 18/43] Death fades music Cvars are respawnfademusicout and respawnfademusicback. Both measure milliseconds. --- src/d_netcmd.c | 3 +++ src/g_game.c | 17 ++++++++++++++++- src/g_game.h | 3 +++ src/p_inter.c | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5cca6637f..7b274d0a1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -988,6 +988,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); + CV_RegisterVar(&cv_respawnfademusicout); + CV_RegisterVar(&cv_respawnfademusicback); + CV_RegisterVar(&cv_resume); // ingame object placing diff --git a/src/g_game.c b/src/g_game.c index 31baf6b3d..9e4a2df63 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -533,6 +533,9 @@ consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_con consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 @@ -2751,7 +2754,19 @@ void G_PlayerReborn(INT32 player) } } - P_RestoreMusic(p); + if (S_MusicPlaying()) + { + P_RestoreMusic(p); + /* mid-way fading out, fade back up */ + S_FadeMusic(100, cv_respawnfademusicback.value); + } + else + { + /* this could be considered a hack, but I like it ...kinda */ + S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); + P_RestoreMusic(p); + } + if (songcredit) S_ShowMusicCredit(); diff --git a/src/g_game.h b/src/g_game.h index c5b3e5dc3..201db19d9 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -121,6 +121,9 @@ extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_gu extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; +extern consvar_t cv_respawnfademusicout; +extern consvar_t cv_respawnfademusicback; + extern consvar_t cv_resume; typedef enum diff --git a/src/p_inter.c b/src/p_inter.c index 905cf1c1f..e4331e039 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2116,6 +2116,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { mobjtype_t item; mobj_t *mo; + int ms; //if (inflictor && (inflictor->type == MT_SHELL || inflictor->type == MT_FIREBALL)) // P_SetTarget(&target->tracer, inflictor); @@ -2330,6 +2331,20 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; + + /* + If the time spent with the music paused is less than half + a second, continue playing the song (just mute it). + */ + if (( ms - cv_respawnfademusicout.value ) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + if (target->player == &players[consoleplayer]) { // don't die in auto map, From f6888ab004de7ba6bdc1cf6e3af20db1199b620b Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:01:01 -0800 Subject: [PATCH 19/43] Reset mapmusresume on level load etc. This is probably important, right? --- src/g_game.c | 1 + src/p_spec.c | 1 + src/s_sound.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 9e4a2df63..39f1bbb3f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2750,6 +2750,7 @@ void G_PlayerReborn(INT32 player) mapmusname[6] = 0; mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); mapmusposition = mapheaderinfo[gamemap-1]->muspos; + mapmusresume = 0; songcredit = true; } } diff --git a/src/p_spec.c b/src/p_spec.c index c4070ef5c..260d4a4f5 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2517,6 +2517,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) mapmusflags |= MUSIC_FORCERESET; mapmusposition = position; + mapmusresume = 0; S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, !(line->flags & ML_EFFECT2) ? prefadems : 0, diff --git a/src/s_sound.c b/src/s_sound.c index 036462edb..3cb5ef7fe 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2232,6 +2232,7 @@ void S_Start(void) mapmusname[6] = 0; mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); mapmusposition = mapheaderinfo[gamemap-1]->muspos; + mapmusresume = 0; } //if (cv_resetmusic.value) // Starting ambience should always be restarted @@ -2306,6 +2307,7 @@ static void Command_Tunes_f(void) mapmusname[6] = 0; mapmusflags = (track & MUSIC_TRACKMASK); mapmusposition = position; + mapmusresume = 0; S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); From 15e82919034f35e75ae7dfd5e8e7dfa896cb6a68 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:01:41 -0800 Subject: [PATCH 20/43] Reset the music fade in cvar pointer too This fixes a bug with death fades. --- src/p_user.c | 1 + src/s_sound.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 7172bebd1..5fee0ac9b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1271,6 +1271,7 @@ void P_RestoreMusic(player_t *player) S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); + S_ClearRestoreMusicFadeInCvar(); mapmusresume = 0; } } diff --git a/src/s_sound.h b/src/s_sound.h index c082b3dd6..8e94f8e16 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -187,6 +187,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 #define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +#define S_ClearRestoreMusicFadeInCvar() \ + S_SetRestoreMusicFadeInCvar(0) int S_GetRestoreMusicFadeIn (void); // Stops the music. From 80c7cc3c879cb39e6d04878813d04f033f528f2a Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:24:10 -0800 Subject: [PATCH 21/43] 3 AM Moment: The death fades now only apply to local players --- src/g_game.c | 13 +------------ src/p_inter.c | 27 +++++++++++++++------------ src/p_user.c | 21 +++++++++++++++++++-- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 39f1bbb3f..f5aab99a9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2755,18 +2755,7 @@ void G_PlayerReborn(INT32 player) } } - if (S_MusicPlaying()) - { - P_RestoreMusic(p); - /* mid-way fading out, fade back up */ - S_FadeMusic(100, cv_respawnfademusicback.value); - } - else - { - /* this could be considered a hack, but I like it ...kinda */ - S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); - P_RestoreMusic(p); - } + P_RestoreMusic(p); if (songcredit) S_ShowMusicCredit(); diff --git a/src/p_inter.c b/src/p_inter.c index e4331e039..12fbcf6dd 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2331,19 +2331,22 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; - if (netgame || multiplayer) - ms = cv_respawntime.value * 1000; - else - ms = 1000; + if (P_IsLocalPlayer(target->player)) + { + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; - /* - If the time spent with the music paused is less than half - a second, continue playing the song (just mute it). - */ - if (( ms - cv_respawnfademusicout.value ) < 500) - S_FadeMusic(0, cv_respawnfademusicout.value); - else - S_FadeOutStopMusic(cv_respawnfademusicout.value); + /* + If the time spent with the music paused is less than half + a second, continue playing the song (just mute it). + */ + if (( ms - cv_respawnfademusicout.value ) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + } if (target->player == &players[consoleplayer]) { diff --git a/src/p_user.c b/src/p_user.c index 5fee0ac9b..80f206d7c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1189,6 +1189,8 @@ boolean P_EndingMusic(player_t *player) void P_RestoreMusic(player_t *player) { UINT32 position; + boolean playing; + int fadein; if (!P_IsLocalPlayer(player)) // Only applies to a local player return; @@ -1269,10 +1271,25 @@ void P_RestoreMusic(player_t *player) else position = mapmusposition; - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, - S_GetRestoreMusicFadeIn()); + playing = S_MusicPlaying(); + + /* + So if the music isn't playing, it's + most likely because we were dead. + */ + if (! playing) + fadein = cv_respawnfademusicback.value; + + if (playing || ! fadein) + fadein = S_GetRestoreMusicFadeIn(); + + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, fadein); S_ClearRestoreMusicFadeInCvar(); mapmusresume = 0; + + /* mid-way fading out, fade back up */ + if (playing) + S_FadeMusic(100, cv_respawnfademusicback.value); } } } From e6eac8cd3d8dda525a089d402fdca6a822f49c17 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:31:50 -0800 Subject: [PATCH 22/43] Revert "More intuitive menu for music resync option" This reverts commit ee78597a42b4e5edf5b22466682b9a00da6bcecf. --- src/m_menu.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index f5d34fc0a..a3dac710d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1378,7 +1378,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music Resynch Threshold", &cv_music_resync_threshold, 150}, + {IT_STRING|IT_CVAR, NULL, "Music Resynch Threshold (MS)", &cv_music_resync_threshold, 150}, }; static menuitem_t OP_DataOptionsMenu[] = @@ -6417,23 +6417,12 @@ static void M_DrawSkyRoom(void) (midi_disabled ? warningflags : highlightflags), (midi_disabled ? "OFF" : "ON"));*/ - V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, - currentMenu->y+currentMenu->menuitems[12].alphaKey, - highlightflags, - ( (cv_music_resync_threshold.value) ? - va("%s MS", cv_music_resync_threshold.string) : "OFF" )); - if (itemOn == 0) lengthstring = 8*(sound_disabled ? 3 : 2); else if (itemOn == 2) lengthstring = 8*(digital_disabled ? 3 : 2); /*else if (itemOn == 5) lengthstring = 8*(midi_disabled ? 3 : 2);*/ - else if (itemOn == 12) - { - lengthstring = 8*( (cv_music_resync_threshold.value) ? - strlen(cv_music_resync_threshold.string) + 3 : 3 ); - } } for (i = 0; i < currentMenu->numitems; ++i) From 3ae147b01b2400bfd5ae5455155b71ff40935061 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:32:24 -0800 Subject: [PATCH 23/43] Revert "Menu option for music resync" This reverts commit a210874ae421007d0bc97b827b4e52c9b076cd90. --- src/m_menu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index a3dac710d..d5084dff2 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1377,8 +1377,6 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - - {IT_STRING|IT_CVAR, NULL, "Music Resynch Threshold (MS)", &cv_music_resync_threshold, 150}, }; static menuitem_t OP_DataOptionsMenu[] = From d99d1994da2e898dea753c0093883f5d34fbe325 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 16:17:09 -0800 Subject: [PATCH 24/43] Let invincibility and grow music fades work again --- src/g_game.c | 26 ++++++++++++++++++++++++++ src/p_user.c | 21 ++------------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index f5aab99a9..0a62b27f9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2596,6 +2596,9 @@ void G_PlayerReborn(INT32 player) INT32 respawnflip; boolean songcredit = false; + boolean local; + boolean playing; + score = players[player].score; marescore = players[player].marescore; lives = players[player].lives; @@ -2755,8 +2758,31 @@ void G_PlayerReborn(INT32 player) } } + /* I'm putting this here because lol */ + + local = P_IsLocalPlayer(p); + + if (local) + { + playing = S_MusicPlaying(); + + /* + Fade it in with the same call to avoid + max volume for a few milliseconds (?). + */ + if (! playing) + S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); + } + P_RestoreMusic(p); + if (local) + { + /* mid-way fading out, fade back up */ + if (playing) + S_FadeMusic(100, cv_respawnfademusicback.value); + } + if (songcredit) S_ShowMusicCredit(); diff --git a/src/p_user.c b/src/p_user.c index 80f206d7c..5fee0ac9b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1189,8 +1189,6 @@ boolean P_EndingMusic(player_t *player) void P_RestoreMusic(player_t *player) { UINT32 position; - boolean playing; - int fadein; if (!P_IsLocalPlayer(player)) // Only applies to a local player return; @@ -1271,25 +1269,10 @@ void P_RestoreMusic(player_t *player) else position = mapmusposition; - playing = S_MusicPlaying(); - - /* - So if the music isn't playing, it's - most likely because we were dead. - */ - if (! playing) - fadein = cv_respawnfademusicback.value; - - if (playing || ! fadein) - fadein = S_GetRestoreMusicFadeIn(); - - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, fadein); + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, + S_GetRestoreMusicFadeIn()); S_ClearRestoreMusicFadeInCvar(); mapmusresume = 0; - - /* mid-way fading out, fade back up */ - if (playing) - S_FadeMusic(100, cv_respawnfademusicback.value); } } } From dd1715aa15838493bef505df575d9943aabb84f1 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 17:23:40 -0800 Subject: [PATCH 25/43] Optionally only resync Invincibility and Grow music --- src/i_sound.h | 1 + src/p_user.c | 2 ++ src/s_sound.c | 22 ++++++++++++++++++++++ src/s_sound.h | 9 +++++++++ src/sdl/mixer_sound.c | 13 ++++++++++++- 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/i_sound.h b/src/i_sound.h index 422cfb8ff..93e3f6dd0 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -159,6 +159,7 @@ boolean I_SetSongPosition(UINT32 position); UINT32 I_GetSongPosition(void); void I_UpdateSongLagThreshold (void); +void I_UpdateSongLagConditions (void); /// ------------------------ // MUSIC PLAYBACK diff --git a/src/p_user.c b/src/p_user.c index 5fee0ac9b..6af902dc2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1248,12 +1248,14 @@ void P_RestoreMusic(player_t *player) if (wantedmus == 2) { S_ChangeMusicInternal("kgrow", true); + S_SetMusicUsage(MUS_SPECIAL); S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1) { S_ChangeMusicInternal("kinvnc", true); + S_SetMusicUsage(MUS_SPECIAL); S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else diff --git a/src/s_sound.c b/src/s_sound.c index 3cb5ef7fe..4e26a1d7b 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -130,6 +130,10 @@ consvar_t cv_music_resync_threshold = { "music_resync_threshold", "100", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold }; +consvar_t cv_music_resync_powerups_only = { + "music_resync_powerups_only", "No", CV_SAVE|CV_CALL, + CV_YesNo, I_UpdateSongLagConditions +}; #define S_MAX_VOLUME 127 @@ -295,6 +299,7 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_playsoundifunfocused); CV_RegisterVar(&cv_music_resync_threshold); + CV_RegisterVar(&cv_music_resync_powerups_only); COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); @@ -1564,6 +1569,7 @@ static void *music_data; static UINT16 music_flags; static boolean music_looping; static consvar_t *music_refade_cv; +static int music_usage; static char queue_name[7]; static UINT16 queue_flags; @@ -1949,6 +1955,7 @@ static void S_UnloadMusic(void) music_looping = false; music_refade_cv = 0; + music_usage = 0; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) @@ -1956,6 +1963,8 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) if (S_MusicDisabled()) return false; + I_UpdateSongLagConditions(); + if ((!fadeinms && !I_PlaySong(looping)) || (fadeinms && !I_FadeInPlaySong(fadeinms, looping))) { @@ -2188,6 +2197,19 @@ S_GetRestoreMusicFadeIn (void) return 0; } +void +S_SetMusicUsage (int type) +{ + music_usage = type; + I_UpdateSongLagConditions(); +} + +int +S_MusicUsage (void) +{ + return music_usage; +} + /// ------------------------ /// Music Fading /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index 8e94f8e16..5c173138e 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -37,6 +37,7 @@ extern consvar_t cv_playmusicifunfocused; extern consvar_t cv_playsoundifunfocused; extern consvar_t cv_music_resync_threshold; +extern consvar_t cv_music_resync_powerups_only; #ifdef SNDSERV extern consvar_t sndserver_cmd, sndserver_arg; @@ -178,6 +179,11 @@ UINT32 S_GetMusicPosition(void); // Music Playback // +enum +{ + MUS_SPECIAL = 1,/* powerups--invincibility, grow */ +}; + // Start music track, arbitrary, given its name, and set whether looping // note: music flags 12 bits for tracknum (gme, other formats with more than one track) // 13-15 aren't used yet @@ -191,6 +197,9 @@ void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); S_SetRestoreMusicFadeInCvar(0) int S_GetRestoreMusicFadeIn (void); +void S_SetMusicUsage (int type); +int S_MusicUsage (void); + // Stops the music. void S_StopMusic(void); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 52610575e..77fcc0914 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -80,6 +80,7 @@ write netcode into the sound code, OKAY? UINT8 sound_started = false; +static UINT32 stutter_threshold_user; static UINT32 stutter_threshold; static Mix_Music *music; @@ -942,7 +943,17 @@ UINT32 I_GetSongPosition(void) void I_UpdateSongLagThreshold (void) { - stutter_threshold = cv_music_resync_threshold.value/1000.0*(4*44100); + stutter_threshold_user = cv_music_resync_threshold.value/1000.0*(4*44100); + I_UpdateSongLagConditions(); +} + +void +I_UpdateSongLagConditions (void) +{ + if (! cv_music_resync_powerups_only.value || S_MusicUsage() == MUS_SPECIAL) + stutter_threshold = stutter_threshold_user; + else + stutter_threshold = 0; } /// ------------------------ From 7e0aa16e70d14a41e368143d8d13657665724d06 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 17:38:55 -0800 Subject: [PATCH 26/43] Reset Invincibility (and Grow) music to the start if stacked Toggleable via the resetspecialmusic cvar. --- src/d_netcmd.c | 2 ++ src/g_game.c | 2 ++ src/g_game.h | 2 ++ src/p_user.c | 6 ++---- src/s_sound.c | 9 +++++++++ src/s_sound.h | 2 ++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7b274d0a1..f5affa0d5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -991,6 +991,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_respawnfademusicout); CV_RegisterVar(&cv_respawnfademusicback); + CV_RegisterVar(&cv_resetspecialmusic); + CV_RegisterVar(&cv_resume); // ingame object placing diff --git a/src/g_game.c b/src/g_game.c index 0a62b27f9..b8bd6467a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -536,6 +536,8 @@ consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resetspecialmusic = {"resetspecialmusic", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 diff --git a/src/g_game.h b/src/g_game.h index 201db19d9..8dd9c2680 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,6 +124,8 @@ extern consvar_t cv_growmusicfade; extern consvar_t cv_respawnfademusicout; extern consvar_t cv_respawnfademusicback; +extern consvar_t cv_resetspecialmusic; + extern consvar_t cv_resume; typedef enum diff --git a/src/p_user.c b/src/p_user.c index 6af902dc2..8d32827f9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1247,15 +1247,13 @@ void P_RestoreMusic(player_t *player) // Item - Grow if (wantedmus == 2) { - S_ChangeMusicInternal("kgrow", true); - S_SetMusicUsage(MUS_SPECIAL); + S_ChangeMusicSpecial("kgrow"); S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1) { - S_ChangeMusicInternal("kinvnc", true); - S_SetMusicUsage(MUS_SPECIAL); + S_ChangeMusicSpecial("kinvnc"); S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else diff --git a/src/s_sound.c b/src/s_sound.c index 4e26a1d7b..1575788e3 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2075,6 +2075,15 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 } } +void +S_ChangeMusicSpecial (const char *mmusic) +{ + if (cv_resetspecialmusic.value) + S_ChangeMusic(mmusic, MUSIC_FORCERESET, true); + else + S_ChangeMusicInternal(mmusic, true); +} + void S_StopMusic(void) { if (!I_SongPlaying() diff --git a/src/s_sound.h b/src/s_sound.h index 5c173138e..0aa93c623 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -192,6 +192,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 #define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0) #define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) +void S_ChangeMusicSpecial (const char *mmusic); + void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); #define S_ClearRestoreMusicFadeInCvar() \ S_SetRestoreMusicFadeInCvar(0) From 5e671b3483dd82217332680b5dc5e096b51806eb Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 11 Mar 2020 19:39:06 -0700 Subject: [PATCH 27/43] Don't reset special music in P_RestoreMusic Because that resets Grow music when you stack Grow over Invincibility, and Invincibility ends. (Also Megamix Themes.) Thanks Snu, for calling P_RestoreMusic every tic! --- src/k_kart.c | 12 ++++++++---- src/p_user.c | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 29579ad50..674060f49 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7101,9 +7101,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetScale(overlay, player->mo->scale); } player->kartstuff[k_invincibilitytimer] = itemtime+(2*TICRATE); // 10 seconds + if (P_IsDisplayPlayer(player)) + S_ChangeMusicSpecial("kinvnc"); + else + S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kinvnc)); P_RestoreMusic(player); - if (!P_IsDisplayPlayer(player)) - S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc)); K_PlayPowerGloatSound(player->mo); player->kartstuff[k_itemamount]--; } @@ -7304,9 +7306,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (cv_kartdebugshrink.value && !modeattacking && !player->bot) player->mo->destscale = (6*player->mo->destscale)/8; player->kartstuff[k_growshrinktimer] = itemtime+(4*TICRATE); // 12 seconds - P_RestoreMusic(player); - if (!P_IsDisplayPlayer(player)) + if (P_IsDisplayPlayer(player)) + S_ChangeMusicSpecial("kgrow"); + else S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); + P_RestoreMusic(player); S_StartSound(player->mo, sfx_kc5a); } player->kartstuff[k_itemamount]--; diff --git a/src/p_user.c b/src/p_user.c index 8d32827f9..5fee0ac9b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1247,13 +1247,13 @@ void P_RestoreMusic(player_t *player) // Item - Grow if (wantedmus == 2) { - S_ChangeMusicSpecial("kgrow"); + S_ChangeMusicInternal("kgrow", true); S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1) { - S_ChangeMusicSpecial("kinvnc"); + S_ChangeMusicInternal("kinvnc", true); S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else From 6975de85b427ddabf583378bc1ce1e6d77d5ceaf Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 31 Mar 2020 16:45:36 -0700 Subject: [PATCH 28/43] Call the substitution macro FOREACH --- src/d_netcmd.c | 4 ++-- src/d_player.h | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 699678d8b..d1c598b04 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -398,9 +398,9 @@ consvar_t cv_kartusepwrlv = {"kartusepwrlv", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo static CV_PossibleValue_t kartdebugitem_cons_t[] = { -#define X( name, n ) { n, #name } +#define FOREACH( name, n ) { n, #name } KART_ITEM_ITERATOR, -#undef X +#undef FOREACH {0} }; consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/d_player.h b/src/d_player.h index 567f42ce5..18874b7b7 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -201,38 +201,38 @@ typedef enum } powertype_t; /* -To use: #define X( name, number ) +To use: #define FOREACH( name, number ) Do with it whatever you want. -Run this macro, then #undef X afterward +Run this macro, then #undef FOREACH afterward */ #define KART_ITEM_ITERATOR \ - X (SAD, -1),\ - X (NONE, 0),\ - X (SNEAKER, 1),\ - X (ROCKETSNEAKER, 2),\ - X (INVINCIBILITY, 3),\ - X (BANANA, 4),\ - X (EGGMAN, 5),\ - X (ORBINAUT, 6),\ - X (JAWZ, 7),\ - X (MINE, 8),\ - X (BALLHOG, 9),\ - X (SPB, 10),\ - X (GROW, 11),\ - X (SHRINK, 12),\ - X (THUNDERSHIELD, 13),\ - X (BUBBLESHIELD, 14),\ - X (FLAMESHIELD, 15),\ - X (HYUDORO, 16),\ - X (POGOSPRING, 17),\ - X (SUPERRING, 18),\ - X (KITCHENSINK, 19) + FOREACH (SAD, -1),\ + FOREACH (NONE, 0),\ + FOREACH (SNEAKER, 1),\ + FOREACH (ROCKETSNEAKER, 2),\ + FOREACH (INVINCIBILITY, 3),\ + FOREACH (BANANA, 4),\ + FOREACH (EGGMAN, 5),\ + FOREACH (ORBINAUT, 6),\ + FOREACH (JAWZ, 7),\ + FOREACH (MINE, 8),\ + FOREACH (BALLHOG, 9),\ + FOREACH (SPB, 10),\ + FOREACH (GROW, 11),\ + FOREACH (SHRINK, 12),\ + FOREACH (THUNDERSHIELD, 13),\ + FOREACH (BUBBLESHIELD, 14),\ + FOREACH (FLAMESHIELD, 15),\ + FOREACH (HYUDORO, 16),\ + FOREACH (POGOSPRING, 17),\ + FOREACH (SUPERRING, 18),\ + FOREACH (KITCHENSINK, 19) typedef enum { -#define X( name, n ) KITEM_ ## name = n +#define FOREACH( name, n ) KITEM_ ## name = n KART_ITEM_ITERATOR, -#undef X +#undef FOREACH NUMKARTITEMS, From c5a5d95a24240e41a1f21eee5aa555112e013230 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 31 Mar 2020 16:52:41 -0700 Subject: [PATCH 29/43] Use KART_ITEM_ITERATOR for the lua constants --- src/dehacked.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 60d61903a..2a5fa95aa 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9113,27 +9113,9 @@ struct { // SRB2Kart // kartitems_t - {"KITEM_SAD",KITEM_SAD}, // Actual items (can be set for k_itemtype) - {"KITEM_NONE",KITEM_NONE}, - {"KITEM_SNEAKER",KITEM_SNEAKER}, - {"KITEM_ROCKETSNEAKER",KITEM_ROCKETSNEAKER}, - {"KITEM_INVINCIBILITY",KITEM_INVINCIBILITY}, - {"KITEM_BANANA",KITEM_BANANA}, - {"KITEM_EGGMAN",KITEM_EGGMAN}, - {"KITEM_ORBINAUT",KITEM_ORBINAUT}, - {"KITEM_JAWZ",KITEM_JAWZ}, - {"KITEM_MINE",KITEM_MINE}, - {"KITEM_BALLHOG",KITEM_BALLHOG}, - {"KITEM_SPB",KITEM_SPB}, - {"KITEM_GROW",KITEM_GROW}, - {"KITEM_SHRINK",KITEM_SHRINK}, - {"KITEM_THUNDERSHIELD",KITEM_THUNDERSHIELD}, - {"KITEM_BUBBLESHIELD",KITEM_BUBBLESHIELD}, - {"KITEM_FLAMESHIELD",KITEM_FLAMESHIELD}, - {"KITEM_HYUDORO",KITEM_HYUDORO}, - {"KITEM_POGOSPRING",KITEM_POGOSPRING}, - {"KITEM_SUPERRING",KITEM_SUPERRING}, - {"KITEM_KITCHENSINK",KITEM_KITCHENSINK}, +#define FOREACH( name, n ) { #name, KITEM_ ## name } + KART_ITEM_ITERATOR, // Actual items (can be set for k_itemtype) +#undef FOREACH {"NUMKARTITEMS",NUMKARTITEMS}, {"KRITEM_TRIPLESNEAKER",KRITEM_TRIPLESNEAKER}, // Additional roulette IDs (not usable for much in Lua besides K_GetItemPatch) {"KRITEM_TRIPLEBANANA",KRITEM_TRIPLEBANANA}, From 9bdebe51bfe10e123460c56e8e1438e94f7c5677 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 31 Mar 2020 16:54:20 -0700 Subject: [PATCH 30/43] Fix a dumb warning --- src/d_netcmd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d1c598b04..132a993c7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -406,16 +406,13 @@ static CV_PossibleValue_t kartdebugitem_cons_t[] = consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartallowgiveitem = { - "kartallowgiveitem", - /* :mhm: */ +consvar_t cv_kartallowgiveitem = {"kartallowgiveitem", #ifdef DEVELOP "Yes", #else "No", #endif - CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, - CV_YesNo, + CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL }; consvar_t cv_kartdebugshrink = {"kartdebugshrink", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugdistribution = {"kartdebugdistribution", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; From 8490919257eb74851d809afdbf8bf52d9a0d51e1 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 19 Apr 2020 22:06:22 -0700 Subject: [PATCH 31/43] Bye death fades --- src/d_netcmd.c | 3 --- src/g_game.c | 29 ----------------------------- src/g_game.h | 3 --- src/p_inter.c | 18 ------------------ 4 files changed, 53 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1dea735cb..4f3319174 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -989,9 +989,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); - CV_RegisterVar(&cv_respawnfademusicout); - CV_RegisterVar(&cv_respawnfademusicback); - CV_RegisterVar(&cv_resetspecialmusic); CV_RegisterVar(&cv_resume); diff --git a/src/g_game.c b/src/g_game.c index 164000479..e15c3f2c0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -527,9 +527,6 @@ consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_con consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_resetspecialmusic = {"resetspecialmusic", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -2592,9 +2589,6 @@ void G_PlayerReborn(INT32 player) INT32 respawnflip; boolean songcredit = false; - boolean local; - boolean playing; - score = players[player].score; marescore = players[player].marescore; lives = players[player].lives; @@ -2754,31 +2748,8 @@ void G_PlayerReborn(INT32 player) } } - /* I'm putting this here because lol */ - - local = P_IsLocalPlayer(p); - - if (local) - { - playing = S_MusicPlaying(); - - /* - Fade it in with the same call to avoid - max volume for a few milliseconds (?). - */ - if (! playing) - S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); - } - P_RestoreMusic(p); - if (local) - { - /* mid-way fading out, fade back up */ - if (playing) - S_FadeMusic(100, cv_respawnfademusicback.value); - } - if (songcredit) S_ShowMusicCredit(); diff --git a/src/g_game.h b/src/g_game.h index 8dd9c2680..64847ef62 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -121,9 +121,6 @@ extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_gu extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; -extern consvar_t cv_respawnfademusicout; -extern consvar_t cv_respawnfademusicback; - extern consvar_t cv_resetspecialmusic; extern consvar_t cv_resume; diff --git a/src/p_inter.c b/src/p_inter.c index 5f09bdac3..e83315a12 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2117,7 +2117,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { mobjtype_t item; mobj_t *mo; - int ms; //if (inflictor && (inflictor->type == MT_SHELL || inflictor->type == MT_FIREBALL)) // P_SetTarget(&target->tracer, inflictor); @@ -2332,23 +2331,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; - if (P_IsLocalPlayer(target->player)) - { - if (netgame || multiplayer) - ms = cv_respawntime.value * 1000; - else - ms = 1000; - - /* - If the time spent with the music paused is less than half - a second, continue playing the song (just mute it). - */ - if (( ms - cv_respawnfademusicout.value ) < 500) - S_FadeMusic(0, cv_respawnfademusicout.value); - else - S_FadeOutStopMusic(cv_respawnfademusicout.value); - } - if (target->player == &players[consoleplayer]) { // don't die in auto map, From feceb97df0ea66e4d7317baaa0d889554fdafcef Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 19 Apr 2020 22:08:37 -0700 Subject: [PATCH 32/43] C90 moment --- src/s_sound.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 1575788e3..5391bf2ab 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -126,14 +126,9 @@ static CV_PossibleValue_t music_resync_threshold_cons_t[] = { {0} }; -consvar_t cv_music_resync_threshold = { - "music_resync_threshold", "100", CV_SAVE|CV_CALL, - music_resync_threshold_cons_t, I_UpdateSongLagThreshold -}; -consvar_t cv_music_resync_powerups_only = { - "music_resync_powerups_only", "No", CV_SAVE|CV_CALL, - CV_YesNo, I_UpdateSongLagConditions -}; +consvar_t cv_music_resync_threshold = {"music_resync_threshold", "100", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagConditions, 0, NULL, NULL, 0, 0, NULL}; #define S_MAX_VOLUME 127 From 652b7bbb9e52ad49b2f141fea27aa58aae1b7edc Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 30 Apr 2020 06:36:28 -0700 Subject: [PATCH 33/43] Retain drift on speed pads --- src/p_spec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index ad711fb8b..a62620d4b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4134,8 +4134,6 @@ DoneSection2: P_InstaThrust(player->mo, player->mo->angle, linespeed); player->kartstuff[k_dashpadcooldown] = TICRATE/3; - player->kartstuff[k_drift] = 0; - player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_pogospring] = 0; S_StartSound(player->mo, sfx_spdpad); From 01cdc1af49c779733f4ccfd2a0ed4d6ba2d0db27 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 30 Apr 2020 09:49:06 -0700 Subject: [PATCH 34/43] Also preserve player angle on speed pads --- src/p_spec.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index a62620d4b..1f3697db4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4096,25 +4096,11 @@ DoneSection2: lineangle = R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y); linespeed = P_AproxDistance(lines[i].v2->x-lines[i].v1->x, lines[i].v2->y-lines[i].v1->y); - player->mo->angle = lineangle; - // SRB2Kart: Scale the speed you get from them! // This is scaled differently from other horizontal speed boosts from stuff like springs, because of how this is used for some ramp jumps. if (player->mo->scale > mapobjectscale) linespeed = FixedMul(linespeed, mapobjectscale + (player->mo->scale - mapobjectscale)); - if (!demo.playback) - { - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - } - if (!(lines[i].flags & ML_EFFECT4)) { P_UnsetThingPosition(player->mo); @@ -4131,7 +4117,7 @@ DoneSection2: P_SetThingPosition(player->mo); } - P_InstaThrust(player->mo, player->mo->angle, linespeed); + P_InstaThrust(player->mo, lineangle, linespeed); player->kartstuff[k_dashpadcooldown] = TICRATE/3; player->kartstuff[k_pogospring] = 0; From e52d569c58eea64fb55d01c53e766a363ceb4944 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 30 Apr 2020 08:06:42 -0700 Subject: [PATCH 35/43] Use all your momentum to push back the camera --- src/p_user.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 5358df1fe..436890e33 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7168,6 +7168,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall UINT8 timeover; mobj_t *mo; fixed_t f1, f2; + fixed_t speed; #ifndef NOCLIPCAM boolean cameranoclip; subsector_t *newsubsec; @@ -7402,8 +7403,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // sets ideal cam pos dist = camdist; - if (player->speed > K_GetKartSpeed(player, false)) - dist += 4*(player->speed - K_GetKartSpeed(player, false)); + /* player->speed subtracts conveyors, janks up the camera */ + speed = R_PointToDist2(0, 0, player->mo->momx, player->mo->momy); + + if (speed > K_GetKartSpeed(player, false)) + dist += 4*(speed - K_GetKartSpeed(player, false)); dist += abs(thiscam->momz)/4; if (player->karthud[khud_boostcam]) From d4efbb710bde07ad05840818b29f96b3e414a1af Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 3 May 2020 19:45:59 -0400 Subject: [PATCH 36/43] Lost fix --- src/k_kart.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index 236bbd862..ee4a94efe 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4780,6 +4780,10 @@ void K_DropHnextList(player_t *player, boolean keepshields) orbit = false; type = MT_EGGMANITEM; break; + // intentionally do nothing + case MT_ROCKETSNEAKER: + case MT_SINK_SHIELD: + return; default: continue; } From c9b2396efb1adbfb798528f581840db76375715b Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 3 May 2020 20:12:01 -0400 Subject: [PATCH 37/43] Fix items vs springs crash --- src/k_collide.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/k_collide.c b/src/k_collide.c index f13ba3423..1921e3d38 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -15,6 +15,7 @@ boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2) { boolean damageitem = false; + boolean sprung = false; if (((t1->target == t2) || (t1->target == t2->target)) && (t1->threshold > 0 || (t2->type != MT_PLAYER && t2->threshold > 0))) return true; @@ -81,7 +82,7 @@ boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2) else if (t2->flags & MF_SPRING && (t1->type != MT_ORBINAUT_SHIELD && t1->type != MT_JAWZ_SHIELD)) { // Let thrown items hit springs! - P_DoSpring(t2, t1); + sprung = P_DoSpring(t2, t1); } else if (t2->flags & MF_SHOOTABLE) { @@ -105,6 +106,11 @@ boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2) P_InstaThrust(t1, R_PointToAngle2(t2->x, t2->y, t1->x, t1->y)+ANGLE_90, 16*FRACUNIT); } + if (sprung) + { + return false; + } + return true; } From 48ba151d980e7859565d84f1700278cd3b246735 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 3 May 2020 20:58:12 -0400 Subject: [PATCH 38/43] 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 39/43] 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 b9ff3403a966c3830ed84e9dc978ce5911fe3578 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 3 May 2020 21:32:12 -0400 Subject: [PATCH 40/43] Add missing netxcmdnames from james stuff --- src/d_netcmd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 83295b9a2..7def24de5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -544,6 +544,11 @@ const char *netxcmdnames[MAXNETXCMD - 1] = "PICKVOTE", "REMOVEPLAYER", "POWERLEVEL", + "PARTYINVITE", + "ACCEPTPARTYINVITE", + "LEAVEPARTY", + "CANCELPARTYINVITE", + "GIVEITEM", #ifdef HAVE_BLUA "LUACMD", "LUAVAR" From 77ddf635a5e0895354a10a3c7e7a6bc2fa9bff42 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 18 Dec 2019 15:34:55 -0800 Subject: [PATCH 41/43] 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 42/43] 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 43/43] -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)