X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcombine.c;h=ebe89be25a183536d0dbdc3c6d474d429450a7f9;hb=bba795d559ad97123c2b8943b1a98a87cc50a908;hp=34830414ec8a185644f93ba2ccab9a380713eac9;hpb=46329d5c3a1f959be78f966dec899adfc136e56a;p=swftools.git diff --git a/src/combine.c b/src/combine.c index 3483041..ebe89be 100644 --- a/src/combine.c +++ b/src/combine.c @@ -20,6 +20,7 @@ // * readers should be object-oriented static char* slavename; +static int slaveid; static char* tag_placeobject2_name (struct swf_tag* tag) { @@ -157,8 +158,15 @@ void write_sprite_defines(struct writer_t*w) * Anyway we can't throw it out, so we just pass it * through. */ + writer_write(w, tag->fulldata, tag->fulllength); break; } + case TAGID_JPEGTABLES: + /* according to the flash specs, there may only + be one JPEGTABLES tag per swf. This is maybe + a big FIXME */ + writer_write(w, tag->fulldata, tag->fulllength); + break; case TAGID_EXPORTASSETS: logf(" deliberately ignoring EXPORTASSETS tag"); break; @@ -198,12 +206,6 @@ void write_sprite(struct writer_t*w, int spriteid, int replaceddefine) startpos = (u8*)writer_getpos(w); - if (spriteid<0) - { - logf(" Didn't find anything named %s in file. No substitutions will occur.", slavename); - spriteid = get_free_id(); - } - logf (" sprite id is %d", spriteid); tmp = spriteid; writer_write(w, &tmp, 2); @@ -303,12 +305,41 @@ void write_master(struct writer_t*w, int spriteid, int replaceddefine, int flags while(master.tags[pos++].id != 0); } +void writeheader(struct writer_t*w, u8*data, int length) +{ + if(config.hassizex || config.hassizey || config.framerate) + { + struct flash_header head; + swf_init(data-3, length+3); + head = swf_read_header(); + if(config.hassizex) + { + head.boundingBox.x2 = head.boundingBox.x1 + config.sizex; + } + if(config.hassizey) + { + head.boundingBox.y2 = head.boundingBox.y1 + config.sizey; + } + if(config.framerate) + { + head.rate = config.framerate; + } + swf_write_header(w, &head); + } + else + writer_write(w, data, length); +} uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slavedata, int slavelength, int*newlength) { char master_flash = 0; char slave_flash = 0; slavename = _slavename; + if(slavename[0] == '#') + { + slaveid = atoi(&slavename[1]); + slavename = 0; + } logf(" move x (%d)", config.movex); logf(" move y (%d)", config.movey); @@ -334,6 +365,9 @@ uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slave logf(" the master file is flash (swf) format\n"); master_flash = 1; } + else + logf(" the master file is not flash (swf) format!\n"); + if(slavedata[2] == 'S' && slavedata[1] == 'W' && slavedata[0] == 'F') @@ -341,6 +375,8 @@ uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slave logf(" the slave file is flash (swf) format\n"); slave_flash = 1; } + else + logf(" the slave file is not flash (swf) format!\n"); if(master_flash && slave_flash) { @@ -381,7 +417,8 @@ uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slave else logf(" tagid %02x places object %d (no name)", tag, id); - if (name && !strcmp(name,slavename)) { + if ((name && slavename && !strcmp(name,slavename)) || + (!slavename && id==slaveid)) { if(id>=0) { spriteid = id; logf(" Slave file attached to object %d.", id); @@ -391,6 +428,17 @@ uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slave } while(master.tags[pos++].id != 0); + if (spriteid<0) + { + if(slavename) { + if(strcmp(slavename,"!!dummy!!")) + logf(" Didn't find anything named %s in file. No substitutions will occur.", slavename); + } + else + logf(" Didn't find id %d in file. No substitutions will occur.", slaveid); + spriteid = get_free_id(); + } + swf_relocate (slavedata, slavelength, masterids); read_swf(&slave, slavedata, slavelength); @@ -402,7 +450,7 @@ uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slave writer_write(&w, "FWS",3); headlength = (u32*)(writer_getpos(&w) + 1); - writer_write(&w, master.header.headerdata, master.header.headerlength); + writeheader(&w, master.header.headerdata, master.header.headerlength); if(config.antistream) { write_sprite_defines(&w);