Example #1
0
/*
 * Interact with feature visuals.
 */
static void do_cmd_knowledge_features(const char *name, int row)
{
	group_funcs fkind_f = { N_ELEMENTS(feature_group_text), FALSE,
		fkind_name, f_cmp_fkind, feat_order, 0
	};

	member_funcs feat_f =
		{ display_feature, feat_lore, f_xchar, f_xattr, feat_prompt,
f_xtra_act, 0 };

	int *features;
	int f_count = 0;
	int i;

	features = C_ZNEW(z_info->f_max, int);

	for (i = 0; i < z_info->f_max; i++) {
		/* Ignore non-features and mimics */
		if (f_info[i].name == 0 || f_info[i].mimic != i)
			continue;

		features[f_count++] = i;	/* Currently no filter for features */
	}

	display_knowledge("features", features, f_count, fkind_f, feat_f,
					  "                    Sym");
	FREE(features);
}
Example #2
0
/*
 * Display known objects
 */
void textui_browse_object_knowledge(void *obj, const char *name)
{
    group_funcs kind_f = { TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0 };
    member_funcs obj_f =
	{ display_object, desc_obj_fake, o_xchar, o_xattr, o_xtra_prompt,
o_xtra_act, 0 };

    int *objects;
    int o_count = 0;
    int i;
    object_kind *k_ptr;

    objects = C_ZNEW(z_info->k_max, int);

    for (i = 0; i < z_info->k_max; i++) {
	k_ptr = &k_info[i];
	/* It's in the list if we've ever seen it, or it has a flavour, and
	 * either it's not one of the special artifacts, or if it is, we're not 
	 * aware of it yet. This way the flavour appears in the list until it
	 * is found. */
	if ((k_ptr->everseen || k_ptr->flavor || OPT(cheat_xtra))
	    && (!kf_has(k_ptr->flags_kind, KF_INSTA_ART)
		|| !artifact_is_known(get_artifact_from_kind(k_ptr)))) {
	    int c = obj_group_order[k_info[i].tval];
	    if (c >= 0)
		objects[o_count++] = i;
	}
    }

    display_knowledge("known objects", objects, o_count, kind_f, obj_f,
		      "Squelch  Inscribed          Sym");

    FREE(objects);
}
Example #3
0
/*
 * Display known monsters.
 */
static void do_cmd_knowledge_monsters(const char *name, int row)
{
    group_funcs r_funcs = { N_ELEMENTS(monster_group), FALSE, race_name,
	m_cmp_race, default_group, mon_summary
    };

    member_funcs m_funcs =
	{ display_monster, mon_lore, m_xchar, m_xattr, recall_prompt, 0, 0 };

    int *monsters;
    int m_count = 0;
    int i;
    size_t j;

    for (i = 0; i < z_info->r_max; i++) {
	monster_race *r_ptr = &r_info[i];
	if (!OPT(cheat_know) && !l_list[i].sights)
	    continue;
	if (!r_ptr->name)
	    continue;

	if (rf_has(r_ptr->flags, RF_UNIQUE))
	    m_count++;

	for (j = 1; j < N_ELEMENTS(monster_group) - 1; j++) {
	    const char *pat = monster_group[j].chars;
	    if (strchr(pat, r_ptr->d_char))
		m_count++;
	}
    }

    default_join = C_ZNEW(m_count, join_t);
    monsters = C_ZNEW(m_count, int);

    m_count = 0;
    for (i = 0; i < z_info->r_max; i++) {
	monster_race *r_ptr = &r_info[i];
	if (!OPT(cheat_know) && !l_list[i].sights)
	    continue;
	if (!r_ptr->name)
	    continue;

	for (j = 0; j < N_ELEMENTS(monster_group) - 1; j++) {
	    const char *pat = monster_group[j].chars;
	    if (j == 0 && !(rf_has(r_ptr->flags, RF_UNIQUE)))
		continue;
	    else if (j > 0 && !strchr(pat, r_ptr->d_char))
		continue;

	    monsters[m_count] = m_count;
	    default_join[m_count].oid = i;
	    default_join[m_count++].gid = j;
	}
    }

    display_knowledge("monsters", monsters, m_count, r_funcs, m_funcs,
		      "                   Sym  Kills");
    FREE(default_join);
    FREE(monsters);
}
Example #4
0
/*
 * Display known artifacts
 */
static void do_cmd_knowledge_artifacts(const char *name, int row)
{
	/* HACK -- should be TV_MAX */
	group_funcs obj_f = {TV_GOLD, FALSE, kind_name, a_cmp_tval, art2gid, 0};
	member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, recall_prompt, 0, 0};

	int *artifacts;
	int a_count = 0;

	artifacts = C_ZNEW(z_info->a_max, int);

	/* Collect valid artifacts */
	a_count = collect_known_artifacts(artifacts, z_info->a_max);

	display_knowledge("artifacts", artifacts, a_count, obj_f, art_f, NULL);
	FREE(artifacts);
}
Example #5
0
/*
 * Display known ego_items
 */
static void do_cmd_knowledge_ego_items(const char *name, int row)
{
	group_funcs obj_f =
		{TV_GOLD, FALSE, ego_grp_name, e_cmp_tval, default_group, 0};

	member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, recall_prompt, 0, 0};

	int *egoitems;
	int e_count = 0;
	int i, j;

	/* HACK: currently no more than 3 tvals for one ego type */
	egoitems = C_ZNEW(z_info->e_max * EGO_TVALS_MAX, int);
	default_join = C_ZNEW(z_info->e_max * EGO_TVALS_MAX, join_t);

	for (i = 0; i < z_info->e_max; i++)
	{
		if (e_info[i].everseen || OPT(cheat_xtra))
		{
			for (j = 0; j < EGO_TVALS_MAX && e_info[i].tval[j]; j++)
			{
				int gid = obj_group_order[e_info[i].tval[j]];

				/* Ignore duplicate gids */
				if (j > 0 && gid == default_join[e_count - 1].gid) continue;

				egoitems[e_count] = e_count;
				default_join[e_count].oid = i;
				default_join[e_count++].gid = gid;
			}
		}
	}

	display_knowledge("ego items", egoitems, e_count, obj_f, ego_f, NULL);

	FREE(default_join);
	FREE(egoitems);
}