From: chaoskagami Date: Mon, 25 Aug 2014 01:01:27 +0000 (-0400) Subject: Implemented voice-stopping on quoted lines. X-Git-Tag: stable-2~11 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=0f3efb8103769cd3bf19ffefbca226f3d02151db;p=vn%2Fvndc.git Implemented voice-stopping on quoted lines. --- diff --git a/.gitignore b/.gitignore index 83b2d3b..de6a576 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ *.ttf # Prevent binary & lib dirs. -./bin/ +./bin/* diff --git a/bin/vndc.x86_64 b/bin/vndc.x86_64 index abae162..3523bfb 100755 Binary files a/bin/vndc.x86_64 and b/bin/vndc.x86_64 differ diff --git a/vndc/src/op_sound.cpp b/vndc/src/op_sound.cpp index f6bd313..e219cac 100644 --- a/vndc/src/op_sound.cpp +++ b/vndc/src/op_sound.cpp @@ -18,27 +18,40 @@ void op_sound(char* file, int* times) { GetData()->ctx->Audio()->FlushSfx(); return; } - // Play command - else { - int count = 1; - if (times != NULL) - count = *times; + // Extension - Voiced auto-stop. If the next line contains quotes, + // it is voiced. We set a flag in response. If the flag is already + // set - e.g. the sound was a voice as well, we stop the previous + // sound before playing this one. + + if(GetData()->vndc_enabled && + (GetData()->next_line[6] == '"' || + GetData()->next_line[strlen(GetData()->next_line) - 1] == '"')) { + if(GetData()->is_spoken_line == true) { + GetData()->ctx->Audio()->FlushSfx(); + } + GetData()->is_spoken_line = true; + } + else + GetData()->is_spoken_line = false; + - char path[400]; - memset(path, 0, 400); + // Play command + int count = 1; + if (times != NULL) + count = *times; - snprintf(path, 400, "sound/%s", file); + char path[400]; + memset(path, 0, 400); - //printf("[op_sound] path: '%s'\n", path); + snprintf(path, 400, "sound/%s", file); - // Load displayable. - int sfxi = GetData()->ctx->Audio()->LoadSfx(path); + // Load sfx. + int sfxi = GetData()->ctx->Audio()->LoadSfx(path); - if (count == -1) { - GetData()->ctx->Audio()->PlaySfx(sfxi, count); - } - else { - GetData()->ctx->Audio()->PlaySfx(sfxi, count-1); - } + if (count == -1) { + GetData()->ctx->Audio()->PlaySfx(sfxi, count); + } + else { + GetData()->ctx->Audio()->PlaySfx(sfxi, count-1); } }