From 639f0e5229cfd9eb5448d014238da984fb932990 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 30 Aug 2024 11:51:43 -0700 Subject: [PATCH] Glitchless: Fix changetile sprite glitch (TEMP) TODO: use color_valid for other commands? --- desktop_version/src/Entity.cpp | 16 ++++++++++++++++ desktop_version/src/Script.cpp | 24 +++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 846d9aa3..c7ab52fd 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -3953,6 +3953,10 @@ int entityclass::getscm(void) } } + if (game.glitchlessmode) + { + return -1; + } return 0; } @@ -3970,6 +3974,10 @@ int entityclass::getlineat( int t ) } } + if (game.glitchlessmode) + { + return -1; + } return 0; } @@ -3989,6 +3997,10 @@ int entityclass::getcrewman( int t, int fallback /*= 0*/ ) } } + if (game.glitchlessmode) + { + return -1; + } return fallback; } @@ -4013,6 +4025,10 @@ int entityclass::getcustomcrewman( int t ) } } + if (game.glitchlessmode) + { + return -1; + } return 0; } diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index d8206779..8c93566b 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -157,6 +157,28 @@ static int getcrewmanfromname(const std::string& name) return obj.getcrewman(color); } +static bool color_valid(const int index, const std::string& name) +{ + if (!INBOUNDS_VEC(index, obj.entities)) + { + return false; + } + + if (!game.glitchlessmode) + { + return true; + } + + const int color = getcolorfromname(name); + const bool using_aem = color == -1; + if (using_aem) + { + return true; + } + + return obj.entities[index].colour == color; +} + /* Also used in gamestate 1001. */ void foundtrinket_textbox1(textboxclass* THIS); @@ -1022,7 +1044,7 @@ void scriptclass::run(void) int crewmate = getcrewmanfromname(words[1]); if (crewmate != -1) i = crewmate; // Ensure AEM is kept - if (INBOUNDS_VEC(i, obj.entities)) + if (color_valid(i, words[1])) { obj.entities[i].tile = ss_toi(words[2]); }