当前位置: 首页>>代码示例>>C++>>正文


C++ I2A函数代码示例

本文整理汇总了C++中I2A函数的典型用法代码示例。如果您正苦于以下问题:C++ I2A函数的具体用法?C++ I2A怎么用?C++ I2A使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了I2A函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: view_spec_menu

/**
 * Display list available specialties.
 */
void view_spec_menu(void)
{
    menu_type menu;
    menu_iter menu_f = { view_spec_tag, 0, view_spec_display, 0, 0 };
    region loc = { 0, 0, 70, -99 };
    char buf[80];

    /* Save the screen and clear it */
    screen_save();

    /* Prompt choices */
    sprintf(buf, "Race, class, and specialties abilities (%c-%c, ESC=exit): ",
	    I2A(0), I2A(spec_known - 1));

    /* Set up the menu */
    menu_init(&menu, MN_SKIN_SCROLL, &menu_f);
    menu.header = buf;
    menu_setpriv(&menu, spec_known, spec_list);
    loc.page_rows = spec_known + 1;
    menu.flags = MN_DBL_TAP;
    menu.browse_hook = view_spec_menu_browser;
    region_erase_bordered(&loc);
    menu_layout(&menu, &loc);

    menu_select(&menu, 0);

    /* Load screen */
    screen_load();

    return;
}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:34,代码来源:specialty.c

示例2: _list_spells

static void _list_spells(doc_ptr doc, int options)
{
    int i;

    doc_insert(doc, "<style:table>");
    doc_printf(doc, "<color:G>    %-20.20s Lvl  SP Fail %-15.15s", "Name", "Desc");
    if (options & _SHOW_STATS)
        doc_insert(doc, "  Cast Fail");
    doc_insert(doc, "</color>\n");

    for (i = 0; i < _MAX_SLOTS; i++)
    {
        if (_spells[i].realm != REALM_NONE)
            _list_spell(doc, _spells[i].realm, _spells[i].spell, i, options);
        else
        {
            if (options & _ALLOW_EMPTY)
                doc_printf(doc, " %c) <color:D>(Empty)</color>\n", I2A(i));
            else
                doc_printf(doc, " <color:D>%c) (Empty)</color>\n", I2A(i));
        }
    }
    doc_insert(doc, "</style>");

    if (_browse_choice != -1 && _spells[_browse_choice].realm != REALM_NONE)
    {
        doc_newline(doc);
        doc_printf(doc, "    <indent>%s</indent>\n\n",
            do_spell(_spells[_browse_choice].realm, _spells[_browse_choice].spell, SPELL_DESC));
    }
}
开发者ID:poschengband,项目名称:poschengband,代码行数:31,代码来源:gray_mage.c

示例3: gear_to_label

/**
 * Convert a gear object into a one character label.
 */
char gear_to_label(struct object *obj)
{
	int i;

	/* Equipment is easy */
	if (object_is_equipped(player->body, obj)) {
		return I2A(equipped_item_slot(player->body, obj));
	}

	/* Check the quiver */
	for (i = 0; i < z_info->quiver_size; i++) {
		if (player->upkeep->quiver[i] == obj) {
			return I2D(i);
		}
	}

	/* Check the inventory */
	for (i = 0; i < z_info->pack_size; i++) {
		if (player->upkeep->inven[i] == obj) {
			return I2A(i);
		}
	}

	return '\0';
}
开发者ID:NickMcConnell,项目名称:angband,代码行数:28,代码来源:obj-gear.c

示例4: _choose_mimic_form

static int _choose_mimic_form(void)
{
    int             r_idx = -1;
    int             i;
    _choice_array_t choices = {{{0}}};

    /* List Known Forms */
    for (i = 0; i < _MAX_FORMS; i++)
    {
        if (_forms[i])
        {
            int        j = choices.size++;
            _choice_t *choice = &choices.choices[j];

            choice->r_idx = _forms[i];
            choice->slot = i;
            choice->type = _TYPE_KNOWN;
            choice->key = I2A(j);
        }
    }

    /* List Visible Forms */
    for (i = 1; i < m_max; i++)
    {
        monster_type *m_ptr = &m_list[i];

        if (!m_ptr->r_idx) continue;
        if (!m_ptr->ml) continue;
        if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) continue;
        if (!r_info[m_ptr->r_idx].body.life) continue; /* Form not implemented yet ... */

        _add_visible_form(&choices, m_ptr->r_idx);
    }

    /* Assign menu keys at the end due to insertion sort */
    for (i = 0; i < choices.size; i++)
    {
        _choice_t *choice = &choices.choices[i];
        
        if (choice->type == _TYPE_VISIBLE)
            choice->key = I2A(i);
    }

    if (choices.size)
    {
        choices.mode = _CHOOSE_MODE_MIMIC;
        if (_choose(&choices))
            r_idx = choices.choices[choices.current].r_idx;
        do_cmd_redraw();
    }
    else
        msg_print("You see nothing to mimic.");
    return r_idx;
}
开发者ID:bamhamcity,项目名称:lessxpcb,代码行数:54,代码来源:race_mimic.c

示例5: _list_spell

static void _list_spell(doc_ptr doc, int realm, int spell, int choice, int options)
{
    magic_type *spell_ptr = _get_spell_info(realm, spell);
    int         cost = calculate_cost(spell_ptr->smana);
    int         fail = calculate_fail_rate(spell_ptr->slevel, spell_ptr->sfail, p_ptr->stat_ind[A_INT]);

    if (cost > p_ptr->csp)
        doc_insert(doc, "<color:D>");
    else if (choice == _browse_choice)
        doc_insert(doc, "<color:B>");
    else if (spell_ptr->slevel > p_ptr->lev)
    {
        if (options & _FROM_BOOK)
            doc_insert(doc, "<color:D>");
        else
            doc_insert(doc, "<color:y>");
    }
    else
        doc_insert(doc, "<color:w>");

    if (spell_ptr->slevel > p_ptr->lev)
        doc_printf(doc, " <color:D>%c)</color> ", I2A(choice));
    else
        doc_printf(doc, " %c) ", I2A(choice));

    doc_printf(doc, "%-20.20s ", do_spell(realm, spell, SPELL_NAME));
    doc_printf(doc, "%3d %3d %3d%% ", spell_ptr->slevel, cost, fail);

    if (spell_ptr->slevel > p_ptr->lev)
    {
        if (options & _FROM_BOOK)
            doc_printf(doc, "%-15.15s", "");
        else
            doc_printf(doc, "%-15.15s", "Forgotten");
    }
    else if (options & _SHOW_INFO)
        doc_printf(doc, "%-15.15s", do_spell(realm, spell, SPELL_INFO));

    if (options & _SHOW_STATS)
    {
        spell_stats_ptr stats = spell_stats_old(realm, spell);
        if (stats->ct_cast + stats->ct_fail)
        {
            doc_printf(doc, " %5d %4d %3d%%",
                stats->ct_cast,
                stats->ct_fail,
                spell_stats_fail(stats)
            );
        }
    }

    doc_insert(doc, "</color>\n");
}
开发者ID:poschengband,项目名称:poschengband,代码行数:53,代码来源:gray_mage.c

示例6: melee_effect_handler_EAT_FOOD

/**
 * Melee effect handler: Eat the player's food.
 */
static void melee_effect_handler_EAT_FOOD(melee_effect_handler_context_t *context)
{
	/* Steal some food */
	int tries;

	/* Take damage */
	take_hit(context->p, context->damage, context->ddesc);

	/* Player is dead */
	if (context->p->is_dead)
		return;

	for (tries = 0; tries < 10; tries++) {
		/* Pick an item from the pack */
		int index = randint0(z_info->pack_size);
		struct object *obj, *eaten;
		char o_name[80];
		bool none_left = false;

		/* Get the item */
		obj = context->p->upkeep->inven[index];

		/* Skip non-objects */
		if (obj == NULL) continue;

		/* Skip non-food objects */
		if (!tval_is_edible(obj)) continue;

		if (obj->number == 1) {
			object_desc(o_name, sizeof(o_name), obj, ODESC_BASE);
			msg("Your %s (%c) was eaten!", o_name, I2A(index));
		} else {
			object_desc(o_name, sizeof(o_name), obj,
						ODESC_PREFIX | ODESC_BASE);
			msg("One of your %s (%c) was eaten!", o_name,
				I2A(index));
		}

		/* Steal and eat */
		eaten = gear_object_for_use(obj, 1, false, &none_left);
		if (eaten->known)
			object_delete(&eaten->known);
		object_delete(&eaten);

		/* Obvious */
		context->obvious = true;

		/* Done */
		break;
	}
}
开发者ID:BardurArantsson,项目名称:angband,代码行数:54,代码来源:mon-blows.c

示例7: pack_overflow

/**
 * Overflow an item from the pack, if it is overfull.
 */
void pack_overflow(void)
{
	int i;
	struct object *obj = NULL;
	char o_name[80];

	if (!pack_is_overfull()) return;

	/* Disturbing */
	disturb(player, 0);

	/* Warning */
	msg("Your pack overflows!");

	/* Find the last inventory item */
	for (i = 1; i <= z_info->pack_size; i++)
		if (!player->upkeep->inven[i])
			break;

	/* Last object was the previous index */
	obj = player->upkeep->inven[i - 1];

	/* Rule out weirdness (like pack full, but inventory empty) */
	assert(obj != NULL);

	/* Describe */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msg("You drop %s (%c).", o_name, I2A(i - 1));

	/* Excise the object and drop it (carefully) near the player */
	gear_excise_object(obj);
	drop_near(cave, obj, 0, player->py, player->px, FALSE);

	/* Describe */
	if (obj->artifact)
		msg("You no longer have the %s (%c).", o_name, I2A(i - 1));
	else
		msg("You no longer have %s (%c).", o_name, I2A(i - 1));

	/* Notice stuff (if needed) */
	if (player->upkeep->notice) notice_stuff(player->upkeep);

	/* Update stuff (if needed) */
	if (player->upkeep->update) update_stuff(player->upkeep);

	/* Redraw stuff (if needed) */
	if (player->upkeep->redraw) redraw_stuff(player->upkeep);
}
开发者ID:tingley,项目名称:angband,代码行数:53,代码来源:obj-gear.c

示例8: inven_takeoff

/**
 * Take off a non-cursed equipment item
 *
 * Note that taking off an item when "full" may cause that item
 * to fall to the ground.
 *
 * Note also that this function does not try to combine the taken off item
 * with other inventory items - that must be done by the calling function.
 */
void inven_takeoff(struct object *obj)
{
	int slot = equipped_item_slot(player->body, obj);
	const char *act;
	char o_name[80];

	/* Paranoia */
	if (slot == player->body.count) return;

	/* Describe the object */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);

	/* Describe removal by slot */
	if (slot_type_is(slot, EQUIP_WEAPON))
		act = "You were wielding";
	else if (slot_type_is(slot, EQUIP_BOW))
		act = "You were holding";
	else if (slot_type_is(slot, EQUIP_LIGHT))
		act = "You were holding";
	else
		act = "You were wearing";

	/* De-equip the object */
	player->body.slots[slot].obj = NULL;
	player->upkeep->equip_cnt--;

	/* Message */
	msgt(MSG_WIELD, "%s %s (%c).", act, o_name, I2A(slot));

	player->upkeep->update |= (PU_BONUS | PU_INVEN);
	player->upkeep->notice |= (PN_IGNORE);
	return;
}
开发者ID:fe051,项目名称:angband,代码行数:42,代码来源:obj-gear.c

示例9: borg_think_shop_buy

/*
 * Buy items from the current shop
 */
static void borg_think_shop_buy(int item)
{
	list_item *l_ptr = &cur_list[item];

	/* Is the borg on page 1 but wants to be one page 2? */
	if ((borg_term_text_comp(26, 5, "1") && item >= STORE_INVEN_MAX / 2) ||
		(borg_term_text_comp(26, 5, "2") && item <  STORE_INVEN_MAX / 2))
	{
		/* Goto the other page */
		borg_keypress(' ');
	}

	/* Log */
	borg_note("# Buying %s (%i gold).", l_ptr->o_name, l_ptr->cost);

	/* Buy one item */
	borg_keypress('0');
	borg_keypress('1');

	/* Buy an item */
	borg_keypress('p');

	/* Buy the desired item */
	borg_keypress(I2A(item % (STORE_INVEN_MAX / 2)));

	/* Increment 'use' count */
	borg_shops[shop_num].u_count++;

	/* The purchase is complete */
	goal_shop = -1;
}
开发者ID:jcheatham,项目名称:Zangband,代码行数:34,代码来源:zborg8.c

示例10: altel6045_get_dt_data

int altel6045_get_dt_data(const hwextisp_intf_t *i, struct device_node *of_node)
{
	int ret = 0;
	int index = 0;
	altek6045_private_data_t* pdata = NULL;
	altek6045_t* mini_isp = NULL;
	
	mini_isp = I2A(i);
	pdata = (altek6045_private_data_t *)mini_isp->pdata;

	ret = of_property_read_u32_array(of_node, "hisi,isp-pin",
		pdata->pin, ISP_MAX);
	if (ret < 0) {
		cam_err("%s failed line %d\n", __func__, __LINE__);
		return ret;
	} else {
		for (index = 0; index < ISP_MAX; index++) {
			cam_debug("%s pin[%d]=%d.\n", __func__, index,
				pdata->pin[index]);
		}
	}
#if 0
    ret = gpio_request(pdata->pin[ISP_DVDD], "isp-dcdc");
    if (ret < 0) {
        cam_err("%s failed to request isp-dvdd pin.", __func__);
        return ret;
    }
#endif
	return ret; 
}
开发者ID:herryfan,项目名称:kernel-huawei-h60,代码行数:30,代码来源:altek6045.c

示例11: display_snipe_list

/*! 
 * @brief スナイパーの技能リストを表示する
 * @return なし
 */
void display_snipe_list(void)
{
	int             i;
	int             y = 1;
	int             x = 1;
	int             plev = p_ptr->lev;
	snipe_power     spell;
	char            psi_desc[80];

	/* Display a list of spells */
	prt("", y, x);
#ifdef JP
	put_str("名前", y, x + 5);
	put_str("Lv   MP", y, x + 35);
#else
	put_str("Name", y, x + 5);
	put_str("Lv Mana", y, x + 35);
#endif

	/* Dump the spells */
	for (i = 0; i < MAX_SNIPE_POWERS; i++)
	{
		/* Access the available spell */
		spell = snipe_powers[i];
		if (spell.min_lev > plev) continue;
		if (spell.mana_cost > (int)p_ptr->concent) continue;

		/* Dump the spell */
		sprintf(psi_desc, "  %c) %-30s%2d %4d",
			I2A(i), spell.name, spell.min_lev, spell.mana_cost);

		Term_putstr(x, y + i + 1, -1, TERM_WHITE, psi_desc);
	}
	return;
}
开发者ID:dis-,项目名称:hengband,代码行数:39,代码来源:snipe.c

示例12: altek6045_power_off

int altek6045_power_off(const hwextisp_intf_t* i)
{
	return misp_exit();
#if 0
    altek6045_private_data_t* pdata = NULL;
    altek6045_t* mini_isp = NULL;

    cam_notice("enter %s.", __func__);
    mini_isp = I2A(i);
    pdata = (altek6045_private_data_t *)mini_isp->pdata;

    if (ncp6925_ctrl.func_tbl->pmic_seq_config) {
	ret = ncp6925_ctrl.func_tbl->pmic_seq_config(&ncp6925_ctrl, VOUT_LDO_4, VOLTAGE_1P8V, MINI_ISP_POWER_OFF);
    }

    udelay(5);

    if (ncp6925_ctrl.func_tbl->pmic_seq_config) {
	ret = ncp6925_ctrl.func_tbl->pmic_seq_config(&ncp6925_ctrl, VOUT_LDO_5, VOLTAGE_1P1V, MINI_ISP_POWER_OFF);
    }

    udelay(5);

    gpio_direction_output(pdata->pin[ISP_DVDD], MINI_ISP_POWER_OFF);

    msleep(2);
#endif
}
开发者ID:herryfan,项目名称:kernel-huawei-h60,代码行数:28,代码来源:altek6045.c

示例13: update_trigger_name_value

STATICFNDEF int4 update_trigger_name_value(int trigvn_len, char *trig_name, int trig_name_len, int new_trig_index)
{
	sgmnt_addrs		*csa;
	mname_entry		gvent;
	gv_namehead		*hasht_tree;
	int			len;
	char			name_and_index[MAX_MIDENT_LEN + 1 + MAX_DIGITS_IN_INT];
	char			new_trig_name[MAX_TRIGNAME_LEN + 1];
	int			num_len;
	char			*ptr;
	int4			result;
	char			save_currkey[SIZEOF(gv_key) + DBKEYSIZE(MAX_KEY_SZ)];
	gv_key			*save_gv_currkey;
	gd_region		*save_gv_cur_region;
	gv_namehead		*save_gv_target;
	sgm_info		*save_sgm_info_ptr;
	mval			trig_gbl;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	if (MAX_AUTO_TRIGNAME_LEN < trigvn_len)
		return PUT_SUCCESS;
	SAVE_TRIGGER_REGION_INFO;
	SWITCH_TO_DEFAULT_REGION;
	if (gv_cur_region->read_only)
		rts_error_csa(CSA_ARG(csa) VARLSTCNT(4) ERR_TRIGMODREGNOTRW, 2, REG_LEN_STR(gv_cur_region));
	assert(0 != gv_target->root);
	/* $get(^#t("#TNAME",^#t(GVN,index,"#TRIGNAME")) */
	BUILD_HASHT_SUB_SUB_CURRKEY(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1);
	if (!gvcst_get(&trig_gbl))
	{	/* There has to be a #TNAME entry */
		if (CDB_STAGNATE > t_tries)
			t_retry(cdb_sc_triggermod);
		else
		{
			assert(WBTEST_HELPOUT_TRIGDEFBAD == gtm_white_box_test_case_number);
			rts_error_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_TRIGNAMBAD, 4, LEN_AND_LIT("\"#TNAME\""), trig_name_len - 1,
					trig_name);
		}
	}
	len = STRLEN(trig_gbl.str.addr) + 1;
	assert(MAX_MIDENT_LEN >= len);
	memcpy(name_and_index, trig_gbl.str.addr, len);
	ptr = name_and_index + len;
	num_len = 0;
	I2A(ptr, num_len, new_trig_index);
	len += num_len;
	/* set ^#t(GVN,index,"#TRIGNAME")=trig_name $C(0) new_trig_index */
	SET_TRIGGER_GLOBAL_SUB_SUB_STR(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1,
		name_and_index, len, result);
	RESTORE_TRIGGER_REGION_INFO;
	return result;
}
开发者ID:ChristyV,项目名称:fis-gtm,代码行数:53,代码来源:trigger_delete.c

示例14: borg_build_armour

/* How to handle the enchant armour building */
static bool borg_build_armour(void)
{
	int i, slot = -1;
	list_item *l_ptr;

	/* Does the borg have enough gold? */
	if (borg_gold < 2000) return (FALSE);

	for (i = EQUIP_BODY; i < equip_num; i++)
	{
		l_ptr = look_up_equip_slot(i);

		/* Is there armour here? */
		if (!l_ptr) continue;

		/* Is there improvement for the to_hit and to_dam bonus */
		if (l_ptr->to_a >= bp_ptr->lev / 5) continue;

		/* Found an armour */
		slot = i;

		break;
	}

	/* Was an armour found? */
	if (slot == -1) return (FALSE);

	/* Let's go for it */
	borg_keypress('E');

	/* Find out if there are armour in the inv */
	for (i = 0; i < inven_num; i++)
	{
		l_ptr = &inventory[i];

		if (l_ptr->tval >= TV_BOOTS && l_ptr->tval <= TV_DRAG_ARMOR)
		{
			/* skip the inv and go to equip */
			borg_keypress('/');

			break;
		}
	}

	/* And enchant the armour */
	borg_keypress(I2A(slot));

	/* Say so */
	borg_note("# Enchanting %s at the magesmith.", l_ptr->o_name);

	return (TRUE);
}
开发者ID:jcheatham,项目名称:Zangband,代码行数:53,代码来源:zborg8.c

示例15: item_menu_browser

/**
 * Show quiver missiles in full inventory
 */
static void item_menu_browser(int oid, void *data, const region *local_area)
{
	char tmp_val[80];
	int count, j, i = num_obj;
	int quiver_slots = (player->upkeep->quiver_cnt + z_info->quiver_slot_size - 1)
		/ z_info->quiver_slot_size;

	/* Set up to output below the menu */
	text_out_hook = text_out_to_screen;
	text_out_wrap = 0;
	text_out_indent = local_area->col - 1;
	text_out_pad = 1;
	prt("", local_area->row + local_area->page_rows, MAX(0, local_area->col - 1));
	Term_gotoxy(local_area->col, local_area->row + local_area->page_rows);

	/* If we're printing pack slots the quiver takes up */
	if (olist_mode & OLIST_QUIVER && player->upkeep->command_wrk == USE_INVEN) {
		/* Quiver may take multiple lines */
		for (j = 0; j < quiver_slots; j++, i++) {
			const char *fmt = "in Quiver: %d missile%s\n";
			char letter = I2A(i);

			/* Number of missiles in this "slot" */
			if (j == quiver_slots - 1)
				count = player->upkeep->quiver_cnt - (z_info->quiver_slot_size *
													  (quiver_slots - 1));
			else
				count = z_info->quiver_slot_size;

			/* Print the (disabled) label */
			strnfmt(tmp_val, sizeof(tmp_val), "%c) ", letter);
			text_out_c(COLOUR_SLATE, tmp_val, local_area->row + i, local_area->col);

			/* Print the count */
			strnfmt(tmp_val, sizeof(tmp_val), fmt, count,
					count == 1 ? "" : "s");
			text_out_c(COLOUR_L_UMBER, tmp_val, local_area->row + i, local_area->col + 3);
		}
	}

	/* Always print a blank line */
	prt("", local_area->row + i, MAX(0, local_area->col - 1));

	/* Blank out whole tiles */
	while ((tile_height > 1) && ((local_area->row + i) % tile_height != 0)) {
		i++;
		prt("", local_area->row + i, MAX(0, local_area->col - 1));
	}

	text_out_pad = 0;
	text_out_indent = 0;
}
开发者ID:angband,项目名称:angband,代码行数:55,代码来源:ui-object.c


注:本文中的I2A函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。