Welcome to the Builder Academy

Question simple_list forced to reset itself

More
17 Jan 2018 23:47 #7391 by thomas
Yes, because it uses "random_from_list" and that isn't reentrant either. To fix:
Code:
void * random_from_list(struct list_data * pList) { + struct iterator_data localIterator; void * pFoundItem; bool found; int number; int count = 1; if (pList->iSize <= 0) return NULL; else number = rand_number(1, pList->iSize); - pFoundItem = merge_iterator(&Iterator, pList); + pFoundItem = merge_iterator(&localIterator, pList); - for (found = FALSE; pFoundItem != NULL; pFoundItem = next_in_list(&Iterator), count++) { + for (found = FALSE; pFoundItem != NULL; pFoundItem = next_in_list(&localIterator), count++) { if (count == number) { found = TRUE; break; } } - remove_iterator(&Iterator); + remove_iterator(&localIterator); if (found) return (pFoundItem); else return NULL; }

Please Log in or Create an account to join the conversation.

More
17 Jan 2018 23:51 #7392 by JTP
Ah so that might be a fix for the new version of TBAmud then ?

Please Log in or Create an account to join the conversation.

More
18 Jan 2018 00:09 - 18 Jan 2018 00:09 #7393 by JTP
Could it be someone already using whirlwind and then trying to use it again ?

Because that seems to be it, maybe your fix also fix that ?
Last edit: 18 Jan 2018 00:09 by JTP.

Please Log in or Create an account to join the conversation.

More
18 Jan 2018 21:04 #7406 by thomas
Yes, this will fix it. The problem is that whirlwind uses the random_from_list() function and that internally uses the static Iterator (until you change it like I did above).

I think you see this because if your whirlwind kills someone while you are in a group, you'll trigger group_gain() which uses simple_list(). Which also uses the static Iterator in lists.c.

Please Log in or Create an account to join the conversation.

More
19 Jan 2018 23:08 #7408 by Fizban
These fixes have been pushed to stock tbaMUD.

Please Log in or Create an account to join the conversation.

More
20 Jan 2018 23:23 - 20 Jan 2018 23:26 #7413 by Fizban
It actually still errors even with these changes made.

Before making them when rumble whirlwinded it sometimes sent this.

[ WARNING: Attempting to get content from iterator with NULL list. ]
[ WARNING: Attempting to remove iterator from NULL list. ]
[ List being freed while not empty. ]

After adding the changes it still sends

[ WARNING: Attempting to get content from iterator with NULL list. ]
[ WARNING: Attempting to remove iterator from NULL list. ]

The third message though has no appeared since adding the changes.
Last edit: 20 Jan 2018 23:26 by Fizban.

Please Log in or Create an account to join the conversation.

Time to create page: 0.201 seconds