Ignore \an and \a tags with out of bounds values rather than doing odd things

Originally committed to SVN as r6551.
This commit is contained in:
Thomas Goyne 2012-03-09 00:23:22 +00:00
parent eea914fa48
commit 931de846ae

View file

@ -420,19 +420,21 @@ Vector2D VisualToolBase::GetLinePosition(AssDialogue *diag) {
} }
param_vec align_tag; param_vec align_tag;
int ovr_align = 0;
if ((align_tag = find_tag(diag, "\\an")) && !(*align_tag)[0]->omitted) if ((align_tag = find_tag(diag, "\\an")) && !(*align_tag)[0]->omitted)
align = (*align_tag)[0]->Get<int>(); ovr_align = (*align_tag)[0]->Get<int>();
else if ((align_tag = find_tag(diag, "\\a"))) { else if ((align_tag = find_tag(diag, "\\a"))) {
align = (*align_tag)[0]->Get<int>(2); ovr_align = (*align_tag)[0]->Get<int>(2);
// \a -> \an values mapping // \a -> \an values mapping
static int align_mapping[] = { 2, 1, 2, 3, 7, 7, 8, 9, 7, 4, 5, 6 }; static int align_mapping[] = { 0, 1, 2, 3, 7, 7, 8, 9, 7, 4, 5, 6 };
if (static_cast<size_t>(align) < sizeof(align_mapping) / sizeof(int)) if (static_cast<size_t>(ovr_align) < sizeof(align_mapping) / sizeof(int))
align = align_mapping[align]; ovr_align = align_mapping[ovr_align];
else
align = 2;
} }
if (ovr_align > 0 && ovr_align <= 9)
align = ovr_align;
// Alignment type // Alignment type
int hor = (align - 1) % 3; int hor = (align - 1) % 3;
int vert = (align - 1) / 3; int vert = (align - 1) / 3;