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) if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->moveAnim->species; 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 else
DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice. DestroyAnimVisualTask(taskId);
#endif #endif
} }
else else
{ {
@ -181,10 +183,12 @@ void SoundTask_PlayDoubleCry(u8 taskId)
{ {
if (gBattleAnimArgs[0] == ANIM_ATTACKER) if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->moveAnim->species; 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 else
DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice. DestroyAnimVisualTask(taskId);
#endif #endif
} }
else else
{ {

View File

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

View File

@ -4762,10 +4762,8 @@ static bool8 FrontierSquaresScroll_End(struct Task *task)
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
DestroyTask(FindTaskIdByFunc(task->func)); 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; return FALSE;
} }