From 4e952450d55054eed0327b9fc86bb053812741a2 Mon Sep 17 00:00:00 2001 From: Info Teddy <59748578+InfoTeddy@users.noreply.github.com> Date: Wed, 15 Jan 2020 20:55:53 -0800 Subject: [PATCH] Prevent the game from thinking horizontal warp lines are cyan crewmates (#87) * Add entity type attribute checks to getcrewman() This means that the game is no longer able to target other non-crewmate entities when it looks for a crewmate. This has actually happened in practice. A command like position(cyan,above) could position the text box above a horizontal warp line instead of the intended crewmate. This is because getcrewman() previously only checked the rule attributes of entities, and if their rule happened to be 6 or 7. Usually this corresponds with crewmates being unflipped or flipped, respectively. But warp lines' rules overlap with rules 6 and 7. If a warp line is vertical, its rule is 5, and if it is horizontal, its rule is 7. Now, usually, this wouldn't be an issue, but getcrewman() does a color check as well. And for cyan, that is color 0. However, if an entity doesn't use a color, it just defaults to color 0. So, getcrewman() found an entity with a rule of 7 and a color of 0. This must mean it's a cyan crewmate! But, well, it's actually just a horizontal warp line. This commit prevents the above from happening. --- desktop_version/src/Entity.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index a347ecf4..976ea695 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -4381,7 +4381,8 @@ int entityclass::getcrewman( int t ) for (int i = 0; i < nentity; i++) { - if (entities[i].rule == 6 || entities[i].rule == 7) + if ((entities[i].type == 12 || entities[i].type == 14) + && (entities[i].rule == 6 || entities[i].rule == 7)) { if(entities[i].colour==t) {