Fix backwards-compatibilty break in the lua karaoke parser

Insert an empty syllable at the beginning of the karaoke syllable table
to better mimick 2.1.x's behavior.

Originally committed to SVN as r6369.
This commit is contained in:
Thomas Goyne 2012-01-26 21:19:25 +00:00
parent 0aec0a9d59
commit d55f1622f1

View file

@ -635,6 +635,19 @@ namespace Automation4 {
luaL_argcheck(L, dia, 1, "Subtitle line must be a dialogue line"); luaL_argcheck(L, dia, 1, "Subtitle line must be a dialogue line");
int idx = 0; int idx = 0;
// 2.1.x stored everything before the first syllable at index zero
// There's no longer any such thing with the new parser, but scripts
// may rely on kara[0] existing so add an empty syllable
lua_newtable(L);
set_field(L, "duration", 0);
set_field(L, "start_time", dia->Start);
set_field(L, "end_time", dia->Start);
set_field(L, "tag", "");
set_field(L, "text", "");
set_field(L, "text_stripped", "");
lua_rawseti(L, -2, idx++);
AssKaraoke kara(dia); AssKaraoke kara(dia);
for (AssKaraoke::iterator it = kara.begin(); it != kara.end(); ++it) { for (AssKaraoke::iterator it = kara.begin(); it != kara.end(); ++it) {
lua_newtable(L); lua_newtable(L);