Merge pull request #1689 from GriffinRichards/task-ub

Remove UBFIX related to task destruction
This commit is contained in:
GriffinR 2022-06-21 16:33:17 -04:00 committed by GitHub
commit c2a08cc84d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 15 deletions

View File

@ -135,10 +135,12 @@ void SoundTask_PlayCryHighPitch(u8 taskId)
{
if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->moveAnim->species;
#ifndef UBFIX
// Destroying the task twice (here and at end of function)
// results in an incorrect value for gAnimVisualTaskCount
#ifndef BUGFIX
else
DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice.
#endif
DestroyAnimVisualTask(taskId);
#endif
}
else
{
@ -181,10 +183,12 @@ void SoundTask_PlayDoubleCry(u8 taskId)
{
if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->moveAnim->species;
#ifndef UBFIX
// Destroying the task twice (here and at end of function)
// results in an incorrect value for gAnimVisualTaskCount
#ifndef BUGFIX
else
DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice.
#endif
DestroyAnimVisualTask(taskId);
#endif
}
else
{

View File

@ -4220,17 +4220,12 @@ static void Task_OpenMonPic(u8 taskId)
return;
break;
default:
#ifndef UBFIX
DestroyTask(taskId);
#endif
// UB: Should not use the task after it has been deleted.
// Accessing data of destroyed task. Task data isn't reset until a new task needs that task id.
if (gTasks[taskId].tIsSwapScreen == TRUE)
Swap_CreateMonSprite();
else
Select_CreateMonSprite();
#ifdef UBFIX
DestroyTask(taskId);
#endif
return;
}
task->tState++;

View File

@ -4762,10 +4762,8 @@ static bool8 FrontierSquaresScroll_End(struct Task *task)
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
DestroyTask(FindTaskIdByFunc(task->func));
task->tState++; // Changing value of a destroyed task
#ifndef UBFIX
task->tState++; // UB: changing value of a destroyed task
#endif
return FALSE;
}