本文整理汇总了C++中OPT函数的典型用法代码示例。如果您正苦于以下问题:C++ OPT函数的具体用法?C++ OPT怎么用?C++ OPT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OPT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: do_cmd_go_down
/**
* Go down one level
*/
void do_cmd_go_down(struct command *cmd)
{
int descend_to = dungeon_get_next_level(player->depth, 1);
/* Verify stairs */
if (!square_isdownstairs(cave, player->py, player->px)) {
msg("I see no down staircase here.");
return;
}
/* Paranoia, no descent from z_info->max_depth - 1 */
if (player->depth == z_info->max_depth - 1) {
msg("The dungeon does not appear to extend deeper");
return;
}
/* Warn a force_descend player if they're going to a quest level */
if (OPT(birth_force_descend)) {
descend_to = dungeon_get_next_level(player->max_depth, 1);
if (is_quest(descend_to) &&
!get_check("Are you sure you want to descend?"))
return;
}
/* Hack -- take a turn */
player->upkeep->energy_use = z_info->move_energy;
/* Success */
msgt(MSG_STAIRS_DOWN, "You enter a maze of down staircases.");
/* Create a way back */
player->upkeep->create_up_stair = true;
player->upkeep->create_down_stair = false;
/* Change level */
dungeon_change_level(descend_to);
}
开发者ID:Chillbon,项目名称:angband,代码行数:40,代码来源:cmd-cave.c
示例2: ui_keymap_query
static void ui_keymap_query(const char *title, int row)
{
char tmp[1024];
int mode = OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG;
struct keypress c;
const struct keypress *act;
prt(title, 13, 0);
prt("Key: ", 14, 0);
/* Get a keymap trigger & mapping */
c = keymap_get_trigger();
act = keymap_find(mode, c);
/* Nothing found */
if (!act)
{
/* Prompt */
prt("No keymap with that trigger. Press any key to continue.", 16, 0);
inkey();
}
/* Found one */
else
{
/* Analyze the current action */
keypress_to_text(tmp, sizeof(tmp), act, false);
/* Display the current action */
prt("Found: ", 15, 0);
Term_addstr(-1, TERM_WHITE, tmp);
prt("Press any key to continue.", 17, 0);
inkey();
}
}
开发者ID:jobjingjo,项目名称:csangband,代码行数:36,代码来源:ui-options.c
示例3: make_gold
/*
* Make a money object
*/
void make_gold(object_type *j_ptr, int lev, int coin_type)
{
int sval;
/* This average is 20 at dlev0, 105 at dlev40, 220 at dlev100. */
/* Follows the formula: y=2x+20 */
s32b avg = 2*lev + 20;
s32b spread = lev + 10;
s32b value = rand_spread(avg, spread);
/* Increase the range to infinite, moving the average to 110% */
while (one_in_(100) && value * 10 <= MAX_SHORT)
value *= 10;
/* Pick a treasure variety scaled by level, or force a type */
if (coin_type != SV_GOLD_ANY)
sval = coin_type;
else
sval = (((value * 100) / MAX_GOLD_DROP) * SV_GOLD_MAX) / 100;
/* Do not create illegal treasure types */
if (sval >= SV_GOLD_MAX) sval = SV_GOLD_MAX - 1;
/* Prepare a gold object */
object_prep(j_ptr, lookup_kind(TV_GOLD, sval), lev, RANDOMISE);
/* If we're playing with no_selling, increase the value */
if (OPT(birth_no_selling) && p_ptr->depth)
value = value * MIN(5, p_ptr->depth);
/* Cap gold at max short (or alternatively make pvals s32b) */
if (value > MAX_SHORT)
value = MAX_SHORT;
j_ptr->pval[DEFAULT_PVAL] = value;
}
开发者ID:Abigail,项目名称:angband,代码行数:39,代码来源:obj-make.c
示例4: do_cmd_go_up
/**
* Go up one level
*/
void do_cmd_go_up(struct command *cmd)
{
int ascend_to;
/* Verify stairs */
if (!square_isupstairs(cave, player->py, player->px)) {
msg("I see no up staircase here.");
return;
}
/* Force descend */
if (OPT(birth_force_descend)) {
msg("Nothing happens!");
return;
}
ascend_to = dungeon_get_next_level(player->depth, -1);
if (ascend_to == player->depth) {
msg("You can't go up from here!");
return;
}
/* Take a turn */
player->upkeep->energy_use = z_info->move_energy;
/* Success */
msgt(MSG_STAIRS_UP, "You enter a maze of up staircases.");
/* Create a way back */
player->upkeep->create_up_stair = false;
player->upkeep->create_down_stair = true;
/* Change level */
dungeon_change_level(ascend_to);
}
开发者ID:pete-mack,项目名称:angband,代码行数:39,代码来源:cmd-cave.c
示例5: collect_known_artifacts
/* If 'artifacts' is NULL, it counts the number of known artifacts, otherwise
it collects the list of known artifacts into 'artifacts' as well. */
static int collect_known_artifacts(int *artifacts, size_t artifacts_len)
{
int a_count = 0;
int j;
if (artifacts)
assert(artifacts_len >= z_info->a_max);
for (j = 0; j < z_info->a_max; j++)
{
/* Artifact doesn't exist */
if (!a_info[j].name) continue;
if (OPT(cheat_xtra) || artifact_is_known(j))
{
if (artifacts)
artifacts[a_count++] = j;
else
a_count++;
}
}
return a_count;
}
开发者ID:coapp-packages,项目名称:angband,代码行数:26,代码来源:ui-knowledge.c
示例6: textui_browse_object_knowledge
/*
* Display known objects
*/
void textui_browse_object_knowledge(const char *name, int row)
{
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);
}
开发者ID:NickMcConnell,项目名称:FAangband,代码行数:39,代码来源:ui-knowledge.c
示例7: print_op
static void print_op(t_ps *ps, int op)
{
if (OPT(OPT_EXEC))
{
if (OPT(OPT_VERBOSE))
{
if (!(OPT(OPT_INTERACTIVE)))
ft_putendl(g_ops[op].name);
print_stacks(ps);
}
else if (!OPT(OPT_INTERACTIVE) && !(OPT(OPT_GRAPHIC)))
ft_printf("%s ", g_ops[op].name);
if (OPT(OPT_GRAPHIC))
{
if ((G_MODE(0)
|| (G_MODE(1) && !(ps->total_ops % (ps->total_elem / 30 + 1)))
|| (G_MODE(2) && CURR_VAL(FIRST(ps->stack_a)) == ps->range_min)))
mlx_redraw(ps, g_ops[op].name);
}
}
}
开发者ID:vimarinc,项目名称:Push_swap,代码行数:21,代码来源:resolve.c
示例8: display_knowledge
/*
* Interactive group by.
* Recognises inscriptions, graphical symbols, lore
*/
static void display_knowledge(const char *title, int *obj_list,
int o_count, group_funcs g_funcs,
member_funcs o_funcs,
const char *otherfields)
{
/* maximum number of groups to display */
int max_group = g_funcs.maxnum < o_count ? g_funcs.maxnum : o_count;
/* This could (should?) be (void **) */
int *g_list, *g_offset;
const char **g_names;
int g_name_len = 8; /* group name length, minumum is 8 */
int grp_cnt = 0; /* total number groups */
int g_cur = 0, grp_old = -1; /* group list positions */
int o_cur = 0; /* object list positions */
int g_o_count = 0; /* object count for group */
int oid = -1; /* object identifiers */
region title_area = { 0, 0, 0, 4 };
region group_region = { 0, 6, MISSING, -2 };
region object_region = { MISSING, 6, 0, -2 };
/* display state variables */
bool tiles = (current_graphics_mode != NULL);
bool tile_picker = FALSE;
bool glyph_picker = FALSE;
byte attr_top = 0;
byte char_left = 0;
int delay = 0;
menu_type group_menu;
menu_type object_menu;
menu_iter object_iter =
{ NULL, NULL, display_group_member, NULL, NULL };
/* Panel state */
/* These are swapped in parallel whenever the actively browsing " */
/* changes */
int *active_cursor = &g_cur, *inactive_cursor = &o_cur;
menu_type *active_menu = &group_menu, *inactive_menu = &object_menu;
int panel = 0;
void *swapspace;
bool do_swap = FALSE;
bool flag = FALSE;
bool redraw = TRUE;
int browser_rows;
int wid, hgt;
int i;
int prev_g = -1;
int omode = OPT(rogue_like_commands);
ui_event ke;
/* Get size */
Term_get_size(&wid, &hgt);
browser_rows = hgt - 8;
/* Disable the roguelike commands for the duration */
OPT(rogue_like_commands) = FALSE;
/* Determine if using tiles or not */
if (tiles)
tiles = (current_graphics_mode->grafID != 0);
if (g_funcs.gcomp)
sort(obj_list, o_count, sizeof(*obj_list), g_funcs.gcomp);
/* Sort everything into group order */
g_list = C_ZNEW(max_group + 1, int);
g_offset = C_ZNEW(max_group + 1, int);
for (i = 0; i < o_count; i++) {
if (prev_g != g_funcs.group(obj_list[i])) {
prev_g = g_funcs.group(obj_list[i]);
g_offset[grp_cnt] = i;
g_list[grp_cnt++] = prev_g;
}
}
g_offset[grp_cnt] = o_count;
g_list[grp_cnt] = -1;
/* The compact set of group names, in display order */
g_names = C_ZNEW(grp_cnt, const char *);
for (i = 0; i < grp_cnt; i++) {
int len;
//.........这里部分代码省略.........
开发者ID:NickMcConnell,项目名称:FAangband,代码行数:101,代码来源:ui-knowledge.c
示例9: price_item
/**
* Determine the price of an object (qty one) in a store.
*
* store_buying == TRUE means the shop is buying, player selling
* == FALSE means the shop is selling, player buying
*
* This function never lets a shop-keeper lose money in a transaction.
*
* The "greed" value should exceed 100 when the player is "buying" the
* object, and should be less than 100 when the player is "selling" it.
*
* Hack -- the black market always charges twice as much as it should.
*/
int price_item(struct store *store, const struct object *obj,
bool store_buying, int qty)
{
int adjust = 100;
int price;
struct owner *proprietor;
if (!store) return 0L;
proprietor = store->owner;
/* Get the value of the stack of wands, or a single item */
if (tval_can_have_charges(obj))
price = object_value(obj, qty, FALSE);
else
price = object_value(obj, 1, FALSE);
/* Worthless items */
if (price <= 0) return (0L);
/* The black market is always a worse deal */
if (store->sidx == STORE_B_MARKET)
adjust = 150;
/* Shop is buying */
if (store_buying) {
/* Set the factor */
adjust = 100 + (100 - adjust);
if (adjust > 100) adjust = 100;
/* Shops now pay 2/3 of true value */
price = price * 2 / 3;
/* Black market sucks */
if (store->sidx == STORE_B_MARKET)
price = price / 2;
/* Check for no_selling option */
if (OPT(birth_no_selling)) return (0L);
} else {
/* Recalculate if the player doesn't know the flavour */
if (!obj->kind->aware) {
obj->kind->aware = TRUE;
if (tval_can_have_charges(obj))
price = object_value(obj, qty, FALSE);
else
price = object_value(obj, 1, FALSE);
obj->kind->aware = FALSE;
}
/* Black market sucks */
if (store->sidx == STORE_B_MARKET)
price = price * 2;
}
/* Compute the final price (with rounding) */
price = (price * adjust + 50L) / 100L;
/* Now convert price to total price for non-wands */
if (!tval_can_have_charges(obj))
price *= qty;
/* Now limit the price to the purse limit */
if (store_buying && (price > proprietor->max_cost * qty))
price = proprietor->max_cost * qty;
/* Note -- Never become "free" */
if (price <= 0L) return (qty);
/* Return the price */
return (price);
}
开发者ID:batogz,项目名称:angband,代码行数:85,代码来源:store.c
示例10: move_player
//.........这里部分代码省略.........
/* Wall (or secret door) */
else
{
msgt(MSG_HITWALL, "You feel a wall blocking your way.");
cave->info[y][x] |= (CAVE_MARK);
cave_light_spot(cave, y, x);
}
}
/* Mention known obstacles */
else
{
if (cave->feat[y][x] == FEAT_RUBBLE)
msgt(MSG_HITWALL, "There is a pile of rubble blocking your way.");
else if (cave->feat[y][x] < FEAT_SECRET)
msgt(MSG_HITWALL, "There is a door blocking your way.");
else
msgt(MSG_HITWALL, "There is a wall blocking your way.");
}
}
/* Normal movement */
else
{
/* See if trap detection status will change */
bool old_dtrap = ((cave->info2[py][px] & (CAVE2_DTRAP)) != 0);
bool new_dtrap = ((cave->info2[y][x] & (CAVE2_DTRAP)) != 0);
/* Note the change in the detect status */
if (old_dtrap != new_dtrap)
p_ptr->redraw |= (PR_DTRAP);
/* Disturb player if the player is about to leave the area */
if (OPT(disturb_detect) && p_ptr->running &&
!p_ptr->running_firststep && old_dtrap && !new_dtrap)
{
disturb(p_ptr, 0, 0);
return;
}
/* Move player */
monster_swap(py, px, y, x);
/* New location */
y = py = p_ptr->py;
x = px = p_ptr->px;
/* Searching */
if (p_ptr->searching ||
(p_ptr->state.skills[SKILL_SEARCH_FREQUENCY] >= 50) ||
one_in_(50 - p_ptr->state.skills[SKILL_SEARCH_FREQUENCY]))
search(FALSE);
/* Handle "store doors" */
if ((cave->feat[p_ptr->py][p_ptr->px] >= FEAT_SHOP_HEAD) &&
(cave->feat[p_ptr->py][p_ptr->px] <= FEAT_SHOP_TAIL))
{
/* Disturb */
disturb(p_ptr, 0, 0);
cmd_insert(CMD_ENTER_STORE);
}
/* All other grids (including traps) */
else
{
/* Handle objects (later) */
p_ptr->notice |= (PN_PICKUP);
}
/* Discover invisible traps */
if (cave->feat[y][x] == FEAT_INVIS)
{
/* Disturb */
disturb(p_ptr, 0, 0);
/* Message */
msg("You found a trap!");
/* Pick a trap */
pick_trap(y, x);
/* Hit the trap */
hit_trap(y, x);
}
/* Set off an visible trap */
else if (cave_isknowntrap(cave, y, x))
{
/* Disturb */
disturb(p_ptr, 0, 0);
/* Hit the trap */
hit_trap(y, x);
}
}
p_ptr->running_firststep = FALSE;
}
开发者ID:tonberrytoby,项目名称:angband,代码行数:101,代码来源:cmd1.c
示例11: get_item
/*
* Let the user select an item, save its "index"
*
* Return TRUE only if an acceptable item was chosen by the user.
*
* The selected item must satisfy the "item_tester_hook()" function,
* if that hook is set, and the "item_tester_tval", if that value is set.
*
* All "item_tester" restrictions are cleared before this function returns.
*
* The user is allowed to choose acceptable items from the equipment,
* inventory, or floor, respectively, if the proper flag was given,
* and there are any acceptable items in that location.
*
* The equipment or inventory are displayed (even if no acceptable
* items are in that location) if the proper flag was given.
*
* If there are no acceptable items available anywhere, and "str" is
* not NULL, then it will be used as the text of a warning message
* before the function returns.
*
* Note that the user must press "-" to specify the item on the floor,
* and there is no way to "examine" the item on the floor, while the
* use of "capital" letters will "examine" an inventory/equipment item,
* and prompt for its use.
*
* If a legal item is selected from the inventory, we save it in "cp"
* directly (0 to 35), and return TRUE.
*
* If a legal item is selected from the floor, we save it in "cp" as
* a negative (-1 to -511), and return TRUE.
*
* If no item is available, we do nothing to "cp", and we display a
* warning message, using "str" if available, and return FALSE.
*
* If no item is selected, we do nothing to "cp", and return FALSE.
*
* Global "p_ptr->command_wrk" is used to choose between equip/inven/floor
* listings. It is equal to USE_INVEN or USE_EQUIP or USE_FLOOR, except
* when this function is first called, when it is equal to zero, which will
* cause it to be set to USE_INVEN.
*
* We always erase the prompt when we are done, leaving a blank line,
* or a warning message, if appropriate, if no items are available.
*
* Note that only "acceptable" floor objects get indexes, so between two
* commands, the indexes of floor objects may change. XXX XXX XXX
*/
bool get_item(int *cp, const char *pmt, const char *str, cmd_code cmd, int mode)
{
int py = p_ptr->py;
int px = p_ptr->px;
unsigned char cmdkey = cmd_lookup_key(cmd,
OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG);
//struct keypress which;
ui_event press;
int j, k;
int i1, i2;
int e1, e2;
int f1, f2;
bool done, item;
bool oops = FALSE;
bool use_inven = ((mode & USE_INVEN) ? TRUE : FALSE);
bool use_equip = ((mode & USE_EQUIP) ? TRUE : FALSE);
bool use_floor = ((mode & USE_FLOOR) ? TRUE : FALSE);
bool is_harmless = ((mode & IS_HARMLESS) ? TRUE : FALSE);
bool quiver_tags = ((mode & QUIVER_TAGS) ? TRUE : FALSE);
int olist_mode = 0;
bool allow_inven = FALSE;
bool allow_equip = FALSE;
bool allow_floor = FALSE;
bool toggle = FALSE;
char tmp_val[160];
char out_val[160];
int floor_list[MAX_FLOOR_STACK];
int floor_num;
bool show_list = TRUE;
/* Hack - Only shift the command key if it actually needs to be shifted. */
if (cmdkey < 0x20)
cmdkey = UN_KTRL(cmdkey);
/* Object list display modes */
if (mode & SHOW_FAIL)
olist_mode |= OLIST_FAIL;
else
olist_mode |= OLIST_WEIGHT;
//.........这里部分代码省略.........
开发者ID:KertaLosataure,项目名称:angband,代码行数:101,代码来源:obj-ui.c
示例12: OPT
#include "stdg.h"
#include "error_msg.h"
extern Option OPT(CallFuture);
extern Option OPT(PutFuture);
extern Option OPT(Swing);
Option* OPT(family)[]=
{
&OPT(CallFuture),
&OPT(PutFuture),
&OPT(Swing),
NULL
};
开发者ID:jayhsieh,项目名称:premia-13,代码行数:14,代码来源:stdg.c
示例13: inkey_ex
//.........这里部分代码省略.........
inkey_scan = 0;
ke.type = EVT_KBRD;
/* Accept result */
return (ke);
}
}
#endif /* ALLOW_BORG */
/* Get the cursor state */
(void)Term_get_cursor(&cursor_state);
/* Show the cursor if waiting, except sometimes in "command" mode */
if (!inkey_scan && (!inkey_flag || character_icky))
(void)Term_set_cursor(TRUE);
/* Hack -- Activate main screen */
Term_activate(term_screen);
/* Get a key */
while (ke.type == EVT_NONE)
{
/* Hack -- Handle "inkey_scan == SCAN_INSTANT */
if (inkey_scan == SCAN_INSTANT &&
(0 != Term_inkey(&kk, FALSE, FALSE)))
break;
/* Hack -- Flush output once when no key ready */
if (!done && (0 != Term_inkey(&kk, FALSE, FALSE)))
{
/* Hack -- activate proper term */
Term_activate(old);
/* Flush output */
Term_fresh();
/* Hack -- activate main screen */
Term_activate(term_screen);
/* Mega-Hack -- reset saved flag */
character_saved = FALSE;
/* Mega-Hack -- reset signal counter */
signal_count = 0;
/* Only once */
done = TRUE;
}
/* Get a key (see above) */
ke = inkey_aux(inkey_scan);
/* Handle mouse buttons */
if ((ke.type == EVT_MOUSE) && (OPT(mouse_buttons)))
{
/* Check to see if we've hit a button */
/* Assuming text buttons here for now - this would have to
* change for GUI buttons */
char key = button_get_key(ke.mouse.x, ke.mouse.y);
if (key)
{
/* Rewrite the event */
/* XXXmacro button implementation needs updating */
ke.type = EVT_BUTTON;
ke.key.code = key;
ke.key.mods = 0;
/* Done */
break;
}
}
/* Treat back-quote as escape */
if (ke.key.code == '`')
ke.key.code = ESCAPE;
}
/* Hack -- restore the term */
Term_activate(old);
/* Restore the cursor */
Term_set_cursor(cursor_state);
/* Cancel the various "global parameters" */
inkey_flag = FALSE;
inkey_scan = 0;
/* Return the keypress */
return (ke);
}
开发者ID:Kilumanjaro,项目名称:angband,代码行数:101,代码来源:util.c
示例14: P1
optimize P1(parse_node_t *, expr) {
if (!expr) return 0;
switch (expr->kind) {
case NODE_TERNARY_OP:
OPT(expr->l.expr);
OPT(expr->r.expr->l.expr);
OPT(expr->r.expr->r.expr);
break;
case NODE_BINARY_OP:
OPT(expr->l.expr);
if (expr->v.number == F_ASSIGN) {
if (IS_NODE(expr->r.expr, NODE_OPCODE_1, F_LOCAL_LVALUE)) {
if (!optimizer_state) {
int x = expr->r.expr->l.number;
if (last_local_refs[x]) {
last_local_refs[x]->v.number = F_TRANSFER_LOCAL;
last_local_refs[x] = 0;
}
}
}
}
OPT(expr->r.expr);
break;
case NODE_UNARY_OP:
OPT(expr->r.expr);
break;
case NODE_OPCODE:
break;
case NODE_TERNARY_OP_1:
OPT(expr->l.expr);
OPT(expr->r.expr->l.expr);
OPT(expr->r.expr->r.expr);
break;
case NODE_BINARY_OP_1:
OPT(expr->l.expr);
OPT(expr->r.expr);
break;
case NODE_UNARY_OP_1:
OPT(expr->r.expr);
if (expr->v.number == F_VOID_ASSIGN_LOCAL) {
if (last_local_refs[expr->l.number] && !optimizer_state) {
last_local_refs[expr->l.number]->v.number = F_TRANSFER_LOCAL;
last_local_refs[expr->l.number] = 0;
}
}
break;
case NODE_OPCODE_1:
if (expr->v.number == F_LOCAL || expr->v.number == F_LOCAL_LVALUE) {
if (expr->v.number == F_LOCAL) {
if(!optimizer_state) {
last_local_refs[expr->l.number] = expr;
break;
}
}
last_local_refs[expr->l.number] = 0;
}
break;
case NODE_OPCODE_2:
break;
case NODE_RETURN:
OPT(expr->r.expr);
break;
case NODE_STRING:
case NODE_REAL:
case NODE_NUMBER:
break;
case NODE_LAND_LOR:
case NODE_BRANCH_LINK:
OPT(expr->l.expr);
OPT(expr->r.expr);
break;
case NODE_CALL_2:
case NODE_CALL_1:
case NODE_CALL:
optimize_expr_list(expr->r.expr);
break;
case NODE_TWO_VALUES:
OPT(expr->l.expr);
OPT(expr->r.expr);
break;
case NODE_CONTROL_JUMP:
case NODE_PARAMETER:
case NODE_PARAMETER_LVALUE:
break;
case NODE_IF:
{
int in_cond;
OPT(expr->v.expr);
in_cond = (optimizer_state & OPTIMIZER_IN_COND);
optimizer_state |= OPTIMIZER_IN_COND;
OPT(expr->l.expr);
OPT(expr->r.expr);
optimizer_state &= ~OPTIMIZER_IN_COND;
optimizer_state |= in_cond;
break;
}
case NODE_LOOP:
{
//.........这里部分代码省略.........
开发者ID:Junho2009,项目名称:propose_srv_linux,代码行数:101,代码来源:generate.c
示例15: describe_flavor_text
/*
* Print an item's flavour text.
*
* \param tb is the textblock to which we are adding.
* \param o_ptr is the object we are describing.
* \param ego is whether we're describing an ego template (as opposed to a
* real object)
*/
static void describe_flavor_text(textblock *tb, const object_type *o_ptr,
oinfo_detail_t mode)
{
int i, count = 0;
bool ego = mode & OINFO_EGO;
bool subj = mode & OINFO_SUBJ;
/* Display the known artifact description */
if (!OPT(birth_randarts) && o_ptr->artifact &&
object_is_known(o_ptr) && o_ptr->artifact->text)
textblock_append(tb, "%s\n\n", o_ptr->artifact->text);
else if (o_ptr->theme && o_ptr->theme->text &&
object_theme_is_known(o_ptr))
textblock_append(tb, "%s\n\n", o_ptr->theme->text);
/* Display the known object description */
else if (object_flavor_is_aware(o_ptr) || object_is_known(o_ptr) || ego) {
bool did_desc = FALSE;
if (!ego && o_ptr->kind->text) {
textblock_append(tb, "%s", o_ptr->kind->text);
did_desc = TRUE;
}
/* Display additional affix descriptions */
for (i = 0; i < MAX_AFFIXES && o_ptr->affix[i]; i++)
if (o_ptr->affix[i]->text && (ego ||
object_affix_is_known(o_ptr, o_ptr->affix[i]->eidx))) {
if (did_desc)
textblock_append(tb, " ");
textblock_append(tb, "%s", o_ptr->affix[i]->text);
did_desc = TRUE;
}
if (did_desc)
textblock_append(tb, "\n\n");
}
/* List the affixes on the item */
for (i = 0; i < MAX_AFFIXES && o_ptr->affix[i]; i++)
if (object_affix_is_known(o_ptr, o_ptr->affix[i]->eidx)) {
if (count == 0)
textblock_append(tb, "This item's known properties are: ");
else
textblock_append(tb, ", ");
textblock_append(tb, "%s", o_ptr->affix[i]->name);
count++;
}
if (count)
textblock_append(tb, ".\n\n");
if (!ego && subj && o_ptr->origin != ORIGIN_STORE) {
/* List the item's known runes */
count = 0;
for (i = 0; i < OF_MAX; i++)
if (of_has(o_ptr->flags, i) && of_has(p_ptr->known_runes, i) &&
obj_flag_type(i) != OFT_INT && obj_flag_type(i) != OFT_NONE) {
if (count == 0)
textblock_append(tb, "This item's known runes are: ");
else
textblock_append(tb, ", ");
textblock_append(tb, "%s", flag_name(i));
count++;
}
if (count)
textblock_append(tb, ".\n\n");
/* List the item's unknown runes */
count = 0;
for (i = 0; i < OF_MAX; i++)
if (of_has(o_ptr->flags, i) && !of_has(p_ptr->known_runes, i) &&
obj_flag_type(i) != OFT_INT && obj_flag_type(i) != OFT_NONE) {
if (count == 0)
textblock_append(tb, "This item's unknown runes are: ");
else
textblock_append(tb, ", ");
textblock_append(tb, "%s", flag_rune(i));
count++;
}
if (count)
textblock_append(tb, ".\n\n");
}
}
开发者ID:nomadicwriter,项目名称:v4,代码行数:92,代码来源:obj-info.c
示例16: main
int
main(int argc, char *argv[])
{
int ret = 1, istty, i, idx;
char *msg = NULL, *timer = NULL, *at_end = NULL, *halfway = NULL;
dldev_t dev;
tymer_t db;
u8 *data;
u16 len;
/* for data security */
/*
umask(S_IRWXG | S_IRWXO);
*/
istty = isatty(0);
i = strlen(argv[0]) - 1;
for(; i >= 0 && argv[0][i] != '/'; i--);
i++;
if(strstr(argv[0] + i, "interval")){
set_timer(POR_INTERVAL);
is_countdn = 0;
}
while((i = getopt(argc, argv, "hd:")) != -1){
switch(i){
case 'd':
dev_file = optarg;
break;
case 'h':
default:
usage();
break;
}
}
argc -= optind;
argv += optind;
#ifdef USB_USBHID
dev.usb.file = dev_file;
#endif
BEGIN_OPT()
OPT("msg", msg)
OPT("timer", timer)
OPT("at_end", at_end)
OPT("halfway", halfway)
END_OPT()
/* allows the user to change only at_end in interval timer */
if(istty && ((!msg || !timer) && (is_countdn || !at_end)))
usage();
if(open_dev(&dev)){
ERROR("open_dev");
goto exit;
}
if(start_session(&dev)){
ERROR("read_app_info");
goto exit;
}
/******************************************************************************/
#ifdef DEBUG
for(i = 0; i < NUM_APPS; i++){
if(!dev.app[i].acd.app_idx)
continue;
printf("%2d: %d%d%d%d%d%d%d%d %02x %02x %04x %04x %04x %04x %04x %04x %s\n", i,
dev.app[i].acd.app_idx,
dev.app[i].acd.code_loc,
dev.app[i].acd.db_loc,
dev.app[i].acd.code_invalid,
dev.app[i].acd.db_modified,
dev.app[i].acd.db_invalid,
dev.app[i].acd.passwd_req,
dev.app[i].acd.mode_name,
dev.app[i].acb.app_type,
dev.app[i].acb.app_inst,
dev.app[i].acb.asd_addr,
dev.app[i].acb.add_addr,
dev.app[i].acb.state_mgr_addr,
dev.app[i].acb.refresh_addr,
dev.app[i].acb.banner_addr,
dev.app[i].acb.code_addr,
dev.app[i].banner
);
}
#endif
/******************************************************************************/
if((idx = find_app(&dev, uapp_name)) < 0){
ERROR("%s application not found", uapp_name);
goto end;
}
if(dump_add(&dev, idx, &data, &len)){
ERROR("dump_add");
//.........这里部分代码省略.........
开发者ID:trishume,项目名称:libdlusb-0.0.9-mac,代码行数:101,代码来源:add_countdn.c
示例17: display_object
/*
* Display the objects in a group.
*/
static void display_object(int col, int row, bool cursor, int oid)
{
int k_idx = oid;
object_kind *k_ptr = &k_info[k_idx];
const char *inscrip = get_autoinscription(oid);
char o_name[80];
/* Choose a color */
bool aware = (!k_ptr->flavor || k_ptr->aware);
byte attr = curs_attrs[(int) aware][(int) cursor];
/* Find graphics bits -- versions of the object_char and object_attr
* defines */
bool use_flavour = (k_ptr->flavor) && !(aware
&& k_ptr->tval == TV_SCROLL);
byte a =
use_flavour ? flavor_info[k_ptr->flavor].x_attr : k_ptr->x_attr;
wchar_t c =
use_flavour ? flavor_info[k_ptr->flavor].x_char : k_ptr->x_char;
/* Display known artifacts differently */
if (kf_has(k_ptr->flags_kind, KF_INSTA_ART)
&& artifact_is_known(get_artifact_from_kind(k_ptr))) {
get_artifact_display_name(o_name, sizeof(o_name),
get_artifact_from_kind(k_ptr));
} else {
object_kind_name(o_name, sizeof(o_name), k_idx, OPT(cheat_know));
}
/* If the type is "tried", display that */
if (k_ptr->tried && !aware)
my_strcat(o_name, " {tried}", sizeof(o_name));
/* Display the name */
c_prt(attr, o_name, row, col);
/* Object recall window */
if (cursor) {
character_icky--;
character_icky--;
p_ptr->object_kind_idx = k_idx;
p_ptr->redraw |= PR_OBJECT;
handle_stuff(p_ptr);
character_icky++;
character_icky++;
}
/* Show autoinscription if around */
if (aware && inscrip)
c_put_str(TERM_YELLOW, inscrip, row, 55);
/* Hack - don't use if double tile */
if ((tile_width > 1) || (tile_height > 1))
return;
/* Display symbol */
big_pad(76, row, a, c);
}
开发者ID:NickMcConnell,项目名称:FAangband,代码行数:64,代码来源:ui-knowledge.c
示例18: do_cmd_knowledge_monsters
/*
* 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 wchar_t *pat = monster_group[j].chars;
if (wcschr(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 wchar_t *pat = monster_group[j].chars;
if (j == 0 && !(rf_has(r_ptr->flags, RF_UNIQUE)))
continue;
else if (j > 0 && !wcschr(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);
}
开发者ID:NickMcConnell,项目名称:FAangband,代码行数:64,代码来源:ui-knowledge.c
示例19: action_forward
enum http_rc_e
action_forward (struct req_args_s *args)
{
const char *id = OPT("id");
const char *action = TOK("ACTION");
if (!id)
return _reply_format_error (args, BADREQ("Missing SRVID"));
if (!action)
return _reply_format_error (args, BADREQ("Missing action"));
GError *err = NULL;
if (!g_ascii_strcasecmp (action, "flush")) {
err = sqlx_remote_execute_FLUSH (id);
if (!err)
return _reply_success_json (args, NULL);
return _reply_common_error (args, err);
}
if (!g_ascii_strcasecmp (action, "reload")) {
err = sqlx_remote_execute_RELOAD (id);
if (!err)
return _reply_success_json (args, NULL);
return _reply_common_error (args, err);
}
if (!g_ascii_strcasecmp (action, "kill")) {
GByteArray *encoded = message_marshall_gba_and_clean (
metautils_message_create_named("REQ_KILL"));
err = gridd_client_exec (id, 1.0, encoded);
if (err)
return _reply_common_error (args, err);
return _reply_success_json (args, NULL);
}
if (!g_ascii_strcasecmp (action, "ping")) {
args->rp->no_access();
GByteArray *encoded = message_marshall_gba_and_clean (
metautils_message_create_named("REQ_PING"));
err = gridd_client_exec (id, 1.0, encoded);
if (err)
return _reply_common_error (args, err);
return _reply_success_json (args, NULL);
}
if (!g_ascii_strcasecmp (action, "lean-glib")) {
MESSAGE req = metautils_message_create_named("REQ_LEAN");
metautils_message_add_field_str(req, "LIBC", "1");
metautils_message_add_field_str(req, "THREADS", "1");
GByteArray *encoded = message_marshall_gba_and_clean (req);
err = gridd_client_exec (id, 1.0, encoded);
if (err)
return _reply_common_error (args, err);
return _reply_success_json (args, NULL);
}
if (!g_ascii_strcasecmp (action, "lean-sqlx")) {
GByteArray *encoded = message_marshall_gba_and_clean (
metautils_message_create_named(NAME_MSGNAME_SQLX_LEANIFY));
err = gridd_client_exec (id, 1.0, encoded);
if (err)
return _reply_common_error (args, err);
return _reply_success_json (args, NULL);
}
if (!g_ascii_strcasecmp (action, "version")) {
args->rp->no_access();
MESSAGE req = metautils_message_create_named("REQ_VERSION");
GByteArray *encoded = message_marshall_gba_and_clean (req);
gchar *packed = NULL;
err = gridd_client_exec_and_concat_string (id, 1.0, encoded, &packed);
if (err) {
g_free0 (packed);
return _reply_common_error (args, err);
}
/* TODO(jfs): quite duplicated from _reply_json() but the original
was not suitable. */
args->rp->set_status (200, "OK");
args->rp->set_body_bytes (g_bytes_new_take((guint8*)packed, strlen(packed)));
args->rp->finalize ();
return HTTPRC_DONE;
}
if (!g_ascii_strcasecmp (action, "handlers")) {
args->rp->no_access();
MESSAGE req = metautils_message_create_named("REQ_HANDLERS");
GByteArray *encoded = message_marshall_gba_and_clean (req);
gchar *packed = NULL;
err = gridd_client_exec_and_concat_string (id, 1.0, encoded, &packed);
if (err) {
g_free0 (packed);
return _reply_common_error (args, err);
}
/* TODO(jfs): quite duplicated from _reply_json() but the original
was not suitable. */
args->rp->set_status (200, "OK");
args->rp->set_body_bytes (g_bytes_new_take((guint8*)packed, strlen(packed)));
args->rp->finalize ();
return HTTPRC_DONE;
}
return _reply_common_error (args, BADREQ("unexpected action"));
//.........这里部分代码省略.........
开发者ID:live-for-dream,项目名称:oio-sds,代码行数:101,代码来源:cache_actions.c
示例20: squelch_hide_item
/**
* Returns TRUE if an item should be hidden due to the player's
* current settings.
*/
bool squelch_hide_item(object_type * o_ptr)
{
return (OPT(hide_squelchable) ? squelch_item_ok(o_ptr) : FALSE);
}
开发者ID:NickMcConnell,项目名称:Beleriand,代码行数:8,代码来源:squelch.c
注:本文中的OPT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论