Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old March 23, 2019, 15:53   #1
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,034
wobbly is on a distinguished road
Trying to understand Run/Disturb Code

Code:
	/* 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);

	}

}
So it takes energy, moves the player & then decreases the run counter (only here returning if the counter is =0 ? ) before queing CMD_RUN?

Now when it disturbs:

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);

	}



	/* Flush input */

	event_signal(EVENT_INPUT_FLUSH);

}
It seems to set the run counter to 0 but I don't see anywhere where it removes the que-ed command? As far as I understand it that run command will still make a move if the run counter is 0? What am I missing here?

Last edited by wobbly; March 23, 2019 at 15:59.
wobbly is offline   Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Townspeople don't disturb (new option; diff included) Derakon Vanilla 6 October 31, 2010 22:49
Trying to understand the Angband 3.X source code nppangband Development 62 July 11, 2010 18:20
feature request - no disturb on 100% search PowerDiver Vanilla 11 June 14, 2010 22:07
Man on the run....well High Elf on the run. Fendell Orcbane AAR 10 May 1, 2010 08:50
feature request - disturb on reverse LOS PowerDiver Vanilla 2 May 18, 2009 06:46


All times are GMT +1. The time now is 04:24.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.