Remove `scmmoveme`

So, I ended up breaking supercrewmate spawning with that roomchange
refactor. However, upon investigating how to fix it, I was running into
a weird interpolation issue due to scmmoveme, as well as the companion
spawning in the ground in "Very Good". And I was wondering why I or no
one else ended up running into them.

Well, as it turns out, scmmoveme ends up doing absolutely nothing. There
are only two instances where scmmoveme is used. The first is if you
respawn in "Very Good", and somehow have your scmprogress set to that
room. But that's impossible, because whenever you respawn, your
scmprogress is always set to the one after the room you respawn in. Even
if you respawned in the room previous to "Very Good" (which is "Don't
Get Ahead of Yourself!"), it still wouldn't work, since the logic always
kicks in when a gotoroom happens, and not only when a supercrewmate is
actually spawned. Since the scmprogress doesn't match, that case never
gets triggered, and we get to the second time scmmoveme is used, which
is in the catch-all case that always executes.

This second instance... also does nothing, because since we just
respawned, and our scmprogress got set to the room ahead of us, there is
no supercrewmate on screen. Then getscm() returns 0, and the player is
always indice 0, so the only thing we end up doing is setting the
player's x-position to their own x-position. Brilliant.

Anyway, this code results in interpolation issues and the supercrewmate
spawning in the ground on "Very Good" if you die, when my fix is
applied, because my fix moves this logic around to a different frame
order, and that actually ends up making scmmoveme no longer dead code.

So to recap: we have dead code, which looks like it does something, but
doesn't. But if you move it around in a certain way, it ends up having
harmful effects. One of the joys of working on this game...

It's also hilarious that it gets saved to the save file. Why? The only
time this variable is true, it is for literally less than a frame,
because it always gets set to false, because you always respawn using a
gotoroom whenever the supercrewmate dies, because you never respawn in
the same room as a supercrewmate, because Intermission 1 was
deliberately designed that way (else you'd keep continually dying since
the supercrewmate wouldn't move out of the way).
This commit is contained in:
Misa 2021-09-11 22:23:47 -07:00
parent 029463ad47
commit a7ae3e0fb0
5 changed files with 2 additions and 41 deletions

View File

@ -307,7 +307,6 @@ void Game::init(void)
supercrewmate = false;
scmhurt = false;
scmprogress = 0;
scmmoveme = false;
swncolstate = 0;
swncoldelay = 0;
swnrecord = 0;
@ -4946,10 +4945,6 @@ void Game::readmaingamesave(const char* savename, tinyxml2::XMLDocument& doc)
{
scmprogress = help.Int(pText);
}
else if (SDL_strcmp(pKey, "scmmoveme") == 0)
{
scmmoveme = help.Int(pText);
}
else if (SDL_strcmp(pKey, "frames") == 0)
{
frames = help.Int(pText);
@ -5152,10 +5147,6 @@ void Game::customloadquick(const std::string& savfile)
{
scmprogress = help.Int(pText);
}
else if (SDL_strcmp(pKey, "scmmoveme") == 0)
{
scmmoveme = help.Int(pText);
}
else if (SDL_strcmp(pKey, "frames") == 0)
{
frames = help.Int(pText);
@ -5525,7 +5516,6 @@ std::string Game::writemaingamesave(tinyxml2::XMLDocument& doc)
xml::update_tag(msgs, "supercrewmate", (int) supercrewmate);
xml::update_tag(msgs, "scmprogress", scmprogress);
xml::update_tag(msgs, "scmmoveme", (int) scmmoveme);
xml::update_tag(msgs, "frames", frames);
@ -5661,7 +5651,6 @@ bool Game::customsavequick(const std::string& savfile)
xml::update_tag(msgs, "supercrewmate", (int) supercrewmate);
xml::update_tag(msgs, "scmprogress", scmprogress);
xml::update_tag(msgs, "scmmoveme", (int) scmmoveme);
xml::update_tag(msgs, "frames", frames);

View File

@ -305,7 +305,7 @@ public:
int swnrecord, swnbestrank, swnrank, swnmessage;
//SuperCrewMate Stuff
bool supercrewmate, scmhurt, scmmoveme;
bool supercrewmate, scmhurt;
int scmprogress;
//Accessibility Options

View File

@ -1544,15 +1544,7 @@ void gamelogic(void)
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved), 2);
break;
case 3:
if (game.scmmoveme)
{
obj.createentity(obj.entities[obj.getplayer()].xp, 185, 24, graphics.crewcolour(game.lastsaved), 2);
game.scmmoveme = false;
}
else
{
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved), 2);
}
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved), 2);
break;
case 4:
obj.createentity(10, 185, 24, graphics.crewcolour(game.lastsaved), 2);
@ -1586,17 +1578,6 @@ void gamelogic(void)
break;
}
}
if (game.scmmoveme)
{
int scm = obj.getscm();
int player = obj.getplayer();
if (INBOUNDS_VEC(scm, obj.entities) && INBOUNDS_VEC(player, obj.entities))
{
obj.entities[scm].xp = obj.entities[player].xp;
}
game.scmmoveme = false;
}
break;
}
}

View File

@ -888,14 +888,6 @@ void mapclass::resetplayer(const bool player_died)
{
game.scmprogress = game.roomx - 40;
}
if (game.scmprogress != 0)
{
game.scmmoveme = true;
}
else
{
game.scmmoveme = false;
}
}
}

View File

@ -3155,7 +3155,6 @@ void scriptclass::hardreset(void)
game.supercrewmate = false;
game.scmhurt = false;
game.scmprogress = 0;
game.scmmoveme = false;
game.swncolstate = 0;
game.swncoldelay = 0;
game.swnrank = 0;