X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfc.c;h=f2224a16ad9a496569cec9c17f55c4bddfb4a453;hb=fe03062883881dcd0e1b8d65d676433d17973477;hp=14d5f9a90ce360a91859a7e5844913475f0ad271;hpb=32bce7795076522c72a9c7f5720a6774f5f8223c;p=swftools.git diff --git a/src/swfc.c b/src/swfc.c index 14d5f9a..f2224a1 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -816,7 +816,8 @@ TAG* removeFromTo(TAG*from, TAG*to) TAG*save = from->prev; while(from!=to) { TAG*next = from->next; - swf_DeleteTag(from); + if(swf_isAllowedSpriteTag(from)) + swf_DeleteTag(from); from = next; } save->next = 0; @@ -953,9 +954,6 @@ static void s_endSprite() { SRECT r = currentrect; - if(stack[stackpos].cut) - tag = removeFromTo(stack[stackpos].cut, tag); - stackpos--; instance_t *i; stringarray_t* index =dictionary_index(&instances); @@ -969,6 +967,12 @@ static void s_endSprite() writeInstance(i); } } + + if(stack[stackpos].cut) + tag = removeFromTo(stack[stackpos].cut, tag); + + // the writeInstance loop above may have inserted tags after what used yo be the current tag, + // so let's make sure 'tag' point to the current tag again. while (tag->next) tag = tag->next; @@ -1028,6 +1032,11 @@ static void s_endSWF() swf = stack[stackpos].swf; filename = stack[stackpos].filename; + // the writeInstance loop above may have inserted tags after what used yo be the current tag, + // so let's make sure 'tag' point to the current tag again. + while (tag->next) + tag = tag->next; + //if(tag->prev && tag->prev->id != ST_SHOWFRAME) // tag = swf_InsertTag(tag, ST_SHOWFRAME); tag = swf_InsertTag(tag, ST_SHOWFRAME); @@ -1549,10 +1558,12 @@ void s_font(char*name, char*filename) swf_FontReduce_swfc(font); tag = swf_InsertTag(tag, ST_DEFINEFONT2); swf_FontSetDefine2(tag, font); - tag = swf_InsertTag(tag, ST_EXPORTASSETS); - swf_SetU16(tag, 1); - swf_SetU16(tag, id); - swf_SetString(tag, name); + if(do_exports) { + tag = swf_InsertTag(tag, ST_EXPORTASSETS); + swf_SetU16(tag, 1); + swf_SetU16(tag, id); + swf_SetString(tag, name); + } incrementid(); } @@ -1634,13 +1645,15 @@ void s_sound(char*name, char*filename) else swf_SetSoundDefine(tag, samples, numsamples); - tag = swf_InsertTag(tag, ST_NAMECHARACTER); - swf_SetU16(tag, id); - swf_SetString(tag, name); - tag = swf_InsertTag(tag, ST_EXPORTASSETS); - swf_SetU16(tag, 1); - swf_SetU16(tag, id); - swf_SetString(tag, name); + if(do_exports) { + tag = swf_InsertTag(tag, ST_NAMECHARACTER); + swf_SetU16(tag, id); + swf_SetString(tag, name); + tag = swf_InsertTag(tag, ST_EXPORTASSETS); + swf_SetU16(tag, 1); + swf_SetU16(tag, id); + swf_SetString(tag, name); + } sound = (sound_t*)malloc(sizeof(sound_t)); /* mem leak */ sound->tag = tag; @@ -2123,7 +2136,7 @@ void s_endClip() swf_SetTagPos(stack[stackpos].tag, 0); swf_GetPlaceObject(stack[stackpos].tag, &p); p.clipdepth = currentdepth; - p.name = 0; + //p.name = 0; swf_ClearTag(stack[stackpos].tag); swf_SetPlaceObject(stack[stackpos].tag, &p); currentdepth++; @@ -2405,7 +2418,7 @@ int parseTwip(char*str) char*p = str; int val = 0; char ex = 0; - char*lastpos = str; + char*lastpos = 0; while(*p) { if(*p == '+' || *p == '-' || *p == '/' || *p == '*') ex = *p; @@ -2427,6 +2440,7 @@ int parseTwip(char*str) v = parseRawTwip(lastpos); } *p = save; + printf("%f %c= %f\n", val/20.0, ex, v/20.0); if(ex == '+') val += v; else if(ex == '-') @@ -2441,6 +2455,7 @@ int parseTwip(char*str) lastpos = 0; } } + printf("%s -> %.2f\n", str, val/20.0); return val; }