Пример #1
0
void CActorCondition::load(IReader &input_packet)
{
	inherited::load		(input_packet);
	load_data			(m_fAlcohol, input_packet);
	load_data			(m_condition_flags, input_packet);
	load_data			(m_fSatiety, input_packet);

	load_data			(m_curr_medicine_influence.fHealth, input_packet);
	load_data			(m_curr_medicine_influence.fPower, input_packet);
	load_data			(m_curr_medicine_influence.fSatiety, input_packet);
	load_data			(m_curr_medicine_influence.fRadiation, input_packet);
	load_data			(m_curr_medicine_influence.fWoundsHeal, input_packet);
	load_data			(m_curr_medicine_influence.fMaxPowerUp, input_packet);
	load_data			(m_curr_medicine_influence.fAlcohol, input_packet);
	load_data			(m_curr_medicine_influence.fTimeTotal, input_packet);
	load_data			(m_curr_medicine_influence.fTimeCurrent, input_packet);

	u8 cntr = input_packet.r_u8();
	for(; cntr>0; cntr--)
	{
		SBooster B;
		B.m_type = (EBoostParams)input_packet.r_u8();
		B.fBoostValue = input_packet.r_float();
		B.fBoostTime = input_packet.r_float();
		m_booster_influences[B.m_type] = B;
		BoostParameters(B);
	}
}
Пример #2
0
void st_LevelOptions::Read(IReader& F)
{
	R_ASSERT(F.find_chunk(CHUNK_LO_VERSION));
    DWORD vers = F.r_u32( );
    if( vers < 0x00000008 )
    {
        ELog.DlgMsg( mtError, "Skipping bad version of level options." );
        return;
    }

    R_ASSERT(F.find_chunk(CHUNK_LO_NAMES));
    F.r_stringZ 	(m_FNLevelPath);

    if (F.find_chunk(CHUNK_LO_PREFIX)) F.r_stringZ 	(m_LevelPrefix);

    R_ASSERT(F.find_chunk(CHUNK_LO_BOP));
    F.r_stringZ 	(m_BOPText); 

    if (F.find_chunk(CHUNK_LO_MAP_VER))
	    F.r_stringZ	(m_map_version);

    vers = 0;
    if (F.find_chunk(CHUNK_LO_BP_VERSION))
	    vers = F.r_u32( );

    if (CURRENT_LEVELOP_BP_VERSION==vers){
	    if (F.find_chunk(CHUNK_BUILD_PARAMS)) 	
        	F.r(&m_BuildParams, sizeof(m_BuildParams));
    }else{
        ELog.DlgMsg	(mtError, "Skipping bad version of build params.");
    	m_BuildParams.Init();
    }

    if (F.find_chunk(CHUNK_LIGHT_QUALITY))
    {
	    m_LightHemiQuality 	= F.r_u8();
	    m_LightSunQuality 	= F.r_u8();
    }
    if (F.find_chunk(CHUNK_MAP_USAGE))
    {
    	if(vers > 0x00000008)
        {
          m_mapUsage.m_GameType.assign	(F.r_u16());
        }else
        {
            m_mapUsage.m_GameType.zero					();
            m_mapUsage.m_GameType.set					(eGameIDDeathmatch ,	F.r_s32());
            m_mapUsage.m_GameType.set					(eGameIDTeamDeathmatch, F.r_s32());
            m_mapUsage.m_GameType.set					(eGameIDArtefactHunt,	F.r_s32());
        }
    }
}
Пример #3
0
bool ESceneLightTools::Load(IReader& F)
{
	u16 version 	= 0;
    if(F.r_chunk(CHUNK_VERSION,&version))
        if( version!=LIGHT_TOOLS_VERSION ){
            ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc());
            return false;
        }

	if (!inherited::Load(F)) return false;

    if (F.find_chunk(CHUNK_FLAGS))
    	m_Flags.assign		(F.r_u32());

    if (F.find_chunk(CHUNK_SUN_SHADOW)){
     	F.r_u8				();
        F.r_fvector2		(m_SunShadowDir);
    }
    
    if (F.find_chunk(CHUNK_LCONTROLS_LAST))
		lcontrol_last_idx	= F.r_u32();
    
	IReader* R 		= F.open_chunk(CHUNK_LCONTROLS); 
    if (R){
        while (!R->eof()){
        	shared_str		l_name;
            R->r_stringZ(l_name);
            u32 l_idx	= R->r_u32();
            AppendLightControl(l_name.c_str(),&l_idx);
        }
        R->close		();
    }

    return true;
}
Пример #4
0
void  CWound::load	(IReader &input_packet)
{
	m_iBoneNum = (u8)input_packet.r_u8();
	for(int i=0; i<ALife::eHitTypeMax; i++){
		m_Wounds[i] = input_packet.r_float_q8 (0.f, WOUND_MAX);
		VERIFY(m_Wounds[i]>=0.0f && m_Wounds[i]<=WOUND_MAX);	
	}
}
Пример #5
0
void SHeliBodyState::load(IReader &input_packet)
{
	type				= (EHeliBodyState)input_packet.r_s16();
	b_looking_at_point	= !!input_packet.r_u8();
	currBodyHPB.x			= input_packet.r_float();
	currBodyHPB.y			= input_packet.r_float();
	currBodyHPB.z			= input_packet.r_float();
}
Пример #6
0
void SHeliEnemy::load(IReader &input_packet)
{
	type				= (EHeliHuntState)input_packet.r_s16();
	input_packet.r_fvector3	(destEnemyPos);
	destEnemyID			= input_packet.r_u32();

	fire_trail_length_des	= input_packet.r_float();
	bUseFireTrail		= !!input_packet.r_u8();
}
Пример #7
0
void CCustomZone::load							(IReader &input_packet)
{
	inherited::load			(input_packet);	

	CCustomZone::EZoneState temp = static_cast<CCustomZone::EZoneState>(input_packet.r_u8());

	if (temp == eZoneStateDisabled)
		m_eZoneState = eZoneStateDisabled;
	else
		m_eZoneState = eZoneStateIdle;
}
Пример #8
0
void CInventoryItem::load(IReader &packet)
{
	m_eItemPlace			= (EItemPlace)packet.r_u8();
	m_fCondition			= packet.r_float();
	SetSlot (packet.r_u8());
	if (GetSlot() == 255)
		SetSlot (NO_ACTIVE_SLOT);

	u8						tmp = packet.r_u8();
	
	if (!tmp)
		return;
	
	if (!object().PPhysicsShell()) {
		object().setup_physic_shell	();
		object().PPhysicsShell()->Disable();
	}
	
	object().PHLoadState(packet);
	object().PPhysicsShell()->Disable();
}
Пример #9
0
bool EDetailManager::LoadColorIndices(IReader& F)
{
	VERIFY				(objects.empty());
    VERIFY  			(m_ColorIndices.empty());

    bool bRes			= true;
    // objects
    IReader* OBJ 		= F.open_chunk(DETMGR_CHUNK_OBJECTS);
    if (OBJ){
        IReader* O   	= OBJ->open_chunk(0);
        for (int count=1; O; count++) {
            EDetail* DO	= xr_new<EDetail>();
            if (DO->Load(*O)) 	objects.push_back(DO);
            else				bRes = false;
            O->close();
            O = OBJ->open_chunk(count);
        }
        OBJ->close();
    }
    // color index map
    R_ASSERT			(F.find_chunk(DETMGR_CHUNK_COLOR_INDEX));
    int cnt				= F.r_u8();
    string256			buf;
    u32 index;
    int ref_cnt;
    for (int k=0; k<cnt; k++){
		index			= F.r_u32();
        ref_cnt			= F.r_u8();
		for (int j=0; j<ref_cnt; j++){
        	F.r_stringZ	(buf,sizeof(buf));
            EDetail* DO	= FindDOByName(buf);
            if (DO) 	m_ColorIndices[index].push_back(DO);    
            else		bRes=false;
        }
    }
	InvalidateCache		();

    return bRes;
}
Пример #10
0
void	CInventoryOwner::load	(IReader &input_packet)
{
	u8 active_slot = input_packet.r_u8();
	if(active_slot == u8(-1))
		inventory().SetActiveSlot(NO_ACTIVE_SLOT);
	else
		inventory().Activate_deffered(active_slot, Device.dwFrame);

	m_tmp_active_slot_num		 = active_slot;

	CharacterInfo().load(input_packet);
	load_data		(m_game_name, input_packet);
	load_data		(m_money,	input_packet);
}
Пример #11
0
void SAINode::LoadStream(IReader& F, ESceneAIMapTool* tools)
{
	u32 			id;
    u16 			pl;
	NodePosition 	np;
    F.r				(&id,3); 			n1 = (SAINode*)tools->UnpackLink(id);
    F.r				(&id,3); 			n2 = (SAINode*)tools->UnpackLink(id);
    F.r				(&id,3); 			n3 = (SAINode*)tools->UnpackLink(id);
    F.r				(&id,3); 			n4 = (SAINode*)tools->UnpackLink(id);
	pl				= F.r_u16(); 		pvDecompress(Plane.n,pl);
    F.r				(&np,sizeof(np)); 	tools->UnpackPosition(Pos,np,tools->m_AIBBox,tools->m_Params);
	Plane.build		(Pos,Plane.n);
    flags.assign	(F.r_u8());
}
Пример #12
0
bool CEditShape::LoadStream(IReader& F)
{
	R_ASSERT(F.find_chunk(SHAPE_CHUNK_VERSION));
    u16 vers		= F.r_u16();

	inherited::LoadStream	(F);

	R_ASSERT(F.find_chunk(SHAPE_CHUNK_SHAPES));
    shapes.resize	(F.r_u32());
    F.r				(shapes.begin(),shapes.size()*sizeof(shape_def));

    if(F.find_chunk(SHAPE_CHUNK_DATA))
    	m_shape_type	= F.r_u8();
    
	ComputeBounds();
	return true;
}
Пример #13
0
void CInventoryOwner::load(IReader &input_packet) {
	CActor* pOurActor = smart_cast<CActor*>(this);
	u8 active_slot = input_packet.r_u8();
	
	if (pOurActor && pOurActor->GetHolderID() == u16(-1)) {
		if(active_slot == u8(-1)) {
			inventory().SetActiveSlot(NO_ACTIVE_SLOT);
		}
		else {
			inventory().Activate_deffered(active_slot, Device.dwFrame);
		}
	}

	m_tmp_active_slot_num = active_slot;

	CharacterInfo().load(input_packet);
	load_data(m_game_name, input_packet);
	load_data(m_money, input_packet);
}
Пример #14
0
void CInventoryItem::load(IReader &packet)
{
	m_eItemPlace = (EItemPlace)packet.r_u8 ()	;
	u16 tmp = packet.r_u16	();
	if(CSE_ALifeInventoryItem::FLAG_NO_POSITION==tmp)
	{
		return;
	}
	
	if(!object().PPhysicsShell())
	{
//.		object().processing_activate();
		object().setup_physic_shell	();
		object().PPhysicsShell()->Disable();
	}
	
	object().PHLoadState(packet);
	object().PPhysicsShell()->Disable();
}
Пример #15
0
void CInventoryItem::load(IReader &packet)
{
	m_ItemCurrPlace.value	= packet.r_u16();
	m_fCondition			= packet.r_float();

//--	load_data( m_upgrades, packet );
//--	install_loaded_upgrades();

	u8						tmp = packet.r_u8();
	if (!tmp)
		return;
	
	if (!object().PPhysicsShell()) {
		object().setup_physic_shell	();
		object().PPhysicsShell()->Disable();
	}
	
	object().PHLoadState(packet);
	object().PPhysicsShell()->Disable();
}
Пример #16
0
void STextureParams::Load(IReader& F)
{
    R_ASSERT(F.find_chunk(THM_CHUNK_TEXTUREPARAM));
    F.r					(&fmt,sizeof(ETFormat));
    flags.assign(F.r_u32());
    border_color= F.r_u32();
    fade_color	= F.r_u32();
    fade_amount	= F.r_u32();
    mip_filter	= F.r_u32();
    width		= F.r_u32();
    height		= F.r_u32();

    if (F.find_chunk(THM_CHUNK_TEXTURE_TYPE)){
        type	= (ETType)F.r_u32();
    }

    if (F.find_chunk(THM_CHUNK_DETAIL_EXT)){
        F.r_stringZ(detail_name);
        detail_scale = F.r_float();
    }

    if (F.find_chunk(THM_CHUNK_MATERIAL)){
    	material		= (ETMaterial)F.r_u32		();
	    material_weight = F.r_float	();
    }

    if (F.find_chunk(THM_CHUNK_BUMP)){
	    bump_virtual_height	= F.r_float				();
	    bump_mode			= (ETBumpMode)F.r_u32	();
        if (bump_mode<STextureParams::tbmNone){
        	bump_mode		= STextureParams::tbmNone; //.. временно (до полного убирания Autogen)
        }
    	F.r_stringZ			(bump_name);
    }

    if (F.find_chunk(THM_CHUNK_EXT_NORMALMAP))
	    F.r_stringZ			(ext_normal_map_name);

	if (F.find_chunk(THM_CHUNK_FADE_DELAY))
		fade_delay			= F.r_u8();
}
Пример #17
0
void CHitMemoryManager::load	(IReader &packet)
{
	if (!m_object->g_Alive())
		return;

	typedef CClientSpawnManager::CALLBACK_TYPE	CALLBACK_TYPE;
	CALLBACK_TYPE					callback;
	callback.bind					(&m_object->memory(),&CMemoryManager::on_requested_spawn);

	int								count = packet.r_u8();
	for (int i=0; i<count; ++i) {
		CDelayedHitObject			delayed_object;
		delayed_object.m_object_id	= packet.r_u16();

		CHitObject					&object = delayed_object.m_hit_object;
		object.m_object				= smart_cast<CEntityAlive*>(Level().Objects.net_Find(delayed_object.m_object_id));
		// object params
		object.m_object_params.m_level_vertex_id	= packet.r_u32();
		packet.r_fvector3			(object.m_object_params.m_position);
#ifdef USE_ORIENTATION
		packet.r_float				(object.m_object_params.m_orientation.yaw);
		packet.r_float				(object.m_object_params.m_orientation.pitch);
		packet.r_float				(object.m_object_params.m_orientation.roll);
#endif
		// self params
		object.m_self_params.m_level_vertex_id	= packet.r_u32();
		packet.r_fvector3			(object.m_self_params.m_position);
#ifdef USE_ORIENTATION
		packet.r_float				(object.m_self_params.m_orientation.yaw);
		packet.r_float				(object.m_self_params.m_orientation.pitch);
		packet.r_float				(object.m_self_params.m_orientation.roll);
#endif
#ifdef USE_LEVEL_TIME
		VERIFY						(Device.dwTimeGlobal >= object.m_level_time);
		object.m_level_time			= packet.r_u32();
		object.m_level_time			+= Device.dwTimeGlobal;
#endif // USE_LEVEL_TIME
#ifdef USE_LAST_LEVEL_TIME
		VERIFY						(Device.dwTimeGlobal >= object.m_last_level_time);
		object.m_last_level_time	= packet.r_u32();
		object.m_last_level_time	+= Device.dwTimeGlobal;
#endif // USE_LAST_LEVEL_TIME
#ifdef USE_FIRST_LEVEL_TIME
		VERIFY						(Device.dwTimeGlobal >= (*I).m_first_level_time);
		object.m_first_level_time	= packet.r_u32();
		object.m_first_level_time	+= Device.dwTimeGlobal;
#endif // USE_FIRST_LEVEL_TIME
		packet.r_fvector3			(object.m_direction);
		object.m_bone_index			= packet.r_u16();
		object.m_amount				= packet.r_float();

		if (object.m_object) {
			add						(object);
			continue;
		}

		m_delayed_objects.push_back	(delayed_object);

		const CClientSpawnManager::CSpawnCallback	*spawn_callback = Level().client_spawn_manager().callback(delayed_object.m_object_id,m_object->ID());
		if (!spawn_callback || !spawn_callback->m_object_callback)
			if(!g_dedicated_server)
				Level().client_spawn_manager().add	(delayed_object.m_object_id,m_object->ID(),callback);
#ifdef DEBUG
		else {
			if (spawn_callback && spawn_callback->m_object_callback) {
				VERIFY				(spawn_callback->m_object_callback == callback);
			}
		}
#endif // DEBUG
	}
}
Пример #18
0
void game_sv_GameState::Create					(shared_str &options)
{
	string_path	fn_game;
	m_item_respawner.clear_respawns();
	if (FS.exist(fn_game, "$level$", "level.game")) 
	{
		IReader *F = FS.r_open	(fn_game);
		IReader *O = 0;

		// Load RPoints
		if (0!=(O = F->open_chunk	(RPOINT_CHUNK)))
		{ 
			for (int id=0; O->find_chunk(id); ++id)
			{
				RPoint					R;
				u8						team;
				u8						type;
				u16						GameType;
				shared_str				rp_profile;

				O->r_fvector3			(R.P);
				O->r_fvector3			(R.A);
				team					= O->r_u8	();	
				type					= O->r_u8	();
				GameType				= O->r_u16	();
				if(type==rptItemSpawn)
					O->r_stringZ		(rp_profile);

				if (GameType != EGameIDs(u16(-1)))
				{
					if ((Type() == eGameIDCaptureTheArtefact) && (GameType & eGameIDCaptureTheArtefact))
					{
						team = team - 1;
						R_ASSERT2( ((team >= 0) && (team < 4)) || 
							(type != rptActorSpawn), 
							"Problem with CTA Team indexes. Propably you have added rpoint of team 0 for cta game type.");
					}
					if ((!(GameType & eGameIDDeathmatch) && (Type() == eGameIDDeathmatch)) ||
						(!(GameType & eGameIDTeamDeathmatch) && (Type() == eGameIDTeamDeathmatch))	||
						(!(GameType & eGameIDArtefactHunt) && (Type() == eGameIDArtefactHunt)) ||
						(!(GameType & eGameIDCaptureTheArtefact) && (Type() == eGameIDCaptureTheArtefact))
						)
					{
						continue;
					};
				};
				switch (type)
				{
				case rptActorSpawn:
					{
						rpoints[team].push_back	(R);
						for (int i=0; i<int(rpoints[team].size())-1; i++)
						{
							RPoint rp = rpoints[team][i];
							float dist = R.P.distance_to_xz(rp.P)/2;
							if (dist<rpoints_MinDist[team])
								rpoints_MinDist[team] = dist;
							dist = R.P.distance_to(rp.P)/2;
							if (dist<rpoints_Dist[team])
								rpoints_Dist[team] = dist;
						};
					}break;
				case rptItemSpawn:
					{
						m_item_respawner.add_new_rpoint(rp_profile, R);
					}
				};
			};
			O->close();
		}

		FS.r_close	(F);
	}

	if (!g_dedicated_server)
	{
		// loading scripts
		ai().script_engine().remove_script_process(ScriptEngine::eScriptProcessorGame);
		string_path					S;
		FS.update_path				(S,"$game_config$","script.ltx");
		CInifile					*l_tpIniFile = xr_new<CInifile>(S);
		R_ASSERT					(l_tpIniFile);

		if( l_tpIniFile->section_exist( type_name() ) )
			if (l_tpIniFile->r_string(type_name(),"script"))
				ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorGame,xr_new<CScriptProcess>("game",l_tpIniFile->r_string(type_name(),"script")));
			else
				ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorGame,xr_new<CScriptProcess>("game",""));

		xr_delete					(l_tpIniFile);
	}

	//---------------------------------------------------------------------
	ConsoleCommands_Create();
	//---------------------------------------------------------------------
//	CCC_LoadCFG_custom*	pTmp = xr_new<CCC_LoadCFG_custom>("sv_");
//	pTmp->Execute				(Console->ConfigFile);
//	xr_delete					(pTmp);
	//---------------------------------------------------------------------
	LPCSTR		svcfg_ltx_name = "-svcfg ";
	if (strstr(Core.Params, svcfg_ltx_name))
	{
		string_path svcfg_name = "";
		int		sz = xr_strlen(svcfg_ltx_name);
		sscanf		(strstr(Core.Params,svcfg_ltx_name)+sz,"%[^ ] ",svcfg_name);
//		if (FS.exist(svcfg_name))
		{
			Console->ExecuteScript(svcfg_name);
		}
	};
	//---------------------------------------------------------------------
	ReadOptions(options);	
}
Пример #19
0
void		CPhysicsShellHolder::	load				(IReader &input_packet)
{
	inherited::load(input_packet);
	st_enable_state=input_packet.r_u8();

}
Пример #20
0
//-----------------------------------------------------------------------
BOOL motions_value::load		(LPCSTR N, IReader *data, vecBones* bones)
{

	m_id						= N;

	bool bRes					= true;
	// Load definitions
	U16Vec rm_bones				(bones->size(),BI_NONE);
	IReader* MP 				= data->open_chunk(OGF_S_SMPARAMS);

	if (MP)
	{
		u16 vers 				= MP->r_u16();
		u16 part_bone_cnt		= 0;
		string128 				buf;
		R_ASSERT3				(vers<=xrOGF_SMParamsVersion,"Invalid OGF/OMF version:",N);
		
		// partitions
		u16						part_count;
		part_count 				= MP->r_u16();

		for (u16 part_i=0; part_i<part_count; part_i++)
		{
			CPartDef& PART		= m_partition[part_i];
			MP->r_stringZ		(buf,sizeof(buf));
			PART.Name			= _strlwr(buf);
			PART.bones.resize	(MP->r_u16());

			for (xr_vector<u32>::iterator b_it=PART.bones.begin(); b_it<PART.bones.end(); b_it++)
			{
				MP->r_stringZ	(buf,sizeof(buf));
				u16 m_idx 		= u16			(MP->r_u32());
				*b_it			= find_bone_id	(bones,buf);
#ifdef _EDITOR
				if (*b_it==BI_NONE )
                {
					bRes		= false;
					Msg			("! Can't find bone: '%s'", buf);
				}

				if (rm_bones.size() <= m_idx)
                {
					bRes		= false;
					Msg			("! Can't load: '%s' invalid bones count", N);
				}
#else
				VERIFY3			(*b_it!=BI_NONE,"Can't find bone:", buf);
#endif
				if (bRes)		rm_bones[m_idx] = u16(*b_it);
			}
			part_bone_cnt		= u16(part_bone_cnt + (u16)PART.bones.size());
		}

#ifdef _EDITOR
		if (part_bone_cnt!=(u16)bones->size()){
			bRes = false;
			Msg("! Different bone count[%s] [Object: '%d' <-> Motions: '%d']", N, bones->size(),part_bone_cnt);
		}
#else
		VERIFY3(part_bone_cnt==(u16)bones->size(),"Different bone count '%s'",N);
#endif
		if (bRes)
		{
			// motion defs (cycle&fx)
			u16 mot_count			= MP->r_u16();
            m_mdefs.resize			(mot_count);

			for (u16 mot_i=0; mot_i<mot_count; mot_i++)
			{
				MP->r_stringZ		(buf,sizeof(buf));
				shared_str nm		= _strlwr		(buf);
				u32 dwFlags			= MP->r_u32		();
				CMotionDef&	D		= m_mdefs[mot_i];
                D.Load				(MP,dwFlags,vers);
//.             m_mdefs.push_back	(D);
				
				if (dwFlags&esmFX)	
					m_fx.insert		(mk_pair(nm,mot_i));
				else				
					m_cycle.insert	(mk_pair(nm,mot_i));

                m_motion_map.insert	(mk_pair(nm,mot_i));
			}
		}
		MP->close();
	}else
	{
		xrDebug::Fatal	(DEBUG_INFO,"Old skinned model version unsupported! (%s)",N);
	}
	if (!bRes)	return false;

	// Load animation
	IReader*	MS		= data->open_chunk(OGF_S_MOTIONS);
	if (!MS) 			return false;

	u32			dwCNT	= 0;
	MS->r_chunk_safe	(0,&dwCNT,sizeof(dwCNT));
    VERIFY		(dwCNT<0x3FFF); // MotionID 2 bit - slot, 14 bit - motion index

	// set per bone motion size
	for (u32 i=0; i<bones->size(); i++)
		m_motions[bones->at(i)->name].resize(dwCNT);

	// load motions
	for (u16 m_idx=0; m_idx<(u16)dwCNT; m_idx++){
		string128			mname;
		R_ASSERT			(MS->find_chunk(m_idx+1));             
		MS->r_stringZ		(mname,sizeof(mname));
#ifdef _DEBUG        
		// sanity check
		xr_strlwr			(mname);
        accel_map::iterator I= m_motion_map.find(mname); 
        VERIFY3				(I!=m_motion_map.end(),"Can't find motion:",mname);
        VERIFY3				(I->second==m_idx,"Invalid motion index:",mname);
#endif
		u32 dwLen			= MS->r_u32();
		for (u32 i=0; i<bones->size(); i++){
			u16 bone_id		= rm_bones[i];
			VERIFY2			(bone_id!=BI_NONE,"Invalid remap index.");
			CMotion&		M	= m_motions[bones->at(bone_id)->name][m_idx];
			M.set_count			(dwLen);
			M.set_flags			(MS->r_u8());
            
            if (M.test_flag(flRKeyAbsent))	{
                CKeyQR* r 		= (CKeyQR*)MS->pointer();
				u32 crc_q		= crc32(r,sizeof(CKeyQR));
				M._keysR.create	(crc_q,1,r);
                MS->advance		(1 * sizeof(CKeyQR));
            }else{
                u32 crc_q		= MS->r_u32	();
                M._keysR.create	(crc_q,dwLen,(CKeyQR*)MS->pointer());
                MS->advance		(dwLen * sizeof(CKeyQR));
            }
            if (M.test_flag(flTKeyPresent))	
            {
                u32 crc_t		= MS->r_u32	();
                if(M.test_flag(flTKey16IsBit))
                {
                    M._keysT16.create	(crc_t,dwLen,(CKeyQT16*)MS->pointer());
                    MS->advance			(dwLen * sizeof(CKeyQT16));
                }else
                {
                    M._keysT8.create	(crc_t,dwLen,(CKeyQT8*)MS->pointer());
                    MS->advance			(dwLen * sizeof(CKeyQT8));
                };
                
                MS->r_fvector3	(M._sizeT);
                MS->r_fvector3	(M._initT);
            }else
            {
                MS->r_fvector3	(M._initT);
            }
		}
	}
//	Msg("Motions %d/%d %4d/%4d/%d, %s",p_cnt,m_cnt, m_load,m_total,m_r,N);
	MS->close();

	return bRes;
}
Пример #21
0
bool CSMotion::Load(IReader& F)
{
	CCustomMotion::Load(F);
	u16 vers	= F.r_u16();
	if (vers==0x0004){
	    m_BoneOrPart= u16(F.r_u32()&0xffff);
		m_Flags.set	(esmFX,F.r_u8());
		m_Flags.set	(esmStopAtEnd,F.r_u8());
		fSpeed		= F.r_float();
	    fAccrue		= F.r_float();
		fFalloff	= F.r_float();
	    fPower		= F.r_float();
		bone_mots.resize(F.r_u32());
        string64	temp_buf;
		for(BoneMotionIt bm_it=bone_mots.begin(); bm_it!=bone_mots.end(); bm_it++){
        	bm_it->SetName	(itoa(int(bm_it-bone_mots.begin()),temp_buf,10));
			bm_it->m_Flags.assign((u8)F.r_u32());
			for (int ch=0; ch<ctMaxChannel; ch++){
				bm_it->envs[ch] = xr_new<CEnvelope> ();
				bm_it->envs[ch]->Load_1(F);
			}
		}
	}else{
		if (vers==0x0005){
            m_Flags.assign	((u8)F.r_u32());
            m_BoneOrPart= u16(F.r_u32()&0xffff);
            fSpeed		= F.r_float();
            fAccrue		= F.r_float();
            fFalloff	= F.r_float();
            fPower		= F.r_float();
            bone_mots.resize(F.r_u32());
            string64 	buf;
            for(BoneMotionIt bm_it=bone_mots.begin(); bm_it!=bone_mots.end(); bm_it++){
                F.r_stringZ		(buf,sizeof(buf));
                bm_it->SetName	(buf);
                bm_it->m_Flags.assign((u8)F.r_u32());
                for (int ch=0; ch<ctMaxChannel; ch++){
                    bm_it->envs[ch] = xr_new<CEnvelope> ();
                    bm_it->envs[ch]->Load_1(F);
                }
            }
        }else{
            if (vers!=EOBJ_SMOTION_VERSION) return false;
            m_Flags.assign	(F.r_u8());
            m_BoneOrPart= F.r_u16();
            fSpeed		= F.r_float();
            fAccrue		= F.r_float();
            fFalloff	= F.r_float();
            fPower		= F.r_float();
            bone_mots.resize(F.r_u16());
            string64 	buf;
            for(BoneMotionIt bm_it=bone_mots.begin(); bm_it!=bone_mots.end(); bm_it++){
                F.r_stringZ		(buf,sizeof(buf));
                bm_it->SetName	(buf);
                bm_it->m_Flags.assign(F.r_u8());
                for (int ch=0; ch<ctMaxChannel; ch++){
                    bm_it->envs[ch] = xr_new<CEnvelope> ();
                    bm_it->envs[ch]->Load_2(F);
                }
            }
        }
	}
	for(BoneMotionIt bm_it=bone_mots.begin(); bm_it!=bone_mots.end(); bm_it++)
    	xr_strlwr		(bm_it->name);
	return true;
}
Пример #22
0
bool CEditableObject::Load(IReader& F)
{
	bool bRes = true;
	do{
		u32 version = 0;
        shared_str buf;
		shared_str sh_name;
		R_ASSERT(F.r_chunk(EOBJ_CHUNK_VERSION,&version));
		if (version!=EOBJ_CURRENT_VERSION){
			ELog.DlgMsg( mtError, "CEditableObject: unsupported file version. Object can't load.");
			bRes = false;
			break;
		}

		R_ASSERT(F.r_chunk(EOBJ_CHUNK_FLAGS, &m_Flags.flags));

		if (F.find_chunk	(EOBJ_CHUNK_CLASSSCRIPT)){
			F.r_stringZ		(m_ClassScript);
		}

		if (F.find_chunk	(EOBJ_CHUNK_LODS)){
			F.r_stringZ		(m_LODs);
		}

		// surfaces
		if (F.find_chunk(EOBJ_CHUNK_SURFACES3)){
			u32 cnt = F.r_u32();
			m_Surfaces.resize(cnt);
			for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){
				*s_it 		= xr_new<CSurface>();
				F.r_stringZ	(buf);	(*s_it)->SetName		(buf.c_str());
				F.r_stringZ	(buf);	(*s_it)->SetShader		(buf.c_str());
				F.r_stringZ	(buf);	(*s_it)->SetShaderXRLC	(buf.c_str());
				F.r_stringZ	(buf);	(*s_it)->SetGameMtl		(buf.c_str());
				F.r_stringZ	(buf); 	(*s_it)->SetTexture		(buf.c_str());
				F.r_stringZ	(buf); 	(*s_it)->SetVMap		(buf.c_str());
				(*s_it)->m_Flags.assign(F.r_u32());
				(*s_it)->SetFVF		(F.r_u32());
				cnt 				= F.r_u32();
				if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str());
				R_ASSERT(1<=cnt);
			}
		}else if (F.find_chunk(EOBJ_CHUNK_SURFACES2)){
			u32 cnt = F.r_u32();
			m_Surfaces.resize(cnt);
			for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){
				*s_it 		= xr_new<CSurface>();
				F.r_stringZ	(buf);	(*s_it)->SetName		(buf.c_str());
				F.r_stringZ	(buf);	(*s_it)->SetShader		(buf.c_str());
				F.r_stringZ	(buf);	(*s_it)->SetShaderXRLC	(buf.c_str());
				F.r_stringZ	(buf); 	(*s_it)->SetTexture		(buf.c_str());
				F.r_stringZ	(buf); 	(*s_it)->SetVMap		(buf.c_str());
				(*s_it)->m_Flags.assign(F.r_u32()); 
				(*s_it)->SetFVF		(F.r_u32());
				cnt 				= F.r_u32();
				if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str());
				R_ASSERT(1<=cnt);
			}
		}else{
			R_ASSERT(F.find_chunk(EOBJ_CHUNK_SURFACES));
			u32 cnt = F.r_u32();
			m_Surfaces.resize(cnt);
			for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){
				*s_it = xr_new<CSurface>();
				F.r_stringZ(buf);
				(*s_it)->SetName(buf.c_str());
				F.r_stringZ(sh_name);
				(*s_it)->m_Flags.set(CSurface::sf2Sided,!!F.r_u8());
				(*s_it)->SetFVF		(F.r_u32());
				cnt 				= F.r_u32();
				if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str());
				R_ASSERT(1<=cnt);
				F.r_stringZ			(buf); (*s_it)->SetTexture(buf.c_str());
				F.r_stringZ			(buf); (*s_it)->SetVMap(buf.c_str());
				(*s_it)->SetShader		(sh_name.c_str());
				(*s_it)->SetShaderXRLC	("default");
			}

			// surfaces xrlc part
			if(F.find_chunk(EOBJ_CHUNK_SURFACES_XRLC))
				for (s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){
					F.r_stringZ(buf); (*s_it)->SetShaderXRLC(buf.c_str());
				}
		}

		// Load meshes
		IReader* OBJ = F.open_chunk(EOBJ_CHUNK_EDITMESHES);
		if(OBJ){
			IReader* M   = OBJ->open_chunk(0);
			for (int count=1; M; count++) {
				CEditableMesh* mesh=xr_new<CEditableMesh>(this);
				if (mesh->LoadMesh(*M))
					m_Meshes.push_back(mesh);
				else{
					ELog.DlgMsg( mtError, "CEditableObject: Can't load mesh '%s'!", *mesh->m_Name );
					xr_delete(mesh);
					bRes = false;
				}
				M->close();
				if (!bRes)	break;
				M = OBJ->open_chunk(count);
			}
			OBJ->close();
		}

		// bones
        if (bRes){
            IReader* B_CHUNK = F.open_chunk(EOBJ_CHUNK_BONES2);
            if (B_CHUNK){
                int chunk = 0;
                IReader* O;
                while (0!=(O=B_CHUNK->open_chunk(chunk++))){
                    m_Bones.push_back(xr_new<CBone>());
                    m_Bones.back()->Load_1(*O);
                    O->close();
                }
                B_CHUNK->close();
                PrepareBones();
            }else if (F.find_chunk(EOBJ_CHUNK_BONES)){
                m_Bones.resize(F.r_u32());
                for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++){
                    *b_it = xr_new<CBone>();
                    (*b_it)->Load_0(F);
                }
                PrepareBones();
            }
    		// skeleton motions
            if (F.find_chunk(EOBJ_CHUNK_SMOTIONS)){
                m_SMotions.resize(F.r_u32());
                for (SMotionIt s_it=m_SMotions.begin(); s_it!=m_SMotions.end(); s_it++){
                    *s_it = xr_new<CSMotion>();
                    if (!(*s_it)->Load(F)){
                        Log		("!Motions has different version. Load failed.");
                        xr_delete(*s_it);
                        m_SMotions.clear();
                        break;                 
                    }
                    // resort bone_mots
	                (*s_it)->SortBonesBySkeleton(m_Bones);
                }
            }
            if (F.find_chunk(EOBJ_CHUNK_SMOTIONS2)){
                F.r_stringZ		(m_SMotionRefs);
            }
        }

		// bone parts
        if (bRes){
            if (F.find_chunk(EOBJ_CHUNK_BONEPARTS)){
                m_BoneParts.resize(F.r_u32());
                bool bBPok = true;
                for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){
                    F.r_stringZ	(buf); bp_it->alias=buf;
                    bp_it->bones.resize(F.r_u32());
                    for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++){
                        int idx		= F.r_u32();
                        if ((idx>=0)&&(idx<(int)m_Bones.size())){
                            *s_it	= m_Bones[idx]->Name();
                        }else{
		                    Log		("!Invalid bone parts.",GetName());
                            bBPok = false;
                            break;
                        }
                    }
                    if (!bBPok) break;
                }
				if (!bBPok)	m_BoneParts.clear();
                if (!m_BoneParts.empty()&&!VerifyBoneParts())
                    Log		("!Invalid bone parts. Found duplicate bones in object '%s'.",GetName());
            }else if (F.find_chunk(EOBJ_CHUNK_BONEPARTS2)){
                m_BoneParts.resize(F.r_u32());
                for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){
                    F.r_stringZ	(buf); bp_it->alias=buf;
                    bp_it->bones.resize(F.r_u32());
                    for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++)
                        F.r_stringZ(*s_it);
                }
                if (!m_BoneParts.empty()&&!VerifyBoneParts())
                    Log			("!Invalid bone parts. Found duplicate bones in object '%s'.",GetName());
            }
        }

        if (bRes){
            if (F.find_chunk	(EOBJ_CHUNK_ACTORTRANSFORM)){
                F.r_fvector3	(a_vPosition);
                F.r_fvector3	(a_vRotate);
            }

            if (F.find_chunk	(EOBJ_CHUNK_DESC)){
                F.r_stringZ		(m_CreateName);
                F.r				(&m_CreateTime,sizeof(m_CreateTime));
                F.r_stringZ		(m_ModifName);
                F.r				(&m_ModifTime,sizeof(m_ModifTime));
            }
	
            ResetSAnimation();
        }

		if (!bRes) break;
		UpdateBox		();
		VerifyMeshNames	();
	}while(0);

	return bRes;
}
Пример #23
0
bool CEditableMesh::LoadMesh(IReader& F){
    u32 version=0;

    R_ASSERT(F.r_chunk(EMESH_CHUNK_VERSION,&version));
    if (version!=EMESH_CURRENT_VERSION){
        ELog.DlgMsg( mtError, "CEditableMesh: unsuported file version. Mesh can't load.");
        return false;
    }

    R_ASSERT(F.find_chunk(EMESH_CHUNK_MESHNAME));
	F.r_stringZ		(m_Name);

    R_ASSERT(F.r_chunk(EMESH_CHUNK_BBOX,&m_Box));
    R_ASSERT(F.r_chunk(EMESH_CHUNK_FLAGS,&m_Flags));
    F.r_chunk(EMESH_CHUNK_BOP,&m_Ops);

    R_ASSERT(F.find_chunk(EMESH_CHUNK_VERTS));
	m_VertCount			= F.r_u32();
    if (m_VertCount<3){
        Log				("!CEditableMesh: Vertices<3.");
     	return false;
    }
    m_Verts				= xr_alloc<Fvector>(m_VertCount);
	F.r					(m_Verts, m_VertCount*sizeof(Fvector));

    R_ASSERT(F.find_chunk(EMESH_CHUNK_FACES));
    m_FaceCount			= F.r_u32();
    m_Faces				= xr_alloc<st_Face>(m_FaceCount);
    if (m_FaceCount==0){
        Log				("!CEditableMesh: Faces==0.");
     	return false;
    }
	F.r					(m_Faces, m_FaceCount*sizeof(st_Face));

	m_SGs				= xr_alloc<u32>(m_FaceCount);
    Memory.mem_fill32	(m_SGs,m_Flags.is(flSGMask)?0:u32(-1),m_FaceCount);
	u32 sg_chunk_size	= F.find_chunk(EMESH_CHUNK_SG);
	if (sg_chunk_size){
		VERIFY			(m_FaceCount*sizeof(u32)==sg_chunk_size);
		F.r				(m_SGs, m_FaceCount*sizeof(u32));
	}

    R_ASSERT(F.find_chunk(EMESH_CHUNK_VMREFS));
    m_VMRefs.resize		(F.r_u32());
    int sz_vmpt			= sizeof(st_VMapPt);
    for (VMRefsIt r_it=m_VMRefs.begin(); r_it!=m_VMRefs.end(); r_it++){
    	r_it->count		= F.r_u8();          
	    r_it->pts		= xr_alloc<st_VMapPt>(r_it->count);
        F.r				(r_it->pts, sz_vmpt*r_it->count);
    }

    R_ASSERT(F.find_chunk(EMESH_CHUNK_SFACE));
    string128 surf_name;
    u32 sface_cnt		= F.r_u16(); // surface-face count
    for (u32 sp_i=0; sp_i<sface_cnt; sp_i++){
        F.r_stringZ		(surf_name,sizeof(surf_name));
        int surf_id;
        CSurface* surf	= m_Parent->FindSurfaceByName(surf_name, &surf_id); VERIFY(surf);
        IntVec&			face_lst = m_SurfFaces[surf];
        face_lst.resize	(F.r_u32());
        if (face_lst.empty()){
	        Log			("!Empty surface found: %s",surf->_Name());
    	 	return false;
        }
        F.r				(&*face_lst.begin(), face_lst.size()*sizeof(int));
        std::sort		(face_lst.begin(),face_lst.end());
    }

    if(F.find_chunk(EMESH_CHUNK_VMAPS_2)){
		m_VMaps.resize	(F.r_u32());
		for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++){
			*vm_it		= xr_new<st_VMap>();
			F.r_stringZ	((*vm_it)->name);
			(*vm_it)->dim 	= F.r_u8();
			(*vm_it)->polymap=F.r_u8();
			(*vm_it)->type	= F.r_u8();
			(*vm_it)->resize(F.r_u32());
			F.r			((*vm_it)->getVMdata(), (*vm_it)->VMdatasize());
			F.r			((*vm_it)->getVIdata(), (*vm_it)->VIdatasize());
			if ((*vm_it)->polymap)
				F.r		((*vm_it)->getPIdata(), (*vm_it)->PIdatasize());
		}
	}else{
		if(F.find_chunk(EMESH_CHUNK_VMAPS_1)){
			m_VMaps.resize	(F.r_u32());
			for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++){
				*vm_it		= xr_new<st_VMap>();
				F.r_stringZ	((*vm_it)->name);
				(*vm_it)->dim 	= F.r_u8();
				(*vm_it)->type	= F.r_u8();
				(*vm_it)->resize(F.r_u32());
				F.r			((*vm_it)->getVMdata(), (*vm_it)->VMdatasize() );
			}
		}else{
			R_ASSERT(F.find_chunk(EMESH_CHUNK_VMAPS_0));
			m_VMaps.resize	(F.r_u32());
			for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++){
				*vm_it		= xr_new<st_VMap>();
				F.r_stringZ	((*vm_it)->name);
				(*vm_it)->dim 	= 2;
				(*vm_it)->type	= vmtUV;
				(*vm_it)->resize(F.r_u32());
				F.r			((*vm_it)->getVMdata(), (*vm_it)->VMdatasize() );
			}
		}
		// update vmaps
		RebuildVMaps();
	}

#ifdef _EDITOR
    if (!EPrefs->object_flags.is(epoDeffLoadRB)){
        GenerateFNormals	();
        GenerateAdjacency	();
	    GenerateVNormals	();
		GenerateRenderBuffers();
        UnloadFNormals		();
        UnloadAdjacency		();
	    UnloadVNormals		();
    }
    if (!EPrefs->object_flags.is(epoDeffLoadCF)) GenerateCFModel();       
#endif
	Optimize(false);
    RebuildVMaps();

	return true;
}