when splitting a stack that has o_id-based shop prices, pick an o_id value for the new stack that will maintain the same price */
| 533 | /* when splitting a stack that has o_id-based shop prices, pick an |
| 534 | o_id value for the new stack that will maintain the same price */ |
| 535 | staticfn unsigned |
| 536 | nextoid(struct obj *oldobj, struct obj *newobj) |
| 537 | { |
| 538 | int olddif, newdif, trylimit = 256; /* limit of 4 suffices at present */ |
| 539 | unsigned oid = svc.context.ident - 1; /* loop increment will reverse -1 */ |
| 540 | |
| 541 | olddif = oid_price_adjustment(oldobj, oldobj->o_id); |
| 542 | do { |
| 543 | ++oid; |
| 544 | if (!oid) /* avoid using 0 (in case value wrapped) */ |
| 545 | ++oid; |
| 546 | newdif = oid_price_adjustment(newobj, oid); |
| 547 | } while (newdif != olddif && --trylimit >= 0); |
| 548 | svc.context.ident = oid; /* update 'last ident used' */ |
| 549 | (void) next_ident(); /* increment context.ident for next use */ |
| 550 | return oid; /* caller will use this ident */ |
| 551 | } |
| 552 | |
| 553 | /* try to find the stack obj was split from, then merge them back together; |
| 554 | returns the combined object if unsplit is successful, null otherwise */ |
no test coverage detected