コード例 #1
0
ファイル: level_changer.cpp プロジェクト: OLR-xray/OLR-3.0
void CLevelChanger::feel_touch_new	(CObject *tpObject)
{
	CActor*			l_tpActor = smart_cast<CActor*>(tpObject);
	VERIFY			(l_tpActor);
	if (!l_tpActor->g_Alive())
		return;

	if (m_bSilentMode) {
		NET_Packet	p;
		p.w_begin	(M_CHANGE_LEVEL);
		p.w			(&m_game_vertex_id,sizeof(m_game_vertex_id));
		p.w			(&m_level_vertex_id,sizeof(m_level_vertex_id));
		p.w_vec3	(m_position);
		p.w_vec3	(m_angles);
		Level().Send(p,net_flags(TRUE));
		return;
	}
	Fvector			p,r;
	bool			b = get_reject_pos(p,r);
	CUIGameSP		*pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
	if (pGameSP)
        pGameSP->ChangeLevel	(m_game_vertex_id,m_level_vertex_id,m_position,m_angles,p,r,b);

	m_entrance_time	= Device.fTimeGlobal;
}
コード例 #2
0
ファイル: Car.cpp プロジェクト: AntonioModer/xray-16
void CCar::SaveNetState(NET_Packet& P)
{

	CPHSkeleton::SaveNetState	   (P);
	P.w_vec3(Position());
	Fvector Angle;
	XFORM().getXYZ(Angle);
	P.w_vec3(Angle);
	{
		xr_map<u16,SDoor>::iterator i,e;
		i=m_doors.begin();
		e=m_doors.end();
		P.w_u16(u16(m_doors.size()));
		for(;i!=e;++i)
			i->second.SaveNetState(P);
	}

	{
		xr_map<u16,SWheel>::iterator i,e;
		i=m_wheels_map.begin();
		e=m_wheels_map.end();
		P.w_u16(u16(m_wheels_map.size()));
		for(;i!=e;++i)
			i->second.SaveNetState(P);
	}
	P.w_float(GetfHealth());
}
コード例 #3
0
void CSE_Abstract::Spawn_Write				(NET_Packet	&tNetPacket, BOOL bLocal)
{
	// generic
	tNetPacket.w_begin			(M_SPAWN);
	tNetPacket.w_stringZ		(s_name			);
	tNetPacket.w_stringZ		(s_name_replace ?	s_name_replace : "");
	tNetPacket.w_u8				(0);
	tNetPacket.w_u8				(s_RP			);
	tNetPacket.w_vec3			(o_Position		);
	tNetPacket.w_vec3			(o_Angle		);
	tNetPacket.w_u16			(RespawnTime	);
	tNetPacket.w_u16			(ID				);
	tNetPacket.w_u16			(ID_Parent		);
	tNetPacket.w_u16			(ID_Phantom		);

	s_flags.set					(M_SPAWN_VERSION,TRUE);
	if (bLocal)
		tNetPacket.w_u16		(u16(s_flags.flags|M_SPAWN_OBJECT_LOCAL) );
	else
		tNetPacket.w_u16		(u16(s_flags.flags&~(M_SPAWN_OBJECT_LOCAL|M_SPAWN_OBJECT_ASPLAYER)));
	
	tNetPacket.w_u16			(SPAWN_VERSION);

	tNetPacket.w_u16			(m_gameType.m_GameType.get());
	
	tNetPacket.w_u16			(script_server_object_version());


	//client object custom data serialization SAVE
	u16 client_data_size		= (u16)client_data.size(); //не может быть больше 256 байт
	tNetPacket.w_u16			(client_data_size);
//	Msg							("SERVER:saving:save:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : "");
	if (client_data_size > 0) {
		tNetPacket.w			(&*client_data.begin(),client_data_size);
	}

	tNetPacket.w_u16			(m_tSpawnID);
//	tNetPacket.w_float			(m_spawn_probability);
//	tNetPacket.w_u32			(m_spawn_flags.get());
//	tNetPacket.w_stringZ		(m_spawn_control);
//	tNetPacket.w_u32			(m_max_spawn_count);
//	tNetPacket.w_u64			(m_min_spawn_interval);
//	tNetPacket.w_u64			(m_max_spawn_interval);

#ifdef XRSE_FACTORY_EXPORTS
	CScriptValueContainer::assign();
#endif

	// write specific data
	u32	position				= tNetPacket.w_tell();
	tNetPacket.w_u16			(0);
	STATE_Write					(tNetPacket);
	u16 size					= u16(tNetPacket.w_tell() - position);
//#ifdef XRSE_FACTORY_EXPORTS
	R_ASSERT3					((m_tClassID == CLSID_SPECTATOR) || (size > sizeof(size)),
		"object isn't successfully saved, get your backup :(",name_replace());
//#endif
	tNetPacket.w_seek			(position,&size,sizeof(u16));
}
コード例 #4
0
void CSE_ALifeInventoryItem::UPDATE_Write	(NET_Packet &tNetPacket)
{
	if (!m_u8NumItems) {
		tNetPacket.w_u8				(0);
		return;
	}

	mask_num_items					num_items;
	num_items.mask					= 0;
	num_items.num_items				= m_u8NumItems;

	R_ASSERT2						(
		num_items.num_items < (u8(1) << 5),
		make_string("%d",num_items.num_items)
		);

	if (State.enabled)									num_items.mask |= inventory_item_state_enabled;
	if (fis_zero(State.angular_vel.square_magnitude()))	num_items.mask |= inventory_item_angular_null;
	if (fis_zero(State.linear_vel.square_magnitude()))	num_items.mask |= inventory_item_linear_null;
	//if (anim_use)										num_items.mask |= animated;

	tNetPacket.w_u8					(num_items.common);

	/*if(check(num_items.mask,animated))
	{
		tNetPacket.w_float				(m_blend_timeCurrent);
	}*/

	{
		tNetPacket.w_vec3				(State.force);
		tNetPacket.w_vec3				(State.torque);

		tNetPacket.w_vec3				(State.position);

		tNetPacket.w_float			(State.quaternion.x);
		tNetPacket.w_float			(State.quaternion.y);
		tNetPacket.w_float			(State.quaternion.z);
		tNetPacket.w_float			(State.quaternion.w);	

		if (!check(num_items.mask,inventory_item_angular_null)) {
			tNetPacket.w_float		(State.angular_vel.x);
			tNetPacket.w_float		(State.angular_vel.y);
			tNetPacket.w_float		(State.angular_vel.z);
		}

		if (!check(num_items.mask,inventory_item_linear_null)) {
			tNetPacket.w_float		(State.linear_vel.x);
			tNetPacket.w_float		(State.linear_vel.y);
			tNetPacket.w_float		(State.linear_vel.z);
		}

	}
	tNetPacket.w_u8(1);	// not freezed - doesn't mean anything...
};
コード例 #5
0
ファイル: PHNetState.cpp プロジェクト: OLR-xray/OLR-3.0
void	SPHNetState::net_Export(NET_Packet& P)
{
	P.w_vec3(linear_vel);
	//P.w_vec3(angular_vel);
	//P.w_vec3(force);
	//P.w_vec3(torque);
	P.w_vec3(position);
	P.w_vec4(*((Fvector4*)&quaternion));
	//P.w_vec4(*((Fvector4*)&previous_quaternion));
	P.w_u8	((u8)enabled);

}
コード例 #6
0
ファイル: inventory_item.cpp プロジェクト: OLR-xray/XRay-NEW
void CInventoryItem::position_Export(NET_Packet& P,SPHNetState	&State)
{
	P.w_u8					( State.enabled );
	P.w_vec3				( State.angular_vel);
	P.w_vec3				( State.linear_vel);
	P.w_vec3				( State.force	);
	P.w_vec3				( State.torque	);
	P.w_float				( State.quaternion.x );
	P.w_float				( State.quaternion.y );
	P.w_float				( State.quaternion.z );
	P.w_float				( State.quaternion.w );
}
コード例 #7
0
ファイル: UIGameSP.cpp プロジェクト: OLR-xray/OLR-3.0
void CChangeLevelWnd::OnOk()
{
	Game().StartStopMenu					(this, true);
	NET_Packet								p;
	p.w_begin								(M_CHANGE_LEVEL);
	p.w										(&m_game_vertex_id,sizeof(m_game_vertex_id));
	p.w										(&m_level_vertex_id,sizeof(m_level_vertex_id));
	p.w_vec3								(m_position);
	p.w_vec3								(m_angles);

	Level().Send							(p,net_flags(TRUE));
}
コード例 #8
0
ファイル: inventory_item.cpp プロジェクト: OLR-xray/XRay-NEW
void CInventoryItem::net_Export			(NET_Packet& P) 
{	
	P.w_float			(m_fCondition);
	P.w_u32				(Level().timeServer());	
	///////////////////////////////////////
	CPHSynchronize* pSyncObj				= NULL;
	SPHNetState	State;
	pSyncObj = object().PHGetSyncItem		(0);
	if (pSyncObj && !object().H_Parent()) 
		pSyncObj->get_State(State);
	else 	
		State.position.set(object().Position());
	///////////////////////////////////////	
	u16 NumItems = object().PHGetSyncItemsNumber();
	if (object().H_Parent())
		NumItems = CSE_ALifeInventoryItem::FLAG_NO_POSITION;
	else
		if (IsGameTypeSingle())
						NumItems = 0;

	P.w_u16					( NumItems		);
	if (NumItems != CSE_ALifeInventoryItem::FLAG_NO_POSITION)
		P.w_vec3			( State.position);

	if (!NumItems || (NumItems == CSE_ALifeInventoryItem::FLAG_NO_POSITION))
		return;
	position_Export(P,State);
};
コード例 #9
0
void CPhysicsShellHolder::PHSaveState(NET_Packet &P)
{

	//CPhysicsShell* pPhysicsShell=PPhysicsShell();
	CKinematics* K	=smart_cast<CKinematics*>(Visual());
	//Flags8 lflags;
	//if(pPhysicsShell&&pPhysicsShell->isActive())			lflags.set(CSE_PHSkeleton::flActive,pPhysicsShell->isEnabled());

//	P.w_u8 (lflags.get());
	if(K)
	{
		P.w_u64(K->LL_GetBonesVisible());
		P.w_u16(K->LL_GetBoneRoot());
	}
	else
	{
		P.w_u64(u64(-1));
		P.w_u16(0);
	}
	/////////////////////////////
	Fvector min,max;

	min.set(flt_max,flt_max,flt_max);
	max.set(-flt_max,-flt_max,-flt_max);
	/////////////////////////////////////

	u16 bones_number=PHGetSyncItemsNumber();
	for(u16 i=0;i<bones_number;i++)
	{
		SPHNetState state;
		PHGetSyncItem(i)->get_State(state);
		Fvector& p=state.position;
		if(p.x<min.x)min.x=p.x;
		if(p.y<min.y)min.y=p.y;
		if(p.z<min.z)min.z=p.z;

		if(p.x>max.x)max.x=p.x;
		if(p.y>max.y)max.y=p.y;
		if(p.z>max.z)max.z=p.z;
	}

	min.sub(2.f*EPS_L);
	max.add(2.f*EPS_L);

	VERIFY(!min.similar(max));
	P.w_vec3(min);
	P.w_vec3(max);

	P.w_u16(bones_number);

	for(u16 i=0;i<bones_number;i++)
	{
		SPHNetState state;
		PHGetSyncItem(i)->get_State(state);
		state.net_Save(P,min,max);
	}
}
コード例 #10
0
void CScriptGameObject::DropItemAndTeleport	(CScriptGameObject* pItem, Fvector position)
{
	DropItem						(pItem);

	NET_Packet						PP;
	CGameObject::u_EventGen			(PP,GE_CHANGE_POS, pItem->object().ID());
	PP.w_vec3						(position);
	CGameObject::u_EventSend		(PP);
}
コード例 #11
0
ファイル: Helicopter2.cpp プロジェクト: OLR-xray/XRay-NEW
void SHeliEnemy::save(NET_Packet &output_packet)
{
	output_packet.w_s16		((s16)type);
	output_packet.w_vec3	(destEnemyPos);
	output_packet.w_u32		(destEnemyID);

	output_packet.w_float	(fire_trail_length_des);
	output_packet.w_u8		(bUseFireTrail ? 1 : 0);
}
コード例 #12
0
ファイル: PHSkeleton.cpp プロジェクト: 2asoft/xray
void CPHSkeleton::SaveNetState(NET_Packet& P)
{

	CPhysicsShellHolder* obj=PPhysicsShellHolder();
	CPhysicsShell* pPhysicsShell=obj->PPhysicsShell();
	IKinematics* K	=smart_cast<IKinematics*>(obj->Visual());
	if(pPhysicsShell&&pPhysicsShell->isActive())			m_flags.set(CSE_PHSkeleton::flActive,pPhysicsShell->isEnabled());

	P.w_u8 (m_flags.get());
	if(K)
	{
		P.w_u64(K->LL_GetBonesVisible());
		P.w_u16(K->LL_GetBoneRoot());
	}
	else
	{
		P.w_u64(u64(-1));
		P.w_u16(0);
	}
	/////////////////////////////
	Fvector min,max;

	min.set(F_MAX,F_MAX,F_MAX);
	max.set(-F_MAX,-F_MAX,-F_MAX);
	/////////////////////////////////////

	u16 bones_number=obj->PHGetSyncItemsNumber();
	for(u16 i=0;i<bones_number;i++)
	{
		SPHNetState state;
		obj->PHGetSyncItem(i)->get_State(state);
		Fvector& p=state.position;
		if(p.x<min.x)min.x=p.x;
		if(p.y<min.y)min.y=p.y;
		if(p.z<min.z)min.z=p.z;

		if(p.x>max.x)max.x=p.x;
		if(p.y>max.y)max.y=p.y;
		if(p.z>max.z)max.z=p.z;
	}

	min.sub(2.f*EPS_L);
	max.add(2.f*EPS_L);

	P.w_vec3(min);
	P.w_vec3(max);

	P.w_u16(bones_number);

	for(u16 i=0;i<bones_number;i++)
	{
		SPHNetState state;
		obj->PHGetSyncItem(i)->get_State(state);
		state.net_Save(P,min,max);
	}
}
コード例 #13
0
ファイル: Explosive.cpp プロジェクト: OLR-xray/OLR-3.0
void CExplosive::GenExplodeEvent (const Fvector& pos, const Fvector& normal)
{
	if (OnClient() || cast_game_object()->Remote()) return;

//	if( m_bExplodeEventSent ) 
//		return;
	VERIFY(!m_explosion_flags.test(flExplodEventSent));//!m_bExplodeEventSent
	VERIFY(0xffff != Initiator());

	NET_Packet		P;
	cast_game_object()->u_EventGen		(P,GE_GRENADE_EXPLODE,cast_game_object()->ID());	
	P.w_u16			(Initiator());
	P.w_vec3		(pos);
	P.w_vec3		(normal);
	cast_game_object()->u_EventSend		(P);

	//m_bExplodeEventSent = true;
	m_explosion_flags.set(flExplodEventSent,TRUE);
}
コード例 #14
0
ファイル: hit_memory_manager.cpp プロジェクト: 2asoft/xray
void CHitMemoryManager::save	(NET_Packet &packet) const
{
	if (!m_object->g_Alive())
		return;

	packet.w_u8					((u8)objects().size());

	HITS::const_iterator		I = objects().begin();
	HITS::const_iterator		E = objects().end();
	for ( ; I != E; ++I) {
		VERIFY					((*I).m_object);
		packet.w_u16			((*I).m_object->ID());
		// object params
		packet.w_u32			((*I).m_object_params.m_level_vertex_id);
		packet.w_vec3			((*I).m_object_params.m_position);
#ifdef USE_ORIENTATION
		packet.w_float			((*I).m_object_params.m_orientation.yaw);
		packet.w_float			((*I).m_object_params.m_orientation.pitch);
		packet.w_float			((*I).m_object_params.m_orientation.roll);
#endif // USE_ORIENTATION
		// self params
		packet.w_u32			((*I).m_self_params.m_level_vertex_id);
		packet.w_vec3			((*I).m_self_params.m_position);
#ifdef USE_ORIENTATION
		packet.w_float			((*I).m_self_params.m_orientation.yaw);
		packet.w_float			((*I).m_self_params.m_orientation.pitch);
		packet.w_float			((*I).m_self_params.m_orientation.roll);
#endif // USE_ORIENTATION
#ifdef USE_LEVEL_TIME
		packet.w_u32			((Device.dwTimeGlobal >= (*I).m_level_time) ? (Device.dwTimeGlobal - (*I).m_level_time) : 0);
#endif // USE_LAST_LEVEL_TIME
#ifdef USE_LEVEL_TIME
		packet.w_u32			((Device.dwTimeGlobal >= (*I).m_level_time) ? (Device.dwTimeGlobal - (*I).m_last_level_time) : 0);
#endif // USE_LAST_LEVEL_TIME
#ifdef USE_FIRST_LEVEL_TIME
		packet.w_u32			((Device.dwTimeGlobal >= (*I).m_level_time) ? (Device.dwTimeGlobal - (*I).m_first_level_time) : 0);
#endif // USE_FIRST_LEVEL_TIME
		packet.w_vec3			((*I).m_direction);
		packet.w_u16			((*I).m_bone_index);
		packet.w_float			((*I).m_amount);
	}
}
コード例 #15
0
void CSoundMemoryManager::save	(NET_Packet &packet) const
{
	if (!m_object->g_Alive())
		return;

	packet.w_u8					((u8)objects().size());

	SOUNDS::const_iterator		I = objects().begin();
	SOUNDS::const_iterator		E = objects().end();
	for ( ; I != E; ++I) {
		packet.w_u16			((*I).m_object ? (*I).m_object->ID() : ALife::_OBJECT_ID(-1));
		// object params
		packet.w_u32			((*I).m_object_params.m_level_vertex_id);
		packet.w_vec3			((*I).m_object_params.m_position);
#ifdef USE_ORIENTATION
		packet.w_float			((*I).m_object_params.m_orientation.yaw);
		packet.w_float			((*I).m_object_params.m_orientation.pitch);
		packet.w_float			((*I).m_object_params.m_orientation.roll);
#endif // USE_ORIENTATION
		// self params
		packet.w_u32			((*I).m_self_params.m_level_vertex_id);
		packet.w_vec3			((*I).m_self_params.m_position);
#ifdef USE_ORIENTATION
		packet.w_float			((*I).m_self_params.m_orientation.yaw);
		packet.w_float			((*I).m_self_params.m_orientation.pitch);
		packet.w_float			((*I).m_self_params.m_orientation.roll);
#endif // USE_ORIENTATION
#ifdef USE_LEVEL_TIME
		packet.w_u32			((Device.dwTimeGlobal >= (*I).m_level_time) ? (Device.dwTimeGlobal - (*I).m_level_time) : 0);
#endif // USE_LAST_LEVEL_TIME
#ifdef USE_LEVEL_TIME
		packet.w_u32			((Device.dwTimeGlobal >= (*I).m_level_time) ? (Device.dwTimeGlobal - (*I).m_last_level_time) : 0);
#endif // USE_LAST_LEVEL_TIME
#ifdef USE_FIRST_LEVEL_TIME
		packet.w_u32			((Device.dwTimeGlobal >= (*I).m_level_time) ? (Device.dwTimeGlobal - (*I).m_first_level_time) : 0);
#endif // USE_FIRST_LEVEL_TIME
		packet.w_u32			((*I).m_sound_type);
		packet.w_float			((*I).m_power);
	}
}
コード例 #16
0
ファイル: Helicopter.cpp プロジェクト: Zen13L/xray-16
void CHelicopter::save(NET_Packet &output_packet)
{
    m_movement.save	(output_packet);
    m_body.save		(output_packet);
    m_enemy.save	(output_packet);
    output_packet.w_vec3(XFORM().c);
    output_packet.w_float(m_barrel_dir_tolerance);
    save_data		(m_use_rocket_on_attack, output_packet);
    save_data		(m_use_mgun_on_attack, output_packet);
    save_data		(m_min_rocket_dist, output_packet);
    save_data		(m_max_rocket_dist, output_packet);
    save_data		(m_min_mgun_dist, output_packet);
    save_data		(m_max_mgun_dist, output_packet);
    save_data		(m_time_between_rocket_attack, output_packet);
    save_data		(m_syncronize_rocket, output_packet);
}
コード例 #17
0
ファイル: PHNetState.cpp プロジェクト: OLR-xray/OLR-3.0
void SPHBonesData::net_Save(NET_Packet &P)
{
	P.w_u64			(bones_mask);
	P.w_u16			(root_bone);
	
	P.w_vec3		(get_min());
	P.w_vec3		(get_max());
	P.w_u16			((u16)bones.size());//bones number;
	PHNETSTATE_I	i=bones.begin(),e=bones.end();
	for(;e!=i;i++)
	{
		(*i).net_Save(P,get_min(),get_max());
	}
	//	this comment is added by Dima (correct me if this is wrong)
	//  if we call 2 times in a row StateWrite then we get different results
	//	WHY???
	//	bones.clear		();
}
コード例 #18
0
ファイル: CustomMonster.cpp プロジェクト: BubbaXXX/xray-16
void CCustomMonster::net_Export(NET_Packet& P)					// export to server
{
	R_ASSERT				(Local());

	// export last known packet
	R_ASSERT				(!NET.empty());
	net_update& N			= NET.back();
	P.w_float				(GetfHealth());
	P.w_u32					(N.dwTimeStamp);
	P.w_u8					(0);
	P.w_vec3				(N.p_pos);
	P.w_float /*w_angle8*/				(N.o_model);
	P.w_float /*w_angle8*/				(N.o_torso.yaw);
	P.w_float /*w_angle8*/				(N.o_torso.pitch);
	P.w_float /*w_angle8*/				(N.o_torso.roll);
	P.w_u8					(u8(g_Team()));
	P.w_u8					(u8(g_Squad()));
	P.w_u8					(u8(g_Group()));
}
コード例 #19
0
ファイル: ai_stalker.cpp プロジェクト: 2asoft/xray
void CAI_Stalker::net_Export		(NET_Packet& P)
{
	R_ASSERT						(Local());

	// export last known packet
	R_ASSERT						(!NET.empty());
	net_update& N					= NET.back();
//	P.w_float						(inventory().TotalWeight());
//	P.w_u32							(m_dwMoney);

	P.w_float						(GetfHealth());

	P.w_u32							(N.dwTimeStamp);
	P.w_u8							(0);
	P.w_vec3						(N.p_pos);
	P.w_float /*w_angle8*/						(N.o_model);
	P.w_float /*w_angle8*/						(N.o_torso.yaw);
	P.w_float /*w_angle8*/						(N.o_torso.pitch);
	P.w_float /*w_angle8*/						(N.o_torso.roll);
	P.w_u8							(u8(g_Team()));
	P.w_u8							(u8(g_Squad()));
	P.w_u8							(u8(g_Group()));
	

	float					f1 = 0;
	GameGraph::_GRAPH_ID		l_game_vertex_id = ai_location().game_vertex_id();
	P.w						(&l_game_vertex_id,			sizeof(l_game_vertex_id));
	P.w						(&l_game_vertex_id,			sizeof(l_game_vertex_id));
//	P.w						(&f1,						sizeof(f1));
//	P.w						(&f1,						sizeof(f1));
	if (ai().game_graph().valid_vertex_id(l_game_vertex_id)) {
		f1					= Position().distance_to	(ai().game_graph().vertex(l_game_vertex_id)->level_point());
		P.w					(&f1,						sizeof(f1));
		f1					= Position().distance_to	(ai().game_graph().vertex(l_game_vertex_id)->level_point());
		P.w					(&f1,						sizeof(f1));
	}
	else {
		P.w					(&f1,						sizeof(f1));
		P.w					(&f1,						sizeof(f1));
	}

	P.w_stringZ						(m_sStartDialog);
}
コード例 #20
0
void CSE_ALifeInventoryItem::UPDATE_Write	(NET_Packet &tNetPacket)
{
	if (!m_u8NumItems) {
		tNetPacket.w_u8				(0);
		return;
	}

	mask_num_items					num_items;
	num_items.mask					= 0;
	num_items.num_items				= m_u8NumItems;

	R_ASSERT2						(
		num_items.num_items < (u8(1) << 5),
		make_string("%d",num_items.num_items)
	);

	if (State.enabled)									num_items.mask |= inventory_item_state_enabled;
	if (fis_zero(State.angular_vel.square_magnitude()))	num_items.mask |= inventory_item_angular_null;
	if (fis_zero(State.linear_vel.square_magnitude()))	num_items.mask |= inventory_item_linear_null;

	tNetPacket.w_u8					(num_items.common);

	tNetPacket.w_vec3				(State.position);

	tNetPacket.w_float_q8			(State.quaternion.x,0.f,1.f);
	tNetPacket.w_float_q8			(State.quaternion.y,0.f,1.f);
	tNetPacket.w_float_q8			(State.quaternion.z,0.f,1.f);
	tNetPacket.w_float_q8			(State.quaternion.w,0.f,1.f);	

	if (!check(num_items.mask,inventory_item_angular_null)) {
		tNetPacket.w_float_q8		(State.angular_vel.x,0.f,10*PI_MUL_2);
		tNetPacket.w_float_q8		(State.angular_vel.y,0.f,10*PI_MUL_2);
		tNetPacket.w_float_q8		(State.angular_vel.z,0.f,10*PI_MUL_2);
	}

	if (!check(num_items.mask,inventory_item_linear_null)) {
		tNetPacket.w_float_q8		(State.linear_vel.x,-32.f,32.f);
		tNetPacket.w_float_q8		(State.linear_vel.y,-32.f,32.f);
		tNetPacket.w_float_q8		(State.linear_vel.z,-32.f,32.f);
	}
};
コード例 #21
0
ファイル: Hit.cpp プロジェクト: OLR-xray/XRay-NEW
void SHit::Write_Packet_Cont		(NET_Packet	&Packet)
{
	Packet.w_u16		(whoID);
	Packet.w_u16		(weaponID);
	Packet.w_dir		(dir);
	Packet.w_float		(power);
	Packet.w_u16		(boneID);
	Packet.w_vec3		(p_in_bone_space);
	Packet.w_float		(impulse);
	Packet.w_u16		(aim_bullet!=0);
	Packet.w_u16		(u16(hit_type&0xffff));	
	if (hit_type == ALife::eHitTypeFireWound)
	{
		Packet.w_float	(ap);
	}
	if (PACKET_TYPE == GE_HIT_STATISTIC)
	{
		Packet.w_u32(BulletID);
		Packet.w_u32(SenderID);
	}
}
コード例 #22
0
ファイル: ai_rat.cpp プロジェクト: 2asoft/xray
void CAI_Rat::net_Export(NET_Packet& P)
{
	R_ASSERT				(Local());

	// export last known packet
	R_ASSERT				(!NET.empty());
	net_update& N			= NET.back();
	P.w_float				(GetfHealth());
	P.w_u32					(N.dwTimeStamp);
	P.w_u8					(0);
	P.w_vec3				(N.p_pos);
	P.w_float				(N.o_model);
	P.w_float				(N.o_torso.yaw);
	P.w_float				(N.o_torso.pitch);
	P.w_float				(N.o_torso.roll);
	P.w_u8					(u8(g_Team()));
	P.w_u8					(u8(g_Squad()));
	P.w_u8					(u8(g_Group()));

	GameGraph::_GRAPH_ID		l_game_vertex_id = ai_location().game_vertex_id();
	P.w						(&l_game_vertex_id,			sizeof(l_game_vertex_id));
	P.w						(&l_game_vertex_id,			sizeof(l_game_vertex_id));
//	P.w						(&m_fGoingSpeed,			sizeof(m_fGoingSpeed));
//	P.w						(&m_fGoingSpeed,			sizeof(m_fGoingSpeed));
	float					f1 = 0;
	if (ai().game_graph().valid_vertex_id(l_game_vertex_id)) {
		f1					= Position().distance_to	(ai().game_graph().vertex(l_game_vertex_id)->level_point());
		P.w					(&f1,						sizeof(f1));
		f1					= Position().distance_to	(ai().game_graph().vertex(l_game_vertex_id)->level_point());
		P.w					(&f1,						sizeof(f1));
	}
	else {
		P.w					(&f1,						sizeof(f1));
		P.w					(&f1,						sizeof(f1));
	}

	CEatableItem::net_Export(P);
}
コード例 #23
0
ファイル: inventory_item.cpp プロジェクト: OLR-xray/OLR-3.0
void CInventoryItem::net_Export			(NET_Packet& P) 
{	
	if (object().H_Parent() || IsGameTypeSingle()) 
	{
		P.w_u8				(0);
		return;
	}
	CPHSynchronize* pSyncObj				= NULL;
	SPHNetState								State;
	pSyncObj = object().PHGetSyncItem		(0);

	if (pSyncObj && !object().H_Parent()) 
		pSyncObj->get_State					(State);
	else 	
		State.position.set					(object().Position());


	mask_num_items			num_items;
	num_items.mask			= 0;
	u16						temp = bone_count_to_synchronize();

	R_ASSERT				(temp < (u16(1) << 5));
	num_items.num_items		= u8(temp);

	if (State.enabled)									num_items.mask |= CSE_ALifeInventoryItem::inventory_item_state_enabled;
	if (fis_zero(State.angular_vel.square_magnitude()))	num_items.mask |= CSE_ALifeInventoryItem::inventory_item_angular_null;
	if (fis_zero(State.linear_vel.square_magnitude()))	num_items.mask |= CSE_ALifeInventoryItem::inventory_item_linear_null;

	P.w_u8					(num_items.common);

	P.w_vec3				(State.position);

	float					magnitude = _sqrt(State.quaternion.magnitude());
	if (fis_zero(magnitude)) {
		magnitude			= 1;
		State.quaternion.x	= 0.f;
		State.quaternion.y	= 0.f;
		State.quaternion.z	= 1.f;
		State.quaternion.w	= 0.f;
	}
	else {
		float				invert_magnitude = 1.f/magnitude;
		
		State.quaternion.x	*= invert_magnitude;
		State.quaternion.y	*= invert_magnitude;
		State.quaternion.z	*= invert_magnitude;
		State.quaternion.w	*= invert_magnitude;

		clamp				(State.quaternion.x,0.f,1.f);
		clamp				(State.quaternion.y,0.f,1.f);
		clamp				(State.quaternion.z,0.f,1.f);
		clamp				(State.quaternion.w,0.f,1.f);
	}

	P.w_float_q8			(State.quaternion.x,0.f,1.f);
	P.w_float_q8			(State.quaternion.y,0.f,1.f);
	P.w_float_q8			(State.quaternion.z,0.f,1.f);
	P.w_float_q8			(State.quaternion.w,0.f,1.f);

	if (!(num_items.mask & CSE_ALifeInventoryItem::inventory_item_angular_null)) {
		clamp				(State.angular_vel.x,0.f,10.f*PI_MUL_2);
		clamp				(State.angular_vel.y,0.f,10.f*PI_MUL_2);
		clamp				(State.angular_vel.z,0.f,10.f*PI_MUL_2);

		P.w_float_q8		(State.angular_vel.x,0.f,10.f*PI_MUL_2);
		P.w_float_q8		(State.angular_vel.y,0.f,10.f*PI_MUL_2);
		P.w_float_q8		(State.angular_vel.z,0.f,10.f*PI_MUL_2);
	}

	if (!(num_items.mask & CSE_ALifeInventoryItem::inventory_item_linear_null)) {
		clamp				(State.linear_vel.x,-32.f,32.f);
		clamp				(State.linear_vel.y,-32.f,32.f);
		clamp				(State.linear_vel.z,-32.f,32.f);

		P.w_float_q8		(State.linear_vel.x,-32.f,32.f);
		P.w_float_q8		(State.linear_vel.y,-32.f,32.f);
		P.w_float_q8		(State.linear_vel.z,-32.f,32.f);
	}
};
コード例 #24
0
ファイル: PhysicObject.cpp プロジェクト: AntonioModer/xray-16
void CPhysicObject::net_Export_PH_Params(NET_Packet& P, SPHNetState& State, mask_num_items&	num_items)
{
	//UI().Font().pFontStat->OutSet(100.0f,100.0f);
	P.w_vec3				(State.force);
	//Msg("Export State.force.y:%4.6f",State.force.y);
	P.w_vec3				(State.torque);
	//UI().Font().pFontStat->OutNext("Export State.torque:%4.6f",State.torque.magnitude());
	P.w_vec3				(State.position);
	//Msg("Export State.position.y:%4.6f",State.position.y);
	//Msg("Export State.enabled:%i",int(State.enabled));

	float					magnitude = _sqrt(State.quaternion.magnitude());
	if (fis_zero(magnitude)) {
		magnitude			= 1;
		State.quaternion.x	= 0.f;
		State.quaternion.y	= 0.f;
		State.quaternion.z	= 1.f;
		State.quaternion.w	= 0.f;
	}
	else {
		/*		float				invert_magnitude = 1.f/magnitude;

		State.quaternion.x	*= invert_magnitude;
		State.quaternion.y	*= invert_magnitude;
		State.quaternion.z	*= invert_magnitude;
		State.quaternion.w	*= invert_magnitude;

		clamp				(State.quaternion.x,-1.f,1.f);
		clamp				(State.quaternion.y,-1.f,1.f);
		clamp				(State.quaternion.z,-1.f,1.f);
		clamp				(State.quaternion.w,-1.f,1.f);*/
	}

	P.w_float			(State.quaternion.x);
	P.w_float			(State.quaternion.y);
	P.w_float			(State.quaternion.z);
	P.w_float			(State.quaternion.w);

	if (!(num_items.mask & CSE_ALifeObjectPhysic::inventory_item_angular_null)) {
		/*	clamp				(State.angular_vel.x,-10.f*PI_MUL_2,10.f*PI_MUL_2);
		clamp				(State.angular_vel.y,-10.f*PI_MUL_2,10.f*PI_MUL_2);
		clamp				(State.angular_vel.z,-10.f*PI_MUL_2,10.f*PI_MUL_2);*/

		P.w_float		(State.angular_vel.x);
		P.w_float		(State.angular_vel.y);
		P.w_float		(State.angular_vel.z);
	}

	if (!(num_items.mask & CSE_ALifeObjectPhysic::inventory_item_linear_null)) {
		/*clamp				(State.linear_vel.x,-32.f,32.f);
		clamp				(State.linear_vel.y,-32.f,32.f);
		clamp				(State.linear_vel.z,-32.f,32.f);*/

		P.w_float		(State.linear_vel.x);
		P.w_float		(State.linear_vel.y);
		P.w_float		(State.linear_vel.z);
		//Msg("Export State.linear_vel.y:%4.6f",State.linear_vel.y);
	}
	else
	{
		//Msg("Export State.linear_vel.y:%4.6f",0.0f);
	}
}