Ejemplo n.º 1
0
CSE_Abstract *CALifeSimulatorBase::spawn_item	(LPCSTR section, const Fvector &position, u32 level_vertex_id, GameGraph::_GRAPH_ID game_vertex_id, u16 parent_id, bool registration)
{
	CSE_Abstract				*abstract = F_entity_Create(section);
	R_ASSERT3					(abstract,"Cannot find item with section",section);

	abstract->s_name			= section;
	abstract->s_gameid			= u8(GAME_SINGLE); // GameID()
	abstract->s_RP				= 0xff;
	abstract->ID				= server().PerformIDgen(0xffff);
	abstract->ID_Parent			= parent_id;
	abstract->ID_Phantom		= 0xffff;
	abstract->o_Position		= position;
	abstract->m_wVersion		= SPAWN_VERSION;
	
	string256					s_name_replace;
	strcpy						(s_name_replace,*abstract->s_name);
	if (abstract->ID < 1000)
		strcat					(s_name_replace,"0");
	if (abstract->ID < 100)
		strcat					(s_name_replace,"0");
	if (abstract->ID < 10)
		strcat					(s_name_replace,"0");
	string16					S1;
	strcat						(s_name_replace,itoa(abstract->ID,S1,10));
	abstract->set_name_replace	(s_name_replace);

	CSE_ALifeDynamicObject		*dynamic_object = smart_cast<CSE_ALifeDynamicObject*>(abstract);
	VERIFY						(dynamic_object);

	//оружие спавним с полным магазинои
	CSE_ALifeItemWeapon* weapon = smart_cast<CSE_ALifeItemWeapon*>(dynamic_object);
	if(weapon)
		weapon->a_elapsed		= weapon->get_ammo_magsize();

	dynamic_object->m_tNodeID	= level_vertex_id;
	dynamic_object->m_tGraphID	= game_vertex_id;
	dynamic_object->m_tSpawnID	= u16(-1);

	if (registration)
		register_object				(dynamic_object,true);
#ifdef LUAICP_COMPAT
	if (parent_id < 0xFFFF)
	{
		 CSE_Abstract *parent = (CSE_Abstract*) objects().object(parent_id,true);
		 if (parent && parent->name() && strstr(parent->name(), "physic_"))
		 {
			 Msg("!WARN: object with section %-32s spawned into %s", section, parent->name());
			 Msg(" %s", get_lua_traceback(game_lua(), 1));
		 }
			 
	}
#endif

	dynamic_object->spawn_supplies	();
	dynamic_object->on_spawn		();

//	Msg							("LSS : SPAWN : [%s],[%s], level %s",*dynamic_object->s_name,dynamic_object->name_replace(),*ai().game_graph().header().level(ai().game_graph().vertex(dynamic_object->m_tGraphID)->level_id()).name());
	return						(dynamic_object);
}
Ejemplo n.º 2
0
void xrServer::Process_update(NET_Packet& P, ClientID sender)
{
    xrClientData* CL		= ID_to_client(sender);
    if (!CL)
    {
        return;
    }
//	if (CL)	CL->net_Ready	= TRUE;

#ifdef DEBUG
    if (g_Dump_Update_Read) Msg("---- UPDATE_Read --- ");
#endif						// Entities

    R_ASSERT(CL->flags.bLocal);
    // while has information
    while (!P.r_eof())
    {
        // find entity
        u16				ID;
        u8				size;

        P.r_u16			(ID);
        P.r_u8			(size);
        u32	_pos		= P.r_tell();
        CSE_Abstract	*E	= ID_to_entity(ID);

        if (E) {
            //Msg				("sv_import: %d '%s'",E->ID,E->name_replace());
            E->net_Ready	= TRUE;
            E->UPDATE_Read	(P);
#ifdef DEBUG
            if (g_Dump_Update_Read) Msg("* %s : %d - %d", E->name(), size, P.r_tell() - _pos);
#endif

            if ((P.r_tell()-_pos) != size)	{
                string16	tmp;
                CLSID2TEXT	(E->m_tClassID,tmp);
                Debug.fatal	(DEBUG_INFO,"Beer from the creator of '%s'",tmp);
            }
        }
        else
            P.r_advance	(size);
    }
#ifdef DEBUG
    if (g_Dump_Update_Read) Msg("-------------------- ");
#endif						// Entities

}
Ejemplo n.º 3
0
void xrServer::Process_update(NET_Packet& P, ClientID sender)
{
	xrClientData* CL		= ID_to_client(sender);
	R_ASSERT2				(CL,"Process_update client not found");

	if (g_Dump_Update_Read) Msg("---- UPDATE_Read --- ");

	R_ASSERT(CL->flags.bLocal);
	// while has information
	while (!P.r_eof())
	{
		// find entity
		u16				ID;
		u8				size;

		P.r_u16			(ID);
		P.r_u8			(size);
		u32	_pos		= P.r_tell();
		CSE_Abstract	*E	= ID_to_entity(ID);
		
		if (E) {
			//Msg				("sv_import: %d '%s'",E->ID,E->name_replace());
			E->net_Ready	= TRUE;
			E->UPDATE_Read	(P);

			u32 cp = P.r_tell();
			if (g_Dump_Update_Read) Msg("* %s : %d - %d", E->name(), size, cp - _pos);

			if ((cp - _pos) != size)	{
				string16	tmp;
				CLSID2TEXT	(E->m_tClassID,tmp);
				Msg("* size = %d, start read = %d, end read = %d", size, _pos, cp);
				Debug.fatal	(DEBUG_INFO,"Beer from the creator of '%s', version of object = %d", tmp, E->m_wVersion);				
			}
		}
		else
			P.r_advance	(size);
	}
	if (g_Dump_Update_Read) Msg("-------------------- ");

}