Changeset 1428 for trunk

Show
Ignore:
Timestamp:
06/04/09 21:57:14 (15 months ago)
Author:
ajps
Message:

Add input-checking on drop command. Change it to take number of items to drop as an argument, as destroy.

Location:
trunk/src
Files:
2 modified

Legend:

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

    r1426 r1428  
    321321        int item = args[0].item; 
    322322        object_type *o_ptr = object_from_item_idx(item); 
     323        int amt = args[1].number; 
     324 
     325        if (!item_is_available(item, NULL, USE_INVEN | USE_EQUIP)) 
     326        { 
     327                msg_print("You do not have that item to drop it."); 
     328                return; 
     329        } 
     330 
     331        /* Hack -- Cannot remove cursed items */ 
     332        if ((item >= INVEN_WIELD) && cursed_p(o_ptr)) 
     333        { 
     334                msg_print("Hmmm, it seems to be cursed."); 
     335                return; 
     336        } 
     337 
     338        inven_drop(item, amt); 
     339        p_ptr->energy_use = 50; 
     340} 
     341 
     342static void obj_drop(object_type *o_ptr, int item) 
     343{ 
    323344        int amt; 
    324345 
     
    326347        if (amt <= 0) return; 
    327348 
    328         /* Hack -- Cannot remove cursed items */ 
    329         if ((item >= INVEN_WIELD) && cursed_p(o_ptr)) 
    330         { 
    331                 msg_print("Hmmm, it seems to be cursed."); 
    332                 return; 
    333         } 
    334  
    335         inven_drop(item, amt); 
    336         p_ptr->energy_use = 50; 
     349        cmd_insert(CMD_DROP, item, amt); 
    337350} 
    338351 
     
    698711          obj_can_wear, (USE_INVEN | USE_FLOOR), NULL }, 
    699712 
    700         { NULL, CMD_DROP, "drop", 
     713        { obj_drop, CMD_NULL, "drop", 
    701714          "Drop which item? ", "You have nothing to drop.", 
    702715          NULL, (USE_EQUIP | USE_INVEN), NULL }, 
  • trunk/src/game-cmd.c

    r1419 r1428  
    157157                case CMD_WIELD: 
    158158                case CMD_TAKEOFF: 
    159                 case CMD_DROP: 
    160159                case CMD_REFILL: 
    161160                case CMD_STUDY_BOOK: 
     
    196195                } 
    197196 
    198                 /* This takes an item number and a number of those items to destroy. */ 
     197                /* These take an item number and a number of those items to process. */ 
     198                case CMD_DROP: 
    199199                case CMD_DESTROY: 
    200200                { 
     201                        /* TODO: Number should probably be replaced by 'repeat'ing */ 
    201202                        cmd.args[0].item = va_arg(vp, int); 
    202203                        cmd.args[1].number = va_arg(vp, int);