void CAI_ScriptConditions::OnEntitySpawned( CBaseEntity *pEntity ) { if( m_fDisabled && m_bLeaveAsleep ) { // Don't add elements if we're not currently running and don't want to automatically wake up. // Any spawning NPC's we miss during this time will be found and added when manually Enabled(). return; } if ( pEntity->MyNPCPointer() == NULL ) return; if ( pEntity->NameMatches( m_Actor ) ) { if ( ActorInList( pEntity ) == false ) { AddNewElement( pEntity ); if ( m_fDisabled == true && m_bLeaveAsleep == false ) { Enable(); } } } }
static void ResizeMultiArray (TRI_multi_array_t* array) { char* oldTable; uint64_t oldAlloc; uint64_t j; oldTable = array->_table; oldAlloc = array->_nrAlloc; array->_nrAlloc = 2 * array->_nrAlloc + 1; array->_table = TRI_Allocate(array->_memoryZone, array->_nrAlloc * array->_elementSize, true); if (array->_table == NULL) { array->_nrAlloc = oldAlloc; array->_table = oldTable; return; } array->_nrUsed = 0; #ifdef TRI_INTERNAL_STATS array->_nrResizes++; #endif for (j = 0; j < oldAlloc; j++) { if (! array->isEmptyElement(array, oldTable + j * array->_elementSize)) { AddNewElement(array, oldTable + j * array->_elementSize); } } TRI_Free(array->_memoryZone, oldTable); }
void CAI_ScriptConditions::OnRestore( void ) { BaseClass::OnRestore(); #ifndef HL2_EPISODIC //Old HL2 save game! Fix up to new system. if ( m_hActor ) { CAI_ScriptConditionsElement conditionactor; conditionactor.SetActor( m_hActor ); conditionactor.SetTimeOut( m_Timeout ); conditionactor.SetTimer( m_Timer ); m_ElementList.AddToTail( conditionactor ); m_hActor = NULL; } if ( m_ElementList.Count() == 0 && m_Actor == NULL_STRING && m_fDisabled == false ) { AddNewElement( NULL ); } #endif }
static int ResizeHashArray (TRI_hash_array_t* array) { TRI_hash_index_element_t* oldTable; uint64_t oldAlloc; uint64_t j; int res; oldTable = array->_table; oldAlloc = array->_nrAlloc; res = AllocateTable(array, 2 * array->_nrAlloc + 1); if (res != TRI_ERROR_NO_ERROR) { return res; } array->_nrUsed = 0; #ifdef TRI_INTERNAL_STATS array->_nrResizes++; #endif for (j = 0; j < oldAlloc; j++) { if (! IsEmptyElement(array, &oldTable[j])) { AddNewElement(array, &oldTable[j]); } } TRI_Free(TRI_UNKNOWN_MEM_ZONE, oldTable); return TRI_ERROR_NO_ERROR; }
static void ResizeAssociativeArray (TRI_associative_array_t* array, uint32_t targetSize) { char * oldTable; uint32_t oldAlloc; uint32_t oldUsed; uint32_t j; oldTable = array->_table; oldAlloc = array->_nrAlloc; array->_nrAlloc = targetSize; #ifdef TRI_INTERNAL_STATS array->_nrResizes++; #endif array->_table = static_cast<char*>(TRI_Allocate(array->_memoryZone, array->_nrAlloc * array->_elementSize, true)); if (array->_table == NULL) { array->_nrAlloc = oldAlloc; array->_table = oldTable; return; } oldUsed = array->_nrUsed; array->_nrUsed = 0; for (j = 0; array->_nrUsed < oldUsed; j++) { if (! array->isEmptyElement(array, oldTable + j * array->_elementSize)) { AddNewElement(array, oldTable + j * array->_elementSize); } } TRI_Free(array->_memoryZone, oldTable); }
static void ResizeAssociativeArray (TRI_associative_array_t* array) { char * oldTable; uint64_t oldAlloc; uint64_t j; oldTable = array->_table; oldAlloc = array->_nrAlloc; array->_nrAlloc = 2 * array->_nrAlloc + 1; array->_nrUsed = 0; array->_nrResizes++; array->_table = TRI_Allocate(array->_nrAlloc * array->_elementSize); for (j = 0; j < array->_nrAlloc; j++) { array->clearElement(array, array->_table + j * array->_elementSize); } for (j = 0; j < oldAlloc; j++) { if (! array->isEmptyElement(array, oldTable + j * array->_elementSize)) { AddNewElement(array, oldTable + j * array->_elementSize); } } TRI_Free(oldTable); }
void CAI_ScriptConditions::Enable( void ) { m_hTarget = gEntList.FindEntityByName( NULL, m_target ); CBaseEntity *pActor = gEntList.FindEntityByName( NULL, m_Actor ); if ( m_ElementList.Count() == 0 ) { if ( m_Actor != NULL_STRING && pActor == NULL ) { DevMsg( "Warning: Spawning AI script conditions (%s) associated with an non-existant NPC\n", GetDebugName() ); m_NoValidActors.FireOutput( this, this, 0 ); Disable(); return; } if ( pActor && pActor->MyNPCPointer() == NULL ) { Warning( "Script condition warning: warning actor is not an NPC\n" ); Disable(); return; } } while( pActor != NULL ) { if( !ActorInList(pActor) ) { AddNewElement( pActor ); } pActor = gEntList.FindEntityByName( pActor, m_Actor ); } //If we are hitting this it means we are using a Target->Player condition if ( m_Actor == NULL_STRING ) { if( !ActorInList(pActor) ) { AddNewElement( NULL ); } } m_fDisabled = false; SetThink( &CAI_ScriptConditions::EvaluationThink ); SetThinkTime(); }
void TXmlStorage::WriteBinaryData(const UnicodeString & Name, const void * Buffer, size_t Size) { RemoveIfExists(Name); AddNewElement(Name, ::StrToHex(UnicodeString(reinterpret_cast<const wchar_t *>(Buffer), Size), true)); }
void TXmlStorage::WriteInt64(const UnicodeString & Name, int64_t Value) { RemoveIfExists(Name); AddNewElement(Name, ::Int64ToStr(Value)); }
void TXmlStorage::WriteStringRaw(const UnicodeString & Name, const UnicodeString & Value) { RemoveIfExists(Name); AddNewElement(Name, Value); }
void TXmlStorage::WriteFloat(const UnicodeString & Name, double Value) { RemoveIfExists(Name); AddNewElement(Name, FORMAT(L"%.5f", Value)); }