uint8_t *SIFSpritesSect::Encode(SIFSprite *sprites, int nsprites, int *datalen_out) { DBuffer buf; int i, f; buf.Append16(nsprites); for(i=0;i<nsprites;i++) { buf.Append8(sprites[i].w); buf.Append8(sprites[i].h); buf.Append8(sprites[i].spritesheet); buf.Append8(sprites[i].nframes); buf.Append8(sprites[i].ndirs); SaveRect(&sprites[i].bbox, &buf); SaveRect(&sprites[i].solidbox, &buf); SavePoint(&sprites[i].spawn_point, &buf); SavePointList(&sprites[i].block_l, &buf); SavePointList(&sprites[i].block_r, &buf); SavePointList(&sprites[i].block_u, &buf); SavePointList(&sprites[i].block_d, &buf); for(f=0;f<sprites[i].nframes;f++) { SaveFrame(&sprites[i].frame[f], sprites[i].ndirs, &buf); } } if (datalen_out) *datalen_out = buf.Length(); return buf.TakeData(); }
void DBuffer::SetTo(DBuffer &other) { SetTo(other.Data(), other.Length()); }