From 931de846aee3566e38ff8e84c1188454b36da0dc Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 9 Mar 2012 00:23:22 +0000 Subject: [PATCH] Ignore \an and \a tags with out of bounds values rather than doing odd things Originally committed to SVN as r6551. --- aegisub/src/visual_tool.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index 88866b36f..790c82f0c 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -420,19 +420,21 @@ Vector2D VisualToolBase::GetLinePosition(AssDialogue *diag) { } param_vec align_tag; + int ovr_align = 0; if ((align_tag = find_tag(diag, "\\an")) && !(*align_tag)[0]->omitted) - align = (*align_tag)[0]->Get(); + ovr_align = (*align_tag)[0]->Get(); else if ((align_tag = find_tag(diag, "\\a"))) { - align = (*align_tag)[0]->Get(2); + ovr_align = (*align_tag)[0]->Get(2); // \a -> \an values mapping - static int align_mapping[] = { 2, 1, 2, 3, 7, 7, 8, 9, 7, 4, 5, 6 }; - if (static_cast(align) < sizeof(align_mapping) / sizeof(int)) - align = align_mapping[align]; - else - align = 2; + static int align_mapping[] = { 0, 1, 2, 3, 7, 7, 8, 9, 7, 4, 5, 6 }; + if (static_cast(ovr_align) < sizeof(align_mapping) / sizeof(int)) + ovr_align = align_mapping[ovr_align]; } + if (ovr_align > 0 && ovr_align <= 9) + align = ovr_align; + // Alignment type int hor = (align - 1) % 3; int vert = (align - 1) / 3;