mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 10:29:45 +01: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:
parent
beab344267
commit
fdce412680
2 changed files with 66 additions and 27 deletions
|
@ -1533,8 +1533,11 @@ void Game::updatestate()
|
|||
|
||||
companion = 6;
|
||||
i = obj.getcompanion();
|
||||
if (i > -1)
|
||||
{
|
||||
obj.entities[i].tile = 0;
|
||||
obj.entities[i].state = 1;
|
||||
}
|
||||
|
||||
advancetext = true;
|
||||
hascontrol = false;
|
||||
|
@ -1559,9 +1562,12 @@ void Game::updatestate()
|
|||
music.playef(2);
|
||||
graphics.textboxactive();
|
||||
i = obj.getcompanion();
|
||||
if (i > -1)
|
||||
{
|
||||
obj.entities[i].tile = 54;
|
||||
obj.entities[i].state = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 108:
|
||||
graphics.createtextbox("Don't worry! I have a", 125, 152, 164, 164, 255);
|
||||
|
@ -1574,8 +1580,11 @@ void Game::updatestate()
|
|||
{
|
||||
|
||||
i = obj.getcompanion();
|
||||
if (i > -1)
|
||||
{
|
||||
obj.entities[i].tile = 0;
|
||||
obj.entities[i].state = 1;
|
||||
}
|
||||
graphics.createtextbox("Follow me!", 185, 154, 164, 164, 255);
|
||||
state++;
|
||||
music.playef(11);
|
||||
|
@ -1649,8 +1658,11 @@ void Game::updatestate()
|
|||
case 122:
|
||||
companion = 7;
|
||||
i = obj.getcompanion();
|
||||
if (i > -1)
|
||||
{
|
||||
obj.entities[i].tile = 6;
|
||||
obj.entities[i].state = 1;
|
||||
}
|
||||
|
||||
advancetext = true;
|
||||
hascontrol = false;
|
||||
|
@ -1665,7 +1677,7 @@ void Game::updatestate()
|
|||
state++;
|
||||
music.playef(2);
|
||||
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;
|
||||
case 126:
|
||||
graphics.createtextbox("I can help with that!", 125, 152-40, 164, 164, 255);
|
||||
|
@ -1687,8 +1699,11 @@ void Game::updatestate()
|
|||
music.playef(14);
|
||||
graphics.textboxactive();
|
||||
i = obj.getcompanion();
|
||||
if (i > -1)
|
||||
{
|
||||
obj.entities[i].tile = 6;
|
||||
obj.entities[i].state = 1;
|
||||
}
|
||||
break;
|
||||
case 132:
|
||||
graphics.textboxremove();
|
||||
|
|
|
@ -1226,8 +1226,11 @@ void gamelogic()
|
|||
case 6:
|
||||
obj.createentity(obj.entities[i].xp, 121.0f, 15.0f,1); //Y=121, the floor in that particular place!
|
||||
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!
|
||||
|
@ -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!
|
||||
}
|
||||
j = obj.getcompanion();
|
||||
if (j > -1)
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (game.roomy >= 104) //don't jump after him!
|
||||
|
@ -1252,17 +1258,23 @@ void gamelogic()
|
|||
{
|
||||
obj.createentity(310, 177, 17, 1);
|
||||
j = obj.getcompanion();
|
||||
if (j > -1)
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 177.0f, 17.0f, 1);
|
||||
j = obj.getcompanion();
|
||||
if (j > -1)
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
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);
|
||||
}
|
||||
j = obj.getcompanion();
|
||||
if (j > -1)
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
//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);
|
||||
j = obj.getcompanion();
|
||||
if (j > -1)
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (game.roomy >= 52)
|
||||
{
|
||||
if (obj.flags[59])
|
||||
{
|
||||
obj.createentity(160.0f, 177.0f, 18, graphics.crewcolour(game.lastsaved), 0, 18, 1);
|
||||
j = obj.getcompanion();
|
||||
if (j > -1)
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.flags[59] = true;
|
||||
obj.createentity(obj.entities[i].xp, -20.0f, 18.0f, graphics.crewcolour(game.lastsaved), 0, 10, 0);
|
||||
j = obj.getcompanion();
|
||||
if (j > -1)
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
//Intermission 1: We're using the SuperCrewMate instead!
|
||||
|
|
Loading…
Reference in a new issue