aboutsummaryrefslogtreecommitdiff
path: root/games/wargus
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2022-02-08 02:44:05 -0500
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2022-02-09 09:35:14 +0700
commit8793f23fa472b137632e86724d318a4f221f25aa (patch)
tree2e30b677d58dce35a1221eb9694afb64a619ed43 /games/wargus
parent27fa2f508dd47169df7d77a30b2dadcf0e0c2c1d (diff)
games/wargus: Add missing diff.
Signed-off-by: B. Watson <yalhcru@gmail.com> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'games/wargus')
-rw-r--r--games/wargus/wartool.ffmpeg.diff129
1 files changed, 129 insertions, 0 deletions
diff --git a/games/wargus/wartool.ffmpeg.diff b/games/wargus/wartool.ffmpeg.diff
new file mode 100644
index 000000000000..19e1edcb868b
--- /dev/null
+++ b/games/wargus/wartool.ffmpeg.diff
@@ -0,0 +1,129 @@
+diff -Naur wargus-2.4.1/wartool.cpp wargus-2.4.1.patched/wartool.cpp
+--- wargus-2.4.1/wartool.cpp 2016-11-08 10:26:25.000000000 -0500
++++ wargus-2.4.1.patched/wartool.cpp 2021-11-19 15:04:56.300380502 -0500
+@@ -1901,25 +1901,27 @@
+ int ConvertMusic(void)
+ {
+ struct stat st;
+- char buf[1024];
++ char buf[8192] = {'\0'};
+ char *cmd;
++ int cmdlen;
+ int ret, i;
+ int count = 0;
+
+ for ( i = 0; MusicNames[i]; ++i ) {
+- sprintf(buf, "%s/%s/%s.wav", Dir, MUSIC_PATH, MusicNames[i]);
++ snprintf(buf, 4095, "%s/%s/%s.wav", Dir, MUSIC_PATH, MusicNames[i]);
+ CheckPath(buf);
+
+ if (stat(buf, &st))
+ continue;
+
+- cmd = (char*) calloc(strlen("ffmpeg2theora --optimize \"") + strlen(buf) + strlen("\" -o \"") + strlen(buf) + strlen("\"") + 1, 1);
++ cmdlen = strlen("ffmpeg -y -i \"") + strlen(buf) + strlen("\" \"") + strlen(buf) + strlen("\" ");
++ cmd = (char*) calloc(cmdlen + 1, 1);
+ if (!cmd) {
+ fprintf(stderr, "Memory error\n");
+ exit(-1);
+ }
+
+- sprintf(cmd, "ffmpeg2theora --optimize \"%s\" -o \"%s/%s/%s.ogg\"", buf, Dir, MUSIC_PATH, MusicNames[i]);
++ snprintf(cmd, cmdlen, "ffmpeg -y -i \"%s\" \"%s/%s/%s.ogg\"", buf, Dir, MUSIC_PATH, MusicNames[i]);
+
+ ret = system(cmd);
+
+@@ -1927,7 +1929,7 @@
+ remove(buf);
+
+ if (ret != 0) {
+- printf("Can't convert wav sound %s to ogv format. Is ffmpeg2theora installed in PATH?\n", MusicNames[i]);
++ printf("Can't convert wav sound %s to ogg format. Is ffmpeg installed in PATH?\n", MusicNames[i]);
+ fflush(stdout);
+ }
+
+@@ -1941,13 +1943,14 @@
+ if (stat(buf, &st))
+ continue;
+
+- cmd = (char*) calloc(strlen("ffmpeg2theora --optimize \"") + strlen(buf) + strlen("\" -o \"") + strlen(buf) + strlen("\"") + 1, 1);
++ cmdlen = strlen("ffmpeg -y -i \"") + strlen(buf) + strlen("\" \"") + strlen(buf) + strlen("\" ");
++ cmd = (char*) calloc(cmdlen + 1, 1);
+ if (!cmd) {
+ fprintf(stderr, "Memory error\n");
+ exit(-1);
+ }
+
+- sprintf(cmd, "ffmpeg2theora --optimize \"%s\" -o \"%s/%s/%s.ogg\"", buf, Dir, MUSIC_PATH, BNEMusicNames[i]);
++ snprintf(cmd, cmdlen, "ffmpeg -y -i \"%s\" \"%s/%s/%s.ogg\"", buf, Dir, MUSIC_PATH, BNEMusicNames[i]);
+
+ ret = system(cmd);
+
+@@ -1955,7 +1958,7 @@
+ remove(buf);
+
+ if (ret != 0) {
+- printf("Can't convert wav sound %s to ogv format. Is ffmpeg2theora installed in PATH?\n", BNEMusicNames[i]);
++ printf("Can't convert wav sound %s to ogg format. Is ffmpeg installed in PATH?\n", BNEMusicNames[i]);
+ fflush(stdout);
+ }
+
+@@ -1979,13 +1982,15 @@
+ int ConvertVideo(const char* file, int video, bool justconvert = false)
+ {
+ unsigned char* vidp;
+- char buf[1024];
++ char buf[8192] = {'\0'};
+ char* cmd;
+ FILE* f;
+ size_t l;
+ int ret;
++ int cmdlen;
++ char outputfile[8192] = {'\0'};
+
+- sprintf(buf,"%s/%s.smk", Dir, file);
++ snprintf(buf,4095,"%s/%s.smk", Dir, file);
+ CheckPath(buf);
+ if (justconvert == false) {
+ vidp = ExtractEntry(ArchiveOffsets[video], &l);
+@@ -2005,21 +2010,36 @@
+ fclose(f);
+ }
+
+- cmd = (char*) calloc(strlen("ffmpeg2theora --optimize \"") + strlen(buf) + strlen("\" -o \"") + strlen(buf) + strlen("\"") + 1, 1);
++ if (CDType & CD_BNE) {
++ cmdlen = strlen("ffmpeg -y -i \"") + strlen(buf) + strlen("\" -codec:v libtheora -qscale:v 31 -codec:a libvorbis -qscale:a 15 -pix_fmt yuv420p -aspect 4:3 -vf scale=640x0,setsar=1:1 \"") + strlen(buf) + strlen("\" ");
++ } else {
++ cmdlen = strlen("ffmpeg -y -i \"") + strlen(buf) + strlen("\" -codec:v libtheora -qscale:v 31 -codec:a libvorbis -qscale:a 15 -pix_fmt yuv420p \"") + strlen(buf) + strlen("\" ");
++ }
++ cmd = (char*) calloc(cmdlen + 1, 1);
+ if (!cmd) {
+ fprintf(stderr, "Memory error\n");
+ exit(-1);
+ }
+
+- sprintf(cmd, "ffmpeg2theora --optimize \"%s/%s.smk\" -o \"%s/%s.ogv\"", Dir, file, Dir, file);
+-
++ if (CDType & CD_BNE) {
++ snprintf(cmd, cmdlen, "ffmpeg -y -i \"%s/%s.smk\" -codec:v libtheora -qscale:v 31 -codec:a libvorbis -qscale:a 15 -pix_fmt yuv420p -aspect 4:3 -vf scale=640:0,setsar=1:1 \"%s/%s.ogv\"", Dir, file, Dir, file);
++ } else {
++ snprintf(cmd, cmdlen, "ffmpeg -y -i \"%s/%s.smk\" -codec:v libtheora -qscale:v 31 -codec:a libvorbis -qscale:a 15 -pix_fmt yuv420p \"%s/%s.ogv\"", Dir, file, Dir, file);
++ }
++ printf("%s\n", cmd);
+ ret = system(cmd);
+
+ free(cmd);
+ remove(buf);
+
+ if (ret != 0) {
+- printf("Can't convert video %s to ogv format. Is ffmpeg2theora installed in PATH?\n", file);
++ sprintf(outputfile, "%s/%s.ogv", Dir, file);
++#ifdef WIN32
++ _unlink(outputfile);
++#else
++ unlink(outputfile);
++#endif
++ printf("Can't convert video %s to ogv format. Is ffmpeg installed in PATH?\n", file);
+ fflush(stdout);
+ return ret;
+ }