From 8fd7210d37691dca94cfca5b8c67fb3169a25459 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 25 Mar 2021 18:57:53 -0700 Subject: [PATCH] De-duplicate warp line creation in createentity() Copy-pasted code begone. This makes it much clearer what the difference between all the warp line entities in this function are. --- desktop_version/src/Entity.cpp | 71 ++++++++++++++-------------------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index c86e03aa..f02e3584 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -1954,51 +1954,36 @@ void entityclass::createentity( float xp, float yp, int t, float vx /*= 0*/, flo entity.size = 13; break; - case 51: //Vertical Warp Line - entity.rule = 5; - entity.type = 51; - entity.size = 6; - entity.life = 0; - entity.w = 1; - entity.h = vx; - //entity.colour = 0; + /* Warp lines */ + case 51: /* Vertical */ + case 52: /* Vertical */ + case 53: /* Horizontal */ + case 54: /* Horizontal */ + entity.type = t; entity.onentity = 1; - entity.invis=true; - if (map.custommode) customwarpmode = true; - break; - case 52: //Vertical Warp Line - entity.rule = 5; - entity.type = 52; - entity.size = 6; + entity.invis = true; entity.life = 0; - entity.w = 1; - entity.h = vx; - //entity.colour = 0; - entity.onentity = 1; - entity.invis=true; - if (map.custommode) customwarpmode = true; - break; - case 53: //Horizontal Warp Line - entity.rule = 7; - entity.type = 53; - entity.size = 5; - entity.life = 0; - entity.w = vx; - entity.h = 1; - entity.onentity = 1; - entity.invis=true; - if (map.custommode) customwarpmode = true; - break; - case 54: //Horizontal Warp Line - entity.rule = 7; - entity.type = 54; - entity.size = 5; - entity.life = 0; - entity.w = vx; - entity.h = 1; - entity.onentity = 1; - entity.invis=true; - if (map.custommode) customwarpmode = true; + switch (t) + { + case 51: + case 52: + entity.rule = 5; + entity.size = 6; + entity.w = 1; + entity.h = vx; + break; + case 53: + case 54: + entity.rule = 7; + entity.size = 5; + entity.w = vx; + entity.h = 1; + break; + } + if (map.custommode) + { + customwarpmode = true; + } break; case 55: // Crew Member (custom, collectable) //1 - position in array