Beispiel #1
0
static void cmd_remove(void)
{
  if (unlink(filename.s) != 0 && errno != ENOENT)
    respond("ZCould not remove crontab");
  trigger_pull(TRIGGER);
  respond("KCrontab removed");
}
Beispiel #2
0
static void cmd_store(str* data)
{
  int i;
  int fd;
  if ((i = str_findfirst(data, 0)) <= 0)
    respond("DStore command is missing data");
  ++i;
  if ((fd = tempfile("tmp/spool")) == -1)
    respond("ZCould not create temporary file");
  if (write(fd, data->s + i, data->len - i) != (long)(data->len - i)
      || (fd = fixup(fd)) == -1
      || fchmod(fd, 0400) == -1
      || close(fd) != 0)
    respond("ZCould not write temporary file");
  if (rename(tempname.s, filename.s) != 0)
    respond("ZCould not rename temporary file");
  trigger_pull(TRIGGER);
  respond("KCrontab successfully written");
}
Beispiel #3
0
Datei: world.c Projekt: cmr/iiag
//
// Right now, only steps the player's zone and updates the time
//
void step_world(void) {
	int i;
	long step, step_diff;
	action * a;

	assert(world.plyr.health > 0);

	if (!world.acts_cnt) {
		step_diff = 0;
	} else {
		step = world.acts->step;
		assert(step >= world.step);
		step_diff = step - world.step;
		world.step = step;

		// process actions
		while (world.acts_cnt && world.acts->step == step) {
			a = pop_action();
			assert(a != NULL);

			if (!a->c->deceased) {
				switch (a->type) {
				case ACT_IDLE:
					trigger_pull(&a->c->on_act_comp, a->c, NULL);
					break;
				case ACT_MOVE:
					crtr_try_move(a->c, a->p.dir.x, a->p.dir.y);
					break;
				case ACT_AA_MOVE:
					crtr_try_aa_move(a->c, a->p.dir.x, a->p.dir.y);
					break;
				case ACT_PICKUP:
					crtr_try_pickup(a->c, a->p.ind);
					break;
				case ACT_DROP:
					crtr_try_drop(a->c, a->p.ind);
					break;
				case ACT_CONSUME:
					crtr_try_consume(a->c, a->p.ind);
					break;
				case ACT_EQUIP:
					crtr_try_equip(a->c, a->p.ind);
					break;
				case ACT_THROW:
					crtr_try_throw(a->c, a->p.throw.ind, a->p.throw.x, a->p.throw.y);
					break;
				}
			}

			a->c->act = NULL;
			crtr_free(a->c);
			free(a);
		}

		// update time
		world.tm.steps += step_diff;

		while (world.tm.steps >= 6000) {
			world.tm.steps -= 6000;
			world.tm.min++;

			if (world.tm.min >= 60) {
				world.tm.min -= 60;
				world.tm.hour++;

				if (world.tm.hour >= 24) {
					world.tm.hour -= 24;
					world.tm.mday++;
					world.tm.wday = (world.tm.wday + 1) % 7 + 1;

					if (world.tm.mday > 30 + (world.tm.month & 1)) {
						world.tm.mday -= 30 + (world.tm.month & 1);
						world.tm.month++;

						if (world.tm.month > 12)
							world.tm.year++;
					}
				}
			}
		}
	}

	// update all zones
	for (i = 0; i < world.zones.cnt; i++) {
		zone_step(world.zones.arr[i], step_diff);
	}
}