Skip to content

Commit fbd85ca

Browse files
committed
game: Fix GlobalContext pause flag definition
1 parent 25fb7b3 commit fbd85ca

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

source/common/flags.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ namespace rst {
1212
template <typename FlagType, typename = typename std::enable_if_t<std::is_enum_v<FlagType>, void>>
1313
class Flags {
1414
public:
15+
constexpr auto& operator=(FlagType v) {
16+
flags = std::underlying_type_t<FlagType>(v);
17+
return *this;
18+
}
1519
constexpr void Set(FlagType v) { flags |= std::underlying_type_t<FlagType>(v); }
1620
constexpr void Clear(FlagType v) { flags &= ~std::underlying_type_t<FlagType>(v); }
1721

source/game/context.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ namespace ui {
2222
class PlayHud;
2323
}
2424

25-
// based on a quick experiment - probably wrong
26-
enum class UiMenuState : u16 {
27-
Closed = 0,
28-
Opening = 1,
29-
Opened = 3,
25+
enum class PauseFlag : u16 {
26+
PauseCalc = 1 << 0,
27+
PauseDraw = 1 << 1,
28+
PauseAll = PauseCalc | PauseDraw,
3029
};
3130

3231
// Keeps track of spawned actors.
@@ -148,7 +147,7 @@ static_assert(sizeof(HudState) == 0x280);
148147

149148
// Likely incomplete.
150149
struct GlobalContext : State {
151-
bool IsUiMenuActive() const { return ui_menu_state != game::UiMenuState::Closed; }
150+
bool IsPaused() const { return pause_flags.IsOneSet(PauseFlag::PauseCalc, PauseFlag::PauseDraw); }
152151

153152
act::Actor* FindActorWithId(act::Id id, act::Type type) const;
154153
template <typename T>
@@ -191,7 +190,7 @@ struct GlobalContext : State {
191190
u8 gap_A7C[12];
192191
u32 field_A88;
193192
u8 gap_A8C[32];
194-
UiMenuState ui_menu_state;
193+
rst::Flags<PauseFlag> pause_flags;
195194
u32 field_AB0;
196195
u8 gap_AB4[76];
197196
int field_B00;
@@ -349,7 +348,7 @@ struct GlobalContext : State {
349348
u8 gap_F0F4[7996];
350349
};
351350
static_assert(rst::util::OffsetOf(&GlobalContext::main_camera) == 0x408);
352-
static_assert(rst::util::OffsetOf(&GlobalContext::ui_menu_state) == 0xAAC);
351+
static_assert(rst::util::OffsetOf(&GlobalContext::pause_flags) == 0xAAC);
353352
static_assert(rst::util::OffsetOf(&GlobalContext::elegy_statues) == 0x2394);
354353
static_assert(rst::util::OffsetOf(&GlobalContext::field_C000) == 0xc000);
355354
static_assert(rst::util::OffsetOf(&GlobalContext::ocarina_state) == 0x8366);

source/game/ui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool OpenScreen(ScreenType screen) {
4545
return false;
4646

4747
ui_ctx.new_screen = GetScreen(screen);
48-
gctx->ui_menu_state = UiMenuState::Opening;
48+
gctx->pause_flags = PauseFlag::PauseCalc;
4949
gctx->enable_letterbox = false;
5050

5151
if (GetStaticContext().field_D38) {

source/rst/link.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void Calc() {
261261
game::act::Player* player = gctx->GetPlayerActor();
262262
if (!player)
263263
return;
264-
if (gctx->IsUiMenuActive())
264+
if (gctx->IsPaused())
265265
return;
266266

267267
if (player->controller_info.state) {

0 commit comments

Comments
 (0)