allow jumps to frames >256
[swftools.git] / lib / as3 / abc.c
index c8e9636..edebba2 100644 (file)
@@ -345,7 +345,7 @@ static void dump_method(FILE*fo, const char*prefix,
         return_type = strdup("void");
 
     fprintf(fo, "%s", prefix);
-    fprintf(fo, "%s %s", attr, type);
+    fprintf(fo, "%s %s ", attr, type);
     fprintf(fo, "%s %s=%s", return_type, name, m->name);
     params_dump(fo, m->parameters, m->optional_parameters);
     fprintf(fo, "(%d params, %d optional)\n", list_length(m->parameters), list_length(m->optional_parameters));
@@ -720,8 +720,6 @@ void* swf_ReadABC(TAG*tag)
     }
 
     pool_read(pool, tag);
-    pool_dump(pool, stdout, 2);
-    printf("pool is %d bytes\n", tag->pos);
 
     int num_methods = swf_GetU30(tag);
     DEBUG printf("%d methods\n", num_methods);
@@ -877,7 +875,7 @@ void* swf_ReadABC(TAG*tag)
        array_append(file->method_bodies, NO_KEY, c);
     }
     if(tag->len - tag->pos) {
-       fprintf(stderr, "%d unparsed bytes remaining in ABC block\n", tag->len - tag->pos);
+       fprintf(stderr, "ERROR: %d unparsed bytes remaining in ABC block\n", tag->len - tag->pos);
        return 0;
     }
 
@@ -1197,12 +1195,15 @@ void swf_WriteABC(TAG*abctag, void*code)
 {
     pool_t*pool = writeABC(abctag, code, 0);
     pool_optimize(pool);
+    swf_ResetTag(abctag, abctag->id);
     writeABC(abctag, code, pool);
     pool_destroy(pool);
 }
 
 void abc_file_free(abc_file_t*file)
 {
+    if(!file)
+        return;
     int t;
     if(file->metadata) {
         for(t=0;t<file->metadata->num;t++) {
@@ -1422,12 +1423,9 @@ void swf_AddButtonLinks(SWF*swf, char stop_each_frame, char events)
                 ActionTAG*oldaction = swf_ButtonGetAction(tag);
                 if(oldaction && oldaction->op == ACTION__GOTOFRAME) {
                     int framenr = GET16(oldaction->data);
-                    if(framenr>254) {
-                        fprintf(stderr, "Warning: Couldn't translate jump to frame %d to flash 9 actionscript\n", framenr);
-                    }
                     if(!events) {
                         __ findpropstrict(h,"[package]::gotoAndStop");
-                        __ pushbyte(h,framenr+1);
+                        __ pushuint(h,framenr+1);
                         __ callpropvoid(h,"[package]::gotoAndStop", 1);
                     } else {
                         char framename[80];