From 92ff6ac8fcadfcea4d2bf6bb1a8c65b63b321e88 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 12 Jun 2020 17:20:37 -0700 Subject: [PATCH] Fix editor ghosts being added multiple times per frame This just results in a messy splotchy effect. Instead, move the ghost adding outside of the render function. --- desktop_version/src/Logic.cpp | 27 +++++++++++++++++++++++++++ desktop_version/src/Render.cpp | 29 ----------------------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 4f31b194..645c6a12 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -1672,5 +1672,32 @@ void gamelogic() { ed.returneditoralpha -= 15; } + + // Editor ghosts! + if (game.ghostsenabled) + { + if (map.custommode && !map.custommodeforreal) + { + if (game.gametimer % 3 == 0) + { + int i = obj.getplayer(); + GhostInfo ghost; + ghost.rx = game.roomx-100; + ghost.ry = game.roomy-100; + if (i > -1) + { + ghost.x = obj.entities[i].xp; + ghost.y = obj.entities[i].yp; + ghost.col = obj.entities[i].colour; + ghost.frame = obj.entities[i].drawframe; + } + ed.ghosts.push_back(ghost); + } + if (ed.ghosts.size() > 100) + { + ed.ghosts.erase(ed.ghosts.begin()); + } + } + } #endif } diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index b6f0369e..30606184 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1352,35 +1352,6 @@ void gamerender() { graphics.drawtowerspikes(); } - -#if !defined(NO_CUSTOM_LEVELS) - // Editor ghosts! - if (game.ghostsenabled) - { - if (map.custommode && !map.custommodeforreal) - { - if (game.gametimer % 3 == 0) - { - int i = obj.getplayer(); - GhostInfo ghost; - ghost.rx = game.roomx-100; - ghost.ry = game.roomy-100; - if (i > -1) - { - ghost.x = obj.entities[i].xp; - ghost.y = obj.entities[i].yp; - ghost.col = obj.entities[i].colour; - ghost.frame = obj.entities[i].drawframe; - } - ed.ghosts.push_back(ghost); - } - if (ed.ghosts.size() > 100) - { - ed.ghosts.erase(ed.ghosts.begin()); - } - } - } -#endif } if(map.extrarow==0 || (map.custommode && map.roomname!=""))