Refactor colors in internal commands

Originally this started as a "deduplicate a bunch of duplicated code in script commands" PR,
but as I was working on that, I discovered there's a lot more that needs to be done than
just deduplication.
Anything which needs a crewmate entity now calls `getcrewmanfromname(name)`, and anything which
just needs the crewmate's color calls `getcolorfromname(name)`. This was done to make sure that
everything works consistently and no copy/pasting is required. Next is the fallback; instead of
giving up and doing various things when it can't find a specific color, it now attempts to treat
the color name as an ID, and if it can't then it returns -1, where each individual command handles
that return value. This means we can keep around AEM -- a bug used in custom levels -- by not
doing anything with the return value if it's -1.

Also, for some reason, there were two `crewcolour` functions, so I stripped out the one in
entityclass and left (and modified) the one in the graphics class, since the graphics class also
has the `crewcolourreal` function.
This commit is contained in:
Ally
2021-08-31 19:09:51 -03:00
committed by GitHub
parent 8ebf8a21e4
commit 64be7dbd53
7 changed files with 107 additions and 461 deletions

View File

@@ -20,6 +20,18 @@ enum
ACTIVITY = 5
};
enum
{
CYAN = 0,
PURPLE = 20,
YELLOW = 14,
RED = 15,
GREEN = 13,
BLUE = 16,
GRAY = 19,
TELEPORTER = 102
};
class entityclass
{
public:
@@ -72,8 +84,6 @@ public:
bool gridmatch(int p1, int p2, int p3, int p4, int p11, int p21, int p31, int p41);
int crewcolour(int t);
void createentity(int xp, int yp, int t, int meta1, int meta2,
int p1, int p2, int p3, int p4);
void createentity(int xp, int yp, int t, int meta1, int meta2,
@@ -98,7 +108,7 @@ public:
int getlineat(int t);
int getcrewman(int t);
int getcrewman(int t, int fallback = 0);
int getcustomcrewman(int t);
int getteleporter(void);