Changeset 227

Show
Ignore:
Timestamp:
06/27/07 21:25:25 (1 year ago)
Author:
takkaria
Message:
  • Simplify the way item pickup is handled, in the hope this makes debugging easier
  • Remove the now fairly pointless "jump" command
  • Remove duplication of the pickup_inven option

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/cave.c

    r152 r227  
    41424142 
    41434143        /* Cancel auto-pickup if badly wounded  XXX XXX */ 
    4144         if ((p_ptr->notice & (PN_PICKUP0 | PN_PICKUP1)) && 
     4144        if ((p_ptr->notice & (PN_PICKUP)) && 
    41454145            (p_ptr->chp < (p_ptr->mhp * op_ptr->hitpoint_warn / 10))) 
    41464146        { 
  • trunk/src/cmd0.c

    r224 r227  
    155155        { "Start running",            '.', do_cmd_run }, 
    156156        { "Stand still",              ',', do_cmd_hold }, 
    157         { "Jump (into a trap)",       '-', do_cmd_jump }, 
    158157        { "Check knowledge",          '|', do_cmd_knowledge }, 
    159158        { "Display menu of actions", '\n', do_cmd_menu }, 
  • trunk/src/cmd1.c

    r224 r227  
    491491 
    492492/* 
    493  * Determine if the object can be picked up, and has "=g" in its inscription
     493 * Determine if the object can be picked up automatically
    494494 */ 
    495495static bool auto_pickup_okay(const object_type *o_ptr, bool check_pack) 
     
    530530                        /* Find another '=' */ 
    531531                        s = strchr(s + 1, '='); 
    532                 } 
    533         } 
    534  
    535         /* Optionally, check the backpack */ 
    536         if (check_pack) 
    537         { 
    538                 int j; 
    539  
    540                 /* Look for similar and inscribed */ 
    541                 for (j = 0; j < INVEN_PACK; j++) 
    542                 { 
    543                         object_type *j_ptr = &inventory[j]; 
    544  
    545                         /* Skip non-objects */ 
    546                         if (!j_ptr->k_idx) continue; 
    547  
    548                         /* The two items must be able to combine */ 
    549                         if (!object_similar(j_ptr, o_ptr)) continue; 
    550  
    551                         /* The backpack item must be inscribed */ 
    552                         if (!j_ptr->note) continue; 
    553  
    554                         /* Find a '=' */ 
    555                         s = strchr(quark_str(j_ptr->note), '='); 
    556  
    557                         /* Process permissions */ 
    558                         while (s) 
    559                         { 
    560                                 /* =g ('g'et) means auto pickup */ 
    561                                 if (s[1] == 'g') return (TRUE); 
    562  
    563                                 /* Find another '=' */ 
    564                                 s = strchr(s + 1, '='); 
    565                         } 
    566532                } 
    567533        } 
     
    613579 * 
    614580 * Called with pickup: 
    615  * 0 to grab gold and describe non-gold objects. 
     581 * 0 to grab gold, auto-pickup some objects, and describe others objects. 
    616582 * 1 to pick up objects either with or without displaying a menu. 
    617583 * 2 to pick up objects, allowing cancel and quick pickup of single objects. 
    618584 * 3 to pick up objects, forcing a menu for any number of objects. 
    619  * 
    620  * Use the "p_ptr->auto_pickup_okay" variable to allow or dis-allow 
    621  * automatically picking things up that take time.  (NOT INCLUDED) 
    622585 * 
    623586 * Scan the list of objects in that floor grid.   Pick up gold automatically. 
     
    816779 
    817780                /* Automatically pick up items into the backpack */ 
    818                 if ((p_ptr->auto_pickup_okay) && (pickup) && (auto_pickup_okay(o_ptr, TRUE))) 
     781                if (p_ptr->auto_pickup_okay && auto_pickup_okay(o_ptr, TRUE)) 
    819782                { 
    820783                        /* Pick up the object (with a message) */ 
     
    15481511 * and also handles attempting to move into walls/doors/rubble/etc. 
    15491512 */ 
    1550 void move_player(int dir, int do_pickup
     1513void move_player(int dir
    15511514{ 
    15521515        int py = p_ptr->py; 
     
    16881651                        p_ptr->command_new = '_'; 
    16891652 
    1690                         /* Free turn XXX XXX XXX */ 
    1691                         p_ptr->energy_use = 0; 
    1692  
    16931653                        /* Handle objects now.  XXX */ 
    1694                         p_ptr->energy_use += py_pickup(do_pickup) * 10; 
    1695                 } 
     1654                        p_ptr->energy_use = py_pickup(1) * 10; 
     1655                } 
     1656 
    16961657 
    16971658                /* All other grids (including traps) */ 
     
    16991660                { 
    17001661                        /* Handle objects (later) */ 
    1701                         if (do_pickup) p_ptr->notice |= (PN_PICKUP1); 
    1702                         else           p_ptr->notice |= (PN_PICKUP0); 
     1662                        p_ptr->notice |= (PN_PICKUP); 
    17031663                } 
    17041664 
     
    24292389        } 
    24302390 
     2391 
    24312392        /* Decrease counter */ 
    24322393        p_ptr->running--; 
     
    24362397 
    24372398        /* Move the player.  Never pick up objects */ 
    2438         move_player(p_ptr->run_cur_dir, FALSE); 
     2399        p_ptr->auto_pickup_okay = FALSE; 
     2400        move_player(p_ptr->run_cur_dir); 
    24392401} 
    2440  
    2441  
  • trunk/src/cmd2.c

    r156 r227  
    20452045 
    20462046/* 
    2047  * Helper function for the "walk" and "jump" commands
    2048  */ 
    2049 static void do_cmd_walk_or_jump(int do_pickup
     2047 * Helper function for the "walk" command
     2048 */ 
     2049void do_cmd_walk(void
    20502050{ 
    20512051        int y, x, dir; 
    2052  
    20532052 
    20542053        /* Get a direction (or abort) */ 
     
    20942093 
    20952094        /* Move the player */ 
    2096         move_player(dir, do_pickup); 
    2097 
    2098  
    2099  
    2100 /* 
    2101  * Walk into a grid (pick up objects as set by the auto-pickup option) 
    2102  */ 
    2103 void do_cmd_walk(void) 
    2104 
    2105         /* Move (usually pickup) */ 
    2106         do_cmd_walk_or_jump(always_pickup); 
    2107 
    2108  
    2109  
    2110 /* 
    2111  * Jump into a grid (flip pickup mode) 
    2112  */ 
    2113 void do_cmd_jump(void) 
    2114 
    2115         /* Move (usually do not pickup) */ 
    2116         do_cmd_walk_or_jump(!always_pickup); 
    2117 
     2095        move_player(dir); 
     2096
     2097 
    21182098 
    21192099 
     
    21822162 * Pick up treasure if "pickup" is true. 
    21832163 */ 
    2184 static void do_cmd_hold_or_stay(int pickup
     2164void do_cmd_hold(void
    21852165{ 
    21862166        /* Allow repeated command */ 
     
    22132193 
    22142194        /* Handle objects now.  XXX XXX XXX */ 
    2215         p_ptr->energy_use += py_pickup(pickup) * 10; 
     2195        p_ptr->energy_use += py_pickup(always_pickup) * 10; 
    22162196 
    22172197        /* Hack -- enter a store if we are on one */ 
     
    22282208                p_ptr->energy_use = 0; 
    22292209        } 
    2230 } 
    2231  
    2232  
    2233 /* 
    2234  * Hold still (usually pickup) 
    2235  */ 
    2236 void do_cmd_hold(void) 
    2237 { 
    2238         /* Hold still (usually pickup) */ 
    2239         do_cmd_hold_or_stay(always_pickup); 
    22402210} 
    22412211 
  • trunk/src/defines.h

    r224 r227  
    15591559 * Bit flags for the "p_ptr->notice" variable 
    15601560 */ 
    1561 #define PN_COMBINE             0x00000001L    /* Combine the pack */ 
    1562 #define PN_REORDER             0x00000002L    /* Reorder the pack */ 
     1561#define PN_COMBINE      0x00000001L   /* Combine the pack */ 
     1562#define PN_REORDER      0x00000002L   /* Reorder the pack */ 
    15631563#define PN_AUTOINSCRIBE 0x00000004L     /* Autoinscribe items */ 
    1564 #define PN_PICKUP0      0x00000008L     /* Notice stuff (allow pickup) */ 
    1565 #define PN_PICKUP1      0x00000010L     /* Pick up stuff */ 
     1564#define PN_PICKUP       0x00000008L     /* Pick stuff up */ 
    15661565/* xxx (many) */ 
    15671566 
  • trunk/src/dungeon.c

    r214 r227  
    12711271 
    12721272                /* Picking up objects */ 
    1273                 else if (p_ptr->notice & (PN_PICKUP1)) 
     1273                else if (p_ptr->notice & (PN_PICKUP)) 
    12741274                { 
    12751275                        /* Recursively call the pickup function, use energy */ 
    1276                         p_ptr->energy_use = py_pickup(1) * 10; 
    1277                         p_ptr->notice &= ~(PN_PICKUP0 | PN_PICKUP1); 
    1278                 } 
    1279  
    1280                 /* Noticing objects (allow pickup) */ 
    1281                 else if (p_ptr->notice & (PN_PICKUP0)) 
    1282                 { 
    1283                         /* Recursively call the pickup function, use energy */ 
    1284                         p_ptr->energy_use = py_pickup(0) * 10; 
    1285                         p_ptr->notice &= ~(PN_PICKUP0 | PN_PICKUP1); 
     1276                        p_ptr->energy_use = py_pickup(always_pickup) * 10; 
     1277                        p_ptr->notice &= ~(PN_PICKUP); 
    12861278                } 
    12871279 
  • trunk/src/externs.h

    r224 r227  
    305305extern void hit_trap(int y, int x); 
    306306extern void py_attack(int y, int x); 
    307 extern void move_player(int dir, int do_pickup); 
     307extern void move_player(int dir); 
    308308extern void run_step(int dir); 
    309309bool do_cmd_walk_test(int y, int x); 
  • trunk/src/types.h

    r163 r227  
    199199 
    200200        u16b flavor;            /* Special object flavor (or zero) */ 
    201  
    202  
    203         bool aware;                   /* The player is "aware" of the item's effects */ 
    204         bool tried;                   /* The player has "tried" one of the items */ 
    205  
    206         bool squelch       /* Squelch this item? */ 
    207         bool everseen;        /* Used to despoilify squelch menus */ 
     201        u16b note;          /* Autoinscription field (later) */ 
     202 
     203        bool aware : 1;               /* The player is "aware" of the item's effects */ 
     204        bool tried : 1;               /* The player has "tried" one of the items */ 
     205 
     206        bool squelch : 1;     /* Squelch this item? */ 
     207        bool everseen : 1;    /* Used to despoilify squelch menus */ 
    208208}; 
    209209