win32 compile fixes
[swftools.git] / lib / modules / swftools.c
index fd27d1b..83f8c6a 100644 (file)
@@ -118,6 +118,7 @@ U16 swf_GetDefineID(TAG * t)
     case ST_DEFINEFONTINFO: //pseudodefine
     case ST_DEFINEFONTINFO2: //pseudodefine
     case ST_DEFINEFONTALIGNZONES: //pseudodefine
+    case ST_DEFINEFONTNAME: //pseudodefine
     case ST_DEFINETEXT:
     case ST_DEFINETEXT2:
     case ST_DEFINESOUND:
@@ -155,6 +156,7 @@ SRECT swf_GetDefineBBox(TAG * t)
   { case ST_DEFINESHAPE:
     case ST_DEFINESHAPE2:
     case ST_DEFINESHAPE3:
+    case ST_DEFINESHAPE4:
     case ST_DEFINEEDITTEXT:
     case ST_DEFINETEXT:
     case ST_DEFINETEXT2:
@@ -240,6 +242,7 @@ static int swf_definingtagids[] =
  ST_DEFINEBUTTON2,
  ST_DEFINESOUND,
  ST_DEFINEVIDEOSTREAM,
+ ST_DEFINEBINARY,
  -1
 };
 
@@ -252,6 +255,7 @@ static int swf_spritetagids[] =
  ST_REMOVEOBJECT,
  ST_REMOVEOBJECT2,
  ST_DOACTION,
+ ST_DOABC,
  ST_STARTSOUND,
  ST_FRAMELABEL,
  ST_SOUNDSTREAMHEAD,
@@ -267,6 +271,7 @@ static int swf_pseudodefiningtagids[] =
  ST_DEFINEFONTINFO,
  ST_DEFINEFONTINFO2,
  ST_DEFINEFONTALIGNZONES,
+ ST_DEFINEFONTNAME,
  ST_DEFINEBUTTONCXFORM,
  ST_DEFINEBUTTONSOUND,
  ST_DEFINESCALINGGRID,
@@ -383,7 +388,7 @@ char* swf_GetName(TAG * t)
     switch(swf_GetTagID(t))
     {
         case ST_FRAMELABEL:
-            name = &t->data[swf_GetTagPos(t)];
+            name = (char*)&t->data[swf_GetTagPos(t)];
         break;
         case ST_PLACEOBJECT3:
         case ST_PLACEOBJECT2: {   
@@ -403,7 +408,7 @@ char* swf_GetName(TAG * t)
               swf_GetU16(t);
             if(flags&PF_NAME) {
               swf_ResetReadBits(t);
-              name = &t->data[swf_GetTagPos(t)];
+              name = (char*)&t->data[swf_GetTagPos(t)];
             }
         }
         break;
@@ -422,13 +427,13 @@ void swf_GetMorphGradient(TAG * tag, GRADIENT * gradient1, GRADIENT * gradient2)
     
     if(gradient1) {
        gradient1->num = num;
-       gradient1->rgba = rfx_calloc(sizeof(RGBA)*gradient1->num);
-       gradient1->ratios = rfx_calloc(sizeof(gradient1->ratios[0])*gradient1->num);
+       gradient1->rgba = (RGBA*)rfx_calloc(sizeof(RGBA)*gradient1->num);
+       gradient1->ratios = (U8*)rfx_calloc(sizeof(gradient1->ratios[0])*gradient1->num);
     }
     if(gradient2) {
        gradient2->num = num;
-       gradient2->rgba = rfx_calloc(sizeof(RGBA)*gradient2->num);
-       gradient2->ratios = rfx_calloc(sizeof(gradient2->ratios[0])*gradient2->num);
+       gradient2->rgba = (RGBA*)rfx_calloc(sizeof(RGBA)*gradient2->num);
+       gradient2->ratios = (U8*)rfx_calloc(sizeof(gradient2->ratios[0])*gradient2->num);
     }
     for(t=0;t<num;t++)
     {
@@ -466,7 +471,6 @@ void enumerateUsedIDs_styles(TAG * tag, void (*callback)(TAG*, int, void*), void
     for(t=0;t<count;t++)
     {
        int type;
-       U8*pos;
        type = swf_GetU8(tag); //type
        DEBUG_ENUMERATE printf("fill style %d) %02x (tagpos=%d)\n", t, type, tag->pos);
        if(type == 0) {
@@ -603,6 +607,8 @@ void enumerateUsedIDs(TAG * tag, int base, void (*callback)(TAG*, int, void*), v
 
        case ST_FREECHARACTER: /* unusual tags, which all start with an ID */
        case ST_NAMECHARACTER:
+       case ST_DEFINEBINARY:
+       case ST_DEFINEFONTNAME:
        case ST_GENERATORTEXT:
            callback(tag, tag->pos + base, callback_data);
         break;
@@ -645,7 +651,7 @@ void enumerateUsedIDs(TAG * tag, int base, void (*callback)(TAG*, int, void*), v
                if(id == ST_END)
                    break;
                tag2->len = tag2->memsize = len;
-               tag2->data = rfx_alloc(len);
+               tag2->data = (U8*)rfx_alloc(len);
                memcpy(tag2->data, &tag->data[tag->pos], len);
                /* I never saw recursive sprites, but they are (theoretically) 
                   possible, so better add base here again */
@@ -668,7 +674,6 @@ void enumerateUsedIDs(TAG * tag, int base, void (*callback)(TAG*, int, void*), v
            }
            while(1)
            {
-               U16 charid;
                if(!swf_GetU8(tag)) //flags
                    break; 
                callback(tag, tag->pos + base, callback_data);
@@ -953,7 +958,7 @@ void swf_Relocate (SWF*swf, char*bitmap)
        
        num = swf_GetNumUsedIDs(tag);
        if(num) {
-           ptr = rfx_alloc(sizeof(int)*num);
+           ptr = (int*)rfx_alloc(sizeof(int)*num);
            swf_GetUsedIDs(tag, ptr);
 
            for(t=0;t<num;t++) {
@@ -961,10 +966,10 @@ void swf_Relocate (SWF*swf, char*bitmap)
                if(slaveids[id]<0) {
                    fprintf(stderr, "swf_Relocate: Mapping id (%d) never encountered before in %s\n", id,
                            swf_TagGetName(tag));
-                   return ;
+               } else {
+                   id = slaveids[id];
+                   PUT16(&tag->data[ptr[t]], id);
                }
-               id = slaveids[id];
-               PUT16(&tag->data[ptr[t]], id);
            }
        }
        tag=tag->next;
@@ -988,7 +993,7 @@ void swf_Relocate2(SWF*swf, int*id2id)
        if(num) {
            int *ptr;
            int t;
-           ptr = rfx_alloc(sizeof(int)*num);
+           ptr = (int*)rfx_alloc(sizeof(int)*num);
            swf_GetUsedIDs(tag, ptr);
            for(t=0;t<num;t++) {
                int id = GET16(&tag->data[ptr[t]]);
@@ -1154,10 +1159,10 @@ static int tagHash(TAG*tag)
 void swf_Optimize(SWF*swf)
 {
     const int hash_size = 131072;
-    char* dontremap = rfx_calloc(sizeof(char)*65536);
-    U16* remap = rfx_alloc(sizeof(U16)*65536);
-    TAG* id2tag = rfx_calloc(sizeof(TAG*)*65536);
-    TAG** hashmap = rfx_calloc(sizeof(TAG*)*hash_size);
+    char* dontremap = (char*)rfx_calloc(sizeof(char)*65536);
+    U16* remap = (U16*)rfx_alloc(sizeof(U16)*65536);
+    TAG* id2tag = (TAG*)rfx_calloc(sizeof(TAG*)*65536);
+    TAG** hashmap = (TAG**)rfx_calloc(sizeof(TAG*)*hash_size);
     TAG* tag;
     int t;
     for(t=0;t<65536;t++) {
@@ -1185,7 +1190,7 @@ void swf_Optimize(SWF*swf)
 
         /* remap the tag */
         int num = swf_GetNumUsedIDs(tag);
-        int*positions = rfx_alloc(sizeof(int)*num);
+        int*positions = (int*)rfx_alloc(sizeof(int)*num);
         int t;
         swf_GetUsedIDs(tag, positions);
         for(t=0;t<num;t++) {
@@ -1266,7 +1271,7 @@ void swf_SetDefineBBox(TAG * tag, SRECT newbbox)
              swf_ResetReadBits(tag);
              after_bbox_offset = tag->pos;
              len = tag->len - after_bbox_offset;
-             data = malloc(len);
+             data = (U8*)malloc(len);
              memcpy(data, &tag->data[after_bbox_offset], len);
              tag->writeBit = 0;
              tag->len = 2;