From 6274acfe5fccb70f5f6f001899fcc0905b03fbd1 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 8 Mar 2021 14:32:20 -0500 Subject: [PATCH] Fix out of bounds access for fighting anims --- src/battle_anim_fight.c | 52 +++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/battle_anim_fight.c b/src/battle_anim_fight.c index 05138111bb..328f178ae1 100644 --- a/src/battle_anim_fight.c +++ b/src/battle_anim_fight.c @@ -51,51 +51,43 @@ const struct SpriteTemplate gUnusedSpriteTemplate_08595E14 = .callback = AnimUnused_080B08A0, }; -static const union AnimCmd sAnim_HandOrFoot[] = +static const union AnimCmd sAnim_Fist[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd sAnim_SlidingKick_0[] = +static const union AnimCmd sAnim_FootWide[] = { ANIMCMD_FRAME(16, 1), ANIMCMD_END, }; -static const union AnimCmd sAnim_SlidingKick_1[] = +static const union AnimCmd sAnim_FootTall[] = { ANIMCMD_FRAME(32, 1), ANIMCMD_END, }; -static const union AnimCmd sAnim_CrossChopHand_0[] = +static const union AnimCmd sAnim_HandLeft[] = { ANIMCMD_FRAME(48, 1), ANIMCMD_END, }; -static const union AnimCmd sAnim_CrossChopHand_1[] = +static const union AnimCmd sAnim_HandRight[] = { ANIMCMD_FRAME(48, 1, .hFlip = TRUE), ANIMCMD_END, }; -static const union AnimCmd *const sAnims_HandOrFoot[] = +static const union AnimCmd *const sAnims_HandsAndFeet[] = { - sAnim_HandOrFoot, -}; - -static const union AnimCmd *const sAnims_SlidingKick[] = -{ - sAnim_SlidingKick_0, - sAnim_SlidingKick_1, -}; - -static const union AnimCmd *const sAnims_CrossChopHand[] = -{ - sAnim_CrossChopHand_0, - sAnim_CrossChopHand_1, + sAnim_Fist, + sAnim_FootWide, + sAnim_FootTall, + sAnim_HandLeft, + sAnim_HandRight, }; const struct SpriteTemplate gKarateChopSpriteTemplate = @@ -103,7 +95,7 @@ const struct SpriteTemplate gKarateChopSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_HandOrFoot, + .anims = sAnims_HandsAndFeet, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimSlideHandOrFootToTarget, @@ -114,7 +106,7 @@ const struct SpriteTemplate gJumpKickSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_HandOrFoot, + .anims = sAnims_HandsAndFeet, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimJumpKick, @@ -125,7 +117,7 @@ const struct SpriteTemplate gFistFootSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_HandOrFoot, + .anims = sAnims_HandsAndFeet, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimBasicFistOrFoot, @@ -136,7 +128,7 @@ const struct SpriteTemplate gFistFootRandomPosSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_HandOrFoot, + .anims = sAnims_HandsAndFeet, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimFistOrFootRandomPos, @@ -147,7 +139,7 @@ const struct SpriteTemplate gCrossChopHandSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_CrossChopHand, + .anims = &sAnims_HandsAndFeet[3], .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimCrossChopHand, @@ -158,7 +150,7 @@ const struct SpriteTemplate gSlidingKickSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_SlidingKick, + .anims = &sAnims_HandsAndFeet[1], .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimSlidingKick, @@ -182,7 +174,7 @@ const struct SpriteTemplate gSpinningHandOrFootSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineDouble_ObjNormal_32x32, - .anims = sAnims_HandOrFoot, + .anims = sAnims_HandsAndFeet, .images = NULL, .affineAnims = sAffineAnims_SpinningHandOrFoot, .callback = AnimSpinningKickOrPunch, @@ -205,7 +197,7 @@ const struct SpriteTemplate gMegaPunchKickSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineDouble_ObjNormal_32x32, - .anims = sAnims_HandOrFoot, + .anims = sAnims_HandsAndFeet, .images = NULL, .affineAnims = sAffineAnims_MegaPunchKick, .callback = AnimSpinningKickOrPunch, @@ -216,7 +208,7 @@ const struct SpriteTemplate gStompFootSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_SlidingKick, + .anims = &sAnims_HandsAndFeet[1], .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimStompFoot, @@ -307,7 +299,7 @@ const struct SpriteTemplate gArmThrustHandSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_HandOrFoot, + .anims = sAnims_HandsAndFeet, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimArmThrustHit, @@ -411,7 +403,7 @@ const struct SpriteTemplate gFocusPunchFistSpriteTemplate = .tileTag = ANIM_TAG_HANDS_AND_FEET, .paletteTag = ANIM_TAG_HANDS_AND_FEET, .oam = &gOamData_AffineDouble_ObjNormal_32x32, - .anims = sAnims_HandOrFoot, + .anims = sAnims_HandsAndFeet, .images = NULL, .affineAnims = sAffineAnims_FocusPunchFist, .callback = AnimFocusPunchFist,