Пример #1
0
static void Action(TAction * a)
{
	TWatch *t;
	TCondition *c;

	for (;;)
	{
		switch (a->action)
		{
		case ACTION_NULL:
			return;

		case ACTION_SOUND:
			SoundPlayAt(a->tileFlags, a->x, a->y);
			break;

		case ACTION_SETTRIGGER:
			Map(a->x, a->y).flags |= TILE_TRIGGER;
			break;

		case ACTION_CLEARTRIGGER:
			Map(a->x, a->y).flags &= ~TILE_TRIGGER;
			break;

		case ACTION_CHANGETILE:
			Map(a->x, a->y).flags = a->tileFlags;
			Map(a->x, a->y).pic = a->tilePic;
			break;

		case ACTION_SETTIMEDWATCH:
			t = FindWatch(a->x);
			if (t) {
				c = t->conditions;
				while (c && c->condition != CONDITION_NULL) {
					if (c->condition ==
					    CONDITION_TIMEDDELAY) {
						c->x = a->y;
						break;
					}
					c++;
				}
				ActivateWatch(t->index);
			}
			break;

		case ACTION_ACTIVATEWATCH:
			ActivateWatch(a->x);
			break;

		case ACTION_DEACTIVATEWATCH:
			DeactivateWatch(a->x);
			break;
		}
		a++;
	}
}
Пример #2
0
void Inotify::WaitForEvents(bool fNoIntr) throw (InotifyException)
{
  ssize_t len = 0;
  
  do {
    len = read(m_fd, m_buf, INOTIFY_BUFLEN);
  } while (fNoIntr && len == -1 && errno == EINTR);
  
  if (len < 0)
    throw InotifyException(IN_EXC_MSG("reading events failed"), errno, this);
  
  ssize_t i = 0;
  while (i < len) {
    struct inotify_event* pEvt = (struct inotify_event*) &m_buf[i];
    InotifyWatch* pW = FindWatch(pEvt->wd);
    if (pW != NULL && pW->IsEnabled()) {
      InotifyEvent evt(pEvt, pW);
      m_events.push_back(evt);
    }
    i += INOTIFY_EVENT_SIZE + (ssize_t) pEvt->len;
  }
}