summaryrefslogtreecommitdiff
path: root/mm/2s2h/Enhancements/Restorations/DayTelopDuration.cpp
blob: 024924a73779727650a7a7f1259b37aadcf3ed35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <libultraship/bridge/consolevariablebridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/ShipInit.hpp"

extern "C" {
#include "variables.h"
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
}

#define CVAR_NAME "gEnhancements.Restorations.DayTelopDuration"
#define CVAR CVarGetInteger(CVAR_NAME, 0)

void RegisterDayTelopDurationRestoration() {
    COND_HOOK(OnGameStateMainStart, CVAR, []() {
        if (gGameState == nullptr || gGameState->destroy != DayTelop_Destroy) {
            return;
        }

        // Only add frames the first time the DayTelop state is detected
        if (gGameState->frames != 1) {
            return;
        }

        DayTelopState* dayTelop = reinterpret_cast<DayTelopState*>(gGameState);
        dayTelop->transitionCountdown += 120;
    });
}

static RegisterShipInitFunc initFunc(RegisterDayTelopDurationRestoration, { CVAR_NAME });