Skip to content

Commit d174607

Browse files
committed
RuntimeFlags: Refactored some bits that came up in code review
1 parent abba49e commit d174607

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

src/game_interpreter.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ void Game_Interpreter::Update(bool reset_loop_count) {
384384

385385
#ifdef ENABLE_DYNAMIC_INTERPRETER_CONFIG
386386
Player::active_interpreter_flags = &_state.easyrpg_runtime_flags;
387+
auto flags_guard = lcf::makeScopeGuard([]() {
388+
Player::active_interpreter_flags = nullptr;
389+
});
387390
#endif
388391

389392
for (; loop_count < loop_limit; ++loop_count) {
@@ -530,9 +533,6 @@ void Game_Interpreter::Update(bool reset_loop_count) {
530533
if (Game_Map::GetNeedRefresh()) {
531534
Game_Map::Refresh();
532535
}
533-
#ifdef ENABLE_DYNAMIC_INTERPRETER_CONFIG
534-
Player::active_interpreter_flags = nullptr;
535-
#endif
536536
}
537537

538538
// Setup Starting Event
@@ -838,7 +838,9 @@ bool Game_Interpreter::OnFinishStackFrame() {
838838

839839
if (is_base_frame) {
840840
#ifdef ENABLE_DYNAMIC_INTERPRETER_CONFIG
841-
ClearStateRuntimeFlags();
841+
// Individual runtime flags that may still be set will be cleared by
842+
// CommandEasyRpgSetInterpreterFlag if neccessary
843+
_state.easyrpg_runtime_flags.conf_override_active = false;
842844
#endif
843845
}
844846

@@ -5394,6 +5396,11 @@ bool Game_Interpreter::CommandEasyRpgSetInterpreterFlag(lcf::rpg::EventCommand c
53945396
}
53955397
}
53965398

5399+
// Clear any inactive flags that might be left over from a previous InterpreterFlag command
5400+
if (!_state.easyrpg_runtime_flags.conf_override_active) {
5401+
_state.easyrpg_runtime_flags.flags.fill(false);
5402+
}
5403+
53975404
switch (flag_id) {
53985405
case 1:
53995406
if (flag_value) {

src/game_interpreter.h

-11
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,6 @@ class Game_Interpreter : public Game_BaseInterpreterContext
347347

348348
int ManiacBitmask(int value, int mask) const;
349349

350-
#ifdef ENABLE_DYNAMIC_INTERPRETER_CONFIG
351-
void ClearStateRuntimeFlags();
352-
#endif
353-
354350
lcf::rpg::SaveEventExecState _state;
355351
KeyInputState _keyinput;
356352
AsyncOp _async_op = {};
@@ -405,11 +401,4 @@ inline AsyncOp Game_Interpreter::GetAsyncOp() const {
405401
return _async_op;
406402
}
407403

408-
#ifdef ENABLE_DYNAMIC_INTERPRETER_CONFIG
409-
inline void Game_Interpreter::ClearStateRuntimeFlags() {
410-
_state.easyrpg_runtime_flags.conf_override_active = false;
411-
_state.easyrpg_runtime_flags.flags.fill(false);
412-
}
413-
#endif
414-
415404
#endif

src/game_interpreter_shared.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace Game_Interpreter_Shared {
109109
bool ManiacCheckContinueLoop(int val, int val2, int type, int op);
110110

111111
#ifdef ENABLE_DYNAMIC_INTERPRETER_CONFIG
112-
typedef bool lcf::rpg::SaveEventExecState::EasyRpgStateRuntime_Flags::* StateRuntimeFlagRef;
112+
using StateRuntimeFlagRef = bool lcf::rpg::SaveEventExecState::EasyRpgStateRuntime_Flags::*;
113113

114114
std::optional<bool> GetRuntimeFlag(lcf::rpg::SaveEventExecState const& state, StateRuntimeFlagRef const field_on, StateRuntimeFlagRef const field_off);
115115

src/window_interpreter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace {
4444
struct RuntimeFlagInfo {
4545
bool (*config_fn)();
4646
Game_Interpreter_Shared::StateRuntimeFlagRef field_on, field_off;
47-
char* name;
47+
std::string_view name;
4848
};
4949

5050
using StateFlags = lcf::rpg::SaveEventExecState::EasyRpgStateRuntime_Flags;

0 commit comments

Comments
 (0)