From a113662050d29a01819a2f606c9bb1d55d941abb Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 12 Feb 2021 16:35:22 -0800 Subject: [PATCH] Clean up resetting editor contents and scripts Contents and scripts should be reset in editorclass::reset(); there's no reason to reset them again right before you load them from an XML file in editorclass::load(). Additionally, the resets now consistently use SDL_zeroa() (for contents) and scriptclass::clearcustom() (for scripts). --- desktop_version/src/Script.cpp | 3 ++- desktop_version/src/editor.cpp | 12 ++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 622acc7d..dc25aa32 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -35,7 +35,8 @@ scriptclass::scriptclass() texty = 0; } -void scriptclass::clearcustom(){ +void scriptclass::clearcustom() +{ customscripts.clear(); } diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 357c83eb..ec1a9c9a 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -364,13 +364,7 @@ void editorclass::reset() } } - for (int j = 0; j < 30 * maxheight; j++) - { - for (int i = 0; i < 40 * maxwidth; i++) - { - contents[i+(j*40*maxwidth)]=0; - } - } + SDL_zeroa(contents); hooklist.clear(); @@ -387,7 +381,7 @@ void editorclass::reset() hookmenupage=0; hookmenu=0; - script.customscripts.clear(); + script.clearcustom(); returneditoralpha = 0; oldreturneditoralpha = 0; @@ -1756,7 +1750,6 @@ bool editorclass::load(std::string& _path) { std::string TextString = (pText); std::vector values = split(TextString,','); - SDL_memset(contents, 0, sizeof(contents)); int x =0; int y =0; for(size_t i = 0; i < values.size(); i++) @@ -1874,7 +1867,6 @@ bool editorclass::load(std::string& _path) { std::string TextString = (pText); std::vector values = split(TextString,'|'); - script.clearcustom(); Script script_; bool headerfound = false; for(size_t i = 0; i < values.size(); i++)