| 1860 | | /* Skip non-objects */ |
|---|
| 1861 | | if (!j_ptr->k_idx) continue; |
|---|
| 1862 | | |
|---|
| 1863 | | /* Check if the two items can be combined */ |
|---|
| 1864 | | if (object_similar(j_ptr, o_ptr)) |
|---|
| 1865 | | return j_ptr->number; |
|---|
| 1866 | | } |
|---|
| 1867 | | |
|---|
| | 1860 | /* Require identical object types */ |
|---|
| | 1861 | if (!j_ptr->k_idx || o_ptr->k_idx != j_ptr->k_idx) continue; |
|---|
| | 1862 | |
|---|
| | 1863 | /* Analyze the items */ |
|---|
| | 1864 | switch (o_ptr->tval) |
|---|
| | 1865 | { |
|---|
| | 1866 | /* Chests */ |
|---|
| | 1867 | case TV_CHEST: |
|---|
| | 1868 | { |
|---|
| | 1869 | /* Never okay */ |
|---|
| | 1870 | return 0; |
|---|
| | 1871 | } |
|---|
| | 1872 | |
|---|
| | 1873 | /* Food and Potions and Scrolls */ |
|---|
| | 1874 | case TV_FOOD: |
|---|
| | 1875 | case TV_POTION: |
|---|
| | 1876 | case TV_SCROLL: |
|---|
| | 1877 | { |
|---|
| | 1878 | /* Assume okay */ |
|---|
| | 1879 | break; |
|---|
| | 1880 | } |
|---|
| | 1881 | |
|---|
| | 1882 | /* Staves and Wands */ |
|---|
| | 1883 | case TV_STAFF: |
|---|
| | 1884 | case TV_WAND: |
|---|
| | 1885 | { |
|---|
| | 1886 | /* Assume okay */ |
|---|
| | 1887 | break; |
|---|
| | 1888 | } |
|---|
| | 1889 | |
|---|
| | 1890 | /* Rods */ |
|---|
| | 1891 | case TV_ROD: |
|---|
| | 1892 | { |
|---|
| | 1893 | /* Assume okay */ |
|---|
| | 1894 | break; |
|---|
| | 1895 | } |
|---|
| | 1896 | |
|---|
| | 1897 | /* Weapons and Armor */ |
|---|
| | 1898 | case TV_BOW: |
|---|
| | 1899 | case TV_DIGGING: |
|---|
| | 1900 | case TV_HAFTED: |
|---|
| | 1901 | case TV_POLEARM: |
|---|
| | 1902 | case TV_SWORD: |
|---|
| | 1903 | case TV_BOOTS: |
|---|
| | 1904 | case TV_GLOVES: |
|---|
| | 1905 | case TV_HELM: |
|---|
| | 1906 | case TV_CROWN: |
|---|
| | 1907 | case TV_SHIELD: |
|---|
| | 1908 | case TV_CLOAK: |
|---|
| | 1909 | case TV_SOFT_ARMOR: |
|---|
| | 1910 | case TV_HARD_ARMOR: |
|---|
| | 1911 | case TV_DRAG_ARMOR: |
|---|
| | 1912 | { |
|---|
| | 1913 | /* Fall through */ |
|---|
| | 1914 | } |
|---|
| | 1915 | |
|---|
| | 1916 | /* Rings, Amulets, Lites */ |
|---|
| | 1917 | case TV_RING: |
|---|
| | 1918 | case TV_AMULET: |
|---|
| | 1919 | case TV_LITE: |
|---|
| | 1920 | { |
|---|
| | 1921 | /* Require both items to be known */ |
|---|
| | 1922 | if (!object_known_p(o_ptr) || !object_known_p(j_ptr)) continue; |
|---|
| | 1923 | |
|---|
| | 1924 | /* Fall through */ |
|---|
| | 1925 | } |
|---|
| | 1926 | |
|---|
| | 1927 | /* Missiles */ |
|---|
| | 1928 | case TV_BOLT: |
|---|
| | 1929 | case TV_ARROW: |
|---|
| | 1930 | case TV_SHOT: |
|---|
| | 1931 | { |
|---|
| | 1932 | /* Require identical knowledge of both items */ |
|---|
| | 1933 | if (object_known_p(o_ptr) != object_known_p(j_ptr)) continue; |
|---|
| | 1934 | |
|---|
| | 1935 | /* Require identical "bonuses" */ |
|---|
| | 1936 | if (o_ptr->to_h != j_ptr->to_h) continue; |
|---|
| | 1937 | if (o_ptr->to_d != j_ptr->to_d) continue; |
|---|
| | 1938 | if (o_ptr->to_a != j_ptr->to_a) continue; |
|---|
| | 1939 | |
|---|
| | 1940 | /* Require identical "pval" code */ |
|---|
| | 1941 | if (o_ptr->pval != j_ptr->pval) continue; |
|---|
| | 1942 | |
|---|
| | 1943 | /* Require identical "artifact" names */ |
|---|
| | 1944 | if (o_ptr->name1 != j_ptr->name1) continue; |
|---|
| | 1945 | |
|---|
| | 1946 | /* Require identical "ego-item" names */ |
|---|
| | 1947 | if (o_ptr->name2 != j_ptr->name2) continue; |
|---|
| | 1948 | |
|---|
| | 1949 | /* Lites must have same amount of fuel */ |
|---|
| | 1950 | else if (o_ptr->timeout != j_ptr->timeout && o_ptr->tval == TV_LITE) |
|---|
| | 1951 | continue; |
|---|
| | 1952 | |
|---|
| | 1953 | /* Require identical "values" */ |
|---|
| | 1954 | if (o_ptr->ac != j_ptr->ac) continue; |
|---|
| | 1955 | if (o_ptr->dd != j_ptr->dd) continue; |
|---|
| | 1956 | if (o_ptr->ds != j_ptr->ds) continue; |
|---|
| | 1957 | |
|---|
| | 1958 | /* Probably okay */ |
|---|
| | 1959 | break; |
|---|
| | 1960 | } |
|---|
| | 1961 | |
|---|
| | 1962 | /* Various */ |
|---|
| | 1963 | default: |
|---|
| | 1964 | { |
|---|
| | 1965 | /* Require knowledge */ |
|---|
| | 1966 | if (!object_known_p(o_ptr) || !object_known_p(j_ptr)) continue; |
|---|
| | 1967 | |
|---|
| | 1968 | /* Probably okay */ |
|---|
| | 1969 | break; |
|---|
| | 1970 | } |
|---|
| | 1971 | } |
|---|
| | 1972 | |
|---|
| | 1973 | |
|---|
| | 1974 | /* Different pseudo-ID statuses preclude combination */ |
|---|
| | 1975 | if (o_ptr->pseudo != j_ptr->pseudo) continue; |
|---|
| | 1976 | |
|---|
| | 1977 | |
|---|
| | 1978 | /* Different flags */ |
|---|
| | 1979 | if (o_ptr->flags1 != j_ptr->flags1 || |
|---|
| | 1980 | o_ptr->flags2 != j_ptr->flags2 || |
|---|
| | 1981 | o_ptr->flags3 != j_ptr->flags3) |
|---|
| | 1982 | continue; |
|---|
| | 1983 | |
|---|
| | 1984 | |
|---|
| | 1985 | /* They match, so they must be similar */ |
|---|
| | 1986 | return j_ptr->number; |
|---|
| | 1987 | |
|---|
| | 1988 | } |
|---|
| | 1989 | |
|---|
| | 1990 | /* No matches found */ |
|---|