int CBaseEntityOutput::Restore( IRestore &restore, int elementCount ) { // load the number of items saved if ( !restore.ReadFields( "Value", this, NULL, m_DataMap.dataDesc, m_DataMap.dataNumFields ) ) return 0; m_ActionList = NULL; // read in all the fields CEventAction *lastEv = NULL; for ( int i = 0; i < elementCount; i++ ) { CEventAction *ev = new CEventAction(NULL); if ( !restore.ReadFields( "EntityOutput", ev, NULL, ev->m_DataMap.dataDesc, ev->m_DataMap.dataNumFields ) ) return 0; // add it to the list in the same order it was saved in if ( lastEv ) { lastEv->m_pNext = ev; } else { m_ActionList = ev; } ev->m_pNext = NULL; lastEv = ev; } return 1; }
int CEventQueue::Restore( IRestore &restore ) { // clear the event queue Clear(); // rebuild the event queue by restoring all the queue items EventQueuePrioritizedEvent_t tmpEvent; // load the number of items saved if ( !restore.ReadFields( "EventQueue", this, NULL, m_DataMap.dataDesc, m_DataMap.dataNumFields ) ) return 0; for ( int i = 0; i < m_iListCount; i++ ) { if ( !restore.ReadFields( "PEvent", &tmpEvent, NULL, tmpEvent.m_DataMap.dataDesc, tmpEvent.m_DataMap.dataNumFields ) ) return 0; // add the restored event into the list if ( tmpEvent.m_pEntTarget ) { AddEvent( tmpEvent.m_pEntTarget, STRING(tmpEvent.m_iTargetInput), tmpEvent.m_VariantValue, tmpEvent.m_flFireTime - gpGlobals->curtime, tmpEvent.m_pActivator, tmpEvent.m_pCaller, tmpEvent.m_iOutputID ); } else { AddEvent( STRING(tmpEvent.m_iTarget), STRING(tmpEvent.m_iTargetInput), tmpEvent.m_VariantValue, tmpEvent.m_flFireTime - gpGlobals->curtime, tmpEvent.m_pActivator, tmpEvent.m_pCaller, tmpEvent.m_iOutputID ); } } return 1; }