Changeset 729
- Timestamp:
- 02/26/08 23:41:01 (9 months ago)
- Files:
-
- trunk/src/cmd-obj.c (modified) (3 diffs)
- trunk/src/obj-ui.c (modified) (1 diff)
- trunk/src/obj-util.c (modified) (1 diff)
- trunk/src/object.h (modified) (1 diff)
- trunk/src/util.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd-obj.c
r724 r729 76 76 text_out_c(TERM_L_BLUE, "\n\n[Press any key to continue]\n"); 77 77 (void)anykey(); 78 78 79 79 screen_load(); 80 80 } … … 112 112 char o_name[80]; 113 113 114 unsigned n; 114 115 115 116 /* Check the slot */ … … 117 118 equip_o_ptr = &inventory[slot]; 118 119 119 /* Prevent wielding into a cursed slot */ 120 if (cursed_p(equip_o_ptr)) 121 { 122 /* Message */ 123 object_desc(o_name, sizeof(o_name), equip_o_ptr, FALSE, ODESC_BASE); 124 msg_format("The %s you are %s appears to be cursed.", 125 o_name, describe_use(slot)); 126 127 return; 128 } 129 130 /* "!t" checks for taking off */ 131 if (check_for_inscrip(o_ptr, "!t")) 132 { 133 /* Prompt */ 134 object_desc(o_name, sizeof(o_name), equip_o_ptr, TRUE, ODESC_FULL); 135 136 /* Forget it */ 137 if (!get_check(format("Really take off %s? ", o_name))) return; 138 } 139 120 /* Check for existing wielded item */ 121 if (equip_o_ptr) 122 { 123 /* Prevent wielding into a cursed slot */ 124 if (cursed_p(equip_o_ptr)) 125 { 126 /* Message */ 127 object_desc(o_name, sizeof(o_name), equip_o_ptr, FALSE, ODESC_BASE); 128 msg_format("The %s you are %s appears to be cursed.", 129 o_name, describe_use(slot)); 130 131 return; 132 } 133 134 /* "!t" checks for taking off */ 135 n = check_for_inscrip(equip_o_ptr, "!t"); 136 while (n--) 137 { 138 /* Prompt */ 139 object_desc(o_name, sizeof(o_name), equip_o_ptr, TRUE, ODESC_FULL); 140 141 /* Forget it */ 142 if (!get_check(format("Really take off %s? ", o_name))) return; 143 } 144 } 145 140 146 wield_item(o_ptr, item); 141 147 } trunk/src/obj-ui.c
r715 r729 573 573 char verify_inscrip[] = "!*"; 574 574 575 /* Inventory */ 575 unsigned n; 576 577 /* Inventory or floor */ 576 578 if (item >= 0) 577 {578 579 o_ptr = &inventory[item]; 579 }580 581 /* Floor */582 580 else 583 {584 581 o_ptr = &o_list[0 - item]; 585 }586 582 587 583 /* Check for a "prevention" inscription */ 588 584 verify_inscrip[1] = p_ptr->command_cmd; 589 585 590 if (o_ptr->note && (check_for_inscrip(o_ptr, "!*") || 591 check_for_inscrip(o_ptr, verify_inscrip))) 592 { 593 /* Verify the choice */ 594 if (!verify_item("Really try", item)) return (FALSE); 586 /* Find both sets of inscriptions, add togther, and prompt that number of times */ 587 n = check_for_inscrip(o_ptr, "!*") + check_for_inscrip(o_ptr, verify_inscrip); 588 while (n--) 589 { 590 if (!verify_item("Really try", item)) 591 return (FALSE); 595 592 } 596 593 trunk/src/obj-util.c
r728 r729 3335 3335 * Looks if "inscrip" is present on the given object. 3336 3336 */ 3337 bool check_for_inscrip(const object_type *o_ptr, const char *inscrip) 3338 { 3339 if (o_ptr->note) 3340 { 3341 const char *s = strstr(quark_str(o_ptr->note), inscrip); 3342 if (s) return TRUE; 3343 } 3344 3345 return FALSE; 3346 } 3347 3348 3337 unsigned check_for_inscrip(const object_type *o_ptr, const char *inscrip) 3338 { 3339 unsigned i = 0; 3340 const char *s; 3341 3342 if (!o_ptr->note) return 0; 3343 3344 s = quark_str(o_ptr->note); 3345 3346 do 3347 { 3348 s = strstr(s, inscrip); 3349 if (!s) break; 3350 3351 i++; 3352 s++; 3353 } 3354 while (s); 3355 3356 return i; 3357 } trunk/src/object.h
r728 r729 136 136 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt); 137 137 void reduce_charges(object_type *o_ptr, int amt); 138 boolcheck_for_inscrip(const object_type *o_ptr, const char *inscrip);138 unsigned check_for_inscrip(const object_type *o_ptr, const char *inscrip); 139 139 140 140 #endif /* !INCLUDED_OBJECT_H */ trunk/src/util.c
r728 r729 2913 2913 { 2914 2914 char verify_inscrip[] = "^*"; 2915 unsigned n; 2915 2916 2916 2917 object_type *o_ptr = &inventory[i]; … … 2921 2922 /* Set up string to look for, e.g. "^d" */ 2922 2923 verify_inscrip[1] = p_ptr->command_cmd; 2923 2924 if (check_for_inscrip(o_ptr, "^*") || check_for_inscrip(o_ptr, verify_inscrip)) 2925 { 2926 /* Hack -- Verify command */ 2924 2925 /* Verify command */ 2926 n = check_for_inscrip(o_ptr, "^*") + check_for_inscrip(o_ptr, verify_inscrip); 2927 while (n--) 2928 { 2927 2929 if (!get_check("Are you sure? ")) 2928 {2929 /* Hack -- Use "newline" */2930 2930 p_ptr->command_cmd = '\n'; 2931 }2932 2931 } 2933 2932 }
