1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-29 03:33:48 +00:00

oh come on, another tiny simplification now that IDs are really unique

This commit is contained in:
fgenesis 2023-05-09 05:39:15 +02:00
parent e3eebf63e9
commit 924bc058b4

View file

@ -758,20 +758,16 @@ bool Game::removeEntityAtCursor()
bool Game::removeEntity(Entity *selected)
{
const int id = selected->getID();
selected->setState(Entity::STATE_DEAD);
selected->safeKill();
for (size_t i = 0; i < entitySaveData.size(); i++)
{
if (entitySaveData[i].x == int(selected->startPos.x) && entitySaveData[i].y == int(selected->startPos.y))
if (entitySaveData[i].id == id)
{
std::vector<EntitySaveData> copy = entitySaveData;
entitySaveData.clear();
for (size_t j = 0; j < copy.size(); j++)
{
if (j != i)
entitySaveData.push_back(copy[j]);
}
entitySaveData.erase(entitySaveData.begin() + i);
return true;
}
}