Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small bug fix



I haven't seen a patch for this problem for version 0.87.8.

Problem: Hold in the inventory some collatable item (e.g., a scroll).
Enter a shop and purchase more of the same, these will be added as
a separate item, marked (unpaid).  As you exit the shop and pay,
the separate item will lose the unpaid tag, but will not be merged.

The following fix seems to work, though I am a little concerned that
I may have introduced a new memory leak.  I haven't fully got to
grips yet with the full details of the system data structures.

Pat Place   prp@sei.cmu.edu

--- patch follows ---
*** /tmp/da21761	Thu Oct  8 19:14:36 1992
--- shop.c	Thu Oct  8 19:07:42 1992
***************
*** 107,118 ****
  }

  int get_payment(object *pl) {
!   object *tmp,*inv;
    char buf[MAX_BUF],buf2[MAX_BUF];

    D_LOCK(pl);
    for(inv=pl->inv;inv!=NULL;inv=inv->below)
!     for(tmp=inv;tmp!=NULL;tmp=tmp->inv)
        if(IS_UNPAID(tmp)) {
          strncpy(buf,query_cost_string(tmp,pl,F_BUY),MAX_BUF);
          if(!pay_for_item(tmp,pl)) {
--- 107,119 ----
  }

  int get_payment(object *pl) {
!   object *tmp,*inv, *tmp2;
    char buf[MAX_BUF],buf2[MAX_BUF];

    D_LOCK(pl);
    for(inv=pl->inv;inv!=NULL;inv=inv->below)
!     for(tmp=inv;tmp!=NULL;tmp=tmp2) {
!       tmp2 = tmp->inv;
        if(IS_UNPAID(tmp)) {
          strncpy(buf,query_cost_string(tmp,pl,F_BUY),MAX_BUF);
          if(!pay_for_item(tmp,pl)) {
***************
*** 123,132 ****
--- 124,136 ----
            return 0;
          } else {
            UNSET_UNPAID(tmp);
+           remove_ob(tmp);
+           insert_ob_in_ob(tmp, pl);
            sprintf(buf2,"You paid %s for %s.",buf,query_name(tmp));
            draw_info(pl,buf2);
          }
        }
+     }
    D_UNLOCK(pl);
    draw_all_inventory(pl);
    return 1;