diff options
author | Fire_Head <Fire-Head@users.noreply.github.com> | 2020-08-03 00:03:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-03 00:03:24 +0200 |
commit | 4b614333c6778ae49cef688f6ef691dd58384d13 (patch) | |
tree | ced50966eaaf373f8733547046baf2bdc558662d /src/extras | |
parent | cleanup (diff) | |
parent | Move sdk and eax (diff) | |
download | re3-4b614333c6778ae49cef688f6ef691dd58384d13.tar re3-4b614333c6778ae49cef688f6ef691dd58384d13.tar.gz re3-4b614333c6778ae49cef688f6ef691dd58384d13.tar.bz2 re3-4b614333c6778ae49cef688f6ef691dd58384d13.tar.lz re3-4b614333c6778ae49cef688f6ef691dd58384d13.tar.xz re3-4b614333c6778ae49cef688f6ef691dd58384d13.tar.zst re3-4b614333c6778ae49cef688f6ef691dd58384d13.zip |
Diffstat (limited to 'src/extras')
-rw-r--r-- | src/extras/frontendoption.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp index 6ab2801c..51814f35 100644 --- a/src/extras/frontendoption.cpp +++ b/src/extras/frontendoption.cpp @@ -43,10 +43,13 @@ GetNumberOfMenuOptions(int screen) return Rows; } -// Used before reloading in InitialiseChangedLanguageSettings and debugmenu +// Used before populating options, but effective in InitialiseChangedLanguageSettings and debugmenu void RemoveCustomFrontendOptions() { + if (numCustomFrontendOptions == 0) + return; + for (int i = 0; i < MENUPAGES; i++) { for (int j = 0; j < NUM_MENUROWS; j++) { if (aScreens[i].m_aEntries[j].m_Action == MENUACTION_TRIGGERFUNC) { @@ -68,9 +71,11 @@ int8 RegisterNewOption(int screen) { numCustomFrontendOptions++; if (numCustomFrontendOptions == 1) - customFrontendOptions = (FrontendOption*)malloc(numCustomFrontendOptions * sizeof(FrontendOption)); - else - customFrontendOptions = (FrontendOption*)realloc(customFrontendOptions, numCustomFrontendOptions * sizeof(FrontendOption)); + customFrontendOptions = (FrontendOption*)malloc(5 * sizeof(FrontendOption)); + else if (numCustomFrontendOptions % 5 == 1) + customFrontendOptions = (FrontendOption*)realloc(customFrontendOptions, (numCustomFrontendOptions + 4) * sizeof(FrontendOption)); + + assert(customFrontendOptions != nil && "Custom frontend options can't be allocated"); uint8 nth = GetNumberOfMenuOptions(screen); if (optionCursor < 0) { |