Ejemplo n.º 1
0
void check_do_led_output(int universe) {
	int i_universe = universe - START_UNIVERSE;
	gettimeofday(&ts, NULL);
	uint32_t time = (uint32_t)(ts.tv_sec*1000000 + ts.tv_usec);
	arrival_flag[i_universe] = 1;
	arrival_time[i_universe] = time;

	int all_arrived = arrival_flag[0];
	int i;
	for (i=1; all_arrived && i<num_universes; ++i)
		all_arrived = arrival_flag[i];

	uint32_t frame_time = get_frame_time(time);

	if (all_arrived) { // All universes arrived!
		DBG("All have arrived, sending");
		if (frame_time < last_frame_time * 3 ||
			(time - last_frame_output) > (last_frame_time * 10)) {
			do_output();
		}
		else {
			DBG("Nope, timeout.");
		}
		last_frame_output = time;
		mark_frame_sent(frame_time);
	}
	else {
		if (frame_time * 3 < last_frame_time) {
			DBG("Sending the packet even though not all arrived!");
			do_output();
			last_frame_output = time;
			mark_frame_sent(frame_time);
		}
	}
}
Ejemplo n.º 2
0
void WindowBase::display() {
	if (framerate > 0) {
		double time = 1.0 / framerate - clock.get_elapsed();
		if (time > 0)
			Clock::sleep(time);
	}
	
	frame = clock.get_elapsed();
	clock.reset();
	
	input().swap_buffers();
	swap_buffers();
	
	std::ostringstream ss;
	ss << "fps: " << 1.0 / get_frame_time();
	set_caption(ss.str());
}
Ejemplo n.º 3
0
void main()
{
	Vector3 vVar0;
	Vector3 vVar3;
	Vector3 vVar6;
	float fVar9;
	
	if (PLAYER::HAS_FORCE_CLEANUP_OCCURRED(2))
	{
		func_4();
	}
	if (ENTITY::DOES_ENTITY_EXIST(iLocal_10))
	{
		ENTITY::FREEZE_ENTITY_POSITION(iLocal_10, true);
		vLocal_4 = {ENTITY::GET_ENTITY_COORDS(iLocal_10, 1)};
		vLocal_7 = {get_entity_rotation(iLocal_10, 2)};
	}
	while (true)
	{
		wait(0);
		if (ENTITY::DOES_ENTITY_EXIST(iLocal_10))
		{
			if (is_object_within_brain_activation_range(iLocal_10))
			{
				switch (iLocal_2)
				{
					case 0:
						if (does_entity_have_drawable(iLocal_10))
						{
							STREAMING::REQUEST_MODEL(joaat("p_abat_roller_1_col"));
							if (STREAMING::HAS_MODEL_LOADED(joaat("p_abat_roller_1_col")))
							{
								if (!func_3(vLocal_4, 0f, 0f, 0f, 0))
								{
									iLocal_3 = create_object(joaat("p_abat_roller_1_col"), vLocal_4, 1, true, false);
									ENTITY::SET_ENTITY_ROTATION(iLocal_3, vLocal_7, 2, 1);
									iLocal_2 = 1;
								}
							}
						}
						break;
					
					case 1:
						if (does_entity_have_drawable(iLocal_10))
						{
							if (_get_number_of_instances_of_streamed_script(joaat("michael2")) > 0)
							{
								request_anim_dict("map_objects");
								if (has_anim_dict_loaded("map_objects"))
								{
									iLocal_2 = 2;
								}
							}
						}
						break;
					
					case 2:
						if (does_entity_have_drawable(iLocal_10))
						{
							if (_get_number_of_instances_of_streamed_script(joaat("michael2")) > 0)
							{
								if (Global_88042)
								{
									if (has_anim_dict_loaded("map_objects"))
									{
										play_entity_anim(iLocal_10, "P_Abat_roller_1_open", "map_objects", 1f, false, 1, 0, 0f, 0);
										iLocal_2 = 3;
									}
								}
							}
						}
						break;
					
					case 3:
						fVar9 = 0.35f;
						vVar0 = {vLocal_4 + Vector(3.45f, 0f, 0f)};
						if (ENTITY::DOES_ENTITY_EXIST(iLocal_3))
						{
							vVar3 = {ENTITY::GET_ENTITY_COORDS(iLocal_3, 1)};
							if (!func_2(vVar3, vVar0, 0.1f, 0))
							{
								vVar6 = {vVar0 - vVar3};
								set_entity_coords(iLocal_3, vVar3 + func_1(vVar6) * FtoV(get_frame_time()) * Vector(fVar9, fVar9, fVar9), 1, false, 0, 1);
							}
							else
							{
								Global_88043 = 1;
								iLocal_2 = 4;
							}
						}
						break;
					
					case 4:
						break;
				}
			}
			else
			{
				func_4();
			}
		}
		else
		{
			func_4();
		}
	}
}