1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Reduce scope of 'j' in screen transition companion logic

Reducing the scope of the variable makes analysis easier - for example,
we can now see it is always initialized before being used.
This commit is contained in:
Misa 2020-09-08 14:59:23 -07:00 committed by Ethan Lee
parent a098448e89
commit b925352864

View file

@ -1402,7 +1402,6 @@ void gamelogic()
}
}
int j;
if (game.roomchange)
{
//We've changed room? Let's bring our companion along!
@ -1414,14 +1413,16 @@ void gamelogic()
switch(game.companion)
{
case 6:
{
obj.createentity(obj.entities[i].xp, 121.0f, 15.0f,1); //Y=121, the floor in that particular place!
j = obj.getcompanion();
int j = obj.getcompanion();
if (j > -1)
{
obj.entities[j].vx = obj.entities[i].vx;
obj.entities[j].dir = obj.entities[i].dir;
}
break;
}
case 7:
if (game.roomy <= 105) //don't jump after him!
{
@ -1433,7 +1434,7 @@ void gamelogic()
{
obj.createentity(obj.entities[i].xp, 86.0f, 16.0f, 1); //Y=86, the ROOF in that particular place!
}
j = obj.getcompanion();
int j = obj.getcompanion();
if (j > -1)
{
obj.entities[j].vx = obj.entities[i].vx;
@ -1447,7 +1448,7 @@ void gamelogic()
if (game.roomx == 102)
{
obj.createentity(310, 177, 17, 1);
j = obj.getcompanion();
int j = obj.getcompanion();
if (j > -1)
{
obj.entities[j].vx = obj.entities[i].vx;
@ -1457,7 +1458,7 @@ void gamelogic()
else
{
obj.createentity(obj.entities[i].xp, 177.0f, 17.0f, 1);
j = obj.getcompanion();
int j = obj.getcompanion();
if (j > -1)
{
obj.entities[j].vx = obj.entities[i].vx;
@ -1477,7 +1478,7 @@ void gamelogic()
{
obj.createentity(obj.entities[i].xp, 185.0f, 18.0f, 15, 0, 1);
}
j = obj.getcompanion();
int j = obj.getcompanion();
if (j > -1)
{
obj.entities[j].vx = obj.entities[i].vx;
@ -1492,7 +1493,7 @@ void gamelogic()
if (!obj.flags[59])
{
obj.createentity(225.0f, 169.0f, 18, graphics.crewcolour(game.lastsaved), 0, 10);
j = obj.getcompanion();
int j = obj.getcompanion();
if (j > -1)
{
obj.entities[j].vx = obj.entities[i].vx;
@ -1505,7 +1506,7 @@ void gamelogic()
if (obj.flags[59])
{
obj.createentity(160.0f, 177.0f, 18, graphics.crewcolour(game.lastsaved), 0, 18, 1);
j = obj.getcompanion();
int j = obj.getcompanion();
if (j > -1)
{
obj.entities[j].vx = obj.entities[i].vx;
@ -1516,7 +1517,7 @@ void gamelogic()
{
obj.flags[59] = true;
obj.createentity(obj.entities[i].xp, -20.0f, 18.0f, graphics.crewcolour(game.lastsaved), 0, 10, 0);
j = obj.getcompanion();
int j = obj.getcompanion();
if (j > -1)
{
obj.entities[j].vx = obj.entities[i].vx;