Пример #1
0
IO_stat MCPlayer::save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t p_version)
{
	IO_stat stat;
	if (!disposable)
	{
		if ((stat = IO_write_uint1(OT_PLAYER, stream)) != IO_NORMAL)
			return stat;
		if ((stat = MCControl::save(stream, p_part, p_force_ext, p_version)) != IO_NORMAL)
			return stat;
		
		// MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
        if ((stat = IO_write_stringref_new(filename, stream, p_version >= 7000)) != IO_NORMAL)
			return stat;
		if ((stat = IO_write_uint4(starttime, stream)) != IO_NORMAL)
			return stat;
		if ((stat = IO_write_uint4(endtime, stream)) != IO_NORMAL)
			return stat;
		if ((stat = IO_write_int4((int4)(rate / 10.0 * MAXINT4),
		                          stream)) != IO_NORMAL)
			return stat;
		
		// MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
        if ((stat = IO_write_stringref_new(userCallbackStr, stream, p_version >= 7000)) != IO_NORMAL)
			return stat;
	}
	return savepropsets(stream, p_version);
}
Пример #2
0
IO_stat MCVariableValue::savekeys(IO_header *stream)
{
	if (is_array())
		return array . savekeys(stream);

	return IO_write_uint4(0, stream);
}
Пример #3
0
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;
}
Пример #4
0
IO_stat MCEPS::save(IO_handle stream, uint4 p_part, bool p_force_ext)
{
	IO_stat stat;

	if ((stat = IO_write_uint1(OT_MCEPS, stream)) != IO_NORMAL)
		return stat;
	if ((stat = MCObject::save(stream, p_part, p_force_ext)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint4(size, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write(postscript, sizeof(char), size, stream)) != IO_NORMAL)
		return stat;
	// MW-2013-11-19: [[ UnicodeFileFormat ]] EPS is always ASCII so legacy.
	if ((stat = IO_write_cstring_legacy(prolog, stream, 2)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_int4(MCU_r8toi4(xscale), stream)) != IO_NORMAL)
		return stat;
	if (flags & F_SCALE_INDEPENDENTLY)
		if ((stat = IO_write_int4(MCU_r8toi4(yscale), stream)) != IO_NORMAL)
			return stat;
	if ((stat = IO_write_int2(angle, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_int2(tx, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_int2(ty, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint2(ex, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint2(ey, stream)) != IO_NORMAL)
		return stat;
	if (flags & F_RETAIN_IMAGE)
		if ((stat = image->save(stream, p_part, p_force_ext)) != IO_NORMAL)
			return stat;
	if ((stat = IO_write_uint2(curpage, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint2(pagecount, stream)) != IO_NORMAL)
		return stat;
	uint2 i;
	for (i = 0 ; i < pagecount ; i++)
		if ((stat = IO_write_uint4(pageIndex[i], stream)) != IO_NORMAL)
			return stat;
	return savepropsets(stream);
}
Пример #5
0
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;
}
Пример #6
0
IO_stat MCVideoClip::save(IO_handle stream, uint4 p_part, bool p_force_ext)
{
	IO_stat stat;

	if ((stat = IO_write_uint1(OT_VIDEO_CLIP, stream)) != IO_NORMAL)
		return stat;
	if ((stat = MCObject::save(stream, p_part, p_force_ext)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint4(size, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write(frames, sizeof(uint1), size, stream)) != IO_NORMAL)
		return stat;
	if (flags & F_FRAME_RATE)
		if ((stat = IO_write_uint2(framerate, stream)) != IO_NORMAL)
			return stat;
	if (flags & F_SCALE_FACTOR)
		if ((stat = IO_write_int4(MCU_r8toi4(scale), stream)) != IO_NORMAL)
			return stat;
	return savepropsets(stream);
}
Пример #7
0
IO_stat IO_write_string(const MCString &p_string, IO_handle p_stream, uint8_t p_size, bool p_write_null)
{
	IO_stat stat = IO_NORMAL;
	uint32_t t_strlen = p_string.getlength();
	uint4 length = 0;
	uint32_t t_inc = p_write_null ? 1 : 0;
	switch (p_size)
	{
		case 1:
		{
			uint1 len = t_strlen == 0 ? 0 : MCU_min(t_strlen + t_inc, MAXUINT1);
			if ((stat = IO_write_uint1(len, p_stream)) != IO_NORMAL)
				return stat;
			length = len;
			break;
		}
		case 2:
		{
			uint2 len = t_strlen == 0 ? 0 : MCU_min(t_strlen + t_inc, MAXUINT2);
			if ((stat = IO_write_uint2(len, p_stream)) != IO_NORMAL)
				return stat;
			length = len;
			break;
		}
		case 4:
			length = t_strlen == 0 ? 0 : t_strlen + t_inc;
			if ((stat = IO_write_uint4(length, p_stream)) != IO_NORMAL)
				return stat;
			break;
	}
	if (length)
	{
		stat = MCStackSecurityWrite(p_string.getstring(), length - t_inc, p_stream);
		if (stat == IO_NORMAL && p_write_null)
			stat = IO_write_uint1(0, p_stream);
	}
	return stat;
}