merge obj with otmp and delete obj if types agree */
| 811 | |
| 812 | /* merge obj with otmp and delete obj if types agree */ |
| 813 | int |
| 814 | merged(struct obj **potmp, struct obj **pobj) |
| 815 | { |
| 816 | struct obj *otmp = *potmp, *obj = *pobj; |
| 817 | boolean discovered = FALSE; |
| 818 | |
| 819 | if (mergable(otmp, obj)) { |
| 820 | /* Approximate age: we do it this way because if we were to |
| 821 | * do it "accurately" (merge only when ages are identical) |
| 822 | * we'd wind up never merging any corpses. |
| 823 | * otmp->age = otmp->age*(1-proportion) + obj->age*proportion; |
| 824 | * |
| 825 | * Don't do the age manipulation if lit. We would need |
| 826 | * to stop the burn on both items, then merge the age, |
| 827 | * then restart the burn. Glob ages are averaged in the |
| 828 | * absorb routine, which uses weight rather than quantity |
| 829 | * to adjust for proportion (glob quantity is always 1). |
| 830 | */ |
| 831 | if (!obj->lamplit && !obj->globby) |
| 832 | otmp->age = ((otmp->age * otmp->quan) + (obj->age * obj->quan)) |
| 833 | / (otmp->quan + obj->quan); |
| 834 | |
| 835 | if (!otmp->globby) |
| 836 | otmp->quan += obj->quan; |
| 837 | /* temporary special case for gold objects!!!! */ |
| 838 | if (otmp->oclass == COIN_CLASS) |
| 839 | otmp->owt = weight(otmp), otmp->bknown = 0; |
| 840 | /* and puddings!!!1!!one! */ |
| 841 | else if (!Is_pudding(otmp)) |
| 842 | otmp->owt = weight(otmp); |
| 843 | if (!has_oname(otmp) && has_oname(obj)) |
| 844 | otmp = *potmp = oname(otmp, ONAME(obj), ONAME_SKIP_INVUPD); |
| 845 | obj_extract_self(obj); |
| 846 | |
| 847 | if (obj->pickup_prev && otmp->where == OBJ_INVENT) |
| 848 | otmp->pickup_prev = 1; |
| 849 | |
| 850 | /* really should merge the timeouts */ |
| 851 | if (obj->lamplit) |
| 852 | obj_merge_light_sources(obj, otmp); |
| 853 | if (obj->timed) |
| 854 | obj_stop_timers(obj); /* follows lights */ |
| 855 | |
| 856 | /* objects can be identified by comparing them (unless Blind, |
| 857 | but that is handled in mergable()); the object becomes |
| 858 | identified in a particular dimension if either object was |
| 859 | previously identified in that dimension, and if the |
| 860 | identification states don't match, one of them must have |
| 861 | previously been identified */ |
| 862 | if (obj->known != otmp->known) { |
| 863 | otmp->known = 1; |
| 864 | discovered = TRUE; |
| 865 | } |
| 866 | if (obj->rknown != otmp->rknown) { |
| 867 | otmp->rknown = 1; |
| 868 | if (otmp->oerodeproof) |
| 869 | discovered = TRUE; |
| 870 | } |
no test coverage detected