Changeset 404

Show
Ignore:
Timestamp:
07/28/07 19:19:51 (1 year ago)
Author:
takkaria
Message:

Add item history tracking, ported (and simplified a bit) from Ey. (closes #149)

Files:

Legend:

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

    r399 r404  
    627627                        object_prep(i_ptr, k_idx); 
    628628                        i_ptr->number = (byte)rand_range(e_ptr->min, e_ptr->max); 
     629                        i_ptr->origin = ORIGIN_BIRTH; 
    629630 
    630631                        object_aware(i_ptr); 
     
    644645        object_prep(i_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION)); 
    645646        i_ptr->number = (byte)rand_range(3, 7); 
     647        i_ptr->origin = ORIGIN_BIRTH; 
    646648        object_aware(i_ptr); 
    647649        object_known(i_ptr); 
    648         k_info[i_ptr->k_idx].everseen = TRUE; 
     650       k_info[i_ptr->k_idx].everseen = TRUE; 
    649651        (void)inven_carry(i_ptr); 
    650652 
     
    657659        i_ptr->number = (byte)rand_range(3, 7); 
    658660        i_ptr->timeout = rand_range(3, 7) * 500; 
     661        i_ptr->origin = ORIGIN_BIRTH; 
    659662        object_aware(i_ptr); 
    660663        object_known(i_ptr); 
  • trunk/src/defines.h

    r399 r404  
    666666#define FEAT_PERM_OUTER 0x3E 
    667667#define FEAT_PERM_SOLID 0x3F 
     668 
     669 
     670 
     671/*** Object origin kinds ***/ 
     672 
     673enum 
     674{ 
     675        ORIGIN_NONE = 0, 
     676        ORIGIN_MIXED, 
     677        ORIGIN_BIRTH, 
     678        ORIGIN_STORE, 
     679        ORIGIN_FLOOR, 
     680        ORIGIN_DROP, 
     681        ORIGIN_DROP_UNKNOWN, 
     682        ORIGIN_ACQUIRE, 
     683        ORIGIN_CHEAT, 
     684        ORIGIN_CHEST 
     685}; 
    668686 
    669687 
  • trunk/src/load.c

    r320 r404  
    301301        rd_byte(&o_ptr->marked); 
    302302 
     303        rd_byte(&o_ptr->origin); 
     304        rd_byte(&o_ptr->origin_depth); 
     305        rd_u16b(&o_ptr->origin_xtra); 
     306 
    303307        /* Old flags */ 
    304         strip_bytes(12); 
     308        strip_bytes(8); 
    305309 
    306310        /* Monster holding object */ 
  • trunk/src/obj-info.c

    r403 r404  
    603603 
    604604/* 
     605 * Describe origin of an item 
     606 */ 
     607static bool describe_origin(const object_type *o_ptr) 
     608{ 
     609        /* Abort now if undisplayable origin */ 
     610        if (o_ptr->origin == ORIGIN_NONE || 
     611            o_ptr->origin == ORIGIN_MIXED) 
     612                return FALSE; 
     613 
     614        if (o_ptr->number > 1) 
     615                p_text_out("They were "); 
     616        else 
     617                p_text_out("It was "); 
     618 
     619        /* Display the right thing */ 
     620        switch (o_ptr->origin) 
     621        { 
     622                case ORIGIN_BIRTH: 
     623                        text_out("an inheritance from your family"); 
     624                        break; 
     625 
     626                case ORIGIN_STORE: 
     627                        text_out("bought in a store"); 
     628                        break; 
     629 
     630                case ORIGIN_FLOOR: 
     631                        text_out("lying on the floor"); 
     632                        break; 
     633 
     634                case ORIGIN_DROP: 
     635                { 
     636                        const char *name = r_name + r_info[o_ptr->origin_xtra].name; 
     637                        bool unique = (r_info[o_ptr->origin_xtra].flags1 & RF1_UNIQUE) ? TRUE : FALSE; 
     638 
     639                        text_out("dropped by %s%s", is_a_vowel(name[0]) ? "an " : "a ", name); 
     640 
     641                        break; 
     642                } 
     643 
     644                case ORIGIN_DROP_UNKNOWN: 
     645                        text_out("dropped by an unknown monster"); 
     646                        break; 
     647 
     648                case ORIGIN_ACQUIRE: 
     649                        text_out("conjured forth by magic"); 
     650                        break; 
     651 
     652                case ORIGIN_CHEAT: 
     653                        text_out("created by a debug option"); 
     654                        break; 
     655 
     656                case ORIGIN_CHEST: 
     657                        text_out("found in a chest"); 
     658                        break; 
     659        } 
     660 
     661        if (o_ptr->origin_depth) 
     662        { 
     663                if (depth_in_feet) 
     664                        text_out(" at a depth of %d feet", o_ptr->origin_depth * 50); 
     665                else 
     666                        text_out(" on dungeon level %d", o_ptr->origin_depth); 
     667        } 
     668 
     669        text_out(".  "); 
     670        return TRUE; 
     671} 
     672 
     673 
     674/* 
    605675 * Output object information 
    606676 */ 
     
    726796        has_info = object_info_out(o_ptr); 
    727797 
     798        /* Dump origin info */ 
     799        describe_origin(o_ptr); 
     800 
    728801        new_paragraph = TRUE; 
    729802        if (!object_known_p(o_ptr)) 
  • trunk/src/object2.c

    r399 r404  
    14041404                o_ptr->pval += j_ptr->pval; 
    14051405        } 
     1406 
     1407        if ((o_ptr->origin != j_ptr->origin) || 
     1408            (o_ptr->origin_depth != j_ptr->origin_depth) || 
     1409            (o_ptr->origin_xtra != j_ptr->origin_xtra)) 
     1410        { 
     1411                int act = 2; 
     1412 
     1413                if ((o_ptr->origin == ORIGIN_DROP) && (o_ptr->origin == j_ptr->origin)) 
     1414                { 
     1415                        monster_race *r_ptr = &r_info[o_ptr->origin_xtra]; 
     1416                        monster_race *s_ptr = &r_info[j_ptr->origin_xtra]; 
     1417 
     1418                        bool r_uniq = (r_ptr->flags1 & RF1_UNIQUE) ? TRUE : FALSE; 
     1419                        bool s_uniq = (r_ptr->flags1 & RF1_UNIQUE) ? TRUE : FALSE; 
     1420 
     1421                        if (r_uniq && !s_uniq) act = 0; 
     1422                        else if (s_uniq && !r_uniq) act = 1; 
     1423                        else act = 2; 
     1424                } 
     1425 
     1426                switch (act) 
     1427                { 
     1428                        /* Overwrite with j_ptr */ 
     1429                        case 1: 
     1430                        { 
     1431                                o_ptr->origin = j_ptr->origin; 
     1432                                o_ptr->origin_depth = j_ptr->origin_depth; 
     1433                                o_ptr->origin_xtra = j_ptr->origin_xtra; 
     1434                        } 
     1435 
     1436                        /* Set as "mixed" */ 
     1437                        case 2: 
     1438                        { 
     1439                                o_ptr->origin = ORIGIN_MIXED; 
     1440                        } 
     1441                } 
     1442        } 
    14061443} 
    14071444 
     
    33613398                /* Make a good (or great) object (if possible) */ 
    33623399                if (!make_object(i_ptr, TRUE, great)) continue; 
     3400                i_ptr->origin = ORIGIN_ACQUIRE; 
     3401                i_ptr->origin_depth = p_ptr->depth; 
    33633402 
    33643403                /* Drop the object */ 
     
    33913430        if (make_object(i_ptr, good, great)) 
    33923431        { 
     3432                i_ptr->origin = ORIGIN_FLOOR; 
     3433                i_ptr->origin_depth = p_ptr->depth; 
     3434 
    33933435                /* Give it to the floor */ 
    33943436                if (!floor_carry(y, x, i_ptr)) 
  • trunk/src/save.c

    r320 r404  
    123123        wr_byte(o_ptr->marked); 
    124124 
     125        wr_byte(o_ptr->origin); 
     126        wr_byte(o_ptr->origin_depth); 
     127        wr_u16b(o_ptr->origin_xtra); 
     128 
    125129        /* Old flags */ 
    126         wr_u32b(0L); 
    127130        wr_u32b(0L); 
    128131        wr_u32b(0L); 
  • trunk/src/store.c

    r399 r404  
    654654                o_ptr->pval += j_ptr->pval; 
    655655        } 
     656 
     657        if ((o_ptr->origin != j_ptr->origin) || 
     658            (o_ptr->origin_depth != j_ptr->origin_depth) || 
     659            (o_ptr->origin_xtra != j_ptr->origin_xtra)) 
     660        { 
     661                int act = 2; 
     662 
     663                if ((o_ptr->origin == ORIGIN_DROP) && (o_ptr->origin == j_ptr->origin)) 
     664                { 
     665                        monster_race *r_ptr = &r_info[o_ptr->origin_xtra]; 
     666                        monster_race *s_ptr = &r_info[j_ptr->origin_xtra]; 
     667 
     668                        bool r_uniq = (r_ptr->flags1 & RF1_UNIQUE) ? TRUE : FALSE; 
     669                        bool s_uniq = (r_ptr->flags1 & RF1_UNIQUE) ? TRUE : FALSE; 
     670 
     671                        if (r_uniq && !s_uniq) act = 0; 
     672                        else if (s_uniq && !r_uniq) act = 1; 
     673                        else act = 2; 
     674                } 
     675 
     676                switch (act) 
     677                { 
     678                        /* Overwrite with j_ptr */ 
     679                        case 1: 
     680                        { 
     681                                o_ptr->origin = j_ptr->origin; 
     682                                o_ptr->origin_depth = j_ptr->origin_depth; 
     683                                o_ptr->origin_xtra = j_ptr->origin_xtra; 
     684                        } 
     685 
     686                        /* Set as "mixed" */ 
     687                        case 2: 
     688                        { 
     689                                o_ptr->origin = ORIGIN_MIXED; 
     690                        } 
     691                } 
     692        } 
    656693} 
    657694 
     
    12201257                object_known(i_ptr); 
    12211258                i_ptr->ident |= IDENT_STORE; 
     1259                i_ptr->origin = ORIGIN_STORE; 
    12221260 
    12231261 
     
    13121350        /* Item belongs to a store */ 
    13131351        object.ident |= IDENT_STORE; 
     1352        object.origin = ORIGIN_STORE; 
    13141353 
    13151354        /* Charge lights */ 
  • trunk/src/types.h

    r320 r404  
    493493        byte xtra2;                     /* Extra info index */ 
    494494 
     495        s16b ac;                        /* Normal AC */ 
     496        s16b to_a;                      /* Plusses to AC */ 
    495497        s16b to_h;                      /* Plusses to hit */ 
    496498        s16b to_d;                      /* Plusses to damage */ 
    497         s16b to_a;                      /* Plusses to AC */ 
    498  
    499         s16b ac;                        /* Normal AC */ 
    500499 
    501500        byte dd, ds;            /* Damage dice/sides */ 
     
    504503 
    505504        byte ident;                     /* Special flags */ 
    506  
    507505        byte marked;            /* Object is marked */ 
    508506 
     
    510508 
    511509        s16b next_o_idx;        /* Next object in stack (if any) */ 
    512  
    513510        s16b held_m_idx;        /* Monster holding us (if any) */ 
     511 
     512        byte origin;        /* How this item was found */ 
     513        byte origin_depth;  /* What depth the item was found at */ 
     514        u16b origin_xtra;   /* Extra information about origin */ 
    514515}; 
    515516 
  • trunk/src/wizard2.c

    r399 r404  
    625625        if (changed) 
    626626        { 
     627                /* Mark as cheat */ 
     628                i_ptr->origin = ORIGIN_CHEAT; 
     629 
    627630                /* Restore the position information */ 
    628631                i_ptr->iy = o_ptr->iy; 
     
    10271030        /* Apply magic (no messages, no artifacts) */ 
    10281031        apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE); 
     1032 
     1033        /* Mark as cheat */ 
     1034        i_ptr->origin = ORIGIN_CHEAT; 
    10291035 
    10301036        if (k_info[k_idx].tval == TV_GOLD) 
     
    10871093        i_ptr->weight = a_ptr->weight; 
    10881094 
    1089         /* Mark that the artifact has been created. */ 
     1095       /* Mark that the artifact has been created. */ 
    10901096        a_ptr->cur_num = 1; 
     1097 
     1098        /* Mark as cheat */ 
     1099        i_ptr->origin = ORIGIN_CHEAT; 
    10911100 
    10921101        /* Drop the artifact from heaven */ 
  • trunk/src/xtra2.c

    r399 r404  
    12341234                /* Mega-Hack -- Actually create "Grond" */ 
    12351235                apply_magic(i_ptr, -1, TRUE, TRUE, TRUE); 
     1236                i_ptr->origin = ORIGIN_DROP; 
     1237                i_ptr->origin_depth = p_ptr->depth; 
     1238                i_ptr->origin_xtra = m_ptr->r_idx; 
    12361239 
    12371240                /* Drop it in the dungeon */ 
     
    12441247                /* Mega-Hack -- Prepare to make "Morgoth" */ 
    12451248                object_prep(i_ptr, lookup_kind(TV_CROWN, SV_MORGOTH)); 
     1249                i_ptr->origin = ORIGIN_DROP; 
     1250                i_ptr->origin_depth = p_ptr->depth; 
     1251                i_ptr->origin_xtra = m_ptr->r_idx; 
    12461252 
    12471253                /* Mega-Hack -- Mark this item as "Morgoth" */ 
     
    12981304                        dump_item++; 
    12991305                } 
     1306 
     1307                /* Set origin */ 
     1308                i_ptr->origin = visible ? ORIGIN_DROP : ORIGIN_DROP_UNKNOWN; 
     1309                i_ptr->origin_depth = p_ptr->depth; 
     1310                i_ptr->origin_xtra = m_ptr->r_idx; 
    13001311 
    13011312                /* Drop it in the dungeon */