int CGameStartup::Run( const char * autoStartLevelName ) { #if defined(RELEASE_SERVER_SECURITY) CryLogAlways("Performing Validation Checks"); if (!PerformDedicatedInstallationSanityCheck()) { CryFatalError("Installation appears to be corrupt. Please check the log file for a list of problems."); } #endif gEnv->pConsole->ExecuteString( "exec autoexec.cfg" ); if (autoStartLevelName) { //load savegame if(CryStringUtils::stristr(autoStartLevelName, CRY_SAVEGAME_FILE_EXT) != 0 ) { CryFixedStringT<256> fileName (autoStartLevelName); // NOTE! two step trimming is intended! fileName.Trim(" "); // first: remove enclosing spaces (outside ") fileName.Trim("\""); // second: remove potential enclosing " gEnv->pGame->GetIGameFramework()->LoadGame(fileName.c_str()); } else //start specified level { CryFixedStringT<256> mapCmd ("map "); mapCmd+=autoStartLevelName; gEnv->pConsole->ExecuteString(mapCmd.c_str()); } } #ifdef WIN32 if (!(gEnv && gEnv->pSystem) || (!gEnv->IsEditor() && !gEnv->IsDedicated())) { ::ShowCursor(TRUE); // Make the cursor visible again (it was hidden in InitFramework() ) if (gEnv && gEnv->pSystem && gEnv->pSystem->GetIHardwareMouse()) gEnv->pSystem->GetIHardwareMouse()->DecrementCounter(); } AllowAccessibilityShortcutKeys(false); for(;;) { ISystem *pSystem = gEnv ? gEnv->pSystem : 0; if (!pSystem) { break; } if (pSystem->PumpWindowMessage(false) == -1) { break; } if (!Update(true, 0)) { // need to clean the message loop (WM_QUIT might cause problems in the case of a restart) // another message loop might have WM_QUIT already so we cannot rely only on this pSystem->PumpWindowMessage(true); break; } } #else // We should use bVisibleByDefault=false then... if (gEnv && gEnv->pHardwareMouse) gEnv->pHardwareMouse->DecrementCounter(); #if !defined(DURANGO) for(;;) { if (!Update(true, 0)) { break; } } #endif #endif //WIN32 return 0; }
void CHUDMissionObjectiveSystem::LoadObjectiveAnalysisData(const char* levelpath) { CryFixedStringT<128> filename; if(levelpath==NULL) { filename = "Libs/UI/ObjectivesAnalysis.xml"; } else { filename.Format("%s/leveldata/ObjectivesAnalysis.xml", levelpath); } XmlNodeRef root = GetISystem()->LoadXmlFromFile(filename.c_str()); if (root == 0) return; XmlNodeRef analysisDataContainerNode = root->findChild("AnalysisData"); SObjectiveAnalysisData analysisData; SSingleObjectiveAnalysisData singleAnalysisData; if (analysisDataContainerNode != 0) { for(int i = 0; i < analysisDataContainerNode->getChildCount(); ++i) { XmlNodeRef analysisDataNode = analysisDataContainerNode->getChild(i); const char* szOuterId = analysisDataNode->getAttr("Id"); if (szOuterId == NULL || szOuterId[0] == '\0') { GameWarning("CHUDMissionObjectiveSystem::LoadObjectiveAnalysisData: Failed to load analysisdata, invalid id"); continue; } analysisData.m_singleObjectiveData.clear(); const int iNumSingleAnalysis = analysisDataNode->getChildCount(); bool bFailedAddedSingleAnalysis = false; for (int j = 0; j < iNumSingleAnalysis; j++) { XmlNodeRef singleAnalysisDataNode = analysisDataNode->getChild(j); const char* szSingleId; int iUseOuterId; // UseOuterId saves needing to duplicate text to the outer Id bool bResult = singleAnalysisDataNode->getAttr("UseOuterId", iUseOuterId); if (bResult && (iUseOuterId == 1)) { szSingleId = szOuterId; } else { szSingleId = analysisDataNode->getAttr("Id"); } if (szSingleId == NULL || szSingleId[0] == '\0') { GameWarning("CHUDMissionObjectiveSystem::LoadObjectiveAnalysisData: Failed to load single analysisdata section for analysis: %s, invalid id", szOuterId); bFailedAddedSingleAnalysis = true; break; } singleAnalysisData.m_id = szSingleId; singleAnalysisDataNode->getAttr("Percent", singleAnalysisData.m_fPercent); analysisData.m_singleObjectiveData.push_back(singleAnalysisData); } if (bFailedAddedSingleAnalysis || analysisData.m_singleObjectiveData.size() < 1) { GameWarning("CHUDMissionObjectiveSystem::LoadObjectiveAnalysisData: Failed to load analysisdata: %s, problem with section data", szOuterId); continue; } analysisDataNode->getAttr("OverrideSectionID",analysisData.m_iOverrideIndex); analysisDataNode->getAttr("AttachInWorld", analysisData.m_bAttachInWorld); m_objectiveAnalysisData[szOuterId] = analysisData; } } }
void COptionsManager::ResetDefaults(const char* option) { if(!m_pPlayerProfileManager) return; const char* user = m_pPlayerProfileManager->GetCurrentUser(); IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user); if(!pProfile) return; XmlNodeRef root = GetISystem()->LoadXmlFile("libs/config/profiles/default/attributes.xml"); bool resetAll = (option==NULL); bool detectHardware = false; for (int i = 0; i < root->getChildCount(); ++i) { XmlNodeRef enumNameNode = root->getChild(i); const char *name = enumNameNode->getAttr("name"); const char *value = enumNameNode->getAttr("value"); if(name && value) { const char* attribCVar = ""; bool bWriteToCfg = false; const bool bIsOption = IsOption(name, attribCVar, bWriteToCfg); if(bIsOption) { if(!resetAll && strcmp(attribCVar,option)) continue; if(!strcmp(attribCVar, "sys_spec_Shadows")) { detectHardware = true; } if(!strcmp(attribCVar, "hud_colorLine")) { CryFixedStringT<32> color; color.Format("%d", g_pGameCVars->hud_colorLine); SetCrysisProfileColor(color.c_str()); } if(!strcmp(attribCVar,"pb_client")) { if(atoi(value)==0) { m_pbEnabled = false; gEnv->pConsole->ExecuteString("net_pb_cl_enable false"); } else { m_pbEnabled = true; gEnv->pConsole->ExecuteString("net_pb_cl_enable true"); } } else if(!strcmp(attribCVar, "g_difficultyLevel")) { SetDifficulty(value); } else { ICVar *pCVar = gEnv->pConsole->GetCVar(attribCVar); if(pCVar) { pCVar->Set(value); } } if(!resetAll) break; } } } if(detectHardware) AutoDetectHardware(""); }
void CGameBrowser::ConfigurationCallback(ECryLobbyService service, SConfigurationParams *requestedParams, uint32 paramCount) { uint32 a; for (a=0;a<paramCount;++a) { switch (requestedParams[a].m_fourCCID) { case CLCC_LAN_USER_NAME: { uint32 userIndex = g_pGame->GetExclusiveControllerDeviceIndex(); IPlatformOS *pPlatformOS = gEnv->pSystem->GetPlatformOS(); IPlatformOS::TUserName tUserName = ""; if(pPlatformOS) { pPlatformOS->UserGetName(userIndex, tUserName); } // this will null terminate for us if necessary cry_strncpy(s_profileName, tUserName.c_str(), CRYLOBBY_USER_NAME_LENGTH); int instance = gEnv->pSystem->GetApplicationInstance(); if (instance>0) { size_t length = strlen(s_profileName); if (length + 3 < CRYLOBBY_USER_NAME_LENGTH) { s_profileName[length] = '('; s_profileName[length+1] = '0' + instance; s_profileName[length+2] = ')'; s_profileName[length+3] = 0; } } requestedParams[a].m_pData = s_profileName; } break; #if defined(PS3) || defined(ORBIS) || USE_STEAM case CLCC_CRYLOBBY_PRESENCE_CONVERTER: { SCryLobbyPresenceConverter* pConverter = (SCryLobbyPresenceConverter*)requestedParams[a].m_pData; if (pConverter) { //-- Use the pConverter->m_numData data items in pConverter->m_pData to create a string in pConverter->m_pStringBuffer //-- Use the initial value of pConverter->sizeOfStringBuffer as a maximum string length allowed, but //-- update pConverter->sizeOfStringBuffer to the correct length when the string is filled in. //-- Set pConverter->sizeOfStringBuffer = 0 to invalidate bad data so it isn't sent to PSN. CryFixedStringT<MAX_PRESENCE_STRING_SIZE> strPresence; if(CreatePresenceString(strPresence, pConverter->m_pData, pConverter->m_numData)) { CryLog("[RichPresence] Succeeded %s", strPresence.c_str()); sprintf((char*)pConverter->m_pStringBuffer, "%s", strPresence.c_str()); pConverter->m_sizeOfStringBuffer = strlen((char*)pConverter->m_pStringBuffer); #if defined(PS3) if (g_pGame) { pConverter->m_sessionId = g_pGame->GetPendingRichPresenceSessionID(); } #endif } else { CryLog("[RichPresence] Failed to create rich presence string"); pConverter->m_sizeOfStringBuffer = 0; } } } break; #endif #if defined(XENON) case CLCC_LIVE_TITLE_ID: requestedParams[a].m_32 = LIVE_TITLE_ID; break; #endif//XENON #if defined(PS3) case CLCC_PSN_COMMUNICATION_ID: requestedParams[a].m_pData = (void*)&s_communication_id; break; case CLCC_PSN_COMMUNICATION_PASSPHRASE: requestedParams[a].m_pData = (void*)&s_communication_passphrase; break; case CLCC_PSN_COMMUNICATION_SIGNATURE: requestedParams[a].m_pData = (void*)&s_communication_signature; break; case CLCC_PSN_CUSTOM_MENU_GAME_INVITE_STRING: GetXMBString("@xmb_invite_button", (SCryLobbyXMBString*)requestedParams[a].m_pData); // <= SCE_NP_CUSTOM_MENU_ACTION_CHARACTER_MAX (max 21 chars + nul) break; case CLCC_PSN_CUSTOM_MENU_GAME_JOIN_STRING: GetXMBString("@xmb_join_button", (SCryLobbyXMBString*)requestedParams[a].m_pData); // <= SCE_NP_CUSTOM_MENU_ACTION_CHARACTER_MAX (max 21 chars + nul) break; case CLCC_PSN_INVITE_SUBJECT_STRING: GetXMBString("@xmb_invite_sub", (SCryLobbyXMBString*)requestedParams[a].m_pData); // < SCE_NP_BASIC_SUBJECT_CHARACTER_MAX (max 17 chars + nul) break; case CLCC_PSN_INVITE_BODY_STRING: GetXMBString("@xmb_invite_body", (SCryLobbyXMBString*)requestedParams[a].m_pData); // < SCE_NP_BASIC_BODY_CHARACTER_MAX (max 511 chars + nul) break; case CLCC_PSN_FRIEND_REQUEST_SUBJECT_STRING: GetXMBString("@xmb_friendrq_sub", (SCryLobbyXMBString*)requestedParams[a].m_pData); // < SCE_NP_BASIC_SUBJECT_CHARACTER_MAX (max 17 chars + nul) break; case CLCC_PSN_FRIEND_REQUEST_BODY_STRING: GetXMBString("@xmb_friendrq_body", (SCryLobbyXMBString*)requestedParams[a].m_pData); // < SCE_NP_BASIC_BODY_CHARACTER_MAX (max 511 chars + nul) break; case CLCC_PSN_AGE_LIMIT: { SAgeData *pAgeData = (SAgeData*)requestedParams[a].m_pData; int userRegion = (pAgeData->countryCode[0] << 8) + pAgeData->countryCode[1]; g_pGame->SetUserRegion(userRegion); if (strncmp(gPS3Env->sTitleID,"BLES",4)==0) { if (strncmp(pAgeData->countryCode,"de",2)==0) { // GERMANY requestedParams[a].m_32 = 18; } else if(strncmp(pAgeData->countryCode,"au",2)==0) { // AUSTRALIA requestedParams[a].m_32 = 15; } else { // EUROPE EXCLUDING GERMANY AND AUSTRALIA requestedParams[a].m_32 = 16; } } else { // US AND JAPAN (and any unknown). requestedParams[a].m_32 = 17; } } break; case CLCC_PSN_STORE_ID: if (strncmp(gPS3Env->sTitleID,"BLES",4)==0) { requestedParams[a].m_pData = (void*)s_sceeStore_id; break; } if (strncmp(gPS3Env->sTitleID,"BLUS",4)==0) { requestedParams[a].m_pData = (void*)s_sceaStore_id; break; } if (strncmp(gPS3Env->sTitleID,"BLJM",4)==0) { requestedParams[a].m_pData = (void*)s_scejStore_id; break; } requestedParams[a].m_pData = (void*)s_testStore_id; break; case CLCC_PSN_IS_DLC_INSTALLED: if (g_pGame && g_pGame->GetDLCManager() && g_pGame->GetDLCManager()->IsDLCLoaded(requestedParams[a].m_8)) { requestedParams[a].m_8 = 1; } else { requestedParams[a].m_8 = 0; } break; #endif//PS3 case CLCC_CRYSTATS_ENCRYPTION_KEY: { #if defined(XENON) requestedParams[a].m_pData = (void*)""; #elif defined(PS3) || defined(ORBIS) requestedParams[a].m_pData = (void*)""; #else requestedParams[a].m_pData = (void*)""; #endif } break; case CLCC_MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH: requestedParams[a].m_8 = MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH; break; #if USE_STEAM #if !defined(RELEASE) case CLCC_STEAM_APPID: requestedParams[a].m_32 = STEAM_APPID; break; #endif // !defined(RELEASE) #endif // USE_STEAM default: CRY_ASSERT_MESSAGE(0,"Unknown Configuration Parameter Requested!"); break; } } }
void CHUDMissionObjectiveSystem::LoadLevelObjectivesInternal(const char* levelpath) { CryFixedStringT<128> filename; if (levelpath==NULL) { // there is no Objectives_global.xml, but there is a file with the previous standard naming // load the file with old name for backwards compatibility if (!gEnv->pCryPak->IsFileExist("Libs/UI/Objectives_global.xml") && gEnv->pCryPak->IsFileExist("Libs/UI/Objectives_new.xml")) { CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "File 'Objectives_new.xml' is deprecated and should be renamed to 'Objectives_global.xml'"); filename = "Libs/UI/Objectives_new.xml"; } else { filename = "Libs/UI/Objectives_global.xml"; } } else { filename.Format("%s/leveldata/Objectives.xml", levelpath); } /*if(gEnv->bMultiplayer) { CGameRules *pGameRules = g_pGame->GetGameRules(); if(stricmp (pGameRules->GetEntity()->GetClass()->GetName(), "Coop")) filename = "Libs/UI/MP_Objectives.xml"; }*/ XmlNodeRef missionObjectives = GetISystem()->LoadXmlFromFile(filename.c_str()); if (missionObjectives == 0) return; for(int tag = 0; tag < missionObjectives->getChildCount(); ++tag) { XmlNodeRef mission = missionObjectives->getChild(tag); const char* attrib; const char* objective; const char* text; const char* optional; const char* levelName; if (!mission->getAttr("name", &levelName)) { levelName = mission->getTag(); } for(int obj = 0; obj < mission->getChildCount(); ++obj) { XmlNodeRef objectiveNode = mission->getChild(obj); string id(levelName); id.append("."); id.append(objectiveNode->getTag()); if(objectiveNode->getAttributeByIndex(0, &attrib, &objective) && objectiveNode->getAttributeByIndex(1, &attrib, &text)) { bool secondaryObjective = false; int attribs = objectiveNode->getNumAttributes(); for(int attribIndex = 2; attribIndex < attribs; ++attribIndex) { if(objectiveNode->getAttributeByIndex(attribIndex, &attrib, &optional)) { if(attrib) { if(!stricmp(attrib, "Secondary")) { if(!stricmp(optional, "true")) secondaryObjective = true; } } } } m_currentMissionObjectives.push_back(CHUDMissionObjective(this, id.c_str(), objective, text, secondaryObjective)); } else GameWarning("Error reading mission objectives."); } } }
// TODO: this whole function should be removed and FindHelperObject_Basic integrated back into FindHelperObject. // It manages some undefined cases that appeared in C2, but it should not be needed with a strict definition of how the grabAndThrow helpers have to be defined in the objects IStatObj::SSubObject* FindHelperObject_Extended( const char* pHelperName, EntityId objectId, int slot ) { IStatObj::SSubObject* pSObjHelper = NULL; IEntity* pEntity = gEnv->pEntitySystem->GetEntity( objectId ); SEntitySlotInfo info; if (pEntity && pEntity->GetSlotInfo( slot, info )) { if (info.pStatObj) { IStatObj* pStatObj = info.pStatObj->GetCloneSourceObject(); // we use the clone source in case it exists. Because when it is cloned, only geometries are cloned. the helpers are NOT cloned. if (!pStatObj) pStatObj = info.pStatObj; // special case: when the pStatObj is the root, we look for the first helper that does not have a hidden parent, whatever is its name as long as it includes pHelperName // because: it can be child of a visible geometry (usually "main"...) even when that geometry is not the root if (!pSObjHelper && !pStatObj->GetParentObject()) { const int subObjectCount = pStatObj->GetSubObjectCount(); for (int sid = 0; sid < subObjectCount; ++sid) { IStatObj::SSubObject* pLocSObjHelper = pStatObj->GetSubObject( sid ); if ( pLocSObjHelper && (pLocSObjHelper->nType==STATIC_SUB_OBJECT_DUMMY) && strstr( pLocSObjHelper->name.c_str(), pHelperName )) { pLocSObjHelper = pStatObj->GetSubObject( pLocSObjHelper->nParent ); if (pLocSObjHelper && (pLocSObjHelper->nType==STATIC_SUB_OBJECT_MESH) && !pLocSObjHelper->bHidden) { pSObjHelper = pStatObj->GetSubObject( sid ); break; } } } } // if all failed, we look from the parent, but by id // because: helpers are not necesarily a subobject of their geometry, but just a child if (!pSObjHelper && pStatObj->GetParentObject()) { IStatObj* pParent = pStatObj->GetParentObject(); IStatObj::SSubObject* pMeSubObject = pParent->FindSubObject( pStatObj->GetGeoName() ); if (pMeSubObject) { const int subObjectCount = pParent->GetSubObjectCount(); for (int sid=0; sid < subObjectCount; ++sid) { IStatObj::SSubObject* pLocSObjHelper = pParent->GetSubObject( sid ); if ( pLocSObjHelper && (pLocSObjHelper->nType==STATIC_SUB_OBJECT_DUMMY) && (pLocSObjHelper->name==pHelperName) && (pParent->GetSubObject( pLocSObjHelper->nParent )==pMeSubObject) ) { pSObjHelper = pLocSObjHelper; break; } } } } //If STILL we don't find the object, try with composed name based on geometry name (for destroyed pieces), and look on the whole hierarchy if (!pSObjHelper) { CryFixedStringT<128> helperNameBuffer; helperNameBuffer.Format("%s_%s", pStatObj->GetGeoName(), pHelperName); pSObjHelper = pStatObj->FindSubObject( helperNameBuffer.c_str() ); if (!pSObjHelper) { IStatObj* pObj = pStatObj; while (pObj->GetParentObject()) pObj = pObj->GetParentObject(); pSObjHelper = FindHelperObject_RecursivePart( pObj, helperNameBuffer.c_str() ); } } } } return pSObjHelper; }
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); } }
bool CMaterialEffects::PlayBreakageEffect(ISurfaceType* pSurfaceType, const char* breakageType, const SMFXBreakageParams& breakageParams) { if (pSurfaceType == 0) return false; CryFixedStringT<128> fxName ("Breakage:"); fxName+=breakageType; TMFXEffectId effectId = this->GetEffectId(fxName.c_str(), pSurfaceType->GetId()); if (effectId == InvalidEffectId) return false; // only play sound at the moment SMFXRunTimeEffectParams params; params.playflags = eMFXPF_Audio; // if hitpos is set, use it // otherwise use matrix (hopefully been set or 0,0,0) if (breakageParams.CheckFlag(SMFXBreakageParams::eBRF_HitPos) && breakageParams.GetHitPos().IsZero() == false) params.pos = breakageParams.GetHitPos(); else params.pos = breakageParams.GetMatrix().GetTranslation(); //params.soundSemantic = eSoundSemantic_Physics_General; const Vec3& hitImpulse = breakageParams.GetHitImpulse(); const float strength = hitImpulse.GetLengthFast(); params.AddAudioRtpc("strength", strength); const float mass = NormalizeMass(breakageParams.GetMass()); params.AddAudioRtpc("mass", mass); if (CMaterialEffectsCVars::Get().mfx_Debug & 2) { TMFXContainerPtr pEffectContainer = InternalGetEffect(effectId); if (pEffectContainer != NULL) { CryLogAlways("[MFX]: %s:%s FX=%s:%s Pos=%f,%f,%f NormMass=%f F=%f Imp=%f,%f,%f RealMass=%f Vel=%f,%f,%f", breakageType, pSurfaceType->GetName(), pEffectContainer->GetParams().libraryName.c_str(), pEffectContainer->GetParams().name.c_str(), params.pos[0],params.pos[1],params.pos[2], mass, strength, breakageParams.GetHitImpulse()[0], breakageParams.GetHitImpulse()[1], breakageParams.GetHitImpulse()[2], breakageParams.GetMass(), breakageParams.GetVelocity()[0], breakageParams.GetVelocity()[1], breakageParams.GetVelocity()[2] ); } } /* if (breakageParams.GetMass() == 0.0f) { int a = 0; } */ const bool bSuccess = ExecuteEffect(effectId, params); return bSuccess; }
bool CCheckpointSystem::LoadGame(const char* fileName) { //make sure not not save/load recursively or multiple times at once if(CHECKPOINT_SAVE_XML_NODE || CHECKPOINT_LOAD_XML_NODE) return false; //set extension FixedCheckpointString file(fileName); SetFilenameExtension(file); CHECKPOINT_LOAD_XML_NODE = ReadXML(file.c_str()); if(!CHECKPOINT_LOAD_XML_NODE) return false; CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_COMMENT, "Loading checkpoint %s", file.c_str()); //check for EntityId errors CHECKPOINT_RESAVE_NECESSARY = false; //process meta data SCheckpointData metaData; if(!ReadMetaData(CHECKPOINT_LOAD_XML_NODE, metaData)) return false; //check version number if(metaData.m_versionNumber != CHECKPOINT_VERSION_NUMBER) { CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Checkpoint version number (%i) does not match current version (%i). Please reexport all checkpoints of this level to prevent errors!", metaData.m_versionNumber, CHECKPOINT_VERSION_NUMBER); } //check for level mismatch CryFixedStringT<32> curlevelName = CCryAction::GetCryAction()->GetLevelName(); RepairLevelName(curlevelName); if(curlevelName.empty() || stricmp(metaData.m_levelName.c_str(), curlevelName.c_str())) { if(!LoadCheckpointMap(metaData, curlevelName)) return false; } else { //reset the dynamic parts of the engine ResetEngine(); } //read actor data and respawn AI // TODO For now, not restoring actor info (AI) - If this happens later, support needs to be added for entity pools //RespawnAI(CHECKPOINT_LOAD_XML_NODE); //load gametokens again ReadGameTokens(CHECKPOINT_LOAD_XML_NODE); //let game read if (m_pGameHandler) { m_pGameHandler->OnReadData(CHECKPOINT_LOAD_XML_NODE); } //resets some gameplay data like action filters etc. RestartGameplay(); //load external entities, that are controlled by flowgraph LoadExternalEntities(CHECKPOINT_LOAD_XML_NODE); //inform listeners UpdateListener(metaData, false); //trigger flowgraph node OnCheckpointLoaded(metaData); //draw text message on screen //static const ColorF color (0.0f, 0.85f, 0.2f, 1.0f); //g_pGame->GetIGameFramework()->GetIPersistantDebug()->Add2DText("Checkpoint loaded", 2.5f, color, 2.0f); //checkpoint file sanity check if(CHECKPOINT_RESAVE_NECESSARY) { CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Checkpoint file contained obsolete or wrong data, trying to re-save checkpoint."); //resave checkpoint to fix changed entity Ids SaveGame(metaData.m_checkPointId, fileName); //make sure the script entity is aware of the activity OnCheckpointLoaded(metaData); } CHECKPOINT_LOAD_XML_NODE = NULL; //when a checkpoint was loaded, it becomes the most recent checkpoint g_lastSavedCheckpoint = fileName; //make sure the scripts are clean //CXP : this caused a crash after some reloads, which hints to problems in the gamerules script //gEnv->pScriptSystem->ForceGarbageCollection(); return true; }
//------------------------------------------------------------------------- // Process a search result. void CGameBrowser::MatchmakingSessionSearchCallback(CryLobbyTaskID taskID, ECryLobbyError error, SCrySessionSearchResult* session, void* arg) { #if 0 // old frontend CFlashFrontEnd *menu = g_pGame->GetFlashMenu(); CMPMenuHub *mpMenuHub = menu ? menu->GetMPMenu() : NULL; #endif CGameBrowser* pGameBrowser = (CGameBrowser*) arg; if (error == eCLE_SuccessContinue || error == eCLE_Success) { #if 0 // old frontend if(session && mpMenuHub && GameLobbyData::IsValidServer(session)) { CUIServerList::SServerInfo si; si.m_hostName = session->m_data.m_name; CRY_TODO(20, 5, 2010, "In the case where too many servers have been filtered out, start a new search query and merge the results with the existing ones"); int requiredDLCs = GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_REQUIRED_DLCS); CryLog("Found server (%s), num data (%d): with DLC version %d", si.m_hostName.c_str(), session->m_data.m_numData, requiredDLCs); if (g_pGameCVars->g_ignoreDLCRequirements || CDLCManager::MeetsDLCRequirements(requiredDLCs, g_pGame->GetDLCManager()->GetSquadCommonDLCs()) || pGameBrowser->m_bFavouriteIdSearch) { si.m_numPlayers = session->m_numFilledSlots; si.m_maxPlayers = session->m_data.m_numPublicSlots; si.m_gameTypeName = GameLobbyData::GetGameRulesFromHash(GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_GAMEMODE)); si.m_gameTypeDisplayName = si.m_gameTypeName.c_str(); si.m_mapName = GameLobbyData::GetMapFromHash(GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_MAP)); si.m_mapDisplayName = PathUtil::GetFileName(si.m_mapName.c_str()).c_str(); si.m_friends = (session->m_numFriends>0); si.m_reqPassword = session->m_flags&eCSSRF_RequirePassword; uint32 variantId = GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_VARIANT); bool bCustomVariant = false; CPlaylistManager *pPlaylistManager = g_pGame->GetPlaylistManager(); if (pPlaylistManager) { const SGameVariant* pVariant = pPlaylistManager->GetVariant(variantId); if (pVariant) { si.m_gameVariantName = pVariant->m_name.c_str(); si.m_gameVariantDisplayName = CHUDUtils::LocalizeString(pVariant->m_localName.c_str()); } bCustomVariant = (variantId == pPlaylistManager->GetCustomVariant()); } // Get more readable map name and game type if (ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager()) { si.m_mapDisplayName = CHUDUtils::LocalizeString(g_pGame->GetMappedLevelName(si.m_mapDisplayName.c_str())); CryFixedStringT<64> tmpString; tmpString.Format("ui_rules_%s", si.m_gameTypeName.c_str()); SLocalizedInfoGame outInfo; if (pLocMgr->GetLocalizedInfoByKey(tmpString.c_str(), outInfo)) { wstring wcharstr = outInfo.swTranslatedText; CryStringUtils::WStrToUTF8(wcharstr, si.m_gameTypeDisplayName); } } // FIXME : // Make server id unique in some other way.... si.m_serverId = (int)session->m_id.get(); // for lack of unique ids deref the pointer location of the server. This is the id that gets sent to flash... si.m_sessionId = session->m_id; si.m_ping = session->m_ping; if (pGameBrowser->m_bFavouriteIdSearch) { #if IMPLEMENT_PC_BLADES if (si.m_sessionFavouriteKeyId != INVALID_SESSION_FAVOURITE_ID) { for (uint32 i = 0; i < pGameBrowser->m_currentSearchFavouriteIdIndex; ++i) { if (si.m_sessionFavouriteKeyId == pGameBrowser->m_searchFavouriteIds[i]) { g_pGame->GetGameServerLists()->ServerFound(si, pGameBrowser->m_currentFavouriteIdSearchType, si.m_sessionFavouriteKeyId); // Invalidate any current search favourite ids, as it has been found pGameBrowser->m_searchFavouriteIds[i] = INVALID_SESSION_FAVOURITE_ID; break; } } } #endif } else { mpMenuHub->AddServer(si); } } } #endif } else if (error != eCLE_SuccessUnreachable) { CryLogAlways("CGameBrowser search for sessions error %d", (int)error); CGameLobby::ShowErrorDialog(error, NULL, NULL, NULL); } if ((error != eCLE_SuccessContinue) && (error != eCLE_SuccessUnreachable)) { CryLogAlways("CCGameBrowser::MatchmakingSessionSearchCallback DONE"); pGameBrowser->FinishedSearch(true, !pGameBrowser->m_bFavouriteIdSearch); // FavouriteId might start another search after this one has finished } }
//--------------------------------------------------------------------- void CVehicleWeapon::GetCacheName(const IEntityClass* pClass, const bool bIsThirdPerson, CryFixedStringT<32> &outCacheName) { outCacheName.Format("%s%s", pClass->GetName(), bIsThirdPerson ? "_3p" : "_fp"); }
void CGameBrowser::ConfigurationCallback(ECryLobbyService service, SConfigurationParams *requestedParams, uint32 paramCount) { uint32 a; for (a=0;a<paramCount;++a) { switch (requestedParams[a].m_fourCCID) { case CLCC_LAN_USER_NAME: { uint32 userIndex = g_pGame->GetExclusiveControllerDeviceIndex(); IPlatformOS *pPlatformOS = gEnv->pSystem->GetPlatformOS(); IPlatformOS::TUserName tUserName = ""; if(pPlatformOS) { pPlatformOS->UserGetName(userIndex, tUserName); } // this will null terminate for us if necessary cry_strncpy(s_profileName, tUserName.c_str(), CRYLOBBY_USER_NAME_LENGTH); int instance = gEnv->pSystem->GetApplicationInstance(); if (instance>0) { size_t length = strlen(s_profileName); if (length + 3 < CRYLOBBY_USER_NAME_LENGTH) { s_profileName[length] = '('; s_profileName[length+1] = '0' + instance; s_profileName[length+2] = ')'; s_profileName[length+3] = 0; } } requestedParams[a].m_pData = s_profileName; } break; #if defined(ORBIS) case CLCC_CRYLOBBY_PRESENCE_CONVERTER: { SCryLobbyPresenceConverter* pConverter = (SCryLobbyPresenceConverter*)requestedParams[a].m_pData; if (pConverter) { //-- Use the pConverter->m_numData data items in pConverter->m_pData to create a string in pConverter->m_pStringBuffer //-- Use the initial value of pConverter->sizeOfStringBuffer as a maximum string length allowed, but //-- update pConverter->sizeOfStringBuffer to the correct length when the string is filled in. //-- Set pConverter->sizeOfStringBuffer = 0 to invalidate bad data so it isn't sent to PSN. CryFixedStringT<MAX_PRESENCE_STRING_SIZE> strPresence; if(CreatePresenceString(strPresence, pConverter->m_pData, pConverter->m_numData)) { CryLog("[RichPresence] Succeeded %s", strPresence.c_str()); sprintf((char*)pConverter->m_pStringBuffer, "%s", strPresence.c_str()); pConverter->m_sizeOfStringBuffer = strlen((char*)pConverter->m_pStringBuffer); } else { CryLog("[RichPresence] Failed to create rich presence string"); pConverter->m_sizeOfStringBuffer = 0; } } } break; #endif #if defined(DURANGO) case CLCC_LIVE_TITLE_ID: requestedParams[a].m_32 = DURANGO_LIVE_TITLE_ID; break; case CLCC_LIVE_SERVICE_CONFIG_ID: requestedParams[a].m_pData = DURANGO_LIVE_SERVICE_CONFIG_ID; break; #endif//DURANGO #if defined(ORBIS) case CLCC_PSN_TITLE_ID: requestedParams[a].m_pData = (void*)&s_title_id; break; case CLCC_PSN_TITLE_SECRET: requestedParams[a].m_pData = (void*)&s_title_secret; break; case CLCC_PSN_AGE_LIMIT: requestedParams[a].m_pData = (void*)&s_age_restrictions; break; case CLCC_PSN_PLUS_TEST_REQUIRED: requestedParams[a].m_32 = FALSE; break; case CLCC_PSN_CREATE_SESSION_ADVERTISEMENT: { SCryLobbySessionAdvertisement* pAdvertisement = (SCryLobbySessionAdvertisement*)requestedParams[a].m_pData; if (pAdvertisement) { pAdvertisement->m_numLanguages = s_NumLocalisedSessionAdvertisementLanguages; pAdvertisement->m_pLocalisedLanguages = (char**)s_LocalisedLanguages; pAdvertisement->m_pLocalisedSessionNames = (char**)s_LocalisedSessionAdvertisementName; pAdvertisement->m_pLocalisedSessionStatus = (char**)s_LocalisedSessionAdvertisementStatus; pAdvertisement->m_pJPGImage = (void*)s_SessionAdvertisementImage; pAdvertisement->m_sizeofJPGImage = strlen(s_SessionAdvertisementImage); // pAdvertisement->m_pData already points to a buffer of maximum size. It just needs to be filled in correctly. // pAdvertisement->m_sizeofData currently set to maximum size. You should change this to be correct size of actual data. // eg: SAdvertDataStruct* pData = (SAdvertDataStruct*)pAdvertisement->m_pData; // pData->id = 12345; // pAdvertisement->m_sizeofData = sizeof(SAdvertDataStruct); uint32* pRealmId = (uint32*)pAdvertisement->m_pData; *pRealmId = 12345; pAdvertisement->m_sizeofData = sizeof(uint32); } } break; case CLCC_PSN_UPDATE_SESSION_ADVERTISEMENT: { SCryLobbySessionAdvertisement* pAdvertisement = (SCryLobbySessionAdvertisement*)requestedParams[a].m_pData; if (pAdvertisement) { // If pAdvertisement->m_numLanguages == 0, no attempt to alter the advertisement language settings will be made. // If pAdvertisement->m_numLanguages > 0, the previous language strings will all be overwritten with new ones. // (All strings are replaced or removed if not specified again) pAdvertisement->m_numLanguages = s_NumLocalisedSessionAdvertisementLanguages; pAdvertisement->m_pLocalisedLanguages = (char**)s_LocalisedLanguages; pAdvertisement->m_pLocalisedSessionNames = (char**)s_LocalisedSessionAdvertisementName; pAdvertisement->m_pLocalisedSessionStatus = (char**)s_LocalisedSessionAdvertisementStatus; // If pAdvertisement->m_pJPGImage is non-null and pAdvertisement->m_sizeofJPGImage > 0, the JPG data for the advertisement will be overwritten with a new JPG pAdvertisement->m_pJPGImage = (void*)s_SessionAdvertisementImage; pAdvertisement->m_sizeofJPGImage = strlen(s_SessionAdvertisementImage); // pAdvertisement->m_pData already points to a buffer containing a copy of the data passed into CryMatchmaking::SessionSetAdvertisementData. // and pAdvertisement->m_sizeofData is set to the correct size. // There should be no need to alter the contents of m_pData in this configuration callback. } } break; case CLCC_PSN_INVITE_BODY_STRING: { SCryLobbyXMBString* pStringData = (SCryLobbyXMBString*)requestedParams[a].m_pData; sprintf((char*)pStringData->m_pStringBuffer, "This is a test invite message"); pStringData->m_sizeOfStringBuffer = strlen((char*)pStringData->m_pStringBuffer); } break; #endif case CLCC_CRYSTATS_ENCRYPTION_KEY: { #if defined(ORBIS) requestedParams[a].m_pData = (void*)""; #else requestedParams[a].m_pData = (void*)""; #endif } break; case CLCC_MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH: requestedParams[a].m_8 = MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH; break; #if USE_STEAM #if !defined(RELEASE) case CLCC_STEAM_APPID: requestedParams[a].m_32 = STEAM_APPID; break; #endif // !defined(RELEASE) #endif // USE_STEAM default: CRY_ASSERT_MESSAGE(0,"Unknown Configuration Parameter Requested!"); break; } } }
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(); }
//------------------------------------------------------------------------- void CGameRulesStandardState::Update( float frameTime ) { if (gEnv->bServer) { if(m_state == EGRS_Intro) { // We assume there is an intro, if we reach this point and an intro hasnt been registered, we know there isn't one. Onwards and upwards. if(!m_pGameRules->IsIntroSequenceRegistered()) { ChangeState(EGRS_PreGame); } } if (m_state == EGRS_PreGame) { if (m_isStarting) { const float remainingTime = m_pGameRules->GetRemainingStartTimer(); if (remainingTime <= 0.f) { CryLog("CGameRulesStandardState::Update(), starting game"); ChangeState(EGRS_InGame); } } else { bool bOk = true; CGameLobby* pGameLobby = g_pGame->GetGameLobby(); const int numPlayers = m_pGameRules->GetPlayerCount(true); if (pGameLobby) { if (m_isWaitingForOverrideTimer) { //-- test override timer m_startTimerOverrideWait -= frameTime; bOk = (m_startTimerOverrideWait <= 0.0f); if (!bOk) { bOk = true; //-- testing min player count doesn't apply to private games const bool publicGame = !pGameLobby->IsPrivateGame(); const bool onlineGame = pGameLobby->IsOnlineGame(); if (publicGame && onlineGame) { // Start only when we have enough players if (m_pGameRules->GetTeamCount() > 1) { //-- team game, insist at least 1 player per team const int numPlayersPerTeamMin = g_pGameCVars->g_gameRules_startTimerMinPlayersPerTeam; const int numPlayersTeam1 = m_pGameRules->GetTeamPlayerCount(1, true); const int numPlayersTeam2 = m_pGameRules->GetTeamPlayerCount(2, true); bOk = ((numPlayersTeam1 >= numPlayersPerTeamMin) && (numPlayersTeam2 >= numPlayersPerTeamMin)); } else { //-- not a team game, so just insist on minimum 2 players const int numPlayersMin = g_pGameCVars->g_gameRules_startTimerMinPlayers; bOk = (numPlayers >= numPlayersMin); } const int numPlayersInLobby = pGameLobby->GetSessionNames().Size(); bOk |= (numPlayersInLobby == numPlayers); } if (bOk) { //-- Enforce a percentage of lobby players in game before starting countdown bOk = (!gEnv->IsClient() || (g_pGame->GetClientActorId() != 0)) && CheckInitialChannelPlayers(); } } } else { bOk = false; if (numPlayers) { //-- Start the override timer. m_startTimerOverrideWait = g_pGameCVars->g_gameRules_startTimerOverrideWait; m_isWaitingForOverrideTimer = true; } } } if (bOk) { CryLog("CGameRulesStandardState::Update(), we have %i players, starting the game", numPlayers); float startTimeLength = #if !defined(_RELEASE) g_pGameCVars->g_gameRules_skipStartTimer ? 0.0f : #endif g_pGameCVars->g_gameRules_startTimerLength; #if USE_PC_PREMATCH bool bDoPCPrematch = false; CGameRules::EPrematchState prematchState = m_pGameRules->GetPrematchState(); if (prematchState==CGameRules::ePS_Prematch) { int numRequiredPlayers = g_pGameCVars->g_minPlayersForRankedGame - m_pGameRules->GetPlayerCount(true); if ((numRequiredPlayers > 0) || (pGameLobby && pGameLobby->UseLobbyTeamBalancing() && !pGameLobby->IsGameBalanced())) { bDoPCPrematch = true; CPlaylistManager *pPlaylistManager = g_pGame->GetPlaylistManager(); if (pGameLobby && pPlaylistManager) { if (!pGameLobby->IsRankedGame() || pPlaylistManager->IsUsingCustomVariant()) { // Private games don't do prematch bDoPCPrematch = false; } } if (bDoPCPrematch) { // If we are waiting for players on pc, spawn ingame and set a prematch state which waits for players. m_pGameRules->StartPrematch(); startTimeLength = 0.f; } } if (!bDoPCPrematch) { m_pGameRules->SkipPrematch(); } } #endif m_pGameRules->ResetGameStartTimer(startTimeLength); StartCountdown(true); } } } else if (m_state == EGRS_PostGame) { const float prevUpdateStamp = m_timeInPostGame; const float timeInPost = (prevUpdateStamp + frameTime); const float timeToShowHUDMessage = g_pGameCVars->g_gameRules_postGame_HUDMessageTime; const float timeToShowTop3 = g_pGameCVars->g_gameRules_postGame_Top3Time; const float timeToShowScoreboard = g_pGameCVars->g_gameRules_postGame_ScoreboardTime; float killcamLength = m_pGameRules->GameEndedByWinningKill() ? g_pGameCVars->kc_length : 0.f; if (g_pGameCVars->kc_showHighlightsAtEndOfGame) { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if(pRecordingSystem) { killcamLength += pRecordingSystem->GetHighlightsReelLength(); killcamLength = min(killcamLength, 20.f); } } const float totalPostGameTime = timeToShowHUDMessage + timeToShowTop3 + timeToShowScoreboard + killcamLength; if (timeInPost > totalPostGameTime) { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if (!pRecordingSystem || (!pRecordingSystem->IsPlaybackQueued() && !pRecordingSystem->IsPlayingBack())) { CGameLobby *pGameLobby = g_pGame->GetGameLobby(); if (pGameLobby) { CryLog("[GameRules] Server trying to return to lobby"); pGameLobby->SvFinishedGame(frameTime); } } else if(pRecordingSystem) { pRecordingSystem->StopHighlightReel(); } } m_timeInPostGame = timeInPost; } } CPlayer * pPlayer = static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetClientActor()); if((pPlayer && pPlayer->ShouldPlayIntro() || gEnv->bServer) && m_pGameRules->IsIntroSequenceRegistered() && !m_bHaveNotifiedIntroListeners) { // All flowgraph nodes that want to listen, should be created at this point OnIntroStart_NotifyListeners(); } #ifndef _RELEASE if(g_pGameCVars->g_hud_postgame_debug) { const char* stateName = ""; switch(m_state) { case EGRS_Reset: { stateName = "EGRS_Reset"; break;} case EGRS_Intro: { stateName = "EGRS_Intro"; break;} case EGRS_PreGame: { stateName = "EGRS_PreGame"; break;} case EGRS_InGame: { stateName = "EGRS_InGame"; break;} case EGRS_PostGame: { stateName = "EGRS_PostGame"; break;} case EGRS_MAX: { stateName = "EGRS_MAX"; break;} } CryWatch("GameRulesStandardState - State = %s", stateName); if(m_state == EGRS_PostGame) { const char* postGameStateName = ""; switch(m_postGameState) { case ePGS_Unknown: { postGameStateName = "ePGS_Unknown"; break; } case ePGS_Starting: { postGameStateName = "ePGS_Starting"; break; } case ePGS_HudMessage: { postGameStateName = "ePGS_HudMessage"; break; } case ePGS_FinalKillcam: { postGameStateName = "ePGS_FinalKillcam"; break; } case ePGS_HighlightReel: { postGameStateName = "ePGS_HighlightReel"; break; } case ePGS_Top3: { postGameStateName = "ePGS_Top3"; break; } case ePGS_Scoreboard: { postGameStateName = "ePGS_Scoreboard"; break; } } CryWatch("GameRulesStandardState -PostGameState = %s", postGameStateName); } } #endif if (gEnv->IsClient()) { if (m_state == EGRS_PreGame) { if( !gEnv->IsDedicated() ) { if (m_isStarting) { const float timeTillStartInSeconds = m_pGameRules->GetRemainingStartTimer(); SHUDEventWrapper::UpdateGameStartCountdown( ePreGameCountdown_MatchStarting, timeTillStartInSeconds ); } else { SHUDEventWrapper::UpdateGameStartCountdown( ePreGameCountdown_WaitingForPlayers, 0.0f ); } } } else if (m_state == EGRS_InGame && !gEnv->IsDedicated() ) { if (m_introMessageShown == false) // Show only once { CGameRules *pGameRules = g_pGame->GetGameRules(); if (pGameRules && pGameRules->HasGameActuallyStarted()) { if (EntityId localPlayerId = g_pGame->GetIGameFramework()->GetClientActorId()) { int teamId = g_pGame->GetGameRules()->GetTeam(localPlayerId); bool bTeamGame = (pGameRules->GetTeamCount() > 1); IActor *pActor = g_pGame->GetIGameFramework()->GetClientActor(); if (pActor->GetSpectatorMode()==CActor::eASM_None && !pActor->IsDead() && (!bTeamGame || teamId!=0)) { if (IGameRulesPlayerStatsModule *statsModule = pGameRules->GetPlayerStatsModule()) { const SGameRulesPlayerStat *stats = statsModule->GetPlayerStats(localPlayerId); if (stats->deaths <= 0) // Not died ever { if (m_startMatchString.empty() == false) { const char* gamemodeName = g_pGame->GetGameRules()->GetEntity()->GetClass()->GetName(); CryFixedStringT<32> strSignalName; strSignalName.Format("StartGame%s", gamemodeName); TAudioSignalID signalId = g_pGame->GetGameAudio()->GetSignalID(strSignalName); CryFixedStringT<64> localisedStartString = CHUDUtils::LocalizeString( m_startMatchString.c_str() ); if (bTeamGame) { CryFixedStringT<16> strTeamName; strTeamName.Format("@ui_hud_team_%d", teamId); SHUDEventWrapper::TeamMessage(strTeamName.c_str(), teamId, SHUDEventWrapper::SMsgAudio(signalId), false, true); SHUDEventWrapper::SimpleBannerMessage(localisedStartString.c_str(), SHUDEventWrapper::kMsgAudioNULL); } else { SHUDEventWrapper::RoundMessageNotify(localisedStartString.c_str(), SHUDEventWrapper::SMsgAudio(signalId)); } } } } m_introMessageShown = true; // Or not if has already died, but don't check again anyway. } } } } } else if(m_state == EGRS_PostGame && !gEnv->IsDedicated()) { if (!gEnv->bServer) { m_timeInPostGame += frameTime; } m_timeInCurrentPostGameState += frameTime; switch (m_postGameState) { case ePGS_Starting: { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if (pRecordingSystem != NULL && (pRecordingSystem->IsPlayingBack() || pRecordingSystem->IsPlaybackQueued())) { // Currently showing a killcam, skip to the killcam stage of the postgame flow EnterPostGameState(ePGS_FinalKillcam); } else { if (m_pGameRules->GetRoundsModule()) { EnterPostGameState(ePGS_Top3); } else { EnterPostGameState(ePGS_HudMessage); } } break; } case ePGS_HudMessage: { if (m_timeInCurrentPostGameState > g_pGameCVars->g_gameRules_postGame_HUDMessageTime) { EnterPostGameState(ePGS_FinalKillcam); } break; } case ePGS_FinalKillcam: { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if (!pRecordingSystem || !(pRecordingSystem->IsPlayingBack() || (pRecordingSystem->IsPlaybackQueued() && pRecordingSystem->HasWinningKillcam()))) { EnterPostGameState(ePGS_Top3); } #ifndef _RELEASE else if(g_pGameCVars->g_hud_postgame_debug && pRecordingSystem) { CryWatch("PostGameState - Waiting for final killcam to end:"); CryWatch("IsPlaybackQueued: %s, IsPlayingBack: %s", pRecordingSystem->IsPlaybackQueued() ? "True" : "False", pRecordingSystem->IsPlayingBack() ? "True" : "False"); } #endif break; } case ePGS_HighlightReel: { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if (!pRecordingSystem || (!pRecordingSystem->IsPlaybackQueued() && !pRecordingSystem->IsPlayingBack())) { CGameLobby *pGameLobby = g_pGame->GetGameLobby(); if (pGameLobby) { CryLog("[GameRules] Client trying to return to lobby"); pGameLobby->SvFinishedGame(frameTime); EnterPostGameState(ePGS_LeavingGame); } } #ifndef _RELEASE else if(g_pGameCVars->g_hud_postgame_debug && pRecordingSystem) { CryWatch("PostGameState - Waiting for highlight reel to end:"); CryWatch("IsPlaybackQueued: %s, IsPlayingBack: %s, IsPlayingHighlightsReel: %s", pRecordingSystem->IsPlaybackQueued() ? "True" : "False", pRecordingSystem->IsPlayingBack() ? "True" : "False", pRecordingSystem->IsPlayingHighlightsReel() ? "True" : "False"); } #endif break; } case ePGS_Top3: { if (m_timeInCurrentPostGameState > g_pGameCVars->g_gameRules_postGame_Top3Time) { EnterPostGameState(ePGS_Scoreboard); } break; } case ePGS_Scoreboard: { if(m_timeInCurrentPostGameState > g_pGameCVars->g_gameRules_postGame_ScoreboardTime) { if(!m_bHasShownHighlightReel && g_pGameCVars->kc_showHighlightsAtEndOfGame) { EnterPostGameState(ePGS_HighlightReel); } else { CGameLobby *pGameLobby = g_pGame->GetGameLobby(); if (pGameLobby) { CryLog("[GameRules] Client trying to return to lobby [No highlight reel]"); pGameLobby->SvFinishedGame(frameTime); } } } break; } } } } }
int CGameStartup::Run( const char * autoStartLevelName ) { gEnv->pConsole->ExecuteString( "exec autoexec.cfg" ); if (autoStartLevelName) { //load savegame if(CryStringUtils::stristr(autoStartLevelName, ".CRYENGINEJMSF") != 0 ) { CryFixedStringT<256> fileName (autoStartLevelName); // NOTE! two step trimming is intended! fileName.Trim(" "); // first: remove enclosing spaces (outside ") fileName.Trim("\""); // second: remove potential enclosing " gEnv->pGame->GetIGameFramework()->LoadGame(fileName.c_str()); } else //start specified level { CryFixedStringT<256> mapCmd ("map "); mapCmd+=autoStartLevelName; gEnv->pConsole->ExecuteString(mapCmd.c_str()); } } #ifdef WIN32 if (!(gEnv && gEnv->pSystem) || (!gEnv->IsEditor() && !gEnv->IsDedicated())) { ::ShowCursor(TRUE); if (gEnv && gEnv->pSystem && gEnv->pSystem->GetIHardwareMouse()) gEnv->pSystem->GetIHardwareMouse()->DecrementCounter(); } AllowAccessibilityShortcutKeys(false); for (;;) { MSG msg; bool bQuit = false; while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { if (msg.message != WM_QUIT) { TranslateMessage(&msg); DispatchMessage(&msg); } else { bQuit = true; break; } } if (bQuit) break; if (!Update(true, 0)) { // need to clean the message loop (WM_QUIT might cause problems in the case of a restart) // another message loop might have WM_QUIT already so we cannot rely only on this while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } break; } } #else // We should use bVisibleByDefault=false then... if (gEnv && gEnv->pHardwareMouse) gEnv->pHardwareMouse->DecrementCounter(); #ifndef GRINGO for(;;) { if (!Update(true, 0)) { break; } } #endif #endif //WIN32 return 0; }
void CRevertibleConfigLoader::ApplyAndStoreCVar( const char *szKey, const char *szValue ) { ICVar * var = gEnv->pConsole->GetCVar(szKey); if (var == NULL) { GameWarning("Variable \"%s\" not found (trying to set it to '%s')", szKey, szValue); return; } const char * oldValue = var->GetString(); if (oldValue!=0 && 0 == strcmp(szValue, oldValue)) { CryLog("No need to change \"%s\" to '%s' as that's also its current value", szKey, szValue ); return; } if (m_allowCheatCVars || (var->GetFlags() & VF_CHEAT) == 0) { const int numStoredCvars = (int)m_savedCVars.size(); #ifndef _RELEASE const char* savedValue = NULL; for (int i=0; i<numStoredCvars; i++) { if (stricmp(m_savedCVars[i].m_name, szKey) == 0) { savedValue = m_savedCVars[i].m_value; break; } } if (savedValue) { GameWarning("Already got an old value for cvar \"%s\" (currently '%s'), about to add another entry...", szKey, savedValue); } #endif SSavedCVar savedCvar; savedCvar.m_name = m_cvarsTextBlock.StoreText(szKey); savedCvar.m_value = m_cvarsTextBlock.StoreText(var->GetString()); if (savedCvar.m_name && savedCvar.m_value) { m_savedCVars.push_back(savedCvar); CryLog("Changing \"%s\" cvar from '%s' to '%s' (now got %" PRISIZE_T " %s to revert when switching game type)", szKey, oldValue, szValue, m_savedCVars.size(), (m_savedCVars.size() == 1) ? "cvar" : "cvars"); } else { GameWarning("!Ran out of room in cvar array.\nPlease increase maxTextBufferSize - current value is %" PRISIZE_T ".\nFor now, game won't remember to undo \"%s = %s\".", m_cvarsTextBlock.GetSizeNeeded(), szKey, var->GetString()); } } else { GameWarning("!Can't change \"%s\" cvar from '%s' to '%s' because it is a cheat var and cannot be changed in release mode", szKey, oldValue, szValue); return; } CryFixedStringT<128> cmd; cmd.Format("%s %s", szKey, szValue); IConsole * pConsole = gEnv->pConsole; pConsole->ExecuteString(cmd.c_str(), true); }