From f151cff34d8bac48d5b69d6b827996d56126d935 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 12 Jun 2020 17:34:19 -0700 Subject: [PATCH] Fix editor ghost colors updating too fast Like actual entities, editor ghost colors were updating every render frame instead of logic frame. So just like actual entities, I added a realcol attribute to them that editorrender() uses instead, and added code to update said realcol attribute in editorlogic(). That way the colors don't go by too quickly (especially the death color). --- desktop_version/src/Logic.cpp | 1 + desktop_version/src/editor.cpp | 15 ++++++++++++++- desktop_version/src/editor.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 645c6a12..8771f178 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -1689,6 +1689,7 @@ void gamelogic() ghost.x = obj.entities[i].xp; ghost.y = obj.entities[i].yp; ghost.col = obj.entities[i].colour; + ghost.realcol = obj.entities[i].realcol; ghost.frame = obj.entities[i].drawframe; } ed.ghosts.push_back(ghost); diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index ded07952..5397dfe2 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -2889,7 +2889,7 @@ void editorrender() point tpoint; tpoint.x = ed.ghosts[i].x; tpoint.y = ed.ghosts[i].y; - graphics.setcol(ed.ghosts[i].col); + graphics.setcolreal(ed.ghosts[i].realcol); Uint32 alpha = graphics.ct.colour & graphics.backBuffer->format->Amask; Uint32 therest = graphics.ct.colour & 0x00FFFFFF; alpha = (3 * (alpha >> 24) / 4) << 24; @@ -3621,6 +3621,19 @@ void editorlogic() if (game.ghostsenabled) { + for (size_t i = 0; i < ed.ghosts.size(); i++) + { + GhostInfo& ghost = ed.ghosts[i]; + + if ((int) i > ed.currentghosts || ghost.rx != ed.levx || ghost.ry != ed.levy) + { + continue; + } + + graphics.setcol(ghost.col); + ghost.realcol = graphics.ct.colour; + } + if (ed.currentghosts + 1 < (int)ed.ghosts.size()) { ed.currentghosts++; if (ed.zmod) ed.currentghosts++; diff --git a/desktop_version/src/editor.h b/desktop_version/src/editor.h index 7e1a7dcf..44a1ebea 100644 --- a/desktop_version/src/editor.h +++ b/desktop_version/src/editor.h @@ -82,6 +82,7 @@ struct GhostInfo { int x; // .xp int y; // .yp int col; // .colour + Uint32 realcol; int frame; // .drawframe };