mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-03 15:39:46 +01:00
Move linecrosskludge off of entityclass
This is a temporary vector that only gets used in mapclass::gotoroom(). It's always guaranteed to be cleared, so it's safe to move it off. I'm fine with using references here because, like, it's a C++ STL vector anyway - when we switch away from the STL (which is a precondition for moving to C), we'll be passing around raw pointers here instead, and won't be using references here anyway.
This commit is contained in:
parent
382b83a54d
commit
75ed9f9631
3 changed files with 12 additions and 14 deletions
|
@ -1148,7 +1148,7 @@ void entityclass::removetrigger( int t )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void entityclass::copylinecross( int t )
|
void entityclass::copylinecross(std::vector<entclass>& linecrosskludge, int t)
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_VEC(t, entities))
|
if (!INBOUNDS_VEC(t, entities))
|
||||||
{
|
{
|
||||||
|
@ -1159,7 +1159,7 @@ void entityclass::copylinecross( int t )
|
||||||
linecrosskludge.push_back(entities[t]);
|
linecrosskludge.push_back(entities[t]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void entityclass::revertlinecross( int t, int s )
|
void entityclass::revertlinecross(std::vector<entclass>& linecrosskludge, int t, int s)
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_VEC(t, entities) || !INBOUNDS_VEC(s, linecrosskludge))
|
if (!INBOUNDS_VEC(t, entities) || !INBOUNDS_VEC(s, linecrosskludge))
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,9 +66,9 @@ public:
|
||||||
|
|
||||||
void removetrigger(int t);
|
void removetrigger(int t);
|
||||||
|
|
||||||
void copylinecross(int t);
|
void copylinecross(std::vector<entclass>& linecrosskludge, int t);
|
||||||
|
|
||||||
void revertlinecross(int t, int s);
|
void revertlinecross(std::vector<entclass>& linecrosskludge, int t, int s);
|
||||||
|
|
||||||
bool gridmatch(int p1, int p2, int p3, int p4, int p11, int p21, int p31, int p41);
|
bool gridmatch(int p1, int p2, int p3, int p4, int p11, int p21, int p31, int p41);
|
||||||
|
|
||||||
|
@ -165,8 +165,6 @@ public:
|
||||||
|
|
||||||
std::vector<entclass> entities;
|
std::vector<entclass> entities;
|
||||||
|
|
||||||
std::vector<entclass> linecrosskludge;
|
|
||||||
|
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -904,6 +904,7 @@ void mapclass::warpto(int rx, int ry , int t, int tx, int ty)
|
||||||
void mapclass::gotoroom(int rx, int ry)
|
void mapclass::gotoroom(int rx, int ry)
|
||||||
{
|
{
|
||||||
int roomchangedir;
|
int roomchangedir;
|
||||||
|
std::vector<entclass> linecrosskludge;
|
||||||
|
|
||||||
//First, destroy the current room
|
//First, destroy the current room
|
||||||
obj.removeallblocks();
|
obj.removeallblocks();
|
||||||
|
@ -912,7 +913,6 @@ void mapclass::gotoroom(int rx, int ry)
|
||||||
game.oldreadytotele = 0;
|
game.oldreadytotele = 0;
|
||||||
|
|
||||||
//Ok, let's save the position of all lines on the screen
|
//Ok, let's save the position of all lines on the screen
|
||||||
obj.linecrosskludge.clear();
|
|
||||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||||
{
|
{
|
||||||
if (obj.entities[i].type == 9)
|
if (obj.entities[i].type == 9)
|
||||||
|
@ -921,7 +921,7 @@ void mapclass::gotoroom(int rx, int ry)
|
||||||
if (obj.entities[i].xp <= 0 || (obj.entities[i].xp + obj.entities[i].w) >= 312)
|
if (obj.entities[i].xp <= 0 || (obj.entities[i].xp + obj.entities[i].w) >= 312)
|
||||||
{
|
{
|
||||||
//it's on a screen edge
|
//it's on a screen edge
|
||||||
obj.copylinecross(i);
|
obj.copylinecross(linecrosskludge, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1069,24 +1069,24 @@ void mapclass::gotoroom(int rx, int ry)
|
||||||
if (obj.entities[i].xp <= 0 || obj.entities[i].xp + obj.entities[i].w >= 312)
|
if (obj.entities[i].xp <= 0 || obj.entities[i].xp + obj.entities[i].w >= 312)
|
||||||
{
|
{
|
||||||
//it's on a screen edge
|
//it's on a screen edge
|
||||||
for (size_t j = 0; j < obj.linecrosskludge.size(); j++)
|
for (size_t j = 0; j < linecrosskludge.size(); j++)
|
||||||
{
|
{
|
||||||
if (obj.entities[i].yp == obj.linecrosskludge[j].yp)
|
if (obj.entities[i].yp == linecrosskludge[j].yp)
|
||||||
{
|
{
|
||||||
//y's match, how about x's?
|
//y's match, how about x's?
|
||||||
//we're moving left:
|
//we're moving left:
|
||||||
if (roomchangedir == 0)
|
if (roomchangedir == 0)
|
||||||
{
|
{
|
||||||
if (obj.entities[i].xp + obj.entities[i].w >= 312 && obj.linecrosskludge[j].xp <= 0)
|
if (obj.entities[i].xp + obj.entities[i].w >= 312 && linecrosskludge[j].xp <= 0)
|
||||||
{
|
{
|
||||||
obj.revertlinecross(i, j);
|
obj.revertlinecross(linecrosskludge, i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (obj.entities[i].xp <= 0 && obj.linecrosskludge[j].xp + obj.linecrosskludge[j].w >= 312)
|
if (obj.entities[i].xp <= 0 && linecrosskludge[j].xp + linecrosskludge[j].w >= 312)
|
||||||
{
|
{
|
||||||
obj.revertlinecross(i, j);
|
obj.revertlinecross(linecrosskludge, i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue