Changeset 1429

Show
Ignore:
Timestamp:
06/04/09 22:51:08 (15 months ago)
Author:
ajps
Message:

Should be the last of the input checking for game commands.

Location:
trunk/src
Files:
2 modified

Legend:

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

    r1428 r1429  
    201201        object_type *o_ptr = object_from_item_idx(args[0].item); 
    202202 
     203        if (obj_has_inscrip(o_ptr)) 
     204                msg_print("Inscription removed."); 
     205 
    203206        o_ptr->note = 0; 
    204         msg_print("Inscription removed."); 
    205207 
    206208        p_ptr->notice |= (PN_COMBINE | PN_SQUELCH); 
     
    265267        int item = args[0].item; 
    266268 
     269        if (!item_is_available(item, NULL, USE_EQUIP)) 
     270        { 
     271                msg_print("You are not wielding that item."); 
     272                return; 
     273        } 
     274 
     275        if (!obj_can_takeoff(object_from_item_idx(item))) 
     276        { 
     277                msg_print("You cannot take off that item."); 
     278                return; 
     279        } 
     280 
    267281        (void)inven_takeoff(item, 255); 
    268282        p_ptr->energy_use = 50; 
     
    280294         
    281295        int item = args[0].item; 
    282          
    283296        object_type *o_ptr = object_from_item_idx(item); 
     297 
     298        if (!item_is_available(item, NULL, USE_INVEN | USE_FLOOR)) 
     299        { 
     300                msg_print("You do not have that item to wield."); 
     301                return; 
     302        }        
    284303 
    285304        /* Check the slot */ 
     
    622641} 
    623642 
     643 
    624644/*** Refuelling ***/ 
    625  
    626 static bool obj_refill_pre(void) 
    627 { 
    628         object_type *o_ptr; 
     645void do_cmd_refill(cmd_code code, cmd_arg args[]) 
     646{ 
     647        object_type *j_ptr = &inventory[INVEN_LITE]; 
    629648        u32b f[OBJ_FLAG_N]; 
    630649 
    631         o_ptr = &inventory[INVEN_LITE]; 
    632         object_flags(o_ptr, f); 
    633  
    634         if (o_ptr->tval != TV_LITE) 
    635         { 
    636                 msg_print("You are not wielding a light."); 
    637                 return FALSE; 
    638         } 
    639  
    640         else if (f[2] & TR2_NO_FUEL) 
    641         { 
    642                 msg_print("Your light cannot be refilled."); 
    643                 return FALSE; 
    644         } 
    645  
    646         return TRUE; 
    647 } 
    648  
    649 void do_cmd_refill(cmd_code code, cmd_arg args[]) 
    650 { 
    651         object_type *j_ptr = &inventory[INVEN_LITE]; 
    652650        int item = args[0].item; 
    653651        object_type *o_ptr = object_from_item_idx(item); 
    654         p_ptr->energy_use = 50; 
     652 
     653        if (!item_is_available(item, NULL, USE_INVEN | USE_FLOOR)) 
     654        { 
     655                msg_print("You do not have that item to refill with it."); 
     656                return; 
     657        } 
     658 
     659        /* Check what we're wielding. */ 
     660        object_flags(j_ptr, f); 
     661 
     662        if (j_ptr->tval != TV_LITE) 
     663        { 
     664                msg_print("You are not wielding a light."); 
     665                return; 
     666        } 
     667 
     668        else if (f[2] & TR2_NO_FUEL) 
     669        { 
     670                msg_print("Your light cannot be refilled."); 
     671                return; 
     672        } 
    655673 
    656674        /* It's a lamp */ 
     
    662680                refuel_torch(j_ptr, o_ptr, item); 
    663681 
     682        p_ptr->energy_use = 50; 
    664683} 
    665684 
     
    759778        { NULL, CMD_REFILL, "refill", 
    760779      "Refuel with what fuel source? ", "You have nothing to refuel with.", 
    761           obj_can_refill, (USE_INVEN | USE_FLOOR), obj_refill_pre }, 
     780          obj_can_refill, (USE_INVEN | USE_FLOOR), NULL }, 
    762781}; 
    763782 
  • trunk/src/cmd3.c

    r1417 r1429  
    216216        { 
    217217                squelch_items(); 
     218                return; 
     219        } 
     220 
     221        if (!item_is_available(item, NULL, USE_INVEN | USE_EQUIP | USE_FLOOR)) 
     222        { 
     223                msg_print("You do not have that item to destroy it."); 
    218224                return; 
    219225        }