Changeset 1445 for trunk

Show
Ignore:
Timestamp:
06/20/09 21:20:53 (9 months ago)
Author:
ajps
Message:

Fix bug allowing repeated use of rods and activatable objects before they had recharged (#882). The use command now checks the status of these items before carrying out the action.

Location:
trunk/src
Files:
3 modified

Legend:

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

    r1431 r1445  
    473473        if (obj_is_rod(o_ptr)) 
    474474        { 
     475                if (!obj_can_zap(o_ptr)) 
     476                { 
     477                        msg_print("The rod is not yet recharged."); 
     478                        return; 
     479                } 
     480 
    475481                use = USE_TIMEOUT; 
    476482                snd = MSG_ZAP_ROD; 
     
    511517                items_allowed = USE_INVEN | USE_FLOOR; 
    512518        } 
    513         else if (obj_can_activate(o_ptr)) 
    514         { 
     519        else if (obj_is_activatable(o_ptr)) 
     520        { 
     521                if (!obj_can_activate(o_ptr)) 
     522                { 
     523                        msg_print("The item is not ready to activate"); 
     524                        return; 
     525                } 
     526                 
    515527                use = USE_TIMEOUT; 
    516528                snd = MSG_ACT_ARTIFACT; 
    517529                items_allowed = USE_EQUIP; 
     530        } 
     531        else 
     532        { 
     533                msg_print("The item cannot be used at the moment"); 
    518534        } 
    519535 
  • trunk/src/object/obj-util.c

    r1443 r1445  
    35743574 
    35753575/* Determine if an object is activatable */ 
    3576 bool obj_can_activate(const object_type *o_ptr) 
     3576bool obj_is_activatable(const object_type *o_ptr) 
    35773577{ 
    35783578        u32b f[OBJ_FLAG_N]; 
     
    35813581        if (!object_known_p(o_ptr)) return (FALSE); 
    35823582 
    3583         /* Check the recharge */ 
    3584         if (o_ptr->timeout) return (FALSE); 
    3585  
    35863583        /* Extract the flags */ 
    35873584        object_flags(o_ptr, f); 
     
    35893586        /* Check activation flag */ 
    35903587        return (f[2] & TR2_ACTIVATE) ? TRUE : FALSE; 
     3588} 
     3589 
     3590/* Determine if an object can be activated now */ 
     3591bool obj_can_activate(const object_type *o_ptr) 
     3592{ 
     3593        if (obj_is_activatable(o_ptr)) 
     3594        { 
     3595                /* Check the recharge */ 
     3596                if (!o_ptr->timeout) return TRUE; 
     3597        } 
     3598 
     3599        return FALSE; 
    35913600} 
    35923601 
  • trunk/src/object/object.h

    r1435 r1445  
    162162bool obj_is_food(const object_type *o_ptr); 
    163163bool obj_can_zap(const object_type *o_ptr); 
     164bool obj_is_activatable(const object_type *o_ptr); 
    164165bool obj_can_activate(const object_type *o_ptr); 
    165166bool obj_can_refill(const object_type *o_ptr);