1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-28 19:23:53 +00:00

Remove pointer from EntitySaveData

Can properly address entities by ID now that they are really unique.
This commit is contained in:
fgenesis 2023-05-09 05:28:16 +02:00
parent eec6027ccc
commit e3eebf63e9
2 changed files with 7 additions and 6 deletions

View file

@ -943,10 +943,10 @@ Entity* Game::getEntityByID(int id) const
EntitySaveData *Game::getEntitySaveDataForEntity(Entity *e)
{
const int id = e->getID();
for (size_t i = 0; i < entitySaveData.size(); i++)
{
if (entitySaveData[i].e == e)
if (entitySaveData[i].id == id)
{
return &entitySaveData[i];
}
@ -1010,7 +1010,9 @@ Entity* Game::createEntityOnMap(const EntitySaveData& sav)
e->rotation.z = sav.rot;
int idx = getIdxForEntityType(type);
entitySaveData.push_back(EntitySaveData(sav.id, sav.x, sav.y, sav.rot, sav.idx, type, e));
EntitySaveData copy = sav;
copy.name = type;
entitySaveData.push_back(copy);
establishEntity(e, sav.id, pos);

View file

@ -129,11 +129,10 @@ typedef std::vector<Element*> ElementUpdateList;
struct EntitySaveData
{
public:
EntitySaveData() : id(0), x(0), y(0), rot(0), idx(0), e(0) {}
EntitySaveData(int id, int x, int y, int rot, int idx, const std::string &name, Entity *e) : name(name), id(id), x(x), y(y), rot(rot), idx(idx), e(e) {}
EntitySaveData() : id(0), x(0), y(0), rot(0), idx(0) {}
EntitySaveData(int id, int x, int y, int rot, int idx, const std::string &name) : name(name), id(id), x(x), y(y), rot(rot), idx(idx) {}
std::string name;
int id, x, y, rot, idx;
Entity *e;
};
class Game : public StateObject