X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=lib%2Frfxswf.c;h=16e000558e71b5fd4e388d89bf86770fba73695a;hb=6d7f1c8bc753adf0a37da7eb18c0499e74b78a6f;hp=c03a997d6ee1f78e9ccc98ba59f4f20e486ebd2e;hpb=6778a872476db77a83e2885a22891fd3d32f1348;p=swftools.git diff --git a/lib/rfxswf.c b/lib/rfxswf.c index c03a997..16e0005 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -1289,6 +1289,8 @@ int swf_ReadSWF(int handle, SWF * swf) return swf_ReadSWF2(&reader, swf); } +int no_extra_tags = 0; + int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, returns length or <0 if fails { U32 len; TAG * t; @@ -1307,37 +1309,55 @@ int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return // Insert REFLEX Tag + if(!no_extra_tags) { + /* this block needs a complete rewrite */ + #ifdef INSERT_RFX_TAG - if ((swf->firstTag && swf->firstTag->id != ST_REFLEX) && - (!swf->firstTag->next || (swf->firstTag->next->id != ST_REFLEX && - (!swf->firstTag->next->next || (swf->firstTag->next->next->id!=ST_REFLEX))))) - { - swf_SetBlock(swf_InsertTagBefore(swf, swf->firstTag,ST_REFLEX),(U8*)"rfx",3); - } + if ((swf->firstTag && swf->firstTag->id != ST_REFLEX) && + (!swf->firstTag->next || (swf->firstTag->next->id != ST_REFLEX && + (!swf->firstTag->next->next || (swf->firstTag->next->next->id!=ST_REFLEX))))) + { + swf_SetBlock(swf_InsertTagBefore(swf, swf->firstTag,ST_REFLEX),(U8*)"rfx",3); + } #endif // INSERT_RFX_TAG - if(swf->fileVersion >= 9) { - if ((!swf->firstTag || swf->firstTag->id != ST_SCENEDESCRIPTION) && - (!swf->firstTag || - !swf->firstTag->next || swf->firstTag->next->id != ST_SCENEDESCRIPTION) && - (!swf->firstTag || - !swf->firstTag->next || - !swf->firstTag->next->next || swf->firstTag->next->next->id != ST_SCENEDESCRIPTION)) - { - TAG*scene = swf_InsertTagBefore(swf, swf->firstTag,ST_SCENEDESCRIPTION); - swf_SetU16(scene, 1); - swf_SetString(scene, (U8*)"Scene 1"); - swf_SetU8(scene, 0); - } - } - - if(swf->fileVersion >= 9) { - if (swf->firstTag && swf->firstTag->id != ST_FILEATTRIBUTES) - { - U32 flags = 0x8; // | 128 = usenetwork, | 16 = Actionscript3 | 8 = hasmetadata - swf_SetU32(swf_InsertTagBefore(swf, swf->firstTag,ST_FILEATTRIBUTES),flags); + if(swf->fileVersion >= 9) { + if ((!swf->firstTag || swf->firstTag->id != ST_SCENEDESCRIPTION) && + (!swf->firstTag || + !swf->firstTag->next || swf->firstTag->next->id != ST_SCENEDESCRIPTION) && + (!swf->firstTag || + !swf->firstTag->next || + !swf->firstTag->next->next || swf->firstTag->next->next->id != ST_SCENEDESCRIPTION)) + { + TAG*scene = swf_InsertTagBefore(swf, swf->firstTag,ST_SCENEDESCRIPTION); + swf_SetU16(scene, 1); + swf_SetString(scene, (U8*)"Scene 1"); + swf_SetU8(scene, 0); + } + } + + if(swf->fileVersion >= 9) { + TAG*tag = swf->firstTag; + U32 flags = 0x08; // 16 = has symbolclass tag | 8 = actionscript3 | 1 = usenetwork + int has_version_8_action=0; + int has_version_9_action=0; + while(tag) { + /* FIXME: this doesn't find actionscript in buttons */ + if(tag->id == ST_DOACTION || tag->id == ST_DOINITACTION) + has_version_8_action=1; + if(tag->id == ST_DOABC) + has_version_9_action=1; + tag = tag->next; + } + if(has_version_8_action && !has_version_9_action) + flags = 0x00; + + if (swf->firstTag && swf->firstTag->id != ST_FILEATTRIBUTES) + { + swf_SetU32(swf_InsertTagBefore(swf, swf->firstTag,ST_FILEATTRIBUTES),flags); + } } }