mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 18:04:09 +03:00
Refactor entities and linecrosskludge to not use the 'active' system
This removes the variables obj.nentity and obj.nlinecrosskludge, as well as removing the 'active' attribute from the entity class object. Now every entity you access is guaranteed to be real and you don't have to check the 'active' variable. The biggest part of this is changing createentity() to modify a newly-created entity object and push it back instead of already modifying an indice in obj.entities. As well, removing an entity now uses the new obj.removeentity() function and removeentity_iter() macro.
This commit is contained in:
@@ -347,7 +347,7 @@ void towerlogic()
|
||||
|
||||
if(!game.completestop)
|
||||
{
|
||||
for (int i = obj.nentity - 1; i >= 0; i--)
|
||||
for (int i = obj.entities.size() - 1; i >= 0; i--)
|
||||
{
|
||||
obj.updateentities(i); // Behavioral logic
|
||||
obj.updateentitylogic(i); // Basic Physics
|
||||
@@ -411,7 +411,7 @@ void towerlogic()
|
||||
//Always wrap except for the very top and very bottom of the tower
|
||||
if(map.ypos>=500 && map.ypos <=5000)
|
||||
{
|
||||
for (int i = 0; i < obj.nentity; i++)
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
if (obj.entities[i].xp <= -10)
|
||||
{
|
||||
@@ -557,7 +557,7 @@ void gamelogic()
|
||||
|
||||
if (game.deathseq != -1)
|
||||
{
|
||||
for (int i = 0; i < obj.nentity; i++)
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
if (game.roomx == 111 && game.roomy == 107 && !map.custommode)
|
||||
{
|
||||
@@ -848,7 +848,7 @@ void gamelogic()
|
||||
obj.entities[obj.getlineat(148 + 32)].xp += 24;
|
||||
if (obj.entities[obj.getlineat(148 + 32)].xp > 320)
|
||||
{
|
||||
obj.entities[obj.getlineat(148 + 32)].active = false;
|
||||
obj.removeentity(obj.getlineat(148 + 32));
|
||||
game.swnmode = false;
|
||||
game.swngame = 6;
|
||||
}
|
||||
@@ -937,7 +937,7 @@ void gamelogic()
|
||||
{
|
||||
if(obj.vertplatforms)
|
||||
{
|
||||
for (int i = obj.nentity - 1; i >= 0; i--)
|
||||
for (int i = obj.entities.size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (obj.entities[i].isplatform)
|
||||
{
|
||||
@@ -966,7 +966,7 @@ void gamelogic()
|
||||
|
||||
if(obj.horplatforms)
|
||||
{
|
||||
for (int ie = obj.nentity - 1; ie >= 0; ie--)
|
||||
for (int ie = obj.entities.size() - 1; ie >= 0; ie--)
|
||||
{
|
||||
if (obj.entities[ie].isplatform)
|
||||
{
|
||||
@@ -1001,7 +1001,7 @@ void gamelogic()
|
||||
}
|
||||
}
|
||||
|
||||
for (int ie = obj.nentity - 1; ie >= 0; ie--)
|
||||
for (int ie = obj.entities.size() - 1; ie >= 0; ie--)
|
||||
{
|
||||
if (!obj.entities[ie].isplatform)
|
||||
{
|
||||
@@ -1040,7 +1040,7 @@ void gamelogic()
|
||||
//Finally: Are we changing room?
|
||||
if (map.warpx && map.warpy)
|
||||
{
|
||||
for (int i = 0; i < obj.nentity; i++)
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
if (obj.entities[i].size < 12) //Don't wrap SWN enemies
|
||||
@@ -1060,7 +1060,7 @@ void gamelogic()
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < obj.nentity; i++)
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
@@ -1083,7 +1083,7 @@ void gamelogic()
|
||||
}
|
||||
else if (map.warpx)
|
||||
{
|
||||
for (int i = 0; i < obj.nentity; i++)
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
if (obj.entities[i].size < 12) //Don't wrap SWN enemies
|
||||
@@ -1135,7 +1135,7 @@ void gamelogic()
|
||||
}
|
||||
else if (map.warpy)
|
||||
{
|
||||
for (int i = 0; i < obj.nentity; i++)
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
if (obj.entities[i].yp <= -12)
|
||||
@@ -1152,7 +1152,7 @@ void gamelogic()
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < obj.nentity; i++)
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
|
||||
Reference in New Issue
Block a user