returns TRUE if obj & otmp can be merged; used in invent.c and mkobj.c */
| 4376 | |
| 4377 | /* returns TRUE if obj & otmp can be merged; used in invent.c and mkobj.c */ |
| 4378 | boolean |
| 4379 | mergable( |
| 4380 | struct obj *otmp, /* potential 'into' stack */ |
| 4381 | struct obj *obj) /* 'combine' stack */ |
| 4382 | { |
| 4383 | size_t objnamelth = 0, otmpnamelth = 0; |
| 4384 | |
| 4385 | /* fail if already the same object, if different types, if either is |
| 4386 | explicitly marked to prevent merge, or if not mergable in general */ |
| 4387 | if (obj == otmp || obj->otyp != otmp->otyp |
| 4388 | || obj->nomerge || otmp->nomerge || !objects[obj->otyp].oc_merge) |
| 4389 | return FALSE; |
| 4390 | |
| 4391 | /* coins of the same kind will always merge */ |
| 4392 | if (obj->oclass == COIN_CLASS) |
| 4393 | return TRUE; |
| 4394 | |
| 4395 | if (obj->cursed != otmp->cursed || obj->blessed != otmp->blessed) |
| 4396 | return FALSE; |
| 4397 | |
| 4398 | if (obj->how_lost == LOST_EXPLODING |
| 4399 | || otmp->how_lost == LOST_EXPLODING) |
| 4400 | return FALSE; |
| 4401 | if (otmp->how_lost != LOST_NONE && (obj->how_lost != otmp->how_lost)) |
| 4402 | return FALSE; |
| 4403 | #if 0 /* don't require 'bypass' to match; that results in items dropped |
| 4404 | * via 'D' not stacking with compatible items already on the floor; |
| 4405 | * caller who wants that behavior should use 'nomerge' instead */ |
| 4406 | if (obj->bypass != otmp->bypass) |
| 4407 | return FALSE; |
| 4408 | #endif |
| 4409 | |
| 4410 | if (obj->globby) |
| 4411 | return TRUE; |
| 4412 | /* Checks beyond this point either aren't applicable to globs |
| 4413 | * or don't inhibit their merger. |
| 4414 | */ |
| 4415 | |
| 4416 | if (obj->unpaid != otmp->unpaid || obj->spe != otmp->spe |
| 4417 | || obj->no_charge != otmp->no_charge || obj->obroken != otmp->obroken |
| 4418 | || obj->otrapped != otmp->otrapped || obj->lamplit != otmp->lamplit) |
| 4419 | return FALSE; |
| 4420 | |
| 4421 | if (obj->oclass == FOOD_CLASS |
| 4422 | && (obj->oeaten != otmp->oeaten || obj->orotten != otmp->orotten)) |
| 4423 | return FALSE; |
| 4424 | |
| 4425 | if (obj->dknown != otmp->dknown |
| 4426 | || (obj->bknown != otmp->bknown && !Role_if(PM_CLERIC) && |
| 4427 | (Blind || Hallucination)) |
| 4428 | || obj->oeroded != otmp->oeroded || obj->oeroded2 != otmp->oeroded2 |
| 4429 | || obj->greased != otmp->greased) |
| 4430 | return FALSE; |
| 4431 | |
| 4432 | if ((erosion_matters(obj)) |
| 4433 | && (obj->oerodeproof != otmp->oerodeproof |
| 4434 | || (obj->rknown != otmp->rknown && (Blind || Hallucination)))) |
| 4435 | return FALSE; |
no test coverage detected