bool CFlowGraphModule::PreLoadModule(const char* fileName) { m_fileName = fileName; XmlNodeRef moduleRef = gEnv->pSystem->LoadXmlFromFile(fileName); if (!moduleRef) { CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "Unable to preload Flowgraph Module: %s", PathUtil::GetFileName(fileName).c_str()); return false; } assert(!stricmp(moduleRef->getTag(), "Graph")); bool module = false; moduleRef->getAttr("isModule", module); assert(module); XmlString tempName; if (moduleRef->getAttr("moduleName", tempName)) m_name = tempName; bool bResult = (m_pRootGraph != NULL); assert(m_pRootGraph == NULL); // first handle module ports XmlNodeRef modulePorts = moduleRef->findChild("ModuleInputsOutputs"); RemoveModulePorts(); if (modulePorts) { int nPorts = modulePorts->getChildCount(); for (int i = 0; i < nPorts; ++i) { XmlString portName; int portType; bool isInput; XmlNodeRef port = modulePorts->getChild(i); port->getAttr("Name", portName); port->getAttr("Type", portType); port->getAttr("Input", isInput); IFlowGraphModule::SModulePortConfig portConfig; portConfig.name = portName.c_str(); portConfig.type = (EFlowDataTypes)portType; portConfig.input = isInput; AddModulePort(portConfig); } } // and create nodes for this module (needs to be done before actual graph load, so that the // nodes can be created there) RegisterNodes(); return bResult; }
void CDLCManager::PopulateDLCContents(const XmlNodeRef &rootNode, int dlcId, const char* name ) { mbstowcs( m_dlcContents[dlcId].name, name, MAX_DLC_NAME ); XmlNodeRef levelsNode = rootNode->findChild("levels"); if (levelsNode) { XmlString levelName; int numLevels = levelsNode->getChildCount(); CryLog( "Found %d levels in the DLC", numLevels ); m_dlcContents[dlcId].levels.reserve(numLevels); for (int i=0; i<numLevels; ++i) { XmlNodeRef levelNode = levelsNode->getChild(i); if (levelNode->getAttr("name", levelName)) { CryLog( "Found level %s and added to the DLC manager", levelName.c_str() ); m_dlcContents[dlcId].levels.push_back(levelName); } } } XmlNodeRef bonusNode = rootNode->findChild("bonus"); if( bonusNode ) { CryLog( "DLC pak includes a pre-sale bonus" ); uint32 bonusID = 0; bonusNode->getAttr("id", bonusID ); m_dlcContents[dlcId].bonusID = bonusID; } XmlNodeRef uniqueIdNode = rootNode->findChild("uniqueId"); if( uniqueIdNode ) { uint32 uniqueID = 0; uniqueIdNode->getAttr("id", uniqueID ); m_dlcContents[dlcId].uniqueID = uniqueID; } XmlNodeRef uniqueTagNode = rootNode->findChild("uniqueTag"); if( uniqueTagNode ) { const char* str = uniqueTagNode->getAttr( "tag" ); m_dlcContents[dlcId].uniqueTag.Format( str ); } }
void CDownloadableResource::LoadConfig( XmlNodeRef inNode) { XmlString str; inNode->getAttr("port",m_port); inNode->getAttr("maxSize",m_maxDownloadSize); #define ReadXMLStr(key,out) if (inNode->getAttr(key,str)) { out=str.c_str(); } ReadXMLStr("server",m_server); ReadXMLStr("name",m_descName); ReadXMLStr("prefix",m_urlPrefix); if (inNode->getAttr("url",str)) { m_url.Format("%s/%s",k_platformPrefix,str.c_str()); } #undef ReadXMLStr }
void GetArchetypesFromLib(XmlNodeRef root, string& name, std::vector<string>* archetypeNames) { if (!root) return; const int iChildCount = root->getChildCount(); for (int iChild = 0; iChild < iChildCount; ++iChild) { XmlNodeRef pChild = root->getChild(iChild); if (!pChild || stricmp(pChild->getTag(), "EntityPrototype")) continue; XmlString sChildName; pChild->getAttr("Name", sChildName); string sFullName; sFullName.Format("%s.%s", name.c_str(), sChildName.c_str()); archetypeNames->push_back(sFullName); } }
bool CDLCManager::VerifyCRCs(const XmlNodeRef &crcNode, const char* sDLCRootFolder) { bool success = true; CryFixedStringT<ICryPak::g_nMaxPath> path; int numFiles = crcNode->getChildCount(); XmlString fileName; uint32 storedCrc; for (int i=0; i<numFiles; ++i) { XmlNodeRef fileNode = crcNode->getChild(i); if (fileNode->getAttr("name", fileName) && fileNode->getAttr("crc", storedCrc)) { bool useCryFile = false; #if defined(WIN32) || defined(WIN64) path.Format("%s/%s", sDLCRootFolder, fileName.c_str()); useCryFile = true; #else CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "No Platform defined in DLCManager" ); #endif CryLog( "CRC: Checking CRC of %s", path.c_str() ); success = gEnv->pCryPak->OpenPack( path.c_str() ); if( !success ) { CryLog( "CRC: Failed to open pack" ); } uint32 computedCrc = gEnv->pCryPak->ComputeCachedPakCDR_CRC( path.c_str(), useCryFile ); if (computedCrc != storedCrc) { CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CRC on file %s (%u) does not match stored value (%u)", path.c_str(), computedCrc, storedCrc); success = false; } gEnv->pCryPak->ClosePack( path.c_str() ); } } return success; }
void CDLCManager::OnDLCMounted(const XmlNodeRef &rootNode, const char* sDLCRootFolder) { CryLog( "OnDLCMounted: '%s'", sDLCRootFolder); XmlString minVersion; XmlString sName; int dlcId; if (rootNode->getAttr("minversion", minVersion) && rootNode->getAttr("name", sName) && rootNode->getAttr("id", dlcId)) { CryLog( "DLC Name = %s, ID = %d", sName.c_str(), dlcId ); if (dlcId >= 0 && dlcId < MAX_DLC_COUNT) { #if (! ENTITLEMENTS_AUTHORATIVE) || defined (DEDICATED_SERVER) //whenever we load a dlc, it is automatically allowed m_allowedDLCs |= BIT(dlcId); #endif if (!IsDLCReallyLoaded(dlcId)) { SFileVersion currentVersion = gEnv->pSystem->GetProductVersion(); SFileVersion minimumVersion = SFileVersion(minVersion.c_str()); if (currentVersion < minimumVersion) { char currentVersionString[MAX_VERSION_STRING]; currentVersion.ToString(currentVersionString); CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Unable to load DLC \"%s\" because it requires version %s and current version is %s", sName.c_str(), minVersion.c_str(), currentVersionString); RequestDLCWarning("DLCVersionMismatch",2, true); } else { XmlNodeRef crcNode = rootNode->findChild("crcs"); PopulateDLCContents(rootNode, dlcId, sName.c_str() ); //insist that CRCs are present and level folders match listed contents if ( !crcNode || !VerifyCRCs(crcNode, sDLCRootFolder) || !CheckLevels( dlcId, sDLCRootFolder ) ) { ClearDLCContents( dlcId ); RequestDLCWarning("DLCFileCorrupt",4, true); CryLog("DLC \"%s\" not loaded successfully", sName.c_str()); } else { CryLog("DLC \"%s\" loaded successfully", sName.c_str()); m_loadedDLCs |= BIT(dlcId); m_dlcContents[ dlcId ].root.Format( "%s", sDLCRootFolder ); XmlNodeRef unlocksXml = rootNode->findChild("Unlocks"); if(unlocksXml) { DoDLCUnlocks( unlocksXml, dlcId); } CryFixedStringT<ICryPak::g_nMaxPath> path; //Level Extras pak contains things which need to be accessed relative to the Level Path //eg. Level meta data, icons and mini maps //also contains Level Names and Rich Presence mappings path.Format("%s/dlcLevelExtras.pak", sDLCRootFolder); CryLog( "DLC: Opening %s as %s", path.c_str(), sDLCRootFolder ); bool success = gEnv->pCryPak->OpenPack( sDLCRootFolder, path ); //Data pak contains things which need to be accessed relative to the Game Root //eg. Objects and Textures for new entities path.Format("%s/dlcData.pak", sDLCRootFolder); string gamePath = PathUtil::GetGameFolder(); CryLog( "DLC: Opening %s as %s", path.c_str(), gamePath.c_str() ); success &= gEnv->pCryPak->OpenPack( gamePath.c_str(), path ); if (success == false) { CRY_ASSERT_MESSAGE(success, "Failed to open DLC packs"); CryLog("Failed to open DLC packs '%s'",path.c_str()); } else { //Only DLCs with data paks can have strings or levels path.Format("%s/", sDLCRootFolder); CryLog( "DLCManager: Adding %s to Mod paths", path.c_str() ); gEnv->pCryPak->AddMod(path.c_str()); //load string mappings for level names in this DLC path.Format( "%s/scripts/dlc%dnames.xml", sDLCRootFolder, dlcId ); g_pGame->LoadMappedLevelNames( path.c_str() ); //and load the actual localized strings ILocalizationManager *pLocMan = GetISystem()->GetLocalizationManager(); path.Format( "%s/scripts/dlc%d%s.xml", sDLCRootFolder, dlcId, pLocMan->GetLanguage() ); pLocMan->LoadExcelXmlSpreadsheet( path ); //see if the pack has a description CryFixedStringT<32> descriptionKey; descriptionKey.Format( "dlc%d_pack_description", dlcId ); SLocalizedInfoGame tempInfo; if( pLocMan->GetLocalizedInfoByKey( descriptionKey.c_str(), tempInfo ) ) { m_dlcContents[ dlcId ].descriptionStr.Format( "@%s", descriptionKey.c_str() ); } //and load the Rich Presence mappings path.Format( "%s/scripts/dlc%dpresence.xml", sDLCRootFolder, dlcId ); g_pGame->AddRichPresence( path.c_str() ); //and get the Score Rewards Path m_dlcContents[ dlcId ].scoreRewardsPath.Format( "%s/scripts/dlc%drewards.xml", sDLCRootFolder, dlcId ); //and the Playlists Path m_dlcContents[ dlcId ].playlistsPath.Format( "%s/scripts/dlc%dplaylists", sDLCRootFolder, dlcId ); ILevelSystem *pLevelSystem = g_pGame->GetIGameFramework()->GetILevelSystem(); path.Format("%s/levels", sDLCRootFolder); CryLog("DLC Levelsystem rescan '%s'", path.c_str()); const uint32 dlcTag = 'DLC0'; pLevelSystem->Rescan(path.c_str(), dlcTag); } } } } else { CryLog("DLC %d already loaded, OK if from re-sign in", dlcId ); } } else { CRY_ASSERT_MESSAGE(false, "DLC id is not within range"); } } else { RequestDLCWarning("DLCXmlError",4, true); } }