Skip to content

Commit

Permalink
Restore lock/lockall/locktrainer/release/releaseall in triggers (rh-h…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgriffin authored Jan 15, 2025
1 parent 7c6c912 commit ed0c9a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
8 changes: 4 additions & 4 deletions include/script.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef GUARD_SCRIPT_H
#define GUARD_SCRIPT_H

#include <setjmp.h>

struct ScriptContext;

typedef bool8 (*ScrCmdFunc)(struct ScriptContext *);
Expand Down Expand Up @@ -107,9 +105,11 @@ enum // effects
SCREFF_TRAINERBATTLE = 1 << 2, // 'trainerbattle' command.
};

#define SCREFF_ANY (SCREFF_SAVE | SCREFF_HARDWARE | SCREFF_TRAINERBATTLE)

enum // effects versions
{
SCREFF_V1 = ~7,
SCREFF_V1 = 0xFFFFFFF8,
};

extern struct ScriptEffectContext *gScriptEffectContext;
Expand Down Expand Up @@ -140,7 +140,7 @@ static inline bool32 Script_IsAnalyzingEffects(void)
_Static_assert((effects) & 0x80000000, "Script_RequestEffects requires an effects version"); \
if ((effects) != SCREFF_V1) \
if (Script_IsAnalyzingEffects()) \
Script_RequestEffects_Internal(effects); \
Script_RequestEffects_Internal((effects) & SCREFF_ANY); \
})

/* Optimize 'Script_RequestWriteVar' to a no-op if it would have no
Expand Down
15 changes: 0 additions & 15 deletions src/scrcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,6 @@ bool8 ScrCmd_turnvobject(struct ScriptContext *ctx)
// The player is frozen after waiting for their current movement to finish.
bool8 ScrCmd_lockall(struct ScriptContext *ctx)
{
// As a special case, skip this during analysis.
if (Script_IsAnalyzingEffects())
return FALSE;
Script_RequestEffects(SCREFF_V1 | SCREFF_HARDWARE);

if (IsOverworldLinkActive())
Expand All @@ -1548,9 +1545,6 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx)
// The player and selected object are frozen after waiting for their current movement to finish.
bool8 ScrCmd_lock(struct ScriptContext *ctx)
{
// As a special case, skip this during analysis.
if (Script_IsAnalyzingEffects())
return FALSE;
Script_RequestEffects(SCREFF_V1 | SCREFF_HARDWARE);

if (IsOverworldLinkActive())
Expand Down Expand Up @@ -1581,9 +1575,6 @@ bool8 ScrCmd_lock(struct ScriptContext *ctx)

bool8 ScrCmd_releaseall(struct ScriptContext *ctx)
{
// As a special case, skip this during analysis.
if (Script_IsAnalyzingEffects())
return FALSE;
Script_RequestEffects(SCREFF_V1 | SCREFF_HARDWARE);

u8 playerObjectId;
Expand All @@ -1603,9 +1594,6 @@ bool8 ScrCmd_releaseall(struct ScriptContext *ctx)

bool8 ScrCmd_release(struct ScriptContext *ctx)
{
// As a special case, skip this during analysis.
if (Script_IsAnalyzingEffects())
return FALSE;
Script_RequestEffects(SCREFF_V1 | SCREFF_HARDWARE);

u8 playerObjectId;
Expand Down Expand Up @@ -2858,9 +2846,6 @@ bool8 ScrCmd_selectapproachingtrainer(struct ScriptContext *ctx)

bool8 ScrCmd_lockfortrainer(struct ScriptContext *ctx)
{
// As a special case, skip this during analysis.
if (Script_IsAnalyzingEffects())
return FALSE;
Script_RequestEffects(SCREFF_V1 | SCREFF_HARDWARE);

if (IsOverworldLinkActive())
Expand Down

0 comments on commit ed0c9a4

Please sign in to comment.