/* called with two args on merge */ void free_obj(obj_t *obj, obj_t *merge) // was called obfree { bill_t *bp = onbill(obj); bill_t *bpm; if (bp) { if (!merge) { bp->useup = true; obj->bitflags &= ~O_IS_UNPAID; /* only for doinvbill */ obj->nobj = billobjs; billobjs = obj; return; } bpm = onbill(merge); if (!bpm) { /* this used to be a rename */ message("BUG: obfree: not on bill??"); return; } else { /* this was a merger */ bpm->bquantity += bp->bquantity; ESHK(shopkeeper)->billct--; *bp = bill[ESHK(shopkeeper)->billct]; } } free_me((VoidPtr) obj); }
void deltrap(trap_t *trap) // was in invent.c! { trap_t *ttmp; if (trap == ftrap) ftrap = ftrap->ntrap; else { for (ttmp = ftrap; ttmp->ntrap != trap; ttmp = ttmp->ntrap) if (!ttmp) { alert_message("error in deltrap"); return; } ttmp->ntrap = trap->ntrap; } free_me((VoidPtr) trap); // free((char *) trap); }
/* -1 if object could not be found (but was paid) */ static Short dopayobj(bill_t *bp) { obj_t *obj; Long ltmp; /* find the object on one of the lists */ obj = bp_to_obj(bp); if (!obj) { message("BUG: Shopkeeper administration out of order."); setpaid(); /* be nice to the player */ return 0; } if (!(obj->bitflags & O_IS_UNPAID) && !bp->useup) { message("BUG: Paid object on bill??"); return 1; } obj->bitflags &= ~O_IS_UNPAID; ltmp = bp->price * bp->bquantity; if (ANGRY(shopkeeper)) ltmp += ltmp/3; if (you.ugold < ltmp) { StrPrintF(ScratchBuffer, "You don't have gold enough to pay %s.", doname(obj)); message(ScratchBuffer); obj->bitflags |= O_IS_UNPAID; return 0; } pay(ltmp, shopkeeper); StrPrintF(ScratchBuffer, "You bought %s for %ld gold piece%s", doname(obj), ltmp, (ltmp == 1 ? "." : "s.")); message(ScratchBuffer); if (bp->useup) { obj_t *otmp = billobjs; if (obj == billobjs) billobjs = obj->nobj; else { while (otmp && otmp->nobj != obj) otmp = otmp->nobj; if (otmp) otmp->nobj = obj->nobj; else message("BUG: Error in shopkeeper administration."); } free_me((VoidPtr) obj); } return 1; }
/* either we paid or left the shop or he just died */ static void setpaid() { obj_t *obj; monst_t *mtmp; for (obj = invent ; obj ; obj = obj->nobj) obj->bitflags &= ~O_IS_UNPAID; for (obj = fobj ; obj ; obj = obj->nobj) obj->bitflags &= ~O_IS_UNPAID; for (obj = fcobj ; obj ; obj = obj->nobj) obj->bitflags &= ~O_IS_UNPAID; for (mtmp = fmon ; mtmp ; mtmp = mtmp->nmon) for (obj = mtmp->minvent ; obj ; obj = obj->nobj) obj->bitflags &= ~O_IS_UNPAID; for (mtmp = fallen_down ; mtmp ; mtmp = mtmp->nmon) for (obj = mtmp->minvent ; obj ; obj = obj->nobj) obj->bitflags &= ~O_IS_UNPAID; while ((obj = billobjs)) { billobjs = obj->nobj; free_me((VoidPtr) obj); // hmmmm. } ESHK(shopkeeper)->billct = 0; }
// ************************************************************** ~LookUpTable() { free_me(table, n); }