diff options
author | rubidium <rubidium@openttd.org> | 2009-08-15 20:34:11 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-08-15 20:34:11 +0000 |
commit | dc4deab88bb4461b854cf5613d38a2d11a2c027f (patch) | |
tree | 11bbeaedad4807560f0f20612b2c14790015cf8f /src/ai/api/ai_abstractlist.hpp | |
parent | 118d5e9facf6fd9d0841775c11b712d0e4c796aa (diff) | |
download | openttd-dc4deab88bb4461b854cf5613d38a2d11a2c027f.tar.xz |
(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.
Diffstat (limited to 'src/ai/api/ai_abstractlist.hpp')
-rw-r--r-- | src/ai/api/ai_abstractlist.hpp | 11 |
1 files changed, 7 insertions, 4 deletions
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<int32> 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. |