Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old April 1, 2009, 11:30   #1
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
store.c store_maint function

I noticed the following line in store_maint

Code:
while (st_ptr->stock_num < stock) store_create_random(which);
This does not allow a way for store_create_random to fail in a helpful manner and can lead to an endless loop freeze. (If somebody like me has been mucking about with the game code ;-)

How about something with a for loop and a maximum number of tries?

Could also return values from store_create_random and/or store_maint to show if the process has gone as planned or not.
__________________
Currently turning (Angband) Japanese.

Last edited by PaulBlay; April 1, 2009 at 11:52.
PaulBlay is offline   Reply With Quote
Old April 1, 2009, 11:44   #2
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
I wrote some suggested alternative code, but there's something wrong with it So more debugging for me.
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old April 1, 2009, 11:52   #3
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
I noticed the following line in store_maint

Code:
while (st_ptr->stock_num < stock) store_create_random(which);
This does not allow a way for store_create_random to fail in a helpful manner and can lead to an endless loop freeze. (If somebody like me has been mucking about with the game code ;-)

How about something with a for look and a maximum number of tries?

Could also return values from store_create_random and/or store_maint to show if the process has gone as planned or not.
A simple change would be to do:

Code:
while ((st_ptr->stock_num < stock) && store_create_random(which)) ;
and make store_create_random() return FALSE when it fails, TRUE otherwise.
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old April 1, 2009, 12:22   #4
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by takkaria View Post
make store_create_random() return FALSE when it fails, TRUE otherwise.
Waddya know. store_create_random already does return FALSE when it fails, TRUE otherwise.

However I suspect it is possible for the functions called by store_create_random to fail (like store_carry) which leaves you with a created object (success) that hasn't increased the stock number. That's another way that you can end up with a potential for infinite loop. Failing on a failed store_carry also would be dubious as just because one object doesn't fit may not mean that the next one won't go in just fine.

I shall obviously have to consider this a little more.
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Z+Angband keymaps (w/function keys?) PaulBlay Variants 3 January 30, 2009 05:13
General Store Malak Darkhunter Vanilla 3 January 11, 2009 18:21
3.10 Bug -- General Store won't buy Lantern awldune Vanilla 2 January 10, 2009 23:01
Selling Items in General Store Vlarg AAR 1 July 3, 2008 19:44
Have lanterns been removed from the general store? rawuest Vanilla 5 February 25, 2008 11:05


All times are GMT +1. The time now is 07:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.