Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#749 closed task (fixed (in master))

A uniform way to access player knowledge of player state

Reported by: stefanor@… Owned by:
Milestone: 3.3.0 Keywords: cleanup
Cc:

Description

In the trunk at the time of writing, you can examine a red worm mass to find out if you are wearing unidentified fire resistance equipment. There's currently code in files.c to extract known resistances, but it's interwoven with the code for displaying the ability tables and thus of no use. One solution (stolen from Crawl) is to add a bool known_only parameter to calc_bonuses; I'd like a second opinion before implementing this. Side benefit: we can get rid of p_ptr->state.dis_to_h and friends.

Change History (7)

comment:1 Changed 11 years ago by Kenneth 'Bessarion' Boyd

The resistance, etc. booleans are all computed fields; there's no savefile effect from adding more fields. What's painful is using record fields instead of arrays.

Zaiband 3.0.10 alpha is going to handle this (as part of the ID-inference code) by explicitly tracking the known boolean status. The initial field conversion in player_type was to:

s16b stat_use[A_MAX];	/**< Current modified stats */
s16b stat_top[A_MAX];	/**< Maximal modified stats */

/*** Extracted fields ***/

s16b stat_add[A_MAX];	/**< Equipment stat bonuses */
s16b stat_ind[A_MAX];	/**< Indexes into stat tables */

bool immune[MAX_IMMUNE];	/**< Immunity list */
bool resist[MAX_RESIST];	/**< Resistance list */
bool sustain[A_MAX];/**< Keep strength, etc. (cf. stat_index enumeration) */

with supporting new enum in defines.h

/**
 * Indexes of the various boolean resists/specials
 *
 * \sa
 */
enum resist_index {[[BR]]
	r_acid = 0,	/**< Resist acid */
	r_elec,		/**< Resist lightning */
	r_fire,		/**< Resist fire */
	r_cold,		/**< Resist cold */
	r_pois,		/**< Resist poison */

	r_fear,		/**< Resist fear */
	r_lite,		/**< Resist light */
	r_dark,		/**< Resist darkness */
	r_blind,	/**< Resist blindness */
	r_confu,	/**< Resist confusion */
	r_sound,	/**< Resist sound */
	r_shard,	/**< Resist shards */
	r_nexus,	/**< Resist nexus */
	r_nethr,	/**< Resist nether */
	r_chaos,	/**< Resist chaos */
	r_disen,	/**< Resist disenchant */

	p_slow_digest,	/**< Slower digestion */
	p_ffall,	/**< Feather falling */
	p_lite,		/**< Permanent light */
	p_regenerate,	/**< Regeneration */
	p_telepathy,	/**< Telepathy */
	p_see_inv,	/**< See invisible */
	p_free_act,	/**< Free action */
	p_hold_life,	/**< Hold life */

	p_impact,	/**< Earthquake blows */
	p_aggravate,	/**< Aggravate monsters */
	p_teleport,	/**< Random teleporting */
	p_exp_drain,	/**< Experience draining */

	p_bless_blade	/* Blessed blade */
};

/**
 * total number of various boolean resists/specials
 *
 * \sa ::resist_index
 */
#define MAX_RESIST (p_bless_blade+1)

/**
 * total number of various boolean immunities
 *
 * \sa ::resist_index
 */
#define MAX_IMMUNE (r_cold+1)

This change did incur some source code size bloat.

I'm indifferent as to whether to use a known-only boolean parameter, or just explicitly store the known state of the flags as well. (Zaiband is going to go with explicitly storing the known state of the flags, but that may not be reasonable for V).

comment:2 Changed 11 years ago by takkaria

some of the work done in [2066d83] (SVN r1174)

comment:3 Changed 10 years ago by takkaria

  • Milestone changed from 3.1.1 beta to 3.1.2 beta

comment:4 Changed 10 years ago by magnate

  • Keywords cleanup added

comment:5 Changed 9 years ago by magnate

  • Milestone changed from 3.2.0 to 3.3.0

Punting to 3.3: non-urgent bug or change.

comment:6 Changed 9 years ago by magnate

  • Status changed from new to pending

This is now complete, and demonstrated in [r2b443eb]: create a player_state struct, call calc_bonuses with id_only set to TRUE, and then call check_state to check individual things about the known_only state. Bring on the borg!

comment:7 Changed 9 years ago by magnate

  • Resolution set to fixed
  • Status changed from pending to closed

In master as of [r72e6029], Sun 22 May 2011.

Note: See TracTickets for help on using tickets.