Beispiel #1
0
/*
 * Start running.
 *
 * Note that running while confused is not allowed.
 */
void do_cmd_run(void)
{
	int py = p_ptr->py;
	int px = p_ptr->px;

	int y, x, dir;


	/* Hack XXX XXX XXX */
	if (p_ptr->confused)
	{
		msg_print("You are too confused!");
		return;
	}


	/* Get a direction (or abort) */
	if (!get_rep_dir(&dir)) return;

	/* Get location */
	y = py + ddy[dir];
	x = px + ddx[dir];


	/* Verify legality */
	if (!do_cmd_walk_test(y, x)) return;


	/* Start run */
	run_step(dir);
}
Beispiel #2
0
static void run_step(int sig)
{
	struct cursor_step *step = &steps[indx % ARRAY_SIZE(steps)];
	struct itimerval itimer = {
			.it_value.tv_usec = 1000 * step->msec,
	};
	int i;

	for (i = 0; i < ncursors; i++) {
		struct cursor *cursor = &cursors[i];
		step->run(cursor, step);
	}

	/* iterate to next count/step: */
	if (count < step->repeat) {
		count++;
	} else {
		count = 0;
		indx++;
	}

	/* and lastly, setup timer for next step */
	setitimer(ITIMER_REAL, &itimer, NULL);
}

int cursor_init(int fd, uint32_t bo_handle, uint32_t crtc_id,
		uint32_t crtc_w, uint32_t crtc_h, uint32_t w, uint32_t h)
{
	struct cursor *cursor = &cursors[ncursors];

	assert(ncursors < MAX_CURSORS);

	cursor->fd = fd;
	cursor->bo_handle = bo_handle;
	cursor->crtc_id = crtc_id;
	cursor->crtc_w = crtc_w;
	cursor->crtc_h = crtc_h;
	cursor->w = w;
	cursor->h = h;

	cursor->enabled = 0;
	cursor->x = w/2;
	cursor->y = h/2;
	cursor->dx = 1;
	cursor->dy = 1;

	ncursors++;

	return 0;
}

int cursor_start(void)
{
	/* setup signal handler to update cursor: */
	signal(SIGALRM, run_step);
	printf("starting cursor\n");
	run_step(SIGALRM);
	return 0;
}
Beispiel #3
0
/**
 * Start running with pathfinder.
 *
 * Note that running while confused is not allowed.
 */
void do_cmd_pathfind(struct command *cmd)
{
	int x, y;

	/* XXX-AS Add better arg checking */
	cmd_get_arg_point(cmd, "point", &x, &y);

	if (player->timed[TMD_CONFUSED])
		return;

	if (findpath(x, y)) {
		player->upkeep->running = 1000;
		/* Calculate torch radius */
		player->upkeep->update |= (PU_TORCH);
		player->upkeep->running_withpathfind = true;
		run_step(0);
	}
}
Beispiel #4
0
/*
 * Start running with pathfinder.
 *
 * Note that running while confused is not allowed.
 */
void do_cmd_pathfind(cmd_code code, cmd_arg args[])
{
	/* Hack XXX XXX XXX */
	if (p_ptr->timed[TMD_CONFUSED])
	{
		msg_print("You are too confused!");
		return;
	}

	if (findpath(args[0].point.y, args[0].point.x))
	{
		p_ptr->running = 1000;
		/* Calculate torch radius */
		p_ptr->update |= (PU_TORCH);
		p_ptr->running_withpathfind = TRUE;
		run_step(0);
	}
}
Beispiel #5
0
/*
 * Start running with pathfinder.
 *
 * Note that running while confused is not allowed.
 */
void do_cmd_pathfind(cmd_code code, cmd_arg args[])
{
	/* Hack XXX XXX XXX */
	int dir = 5;
	if (player_confuse_dir(p_ptr, &dir, TRUE))
	{
		return;
	}

	if (findpath(args[0].point.x, args[0].point.y))
	{
		p_ptr->running = 1000;
		/* Calculate torch radius */
		p_ptr->update |= (PU_TORCH);
		p_ptr->running_withpathfind = TRUE;
		run_step(0);
	}
}
Beispiel #6
0
/*
 * Start running.
 *
 * Note that running while confused is not allowed.
 */
void do_cmd_run(cmd_code code, cmd_arg args[])
{
	int x, y;
	int dir = args[0].direction;

	if (player_confuse_dir(p_ptr, &dir, TRUE))
	{
		return;
	}

	/* Get location */
	y = p_ptr->py + ddy[dir];
	x = p_ptr->px + ddx[dir];
	if (!do_cmd_walk_test(y, x))
		return;

	/* Start run */
	run_step(dir);
}
Beispiel #7
0
/*
 * Start running.
 *
 * Note that running while confused is not allowed.
 */
void do_cmd_run(cmd_code code, cmd_arg args[])
{
	int x, y;
	int dir = args[0].direction;

	if (p_ptr->timed[TMD_CONFUSED])
	{
		msg_print("You are too confused!");
		return;
	}

	/* Get location */
	y = p_ptr->py + ddy[dir];
	x = p_ptr->px + ddx[dir];
	if (!do_cmd_walk_test(y, x))
		return;

	/* Start run */
	run_step(dir);
}
Beispiel #8
0
/**
 * Start running.
 *
 * Note that running while confused is not allowed.
 */
void do_cmd_run(struct command *cmd)
{
	int x, y, dir;

	/* Get arguments */
	if (cmd_get_direction(cmd, "direction", &dir, false) != CMD_OK)
		return;

	if (player_confuse_dir(player, &dir, true))
		return;

	/* Get location */
	if (dir) {
		y = player->py + ddy[dir];
		x = player->px + ddx[dir];
		if (!do_cmd_walk_test(y, x))
			return;
	}

	/* Start run */
	run_step(dir);
}