/* ================ idThread::Execute ================ */ bool idThread::Execute( void ) { idThread *oldThread; bool done; if ( manualControl && ( waitingUntil > gameLocal.time ) ) { return false; } oldThread = currentThread; currentThread = this; lastExecuteTime = gameLocal.time; ClearWaitFor(); done = interpreter.Execute(); if ( done ) { End(); if ( interpreter.terminateOnExit ) { PostEventMS( &EV_Remove, 0 ); } } else if ( !manualControl ) { if ( waitingUntil > lastExecuteTime ) { PostEventMS( &EV_Thread_Execute, waitingUntil - lastExecuteTime ); } else if ( interpreter.MultiFrameEventInProgress() ) { PostEventMS( &EV_Thread_Execute, gameLocal.msec ); } } currentThread = oldThread; return done; }
/* ================ idThread::ObjectMoveDone ================ */ void idThread::ObjectMoveDone( idEntity *obj ) { assert( obj ); if( IsWaitingFor( obj ) ) { ClearWaitFor(); DelayedStart( 0 ); } }
/* ================ idThread::ThreadCallback ================ */ void idThread::ThreadCallback( idThread *thread ) { if( interpreter.threadDying ) { return; } if( thread == waitingForThread ) { ClearWaitFor(); DelayedStart( 0 ); } }
/* ================ idThread::Init ================ */ void idThread::Init( void ) { threadNum = GetFreeThreadNum(); threadNode.AddToEnd( threadList ); creationTime = gameLocal.time; lastExecuteTime = 0; manualControl = false; guiThread = false; ClearWaitFor(); }
/* ================ idThread::Init ================ */ void idThread::Init( void ) { // create a unique threadNum do { threadIndex++; if( threadIndex == 0 ) { threadIndex = 1; } } while( GetThread( threadIndex ) ); threadNum = threadIndex; threadList.Append( this ); creationTime = gameLocal.time; lastExecuteTime = 0; manualControl = false; ClearWaitFor(); interpreter.SetThread( this ); }
/* ================ idThread::Execute ================ */ bool idThread::Execute( void ) { idThread *oldThread; bool done; int now = gameLocal.time; if ( guiThread ) { now = gameLocal.ToGuiTime( now ); } if ( manualControl && ( waitingUntil > now ) ) { return false; } oldThread = currentThread; currentThread = this; lastExecuteTime = now; ClearWaitFor(); done = interpreter.Execute(); if ( done ) { End(); if ( interpreter.terminateOnExit ) { PostEventMS( &EV_Remove, 0 ); } } else if ( !manualControl ) { if ( waitingUntil > lastExecuteTime ) { if ( guiThread ) { PostGUIEventMS( &EV_Thread_Execute, waitingUntil - lastExecuteTime ); } else { PostEventMS( &EV_Thread_Execute, waitingUntil - lastExecuteTime ); } } else if ( waitFrame ) { waitFrame = false; if ( guiThread ) { PostGUIEventMS( &EV_Thread_Execute, NEXT_FRAME_EVENT_TIME ); } else { PostEventMS( &EV_Thread_Execute, NEXT_FRAME_EVENT_TIME ); } } } currentThread = oldThread; return done; }
/* ================ idThread::Pause ================ */ void idThread::Pause( void ) { ClearWaitFor(); interpreter.doneProcessing = true; }
/* ================ idThread::CallFunction NOTE: If this is called from within a event called by this thread, the function arguments will be invalid after calling this function. ================ */ void idThread::CallFunction( idEntity *self, const function_t *func, bool clearStack ) { assert( self ); ClearWaitFor(); interpreter.EnterObjectFunction( self, func, clearStack ); }
/* ================ idThread::CallFunction NOTE: If this is called from within a event called by this thread, the function arguments will be invalid after calling this function. ================ */ void idThread::CallFunction( const function_t *func, bool clearStack ) { ClearWaitFor(); interpreter.EnterFunction( func, clearStack ); }
/* ================ idThread::CallFunction NOTE: If this is called from within a event called by this thread, the function arguments will be invalid after calling this function. ================ */ void idThread::CallFunction( idScriptObject* object, const sdProgram::sdFunction* func ) { assert( object ); ClearWaitFor(); interpreter.EnterObjectFunction( object, reinterpret_cast< const function_t* >( func ), true ); }
/* ================ idThread::CallFunction NOTE: If this is called from within a event called by this thread, the function arguments will be invalid after calling this function. ================ */ void idThread::CallFunction( const sdProgram::sdFunction* func ) { ClearWaitFor(); interpreter.EnterFunction( reinterpret_cast< const function_t* >( func ), true ); }