Animatedsprite ya no permite indices fuera de rango

This commit is contained in:
2022-09-25 13:00:39 +02:00
parent 66840ebf11
commit 8a4d2a541d
18 changed files with 79 additions and 71 deletions

View File

@@ -865,19 +865,19 @@ void Room::setBottomSurfaces()
line.x1 = (tile[i] % mapWidth) * tileSize;
line.y = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
lastOne = i;
++i;
i++;
while (tile[i] == tile[i - 1] + 1)
{
lastOne = i;
++i;
i++;
}
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
bottomSurfaces.push_back(line);
if (tile[i] == -1)
{ // Si el siguiente elemento es un separador, hay que saltarlo
++i;
i++;
}
}
}
@@ -912,19 +912,19 @@ void Room::setTopSurfaces()
line.x1 = (tile[i] % mapWidth) * tileSize;
line.y = (tile[i] / mapWidth) * tileSize;
lastOne = i;
++i;
i++;
while (tile[i] == tile[i - 1] + 1)
{
lastOne = i;
++i;
i++;
}
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
topSurfaces.push_back(line);
if (tile[i] == -1)
{ // Si el siguiente elemento es un separador, hay que saltarlo
++i;
i++;
}
}
}
@@ -959,11 +959,11 @@ void Room::setLeftSurfaces()
line.y1 = ((tile[i] / mapWidth) * tileSize);
while (tile[i] + mapWidth == tile[i + 1])
{
++i;
i++;
}
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
leftSurfaces.push_back(line);
++i;
i++;
}
}
@@ -997,11 +997,11 @@ void Room::setRightSurfaces()
line.y1 = ((tile[i] / mapWidth) * tileSize);
while (tile[i] + mapWidth == tile[i + 1])
{
++i;
i++;
}
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
rightSurfaces.push_back(line);
++i;
i++;
}
}
@@ -1037,7 +1037,7 @@ void Room::setLeftSlopes()
lastOneFound = lookingFor;
lookingFor += mapWidth + 1;
found.erase(found.begin() + i);
--i;
i--;
}
}
line.x2 = ((lastOneFound % mapWidth) * tileSize) + tileSize - 1;
@@ -1078,7 +1078,7 @@ void Room::setRightSlopes()
lastOneFound = lookingFor;
lookingFor += mapWidth - 1;
found.erase(found.begin() + i);
--i;
i--;
}
}
line.x2 = (lastOneFound % mapWidth) * tileSize;