diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index 39e9c55..5d547e9 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -220,7 +220,6 @@ Entity::Entity() //energyChargeTarget = energyShotTarget = true; deathSound = "GenericDeath"; entityID = 0; - //assignUniqueID(); hair = 0; maxSpeedLerp = 1; fillGridFromQuad = false; @@ -1141,17 +1140,6 @@ void Entity::frozenUpdate(float dt) void Entity::update(float dt) { - /* - if (position.isnan()) - position = backupPos; - if (vel.isnan()) - vel = backupVel; - */ - /* - if (entityID == 0) - assignUniqueID(); - */ - Vector backupPos = position; Vector backupVel = vel; @@ -2956,9 +2944,10 @@ void Entity::fillGrid() } } -void Entity::assignUniqueID() +void Entity::assignUniqueID(bool temporary) { - int id = 1; + const int inc = temporary ? -1 : 1; + int id = inc; while (1) { bool isFree = true; @@ -2978,7 +2967,7 @@ void Entity::assignUniqueID() { break; } - id++; + id += inc; } entityID = id; } @@ -2996,7 +2985,7 @@ void Entity::setID(int id) std::ostringstream os; os << "ID conflict between " << name << " and " << e->name; debugLog(os.str()); - e->assignUniqueID(); + e->assignUniqueID(e->getID() < 0); } } } diff --git a/Aquaria/Entity.h b/Aquaria/Entity.h index 7532125..0aff3ed 100644 --- a/Aquaria/Entity.h +++ b/Aquaria/Entity.h @@ -395,7 +395,7 @@ public: InterpolatedVector maxSpeedLerp; Hair *hair; - void assignUniqueID(); + void assignUniqueID(bool temporary); int entityID; int getMaxSpeed(); std::string deathSound; diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index b6847f4..1e2ba50 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -2659,7 +2659,7 @@ Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool } else { - e->assignUniqueID(); + e->assignUniqueID(!createSaveData); // when entity is placed on map, give positive ID; otherwise, if script-spawned, give negative ID } } @@ -2718,19 +2718,6 @@ void Game::initEntities() } } -void Game::assignEntitiesUniqueIDs() -{ - FOR_ENTITIES(i) - { - Entity *e = *i; - if (e && e->entityID == 0) - { - e->assignUniqueID(); - } - } - -} - EntitySaveData *Game::getEntitySaveDataForEntity(Entity *e, Vector pos) { diff --git a/Aquaria/Game.h b/Aquaria/Game.h index cb3a999..f43b37e 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -465,7 +465,6 @@ public: bool multiSelecting; Vector multiSelectPoint; std::vector selectedElements; - void fixEntityIDs(); Vector groupCenter; Vector getSelectedElementsCenter(); @@ -1088,7 +1087,6 @@ protected: Quad *options; Quad *image; - void assignEntitiesUniqueIDs(); void initEntities(); diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index ca6aea6..473edb2 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -1864,15 +1864,6 @@ void SceneEditor::skinLevel(pngRawInfo *png, int minX, int minY, int maxX, int m } } -void SceneEditor::fixEntityIDs() -{ - FOR_ENTITIES(i) - { - Entity *e = *i; - e->assignUniqueID(); - } -} - void SceneEditor::generateLevel() { //pngSetStandardOrientation(0);