IO_stat MCCdata::save(IO_handle stream, Object_type type, uint4 p_part) { IO_stat stat; // If p_part is non-zero it means we only want to save data specific // to a given card. In this case, we simply don't save the rest. if (p_part != 0 && id != p_part) return IO_NORMAL; if ((stat = IO_write_uint1(type, stream)) != IO_NORMAL) return stat; if ((stat = IO_write_uint4(p_part != 0 ? 0 : id, stream)) != IO_NORMAL) return stat; if (type == OT_BDATA) { uint1 set = data ? 1 : 0; return IO_write_uint1(set, stream); } else if (id & COMPACT_PARAGRAPHS) return IO_write_string((char *)data, stream, sizeof(uint1)); else { MCParagraph *tptr = (MCParagraph *)data; if (tptr != NULL) do { if ((stat = tptr->save(stream, p_part)) != IO_NORMAL) return stat; tptr = (MCParagraph *)tptr->next(); } while (tptr != data); } return IO_NORMAL; }
IO_stat MCCdata::save(IO_handle stream, Object_type type, uint4 p_part, MCObject *p_parent, uint32_t p_version) { IO_stat stat; // If p_part is non-zero it means we only want to save data specific // to a given card. In this case, we simply don't save the rest. if (p_part != 0 && id != p_part) return IO_NORMAL; if ((stat = IO_write_uint1(type, stream)) != IO_NORMAL) return stat; if ((stat = IO_write_uint4(p_part != 0 ? 0 : id, stream)) != IO_NORMAL) return stat; if (type == OT_BDATA) { uint1 set = data ? 1 : 0; return IO_write_uint1(set, stream); } else if (id & COMPACT_PARAGRAPHS) { // MW-2013-11-19: [[ UnicodeFileFormat ]] This flag is never set by newer engines // so is just legacy. (Indeed, this codepath should never be hit!). return IO_write_cstring_legacy((char *)data, stream, sizeof(uint1)); } else { MCParagraph *tptr = (MCParagraph *)data; if (tptr != NULL) do { // Ensure field's saved MCCdata paragraphs have a parent when needed if (p_parent != nil) tptr -> setparent(MCObjectCast<MCField>(p_parent)); if ((stat = tptr->save(stream, p_part, p_version)) != IO_NORMAL) return stat; tptr = (MCParagraph *)tptr->next(); } while (tptr != data); } return IO_NORMAL; }
// MW-2011-01-13: As styledtext is an internal (not published in anyway) format // we can change it to include the paragraph style for now. IO_stat MCStyledText::save(IO_handle p_stream, uint4 p_part, bool p_force_ext) { IO_stat stat; if ((stat = IO_write_uint1(OT_STYLED_TEXT, p_stream)) != IO_NORMAL) return stat; MCParagraph *tptr = m_paragraphs; if (tptr != NULL) do { if ((stat = tptr->save(p_stream, p_part)) != IO_NORMAL) return stat; tptr = (MCParagraph *)tptr->next(); } while (tptr != m_paragraphs); return IO_NORMAL; }