"Intelligently" append dialogue lines to the end of the Events section instead of to the absolute end of file. This will make appending lines slower if attachments are present, but much safer. Updates #1211.

Originally committed to SVN as r4598.
This commit is contained in:
Niels Martin Hansen 2010-06-24 20:48:49 +00:00
parent 6b36d730af
commit 4f0982c7d5

View file

@ -776,7 +776,17 @@ namespace Automation4 {
for (int i = 1; i <= n; i++) {
lua_pushvalue(L, i);
AssEntry *e = LuaToAssEntry(L);
laf->ass->Line.push_back(e);
if (e->GetType() == ENTRY_DIALOGUE) {
// find insertion point, looking backwards
std::list<AssEntry*>::iterator it = laf->ass->Line.end();
do { --it; } while ((*it)->GetType() != ENTRY_DIALOGUE);
// found last dialogue entry in file, move one past
++it;
laf->ass->Line.insert(it, e);
}
else {
laf->ass->Line.push_back(e);
}
}
return 0;