diff options
author | yexo <yexo@openttd.org> | 2009-07-31 19:50:01 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-07-31 19:50:01 +0000 |
commit | c2ed8840123cc81f58b3db8d6341b22349b4ac78 (patch) | |
tree | 71e42277f511c8cdfa800e9d564d159e20b595ff /src/ai/api | |
parent | 0bb3d7030ffdd336acd0131a00b93c6aa1b26419 (diff) | |
download | openttd-c2ed8840123cc81f58b3db8d6341b22349b4ac78.tar.xz |
(svn r17005) -Add [NoAI]: AIAbstractList::SORT_ASCENDING / SORT_DESCENDING
Diffstat (limited to 'src/ai/api')
-rw-r--r-- | src/ai/api/ai_abstractlist.hpp | 6 | ||||
-rw-r--r-- | src/ai/api/ai_abstractlist.hpp.sq | 3 | ||||
-rw-r--r-- | src/ai/api/squirrel_export.awk | 19 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/ai/api/ai_abstractlist.hpp b/src/ai/api/ai_abstractlist.hpp index d99791fd4..0a8739182 100644 --- a/src/ai/api/ai_abstractlist.hpp +++ b/src/ai/api/ai_abstractlist.hpp @@ -25,6 +25,11 @@ public: SORT_BY_ITEM, //!< Sort the list based on the item itself. }; + /** Sort ascending */ + static const bool SORT_ASCENDING = true; + /** Sort descnding */ + static const bool SORT_DESCENDING = false; + private: AIAbstractListSorter *sorter; SorterType sorter_type; @@ -123,6 +128,7 @@ public: * @param sorter the type of sorter to use * @param ascending if true, lowest value is on top, else at bottom. * @note the current item stays at the same place. + * @see SORT_ASCENDING SORT_DESCENDING */ void Sort(SorterType sorter, bool ascending); diff --git a/src/ai/api/ai_abstractlist.hpp.sq b/src/ai/api/ai_abstractlist.hpp.sq index 1ab62061a..cf84420fb 100644 --- a/src/ai/api/ai_abstractlist.hpp.sq +++ b/src/ai/api/ai_abstractlist.hpp.sq @@ -24,6 +24,9 @@ void SQAIAbstractList_Register(Squirrel *engine) { SQAIAbstractList.DefSQConst(engine, AIAbstractList::SORT_BY_VALUE, "SORT_BY_VALUE"); SQAIAbstractList.DefSQConst(engine, AIAbstractList::SORT_BY_ITEM, "SORT_BY_ITEM"); + SQAIAbstractList.DefSQConst(engine, AIAbstractList::SORT_ASCENDING, "SORT_ASCENDING"); + SQAIAbstractList.DefSQConst(engine, AIAbstractList::SORT_DESCENDING, "SORT_DESCENDING"); + SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::Clear, "Clear", 1, "x"); SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::HasItem, "HasItem", 2, "xi"); SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::Begin, "Begin", 1, "x"); diff --git a/src/ai/api/squirrel_export.awk b/src/ai/api/squirrel_export.awk index 930de32dd..eb829a510 100644 --- a/src/ai/api/squirrel_export.awk +++ b/src/ai/api/squirrel_export.awk @@ -34,6 +34,7 @@ BEGIN { enum_value_size = 0 enum_string_to_error_size = 0 enum_error_to_string_size = 0 + const_size = 0 struct_size = 0 method_size = 0 static_method_size = 0 @@ -217,6 +218,17 @@ BEGIN { } if (enum_value_size != 0) print "" + # Const values + mlen = 0 + for (i = 1; i <= const_size; i++) { + if (mlen <= length(const_value[i])) mlen = length(const_value[i]) + } + for (i = 1; i <= const_size; i++) { + print " SQ" cls ".DefSQConst(engine, " cls "::" const_value[i] ", " substr(spaces, 1, mlen - length(const_value[i])) "\"" const_value[i] "\");" + delete const_value[i] + } + if (const_size != 0) print "" + # Mapping of OTTD strings to errors mlen = 0 for (i = 1; i <= enum_string_to_error_size; i++) { @@ -320,6 +332,13 @@ BEGIN { } } +# Add a const (non-enum) value +/^[ ]*static const \w+ \w+ = \w+;$/ { + const_size++ + const_value[const_size] = $4 + next +} + # Add a method to the list /^.*\(.*\).*$/ { if (cls_level != 1) next |