View Single Post
Old April 4, 2019, 07:55   #5
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,077
wobbly is on a distinguished road
Had my plans messed up by the flu & only just got round to this, so apologises for the delay. Anyway I've got something that appears to be working on mine. Not sure whether it's the best solution but it is working when I test it.

In player-path.c, run_step I've inserted a little check here:

Code:
/* Inserted a check here before movement - MC */
	if ((!player->upkeep->running) && (!player->upkeep->running_withpathfind)) {
		return;
	}
	
	/* Take time */
	player->upkeep->energy_use = z_info->move_energy / player->state.num_moves;

	/* Move the player; running straight into a trap == trying to disarm */
	move_player(run_cur_dir, dir && disarm ? true : false);

	/* Decrease counter if it hasn't been cancelled */
	/* occurs after movement so that using p->u->running as flag works */
	if (player->upkeep->running) {
		player->upkeep->running--;
	} else if (!player->upkeep->running_withpathfind)
		return;

	/* Prepare the next step */
	if (player->upkeep->running) {
		cmdq_push(CMD_RUN);
		cmd_set_arg_direction(cmdq_peek(), "direction", 0);
	}
}
This next bit I'm less sure of as I don't exactly get running_withpathfind but it looked like it should be there.
In player-util.c, disturb I added a bit:

Code:
void disturb(struct player *p, int stop_search)
{
	/* Cancel repeated commands */
	cmd_cancel_repeat();

	/* Cancel Resting */
	if (player_is_resting(p)) {
		player_resting_cancel(p, true);
		p->upkeep->redraw |= PR_STATE;
	}

	/* Cancel running */
	if (p->upkeep->running) {
		p->upkeep->running = 0;

		/* Check for new panel if appropriate */
		event_signal(EVENT_PLAYERMOVED);
		p->upkeep->update |= PU_TORCH;

		/* Mark the whole map to be redrawn */
		event_signal_point(EVENT_MAP, -1, -1);
	}
	/* Cancel running_withpathfind?? - MC */
	if (p->upkeep->running_withpathfind) {
player->upkeep->running_withpathfind = false;

/* Check for new panel if appropriate */
		event_signal(EVENT_PLAYERMOVED);
		p->upkeep->update |= PU_TORCH;

		/* Mark the whole map to be redrawn */
		event_signal_point(EVENT_MAP, -1, -1);
	}
	/* Flush input */
	event_signal(EVENT_INPUT_FLUSH);
}
There's also a disturb missing where ever the game IDs the call of the grave curse. Currently if it summons an invisible monster the curse will id, but not disturb which seems inconsistent.

I was tempted to add message spam in to trace & output what was going on inside the code, though in the end I didn't. I assume there is a more technical way to do that then message spam? What's the usual way to get the game to output this information?

Last edited by wobbly; April 4, 2019 at 09:55.
wobbly is offline   Reply With Quote