alpha conversion fix.
[swftools.git] / src / swfc.c
index 25e047d..bdb631a 100644 (file)
@@ -20,7 +20,7 @@
 #include "../lib/rfxswf.h"
 #include "../lib/log.h"
 #include "../lib/args.h"
-#include "q.h"
+#include "../lib/q.h"
 #include "parser.h"
 #include "wav.h"
 
@@ -441,7 +441,7 @@ static void s_endSWF()
        swf->movieSize.ymax += 20;
     }
 
-    fi = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+    fi = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
     if(fi<0) {
        syntaxerror("couldn't create output file %s", filename);
     }
@@ -619,7 +619,7 @@ void s_font(char*name, char*filename)
     int f;
     SWF swf;
     SWFFONT* font;
-    f = open(filename,O_RDONLY);
+    f = open(filename,O_RDONLY|O_BINARY);
     if (f<0) { 
        warning("Couldn't open file \"%s\": %s", filename, strerror(errno));
        font = (SWFFONT*)malloc(sizeof(SWFFONT));
@@ -712,7 +712,7 @@ void s_playsound(char*name, int loops, int nomultiple, int stop)
     memset(&info, 0, sizeof(info));
     info.stop = stop;
     info.loops = loops;
-    info.multiple = !nomultiple;
+    info.nomultiple = nomultiple;
     swf_SetSoundInfo(tag, &info);
 }
 
@@ -1051,11 +1051,18 @@ int parseInt(char*str)
 }
 int parseTwip(char*str)
 {
-    char*dot = strchr(str, '.');
+    char*dot;
+    int sign=1;
+    if(str[0]=='+' || str[0]=='-') {
+       if(str[0]=='-')
+           sign = -1;
+       str++;
+    }
+    dot = strchr(str, '.');
     if(!dot) {
        int l=strlen(str);
        int t;
-       return parseInt(str)*20;
+       return sign*parseInt(str)*20;
     } else {
        int l=strlen(++dot);
        char*s;
@@ -1072,11 +1079,11 @@ int parseTwip(char*str)
            l=2;
        }
        if(l==0)
-           return atoi(str)*20;
+           return sign*atoi(str)*20;
        if(l==1)
-           return atoi(str)*20+atoi(dot)*2;
+           return sign*atoi(str)*20+atoi(dot)*2;
        if(l==2)
-           return atoi(str)*20+atoi(dot)/5;
+           return sign*atoi(str)*20+atoi(dot)/5;
     }
     return 0;
 }
@@ -1332,8 +1339,13 @@ static int c_play(map_t*args)
     char*name = lu(args, "sound");
     char*loop = lu(args, "loop");
     char*nomultiple = lu(args, "nomultiple");
+    int nm = 0;
+    if(!strcmp(nomultiple, "nomultiple"))
+       nm = 1;
+    else
+       nm = parseInt(nomultiple);
 
-    s_playsound(name, parseInt(loop), parseInt(nomultiple), 0);
+    s_playsound(name, parseInt(loop), nm, 0);
     return 0;
 }