Example #1
0
int UpdateEventList( void )
{
  Event *e = EventListBegin( );

  // Increment our elapsed timer
  ++elapsed;

  // List is empty
  if(e == EventListEnd( ))
    return 0;

  while(e != EventListEnd( ))
  {
    Condition *c = e->conditions;
    int allConditionsReturnedTrue = 1;

    // Check all the conditions
    while(c)
    {
      if(!c->cb( c ))
      {
        allConditionsReturnedTrue = 0;
        break;
      }

      c = c->next;
    }

    if(allConditionsReturnedTrue)
    {
      Action *a = e->actions;

      // Run all actions
      while(a)
      {
        a->cb( a );
        a = a->next;
      }

      // Remove event from queue
      e = EventListRemove( e );
    }
    else
      e = e->next;
  }

  // List is not empty
  return 1;
}