diff --git a/CHANGELOG.md b/CHANGELOG.md index c8ccf1f6..fef37e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Add a `Close Project` option - Add charts to the `Wild Pokémon` tab that show species and level distributions. - An alert will be displayed when attempting to open a seemingly invalid project. +- Add support for defining project values with `enum` where `#define` was expected. ### Changed - Edits to map connections now have Undo/Redo and can be viewed in exported timelapses. @@ -42,6 +43,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix map connections rendering incorrectly if their dimensions were smaller than the border draw distance. - Fix the map list filter retaining text between project open/close. - Fix the map list mishandling value gaps when sorting by Area. +- Fix a freeze on startup if project values are defined with mismatched parentheses. ## [5.4.1] - 2024-03-21 ### Fixed diff --git a/include/core/parseutil.h b/include/core/parseutil.h index 9e00087e..bc167a30 100644 --- a/include/core/parseutil.h +++ b/include/core/parseutil.h @@ -54,9 +54,9 @@ class ParseUtil QString readCIncbin(const QString &text, const QString &label); QMap readCIncbinMulti(const QString &filepath); QStringList readCIncbinArray(const QString &filename, const QString &label); - QMap readCDefinesByPrefix(const QString &filename, QStringList prefixes); - QMap readCDefinesByName(const QString &filename, QStringList names); - QStringList readCDefineNames(const QString&, const QStringList&); + QMap readCDefinesByRegex(const QString &filename, const QStringList ®exList); + QMap readCDefinesByName(const QString &filename, const QStringList &names); + QStringList readCDefineNames(const QString &filename, const QStringList ®exList); QMap> readCStructs(const QString &, const QString & = "", const QHash = { }); QList getLabelMacros(const QList&, const QString&); QStringList getLabelValues(const QList&, const QString&); @@ -97,8 +97,14 @@ class ParseUtil void recordErrors(const QStringList &errors); void logRecordedErrors(); QString createErrorMessage(const QString &message, const QString &expression); - QString readCDefinesFile(const QString &filename); - QMap readCDefines(const QString &filename, const QStringList &searchText, bool fullMatch); + + struct ParsedDefines { + QMap expressions; // Map of all define names encountered to their expressions + QStringList filteredNames; // List of define names that matched the search text, in the order that they were encountered + }; + ParsedDefines readCDefines(const QString &filename, const QStringList &filterList, bool useRegex); + QMap evaluateCDefines(const QString &filename, const QStringList &filterList, bool useRegex); + bool defineNameMatchesFilter(const QString &name, const QStringList &filterList, bool useRegex); static const QRegularExpression re_incScriptLabel; static const QRegularExpression re_globalIncScriptLabel; diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp index c5d09635..04cdbcc7 100644 --- a/src/core/parseutil.cpp +++ b/src/core/parseutil.cpp @@ -15,6 +15,22 @@ const QRegularExpression ParseUtil::re_poryScriptLabel("\\b(script)(\\((global|l const QRegularExpression ParseUtil::re_globalPoryScriptLabel("\\b(script)(\\((global)\\))?\\s*\\b(?