mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-02-04 08:06:16 +03:00
Guard all cases obj.getcompanion() is used unchecked
And this the function with the least amount of cases where its sentinel value is used unchecked. Thankfully. obj.getplayer() was a bit of a slug to get through.
This commit is contained in:
@@ -1533,8 +1533,11 @@ void Game::updatestate()
|
|||||||
|
|
||||||
companion = 6;
|
companion = 6;
|
||||||
i = obj.getcompanion();
|
i = obj.getcompanion();
|
||||||
|
if (i > -1)
|
||||||
|
{
|
||||||
obj.entities[i].tile = 0;
|
obj.entities[i].tile = 0;
|
||||||
obj.entities[i].state = 1;
|
obj.entities[i].state = 1;
|
||||||
|
}
|
||||||
|
|
||||||
advancetext = true;
|
advancetext = true;
|
||||||
hascontrol = false;
|
hascontrol = false;
|
||||||
@@ -1559,9 +1562,12 @@ void Game::updatestate()
|
|||||||
music.playef(2);
|
music.playef(2);
|
||||||
graphics.textboxactive();
|
graphics.textboxactive();
|
||||||
i = obj.getcompanion();
|
i = obj.getcompanion();
|
||||||
|
if (i > -1)
|
||||||
|
{
|
||||||
obj.entities[i].tile = 54;
|
obj.entities[i].tile = 54;
|
||||||
obj.entities[i].state = 0;
|
obj.entities[i].state = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 108:
|
case 108:
|
||||||
graphics.createtextbox("Don't worry! I have a", 125, 152, 164, 164, 255);
|
graphics.createtextbox("Don't worry! I have a", 125, 152, 164, 164, 255);
|
||||||
@@ -1574,8 +1580,11 @@ void Game::updatestate()
|
|||||||
{
|
{
|
||||||
|
|
||||||
i = obj.getcompanion();
|
i = obj.getcompanion();
|
||||||
|
if (i > -1)
|
||||||
|
{
|
||||||
obj.entities[i].tile = 0;
|
obj.entities[i].tile = 0;
|
||||||
obj.entities[i].state = 1;
|
obj.entities[i].state = 1;
|
||||||
|
}
|
||||||
graphics.createtextbox("Follow me!", 185, 154, 164, 164, 255);
|
graphics.createtextbox("Follow me!", 185, 154, 164, 164, 255);
|
||||||
state++;
|
state++;
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
@@ -1649,8 +1658,11 @@ void Game::updatestate()
|
|||||||
case 122:
|
case 122:
|
||||||
companion = 7;
|
companion = 7;
|
||||||
i = obj.getcompanion();
|
i = obj.getcompanion();
|
||||||
|
if (i > -1)
|
||||||
|
{
|
||||||
obj.entities[i].tile = 6;
|
obj.entities[i].tile = 6;
|
||||||
obj.entities[i].state = 1;
|
obj.entities[i].state = 1;
|
||||||
|
}
|
||||||
|
|
||||||
advancetext = true;
|
advancetext = true;
|
||||||
hascontrol = false;
|
hascontrol = false;
|
||||||
@@ -1665,7 +1677,7 @@ void Game::updatestate()
|
|||||||
state++;
|
state++;
|
||||||
music.playef(2);
|
music.playef(2);
|
||||||
graphics.textboxactive();
|
graphics.textboxactive();
|
||||||
i = obj.getcompanion(); //obj.entities[i].tile = 66; obj.entities[i].state = 0;
|
i = obj.getcompanion(); if (i > -1) { /*obj.entities[i].tile = 66; obj.entities[i].state = 0;*/ }
|
||||||
break;
|
break;
|
||||||
case 126:
|
case 126:
|
||||||
graphics.createtextbox("I can help with that!", 125, 152-40, 164, 164, 255);
|
graphics.createtextbox("I can help with that!", 125, 152-40, 164, 164, 255);
|
||||||
@@ -1687,8 +1699,11 @@ void Game::updatestate()
|
|||||||
music.playef(14);
|
music.playef(14);
|
||||||
graphics.textboxactive();
|
graphics.textboxactive();
|
||||||
i = obj.getcompanion();
|
i = obj.getcompanion();
|
||||||
|
if (i > -1)
|
||||||
|
{
|
||||||
obj.entities[i].tile = 6;
|
obj.entities[i].tile = 6;
|
||||||
obj.entities[i].state = 1;
|
obj.entities[i].state = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 132:
|
case 132:
|
||||||
graphics.textboxremove();
|
graphics.textboxremove();
|
||||||
|
|||||||
@@ -1226,8 +1226,11 @@ void gamelogic()
|
|||||||
case 6:
|
case 6:
|
||||||
obj.createentity(obj.entities[i].xp, 121.0f, 15.0f,1); //Y=121, the floor in that particular place!
|
obj.createentity(obj.entities[i].xp, 121.0f, 15.0f,1); //Y=121, the floor in that particular place!
|
||||||
j = obj.getcompanion();
|
j = obj.getcompanion();
|
||||||
|
if (j > -1)
|
||||||
|
{
|
||||||
obj.entities[j].vx = obj.entities[i].vx;
|
obj.entities[j].vx = obj.entities[i].vx;
|
||||||
obj.entities[j].dir = obj.entities[i].dir;
|
obj.entities[j].dir = obj.entities[i].dir;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (game.roomy <= 105) //don't jump after him!
|
if (game.roomy <= 105) //don't jump after him!
|
||||||
@@ -1241,9 +1244,12 @@ void gamelogic()
|
|||||||
obj.createentity(obj.entities[i].xp, 86.0f, 16.0f, 1); //Y=86, the ROOF in that particular place!
|
obj.createentity(obj.entities[i].xp, 86.0f, 16.0f, 1); //Y=86, the ROOF in that particular place!
|
||||||
}
|
}
|
||||||
j = obj.getcompanion();
|
j = obj.getcompanion();
|
||||||
|
if (j > -1)
|
||||||
|
{
|
||||||
obj.entities[j].vx = obj.entities[i].vx;
|
obj.entities[j].vx = obj.entities[i].vx;
|
||||||
obj.entities[j].dir = obj.entities[i].dir;
|
obj.entities[j].dir = obj.entities[i].dir;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
if (game.roomy >= 104) //don't jump after him!
|
if (game.roomy >= 104) //don't jump after him!
|
||||||
@@ -1252,17 +1258,23 @@ void gamelogic()
|
|||||||
{
|
{
|
||||||
obj.createentity(310, 177, 17, 1);
|
obj.createentity(310, 177, 17, 1);
|
||||||
j = obj.getcompanion();
|
j = obj.getcompanion();
|
||||||
|
if (j > -1)
|
||||||
|
{
|
||||||
obj.entities[j].vx = obj.entities[i].vx;
|
obj.entities[j].vx = obj.entities[i].vx;
|
||||||
obj.entities[j].dir = obj.entities[i].dir;
|
obj.entities[j].dir = obj.entities[i].dir;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
obj.createentity(obj.entities[i].xp, 177.0f, 17.0f, 1);
|
obj.createentity(obj.entities[i].xp, 177.0f, 17.0f, 1);
|
||||||
j = obj.getcompanion();
|
j = obj.getcompanion();
|
||||||
|
if (j > -1)
|
||||||
|
{
|
||||||
obj.entities[j].vx = obj.entities[i].vx;
|
obj.entities[j].vx = obj.entities[i].vx;
|
||||||
obj.entities[j].dir = obj.entities[i].dir;
|
obj.entities[j].dir = obj.entities[i].dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
if (!map.towermode) //don't go back into the tower!
|
if (!map.towermode) //don't go back into the tower!
|
||||||
@@ -1276,9 +1288,12 @@ void gamelogic()
|
|||||||
obj.createentity(obj.entities[i].xp, 185.0f, 18.0f, 15, 0, 1);
|
obj.createentity(obj.entities[i].xp, 185.0f, 18.0f, 15, 0, 1);
|
||||||
}
|
}
|
||||||
j = obj.getcompanion();
|
j = obj.getcompanion();
|
||||||
|
if (j > -1)
|
||||||
|
{
|
||||||
obj.entities[j].vx = obj.entities[i].vx;
|
obj.entities[j].vx = obj.entities[i].vx;
|
||||||
obj.entities[j].dir = obj.entities[i].dir;
|
obj.entities[j].dir = obj.entities[i].dir;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
//intermission 2, choose colour based on lastsaved
|
//intermission 2, choose colour based on lastsaved
|
||||||
@@ -1288,28 +1303,37 @@ void gamelogic()
|
|||||||
{
|
{
|
||||||
obj.createentity(225.0f, 169.0f, 18, graphics.crewcolour(game.lastsaved), 0, 10);
|
obj.createentity(225.0f, 169.0f, 18, graphics.crewcolour(game.lastsaved), 0, 10);
|
||||||
j = obj.getcompanion();
|
j = obj.getcompanion();
|
||||||
|
if (j > -1)
|
||||||
|
{
|
||||||
obj.entities[j].vx = obj.entities[i].vx;
|
obj.entities[j].vx = obj.entities[i].vx;
|
||||||
obj.entities[j].dir = obj.entities[i].dir;
|
obj.entities[j].dir = obj.entities[i].dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (game.roomy >= 52)
|
else if (game.roomy >= 52)
|
||||||
{
|
{
|
||||||
if (obj.flags[59])
|
if (obj.flags[59])
|
||||||
{
|
{
|
||||||
obj.createentity(160.0f, 177.0f, 18, graphics.crewcolour(game.lastsaved), 0, 18, 1);
|
obj.createentity(160.0f, 177.0f, 18, graphics.crewcolour(game.lastsaved), 0, 18, 1);
|
||||||
j = obj.getcompanion();
|
j = obj.getcompanion();
|
||||||
|
if (j > -1)
|
||||||
|
{
|
||||||
obj.entities[j].vx = obj.entities[i].vx;
|
obj.entities[j].vx = obj.entities[i].vx;
|
||||||
obj.entities[j].dir = obj.entities[i].dir;
|
obj.entities[j].dir = obj.entities[i].dir;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
obj.flags[59] = true;
|
obj.flags[59] = true;
|
||||||
obj.createentity(obj.entities[i].xp, -20.0f, 18.0f, graphics.crewcolour(game.lastsaved), 0, 10, 0);
|
obj.createentity(obj.entities[i].xp, -20.0f, 18.0f, graphics.crewcolour(game.lastsaved), 0, 10, 0);
|
||||||
j = obj.getcompanion();
|
j = obj.getcompanion();
|
||||||
|
if (j > -1)
|
||||||
|
{
|
||||||
obj.entities[j].vx = obj.entities[i].vx;
|
obj.entities[j].vx = obj.entities[i].vx;
|
||||||
obj.entities[j].dir = obj.entities[i].dir;
|
obj.entities[j].dir = obj.entities[i].dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
//Intermission 1: We're using the SuperCrewMate instead!
|
//Intermission 1: We're using the SuperCrewMate instead!
|
||||||
|
|||||||
Reference in New Issue
Block a user