From 2caa5ff01856a925c4a4385b8a2b40c1a8a536dc Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 12 Apr 2024 14:17:33 +0100 Subject: [PATCH] Dedicated server -spoilers startup parameter Servers should get enough free for a healthy launch ecosystem, but not everything. We'll give the relevant password out after, like, the first week probably? Please be patient, commit-diver --- src/d_clisrv.c | 3 +-- src/d_main.cpp | 15 ++++++++++- src/g_game.c | 40 +++++++++++++-------------- src/m_cond.c | 73 +++++++++++++++++++++++++++++++++++++++++--------- src/m_cond.h | 1 + 5 files changed, 97 insertions(+), 35 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a784102ce..586e88d61 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3382,8 +3382,7 @@ void SV_ResetServer(void) // Copy our unlocks to a place where net material can grab at/overwrite them safely. // (permits all unlocks in dedicated) - for (i = 0; i < MAXUNLOCKABLES; i++) - netUnlocked[i] = (dedicated || gamedata->unlocked[i]); + M_SetNetUnlocked(); expectChallenge = false; diff --git a/src/d_main.cpp b/src/d_main.cpp index 3b139029b..5130cca6f 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1538,6 +1538,19 @@ void D_SRB2Main(void) // for dedicated server dedicated = M_CheckParm("-dedicated") != 0; + if (dedicated) + { + p = M_CheckParm("-spoilers"); + if (p && M_IsNextParm()) + { + usedTourney = M_TryExactPassword(M_GetNextParm(), "XpsOixVTZSW0cwbiYAVgzokAmWfeYNq5mEckVsktheq4GOUWQecF5lWTkGNBJtoYX9vUMprFzraSovOSCeQ96Q=="); + + if (usedTourney) + { + CONS_Printf(M_GetText("Spoiler mode ON.\n")); + } + } + } if (devparm) CONS_Printf(M_GetText("Development mode ON.\n")); @@ -1932,7 +1945,7 @@ void D_SRB2Main(void) } { - if (!M_CheckParm("-server") && !M_CheckParm("-dedicated")) + if (!M_CheckParm("-server") && !dedicated) { G_SetUsedCheats(); diff --git a/src/g_game.c b/src/g_game.c index 8b509fd67..9b6950359 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3640,12 +3640,12 @@ static INT32 TOLMaps(UINT8 pgametype) // Not completed continue; } + } - if (M_MapLocked(i + 1) == true) - { - // We haven't earned this one. - continue; - } + if (M_MapLocked(i + 1) == true) + { + // We haven't earned this one. + continue; } num++; @@ -3753,12 +3753,12 @@ tryAgain: // Not completed continue; } + } - if (M_MapLocked(i + 1) == true) - { - // We haven't earned this one. - continue; - } + if (M_MapLocked(i + 1) == true) + { + // We haven't earned this one. + continue; } if (ignoreBuffers == false) @@ -4331,12 +4331,12 @@ void G_GetNextMap(void) // Not completed continue; } + } - if (M_MapLocked(cm + 1) == true) - { - // We haven't earned this one. - continue; - } + if (M_MapLocked(cm + 1) == true) + { + // We haven't earned this one. + continue; } // If the map is in multiple cups, only consider the first one valid. @@ -4416,12 +4416,12 @@ void G_GetNextMap(void) // Not completed continue; } + } - if (M_MapLocked(cm + 1) == true) - { - // We haven't earned this one. - continue; - } + if (M_MapLocked(cm + 1) == true) + { + // We haven't earned this one. + continue; } break; diff --git a/src/m_cond.c b/src/m_cond.c index cfe396886..fe095be8c 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -734,8 +734,7 @@ void M_ClearSecrets(void) memset(gamedata->collected, 0, sizeof(gamedata->collected)); memset(gamedata->unlocked, 0, sizeof(gamedata->unlocked)); memset(gamedata->unlockpending, 0, sizeof(gamedata->unlockpending)); - if (!dedicated) - memset(netUnlocked, 0, sizeof(netUnlocked)); + memset(netUnlocked, 0, sizeof(netUnlocked)); memset(gamedata->achieved, 0, sizeof(gamedata->achieved)); Z_Free(gamedata->spraycans); @@ -1281,6 +1280,66 @@ void M_FinaliseGameData(void) M_UpdateUnlockablesAndExtraEmblems(false, true); } +void M_SetNetUnlocked(void) +{ + UINT16 i; + + // Use your gamedata as baseline + for (i = 0; i < MAXUNLOCKABLES; i++) + { + netUnlocked[i] = gamedata->unlocked[i]; + } + + if (!dedicated) + { + return; + } + + // Dedicated spoiler password - tournament mode equivalent. + if (usedTourney) + { + for (i = 0; i < MAXUNLOCKABLES; i++) + { + if (unlockables[i].conditionset == 55) + continue; + + netUnlocked[i] = true; + } + + return; + } + + // Okay, now it's dedicated first-week spoilerless behaviour. + for (i = 0; i < MAXUNLOCKABLES; i++) + { + if (netUnlocked[i]) + continue; + + switch (unlockables[i].type) + { + case SECRET_CUP: + { + // Give the first seven Cups for free. + cupheader_t *cup = M_UnlockableCup(&unlockables[i]); + if (cup && cup->id < 7) + netUnlocked[i] = true; + + break; + } + case SECRET_ADDONS: + { + netUnlocked[i] = true; + break; + } + default: + { + // Most stuff isn't given to dedis for free + break; + } + } + } +} + // ---------------------- // Condition set checking // ---------------------- @@ -3404,11 +3463,6 @@ boolean M_SecretUnlocked(INT32 type, boolean local) boolean M_CupLocked(cupheader_t *cup) { - // Don't lock maps in dedicated servers. - // That just makes hosts' lives hell. - if (dedicated) - return false; - // No skipping over any part of your marathon. if (marathonmode) return false; @@ -3464,11 +3518,6 @@ boolean M_CupSecondRowLocked(void) boolean M_MapLocked(UINT16 mapnum) { - // Don't lock maps in dedicated servers. - // That just makes hosts' lives hell. - if (dedicated) - return false; - // No skipping over any part of your marathon. if (marathonmode) return false; diff --git a/src/m_cond.h b/src/m_cond.h index b23d267f1..d0881ae3b 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -443,6 +443,7 @@ void M_ClearConditionSet(UINT16 set); void M_ClearSecrets(void); void M_ClearStats(void); void M_FinaliseGameData(void); +void M_SetNetUnlocked(void); boolean M_NotFreePlay(void); UINT16 M_CheckCupEmeralds(UINT8 difficulty);