Changeset 676

Show
Ignore:
Timestamp:
02/01/08 04:41:56 (8 months ago)
Author:
takkaria
Message:
  • Move out the value_check_aux*() functions to obj-make.c (though I'm considering perhaps a new obj-know.c might be a better place)
  • Make the pseudo-ID constants into an enum and place in object.h
  • Make object_desc() take an odesc_detail_t instead of an int
  • Clean up some whitespace
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/angband.h

    r610 r676  
    3838#include "ui.h" 
    3939#include "z-type.h" 
     40#include "object.h" 
    4041#include "externs.h" 
    41 #include "object.h" 
    4242 
    4343 
  • trunk/src/defines.h

    r655 r676  
    17081708 
    17091709/* 
    1710  * The special inscriptions. 
    1711  */ 
    1712 #define INSCRIP_NULL            0 
    1713 #define INSCRIP_TERRIBLE        1 
    1714 #define INSCRIP_WORTHLESS       2 
    1715 #define INSCRIP_CURSED          3 
    1716 #define INSCRIP_BROKEN          4 
    1717 #define INSCRIP_AVERAGE         5 
    1718 #define INSCRIP_GOOD            6 
    1719 #define INSCRIP_EXCELLENT       7 
    1720 #define INSCRIP_SPECIAL         8 
    1721 #define INSCRIP_UNCURSED        9 
    1722 #define INSCRIP_INDESTRUCTIBLE  10 
    1723  
    1724 /* 
    1725  * Number of special inscriptions, plus one. 
    1726  */ 
    1727 #define MAX_INSCRIP                     11 
    1728  
    1729  
    1730 /* 
    17311710 * Some bit-flags for the "smart" field of "monster_type". 
    17321711 * 
  • trunk/src/dungeon.c

    r669 r676  
    2121 
    2222 
    23 /* 
    24  * Return a "feeling" (or NULL) about an item.  Method 1 (Heavy). 
    25  */ 
    26 int value_check_aux1(const object_type *o_ptr) 
    27 { 
    28         /* Artifacts */ 
    29         if (artifact_p(o_ptr)) 
    30         { 
    31                 /* Cursed/Broken */ 
    32                 if (cursed_p(o_ptr) || broken_p(o_ptr)) return (INSCRIP_TERRIBLE); 
    33  
    34                 /* Normal */ 
    35                 return (INSCRIP_SPECIAL); 
    36         } 
    37  
    38         /* Ego-Items */ 
    39         if (ego_item_p(o_ptr)) 
    40         { 
    41                 /* Cursed/Broken */ 
    42                 if (cursed_p(o_ptr) || broken_p(o_ptr)) return (INSCRIP_WORTHLESS); 
    43  
    44                 /* Normal */ 
    45                 return (INSCRIP_EXCELLENT); 
    46         } 
    47  
    48         /* Cursed items */ 
    49         if (cursed_p(o_ptr)) return (INSCRIP_CURSED); 
    50  
    51         /* Broken items */ 
    52         if (broken_p(o_ptr)) return (INSCRIP_BROKEN); 
    53  
    54         /* Good "armor" bonus */ 
    55         if (o_ptr->to_a > 0) return (INSCRIP_GOOD); 
    56  
    57         /* Good "weapon" bonus */ 
    58         if (o_ptr->to_h + o_ptr->to_d > 0) return (INSCRIP_GOOD); 
    59  
    60         /* Default to "average" */ 
    61         return (INSCRIP_AVERAGE); 
    62 } 
    63  
    64  
    65 /* 
    66  * Return a "feeling" (or NULL) about an item.  Method 2 (Light). 
    67  */ 
    68 static int value_check_aux2(const object_type *o_ptr) 
    69 { 
    70         /* Cursed items (all of them) */ 
    71         if (cursed_p(o_ptr)) return (INSCRIP_CURSED); 
    72  
    73         /* Broken items (all of them) */ 
    74         if (broken_p(o_ptr)) return (INSCRIP_BROKEN); 
    75  
    76         /* Artifacts -- except cursed/broken ones */ 
    77         if (artifact_p(o_ptr)) return (INSCRIP_GOOD); 
    78  
    79         /* Ego-Items -- except cursed/broken ones */ 
    80         if (ego_item_p(o_ptr)) return (INSCRIP_GOOD); 
    81  
    82         /* Good armor bonus */ 
    83         if (o_ptr->to_a > 0) return (INSCRIP_GOOD); 
    84  
    85         /* Good weapon bonuses */ 
    86         if (o_ptr->to_h + o_ptr->to_d > 0) return (INSCRIP_GOOD); 
    87  
    88         /* No feeling */ 
    89         return (0); 
    90 } 
    91  
    92  
    9323 
    9424/* 
     
    192122 
    193123                /* Check for a feeling */ 
    194                 feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr)); 
     124                feel = (heavy ? object_pseudo_heavy(o_ptr) : object_pseudo_light(o_ptr)); 
    195125 
    196126                /* Skip non-feelings */ 
  • trunk/src/externs.h

    r671 r676  
    7575extern cptr stat_names_full[A_MAX]; 
    7676extern const char *window_flag_desc[32]; 
    77 extern cptr inscrip_text[MAX_INSCRIP]; 
     77extern const char *inscrip_text[]; 
    7878extern const grouper object_text_order[]; 
    7979extern const byte store_choices[MAX_STORES-2][STORE_CHOICES][2]; 
  • trunk/src/obj-desc.c

    r668 r676  
    713713 *   OD_FULL   -- Rings of Death [1,+3] (+2 to Stealth) {nifty} (squelch) 
    714714 */ 
    715 size_t object_desc(char *buf, size_t max, const object_type *o_ptr, bool prefix, int mode) 
     715size_t object_desc(char *buf, size_t max, const object_type *o_ptr, bool prefix, odesc_detail_t mode) 
    716716{ 
    717717        object_kind *k_ptr = &k_info[o_ptr->k_idx]; 
     
    801801 * player isn't meant to know. 
    802802 */ 
    803 void object_desc_spoil(char *buf, size_t max, const object_type *o_ptr, int pref, int mode) 
     803void object_desc_spoil(char *buf, size_t max, const object_type *o_ptr, int pref, odesc_detail_t mode) 
    804804{ 
    805805        object_type object_type_body; 
  • trunk/src/obj-make.c

    r653 r676  
    9494        /* Occasional level boost */ 
    9595        if ((level > 0) && one_in_(GREAT_OBJ)) 
    96         {  
    97                 /* What a bizarre calculation */  
    98                 level = 1 + (level * MAX_O_DEPTH / randint(MAX_O_DEPTH));  
     96        { 
     97                /* What a bizarre calculation */ 
     98                level = 1 + (level * MAX_O_DEPTH / randint(MAX_O_DEPTH)); 
    9999        } 
    100100 
     
    534534 
    535535                /* Cursed (if "bad") */ 
    536                 if (o_ptr->to_h + o_ptr->to_d < 0) 
    537                        o_ptr->flags3 |= TR3_LIGHT_CURSE; 
     536                if (o_ptr->to_h < 0 || o_ptr->to_d < 0) 
     537                    o_ptr->flags3 |= TR3_LIGHT_CURSE; 
    538538        } 
    539539 
     
    16881688 
    16891689        k_idx = lookup_kind(TV_GOLD, sval); 
    1690          
     1690 
    16911691        /* Prepare a gold object */ 
    16921692        object_prep(j_ptr, k_idx); 
     
    17021702} 
    17031703 
    1704  
     1704/* 
     1705 * Return a "feeling" (or NULL) about an item.  Method 1 (Heavy). 
     1706 */ 
     1707int object_pseudo_heavy(const object_type *o_ptr) 
     1708
     1709        if (artifact_p(o_ptr)) 
     1710        { 
     1711                if (cursed_p(o_ptr) || broken_p(o_ptr)) 
     1712                        return INSCRIP_TERRIBLE; 
     1713                else 
     1714                        return INSCRIP_SPECIAL; 
     1715        } 
     1716 
     1717        if (ego_item_p(o_ptr)) 
     1718        { 
     1719                if (cursed_p(o_ptr) || broken_p(o_ptr)) 
     1720                        return INSCRIP_WORTHLESS; 
     1721                else 
     1722                        return INSCRIP_EXCELLENT; 
     1723        } 
     1724 
     1725        if (cursed_p(o_ptr)) 
     1726                return INSCRIP_CURSED; 
     1727        else if (broken_p(o_ptr)) 
     1728                return INSCRIP_BROKEN; 
     1729        else if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d > 0)) 
     1730                return INSCRIP_GOOD; 
     1731 
     1732        /* Default to "average" */ 
     1733        return (INSCRIP_AVERAGE); 
     1734
     1735 
     1736 
     1737 
     1738/* 
     1739 * Return a "feeling" (or NULL) about an item.  Method 2 (Light). 
     1740 */ 
     1741int object_pseudo_light(const object_type *o_ptr) 
     1742
     1743        /* Cursed items (all of them) */ 
     1744        if (cursed_p(o_ptr)) return (INSCRIP_CURSED); 
     1745 
     1746        /* Broken items (all of them) */ 
     1747        if (broken_p(o_ptr)) return (INSCRIP_BROKEN); 
     1748 
     1749        /* Artifacts -- except cursed/broken ones */ 
     1750        if (artifact_p(o_ptr)) return (INSCRIP_GOOD); 
     1751 
     1752        /* Ego-Items -- except cursed/broken ones */ 
     1753        if (ego_item_p(o_ptr)) return (INSCRIP_GOOD); 
     1754 
     1755        /* Good armor bonus */ 
     1756        if (o_ptr->to_a > 0) return (INSCRIP_GOOD); 
     1757 
     1758        /* Good weapon bonuses */ 
     1759        if (o_ptr->to_h + o_ptr->to_d > 0) return (INSCRIP_GOOD); 
     1760 
     1761        /* No feeling */ 
     1762        return (0); 
     1763
     1764 
  • trunk/src/object.h

    r668 r676  
    1616 * Modes for object_desc(). 
    1717 */ 
    18 enum 
     18typedef enum 
    1919{ 
    20         ODESC_BASE = 0,   /** Only describe the base name */ 
    21         ODESC_COMBAT = 1, /** Also show combat bonuses */ 
    22         ODESC_FULL = 3,   /** Show entire description */ 
    23         ODESC_STORE = 4   /** Also show {squelch} marker */ 
    24 }; 
     20        ODESC_BASE = 0,   /*!< Only describe the base name */ 
     21        ODESC_COMBAT = 1, /*!< Also show combat bonuses */ 
     22        ODESC_FULL = 3,   /*!< Show entire description */ 
     23        ODESC_STORE = 4   /*!< Also show {squelch} marker */ 
     24} odesc_detail_t; 
     25 
     26 
     27/** 
     28 * Pseudo-ID markers. 
     29 */ 
     30typedef enum 
     31
     32        INSCRIP_NULL = 0,            /*!< No pseudo-ID status */ 
     33        INSCRIP_TERRIBLE = 1,        /*!< Cursed artifact */ 
     34        INSCRIP_WORTHLESS = 2,       /*!< Worthless item */ 
     35        INSCRIP_CURSED = 3,          /*!< Cursed normal item */ 
     36        INSCRIP_BROKEN = 4,          /*!< Cursed ego-item */ 
     37        INSCRIP_AVERAGE = 5,         /*!< Item with no interesting features */ 
     38        INSCRIP_GOOD = 6,            /*!< Item with some combat bonuses */ 
     39        INSCRIP_EXCELLENT = 7,       /*!< Ego-item */ 
     40        INSCRIP_SPECIAL = 8,         /*!< Artifact */ 
     41        INSCRIP_UNCURSED = 9,        /*!< Item previous cursed, now uncursed */ 
     42        INSCRIP_INDESTRUCTIBLE = 10, /*!< Artifact that was tried to be destroyed */ 
     43 
     44        INSCRIP_MAX                  /*!< Maximum number of pseudo-ID markers */ 
     45} obj_pseudo_t; 
     46 
     47 
    2548 
    2649 
     
    2952/* obj-desc.c */ 
    3053void object_kind_name(char *buf, size_t max, int k_idx, bool easy_know); 
    31 size_t object_desc(char *buf, size_t max, const object_type *o_ptr, bool prefix, int mode); 
    32 void object_desc_spoil(char *buf, size_t max, const object_type *o_ptr, int pref, int mode); 
     54size_t object_desc(char *buf, size_t max, const object_type *o_ptr, bool prefix, odesc_detail_t mode); 
     55void object_desc_spoil(char *buf, size_t max, const object_type *o_ptr, int pref, odesc_detail_t mode); 
    3356 
    3457/* obj-info.c */ 
     
    4568bool make_object(object_type *j_ptr, int lev, bool good, bool great); 
    4669bool make_gold(object_type *j_ptr, int lev); 
     70int object_pseudo_heavy(const object_type *o_ptr); 
     71int object_pseudo_light(const object_type *o_ptr); 
    4772 
    4873/* obj-ui.c */ 
  • trunk/src/squelch.c

    r653 r676  
    341341        bool fullid = object_known_p(o_ptr); 
    342342        bool sensed = (o_ptr->ident & IDENT_SENSE) || fullid; 
    343         byte feel   = fullid ? value_check_aux1(o_ptr) : o_ptr->pseudo; 
     343        byte feel   = fullid ? object_pseudo_heavy(o_ptr) : o_ptr->pseudo; 
    344344 
    345345 
  • trunk/src/tables.c

    r543 r676  
    13991399 
    14001400 
    1401 cptr inscrip_text[MAX_INSCRIP] = 
     1401const char *inscrip_text[] = 
    14021402{ 
    14031403        NULL,