From fe8f93a6b2d6103820417a44b9a95fec5f87baec Mon Sep 17 00:00:00 2001 From: Nauzhror Date: Fri, 19 Jan 2018 18:53:04 -0500 Subject: [PATCH] Bugfixes (#38) * Added %log%, and made %send%, %echo%, etc. not force capitalization. * Fixed Previous Commit * Really fixed this time. * Fixed look 2.mail Also reverted CMMAND_TERMS, was increased in previous commit when it didn't need to be due to the removed of marena. * Fixed add_to_lookup_table Fixed as per Welcor https://www.tbamud.com/forum/2-general/4307-crash-bug-need-assistance-with-gdb?start=20#7390 * Fixed two crash bugs Fixed tw crash bugs Welcor found here https://www.tbamud.com/forum/4-development/4300-simple-list-forced-to-reset-itself --- src/fight.c | 7 +++++-- src/lists.c | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/fight.c b/src/fight.c index d325011..cfa53e8 100644 --- a/src/fight.c +++ b/src/fight.c @@ -930,8 +930,11 @@ void perform_violence(void) continue; } - if (GROUP(ch)) { - while ((tch = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL) { + if (GROUP(ch) && GROUP(ch)->members && GROUP(ch)->members->iSize) { + struct iterator_data Iterator; + + tch = (struct char_data *) merge_iterator(&Iterator, GROUP(ch)->members); + for (; tch ; tch = next_in_list(&Iterator)) { if (tch == ch) continue; if (!IS_NPC(tch) && !PRF_FLAGGED(tch, PRF_AUTOASSIST)) diff --git a/src/lists.c b/src/lists.c index 34b4f9f..3a61209 100644 --- a/src/lists.c +++ b/src/lists.c @@ -268,6 +268,7 @@ void * simple_list(struct list_data * pList) void * random_from_list(struct list_data * pList) { + struct iterator_data localIterator; void * pFoundItem; bool found; int number; @@ -278,17 +279,17 @@ void * random_from_list(struct list_data * pList) 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