Changeset 729

Show
Ignore:
Timestamp:
02/26/08 23:41:01 (9 months ago)
Author:
takkaria
Message:

Fix #492: Make inscriptions like "!k!k!k" prompt multiple times again.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/cmd-obj.c

    r724 r729  
    7676        text_out_c(TERM_L_BLUE, "\n\n[Press any key to continue]\n"); 
    7777        (void)anykey(); 
    78        
     78 
    7979        screen_load(); 
    8080} 
     
    112112        char o_name[80]; 
    113113 
     114        unsigned n; 
    114115 
    115116        /* Check the slot */ 
     
    117118        equip_o_ptr = &inventory[slot]; 
    118119 
    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 
    140146        wield_item(o_ptr, item); 
    141147} 
  • trunk/src/obj-ui.c

    r715 r729  
    573573        char verify_inscrip[] = "!*"; 
    574574 
    575         /* Inventory */ 
     575        unsigned n; 
     576 
     577        /* Inventory or floor */ 
    576578        if (item >= 0) 
    577         { 
    578579                o_ptr = &inventory[item]; 
    579         } 
    580  
    581         /* Floor */ 
    582580        else 
    583         { 
    584581                o_ptr = &o_list[0 - item]; 
    585         } 
    586582 
    587583        /* Check for a "prevention" inscription */ 
    588584        verify_inscrip[1] = p_ptr->command_cmd; 
    589585 
    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); 
    595592        } 
    596593 
  • trunk/src/obj-util.c

    r728 r729  
    33353335 * Looks if "inscrip" is present on the given object. 
    33363336 */ 
    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  
     3337unsigned 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  
    136136void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt); 
    137137void reduce_charges(object_type *o_ptr, int amt); 
    138 bool check_for_inscrip(const object_type *o_ptr, const char *inscrip); 
     138unsigned check_for_inscrip(const object_type *o_ptr, const char *inscrip); 
    139139 
    140140#endif /* !INCLUDED_OBJECT_H */ 
  • trunk/src/util.c

    r728 r729  
    29132913        { 
    29142914                char verify_inscrip[] = "^*"; 
     2915                unsigned n; 
    29152916 
    29162917                object_type *o_ptr = &inventory[i]; 
     
    29212922                /* Set up string to look for, e.g. "^d" */ 
    29222923                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                { 
    29272929                        if (!get_check("Are you sure? ")) 
    2928                         { 
    2929                                 /* Hack -- Use "newline" */ 
    29302930                                p_ptr->command_cmd = '\n'; 
    2931                         } 
    29322931                } 
    29332932        }