Sorry for not replying...I got dropped from the list due (I think) to ISP problems, and I read Dust's message on the archive page. As far as I can tell, no one has posted this particular solution. First, I would strongly advocate removing top_shop_offset from the code altogether. It is used erroneously in several places and seems to be causing the infamous sedit bug. I will summarize all of the code changes here, since they are not extensive, and some changes were missed in previous posts regarding the solution. genolc.h: -extern int top_shop_offset; genolc.c: -int top_shop_offset = 1; genmob.c: - for (shop = 0; shop <= top_shop - top_shop_offset; shop++) + for (shop = 0; shop <= top_shop; shop++) - for (counter = 0; counter <= top_shop - top_shop_offset; counter++) + for (counter = 0; counter <= top_shop; counter++) genshp.c: - for (rshop_num = 0; rshop_num <= top_shop - top_shop_offset; rshop_num++) + for (rshop_num = 0; rshop_num <= top_shop; rshop_num++) - RECREATE(shop_index, struct shop_data, top_shop - top_shop_offset + 1); + RECREATE(shop_index, struct shop_data, top_shop + 1); - for (rshop = top_shop - top_shop_offset; rshop > 0; rshop--) { + for (rshop = top_shop; rshop > 0; rshop--) { The most glaring error I discovered is the RECREATE above, which does not actually allocate enough memory for the entire shop_index. top_shop is a pointer to the last element, not the size of the array, so even though the top_shop is being incremented right above the RECREATE, you still need to allocation top_shop + 1 elements. Without the above modifications: This bug would cause one shop to drop out of the list each time a shop is added. If you happen to modify the zone containing the dropped shop, then it will be lost on disk, too. Otherwise, it will be fine after a reboot. Of course, if you ever try to access shop_index[top_shop] (or shop_index[top_shop - top_shop_index + 1], which is the same thing), you will probably crash. Mike -- +---------------------------------------------------------------+ | 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/06/01 PST