bool map_context::save()
{
	std::string data = map_.write();
	try {
		if (!is_embedded()) {
			write_file(get_filename(), data);
		} else {
			std::string map_string = read_file(get_filename());
			boost::regex re("(.*map_data\\s*=\\s*\")(.+?)(\".*)");
			boost::smatch m;
			if (boost::regex_search(map_string, m, re, boost::regex_constants::match_not_dot_null)) {
				std::stringstream ss;
				ss << m[1];
				ss << data;
				ss << m[3];
				write_file(get_filename(), ss.str());
			} else {
				throw editor_map_save_exception(_("Could not save into scenario"));
			}
		}
		clear_modified();
	} catch (io_exception& e) {
		utils::string_map symbols;
		symbols["msg"] = e.what();
		const std::string msg = vgettext("Could not save the map: $msg", symbols);
		throw editor_map_save_exception(msg);
	}
	return true;
}
void Tracked_Blip_Buffer::end_frame( blip_time_t t )
{
	Blip_Buffer::end_frame( t );
	if ( clear_modified() )
		last_non_silence = samples_avail() + blip_buffer_extra_;
}