/** * Notice things about an object that would be noticed in time. */ static void object_notice_after_time(void) { int i; int flag; object_type *o_ptr; char o_name[80]; bitflag f[OF_SIZE], timed_mask[OF_SIZE]; flags_init(timed_mask, OF_SIZE, OF_NOTICE_TIMED_MASK, FLAG_END); /* Check every item the player is wearing */ for (i = INVEN_WIELD; i < ALL_INVEN_TOTAL; i++) { o_ptr = &p_ptr->inventory[i]; if (!o_ptr->k_idx || object_is_known(o_ptr)) continue; /* Check for timed notice flags */ object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE); object_flags(o_ptr, f); of_inter(f, timed_mask); for (flag = of_next(f, FLAG_START); flag != FLAG_END; flag = of_next(f, flag + 1)) { if (!of_has(o_ptr->known_flags, flag)) { /* Message */ if (!streq(msgs[flag], "")) msg_format(msgs[flag], o_name); /* Notice the flag */ object_notice_flag(o_ptr, flag); if (object_is_jewelry(o_ptr) && (!object_effect(o_ptr) || object_effect_is_known(o_ptr))) { /* XXX this is a small hack, but jewelry with anything noticeable really is obvious */ /* XXX except, wait until learn activation if that is only clue */ object_flavor_aware(o_ptr); object_check_for_ident(o_ptr); } } else { /* Notice the flag is absent */ object_notice_flag(o_ptr, flag); } } /* XXX Is this necessary? */ object_check_for_ident(o_ptr); } }
int main(int argc, char ** argv) { /* argv[1] is the base directory */ /* argv[2] is the file or path to be served within the directory */ struct flags flag; flags_init(&flag); flag.dir = malloc(strlen(argv[1])+1); strcpy((char *)flag.dir,argv[1]); int http_status = 0; int status = 0; /* printf("argv[1]: %s\nargv[2]: %s\n",argv[1],argv[2]); */ status = checkuri(argv[2],&http_status,&flag); /* status = checkuri(argv[2],NULL, &flag); */ printf("HTTP Return code: %d\n",http_status); /* printf("%d\n",status); */ exit(0); }
int main ( int argc , char ** argv ) { if(argc != 3 ) { printf("Usage %s file.in file.out\n" , argv[0] ); return 0; } /* Inits */ BM_init(); flags_init(); /* END Inits */ /* Read input */ FILE * fin = fopen ( argv[1] , "r"); FILE * fout = fopen ( argv[2] , "w" ); STATE p_st = state_read ( fin ); //state_print(p_st,fout); STATE n_st = state_read ( fin ); //state_print(n_st,fout); fclose(fin); /* END Read Input */ /* Sets */ cur_state_set ( p_st ); /* END Sets */ /* Output */ move_print ( determine_move ( n_st ) , fout ); fclose(fout); cur_state_free(); /* END Output */ return 0; }
void main() { win7compat_init(); log_init(); fork_init(); /* fork_init() will directly jump to restored thread context if we are a fork child */ mm_init(); flags_init(); /* Parse command line */ const char *cmdline = GetCommandLineA(); int len = strlen(cmdline); if (len > BLOCK_SIZE) /* TODO: Test if there is sufficient space for argv[] array */ { init_subsystems(); kprintf("Command line too long.\n"); process_exit(1, 0); } startup = mm_mmap(NULL, BLOCK_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, INTERNAL_MAP_TOPDOWN | INTERNAL_MAP_NORESET | INTERNAL_MAP_VIRTUALALLOC, NULL, 0); *(uintptr_t*) startup = 1; char *current_startup_base = startup + sizeof(uintptr_t); memcpy(current_startup_base, cmdline, len + 1); char *envbuf = (char *)ALIGN_TO(current_startup_base + len + 1, sizeof(void*)); char *env0 = envbuf; ENV("TERM=xterm"); char *env1 = envbuf; ENV("HOME=/root"); char *env2 = envbuf; ENV("DISPLAY=127.0.0.1:0"); char *env3 = envbuf; ENV("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin"); int argc = 0; char **argv = (char **)ALIGN_TO(envbuf, sizeof(void*)); /* Parse command line */ int in_quote = 0; char *j = current_startup_base; for (char *i = current_startup_base; i <= current_startup_base + len; i++) if (!in_quote && (*i == ' ' || *i == '\t' || *i == '\r' || *i == '\n' || *i == 0)) { *i = 0; if (i > j) argv[argc++] = j; j = i + 1; } else if (*i == '"') { *i = 0; if (in_quote) argv[argc++] = j; in_quote = !in_quote; j = i + 1; } argv[argc] = NULL; char **envp = argv + argc + 1; int env_size = 4; envp[0] = env0; envp[1] = env1; envp[2] = env2; envp[3] = env3; envp[4] = NULL; char *buffer_base = (char*)(envp + env_size + 1); const char *filename = NULL; int arg_start; for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "--session-id")) { if (++i < argc) { int len = strlen(argv[i]); if (len >= MAX_SESSION_ID_LEN) { init_subsystems(); kprintf("--session-id: Session ID too long.\n"); process_exit(1, 0); } for (int j = 0; j < len; j++) { char ch = argv[i][j]; if (!((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_' || ch == '-')) { init_subsystems(); kprintf("--session-id: Invalid characters.\n"); process_exit(1, 0); } } strcpy(cmdline_flags->global_session_id, argv[i]); } else { init_subsystems(); kprintf("--session-id: No ID given.\n"); process_exit(1, 0); } } else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { init_subsystems(); print_help(); process_exit(1, 0); } else if (!strcmp(argv[i], "--usage")) { init_subsystems(); print_usage(); process_exit(1, 0); } else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) { init_subsystems(); print_version(); process_exit(1, 0); } else if (!strcmp(argv[i], "--dbt-trace")) cmdline_flags->dbt_trace = true; else if (!strcmp(argv[i], "--dbt-trace-all")) { cmdline_flags->dbt_trace = true; cmdline_flags->dbt_trace_all = true; } else if (argv[i][0] == '-') { init_subsystems(); kprintf("Unrecognized option: %s\n", argv[i]); process_exit(1, 0); } else if (!filename) { filename = argv[i]; arg_start = i; break; } } init_subsystems(); if (filename) { install_syscall_handler(); int r = do_execve(filename, argc - arg_start, argv + arg_start, env_size, envp, buffer_base, NULL); if (r == -L_ENOENT) { kprintf("Executable not found."); process_exit(1, 0); } } print_usage(); process_exit(1, 0); }
int main(void) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; // Set clock to 1 MHz BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; // Set Flash clock FCTL2 = FWKEY + FSSEL0 + FN1; flags_init(); relay_init(); dram_init_mcu(); dram_power_on(); int* address = (int*)SEGMENT_DATA_START; //memory location for data storage // Span DRAM cells for(char i = 20; i != 21; ++i){ for(char j = 20; j != 21; ++j){ unsigned char dataFromDRAM; // Run through delays, until a cell fails for(int delay = DELAY_START; delay <= DELAY_LIMIT; delay += DELAY_INCREMENT){ // Write all 1's dram_wb(i, j, 0xF); dram_power_off(); // Builtin function __delay_cycles, broken down into less than UINT_MAX chunks for(int delaySteps = 0; delaySteps < delay; ++delaySteps){ __delay_cycles(DELAY_STEP); } dram_power_on(); dataFromDRAM = dram_rb(i, j); if(dataFromDRAM != 0xF){ flash_wb(address, delay); break; } // Write all 0's dram_wb(i, j, 0x0); dram_power_off(); // Builtin function __delay_cycles, broken down into less than UINT_MAX chunks for(int delaySteps = 0; delaySteps < delay; ++delaySteps){ __delay_cycles(DELAY_STEP); } dram_power_on(); dataFromDRAM = dram_rb(i, j); if(dataFromDRAM != 0x0){ flash_wb(address, delay); break; } } address++; } } return 0; }
/** * Accept characters representing a race or group of monsters and * an (adjusted) depth, and use these to set values for required racial * type, monster symbol, monster symbol color, and breath type. -LM- * * This function is called to set restrictions, point the monster * allocation function to mon_select(), and remake monster allocation. * It undoes all of this things when called with the symbol '\0'. * * Describe the monsters (used by cheat_room) and determine if they * should be neatly ordered or randomly placed (used in monster pits). */ extern char *mon_restrict(char symbol, byte depth, bool * ordered, bool unique_ok) { int i, j; /* Assume no definite name */ char name[80] = "misc"; /* Clear global monster restriction variables. */ allow_unique = unique_ok; for (i = 0; i < 10; i++) d_char_req[i] = '\0'; for (i = 0; i < 4; i++) d_attr_req[i] = 0; racial_flag_mask = 0; rsf_wipe(breath_flag_mask); /* No symbol, no restrictions. */ if (symbol == '\0') { get_mon_num_hook = NULL; get_mon_num_prep(); return ("misc"); } /* Handle the "wild card" symbol '*' */ if (symbol == '*') { for (i = 0; i < 2500; i++) { /* Get a random monster. */ j = randint1(z_info->r_max - 1); /* Must be a real monster */ if (!r_info[j].rarity) continue; /* Try for close to depth, accept in-depth if necessary */ if (i < 200) { if ((!rf_has(r_info[j].flags, RF_UNIQUE)) && (r_info[j].level != 0) && (r_info[j].level <= depth) && (ABS(r_info[j].level - p_ptr->danger) < 1 + (p_ptr->danger / 4))) break; } else { if ((!rf_has(r_info[j].flags, RF_UNIQUE)) && (r_info[j].level != 0) && (r_info[j].level <= depth)) break; } } /* We've found a monster. */ if (i < 2499) { /* ...use that monster's symbol for all monsters. */ symbol = r_info[j].d_char; } else { /* Paranoia - pit stays empty if no monster is found */ return (NULL); } } /* Apply monster restrictions according to symbol. */ switch (symbol) { /* All animals */ case 'A': { strcpy(name, "animal"); racial_flag_mask = RF_ANIMAL; *ordered = FALSE; break; } /* Insects */ case '1': { strcpy(name, "insect"); strcpy(d_char_req, "aclFIK"); *ordered = FALSE; break; } /* Reptiles */ case '2': { strcpy(name, "reptile"); strcpy(d_char_req, "nJR"); *ordered = FALSE; break; } /* Jellies, etc. */ case '3': { strcpy(name, "jelly"); strcpy(d_char_req, "ijm,"); *ordered = FALSE; break; } /* Humans and humaniods */ case 'p': case 'h': { /* 'p's and 'h's can coexist. */ if (randint0(3) == 0) { strcpy(d_char_req, "ph"); /* If so, they will usually all be of similar classes. */ if (randint0(4) != 0) { /* Randomizer. */ i = randint0(5); /* Magicians and necromancers */ if (i == 0) { d_attr_req[0] = TERM_RED; d_attr_req[1] = TERM_L_RED; d_attr_req[2] = TERM_VIOLET; strcpy(name, "school of sorcery"); } /* Priests and paladins */ else if (i == 1) { d_attr_req[0] = TERM_GREEN; d_attr_req[1] = TERM_L_GREEN; d_attr_req[2] = TERM_WHITE; d_attr_req[3] = TERM_L_WHITE; strcpy(name, "temple of piety"); } /* Druids and ninjas */ else if (i == 2) { d_attr_req[0] = TERM_ORANGE; d_attr_req[1] = TERM_YELLOW; strcpy(name, "gathering of nature"); } /* Thieves and assassins */ else if (i == 3) { d_attr_req[0] = TERM_BLUE; d_attr_req[1] = TERM_L_BLUE; d_attr_req[2] = TERM_SLATE; d_attr_req[3] = TERM_L_DARK; strcpy(name, "den of thieves"); } /* Warriors and rangers */ else { d_attr_req[0] = TERM_UMBER; d_attr_req[1] = TERM_L_UMBER; strcpy(name, "fighter's hall"); } } else { strcpy(name, "humans and humanoids"); } } /* Usually, just accept the symbol. */ else { d_char_req[0] = symbol; if (symbol == 'p') strcpy(name, "human"); else if (symbol == 'h') strcpy(name, "humanoid"); } *ordered = FALSE; break; } /* Orcs */ case 'o': { strcpy(name, "orc"); strcpy(d_char_req, "o"); *ordered = TRUE; break; } /* Trolls */ case 'T': { strcpy(name, "troll"); strcpy(d_char_req, "T"); *ordered = TRUE; break; } /* Giants (sometimes ogres at low levels) */ case 'P': { strcpy(name, "giant"); if ((p_ptr->danger < 30) && (randint0(3) == 0)) strcpy(d_char_req, "O"); else strcpy(d_char_req, "P"); *ordered = TRUE; break; } /* Orcs, ogres, trolls, or giants */ case '%': { strcpy(name, "moria"); strcpy(d_char_req, "oOPT"); *ordered = FALSE; break; } /* Monsters found in caves */ case '0': { strcpy(name, "dungeon monsters"); strcpy(d_char_req, "ykoOT"); *ordered = FALSE; break; } /* Monsters found in wilderness caves */ case 'x': { strcpy(name, "underworld monsters"); strcpy(d_char_req, "bgkosuyOTUVXW"); *ordered = FALSE; break; } /* Undead */ case 'N': { /* Sometimes, restrict by symbol. */ if ((depth > 40) && (randint0(3) == 0)) { for (i = 0; i < 500; i++) { /* Find a suitable monster near depth. */ j = randint1(z_info->r_max - 1); /* Require a non-unique undead. */ if (rf_has(r_info[j].flags, RF_UNDEAD) && (!rf_has(r_info[j].flags, RF_UNIQUE)) && (strchr("GLWV", r_info[j].d_char)) && (ABS(r_info[j].level - p_ptr->danger) < 1 + (p_ptr->danger / 4))) { break; } } /* If we find a monster, */ if (i < 499) { /* Use that monster's symbol for all monsters */ d_char_req[0] = r_info[j].d_char; /* No pit name (yet) */ /* In this case, we do order the monsters */ *ordered = TRUE; } else { /* Accept any undead. */ strcpy(name, "undead"); racial_flag_mask = RF_UNDEAD; *ordered = FALSE; } } else { /* No restrictions on symbol. */ strcpy(name, "undead"); racial_flag_mask = RF_UNDEAD; *ordered = FALSE; } break; } /* Demons */ case 'u': case 'U': { strcpy(name, "demon"); if (depth > 55) strcpy(d_char_req, "U"); else if (depth < 40) strcpy(d_char_req, "u"); else strcpy(d_char_req, "uU"); *ordered = TRUE; break; } /* Dragons */ case 'd': case 'D': { strcpy(d_char_req, "dD"); /* Dragons usually associate with others of their kind. */ if (randint0(6) != 0) { /* Dragons of a single kind are ordered. */ *ordered = TRUE; /* Some dragon types are not found everywhere */ if (depth > 70) i = randint0(35); else if (depth > 45) i = randint0(32); else if (depth > 32) i = randint0(30); else if (depth > 23) i = randint0(28); else i = randint0(24); if (i < 4) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_ACID, FLAG_END); strcpy(name, "dragon - acid"); } else if (i < 8) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_ELEC, FLAG_END); strcpy(name, "dragon - electricity"); } else if (i < 12) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_FIRE, FLAG_END); strcpy(name, "dragon - fire"); } else if (i < 16) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_COLD, FLAG_END); strcpy(name, "dragon - cold"); } else if (i < 20) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_POIS, FLAG_END); strcpy(name, "dragon - poison"); } else if (i < 24) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_ACID, RSF_BRTH_ELEC, RSF_BRTH_FIRE, RSF_BRTH_COLD, RSF_BRTH_POIS, FLAG_END); strcpy(name, "dragon - multihued"); } else if (i < 26) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_CONFU, FLAG_END); strcpy(name, "dragon - confusion"); } else if (i < 28) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_SOUND, FLAG_END); strcpy(name, "dragon - sound"); } else if (i < 30) { flags_init(breath_flag_mask, RSF_SIZE, RSF_BRTH_LIGHT, RSF_BRTH_DARK, FLAG_END); strcpy(name, "dragon - ethereal"); } /* Chaos, Law, Balance, Power, etc.) */ else { d_attr_req[0] = TERM_VIOLET; d_attr_req[1] = TERM_L_BLUE; d_attr_req[2] = TERM_L_GREEN; strcpy(name, "dragon - arcane"); } } else { strcpy(name, "dragon - mixed"); /* Dragons of all kinds are not ordered. */ *ordered = FALSE; } break; } /* Vortexes and elementals */ case 'v': case 'E': { /* Usually, just have any kind of 'v' or 'E' */ if (randint0(3) != 0) { d_char_req[0] = symbol; if (symbol == 'v') strcpy(name, "vortex"); if (symbol == 'E') strcpy(name, "elemental"); } /* Sometimes, choose both 'v' and 'E's of one element */ else { strcpy(d_char_req, "vE"); i = randint0(4); /* Fire */ if (i == 0) { d_attr_req[0] = TERM_RED; strcpy(name, "fire"); } /* Frost */ if (i == 1) { d_attr_req[0] = TERM_L_WHITE; d_attr_req[1] = TERM_WHITE; strcpy(name, "frost"); } /* Air/electricity */ if (i == 2) { d_attr_req[0] = TERM_L_BLUE; d_attr_req[1] = TERM_BLUE; strcpy(name, "air"); } /* Acid/water/earth */ if (i == 3) { d_attr_req[0] = TERM_GREEN; d_attr_req[1] = TERM_L_UMBER; d_attr_req[2] = TERM_UMBER; d_attr_req[3] = TERM_SLATE; strcpy(name, "earth & water"); } } *ordered = FALSE; break; } /* Special case: mimics and treasure */ case '!': case '?': case '=': case '~': case '|': case '.': case '$': { if (symbol == '$') { strcpy(name, "treasure"); /* Nothing but loot! */ if (randint0(3) == 0) strcpy(d_char_req, "$"); /* Guard the money well. */ else strcpy(d_char_req, "$!?=~|."); } else { /* No treasure. */ strcpy(d_char_req, "!?=~|."); strcpy(name, "mimic"); } *ordered = FALSE; break; } /* Special case: creatures of earth. */ case 'X': case '#': { strcpy(d_char_req, "X#"); strcpy(name, "creatures of earth"); *ordered = FALSE; break; } /* Water creatures. */ case '6': { allow_unique = TRUE; strcpy(d_char_req, "vEZ"); d_attr_req[0] = TERM_SLATE; break; } /* Beings of fire or ice. */ case '7': { allow_unique = TRUE; strcpy(d_char_req, "vE"); if (randint0(2) == 0) d_attr_req[0] = TERM_RED; else { d_attr_req[0] = TERM_L_WHITE; d_attr_req[1] = TERM_WHITE; } break; } /* Space for more monster types here. */ /* Any symbol not handled elsewhere. */ default: { /* Accept the character. */ d_char_req[0] = symbol; /* Some monsters should logically be ordered. */ if (strchr("knosuyzGLMOPTUVW", symbol)) *ordered = TRUE; /* Most should not */ else *ordered = FALSE; break; } } /* If monster pit hasn't been named already, get a name. */ if (streq(name, "misc")) { /* Search a table for a description of the symbol */ for (i = 0; d_char_req_desc[i]; ++i) { if (symbol == d_char_req_desc[i][0]) { /* Get all but the 1st 2 characters of the text. */ sprintf(name, "%s", d_char_req_desc[i] + 2); break; } } } /* Apply our restrictions */ get_mon_num_hook = mon_select; /* Prepare allocation table */ get_mon_num_prep(); /* Return the name. */ return (format("%s", name)); }
/* * Parses flags and starts the server. */ int main(int argc, char *argv[]) { struct flags flag; int ch; flags_init(&flag); setprogname((char *) argv[0]); while ((ch = getopt(argc, argv, FLAGS_SUPPORTED)) != -1) { switch (ch) { case 'c': flag.c_dir = optarg; if (!is_dir(flag.c_dir)) { errx(EXIT_FAILURE, "invalid CGI dir"); } break; case 'd': flag.dflag = 1; break; case 'h': usage(); exit(EXIT_SUCCESS); /* NOTREACHED */ break; case 'i': flag.i_address = optarg; { struct in_addr addr4; struct in6_addr addr6; if (inet_pton(AF_INET, flag.i_address, &addr4) == 1) { flag.ipv6 = 0; } else if (inet_pton(AF_INET6, flag.i_address, &addr6) == 1) { flag.ipv6 = 1; } else { errx(EXIT_FAILURE, "neither valid IPv4 nor IPv6 address %s", flag.i_address); } } break; case 'l': flag.lflag=1; flag.l_log_file = optarg; if((flag.logfd=open(flag.l_log_file,O_CREAT | O_APPEND | O_WRONLY,0666))<0){ perror("Logfile error"); exit(EXIT_FAILURE); } break; case 'p': flag.p_port = atoi(optarg); if ((flag.p_port < MIN_PORT) || (flag.p_port > MAX_PORT)) { errx(EXIT_FAILURE, "port must be between %d and %d", MIN_PORT, MAX_PORT); } break; default: usage(); exit(EXIT_FAILURE); /* NOTREACHED */ break; } } argc -= optind; argv += optind; /* get mandatory dir parameter */ if (argc != 1) { usage(); exit(EXIT_FAILURE); } flag.dir = argv[0]; if (!is_dir(flag.dir)) { errx(EXIT_FAILURE, "invalid dir"); } #if DEBUG /* enable debugging flag */ flag.dflag = 1; #endif run_server(&flag); close(flag.logfd); return EXIT_SUCCESS; }
/** * Carry an object and delete it. */ extern void py_pickup_aux(int o_idx, bool msg) { int slot, quiver_slot = 0; char o_name[120]; object_type *o_ptr = &o_list[o_idx]; object_type *i_ptr = &p_ptr->inventory[INVEN_LIGHT]; bitflag f[OF_SIZE], obvious_mask[OF_SIZE]; flags_init(obvious_mask, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END); of_copy(f, o_ptr->flags_obj); /* Carry the object */ slot = inven_carry(p_ptr, o_ptr); /* Handle errors (paranoia) */ if (slot < 0) return; /* If we have picked up ammo which matches something in the quiver, note * that it so that we can wield it later (and suppress pick up message) */ if (obj_is_quiver_obj(o_ptr)) { int i; for (i = QUIVER_START; i < QUIVER_END; i++) { if (!p_ptr->inventory[i].k_idx) continue; if (!object_similar(&p_ptr->inventory[i], o_ptr, OSTACK_QUIVER)) continue; quiver_slot = i; break; } } /* Get the object again */ o_ptr = &p_ptr->inventory[slot]; /* Set squelch status */ p_ptr->notice |= PN_SQUELCH; /* Stone of Lore gives id on pickup */ if (!object_known_p(o_ptr)) { if (i_ptr->sval == SV_STONE_LORE) identify_object(o_ptr); /* Otherwise pseudo-ID */ else { bool heavy = FALSE; int feel; /* Heavy sensing */ heavy = (player_has(PF_PSEUDO_ID_HEAVY)); /* Type of feeling */ feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr)); /* We have "felt" it */ o_ptr->ident |= (IDENT_SENSE); /* Inscribe it textually */ o_ptr->feel = feel; /* Set squelch flag as appropriate */ p_ptr->notice |= PN_SQUELCH; } } /* Log artifacts if found */ if (artifact_p(o_ptr)) history_add_artifact(o_ptr->name1, object_is_known(o_ptr), TRUE); /* Notice dice and other obvious stuff */ notice_other(IF_DD_DS, slot + 1); (void) of_inter(f, obvious_mask); of_union(o_ptr->id_obj, f); /* Average things are average */ if ((o_ptr->feel == FEEL_AVERAGE) && (is_weapon(o_ptr) || is_armour(o_ptr))){ notice_other(IF_AC, slot + 1); notice_other(IF_TO_A, slot + 1); notice_other(IF_TO_H, slot + 1); notice_other(IF_TO_D, slot + 1); } /* Recalculate the bonuses */ p_ptr->update |= (PU_BONUS); /* Optionally, display a message */ if (msg && !quiver_slot) { /* Describe the object */ object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL); /* Message */ msg_format("You have %s (%c).", o_name, index_to_label(slot)); } /* Delete the object */ delete_object_idx(o_idx); /* If we have a quiver slot that this item matches, use it */ if (quiver_slot) wield_item(o_ptr, slot, quiver_slot); }
/* XXX Eddie should messages be adhoc all over the place? perhaps the main * loop should check for change in inventory/wieldeds and all messages be * printed from one place */ void object_notice_on_wield(object_type *o_ptr) { bitflag f[OF_SIZE], obvious_mask[OF_SIZE]; bool obvious = FALSE; const slay_t *s_ptr; flags_init(obvious_mask, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END); /* Save time of wield for later */ object_last_wield = turn; /* Only deal with un-ID'd items */ if (object_is_known(o_ptr)) return; /* Wear it */ object_flavor_tried(o_ptr); if (object_add_ident_flags(o_ptr, IDENT_WORN)) object_check_for_ident(o_ptr); if (obj_is_light(o_ptr) && ego_item_p(o_ptr)) object_notice_ego(o_ptr); if (object_flavor_is_aware(o_ptr) && easy_know(o_ptr)) { object_notice_everything(o_ptr); return; } /* Automatically sense artifacts upon wield */ object_sense_artifact(o_ptr); /* Note artifacts when found */ if (artifact_p(o_ptr)) history_add_artifact(o_ptr->name1, object_is_known(o_ptr), TRUE); /* special case FA, needed at least for mages wielding gloves */ if (object_FA_would_be_obvious(o_ptr)) of_on(obvious_mask, OF_FREE_ACT); /* Learn about obvious flags */ of_union(o_ptr->known_flags, obvious_mask); /* Extract the flags */ object_flags(o_ptr, f); /* Find obvious things (disregarding curses) */ flags_clear(obvious_mask, OF_SIZE, OF_CURSE_MASK, FLAG_END); if (of_is_inter(f, obvious_mask)) obvious = TRUE; flags_init(obvious_mask, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END); /* XXX Eddie should these next NOT call object_check_for_ident due to worries about repairing? */ /* XXX Eddie this is a small hack, but jewelry with anything noticeable really is obvious */ /* XXX Eddie learn =soulkeeping vs =bodykeeping when notice sustain_str */ if (object_is_jewelry(o_ptr)) { /* Learn the flavor of jewelry with obvious flags */ if (EASY_LEARN && obvious) object_flavor_aware(o_ptr); /* Learn all flags on any aware non-artifact jewelry */ if (object_flavor_is_aware(o_ptr) && !artifact_p(o_ptr)) object_know_all_flags(o_ptr); } object_check_for_ident(o_ptr); if (!obvious) return; /* Messages */ for (s_ptr = slay_table; s_ptr->slay_flag; s_ptr++) { if (of_has(f, s_ptr->slay_flag) && s_ptr->brand) { char o_name[40]; object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE); msg_format("Your %s %s!", o_name, s_ptr->active_verb); } } /* XXX Eddie need to add stealth here, also need to assert/double-check everything is covered */ if (of_has(f, OF_STR)) msg_format("You feel %s!", o_ptr->pval > 0 ? "stronger" : "weaker"); if (of_has(f, OF_INT)) msg_format("You feel %s!", o_ptr->pval > 0 ? "smarter" : "more stupid"); if (of_has(f, OF_WIS)) msg_format("You feel %s!", o_ptr->pval > 0 ? "wiser" : "more naive"); if (of_has(f, OF_DEX)) msg_format("You feel %s!", o_ptr->pval > 0 ? "more dextrous" : "clumsier"); if (of_has(f, OF_CON)) msg_format("You feel %s!", o_ptr->pval > 0 ? "healthier" : "sicklier"); if (of_has(f, OF_CHR)) msg_format("You feel %s!", o_ptr->pval > 0 ? "cuter" : "uglier"); if (of_has(f, OF_SPEED)) msg_format("You feel strangely %s.", o_ptr->pval > 0 ? "quick" : "sluggish"); if (flags_test(f, OF_SIZE, OF_BLOWS, OF_SHOTS, FLAG_END)) msg_format("Your hands %s", o_ptr->pval > 0 ? "tingle!" : "ache."); if (of_has(f, OF_INFRA)) msg_format("Your eyes tingle."); if (of_has(f, OF_LIGHT)) msg_print("It glows!"); if (of_has(f, OF_TELEPATHY)) msg_print("Your mind feels strangely sharper!"); /* WARNING -- masking f by obvious mask -- this should be at the end of this function */ flags_mask(f, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END); /* learn the ego on any obvious brand or slay */ if (EASY_LEARN && ego_item_p(o_ptr) && obvious && flags_test(f, OF_SIZE, OF_ALL_SLAY_MASK, FLAG_END)) object_notice_ego(o_ptr); /* Remember the flags */ object_notice_sensing(o_ptr); /* XXX Eddie should we check_for_ident here? */ }