Renaming Script Contexts
- Determined how the various script contexts were used and renamed accordingly. - ScriptContext2_Enable/Disable => Lock/UnlockPlayerFieldControls - The sole purpose of the flag is to make sure the player can't move around in the overworld. It has nothing to do with script contexts. - ScriptContext1 => ScriptContext - It is the global script context used to set up scripts which run over many frames. - ScriptContext2_RunNewScript => RunScriptImmediately - ScriptContext2's sole purpose was to run scripts immediately and in a separate context, usually while the global context is waiting for things like map loads or screen changes.
This commit is contained in:
+34
-34
@@ -360,7 +360,7 @@ static void (*const sMovementStatusHandler[])(struct LinkPlayerObjectEvent *, st
|
||||
// code
|
||||
void DoWhiteOut(void)
|
||||
{
|
||||
ScriptContext2_RunNewScript(EventScript_WhiteOut);
|
||||
RunScriptImmediately(EventScript_WhiteOut);
|
||||
SetMoney(&gSaveBlock1Ptr->money, GetMoney(&gSaveBlock1Ptr->money) / 2);
|
||||
HealPlayerParty();
|
||||
Overworld_ResetStateAfterWhiteOut();
|
||||
@@ -386,7 +386,7 @@ void Overworld_ResetStateAfterTeleport(void)
|
||||
FlagClear(FLAG_SYS_SAFARI_MODE);
|
||||
FlagClear(FLAG_SYS_USE_STRENGTH);
|
||||
FlagClear(FLAG_SYS_USE_FLASH);
|
||||
ScriptContext2_RunNewScript(EventScript_ResetMrBriney);
|
||||
RunScriptImmediately(EventScript_ResetMrBriney);
|
||||
}
|
||||
|
||||
void Overworld_ResetStateAfterDigEscRope(void)
|
||||
@@ -1432,11 +1432,11 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
|
||||
UpdatePlayerAvatarTransitionState();
|
||||
FieldClearPlayerInput(&inputStruct);
|
||||
FieldGetPlayerInput(&inputStruct, newKeys, heldKeys);
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
if (ProcessPlayerFieldInput(&inputStruct) == 1)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
HideMapNamePopUpWindow();
|
||||
}
|
||||
else
|
||||
@@ -1454,7 +1454,7 @@ void CB1_Overworld(void)
|
||||
|
||||
static void OverworldBasic(void)
|
||||
{
|
||||
ScriptContext2_RunScript();
|
||||
ScriptContext_RunScript();
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
CameraUpdate();
|
||||
@@ -1527,8 +1527,8 @@ void CB2_NewGame(void)
|
||||
NewGameInitData();
|
||||
ResetInitialPlayerAvatarState();
|
||||
PlayTimeCounter_Start();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
gFieldCallback = ExecuteTruckSequence;
|
||||
gFieldCallback2 = NULL;
|
||||
DoMapLoadLoop(&gMain.state);
|
||||
@@ -1548,8 +1548,8 @@ void CB2_WhiteOut(void)
|
||||
ResetSafariZoneFlag_();
|
||||
DoWhiteOut();
|
||||
ResetInitialPlayerAvatarState();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_WarpExitFadeFromBlack;
|
||||
state = 0;
|
||||
DoMapLoadLoop(&state);
|
||||
@@ -1562,8 +1562,8 @@ void CB2_WhiteOut(void)
|
||||
void CB2_LoadMap(void)
|
||||
{
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
SetMainCallback2(CB2_DoChangeMap);
|
||||
gMain.savedCallback = CB2_LoadMap2;
|
||||
@@ -1582,8 +1582,8 @@ void CB2_ReturnToFieldContestHall(void)
|
||||
if (!gMain.state)
|
||||
{
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
}
|
||||
if (LoadMapInStepsLocal(&gMain.state, TRUE))
|
||||
@@ -1652,8 +1652,8 @@ void CB2_ReturnToFieldFromMultiplayer(void)
|
||||
else
|
||||
gFieldCallback = FieldCB_ReturnToFieldCableLink;
|
||||
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
CB2_ReturnToField();
|
||||
}
|
||||
|
||||
@@ -1723,8 +1723,8 @@ void CB2_ContinueSavedGame(void)
|
||||
InitMapFromSavedGame();
|
||||
|
||||
PlayTimeCounter_Start();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
InitMatchCallCounters();
|
||||
if (UseContinueGameWarp() == TRUE)
|
||||
{
|
||||
@@ -1803,8 +1803,8 @@ static bool32 LoadMapInStepsLink(u8 *state)
|
||||
{
|
||||
case 0:
|
||||
InitOverworldBgs();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
ResetMirageTowerAndSaveBlockPtrs();
|
||||
ResetScreenForMapLoad();
|
||||
(*state)++;
|
||||
@@ -2505,7 +2505,7 @@ static void ResetPlayerHeldKeys(u16 *keys)
|
||||
|
||||
static u16 KeyInterCB_SelfIdle(u32 key)
|
||||
{
|
||||
if (ScriptContext2_IsEnabled() == TRUE)
|
||||
if (ArePlayerFieldControlsLocked() == TRUE)
|
||||
return LINK_KEY_CODE_EMPTY;
|
||||
if (GetLinkRecvQueueLength() > 4)
|
||||
return LINK_KEY_CODE_HANDLE_RECV_QUEUE;
|
||||
@@ -2525,7 +2525,7 @@ static u16 KeyInterCB_Idle(u32 key)
|
||||
static u16 KeyInterCB_DeferToEventScript(u32 key)
|
||||
{
|
||||
u16 retVal;
|
||||
if (ScriptContext2_IsEnabled() == TRUE)
|
||||
if (ArePlayerFieldControlsLocked() == TRUE)
|
||||
{
|
||||
retVal = LINK_KEY_CODE_EMPTY;
|
||||
}
|
||||
@@ -2548,7 +2548,7 @@ static u16 KeyInterCB_DeferToRecvQueue(u32 key)
|
||||
else
|
||||
{
|
||||
retVal = LINK_KEY_CODE_IDLE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
SetKeyInterceptCallback(KeyInterCB_Idle);
|
||||
}
|
||||
return retVal;
|
||||
@@ -2565,7 +2565,7 @@ static u16 KeyInterCB_DeferToSendQueue(u32 key)
|
||||
else
|
||||
{
|
||||
retVal = LINK_KEY_CODE_IDLE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
SetKeyInterceptCallback(KeyInterCB_Idle);
|
||||
}
|
||||
return retVal;
|
||||
@@ -2618,7 +2618,7 @@ static u16 KeyInterCB_WaitForPlayersToExit(u32 keyOrPlayerId)
|
||||
CheckRfuKeepAliveTimer();
|
||||
if (AreAllPlayersInLinkState(PLAYER_LINK_STATE_EXITING_ROOM) == TRUE)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_DoLinkRoomExit);
|
||||
ScriptContext_SetupScript(EventScript_DoLinkRoomExit);
|
||||
SetKeyInterceptCallback(KeyInterCB_SendNothing);
|
||||
}
|
||||
return LINK_KEY_CODE_EMPTY;
|
||||
@@ -2797,41 +2797,41 @@ static u16 GetDirectionForEventScript(const u8 *script)
|
||||
|
||||
static void InitLinkPlayerQueueScript(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void InitLinkRoomStartMenuScript(void)
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void RunInteractLocalPlayerScript(const u8 *script)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(script);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void RunConfirmLeaveCableClubScript(void)
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ScriptContext1_SetupScript(EventScript_ConfirmLeaveCableClubRoom);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_ConfirmLeaveCableClubRoom);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void InitMenuBasedScript(const u8 *script)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(script);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void RunTerminateLinkScript(void)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_TerminateLink);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_TerminateLink);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
bool32 Overworld_IsRecvQueueAtMax(void)
|
||||
|
||||
Reference in New Issue
Block a user