void CEntityAudioProxy::OnMove() { CRY_ASSERT_MESSAGE(!(((m_nFlags & eEAPF_CAN_MOVE_WITH_ENTITY) > 0) && ((m_pEntity->GetFlagsExtended() & ENTITY_FLAG_EXTENDED_AUDIO_LISTENER) > 0)), "An CEntityAudioProxy cannot have both flags (eEAPF_CAN_MOVE_WITH_ENTITY & ENTITY_FLAG_EXTENDED_AUDIO_LISTENER) set simultaneously!"); Matrix34 const& tm = m_pEntity->GetWorldTM(); CRY_ASSERT_MESSAGE(tm.IsValid(), "Invalid Matrix34 during CEntityAudioProxy::OnMove"); if ((m_nFlags & eEAPF_CAN_MOVE_WITH_ENTITY) > 0) { std::for_each(m_mapAuxAudioProxies.begin(), m_mapAuxAudioProxies.end(), SRepositionAudioProxy(tm)); } else if ((m_pEntity->GetFlagsExtended() & ENTITY_FLAG_EXTENDED_AUDIO_LISTENER) > 0) { Matrix34 position = tm; position += CVar::audioListenerOffset; if (!s_audioListenerLastTransformation.IsEquivalent(position, 0.01f)) { s_audioListenerLastTransformation = position; SAudioRequest oRequest; oRequest.nFlags = eARF_PRIORITY_NORMAL; oRequest.pOwner = this; SAudioListenerRequestData<eALRT_SET_POSITION> oRequestData(s_audioListenerLastTransformation); oRequest.pData = &oRequestData; gEnv->pAudioSystem->PushRequest(oRequest); // As this is an audio listener add its entity to the AreaManager for raising audio relevant events. gEnv->pEntitySystem->GetAreaManager()->MarkEntityForUpdate(m_pEntity->GetId()); } } }
/* static */ bool CGameBrowser::CreatePresenceString(CryFixedStringT<MAX_PRESENCE_STRING_SIZE> &out, SCryLobbyUserData *pData, uint32 numData) { bool result = true; if(numData > 0) { CRY_ASSERT_MESSAGE(pData[CGame::eRPT_String].m_id == RICHPRESENCE_ID, ""); // pData[0] indicates the type of rich presence we setting, i.e. frontend, lobby, in-game // additional pData's are parameters that can be passed into the rich presence string, only used for gameplay at the moment switch(pData[CGame::eRPT_String].m_int32) { case RICHPRESENCE_FRONTEND: LocalisePresenceString(out, "@mp_rp_frontend"); break; case RICHPRESENCE_LOBBY: LocalisePresenceString(out, "@mp_rp_lobby"); break; case RICHPRESENCE_GAMEPLAY: #ifdef GAME_IS_CRYSIS2 if(numData == 3) { const int gameModeId = pData[CGame::eRPT_Param1].m_int32; const int mapId = pData[CGame::eRPT_Param2].m_int32; LocaliseInGamePresenceString( out, "@mp_rp_gameplay", gameModeId, mapId ); } #if !defined(_RELEASE) else { CRY_ASSERT_MESSAGE(numData == 3, "Invalid data passed for gameplay rich presence state"); result = false; } #endif #endif break; case RICHPRESENCE_SINGLEPLAYER: LocalisePresenceString(out, "@mp_rp_singleplayer"); break; case RICHPRESENCE_IDLE: LocalisePresenceString(out, "@mp_rp_idle"); break; default: CRY_ASSERT_MESSAGE(false, "[RichPresence] unknown rich presence type given"); result = false; break; } } else { CryLog("[RichPresence] Failed to set richpresence because numData was 0 or there was no hud"); result = false; } return result; }
//------------------------------------------------- void CHandGrenades::InitFireModes() { inherited::InitFireModes(); int firemodeCount = m_firemodes.size(); m_pThrow = NULL; int throwId = -1; for(int i = 0; i < firemodeCount; i++) { if (crygti_isof<CThrow>(m_firemodes[i])) { CRY_ASSERT_MESSAGE(!m_pThrow, "Multiple Throw firemodes assigned to weapon"); m_pThrow = crygti_cast<CThrow*>(m_firemodes[i]); throwId = i; } } CRY_ASSERT_MESSAGE(m_pThrow, "No Throw firemode assigned to weapon"); if(m_pThrow) { SetCurrentFireMode(throwId); } }
//------------------------------------------------------------------------ void CVehicleViewSteer::UpdateView(SViewParams &viewParams, EntityId playerId) { static bool doUpdate = true; if (!doUpdate) return; if (m_position.IsValid()) { viewParams.position = m_position; } else { CRY_ASSERT_MESSAGE(0, "camera position invalid"); } Vec3 dir = (m_lookAt - m_position).GetNormalizedSafe(); if (dir.IsValid() && dir.GetLengthSquared() > 0.01f) { viewParams.rotation = Quat::CreateRotationVDir(dir); } else { CRY_ASSERT_MESSAGE(0, "camera rotation invalid"); } // set view direction on actor IActor* pActor = m_pSeat->GetPassengerActor(true); if (pActor && pActor->IsClient()) { pActor->SetViewInVehicle(viewParams.rotation); } }
//----------------------------------------------------------------------------------------------------- void ScreenLayoutManager::SetState( ScreenLayoutStates flags ) { CRY_ASSERT_MESSAGE( !((flags&eSLO_ScaleMethod_None) && (flags&eSLO_ScaleMethod_WithY)), "HUD: Conflicting scale methods" ); CRY_ASSERT_MESSAGE( !((flags&eSLO_ScaleMethod_None) && (flags&eSLO_ScaleMethod_WithX)), "HUD: Conflicting scale methods" ); CRY_ASSERT_MESSAGE( !((flags&eSLO_ScaleMethod_WithY) && (flags&eSLO_ScaleMethod_WithX)), "HUD: Conflicting scale methods" ); m_flags = flags; // |= /? }
void CFlowNode_AISequenceAction_WeaponHolster::HandleSequenceEvent(AIActionSequence::SequenceEvent sequenceEvent) { switch(sequenceEvent) { case AIActionSequence::StartAction: { CRY_ASSERT_MESSAGE(m_actInfo.pEntity, "entity has magically gone"); if (!m_actInfo.pEntity) { // the entity has gone for some reason, at least make sure the action gets finished properly and the FG continues CancelSequenceAndActivateOutputPort(OutputPort_Done); return; } assert(gEnv && gEnv->pGame && gEnv->pGame->GetIGameFramework() && gEnv->pGame->GetIGameFramework()->GetIActorSystem()); IActor* pActor = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_actInfo.pEntity->GetId()); if (!pActor) { CRY_ASSERT_MESSAGE(0, "Provided entity must be an IActor"); CryWarning(VALIDATOR_MODULE_AI, VALIDATOR_WARNING, "Provided entity %s must be an IActor", m_actInfo.pEntity->GetName()); CancelSequenceAndActivateOutputPort(OutputPort_Done); return; } const bool skipHolsterAnimation = GetPortBool(&m_actInfo, InputPort_SkipHolsterAnimation); pActor->HolsterItem(true, !skipHolsterAnimation); FinishSequenceActionAndActivateOutputPort(OutputPort_Done); } break; } }
void CEffectsController::InitWithEntity(IEntity *pEntity) { CRY_ASSERT_MESSAGE(pEntity, "Init Effect controller with NULL entity, this will crash!"); CRY_ASSERT_MESSAGE((m_pOwnerEntity == NULL), "Effect controller had already an entity assigned"); m_pOwnerEntity = pEntity; }
void CActionScope::QueueAnimFromSequence(uint32 layer, uint32 pos, bool isPersistent) { CRY_ASSERT_MESSAGE(layer < m_numLayers, "Invalid layer idx"); SSequencer &sequencer = m_layerSequencers[layer]; if (pos < sequencer.sequence.size()) { const SAnimClip &animClip = sequencer.sequence[pos]; const SAnimBlend &fragmentBlend = animClip.blend; sequencer.blend = fragmentBlend; sequencer.installTime = sequencer.blend.exitTime; if (pos > 0) { sequencer.referenceTime = sequencer.sequence[pos-1].referenceLength; } sequencer.flags |= eSF_Queued; CRY_ASSERT_MESSAGE(sequencer.installTime >= 0.0f, "Invalid exit time!"); } else if (!isPersistent) { if (pos > 0) { sequencer.referenceTime = sequencer.sequence[pos-1].referenceLength; } sequencer.installTime = sequencer.referenceTime; sequencer.flags |= eSF_Queued; } }
void CTacticalPointLanguageExtender::UnregisterFromTacticalPointSystem() { CRY_ASSERT_MESSAGE(gEnv->pAISystem->GetTacticalPointSystem() != NULL, "Expecting tactical point system to exist, but it doesn't."); ITacticalPointSystem& tacticalPointSystem = *gEnv->pAISystem->GetTacticalPointSystem(); bool successfullyRemovedLanguageExtender = tacticalPointSystem.RemoveLanguageExtender(this); CRY_ASSERT_MESSAGE(successfullyRemovedLanguageExtender, "Failed to remove tactical point language extender."); }
void CTacticalPointLanguageExtender::RegisterWithTacticalPointSystem() { CRY_ASSERT_MESSAGE(gEnv->pAISystem->GetTacticalPointSystem() != NULL, "Expecting tactical point system to exist, but it doesn't."); ITacticalPointSystem& tacticalPointSystem = *gEnv->pAISystem->GetTacticalPointSystem(); bool successfullyAddedLanguageExtender = tacticalPointSystem.AddLanguageExtender(this); CRY_ASSERT_MESSAGE(successfullyAddedLanguageExtender, "Failed to add tactical point language extender."); }
CPlayerPlugin::~CPlayerPlugin() { if (m_ownerPlayer) { CRY_ASSERT_MESSAGE(!m_entered, ("[PLAYER PLUG-IN] <%s %s \"%s\"> %s", m_ownerPlayer->IsClient() ? "Local" : "Remote", m_ownerPlayer->GetEntity()->GetClass()->GetName(), m_ownerPlayer->GetEntity()->GetName(), string().Format("Player plug-in is being destroyed without having been shut down cleanly!").c_str())); } else { CRY_ASSERT_MESSAGE(!m_entered, ("[PLAYER PLUG-IN] <NULL> %s", string().Format("Player plug-in is being destroyed without having been shut down cleanly!").c_str())); } }
// message from server received on clients void CVTOLVehicleManager::OnSingleEntityRMI(CGameRules::SModuleRMIEntityParams params) { switch(params.m_data) { case eRMITypeSingleEntity_vtol_destroyed: { CryLog("CVTOLVehicleManager::OnSingleEntityRMI() eRMITypeSingleEntity_vtol_destroyed"); IVehicle* pVehicle = m_pVehicleSystem->GetVehicle( params.m_entityId ); CRY_ASSERT_MESSAGE(pVehicle, "have received destroyed VTOL RMI, but cannot find the vehicle for specified entity id"); if (pVehicle) { DestroyVTOL(pVehicle->GetEntity(), m_vtolList[params.m_entityId]); } break; } case eRMITypeSingleEntity_vtol_hidden: // for late joining clients only { CryLog("CVTOLVehicleManager::OnSingleEntityRMI() eRMITypeSingleEntity_vtol_hidden"); IVehicle* pVehicle = m_pVehicleSystem->GetVehicle(params.m_entityId); CRY_ASSERT_MESSAGE(pVehicle, "have received hidden VTOL RMI, but cannot find the vehicle for specified entity id"); if (pVehicle) { //Hide existing vehicle IEntity* pVehicleEntity = pVehicle->GetEntity(); pVehicleEntity->SetPos(Vec3(0.f,0.f,0.f)); // TODO - get Gary's fix for this if any pVehicleEntity->Hide(true); SVTOLInfo& info = m_vtolList[params.m_entityId]; info.state = EVS_Invisible; info.stateTime = 0.f; // this may allow clients to do their own respawn handling, stopping the need for respawned RMI below SHUDEvent hudEvent(eHUDEvent_RemoveEntity); hudEvent.AddData((int)params.m_entityId); CHUDEventDispatcher::CallEvent(hudEvent); } break; } case eRMITypeSingleEntity_vtol_respawned: { CryLog("CVTOLVehicleManager::OnSingleEntityRMI() eRMITypeSingleEntity_vtol_respawned"); IVehicle* pVehicle = m_pVehicleSystem->GetVehicle(params.m_entityId); CRY_ASSERT_MESSAGE(pVehicle, "have received respawned VTOL RMI, but cannot find the vehicle for specified entity id"); if (pVehicle) { RespawnVTOL(pVehicle, m_vtolList[params.m_entityId]); } break; } default: CRY_ASSERT_MESSAGE(0, string().Format("unhandled RMI data %d", params.m_data)); break; } }
CEntity* CEntityPool::GetEntityFromPool(bool &outIsActive, EntityId forcedPoolId /*= 0*/) { FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY); CEntity* pPoolEntity = NULL; if (forcedPoolId > 0) { pPoolEntity = GetPoolEntityWithPoolId(outIsActive, forcedPoolId); } if (!pPoolEntity) { pPoolEntity = GetPoolEntityFromInactiveSet(); if (pPoolEntity) outIsActive = false; } if (!pPoolEntity) { pPoolEntity = GetPoolEntityFromActiveSet(); if (pPoolEntity) outIsActive = true; } if (!pPoolEntity) { CRY_ASSERT_MESSAGE(false, "CEntityPool::GetEntityFromPool() Creating new entity for pool usage at run-time. Pool was too small!"); EntityWarning("[Entity Pool] Pool \'%s\' was too small. A new entity had to be created at run-time. Consider increasing the pool size.", m_sName.c_str()); #ifdef ENTITY_POOL_DEBUGGING m_bDebug_HasExpanded = true; #endif //ENTITY_POOL_DEBUGGING // Make sure not to go above the max size if (m_uMaxSize > 0 && m_InactivePoolIds.size() + m_ActivePoolIds.size() < m_uMaxSize) { // Make a new one if (!CreatePoolEntity(pPoolEntity, false)) { CRY_ASSERT_MESSAGE(false, "CEntityPool::GetEntityFromPool() Failed when creating a new pool entity."); } } else { CRY_ASSERT_MESSAGE(false, "CEntityPool::GetEntityFromPool() Have to create a new pool entity but am already at max size!"); EntityWarning("[Entity Pool] Pool \'%s\' has reached its max size and a new entity was requested. The new entity was not created!", m_sName.c_str()); } outIsActive = false; } return pPoolEntity; }
/* static */ const char* CGameBrowser::GetGameModeStringFromId(int32 id) { char *strGameMode = NULL; switch(id) { #ifdef GAME_IS_CRYSIS2 case RICHPRESENCE_GAMEMODES_INSTANTACTION: strGameMode = "@ui_rules_InstantAction"; break; case RICHPRESENCE_GAMEMODES_TEAMINSTANTACTION: strGameMode = "@ui_rules_TeamInstantAction"; break; case RICHPRESENCE_GAMEMODES_ASSAULT: strGameMode = "@ui_rules_Assault"; break; case RICHPRESENCE_GAMEMODES_CAPTURETHEFLAG: strGameMode = "@ui_rules_CaptureTheFlag"; break; case RICHPRESENCE_GAMEMODES_EXTRACTION: strGameMode = "@ui_rules_Extraction"; break; case RICHPRESENCE_GAMEMODES_CRASHSITE: strGameMode = "@ui_rules_CrashSite"; break; case RICHPRESENCE_GAMEMODES_ALLORNOTHING: strGameMode = "@ui_rules_AllOrNothing"; break; case RICHPRESENCE_GAMEMODES_BOMBTHEBASE: strGameMode = "@ui_rules_BombTheBase"; break; case RICHPRESENCE_GAMEMODES_POWERSTRUGGLE: strGameMode = "@ui_rules_PowerStruggleLite"; break; default: CRY_ASSERT_MESSAGE(false, "Failed to find game rules rich presence string"); break; #else case 0: //fallthrough to prevent warning default: CRY_ASSERT_MESSAGE(false, "Failed to find game rules rich presence string"); break; } #endif return strGameMode; }
void CFireMode::InitFireMode( IWeapon* pWeapon, const SParentFireModeParams* pParams) { CRY_ASSERT_MESSAGE(pParams, "Fire Mode Params NULL! Have you set up the weapon xml correctly?"); CRY_ASSERT_MESSAGE(pParams->pBaseFireMode, "Fire Mode Base Params NULL!"); m_pWeapon = static_cast<CWeapon *>(pWeapon); m_fireParams = pParams->pBaseFireMode; m_parentFireParams = pParams; ResetParams(); }
//---------------------------------------------------------- void CSingleAllocTextBlock::Lock() { CRY_ASSERT_MESSAGE(m_numBytesUsed == m_sizeNeeded, string().Format("Didn't fill entire block of reserved memory: allocated %d bytes, used %d", m_sizeNeeded, m_numBytesUsed)); #if MORE_SINGLE_ALLOC_TEXT_BLOCK_CHECKS CRY_ASSERT_MESSAGE(m_mem[m_sizeNeeded] == '@', "Memory overwrite"); #endif m_reuseDuplicatedStringsArray = NULL; m_reuseDuplicatedStringsArraySize = 0; m_reuseDuplicatedStringsNumUsed = 0; }
bool LuaArgToUIArgImpl(T& t, int idx, TUIData &value) { bool bOk = false; switch(GetVarType(t, idx)) { case svtBool: { bool val; bOk = GetVarValue(t, idx, val); value = TUIData(val); } break; case svtNumber: { float val; bOk = GetVarValue(t, idx, val); value = TUIData(val); } break; case svtString: { const char* val; bOk = GetVarValue(t, idx, val); value = TUIData( string(val) ); } break; case svtObject: { Vec3 val(ZERO); bOk = GetVarValue(t, idx, val); value = TUIData(val); } break; case svtPointer: { ScriptHandle sh; bOk = GetVarValue(t, idx, sh); value = TUIData((EntityId)sh.n); } break; case svtNull: CRY_ASSERT_MESSAGE(false, "Invalid data type for UIAction call!"); break; case svtUserData: CRY_ASSERT_MESSAGE(false, "Invalid data type for UIAction call!"); break; case svtFunction: CRY_ASSERT_MESSAGE(false, "Invalid data type for UIAction call!"); break; } return bOk; }
TBitfield AutoEnum_GetBitfieldFromString(const char *inString, const char **inArray, int arraySize) { unsigned int reply = 0; if(inString && inString[0] != '\0') // Avoid a load of work if the string's NULL or empty { const char *startFrom = inString; assert(arraySize > 0); char skipThisString[32]; size_t skipChars = cry_copyStringUntilFindChar(skipThisString, inArray[0], sizeof(skipThisString), '_'); size_t foundAtIndex = 0; #if DO_PARSE_BITFIELD_STRING_LOGS CryLog("AutoEnum_GetBitfieldFromString: Parsing '%s' (skipping first %d chars '%s%s' of each string in array)", inString, skipChars, skipThisString, skipChars ? "_" : ""); #endif do { char gotToken[32]; foundAtIndex = cry_copyStringUntilFindChar(gotToken, startFrom, sizeof(gotToken), '|'); startFrom += foundAtIndex; bool done = false; for(int i = 0; i < arraySize; ++ i) { if(0 == stricmp(inArray[i] + skipChars, gotToken)) { CRY_ASSERT_MESSAGE((reply & BIT(i)) == 0, string().Format("Bit '%s' already turned on! Does it feature more than once in string '%s'?", gotToken, inString)); #if DO_PARSE_BITFIELD_STRING_LOGS CryLog("AutoEnum_GetBitfieldFromString: Token = '%s' = BIT(%d) = %d, remaining string = '%s'", gotToken, i, BIT(i), foundAtIndex ? startFrom : ""); #endif reply |= BIT(i); done = true; break; } } CRY_ASSERT_MESSAGE(done, string().Format("No flag called '%s' in list", gotToken)); } while(foundAtIndex); } return reply; }
void CFlashUIEventNode::FlushNextEvent( SActivationInfo* pActInfo ) { if (m_events.size() > 0) { const std::pair<SUIArguments, int> &data = m_events.get(); const SUIArguments & args = data.first; bool bTriggerEvent = true; const int checkValue = GetPortInt(pActInfo, eI_CheckPort); if (checkValue >= 0) { bTriggerEvent = false; CRY_ASSERT_MESSAGE(checkValue < args.GetArgCount(), "Port does not exist!" ); if (checkValue < args.GetArgCount()) { string val = GetPortString(pActInfo, eI_CheckValue); string compstr; args.GetArg(checkValue).GetValueWithConversion(compstr); bTriggerEvent = val == compstr; } } if (bTriggerEvent) { int end = m_eventDesc.InputParams.Params.size(); string val; int i = 0; for (; i < end; ++i) { CRY_ASSERT_MESSAGE( i < args.GetArgCount(), "UIEvent received wrong number of arguments!" ); ActivateDynOutput( i < args.GetArgCount() ? args.GetArg(i) : TUIData(string("")), m_eventDesc.InputParams.Params[i], pActInfo, i + 2 ); } if (m_eventDesc.InputParams.IsDynamic) { SUIArguments dynarg; for (; i < args.GetArgCount(); ++i) { if (args.GetArg( i, val )) dynarg.AddArgument( val ); } ActivateOutput( pActInfo, end + eO_DynamicPorts, string( dynarg.GetAsString())); } ActivateOutput( pActInfo, eO_OnEvent, true ); ActivateOutput( pActInfo, eO_OnInstanceId, data.second ); } m_events.pop(); } }
void CDownloadableResource::SetDownloadInfo(const char* pUrl, const char* pUrlPrefix, const char* pServer, const int port, const int maxDownloadSize, const char* pDescName/*=NULL*/) { CRY_ASSERT(pUrl && pServer && maxDownloadSize>0); CRY_ASSERT_MESSAGE(m_port==0,"You cannot call CDownloadableResource::SetDownloadInfo() twice on the same resource"); // not unless the code is strengthened anyway CRY_ASSERT_MESSAGE(port!=0,"You cannot request a download from port 0"); // invalid generally, but also we use 0 as not initialized here m_port = port; m_maxDownloadSize = maxDownloadSize; m_server = pServer; m_descName = pDescName ? pDescName : pUrl; m_urlPrefix = pUrlPrefix; m_url = pUrl; }
void CUIManager::Init() { CHUDEventDispatcher::SetUpEventListener(); SHUDEvent::InitDataStack(); m_pWarningManager = new CWarningsManager(); m_pOptions = new CProfileOptions(); m_pScreenLayoutMan = new ScreenLayoutManager(); m_p2DRendUtils = new C2DRenderUtils(m_pScreenLayoutMan); m_pHudSilhouettes = new CHUDSilhouettes(); m_pCVars = new CUICVars(); m_pMOSystem = new CHUDMissionObjectiveSystem(); m_pCVars->RegisterConsoleCommandsAndVars(); IUIEventSystemFactory* pFactory = IUIEventSystemFactory::GetFirst(); while (pFactory) { TUIEventSystemPtr pGameEvent = pFactory->Create(); CRY_ASSERT_MESSAGE(pGameEvent != NULL, "Invalid IUIEventSystemFactory!"); const char* name = pGameEvent->GetTypeName(); TUIEventSystems::const_iterator it = m_EventSystems.find(name); if(it == m_EventSystems.end()) { m_EventSystems[name] = pGameEvent; } else { string str; str.Format("IUIGameEventSystem \"%s\" already exists!", name); CRY_ASSERT_MESSAGE(false, str.c_str()); } pFactory = pFactory->GetNext(); } TUIEventSystems::const_iterator it = m_EventSystems.begin(); TUIEventSystems::const_iterator end = m_EventSystems.end(); for (;it != end; ++it) { it->second->InitEventSystem(); } InitSound(); gEnv->pSystem->GetISystemEventDispatcher()->RegisterListener( this ); g_pGame->GetIGameFramework()->RegisterListener(this, "CUIManager", FRAMEWORKLISTENERPRIORITY_HUD); m_bRegistered = true; }
void CDamageEffectController::OnRevive() { uint8 bitCheck = 1; bool netSync = false; for(int i = 0; i < MAX_NUM_DAMAGE_EFFECTS; i++) { if (m_activeEffectsBitfield & bitCheck) { netSync = true; CRY_ASSERT_MESSAGE(m_effectList[i], "The effect should not be null if it is active"); m_effectList[i]->Leave(); } bitCheck = bitCheck << 1; } m_activeEffectsBitfield = 0; m_effectsKillBitfield = 0; if (netSync) { CHANGED_NETWORK_STATE(m_ownerActor, eEA_GameServerDynamic); } }
//---------------------------------------------------------- void CSingleAllocTextBlock::IncreaseSizeNeeded(size_t theSize) { CRY_ASSERT_MESSAGE(m_mem == NULL, "Shouldn't try and increase size after memory allocation!"); m_sizeNeeded += theSize; m_sizeNeededWithoutUsingDuplicates += theSize; }
//---------------------------------------------------------- const char * CSingleAllocTextBlock::StoreText(const char * textIn, bool doDuplicateCheck) { const char * reply = NULL; if (textIn) { reply = doDuplicateCheck ? FindDuplicate(textIn) : NULL; if (reply == NULL) { CRY_ASSERT_MESSAGE(m_mem != NULL, "No memory has been allocated!"); if (cry_strncpy(m_mem + m_numBytesUsed, textIn, m_sizeNeeded - m_numBytesUsed)) { reply = m_mem + m_numBytesUsed; m_numBytesUsed += strlen(reply) + 1; if (doDuplicateCheck) { RememberPossibleDuplicate(reply); } } #ifndef _RELEASE else { GameWarning("Tried to store too much text in a single-alloc text block of size %" PRISIZE_T " (%" PRISIZE_T " bytes have already been used, no room for '%s')", m_sizeNeeded, m_numBytesUsed, textIn); } #endif } SingleAllocTextBlockLog ("Storing a copy of '%s', now used %u/%u bytes, %u bytes left", textIn, m_numBytesUsed, m_sizeNeeded, m_sizeNeeded - m_numBytesUsed); } CRY_ASSERT_TRACE (m_numBytesUsed <= m_sizeNeeded, ("Counters have been set to invalid values! Apparently used %d/%d bytes!", m_numBytesUsed, m_sizeNeeded)); return reply; }
//------------------------------------------------------------------------ IUIElement* CScriptBind_UIAction::GetElement( const char* sName, int instanceID, bool bSupressWarning ) { if (gEnv->IsDedicated()) return NULL; CRY_ASSERT_MESSAGE( gEnv->pFlashUI, "FlashUI extension does not exist!" ); if ( !gEnv->pFlashUI ) { UIACTION_WARNING( "LUA: FlashUI extension does not exist!" ); return NULL; } IUIElement* pElement = gEnv->pFlashUI->GetUIElement( sName ); if ( pElement && instanceID > 0) pElement = pElement->GetInstance( instanceID ); if (pElement && pElement->IsValid()) return pElement; if (!bSupressWarning) { UIACTION_WARNING( "LUA: Try to access UIElement %s that is not valid!", sName ); } return NULL; }
void CDamageEffectController::SetActiveEffects(uint8 active) { uint8 bitCheck = 1; for(int i = 0; i < MAX_NUM_DAMAGE_EFFECTS; i++) { bool serverActive = !((active & bitCheck) == 0); bool locallyActive = !((m_activeEffectsBitfield & bitCheck) == 0); if ( serverActive != locallyActive ) { CRY_ASSERT_MESSAGE(m_effectList[i], "The effect should not be null"); if (serverActive) { m_effectList[i]->Enter(); m_effectsResetSwitchBitfield &= ~bitCheck; m_activeEffectsBitfield |= bitCheck; } else { m_effectList[i]->Leave(); m_activeEffectsBitfield &= ~bitCheck; } } bitCheck = bitCheck << 1; } }
//------------------------------------------------------------------------------------ bool CFlashUIAction::Serialize( XmlNodeRef& xmlNode, bool bIsLoading ) { CRY_ASSERT_MESSAGE(m_type == eUIAT_FlowGraph, "Try to serialize Flowgraph of Lua UI Action"); bool ok = m_pFlowGraph->SerializeXML( xmlNode, bIsLoading ); SetValid(ok); return ok; }
int CActionScope::GetNumAnimsInSequence(uint32 layer) const { CRY_ASSERT_MESSAGE(layer < m_numLayers, "Invalid layer idx"); SSequencer &sequencer = m_layerSequencers[layer]; return sequencer.sequence.size(); }
void CGameLocalizationManager::LegacyLoadLocalizationData() { // fallback to old system if localization.xml can not be found GameWarning("Using Legacy localization loading"); ILocalizationManager *pLocMan = GetISystem()->GetLocalizationManager(); string const sLocalizationFolder(PathUtil::GetLocalizationFolder()); string const search(sLocalizationFolder + "*.xml"); ICryPak *pPak = gEnv->pCryPak; _finddata_t fd; intptr_t handle = pPak->FindFirst(search.c_str(), &fd); if (handle > -1) { do { CRY_ASSERT_MESSAGE(stricmp(PathUtil::GetExt(fd.name), "xml") == 0, "expected xml files only"); string filename = sLocalizationFolder + fd.name; pLocMan->LoadExcelXmlSpreadsheet(filename.c_str()); } while (pPak->FindNext(handle, &fd) >= 0); pPak->FindClose(handle); } else { GameWarning("Unable to find any Localization Data!"); } }
void CDamageEffectController::UpdateEffects(float frameTime) { uint8 bitCheck = 1; bool netSync = false; for(int i = 0; i < MAX_NUM_DAMAGE_EFFECTS; i++) { if (m_activeEffectsBitfield & bitCheck) { CRY_ASSERT_MESSAGE(m_effectList[i], "The effect should not be null if it is active"); if (!m_effectList[i]->Update(frameTime) && gEnv->bServer) { netSync = true; m_effectList[i]->Leave(); m_activeEffectsBitfield &= ~bitCheck; } } bitCheck = bitCheck << 1; } if (netSync) { CHANGED_NETWORK_STATE(m_ownerActor, eEA_GameServerDynamic); } }