void CCheckpointSystem::WriteXML(XmlNodeRef data, const char *fileName)
{
	IPlayerProfileManager *pPlayerProfMan = CCryAction::GetCryAction()->GetIPlayerProfileManager();;

	string path;
	if(!pPlayerProfMan)
	{
		path = CONSOLE_SAVEGAME_DIRECTORY;
	}
	else
	{
		const char* sharedSaveGameFolder = pPlayerProfMan->GetSharedSaveGameFolder();
		path = sharedSaveGameFolder;
	}

	path = PathUtil::AddSlash(path);
	path.append(fileName);
	if(data)
	{
		//write checkpoint data to xml file with given name
		const string xmlHeader("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");

		bool bSuccess = data->saveToFile(path.c_str(), 32767/2, NULL);
		if (bSuccess)
		{
			//remember last saved checkpoint for "quickload"
			g_lastSavedCheckpoint = fileName;
		}
		else
			CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Failed writing checkpoint file at %s", path.c_str());
	}
}
示例#2
0
	bool State_t::SaveToFile(IFile* file) const
	{
		XmlNodeRef xmlInfo = CreateXmlNode("AgentState");

        CTextNode node(xmlInfo);
        
		this->m_vars.Save(&node);

        return xmlInfo->saveToFile(file);
	}
示例#3
0
	bool State_t::SaveToFile(const char* fileName) const
	{
		XmlNodeRef xmlInfo = CreateXmlNode("AgentState");

        CTextNode node(xmlInfo);
		
		this->m_vars.Save(&node);

		if (this->m_bt)
		{
			this->m_bt->Save(&node);
		}

        CFileSystem::MakeSureDirectoryExist(fileName);
        return xmlInfo->saveToFile(fileName);
	}
示例#4
0
void CGameStats::SaveStats()
{
	if(m_roundStats->m_round)
	{
		SGetTime time(m_roundStart);
		CryFixedStringT<128> timeStr;
		time_t ltime;
		::time( &ltime );
		tm *today = localtime( &ltime );
		strftime(timeStr.m_str, timeStr.MAX_SIZE, "%y-%m-%d_%H%M%S", today);

		XmlNodeRef root = gEnv->pSystem->CreateXmlNode("round");
		root->setAttr("round", m_roundStats->m_round);
		SRoundStats::SaveToXML(root, "", *m_roundStats.get());
		for(PlayerStatsMap::iterator it = m_playerMap.begin(), eit = m_playerMap.end(); it != eit; ++it)
		{
			for( SPlayerInfo::TStatsVct::iterator si = it->second.stats.begin(); si < it->second.stats.end(); ++si )
			{
				it->second.stats.back()->End(time);

				XmlNodeRef plr = gEnv->pSystem->CreateXmlNode("player");
				if(IEntity *p = gEnv->pEntitySystem->GetEntity(it->first))
				{
					plr->setAttr("id", p->GetId());
					if ( IActor* pAct = m_pGameFramework->GetIActorSystem()->GetActor(p->GetId()) )
					{
						int profile = m_pGameFramework->GetNetChannel(pAct->GetChannelId())->GetProfileId();
						plr->setAttr("profile", profile);
					}
				}
				plr->setAttr("name", it->second.name);
				plr->setAttr("team", it->second.team);
				plr->setAttr("spectator", it->second.spectator);
			
				SPlayerStats::SaveToXML(plr, "", *(si->get()));
				root->addChild(plr);
			}
		}
		root->saveToFile(string().Format("%s/StatsLogs/Round_%s.xml", gEnv->pCryPak->GetAlias("%USER%"), timeStr.c_str()));
	}
}
void CAnimationProxyDualCharacterBase::Generate1P3PPairFile()
{
    const int MAX_MODELS = 128;
    ICharacterModel *pCharacterModels[MAX_MODELS];
    int numModels;
    gEnv->pCharacterManager->GetLoadedModels(NULL, numModels);
    numModels = min(numModels, MAX_MODELS);

    gEnv->pCharacterManager->GetLoadedModels(pCharacterModels, numModels);

    s_animCrCHashMap.clear();

    for (uint32 i=0; i<numModels; ++i)
        {
            if (pCharacterModels[i]->GetNumInstances() > 0)
                {
                    IAnimationSet *animSet = pCharacterModels[i]->GetICharInstanceFromModel(0)->GetIAnimationSet();
                    uint32 numAnims = animSet->GetAnimationCount();

                    for (uint32 anm = 0; anm < numAnims; anm++)
                        {
                            uint32 animCRC = animSet->GetCRCByAnimID(anm);
                            if (s_animCrCHashMap.find(animCRC) == s_animCrCHashMap.end())
                                {
                                    int animID3P = -1;
                                    const char *name = animSet->GetNameByAnimID(anm);
                                    if (strlen(name) >= 255)
                                        {
                                            CRY_ASSERT_MESSAGE(0, string().Format("[CAnimationProxyDualCharacterBase::Generate1P3PPairFiles] Animname %s overruns buffer", name));
                                            CryLogAlways("[CAnimationProxyDualCharacterBase::Generate1P3PPairFiles] Animname %s overruns buffer", name);
                                            continue;
                                        }
                                    const char *pos = CryStringUtils::stristr(name, "_1p");
                                    if (pos)
                                        {
                                            char name3P[256];
                                            strcpy(name3P, name);
                                            name3P[(int)(TRUNCATE_PTR)pos + 1 - (int)(TRUNCATE_PTR)name] = '3';
                                            animID3P = animSet->GetAnimIDByName(name3P);

                                            if (animID3P >= 0)
                                                {
                                                    uint32 animCRCTP = animSet->GetCRCByAnimID(animID3P);
                                                    s_animCrCHashMap[animCRC] = animCRCTP;
                                                }
                                        }
                                }
                        }
                }
        }


    //--- Save the file
    CryFixedStringT<256> animCrC;
    XmlNodeRef nodePairList	= gEnv->pSystem->CreateXmlNode( "Pairs" );
    for (NameHashMap::iterator iter = s_animCrCHashMap.begin(); iter != s_animCrCHashMap.end(); ++iter)
        {
            XmlNodeRef nodePair = nodePairList->newChild( "Pair" );
            animCrC.Format("%u", iter->first);
            nodePair->setAttr( "FP", animCrC.c_str());
            animCrC.Format("%u", iter->second);
            nodePair->setAttr( "TP", animCrC.c_str());
        }
    nodePairList->saveToFile(ANIMPAIR_PATHNAME);

    s_animCrCHashMap.clear();
    Load1P3PPairFile();
}
示例#6
0
    bool State_t::SaveToFile(IFile* file, Agent* pAgent) const
    {
        XmlNodeRef xmlInfo = this->SaveToXmlNode(pAgent);

        return xmlInfo->saveToFile(file);
    }
示例#7
0
 bool State_t::SaveToFile(const char* fileName, Agent* pAgent) const
 {
     XmlNodeRef xmlInfo = this->SaveToXmlNode(pAgent);
     CFileSystem::MakeSureDirectoryExist(fileName);
     return xmlInfo->saveToFile(fileName);
 }
bool CScriptSurfaceTypesLoader::LoadSurfaceTypes( const char *sFolder,bool bReload )
{
	{
		if (!gEnv->p3DEngine)
			return false;

		I3DEngine *pEngine = gEnv->p3DEngine;
		ISurfaceTypeEnumerator *pEnum = pEngine->GetMaterialManager()->GetSurfaceTypeManager()->GetEnumerator();
		if (pEnum)
		{
			for (ISurfaceType *pSurfaceType = pEnum->GetFirst(); pSurfaceType; pSurfaceType = pEnum->GetNext())
			{
				SmartScriptTable mtlTable(gEnv->pScriptSystem);
				gEnv->pScriptSystem->SetGlobalValue( pSurfaceType->GetName(),mtlTable );

				SmartScriptTable aiTable(gEnv->pScriptSystem);
				mtlTable->SetValue("AI",aiTable);
				aiTable->SetValue( "fImpactRadius",5.0f );
				aiTable->SetValue( "fFootStepRadius",15.0f );
				aiTable->SetValue( "proneMult",0.2f );
				aiTable->SetValue( "crouchMult",0.5f );
				aiTable->SetValue( "movingMult",2.5f );
			}

			pEnum->Release();
		}
	}

	return true; // Do not load surface types from script anymore.

	m_root = GetISystem()->CreateXmlNode("SurfaceTypes");

	IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
	//////////////////////////////////////////////////////////////////////////
	// Make sure Materials table exist.
	//////////////////////////////////////////////////////////////////////////
	SmartScriptTable mtlTable;

	if (!pScriptSystem->GetGlobalValue("Materials", mtlTable) || bReload)
	{
		mtlTable = pScriptSystem->CreateTable();
		pScriptSystem->SetGlobalValue("Materials", mtlTable);
	}

	ICryPak *pIPak = gEnv->pCryPak;

	ISurfaceTypeManager *pSurfaceManager = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager();

	if (!bReload)
		stl::push_back_unique( m_folders,sFolder );

	string searchFolder = string(sFolder) + "/";;
	string searchFilter = searchFolder + "mat_*.lua";

	gEnv->pScriptSystem->ExecuteFile(searchFolder+"common.lua", false, bReload);

	_finddata_t fd;
	intptr_t fhandle;
	fhandle = pIPak->FindFirst( searchFilter,&fd );
	if (fhandle != -1)
	{
		do {
			// Skip back folders.
			if (fd.attrib & _A_SUBDIR) // skip if directory.
				continue;

			char name[_MAX_PATH];
			_splitpath( fd.name,NULL,NULL,name,NULL );

			if (strlen(name) == 0)
				continue;

			if (bReload)
			{
				ISurfaceType *pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(name);
				if (pSurfaceType)
				{
					pSurfaceType->Load( pSurfaceType->GetId() );
					continue;
				}
			}

			ISurfaceType *pSurfaceType = new CScriptSurfaceType( this,name,searchFolder+fd.name,0 );
			if (pSurfaceManager->RegisterSurfaceType( pSurfaceType ))
				m_surfaceTypes.push_back(pSurfaceType);
			else
				pSurfaceType->Release();
		} while (pIPak->FindNext( fhandle,&fd ) == 0);
		pIPak->FindClose(fhandle);
	}

	if (m_root)
	{
		m_root->saveToFile( "SurfaceTypes.xml" );
	}

	return true;
}