[OASIS OLC] Sedit bug(?)

From: Todd A Laycock (tlayco1@uic.edu)
Date: 06/14/01

Hello list,

I remember a few months back (I think), alot of people mentioning
something about a bug with shop editting in oasis 2.0.  The bug I believe
was that the strings in certain shops (primarily those immediately after
the shop being editted) would be corrupted.  I don't remember if there was
a solution ever posted or found, but I found what I think is the error and
thought I should share the solution I have.

First of all from what I can tell by viewing the contents of the patch:
the error is still there.

I believe what causes the error is found in two places, both in genshp.c.
In the add_shop function, this for loop:

+  for (rshop = top_shop - top_shop_offset; rshop > 0; rshop--) {
+    if (nshp->vnum > SHOP_NUM(rshop - 1)) {
+      found = rshop;
+      /* Make a "nofree" variant and remove these later. */
+      shop_index[rshop].in_room = NULL;
+      shop_index[rshop].producing = NULL;
+      shop_index[rshop].type = NULL;
+      copy_shop(&shop_index[rshop], nshp);
+      break;
+    }
+    shop_index[rshop] = shop_index[rshop - 1];
+  }

contains part 1 of the error at the second to last line:

     shop_index[rshop] = shop_index[rshop - 1];

the second part is found in copy_shop, at this line:


It seems to me that when you're inserting a new shop that is not at the
end of the shop_index, the strings are not copied with str_dup but just
the pointers to the strings.  Then when the new shop is inserted, that
free_shop_strings(tshop) line is called, freeing the still in use strings
in the next shop.  If you were just editting a shop that already existed,
the add_shop function handled all the strings properly.

My solution was to comment out the free_shop_strings line in copy_shop,
and insert a call to it in this block in add_shop:

+  /*
+   * The shop already exists, just update it.
+   */
+  if ((rshop = real_shop(S_NUM(nshp))) != NOWHERE) {
+    free_shop_strings(&shop_index[rshop]);
+    copy_shop(&shop_index[rshop], nshp);
+    if (rznum != NOWHERE)
+      add_to_save_list(zone_table[rznum].number, SL_SHP);
+    else
+      mudlog("SYSERR: GenOLC: Cannot determine shop zone.", BRF, LVL_BUILDER, TRUE);
+    return rshop;
+  }

Hope this works for anyone else that doesn't already have a solution in
place for it.

Todd A Laycock

   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |

This archive was generated by hypermail 2b30 : 12/05/01 PST