Ejemplo n.º 1
0
Archivo: Car.cpp Proyecto: genail/gear
void Car::deserialize(const CL_NetGameEvent &p_event)
{
	static const unsigned ARGUMENT_COUNT = 15;

	if (p_event.get_argument_count() != ARGUMENT_COUNT) {
		// when serialize data is invalid don't do anything
		cl_log_event(
				LOG_DEBUG,
				"invalid serialize data count: %1",
				p_event.get_argument_count()
		);

		return;
	}

	int idx = 0;

	// load iteration counter
	m_impl->m_iterId = p_event.get_argument(idx++);

	// saved inputs
	m_impl->m_inputState.accel = p_event.get_argument(idx++);
	m_impl->m_inputState.brake = p_event.get_argument(idx++);
	m_impl->m_inputState.turn = hexToFloat(p_event.get_argument(idx++));
	m_impl->m_inputLocked = p_event.get_argument(idx++);

	// corpse state
	m_impl->m_position.x = hexToFloat(p_event.get_argument(idx++));
	m_impl->m_position.y = hexToFloat(p_event.get_argument(idx++));
	m_impl->m_rotation.set_radians(hexToFloat(p_event.get_argument(idx++)));
	m_impl->m_speed = hexToFloat(p_event.get_argument(idx++));

	// physics parameters
	m_impl->m_phyMoveRot.set_radians(hexToFloat(p_event.get_argument(idx++)));
	m_impl->m_phyMoveVec.x = hexToFloat(p_event.get_argument(idx++));
	m_impl->m_phyMoveVec.y = hexToFloat(p_event.get_argument(idx++));
	m_impl->m_phySpeedDelta = hexToFloat(p_event.get_argument(idx++));
	m_impl->m_phyWheelsTurn = hexToFloat(p_event.get_argument(idx++));

	m_impl->m_damage = hexToFloat(p_event.get_argument(idx++));
}
Ejemplo n.º 2
0
void CarState::parseEvent(const CL_NetGameEvent &p_event)
{
	assert(p_event.get_name() == EVENT_CAR_STATE);

	m_name = p_event.get_argument(0);
	m_serialData = CL_NetGameEvent("");

	const int argCount = static_cast<signed>(p_event.get_argument_count());

	for (int i = 1; i < argCount; ++i) {
		m_serialData.add_argument(p_event.get_argument(i));
	}
}
Ejemplo n.º 3
0
void Cliente::on_evento_juego_actualizar_mouse(const CL_NetGameEvent &e)
{
	cl_log_event("eventos", "Actualizar Mouse");
	int numarg = e.get_argument_count();

	int idtanque = e.get_argument(0);

	if(idtanque != mundo->getTanqueJugador()->getID())
	{
		if(numarg==1) //Boton Izquierdo (Disparar)
		{
			mundo->teclatanquedown(idtanque,CL_KEY_SPACE);
		}
		/*else if(numarg==3) //Mover mouse
		{
			float x=e.get_argument(1),y=e.get_argument(2); //coordenadas
			mundo->getTanqueID(idtanque)->setTargetPosTorreta(CL_Vec2f(x,y));
		}*/	
	}
}