From dc4deab88bb4461b854cf5613d38a2d11a2c027f Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 15 Aug 2009 20:34:11 +0000 Subject: (svn r17193) -Fix [FS#3124]: guard the valuator against 'external' modifications of the valuated list which could cause it to go into an infinite loop. --- src/ai/api/ai_abstractlist.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/ai/api/ai_abstractlist.hpp') diff --git a/src/ai/api/ai_abstractlist.hpp b/src/ai/api/ai_abstractlist.hpp index 0a8739182..e0fd4226d 100644 --- a/src/ai/api/ai_abstractlist.hpp +++ b/src/ai/api/ai_abstractlist.hpp @@ -31,10 +31,11 @@ public: static const bool SORT_DESCENDING = false; private: - AIAbstractListSorter *sorter; - SorterType sorter_type; - bool sort_ascending; - bool initialized; + AIAbstractListSorter *sorter; //!< Sorting algorithm + SorterType sorter_type; //!< Sorting type + bool sort_ascending; //!< Whether to sort ascending or descending + bool initialized; //!< Whether an iteration has been started + int modifications; //!< Number of modification that has been done. To prevent changing data while valuating. public: typedef std::set AIItemList; //!< The list of items inside the bucket @@ -251,6 +252,8 @@ public: * @param valuator_function The function which will be doing the valuation. * @param params The params to give to the valuators (minus the first param, * which is always the index-value we are valuating). + * @note You may not add, remove or change (setting the value of) items while + * valuating. You may also not (re)sort while valuating. * @note You can write your own valuators and use them. Just remember that * the first parameter should be the index-value, and it should return * an integer. -- cgit v1.2.3-70-g09d2